@defai.digital/ax-cli 2.8.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/README.md +85 -9
- package/dist/agent/context-manager.js +9 -0
- package/dist/agent/context-manager.js.map +1 -1
- package/dist/agent/dependency-resolver.js +13 -5
- package/dist/agent/dependency-resolver.js.map +1 -1
- package/dist/agent/llm-agent.d.ts +48 -0
- package/dist/agent/llm-agent.js +375 -3
- package/dist/agent/llm-agent.js.map +1 -1
- package/dist/agent/subagent-orchestrator.d.ts +4 -0
- package/dist/agent/subagent-orchestrator.js +54 -11
- package/dist/agent/subagent-orchestrator.js.map +1 -1
- package/dist/agent/subagent.js +35 -11
- package/dist/agent/subagent.js.map +1 -1
- 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/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 +270 -2
- package/dist/hooks/use-input-handler.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.js +19 -12
- package/dist/mcp/client.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/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 -67
- package/dist/tools/bash.js.map +1 -1
- package/dist/tools/search.js +15 -2
- package/dist/tools/search.js.map +1 -1
- package/dist/tools/text-editor.js +4 -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 +152 -44
- 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/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/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/package.json +2 -1
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Multi-Phase Task Planning System - Type Definitions
|
|
3
|
+
*
|
|
4
|
+
* Defines the core data structures for task decomposition,
|
|
5
|
+
* phase execution, and plan persistence.
|
|
6
|
+
*/
|
|
7
|
+
import { z } from "zod";
|
|
8
|
+
// ============================================================================
|
|
9
|
+
// Enums
|
|
10
|
+
// ============================================================================
|
|
11
|
+
/**
|
|
12
|
+
* Risk level for a phase - determines approval requirements
|
|
13
|
+
*/
|
|
14
|
+
export var RiskLevel;
|
|
15
|
+
(function (RiskLevel) {
|
|
16
|
+
RiskLevel["LOW"] = "low";
|
|
17
|
+
RiskLevel["MEDIUM"] = "medium";
|
|
18
|
+
RiskLevel["HIGH"] = "high";
|
|
19
|
+
})(RiskLevel || (RiskLevel = {}));
|
|
20
|
+
/**
|
|
21
|
+
* Fallback strategy when a phase fails
|
|
22
|
+
*/
|
|
23
|
+
export var FallbackStrategy;
|
|
24
|
+
(function (FallbackStrategy) {
|
|
25
|
+
FallbackStrategy["RETRY"] = "retry";
|
|
26
|
+
FallbackStrategy["SKIP"] = "skip";
|
|
27
|
+
FallbackStrategy["ABORT"] = "abort";
|
|
28
|
+
})(FallbackStrategy || (FallbackStrategy = {}));
|
|
29
|
+
/**
|
|
30
|
+
* Status of an individual phase
|
|
31
|
+
*/
|
|
32
|
+
export var PhaseStatus;
|
|
33
|
+
(function (PhaseStatus) {
|
|
34
|
+
PhaseStatus["PENDING"] = "pending";
|
|
35
|
+
PhaseStatus["APPROVED"] = "approved";
|
|
36
|
+
PhaseStatus["QUEUED"] = "queued";
|
|
37
|
+
PhaseStatus["EXECUTING"] = "executing";
|
|
38
|
+
PhaseStatus["COMPLETED"] = "completed";
|
|
39
|
+
PhaseStatus["FAILED"] = "failed";
|
|
40
|
+
PhaseStatus["SKIPPED"] = "skipped";
|
|
41
|
+
PhaseStatus["CANCELLED"] = "cancelled";
|
|
42
|
+
})(PhaseStatus || (PhaseStatus = {}));
|
|
43
|
+
/**
|
|
44
|
+
* Status of the overall plan
|
|
45
|
+
*/
|
|
46
|
+
export var PlanStatus;
|
|
47
|
+
(function (PlanStatus) {
|
|
48
|
+
PlanStatus["CREATED"] = "created";
|
|
49
|
+
PlanStatus["APPROVED"] = "approved";
|
|
50
|
+
PlanStatus["EXECUTING"] = "executing";
|
|
51
|
+
PlanStatus["PAUSED"] = "paused";
|
|
52
|
+
PlanStatus["COMPLETED"] = "completed";
|
|
53
|
+
PlanStatus["FAILED"] = "failed";
|
|
54
|
+
PlanStatus["ABANDONED"] = "abandoned";
|
|
55
|
+
})(PlanStatus || (PlanStatus = {}));
|
|
56
|
+
// ============================================================================
|
|
57
|
+
// Zod Schemas for Runtime Validation
|
|
58
|
+
// ============================================================================
|
|
59
|
+
export const RiskLevelSchema = z.nativeEnum(RiskLevel);
|
|
60
|
+
export const FallbackStrategySchema = z.nativeEnum(FallbackStrategy);
|
|
61
|
+
export const PhaseStatusSchema = z.nativeEnum(PhaseStatus);
|
|
62
|
+
export const PlanStatusSchema = z.nativeEnum(PlanStatus);
|
|
63
|
+
export const TaskPhaseSchema = z.object({
|
|
64
|
+
id: z.string(),
|
|
65
|
+
index: z.number(),
|
|
66
|
+
name: z.string(),
|
|
67
|
+
description: z.string(),
|
|
68
|
+
objectives: z.array(z.string()),
|
|
69
|
+
toolsRequired: z.array(z.string()),
|
|
70
|
+
dependencies: z.array(z.string()),
|
|
71
|
+
canRunInParallel: z.boolean(),
|
|
72
|
+
riskLevel: RiskLevelSchema,
|
|
73
|
+
requiresApproval: z.boolean(),
|
|
74
|
+
fallbackStrategy: FallbackStrategySchema,
|
|
75
|
+
maxRetries: z.number().default(3),
|
|
76
|
+
status: PhaseStatusSchema,
|
|
77
|
+
startedAt: z.date().optional(),
|
|
78
|
+
completedAt: z.date().optional(),
|
|
79
|
+
duration: z.number().optional(),
|
|
80
|
+
checkpointId: z.string().optional(),
|
|
81
|
+
retryCount: z.number().default(0),
|
|
82
|
+
output: z.string().optional(),
|
|
83
|
+
error: z.string().optional(),
|
|
84
|
+
tokensUsed: z.number().optional(),
|
|
85
|
+
filesModified: z.array(z.string()).optional(),
|
|
86
|
+
});
|
|
87
|
+
export const TaskPlanSchema = z.object({
|
|
88
|
+
id: z.string(),
|
|
89
|
+
version: z.number(),
|
|
90
|
+
originalPrompt: z.string(),
|
|
91
|
+
reasoning: z.string(),
|
|
92
|
+
complexity: z.enum(["simple", "moderate", "complex"]),
|
|
93
|
+
phases: z.array(TaskPhaseSchema),
|
|
94
|
+
currentPhaseIndex: z.number(),
|
|
95
|
+
status: PlanStatusSchema,
|
|
96
|
+
createdAt: z.date(),
|
|
97
|
+
updatedAt: z.date(),
|
|
98
|
+
estimatedTotalTokens: z.number(),
|
|
99
|
+
estimatedDuration: z.number(),
|
|
100
|
+
initialCheckpointId: z.string().optional(),
|
|
101
|
+
totalTokensUsed: z.number().default(0),
|
|
102
|
+
actualDuration: z.number().default(0),
|
|
103
|
+
phasesCompleted: z.number().default(0),
|
|
104
|
+
phasesFailed: z.number().default(0),
|
|
105
|
+
phasesSkipped: z.number().default(0),
|
|
106
|
+
});
|
|
107
|
+
export const PhaseResultSchema = z.object({
|
|
108
|
+
phaseId: z.string(),
|
|
109
|
+
success: z.boolean(),
|
|
110
|
+
output: z.string().optional(),
|
|
111
|
+
error: z.string().optional(),
|
|
112
|
+
duration: z.number(),
|
|
113
|
+
tokensUsed: z.number(),
|
|
114
|
+
filesModified: z.array(z.string()),
|
|
115
|
+
checkpointId: z.string().optional(),
|
|
116
|
+
wasRetry: z.boolean(),
|
|
117
|
+
retryAttempt: z.number(),
|
|
118
|
+
});
|
|
119
|
+
// ============================================================================
|
|
120
|
+
// LLM Response Schemas (for parsing plan generation)
|
|
121
|
+
// ============================================================================
|
|
122
|
+
/**
|
|
123
|
+
* Schema for LLM-generated phase (before adding execution state)
|
|
124
|
+
*/
|
|
125
|
+
export const LLMPhaseResponseSchema = z.object({
|
|
126
|
+
name: z.string(),
|
|
127
|
+
description: z.string(),
|
|
128
|
+
objectives: z.array(z.string()),
|
|
129
|
+
toolsRequired: z.array(z.string()).default([]),
|
|
130
|
+
dependencies: z.array(z.string()).default([]),
|
|
131
|
+
canRunInParallel: z.boolean().default(false),
|
|
132
|
+
riskLevel: z.enum(["low", "medium", "high"]).default("low"),
|
|
133
|
+
requiresApproval: z.boolean().default(false),
|
|
134
|
+
});
|
|
135
|
+
/**
|
|
136
|
+
* Schema for LLM-generated plan response
|
|
137
|
+
*/
|
|
138
|
+
export const LLMPlanResponseSchema = z.object({
|
|
139
|
+
reasoning: z.string(),
|
|
140
|
+
complexity: z.enum(["simple", "moderate", "complex"]),
|
|
141
|
+
phases: z.array(LLMPhaseResponseSchema),
|
|
142
|
+
});
|
|
143
|
+
// ============================================================================
|
|
144
|
+
// Factory Functions
|
|
145
|
+
// ============================================================================
|
|
146
|
+
/**
|
|
147
|
+
* Create a new TaskPhase with defaults
|
|
148
|
+
*/
|
|
149
|
+
export function createPhase(partial) {
|
|
150
|
+
return {
|
|
151
|
+
objectives: [],
|
|
152
|
+
toolsRequired: [],
|
|
153
|
+
dependencies: [],
|
|
154
|
+
canRunInParallel: false,
|
|
155
|
+
riskLevel: RiskLevel.LOW,
|
|
156
|
+
requiresApproval: false,
|
|
157
|
+
fallbackStrategy: FallbackStrategy.ABORT,
|
|
158
|
+
maxRetries: 3,
|
|
159
|
+
status: PhaseStatus.PENDING,
|
|
160
|
+
retryCount: 0,
|
|
161
|
+
...partial,
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Create a new TaskPlan with defaults
|
|
166
|
+
*/
|
|
167
|
+
export function createPlan(partial) {
|
|
168
|
+
const now = new Date();
|
|
169
|
+
return {
|
|
170
|
+
version: 1,
|
|
171
|
+
reasoning: "",
|
|
172
|
+
complexity: "moderate",
|
|
173
|
+
currentPhaseIndex: -1,
|
|
174
|
+
status: PlanStatus.CREATED,
|
|
175
|
+
createdAt: now,
|
|
176
|
+
updatedAt: now,
|
|
177
|
+
estimatedTotalTokens: 0,
|
|
178
|
+
estimatedDuration: 0,
|
|
179
|
+
totalTokensUsed: 0,
|
|
180
|
+
actualDuration: 0,
|
|
181
|
+
phasesCompleted: 0,
|
|
182
|
+
phasesFailed: 0,
|
|
183
|
+
phasesSkipped: 0,
|
|
184
|
+
...partial,
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Create default execution options
|
|
189
|
+
*/
|
|
190
|
+
export function createDefaultExecutionOptions() {
|
|
191
|
+
return {
|
|
192
|
+
autoApprove: false,
|
|
193
|
+
autoApproveLowRisk: false,
|
|
194
|
+
createCheckpoints: true,
|
|
195
|
+
pruneContextBetweenPhases: true,
|
|
196
|
+
targetContextPercentage: 50,
|
|
197
|
+
maxParallelPhases: 5,
|
|
198
|
+
phaseTimeoutMs: 600000, // 10 minutes
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Create default planner options
|
|
203
|
+
*/
|
|
204
|
+
export function createDefaultPlannerOptions() {
|
|
205
|
+
return {
|
|
206
|
+
maxPhases: 10,
|
|
207
|
+
autoPlanThreshold: 3,
|
|
208
|
+
requirePlanApproval: true,
|
|
209
|
+
requireHighRiskApproval: true,
|
|
210
|
+
defaultExecutionOptions: createDefaultExecutionOptions(),
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/planner/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,+EAA+E;AAC/E,QAAQ;AACR,+EAA+E;AAE/E;;GAEG;AACH,MAAM,CAAN,IAAY,SAIX;AAJD,WAAY,SAAS;IACnB,wBAAW,CAAA;IACX,8BAAiB,CAAA;IACjB,0BAAa,CAAA;AACf,CAAC,EAJW,SAAS,KAAT,SAAS,QAIpB;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IAAI;QAC/B,uBAAuB,EAAE,EAAE;QAC3B,iBAAiB,EAAE,CAAC;QACpB,cAAc,EAAE,MAAM,EAAE,aAAa;KACtC,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,2BAA2B;IACzC,OAAO;QACL,SAAS,EAAE,EAAE;QACb,iBAAiB,EAAE,CAAC;QACpB,mBAAmB,EAAE,IAAI;QACzB,uBAAuB,EAAE,IAAI;QAC7B,uBAAuB,EAAE,6BAA6B,EAAE;KACzD,CAAC;AACJ,CAAC"}
|
|
@@ -58,3 +58,8 @@ export declare function safeValidateConfirmationOptions(data: unknown): {
|
|
|
58
58
|
error?: z.ZodError;
|
|
59
59
|
};
|
|
60
60
|
export declare function validateConfirmationResult(data: unknown): ConfirmationResult;
|
|
61
|
+
export declare function safeValidateConfirmationResult(data: unknown): {
|
|
62
|
+
success: boolean;
|
|
63
|
+
data?: ConfirmationResult;
|
|
64
|
+
error?: z.ZodError;
|
|
65
|
+
};
|
|
@@ -38,4 +38,11 @@ export function safeValidateConfirmationOptions(data) {
|
|
|
38
38
|
export function validateConfirmationResult(data) {
|
|
39
39
|
return ConfirmationResultSchema.parse(data);
|
|
40
40
|
}
|
|
41
|
+
export function safeValidateConfirmationResult(data) {
|
|
42
|
+
const result = ConfirmationResultSchema.safeParse(data);
|
|
43
|
+
if (result.success) {
|
|
44
|
+
return { success: true, data: result.data };
|
|
45
|
+
}
|
|
46
|
+
return { success: false, error: result.error };
|
|
47
|
+
}
|
|
41
48
|
//# sourceMappingURL=confirmation-schemas.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"confirmation-schemas.js","sourceRoot":"","sources":["../../src/schemas/confirmation-schemas.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,8BAA8B;AAC9B,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,CAAC,MAAM,CAAC;IAChD,SAAS,EAA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BAAyB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AAC/C,CAAC;AAED,MAAM,UAAU,+BAA+B,CAAC,IAAa;IAK3D,MAAM,MAAM,GAAG,yBAAyB,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IACzD,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;QACnB,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC;IAC9C,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC;AACjD,CAAC;AAED,MAAM,UAAU,0BAA0B,CAAC,IAAa;IACtD,OAAO,wBAAwB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AAC9C,CAAC;AAED,MAAM,UAAU,8BAA8B,CAAC,IAAa;IAK1D,MAAM,MAAM,GAAG,wBAAwB,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IACxD,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;QACnB,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC;IAC9C,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC;AACjD,CAAC"}
|
package/dist/schemas/index.d.ts
CHANGED
|
@@ -94,16 +94,16 @@ export declare const ProjectTemplateSchema: z.ZodObject<{
|
|
|
94
94
|
description: string;
|
|
95
95
|
id: string;
|
|
96
96
|
version: string;
|
|
97
|
+
createdAt: string;
|
|
98
|
+
projectType: string;
|
|
97
99
|
metadata: {
|
|
98
100
|
scripts?: Record<string, string> | undefined;
|
|
99
101
|
directories?: Record<string, string> | undefined;
|
|
100
102
|
conventions?: Record<string, string> | undefined;
|
|
101
103
|
keyFiles?: string[] | undefined;
|
|
102
104
|
};
|
|
103
|
-
projectType: string;
|
|
104
105
|
tags: string[];
|
|
105
106
|
instructions: string;
|
|
106
|
-
createdAt: string;
|
|
107
107
|
isBuiltIn: boolean;
|
|
108
108
|
author?: string | undefined;
|
|
109
109
|
}, {
|
|
@@ -111,16 +111,16 @@ export declare const ProjectTemplateSchema: z.ZodObject<{
|
|
|
111
111
|
description: string;
|
|
112
112
|
id: string;
|
|
113
113
|
version: string;
|
|
114
|
+
createdAt: string;
|
|
115
|
+
projectType: string;
|
|
114
116
|
metadata: {
|
|
115
117
|
scripts?: Record<string, string> | undefined;
|
|
116
118
|
directories?: Record<string, string> | undefined;
|
|
117
119
|
conventions?: Record<string, string> | undefined;
|
|
118
120
|
keyFiles?: string[] | undefined;
|
|
119
121
|
};
|
|
120
|
-
projectType: string;
|
|
121
122
|
tags: string[];
|
|
122
123
|
instructions: string;
|
|
123
|
-
createdAt: string;
|
|
124
124
|
isBuiltIn: boolean;
|
|
125
125
|
author?: string | undefined;
|
|
126
126
|
}>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ToolResult } from '../types/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* BashOutputTool - Retrieve output from background tasks
|
|
4
|
+
*
|
|
5
|
+
* This tool allows the AI agent to check on and retrieve output
|
|
6
|
+
* from commands that were run in the background.
|
|
7
|
+
*/
|
|
8
|
+
export declare class BashOutputTool {
|
|
9
|
+
private backgroundTaskManager;
|
|
10
|
+
/**
|
|
11
|
+
* Get output from a background task
|
|
12
|
+
* @param taskId The background task ID
|
|
13
|
+
* @param wait Whether to wait for the task to complete (default: false)
|
|
14
|
+
* @param timeoutMs Maximum time to wait in milliseconds (default: 30000)
|
|
15
|
+
*/
|
|
16
|
+
execute(taskId: string, wait?: boolean, timeoutMs?: number): Promise<ToolResult>;
|
|
17
|
+
/**
|
|
18
|
+
* List all background tasks
|
|
19
|
+
*/
|
|
20
|
+
listTasks(): ToolResult;
|
|
21
|
+
/**
|
|
22
|
+
* Kill a background task
|
|
23
|
+
*/
|
|
24
|
+
killTask(taskId: string): ToolResult;
|
|
25
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { getBackgroundTaskManager } from '../utils/background-task-manager.js';
|
|
2
|
+
/**
|
|
3
|
+
* BashOutputTool - Retrieve output from background tasks
|
|
4
|
+
*
|
|
5
|
+
* This tool allows the AI agent to check on and retrieve output
|
|
6
|
+
* from commands that were run in the background.
|
|
7
|
+
*/
|
|
8
|
+
export class BashOutputTool {
|
|
9
|
+
backgroundTaskManager = getBackgroundTaskManager();
|
|
10
|
+
/**
|
|
11
|
+
* Get output from a background task
|
|
12
|
+
* @param taskId The background task ID
|
|
13
|
+
* @param wait Whether to wait for the task to complete (default: false)
|
|
14
|
+
* @param timeoutMs Maximum time to wait in milliseconds (default: 30000)
|
|
15
|
+
*/
|
|
16
|
+
async execute(taskId, wait = false, timeoutMs = 30000) {
|
|
17
|
+
if (!taskId) {
|
|
18
|
+
return {
|
|
19
|
+
success: false,
|
|
20
|
+
error: 'Task ID is required'
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
try {
|
|
24
|
+
let output;
|
|
25
|
+
if (wait) {
|
|
26
|
+
// Wait for task to complete
|
|
27
|
+
output = await this.backgroundTaskManager.waitForTask(taskId, timeoutMs);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
output = this.backgroundTaskManager.getOutput(taskId);
|
|
31
|
+
}
|
|
32
|
+
if (!output) {
|
|
33
|
+
return {
|
|
34
|
+
success: false,
|
|
35
|
+
error: `Task not found: ${taskId}`
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
// Format output
|
|
39
|
+
const statusEmoji = {
|
|
40
|
+
'running': '🔄',
|
|
41
|
+
'completed': '✅',
|
|
42
|
+
'failed': '❌',
|
|
43
|
+
'killed': '🛑'
|
|
44
|
+
}[output.status] || '❓';
|
|
45
|
+
let result = `${statusEmoji} Task ${taskId}\n`;
|
|
46
|
+
result += `Status: ${output.status}`;
|
|
47
|
+
if (output.exitCode !== undefined && output.exitCode !== null) {
|
|
48
|
+
result += ` (exit code: ${output.exitCode})`;
|
|
49
|
+
}
|
|
50
|
+
result += '\n';
|
|
51
|
+
if (output.startTime) {
|
|
52
|
+
const elapsed = output.endTime
|
|
53
|
+
? Math.round((output.endTime.getTime() - output.startTime.getTime()) / 1000)
|
|
54
|
+
: Math.round((Date.now() - output.startTime.getTime()) / 1000);
|
|
55
|
+
result += `Duration: ${elapsed}s\n`;
|
|
56
|
+
}
|
|
57
|
+
result += '\n';
|
|
58
|
+
if (output.stdout) {
|
|
59
|
+
result += '--- STDOUT ---\n';
|
|
60
|
+
result += output.stdout;
|
|
61
|
+
result += '\n';
|
|
62
|
+
}
|
|
63
|
+
if (output.stderr) {
|
|
64
|
+
result += '--- STDERR ---\n';
|
|
65
|
+
result += output.stderr;
|
|
66
|
+
result += '\n';
|
|
67
|
+
}
|
|
68
|
+
if (!output.stdout && !output.stderr) {
|
|
69
|
+
result += '(No output yet)\n';
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
success: true,
|
|
73
|
+
output: result.trim()
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
return {
|
|
78
|
+
success: false,
|
|
79
|
+
error: `Failed to get task output: ${error.message}`
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* List all background tasks
|
|
85
|
+
*/
|
|
86
|
+
listTasks() {
|
|
87
|
+
const tasks = this.backgroundTaskManager.listTasks();
|
|
88
|
+
if (tasks.length === 0) {
|
|
89
|
+
return {
|
|
90
|
+
success: true,
|
|
91
|
+
output: 'No background tasks'
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
let result = `📋 Background Tasks (${tasks.length})\n\n`;
|
|
95
|
+
const statusEmoji = {
|
|
96
|
+
'running': '🔄',
|
|
97
|
+
'completed': '✅',
|
|
98
|
+
'failed': '❌',
|
|
99
|
+
'killed': '🛑'
|
|
100
|
+
};
|
|
101
|
+
for (const task of tasks) {
|
|
102
|
+
const emoji = statusEmoji[task.status] || '❓';
|
|
103
|
+
const elapsed = task.endTime
|
|
104
|
+
? Math.round((task.endTime.getTime() - task.startTime.getTime()) / 1000)
|
|
105
|
+
: Math.round((Date.now() - task.startTime.getTime()) / 1000);
|
|
106
|
+
result += `${emoji} ${task.id}\n`;
|
|
107
|
+
result += ` Command: ${task.command.length > 50 ? task.command.slice(0, 50) + '...' : task.command}\n`;
|
|
108
|
+
result += ` Status: ${task.status}`;
|
|
109
|
+
if (task.exitCode !== undefined && task.exitCode !== null) {
|
|
110
|
+
result += ` (exit: ${task.exitCode})`;
|
|
111
|
+
}
|
|
112
|
+
result += ` | Duration: ${elapsed}s\n`;
|
|
113
|
+
result += '\n';
|
|
114
|
+
}
|
|
115
|
+
return {
|
|
116
|
+
success: true,
|
|
117
|
+
output: result.trim()
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Kill a background task
|
|
122
|
+
*/
|
|
123
|
+
killTask(taskId) {
|
|
124
|
+
if (!taskId) {
|
|
125
|
+
return {
|
|
126
|
+
success: false,
|
|
127
|
+
error: 'Task ID is required'
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
const killed = this.backgroundTaskManager.kill(taskId);
|
|
131
|
+
if (killed) {
|
|
132
|
+
return {
|
|
133
|
+
success: true,
|
|
134
|
+
output: `🛑 Task ${taskId} has been killed`
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
return {
|
|
139
|
+
success: false,
|
|
140
|
+
error: `Could not kill task ${taskId}. It may not exist or is not running.`
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
//# sourceMappingURL=bash-output.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bash-output.js","sourceRoot":"","sources":["../../src/tools/bash-output.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAA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I,IAAI,CAAC,QAAQ,KAAK,IAAI,EAAE,CAAC;gBAC1D,MAAM,IAAI,WAAW,IAAI,CAAC,QAAQ,GAAG,CAAC;YACxC,CAAC;YACD,MAAM,IAAI,gBAAgB,OAAO,KAAK,CAAC;YACvC,MAAM,IAAI,IAAI,CAAC;QACjB,CAAC;QAED,OAAO;YACL,OAAO,EAAE,IAAI;YACb,MAAM,EAAE,MAAM,CAAC,IAAI,EAAE;SACtB,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,QAAQ,CAAC,MAAc;QACrB,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,KAAK,EAAE,qBAAqB;aAC7B,CAAC;QACJ,CAAC;QAED,MAAM,MAAM,GAAG,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAEvD,IAAI,MAAM,EAAE,CAAC;YACX,OAAO;gBACL,OAAO,EAAE,IAAI;gBACb,MAAM,EAAE,WAAW,MAAM,kBAAkB;aAC5C,CAAC;QACJ,CAAC;aAAM,CAAC;YACN,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,KAAK,EAAE,uBAAuB,MAAM,uCAAuC;aAC5E,CAAC;QACJ,CAAC;IACH,CAAC;CACF"}
|
package/dist/tools/bash.d.ts
CHANGED
|
@@ -1,10 +1,54 @@
|
|
|
1
1
|
import { ToolResult } from '../types/index.js';
|
|
2
|
-
|
|
2
|
+
import { EventEmitter } from 'events';
|
|
3
|
+
export interface BashExecuteOptions {
|
|
4
|
+
timeout?: number;
|
|
5
|
+
background?: boolean;
|
|
6
|
+
/** Abort signal to cancel execution or move to background */
|
|
7
|
+
signal?: AbortSignal;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Result when command is moved to background
|
|
11
|
+
*/
|
|
12
|
+
export interface BackgroundTransferResult {
|
|
13
|
+
movedToBackground: true;
|
|
14
|
+
taskId: string;
|
|
15
|
+
partialOutput: string;
|
|
16
|
+
}
|
|
17
|
+
export declare class BashTool extends EventEmitter {
|
|
3
18
|
private static readonly MAX_BUFFER_SIZE;
|
|
4
19
|
private static readonly DEFAULT_TIMEOUT;
|
|
5
20
|
private currentDirectory;
|
|
6
21
|
private confirmationService;
|
|
7
|
-
|
|
22
|
+
private backgroundTaskManager;
|
|
23
|
+
/** Currently running process (for Ctrl+B transfer) */
|
|
24
|
+
private currentProcess;
|
|
25
|
+
private currentCommand;
|
|
26
|
+
private currentOutput;
|
|
27
|
+
constructor();
|
|
28
|
+
/**
|
|
29
|
+
* Check if a command is currently executing
|
|
30
|
+
*/
|
|
31
|
+
isExecuting(): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Move the currently running command to background
|
|
34
|
+
* Returns task ID if successful, null if no command is running
|
|
35
|
+
*/
|
|
36
|
+
moveToBackground(): string | null;
|
|
37
|
+
/**
|
|
38
|
+
* Execute a bash command
|
|
39
|
+
* @param command The command to execute
|
|
40
|
+
* @param options Execution options (timeout, background, signal)
|
|
41
|
+
*/
|
|
42
|
+
execute(command: string, options?: BashExecuteOptions | number): Promise<ToolResult>;
|
|
43
|
+
/**
|
|
44
|
+
* Handle cd command separately (no spawn needed)
|
|
45
|
+
*/
|
|
46
|
+
private handleCdCommand;
|
|
47
|
+
/**
|
|
48
|
+
* Execute command using spawn (interruptible)
|
|
49
|
+
* Returns ToolResult normally, or BackgroundTransferResult if moved to background
|
|
50
|
+
*/
|
|
51
|
+
private executeWithSpawn;
|
|
8
52
|
getCurrentDirectory(): string;
|
|
9
53
|
listFiles(directory?: string): Promise<ToolResult>;
|
|
10
54
|
findFiles(pattern: string, directory?: string): Promise<ToolResult>;
|