@defai.digital/ax-cli 2.7.0 → 2.8.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.
Files changed (99) hide show
  1. package/.ax-cli/checkpoints/2025-11-20/checkpoint-2dd84869-e62d-46c8-9885-7e45f37f36e2.json +69 -0
  2. package/.ax-cli/checkpoints/2025-11-20/checkpoint-484dc350-353f-4808-9ed1-ebb3cefdab37.json +24 -0
  3. package/.ax-cli/checkpoints/2025-11-20/checkpoint-74a18b87-6172-4215-962b-44bb9f46a662.json +69 -0
  4. package/.ax-cli/checkpoints/2025-11-20/checkpoint-870a5fb9-6e82-4ff2-8ec8-af4c251cc514.json +44 -0
  5. package/.ax-cli/checkpoints/2025-11-20/checkpoint-93946601-0e83-456c-ba47-def9713124dd.json +24 -0
  6. package/.ax-cli/checkpoints/metadata.json +62 -0
  7. package/README.md +2 -2
  8. package/dist/agent/context-manager.d.ts +2 -2
  9. package/dist/agent/context-manager.js +28 -15
  10. package/dist/agent/context-manager.js.map +1 -1
  11. package/dist/agent/dependency-resolver.d.ts +83 -0
  12. package/dist/agent/dependency-resolver.js +302 -0
  13. package/dist/agent/dependency-resolver.js.map +1 -0
  14. package/dist/agent/llm-agent.d.ts +63 -0
  15. package/dist/agent/llm-agent.js +250 -0
  16. package/dist/agent/llm-agent.js.map +1 -1
  17. package/dist/agent/specialized/analysis-agent.d.ts +11 -0
  18. package/dist/agent/specialized/analysis-agent.js +33 -0
  19. package/dist/agent/specialized/analysis-agent.js.map +1 -0
  20. package/dist/agent/specialized/debug-agent.d.ts +11 -0
  21. package/dist/agent/specialized/debug-agent.js +33 -0
  22. package/dist/agent/specialized/debug-agent.js.map +1 -0
  23. package/dist/agent/specialized/documentation-agent.d.ts +11 -0
  24. package/dist/agent/specialized/documentation-agent.js +33 -0
  25. package/dist/agent/specialized/documentation-agent.js.map +1 -0
  26. package/dist/agent/specialized/index.d.ts +11 -0
  27. package/dist/agent/specialized/index.js +12 -0
  28. package/dist/agent/specialized/index.js.map +1 -0
  29. package/dist/agent/specialized/performance-agent.d.ts +11 -0
  30. package/dist/agent/specialized/performance-agent.js +33 -0
  31. package/dist/agent/specialized/performance-agent.js.map +1 -0
  32. package/dist/agent/specialized/refactoring-agent.d.ts +11 -0
  33. package/dist/agent/specialized/refactoring-agent.js +33 -0
  34. package/dist/agent/specialized/refactoring-agent.js.map +1 -0
  35. package/dist/agent/specialized/testing-agent.d.ts +11 -0
  36. package/dist/agent/specialized/testing-agent.js +33 -0
  37. package/dist/agent/specialized/testing-agent.js.map +1 -0
  38. package/dist/agent/subagent-orchestrator.d.ts +124 -0
  39. package/dist/agent/subagent-orchestrator.js +345 -0
  40. package/dist/agent/subagent-orchestrator.js.map +1 -0
  41. package/dist/agent/subagent-types.d.ts +262 -0
  42. package/dist/agent/subagent-types.js +152 -0
  43. package/dist/agent/subagent-types.js.map +1 -0
  44. package/dist/agent/subagent.d.ts +88 -0
  45. package/dist/agent/subagent.js +402 -0
  46. package/dist/agent/subagent.js.map +1 -0
  47. package/dist/checkpoint/index.d.ts +9 -0
  48. package/dist/checkpoint/index.js +11 -0
  49. package/dist/checkpoint/index.js.map +1 -0
  50. package/dist/checkpoint/manager.d.ts +99 -0
  51. package/dist/checkpoint/manager.js +281 -0
  52. package/dist/checkpoint/manager.js.map +1 -0
  53. package/dist/checkpoint/storage.d.ts +31 -0
  54. package/dist/checkpoint/storage.js +265 -0
  55. package/dist/checkpoint/storage.js.map +1 -0
  56. package/dist/checkpoint/types.d.ts +111 -0
  57. package/dist/checkpoint/types.js +17 -0
  58. package/dist/checkpoint/types.js.map +1 -0
  59. package/dist/commands/rewind.d.ts +19 -0
  60. package/dist/commands/rewind.js +221 -0
  61. package/dist/commands/rewind.js.map +1 -0
  62. package/dist/hooks/use-input-handler.js +24 -0
  63. package/dist/hooks/use-input-handler.js.map +1 -1
  64. package/dist/llm/client.js +2 -1
  65. package/dist/llm/client.js.map +1 -1
  66. package/dist/mcp/client.d.ts +1 -0
  67. package/dist/mcp/client.js +27 -12
  68. package/dist/mcp/client.js.map +1 -1
  69. package/dist/mcp/transports.d.ts +0 -1
  70. package/dist/mcp/transports.js +10 -7
  71. package/dist/mcp/transports.js.map +1 -1
  72. package/dist/schemas/api-schemas.js +4 -0
  73. package/dist/schemas/api-schemas.js.map +1 -1
  74. package/dist/tools/bash.js +26 -1
  75. package/dist/tools/bash.js.map +1 -1
  76. package/dist/tools/search.js +21 -9
  77. package/dist/tools/search.js.map +1 -1
  78. package/dist/tools/text-editor.d.ts +16 -0
  79. package/dist/tools/text-editor.js +33 -0
  80. package/dist/tools/text-editor.js.map +1 -1
  81. package/dist/ui/components/chat-interface.js +3 -2
  82. package/dist/ui/components/chat-interface.js.map +1 -1
  83. package/dist/ui/components/subagent-monitor.d.ts +29 -0
  84. package/dist/ui/components/subagent-monitor.js +150 -0
  85. package/dist/ui/components/subagent-monitor.js.map +1 -0
  86. package/dist/utils/history-manager.d.ts +1 -0
  87. package/dist/utils/history-manager.js +40 -5
  88. package/dist/utils/history-manager.js.map +1 -1
  89. package/dist/utils/json-utils.d.ts +7 -0
  90. package/dist/utils/json-utils.js +70 -2
  91. package/dist/utils/json-utils.js.map +1 -1
  92. package/dist/utils/settings-manager.js +12 -10
  93. package/dist/utils/settings-manager.js.map +1 -1
  94. package/dist/utils/text-utils.js +3 -3
  95. package/dist/utils/text-utils.js.map +1 -1
  96. package/dist/utils/token-counter.d.ts +5 -0
  97. package/dist/utils/token-counter.js +18 -3
  98. package/dist/utils/token-counter.js.map +1 -1
  99. package/package.json +2 -1
@@ -0,0 +1,262 @@
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
+ import type { LLMToolCall } from '../llm/client.js';
8
+ /**
9
+ * Types of specialized agents available
10
+ */
11
+ export declare enum SubagentRole {
12
+ /** General-purpose agent for any task */
13
+ GENERAL = "general",
14
+ /** Specialized in writing and running tests */
15
+ TESTING = "testing",
16
+ /** Specialized in generating documentation */
17
+ DOCUMENTATION = "documentation",
18
+ /** Specialized in code refactoring */
19
+ REFACTORING = "refactoring",
20
+ /** Specialized in code analysis and bug detection */
21
+ ANALYSIS = "analysis",
22
+ /** Specialized in debugging and error resolution */
23
+ DEBUG = "debug",
24
+ /** Specialized in performance optimization */
25
+ PERFORMANCE = "performance"
26
+ }
27
+ /**
28
+ * Chat entry (from llm-agent.ts to avoid circular dependency)
29
+ */
30
+ export interface ChatEntry {
31
+ type: 'user' | 'assistant' | 'tool_result' | 'tool_call';
32
+ content: string;
33
+ timestamp: Date;
34
+ toolCalls?: LLMToolCall[];
35
+ toolCall?: LLMToolCall;
36
+ toolResult?: {
37
+ success: boolean;
38
+ output?: string;
39
+ error?: string;
40
+ };
41
+ isStreaming?: boolean;
42
+ reasoningContent?: string;
43
+ isReasoningStreaming?: boolean;
44
+ }
45
+ /**
46
+ * Configuration for creating a subagent
47
+ */
48
+ export interface SubagentConfig {
49
+ /** Role/specialization of the subagent */
50
+ role: SubagentRole;
51
+ /** Tools this subagent is allowed to use */
52
+ allowedTools: string[];
53
+ /** Maximum tool execution rounds */
54
+ maxToolRounds: number;
55
+ /** Number of conversation messages to include as context */
56
+ contextDepth: number;
57
+ /** Custom system prompt (overrides role-based prompt) */
58
+ customSystemPrompt?: string;
59
+ /** Execution timeout in milliseconds */
60
+ timeout?: number;
61
+ /** Priority level (higher = executed first) */
62
+ priority?: number;
63
+ }
64
+ /**
65
+ * Task to be executed by a subagent
66
+ */
67
+ export interface SubagentTask {
68
+ /** Unique task identifier */
69
+ id: string;
70
+ /** Human-readable task description */
71
+ description: string;
72
+ /** Subagent role to use for this task */
73
+ role: SubagentRole;
74
+ /** Priority level (higher = executed first) */
75
+ priority: number;
76
+ /** Context to provide to the subagent */
77
+ context: SubagentContext;
78
+ /** IDs of tasks that must complete before this one */
79
+ dependencies?: string[];
80
+ /** Maximum tool rounds for this task */
81
+ maxToolRounds?: number;
82
+ /** Timeout in milliseconds */
83
+ timeout?: number;
84
+ }
85
+ /**
86
+ * Context provided to a subagent
87
+ */
88
+ export interface SubagentContext {
89
+ /** File paths to include in context */
90
+ files?: string[];
91
+ /** Code snippets to include */
92
+ codeSnippets?: CodeSnippet[];
93
+ /** Relevant conversation history */
94
+ conversationHistory?: ChatEntry[];
95
+ /** Additional metadata */
96
+ metadata?: Record<string, unknown>;
97
+ }
98
+ /**
99
+ * Code snippet for context
100
+ */
101
+ export interface CodeSnippet {
102
+ /** File path this snippet is from */
103
+ path: string;
104
+ /** The code content */
105
+ content: string;
106
+ /** Programming language */
107
+ language: string;
108
+ /** Starting line number */
109
+ startLine?: number;
110
+ /** Ending line number */
111
+ endLine?: number;
112
+ }
113
+ /**
114
+ * Execution state of a subagent
115
+ */
116
+ export declare enum SubagentState {
117
+ /** Waiting to be started */
118
+ PENDING = "pending",
119
+ /** Currently executing */
120
+ RUNNING = "running",
121
+ /** Successfully completed */
122
+ COMPLETED = "completed",
123
+ /** Failed with error */
124
+ FAILED = "failed",
125
+ /** Cancelled by user or system */
126
+ CANCELLED = "cancelled"
127
+ }
128
+ /**
129
+ * Status information for a subagent
130
+ */
131
+ export interface SubagentStatus {
132
+ /** Subagent unique identifier */
133
+ id: string;
134
+ /** Task being executed */
135
+ taskId: string;
136
+ /** Subagent role */
137
+ role: SubagentRole;
138
+ /** Current execution state */
139
+ state: SubagentState;
140
+ /** Progress percentage (0-100) */
141
+ progress: number;
142
+ /** When execution started */
143
+ startTime: Date;
144
+ /** When execution ended (if completed/failed) */
145
+ endTime?: Date;
146
+ /** Error message if failed */
147
+ error?: string;
148
+ /** Current action being performed */
149
+ currentAction?: string;
150
+ /** Tools used so far */
151
+ toolsUsed?: string[];
152
+ /** Number of tool rounds used */
153
+ toolRoundsUsed?: number;
154
+ }
155
+ /**
156
+ * Result of subagent execution
157
+ */
158
+ export interface SubagentResult {
159
+ /** Subagent identifier */
160
+ id: string;
161
+ /** Task identifier */
162
+ taskId: string;
163
+ /** Subagent role */
164
+ role: SubagentRole;
165
+ /** Whether execution was successful */
166
+ success: boolean;
167
+ /** Output/response from the subagent */
168
+ output: string;
169
+ /** Files modified */
170
+ filesModified?: string[];
171
+ /** Files created */
172
+ filesCreated?: string[];
173
+ /** Tool calls made during execution */
174
+ toolCalls?: LLMToolCall[];
175
+ /** Error message if failed */
176
+ error?: string;
177
+ /** Execution time in milliseconds */
178
+ executionTime: number;
179
+ /** Final status */
180
+ status: SubagentStatus;
181
+ /** Artifacts produced (file paths, URLs, etc) */
182
+ artifacts?: string[];
183
+ }
184
+ /**
185
+ * Message sent to/from a subagent
186
+ */
187
+ export interface SubagentMessage {
188
+ /** Message sender */
189
+ from: 'parent' | 'subagent';
190
+ /** Message recipient */
191
+ to: 'parent' | 'subagent';
192
+ /** Message type */
193
+ type: 'instruction' | 'progress' | 'result' | 'error' | 'cancellation';
194
+ /** Message content */
195
+ content: string;
196
+ /** Timestamp */
197
+ timestamp: Date;
198
+ /** Additional data */
199
+ data?: unknown;
200
+ }
201
+ /**
202
+ * Event emitted by subagent system
203
+ */
204
+ export interface SubagentEvent {
205
+ /** Event type */
206
+ type: 'spawn' | 'start' | 'progress' | 'complete' | 'fail' | 'cancel';
207
+ /** Subagent ID */
208
+ subagentId: string;
209
+ /** Task ID */
210
+ taskId: string;
211
+ /** Event data */
212
+ data?: unknown;
213
+ /** Timestamp */
214
+ timestamp: Date;
215
+ }
216
+ /**
217
+ * Configuration for subagent orchestrator
218
+ */
219
+ export interface OrchestratorConfig {
220
+ /** Maximum concurrent subagents */
221
+ maxConcurrentAgents: number;
222
+ /** Default timeout for subagents */
223
+ defaultTimeout: number;
224
+ /** Enable automatic checkpoint before spawning */
225
+ autoCheckpoint: boolean;
226
+ /** Enable detailed logging */
227
+ verbose: boolean;
228
+ }
229
+ /**
230
+ * Dependency graph node
231
+ */
232
+ export interface DependencyNode {
233
+ /** Task ID */
234
+ taskId: string;
235
+ /** Tasks this depends on */
236
+ dependencies: string[];
237
+ /** Tasks that depend on this */
238
+ dependents: string[];
239
+ /** Execution level (0 = no dependencies) */
240
+ level: number;
241
+ }
242
+ /**
243
+ * Dependency graph
244
+ */
245
+ export interface DependencyGraph {
246
+ /** All nodes in the graph */
247
+ nodes: Map<string, DependencyNode>;
248
+ /** Execution order (batches that can run in parallel) */
249
+ executionOrder: string[][];
250
+ /** Whether graph has cycles */
251
+ hasCycles: boolean;
252
+ /** Cycle details if any */
253
+ cycles?: string[][];
254
+ }
255
+ /**
256
+ * Default subagent configuration by role
257
+ */
258
+ export declare const DEFAULT_SUBAGENT_CONFIG: Record<SubagentRole, Partial<SubagentConfig>>;
259
+ /**
260
+ * System prompts for each subagent role
261
+ */
262
+ export declare const SUBAGENT_SYSTEM_PROMPTS: Record<SubagentRole, string>;
@@ -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,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AAY,CAAC,WAAW,CAAC,EAAE;;;;;;;;iCAQG;CAChC,CAAC"}
@@ -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
+ }