@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 ADDED
@@ -0,0 +1,366 @@
1
+ # 🚀 Intelligent Agent MCP Server
2
+
3
+ A powerful Model Context Protocol (MCP) server featuring two core capabilities:
4
+ - **🧠 The Brain** (`sequential_thinking`) - Deep reasoning and planning
5
+ - **🤖 The Body** (`orchestrator`) - Parallel task execution
6
+
7
+ ## 📋 Overview
8
+
9
+ This MCP server enables AI agents to:
10
+ 1. Think through complex problems step-by-step with branching and revision
11
+ 2. Execute multi-step task plans with parallel processing and dependency management
12
+
13
+ ```
14
+ ┌─────────────────────────────────────────────────────────────────┐
15
+ │ Intelligent Agent Flow │
16
+ ├─────────────────────────────────────────────────────────────────┤
17
+ │ │
18
+ │ User Query → [sequential_thinking] → Plan → [orchestrator] │
19
+ │ (Analysis) (Execution) │
20
+ │ ↓ ↓ │
21
+ │ Thought Steps Parallel Tasks │
22
+ │ Branching/Revision DAG Resolution │
23
+ │ Hypothesis Testing Result Aggregation │
24
+ │ ↓ ↓ │
25
+ │ Final Plan Final Results │
26
+ │ │
27
+ └─────────────────────────────────────────────────────────────────┘
28
+ ```
29
+
30
+ ## 🛠️ Installation
31
+
32
+ ```bash
33
+ # Clone or create the project
34
+ cd intelligent-agent-mcp
35
+
36
+ # Install dependencies
37
+ npm install
38
+
39
+ # Build TypeScript
40
+ npm run build
41
+
42
+ # Run the server
43
+ npm start
44
+ ```
45
+
46
+ ## ⚙️ Configuration
47
+
48
+ Add to your MCP client configuration (e.g., Claude Desktop):
49
+
50
+ ```json
51
+ {
52
+ "mcpServers": {
53
+ "intelligent-agent": {
54
+ "command": "node",
55
+ "args": ["/path/to/intelligent-agent-mcp/dist/index.js"]
56
+ }
57
+ }
58
+ }
59
+ ```
60
+
61
+ ---
62
+
63
+ ## 🧠 Tool 1: Sequential Thinking (The Brain)
64
+
65
+ A sophisticated reasoning system for complex problem-solving.
66
+
67
+ ### Features
68
+
69
+ | Feature | Description |
70
+ |---------|-------------|
71
+ | **Iterative Thinking** | Step-by-step reasoning with adjustable depth |
72
+ | **Dynamic Adjustment** | Modify thinking steps on-the-fly |
73
+ | **Branching** | Explore alternative solution paths |
74
+ | **Revision** | Correct previous thoughts when errors found |
75
+ | **Hypothesis Testing** | Formulate and verify theories |
76
+ | **Confidence Tracking** | Monitor certainty levels |
77
+
78
+ ### Actions
79
+
80
+ | Action | Description | Required Params |
81
+ |--------|-------------|-----------------|
82
+ | `start_session` | Begin new thinking session | `problemStatement` |
83
+ | `add_thought` | Add a reasoning step | `sessionId`, `thought` |
84
+ | `create_branch` | Explore alternative | `sessionId`, `branchFromThoughtId` |
85
+ | `revise_thought` | Correct previous thought | `sessionId`, `reviseThoughtId`, `thought` |
86
+ | `set_hypothesis` | Propose testable theory | `sessionId`, `hypothesis` |
87
+ | `verify_hypothesis` | Confirm/refute theory | `sessionId`, `verificationStatus` |
88
+ | `adjust_total_thoughts` | Change thinking depth | `sessionId`, `totalThoughts` |
89
+ | `conclude` | Synthesize final answer | `sessionId`, `thought` |
90
+ | `get_status` | Check session progress | `sessionId` |
91
+ | `get_history` | Review all thoughts | `sessionId` |
92
+
93
+ ### Example Usage
94
+
95
+ ```typescript
96
+ // 1. Start a thinking session
97
+ {
98
+ "action": "start_session",
99
+ "problemStatement": "Design a scalable microservices architecture for an e-commerce platform",
100
+ "totalThoughts": 6
101
+ }
102
+
103
+ // 2. Add initial analysis
104
+ {
105
+ "action": "add_thought",
106
+ "sessionId": "abc-123",
107
+ "thought": "The core domains are: User Management, Product Catalog, Order Processing, Payment, and Inventory",
108
+ "thoughtType": "initial_analysis",
109
+ "confidence": 85
110
+ }
111
+
112
+ // 3. Set a hypothesis
113
+ {
114
+ "action": "set_hypothesis",
115
+ "sessionId": "abc-123",
116
+ "hypothesis": "Event-driven architecture with Kafka will handle peak loads better than synchronous REST"
117
+ }
118
+
119
+ // 4. Create a branch to explore alternatives
120
+ {
121
+ "action": "create_branch",
122
+ "sessionId": "abc-123",
123
+ "branchFromThoughtId": "thought-456",
124
+ "branchLabel": "Option B: GraphQL Federation",
125
+ "thought": "Alternative approach using GraphQL for unified API layer"
126
+ }
127
+
128
+ // 5. Verify the hypothesis
129
+ {
130
+ "action": "verify_hypothesis",
131
+ "sessionId": "abc-123",
132
+ "verificationStatus": "verified",
133
+ "verificationEvidence": "Benchmark shows 3x throughput improvement under load"
134
+ }
135
+
136
+ // 6. Conclude
137
+ {
138
+ "action": "conclude",
139
+ "sessionId": "abc-123",
140
+ "thought": "Recommended architecture: Event-driven microservices with Kafka, using CQRS pattern for read-heavy services",
141
+ "confidence": 90
142
+ }
143
+ ```
144
+
145
+ ---
146
+
147
+ ## 🤖 Tool 2: Orchestrator (The Body)
148
+
149
+ A DAG-based execution engine for parallel task processing.
150
+
151
+ ### Features
152
+
153
+ | Feature | Description |
154
+ |---------|-------------|
155
+ | **DAG Execution** | Topological sorting for dependency resolution |
156
+ | **Parallel Processing** | Independent tasks run concurrently |
157
+ | **Tool Chaining** | Reference outputs from previous tasks |
158
+ | **Error Handling** | Graceful degradation with retries |
159
+ | **Result Aggregation** | Combine all task outputs |
160
+
161
+ ### Built-in Tools
162
+
163
+ | Tool | Description | Input |
164
+ |------|-------------|-------|
165
+ | `echo` | Returns input as-is | `{ any: "value" }` |
166
+ | `delay` | Waits specified ms | `{ milliseconds: 1000 }` |
167
+ | `transform` | Text/number transforms | `{ data: "text", operation: "uppercase" }` |
168
+ | `aggregate` | Combine values | `{ values: [...], operation: "sum" }` |
169
+ | `fetch` | HTTP request (simulated) | `{ url: "https://..." }` |
170
+ | `compute` | Math expressions | `{ expression: "a + b", variables: { a: 1, b: 2 } }` |
171
+
172
+ ### Transform Operations
173
+ - `uppercase` / `lowercase` / `reverse` / `length` / `double`
174
+
175
+ ### Aggregate Operations
176
+ - `sum` / `concat` / `array` / `count`
177
+
178
+ ### Actions
179
+
180
+ | Action | Description | Required Params |
181
+ |--------|-------------|-----------------|
182
+ | `validate_plan` | Check plan validity | `plan` |
183
+ | `execute_plan` | Run the full plan | `plan` |
184
+ | `get_execution_status` | Check previous results | `planId` |
185
+
186
+ ### Example: Parallel Data Processing
187
+
188
+ ```typescript
189
+ {
190
+ "action": "execute_plan",
191
+ "plan": {
192
+ "planId": "data-pipeline-001",
193
+ "name": "Parallel Data Pipeline",
194
+ "tasks": [
195
+ {
196
+ "id": "fetch_users",
197
+ "name": "Fetch Users",
198
+ "toolName": "fetch",
199
+ "toolInput": { "url": "https://api.example.com/users" },
200
+ "dependencies": []
201
+ },
202
+ {
203
+ "id": "fetch_orders",
204
+ "name": "Fetch Orders",
205
+ "toolName": "fetch",
206
+ "toolInput": { "url": "https://api.example.com/orders" },
207
+ "dependencies": []
208
+ },
209
+ {
210
+ "id": "fetch_products",
211
+ "name": "Fetch Products",
212
+ "toolName": "fetch",
213
+ "toolInput": { "url": "https://api.example.com/products" },
214
+ "dependencies": []
215
+ },
216
+ {
217
+ "id": "transform_users",
218
+ "name": "Process Users",
219
+ "toolName": "transform",
220
+ "toolInput": {
221
+ "data": "${fetch_users.body}",
222
+ "operation": "uppercase"
223
+ },
224
+ "dependencies": ["fetch_users"]
225
+ },
226
+ {
227
+ "id": "aggregate_all",
228
+ "name": "Combine Results",
229
+ "toolName": "aggregate",
230
+ "toolInput": {
231
+ "values": [
232
+ "${fetch_users}",
233
+ "${fetch_orders}",
234
+ "${fetch_products}"
235
+ ],
236
+ "operation": "array"
237
+ },
238
+ "dependencies": ["fetch_users", "fetch_orders", "fetch_products"]
239
+ }
240
+ ]
241
+ }
242
+ }
243
+ ```
244
+
245
+ ### Execution Visualization
246
+
247
+ ```
248
+ ┌─────────────────────────────────────────────────┐
249
+ │ DAG Execution Visualization │
250
+ ├─────────────────────────────────────────────────┤
251
+ │ Layer 1 (Parallel): │
252
+ │ ├── Fetch Users (no deps) │
253
+ │ ├── Fetch Orders (no deps) │
254
+ │ ├── Fetch Products (no deps) │
255
+ │ ↓ │
256
+ │ Layer 2 (Parallel): │
257
+ │ ├── Process Users ← [fetch_users] │
258
+ │ ├── Combine Results ← [fetch_users, ...] │
259
+ └─────────────────────────────────────────────────┘
260
+ ```
261
+
262
+ ---
263
+
264
+ ## 🔗 Integration Workflow
265
+
266
+ The recommended pattern for complex tasks:
267
+
268
+ ```
269
+ 1. User: "Analyze competitors and create a market report"
270
+
271
+ 2. AI calls sequential_thinking:
272
+ - start_session: "Analyze competitors and create market report"
273
+ - add_thought: "Need to gather data from multiple sources"
274
+ - add_thought: "Identify key competitors: A, B, C"
275
+ - set_hypothesis: "Competitor A leads in market share"
276
+ - add_thought: "Data sources: financial reports, social media, reviews"
277
+ - conclude: "Plan: Fetch data in parallel, then synthesize"
278
+
279
+ 3. AI creates execution plan from thinking output
280
+
281
+ 4. AI calls orchestrator:
282
+ - execute_plan with parallel fetch tasks
283
+ - Aggregate results
284
+ - Generate final report
285
+
286
+ 5. Return synthesized results to user
287
+ ```
288
+
289
+ ---
290
+
291
+ ## 📊 Error Handling
292
+
293
+ ### Sequential Thinking
294
+ - Invalid sessions return helpful error messages
295
+ - Unverified hypotheses block conclusion
296
+ - Revision history maintained for audit
297
+
298
+ ### Orchestrator
299
+ - Failed tasks don't crash the pipeline
300
+ - Retry support with configurable delays
301
+ - Skipped tasks for unmet dependencies
302
+ - Comprehensive error reporting
303
+
304
+ ```typescript
305
+ // Example error response
306
+ {
307
+ "success": false,
308
+ "status": "completed_with_errors",
309
+ "errors": [
310
+ {
311
+ "taskId": "fetch_data",
312
+ "taskName": "Fetch External Data",
313
+ "error": "Task timed out after 5000ms",
314
+ "timestamp": "2024-01-15T10:30:00Z"
315
+ }
316
+ ]
317
+ }
318
+ ```
319
+
320
+ ---
321
+
322
+ ## 🧪 Testing
323
+
324
+ ```bash
325
+ # Run in development mode
326
+ npm run dev
327
+
328
+ # Build and run
329
+ npm run build && npm start
330
+ ```
331
+
332
+ ---
333
+
334
+ ## 📁 Project Structure
335
+
336
+ ```
337
+ intelligent-agent-mcp/
338
+ ├── package.json
339
+ ├── tsconfig.json
340
+ ├── src/
341
+ │ ├── index.ts # MCP Server entry point
342
+ │ ├── tools/
343
+ │ │ ├── sequential-thinking.ts # The Brain
344
+ │ │ └── orchestrator.ts # The Body
345
+ │ ├── types/
346
+ │ │ └── index.ts # TypeScript interfaces
347
+ │ └── utils/
348
+ │ └── dag.ts # DAG utilities
349
+ └── README.md
350
+ ```
351
+
352
+ ---
353
+
354
+ ## 📜 License
355
+
356
+ MIT
357
+
358
+ ---
359
+
360
+ ## 🤝 Contributing
361
+
362
+ Contributions welcome! Areas of interest:
363
+ - Additional built-in tools for orchestrator
364
+ - Persistent session storage for thinking
365
+ - WebSocket transport support
366
+ - Visualization dashboard
package/dist/dag.d.ts ADDED
@@ -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/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"}
package/dist/dag.js ADDED
@@ -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/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,CAAC;IAEzC,iCAAiC;IACjC,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;QAC9B,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACpC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;gBACtB,mBAAmB,CAAC,IAAI,CAAC,SAAS,IAAI,CAAC,EAAE,mCAAmC,GAAG,GAAG,CAAC,CAAC;YACtF,CAAC;QACH,CAAC;IACH,CAAC;IAED,IAAI,mBAAmB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACnC,MAAM,CAAC,IAAI,CAAC,GAAG,mBAAmB,CAA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