@defai.digital/ax-cli 1.2.3 → 2.0.2
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/README.md +13 -0
- package/config/messages.yaml +0 -1
- package/config/prompts.yaml +1 -6
- package/dist/agent/context-manager.d.ts +9 -8
- package/dist/agent/context-manager.js +25 -15
- package/dist/agent/context-manager.js.map +1 -1
- package/dist/agent/{grok-agent.d.ts → llm-agent.d.ts} +48 -8
- package/dist/agent/{grok-agent.js → llm-agent.js} +265 -192
- package/dist/agent/llm-agent.js.map +1 -0
- package/dist/commands/mcp.js +1 -1
- package/dist/commands/mcp.js.map +1 -1
- package/dist/commands/setup.d.ts +5 -0
- package/dist/commands/setup.js +106 -0
- package/dist/commands/setup.js.map +1 -0
- package/dist/hooks/use-input-handler.d.ts +3 -3
- package/dist/hooks/use-input-handler.js +2 -2
- package/dist/hooks/use-input-handler.js.map +1 -1
- package/dist/index.js +15 -12
- package/dist/index.js.map +1 -1
- package/dist/{grok → llm}/client.d.ts +11 -11
- package/dist/{grok → llm}/client.js +6 -6
- package/dist/llm/client.js.map +1 -0
- package/dist/llm/tools.d.ts +8 -0
- package/dist/{grok → llm}/tools.js +2 -33
- package/dist/llm/tools.js.map +1 -0
- package/dist/{grok → llm}/types.d.ts +3 -3
- package/dist/llm/types.js.map +1 -0
- package/dist/schemas/api-schemas.d.ts +9 -9
- package/dist/schemas/api-schemas.js +13 -13
- package/dist/schemas/api-schemas.js.map +1 -1
- package/dist/tools/bash.js +25 -15
- package/dist/tools/bash.js.map +1 -1
- package/dist/tools/index.d.ts +0 -1
- package/dist/tools/index.js +0 -1
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/search.d.ts +2 -2
- package/dist/tools/search.js +21 -13
- package/dist/tools/search.js.map +1 -1
- package/dist/tools/text-editor.js +85 -59
- package/dist/tools/text-editor.js.map +1 -1
- package/dist/tools/todo-tool.js +14 -0
- package/dist/tools/todo-tool.js.map +1 -1
- package/dist/ui/app.js +1 -1
- package/dist/ui/app.js.map +1 -1
- package/dist/ui/components/api-key-input.d.ts +2 -2
- package/dist/ui/components/api-key-input.js +2 -2
- package/dist/ui/components/api-key-input.js.map +1 -1
- package/dist/ui/components/chat-history.d.ts +1 -1
- package/dist/ui/components/chat-interface.d.ts +2 -2
- package/dist/ui/components/chat-interface.js +1 -1
- package/dist/ui/components/chat-interface.js.map +1 -1
- package/dist/ui/components/mcp-status.js +1 -1
- package/dist/ui/components/mcp-status.js.map +1 -1
- package/dist/ui/components/model-selection.js +1 -1
- package/dist/ui/components/model-selection.js.map +1 -1
- package/dist/utils/confirmation-service.d.ts +8 -0
- package/dist/utils/confirmation-service.js +26 -0
- package/dist/utils/confirmation-service.js.map +1 -1
- package/dist/utils/path-validator.d.ts +36 -0
- package/dist/utils/path-validator.js +61 -0
- package/dist/utils/path-validator.js.map +1 -1
- package/dist/utils/prompt-builder.d.ts +0 -1
- package/dist/utils/prompt-builder.js +1 -1
- package/dist/utils/prompt-builder.js.map +1 -1
- package/dist/utils/settings-manager.js +1 -1
- package/dist/utils/settings-manager.js.map +1 -1
- package/dist/utils/tool-helpers.d.ts +25 -0
- package/dist/utils/tool-helpers.js +53 -0
- package/dist/utils/tool-helpers.js.map +1 -0
- package/package.json +13 -4
- package/automatosx.config.json +0 -333
- package/dist/agent/grok-agent.js.map +0 -1
- package/dist/grok/client.js.map +0 -1
- package/dist/grok/tools.d.ts +0 -8
- package/dist/grok/tools.js.map +0 -1
- package/dist/grok/types.js.map +0 -1
- package/dist/tools/morph-editor.d.ts +0 -36
- package/dist/tools/morph-editor.js +0 -308
- package/dist/tools/morph-editor.js.map +0 -1
- package/packages/schemas/dist/index.d.ts +0 -14
- package/packages/schemas/dist/index.d.ts.map +0 -1
- package/packages/schemas/dist/index.js +0 -19
- package/packages/schemas/dist/index.js.map +0 -1
- package/packages/schemas/dist/public/core/brand-types.d.ts +0 -308
- package/packages/schemas/dist/public/core/brand-types.d.ts.map +0 -1
- package/packages/schemas/dist/public/core/brand-types.js +0 -243
- package/packages/schemas/dist/public/core/brand-types.js.map +0 -1
- package/packages/schemas/dist/public/core/enums.d.ts +0 -227
- package/packages/schemas/dist/public/core/enums.d.ts.map +0 -1
- package/packages/schemas/dist/public/core/enums.js +0 -222
- package/packages/schemas/dist/public/core/enums.js.map +0 -1
- package/packages/schemas/dist/public/core/id-types.d.ts +0 -286
- package/packages/schemas/dist/public/core/id-types.d.ts.map +0 -1
- package/packages/schemas/dist/public/core/id-types.js +0 -136
- package/packages/schemas/dist/public/core/id-types.js.map +0 -1
- /package/dist/{grok → llm}/types.js +0 -0
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { getAllGrokTools, getMCPManager, initializeMCPServers, } from "../
|
|
1
|
+
import { LLMClient } from "../llm/client.js";
|
|
2
|
+
import { getAllGrokTools, getMCPManager, initializeMCPServers, } from "../llm/tools.js";
|
|
3
3
|
import { loadMCPConfig } from "../mcp/config.js";
|
|
4
|
-
import { TextEditorTool,
|
|
4
|
+
import { TextEditorTool, BashTool, TodoTool, SearchTool, } from "../tools/index.js";
|
|
5
5
|
import { EventEmitter } from "events";
|
|
6
6
|
import { createTokenCounter } from "../utils/token-counter.js";
|
|
7
7
|
import { loadCustomInstructions } from "../utils/custom-instructions.js";
|
|
8
8
|
import { getSettingsManager } from "../utils/settings-manager.js";
|
|
9
9
|
import { ContextManager } from "./context-manager.js";
|
|
10
10
|
import { buildSystemPrompt } from "../utils/prompt-builder.js";
|
|
11
|
-
export class
|
|
12
|
-
|
|
11
|
+
export class LLMAgent extends EventEmitter {
|
|
12
|
+
llmClient;
|
|
13
13
|
textEditor;
|
|
14
|
-
morphEditor;
|
|
15
14
|
bash;
|
|
16
15
|
todoTool;
|
|
17
16
|
search;
|
|
@@ -27,9 +26,8 @@ export class GrokAgent extends EventEmitter {
|
|
|
27
26
|
const savedModel = manager.getCurrentModel();
|
|
28
27
|
const modelToUse = model || savedModel || "grok-code-fast-1";
|
|
29
28
|
this.maxToolRounds = maxToolRounds || 400;
|
|
30
|
-
this.
|
|
29
|
+
this.llmClient = new LLMClient(apiKey, modelToUse, baseURL);
|
|
31
30
|
this.textEditor = new TextEditorTool();
|
|
32
|
-
this.morphEditor = process.env.MORPH_API_KEY ? new MorphEditorTool() : null;
|
|
33
31
|
this.bash = new BashTool();
|
|
34
32
|
this.todoTool = new TodoTool();
|
|
35
33
|
this.search = new SearchTool();
|
|
@@ -40,7 +38,6 @@ export class GrokAgent extends EventEmitter {
|
|
|
40
38
|
// Build system prompt from YAML configuration
|
|
41
39
|
const customInstructions = loadCustomInstructions();
|
|
42
40
|
const systemPrompt = buildSystemPrompt({
|
|
43
|
-
hasMorphEditor: !!this.morphEditor,
|
|
44
41
|
customInstructions: customInstructions || undefined,
|
|
45
42
|
});
|
|
46
43
|
// Initialize with system message
|
|
@@ -67,7 +64,7 @@ export class GrokAgent extends EventEmitter {
|
|
|
67
64
|
});
|
|
68
65
|
}
|
|
69
66
|
isGrokModel() {
|
|
70
|
-
const currentModel = this.
|
|
67
|
+
const currentModel = this.llmClient.getCurrentModel();
|
|
71
68
|
return currentModel.toLowerCase().includes("grok");
|
|
72
69
|
}
|
|
73
70
|
// Heuristic: enable web search only when likely needed
|
|
@@ -113,7 +110,7 @@ export class GrokAgent extends EventEmitter {
|
|
|
113
110
|
let toolRounds = 0;
|
|
114
111
|
try {
|
|
115
112
|
const tools = await getAllGrokTools();
|
|
116
|
-
let currentResponse = await this.
|
|
113
|
+
let currentResponse = await this.llmClient.chat(this.messages, tools, {
|
|
117
114
|
searchOptions: this.isGrokModel() && this.shouldUseSearchFor(message)
|
|
118
115
|
? { search_parameters: { mode: "auto" } }
|
|
119
116
|
: { search_parameters: { mode: "off" } }
|
|
@@ -122,7 +119,7 @@ export class GrokAgent extends EventEmitter {
|
|
|
122
119
|
while (toolRounds < maxToolRounds) {
|
|
123
120
|
const assistantMessage = currentResponse.choices[0]?.message;
|
|
124
121
|
if (!assistantMessage) {
|
|
125
|
-
throw new Error("No response from
|
|
122
|
+
throw new Error("No response from AI");
|
|
126
123
|
}
|
|
127
124
|
// Handle tool calls
|
|
128
125
|
if (assistantMessage.tool_calls &&
|
|
@@ -186,7 +183,7 @@ export class GrokAgent extends EventEmitter {
|
|
|
186
183
|
});
|
|
187
184
|
}
|
|
188
185
|
// Get next response - this might contain more tool calls
|
|
189
|
-
currentResponse = await this.
|
|
186
|
+
currentResponse = await this.llmClient.chat(this.messages, tools, {
|
|
190
187
|
searchOptions: this.isGrokModel() && this.shouldUseSearchFor(message)
|
|
191
188
|
? { search_parameters: { mode: "auto" } }
|
|
192
189
|
: { search_parameters: { mode: "off" } }
|
|
@@ -249,6 +246,9 @@ export class GrokAgent extends EventEmitter {
|
|
|
249
246
|
else if (Array.isArray(acc[key]) && Array.isArray(value)) {
|
|
250
247
|
const accArray = acc[key];
|
|
251
248
|
for (let i = 0; i < value.length; i++) {
|
|
249
|
+
// Validate that value[i] exists before processing
|
|
250
|
+
if (value[i] === undefined || value[i] === null)
|
|
251
|
+
continue;
|
|
252
252
|
if (!accArray[i])
|
|
253
253
|
accArray[i] = {};
|
|
254
254
|
accArray[i] = reduce(accArray[i], value[i]);
|
|
@@ -266,9 +266,11 @@ export class GrokAgent extends EventEmitter {
|
|
|
266
266
|
}
|
|
267
267
|
return reduce(previous, item.choices[0].delta);
|
|
268
268
|
}
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
269
|
+
/**
|
|
270
|
+
* Prepare user message and apply context management
|
|
271
|
+
* Returns the calculated input tokens
|
|
272
|
+
*/
|
|
273
|
+
prepareUserMessageForStreaming(message) {
|
|
272
274
|
// Add user message to conversation
|
|
273
275
|
const userEntry = {
|
|
274
276
|
type: "user",
|
|
@@ -282,12 +284,12 @@ export class GrokAgent extends EventEmitter {
|
|
|
282
284
|
this.messages = this.contextManager.pruneMessages(this.messages, this.tokenCounter);
|
|
283
285
|
}
|
|
284
286
|
// Calculate input tokens
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
287
|
+
return this.tokenCounter.countMessageTokens(this.messages);
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Yield context warnings if needed
|
|
291
|
+
*/
|
|
292
|
+
async *yieldContextWarnings() {
|
|
291
293
|
const stats = this.contextManager.getStats(this.messages, this.tokenCounter);
|
|
292
294
|
if (stats.shouldPrune || stats.isNearLimit) {
|
|
293
295
|
const warning = this.contextManager.createWarningMessage(stats);
|
|
@@ -296,173 +298,231 @@ export class GrokAgent extends EventEmitter {
|
|
|
296
298
|
content: `\n${warning}\n\n`,
|
|
297
299
|
};
|
|
298
300
|
}
|
|
299
|
-
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Check if operation was cancelled
|
|
304
|
+
*/
|
|
305
|
+
isCancelled() {
|
|
306
|
+
return this.abortController?.signal.aborted ?? false;
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Yield cancellation message
|
|
310
|
+
*/
|
|
311
|
+
async *yieldCancellation() {
|
|
312
|
+
yield {
|
|
313
|
+
type: "content",
|
|
314
|
+
content: "\n\n[Operation cancelled by user]",
|
|
315
|
+
};
|
|
316
|
+
yield { type: "done" };
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* Load tools with error handling
|
|
320
|
+
* Returns tools array, logs error if loading fails
|
|
321
|
+
*/
|
|
322
|
+
async loadToolsSafely() {
|
|
323
|
+
try {
|
|
324
|
+
return await getAllGrokTools();
|
|
325
|
+
}
|
|
326
|
+
catch (error) {
|
|
327
|
+
// Log error but don't throw - continue with empty tools
|
|
328
|
+
console.warn(`⚠️ Error loading tools: ${error.message}`);
|
|
329
|
+
return [];
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* Process streaming chunks and accumulate message
|
|
334
|
+
*/
|
|
335
|
+
async *processStreamingChunks(stream, inputTokens, lastTokenUpdate, totalOutputTokens) {
|
|
336
|
+
let accumulatedMessage = {};
|
|
337
|
+
let accumulatedContent = "";
|
|
338
|
+
let toolCallsYielded = false;
|
|
339
|
+
for await (const chunk of stream) {
|
|
340
|
+
// Check for cancellation in the streaming loop
|
|
341
|
+
if (this.isCancelled()) {
|
|
342
|
+
yield* this.yieldCancellation();
|
|
343
|
+
// Return empty state after cancellation to avoid processing partial results
|
|
344
|
+
return { accumulated: {}, content: "", yielded: false };
|
|
345
|
+
}
|
|
346
|
+
if (!chunk.choices?.[0])
|
|
347
|
+
continue;
|
|
348
|
+
// Accumulate the message using reducer
|
|
349
|
+
accumulatedMessage = this.messageReducer(accumulatedMessage, chunk);
|
|
350
|
+
// Check for tool calls - yield when we have complete tool calls with function names
|
|
351
|
+
if (!toolCallsYielded && accumulatedMessage.tool_calls?.length > 0) {
|
|
352
|
+
const hasCompleteTool = accumulatedMessage.tool_calls.some((tc) => tc.function?.name);
|
|
353
|
+
if (hasCompleteTool) {
|
|
354
|
+
yield {
|
|
355
|
+
type: "tool_calls",
|
|
356
|
+
toolCalls: accumulatedMessage.tool_calls,
|
|
357
|
+
};
|
|
358
|
+
toolCallsYielded = true;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
// Stream reasoning content (GLM-4.6 thinking mode)
|
|
362
|
+
if (chunk.choices[0].delta?.reasoning_content) {
|
|
363
|
+
yield {
|
|
364
|
+
type: "reasoning",
|
|
365
|
+
reasoningContent: chunk.choices[0].delta.reasoning_content,
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
// Stream content as it comes
|
|
369
|
+
if (chunk.choices[0].delta?.content) {
|
|
370
|
+
accumulatedContent += chunk.choices[0].delta.content;
|
|
371
|
+
// Update token count in real-time
|
|
372
|
+
const currentOutputTokens = this.tokenCounter.estimateStreamingTokens(accumulatedContent) +
|
|
373
|
+
(accumulatedMessage.tool_calls
|
|
374
|
+
? this.tokenCounter.countTokens(JSON.stringify(accumulatedMessage.tool_calls))
|
|
375
|
+
: 0);
|
|
376
|
+
totalOutputTokens.value = currentOutputTokens;
|
|
377
|
+
yield {
|
|
378
|
+
type: "content",
|
|
379
|
+
content: chunk.choices[0].delta.content,
|
|
380
|
+
};
|
|
381
|
+
// Emit token count update (throttled to 250ms)
|
|
382
|
+
const now = Date.now();
|
|
383
|
+
if (now - lastTokenUpdate.value > 250) {
|
|
384
|
+
lastTokenUpdate.value = now;
|
|
385
|
+
yield {
|
|
386
|
+
type: "token_count",
|
|
387
|
+
tokenCount: inputTokens + totalOutputTokens.value,
|
|
388
|
+
};
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
return { accumulated: accumulatedMessage, content: accumulatedContent, yielded: toolCallsYielded };
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
395
|
+
* Add assistant message to history and conversation
|
|
396
|
+
*/
|
|
397
|
+
addAssistantMessage(accumulatedMessage) {
|
|
398
|
+
const assistantEntry = {
|
|
399
|
+
type: "assistant",
|
|
400
|
+
content: accumulatedMessage.content || "Using tools to help you...",
|
|
401
|
+
timestamp: new Date(),
|
|
402
|
+
toolCalls: accumulatedMessage.tool_calls || undefined,
|
|
403
|
+
};
|
|
404
|
+
this.chatHistory.push(assistantEntry);
|
|
405
|
+
this.messages.push({
|
|
406
|
+
role: "assistant",
|
|
407
|
+
content: accumulatedMessage.content || "",
|
|
408
|
+
tool_calls: accumulatedMessage.tool_calls,
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
/**
|
|
412
|
+
* Execute tool calls and yield results
|
|
413
|
+
*/
|
|
414
|
+
async *executeToolCalls(toolCalls, toolCallsYielded, inputTokens, totalOutputTokens) {
|
|
415
|
+
// Only yield tool_calls if we haven't already yielded them during streaming
|
|
416
|
+
if (!toolCallsYielded) {
|
|
417
|
+
yield {
|
|
418
|
+
type: "tool_calls",
|
|
419
|
+
toolCalls,
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
// Execute tools
|
|
423
|
+
for (const toolCall of toolCalls) {
|
|
424
|
+
// Check for cancellation before executing each tool
|
|
425
|
+
if (this.isCancelled()) {
|
|
426
|
+
yield* this.yieldCancellation();
|
|
427
|
+
return;
|
|
428
|
+
}
|
|
429
|
+
const result = await this.executeTool(toolCall);
|
|
430
|
+
const toolResultEntry = {
|
|
431
|
+
type: "tool_result",
|
|
432
|
+
content: result.success
|
|
433
|
+
? result.output || "Success"
|
|
434
|
+
: result.error || "Error occurred",
|
|
435
|
+
timestamp: new Date(),
|
|
436
|
+
toolCall: toolCall,
|
|
437
|
+
toolResult: result,
|
|
438
|
+
};
|
|
439
|
+
this.chatHistory.push(toolResultEntry);
|
|
440
|
+
yield {
|
|
441
|
+
type: "tool_result",
|
|
442
|
+
toolCall,
|
|
443
|
+
toolResult: result,
|
|
444
|
+
};
|
|
445
|
+
// Add tool result with proper format (needed for AI context)
|
|
446
|
+
this.messages.push({
|
|
447
|
+
role: "tool",
|
|
448
|
+
content: result.success
|
|
449
|
+
? result.output || "Success"
|
|
450
|
+
: result.error || "Error",
|
|
451
|
+
tool_call_id: toolCall.id,
|
|
452
|
+
});
|
|
453
|
+
}
|
|
454
|
+
// Update token count after processing all tool calls
|
|
455
|
+
inputTokens.value = this.tokenCounter.countMessageTokens(this.messages);
|
|
456
|
+
yield {
|
|
457
|
+
type: "token_count",
|
|
458
|
+
tokenCount: inputTokens.value + totalOutputTokens.value,
|
|
459
|
+
};
|
|
460
|
+
}
|
|
461
|
+
async *processUserMessageStream(message) {
|
|
462
|
+
// Create new abort controller for this request
|
|
463
|
+
this.abortController = new AbortController();
|
|
464
|
+
// Prepare user message and get input tokens
|
|
465
|
+
const inputTokensRef = { value: this.prepareUserMessageForStreaming(message) };
|
|
466
|
+
yield {
|
|
467
|
+
type: "token_count",
|
|
468
|
+
tokenCount: inputTokensRef.value,
|
|
469
|
+
};
|
|
470
|
+
// Yield context warnings if needed
|
|
471
|
+
yield* this.yieldContextWarnings();
|
|
472
|
+
const maxToolRounds = this.maxToolRounds;
|
|
300
473
|
let toolRounds = 0;
|
|
301
|
-
|
|
302
|
-
|
|
474
|
+
const totalOutputTokensRef = { value: 0 };
|
|
475
|
+
const lastTokenUpdateRef = { value: 0 };
|
|
303
476
|
try {
|
|
304
477
|
// Agent loop - continue until no more tool calls or max rounds reached
|
|
305
478
|
while (toolRounds < maxToolRounds) {
|
|
306
479
|
// Check if operation was cancelled
|
|
307
|
-
if (this.
|
|
308
|
-
yield
|
|
309
|
-
type: "content",
|
|
310
|
-
content: "\n\n[Operation cancelled by user]",
|
|
311
|
-
};
|
|
312
|
-
yield { type: "done" };
|
|
480
|
+
if (this.isCancelled()) {
|
|
481
|
+
yield* this.yieldCancellation();
|
|
313
482
|
return;
|
|
314
483
|
}
|
|
315
|
-
//
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
}
|
|
320
|
-
catch (error) {
|
|
484
|
+
// Load tools safely
|
|
485
|
+
const tools = await this.loadToolsSafely();
|
|
486
|
+
// Yield warning if no tools available
|
|
487
|
+
if (tools.length === 0) {
|
|
321
488
|
yield {
|
|
322
489
|
type: "content",
|
|
323
|
-
content:
|
|
490
|
+
content: "\n⚠️ No tools available, continuing with limited functionality...\n\n"
|
|
324
491
|
};
|
|
325
|
-
tools = []; // Continue with no tools
|
|
326
492
|
}
|
|
327
|
-
|
|
493
|
+
// Create chat stream
|
|
494
|
+
const stream = this.llmClient.chatStream(this.messages, tools, {
|
|
328
495
|
searchOptions: this.isGrokModel() && this.shouldUseSearchFor(message)
|
|
329
496
|
? { search_parameters: { mode: "auto" } }
|
|
330
497
|
: { search_parameters: { mode: "off" } }
|
|
331
498
|
});
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
let
|
|
335
|
-
for await (const chunk of
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
yield {
|
|
339
|
-
type: "content",
|
|
340
|
-
content: "\n\n[Operation cancelled by user]",
|
|
341
|
-
};
|
|
342
|
-
yield { type: "done" };
|
|
343
|
-
return;
|
|
499
|
+
// Process streaming chunks
|
|
500
|
+
const chunkGen = this.processStreamingChunks(stream, inputTokensRef.value, lastTokenUpdateRef, totalOutputTokensRef);
|
|
501
|
+
let streamResult;
|
|
502
|
+
for await (const chunk of chunkGen) {
|
|
503
|
+
if ('accumulated' in chunk) {
|
|
504
|
+
streamResult = chunk;
|
|
344
505
|
}
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
// Accumulate the message using reducer
|
|
348
|
-
accumulatedMessage = this.messageReducer(accumulatedMessage, chunk);
|
|
349
|
-
// Check for tool calls - yield when we have complete tool calls with function names
|
|
350
|
-
if (!toolCallsYielded && accumulatedMessage.tool_calls?.length > 0) {
|
|
351
|
-
// Check if we have at least one complete tool call with a function name
|
|
352
|
-
const hasCompleteTool = accumulatedMessage.tool_calls.some((tc) => tc.function?.name);
|
|
353
|
-
if (hasCompleteTool) {
|
|
354
|
-
yield {
|
|
355
|
-
type: "tool_calls",
|
|
356
|
-
toolCalls: accumulatedMessage.tool_calls,
|
|
357
|
-
};
|
|
358
|
-
toolCallsYielded = true;
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
// Stream reasoning content (GLM-4.6 thinking mode)
|
|
362
|
-
if (chunk.choices[0].delta?.reasoning_content) {
|
|
363
|
-
yield {
|
|
364
|
-
type: "reasoning",
|
|
365
|
-
reasoningContent: chunk.choices[0].delta.reasoning_content,
|
|
366
|
-
};
|
|
367
|
-
}
|
|
368
|
-
// Stream content as it comes
|
|
369
|
-
if (chunk.choices[0].delta?.content) {
|
|
370
|
-
accumulatedContent += chunk.choices[0].delta.content;
|
|
371
|
-
// Update token count in real-time including accumulated content and any tool calls
|
|
372
|
-
const currentOutputTokens = this.tokenCounter.estimateStreamingTokens(accumulatedContent) +
|
|
373
|
-
(accumulatedMessage.tool_calls
|
|
374
|
-
? this.tokenCounter.countTokens(JSON.stringify(accumulatedMessage.tool_calls))
|
|
375
|
-
: 0);
|
|
376
|
-
totalOutputTokens = currentOutputTokens;
|
|
377
|
-
yield {
|
|
378
|
-
type: "content",
|
|
379
|
-
content: chunk.choices[0].delta.content,
|
|
380
|
-
};
|
|
381
|
-
// Emit token count update
|
|
382
|
-
const now = Date.now();
|
|
383
|
-
if (now - lastTokenUpdate > 250) {
|
|
384
|
-
lastTokenUpdate = now;
|
|
385
|
-
yield {
|
|
386
|
-
type: "token_count",
|
|
387
|
-
tokenCount: inputTokens + totalOutputTokens,
|
|
388
|
-
};
|
|
389
|
-
}
|
|
506
|
+
else {
|
|
507
|
+
yield chunk;
|
|
390
508
|
}
|
|
391
509
|
}
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
timestamp: new Date(),
|
|
397
|
-
toolCalls: accumulatedMessage.tool_calls || undefined,
|
|
398
|
-
};
|
|
399
|
-
this.chatHistory.push(assistantEntry);
|
|
400
|
-
// Add accumulated message to conversation
|
|
401
|
-
this.messages.push({
|
|
402
|
-
role: "assistant",
|
|
403
|
-
content: accumulatedMessage.content || "",
|
|
404
|
-
tool_calls: accumulatedMessage.tool_calls,
|
|
405
|
-
});
|
|
510
|
+
if (!streamResult)
|
|
511
|
+
continue;
|
|
512
|
+
// Add assistant message to history
|
|
513
|
+
this.addAssistantMessage(streamResult.accumulated);
|
|
406
514
|
// Handle tool calls if present
|
|
407
|
-
if (
|
|
515
|
+
if (streamResult.accumulated.tool_calls?.length > 0) {
|
|
408
516
|
toolRounds++;
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
yield {
|
|
412
|
-
type: "tool_calls",
|
|
413
|
-
toolCalls: accumulatedMessage.tool_calls,
|
|
414
|
-
};
|
|
415
|
-
}
|
|
416
|
-
// Execute tools
|
|
417
|
-
for (const toolCall of accumulatedMessage.tool_calls) {
|
|
418
|
-
// Check for cancellation before executing each tool
|
|
419
|
-
if (this.abortController?.signal.aborted) {
|
|
420
|
-
yield {
|
|
421
|
-
type: "content",
|
|
422
|
-
content: "\n\n[Operation cancelled by user]",
|
|
423
|
-
};
|
|
424
|
-
yield { type: "done" };
|
|
425
|
-
return;
|
|
426
|
-
}
|
|
427
|
-
const result = await this.executeTool(toolCall);
|
|
428
|
-
const toolResultEntry = {
|
|
429
|
-
type: "tool_result",
|
|
430
|
-
content: result.success
|
|
431
|
-
? result.output || "Success"
|
|
432
|
-
: result.error || "Error occurred",
|
|
433
|
-
timestamp: new Date(),
|
|
434
|
-
toolCall: toolCall,
|
|
435
|
-
toolResult: result,
|
|
436
|
-
};
|
|
437
|
-
this.chatHistory.push(toolResultEntry);
|
|
438
|
-
yield {
|
|
439
|
-
type: "tool_result",
|
|
440
|
-
toolCall,
|
|
441
|
-
toolResult: result,
|
|
442
|
-
};
|
|
443
|
-
// Add tool result with proper format (needed for AI context)
|
|
444
|
-
this.messages.push({
|
|
445
|
-
role: "tool",
|
|
446
|
-
content: result.success
|
|
447
|
-
? result.output || "Success"
|
|
448
|
-
: result.error || "Error",
|
|
449
|
-
tool_call_id: toolCall.id,
|
|
450
|
-
});
|
|
451
|
-
}
|
|
452
|
-
// Update token count after processing all tool calls to include tool results
|
|
453
|
-
inputTokens = this.tokenCounter.countMessageTokens(this.messages);
|
|
454
|
-
// Final token update after tools processed
|
|
455
|
-
yield {
|
|
456
|
-
type: "token_count",
|
|
457
|
-
tokenCount: inputTokens + totalOutputTokens,
|
|
458
|
-
};
|
|
459
|
-
// Continue the loop to get the next response (which might have more tool calls)
|
|
517
|
+
yield* this.executeToolCalls(streamResult.accumulated.tool_calls, streamResult.yielded, inputTokensRef, totalOutputTokensRef);
|
|
518
|
+
// Continue loop to get next response
|
|
460
519
|
}
|
|
461
520
|
else {
|
|
462
521
|
// No tool calls, we're done
|
|
463
522
|
break;
|
|
464
523
|
}
|
|
465
524
|
}
|
|
525
|
+
// Check if max rounds reached
|
|
466
526
|
if (toolRounds >= maxToolRounds) {
|
|
467
527
|
yield {
|
|
468
528
|
type: "content",
|
|
@@ -473,12 +533,8 @@ export class GrokAgent extends EventEmitter {
|
|
|
473
533
|
}
|
|
474
534
|
catch (error) {
|
|
475
535
|
// Check if this was a cancellation
|
|
476
|
-
if (this.
|
|
477
|
-
yield
|
|
478
|
-
type: "content",
|
|
479
|
-
content: "\n\n[Operation cancelled by user]",
|
|
480
|
-
};
|
|
481
|
-
yield { type: "done" };
|
|
536
|
+
if (this.isCancelled()) {
|
|
537
|
+
yield* this.yieldCancellation();
|
|
482
538
|
return;
|
|
483
539
|
}
|
|
484
540
|
const errorEntry = {
|
|
@@ -498,16 +554,44 @@ export class GrokAgent extends EventEmitter {
|
|
|
498
554
|
this.abortController = null;
|
|
499
555
|
}
|
|
500
556
|
}
|
|
501
|
-
|
|
557
|
+
/**
|
|
558
|
+
* Parse and validate tool call arguments
|
|
559
|
+
* @param toolCall The tool call to parse arguments from
|
|
560
|
+
* @param toolType Type of tool (for error messages)
|
|
561
|
+
* @returns Parsed arguments or error result
|
|
562
|
+
*/
|
|
563
|
+
parseToolArguments(toolCall, toolType = 'Tool') {
|
|
564
|
+
if (!toolCall.function.arguments || toolCall.function.arguments.trim() === '') {
|
|
565
|
+
return {
|
|
566
|
+
success: false,
|
|
567
|
+
error: `${toolType} ${toolCall.function.name} called with empty arguments`,
|
|
568
|
+
};
|
|
569
|
+
}
|
|
502
570
|
try {
|
|
503
|
-
|
|
504
|
-
|
|
571
|
+
const args = JSON.parse(toolCall.function.arguments);
|
|
572
|
+
// Validate that args is an object (not null, array, or primitive)
|
|
573
|
+
if (typeof args !== 'object' || args === null || Array.isArray(args)) {
|
|
505
574
|
return {
|
|
506
575
|
success: false,
|
|
507
|
-
error:
|
|
576
|
+
error: `${toolType} ${toolCall.function.name} arguments must be a JSON object, got ${Array.isArray(args) ? 'array' : typeof args}`,
|
|
508
577
|
};
|
|
509
578
|
}
|
|
510
|
-
|
|
579
|
+
return { success: true, args };
|
|
580
|
+
}
|
|
581
|
+
catch (error) {
|
|
582
|
+
return {
|
|
583
|
+
success: false,
|
|
584
|
+
error: `Failed to parse ${toolType} arguments: ${error instanceof Error ? error.message : 'Invalid JSON'}`,
|
|
585
|
+
};
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
async executeTool(toolCall) {
|
|
589
|
+
try {
|
|
590
|
+
const parseResult = this.parseToolArguments(toolCall, 'Tool');
|
|
591
|
+
if (!parseResult.success) {
|
|
592
|
+
return { success: false, error: parseResult.error };
|
|
593
|
+
}
|
|
594
|
+
const args = parseResult.args;
|
|
511
595
|
switch (toolCall.function.name) {
|
|
512
596
|
case "view_file":
|
|
513
597
|
const range = args.start_line && args.end_line
|
|
@@ -518,14 +602,6 @@ export class GrokAgent extends EventEmitter {
|
|
|
518
602
|
return await this.textEditor.create(args.path, args.content);
|
|
519
603
|
case "str_replace_editor":
|
|
520
604
|
return await this.textEditor.strReplace(args.path, args.old_str, args.new_str, args.replace_all);
|
|
521
|
-
case "edit_file":
|
|
522
|
-
if (!this.morphEditor) {
|
|
523
|
-
return {
|
|
524
|
-
success: false,
|
|
525
|
-
error: "Morph Fast Apply not available. Please set MORPH_API_KEY environment variable to use this feature.",
|
|
526
|
-
};
|
|
527
|
-
}
|
|
528
|
-
return await this.morphEditor.editFile(args.target_file, args.instructions, args.code_edit);
|
|
529
605
|
case "bash":
|
|
530
606
|
return await this.bash.execute(args.command);
|
|
531
607
|
case "create_todo_list":
|
|
@@ -564,14 +640,11 @@ export class GrokAgent extends EventEmitter {
|
|
|
564
640
|
}
|
|
565
641
|
async executeMCPTool(toolCall) {
|
|
566
642
|
try {
|
|
567
|
-
|
|
568
|
-
if (!
|
|
569
|
-
return {
|
|
570
|
-
success: false,
|
|
571
|
-
error: `MCP tool ${toolCall.function.name} called with empty arguments`,
|
|
572
|
-
};
|
|
643
|
+
const parseResult = this.parseToolArguments(toolCall, 'MCP tool');
|
|
644
|
+
if (!parseResult.success) {
|
|
645
|
+
return { success: false, error: parseResult.error };
|
|
573
646
|
}
|
|
574
|
-
const args =
|
|
647
|
+
const args = parseResult.args;
|
|
575
648
|
const mcpManager = getMCPManager();
|
|
576
649
|
const result = await mcpManager.callTool(toolCall.function.name, args);
|
|
577
650
|
if (result.isError) {
|
|
@@ -618,10 +691,10 @@ export class GrokAgent extends EventEmitter {
|
|
|
618
691
|
return await this.bash.execute(command);
|
|
619
692
|
}
|
|
620
693
|
getCurrentModel() {
|
|
621
|
-
return this.
|
|
694
|
+
return this.llmClient.getCurrentModel();
|
|
622
695
|
}
|
|
623
696
|
setModel(model) {
|
|
624
|
-
this.
|
|
697
|
+
this.llmClient.setModel(model);
|
|
625
698
|
// Update token counter for new model
|
|
626
699
|
this.tokenCounter.dispose();
|
|
627
700
|
this.tokenCounter = createTokenCounter(model);
|
|
@@ -645,4 +718,4 @@ export class GrokAgent extends EventEmitter {
|
|
|
645
718
|
}
|
|
646
719
|
}
|
|
647
720
|
}
|
|
648
|
-
//# sourceMappingURL=
|
|
721
|
+
//# sourceMappingURL=llm-agent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llm-agent.js","sourceRoot":"","sources":["../../src/agent/llm-agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAoC,MAAM,kBAAkB,CAAC;AAC/E,OAAO,EACL,eAAe,EACf,aAAa,EACb,oBAAoB,GACrB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EACL,cAAc,EACd,QAAQ,EACR,QAAQ,EACR,UAAU,GACX,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,kBAAkB,EAAgB,MAAM,2BAA2B,CAAC;AAC7E,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AACzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AA2B/D,MAAM,OAAO,QAAS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