claude-flow-novice 2.0.4 → 2.0.5
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/dist/src/cli/commands/guidance.js +668 -487
- package/dist/src/cli/commands/index-validate.js +29 -18
- package/dist/src/cli/commands/mcp-troubleshoot.js +282 -230
- package/dist/src/cli/commands/neural-goal-init.js +125 -92
- package/dist/src/cli/commands/swarm-exec.js +393 -317
- package/dist/src/cli/commands/validate-framework.js +1100 -983
- package/dist/src/cli/commands/validate.js +223 -144
- package/dist/src/cli/main.js +1 -1
- package/dist/src/cli/simple-commands/__tests__/agent.test.js +277 -265
- package/dist/src/cli/simple-commands/__tests__/memory.test.js +7 -6
- package/dist/src/cli/simple-commands/__tests__/swarm.test.js +356 -373
- package/dist/src/cli/simple-commands/__tests__/task.test.js +7 -6
- package/dist/src/cli/simple-commands/agent.js +193 -157
- package/dist/src/cli/simple-commands/analysis.js +446 -336
- package/dist/src/cli/simple-commands/automation-executor.js +1339 -1095
- package/dist/src/cli/simple-commands/automation.js +469 -481
- package/dist/src/cli/simple-commands/batch-manager.js +313 -261
- package/dist/src/cli/simple-commands/claude-telemetry.js +267 -241
- package/dist/src/cli/simple-commands/claude-track.js +90 -68
- package/dist/src/cli/simple-commands/concurrent-display.js +320 -266
- package/dist/src/cli/simple-commands/config.js +290 -245
- package/dist/src/cli/simple-commands/coordination.js +234 -182
- package/dist/src/cli/simple-commands/enhanced-ui-views.js +615 -812
- package/dist/src/cli/simple-commands/enhanced-webui-complete.js +981 -922
- package/dist/src/cli/simple-commands/fix-hook-variables.js +294 -274
- package/dist/src/cli/simple-commands/github/gh-coordinator.js +457 -378
- package/dist/src/cli/simple-commands/github/github-api.js +574 -535
- package/dist/src/cli/simple-commands/github/init.js +303 -276
- package/dist/src/cli/simple-commands/github.js +247 -222
- package/dist/src/cli/simple-commands/goal.js +63 -51
- package/dist/src/cli/simple-commands/hive-mind/auto-save-middleware.js +278 -208
- package/dist/src/cli/simple-commands/hive-mind/communication.js +696 -601
- package/dist/src/cli/simple-commands/hive-mind/core.js +979 -907
- package/dist/src/cli/simple-commands/hive-mind/db-optimizer.js +655 -406
- package/dist/src/cli/simple-commands/hive-mind/mcp-wrapper.js +1245 -1125
- package/dist/src/cli/simple-commands/hive-mind/memory.js +1090 -854
- package/dist/src/cli/simple-commands/hive-mind/performance-optimizer.js +574 -459
- package/dist/src/cli/simple-commands/hive-mind/performance-test.js +347 -263
- package/dist/src/cli/simple-commands/hive-mind/queen.js +768 -727
- package/dist/src/cli/simple-commands/hive-mind/session-manager.js +1049 -745
- package/dist/src/cli/simple-commands/hive-mind-optimize.js +283 -227
- package/dist/src/cli/simple-commands/hive-mind-wizard.js +217 -174
- package/dist/src/cli/simple-commands/hive-mind.js +2282 -1841
- package/dist/src/cli/simple-commands/hive.js +79 -90
- package/dist/src/cli/simple-commands/hook-safety.js +521 -431
- package/dist/src/cli/simple-commands/hooks/session-start-soul.js +254 -203
- package/dist/src/cli/simple-commands/hooks.js +1204 -1064
- package/dist/src/cli/simple-commands/init/agent-copier.js +319 -294
- package/dist/src/cli/simple-commands/init/batch-init.js +562 -496
- package/dist/src/cli/simple-commands/init/claude-commands/claude-flow-commands.js +19 -13
- package/dist/src/cli/simple-commands/init/claude-commands/optimized-claude-flow-commands.js +19 -13
- package/dist/src/cli/simple-commands/init/claude-commands/optimized-slash-commands.js +88 -61
- package/dist/src/cli/simple-commands/init/claude-commands/optimized-sparc-commands.js +150 -125
- package/dist/src/cli/simple-commands/init/claude-commands/slash-commands.js +49 -42
- package/dist/src/cli/simple-commands/init/claude-commands/sparc-commands.js +61 -43
- package/dist/src/cli/simple-commands/init/copy-revised-templates.js +147 -141
- package/dist/src/cli/simple-commands/init/executable-wrapper.js +44 -31
- package/dist/src/cli/simple-commands/init/gitignore-updater.js +90 -64
- package/dist/src/cli/simple-commands/init/help.js +107 -104
- package/dist/src/cli/simple-commands/init/hive-mind-init.js +528 -509
- package/dist/src/cli/simple-commands/init/index.js +1759 -1510
- package/dist/src/cli/simple-commands/init/performance-monitor.js +317 -234
- package/dist/src/cli/simple-commands/init/rollback/backup-manager.js +504 -441
- package/dist/src/cli/simple-commands/init/rollback/index.js +364 -289
- package/dist/src/cli/simple-commands/init/rollback/recovery-manager.js +728 -652
- package/dist/src/cli/simple-commands/init/rollback/rollback-executor.js +481 -416
- package/dist/src/cli/simple-commands/init/rollback/state-tracker.js +448 -369
- package/dist/src/cli/simple-commands/init/sparc/roo-readme.js +2 -1
- package/dist/src/cli/simple-commands/init/sparc/roomodes-config.js +99 -122
- package/dist/src/cli/simple-commands/init/sparc/workflows.js +37 -32
- package/dist/src/cli/simple-commands/init/sparc-structure.js +62 -55
- package/dist/src/cli/simple-commands/init/template-copier.js +533 -421
- package/dist/src/cli/simple-commands/init/templates/coordination-md.js +6 -3
- package/dist/src/cli/simple-commands/init/templates/enhanced-templates.js +318 -344
- package/dist/src/cli/simple-commands/init/templates/github-safe-enhanced.js +218 -173
- package/dist/src/cli/simple-commands/init/templates/github-safe.js +75 -65
- package/dist/src/cli/simple-commands/init/templates/memory-bank-md.js +6 -3
- package/dist/src/cli/simple-commands/init/templates/readme-files.js +4 -2
- package/dist/src/cli/simple-commands/init/templates/safe-hook-patterns.js +230 -187
- package/dist/src/cli/simple-commands/init/templates/sparc-modes.js +80 -53
- package/dist/src/cli/simple-commands/init/templates/verification-claude-md.js +85 -101
- package/dist/src/cli/simple-commands/init/validation/config-validator.js +330 -283
- package/dist/src/cli/simple-commands/init/validation/health-checker.js +561 -495
- package/dist/src/cli/simple-commands/init/validation/index.js +358 -302
- package/dist/src/cli/simple-commands/init/validation/mode-validator.js +359 -308
- package/dist/src/cli/simple-commands/init/validation/post-init-validator.js +366 -389
- package/dist/src/cli/simple-commands/init/validation/pre-init-validator.js +268 -270
- package/dist/src/cli/simple-commands/init/validation/test-runner.js +447 -427
- package/dist/src/cli/simple-commands/init.js +2 -1
- package/dist/src/cli/simple-commands/mcp-health.js +158 -131
- package/dist/src/cli/simple-commands/mcp-integration-layer.js +634 -533
- package/dist/src/cli/simple-commands/mcp.js +400 -345
- package/dist/src/cli/simple-commands/memory-consolidation.js +537 -426
- package/dist/src/cli/simple-commands/memory.js +311 -247
- package/dist/src/cli/simple-commands/migrate-hooks.js +46 -39
- package/dist/src/cli/simple-commands/monitor.js +363 -294
- package/dist/src/cli/simple-commands/neural.js +65 -51
- package/dist/src/cli/simple-commands/pair-autofix-only.js +662 -538
- package/dist/src/cli/simple-commands/pair-basic.js +656 -528
- package/dist/src/cli/simple-commands/pair-old.js +543 -430
- package/dist/src/cli/simple-commands/pair-working.js +751 -615
- package/dist/src/cli/simple-commands/pair.js +751 -615
- package/dist/src/cli/simple-commands/performance-hooks.js +111 -83
- package/dist/src/cli/simple-commands/performance-metrics.js +433 -348
- package/dist/src/cli/simple-commands/process-ui-enhanced.js +787 -708
- package/dist/src/cli/simple-commands/process-ui.js +254 -230
- package/dist/src/cli/simple-commands/realtime-update-system.js +611 -525
- package/dist/src/cli/simple-commands/sparc/architecture.js +1530 -1704
- package/dist/src/cli/simple-commands/sparc/commands.js +516 -438
- package/dist/src/cli/simple-commands/sparc/completion.js +1481 -1224
- package/dist/src/cli/simple-commands/sparc/coordinator.js +978 -913
- package/dist/src/cli/simple-commands/sparc/index.js +298 -241
- package/dist/src/cli/simple-commands/sparc/phase-base.js +390 -314
- package/dist/src/cli/simple-commands/sparc/pseudocode.js +869 -965
- package/dist/src/cli/simple-commands/sparc/refinement.js +1273 -980
- package/dist/src/cli/simple-commands/sparc/specification.js +645 -559
- package/dist/src/cli/simple-commands/sparc-modes/architect.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/ask.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/code.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/debug.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/devops.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/docs-writer.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/generic.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/index.js +55 -47
- package/dist/src/cli/simple-commands/sparc-modes/integration.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/mcp.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/monitoring.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/optimization.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/security-review.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/sparc-orchestrator.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/spec-pseudocode.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/supabase-admin.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/swarm.js +87 -101
- package/dist/src/cli/simple-commands/sparc-modes/tdd.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/tutorial.js +1 -1
- package/dist/src/cli/simple-commands/sparc.js +493 -465
- package/dist/src/cli/simple-commands/start-ui.js +132 -108
- package/dist/src/cli/simple-commands/start-wrapper.js +268 -240
- package/dist/src/cli/simple-commands/start.js +1 -1
- package/dist/src/cli/simple-commands/status.js +275 -254
- package/dist/src/cli/simple-commands/stream-chain-clean.js +171 -128
- package/dist/src/cli/simple-commands/stream-chain-fixed.js +82 -61
- package/dist/src/cli/simple-commands/stream-chain-real.js +331 -267
- package/dist/src/cli/simple-commands/stream-chain-working.js +263 -211
- package/dist/src/cli/simple-commands/stream-chain.js +318 -260
- package/dist/src/cli/simple-commands/stream-processor.js +315 -290
- package/dist/src/cli/simple-commands/swarm-executor.js +222 -189
- package/dist/src/cli/simple-commands/swarm-metrics-integration.js +300 -208
- package/dist/src/cli/simple-commands/swarm-ui.js +703 -623
- package/dist/src/cli/simple-commands/swarm-webui-integration.js +286 -258
- package/dist/src/cli/simple-commands/swarm.js +1082 -887
- package/dist/src/cli/simple-commands/task.js +206 -161
- package/dist/src/cli/simple-commands/timestamp-fix.js +89 -59
- package/dist/src/cli/simple-commands/token-tracker.js +316 -258
- package/dist/src/cli/simple-commands/tool-execution-framework.js +519 -433
- package/dist/src/cli/simple-commands/train-and-stream.js +331 -275
- package/dist/src/cli/simple-commands/training-pipeline.js +725 -619
- package/dist/src/cli/simple-commands/training.js +227 -170
- package/dist/src/cli/simple-commands/verification-hooks.js +284 -261
- package/dist/src/cli/simple-commands/verification-integration.js +417 -389
- package/dist/src/cli/simple-commands/verification-training-integration.js +606 -486
- package/dist/src/cli/simple-commands/verification.js +513 -493
- package/dist/src/cli/simple-commands/web-server.js +836 -766
- package/dist/src/cli/simple-commands/webui-validator.js +124 -106
- package/dist/src/coordination/byzantine-memory-channels.js +25 -1
- package/dist/src/coordination/event-bus/demo-wasm-integration.js +251 -212
- package/dist/src/coordination/event-bus/qe-event-bus.js +748 -608
- package/dist/src/coordination/event-bus/qe-event-bus.test.js +454 -379
- package/dist/src/coordination/iteration-tracker.js +454 -363
- package/dist/src/index.js +384 -35
- package/dist/src/mcp/DEPRECATED.js +60 -46
- package/dist/src/mcp/fixes/mcp-error-fixes.js +134 -115
- package/dist/src/mcp/implementations/agent-tracker.js +128 -114
- package/dist/src/mcp/implementations/daa-tools.js +350 -292
- package/dist/src/mcp/implementations/workflow-tools.js +361 -329
- package/dist/src/mcp/mcp-config-manager.js +1331 -1183
- package/dist/src/mcp/mcp-server-novice-simplified.js +17 -11
- package/dist/src/mcp/mcp-server-novice.js +17 -11
- package/dist/src/mcp/mcp-server-sdk.js +17 -11
- package/dist/src/mcp/mcp-server.js +1484 -1620
- package/dist/src/mcp/ruv-swarm-wrapper.js +239 -209
- package/dist/src/memory/advanced-serializer.js +589 -609
- package/dist/src/memory/enhanced-examples.js +305 -220
- package/dist/src/memory/enhanced-memory.js +336 -295
- package/dist/src/memory/enhanced-session-serializer.js +492 -408
- package/dist/src/memory/fallback-memory-system.js +1021 -900
- package/dist/src/memory/fallback-store.js +131 -93
- package/dist/src/memory/high-performance-serialization.js +730 -592
- package/dist/src/memory/in-memory-store.js +213 -161
- package/dist/src/memory/index.js +157 -123
- package/dist/src/memory/lock-free-structures.js +764 -578
- package/dist/src/memory/memory-mapped-persistence.js +766 -585
- package/dist/src/memory/memory-pressure-manager.js +707 -569
- package/dist/src/memory/migration.js +445 -358
- package/dist/src/memory/shared-memory.js +768 -641
- package/dist/src/memory/sqlite-store.js +325 -245
- package/dist/src/memory/sqlite-wrapper.js +151 -122
- package/dist/src/memory/swarm-memory.js +603 -470
- package/dist/src/memory/test-example.js +134 -126
- package/dist/src/memory/ultra-fast-memory-store.js +821 -622
- package/dist/src/memory/unified-memory-manager.js +437 -356
- package/dist/src/swarm/CodeRefactoringSwarm.js +952 -777
- package/dist/src/utils/__tests__/github-cli-safety-wrapper.test.js +400 -332
- package/dist/src/utils/error-handler.js +2 -36
- package/dist/src/utils/github-cli-safe.js +64 -56
- package/dist/src/utils/github-cli-safety-wrapper.js +546 -451
- package/dist/src/utils/npx-isolated-cache.js +119 -104
- package/dist/src/utils/preference-manager.js +652 -622
- package/dist/src/utils/timezone-utils.js +105 -86
- package/dist/src/web/api/apm-routes.js +353 -0
- package/dist/src/web/api/config/api-config.js +184 -0
- package/dist/src/web/api/middleware/auth.js +203 -0
- package/dist/src/web/api/middleware/cache.js +273 -0
- package/dist/src/web/api/middleware/error-handler.js +257 -0
- package/dist/src/web/api/middleware/request-logger.js +215 -0
- package/dist/src/web/api/middleware/validation.js +323 -0
- package/dist/src/web/api/routes/events.js +463 -0
- package/dist/src/web/api/routes/hierarchy.js +300 -0
- package/dist/src/web/api/routes/index.js +12 -0
- package/dist/src/web/api/routes/metrics.js +559 -0
- package/dist/src/web/api/routes/parallel-status.js +359 -0
- package/dist/src/web/api/routes/status.js +448 -0
- package/dist/src/web/api/server.js +462 -0
- package/dist/src/web/dashboard/hooks/useWebSocket.js +383 -0
- package/dist/src/web/dashboard/index.js +85 -0
- package/dist/src/web/dashboard/realtime/CustomSyncManager.js +439 -0
- package/dist/src/web/dashboard/realtime/NativeWebSocketManager.js +323 -0
- package/dist/src/web/dashboard/realtime/PerformanceBenchmark.js +527 -0
- package/dist/src/web/dashboard/realtime/RealtimeCommunicationManager.js +474 -0
- package/dist/src/web/dashboard/realtime/RealtimeServer.js +666 -0
- package/dist/src/web/dashboard/realtime/SSEManager.js +426 -0
- package/dist/src/web/dashboard/types.js +4 -0
- package/dist/src/web/messaging/agent-status-tracker.js +453 -0
- package/dist/src/web/messaging/human-intervention-system.js +305 -0
- package/dist/src/web/messaging/message-filter.js +302 -0
- package/dist/src/web/messaging/swarm-message-router.js +324 -0
- package/dist/src/web/messaging/transparency-logger.js +421 -0
- package/dist/src/web/portal-server.js +460 -0
- package/dist/src/web/server.js +322 -0
- package/dist/src/web/websocket/apm-websocket-handler.js +453 -0
- package/dist/src/web/websocket/websocket-manager.js +780 -0
- package/package.json +5 -3
- package/dist/src/cli/minimal-main.js +0 -22
- package/dist/src/enterprise/analytics-manager.js +0 -1135
- package/dist/src/enterprise/audit-manager.js +0 -1115
- package/dist/src/enterprise/cloud-manager.js +0 -891
- package/dist/src/enterprise/deployment-manager.js +0 -966
- package/dist/src/enterprise/index.js +0 -6
- package/dist/src/enterprise/project-manager.js +0 -584
- package/dist/src/enterprise/security-manager.js +0 -991
- package/dist/src/migration/index.js +0 -92
- package/dist/src/migration/logger.js +0 -121
- package/dist/src/migration/migration-analyzer.js +0 -268
- package/dist/src/migration/migration-runner.js +0 -522
- package/dist/src/migration/migration-validator.js +0 -285
- package/dist/src/migration/progress-reporter.js +0 -150
- package/dist/src/migration/rollback-manager.js +0 -321
- package/dist/src/migration/tests/migration-system.test.js +0 -7
- package/dist/src/migration/types.js +0 -3
- package/dist/src/swarm/__tests__/integration.test.js +0 -227
- package/dist/src/swarm/__tests__/prompt-copier.test.js +0 -344
- package/dist/src/swarm/advanced-orchestrator.js +0 -1095
- package/dist/src/swarm/claude-code-interface.js +0 -961
- package/dist/src/swarm/claude-flow-executor.js +0 -229
- package/dist/src/swarm/consensus-coordinator.js +0 -475
- package/dist/src/swarm/coordinator.js +0 -2993
- package/dist/src/swarm/direct-executor.js +0 -1180
- package/dist/src/swarm/error-recovery/advanced-error-detection.js +0 -691
- package/dist/src/swarm/error-recovery/automated-recovery-workflows.js +0 -998
- package/dist/src/swarm/error-recovery/error-recovery-coordinator.js +0 -1197
- package/dist/src/swarm/error-recovery/recovery-monitoring.js +0 -772
- package/dist/src/swarm/error-recovery/resilience-architecture.js +0 -714
- package/dist/src/swarm/error-recovery/self-healing-mechanisms.js +0 -1319
- package/dist/src/swarm/error-recovery/test-error-recovery-effectiveness.js +0 -808
- package/dist/src/swarm/executor-v2.js +0 -322
- package/dist/src/swarm/executor.js +0 -815
- package/dist/src/swarm/hive-mind-integration.js +0 -703
- package/dist/src/swarm/index.js +0 -41
- package/dist/src/swarm/json-output-aggregator.js +0 -267
- package/dist/src/swarm/large-scale-coordinator.js +0 -542
- package/dist/src/swarm/mcp-integration-wrapper.js +0 -628
- package/dist/src/swarm/memory.js +0 -1117
- package/dist/src/swarm/optimizations/__tests__/optimization.test.js +0 -348
- package/dist/src/swarm/optimizations/async-file-manager.js +0 -285
- package/dist/src/swarm/optimizations/circular-buffer.js +0 -162
- package/dist/src/swarm/optimizations/connection-pool.js +0 -244
- package/dist/src/swarm/optimizations/index.js +0 -28
- package/dist/src/swarm/optimizations/optimized-executor.js +0 -320
- package/dist/src/swarm/optimizations/ttl-map.js +0 -234
- package/dist/src/swarm/prompt-cli.js +0 -200
- package/dist/src/swarm/prompt-copier-enhanced.js +0 -202
- package/dist/src/swarm/prompt-copier.js +0 -381
- package/dist/src/swarm/prompt-manager.js +0 -295
- package/dist/src/swarm/prompt-utils.js +0 -310
- package/dist/src/swarm/result-aggregator.js +0 -718
- package/dist/src/swarm/sparc-executor.js +0 -1568
- package/dist/src/swarm/strategies/auto.js +0 -758
- package/dist/src/swarm/strategies/base.js +0 -128
- package/dist/src/swarm/strategies/research.js +0 -914
- package/dist/src/swarm/strategies/strategy-metrics-patch.js +0 -2
- package/dist/src/swarm/types.js +0 -52
- package/dist/src/swarm/workers/copy-worker.js +0 -56
- package/dist/src/validators/epic-config-schema.js +0 -214
- package/dist/src/validators/index.js +0 -10
- package/dist/src/validators/swarm-init-validator.js +0 -259
- package/dist/src/validators/todowrite-batching-validator.js +0 -215
- package/dist/src/validators/todowrite-integration.js +0 -187
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/documentSymbols/browser/documentSymbols.js +0 -23
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/dropOrPasteInto/browser/copyPasteContribution.js +0 -57
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/dropOrPasteInto/browser/copyPasteController.js +0 -401
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/dropOrPasteInto/browser/defaultProviders.js +0 -181
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/dropOrPasteInto/browser/dropIntoEditorContribution.js +0 -44
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/dropOrPasteInto/browser/dropIntoEditorController.js +0 -157
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/dropOrPasteInto/browser/edit.js +0 -71
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/editorState/browser/editorState.js +0 -112
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/find/browser/findController.js +0 -990
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/find/browser/findDecorations.js +0 -296
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/find/browser/findModel.js +0 -488
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/find/browser/findOptionsWidget.js +0 -138
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/find/browser/findState.js +0 -243
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/find/browser/findWidget.js +0 -1177
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/folding/browser/folding.js +0 -1093
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/folding/browser/foldingDecorations.js +0 -133
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/folding/browser/foldingModel.js +0 -538
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/folding/browser/foldingRanges.js +0 -351
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/fontZoom/browser/fontZoom.js +0 -49
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/format/browser/format.js +0 -360
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/format/browser/formatActions.js +0 -263
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/format/browser/formattingEdit.js +0 -54
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/gotoSymbol/browser/link/clickLinkGesture.js +0 -149
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/hover/browser/contentHover.js +0 -874
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/inlineCompletions/browser/commandIds.js +0 -7
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/inlineCompletions/browser/commands.js +0 -199
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/linesOperations/browser/copyLinesCommand.js +0 -70
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/quickAccess/browser/commandsQuickAccess.js +0 -26
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/quickAccess/browser/editorNavigationQuickAccess.js +0 -153
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/readOnlyMessage/browser/contribution.js +0 -33
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/semanticTokens/browser/documentSemanticTokens.js +0 -354
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/smartSelect/browser/bracketSelections.js +0 -146
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/suggest/browser/completionModel.js +0 -224
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/unicodeHighlighter/browser/bannerController.js +0 -119
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/edcore.main.js +0 -14
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/editor.all.js +0 -63
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/editor.api.js +0 -55
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/editor.main.js +0 -7
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/editor.worker.js +0 -25
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/standalone/browser/colorizer.js +0 -118
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/language/css/css.worker.js +0 -36869
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/language/css/cssMode.js +0 -2035
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/accessibility/browser/accessibilityService.js +0 -88
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/accessibility/common/accessibility.js +0 -9
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/action/common/action.js +0 -7
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/action/common/actionCommonCategories.js +0 -13
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/actionWidget/browser/actionList.js +0 -276
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/actionWidget/browser/actionWidget.js +0 -248
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/actionWidget/common/actionWidget.js +0 -5
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/actions/common/actions.js +0 -409
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/audioCues/browser/audioCueService.js +0 -176
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/clipboard/browser/clipboardService.js +0 -141
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/clipboard/common/clipboardService.js +0 -6
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/commands/common/commands.js +0 -80
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/configuration/common/configuration.js +0 -86
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/configuration/common/configurationModels.js +0 -554
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/configuration/common/configurationRegistry.js +0 -317
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/configuration/common/configurations.js +0 -41
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/contextkey/browser/contextKeyService.js +0 -432
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/contextkey/common/contextkey.js +0 -1547
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/contextkey/common/contextkeys.js +0 -18
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/contextview/browser/contextMenuHandler.js +0 -124
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/contextview/browser/contextMenuService.js +0 -101
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/contextview/browser/contextView.js +0 -7
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/contextview/browser/contextViewService.js +0 -72
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/dialogs/common/dialogs.js +0 -2
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/dnd/browser/dnd.js +0 -36
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/editor/common/editor.js +0 -17
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/environment/common/environment.js +0 -2
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/extensions/common/extensions.js +0 -47
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/files/common/files.js +0 -9
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/history/browser/contextScopedHistoryWidget.js +0 -105
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/instantiation/common/descriptors.js +0 -11
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/instantiation/common/extensions.js +0 -15
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/keybinding/common/abstractKeybindingService.js +0 -277
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/keybinding/common/baseResolvedKeybinding.js +0 -53
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/quickinput/browser/commandsQuickAccess.js +0 -354
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/theme/browser/defaultStyles.js +0 -162
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/theme/common/colorRegistry.js +0 -482
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/abap/abap.js +0 -10
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/apex/apex.js +0 -10
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/azcli/azcli.js +0 -10
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/bat/bat.js +0 -10
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/bicep/bicep.js +0 -11
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/cameligo/cameligo.js +0 -10
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/clojure/clojure.js +0 -10
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/coffee/coffee.js +0 -10
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/cpp/cpp.js +0 -10
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/csharp/csharp.js +0 -10
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/csp/csp.js +0 -10
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/css/css.js +0 -12
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/cypher/cypher.js +0 -10
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/dart/dart.js +0 -10
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/dockerfile/dockerfile.js +0 -10
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/ecl/ecl.js +0 -10
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/elixir/elixir.js +0 -10
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/flow9/flow9.js +0 -10
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/editor/editor.main.js +0 -745
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/editor/editor.main.nls.de.js +0 -31
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/editor/editor.main.nls.es.js +0 -31
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/editor/editor.main.nls.fr.js +0 -29
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/editor/editor.main.nls.it.js +0 -29
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/editor/editor.main.nls.ja.js +0 -31
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/editor/editor.main.nls.js +0 -29
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/editor/editor.main.nls.ko.js +0 -29
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/editor/editor.main.nls.ru.js +0 -31
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/editor/editor.main.nls.zh-cn.js +0 -31
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/editor/editor.main.nls.zh-tw.js +0 -29
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/language/css/cssMode.js +0 -13
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/language/css/cssWorker.js +0 -81
- package/dist/src/web/frontend/node_modules/.multicast-dns-iKseM9bB/cli.js +0 -64
- package/dist/src/web/frontend/node_modules/.multicast-dns-iKseM9bB/example.js +0 -36
- package/dist/src/web/frontend/node_modules/.multicast-dns-iKseM9bB/index.js +0 -205
- package/dist/src/web/frontend/node_modules/.multicast-dns-iKseM9bB/test.js +0 -260
- package/dist/src/web/frontend/node_modules/.nanoid-PAMEV9Hd/async/index.browser.js +0 -34
- package/dist/src/web/frontend/node_modules/.nanoid-PAMEV9Hd/async/index.js +0 -35
- package/dist/src/web/frontend/node_modules/.nanoid-PAMEV9Hd/async/index.native.js +0 -26
- package/dist/src/web/frontend/node_modules/.nanoid-PAMEV9Hd/index.browser.js +0 -34
- package/dist/src/web/frontend/node_modules/.nanoid-PAMEV9Hd/index.js +0 -45
- package/dist/src/web/frontend/node_modules/.nanoid-PAMEV9Hd/nanoid.js +0 -1
- package/dist/src/web/frontend/node_modules/.nanoid-PAMEV9Hd/non-secure/index.js +0 -21
- package/dist/src/web/frontend/node_modules/.nanoid-PAMEV9Hd/url-alphabet/index.js +0 -3
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/bin/nodemon.js +0 -16
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/cli/index.js +0 -49
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/cli/parse.js +0 -230
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/config/command.js +0 -43
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/config/defaults.js +0 -34
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/config/exec.js +0 -234
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/config/index.js +0 -93
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/config/load.js +0 -225
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/help/index.js +0 -27
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/index.js +0 -1
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/monitor/index.js +0 -4
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/monitor/match.js +0 -287
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/monitor/run.js +0 -562
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/monitor/signals.js +0 -34
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/monitor/watch.js +0 -244
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/nodemon.js +0 -317
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/rules/add.js +0 -89
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/rules/index.js +0 -53
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/rules/parse.js +0 -43
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/spawn.js +0 -74
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/utils/bus.js +0 -44
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/utils/clone.js +0 -40
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/utils/colour.js +0 -26
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/utils/index.js +0 -103
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/utils/log.js +0 -82
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/utils/merge.js +0 -47
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/version.js +0 -100
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/node_modules/brace-expansion/index.js +0 -201
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/node_modules/has-flag/index.js +0 -8
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/node_modules/minimatch/minimatch.js +0 -947
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/node_modules/supports-color/browser.js +0 -5
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/node_modules/supports-color/index.js +0 -131
- package/dist/src/web/frontend/node_modules/.pidtree-icfat3SQ/bin/pidtree.js +0 -128
- package/dist/src/web/frontend/node_modules/.pidtree-icfat3SQ/index.js +0 -49
- package/dist/src/web/frontend/node_modules/.pidtree-icfat3SQ/lib/bin.js +0 -61
- package/dist/src/web/frontend/node_modules/.pidtree-icfat3SQ/lib/get.js +0 -45
- package/dist/src/web/frontend/node_modules/.pidtree-icfat3SQ/lib/pidtree.js +0 -104
- package/dist/src/web/frontend/node_modules/.pidtree-icfat3SQ/lib/ps.js +0 -47
- package/dist/src/web/frontend/node_modules/.pidtree-icfat3SQ/lib/wmic.js +0 -49
- package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/doc.js +0 -1270
- package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/plugins/acorn.js +0 -15
- package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/plugins/angular.js +0 -2
- package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/plugins/babel.js +0 -15
- package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/plugins/estree.js +0 -36
- package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/plugins/flow.js +0 -19
- package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/plugins/glimmer.js +0 -29
- package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/plugins/graphql.js +0 -29
- package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/plugins/html.js +0 -22
- package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/plugins/markdown.js +0 -63
- package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/plugins/meriyah.js +0 -4
- package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/plugins/postcss.js +0 -54
- package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/plugins/typescript.js +0 -20
- package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/plugins/yaml.js +0 -160
- package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/standalone.js +0 -34
- package/dist/src/web/frontend/node_modules/.react-scripts-OTANyoRb/bin/react-scripts.js +0 -58
- package/dist/src/web/frontend/node_modules/.react-scripts-OTANyoRb/config/env.js +0 -112
- package/dist/src/web/frontend/node_modules/.react-scripts-OTANyoRb/config/getHttpsConfig.js +0 -74
- package/dist/src/web/frontend/node_modules/.react-scripts-OTANyoRb/config/jest/babelTransform.js +0 -37
- package/dist/src/web/frontend/node_modules/.react-scripts-OTANyoRb/config/jest/cssTransform.js +0 -22
- package/dist/src/web/frontend/node_modules/.react-scripts-OTANyoRb/config/jest/fileTransform.js +0 -40
- package/dist/src/web/frontend/node_modules/.react-scripts-OTANyoRb/config/modules.js +0 -142
- package/dist/src/web/frontend/node_modules/.react-scripts-OTANyoRb/config/paths.js +0 -153
- package/dist/src/web/frontend/node_modules/.react-scripts-OTANyoRb/config/webpack/persistentCache/createEnvironmentHash.js +0 -9
- package/dist/src/web/frontend/node_modules/.react-scripts-OTANyoRb/config/webpack.config.js +0 -796
- package/dist/src/web/frontend/node_modules/.react-scripts-OTANyoRb/config/webpackDevServer.config.js +0 -135
- package/dist/src/web/frontend/node_modules/.react-scripts-OTANyoRb/scripts/build.js +0 -225
- package/dist/src/web/frontend/node_modules/.react-scripts-OTANyoRb/scripts/eject.js +0 -340
|
@@ -4,371 +4,469 @@
|
|
|
4
4
|
* This module provides the core infrastructure for executing automation
|
|
5
5
|
* workflows with Claude CLI integration, while preserving existing
|
|
6
6
|
* swarm and hive-mind functionality.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { promises as fs } from 'fs';
|
|
10
|
+
import { spawn } from 'child_process';
|
|
11
|
+
import { join, dirname } from 'path';
|
|
12
|
+
import { printSuccess, printError, printWarning } from '../utils.js';
|
|
13
|
+
|
|
11
14
|
// Simple ID generator
|
|
12
15
|
function generateId(prefix = 'id') {
|
|
13
|
-
|
|
16
|
+
return `${prefix}-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
14
17
|
}
|
|
18
|
+
|
|
15
19
|
/**
|
|
16
20
|
* WorkflowExecutor - Core class for executing automation workflows
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
if (this.options.nonInteractive) {
|
|
34
|
-
console.log(`🖥️ Non-Interactive Mode: Enabled`);
|
|
35
|
-
if (this.options.outputFormat === 'stream-json') {
|
|
36
|
-
console.log();
|
|
37
|
-
console.log('● Running MLE-STAR workflow with Claude CLI integration');
|
|
38
|
-
console.log(' ⎿ Command format: claude --print --output-format stream-json --verbose --dangerously-skip-permissions');
|
|
39
|
-
console.log(' ⎿ Each agent will show real-time stream output below');
|
|
40
|
-
console.log(' ⎿ Interactive-style formatting enabled');
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
console.log();
|
|
45
|
-
// Pre-execution hooks
|
|
46
|
-
if (this.hooksEnabled) {
|
|
47
|
-
await this.executeHook('pre-task', {
|
|
48
|
-
description: `Execute workflow: ${workflowData.name}`,
|
|
49
|
-
sessionId: this.sessionId
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
// Validate workflow
|
|
53
|
-
this.validateWorkflow(workflowData);
|
|
54
|
-
// Apply variable substitutions
|
|
55
|
-
const processedWorkflow = this.applyVariables(workflowData, variables);
|
|
56
|
-
// Initialize agents if Claude integration is enabled
|
|
57
|
-
if (this.options.enableClaude) {
|
|
58
|
-
await this.initializeClaudeAgents(processedWorkflow.agents);
|
|
59
|
-
}
|
|
60
|
-
// Execute workflow phases
|
|
61
|
-
const result = await this.executeWorkflowTasks(processedWorkflow);
|
|
62
|
-
// Post-execution hooks
|
|
63
|
-
if (this.hooksEnabled) {
|
|
64
|
-
await this.executeHook('post-task', {
|
|
65
|
-
taskId: this.executionId,
|
|
66
|
-
sessionId: this.sessionId,
|
|
67
|
-
result: result.success ? 'success' : 'failure'
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
const duration = Date.now() - this.startTime;
|
|
71
|
-
if (result.success) {
|
|
72
|
-
printSuccess(`✅ Workflow completed successfully in ${this.formatDuration(duration)}`);
|
|
73
|
-
console.log(`📊 Tasks: ${result.completedTasks}/${result.totalTasks} completed`);
|
|
74
|
-
console.log(`🆔 Execution ID: ${this.executionId}`);
|
|
75
|
-
} else {
|
|
76
|
-
printError(`❌ Workflow failed after ${this.formatDuration(duration)}`);
|
|
77
|
-
console.log(`📊 Tasks: ${result.completedTasks}/${result.totalTasks} completed`);
|
|
78
|
-
console.log(`❌ Errors: ${this.errors.length}`);
|
|
79
|
-
}
|
|
80
|
-
// Cleanup Claude instances
|
|
81
|
-
if (this.options.enableClaude) {
|
|
82
|
-
await this.cleanupClaudeInstances();
|
|
83
|
-
}
|
|
84
|
-
return result;
|
|
85
|
-
} catch (error) {
|
|
86
|
-
printError(`Workflow execution failed: ${error.message}`);
|
|
87
|
-
await this.cleanupClaudeInstances();
|
|
88
|
-
throw error;
|
|
89
|
-
}
|
|
21
|
+
*/
|
|
22
|
+
export class WorkflowExecutor {
|
|
23
|
+
constructor(options = {}) {
|
|
24
|
+
this.options = {
|
|
25
|
+
enableClaude: false,
|
|
26
|
+
nonInteractive: false,
|
|
27
|
+
outputFormat: 'text',
|
|
28
|
+
maxConcurrency: 3,
|
|
29
|
+
timeout: 3600000, // 1 hour default
|
|
30
|
+
logLevel: 'info',
|
|
31
|
+
...options,
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
// Increase timeout for ML workflows
|
|
35
|
+
if (options.workflowType === 'ml' || options.workflowName?.toLowerCase().includes('mle')) {
|
|
36
|
+
this.options.timeout = 7200000; // 2 hours for ML workflows
|
|
90
37
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
38
|
+
|
|
39
|
+
// Execution state
|
|
40
|
+
this.executionId = generateId('workflow-exec');
|
|
41
|
+
this.startTime = Date.now();
|
|
42
|
+
this.activeTasks = new Map();
|
|
43
|
+
this.claudeInstances = new Map();
|
|
44
|
+
this.results = new Map();
|
|
45
|
+
this.errors = [];
|
|
46
|
+
this.currentWorkflow = null;
|
|
47
|
+
|
|
48
|
+
// Stream chaining support
|
|
49
|
+
this.taskOutputStreams = new Map(); // Store output streams for chaining
|
|
50
|
+
this.enableChaining = options.enableChaining !== false; // Default to true
|
|
51
|
+
|
|
52
|
+
// Hooks integration
|
|
53
|
+
this.hooksEnabled = true;
|
|
54
|
+
this.sessionId = generateId('automation-session');
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Execute a workflow from JSON definition
|
|
59
|
+
*/
|
|
60
|
+
async executeWorkflow(workflowData, variables = {}) {
|
|
61
|
+
try {
|
|
62
|
+
// Store workflow for reference
|
|
63
|
+
this.currentWorkflow = workflowData;
|
|
64
|
+
|
|
65
|
+
if (this.options.logLevel === 'quiet') {
|
|
66
|
+
console.log(`🚀 Executing workflow: ${this.executionId}`);
|
|
67
|
+
} else {
|
|
68
|
+
console.log(`🚀 Starting workflow execution: ${this.executionId}`);
|
|
69
|
+
console.log(`📋 Workflow: ${workflowData.name}`);
|
|
70
|
+
console.log(`🎯 Strategy: MLE-STAR Machine Learning Engineering`);
|
|
71
|
+
|
|
72
|
+
if (this.options.enableClaude) {
|
|
73
|
+
console.log(`🤖 Claude CLI Integration: Enabled`);
|
|
100
74
|
}
|
|
75
|
+
|
|
101
76
|
if (this.options.nonInteractive) {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
console.log(`🤖 Non-interactive mode: Claude instances will be spawned per task`);
|
|
105
|
-
console.log(`📋 Each task will launch its own Claude process with specific prompts`);
|
|
106
|
-
}
|
|
107
|
-
return;
|
|
108
|
-
} else {
|
|
109
|
-
// Interactive mode: spawn single Claude instance with master coordination prompt
|
|
110
|
-
console.log(`🤖 Interactive mode: Initializing single Claude instance for workflow coordination...`);
|
|
111
|
-
try {
|
|
112
|
-
// Create master coordination prompt for all agents and workflow
|
|
113
|
-
const masterPrompt = this.createMasterCoordinationPrompt(agents);
|
|
114
|
-
// Spawn single Claude instance for workflow coordination
|
|
115
|
-
const claudeProcess = await this.spawnClaudeInstance({
|
|
116
|
-
id: 'master-coordinator',
|
|
117
|
-
name: 'Workflow Coordinator',
|
|
118
|
-
type: 'coordinator'
|
|
119
|
-
}, masterPrompt);
|
|
120
|
-
// Store as master coordinator
|
|
121
|
-
this.claudeInstances.set('master-coordinator', {
|
|
122
|
-
process: claudeProcess,
|
|
123
|
-
agent: {
|
|
124
|
-
id: 'master-coordinator',
|
|
125
|
-
name: 'Workflow Coordinator',
|
|
126
|
-
type: 'coordinator'
|
|
127
|
-
},
|
|
128
|
-
status: 'active',
|
|
129
|
-
startTime: Date.now(),
|
|
130
|
-
agents: agents
|
|
131
|
-
});
|
|
132
|
-
console.log(` ✅ Master Workflow Coordinator (PID: ${claudeProcess.pid})`);
|
|
133
|
-
console.log(` 🎯 Coordinating ${agents.length} sub-agents via concurrent streams`);
|
|
134
|
-
console.log(` 📋 Agents: ${agents.map((a)=>a.name).join(', ')}`);
|
|
135
|
-
} catch (error) {
|
|
136
|
-
console.error(` ❌ Failed to initialize master coordinator: ${error.message}`);
|
|
137
|
-
this.errors.push({
|
|
138
|
-
type: 'master_coordinator_initialization',
|
|
139
|
-
error: error.message,
|
|
140
|
-
timestamp: new Date()
|
|
141
|
-
});
|
|
142
|
-
}
|
|
77
|
+
console.log(`🖥️ Non-Interactive Mode: Enabled`);
|
|
78
|
+
if (this.options.outputFormat === 'stream-json') {
|
|
143
79
|
console.log();
|
|
80
|
+
console.log('● Running MLE-STAR workflow with Claude CLI integration');
|
|
81
|
+
console.log(
|
|
82
|
+
' ⎿ Command format: claude --print --output-format stream-json --verbose --dangerously-skip-permissions',
|
|
83
|
+
);
|
|
84
|
+
console.log(' ⎿ Each agent will show real-time stream output below');
|
|
85
|
+
console.log(' ⎿ Interactive-style formatting enabled');
|
|
86
|
+
}
|
|
144
87
|
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
console.log();
|
|
91
|
+
|
|
92
|
+
// Pre-execution hooks
|
|
93
|
+
if (this.hooksEnabled) {
|
|
94
|
+
await this.executeHook('pre-task', {
|
|
95
|
+
description: `Execute workflow: ${workflowData.name}`,
|
|
96
|
+
sessionId: this.sessionId,
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Validate workflow
|
|
101
|
+
this.validateWorkflow(workflowData);
|
|
102
|
+
|
|
103
|
+
// Apply variable substitutions
|
|
104
|
+
const processedWorkflow = this.applyVariables(workflowData, variables);
|
|
105
|
+
|
|
106
|
+
// Initialize agents if Claude integration is enabled
|
|
107
|
+
if (this.options.enableClaude) {
|
|
108
|
+
await this.initializeClaudeAgents(processedWorkflow.agents);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Execute workflow phases
|
|
112
|
+
const result = await this.executeWorkflowTasks(processedWorkflow);
|
|
113
|
+
|
|
114
|
+
// Post-execution hooks
|
|
115
|
+
if (this.hooksEnabled) {
|
|
116
|
+
await this.executeHook('post-task', {
|
|
117
|
+
taskId: this.executionId,
|
|
118
|
+
sessionId: this.sessionId,
|
|
119
|
+
result: result.success ? 'success' : 'failure',
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const duration = Date.now() - this.startTime;
|
|
124
|
+
|
|
125
|
+
if (result.success) {
|
|
126
|
+
printSuccess(`✅ Workflow completed successfully in ${this.formatDuration(duration)}`);
|
|
127
|
+
console.log(`📊 Tasks: ${result.completedTasks}/${result.totalTasks} completed`);
|
|
128
|
+
console.log(`🆔 Execution ID: ${this.executionId}`);
|
|
129
|
+
} else {
|
|
130
|
+
printError(`❌ Workflow failed after ${this.formatDuration(duration)}`);
|
|
131
|
+
console.log(`📊 Tasks: ${result.completedTasks}/${result.totalTasks} completed`);
|
|
132
|
+
console.log(`❌ Errors: ${this.errors.length}`);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// Cleanup Claude instances
|
|
136
|
+
if (this.options.enableClaude) {
|
|
137
|
+
await this.cleanupClaudeInstances();
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
return result;
|
|
141
|
+
} catch (error) {
|
|
142
|
+
printError(`Workflow execution failed: ${error.message}`);
|
|
143
|
+
await this.cleanupClaudeInstances();
|
|
144
|
+
throw error;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Initialize Claude CLI instances for agents
|
|
150
|
+
*/
|
|
151
|
+
async initializeClaudeAgents(agents) {
|
|
152
|
+
if (!agents || agents.length === 0) {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// Check if Claude CLI is available
|
|
157
|
+
if (!(await this.isClaudeAvailable())) {
|
|
158
|
+
throw new Error('Claude CLI not found. Please install Claude Code: https://claude.ai/code');
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
if (this.options.nonInteractive) {
|
|
162
|
+
// Non-interactive mode: agents are spawned per task instead
|
|
163
|
+
if (this.options.logLevel !== 'quiet') {
|
|
164
|
+
console.log(`🤖 Non-interactive mode: Claude instances will be spawned per task`);
|
|
165
|
+
console.log(`📋 Each task will launch its own Claude process with specific prompts`);
|
|
166
|
+
}
|
|
167
|
+
return;
|
|
168
|
+
} else {
|
|
169
|
+
// Interactive mode: spawn single Claude instance with master coordination prompt
|
|
170
|
+
console.log(
|
|
171
|
+
`🤖 Interactive mode: Initializing single Claude instance for workflow coordination...`,
|
|
172
|
+
);
|
|
173
|
+
|
|
174
|
+
try {
|
|
175
|
+
// Create master coordination prompt for all agents and workflow
|
|
176
|
+
const masterPrompt = this.createMasterCoordinationPrompt(agents);
|
|
177
|
+
|
|
178
|
+
// Spawn single Claude instance for workflow coordination
|
|
179
|
+
const claudeProcess = await this.spawnClaudeInstance(
|
|
180
|
+
{
|
|
181
|
+
id: 'master-coordinator',
|
|
182
|
+
name: 'Workflow Coordinator',
|
|
183
|
+
type: 'coordinator',
|
|
184
|
+
},
|
|
185
|
+
masterPrompt,
|
|
186
|
+
);
|
|
187
|
+
|
|
188
|
+
// Store as master coordinator
|
|
189
|
+
this.claudeInstances.set('master-coordinator', {
|
|
190
|
+
process: claudeProcess,
|
|
191
|
+
agent: { id: 'master-coordinator', name: 'Workflow Coordinator', type: 'coordinator' },
|
|
192
|
+
status: 'active',
|
|
193
|
+
startTime: Date.now(),
|
|
194
|
+
agents: agents, // Store agent definitions for reference
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
console.log(` ✅ Master Workflow Coordinator (PID: ${claudeProcess.pid})`);
|
|
198
|
+
console.log(` 🎯 Coordinating ${agents.length} sub-agents via concurrent streams`);
|
|
199
|
+
console.log(` 📋 Agents: ${agents.map((a) => a.name).join(', ')}`);
|
|
200
|
+
} catch (error) {
|
|
201
|
+
console.error(` ❌ Failed to initialize master coordinator: ${error.message}`);
|
|
202
|
+
this.errors.push({
|
|
203
|
+
type: 'master_coordinator_initialization',
|
|
204
|
+
error: error.message,
|
|
205
|
+
timestamp: new Date(),
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
console.log();
|
|
145
210
|
}
|
|
146
|
-
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
147
214
|
* Check if Claude CLI is available
|
|
148
|
-
*/
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
return false;
|
|
157
|
-
}
|
|
215
|
+
*/
|
|
216
|
+
async isClaudeAvailable() {
|
|
217
|
+
try {
|
|
218
|
+
const { execSync } = await import('child_process');
|
|
219
|
+
execSync('which claude', { stdio: 'ignore' });
|
|
220
|
+
return true;
|
|
221
|
+
} catch {
|
|
222
|
+
return false;
|
|
158
223
|
}
|
|
159
|
-
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
160
227
|
* Spawn a Claude CLI instance for an agent
|
|
161
228
|
* @param {Object} agent - The agent configuration
|
|
162
229
|
* @param {string} prompt - The prompt for the agent
|
|
163
230
|
* @param {Object} options - Additional options
|
|
164
231
|
* @param {Stream} options.inputStream - Optional input stream from previous agent
|
|
165
232
|
* @param {boolean} options.enableChaining - Whether to enable stream-json chaining
|
|
166
|
-
*/
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
// Always skip permissions for automated workflows (both interactive and non-interactive)
|
|
182
|
-
claudeArgs.push('--dangerously-skip-permissions');
|
|
183
|
-
// Always add the prompt as the final argument
|
|
184
|
-
claudeArgs.push(prompt);
|
|
185
|
-
// Only show command details in verbose mode
|
|
186
|
-
if (this.options.logLevel === 'debug') {
|
|
187
|
-
const displayPrompt = prompt.length > 100 ? prompt.substring(0, 100) + '...' : prompt;
|
|
188
|
-
const flagsDisplay = this.options.nonInteractive ? this.options.outputFormat === 'stream-json' ? options.inputStream ? '--print --input-format stream-json --output-format stream-json --verbose --dangerously-skip-permissions' : '--print --output-format stream-json --verbose --dangerously-skip-permissions' : '--print --dangerously-skip-permissions' : '--dangerously-skip-permissions';
|
|
189
|
-
console.log(` 🤖 Spawning Claude for ${agent1.name}: claude ${flagsDisplay} "${displayPrompt}"`);
|
|
190
|
-
} else if (this.options.logLevel !== 'quiet') {
|
|
191
|
-
console.log(` 🚀 Starting ${agent1.name}`);
|
|
192
|
-
}
|
|
193
|
-
// Determine stdio configuration based on mode and chaining
|
|
194
|
-
const stdioConfig = this.options.nonInteractive ? [
|
|
195
|
-
options.inputStream ? 'pipe' : 'inherit',
|
|
196
|
-
'pipe',
|
|
197
|
-
'pipe'
|
|
198
|
-
] // Non-interactive: pipe for chaining
|
|
199
|
-
: [
|
|
200
|
-
'inherit',
|
|
201
|
-
'inherit',
|
|
202
|
-
'inherit'
|
|
203
|
-
]; // Interactive: inherit all for normal Claude interaction
|
|
204
|
-
// Spawn Claude process
|
|
205
|
-
const claudeProcess = spawn('claude', claudeArgs, {
|
|
206
|
-
stdio: stdioConfig,
|
|
207
|
-
shell: false
|
|
208
|
-
});
|
|
209
|
-
// If we have an input stream, pipe it to Claude's stdin
|
|
210
|
-
if (options.inputStream && claudeProcess.stdin) {
|
|
211
|
-
console.log(` 🔗 Chaining: Piping output from previous agent to ${agent1.name}`);
|
|
212
|
-
options.inputStream.pipe(claudeProcess.stdin);
|
|
233
|
+
*/
|
|
234
|
+
async spawnClaudeInstance(agent, prompt, options = {}) {
|
|
235
|
+
const claudeArgs = [];
|
|
236
|
+
|
|
237
|
+
// Add flags based on mode
|
|
238
|
+
if (this.options.nonInteractive) {
|
|
239
|
+
// Non-interactive mode: use --print with stream-json output
|
|
240
|
+
claudeArgs.push('--print');
|
|
241
|
+
if (this.options.outputFormat === 'stream-json') {
|
|
242
|
+
claudeArgs.push('--output-format', 'stream-json');
|
|
243
|
+
claudeArgs.push('--verbose'); // Required for stream-json
|
|
244
|
+
|
|
245
|
+
// Add input format if we're chaining from a previous agent
|
|
246
|
+
if (options.inputStream) {
|
|
247
|
+
claudeArgs.push('--input-format', 'stream-json');
|
|
213
248
|
}
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
// Always skip permissions for automated workflows (both interactive and non-interactive)
|
|
253
|
+
claudeArgs.push('--dangerously-skip-permissions');
|
|
254
|
+
|
|
255
|
+
// Always add the prompt as the final argument
|
|
256
|
+
claudeArgs.push(prompt);
|
|
257
|
+
|
|
258
|
+
// Only show command details in verbose mode
|
|
259
|
+
if (this.options.logLevel === 'debug') {
|
|
260
|
+
const displayPrompt = prompt.length > 100 ? prompt.substring(0, 100) + '...' : prompt;
|
|
261
|
+
const flagsDisplay = this.options.nonInteractive
|
|
262
|
+
? this.options.outputFormat === 'stream-json'
|
|
263
|
+
? options.inputStream
|
|
264
|
+
? '--print --input-format stream-json --output-format stream-json --verbose --dangerously-skip-permissions'
|
|
265
|
+
: '--print --output-format stream-json --verbose --dangerously-skip-permissions'
|
|
266
|
+
: '--print --dangerously-skip-permissions'
|
|
267
|
+
: '--dangerously-skip-permissions';
|
|
268
|
+
console.log(
|
|
269
|
+
` 🤖 Spawning Claude for ${agent.name}: claude ${flagsDisplay} "${displayPrompt}"`,
|
|
270
|
+
);
|
|
271
|
+
} else if (this.options.logLevel !== 'quiet') {
|
|
272
|
+
console.log(` 🚀 Starting ${agent.name}`);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
// Determine stdio configuration based on mode and chaining
|
|
276
|
+
const stdioConfig = this.options.nonInteractive
|
|
277
|
+
? [options.inputStream ? 'pipe' : 'inherit', 'pipe', 'pipe'] // Non-interactive: pipe for chaining
|
|
278
|
+
: ['inherit', 'inherit', 'inherit']; // Interactive: inherit all for normal Claude interaction
|
|
279
|
+
|
|
280
|
+
// Spawn Claude process
|
|
281
|
+
const claudeProcess = spawn('claude', claudeArgs, {
|
|
282
|
+
stdio: stdioConfig,
|
|
283
|
+
shell: false,
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
// If we have an input stream, pipe it to Claude's stdin
|
|
287
|
+
if (options.inputStream && claudeProcess.stdin) {
|
|
288
|
+
console.log(` 🔗 Chaining: Piping output from previous agent to ${agent.name}`);
|
|
289
|
+
options.inputStream.pipe(claudeProcess.stdin);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
// Handle stdout with stream processor for better formatting (only in non-interactive mode)
|
|
293
|
+
if (
|
|
294
|
+
this.options.nonInteractive &&
|
|
295
|
+
this.options.outputFormat === 'stream-json' &&
|
|
296
|
+
claudeProcess.stdout
|
|
297
|
+
) {
|
|
298
|
+
// Import and use stream processor
|
|
299
|
+
const { createStreamProcessor } = await import('./stream-processor.js');
|
|
300
|
+
const streamProcessor = createStreamProcessor(agent.name, this.getAgentIcon(agent.id), {
|
|
301
|
+
verbose: this.options.logLevel === 'debug',
|
|
302
|
+
logLevel: this.options.logLevel,
|
|
303
|
+
taskId: agent.taskId,
|
|
304
|
+
agentId: agent.id,
|
|
305
|
+
display: null, // Interactive-style formatting instead of concurrent display
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
// Pipe stdout through processor
|
|
309
|
+
claudeProcess.stdout.pipe(streamProcessor);
|
|
310
|
+
|
|
311
|
+
// Handle stderr for non-interactive mode
|
|
312
|
+
claudeProcess.stderr.on('data', (data) => {
|
|
313
|
+
const message = data.toString().trim();
|
|
314
|
+
if (message) {
|
|
315
|
+
console.error(` ❌ [${agent.name}] Error: ${message}`);
|
|
242
316
|
}
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
});
|
|
254
|
-
claudeProcess.on('exit', (code)=>{
|
|
255
|
-
const instance = this.claudeInstances.get(agent1.id);
|
|
256
|
-
if (instance) {
|
|
257
|
-
instance.status = code === 0 ? 'completed' : 'failed';
|
|
258
|
-
instance.exitCode = code;
|
|
259
|
-
instance.endTime = Date.now();
|
|
260
|
-
}
|
|
261
|
-
});
|
|
262
|
-
return claudeProcess;
|
|
317
|
+
});
|
|
318
|
+
} else if (this.options.nonInteractive && this.options.outputFormat !== 'stream-json') {
|
|
319
|
+
// For non-interactive non-stream-json output, show stdout directly
|
|
320
|
+
claudeProcess.stdout.on('data', (data) => {
|
|
321
|
+
console.log(data.toString().trimEnd());
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
claudeProcess.stderr.on('data', (data) => {
|
|
325
|
+
console.error(data.toString().trimEnd());
|
|
326
|
+
});
|
|
263
327
|
}
|
|
264
|
-
|
|
328
|
+
// Note: In interactive mode, stdio is inherited so Claude handles its own I/O
|
|
329
|
+
|
|
330
|
+
// Handle process events
|
|
331
|
+
claudeProcess.on('error', (error) => {
|
|
332
|
+
console.error(`❌ Claude instance error for ${agent.name}:`, error.message);
|
|
333
|
+
this.errors.push({
|
|
334
|
+
type: 'claude_instance_error',
|
|
335
|
+
agent: agent.id,
|
|
336
|
+
error: error.message,
|
|
337
|
+
timestamp: new Date(),
|
|
338
|
+
});
|
|
339
|
+
});
|
|
340
|
+
|
|
341
|
+
claudeProcess.on('exit', (code) => {
|
|
342
|
+
const instance = this.claudeInstances.get(agent.id);
|
|
343
|
+
if (instance) {
|
|
344
|
+
instance.status = code === 0 ? 'completed' : 'failed';
|
|
345
|
+
instance.exitCode = code;
|
|
346
|
+
instance.endTime = Date.now();
|
|
347
|
+
}
|
|
348
|
+
});
|
|
349
|
+
|
|
350
|
+
return claudeProcess;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
/**
|
|
265
354
|
* Handle Claude stream events
|
|
266
|
-
*/
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
355
|
+
*/
|
|
356
|
+
handleClaudeStreamEvent(agent, event) {
|
|
357
|
+
if (this.options.outputFormat === 'stream-json') {
|
|
358
|
+
// Create concise formatted JSON with summary
|
|
359
|
+
const summary = this.getEventSummary(event);
|
|
360
|
+
const icon = this.getEventIcon(event.type);
|
|
361
|
+
|
|
362
|
+
// Simplified output for better readability
|
|
363
|
+
const output = {
|
|
364
|
+
t: new Date().toISOString().split('T')[1].split('.')[0], // HH:MM:SS
|
|
365
|
+
agent: `${this.getAgentIcon(agent.id)} ${agent.name}`,
|
|
366
|
+
phase: this.currentPhase,
|
|
367
|
+
event: `${icon} ${summary}`,
|
|
368
|
+
};
|
|
369
|
+
|
|
370
|
+
// Add relevant details based on event type
|
|
371
|
+
if (event.type === 'tool_use' && event.name) {
|
|
372
|
+
output.tool = event.name;
|
|
373
|
+
} else if (event.type === 'error' && event.error) {
|
|
374
|
+
output.error = event.error;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
console.log(JSON.stringify(output));
|
|
378
|
+
} else {
|
|
379
|
+
// Format output for text mode
|
|
380
|
+
switch (event.type) {
|
|
381
|
+
case 'tool_use':
|
|
382
|
+
console.log(` [${agent.name}] 🔧 Using tool: ${event.name}`);
|
|
383
|
+
break;
|
|
384
|
+
case 'message':
|
|
385
|
+
console.log(` [${agent.name}] 💬 ${event.content}`);
|
|
386
|
+
break;
|
|
387
|
+
case 'completion':
|
|
388
|
+
console.log(` [${agent.name}] ✅ Task completed`);
|
|
389
|
+
break;
|
|
390
|
+
case 'error':
|
|
391
|
+
console.error(` [${agent.name}] ❌ Error: ${event.error}`);
|
|
392
|
+
break;
|
|
393
|
+
default:
|
|
394
|
+
// Log other events in debug mode
|
|
395
|
+
if (this.options.logLevel === 'debug') {
|
|
396
|
+
console.log(` [${agent.name}] ${event.type}: ${JSON.stringify(event)}`);
|
|
397
|
+
}
|
|
398
|
+
}
|
|
307
399
|
}
|
|
308
|
-
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
/**
|
|
309
403
|
* Get a brief summary of an event
|
|
310
|
-
*/
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
404
|
+
*/
|
|
405
|
+
getEventSummary(event) {
|
|
406
|
+
switch (event.type) {
|
|
407
|
+
case 'tool_use':
|
|
408
|
+
return `Using ${event.name} tool`;
|
|
409
|
+
case 'message':
|
|
410
|
+
return event.content?.substring(0, 100) + (event.content?.length > 100 ? '...' : '');
|
|
411
|
+
case 'completion':
|
|
412
|
+
return 'Task completed successfully';
|
|
413
|
+
case 'error':
|
|
414
|
+
return `Error: ${event.error}`;
|
|
415
|
+
case 'status':
|
|
416
|
+
return event.status || 'Status update';
|
|
417
|
+
default:
|
|
418
|
+
return event.type;
|
|
325
419
|
}
|
|
326
|
-
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
/**
|
|
327
423
|
* Get icon for event type
|
|
328
|
-
*/
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
424
|
+
*/
|
|
425
|
+
getEventIcon(eventType) {
|
|
426
|
+
const icons = {
|
|
427
|
+
tool_use: '🔧',
|
|
428
|
+
message: '💬',
|
|
429
|
+
completion: '✅',
|
|
430
|
+
error: '❌',
|
|
431
|
+
status: '📊',
|
|
432
|
+
init: '🚀',
|
|
433
|
+
thinking: '🤔',
|
|
434
|
+
result: '📋',
|
|
435
|
+
};
|
|
436
|
+
return icons[eventType] || '📌';
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
/**
|
|
342
440
|
* Create task-specific Claude prompt with comprehensive MLE-STAR instructions
|
|
343
|
-
*/
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
...task.input
|
|
351
|
-
};
|
|
352
|
-
for (const [key, value] of Object.entries(allVariables)){
|
|
353
|
-
const pattern = new RegExp(`\\$\\{${key}\\}`, 'g');
|
|
354
|
-
basePrompt = basePrompt.replace(pattern, value);
|
|
355
|
-
}
|
|
356
|
-
// Create comprehensive task prompt with MLE-STAR methodology
|
|
357
|
-
return `🎯 MLE-STAR AGENT TASK EXECUTION
|
|
441
|
+
*/
|
|
442
|
+
createTaskPrompt(task, agent, workflow) {
|
|
443
|
+
// Use the claudePrompt from the task if available
|
|
444
|
+
if (task.claudePrompt) {
|
|
445
|
+
// Apply variable substitutions to the prompt
|
|
446
|
+
let basePrompt = task.claudePrompt;
|
|
447
|
+
const allVariables = { ...workflow.variables, ...task.input };
|
|
358
448
|
|
|
359
|
-
|
|
449
|
+
for (const [key, value] of Object.entries(allVariables)) {
|
|
450
|
+
const pattern = new RegExp(`\\$\\{${key}\\}`, 'g');
|
|
451
|
+
basePrompt = basePrompt.replace(pattern, value);
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
// Create comprehensive task prompt with MLE-STAR methodology
|
|
455
|
+
return `🎯 MLE-STAR AGENT TASK EXECUTION
|
|
456
|
+
|
|
457
|
+
You are the **${agent.name}** (${agent.type}) in a coordinated MLE-STAR automation workflow.
|
|
360
458
|
|
|
361
459
|
📋 IMMEDIATE TASK:
|
|
362
460
|
${basePrompt}
|
|
363
461
|
|
|
364
462
|
🤖 AGENT ROLE & SPECIALIZATION:
|
|
365
|
-
${this.getAgentRoleDescription(
|
|
463
|
+
${this.getAgentRoleDescription(agent.type)}
|
|
366
464
|
|
|
367
465
|
🎯 AGENT CAPABILITIES:
|
|
368
|
-
${
|
|
466
|
+
${agent.config?.capabilities?.join(', ') || 'general automation'}
|
|
369
467
|
|
|
370
468
|
🔬 MLE-STAR METHODOLOGY FOCUS:
|
|
371
|
-
${this.getMethodologyGuidance(
|
|
469
|
+
${this.getMethodologyGuidance(agent.type)}
|
|
372
470
|
|
|
373
471
|
🔧 COORDINATION REQUIREMENTS:
|
|
374
472
|
1. **HOOKS INTEGRATION** (CRITICAL):
|
|
@@ -377,20 +475,20 @@ ${this.getMethodologyGuidance(agent1.type)}
|
|
|
377
475
|
- WHEN complete: \`npx claude-flow@alpha hooks post-task --task-id "${task.id}"\`
|
|
378
476
|
|
|
379
477
|
2. **MEMORY STORAGE** (CRITICAL):
|
|
380
|
-
- Store findings: \`npx claude-flow@alpha memory store "agent/${
|
|
381
|
-
- Store results: \`npx claude-flow@alpha memory store "agent/${
|
|
478
|
+
- Store findings: \`npx claude-flow@alpha memory store "agent/${agent.id}/findings" "[your_findings]"\`
|
|
479
|
+
- Store results: \`npx claude-flow@alpha memory store "agent/${agent.id}/results" "[your_results]"\`
|
|
382
480
|
- Check other agents: \`npx claude-flow@alpha memory search "agent/*"\`
|
|
383
481
|
|
|
384
482
|
3. **SESSION COORDINATION**:
|
|
385
483
|
- Session ID: ${this.sessionId}
|
|
386
484
|
- Execution ID: ${this.executionId}
|
|
387
485
|
- Task ID: ${task.id}
|
|
388
|
-
- Agent ID: ${
|
|
486
|
+
- Agent ID: ${agent.id}
|
|
389
487
|
|
|
390
488
|
4. **WORKFLOW PIPELINE AWARENESS**:
|
|
391
|
-
- Your position: ${this.getAgentPositionInPipeline(
|
|
392
|
-
- Coordinate with: ${this.getCoordinationPartners(
|
|
393
|
-
- File naming: Use \`${
|
|
489
|
+
- Your position: ${this.getAgentPositionInPipeline(agent.type)}
|
|
490
|
+
- Coordinate with: ${this.getCoordinationPartners(agent.type)}
|
|
491
|
+
- File naming: Use \`${agent.id}_[component].[ext]\` convention
|
|
394
492
|
|
|
395
493
|
5. **OUTPUT REQUIREMENTS**:
|
|
396
494
|
- Use detailed progress reporting
|
|
@@ -414,30 +512,33 @@ ${this.getMethodologyGuidance(agent1.type)}
|
|
|
414
512
|
- Ready for next pipeline phase
|
|
415
513
|
|
|
416
514
|
Begin execution now with the hooks pre-task command.`;
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
}
|
|
515
|
+
} else {
|
|
516
|
+
// Fallback to full agent prompt
|
|
517
|
+
return this.createAgentPrompt(agent);
|
|
421
518
|
}
|
|
422
|
-
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
/**
|
|
423
522
|
* Create agent-specific Claude prompt
|
|
424
|
-
*/
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
523
|
+
*/
|
|
524
|
+
createAgentPrompt(agent) {
|
|
525
|
+
const { config } = agent;
|
|
526
|
+
const capabilities = config?.capabilities?.join(', ') || 'general automation';
|
|
527
|
+
|
|
528
|
+
return `You are the ${agent.name} in a coordinated MLE-STAR automation workflow.
|
|
428
529
|
|
|
429
|
-
🎯 AGENT ROLE: ${
|
|
530
|
+
🎯 AGENT ROLE: ${agent.type.toUpperCase()}
|
|
430
531
|
📋 CAPABILITIES: ${capabilities}
|
|
431
|
-
🆔 AGENT ID: ${
|
|
532
|
+
🆔 AGENT ID: ${agent.id}
|
|
432
533
|
|
|
433
534
|
CRITICAL COORDINATION REQUIREMENTS:
|
|
434
535
|
1. HOOKS: Use claude-flow-novice hooks for coordination:
|
|
435
536
|
- Run "npx claude-flow@alpha hooks pre-task --description '[your task]'" before starting
|
|
436
537
|
- Run "npx claude-flow@alpha hooks post-edit --file '[file]'" after each file operation
|
|
437
|
-
- Run "npx claude-flow@alpha hooks post-task --task-id '${
|
|
538
|
+
- Run "npx claude-flow@alpha hooks post-task --task-id '${agent.id}'" when complete
|
|
438
539
|
|
|
439
540
|
2. MEMORY: Store all findings and results:
|
|
440
|
-
- Use "npx claude-flow@alpha memory store 'agent/${
|
|
541
|
+
- Use "npx claude-flow@alpha memory store 'agent/${agent.id}/[key]' '[value]'" for important data
|
|
441
542
|
- Check "npx claude-flow@alpha memory search 'agent/*'" for coordination with other agents
|
|
442
543
|
|
|
443
544
|
3. SESSION: Maintain session coordination:
|
|
@@ -448,24 +549,27 @@ AGENT-SPECIFIC CONFIGURATION:
|
|
|
448
549
|
${JSON.stringify(config, null, 2)}
|
|
449
550
|
|
|
450
551
|
MLE-STAR METHODOLOGY FOCUS:
|
|
451
|
-
${this.getMethodologyGuidance(
|
|
552
|
+
${this.getMethodologyGuidance(agent.type)}
|
|
452
553
|
|
|
453
554
|
WORKFLOW COORDINATION:
|
|
454
555
|
- Work with other agents in the pipeline: Search → Foundation → Refinement → Ensemble → Validation
|
|
455
556
|
- Share findings through memory system
|
|
456
|
-
- Use proper file naming conventions: ${
|
|
557
|
+
- Use proper file naming conventions: ${agent.id}_[component].[ext]
|
|
457
558
|
- Follow MLE-STAR best practices for your role
|
|
458
559
|
|
|
459
560
|
Execute your role in the MLE-STAR workflow with full coordination and hook integration.`;
|
|
460
|
-
|
|
461
|
-
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
/**
|
|
462
564
|
* Create master coordination prompt for interactive mode
|
|
463
|
-
*/
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
565
|
+
*/
|
|
566
|
+
createMasterCoordinationPrompt(agents) {
|
|
567
|
+
const workflowData = this.currentWorkflow || {
|
|
568
|
+
name: 'MLE-STAR Workflow',
|
|
569
|
+
description: 'Machine Learning Engineering via Search and Targeted Refinement',
|
|
570
|
+
};
|
|
571
|
+
|
|
572
|
+
return `🚀 MLE-STAR WORKFLOW COORDINATION MASTER
|
|
469
573
|
|
|
470
574
|
You are the MASTER COORDINATOR for a comprehensive MLE-STAR (Machine Learning Engineering via Search and Targeted Refinement) workflow.
|
|
471
575
|
|
|
@@ -475,11 +579,15 @@ You are the MASTER COORDINATOR for a comprehensive MLE-STAR (Machine Learning En
|
|
|
475
579
|
🔄 SESSION ID: ${this.sessionId}
|
|
476
580
|
|
|
477
581
|
🤖 SUB-AGENTS TO COORDINATE (${agents.length} total):
|
|
478
|
-
${agents
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
582
|
+
${agents
|
|
583
|
+
.map(
|
|
584
|
+
(agent, index) => `
|
|
585
|
+
${index + 1}. ${agent.name} (${agent.type})
|
|
586
|
+
🎯 Role: ${this.getAgentRoleDescription(agent.type)}
|
|
587
|
+
📋 Capabilities: ${agent.config?.capabilities?.join(', ') || 'general automation'}
|
|
588
|
+
🆔 ID: ${agent.id}`,
|
|
589
|
+
)
|
|
590
|
+
.join('')}
|
|
483
591
|
|
|
484
592
|
🔧 CRITICAL: USE CONCURRENT STREAMS FOR PARALLEL EXECUTION
|
|
485
593
|
|
|
@@ -530,24 +638,28 @@ METHODOLOGY PHASES:
|
|
|
530
638
|
${this.getMasterMethodologyGuide()}
|
|
531
639
|
|
|
532
640
|
🚀 BEGIN: Start by deploying all sub-agents with detailed prompts using the Task tool for concurrent execution. Each agent should receive comprehensive instructions for their specific MLE-STAR role.`;
|
|
533
|
-
|
|
534
|
-
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
/**
|
|
535
644
|
* Get agent role description for coordination
|
|
536
|
-
*/
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
645
|
+
*/
|
|
646
|
+
getAgentRoleDescription(agentType) {
|
|
647
|
+
const roles = {
|
|
648
|
+
researcher: 'Web Search & Foundation Discovery - Find state-of-the-art approaches',
|
|
649
|
+
coder: 'Model Implementation & Training Pipeline - Build foundation models',
|
|
650
|
+
optimizer: 'Performance Tuning & Architecture Refinement - Optimize models',
|
|
651
|
+
analyst: 'Ensemble Methods & Meta-Learning - Combine multiple approaches',
|
|
652
|
+
tester: 'Validation & Debugging - Ensure quality and performance',
|
|
653
|
+
coordinator: 'Workflow Orchestration - Manage overall pipeline',
|
|
654
|
+
};
|
|
655
|
+
return roles[agentType] || 'Specialized automation task execution';
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
/**
|
|
548
659
|
* Get comprehensive methodology guide for master coordinator
|
|
549
|
-
*/
|
|
550
|
-
|
|
660
|
+
*/
|
|
661
|
+
getMasterMethodologyGuide() {
|
|
662
|
+
return `
|
|
551
663
|
PHASE 1 - SEARCH & FOUNDATION (Parallel):
|
|
552
664
|
🔬 Search Agent: Research ML approaches, algorithms, and best practices
|
|
553
665
|
💻 Foundation Agent: Implement baseline models and training infrastructure
|
|
@@ -564,796 +676,928 @@ COORDINATION KEY POINTS:
|
|
|
564
676
|
- Maintain communication through progress updates
|
|
565
677
|
- Each phase builds on previous phases
|
|
566
678
|
- Final deliverable: Production-ready ML pipeline`;
|
|
567
|
-
|
|
568
|
-
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
/**
|
|
569
682
|
* Get agent position in MLE-STAR pipeline
|
|
570
|
-
*/
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
683
|
+
*/
|
|
684
|
+
getAgentPositionInPipeline(agentType) {
|
|
685
|
+
const positions = {
|
|
686
|
+
researcher: 'Phase 1: Search & Foundation Discovery (Parallel with Foundation)',
|
|
687
|
+
coder: 'Phase 1: Foundation Model Building (Parallel with Search)',
|
|
688
|
+
optimizer: 'Phase 2: Refinement & Optimization (Sequential, depends on Phase 1)',
|
|
689
|
+
analyst: 'Phase 3: Ensemble & Meta-Learning (Parallel with Validation)',
|
|
690
|
+
tester: 'Phase 3: Validation & Debugging (Parallel with Ensemble)',
|
|
691
|
+
coordinator: 'All Phases: Workflow Orchestration & Coordination',
|
|
692
|
+
};
|
|
693
|
+
return positions[agentType] || 'Specialized task execution';
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
/**
|
|
582
697
|
* Get coordination partners for agent type
|
|
583
|
-
*/
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
698
|
+
*/
|
|
699
|
+
getCoordinationPartners(agentType) {
|
|
700
|
+
const partners = {
|
|
701
|
+
researcher: 'Foundation Agent (parallel), Refinement Agent (handoff)',
|
|
702
|
+
coder: 'Search Agent (parallel), Refinement Agent (handoff)',
|
|
703
|
+
optimizer: 'Search & Foundation Agents (input), Ensemble & Validation Agents (handoff)',
|
|
704
|
+
analyst: 'Refinement Agent (input), Validation Agent (parallel)',
|
|
705
|
+
tester: 'All previous agents (validation), Ensemble Agent (parallel)',
|
|
706
|
+
coordinator: 'All agents (orchestration and monitoring)',
|
|
707
|
+
};
|
|
708
|
+
return partners[agentType] || 'Other workflow agents as needed';
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
/**
|
|
595
712
|
* Get methodology guidance for agent type
|
|
596
|
-
*/
|
|
597
|
-
|
|
598
|
-
|
|
713
|
+
*/
|
|
714
|
+
getMethodologyGuidance(agentType) {
|
|
715
|
+
const guidance = {
|
|
716
|
+
researcher: `SEARCH PHASE - Web Research & Foundation Discovery:
|
|
599
717
|
- Search for state-of-the-art ML approaches for the problem domain
|
|
600
718
|
- Find winning Kaggle solutions and benchmark results
|
|
601
719
|
- Identify promising model architectures and techniques
|
|
602
720
|
- Document implementation examples and model cards
|
|
603
721
|
- Focus on proven, recent approaches with good performance`,
|
|
604
|
-
|
|
722
|
+
|
|
723
|
+
coder: `FOUNDATION PHASE - Initial Model Building:
|
|
605
724
|
- Analyze dataset characteristics and problem type
|
|
606
725
|
- Implement baseline models based on research findings
|
|
607
726
|
- Create robust preprocessing pipelines
|
|
608
727
|
- Build modular, testable code components
|
|
609
728
|
- Establish performance baselines for comparison`,
|
|
610
|
-
|
|
729
|
+
|
|
730
|
+
optimizer: `REFINEMENT PHASE - Targeted Component Optimization:
|
|
611
731
|
- Perform ablation analysis to identify high-impact components
|
|
612
732
|
- Focus deep optimization on most impactful pipeline elements
|
|
613
733
|
- Use iterative improvement with structured feedback
|
|
614
734
|
- Implement advanced feature engineering techniques
|
|
615
735
|
- Optimize hyperparameters systematically`,
|
|
616
|
-
|
|
736
|
+
|
|
737
|
+
architect: `ENSEMBLE PHASE - Intelligent Model Combination:
|
|
617
738
|
- Create sophisticated ensemble strategies beyond simple averaging
|
|
618
739
|
- Implement stacking with meta-learners
|
|
619
740
|
- Use dynamic weighting and mixture of experts
|
|
620
741
|
- Apply Bayesian model averaging where appropriate
|
|
621
742
|
- Optimize ensemble composition for maximum performance`,
|
|
622
|
-
|
|
743
|
+
|
|
744
|
+
tester: `VALIDATION PHASE - Comprehensive Testing & Debugging:
|
|
623
745
|
- Implement rigorous cross-validation strategies
|
|
624
746
|
- Detect and prevent data leakage
|
|
625
747
|
- Perform error analysis and debugging
|
|
626
748
|
- Validate model robustness and generalization
|
|
627
749
|
- Ensure production readiness with quality checks`,
|
|
628
|
-
|
|
750
|
+
|
|
751
|
+
coordinator: `ORCHESTRATION PHASE - Workflow Management:
|
|
629
752
|
- Coordinate between all agents and phases
|
|
630
753
|
- Monitor progress and performance metrics
|
|
631
754
|
- Manage resource allocation and scheduling
|
|
632
755
|
- Handle error recovery and workflow adaptation
|
|
633
|
-
- Prepare final deployment and documentation
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
756
|
+
- Prepare final deployment and documentation`,
|
|
757
|
+
};
|
|
758
|
+
|
|
759
|
+
return (
|
|
760
|
+
guidance[agentType] ||
|
|
761
|
+
'Focus on your specialized capabilities and coordinate with other agents.'
|
|
762
|
+
);
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
/**
|
|
638
766
|
* Execute workflow tasks with dependency management
|
|
639
|
-
*/
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
task: task.id,
|
|
732
|
-
error: error.message || error,
|
|
733
|
-
timestamp: new Date()
|
|
734
|
-
});
|
|
735
|
-
// Check if we should fail fast
|
|
736
|
-
if (workflow.settings?.failurePolicy === 'fail-fast') {
|
|
737
|
-
console.log(`\n🛑 Failing fast due to task failure`);
|
|
738
|
-
break;
|
|
739
|
-
}
|
|
740
|
-
}
|
|
741
|
-
}
|
|
742
|
-
// Show updated task board
|
|
743
|
-
if (!concurrentDisplay) {
|
|
744
|
-
console.log(`\n📊 Phase ${phaseIndex + 1} Complete:`);
|
|
745
|
-
this.displayTaskBoard(taskStatuses);
|
|
746
|
-
}
|
|
747
|
-
// Stop if fail-fast and we have failures
|
|
748
|
-
if (workflow.settings?.failurePolicy === 'fail-fast' && failedTasks > 0) {
|
|
749
|
-
break;
|
|
750
|
-
}
|
|
767
|
+
*/
|
|
768
|
+
async executeWorkflowTasks(workflow) {
|
|
769
|
+
const { tasks, dependencies = {} } = workflow;
|
|
770
|
+
|
|
771
|
+
let completedTasks = 0;
|
|
772
|
+
let failedTasks = 0;
|
|
773
|
+
const totalTasks = tasks.length;
|
|
774
|
+
|
|
775
|
+
// Task status tracking
|
|
776
|
+
const taskStatuses = new Map();
|
|
777
|
+
tasks.forEach((task) => {
|
|
778
|
+
taskStatuses.set(task.id, {
|
|
779
|
+
name: task.name || task.id,
|
|
780
|
+
status: 'pending',
|
|
781
|
+
agent: task.assignTo,
|
|
782
|
+
startTime: null,
|
|
783
|
+
endTime: null,
|
|
784
|
+
summary: '',
|
|
785
|
+
});
|
|
786
|
+
});
|
|
787
|
+
|
|
788
|
+
// Create task execution plan based on dependencies
|
|
789
|
+
const executionPlan = this.createExecutionPlan(tasks, dependencies);
|
|
790
|
+
|
|
791
|
+
console.log(`📋 Executing ${totalTasks} tasks in ${executionPlan.length} phases...`);
|
|
792
|
+
console.log();
|
|
793
|
+
|
|
794
|
+
// Note: Concurrent display disabled in favor of interactive-style stream processing
|
|
795
|
+
let concurrentDisplay = null;
|
|
796
|
+
// if (this.options.nonInteractive && this.options.outputFormat === 'stream-json') {
|
|
797
|
+
// const { createConcurrentDisplay } = await import('./concurrent-display.js');
|
|
798
|
+
//
|
|
799
|
+
// // Get all agents and their tasks
|
|
800
|
+
// const agentTasks = workflow.agents?.map(agent => ({
|
|
801
|
+
// id: agent.id,
|
|
802
|
+
// name: agent.name,
|
|
803
|
+
// type: agent.type,
|
|
804
|
+
// tasks: tasks.filter(t => t.assignTo === agent.id).map(t => t.name)
|
|
805
|
+
// })) || [];
|
|
806
|
+
//
|
|
807
|
+
// concurrentDisplay = createConcurrentDisplay(agentTasks);
|
|
808
|
+
// concurrentDisplay.start();
|
|
809
|
+
//
|
|
810
|
+
// // Store reference for stream processors
|
|
811
|
+
// this.concurrentDisplay = concurrentDisplay;
|
|
812
|
+
// }
|
|
813
|
+
|
|
814
|
+
// Execute tasks phase by phase
|
|
815
|
+
for (const [phaseIndex, phaseTasks] of executionPlan.entries()) {
|
|
816
|
+
this.currentPhase = `Phase ${phaseIndex + 1}`;
|
|
817
|
+
|
|
818
|
+
// Show regular task board or update concurrent display
|
|
819
|
+
if (!concurrentDisplay) {
|
|
820
|
+
if (this.options.logLevel === 'quiet') {
|
|
821
|
+
console.log(`\n🔄 Phase ${phaseIndex + 1}: Running ${phaseTasks.length} tasks`);
|
|
822
|
+
} else {
|
|
823
|
+
console.log(`\n🔄 Phase ${phaseIndex + 1}: ${phaseTasks.length} concurrent tasks`);
|
|
824
|
+
}
|
|
825
|
+
this.displayTaskBoard(taskStatuses, phaseTasks);
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
// Mark tasks as in-progress
|
|
829
|
+
phaseTasks.forEach((task) => {
|
|
830
|
+
const status = taskStatuses.get(task.id);
|
|
831
|
+
status.status = 'in-progress';
|
|
832
|
+
status.startTime = Date.now();
|
|
833
|
+
});
|
|
834
|
+
|
|
835
|
+
// Execute tasks in this phase (potentially in parallel)
|
|
836
|
+
const phasePromises = phaseTasks.map(async (task) => {
|
|
837
|
+
const taskStatus = taskStatuses.get(task.id);
|
|
838
|
+
|
|
839
|
+
try {
|
|
840
|
+
// Show task starting
|
|
841
|
+
console.log(`\n 🚀 Starting: ${task.name || task.id}`);
|
|
842
|
+
console.log(` Agent: ${task.assignTo}`);
|
|
843
|
+
console.log(` Description: ${task.description?.substring(0, 80)}...`);
|
|
844
|
+
|
|
845
|
+
const result = await this.executeTask(task, workflow);
|
|
846
|
+
|
|
847
|
+
taskStatus.status = result.success ? 'completed' : 'failed';
|
|
848
|
+
taskStatus.endTime = Date.now();
|
|
849
|
+
taskStatus.summary = result.success
|
|
850
|
+
? `✅ Completed in ${this.formatDuration(result.duration)}`
|
|
851
|
+
: `❌ Failed: ${result.error?.message || 'Unknown error'}`;
|
|
852
|
+
|
|
853
|
+
return result;
|
|
854
|
+
} catch (error) {
|
|
855
|
+
taskStatus.status = 'failed';
|
|
856
|
+
taskStatus.endTime = Date.now();
|
|
857
|
+
taskStatus.summary = `❌ Error: ${error.message}`;
|
|
858
|
+
throw error;
|
|
751
859
|
}
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
860
|
+
});
|
|
861
|
+
|
|
862
|
+
// Wait for all phase tasks to complete
|
|
863
|
+
const phaseResults = await Promise.allSettled(phasePromises);
|
|
864
|
+
|
|
865
|
+
// Process phase results
|
|
866
|
+
for (const [taskIndex, result] of phaseResults.entries()) {
|
|
867
|
+
const task = phaseTasks[taskIndex];
|
|
868
|
+
const taskStatus = taskStatuses.get(task.id);
|
|
869
|
+
|
|
870
|
+
if (result.status === 'fulfilled' && result.value.success) {
|
|
871
|
+
completedTasks++;
|
|
872
|
+
this.results.set(task.id, result.value);
|
|
756
873
|
} else {
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
874
|
+
failedTasks++;
|
|
875
|
+
const error = result.status === 'rejected' ? result.reason : result.value.error;
|
|
876
|
+
this.errors.push({
|
|
877
|
+
type: 'task_execution',
|
|
878
|
+
task: task.id,
|
|
879
|
+
error: error.message || error,
|
|
880
|
+
timestamp: new Date(),
|
|
881
|
+
});
|
|
882
|
+
|
|
883
|
+
// Check if we should fail fast
|
|
884
|
+
if (workflow.settings?.failurePolicy === 'fail-fast') {
|
|
885
|
+
console.log(`\n🛑 Failing fast due to task failure`);
|
|
886
|
+
break;
|
|
887
|
+
}
|
|
760
888
|
}
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
// Show updated task board
|
|
892
|
+
if (!concurrentDisplay) {
|
|
893
|
+
console.log(`\n📊 Phase ${phaseIndex + 1} Complete:`);
|
|
894
|
+
this.displayTaskBoard(taskStatuses);
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
// Stop if fail-fast and we have failures
|
|
898
|
+
if (workflow.settings?.failurePolicy === 'fail-fast' && failedTasks > 0) {
|
|
899
|
+
break;
|
|
900
|
+
}
|
|
771
901
|
}
|
|
772
|
-
|
|
902
|
+
|
|
903
|
+
// Final summary
|
|
904
|
+
if (!concurrentDisplay) {
|
|
905
|
+
console.log(`\n📊 Final Workflow Summary:`);
|
|
906
|
+
this.displayTaskBoard(taskStatuses);
|
|
907
|
+
} else {
|
|
908
|
+
// Stop concurrent display
|
|
909
|
+
concurrentDisplay.stop();
|
|
910
|
+
console.log(); // Add some space after display
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
return {
|
|
914
|
+
success: failedTasks === 0,
|
|
915
|
+
totalTasks,
|
|
916
|
+
completedTasks,
|
|
917
|
+
failedTasks,
|
|
918
|
+
executionId: this.executionId,
|
|
919
|
+
duration: Date.now() - this.startTime,
|
|
920
|
+
results: Object.fromEntries(this.results),
|
|
921
|
+
errors: this.errors,
|
|
922
|
+
};
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
/**
|
|
773
926
|
* Display task board showing current status
|
|
774
|
-
*/
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
927
|
+
*/
|
|
928
|
+
displayTaskBoard(taskStatuses, highlightTasks = []) {
|
|
929
|
+
// In quiet mode, just show simple progress
|
|
930
|
+
if (this.options.logLevel === 'quiet') {
|
|
931
|
+
const totalTasks = taskStatuses.size;
|
|
932
|
+
const completedTasks = Array.from(taskStatuses.values()).filter(
|
|
933
|
+
(s) => s.status === 'completed',
|
|
934
|
+
).length;
|
|
935
|
+
const activeTasks = Array.from(taskStatuses.values()).filter(
|
|
936
|
+
(s) => s.status === 'in-progress',
|
|
937
|
+
).length;
|
|
938
|
+
console.log(`📊 Progress: ${completedTasks}/${totalTasks} completed, ${activeTasks} active`);
|
|
939
|
+
return;
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
const frames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
|
|
943
|
+
const frameIndex = Math.floor(Date.now() / 100) % frames.length;
|
|
944
|
+
const spinner = frames[frameIndex];
|
|
945
|
+
|
|
946
|
+
console.log('\n╔═══════════════════════════════════════════════════════════════╗');
|
|
947
|
+
console.log('║ 🤖 CONCURRENT TASK STATUS ║');
|
|
948
|
+
console.log('╠═══════════════════════════════════════════════════════════════╣');
|
|
949
|
+
|
|
950
|
+
// Group by status
|
|
951
|
+
const statusGroups = {
|
|
952
|
+
'in-progress': [],
|
|
953
|
+
completed: [],
|
|
954
|
+
failed: [],
|
|
955
|
+
pending: [],
|
|
956
|
+
};
|
|
957
|
+
|
|
958
|
+
taskStatuses.forEach((status, taskId) => {
|
|
959
|
+
statusGroups[status.status].push({ taskId, ...status });
|
|
960
|
+
});
|
|
961
|
+
|
|
962
|
+
// Show in-progress tasks with animation
|
|
963
|
+
if (statusGroups['in-progress'].length > 0) {
|
|
964
|
+
console.log(
|
|
965
|
+
`║ ${spinner} RUNNING (${statusGroups['in-progress'].length} agents): ║`,
|
|
966
|
+
);
|
|
967
|
+
statusGroups['in-progress'].forEach((task) => {
|
|
968
|
+
const duration = task.startTime ? this.formatDuration(Date.now() - task.startTime) : '';
|
|
969
|
+
const progress = this.getProgressBar(Date.now() - task.startTime, 60000); // 1 min expected
|
|
970
|
+
const agentIcon = this.getAgentIcon(task.agent);
|
|
971
|
+
console.log(
|
|
972
|
+
`║ ${agentIcon} ${task.name.padEnd(25)} ${progress} ${duration.padStart(8)} ║`,
|
|
973
|
+
);
|
|
974
|
+
});
|
|
975
|
+
}
|
|
976
|
+
|
|
977
|
+
// Show completed tasks
|
|
978
|
+
if (statusGroups['completed'].length > 0) {
|
|
979
|
+
console.log(
|
|
980
|
+
`║ ✅ COMPLETED (${statusGroups['completed'].length}): ║`,
|
|
981
|
+
);
|
|
982
|
+
statusGroups['completed'].forEach((task) => {
|
|
983
|
+
const duration =
|
|
984
|
+
task.endTime && task.startTime ? this.formatDuration(task.endTime - task.startTime) : '';
|
|
985
|
+
console.log(`║ ✓ ${task.name.padEnd(35)} ${duration.padStart(10)} ║`);
|
|
986
|
+
});
|
|
987
|
+
}
|
|
988
|
+
|
|
989
|
+
// Show failed tasks
|
|
990
|
+
if (statusGroups['failed'].length > 0) {
|
|
991
|
+
console.log(
|
|
992
|
+
`║ ❌ FAILED (${statusGroups['failed'].length}): ║`,
|
|
993
|
+
);
|
|
994
|
+
statusGroups['failed'].forEach((task) => {
|
|
995
|
+
const errorMsg = (task.summary || '').substring(0, 25);
|
|
996
|
+
console.log(`║ ✗ ${task.name.padEnd(25)} ${errorMsg.padEnd(20)} ║`);
|
|
997
|
+
});
|
|
998
|
+
}
|
|
999
|
+
|
|
1000
|
+
// Show pending tasks count
|
|
1001
|
+
if (statusGroups['pending'].length > 0) {
|
|
1002
|
+
console.log(
|
|
1003
|
+
`║ ⏳ QUEUED: ${statusGroups['pending'].length} tasks waiting ║`,
|
|
1004
|
+
);
|
|
1005
|
+
}
|
|
1006
|
+
|
|
1007
|
+
// Summary stats
|
|
1008
|
+
const total = taskStatuses.size;
|
|
1009
|
+
const completed = statusGroups['completed'].length;
|
|
1010
|
+
const failed = statusGroups['failed'].length;
|
|
1011
|
+
const progress = total > 0 ? Math.floor(((completed + failed) / total) * 100) : 0;
|
|
1012
|
+
|
|
1013
|
+
console.log('╠═══════════════════════════════════════════════════════════════╣');
|
|
1014
|
+
console.log(
|
|
1015
|
+
`║ 📊 Progress: ${progress}% (${completed}/${total}) │ ⚡ Active: ${statusGroups['in-progress'].length} │ ❌ Failed: ${failed} ║`,
|
|
1016
|
+
);
|
|
1017
|
+
console.log('╚═══════════════════════════════════════════════════════════════╝');
|
|
1018
|
+
}
|
|
1019
|
+
|
|
1020
|
+
/**
|
|
1021
|
+
* Get progress bar visualization
|
|
1022
|
+
*/
|
|
1023
|
+
getProgressBar(elapsed, expected) {
|
|
1024
|
+
const progress = Math.min(elapsed / expected, 1);
|
|
1025
|
+
const filled = Math.floor(progress * 10);
|
|
1026
|
+
const empty = 10 - filled;
|
|
1027
|
+
return '[' + '█'.repeat(filled) + '░'.repeat(empty) + ']';
|
|
1028
|
+
}
|
|
1029
|
+
|
|
1030
|
+
/**
|
|
1031
|
+
* Get agent icon based on type
|
|
1032
|
+
*/
|
|
1033
|
+
getAgentIcon(agentId) {
|
|
1034
|
+
const icons = {
|
|
1035
|
+
search: '🔍',
|
|
1036
|
+
foundation: '🏗️',
|
|
1037
|
+
refinement: '🔧',
|
|
1038
|
+
ensemble: '🎯',
|
|
1039
|
+
validation: '✅',
|
|
1040
|
+
coordinator: '🎮',
|
|
1041
|
+
researcher: '🔬',
|
|
1042
|
+
coder: '💻',
|
|
1043
|
+
optimizer: '⚡',
|
|
1044
|
+
architect: '🏛️',
|
|
1045
|
+
tester: '🧪',
|
|
1046
|
+
};
|
|
1047
|
+
|
|
1048
|
+
// Extract agent type from ID
|
|
1049
|
+
const type = agentId?.split('_')[0] || 'default';
|
|
1050
|
+
return icons[type] || '🤖';
|
|
1051
|
+
}
|
|
1052
|
+
|
|
1053
|
+
/**
|
|
1054
|
+
* Execute a single task
|
|
1055
|
+
*/
|
|
1056
|
+
async executeTask(task, workflow) {
|
|
1057
|
+
const startTime = Date.now();
|
|
1058
|
+
|
|
1059
|
+
try {
|
|
1060
|
+
// Store task execution in memory if hooks enabled
|
|
1061
|
+
if (this.hooksEnabled) {
|
|
1062
|
+
await this.executeHook('notify', {
|
|
1063
|
+
message: `Starting task: ${task.name || task.id}`,
|
|
1064
|
+
sessionId: this.sessionId,
|
|
1065
|
+
});
|
|
1066
|
+
}
|
|
1067
|
+
|
|
1068
|
+
if (this.options.nonInteractive && this.options.outputFormat === 'stream-json') {
|
|
1069
|
+
console.log(`\n● ${task.name || task.id} - Starting Execution`);
|
|
1070
|
+
console.log(` ⎿ ${task.description}`);
|
|
1071
|
+
console.log(` ⎿ Agent: ${task.assignTo}`);
|
|
1072
|
+
} else {
|
|
1073
|
+
console.log(` 🔄 Executing: ${task.description}`);
|
|
1074
|
+
}
|
|
1075
|
+
|
|
1076
|
+
// For demonstration/testing mode (when Claude integration is disabled)
|
|
1077
|
+
// we simulate successful task completion
|
|
1078
|
+
if (!this.options.enableClaude) {
|
|
1079
|
+
// Simulate variable execution time
|
|
1080
|
+
const executionTime = Math.min(
|
|
1081
|
+
1000 + Math.random() * 3000, // 1-4 seconds simulation
|
|
1082
|
+
task.timeout || 30000,
|
|
1083
|
+
);
|
|
1084
|
+
|
|
1085
|
+
await new Promise((resolve) => setTimeout(resolve, executionTime));
|
|
1086
|
+
|
|
1087
|
+
// Simulate successful completion for demo/testing
|
|
1088
|
+
const result = {
|
|
1089
|
+
success: true,
|
|
1090
|
+
taskId: task.id,
|
|
1091
|
+
duration: Date.now() - startTime,
|
|
1092
|
+
output: {
|
|
1093
|
+
status: 'completed',
|
|
1094
|
+
agent: task.assignTo,
|
|
1095
|
+
executionTime: Date.now() - startTime,
|
|
1096
|
+
metadata: {
|
|
1097
|
+
timestamp: new Date().toISOString(),
|
|
1098
|
+
executionId: this.executionId,
|
|
1099
|
+
mode: 'simulation',
|
|
1100
|
+
},
|
|
1101
|
+
},
|
|
806
1102
|
};
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
1103
|
+
|
|
1104
|
+
// Store result in memory
|
|
1105
|
+
if (this.hooksEnabled) {
|
|
1106
|
+
await this.storeTaskResult(task.id, result.output);
|
|
1107
|
+
}
|
|
1108
|
+
|
|
1109
|
+
return result;
|
|
1110
|
+
} else {
|
|
1111
|
+
// When Claude integration is enabled, delegate to actual Claude instance
|
|
1112
|
+
|
|
1113
|
+
// Check if we have a master coordinator (interactive mode)
|
|
1114
|
+
const masterCoordinator = this.claudeInstances.get('master-coordinator');
|
|
1115
|
+
if (masterCoordinator && !this.options.nonInteractive) {
|
|
1116
|
+
// Interactive mode: All tasks are coordinated by the master coordinator
|
|
1117
|
+
console.log(` 🎯 Task delegated to Master Coordinator: ${task.description}`);
|
|
1118
|
+
|
|
1119
|
+
// In interactive mode, the master coordinator handles all tasks
|
|
1120
|
+
// We just wait for the master coordinator process to complete
|
|
1121
|
+
const completionPromise = new Promise((resolve, reject) => {
|
|
1122
|
+
masterCoordinator.process.on('exit', (code) => {
|
|
1123
|
+
if (code === 0) {
|
|
1124
|
+
resolve({ success: true, code });
|
|
1125
|
+
} else {
|
|
1126
|
+
reject(new Error(`Master coordinator exited with code ${code}`));
|
|
1127
|
+
}
|
|
811
1128
|
});
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
console.log(`║ ${spinner} RUNNING (${statusGroups['in-progress'].length} agents): ║`);
|
|
816
|
-
statusGroups['in-progress'].forEach((task)=>{
|
|
817
|
-
const duration = task.startTime ? this.formatDuration(Date.now() - task.startTime) : '';
|
|
818
|
-
const progress = this.getProgressBar(Date.now() - task.startTime, 60000); // 1 min expected
|
|
819
|
-
const agentIcon = this.getAgentIcon(task.agent);
|
|
820
|
-
console.log(`║ ${agentIcon} ${task.name.padEnd(25)} ${progress} ${duration.padStart(8)} ║`);
|
|
1129
|
+
|
|
1130
|
+
masterCoordinator.process.on('error', (err) => {
|
|
1131
|
+
reject(err);
|
|
821
1132
|
});
|
|
1133
|
+
});
|
|
1134
|
+
|
|
1135
|
+
// For interactive mode, we use a longer timeout since user interaction is involved
|
|
1136
|
+
const timeout = Math.max(this.options.timeout, 1800000); // 30 minutes minimum for interactive
|
|
1137
|
+
const timeoutPromise = new Promise((_, reject) => {
|
|
1138
|
+
setTimeout(() => reject(new Error('Interactive session timeout')), timeout);
|
|
1139
|
+
});
|
|
1140
|
+
|
|
1141
|
+
try {
|
|
1142
|
+
await Promise.race([completionPromise, timeoutPromise]);
|
|
1143
|
+
|
|
1144
|
+
const result = {
|
|
1145
|
+
success: true,
|
|
1146
|
+
taskId: task.id,
|
|
1147
|
+
duration: Date.now() - startTime,
|
|
1148
|
+
output: {
|
|
1149
|
+
status: 'completed',
|
|
1150
|
+
agent: 'master-coordinator',
|
|
1151
|
+
executionTime: Date.now() - startTime,
|
|
1152
|
+
metadata: {
|
|
1153
|
+
timestamp: new Date().toISOString(),
|
|
1154
|
+
executionId: this.executionId,
|
|
1155
|
+
mode: 'interactive-coordination',
|
|
1156
|
+
},
|
|
1157
|
+
},
|
|
1158
|
+
};
|
|
1159
|
+
|
|
1160
|
+
// Store result in memory
|
|
1161
|
+
if (this.hooksEnabled) {
|
|
1162
|
+
await this.storeTaskResult(task.id, result.output);
|
|
1163
|
+
}
|
|
1164
|
+
|
|
1165
|
+
return result;
|
|
1166
|
+
} catch (error) {
|
|
1167
|
+
throw new Error(`Task execution failed: ${error.message}`);
|
|
1168
|
+
}
|
|
822
1169
|
}
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
1170
|
+
|
|
1171
|
+
// Non-interactive mode or no master coordinator: use individual Claude instances
|
|
1172
|
+
const claudeInstance = this.claudeInstances.get(task.assignTo);
|
|
1173
|
+
if (!claudeInstance) {
|
|
1174
|
+
// If no pre-spawned instance, create one for this task
|
|
1175
|
+
const agent = workflow.agents.find((a) => a.id === task.assignTo);
|
|
1176
|
+
if (!agent) {
|
|
1177
|
+
throw new Error(`No agent definition found for: ${task.assignTo}`);
|
|
1178
|
+
}
|
|
1179
|
+
|
|
1180
|
+
// Create task-specific prompt
|
|
1181
|
+
const taskPrompt = this.createTaskPrompt(task, agent, workflow);
|
|
1182
|
+
|
|
1183
|
+
// Check if we should chain from a previous task
|
|
1184
|
+
let chainOptions = {};
|
|
1185
|
+
if (
|
|
1186
|
+
this.enableChaining &&
|
|
1187
|
+
this.options.outputFormat === 'stream-json' &&
|
|
1188
|
+
task.depends?.length > 0
|
|
1189
|
+
) {
|
|
1190
|
+
// Get the output stream from the last dependency
|
|
1191
|
+
const lastDependency = task.depends[task.depends.length - 1];
|
|
1192
|
+
const dependencyStream = this.taskOutputStreams.get(lastDependency);
|
|
1193
|
+
if (dependencyStream) {
|
|
1194
|
+
console.log(` 🔗 Enabling stream chaining from ${lastDependency} to ${task.id}`);
|
|
1195
|
+
chainOptions.inputStream = dependencyStream;
|
|
1196
|
+
}
|
|
1197
|
+
}
|
|
1198
|
+
|
|
1199
|
+
// Spawn Claude instance for this specific task
|
|
1200
|
+
const taskClaudeProcess = await this.spawnClaudeInstance(agent, taskPrompt, chainOptions);
|
|
1201
|
+
|
|
1202
|
+
// Store the output stream for potential chaining
|
|
1203
|
+
if (
|
|
1204
|
+
this.enableChaining &&
|
|
1205
|
+
this.options.outputFormat === 'stream-json' &&
|
|
1206
|
+
taskClaudeProcess.stdout
|
|
1207
|
+
) {
|
|
1208
|
+
this.taskOutputStreams.set(task.id, taskClaudeProcess.stdout);
|
|
1209
|
+
}
|
|
1210
|
+
|
|
1211
|
+
// Store the instance
|
|
1212
|
+
this.claudeInstances.set(agent.id, {
|
|
1213
|
+
process: taskClaudeProcess,
|
|
1214
|
+
agent: agent,
|
|
1215
|
+
status: 'active',
|
|
1216
|
+
startTime: Date.now(),
|
|
1217
|
+
taskId: task.id,
|
|
1218
|
+
});
|
|
1219
|
+
|
|
1220
|
+
// Wait for task completion or timeout
|
|
1221
|
+
// Use longer timeout for ML tasks
|
|
1222
|
+
const baseTimeout = this.options.timeout || 60000;
|
|
1223
|
+
const isMLTask =
|
|
1224
|
+
task.type?.toLowerCase().includes('ml') ||
|
|
1225
|
+
task.type?.toLowerCase().includes('model') ||
|
|
1226
|
+
task.type?.toLowerCase().includes('search') ||
|
|
1227
|
+
task.type?.toLowerCase().includes('analysis') ||
|
|
1228
|
+
this.options.workflowType === 'ml';
|
|
1229
|
+
const timeout = task.timeout || (isMLTask ? Math.max(baseTimeout, 300000) : baseTimeout); // Min 5 minutes for ML tasks
|
|
1230
|
+
|
|
1231
|
+
if (this.options.logLevel === 'debug' || this.options.verbose) {
|
|
1232
|
+
console.log(
|
|
1233
|
+
` ⏱️ Timeout: ${this.formatDuration(timeout)} (Base: ${this.formatDuration(baseTimeout)}, ML Task: ${isMLTask})`,
|
|
1234
|
+
);
|
|
1235
|
+
}
|
|
1236
|
+
|
|
1237
|
+
const completionPromise = new Promise((resolve, reject) => {
|
|
1238
|
+
taskClaudeProcess.on('exit', (code) => {
|
|
1239
|
+
if (code === 0) {
|
|
1240
|
+
resolve({ success: true, code });
|
|
1241
|
+
} else {
|
|
1242
|
+
reject(new Error(`Process exited with code ${code}`));
|
|
1243
|
+
}
|
|
829
1244
|
});
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
console.log(`║ ❌ FAILED (${statusGroups['failed'].length}): ║`);
|
|
834
|
-
statusGroups['failed'].forEach((task)=>{
|
|
835
|
-
const errorMsg = (task.summary || '').substring(0, 25);
|
|
836
|
-
console.log(`║ ✗ ${task.name.padEnd(25)} ${errorMsg.padEnd(20)} ║`);
|
|
1245
|
+
|
|
1246
|
+
taskClaudeProcess.on('error', (err) => {
|
|
1247
|
+
reject(err);
|
|
837
1248
|
});
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
refinement: '🔧',
|
|
867
|
-
ensemble: '🎯',
|
|
868
|
-
validation: '✅',
|
|
869
|
-
coordinator: '🎮',
|
|
870
|
-
researcher: '🔬',
|
|
871
|
-
coder: '💻',
|
|
872
|
-
optimizer: '⚡',
|
|
873
|
-
architect: '🏛️',
|
|
874
|
-
tester: '🧪'
|
|
875
|
-
};
|
|
876
|
-
// Extract agent type from ID
|
|
877
|
-
const type = agentId?.split('_')[0] || 'default';
|
|
878
|
-
return icons[type] || '🤖';
|
|
879
|
-
}
|
|
880
|
-
/**
|
|
881
|
-
* Execute a single task
|
|
882
|
-
*/ async executeTask(task, workflow) {
|
|
883
|
-
const startTime = Date.now();
|
|
884
|
-
try {
|
|
885
|
-
// Store task execution in memory if hooks enabled
|
|
1249
|
+
});
|
|
1250
|
+
|
|
1251
|
+
const timeoutPromise = new Promise((_, reject) => {
|
|
1252
|
+
// Use a much longer timeout for ML tasks since Claude is actively working
|
|
1253
|
+
const actualTimeout = isMLTask ? Math.max(timeout, 600000) : timeout; // 10 min minimum for ML
|
|
1254
|
+
setTimeout(() => reject(new Error('Task timeout')), actualTimeout);
|
|
1255
|
+
});
|
|
1256
|
+
|
|
1257
|
+
try {
|
|
1258
|
+
await Promise.race([completionPromise, timeoutPromise]);
|
|
1259
|
+
|
|
1260
|
+
const result = {
|
|
1261
|
+
success: true,
|
|
1262
|
+
taskId: task.id,
|
|
1263
|
+
duration: Date.now() - startTime,
|
|
1264
|
+
output: {
|
|
1265
|
+
status: 'completed',
|
|
1266
|
+
agent: task.assignTo,
|
|
1267
|
+
executionTime: Date.now() - startTime,
|
|
1268
|
+
metadata: {
|
|
1269
|
+
timestamp: new Date().toISOString(),
|
|
1270
|
+
executionId: this.executionId,
|
|
1271
|
+
mode: 'claude-task-execution',
|
|
1272
|
+
},
|
|
1273
|
+
},
|
|
1274
|
+
};
|
|
1275
|
+
|
|
1276
|
+
// Store result in memory
|
|
886
1277
|
if (this.hooksEnabled) {
|
|
887
|
-
|
|
888
|
-
message: `Starting task: ${task.name || task.id}`,
|
|
889
|
-
sessionId: this.sessionId
|
|
890
|
-
});
|
|
891
|
-
}
|
|
892
|
-
if (this.options.nonInteractive && this.options.outputFormat === 'stream-json') {
|
|
893
|
-
console.log(`\n● ${task.name || task.id} - Starting Execution`);
|
|
894
|
-
console.log(` ⎿ ${task.description}`);
|
|
895
|
-
console.log(` ⎿ Agent: ${task.assignTo}`);
|
|
896
|
-
} else {
|
|
897
|
-
console.log(` 🔄 Executing: ${task.description}`);
|
|
1278
|
+
await this.storeTaskResult(task.id, result.output);
|
|
898
1279
|
}
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
return result;
|
|
926
|
-
} else {
|
|
927
|
-
// When Claude integration is enabled, delegate to actual Claude instance
|
|
928
|
-
// Check if we have a master coordinator (interactive mode)
|
|
929
|
-
const masterCoordinator = this.claudeInstances.get('master-coordinator');
|
|
930
|
-
if (masterCoordinator && !this.options.nonInteractive) {
|
|
931
|
-
// Interactive mode: All tasks are coordinated by the master coordinator
|
|
932
|
-
console.log(` 🎯 Task delegated to Master Coordinator: ${task.description}`);
|
|
933
|
-
// In interactive mode, the master coordinator handles all tasks
|
|
934
|
-
// We just wait for the master coordinator process to complete
|
|
935
|
-
const completionPromise = new Promise((resolve, reject)=>{
|
|
936
|
-
masterCoordinator.process.on('exit', (code)=>{
|
|
937
|
-
if (code === 0) {
|
|
938
|
-
resolve({
|
|
939
|
-
success: true,
|
|
940
|
-
code
|
|
941
|
-
});
|
|
942
|
-
} else {
|
|
943
|
-
reject(new Error(`Master coordinator exited with code ${code}`));
|
|
944
|
-
}
|
|
945
|
-
});
|
|
946
|
-
masterCoordinator.process.on('error', (err)=>{
|
|
947
|
-
reject(err);
|
|
948
|
-
});
|
|
949
|
-
});
|
|
950
|
-
// For interactive mode, we use a longer timeout since user interaction is involved
|
|
951
|
-
const timeout = Math.max(this.options.timeout, 1800000); // 30 minutes minimum for interactive
|
|
952
|
-
const timeoutPromise = new Promise((_, reject)=>{
|
|
953
|
-
setTimeout(()=>reject(new Error('Interactive session timeout')), timeout);
|
|
954
|
-
});
|
|
955
|
-
try {
|
|
956
|
-
await Promise.race([
|
|
957
|
-
completionPromise,
|
|
958
|
-
timeoutPromise
|
|
959
|
-
]);
|
|
960
|
-
const result = {
|
|
961
|
-
success: true,
|
|
962
|
-
taskId: task.id,
|
|
963
|
-
duration: Date.now() - startTime,
|
|
964
|
-
output: {
|
|
965
|
-
status: 'completed',
|
|
966
|
-
agent: 'master-coordinator',
|
|
967
|
-
executionTime: Date.now() - startTime,
|
|
968
|
-
metadata: {
|
|
969
|
-
timestamp: new Date().toISOString(),
|
|
970
|
-
executionId: this.executionId,
|
|
971
|
-
mode: 'interactive-coordination'
|
|
972
|
-
}
|
|
973
|
-
}
|
|
974
|
-
};
|
|
975
|
-
// Store result in memory
|
|
976
|
-
if (this.hooksEnabled) {
|
|
977
|
-
await this.storeTaskResult(task.id, result.output);
|
|
978
|
-
}
|
|
979
|
-
return result;
|
|
980
|
-
} catch (error) {
|
|
981
|
-
throw new Error(`Task execution failed: ${error.message}`);
|
|
982
|
-
}
|
|
983
|
-
}
|
|
984
|
-
// Non-interactive mode or no master coordinator: use individual Claude instances
|
|
985
|
-
const claudeInstance = this.claudeInstances.get(task.assignTo);
|
|
986
|
-
if (!claudeInstance) {
|
|
987
|
-
// If no pre-spawned instance, create one for this task
|
|
988
|
-
const agent1 = workflow.agents.find((a)=>a.id === task.assignTo);
|
|
989
|
-
if (!agent1) {
|
|
990
|
-
throw new Error(`No agent definition found for: ${task.assignTo}`);
|
|
991
|
-
}
|
|
992
|
-
// Create task-specific prompt
|
|
993
|
-
const taskPrompt = this.createTaskPrompt(task, agent1, workflow);
|
|
994
|
-
// Check if we should chain from a previous task
|
|
995
|
-
let chainOptions = {};
|
|
996
|
-
if (this.enableChaining && this.options.outputFormat === 'stream-json' && task.depends?.length > 0) {
|
|
997
|
-
// Get the output stream from the last dependency
|
|
998
|
-
const lastDependency = task.depends[task.depends.length - 1];
|
|
999
|
-
const dependencyStream = this.taskOutputStreams.get(lastDependency);
|
|
1000
|
-
if (dependencyStream) {
|
|
1001
|
-
console.log(` 🔗 Enabling stream chaining from ${lastDependency} to ${task.id}`);
|
|
1002
|
-
chainOptions.inputStream = dependencyStream;
|
|
1003
|
-
}
|
|
1004
|
-
}
|
|
1005
|
-
// Spawn Claude instance for this specific task
|
|
1006
|
-
const taskClaudeProcess = await this.spawnClaudeInstance(agent1, taskPrompt, chainOptions);
|
|
1007
|
-
// Store the output stream for potential chaining
|
|
1008
|
-
if (this.enableChaining && this.options.outputFormat === 'stream-json' && taskClaudeProcess.stdout) {
|
|
1009
|
-
this.taskOutputStreams.set(task.id, taskClaudeProcess.stdout);
|
|
1010
|
-
}
|
|
1011
|
-
// Store the instance
|
|
1012
|
-
this.claudeInstances.set(agent1.id, {
|
|
1013
|
-
process: taskClaudeProcess,
|
|
1014
|
-
agent: agent1,
|
|
1015
|
-
status: 'active',
|
|
1016
|
-
startTime: Date.now(),
|
|
1017
|
-
taskId: task.id
|
|
1018
|
-
});
|
|
1019
|
-
// Wait for task completion or timeout
|
|
1020
|
-
// Use longer timeout for ML tasks
|
|
1021
|
-
const baseTimeout = this.options.timeout || 60000;
|
|
1022
|
-
const isMLTask = task.type?.toLowerCase().includes('ml') || task.type?.toLowerCase().includes('model') || task.type?.toLowerCase().includes('search') || task.type?.toLowerCase().includes('analysis') || this.options.workflowType === 'ml';
|
|
1023
|
-
const timeout = task.timeout || (isMLTask ? Math.max(baseTimeout, 300000) : baseTimeout); // Min 5 minutes for ML tasks
|
|
1024
|
-
if (this.options.logLevel === 'debug' || this.options.verbose) {
|
|
1025
|
-
console.log(` ⏱️ Timeout: ${this.formatDuration(timeout)} (Base: ${this.formatDuration(baseTimeout)}, ML Task: ${isMLTask})`);
|
|
1026
|
-
}
|
|
1027
|
-
const completionPromise = new Promise((resolve, reject)=>{
|
|
1028
|
-
taskClaudeProcess.on('exit', (code)=>{
|
|
1029
|
-
if (code === 0) {
|
|
1030
|
-
resolve({
|
|
1031
|
-
success: true,
|
|
1032
|
-
code
|
|
1033
|
-
});
|
|
1034
|
-
} else {
|
|
1035
|
-
reject(new Error(`Process exited with code ${code}`));
|
|
1036
|
-
}
|
|
1037
|
-
});
|
|
1038
|
-
taskClaudeProcess.on('error', (err)=>{
|
|
1039
|
-
reject(err);
|
|
1040
|
-
});
|
|
1041
|
-
});
|
|
1042
|
-
const timeoutPromise = new Promise((_, reject)=>{
|
|
1043
|
-
// Use a much longer timeout for ML tasks since Claude is actively working
|
|
1044
|
-
const actualTimeout = isMLTask ? Math.max(timeout, 600000) : timeout; // 10 min minimum for ML
|
|
1045
|
-
setTimeout(()=>reject(new Error('Task timeout')), actualTimeout);
|
|
1046
|
-
});
|
|
1047
|
-
try {
|
|
1048
|
-
await Promise.race([
|
|
1049
|
-
completionPromise,
|
|
1050
|
-
timeoutPromise
|
|
1051
|
-
]);
|
|
1052
|
-
const result = {
|
|
1053
|
-
success: true,
|
|
1054
|
-
taskId: task.id,
|
|
1055
|
-
duration: Date.now() - startTime,
|
|
1056
|
-
output: {
|
|
1057
|
-
status: 'completed',
|
|
1058
|
-
agent: task.assignTo,
|
|
1059
|
-
executionTime: Date.now() - startTime,
|
|
1060
|
-
metadata: {
|
|
1061
|
-
timestamp: new Date().toISOString(),
|
|
1062
|
-
executionId: this.executionId,
|
|
1063
|
-
mode: 'claude-task-execution'
|
|
1064
|
-
}
|
|
1065
|
-
}
|
|
1066
|
-
};
|
|
1067
|
-
// Store result in memory
|
|
1068
|
-
if (this.hooksEnabled) {
|
|
1069
|
-
await this.storeTaskResult(task.id, result.output);
|
|
1070
|
-
}
|
|
1071
|
-
return result;
|
|
1072
|
-
} catch (error) {
|
|
1073
|
-
throw error;
|
|
1074
|
-
}
|
|
1075
|
-
} else {
|
|
1076
|
-
// Use existing Claude instance
|
|
1077
|
-
// In a full implementation, this would send the task to the running instance
|
|
1078
|
-
// For now, we'll spawn a new instance per task for simplicity
|
|
1079
|
-
const agent1 = claudeInstance.agent;
|
|
1080
|
-
const taskPrompt = this.createTaskPrompt(task, agent1, workflow);
|
|
1081
|
-
// Check if we should chain from a previous task
|
|
1082
|
-
let chainOptions = {};
|
|
1083
|
-
if (this.enableChaining && this.options.outputFormat === 'stream-json' && task.depends?.length > 0) {
|
|
1084
|
-
// Get the output stream from the last dependency
|
|
1085
|
-
const lastDependency = task.depends[task.depends.length - 1];
|
|
1086
|
-
const dependencyStream = this.taskOutputStreams.get(lastDependency);
|
|
1087
|
-
if (dependencyStream) {
|
|
1088
|
-
console.log(` 🔗 Enabling stream chaining from ${lastDependency} to ${task.id}`);
|
|
1089
|
-
chainOptions.inputStream = dependencyStream;
|
|
1090
|
-
}
|
|
1091
|
-
}
|
|
1092
|
-
// For now, spawn a new instance for each task
|
|
1093
|
-
const taskClaudeProcess = await this.spawnClaudeInstance(agent1, taskPrompt, chainOptions);
|
|
1094
|
-
// Store the output stream for potential chaining
|
|
1095
|
-
if (this.enableChaining && this.options.outputFormat === 'stream-json' && taskClaudeProcess.stdout) {
|
|
1096
|
-
this.taskOutputStreams.set(task.id, taskClaudeProcess.stdout);
|
|
1097
|
-
}
|
|
1098
|
-
// Wait for completion
|
|
1099
|
-
// Use longer timeout for ML tasks
|
|
1100
|
-
const baseTimeout = this.options.timeout || 60000;
|
|
1101
|
-
const isMLTask = task.type?.toLowerCase().includes('ml') || task.type?.toLowerCase().includes('model') || task.type?.toLowerCase().includes('search') || task.type?.toLowerCase().includes('analysis') || this.options.workflowType === 'ml';
|
|
1102
|
-
const timeout = task.timeout || (isMLTask ? Math.max(baseTimeout, 300000) : baseTimeout); // Min 5 minutes for ML tasks
|
|
1103
|
-
if (this.options.logLevel === 'debug' || this.options.verbose) {
|
|
1104
|
-
console.log(` ⏱️ Timeout: ${this.formatDuration(timeout)} (Base: ${this.formatDuration(baseTimeout)}, ML Task: ${isMLTask})`);
|
|
1105
|
-
}
|
|
1106
|
-
const completionPromise = new Promise((resolve, reject)=>{
|
|
1107
|
-
taskClaudeProcess.on('exit', (code)=>{
|
|
1108
|
-
if (code === 0) {
|
|
1109
|
-
resolve({
|
|
1110
|
-
success: true,
|
|
1111
|
-
code
|
|
1112
|
-
});
|
|
1113
|
-
} else {
|
|
1114
|
-
reject(new Error(`Process exited with code ${code}`));
|
|
1115
|
-
}
|
|
1116
|
-
});
|
|
1117
|
-
taskClaudeProcess.on('error', (err)=>{
|
|
1118
|
-
reject(err);
|
|
1119
|
-
});
|
|
1120
|
-
});
|
|
1121
|
-
const timeoutPromise = new Promise((_, reject)=>{
|
|
1122
|
-
// Use a much longer timeout for ML tasks since Claude is actively working
|
|
1123
|
-
const actualTimeout = isMLTask ? Math.max(timeout, 600000) : timeout; // 10 min minimum for ML
|
|
1124
|
-
setTimeout(()=>reject(new Error('Task timeout')), actualTimeout);
|
|
1125
|
-
});
|
|
1126
|
-
try {
|
|
1127
|
-
await Promise.race([
|
|
1128
|
-
completionPromise,
|
|
1129
|
-
timeoutPromise
|
|
1130
|
-
]);
|
|
1131
|
-
const result = {
|
|
1132
|
-
success: true,
|
|
1133
|
-
taskId: task.id,
|
|
1134
|
-
duration: Date.now() - startTime,
|
|
1135
|
-
output: {
|
|
1136
|
-
status: 'completed',
|
|
1137
|
-
agent: task.assignTo,
|
|
1138
|
-
executionTime: Date.now() - startTime,
|
|
1139
|
-
metadata: {
|
|
1140
|
-
timestamp: new Date().toISOString(),
|
|
1141
|
-
executionId: this.executionId,
|
|
1142
|
-
mode: 'claude-task-execution'
|
|
1143
|
-
}
|
|
1144
|
-
}
|
|
1145
|
-
};
|
|
1146
|
-
// Store result in memory
|
|
1147
|
-
if (this.hooksEnabled) {
|
|
1148
|
-
await this.storeTaskResult(task.id, result.output);
|
|
1149
|
-
}
|
|
1150
|
-
return result;
|
|
1151
|
-
} catch (error) {
|
|
1152
|
-
throw error;
|
|
1153
|
-
}
|
|
1154
|
-
}
|
|
1280
|
+
|
|
1281
|
+
return result;
|
|
1282
|
+
} catch (error) {
|
|
1283
|
+
throw error;
|
|
1284
|
+
}
|
|
1285
|
+
} else {
|
|
1286
|
+
// Use existing Claude instance
|
|
1287
|
+
// In a full implementation, this would send the task to the running instance
|
|
1288
|
+
// For now, we'll spawn a new instance per task for simplicity
|
|
1289
|
+
|
|
1290
|
+
const agent = claudeInstance.agent;
|
|
1291
|
+
const taskPrompt = this.createTaskPrompt(task, agent, workflow);
|
|
1292
|
+
|
|
1293
|
+
// Check if we should chain from a previous task
|
|
1294
|
+
let chainOptions = {};
|
|
1295
|
+
if (
|
|
1296
|
+
this.enableChaining &&
|
|
1297
|
+
this.options.outputFormat === 'stream-json' &&
|
|
1298
|
+
task.depends?.length > 0
|
|
1299
|
+
) {
|
|
1300
|
+
// Get the output stream from the last dependency
|
|
1301
|
+
const lastDependency = task.depends[task.depends.length - 1];
|
|
1302
|
+
const dependencyStream = this.taskOutputStreams.get(lastDependency);
|
|
1303
|
+
if (dependencyStream) {
|
|
1304
|
+
console.log(` 🔗 Enabling stream chaining from ${lastDependency} to ${task.id}`);
|
|
1305
|
+
chainOptions.inputStream = dependencyStream;
|
|
1155
1306
|
}
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1307
|
+
}
|
|
1308
|
+
|
|
1309
|
+
// For now, spawn a new instance for each task
|
|
1310
|
+
const taskClaudeProcess = await this.spawnClaudeInstance(agent, taskPrompt, chainOptions);
|
|
1311
|
+
|
|
1312
|
+
// Store the output stream for potential chaining
|
|
1313
|
+
if (
|
|
1314
|
+
this.enableChaining &&
|
|
1315
|
+
this.options.outputFormat === 'stream-json' &&
|
|
1316
|
+
taskClaudeProcess.stdout
|
|
1317
|
+
) {
|
|
1318
|
+
this.taskOutputStreams.set(task.id, taskClaudeProcess.stdout);
|
|
1319
|
+
}
|
|
1320
|
+
|
|
1321
|
+
// Wait for completion
|
|
1322
|
+
// Use longer timeout for ML tasks
|
|
1323
|
+
const baseTimeout = this.options.timeout || 60000;
|
|
1324
|
+
const isMLTask =
|
|
1325
|
+
task.type?.toLowerCase().includes('ml') ||
|
|
1326
|
+
task.type?.toLowerCase().includes('model') ||
|
|
1327
|
+
task.type?.toLowerCase().includes('search') ||
|
|
1328
|
+
task.type?.toLowerCase().includes('analysis') ||
|
|
1329
|
+
this.options.workflowType === 'ml';
|
|
1330
|
+
const timeout = task.timeout || (isMLTask ? Math.max(baseTimeout, 300000) : baseTimeout); // Min 5 minutes for ML tasks
|
|
1331
|
+
|
|
1332
|
+
if (this.options.logLevel === 'debug' || this.options.verbose) {
|
|
1333
|
+
console.log(
|
|
1334
|
+
` ⏱️ Timeout: ${this.formatDuration(timeout)} (Base: ${this.formatDuration(baseTimeout)}, ML Task: ${isMLTask})`,
|
|
1335
|
+
);
|
|
1336
|
+
}
|
|
1337
|
+
|
|
1338
|
+
const completionPromise = new Promise((resolve, reject) => {
|
|
1339
|
+
taskClaudeProcess.on('exit', (code) => {
|
|
1340
|
+
if (code === 0) {
|
|
1341
|
+
resolve({ success: true, code });
|
|
1342
|
+
} else {
|
|
1343
|
+
reject(new Error(`Process exited with code ${code}`));
|
|
1344
|
+
}
|
|
1345
|
+
});
|
|
1346
|
+
|
|
1347
|
+
taskClaudeProcess.on('error', (err) => {
|
|
1348
|
+
reject(err);
|
|
1349
|
+
});
|
|
1350
|
+
});
|
|
1351
|
+
|
|
1352
|
+
const timeoutPromise = new Promise((_, reject) => {
|
|
1353
|
+
// Use a much longer timeout for ML tasks since Claude is actively working
|
|
1354
|
+
const actualTimeout = isMLTask ? Math.max(timeout, 600000) : timeout; // 10 min minimum for ML
|
|
1355
|
+
setTimeout(() => reject(new Error('Task timeout')), actualTimeout);
|
|
1356
|
+
});
|
|
1357
|
+
|
|
1358
|
+
try {
|
|
1359
|
+
await Promise.race([completionPromise, timeoutPromise]);
|
|
1360
|
+
|
|
1361
|
+
const result = {
|
|
1362
|
+
success: true,
|
|
1363
|
+
taskId: task.id,
|
|
1364
|
+
duration: Date.now() - startTime,
|
|
1365
|
+
output: {
|
|
1366
|
+
status: 'completed',
|
|
1367
|
+
agent: task.assignTo,
|
|
1368
|
+
executionTime: Date.now() - startTime,
|
|
1369
|
+
metadata: {
|
|
1370
|
+
timestamp: new Date().toISOString(),
|
|
1371
|
+
executionId: this.executionId,
|
|
1372
|
+
mode: 'claude-task-execution',
|
|
1373
|
+
},
|
|
1374
|
+
},
|
|
1162
1375
|
};
|
|
1376
|
+
|
|
1377
|
+
// Store result in memory
|
|
1378
|
+
if (this.hooksEnabled) {
|
|
1379
|
+
await this.storeTaskResult(task.id, result.output);
|
|
1380
|
+
}
|
|
1381
|
+
|
|
1382
|
+
return result;
|
|
1383
|
+
} catch (error) {
|
|
1384
|
+
throw error;
|
|
1385
|
+
}
|
|
1163
1386
|
}
|
|
1387
|
+
}
|
|
1388
|
+
} catch (error) {
|
|
1389
|
+
return {
|
|
1390
|
+
success: false,
|
|
1391
|
+
taskId: task.id,
|
|
1392
|
+
duration: Date.now() - startTime,
|
|
1393
|
+
error: error,
|
|
1394
|
+
};
|
|
1164
1395
|
}
|
|
1165
|
-
|
|
1396
|
+
}
|
|
1397
|
+
|
|
1398
|
+
/**
|
|
1166
1399
|
* Create execution plan based on task dependencies
|
|
1167
|
-
*/
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1400
|
+
*/
|
|
1401
|
+
createExecutionPlan(tasks, dependencies) {
|
|
1402
|
+
const taskMap = new Map(tasks.map((task) => [task.id, task]));
|
|
1403
|
+
const completed = new Set();
|
|
1404
|
+
const phases = [];
|
|
1405
|
+
|
|
1406
|
+
while (completed.size < tasks.length) {
|
|
1407
|
+
const readyTasks = tasks.filter((task) => {
|
|
1408
|
+
if (completed.has(task.id)) return false;
|
|
1409
|
+
|
|
1410
|
+
const deps = task.depends || dependencies[task.id] || [];
|
|
1411
|
+
return deps.every((dep) => completed.has(dep));
|
|
1412
|
+
});
|
|
1413
|
+
|
|
1414
|
+
if (readyTasks.length === 0) {
|
|
1415
|
+
throw new Error('Circular dependency detected or invalid dependencies');
|
|
1416
|
+
}
|
|
1417
|
+
|
|
1418
|
+
phases.push(readyTasks);
|
|
1419
|
+
readyTasks.forEach((task) => completed.add(task.id));
|
|
1187
1420
|
}
|
|
1188
|
-
|
|
1421
|
+
|
|
1422
|
+
return phases;
|
|
1423
|
+
}
|
|
1424
|
+
|
|
1425
|
+
/**
|
|
1189
1426
|
* Execute a hook command
|
|
1190
|
-
*/
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1427
|
+
*/
|
|
1428
|
+
async executeHook(hookType, params) {
|
|
1429
|
+
try {
|
|
1430
|
+
const { execSync } = await import('child_process');
|
|
1431
|
+
|
|
1432
|
+
let hookCommand = `npx claude-flow@alpha hooks ${hookType}`;
|
|
1433
|
+
|
|
1434
|
+
if (params.description) {
|
|
1435
|
+
hookCommand += ` --description "${params.description}"`;
|
|
1436
|
+
}
|
|
1437
|
+
if (params.file) {
|
|
1438
|
+
hookCommand += ` --file "${params.file}"`;
|
|
1439
|
+
}
|
|
1440
|
+
if (params.taskId) {
|
|
1441
|
+
hookCommand += ` --task-id "${params.taskId}"`;
|
|
1442
|
+
}
|
|
1443
|
+
if (params.sessionId) {
|
|
1444
|
+
hookCommand += ` --session-id "${params.sessionId}"`;
|
|
1445
|
+
}
|
|
1446
|
+
if (params.message) {
|
|
1447
|
+
hookCommand += ` --message "${params.message}"`;
|
|
1448
|
+
}
|
|
1449
|
+
|
|
1450
|
+
execSync(hookCommand, { stdio: 'pipe' });
|
|
1451
|
+
} catch (error) {
|
|
1452
|
+
// Hooks are optional, don't fail the workflow if they fail
|
|
1453
|
+
console.debug(`Hook ${hookType} failed:`, error.message);
|
|
1216
1454
|
}
|
|
1217
|
-
|
|
1455
|
+
}
|
|
1456
|
+
|
|
1457
|
+
/**
|
|
1218
1458
|
* Store task result in memory
|
|
1219
|
-
*/
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1459
|
+
*/
|
|
1460
|
+
async storeTaskResult(taskId, result) {
|
|
1461
|
+
try {
|
|
1462
|
+
const { execSync } = await import('child_process');
|
|
1463
|
+
const resultJson = JSON.stringify(result);
|
|
1464
|
+
|
|
1465
|
+
execSync(
|
|
1466
|
+
`npx claude-flow@alpha memory store "workflow/${this.executionId}/${taskId}" '${resultJson}'`,
|
|
1467
|
+
{
|
|
1468
|
+
stdio: 'pipe',
|
|
1469
|
+
},
|
|
1470
|
+
);
|
|
1471
|
+
} catch (error) {
|
|
1472
|
+
console.debug(`Failed to store task result for ${taskId}:`, error.message);
|
|
1229
1473
|
}
|
|
1230
|
-
|
|
1474
|
+
}
|
|
1475
|
+
|
|
1476
|
+
/**
|
|
1231
1477
|
* Validate workflow definition
|
|
1232
|
-
*/
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1478
|
+
*/
|
|
1479
|
+
validateWorkflow(workflow) {
|
|
1480
|
+
if (!workflow.name) {
|
|
1481
|
+
throw new Error('Workflow name is required');
|
|
1482
|
+
}
|
|
1483
|
+
|
|
1484
|
+
if (!workflow.tasks || workflow.tasks.length === 0) {
|
|
1485
|
+
throw new Error('Workflow must contain at least one task');
|
|
1486
|
+
}
|
|
1487
|
+
|
|
1488
|
+
// Validate task structure
|
|
1489
|
+
for (const task of workflow.tasks) {
|
|
1490
|
+
if (!task.id || !task.type || !task.description) {
|
|
1491
|
+
throw new Error(`Task ${task.id || 'unknown'} is missing required fields`);
|
|
1492
|
+
}
|
|
1493
|
+
}
|
|
1494
|
+
|
|
1495
|
+
// Validate agent assignments
|
|
1496
|
+
if (workflow.agents) {
|
|
1497
|
+
const agentIds = new Set(workflow.agents.map((a) => a.id));
|
|
1498
|
+
for (const task of workflow.tasks) {
|
|
1499
|
+
if (task.assignTo && !agentIds.has(task.assignTo)) {
|
|
1500
|
+
throw new Error(`Task ${task.id} assigned to unknown agent: ${task.assignTo}`);
|
|
1253
1501
|
}
|
|
1502
|
+
}
|
|
1254
1503
|
}
|
|
1255
|
-
|
|
1504
|
+
}
|
|
1505
|
+
|
|
1506
|
+
/**
|
|
1256
1507
|
* Apply variable substitutions to workflow
|
|
1257
|
-
*/
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
processedStr = processedStr.replace(pattern, value);
|
|
1268
|
-
}
|
|
1269
|
-
return JSON.parse(processedStr);
|
|
1508
|
+
*/
|
|
1509
|
+
applyVariables(workflow, variables) {
|
|
1510
|
+
const allVariables = { ...workflow.variables, ...variables };
|
|
1511
|
+
const workflowStr = JSON.stringify(workflow);
|
|
1512
|
+
|
|
1513
|
+
// Simple variable substitution
|
|
1514
|
+
let processedStr = workflowStr;
|
|
1515
|
+
for (const [key, value] of Object.entries(allVariables)) {
|
|
1516
|
+
const pattern = new RegExp(`\\$\\{${key}\\}`, 'g');
|
|
1517
|
+
processedStr = processedStr.replace(pattern, value);
|
|
1270
1518
|
}
|
|
1271
|
-
|
|
1519
|
+
|
|
1520
|
+
return JSON.parse(processedStr);
|
|
1521
|
+
}
|
|
1522
|
+
|
|
1523
|
+
/**
|
|
1272
1524
|
* Cleanup Claude instances
|
|
1273
|
-
*/
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
} catch (error) {
|
|
1289
|
-
console.error(` ❌ Error cleaning up ${instance.agent.name}:`, error.message);
|
|
1525
|
+
*/
|
|
1526
|
+
async cleanupClaudeInstances() {
|
|
1527
|
+
if (this.claudeInstances.size === 0) return;
|
|
1528
|
+
|
|
1529
|
+
console.log('🧹 Cleaning up Claude instances...');
|
|
1530
|
+
|
|
1531
|
+
for (const [agentId, instance] of this.claudeInstances.entries()) {
|
|
1532
|
+
try {
|
|
1533
|
+
if (instance.process && !instance.process.killed) {
|
|
1534
|
+
instance.process.kill('SIGTERM');
|
|
1535
|
+
|
|
1536
|
+
// Wait for graceful shutdown, then force kill if needed
|
|
1537
|
+
setTimeout(() => {
|
|
1538
|
+
if (!instance.process.killed) {
|
|
1539
|
+
instance.process.kill('SIGKILL');
|
|
1290
1540
|
}
|
|
1541
|
+
}, 5000);
|
|
1291
1542
|
}
|
|
1292
|
-
|
|
1543
|
+
|
|
1544
|
+
console.log(` ✅ Cleaned up ${instance.agent.name}`);
|
|
1545
|
+
} catch (error) {
|
|
1546
|
+
console.error(` ❌ Error cleaning up ${instance.agent.name}:`, error.message);
|
|
1547
|
+
}
|
|
1293
1548
|
}
|
|
1294
|
-
|
|
1549
|
+
|
|
1550
|
+
this.claudeInstances.clear();
|
|
1551
|
+
}
|
|
1552
|
+
|
|
1553
|
+
/**
|
|
1295
1554
|
* Format duration in human readable format
|
|
1296
|
-
*/
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
constructor(options = {}){
|
|
1309
|
-
this.options = {
|
|
1310
|
-
enableClaude: false,
|
|
1311
|
-
nonInteractive: false,
|
|
1312
|
-
outputFormat: 'text',
|
|
1313
|
-
maxConcurrency: 3,
|
|
1314
|
-
timeout: 3600000,
|
|
1315
|
-
logLevel: 'info',
|
|
1316
|
-
...options
|
|
1317
|
-
};
|
|
1318
|
-
// Increase timeout for ML workflows
|
|
1319
|
-
if (options.workflowType === 'ml' || options.workflowName?.toLowerCase().includes('mle')) {
|
|
1320
|
-
this.options.timeout = 7200000; // 2 hours for ML workflows
|
|
1321
|
-
}
|
|
1322
|
-
// Execution state
|
|
1323
|
-
this.executionId = generateId('workflow-exec');
|
|
1324
|
-
this.startTime = Date.now();
|
|
1325
|
-
this.activeTasks = new Map();
|
|
1326
|
-
this.claudeInstances = new Map();
|
|
1327
|
-
this.results = new Map();
|
|
1328
|
-
this.errors = [];
|
|
1329
|
-
this.currentWorkflow = null;
|
|
1330
|
-
// Stream chaining support
|
|
1331
|
-
this.taskOutputStreams = new Map(); // Store output streams for chaining
|
|
1332
|
-
this.enableChaining = options.enableChaining !== false; // Default to true
|
|
1333
|
-
// Hooks integration
|
|
1334
|
-
this.hooksEnabled = true;
|
|
1335
|
-
this.sessionId = generateId('automation-session');
|
|
1555
|
+
*/
|
|
1556
|
+
formatDuration(ms) {
|
|
1557
|
+
const seconds = Math.floor(ms / 1000);
|
|
1558
|
+
const minutes = Math.floor(seconds / 60);
|
|
1559
|
+
const hours = Math.floor(minutes / 60);
|
|
1560
|
+
|
|
1561
|
+
if (hours > 0) {
|
|
1562
|
+
return `${hours}h ${minutes % 60}m ${seconds % 60}s`;
|
|
1563
|
+
} else if (minutes > 0) {
|
|
1564
|
+
return `${minutes}m ${seconds % 60}s`;
|
|
1565
|
+
} else {
|
|
1566
|
+
return `${seconds}s`;
|
|
1336
1567
|
}
|
|
1568
|
+
}
|
|
1337
1569
|
}
|
|
1570
|
+
|
|
1338
1571
|
/**
|
|
1339
1572
|
* Load workflow from file
|
|
1340
|
-
*/
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
throw new Error(`Failed to load workflow: ${error.message}`);
|
|
1573
|
+
*/
|
|
1574
|
+
export async function loadWorkflowFromFile(filePath) {
|
|
1575
|
+
try {
|
|
1576
|
+
const content = await fs.readFile(filePath, 'utf-8');
|
|
1577
|
+
|
|
1578
|
+
if (filePath.endsWith('.json')) {
|
|
1579
|
+
return JSON.parse(content);
|
|
1580
|
+
} else if (filePath.endsWith('.yaml') || filePath.endsWith('.yml')) {
|
|
1581
|
+
// For now, just return error - YAML support can be added later
|
|
1582
|
+
throw new Error('YAML workflows not yet supported');
|
|
1583
|
+
} else {
|
|
1584
|
+
throw new Error('Unsupported workflow file format. Use .json or .yaml');
|
|
1353
1585
|
}
|
|
1586
|
+
} catch (error) {
|
|
1587
|
+
throw new Error(`Failed to load workflow: ${error.message}`);
|
|
1588
|
+
}
|
|
1354
1589
|
}
|
|
1590
|
+
|
|
1355
1591
|
/**
|
|
1356
1592
|
* Get default MLE-STAR workflow path
|
|
1357
|
-
*/
|
|
1358
|
-
|
|
1593
|
+
*/
|
|
1594
|
+
export function getMLEStarWorkflowPath() {
|
|
1595
|
+
return join(
|
|
1596
|
+
process.cwd(),
|
|
1597
|
+
'src',
|
|
1598
|
+
'cli',
|
|
1599
|
+
'simple-commands',
|
|
1600
|
+
'templates',
|
|
1601
|
+
'mle-star-workflow.json',
|
|
1602
|
+
);
|
|
1359
1603
|
}
|