@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,142 @@
|
|
|
1
|
+
export interface ThoughtStep {
|
|
2
|
+
id: string;
|
|
3
|
+
stepNumber: number;
|
|
4
|
+
thought: string;
|
|
5
|
+
thoughtType: ThoughtType;
|
|
6
|
+
timestamp: string;
|
|
7
|
+
parentId?: string;
|
|
8
|
+
branchLabel?: string;
|
|
9
|
+
isRevision?: boolean;
|
|
10
|
+
revisedFromId?: string;
|
|
11
|
+
hypothesis?: string;
|
|
12
|
+
verificationStatus?: VerificationStatus;
|
|
13
|
+
verificationEvidence?: string;
|
|
14
|
+
confidence: number;
|
|
15
|
+
metadata?: Record<string, unknown>;
|
|
16
|
+
}
|
|
17
|
+
export type ThoughtType = 'initial_analysis' | 'decomposition' | 'hypothesis' | 'verification' | 'branch_exploration' | 'synthesis' | 'revision' | 'conclusion';
|
|
18
|
+
export type VerificationStatus = 'pending' | 'verified' | 'refuted' | 'partially_verified' | 'needs_more_evidence';
|
|
19
|
+
export interface ThinkingSession {
|
|
20
|
+
sessionId: string;
|
|
21
|
+
problemStatement: string;
|
|
22
|
+
totalThoughts: number;
|
|
23
|
+
currentStep: number;
|
|
24
|
+
thoughtHistory: ThoughtStep[];
|
|
25
|
+
branches: Branch[];
|
|
26
|
+
status: SessionStatus;
|
|
27
|
+
createdAt: string;
|
|
28
|
+
updatedAt: string;
|
|
29
|
+
finalConclusion?: string;
|
|
30
|
+
}
|
|
31
|
+
export interface Branch {
|
|
32
|
+
id: string;
|
|
33
|
+
label: string;
|
|
34
|
+
parentThoughtId: string;
|
|
35
|
+
thoughtIds: string[];
|
|
36
|
+
status: 'active' | 'merged' | 'abandoned';
|
|
37
|
+
mergedIntoId?: string;
|
|
38
|
+
}
|
|
39
|
+
export type SessionStatus = 'in_progress' | 'awaiting_verification' | 'completed' | 'paused';
|
|
40
|
+
export interface SequentialThinkingInput {
|
|
41
|
+
action: ThinkingAction;
|
|
42
|
+
sessionId?: string;
|
|
43
|
+
problemStatement?: string;
|
|
44
|
+
thought?: string;
|
|
45
|
+
thoughtType?: ThoughtType;
|
|
46
|
+
totalThoughts?: number;
|
|
47
|
+
branchFromThoughtId?: string;
|
|
48
|
+
branchLabel?: string;
|
|
49
|
+
reviseThoughtId?: string;
|
|
50
|
+
hypothesis?: string;
|
|
51
|
+
verificationEvidence?: string;
|
|
52
|
+
verificationStatus?: VerificationStatus;
|
|
53
|
+
confidence?: number;
|
|
54
|
+
}
|
|
55
|
+
export type ThinkingAction = 'start_session' | 'add_thought' | 'create_branch' | 'revise_thought' | 'set_hypothesis' | 'verify_hypothesis' | 'adjust_total_thoughts' | 'conclude' | 'get_status' | 'get_history';
|
|
56
|
+
export interface SequentialThinkingOutput {
|
|
57
|
+
success: boolean;
|
|
58
|
+
sessionId: string;
|
|
59
|
+
currentStep: number;
|
|
60
|
+
totalThoughts: number;
|
|
61
|
+
status: SessionStatus;
|
|
62
|
+
thought?: ThoughtStep;
|
|
63
|
+
thoughtHistory?: ThoughtStep[];
|
|
64
|
+
branches?: Branch[];
|
|
65
|
+
message: string;
|
|
66
|
+
nextSuggestedActions?: string[];
|
|
67
|
+
conclusion?: string;
|
|
68
|
+
}
|
|
69
|
+
export interface TaskNode {
|
|
70
|
+
id: string;
|
|
71
|
+
name: string;
|
|
72
|
+
description?: string;
|
|
73
|
+
toolName: string;
|
|
74
|
+
toolInput: Record<string, unknown>;
|
|
75
|
+
dependencies: string[];
|
|
76
|
+
timeout?: number;
|
|
77
|
+
retryCount?: number;
|
|
78
|
+
retryDelay?: number;
|
|
79
|
+
}
|
|
80
|
+
export interface ExecutionPlan {
|
|
81
|
+
planId: string;
|
|
82
|
+
name: string;
|
|
83
|
+
description?: string;
|
|
84
|
+
tasks: TaskNode[];
|
|
85
|
+
metadata?: Record<string, unknown>;
|
|
86
|
+
}
|
|
87
|
+
export interface TaskResult {
|
|
88
|
+
taskId: string;
|
|
89
|
+
taskName: string;
|
|
90
|
+
status: TaskStatus;
|
|
91
|
+
result?: unknown;
|
|
92
|
+
error?: string;
|
|
93
|
+
startTime: string;
|
|
94
|
+
endTime: string;
|
|
95
|
+
duration: number;
|
|
96
|
+
retries: number;
|
|
97
|
+
}
|
|
98
|
+
export type TaskStatus = 'pending' | 'running' | 'completed' | 'failed' | 'skipped';
|
|
99
|
+
export interface ExecutionResult {
|
|
100
|
+
planId: string;
|
|
101
|
+
planName: string;
|
|
102
|
+
status: ExecutionStatus;
|
|
103
|
+
taskResults: TaskResult[];
|
|
104
|
+
startTime: string;
|
|
105
|
+
endTime: string;
|
|
106
|
+
totalDuration: number;
|
|
107
|
+
successCount: number;
|
|
108
|
+
failureCount: number;
|
|
109
|
+
skippedCount: number;
|
|
110
|
+
executionOrder: string[][];
|
|
111
|
+
aggregatedResults: Record<string, unknown>;
|
|
112
|
+
errors: ExecutionError[];
|
|
113
|
+
}
|
|
114
|
+
export type ExecutionStatus = 'completed' | 'completed_with_errors' | 'failed';
|
|
115
|
+
export interface ExecutionError {
|
|
116
|
+
taskId: string;
|
|
117
|
+
taskName: string;
|
|
118
|
+
error: string;
|
|
119
|
+
timestamp: string;
|
|
120
|
+
}
|
|
121
|
+
export interface OrchestratorInput {
|
|
122
|
+
action: OrchestratorAction;
|
|
123
|
+
plan?: ExecutionPlan;
|
|
124
|
+
planId?: string;
|
|
125
|
+
}
|
|
126
|
+
export type OrchestratorAction = 'execute_plan' | 'validate_plan' | 'get_execution_status';
|
|
127
|
+
export interface OrchestratorOutput {
|
|
128
|
+
success: boolean;
|
|
129
|
+
message: string;
|
|
130
|
+
result?: ExecutionResult;
|
|
131
|
+
validationErrors?: string[];
|
|
132
|
+
executionOrder?: string[][];
|
|
133
|
+
}
|
|
134
|
+
export interface ToolDefinition {
|
|
135
|
+
name: string;
|
|
136
|
+
description: string;
|
|
137
|
+
execute: (input: Record<string, unknown>) => Promise<unknown>;
|
|
138
|
+
}
|
|
139
|
+
export interface ToolRegistry {
|
|
140
|
+
[toolName: string]: ToolDefinition;
|
|
141
|
+
}
|
|
142
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAA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src/types/index.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,wCAAwC;AACxC,+CAA+C"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { ExecutionPlan } from '../types/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* DAG (Directed Acyclic Graph) Utilities
|
|
4
|
+
* Provides topological sorting and parallel layer detection for task orchestration
|
|
5
|
+
*/
|
|
6
|
+
export interface DAGValidationResult {
|
|
7
|
+
isValid: boolean;
|
|
8
|
+
errors: string[];
|
|
9
|
+
hasCycle: boolean;
|
|
10
|
+
missingDependencies: string[];
|
|
11
|
+
}
|
|
12
|
+
export interface TopologicalResult {
|
|
13
|
+
isValid: boolean;
|
|
14
|
+
order: string[];
|
|
15
|
+
layers: string[][];
|
|
16
|
+
errors: string[];
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Validates a DAG for cycles and missing dependencies
|
|
20
|
+
*/
|
|
21
|
+
export declare function validateDAG(plan: ExecutionPlan): DAGValidationResult;
|
|
22
|
+
/**
|
|
23
|
+
* Performs topological sort and groups tasks into parallel execution layers
|
|
24
|
+
* Uses Kahn's algorithm for layered topological sort
|
|
25
|
+
*/
|
|
26
|
+
export declare function topologicalSortWithLayers(plan: ExecutionPlan): TopologicalResult;
|
|
27
|
+
/**
|
|
28
|
+
* Gets the maximum parallelism possible for a plan
|
|
29
|
+
*/
|
|
30
|
+
export declare function getMaxParallelism(plan: ExecutionPlan): number;
|
|
31
|
+
/**
|
|
32
|
+
* Calculates critical path (longest execution path)
|
|
33
|
+
*/
|
|
34
|
+
export declare function getCriticalPath(plan: ExecutionPlan): string[];
|
|
35
|
+
/**
|
|
36
|
+
* Visualizes the DAG as ASCII art
|
|
37
|
+
*/
|
|
38
|
+
export declare function visualizeDAG(plan: ExecutionPlan): string;
|
|
39
|
+
//# sourceMappingURL=dag.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dag.d.ts","sourceRoot":"","sources":["../../src/utils/dag.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAY,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEjE;;;GAGG;AAEH,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;IAClB,mBAAmB,EAAE,MAAM,EAAE,CAAC;CAC/B;AAED,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC;IACnB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,aAAa,GAAG,mBAAmB,CA8BpE;AAuED;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,aAAa,GAAG,iBAAiB,CAkFhF;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,aAAa,GAAG,MAAM,CAK7D;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,aAAa,GAAG,MAAM,EAAE,CAwC7D;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,aAAa,GAAG,MAAM,CAkCxD"}
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validates a DAG for cycles and missing dependencies
|
|
3
|
+
*/
|
|
4
|
+
export function validateDAG(plan) {
|
|
5
|
+
const errors = [];
|
|
6
|
+
const taskIds = new Set(plan.tasks.map(t => t.id));
|
|
7
|
+
const missingDependencies = [];
|
|
8
|
+
// Check for missing dependencies
|
|
9
|
+
for (const task of plan.tasks) {
|
|
10
|
+
for (const dep of task.dependencies) {
|
|
11
|
+
if (!taskIds.has(dep)) {
|
|
12
|
+
missingDependencies.push(`Task "${task.id}" depends on non-existent task "${dep}"`);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
if (missingDependencies.length > 0) {
|
|
17
|
+
errors.push(...missingDependencies);
|
|
18
|
+
}
|
|
19
|
+
// Check for cycles using DFS
|
|
20
|
+
const hasCycle = detectCycle(plan.tasks);
|
|
21
|
+
if (hasCycle) {
|
|
22
|
+
errors.push('Circular dependency detected in task graph');
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
isValid: errors.length === 0,
|
|
26
|
+
errors,
|
|
27
|
+
hasCycle,
|
|
28
|
+
missingDependencies
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Detects cycles in the task graph using DFS with coloring
|
|
33
|
+
*/
|
|
34
|
+
function detectCycle(tasks) {
|
|
35
|
+
const WHITE = 0; // Not visited
|
|
36
|
+
const GRAY = 1; // Currently visiting (in recursion stack)
|
|
37
|
+
const BLACK = 2; // Completely visited
|
|
38
|
+
const color = new Map();
|
|
39
|
+
const adjacency = buildAdjacencyList(tasks);
|
|
40
|
+
// Initialize all nodes as white
|
|
41
|
+
for (const task of tasks) {
|
|
42
|
+
color.set(task.id, WHITE);
|
|
43
|
+
}
|
|
44
|
+
function dfs(nodeId) {
|
|
45
|
+
color.set(nodeId, GRAY);
|
|
46
|
+
const neighbors = adjacency.get(nodeId) || [];
|
|
47
|
+
for (const neighbor of neighbors) {
|
|
48
|
+
if (color.get(neighbor) === GRAY) {
|
|
49
|
+
// Found a back edge - cycle exists
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
if (color.get(neighbor) === WHITE && dfs(neighbor)) {
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
color.set(nodeId, BLACK);
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
// Check all nodes (handles disconnected components)
|
|
60
|
+
for (const task of tasks) {
|
|
61
|
+
if (color.get(task.id) === WHITE) {
|
|
62
|
+
if (dfs(task.id)) {
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Builds adjacency list from tasks (task -> tasks that depend on it)
|
|
71
|
+
*/
|
|
72
|
+
function buildAdjacencyList(tasks) {
|
|
73
|
+
const adjacency = new Map();
|
|
74
|
+
// Initialize empty arrays for all tasks
|
|
75
|
+
for (const task of tasks) {
|
|
76
|
+
adjacency.set(task.id, []);
|
|
77
|
+
}
|
|
78
|
+
// Build reverse adjacency (which tasks depend on which)
|
|
79
|
+
for (const task of tasks) {
|
|
80
|
+
for (const dep of task.dependencies) {
|
|
81
|
+
const dependents = adjacency.get(dep) || [];
|
|
82
|
+
dependents.push(task.id);
|
|
83
|
+
adjacency.set(dep, dependents);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return adjacency;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Performs topological sort and groups tasks into parallel execution layers
|
|
90
|
+
* Uses Kahn's algorithm for layered topological sort
|
|
91
|
+
*/
|
|
92
|
+
export function topologicalSortWithLayers(plan) {
|
|
93
|
+
const validation = validateDAG(plan);
|
|
94
|
+
if (!validation.isValid) {
|
|
95
|
+
return {
|
|
96
|
+
isValid: false,
|
|
97
|
+
order: [],
|
|
98
|
+
layers: [],
|
|
99
|
+
errors: validation.errors
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
const tasks = plan.tasks;
|
|
103
|
+
const taskMap = new Map(tasks.map(t => [t.id, t]));
|
|
104
|
+
// Calculate in-degree for each task
|
|
105
|
+
const inDegree = new Map();
|
|
106
|
+
for (const task of tasks) {
|
|
107
|
+
inDegree.set(task.id, task.dependencies.length);
|
|
108
|
+
}
|
|
109
|
+
// Build reverse adjacency (task -> tasks that depend on it)
|
|
110
|
+
const dependents = new Map();
|
|
111
|
+
for (const task of tasks) {
|
|
112
|
+
dependents.set(task.id, []);
|
|
113
|
+
}
|
|
114
|
+
for (const task of tasks) {
|
|
115
|
+
for (const dep of task.dependencies) {
|
|
116
|
+
dependents.get(dep).push(task.id);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
const layers = [];
|
|
120
|
+
const order = [];
|
|
121
|
+
const processed = new Set();
|
|
122
|
+
// Start with tasks that have no dependencies (in-degree = 0)
|
|
123
|
+
let currentLayer = tasks
|
|
124
|
+
.filter(t => t.dependencies.length === 0)
|
|
125
|
+
.map(t => t.id);
|
|
126
|
+
while (currentLayer.length > 0) {
|
|
127
|
+
// Sort for deterministic ordering
|
|
128
|
+
currentLayer.sort();
|
|
129
|
+
layers.push([...currentLayer]);
|
|
130
|
+
order.push(...currentLayer);
|
|
131
|
+
const nextLayer = [];
|
|
132
|
+
for (const taskId of currentLayer) {
|
|
133
|
+
processed.add(taskId);
|
|
134
|
+
// Reduce in-degree for all dependent tasks
|
|
135
|
+
for (const dependentId of dependents.get(taskId) || []) {
|
|
136
|
+
const newInDegree = inDegree.get(dependentId) - 1;
|
|
137
|
+
inDegree.set(dependentId, newInDegree);
|
|
138
|
+
// If all dependencies are satisfied, add to next layer
|
|
139
|
+
if (newInDegree === 0 && !processed.has(dependentId)) {
|
|
140
|
+
nextLayer.push(dependentId);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
currentLayer = nextLayer;
|
|
145
|
+
}
|
|
146
|
+
// Verify all tasks were processed
|
|
147
|
+
if (order.length !== tasks.length) {
|
|
148
|
+
return {
|
|
149
|
+
isValid: false,
|
|
150
|
+
order: [],
|
|
151
|
+
layers: [],
|
|
152
|
+
errors: ['Not all tasks could be processed - possible cycle or invalid graph']
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
return {
|
|
156
|
+
isValid: true,
|
|
157
|
+
order,
|
|
158
|
+
layers,
|
|
159
|
+
errors: []
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Gets the maximum parallelism possible for a plan
|
|
164
|
+
*/
|
|
165
|
+
export function getMaxParallelism(plan) {
|
|
166
|
+
const result = topologicalSortWithLayers(plan);
|
|
167
|
+
if (!result.isValid)
|
|
168
|
+
return 0;
|
|
169
|
+
return Math.max(...result.layers.map(layer => layer.length));
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Calculates critical path (longest execution path)
|
|
173
|
+
*/
|
|
174
|
+
export function getCriticalPath(plan) {
|
|
175
|
+
const result = topologicalSortWithLayers(plan);
|
|
176
|
+
if (!result.isValid)
|
|
177
|
+
return [];
|
|
178
|
+
const taskMap = new Map(plan.tasks.map(t => [t.id, t]));
|
|
179
|
+
const longestPath = new Map();
|
|
180
|
+
// Initialize: tasks with no dependencies have path of just themselves
|
|
181
|
+
for (const task of plan.tasks) {
|
|
182
|
+
if (task.dependencies.length === 0) {
|
|
183
|
+
longestPath.set(task.id, [task.id]);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
// Process in topological order
|
|
187
|
+
for (const taskId of result.order) {
|
|
188
|
+
const task = taskMap.get(taskId);
|
|
189
|
+
if (task.dependencies.length > 0) {
|
|
190
|
+
// Find the longest path among dependencies
|
|
191
|
+
let maxPath = [];
|
|
192
|
+
for (const depId of task.dependencies) {
|
|
193
|
+
const depPath = longestPath.get(depId) || [];
|
|
194
|
+
if (depPath.length > maxPath.length) {
|
|
195
|
+
maxPath = depPath;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
longestPath.set(taskId, [...maxPath, taskId]);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
// Find the overall longest path
|
|
202
|
+
let criticalPath = [];
|
|
203
|
+
for (const path of longestPath.values()) {
|
|
204
|
+
if (path.length > criticalPath.length) {
|
|
205
|
+
criticalPath = path;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
return criticalPath;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Visualizes the DAG as ASCII art
|
|
212
|
+
*/
|
|
213
|
+
export function visualizeDAG(plan) {
|
|
214
|
+
const result = topologicalSortWithLayers(plan);
|
|
215
|
+
if (!result.isValid) {
|
|
216
|
+
return `Invalid DAG: ${result.errors.join(', ')}`;
|
|
217
|
+
}
|
|
218
|
+
const taskMap = new Map(plan.tasks.map(t => [t.id, t]));
|
|
219
|
+
const lines = [];
|
|
220
|
+
lines.push('┌─────────────────────────────────────────────────┐');
|
|
221
|
+
lines.push('│ DAG Execution Visualization │');
|
|
222
|
+
lines.push('├─────────────────────────────────────────────────┤');
|
|
223
|
+
for (let i = 0; i < result.layers.length; i++) {
|
|
224
|
+
const layer = result.layers[i];
|
|
225
|
+
lines.push(`│ Layer ${i + 1} (Parallel): │`);
|
|
226
|
+
for (const taskId of layer) {
|
|
227
|
+
const task = taskMap.get(taskId);
|
|
228
|
+
const deps = task.dependencies.length > 0
|
|
229
|
+
? ` ← [${task.dependencies.join(', ')}]`
|
|
230
|
+
: ' (no deps)';
|
|
231
|
+
const line = `│ ├── ${task.name}${deps}`;
|
|
232
|
+
lines.push(line.padEnd(50) + '│');
|
|
233
|
+
}
|
|
234
|
+
if (i < result.layers.length - 1) {
|
|
235
|
+
lines.push('│ ↓ │');
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
lines.push('└─────────────────────────────────────────────────┘');
|
|
239
|
+
return lines.join('\n');
|
|
240
|
+
}
|
|
241
|
+
//# sourceMappingURL=dag.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dag.js","sourceRoot":"","sources":["../../src/utils/dag.ts"],"names":[],"mappings":"AAqBA;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,IAAmB;IAC7C,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACnD,MAAM,mBAAmB,GAAa,EAAE,CAA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AK,CAAC,IAAI,CAAC,qDAAqD,CAAC,CAAC;QACpE,CAAC;IACH,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,qDAAqD,CAAC,CAAC;IAElE,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@gotza02/mathinking",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "MCP Server with sequential thinking (The Brain) and orchestrator (The Body) capabilities",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"bin": {
|
|
8
|
+
"mathinking": "./dist/index.js"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"dist"
|
|
12
|
+
],
|
|
13
|
+
"publishConfig": {
|
|
14
|
+
"access": "public"
|
|
15
|
+
},
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "tsc",
|
|
18
|
+
"postbuild": "sed -i '1i #!/usr/bin/env node' dist/index.js",
|
|
19
|
+
"start": "node dist/index.js",
|
|
20
|
+
"dev": "tsx src/index.ts",
|
|
21
|
+
"watch": "tsc --watch",
|
|
22
|
+
"test": "tsx src/test-all.ts"
|
|
23
|
+
},
|
|
24
|
+
"keywords": [
|
|
25
|
+
"mcp",
|
|
26
|
+
"agent",
|
|
27
|
+
"orchestration",
|
|
28
|
+
"thinking",
|
|
29
|
+
"reasoning"
|
|
30
|
+
],
|
|
31
|
+
"license": "MIT",
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@modelcontextprotocol/sdk": "^1.0.0",
|
|
34
|
+
"uuid": "^9.0.0"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@types/node": "^20.10.0",
|
|
38
|
+
"@types/uuid": "^9.0.0",
|
|
39
|
+
"tsx": "^4.7.0",
|
|
40
|
+
"typescript": "^5.3.0"
|
|
41
|
+
},
|
|
42
|
+
"engines": {
|
|
43
|
+
"node": ">=18.0.0"
|
|
44
|
+
}
|
|
45
|
+
}
|