erosolar-cli 2.1.238 → 2.1.239
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 +9 -0
- package/dist/contracts/tools.schema.json +3 -1
- package/dist/core/agent.d.ts.map +1 -1
- package/dist/core/agent.js +5 -1
- package/dist/core/agent.js.map +1 -1
- package/dist/core/agentOrchestrator.d.ts +4 -0
- package/dist/core/agentOrchestrator.d.ts.map +1 -1
- package/dist/core/agentOrchestrator.js +58 -6
- package/dist/core/agentOrchestrator.js.map +1 -1
- package/dist/core/autoExecutionOrchestrator.d.ts +172 -0
- package/dist/core/autoExecutionOrchestrator.d.ts.map +1 -0
- package/dist/core/autoExecutionOrchestrator.js +591 -0
- package/dist/core/autoExecutionOrchestrator.js.map +1 -0
- package/dist/core/contextManager.d.ts.map +1 -1
- package/dist/core/contextManager.js.map +1 -1
- package/dist/core/dualAgentOrchestrator.d.ts +34 -0
- package/dist/core/dualAgentOrchestrator.d.ts.map +1 -0
- package/dist/core/dualAgentOrchestrator.js +94 -0
- package/dist/core/dualAgentOrchestrator.js.map +1 -0
- package/dist/core/errors/safetyValidator.d.ts +25 -12
- package/dist/core/errors/safetyValidator.d.ts.map +1 -1
- package/dist/core/errors/safetyValidator.js +165 -17
- package/dist/core/errors/safetyValidator.js.map +1 -1
- package/dist/core/governmentProcedures.d.ts +118 -0
- package/dist/core/governmentProcedures.d.ts.map +1 -0
- package/dist/core/governmentProcedures.js +912 -0
- package/dist/core/governmentProcedures.js.map +1 -0
- package/dist/core/infrastructureTemplates.d.ts +123 -0
- package/dist/core/infrastructureTemplates.d.ts.map +1 -0
- package/dist/core/infrastructureTemplates.js +1326 -0
- package/dist/core/infrastructureTemplates.js.map +1 -0
- package/dist/core/orchestration.d.ts +534 -0
- package/dist/core/orchestration.d.ts.map +1 -0
- package/dist/core/orchestration.js +2009 -0
- package/dist/core/orchestration.js.map +1 -0
- package/dist/core/persistentObjectiveStore.d.ts +292 -0
- package/dist/core/persistentObjectiveStore.d.ts.map +1 -0
- package/dist/core/persistentObjectiveStore.js +613 -0
- package/dist/core/persistentObjectiveStore.js.map +1 -0
- package/dist/core/preferences.js +1 -1
- package/dist/core/preferences.js.map +1 -1
- package/dist/core/reliabilityPrompt.d.ts.map +1 -1
- package/dist/core/reliabilityPrompt.js +3 -0
- package/dist/core/reliabilityPrompt.js.map +1 -1
- package/dist/core/securityDeliverableGenerator.d.ts +292 -0
- package/dist/core/securityDeliverableGenerator.d.ts.map +1 -0
- package/dist/core/securityDeliverableGenerator.js +1590 -0
- package/dist/core/securityDeliverableGenerator.js.map +1 -0
- package/dist/core/taskCompletionDetector.d.ts.map +1 -1
- package/dist/core/taskCompletionDetector.js +4 -1
- package/dist/core/taskCompletionDetector.js.map +1 -1
- package/dist/shell/autoExecutor.d.ts.map +1 -1
- package/dist/shell/autoExecutor.js +32 -3
- package/dist/shell/autoExecutor.js.map +1 -1
- package/dist/shell/interactiveShell.d.ts +9 -0
- package/dist/shell/interactiveShell.d.ts.map +1 -1
- package/dist/shell/interactiveShell.js +282 -190
- package/dist/shell/interactiveShell.js.map +1 -1
- package/dist/tools/bashTools.d.ts +3 -5
- package/dist/tools/bashTools.d.ts.map +1 -1
- package/dist/tools/bashTools.js +259 -161
- package/dist/tools/bashTools.js.map +1 -1
- package/dist/tools/tao/index.d.ts +4 -4
- package/dist/tools/tao/index.d.ts.map +1 -1
- package/dist/tools/tao/index.js +15 -5
- package/dist/tools/tao/index.js.map +1 -1
- package/dist/tools/tao/rl.d.ts +164 -0
- package/dist/tools/tao/rl.d.ts.map +1 -0
- package/dist/tools/tao/rl.js +2998 -0
- package/dist/tools/tao/rl.js.map +1 -0
- package/dist/tools/taoTools.d.ts +2 -2
- package/dist/tools/taoTools.d.ts.map +1 -1
- package/dist/tools/taoTools.js +103 -20
- package/dist/tools/taoTools.js.map +1 -1
- package/dist/ui/PromptController.d.ts +3 -0
- package/dist/ui/PromptController.d.ts.map +1 -1
- package/dist/ui/PromptController.js +3 -0
- package/dist/ui/PromptController.js.map +1 -1
- package/dist/ui/UnifiedUIRenderer.d.ts +4 -0
- package/dist/ui/UnifiedUIRenderer.d.ts.map +1 -1
- package/dist/ui/UnifiedUIRenderer.js +37 -6
- package/dist/ui/UnifiedUIRenderer.js.map +1 -1
- package/dist/ui/display.d.ts +9 -1
- package/dist/ui/display.d.ts.map +1 -1
- package/dist/ui/display.js +66 -9
- package/dist/ui/display.js.map +1 -1
- package/dist/ui/shortcutsHelp.d.ts.map +1 -1
- package/dist/ui/shortcutsHelp.js +1 -0
- package/dist/ui/shortcutsHelp.js.map +1 -1
- package/package.json +3 -2
- package/dist/capabilities/askUserCapability.d.ts +0 -14
- package/dist/capabilities/askUserCapability.d.ts.map +0 -1
- package/dist/capabilities/askUserCapability.js +0 -134
- package/dist/capabilities/askUserCapability.js.map +0 -1
- package/dist/capabilities/codeGenerationCapability.d.ts +0 -13
- package/dist/capabilities/codeGenerationCapability.d.ts.map +0 -1
- package/dist/capabilities/codeGenerationCapability.js +0 -25
- package/dist/capabilities/codeGenerationCapability.js.map +0 -1
- package/dist/capabilities/performanceMonitoringCapability.d.ts +0 -108
- package/dist/capabilities/performanceMonitoringCapability.d.ts.map +0 -1
- package/dist/capabilities/performanceMonitoringCapability.js +0 -176
- package/dist/capabilities/performanceMonitoringCapability.js.map +0 -1
- package/dist/capabilities/todoCapability.d.ts +0 -19
- package/dist/capabilities/todoCapability.d.ts.map +0 -1
- package/dist/capabilities/todoCapability.js +0 -170
- package/dist/capabilities/todoCapability.js.map +0 -1
- package/dist/core/baseToolFactory.d.ts +0 -187
- package/dist/core/baseToolFactory.d.ts.map +0 -1
- package/dist/core/baseToolFactory.js +0 -352
- package/dist/core/baseToolFactory.js.map +0 -1
- package/dist/core/intelligentSummarizer.d.ts +0 -79
- package/dist/core/intelligentSummarizer.d.ts.map +0 -1
- package/dist/core/intelligentSummarizer.js +0 -273
- package/dist/core/intelligentSummarizer.js.map +0 -1
- package/dist/core/memorySystem.d.ts +0 -67
- package/dist/core/memorySystem.d.ts.map +0 -1
- package/dist/core/memorySystem.js +0 -334
- package/dist/core/memorySystem.js.map +0 -1
- package/dist/core/outputStyles.d.ts +0 -48
- package/dist/core/outputStyles.d.ts.map +0 -1
- package/dist/core/outputStyles.js +0 -270
- package/dist/core/outputStyles.js.map +0 -1
- package/dist/core/toolPatternAnalyzer.d.ts +0 -87
- package/dist/core/toolPatternAnalyzer.d.ts.map +0 -1
- package/dist/core/toolPatternAnalyzer.js +0 -272
- package/dist/core/toolPatternAnalyzer.js.map +0 -1
- package/dist/tools/backgroundBashTools.d.ts +0 -21
- package/dist/tools/backgroundBashTools.d.ts.map +0 -1
- package/dist/tools/backgroundBashTools.js +0 -215
- package/dist/tools/backgroundBashTools.js.map +0 -1
- package/dist/tools/code-quality-dashboard.d.ts +0 -57
- package/dist/tools/code-quality-dashboard.d.ts.map +0 -1
- package/dist/tools/code-quality-dashboard.js +0 -218
- package/dist/tools/code-quality-dashboard.js.map +0 -1
- package/dist/tools/tao/rlEngine.d.ts +0 -40
- package/dist/tools/tao/rlEngine.d.ts.map +0 -1
- package/dist/tools/tao/rlEngine.js +0 -237
- package/dist/tools/tao/rlEngine.js.map +0 -1
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Performance Monitoring Capability
|
|
3
|
-
*
|
|
4
|
-
* Provides tools for:
|
|
5
|
-
* - Viewing performance statistics
|
|
6
|
-
* - Analyzing tool execution patterns
|
|
7
|
-
* - Identifying performance bottlenecks
|
|
8
|
-
* - Debugging slow operations
|
|
9
|
-
*/
|
|
10
|
-
import { globalPerformanceMonitor } from '../core/performanceMonitor.js';
|
|
11
|
-
export const performanceMonitoringCapability = {
|
|
12
|
-
name: 'performance_monitoring',
|
|
13
|
-
description: 'Monitor and analyze tool execution performance',
|
|
14
|
-
tools: [
|
|
15
|
-
{
|
|
16
|
-
name: 'get_performance_stats',
|
|
17
|
-
description: 'Get comprehensive performance statistics for all tool executions',
|
|
18
|
-
parameters: {
|
|
19
|
-
type: 'object',
|
|
20
|
-
properties: {
|
|
21
|
-
clear_metrics: {
|
|
22
|
-
type: 'boolean',
|
|
23
|
-
description: 'Whether to clear metrics after retrieving stats (default: false)',
|
|
24
|
-
default: false,
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
handler: async (args) => {
|
|
29
|
-
const stats = globalPerformanceMonitor.getStats();
|
|
30
|
-
if (args.clear_metrics) {
|
|
31
|
-
globalPerformanceMonitor.clear();
|
|
32
|
-
}
|
|
33
|
-
return JSON.stringify(stats, null, 2);
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
name: 'get_performance_report',
|
|
38
|
-
description: 'Get a formatted performance report with insights and recommendations',
|
|
39
|
-
parameters: {
|
|
40
|
-
type: 'object',
|
|
41
|
-
properties: {
|
|
42
|
-
include_recent_activity: {
|
|
43
|
-
type: 'boolean',
|
|
44
|
-
description: 'Include recent tool activity in the report (default: true)',
|
|
45
|
-
default: true,
|
|
46
|
-
},
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
handler: async (_args) => {
|
|
50
|
-
return globalPerformanceMonitor.generateReport();
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
name: 'analyze_tool_performance',
|
|
55
|
-
description: 'Analyze performance metrics for a specific tool',
|
|
56
|
-
parameters: {
|
|
57
|
-
type: 'object',
|
|
58
|
-
properties: {
|
|
59
|
-
tool_name: {
|
|
60
|
-
type: 'string',
|
|
61
|
-
description: 'Name of the tool to analyze',
|
|
62
|
-
},
|
|
63
|
-
},
|
|
64
|
-
required: ['tool_name'],
|
|
65
|
-
},
|
|
66
|
-
handler: async (args) => {
|
|
67
|
-
const metrics = globalPerformanceMonitor.getToolMetrics(args.tool_name);
|
|
68
|
-
if (metrics.length === 0) {
|
|
69
|
-
return `No performance data found for tool: ${args.tool_name}`;
|
|
70
|
-
}
|
|
71
|
-
const successfulMetrics = metrics.filter(m => m.success);
|
|
72
|
-
const failedMetrics = metrics.filter(m => !m.success);
|
|
73
|
-
const executionTimes = successfulMetrics.map(m => m.executionTimeMs);
|
|
74
|
-
const averageTime = executionTimes.length > 0
|
|
75
|
-
? executionTimes.reduce((sum, time) => sum + time, 0) / executionTimes.length
|
|
76
|
-
: 0;
|
|
77
|
-
const maxTime = executionTimes.length > 0 ? Math.max(...executionTimes) : 0;
|
|
78
|
-
const minTime = executionTimes.length > 0 ? Math.min(...executionTimes) : 0;
|
|
79
|
-
let report = `Performance Analysis for: ${args.tool_name}\n`;
|
|
80
|
-
report += `Total Executions: ${metrics.length}\n`;
|
|
81
|
-
report += `Successful: ${successfulMetrics.length}\n`;
|
|
82
|
-
report += `Failed: ${failedMetrics.length}\n`;
|
|
83
|
-
report += `Success Rate: ${((successfulMetrics.length / metrics.length) * 100).toFixed(1)}%\n`;
|
|
84
|
-
if (successfulMetrics.length > 0) {
|
|
85
|
-
report += `\nExecution Times:\n`;
|
|
86
|
-
report += ` Average: ${averageTime.toFixed(2)}ms\n`;
|
|
87
|
-
report += ` Fastest: ${minTime.toFixed(2)}ms\n`;
|
|
88
|
-
report += ` Slowest: ${maxTime.toFixed(2)}ms\n`;
|
|
89
|
-
// Performance categorization
|
|
90
|
-
if (averageTime > 5000) {
|
|
91
|
-
report += ` ⚠️ Performance Warning: This tool is consistently slow (>5s)\n`;
|
|
92
|
-
}
|
|
93
|
-
else if (averageTime > 1000) {
|
|
94
|
-
report += ` ℹ️ Performance Note: This tool is moderately slow (>1s)\n`;
|
|
95
|
-
}
|
|
96
|
-
else {
|
|
97
|
-
report += ` ✓ Performance: This tool is fast (<1s)\n`;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
if (failedMetrics.length > 0) {
|
|
101
|
-
report += `\nRecent Failures:\n`;
|
|
102
|
-
failedMetrics.slice(-5).forEach(metric => {
|
|
103
|
-
report += ` ${new Date(metric.timestamp).toISOString()}: ${metric.error}\n`;
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
return report;
|
|
107
|
-
},
|
|
108
|
-
},
|
|
109
|
-
{
|
|
110
|
-
name: 'clear_performance_metrics',
|
|
111
|
-
description: 'Clear all performance metrics and start fresh',
|
|
112
|
-
parameters: {
|
|
113
|
-
type: 'object',
|
|
114
|
-
properties: {},
|
|
115
|
-
},
|
|
116
|
-
handler: async () => {
|
|
117
|
-
globalPerformanceMonitor.clear();
|
|
118
|
-
return 'Performance metrics cleared successfully';
|
|
119
|
-
},
|
|
120
|
-
},
|
|
121
|
-
{
|
|
122
|
-
name: 'identify_performance_bottlenecks',
|
|
123
|
-
description: 'Identify tools that are causing performance bottlenecks',
|
|
124
|
-
parameters: {
|
|
125
|
-
type: 'object',
|
|
126
|
-
properties: {
|
|
127
|
-
slow_threshold_ms: {
|
|
128
|
-
type: 'number',
|
|
129
|
-
description: 'Threshold for considering a tool slow (default: 1000ms)',
|
|
130
|
-
default: 1000,
|
|
131
|
-
},
|
|
132
|
-
},
|
|
133
|
-
},
|
|
134
|
-
handler: async (args) => {
|
|
135
|
-
const threshold = args.slow_threshold_ms ?? 1000;
|
|
136
|
-
// Get all tools and their average execution times
|
|
137
|
-
const toolMetrics = new Map();
|
|
138
|
-
globalPerformanceMonitor.getToolMetrics('*').forEach(metric => {
|
|
139
|
-
if (metric.success) {
|
|
140
|
-
const existing = toolMetrics.get(metric.toolName) || { totalTime: 0, count: 0, maxTime: 0 };
|
|
141
|
-
toolMetrics.set(metric.toolName, {
|
|
142
|
-
totalTime: existing.totalTime + metric.executionTimeMs,
|
|
143
|
-
count: existing.count + 1,
|
|
144
|
-
maxTime: Math.max(existing.maxTime, metric.executionTimeMs),
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
});
|
|
148
|
-
const slowTools = Array.from(toolMetrics.entries())
|
|
149
|
-
.map(([toolName, data]) => ({
|
|
150
|
-
toolName,
|
|
151
|
-
averageTime: data.totalTime / data.count,
|
|
152
|
-
maxTime: data.maxTime,
|
|
153
|
-
count: data.count,
|
|
154
|
-
}))
|
|
155
|
-
.filter(tool => tool.averageTime > threshold)
|
|
156
|
-
.sort((a, b) => b.averageTime - a.averageTime);
|
|
157
|
-
if (slowTools.length === 0) {
|
|
158
|
-
return `No performance bottlenecks detected (threshold: ${threshold}ms)`;
|
|
159
|
-
}
|
|
160
|
-
let report = `Performance Bottlenecks (threshold: ${threshold}ms):\n\n`;
|
|
161
|
-
slowTools.forEach(tool => {
|
|
162
|
-
report += `🔴 ${tool.toolName}\n`;
|
|
163
|
-
report += ` Average: ${tool.averageTime.toFixed(2)}ms\n`;
|
|
164
|
-
report += ` Maximum: ${tool.maxTime.toFixed(2)}ms\n`;
|
|
165
|
-
report += ` Calls: ${tool.count}\n\n`;
|
|
166
|
-
});
|
|
167
|
-
report += `Recommendations:\n`;
|
|
168
|
-
report += `• Consider optimizing the slowest tools\n`;
|
|
169
|
-
report += `• Use caching for expensive operations\n`;
|
|
170
|
-
report += `• Batch operations when possible\n`;
|
|
171
|
-
return report;
|
|
172
|
-
},
|
|
173
|
-
},
|
|
174
|
-
],
|
|
175
|
-
};
|
|
176
|
-
//# sourceMappingURL=performanceMonitoringCapability.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"performanceMonitoringCapability.js","sourceRoot":"","sources":["../../src/capabilities/performanceMonitoringCapability.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAEzE,MAAM,CAAC,MAAM,+BAA+B,GAAG;IAC7C,IAAI,EAAE,wBAAwB;IAC9B,WAAW,EAAE,gDAAgD;IAC7D,KAAK,EAAE;QACL;YACE,IAAI,EAAE,uBAAuB;YAC7B,WAAW,EAAE,kEAAkE;YAC/E,UAAU,EAAE;gBACV,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACV,aAAa,EAAE;wBACb,IAAI,EAAE,SAAS;wBACf,WAAW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,IAAI,CAAC,OAAO;oBACrB,KAAK,EAAE,IAAI,CAAC,KAAK;iBAClB,CAAC,CAAC;qBACF,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,WAAW,GAAG,SAAS,CAAC;qBAC5C,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,GAAG,CAAC,CAAC,WAAW,CAAC,CAAC;gBAEjD,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;oBAC3B,OAAO,mDAAmD,SAAS,KAAK,CAAC;gBAC3E,CAAC;gBAED,IAAI,MAAM,GAAG,uCAAuC,SAAS,UAAU,CAAC;gBACxE,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;oBACvB,MAAM,IAAI,MAAM,IAAI,CAAC,QAAQ,IAAI,CAAC;oBAClC,MAAM,IAAI,eAAe,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC;oBAC3D,MAAM,IAAI,eAAe,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC;oBACvD,MAAM,IAAI,aAAa,IAAI,CAAC,KAAK,MAAM,CAAC;gBAC1C,CAAC,CAAC,CAAC;gBAEH,MAAM,IAAI,oBAAoB,CAAC;gBAC/B,MAAM,IAAI,2CAA2C,CAAC;gBACtD,MAAM,IAAI,0CAA0C,CAAC;gBACrD,MAAM,IAAI,oCAAoC,CAAC;gBAE/C,OAAO,MAAM,CAAC;YAChB,CAAC;SACF;KACF;CACF,CAAC"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { CapabilityModule, CapabilityContribution, CapabilityContext } from '../runtime/agentHost.js';
|
|
2
|
-
export interface TodoItem {
|
|
3
|
-
content: string;
|
|
4
|
-
status: 'pending' | 'in_progress' | 'completed';
|
|
5
|
-
activeForm: string;
|
|
6
|
-
}
|
|
7
|
-
export interface TodoState {
|
|
8
|
-
items: TodoItem[];
|
|
9
|
-
lastUpdate: number;
|
|
10
|
-
}
|
|
11
|
-
export declare class TodoCapability implements CapabilityModule {
|
|
12
|
-
id: string;
|
|
13
|
-
description: string;
|
|
14
|
-
create(_context: CapabilityContext): Promise<CapabilityContribution>;
|
|
15
|
-
private formatTodoList;
|
|
16
|
-
}
|
|
17
|
-
export declare const getTodoState: () => TodoState;
|
|
18
|
-
export declare const clearTodoState: () => void;
|
|
19
|
-
//# sourceMappingURL=todoCapability.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"todoCapability.d.ts","sourceRoot":"","sources":["../../src/capabilities/todoCapability.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE3G,MAAM,WAAW,QAAQ;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,SAAS,GAAG,aAAa,GAAG,WAAW,CAAC;IAChD,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,QAAQ,EAAE,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;CACpB;AAOD,qBAAa,cAAe,YAAW,gBAAgB;IACrD,EAAE,SAAqB;IACvB,WAAW,SAAgE;IAErE,MAAM,CAAC,QAAQ,EAAE,iBAAiB,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAoI1E,OAAO,CAAC,cAAc;CAuCvB;AAED,eAAO,MAAM,YAAY,QAAO,SAA4B,CAAC;AAC7D,eAAO,MAAM,cAAc,QAAO,IAEjC,CAAC"}
|
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
let globalTodoState = {
|
|
2
|
-
items: [],
|
|
3
|
-
lastUpdate: Date.now(),
|
|
4
|
-
};
|
|
5
|
-
export class TodoCapability {
|
|
6
|
-
id = 'capability.todo';
|
|
7
|
-
description = 'Task and todo list management for tracking multi-step work';
|
|
8
|
-
async create(_context) {
|
|
9
|
-
return {
|
|
10
|
-
id: 'todo.tools',
|
|
11
|
-
description: 'Todo list management tools for tracking tasks',
|
|
12
|
-
toolSuite: {
|
|
13
|
-
id: 'todo',
|
|
14
|
-
tools: [
|
|
15
|
-
{
|
|
16
|
-
name: 'todo_write',
|
|
17
|
-
description: `Create and manage a structured task list for your current coding session. Use this ONLY when the user asks for a todo list or the work is clearly multi-step/complex.
|
|
18
|
-
|
|
19
|
-
## When to Use This Tool
|
|
20
|
-
Use this tool proactively in these scenarios:
|
|
21
|
-
|
|
22
|
-
1. Complex multi-step tasks - When a task requires 3 or more distinct steps
|
|
23
|
-
2. Non-trivial and complex tasks - Tasks that require careful planning
|
|
24
|
-
3. User explicitly requests todo list
|
|
25
|
-
4. User provides multiple tasks (numbered or comma-separated)
|
|
26
|
-
5. After receiving new instructions - Capture requirements as todos
|
|
27
|
-
6. When starting work on a task - Mark it as in_progress BEFORE beginning work
|
|
28
|
-
7. After completing a task - Mark completed and add follow-up tasks
|
|
29
|
-
|
|
30
|
-
## When NOT to Use
|
|
31
|
-
Skip when:
|
|
32
|
-
1. Single, straightforward task
|
|
33
|
-
2. Trivial task (less than 3 simple steps)
|
|
34
|
-
3. Purely conversational/informational task
|
|
35
|
-
4. Simple release commands (e.g., bump version/publish) unless the user asks for tracking
|
|
36
|
-
|
|
37
|
-
## Task States
|
|
38
|
-
- pending: Task not yet started
|
|
39
|
-
- in_progress: Currently working on (limit to ONE at a time)
|
|
40
|
-
- completed: Task finished successfully
|
|
41
|
-
|
|
42
|
-
## Task Requirements
|
|
43
|
-
- content: Imperative form (e.g., "Run tests", "Build project")
|
|
44
|
-
- activeForm: Present continuous form (e.g., "Running tests", "Building project")
|
|
45
|
-
|
|
46
|
-
## Task Management
|
|
47
|
-
- Update status in real-time as you work
|
|
48
|
-
- Mark tasks complete IMMEDIATELY after finishing
|
|
49
|
-
- Exactly ONE task must be in_progress at any time
|
|
50
|
-
- Complete current tasks before starting new ones
|
|
51
|
-
- Remove irrelevant tasks entirely
|
|
52
|
-
|
|
53
|
-
## Task Completion Requirements
|
|
54
|
-
ONLY mark completed when FULLY accomplished:
|
|
55
|
-
- Never mark completed if tests failing, implementation partial, or errors unresolved
|
|
56
|
-
- When blocked, create new task describing what needs resolution
|
|
57
|
-
- Keep as in_progress if encountering errors or blockers`,
|
|
58
|
-
parameters: {
|
|
59
|
-
type: 'object',
|
|
60
|
-
properties: {
|
|
61
|
-
todos: {
|
|
62
|
-
type: 'array',
|
|
63
|
-
description: 'The updated todo list',
|
|
64
|
-
items: {
|
|
65
|
-
type: 'object',
|
|
66
|
-
properties: {
|
|
67
|
-
content: {
|
|
68
|
-
type: 'string',
|
|
69
|
-
minLength: 1,
|
|
70
|
-
description: 'The task description in imperative form',
|
|
71
|
-
},
|
|
72
|
-
status: {
|
|
73
|
-
type: 'string',
|
|
74
|
-
enum: ['pending', 'in_progress', 'completed'],
|
|
75
|
-
description: 'Current status of the task',
|
|
76
|
-
},
|
|
77
|
-
activeForm: {
|
|
78
|
-
type: 'string',
|
|
79
|
-
minLength: 1,
|
|
80
|
-
description: 'The task description in present continuous form',
|
|
81
|
-
},
|
|
82
|
-
},
|
|
83
|
-
required: ['content', 'status', 'activeForm'],
|
|
84
|
-
},
|
|
85
|
-
},
|
|
86
|
-
},
|
|
87
|
-
required: ['todos'],
|
|
88
|
-
},
|
|
89
|
-
handler: async (args) => {
|
|
90
|
-
const { todos } = args;
|
|
91
|
-
if (!Array.isArray(todos)) {
|
|
92
|
-
return 'Error: todos must be an array';
|
|
93
|
-
}
|
|
94
|
-
// Validate todos
|
|
95
|
-
for (const todo of todos) {
|
|
96
|
-
if (!todo.content || !todo.status || !todo.activeForm) {
|
|
97
|
-
return 'Error: Each todo must have content, status, and activeForm';
|
|
98
|
-
}
|
|
99
|
-
if (!['pending', 'in_progress', 'completed'].includes(todo.status)) {
|
|
100
|
-
return 'Error: Invalid status. Must be pending, in_progress, or completed';
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
// Check for exactly one in_progress task
|
|
104
|
-
const inProgressCount = todos.filter((t) => t.status === 'in_progress').length;
|
|
105
|
-
if (inProgressCount > 1) {
|
|
106
|
-
return 'Warning: Multiple tasks marked as in_progress. Only one task should be actively worked on at a time.';
|
|
107
|
-
}
|
|
108
|
-
globalTodoState = {
|
|
109
|
-
items: todos,
|
|
110
|
-
lastUpdate: Date.now(),
|
|
111
|
-
};
|
|
112
|
-
return this.formatTodoList(todos);
|
|
113
|
-
},
|
|
114
|
-
},
|
|
115
|
-
{
|
|
116
|
-
name: 'todo_read',
|
|
117
|
-
description: 'Read the current todo list to check progress',
|
|
118
|
-
parameters: {
|
|
119
|
-
type: 'object',
|
|
120
|
-
properties: {},
|
|
121
|
-
},
|
|
122
|
-
handler: async () => {
|
|
123
|
-
if (!globalTodoState.items.length) {
|
|
124
|
-
return 'No active todo list';
|
|
125
|
-
}
|
|
126
|
-
return this.formatTodoList(globalTodoState.items);
|
|
127
|
-
},
|
|
128
|
-
},
|
|
129
|
-
],
|
|
130
|
-
},
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
formatTodoList(todos) {
|
|
134
|
-
if (!todos.length) {
|
|
135
|
-
return 'Todo list is empty';
|
|
136
|
-
}
|
|
137
|
-
const lines = ['Todo List:'];
|
|
138
|
-
const pending = todos.filter((t) => t.status === 'pending');
|
|
139
|
-
const inProgress = todos.filter((t) => t.status === 'in_progress');
|
|
140
|
-
const completed = todos.filter((t) => t.status === 'completed');
|
|
141
|
-
if (inProgress.length > 0) {
|
|
142
|
-
lines.push('\n🔵 In Progress:');
|
|
143
|
-
for (const todo of inProgress) {
|
|
144
|
-
lines.push(` • ${todo.activeForm}`);
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
if (pending.length > 0) {
|
|
148
|
-
lines.push('\n⚪ Pending:');
|
|
149
|
-
for (const todo of pending) {
|
|
150
|
-
lines.push(` • ${todo.content}`);
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
if (completed.length > 0) {
|
|
154
|
-
lines.push('\n✅ Completed:');
|
|
155
|
-
for (const todo of completed) {
|
|
156
|
-
lines.push(` • ${todo.content}`);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
const total = todos.length;
|
|
160
|
-
const completedCount = completed.length;
|
|
161
|
-
const progress = total > 0 ? Math.round((completedCount / total) * 100) : 0;
|
|
162
|
-
lines.push(`\nProgress: ${completedCount}/${total} (${progress}%)`);
|
|
163
|
-
return lines.join('\n');
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
export const getTodoState = () => globalTodoState;
|
|
167
|
-
export const clearTodoState = () => {
|
|
168
|
-
globalTodoState = { items: [], lastUpdate: Date.now() };
|
|
169
|
-
};
|
|
170
|
-
//# sourceMappingURL=todoCapability.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"todoCapability.js","sourceRoot":"","sources":["../../src/capabilities/todoCapability.ts"],"names":[],"mappings":"AAaA,IAAI,eAAe,GAAc;IAC/B,KAAK,EAAE,EAAE;IACT,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE;CACvB,CAAC;AAEF,MAAM,OAAO,cAAc;IACzB,EAAE,GAAG,iBAAiB,CAAC;IACvB,WAAW,GAAG,4DAA4D,CAAC;IAE3E,KAAK,CAAC,MAAM,CAAC,QAA2B;QACtC,OAAO;YACL,EAAE,EAAE,YAAY;YAChB,WAAW,EAAE,+CAA+C;YAC5D,SAAS,EAAE;gBACT,EAAE,EAAE,MAAM;gBACV,KAAK,EAAE;oBACL;wBACE,IAAI,EAAE,YAAY;wBAClB,WAAW,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yDAwCgC;wBAC7C,UAAU,EAAE;4BACV,IAAI,EAAE,QAAQ;4BACd,UAAU,EAAE;gCACV,KAAK,EAAE;oCACL,IAAI,EAAE,OAAO;oCACb,WAAW,EAAE,uBAAuB;oCACpC,KAAK,EAAE;wCACL,IA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,GAAG,GAAS,EAAE;IACvC,eAAe,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;AAC1D,CAAC,CAAC"}
|
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Base Tool Factory
|
|
3
|
-
*
|
|
4
|
-
* Provides utilities and patterns for creating tools with consistent:
|
|
5
|
-
* - Error handling
|
|
6
|
-
* - JSON schema generation
|
|
7
|
-
* - Result formatting
|
|
8
|
-
* - Progress reporting
|
|
9
|
-
* - Timeout handling
|
|
10
|
-
*
|
|
11
|
-
* Usage:
|
|
12
|
-
* ```typescript
|
|
13
|
-
* import { createTool, ToolBuilder, commonSchemas } from '../core/baseToolFactory.js';
|
|
14
|
-
*
|
|
15
|
-
* const myTool = createTool({
|
|
16
|
-
* name: 'MyTool',
|
|
17
|
-
* description: 'Does something useful',
|
|
18
|
-
* parameters: {
|
|
19
|
-
* input: { type: 'string', required: true, description: 'Input value' },
|
|
20
|
-
* },
|
|
21
|
-
* handler: async (args) => {
|
|
22
|
-
* // Implementation
|
|
23
|
-
* return { success: true, data: args.input };
|
|
24
|
-
* },
|
|
25
|
-
* });
|
|
26
|
-
* ```
|
|
27
|
-
*/
|
|
28
|
-
import type { ToolDefinition, ToolSuite } from './toolRuntime.js';
|
|
29
|
-
/**
|
|
30
|
-
* Common schema fragments for reuse across tools
|
|
31
|
-
*/
|
|
32
|
-
export declare const commonSchemas: {
|
|
33
|
-
/** File path parameter */
|
|
34
|
-
filePath: {
|
|
35
|
-
type: "string";
|
|
36
|
-
description: string;
|
|
37
|
-
};
|
|
38
|
-
/** Directory path parameter */
|
|
39
|
-
directoryPath: {
|
|
40
|
-
type: "string";
|
|
41
|
-
description: string;
|
|
42
|
-
};
|
|
43
|
-
/** Timeout in milliseconds */
|
|
44
|
-
timeout: {
|
|
45
|
-
type: "number";
|
|
46
|
-
description: string;
|
|
47
|
-
default: number;
|
|
48
|
-
};
|
|
49
|
-
/** Boolean flag */
|
|
50
|
-
flag: (description: string, defaultValue?: boolean) => {
|
|
51
|
-
type: "boolean";
|
|
52
|
-
description: string;
|
|
53
|
-
default: boolean;
|
|
54
|
-
};
|
|
55
|
-
/** String with enum options */
|
|
56
|
-
enum: (description: string, values: string[], defaultValue?: string) => {
|
|
57
|
-
default?: string | undefined;
|
|
58
|
-
type: "string";
|
|
59
|
-
description: string;
|
|
60
|
-
enum: string[];
|
|
61
|
-
};
|
|
62
|
-
/** Array of strings */
|
|
63
|
-
stringArray: (description: string) => {
|
|
64
|
-
type: "array";
|
|
65
|
-
items: {
|
|
66
|
-
type: "string";
|
|
67
|
-
};
|
|
68
|
-
description: string;
|
|
69
|
-
};
|
|
70
|
-
/** Optional string */
|
|
71
|
-
optionalString: (description: string) => {
|
|
72
|
-
type: "string";
|
|
73
|
-
description: string;
|
|
74
|
-
};
|
|
75
|
-
/** Required string */
|
|
76
|
-
requiredString: (description: string) => {
|
|
77
|
-
type: "string";
|
|
78
|
-
description: string;
|
|
79
|
-
};
|
|
80
|
-
};
|
|
81
|
-
export interface ToolResult {
|
|
82
|
-
success: boolean;
|
|
83
|
-
data?: unknown;
|
|
84
|
-
error?: string;
|
|
85
|
-
warnings?: string[];
|
|
86
|
-
metadata?: Record<string, unknown>;
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Format a tool result to a consistent JSON string
|
|
90
|
-
*/
|
|
91
|
-
export declare function formatToolResult(result: ToolResult): string;
|
|
92
|
-
/**
|
|
93
|
-
* Create a successful tool result
|
|
94
|
-
*/
|
|
95
|
-
export declare function successResult(data: unknown, metadata?: Record<string, unknown>): string;
|
|
96
|
-
/**
|
|
97
|
-
* Create a failed tool result
|
|
98
|
-
*/
|
|
99
|
-
export declare function errorResult(error: string | Error, metadata?: Record<string, unknown>): string;
|
|
100
|
-
/**
|
|
101
|
-
* Create a result with warnings
|
|
102
|
-
*/
|
|
103
|
-
export declare function warningResult(data: unknown, warnings: string[], metadata?: Record<string, unknown>): string;
|
|
104
|
-
export interface SimpleParameterDef {
|
|
105
|
-
type: 'string' | 'number' | 'boolean' | 'array' | 'object';
|
|
106
|
-
description: string;
|
|
107
|
-
required?: boolean;
|
|
108
|
-
default?: unknown;
|
|
109
|
-
enum?: string[];
|
|
110
|
-
items?: {
|
|
111
|
-
type: string;
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
export interface CreateToolOptions<T extends Record<string, unknown>> {
|
|
115
|
-
name: string;
|
|
116
|
-
description: string;
|
|
117
|
-
parameters?: Record<string, SimpleParameterDef>;
|
|
118
|
-
handler: (args: T) => Promise<unknown> | unknown;
|
|
119
|
-
cacheable?: boolean;
|
|
120
|
-
formatResult?: (result: unknown) => string;
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Create a tool definition with simplified parameter handling
|
|
124
|
-
*/
|
|
125
|
-
export declare function createTool<T extends Record<string, unknown>>(options: CreateToolOptions<T>): ToolDefinition<T>;
|
|
126
|
-
/**
|
|
127
|
-
* Fluent builder for creating tools
|
|
128
|
-
*
|
|
129
|
-
* Usage:
|
|
130
|
-
* ```typescript
|
|
131
|
-
* const tool = new ToolBuilder('MyTool')
|
|
132
|
-
* .description('Does something useful')
|
|
133
|
-
* .param('input', 'string', 'The input value', true)
|
|
134
|
-
* .param('verbose', 'boolean', 'Enable verbose output', false, false)
|
|
135
|
-
* .handler(async (args) => {
|
|
136
|
-
* return { data: args.input };
|
|
137
|
-
* })
|
|
138
|
-
* .build();
|
|
139
|
-
* ```
|
|
140
|
-
*/
|
|
141
|
-
export declare class ToolBuilder<T extends Record<string, unknown> = Record<string, unknown>> {
|
|
142
|
-
private _name;
|
|
143
|
-
private _description;
|
|
144
|
-
private _parameters;
|
|
145
|
-
private _handler?;
|
|
146
|
-
private _cacheable;
|
|
147
|
-
private _formatResult?;
|
|
148
|
-
constructor(name: string);
|
|
149
|
-
description(desc: string): this;
|
|
150
|
-
param(name: string, type: SimpleParameterDef['type'], description: string, required?: boolean, defaultValue?: unknown): this;
|
|
151
|
-
enumParam(name: string, description: string, values: string[], required?: boolean, defaultValue?: string): this;
|
|
152
|
-
arrayParam(name: string, description: string, itemType?: string, required?: boolean): this;
|
|
153
|
-
handler(fn: (args: T) => Promise<unknown> | unknown): this;
|
|
154
|
-
cacheable(value?: boolean): this;
|
|
155
|
-
formatResult(fn: (result: unknown) => string): this;
|
|
156
|
-
build(): ToolDefinition<T>;
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* Builder for creating tool suites
|
|
160
|
-
*/
|
|
161
|
-
export declare class ToolSuiteBuilder {
|
|
162
|
-
private _id;
|
|
163
|
-
private _description?;
|
|
164
|
-
private _tools;
|
|
165
|
-
constructor(id: string);
|
|
166
|
-
description(desc: string): this;
|
|
167
|
-
addTool(tool: ToolDefinition): this;
|
|
168
|
-
addTools(tools: ToolDefinition[]): this;
|
|
169
|
-
build(): ToolSuite;
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* Execute with timeout
|
|
173
|
-
*/
|
|
174
|
-
export declare function withTimeout<T>(promise: Promise<T>, timeoutMs: number, errorMessage?: string): Promise<T>;
|
|
175
|
-
/**
|
|
176
|
-
* Execute with progress reporting for long operations
|
|
177
|
-
*/
|
|
178
|
-
export declare function withProgress<T>(operation: (report: (current: number, total?: number, message?: string) => void) => Promise<T>): Promise<T>;
|
|
179
|
-
/**
|
|
180
|
-
* Retry an operation with exponential backoff
|
|
181
|
-
*/
|
|
182
|
-
export declare function withRetry<T>(operation: () => Promise<T>, options?: {
|
|
183
|
-
maxRetries?: number;
|
|
184
|
-
baseDelayMs?: number;
|
|
185
|
-
shouldRetry?: (error: unknown) => boolean;
|
|
186
|
-
}): Promise<T>;
|
|
187
|
-
//# sourceMappingURL=baseToolFactory.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"baseToolFactory.d.ts","sourceRoot":"","sources":["../../src/core/baseToolFactory.ts"],"names":[],"m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