@defai.digital/ax-cli 2.7.0 → 3.0.0
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/.ax-cli/checkpoints/2025-11-20/checkpoint-2dd84869-e62d-46c8-9885-7e45f37f36e2.json +69 -0
- package/.ax-cli/checkpoints/2025-11-20/checkpoint-484dc350-353f-4808-9ed1-ebb3cefdab37.json +24 -0
- package/.ax-cli/checkpoints/2025-11-20/checkpoint-74a18b87-6172-4215-962b-44bb9f46a662.json +69 -0
- package/.ax-cli/checkpoints/2025-11-20/checkpoint-870a5fb9-6e82-4ff2-8ec8-af4c251cc514.json +44 -0
- package/.ax-cli/checkpoints/2025-11-20/checkpoint-93946601-0e83-456c-ba47-def9713124dd.json +24 -0
- package/.ax-cli/checkpoints/metadata.json +62 -0
- package/README.md +87 -11
- package/dist/agent/context-manager.d.ts +2 -2
- package/dist/agent/context-manager.js +37 -15
- package/dist/agent/context-manager.js.map +1 -1
- package/dist/agent/dependency-resolver.d.ts +83 -0
- package/dist/agent/dependency-resolver.js +310 -0
- package/dist/agent/dependency-resolver.js.map +1 -0
- package/dist/agent/llm-agent.d.ts +111 -0
- package/dist/agent/llm-agent.js +625 -3
- package/dist/agent/llm-agent.js.map +1 -1
- package/dist/agent/specialized/analysis-agent.d.ts +11 -0
- package/dist/agent/specialized/analysis-agent.js +33 -0
- package/dist/agent/specialized/analysis-agent.js.map +1 -0
- package/dist/agent/specialized/debug-agent.d.ts +11 -0
- package/dist/agent/specialized/debug-agent.js +33 -0
- package/dist/agent/specialized/debug-agent.js.map +1 -0
- package/dist/agent/specialized/documentation-agent.d.ts +11 -0
- package/dist/agent/specialized/documentation-agent.js +33 -0
- package/dist/agent/specialized/documentation-agent.js.map +1 -0
- package/dist/agent/specialized/index.d.ts +11 -0
- package/dist/agent/specialized/index.js +12 -0
- package/dist/agent/specialized/index.js.map +1 -0
- package/dist/agent/specialized/performance-agent.d.ts +11 -0
- package/dist/agent/specialized/performance-agent.js +33 -0
- package/dist/agent/specialized/performance-agent.js.map +1 -0
- package/dist/agent/specialized/refactoring-agent.d.ts +11 -0
- package/dist/agent/specialized/refactoring-agent.js +33 -0
- package/dist/agent/specialized/refactoring-agent.js.map +1 -0
- package/dist/agent/specialized/testing-agent.d.ts +11 -0
- package/dist/agent/specialized/testing-agent.js +33 -0
- package/dist/agent/specialized/testing-agent.js.map +1 -0
- package/dist/agent/subagent-orchestrator.d.ts +128 -0
- package/dist/agent/subagent-orchestrator.js +388 -0
- package/dist/agent/subagent-orchestrator.js.map +1 -0
- package/dist/agent/subagent-types.d.ts +262 -0
- package/dist/agent/subagent-types.js +152 -0
- package/dist/agent/subagent-types.js.map +1 -0
- package/dist/agent/subagent.d.ts +88 -0
- package/dist/agent/subagent.js +426 -0
- package/dist/agent/subagent.js.map +1 -0
- package/dist/checkpoint/index.d.ts +9 -0
- package/dist/checkpoint/index.js +11 -0
- package/dist/checkpoint/index.js.map +1 -0
- package/dist/checkpoint/manager.d.ts +99 -0
- package/dist/checkpoint/manager.js +281 -0
- package/dist/checkpoint/manager.js.map +1 -0
- package/dist/checkpoint/storage.d.ts +31 -0
- package/dist/checkpoint/storage.js +265 -0
- package/dist/checkpoint/storage.js.map +1 -0
- package/dist/checkpoint/types.d.ts +111 -0
- package/dist/checkpoint/types.js +17 -0
- package/dist/checkpoint/types.js.map +1 -0
- package/dist/commands/cache.js +5 -3
- package/dist/commands/cache.js.map +1 -1
- package/dist/commands/memory.js +21 -16
- package/dist/commands/memory.js.map +1 -1
- package/dist/commands/plan.d.ts +43 -0
- package/dist/commands/plan.js +385 -0
- package/dist/commands/plan.js.map +1 -0
- package/dist/commands/rewind.d.ts +19 -0
- package/dist/commands/rewind.js +221 -0
- package/dist/commands/rewind.js.map +1 -0
- package/dist/constants.d.ts +28 -0
- package/dist/constants.js +29 -0
- package/dist/constants.js.map +1 -1
- package/dist/hooks/use-enhanced-input.d.ts +5 -1
- package/dist/hooks/use-enhanced-input.js +23 -10
- package/dist/hooks/use-enhanced-input.js.map +1 -1
- package/dist/hooks/use-input-handler.d.ts +11 -1
- package/dist/hooks/use-input-handler.js +294 -2
- package/dist/hooks/use-input-handler.js.map +1 -1
- package/dist/llm/client.js +2 -1
- package/dist/llm/client.js.map +1 -1
- package/dist/llm/tools.d.ts +5 -0
- package/dist/llm/tools.js +57 -6
- package/dist/llm/tools.js.map +1 -1
- package/dist/mcp/client.d.ts +1 -0
- package/dist/mcp/client.js +30 -8
- package/dist/mcp/client.js.map +1 -1
- package/dist/mcp/transports.d.ts +0 -1
- package/dist/mcp/transports.js +10 -7
- package/dist/mcp/transports.js.map +1 -1
- package/dist/planner/dependency-resolver.d.ts +72 -0
- package/dist/planner/dependency-resolver.js +272 -0
- package/dist/planner/dependency-resolver.js.map +1 -0
- package/dist/planner/index.d.ts +12 -0
- package/dist/planner/index.js +26 -0
- package/dist/planner/index.js.map +1 -0
- package/dist/planner/plan-generator.d.ts +74 -0
- package/dist/planner/plan-generator.js +244 -0
- package/dist/planner/plan-generator.js.map +1 -0
- package/dist/planner/plan-storage.d.ts +98 -0
- package/dist/planner/plan-storage.js +325 -0
- package/dist/planner/plan-storage.js.map +1 -0
- package/dist/planner/prompts/planning-prompt.d.ts +41 -0
- package/dist/planner/prompts/planning-prompt.js +289 -0
- package/dist/planner/prompts/planning-prompt.js.map +1 -0
- package/dist/planner/task-planner.d.ts +135 -0
- package/dist/planner/task-planner.js +493 -0
- package/dist/planner/task-planner.js.map +1 -0
- package/dist/planner/token-estimator.d.ts +63 -0
- package/dist/planner/token-estimator.js +295 -0
- package/dist/planner/token-estimator.js.map +1 -0
- package/dist/planner/types.d.ts +669 -0
- package/dist/planner/types.js +213 -0
- package/dist/planner/types.js.map +1 -0
- package/dist/schemas/api-schemas.js +4 -0
- package/dist/schemas/api-schemas.js.map +1 -1
- package/dist/schemas/confirmation-schemas.d.ts +5 -0
- package/dist/schemas/confirmation-schemas.js +7 -0
- package/dist/schemas/confirmation-schemas.js.map +1 -1
- package/dist/schemas/index.d.ts +4 -4
- package/dist/tools/bash-output.d.ts +25 -0
- package/dist/tools/bash-output.js +145 -0
- package/dist/tools/bash-output.js.map +1 -0
- package/dist/tools/bash.d.ts +46 -2
- package/dist/tools/bash.js +241 -42
- package/dist/tools/bash.js.map +1 -1
- package/dist/tools/search.js +34 -9
- package/dist/tools/search.js.map +1 -1
- package/dist/tools/text-editor.d.ts +16 -0
- package/dist/tools/text-editor.js +37 -2
- package/dist/tools/text-editor.js.map +1 -1
- package/dist/ui/components/chat-history.d.ts +1 -0
- package/dist/ui/components/chat-history.js +125 -41
- package/dist/ui/components/chat-history.js.map +1 -1
- package/dist/ui/components/chat-input.js +10 -3
- package/dist/ui/components/chat-input.js.map +1 -1
- package/dist/ui/components/chat-interface.js +154 -45
- package/dist/ui/components/chat-interface.js.map +1 -1
- package/dist/ui/components/collapsible-tool-result.d.ts +26 -0
- package/dist/ui/components/collapsible-tool-result.js +172 -0
- package/dist/ui/components/collapsible-tool-result.js.map +1 -0
- package/dist/ui/components/command-suggestions.js +2 -1
- package/dist/ui/components/command-suggestions.js.map +1 -1
- package/dist/ui/components/confirmation-dialog.js +25 -36
- package/dist/ui/components/confirmation-dialog.js.map +1 -1
- package/dist/ui/components/index.d.ts +8 -0
- package/dist/ui/components/index.js +9 -0
- package/dist/ui/components/index.js.map +1 -1
- package/dist/ui/components/keyboard-hints.d.ts +35 -0
- package/dist/ui/components/keyboard-hints.js +134 -0
- package/dist/ui/components/keyboard-hints.js.map +1 -0
- package/dist/ui/components/loading-spinner.d.ts +2 -1
- package/dist/ui/components/loading-spinner.js +86 -34
- package/dist/ui/components/loading-spinner.js.map +1 -1
- package/dist/ui/components/phase-progress.d.ts +21 -0
- package/dist/ui/components/phase-progress.js +228 -0
- package/dist/ui/components/phase-progress.js.map +1 -0
- package/dist/ui/components/quick-actions.d.ts +12 -0
- package/dist/ui/components/quick-actions.js +122 -0
- package/dist/ui/components/quick-actions.js.map +1 -0
- package/dist/ui/components/reasoning-display.d.ts +0 -80
- package/dist/ui/components/reasoning-display.js +0 -83
- package/dist/ui/components/reasoning-display.js.map +1 -1
- package/dist/ui/components/status-bar.d.ts +25 -0
- package/dist/ui/components/status-bar.js +125 -0
- package/dist/ui/components/status-bar.js.map +1 -0
- package/dist/ui/components/subagent-monitor.d.ts +29 -0
- package/dist/ui/components/subagent-monitor.js +150 -0
- package/dist/ui/components/subagent-monitor.js.map +1 -0
- package/dist/ui/components/toast-notification.d.ts +123 -0
- package/dist/ui/components/toast-notification.js +143 -0
- package/dist/ui/components/toast-notification.js.map +1 -0
- package/dist/ui/components/welcome-panel.d.ts +10 -0
- package/dist/ui/components/welcome-panel.js +107 -0
- package/dist/ui/components/welcome-panel.js.map +1 -0
- package/dist/utils/background-task-manager.d.ts +95 -0
- package/dist/utils/background-task-manager.js +330 -0
- package/dist/utils/background-task-manager.js.map +1 -0
- package/dist/utils/confirmation-service.js +8 -3
- package/dist/utils/confirmation-service.js.map +1 -1
- package/dist/utils/history-manager.d.ts +1 -0
- package/dist/utils/history-manager.js +40 -5
- package/dist/utils/history-manager.js.map +1 -1
- package/dist/utils/json-utils.d.ts +7 -0
- package/dist/utils/json-utils.js +70 -2
- package/dist/utils/json-utils.js.map +1 -1
- package/dist/utils/message-optimizer.d.ts +1 -0
- package/dist/utils/message-optimizer.js +7 -1
- package/dist/utils/message-optimizer.js.map +1 -1
- package/dist/utils/project-analyzer.js +5 -2
- package/dist/utils/project-analyzer.js.map +1 -1
- package/dist/utils/settings-manager.js +12 -10
- package/dist/utils/settings-manager.js.map +1 -1
- package/dist/utils/text-utils.js +3 -3
- package/dist/utils/text-utils.js.map +1 -1
- package/dist/utils/token-counter.d.ts +5 -0
- package/dist/utils/token-counter.js +18 -3
- package/dist/utils/token-counter.js.map +1 -1
- package/package.json +3 -1
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Subagent System Types
|
|
3
|
+
*
|
|
4
|
+
* Type definitions for the autonomous subagent system that enables
|
|
5
|
+
* parallel task execution and specialized agent capabilities.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Types of specialized agents available
|
|
9
|
+
*/
|
|
10
|
+
export var SubagentRole;
|
|
11
|
+
(function (SubagentRole) {
|
|
12
|
+
/** General-purpose agent for any task */
|
|
13
|
+
SubagentRole["GENERAL"] = "general";
|
|
14
|
+
/** Specialized in writing and running tests */
|
|
15
|
+
SubagentRole["TESTING"] = "testing";
|
|
16
|
+
/** Specialized in generating documentation */
|
|
17
|
+
SubagentRole["DOCUMENTATION"] = "documentation";
|
|
18
|
+
/** Specialized in code refactoring */
|
|
19
|
+
SubagentRole["REFACTORING"] = "refactoring";
|
|
20
|
+
/** Specialized in code analysis and bug detection */
|
|
21
|
+
SubagentRole["ANALYSIS"] = "analysis";
|
|
22
|
+
/** Specialized in debugging and error resolution */
|
|
23
|
+
SubagentRole["DEBUG"] = "debug";
|
|
24
|
+
/** Specialized in performance optimization */
|
|
25
|
+
SubagentRole["PERFORMANCE"] = "performance";
|
|
26
|
+
})(SubagentRole || (SubagentRole = {}));
|
|
27
|
+
/**
|
|
28
|
+
* Execution state of a subagent
|
|
29
|
+
*/
|
|
30
|
+
export var SubagentState;
|
|
31
|
+
(function (SubagentState) {
|
|
32
|
+
/** Waiting to be started */
|
|
33
|
+
SubagentState["PENDING"] = "pending";
|
|
34
|
+
/** Currently executing */
|
|
35
|
+
SubagentState["RUNNING"] = "running";
|
|
36
|
+
/** Successfully completed */
|
|
37
|
+
SubagentState["COMPLETED"] = "completed";
|
|
38
|
+
/** Failed with error */
|
|
39
|
+
SubagentState["FAILED"] = "failed";
|
|
40
|
+
/** Cancelled by user or system */
|
|
41
|
+
SubagentState["CANCELLED"] = "cancelled";
|
|
42
|
+
})(SubagentState || (SubagentState = {}));
|
|
43
|
+
/**
|
|
44
|
+
* Default subagent configuration by role
|
|
45
|
+
*/
|
|
46
|
+
export const DEFAULT_SUBAGENT_CONFIG = {
|
|
47
|
+
[SubagentRole.GENERAL]: {
|
|
48
|
+
allowedTools: ['bash', 'text_editor', 'search', 'todo'],
|
|
49
|
+
maxToolRounds: 30,
|
|
50
|
+
contextDepth: 20,
|
|
51
|
+
priority: 1,
|
|
52
|
+
},
|
|
53
|
+
[SubagentRole.TESTING]: {
|
|
54
|
+
allowedTools: ['bash', 'text_editor', 'search'],
|
|
55
|
+
maxToolRounds: 20,
|
|
56
|
+
contextDepth: 15,
|
|
57
|
+
priority: 2,
|
|
58
|
+
},
|
|
59
|
+
[SubagentRole.DOCUMENTATION]: {
|
|
60
|
+
allowedTools: ['text_editor', 'search'],
|
|
61
|
+
maxToolRounds: 15,
|
|
62
|
+
contextDepth: 10,
|
|
63
|
+
priority: 2,
|
|
64
|
+
},
|
|
65
|
+
[SubagentRole.REFACTORING]: {
|
|
66
|
+
allowedTools: ['text_editor', 'search', 'bash'],
|
|
67
|
+
maxToolRounds: 25,
|
|
68
|
+
contextDepth: 20,
|
|
69
|
+
priority: 2,
|
|
70
|
+
},
|
|
71
|
+
[SubagentRole.ANALYSIS]: {
|
|
72
|
+
allowedTools: ['search', 'bash'],
|
|
73
|
+
maxToolRounds: 15,
|
|
74
|
+
contextDepth: 15,
|
|
75
|
+
priority: 3,
|
|
76
|
+
},
|
|
77
|
+
[SubagentRole.DEBUG]: {
|
|
78
|
+
allowedTools: ['bash', 'text_editor', 'search'],
|
|
79
|
+
maxToolRounds: 25,
|
|
80
|
+
contextDepth: 20,
|
|
81
|
+
priority: 3,
|
|
82
|
+
},
|
|
83
|
+
[SubagentRole.PERFORMANCE]: {
|
|
84
|
+
allowedTools: ['bash', 'search', 'text_editor'],
|
|
85
|
+
maxToolRounds: 20,
|
|
86
|
+
contextDepth: 15,
|
|
87
|
+
priority: 2,
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* System prompts for each subagent role
|
|
92
|
+
*/
|
|
93
|
+
export const SUBAGENT_SYSTEM_PROMPTS = {
|
|
94
|
+
[SubagentRole.GENERAL]: `You are a general-purpose AI coding assistant.
|
|
95
|
+
You can handle any coding task assigned to you.
|
|
96
|
+
Be thorough, clear, and follow best practices.`,
|
|
97
|
+
[SubagentRole.TESTING]: `You are a specialized testing agent.
|
|
98
|
+
Your role is to:
|
|
99
|
+
- Write comprehensive unit tests
|
|
100
|
+
- Write integration tests
|
|
101
|
+
- Ensure high test coverage
|
|
102
|
+
- Follow testing best practices for the project's framework
|
|
103
|
+
- Write clear, maintainable test code
|
|
104
|
+
- Include edge cases and error scenarios
|
|
105
|
+
Focus ONLY on testing tasks.`,
|
|
106
|
+
[SubagentRole.DOCUMENTATION]: `You are a specialized documentation agent.
|
|
107
|
+
Your role is to:
|
|
108
|
+
- Generate clear, comprehensive documentation
|
|
109
|
+
- Follow documentation standards (JSDoc, Markdown, etc.)
|
|
110
|
+
- Include usage examples
|
|
111
|
+
- Document edge cases and limitations
|
|
112
|
+
- Write in clear, concise language
|
|
113
|
+
- Structure documentation logically
|
|
114
|
+
Focus ONLY on documentation tasks.`,
|
|
115
|
+
[SubagentRole.REFACTORING]: `You are a specialized refactoring agent.
|
|
116
|
+
Your role is to:
|
|
117
|
+
- Improve code structure and readability
|
|
118
|
+
- Apply SOLID principles
|
|
119
|
+
- Reduce code duplication
|
|
120
|
+
- Optimize performance where applicable
|
|
121
|
+
- Maintain backward compatibility
|
|
122
|
+
- Preserve existing functionality
|
|
123
|
+
Focus ONLY on refactoring tasks.`,
|
|
124
|
+
[SubagentRole.ANALYSIS]: `You are a specialized code analysis agent.
|
|
125
|
+
Your role is to:
|
|
126
|
+
- Analyze code for potential bugs
|
|
127
|
+
- Identify security vulnerabilities
|
|
128
|
+
- Detect code smells and anti-patterns
|
|
129
|
+
- Suggest improvements
|
|
130
|
+
- Check for best practice violations
|
|
131
|
+
- Provide detailed analysis reports
|
|
132
|
+
Focus ONLY on analysis tasks.`,
|
|
133
|
+
[SubagentRole.DEBUG]: `You are a specialized debugging agent.
|
|
134
|
+
Your role is to:
|
|
135
|
+
- Identify and fix bugs
|
|
136
|
+
- Add proper error handling
|
|
137
|
+
- Improve error messages
|
|
138
|
+
- Add logging where helpful
|
|
139
|
+
- Test fixes thoroughly
|
|
140
|
+
- Explain the root cause of issues
|
|
141
|
+
Focus ONLY on debugging tasks.`,
|
|
142
|
+
[SubagentRole.PERFORMANCE]: `You are a specialized performance optimization agent.
|
|
143
|
+
Your role is to:
|
|
144
|
+
- Identify performance bottlenecks
|
|
145
|
+
- Optimize algorithms and data structures
|
|
146
|
+
- Reduce memory usage
|
|
147
|
+
- Improve execution speed
|
|
148
|
+
- Add performance monitoring
|
|
149
|
+
- Benchmark optimizations
|
|
150
|
+
Focus ONLY on performance tasks.`,
|
|
151
|
+
};
|
|
152
|
+
//# sourceMappingURL=subagent-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subagent-types.js","sourceRoot":"","sources":["../../src/agent/subagent-types.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Subagent Base Class
|
|
3
|
+
*
|
|
4
|
+
* Base class for all specialized subagents. Subagents are lightweight AI agents
|
|
5
|
+
* that focus on specific tasks (testing, documentation, refactoring, etc.) with
|
|
6
|
+
* limited tool access and shallow conversation history.
|
|
7
|
+
*/
|
|
8
|
+
import { EventEmitter } from 'events';
|
|
9
|
+
import { LLMClient } from '../llm/client.js';
|
|
10
|
+
import type { LLMMessage } from '../llm/client.js';
|
|
11
|
+
import type { ChatEntry } from './llm-agent.js';
|
|
12
|
+
import type { SubagentConfig, SubagentTask, SubagentResult, SubagentStatus } from './subagent-types.js';
|
|
13
|
+
import { SubagentRole } from './subagent-types.js';
|
|
14
|
+
/**
|
|
15
|
+
* Base Subagent class
|
|
16
|
+
*/
|
|
17
|
+
export declare class Subagent extends EventEmitter {
|
|
18
|
+
readonly id: string;
|
|
19
|
+
readonly role: SubagentRole;
|
|
20
|
+
readonly config: SubagentConfig;
|
|
21
|
+
protected llmClient: LLMClient;
|
|
22
|
+
protected chatHistory: ChatEntry[];
|
|
23
|
+
protected messages: LLMMessage[];
|
|
24
|
+
protected tools: Map<string, any>;
|
|
25
|
+
protected isActive: boolean;
|
|
26
|
+
protected currentTaskId: string | null;
|
|
27
|
+
protected status: SubagentStatus;
|
|
28
|
+
constructor(role: SubagentRole, configOverrides?: Partial<SubagentConfig>);
|
|
29
|
+
/**
|
|
30
|
+
* Get default configuration for a role
|
|
31
|
+
*/
|
|
32
|
+
private getDefaultConfig;
|
|
33
|
+
/**
|
|
34
|
+
* Initialize tools based on allowed tools in config
|
|
35
|
+
*/
|
|
36
|
+
private initializeTools;
|
|
37
|
+
/**
|
|
38
|
+
* Build system prompt for this subagent role
|
|
39
|
+
* Override in specialized subagent classes
|
|
40
|
+
*/
|
|
41
|
+
protected buildSystemPrompt(): string;
|
|
42
|
+
/**
|
|
43
|
+
* Execute a task
|
|
44
|
+
*/
|
|
45
|
+
executeTask(task: SubagentTask): Promise<SubagentResult>;
|
|
46
|
+
/**
|
|
47
|
+
* Build context prompt from task
|
|
48
|
+
*/
|
|
49
|
+
private buildContextPrompt;
|
|
50
|
+
/**
|
|
51
|
+
* Execute a tool call
|
|
52
|
+
*/
|
|
53
|
+
private executeToolCall;
|
|
54
|
+
/**
|
|
55
|
+
* Get tool definitions for LLM
|
|
56
|
+
*/
|
|
57
|
+
private getToolDefinitions;
|
|
58
|
+
/**
|
|
59
|
+
* Get current status
|
|
60
|
+
*/
|
|
61
|
+
getStatus(): SubagentStatus;
|
|
62
|
+
/**
|
|
63
|
+
* Abort execution
|
|
64
|
+
*/
|
|
65
|
+
abort(): void;
|
|
66
|
+
/**
|
|
67
|
+
* Terminate subagent
|
|
68
|
+
*/
|
|
69
|
+
terminate(): Promise<void>;
|
|
70
|
+
/**
|
|
71
|
+
* Get chat history (for debugging/monitoring)
|
|
72
|
+
*/
|
|
73
|
+
getChatHistory(): ChatEntry[];
|
|
74
|
+
/**
|
|
75
|
+
* Get logs (alias for getChatHistory for test compatibility)
|
|
76
|
+
*/
|
|
77
|
+
getLogs(): ChatEntry[];
|
|
78
|
+
/**
|
|
79
|
+
* Receive a message from parent/orchestrator
|
|
80
|
+
*/
|
|
81
|
+
receiveMessage(message: {
|
|
82
|
+
from: 'parent' | 'orchestrator';
|
|
83
|
+
to: 'subagent';
|
|
84
|
+
type: 'instruction' | 'cancellation' | 'query';
|
|
85
|
+
content: string;
|
|
86
|
+
timestamp: Date;
|
|
87
|
+
}): Promise<void>;
|
|
88
|
+
}
|
|
@@ -0,0 +1,426 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Subagent Base Class
|
|
3
|
+
*
|
|
4
|
+
* Base class for all specialized subagents. Subagents are lightweight AI agents
|
|
5
|
+
* that focus on specific tasks (testing, documentation, refactoring, etc.) with
|
|
6
|
+
* limited tool access and shallow conversation history.
|
|
7
|
+
*/
|
|
8
|
+
import { EventEmitter } from 'events';
|
|
9
|
+
import { LLMClient } from '../llm/client.js';
|
|
10
|
+
import { SubagentRole, SubagentState } from './subagent-types.js';
|
|
11
|
+
// Import tools
|
|
12
|
+
import { BashTool } from '../tools/bash.js';
|
|
13
|
+
import { TextEditorTool } from '../tools/text-editor.js';
|
|
14
|
+
import { SearchTool } from '../tools/search.js';
|
|
15
|
+
/**
|
|
16
|
+
* Base Subagent class
|
|
17
|
+
*/
|
|
18
|
+
export class Subagent extends EventEmitter {
|
|
19
|
+
id;
|
|
20
|
+
role;
|
|
21
|
+
config;
|
|
22
|
+
llmClient;
|
|
23
|
+
chatHistory;
|
|
24
|
+
messages;
|
|
25
|
+
tools;
|
|
26
|
+
isActive;
|
|
27
|
+
currentTaskId;
|
|
28
|
+
status;
|
|
29
|
+
constructor(role, configOverrides) {
|
|
30
|
+
super();
|
|
31
|
+
this.id = `${role}-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
32
|
+
this.role = role;
|
|
33
|
+
// Merge with default config for this role
|
|
34
|
+
const defaultConfig = this.getDefaultConfig(role);
|
|
35
|
+
this.config = { ...defaultConfig, ...configOverrides, role };
|
|
36
|
+
this.chatHistory = [];
|
|
37
|
+
this.messages = [];
|
|
38
|
+
this.tools = new Map();
|
|
39
|
+
this.isActive = false;
|
|
40
|
+
this.currentTaskId = null;
|
|
41
|
+
// Initialize status
|
|
42
|
+
this.status = {
|
|
43
|
+
id: this.id,
|
|
44
|
+
taskId: '',
|
|
45
|
+
role: this.role,
|
|
46
|
+
state: SubagentState.PENDING,
|
|
47
|
+
progress: 0,
|
|
48
|
+
startTime: new Date(),
|
|
49
|
+
};
|
|
50
|
+
// Initialize LLM client with same settings as main agent
|
|
51
|
+
this.llmClient = new LLMClient(process.env.YOUR_API_KEY || '', process.env.GROK_MODEL || 'glm-4.6', process.env.GROK_BASE_URL);
|
|
52
|
+
// Initialize allowed tools
|
|
53
|
+
this.initializeTools();
|
|
54
|
+
// Set system prompt
|
|
55
|
+
this.messages.push({
|
|
56
|
+
role: 'system',
|
|
57
|
+
content: this.buildSystemPrompt(),
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Get default configuration for a role
|
|
62
|
+
*/
|
|
63
|
+
getDefaultConfig(role) {
|
|
64
|
+
// Default tools and settings based on role
|
|
65
|
+
const roleDefaults = {
|
|
66
|
+
[SubagentRole.GENERAL]: {
|
|
67
|
+
allowedTools: ['bash', 'text_editor', 'search'],
|
|
68
|
+
maxToolRounds: 30,
|
|
69
|
+
contextDepth: 20,
|
|
70
|
+
priority: 1,
|
|
71
|
+
},
|
|
72
|
+
[SubagentRole.TESTING]: {
|
|
73
|
+
allowedTools: ['bash', 'text_editor', 'search'],
|
|
74
|
+
maxToolRounds: 20,
|
|
75
|
+
contextDepth: 10,
|
|
76
|
+
priority: 2,
|
|
77
|
+
},
|
|
78
|
+
[SubagentRole.DOCUMENTATION]: {
|
|
79
|
+
allowedTools: ['text_editor', 'search'],
|
|
80
|
+
maxToolRounds: 15,
|
|
81
|
+
contextDepth: 20,
|
|
82
|
+
priority: 1,
|
|
83
|
+
},
|
|
84
|
+
[SubagentRole.REFACTORING]: {
|
|
85
|
+
allowedTools: ['bash', 'text_editor', 'search'],
|
|
86
|
+
maxToolRounds: 25,
|
|
87
|
+
contextDepth: 20,
|
|
88
|
+
priority: 2,
|
|
89
|
+
},
|
|
90
|
+
[SubagentRole.ANALYSIS]: {
|
|
91
|
+
allowedTools: ['bash', 'text_editor', 'search'],
|
|
92
|
+
maxToolRounds: 15,
|
|
93
|
+
contextDepth: 15,
|
|
94
|
+
priority: 3,
|
|
95
|
+
},
|
|
96
|
+
[SubagentRole.DEBUG]: {
|
|
97
|
+
allowedTools: ['bash', 'text_editor', 'search'],
|
|
98
|
+
maxToolRounds: 30,
|
|
99
|
+
contextDepth: 15,
|
|
100
|
+
priority: 3,
|
|
101
|
+
},
|
|
102
|
+
[SubagentRole.PERFORMANCE]: {
|
|
103
|
+
allowedTools: ['bash', 'search'],
|
|
104
|
+
maxToolRounds: 25,
|
|
105
|
+
contextDepth: 10,
|
|
106
|
+
priority: 2,
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
return {
|
|
110
|
+
role,
|
|
111
|
+
allowedTools: [],
|
|
112
|
+
maxToolRounds: 20,
|
|
113
|
+
contextDepth: 10,
|
|
114
|
+
priority: 1,
|
|
115
|
+
...roleDefaults[role],
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Initialize tools based on allowed tools in config
|
|
120
|
+
*/
|
|
121
|
+
initializeTools() {
|
|
122
|
+
const allowedTools = this.config.allowedTools;
|
|
123
|
+
if (allowedTools.includes('bash')) {
|
|
124
|
+
this.tools.set('bash', new BashTool());
|
|
125
|
+
}
|
|
126
|
+
if (allowedTools.includes('text_editor')) {
|
|
127
|
+
// TextEditorTool doesn't need parameters
|
|
128
|
+
this.tools.set('text_editor', new TextEditorTool());
|
|
129
|
+
}
|
|
130
|
+
if (allowedTools.includes('search')) {
|
|
131
|
+
this.tools.set('search', new SearchTool());
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Build system prompt for this subagent role
|
|
136
|
+
* Override in specialized subagent classes
|
|
137
|
+
*/
|
|
138
|
+
buildSystemPrompt() {
|
|
139
|
+
return this.config.customSystemPrompt || `You are a specialized ${this.role} agent.`;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Execute a task
|
|
143
|
+
*/
|
|
144
|
+
async executeTask(task) {
|
|
145
|
+
this.isActive = true;
|
|
146
|
+
this.currentTaskId = task.id;
|
|
147
|
+
const startTime = Date.now();
|
|
148
|
+
// Update status
|
|
149
|
+
this.status = {
|
|
150
|
+
id: this.id,
|
|
151
|
+
taskId: task.id,
|
|
152
|
+
role: this.role,
|
|
153
|
+
state: SubagentState.RUNNING,
|
|
154
|
+
progress: 0,
|
|
155
|
+
startTime: new Date(),
|
|
156
|
+
toolsUsed: [],
|
|
157
|
+
toolRoundsUsed: 0,
|
|
158
|
+
};
|
|
159
|
+
const result = {
|
|
160
|
+
id: this.id,
|
|
161
|
+
taskId: task.id,
|
|
162
|
+
role: this.role,
|
|
163
|
+
success: false,
|
|
164
|
+
output: '',
|
|
165
|
+
executionTime: 0,
|
|
166
|
+
status: this.status,
|
|
167
|
+
filesModified: [],
|
|
168
|
+
filesCreated: [],
|
|
169
|
+
toolCalls: [],
|
|
170
|
+
};
|
|
171
|
+
try {
|
|
172
|
+
// Emit both 'start' and 'task-started' for compatibility
|
|
173
|
+
this.emit('start', { taskId: task.id, role: this.role });
|
|
174
|
+
this.emit('task-started', { taskId: task.id, role: this.role });
|
|
175
|
+
// Add task context to messages
|
|
176
|
+
const contextPrompt = this.buildContextPrompt(task);
|
|
177
|
+
this.messages.push({
|
|
178
|
+
role: 'user',
|
|
179
|
+
content: contextPrompt,
|
|
180
|
+
});
|
|
181
|
+
// Add to chat history
|
|
182
|
+
this.chatHistory.push({
|
|
183
|
+
type: 'user',
|
|
184
|
+
content: contextPrompt,
|
|
185
|
+
timestamp: new Date(),
|
|
186
|
+
});
|
|
187
|
+
// Execute with tool rounds limit
|
|
188
|
+
let toolRounds = 0;
|
|
189
|
+
let isComplete = false;
|
|
190
|
+
while (toolRounds < this.config.maxToolRounds && !isComplete) {
|
|
191
|
+
const response = await this.llmClient.chat(this.messages, this.getToolDefinitions(), { stream: false });
|
|
192
|
+
if (!response.choices || response.choices.length === 0) {
|
|
193
|
+
throw new Error('No response from LLM');
|
|
194
|
+
}
|
|
195
|
+
const choice = response.choices[0];
|
|
196
|
+
const message = choice.message;
|
|
197
|
+
// Handle content
|
|
198
|
+
if (message.content) {
|
|
199
|
+
this.chatHistory.push({
|
|
200
|
+
type: 'assistant',
|
|
201
|
+
content: message.content,
|
|
202
|
+
timestamp: new Date(),
|
|
203
|
+
});
|
|
204
|
+
result.output = message.content;
|
|
205
|
+
this.emit('progress', {
|
|
206
|
+
taskId: task.id,
|
|
207
|
+
content: message.content,
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
// Handle tool calls
|
|
211
|
+
if (message.tool_calls && message.tool_calls.length > 0) {
|
|
212
|
+
this.messages.push({
|
|
213
|
+
role: 'assistant',
|
|
214
|
+
content: message.content || '',
|
|
215
|
+
tool_calls: message.tool_calls,
|
|
216
|
+
});
|
|
217
|
+
for (const toolCall of message.tool_calls) {
|
|
218
|
+
const toolResult = await this.executeToolCall(toolCall);
|
|
219
|
+
// Track tool usage in status
|
|
220
|
+
if (!this.status.toolsUsed) {
|
|
221
|
+
this.status.toolsUsed = [];
|
|
222
|
+
}
|
|
223
|
+
if (!this.status.toolsUsed.includes(toolCall.function.name)) {
|
|
224
|
+
this.status.toolsUsed.push(toolCall.function.name);
|
|
225
|
+
}
|
|
226
|
+
// Track tool calls
|
|
227
|
+
if (!result.toolCalls) {
|
|
228
|
+
result.toolCalls = [];
|
|
229
|
+
}
|
|
230
|
+
result.toolCalls.push(toolCall);
|
|
231
|
+
// Track files created/modified
|
|
232
|
+
if (toolCall.function.name === 'text_editor' && toolResult.success) {
|
|
233
|
+
try {
|
|
234
|
+
const args = JSON.parse(toolCall.function.arguments);
|
|
235
|
+
if (args.path) {
|
|
236
|
+
if (args.command === 'create') {
|
|
237
|
+
if (!result.filesCreated.includes(args.path)) {
|
|
238
|
+
result.filesCreated.push(args.path);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
else {
|
|
242
|
+
if (!result.filesModified.includes(args.path)) {
|
|
243
|
+
result.filesModified.push(args.path);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
catch {
|
|
249
|
+
// Ignore JSON parse errors for file tracking - non-critical
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
// Add tool result to messages
|
|
253
|
+
this.messages.push({
|
|
254
|
+
role: 'tool',
|
|
255
|
+
tool_call_id: toolCall.id,
|
|
256
|
+
content: toolResult.output || toolResult.error || '',
|
|
257
|
+
});
|
|
258
|
+
this.chatHistory.push({
|
|
259
|
+
type: 'tool_result',
|
|
260
|
+
content: toolResult.output || toolResult.error || '',
|
|
261
|
+
timestamp: new Date(),
|
|
262
|
+
toolCall: toolCall,
|
|
263
|
+
toolResult: toolResult,
|
|
264
|
+
});
|
|
265
|
+
this.emit('tool-executed', {
|
|
266
|
+
taskId: task.id,
|
|
267
|
+
toolName: toolCall.function.name,
|
|
268
|
+
result: toolResult,
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
toolRounds++;
|
|
272
|
+
this.status.toolRoundsUsed = toolRounds;
|
|
273
|
+
}
|
|
274
|
+
else {
|
|
275
|
+
// No more tool calls, task complete
|
|
276
|
+
isComplete = true;
|
|
277
|
+
}
|
|
278
|
+
// Check timeout
|
|
279
|
+
const elapsed = Date.now() - startTime;
|
|
280
|
+
if (this.config.timeout && elapsed > this.config.timeout) {
|
|
281
|
+
throw new Error(`Task timeout after ${elapsed}ms`);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
result.success = true;
|
|
285
|
+
result.executionTime = Date.now() - startTime;
|
|
286
|
+
this.status.state = SubagentState.COMPLETED;
|
|
287
|
+
this.status.endTime = new Date();
|
|
288
|
+
this.status.progress = 100;
|
|
289
|
+
result.status = { ...this.status };
|
|
290
|
+
this.emit('task-completed', { taskId: task.id, result });
|
|
291
|
+
}
|
|
292
|
+
catch (error) {
|
|
293
|
+
result.success = false;
|
|
294
|
+
result.error = error.message;
|
|
295
|
+
result.executionTime = Date.now() - startTime;
|
|
296
|
+
this.status.state = SubagentState.FAILED;
|
|
297
|
+
this.status.endTime = new Date();
|
|
298
|
+
this.status.error = error.message;
|
|
299
|
+
result.status = { ...this.status };
|
|
300
|
+
this.emit('task-failed', { taskId: task.id, error: error.message });
|
|
301
|
+
}
|
|
302
|
+
finally {
|
|
303
|
+
this.isActive = false;
|
|
304
|
+
this.currentTaskId = null;
|
|
305
|
+
}
|
|
306
|
+
return result;
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Build context prompt from task
|
|
310
|
+
*/
|
|
311
|
+
buildContextPrompt(task) {
|
|
312
|
+
let prompt = `Task: ${task.description}\n\n`;
|
|
313
|
+
if (task.context) {
|
|
314
|
+
prompt += `Context:\n`;
|
|
315
|
+
if (task.context.metadata?.workingDirectory) {
|
|
316
|
+
prompt += `- Working Directory: ${task.context.metadata.workingDirectory}\n`;
|
|
317
|
+
}
|
|
318
|
+
if (task.context.conversationHistory && task.context.conversationHistory.length > 0) {
|
|
319
|
+
prompt += `\nRecent conversation:\n`;
|
|
320
|
+
task.context.conversationHistory.slice(-5).forEach((entry) => {
|
|
321
|
+
prompt += `${entry.type}: ${entry.content.substring(0, 200)}\n`;
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
return prompt;
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* Execute a tool call
|
|
329
|
+
*/
|
|
330
|
+
async executeToolCall(toolCall) {
|
|
331
|
+
const toolName = toolCall.function.name;
|
|
332
|
+
const tool = this.tools.get(toolName);
|
|
333
|
+
if (!tool) {
|
|
334
|
+
return {
|
|
335
|
+
success: false,
|
|
336
|
+
error: `Tool '${toolName}' not available for ${this.role} agent`,
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
// Validate arguments exist before parsing
|
|
340
|
+
if (!toolCall.function.arguments || toolCall.function.arguments.trim() === '') {
|
|
341
|
+
return {
|
|
342
|
+
success: false,
|
|
343
|
+
error: `Tool '${toolName}' called with empty arguments`,
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
let args;
|
|
347
|
+
try {
|
|
348
|
+
args = JSON.parse(toolCall.function.arguments);
|
|
349
|
+
}
|
|
350
|
+
catch (parseError) {
|
|
351
|
+
return {
|
|
352
|
+
success: false,
|
|
353
|
+
error: `Failed to parse ${toolName} arguments: ${parseError.message}`,
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
try {
|
|
357
|
+
const result = await tool.execute(args);
|
|
358
|
+
return result;
|
|
359
|
+
}
|
|
360
|
+
catch (error) {
|
|
361
|
+
return {
|
|
362
|
+
success: false,
|
|
363
|
+
error: `Tool execution error in ${toolName}: ${error.message}`,
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* Get tool definitions for LLM
|
|
369
|
+
*/
|
|
370
|
+
getToolDefinitions() {
|
|
371
|
+
const definitions = [];
|
|
372
|
+
for (const [, tool] of this.tools) {
|
|
373
|
+
if (typeof tool.getToolDefinition === 'function') {
|
|
374
|
+
definitions.push(tool.getToolDefinition());
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
return definitions;
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* Get current status
|
|
381
|
+
*/
|
|
382
|
+
getStatus() {
|
|
383
|
+
return { ...this.status };
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* Abort execution
|
|
387
|
+
*/
|
|
388
|
+
abort() {
|
|
389
|
+
this.isActive = false;
|
|
390
|
+
this.status.state = SubagentState.CANCELLED;
|
|
391
|
+
this.status.endTime = new Date();
|
|
392
|
+
this.emit('cancel', { role: this.role });
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
395
|
+
* Terminate subagent
|
|
396
|
+
*/
|
|
397
|
+
async terminate() {
|
|
398
|
+
this.isActive = false;
|
|
399
|
+
this.currentTaskId = null;
|
|
400
|
+
this.removeAllListeners();
|
|
401
|
+
this.emit('terminated', { role: this.role });
|
|
402
|
+
}
|
|
403
|
+
/**
|
|
404
|
+
* Get chat history (for debugging/monitoring)
|
|
405
|
+
*/
|
|
406
|
+
getChatHistory() {
|
|
407
|
+
return [...this.chatHistory];
|
|
408
|
+
}
|
|
409
|
+
/**
|
|
410
|
+
* Get logs (alias for getChatHistory for test compatibility)
|
|
411
|
+
*/
|
|
412
|
+
getLogs() {
|
|
413
|
+
return [...this.chatHistory];
|
|
414
|
+
}
|
|
415
|
+
/**
|
|
416
|
+
* Receive a message from parent/orchestrator
|
|
417
|
+
*/
|
|
418
|
+
async receiveMessage(message) {
|
|
419
|
+
this.emit('message', message);
|
|
420
|
+
// Handle cancellation messages
|
|
421
|
+
if (message.type === 'cancellation') {
|
|
422
|
+
this.abort();
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
//# sourceMappingURL=subagent.js.map
|