@gotza02/mathinking 1.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 +366 -0
- package/dist/dag.d.ts +39 -0
- package/dist/dag.d.ts.map +1 -0
- package/dist/dag.js +241 -0
- package/dist/dag.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +300 -0
- package/dist/index.js.map +1 -0
- package/dist/orchestrator.d.ts +65 -0
- package/dist/orchestrator.d.ts.map +1 -0
- package/dist/orchestrator.js +485 -0
- package/dist/orchestrator.js.map +1 -0
- package/dist/sequential-thinking.d.ts +70 -0
- package/dist/sequential-thinking.d.ts.map +1 -0
- package/dist/sequential-thinking.js +602 -0
- package/dist/sequential-thinking.js.map +1 -0
- package/dist/test-all.d.ts +2 -0
- package/dist/test-all.d.ts.map +1 -0
- package/dist/test-all.js +158 -0
- package/dist/test-all.js.map +1 -0
- package/dist/tools/orchestrator.d.ts +65 -0
- package/dist/tools/orchestrator.d.ts.map +1 -0
- package/dist/tools/orchestrator.js +486 -0
- package/dist/tools/orchestrator.js.map +1 -0
- package/dist/tools/sequential-thinking.d.ts +70 -0
- package/dist/tools/sequential-thinking.d.ts.map +1 -0
- package/dist/tools/sequential-thinking.js +602 -0
- package/dist/tools/sequential-thinking.js.map +1 -0
- package/dist/types/index.d.ts +142 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +5 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/dag.d.ts +39 -0
- package/dist/utils/dag.d.ts.map +1 -0
- package/dist/utils/dag.js +241 -0
- package/dist/utils/dag.js.map +1 -0
- package/package.json +45 -0
|
@@ -0,0 +1,486 @@
|
|
|
1
|
+
import { topologicalSortWithLayers, validateDAG, visualizeDAG, getCriticalPath, getMaxParallelism } from '../utils/dag.js';
|
|
2
|
+
/**
|
|
3
|
+
* Orchestrator Manager (The Body)
|
|
4
|
+
*
|
|
5
|
+
* Provides DAG-based task execution with:
|
|
6
|
+
* - Topological sorting for dependency resolution
|
|
7
|
+
* - Parallel execution of independent tasks
|
|
8
|
+
* - Tool orchestration via registry
|
|
9
|
+
* - Graceful error handling
|
|
10
|
+
* - Result aggregation
|
|
11
|
+
*/
|
|
12
|
+
export class OrchestratorManager {
|
|
13
|
+
toolRegistry = {};
|
|
14
|
+
executionHistory = new Map();
|
|
15
|
+
constructor() {
|
|
16
|
+
this.registerBuiltInTools();
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Register built-in tools for testing and common operations
|
|
20
|
+
*/
|
|
21
|
+
registerBuiltInTools() {
|
|
22
|
+
// Echo tool - returns input as output (useful for testing)
|
|
23
|
+
this.registerTool({
|
|
24
|
+
name: 'echo',
|
|
25
|
+
description: 'Returns the input as output',
|
|
26
|
+
execute: async (input) => input
|
|
27
|
+
});
|
|
28
|
+
// Delay tool - waits for specified milliseconds
|
|
29
|
+
this.registerTool({
|
|
30
|
+
name: 'delay',
|
|
31
|
+
description: 'Waits for specified milliseconds',
|
|
32
|
+
execute: async (input) => {
|
|
33
|
+
const ms = input.milliseconds || 100;
|
|
34
|
+
await new Promise(resolve => setTimeout(resolve, ms));
|
|
35
|
+
return { delayed: ms, timestamp: new Date().toISOString() };
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
// Transform tool - applies simple transformations
|
|
39
|
+
this.registerTool({
|
|
40
|
+
name: 'transform',
|
|
41
|
+
description: 'Applies transformations to data',
|
|
42
|
+
execute: async (input) => {
|
|
43
|
+
const data = input.data;
|
|
44
|
+
const operation = input.operation;
|
|
45
|
+
switch (operation) {
|
|
46
|
+
case 'uppercase':
|
|
47
|
+
return { result: String(data).toUpperCase() };
|
|
48
|
+
case 'lowercase':
|
|
49
|
+
return { result: String(data).toLowerCase() };
|
|
50
|
+
case 'reverse':
|
|
51
|
+
return { result: String(data).split('').reverse().join('') };
|
|
52
|
+
case 'length':
|
|
53
|
+
return { result: String(data).length };
|
|
54
|
+
case 'double':
|
|
55
|
+
return { result: Number(data) * 2 };
|
|
56
|
+
default:
|
|
57
|
+
return { result: data, operation: 'none' };
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
// Aggregate tool - combines multiple inputs
|
|
62
|
+
this.registerTool({
|
|
63
|
+
name: 'aggregate',
|
|
64
|
+
description: 'Aggregates multiple values',
|
|
65
|
+
execute: async (input) => {
|
|
66
|
+
const values = input.values;
|
|
67
|
+
const operation = input.operation;
|
|
68
|
+
if (!Array.isArray(values)) {
|
|
69
|
+
return { result: values };
|
|
70
|
+
}
|
|
71
|
+
switch (operation) {
|
|
72
|
+
case 'sum':
|
|
73
|
+
return { result: values.reduce((a, b) => a + Number(b), 0) };
|
|
74
|
+
case 'concat':
|
|
75
|
+
return { result: values.join('') };
|
|
76
|
+
case 'array':
|
|
77
|
+
return { result: values };
|
|
78
|
+
case 'count':
|
|
79
|
+
return { result: values.length };
|
|
80
|
+
default:
|
|
81
|
+
return { result: values };
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
// HTTP fetch tool (simulated for safety)
|
|
86
|
+
this.registerTool({
|
|
87
|
+
name: 'fetch',
|
|
88
|
+
description: 'Simulates HTTP fetch',
|
|
89
|
+
execute: async (input) => {
|
|
90
|
+
const url = input.url;
|
|
91
|
+
// In production, this would actually fetch
|
|
92
|
+
return {
|
|
93
|
+
url,
|
|
94
|
+
status: 200,
|
|
95
|
+
body: `Simulated response from ${url}`,
|
|
96
|
+
timestamp: new Date().toISOString()
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
// Compute tool - performs calculations
|
|
101
|
+
this.registerTool({
|
|
102
|
+
name: 'compute',
|
|
103
|
+
description: 'Performs mathematical computations',
|
|
104
|
+
execute: async (input) => {
|
|
105
|
+
const expression = input.expression;
|
|
106
|
+
const variables = input.variables || {};
|
|
107
|
+
// Simple expression evaluator (safe subset)
|
|
108
|
+
let result = expression;
|
|
109
|
+
for (const [key, value] of Object.entries(variables)) {
|
|
110
|
+
result = result.replace(new RegExp(`\\b${key}\\b`, 'g'), String(value));
|
|
111
|
+
}
|
|
112
|
+
// Evaluate simple math expressions
|
|
113
|
+
try {
|
|
114
|
+
// Only allow safe characters
|
|
115
|
+
if (/^[\d\s+\-*/().]+$/.test(result)) {
|
|
116
|
+
return { result: Function(`"use strict"; return (${result})`)() };
|
|
117
|
+
}
|
|
118
|
+
return { error: 'Invalid expression', expression };
|
|
119
|
+
}
|
|
120
|
+
catch {
|
|
121
|
+
return { error: 'Computation failed', expression };
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Register a custom tool
|
|
128
|
+
*/
|
|
129
|
+
registerTool(tool) {
|
|
130
|
+
this.toolRegistry[tool.name] = tool;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Get list of registered tools
|
|
134
|
+
*/
|
|
135
|
+
getRegisteredTools() {
|
|
136
|
+
return Object.keys(this.toolRegistry);
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Process an orchestrator action
|
|
140
|
+
*/
|
|
141
|
+
async process(input) {
|
|
142
|
+
switch (input.action) {
|
|
143
|
+
case 'execute_plan':
|
|
144
|
+
return this.executePlan(input);
|
|
145
|
+
case 'validate_plan':
|
|
146
|
+
return this.validatePlan(input);
|
|
147
|
+
case 'get_execution_status':
|
|
148
|
+
return this.getExecutionStatus(input);
|
|
149
|
+
default:
|
|
150
|
+
return {
|
|
151
|
+
success: false,
|
|
152
|
+
message: `Unknown action: ${input.action}`
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Validate an execution plan
|
|
158
|
+
*/
|
|
159
|
+
validatePlan(input) {
|
|
160
|
+
if (!input.plan) {
|
|
161
|
+
return {
|
|
162
|
+
success: false,
|
|
163
|
+
message: 'Execution plan is required',
|
|
164
|
+
validationErrors: ['No plan provided']
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
const validation = validateDAG(input.plan);
|
|
168
|
+
const errors = [...validation.errors];
|
|
169
|
+
// Check for unregistered tools
|
|
170
|
+
for (const task of input.plan.tasks) {
|
|
171
|
+
if (!this.toolRegistry[task.toolName]) {
|
|
172
|
+
errors.push(`Task "${task.id}" uses unregistered tool "${task.toolName}". Available tools: ${this.getRegisteredTools().join(', ')}`);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
if (errors.length > 0) {
|
|
176
|
+
return {
|
|
177
|
+
success: false,
|
|
178
|
+
message: 'Plan validation failed',
|
|
179
|
+
validationErrors: errors
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
const topoResult = topologicalSortWithLayers(input.plan);
|
|
183
|
+
const criticalPath = getCriticalPath(input.plan);
|
|
184
|
+
const maxParallelism = getMaxParallelism(input.plan);
|
|
185
|
+
return {
|
|
186
|
+
success: true,
|
|
187
|
+
message: `Plan is valid!\n\n${visualizeDAG(input.plan)}\n\nCritical Path: ${criticalPath.join(' → ')}\nMax Parallelism: ${maxParallelism} concurrent tasks`,
|
|
188
|
+
executionOrder: topoResult.layers
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Execute a plan with parallel processing
|
|
193
|
+
*/
|
|
194
|
+
async executePlan(input) {
|
|
195
|
+
if (!input.plan) {
|
|
196
|
+
return {
|
|
197
|
+
success: false,
|
|
198
|
+
message: 'Execution plan is required'
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
// Validate first
|
|
202
|
+
const validation = this.validatePlan(input);
|
|
203
|
+
if (!validation.success) {
|
|
204
|
+
return validation;
|
|
205
|
+
}
|
|
206
|
+
const plan = input.plan;
|
|
207
|
+
const startTime = new Date();
|
|
208
|
+
// Get execution layers
|
|
209
|
+
const topoResult = topologicalSortWithLayers(plan);
|
|
210
|
+
const taskMap = new Map(plan.tasks.map(t => [t.id, t]));
|
|
211
|
+
const taskResults = [];
|
|
212
|
+
const taskOutputs = new Map();
|
|
213
|
+
const errors = [];
|
|
214
|
+
console.log(`\n🚀 Starting execution of plan: ${plan.name}`);
|
|
215
|
+
console.log(`📊 Total tasks: ${plan.tasks.length}`);
|
|
216
|
+
console.log(`📦 Execution layers: ${topoResult.layers.length}`);
|
|
217
|
+
console.log(`⚡ Max parallelism: ${Math.max(...topoResult.layers.map(l => l.length))}\n`);
|
|
218
|
+
// Execute layer by layer
|
|
219
|
+
for (let layerIndex = 0; layerIndex < topoResult.layers.length; layerIndex++) {
|
|
220
|
+
const layer = topoResult.layers[layerIndex];
|
|
221
|
+
console.log(`\n📍 Layer ${layerIndex + 1}: Executing ${layer.length} task(s) in parallel`);
|
|
222
|
+
console.log(` Tasks: [${layer.join(', ')}]`);
|
|
223
|
+
// Execute all tasks in this layer in parallel
|
|
224
|
+
const layerPromises = layer.map(async (taskId) => {
|
|
225
|
+
const task = taskMap.get(taskId);
|
|
226
|
+
return this.executeTask(task, taskOutputs, errors);
|
|
227
|
+
});
|
|
228
|
+
// Wait for all tasks in this layer to complete
|
|
229
|
+
const layerResults = await Promise.all(layerPromises);
|
|
230
|
+
// Store results
|
|
231
|
+
for (const result of layerResults) {
|
|
232
|
+
taskResults.push(result);
|
|
233
|
+
if (result.status === 'completed' && result.result !== undefined) {
|
|
234
|
+
taskOutputs.set(result.taskId, result.result);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
const endTime = new Date();
|
|
239
|
+
const totalDuration = endTime.getTime() - startTime.getTime();
|
|
240
|
+
// Aggregate results
|
|
241
|
+
const aggregatedResults = {};
|
|
242
|
+
for (const [taskId, output] of taskOutputs) {
|
|
243
|
+
aggregatedResults[taskId] = output;
|
|
244
|
+
}
|
|
245
|
+
const successCount = taskResults.filter(r => r.status === 'completed').length;
|
|
246
|
+
const failureCount = taskResults.filter(r => r.status === 'failed').length;
|
|
247
|
+
const skippedCount = taskResults.filter(r => r.status === 'skipped').length;
|
|
248
|
+
const executionResult = {
|
|
249
|
+
planId: plan.planId,
|
|
250
|
+
planName: plan.name,
|
|
251
|
+
status: failureCount === 0 ? 'completed' : successCount > 0 ? 'completed_with_errors' : 'failed',
|
|
252
|
+
taskResults,
|
|
253
|
+
startTime: startTime.toISOString(),
|
|
254
|
+
endTime: endTime.toISOString(),
|
|
255
|
+
totalDuration,
|
|
256
|
+
successCount,
|
|
257
|
+
failureCount,
|
|
258
|
+
skippedCount,
|
|
259
|
+
executionOrder: topoResult.layers,
|
|
260
|
+
aggregatedResults,
|
|
261
|
+
errors
|
|
262
|
+
};
|
|
263
|
+
this.executionHistory.set(plan.planId, executionResult);
|
|
264
|
+
const statusEmoji = executionResult.status === 'completed' ? '✅' :
|
|
265
|
+
executionResult.status === 'completed_with_errors' ? '⚠️' : '❌';
|
|
266
|
+
return {
|
|
267
|
+
success: executionResult.status !== 'failed',
|
|
268
|
+
message: `${statusEmoji} Execution ${executionResult.status}\n\n` +
|
|
269
|
+
`📊 Results: ${successCount} succeeded, ${failureCount} failed, ${skippedCount} skipped\n` +
|
|
270
|
+
`⏱️ Total time: ${totalDuration}ms\n` +
|
|
271
|
+
`\n${this.formatExecutionSummary(executionResult)}`,
|
|
272
|
+
result: executionResult,
|
|
273
|
+
executionOrder: topoResult.layers
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Execute a single task with error handling and retries
|
|
278
|
+
*/
|
|
279
|
+
async executeTask(task, taskOutputs, errors) {
|
|
280
|
+
const startTime = new Date();
|
|
281
|
+
const maxRetries = task.retryCount || 0;
|
|
282
|
+
const retryDelay = task.retryDelay || 1000;
|
|
283
|
+
let retries = 0;
|
|
284
|
+
console.log(` ⚙️ Starting: ${task.name} (${task.id})`);
|
|
285
|
+
// Get tool
|
|
286
|
+
const tool = this.toolRegistry[task.toolName];
|
|
287
|
+
if (!tool) {
|
|
288
|
+
const error = `Tool "${task.toolName}" not found`;
|
|
289
|
+
errors.push({
|
|
290
|
+
taskId: task.id,
|
|
291
|
+
taskName: task.name,
|
|
292
|
+
error,
|
|
293
|
+
timestamp: new Date().toISOString()
|
|
294
|
+
});
|
|
295
|
+
return {
|
|
296
|
+
taskId: task.id,
|
|
297
|
+
taskName: task.name,
|
|
298
|
+
status: 'failed',
|
|
299
|
+
error,
|
|
300
|
+
startTime: startTime.toISOString(),
|
|
301
|
+
endTime: new Date().toISOString(),
|
|
302
|
+
duration: 0,
|
|
303
|
+
retries: 0
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
// Resolve input with dependency outputs
|
|
307
|
+
const resolvedInput = this.resolveInput(task.toolInput, taskOutputs);
|
|
308
|
+
while (retries <= maxRetries) {
|
|
309
|
+
try {
|
|
310
|
+
// Execute with timeout if specified
|
|
311
|
+
const result = task.timeout
|
|
312
|
+
? await this.executeWithTimeout(tool.execute(resolvedInput), task.timeout)
|
|
313
|
+
: await tool.execute(resolvedInput);
|
|
314
|
+
const endTime = new Date();
|
|
315
|
+
console.log(` ✓ Completed: ${task.name} (${endTime.getTime() - startTime.getTime()}ms)`);
|
|
316
|
+
return {
|
|
317
|
+
taskId: task.id,
|
|
318
|
+
taskName: task.name,
|
|
319
|
+
status: 'completed',
|
|
320
|
+
result,
|
|
321
|
+
startTime: startTime.toISOString(),
|
|
322
|
+
endTime: endTime.toISOString(),
|
|
323
|
+
duration: endTime.getTime() - startTime.getTime(),
|
|
324
|
+
retries
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
catch (err) {
|
|
328
|
+
retries++;
|
|
329
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
330
|
+
if (retries <= maxRetries) {
|
|
331
|
+
console.log(` ⟳ Retry ${retries}/${maxRetries}: ${task.name}`);
|
|
332
|
+
await new Promise(resolve => setTimeout(resolve, retryDelay));
|
|
333
|
+
}
|
|
334
|
+
else {
|
|
335
|
+
console.log(` ✗ Failed: ${task.name} - ${errorMessage}`);
|
|
336
|
+
errors.push({
|
|
337
|
+
taskId: task.id,
|
|
338
|
+
taskName: task.name,
|
|
339
|
+
error: errorMessage,
|
|
340
|
+
timestamp: new Date().toISOString()
|
|
341
|
+
});
|
|
342
|
+
return {
|
|
343
|
+
taskId: task.id,
|
|
344
|
+
taskName: task.name,
|
|
345
|
+
status: 'failed',
|
|
346
|
+
error: errorMessage,
|
|
347
|
+
startTime: startTime.toISOString(),
|
|
348
|
+
endTime: new Date().toISOString(),
|
|
349
|
+
duration: new Date().getTime() - startTime.getTime(),
|
|
350
|
+
retries: retries - 1
|
|
351
|
+
};
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
// Should never reach here, but TypeScript needs it
|
|
356
|
+
return {
|
|
357
|
+
taskId: task.id,
|
|
358
|
+
taskName: task.name,
|
|
359
|
+
status: 'failed',
|
|
360
|
+
error: 'Unknown error',
|
|
361
|
+
startTime: startTime.toISOString(),
|
|
362
|
+
endTime: new Date().toISOString(),
|
|
363
|
+
duration: 0,
|
|
364
|
+
retries
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* Resolve input placeholders with outputs from previous tasks
|
|
369
|
+
* Supports syntax: "${taskId.property}" or "${taskId}"
|
|
370
|
+
*/
|
|
371
|
+
resolveInput(input, taskOutputs) {
|
|
372
|
+
const resolved = {};
|
|
373
|
+
for (const [key, value] of Object.entries(input)) {
|
|
374
|
+
resolved[key] = this.resolveValue(value, taskOutputs);
|
|
375
|
+
}
|
|
376
|
+
return resolved;
|
|
377
|
+
}
|
|
378
|
+
resolveValue(value, taskOutputs) {
|
|
379
|
+
if (typeof value === 'string') {
|
|
380
|
+
// Check for placeholder pattern: ${taskId} or ${taskId.property}
|
|
381
|
+
const placeholderRegex = /\$\{([^}]+)\}/g;
|
|
382
|
+
// If entire string is a single placeholder, return the actual value (not stringified)
|
|
383
|
+
const singleMatch = value.match(/^\$\{([^}]+)\}$/);
|
|
384
|
+
if (singleMatch) {
|
|
385
|
+
return this.resolvePlaceholder(singleMatch[1], taskOutputs);
|
|
386
|
+
}
|
|
387
|
+
// Otherwise, replace placeholders in string
|
|
388
|
+
return value.replace(placeholderRegex, (_, placeholder) => {
|
|
389
|
+
const resolved = this.resolvePlaceholder(placeholder, taskOutputs);
|
|
390
|
+
return String(resolved);
|
|
391
|
+
});
|
|
392
|
+
}
|
|
393
|
+
if (Array.isArray(value)) {
|
|
394
|
+
return value.map(v => this.resolveValue(v, taskOutputs));
|
|
395
|
+
}
|
|
396
|
+
if (value && typeof value === 'object') {
|
|
397
|
+
return this.resolveInput(value, taskOutputs);
|
|
398
|
+
}
|
|
399
|
+
return value;
|
|
400
|
+
}
|
|
401
|
+
resolvePlaceholder(placeholder, taskOutputs) {
|
|
402
|
+
const parts = placeholder.split('.');
|
|
403
|
+
const taskId = parts[0];
|
|
404
|
+
const output = taskOutputs.get(taskId);
|
|
405
|
+
if (output === undefined) {
|
|
406
|
+
return `\${${placeholder}}`; // Return unresolved if task hasn't run
|
|
407
|
+
}
|
|
408
|
+
if (parts.length === 1) {
|
|
409
|
+
return output;
|
|
410
|
+
}
|
|
411
|
+
// Navigate nested properties
|
|
412
|
+
let current = output;
|
|
413
|
+
for (let i = 1; i < parts.length; i++) {
|
|
414
|
+
// Allow traversal of objects and strings (for .length etc)
|
|
415
|
+
if (current && (typeof current === 'object' || typeof current === 'string')) {
|
|
416
|
+
current = current[parts[i]];
|
|
417
|
+
}
|
|
418
|
+
else {
|
|
419
|
+
return undefined;
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
return current;
|
|
423
|
+
}
|
|
424
|
+
/**
|
|
425
|
+
* Execute a promise with timeout
|
|
426
|
+
*/
|
|
427
|
+
async executeWithTimeout(promise, timeoutMs) {
|
|
428
|
+
return Promise.race([
|
|
429
|
+
promise,
|
|
430
|
+
new Promise((_, reject) => setTimeout(() => reject(new Error(`Task timed out after ${timeoutMs}ms`)), timeoutMs))
|
|
431
|
+
]);
|
|
432
|
+
}
|
|
433
|
+
/**
|
|
434
|
+
* Get execution status for a plan
|
|
435
|
+
*/
|
|
436
|
+
getExecutionStatus(input) {
|
|
437
|
+
if (!input.planId) {
|
|
438
|
+
return {
|
|
439
|
+
success: false,
|
|
440
|
+
message: 'Plan ID is required'
|
|
441
|
+
};
|
|
442
|
+
}
|
|
443
|
+
const result = this.executionHistory.get(input.planId);
|
|
444
|
+
if (!result) {
|
|
445
|
+
return {
|
|
446
|
+
success: false,
|
|
447
|
+
message: `No execution found for plan ID: ${input.planId}`
|
|
448
|
+
};
|
|
449
|
+
}
|
|
450
|
+
return {
|
|
451
|
+
success: true,
|
|
452
|
+
message: this.formatExecutionSummary(result),
|
|
453
|
+
result
|
|
454
|
+
};
|
|
455
|
+
}
|
|
456
|
+
/**
|
|
457
|
+
* Format execution summary for display
|
|
458
|
+
*/
|
|
459
|
+
formatExecutionSummary(result) {
|
|
460
|
+
const lines = [
|
|
461
|
+
'┌─────────────────────────────────────────────────┐',
|
|
462
|
+
`│ Execution Summary: ${result.planName.padEnd(28)}│`,
|
|
463
|
+
'├─────────────────────────────────────────────────┤'
|
|
464
|
+
];
|
|
465
|
+
for (const taskResult of result.taskResults) {
|
|
466
|
+
const statusIcon = taskResult.status === 'completed' ? '✓' :
|
|
467
|
+
taskResult.status === 'failed' ? '✗' : '○';
|
|
468
|
+
const duration = `${taskResult.duration}ms`;
|
|
469
|
+
const line = `│ ${statusIcon} ${taskResult.taskName.padEnd(30)} ${duration.padStart(10)} │`;
|
|
470
|
+
lines.push(line);
|
|
471
|
+
}
|
|
472
|
+
lines.push('├─────────────────────────────────────────────────┤');
|
|
473
|
+
lines.push(`│ Total Duration: ${String(result.totalDuration + 'ms').padEnd(30)}│`);
|
|
474
|
+
lines.push('└─────────────────────────────────────────────────┘');
|
|
475
|
+
if (result.errors.length > 0) {
|
|
476
|
+
lines.push('\n⚠️ Errors:');
|
|
477
|
+
for (const error of result.errors) {
|
|
478
|
+
lines.push(` • ${error.taskName}: ${error.error}`);
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
return lines.join('\n');
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
// Export singleton instance
|
|
485
|
+
export const orchestratorManager = new OrchestratorManager();
|
|
486
|
+
//# sourceMappingURL=orchestrator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orchestrator.js","sourceRoot":"","sources":["../../src/tools/orchestrator.ts"],"names":[],"mappings":"AACA,OAAO,EACL,yBAAyB,EACzB,WAAW,EACX,YAAY,EACZ,eAAe,EACf,iBAAiB,EAClB,MAAM,iBAAiB,CAAC;AAazB;;;;;;;;;GASG;AACH,MAAM,OAAO,mBAAmB;IACtB,YAAY,GAAiB,EAAE,CAAC;IAChC,gBAAgB,GAAiC,IAAI,GAAG,EAAE,CAAC;IAEnE;QACE,IAAI,CAAC,oBAAoB,EAAE,CAAC;IAC9B,CAAC;IAED;;OAEG;IACK,oBAAoB;QAC1B,2DAA2D;QAC3D,IAAI,CAAC,YAAY,CAAC;YAChB,IAAI,EAAE,MAAM;YACZ,WAAW,EAAE,6BAA6B;YAC1C,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK;SAChC,CAAC,CAAC;QAEH,gDAAgD;QAChD,IAAI,CAAC,YAAY,CAAC;YAChB,IAAI,EAAE,OAAO;YACb,WAAW,EAAE,kCAAkC;YAC/C,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;gBACvB,MAAM,EAAE,GAAI,KAAK,CAAC,YAAuB,IAAI,GAAG,CAAC;gBACjD,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;gBACtD,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC;YAC9D,CAAC;SACF,CAAC,CAAC;QAEH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entialThinkingInput, SequentialThinkingOutput } from '../types/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Sequential Thinking Manager (The Brain)
|
|
4
|
+
*
|
|
5
|
+
* Provides deep reasoning capabilities with:
|
|
6
|
+
* - Iterative step-by-step thinking
|
|
7
|
+
* - Dynamic adjustment of thinking depth
|
|
8
|
+
* - Branching for exploring alternatives
|
|
9
|
+
* - Revision for correcting previous thoughts
|
|
10
|
+
* - Hypothesis verification
|
|
11
|
+
*/
|
|
12
|
+
export declare class SequentialThinkingManager {
|
|
13
|
+
private sessions;
|
|
14
|
+
/**
|
|
15
|
+
* Process a thinking action
|
|
16
|
+
*/
|
|
17
|
+
process(input: SequentialThinkingInput): Promise<SequentialThinkingOutput>;
|
|
18
|
+
/**
|
|
19
|
+
* Start a new thinking session
|
|
20
|
+
*/
|
|
21
|
+
private startSession;
|
|
22
|
+
/**
|
|
23
|
+
* Add a new thought to the session
|
|
24
|
+
*/
|
|
25
|
+
private addThought;
|
|
26
|
+
/**
|
|
27
|
+
* Create a branch for exploring alternative thought paths
|
|
28
|
+
*/
|
|
29
|
+
private createBranch;
|
|
30
|
+
/**
|
|
31
|
+
* Revise a previous thought
|
|
32
|
+
*/
|
|
33
|
+
private reviseThought;
|
|
34
|
+
/**
|
|
35
|
+
* Set a hypothesis that needs verification
|
|
36
|
+
*/
|
|
37
|
+
private setHypothesis;
|
|
38
|
+
/**
|
|
39
|
+
* Verify a hypothesis with evidence
|
|
40
|
+
*/
|
|
41
|
+
private verifyHypothesis;
|
|
42
|
+
/**
|
|
43
|
+
* Dynamically adjust the total number of thinking steps
|
|
44
|
+
*/
|
|
45
|
+
private adjustTotalThoughts;
|
|
46
|
+
/**
|
|
47
|
+
* Conclude the thinking session with a final synthesis
|
|
48
|
+
*/
|
|
49
|
+
private conclude;
|
|
50
|
+
/**
|
|
51
|
+
* Get current session status
|
|
52
|
+
*/
|
|
53
|
+
private getStatus;
|
|
54
|
+
/**
|
|
55
|
+
* Get complete thought history
|
|
56
|
+
*/
|
|
57
|
+
private getHistory;
|
|
58
|
+
private getSession;
|
|
59
|
+
private errorResponse;
|
|
60
|
+
private getThoughtMessage;
|
|
61
|
+
private getConfidenceBar;
|
|
62
|
+
private getSuggestedActions;
|
|
63
|
+
private getVerificationConfidence;
|
|
64
|
+
private getVerificationEmoji;
|
|
65
|
+
private getPostVerificationActions;
|
|
66
|
+
private getStatusBasedActions;
|
|
67
|
+
private generateSessionStats;
|
|
68
|
+
}
|
|
69
|
+
export declare const thinkingManager: SequentialThinkingManager;
|
|
70
|
+
//# sourceMappingURL=sequential-thinking.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sequential-thinking.d.ts","sourceRoot":"","sources":["../../src/tools/sequential-thinking.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAIV,uBAAuB,EACvB,wBAAwB,EAIzB,MAAM,mBAAmB,CAAC;AAE3B;;;;;;;;;GASG;AACH,qBAAa,yBAAyB;IACpC,OAAO,CAAC,QAAQ,CAA2C;IAE3D;;OAEG;IACG,OAAO,CAAC,KAAK,EAAE,uBAAuB,GAAG,OAAO,CAAC,wBAAwB,CAAC;IAmChF;;OAEG;IACH,OAAO,CAAC,YAAY;IAqCpB;;OAEG;IACH,OAAO,CAAC,UAAU;IA2ClB;;OAEG;IACH,OAAO,CAAC,YAAY;IA+EpB;;OAEG;IACH,OAAO,CAAC,aAAa;IAqDrB;;OAEG;IACH,OAAO,CAAC,aAAa;IA4CrB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IA2DxB;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAgC3B;;OAEG;IACH,OAAO,CAAC,QAAQ;IAkEhB;;OAEG;IACH,OAAO,CAAC,SAAS;IAoBjB;;OAEG;IACH,OAAO,CAAC,UAAU;IAuBlB,OAAO,CAAC,UAAU;IAKlB,OAAO,CAAC,aAAa;IAWrB,OAAO,CAAC,iBAAiB;IAQzB,OAAO,CAAC,gBAAgB;IAKxB,OAAO,CAAC,mBAAmB;IAyB3B,OAAO,CAAC,yBAAyB;IAYjC,OAAO,CAAC,oBAAoB;IAU5B,OAAO,CAAC,0BAA0B;IA4BlC,OAAO,CAAC,qBAAqB;IAgB7B,OAAO,CAAC,oBAAoB;CA6B7B;AAGD,eAAO,MAAM,eAAe,2BAAkC,CAAC"}
|