@defai.digital/ax-cli 3.8.22 → 3.8.24

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.
Files changed (120) hide show
  1. package/README.md +8 -2
  2. package/config-defaults/models.yaml +1 -1
  3. package/dist/agent/core/index.d.ts +8 -0
  4. package/dist/agent/core/index.js +9 -0
  5. package/dist/agent/core/index.js.map +1 -0
  6. package/dist/agent/core/types.d.ts +92 -0
  7. package/dist/agent/core/types.js +11 -0
  8. package/dist/agent/core/types.js.map +1 -0
  9. package/dist/agent/execution/index.d.ts +9 -0
  10. package/dist/agent/execution/index.js +9 -0
  11. package/dist/agent/execution/index.js.map +1 -0
  12. package/dist/agent/execution/tool-executor.d.ts +79 -0
  13. package/dist/agent/execution/tool-executor.js +281 -0
  14. package/dist/agent/execution/tool-executor.js.map +1 -0
  15. package/dist/agent/llm-agent.d.ts +22 -98
  16. package/dist/agent/llm-agent.js +181 -722
  17. package/dist/agent/llm-agent.js.map +1 -1
  18. package/dist/agent/planning/index.d.ts +9 -0
  19. package/dist/agent/planning/index.js +9 -0
  20. package/dist/agent/planning/index.js.map +1 -0
  21. package/dist/agent/planning/plan-executor.d.ts +84 -0
  22. package/dist/agent/planning/plan-executor.js +223 -0
  23. package/dist/agent/planning/plan-executor.js.map +1 -0
  24. package/dist/agent/streaming/index.d.ts +9 -0
  25. package/dist/agent/streaming/index.js +9 -0
  26. package/dist/agent/streaming/index.js.map +1 -0
  27. package/dist/agent/streaming/stream-handler.d.ts +62 -0
  28. package/dist/agent/streaming/stream-handler.js +193 -0
  29. package/dist/agent/streaming/stream-handler.js.map +1 -0
  30. package/dist/agent/subagent-orchestrator.d.ts +3 -3
  31. package/dist/agent/subagent-orchestrator.js +1 -0
  32. package/dist/agent/subagent-orchestrator.js.map +1 -1
  33. package/dist/agent/subagent-types.d.ts +10 -22
  34. package/dist/agent/subagent-types.js +19 -0
  35. package/dist/agent/subagent-types.js.map +1 -1
  36. package/dist/commands/usage.js +14 -0
  37. package/dist/commands/usage.js.map +1 -1
  38. package/dist/index.js +9 -7
  39. package/dist/index.js.map +1 -1
  40. package/dist/llm/client.d.ts +33 -1
  41. package/dist/llm/client.js +23 -11
  42. package/dist/llm/client.js.map +1 -1
  43. package/dist/llm/types.d.ts +7 -1
  44. package/dist/llm/types.js +5 -4
  45. package/dist/llm/types.js.map +1 -1
  46. package/dist/mcp/index.d.ts +31 -0
  47. package/dist/mcp/index.js +36 -0
  48. package/dist/mcp/index.js.map +1 -0
  49. package/dist/planner/types.d.ts +8 -8
  50. package/dist/schemas/index.d.ts +4 -4
  51. package/dist/schemas/tool-schemas.d.ts +12 -12
  52. package/dist/tools/bash.js +1 -1
  53. package/dist/tools/bash.js.map +1 -1
  54. package/dist/tools/text-editor.js +57 -63
  55. package/dist/tools/text-editor.js.map +1 -1
  56. package/dist/ui/hooks/use-enhanced-input.js +66 -81
  57. package/dist/ui/hooks/use-enhanced-input.js.map +1 -1
  58. package/dist/utils/background-task-manager.js +10 -2
  59. package/dist/utils/background-task-manager.js.map +1 -1
  60. package/dist/utils/confirmation-service.js +8 -5
  61. package/dist/utils/confirmation-service.js.map +1 -1
  62. package/dist/utils/index.d.ts +85 -6
  63. package/dist/utils/index.js +103 -15
  64. package/dist/utils/index.js.map +1 -1
  65. package/dist/utils/retry-helper.d.ts +7 -6
  66. package/dist/utils/retry-helper.js +8 -6
  67. package/dist/utils/retry-helper.js.map +1 -1
  68. package/dist/utils/settings-manager.d.ts +6 -0
  69. package/dist/utils/settings-manager.js +51 -64
  70. package/dist/utils/settings-manager.js.map +1 -1
  71. package/node_modules/@ax-cli/schemas/dist/index.d.ts +1 -0
  72. package/node_modules/@ax-cli/schemas/dist/index.d.ts.map +1 -1
  73. package/node_modules/@ax-cli/schemas/dist/index.js.map +1 -1
  74. package/node_modules/@ax-cli/schemas/dist/public/agent/chat-types.d.ts +164 -0
  75. package/node_modules/@ax-cli/schemas/dist/public/agent/chat-types.d.ts.map +1 -0
  76. package/node_modules/@ax-cli/schemas/dist/public/agent/chat-types.js +10 -0
  77. package/node_modules/@ax-cli/schemas/dist/public/agent/chat-types.js.map +1 -0
  78. package/node_modules/@ax-cli/schemas/dist/public/agent/index.d.ts +9 -0
  79. package/node_modules/@ax-cli/schemas/dist/public/agent/index.d.ts.map +1 -0
  80. package/node_modules/@ax-cli/schemas/dist/public/agent/index.js +9 -0
  81. package/node_modules/@ax-cli/schemas/dist/public/agent/index.js.map +1 -0
  82. package/package.json +1 -1
  83. package/packages/schemas/dist/index.d.ts +1 -0
  84. package/packages/schemas/dist/index.d.ts.map +1 -1
  85. package/packages/schemas/dist/index.js.map +1 -1
  86. package/packages/schemas/dist/public/agent/chat-types.d.ts +164 -0
  87. package/packages/schemas/dist/public/agent/chat-types.d.ts.map +1 -0
  88. package/packages/schemas/dist/public/agent/chat-types.js +10 -0
  89. package/packages/schemas/dist/public/agent/chat-types.js.map +1 -0
  90. package/packages/schemas/dist/public/agent/index.d.ts +9 -0
  91. package/packages/schemas/dist/public/agent/index.d.ts.map +1 -0
  92. package/packages/schemas/dist/public/agent/index.js +9 -0
  93. package/packages/schemas/dist/public/agent/index.js.map +1 -0
  94. package/dist/mcp/config-detector-v2.d.ts +0 -83
  95. package/dist/mcp/config-detector-v2.js +0 -328
  96. package/dist/mcp/config-detector-v2.js.map +0 -1
  97. package/dist/mcp/config-migrator-v2.d.ts +0 -89
  98. package/dist/mcp/config-migrator-v2.js +0 -288
  99. package/dist/mcp/config-migrator-v2.js.map +0 -1
  100. package/dist/mcp/config-v2.d.ts +0 -111
  101. package/dist/mcp/config-v2.js +0 -443
  102. package/dist/mcp/config-v2.js.map +0 -1
  103. package/dist/mcp/transports-v2.d.ts +0 -152
  104. package/dist/mcp/transports-v2.js +0 -481
  105. package/dist/mcp/transports-v2.js.map +0 -1
  106. package/dist/utils/error-sanitizer.d.ts +0 -119
  107. package/dist/utils/error-sanitizer.js +0 -253
  108. package/dist/utils/error-sanitizer.js.map +0 -1
  109. package/dist/utils/errors.d.ts +0 -74
  110. package/dist/utils/errors.js +0 -139
  111. package/dist/utils/errors.js.map +0 -1
  112. package/dist/utils/incremental-analyzer.d.ts +0 -134
  113. package/dist/utils/incremental-analyzer.js +0 -377
  114. package/dist/utils/incremental-analyzer.js.map +0 -1
  115. package/dist/utils/settings.d.ts +0 -1
  116. package/dist/utils/settings.js +0 -4
  117. package/dist/utils/settings.js.map +0 -1
  118. package/dist/utils/streaming-analyzer.d.ts +0 -160
  119. package/dist/utils/streaming-analyzer.js +0 -214
  120. package/dist/utils/streaming-analyzer.js.map +0 -1
@@ -1,64 +1,18 @@
1
- import { LLMToolCall } from "../llm/client.js";
2
1
  import type { SamplingConfig, ThinkingConfig } from "../llm/types.js";
3
2
  import { ToolResult } from "../types/index.js";
4
3
  import { EventEmitter } from "events";
5
4
  import { CheckpointManager } from "../checkpoint/index.js";
6
5
  import { SubagentOrchestrator } from "./subagent-orchestrator.js";
7
6
  import { TaskPlan } from "../planner/index.js";
8
- export interface ChatEntry {
9
- type: "user" | "assistant" | "tool_result" | "tool_call";
10
- content: string;
11
- timestamp: Date;
12
- toolCalls?: LLMToolCall[];
13
- toolCall?: LLMToolCall;
14
- toolResult?: {
15
- success: boolean;
16
- output?: string;
17
- error?: string;
18
- };
19
- isStreaming?: boolean;
20
- /** GLM-4.6 reasoning content (thinking mode) */
21
- reasoningContent?: string;
22
- /** Whether reasoning is currently streaming */
23
- isReasoningStreaming?: boolean;
24
- /** Response duration in milliseconds */
25
- durationMs?: number;
26
- /** Tool execution start time (for elapsed time display while running) */
27
- executionStartTime?: Date;
28
- /** Tool execution duration in milliseconds (shown after completion) */
29
- executionDurationMs?: number;
30
- }
31
- export interface StreamingChunk {
32
- type: "content" | "reasoning" | "tool_calls" | "tool_result" | "done" | "token_count";
33
- content?: string;
34
- /** GLM-4.6 reasoning content chunk */
35
- reasoningContent?: string;
36
- toolCalls?: LLMToolCall[];
37
- toolCall?: LLMToolCall;
38
- toolResult?: ToolResult;
39
- tokenCount?: number;
40
- /** Tool execution duration in milliseconds (for tool_result type) */
41
- executionDurationMs?: number;
42
- }
43
- /**
44
- * Accumulated message from streaming response
45
- * Contains the full message content and any tool calls
46
- */
47
- export interface AccumulatedMessage {
48
- role?: string;
49
- content?: string;
50
- tool_calls?: LLMToolCall[];
51
- [key: string]: unknown;
52
- }
7
+ import type { ChatEntry as CoreChatEntry, StreamingChunk as CoreStreamingChunk, AccumulatedMessage as CoreAccumulatedMessage } from "./core/index.js";
8
+ export type ChatEntry = CoreChatEntry;
9
+ export type StreamingChunk = CoreStreamingChunk;
10
+ export type AccumulatedMessage = CoreAccumulatedMessage;
53
11
  export declare class LLMAgent extends EventEmitter {
54
12
  private llmClient;
55
- private textEditor;
56
- private bash;
57
- private bashOutput;
58
- private todoTool;
59
- private search;
60
- private _architectureTool?;
61
- private _validationTool?;
13
+ private toolExecutor;
14
+ private streamHandler;
15
+ private planExecutor;
62
16
  private chatHistory;
63
17
  private messages;
64
18
  private tokenCounter;
@@ -87,6 +41,11 @@ export declare class LLMAgent extends EventEmitter {
87
41
  /** BUG FIX: Track approval timeouts for cleanup to prevent memory leaks */
88
42
  private toolApprovalTimeouts;
89
43
  constructor(apiKey: string, baseURL?: string, model?: string, maxToolRounds?: number);
44
+ /**
45
+ * Run an async task in background with proper error handling
46
+ * Centralizes the common pattern of background initialization
47
+ */
48
+ private runBackgroundTask;
90
49
  private initializeCheckpointManager;
91
50
  private initializeMCP;
92
51
  /**
@@ -159,16 +118,6 @@ export declare class LLMAgent extends EventEmitter {
159
118
  * Used specifically for isRepetitiveToolCall to avoid redundant parsing
160
119
  */
161
120
  private parseToolArgumentsCached;
162
- /**
163
- * Lazy-loaded getter for ArchitectureTool
164
- * Only instantiates when first accessed to reduce startup time
165
- */
166
- private get architectureTool();
167
- /**
168
- * Lazy-loaded getter for ValidationTool
169
- * Only instantiates when first accessed to reduce startup time
170
- */
171
- private get validationTool();
172
121
  /**
173
122
  * Detect if a tool call is repetitive (likely causing a loop)
174
123
  * Uses the intelligent LoopDetector which provides:
@@ -199,14 +148,6 @@ export declare class LLMAgent extends EventEmitter {
199
148
  * Get the current plan if any
200
149
  */
201
150
  getCurrentPlan(): TaskPlan | null;
202
- /**
203
- * Execute a single phase using the LLM
204
- */
205
- private executePhase;
206
- /**
207
- * Build a prompt for phase execution
208
- */
209
- private buildPhasePrompt;
210
151
  /**
211
152
  * Generate and execute a plan for a complex request
212
153
  * Uses TodoWrite for Claude Code-style seamless progress display
@@ -217,26 +158,7 @@ export declare class LLMAgent extends EventEmitter {
217
158
  * Executes the core message processing loop without planning
218
159
  */
219
160
  private processUserMessageStreamInternal;
220
- /**
221
- * Format plan summary for display
222
- */
223
- private formatPlanSummary;
224
- /**
225
- * Format plan result for display
226
- */
227
- private formatPlanResult;
228
161
  processUserMessage(message: string): Promise<ChatEntry[]>;
229
- /**
230
- * Optimized streaming delta merge - mutates accumulator for performance
231
- * This is safe because accumulator is only used internally during streaming
232
- *
233
- * Performance: 50% faster than immutable approach (no object copying)
234
- */
235
- private reduceStreamDelta;
236
- /**
237
- * Accumulate streaming message chunks
238
- */
239
- private messageReducer;
240
162
  /**
241
163
  * Prepare user message and apply context management
242
164
  * Returns the calculated input tokens
@@ -260,9 +182,15 @@ export declare class LLMAgent extends EventEmitter {
260
182
  */
261
183
  private loadToolsSafely;
262
184
  /**
263
- * Process streaming chunks and accumulate message
185
+ * Format tool result content for display or message
186
+ * Centralizes the common pattern of formatting success/error output
187
+ *
188
+ * @param result - Tool execution result
189
+ * @param defaultSuccess - Default message if success but no output (default: "Success")
190
+ * @param defaultError - Default message if error but no error message (default: "Error occurred")
191
+ * @returns Formatted content string
264
192
  */
265
- private processStreamingChunks;
193
+ private formatToolResultContent;
266
194
  /**
267
195
  * Add assistant message to history and conversation
268
196
  */
@@ -273,14 +201,10 @@ export declare class LLMAgent extends EventEmitter {
273
201
  private executeToolCalls;
274
202
  processUserMessageStream(message: string): AsyncGenerator<StreamingChunk, void, unknown>;
275
203
  /**
276
- * Parse and validate tool call arguments
277
- * @param toolCall The tool call to parse arguments from
278
- * @param toolType Type of tool (for error messages)
279
- * @returns Parsed arguments or error result
204
+ * Execute a tool call using the ToolExecutor
205
+ * Handles tool approval for VSCode integration before delegation
280
206
  */
281
- private parseToolArguments;
282
207
  private executeTool;
283
- private executeMCPTool;
284
208
  getChatHistory(): ChatEntry[];
285
209
  getCurrentDirectory(): string;
286
210
  executeBashCommand(command: string): Promise<ToolResult>;