attocode 0.2.3 → 0.2.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/CHANGELOG.md +122 -1
- package/README.md +65 -5
- package/dist/src/adapters.d.ts +2 -1
- package/dist/src/adapters.d.ts.map +1 -1
- package/dist/src/adapters.js +74 -12
- package/dist/src/adapters.js.map +1 -1
- package/dist/src/agent/agent-builder.d.ts +117 -0
- package/dist/src/agent/agent-builder.d.ts.map +1 -0
- package/dist/src/agent/agent-builder.js +204 -0
- package/dist/src/agent/agent-builder.js.map +1 -0
- package/dist/src/agent/feature-initializer.d.ts +80 -0
- package/dist/src/agent/feature-initializer.d.ts.map +1 -0
- package/dist/src/agent/feature-initializer.js +677 -0
- package/dist/src/agent/feature-initializer.js.map +1 -0
- package/dist/src/agent/index.d.ts +13 -0
- package/dist/src/agent/index.d.ts.map +1 -0
- package/dist/src/agent/index.js +13 -0
- package/dist/src/agent/index.js.map +1 -0
- package/dist/src/agent/message-builder.d.ts +50 -0
- package/dist/src/agent/message-builder.d.ts.map +1 -0
- package/dist/src/agent/message-builder.js +173 -0
- package/dist/src/agent/message-builder.js.map +1 -0
- package/dist/src/agent/session-api.d.ts +94 -0
- package/dist/src/agent/session-api.d.ts.map +1 -0
- package/dist/src/agent/session-api.js +262 -0
- package/dist/src/agent/session-api.js.map +1 -0
- package/dist/src/agent-tools/lsp-file-tools.d.ts +1 -1
- package/dist/src/agent-tools/lsp-file-tools.d.ts.map +1 -1
- package/dist/src/agent.d.ts +52 -213
- package/dist/src/agent.d.ts.map +1 -1
- package/dist/src/agent.js +544 -4072
- package/dist/src/agent.js.map +1 -1
- package/dist/src/cli.d.ts.map +1 -1
- package/dist/src/cli.js +2 -1
- package/dist/src/cli.js.map +1 -1
- package/dist/src/commands/handler.d.ts.map +1 -1
- package/dist/src/commands/handler.js +18 -9
- package/dist/src/commands/handler.js.map +1 -1
- package/dist/src/commands/init-commands.d.ts.map +1 -1
- package/dist/src/commands/init-commands.js +16 -1
- package/dist/src/commands/init-commands.js.map +1 -1
- package/dist/src/commands/init.d.ts.map +1 -1
- package/dist/src/commands/init.js +31 -0
- package/dist/src/commands/init.js.map +1 -1
- package/dist/src/config/base-types.d.ts +45 -0
- package/dist/src/config/base-types.d.ts.map +1 -0
- package/dist/src/config/base-types.js +9 -0
- package/dist/src/config/base-types.js.map +1 -0
- package/dist/src/config/config-manager.d.ts +35 -0
- package/dist/src/config/config-manager.d.ts.map +1 -0
- package/dist/src/config/config-manager.js +108 -0
- package/dist/src/config/config-manager.js.map +1 -0
- package/dist/src/config/index.d.ts +4 -0
- package/dist/src/config/index.d.ts.map +1 -0
- package/dist/src/config/index.js +3 -0
- package/dist/src/config/index.js.map +1 -0
- package/dist/src/config/schema.d.ts +1546 -0
- package/dist/src/config/schema.d.ts.map +1 -0
- package/dist/src/config/schema.js +268 -0
- package/dist/src/config/schema.js.map +1 -0
- package/dist/src/config.d.ts +4 -1
- package/dist/src/config.d.ts.map +1 -1
- package/dist/src/config.js +8 -12
- package/dist/src/config.js.map +1 -1
- package/dist/src/core/agent-state-machine.d.ts +131 -0
- package/dist/src/core/agent-state-machine.d.ts.map +1 -0
- package/dist/src/core/agent-state-machine.js +302 -0
- package/dist/src/core/agent-state-machine.js.map +1 -0
- package/dist/src/core/base-manager.d.ts +79 -0
- package/dist/src/core/base-manager.d.ts.map +1 -0
- package/dist/src/core/base-manager.js +170 -0
- package/dist/src/core/base-manager.js.map +1 -0
- package/dist/src/core/completion-analyzer.d.ts +15 -0
- package/dist/src/core/completion-analyzer.d.ts.map +1 -0
- package/dist/src/core/completion-analyzer.js +53 -0
- package/dist/src/core/completion-analyzer.js.map +1 -0
- package/dist/src/core/execution-loop.d.ts +46 -0
- package/dist/src/core/execution-loop.d.ts.map +1 -0
- package/dist/src/core/execution-loop.js +1397 -0
- package/dist/src/core/execution-loop.js.map +1 -0
- package/dist/src/core/index.d.ts +7 -0
- package/dist/src/core/index.d.ts.map +1 -1
- package/dist/src/core/index.js +9 -0
- package/dist/src/core/index.js.map +1 -1
- package/dist/src/core/process-handlers.d.ts.map +1 -1
- package/dist/src/core/process-handlers.js +14 -0
- package/dist/src/core/process-handlers.js.map +1 -1
- package/dist/src/core/protocol/types.d.ts +12 -12
- package/dist/src/core/response-handler.d.ts +16 -0
- package/dist/src/core/response-handler.d.ts.map +1 -0
- package/dist/src/core/response-handler.js +235 -0
- package/dist/src/core/response-handler.js.map +1 -0
- package/dist/src/core/subagent-spawner.d.ts +43 -0
- package/dist/src/core/subagent-spawner.d.ts.map +1 -0
- package/dist/src/core/subagent-spawner.js +973 -0
- package/dist/src/core/subagent-spawner.js.map +1 -0
- package/dist/src/core/tool-executor.d.ts +59 -0
- package/dist/src/core/tool-executor.d.ts.map +1 -0
- package/dist/src/core/tool-executor.js +682 -0
- package/dist/src/core/tool-executor.js.map +1 -0
- package/dist/src/core/types.d.ts +134 -0
- package/dist/src/core/types.d.ts.map +1 -0
- package/dist/src/core/types.js +12 -0
- package/dist/src/core/types.js.map +1 -0
- package/dist/src/defaults.d.ts +2 -2
- package/dist/src/defaults.d.ts.map +1 -1
- package/dist/src/defaults.js +29 -1
- package/dist/src/defaults.js.map +1 -1
- package/dist/src/integrations/agents/agent-registry.d.ts +262 -0
- package/dist/src/integrations/agents/agent-registry.d.ts.map +1 -0
- package/dist/src/integrations/agents/agent-registry.js +686 -0
- package/dist/src/integrations/agents/agent-registry.js.map +1 -0
- package/dist/src/integrations/agents/async-subagent.d.ts +135 -0
- package/dist/src/integrations/agents/async-subagent.d.ts.map +1 -0
- package/dist/src/integrations/agents/async-subagent.js +213 -0
- package/dist/src/integrations/agents/async-subagent.js.map +1 -0
- package/dist/src/integrations/agents/complexity-classifier.d.ts +86 -0
- package/dist/src/integrations/agents/complexity-classifier.d.ts.map +1 -0
- package/dist/src/integrations/agents/complexity-classifier.js +233 -0
- package/dist/src/integrations/agents/complexity-classifier.js.map +1 -0
- package/dist/src/integrations/agents/delegation-protocol.d.ts +86 -0
- package/dist/src/integrations/agents/delegation-protocol.d.ts.map +1 -0
- package/dist/src/integrations/agents/delegation-protocol.js +127 -0
- package/dist/src/integrations/agents/delegation-protocol.js.map +1 -0
- package/dist/src/integrations/agents/multi-agent.d.ts +150 -0
- package/dist/src/integrations/agents/multi-agent.d.ts.map +1 -0
- package/dist/src/integrations/agents/multi-agent.js +306 -0
- package/dist/src/integrations/agents/multi-agent.js.map +1 -0
- package/dist/src/integrations/agents/result-synthesizer.d.ts +389 -0
- package/dist/src/integrations/agents/result-synthesizer.d.ts.map +1 -0
- package/dist/src/integrations/agents/result-synthesizer.js +951 -0
- package/dist/src/integrations/agents/result-synthesizer.js.map +1 -0
- package/dist/src/integrations/agents/shared-blackboard.d.ts +406 -0
- package/dist/src/integrations/agents/shared-blackboard.d.ts.map +1 -0
- package/dist/src/integrations/agents/shared-blackboard.js +757 -0
- package/dist/src/integrations/agents/shared-blackboard.js.map +1 -0
- package/dist/src/integrations/agents/subagent-output-store.d.ts +91 -0
- package/dist/src/integrations/agents/subagent-output-store.d.ts.map +1 -0
- package/dist/src/integrations/agents/subagent-output-store.js +257 -0
- package/dist/src/integrations/agents/subagent-output-store.js.map +1 -0
- package/dist/src/integrations/auto-compaction.d.ts.map +1 -1
- package/dist/src/integrations/auto-compaction.js +3 -2
- package/dist/src/integrations/auto-compaction.js.map +1 -1
- package/dist/src/integrations/budget/budget-pool.d.ts +115 -0
- package/dist/src/integrations/budget/budget-pool.d.ts.map +1 -0
- package/dist/src/integrations/budget/budget-pool.js +205 -0
- package/dist/src/integrations/budget/budget-pool.js.map +1 -0
- package/dist/src/integrations/budget/cancellation.d.ts +229 -0
- package/dist/src/integrations/budget/cancellation.d.ts.map +1 -0
- package/dist/src/integrations/budget/cancellation.js +520 -0
- package/dist/src/integrations/budget/cancellation.js.map +1 -0
- package/dist/src/integrations/budget/dynamic-budget.d.ts +81 -0
- package/dist/src/integrations/budget/dynamic-budget.d.ts.map +1 -0
- package/dist/src/integrations/budget/dynamic-budget.js +151 -0
- package/dist/src/integrations/budget/dynamic-budget.js.map +1 -0
- package/dist/src/integrations/budget/economics.d.ts +435 -0
- package/dist/src/integrations/budget/economics.d.ts.map +1 -0
- package/dist/src/integrations/budget/economics.js +1007 -0
- package/dist/src/integrations/budget/economics.js.map +1 -0
- package/dist/src/integrations/budget/injection-budget.d.ts +71 -0
- package/dist/src/integrations/budget/injection-budget.d.ts.map +1 -0
- package/dist/src/integrations/budget/injection-budget.js +137 -0
- package/dist/src/integrations/budget/injection-budget.js.map +1 -0
- package/dist/src/integrations/budget/loop-detector.d.ts +105 -0
- package/dist/src/integrations/budget/loop-detector.d.ts.map +1 -0
- package/dist/src/integrations/budget/loop-detector.js +287 -0
- package/dist/src/integrations/budget/loop-detector.js.map +1 -0
- package/dist/src/integrations/budget/phase-tracker.d.ts +114 -0
- package/dist/src/integrations/budget/phase-tracker.d.ts.map +1 -0
- package/dist/src/integrations/budget/phase-tracker.js +262 -0
- package/dist/src/integrations/budget/phase-tracker.js.map +1 -0
- package/dist/src/integrations/budget/resources.d.ts +182 -0
- package/dist/src/integrations/budget/resources.d.ts.map +1 -0
- package/dist/src/integrations/budget/resources.js +318 -0
- package/dist/src/integrations/budget/resources.js.map +1 -0
- package/dist/src/integrations/budget-pool.d.ts +7 -0
- package/dist/src/integrations/budget-pool.d.ts.map +1 -1
- package/dist/src/integrations/budget-pool.js +43 -0
- package/dist/src/integrations/budget-pool.js.map +1 -1
- package/dist/src/integrations/codebase-ast.d.ts +52 -0
- package/dist/src/integrations/codebase-ast.d.ts.map +1 -0
- package/dist/src/integrations/codebase-ast.js +457 -0
- package/dist/src/integrations/codebase-ast.js.map +1 -0
- package/dist/src/integrations/codebase-context.d.ts +18 -0
- package/dist/src/integrations/codebase-context.d.ts.map +1 -1
- package/dist/src/integrations/codebase-context.js +197 -17
- package/dist/src/integrations/codebase-context.js.map +1 -1
- package/dist/src/integrations/compaction.d.ts.map +1 -1
- package/dist/src/integrations/compaction.js +14 -6
- package/dist/src/integrations/compaction.js.map +1 -1
- package/dist/src/integrations/context/auto-compaction.d.ts +210 -0
- package/dist/src/integrations/context/auto-compaction.d.ts.map +1 -0
- package/dist/src/integrations/context/auto-compaction.js +477 -0
- package/dist/src/integrations/context/auto-compaction.js.map +1 -0
- package/dist/src/integrations/context/code-analyzer.d.ts +71 -0
- package/dist/src/integrations/context/code-analyzer.d.ts.map +1 -0
- package/dist/src/integrations/context/code-analyzer.js +448 -0
- package/dist/src/integrations/context/code-analyzer.js.map +1 -0
- package/dist/src/integrations/context/code-selector.d.ts +78 -0
- package/dist/src/integrations/context/code-selector.d.ts.map +1 -0
- package/dist/src/integrations/context/code-selector.js +649 -0
- package/dist/src/integrations/context/code-selector.js.map +1 -0
- package/dist/src/integrations/context/codebase-ast.d.ts +138 -0
- package/dist/src/integrations/context/codebase-ast.d.ts.map +1 -0
- package/dist/src/integrations/context/codebase-ast.js +818 -0
- package/dist/src/integrations/context/codebase-ast.js.map +1 -0
- package/dist/src/integrations/context/codebase-context.d.ts +473 -0
- package/dist/src/integrations/context/codebase-context.d.ts.map +1 -0
- package/dist/src/integrations/context/codebase-context.js +685 -0
- package/dist/src/integrations/context/codebase-context.js.map +1 -0
- package/dist/src/integrations/context/compaction.d.ts +191 -0
- package/dist/src/integrations/context/compaction.d.ts.map +1 -0
- package/dist/src/integrations/context/compaction.js +384 -0
- package/dist/src/integrations/context/compaction.js.map +1 -0
- package/dist/src/integrations/context/context-engineering.d.ts +274 -0
- package/dist/src/integrations/context/context-engineering.d.ts.map +1 -0
- package/dist/src/integrations/context/context-engineering.js +437 -0
- package/dist/src/integrations/context/context-engineering.js.map +1 -0
- package/dist/src/integrations/context/file-cache.d.ts +97 -0
- package/dist/src/integrations/context/file-cache.d.ts.map +1 -0
- package/dist/src/integrations/context/file-cache.js +218 -0
- package/dist/src/integrations/context/file-cache.js.map +1 -0
- package/dist/src/integrations/context/semantic-cache.d.ts +178 -0
- package/dist/src/integrations/context/semantic-cache.d.ts.map +1 -0
- package/dist/src/integrations/context/semantic-cache.js +372 -0
- package/dist/src/integrations/context/semantic-cache.js.map +1 -0
- package/dist/src/integrations/context-engineering.d.ts +8 -0
- package/dist/src/integrations/context-engineering.d.ts.map +1 -1
- package/dist/src/integrations/context-engineering.js +19 -0
- package/dist/src/integrations/context-engineering.js.map +1 -1
- package/dist/src/integrations/economics.d.ts +25 -1
- package/dist/src/integrations/economics.d.ts.map +1 -1
- package/dist/src/integrations/economics.js +217 -38
- package/dist/src/integrations/economics.js.map +1 -1
- package/dist/src/integrations/edit-validator.d.ts +30 -0
- package/dist/src/integrations/edit-validator.d.ts.map +1 -0
- package/dist/src/integrations/edit-validator.js +85 -0
- package/dist/src/integrations/edit-validator.js.map +1 -0
- package/dist/src/integrations/file-cache.d.ts +7 -0
- package/dist/src/integrations/file-cache.d.ts.map +1 -1
- package/dist/src/integrations/file-cache.js +54 -0
- package/dist/src/integrations/file-cache.js.map +1 -1
- package/dist/src/integrations/health-check.d.ts.map +1 -1
- package/dist/src/integrations/health-check.js +3 -2
- package/dist/src/integrations/health-check.js.map +1 -1
- package/dist/src/integrations/hierarchical-config.d.ts +3 -0
- package/dist/src/integrations/hierarchical-config.d.ts.map +1 -1
- package/dist/src/integrations/hierarchical-config.js +3 -0
- package/dist/src/integrations/hierarchical-config.js.map +1 -1
- package/dist/src/integrations/hooks.d.ts +2 -0
- package/dist/src/integrations/hooks.d.ts.map +1 -1
- package/dist/src/integrations/hooks.js +99 -15
- package/dist/src/integrations/hooks.js.map +1 -1
- package/dist/src/integrations/index.d.ts +77 -66
- package/dist/src/integrations/index.d.ts.map +1 -1
- package/dist/src/integrations/index.js +83 -67
- package/dist/src/integrations/index.js.map +1 -1
- package/dist/src/integrations/logger.d.ts +104 -0
- package/dist/src/integrations/logger.d.ts.map +1 -0
- package/dist/src/integrations/logger.js +219 -0
- package/dist/src/integrations/logger.js.map +1 -0
- package/dist/src/integrations/lsp/lsp.d.ts +196 -0
- package/dist/src/integrations/lsp/lsp.d.ts.map +1 -0
- package/dist/src/integrations/lsp/lsp.js +583 -0
- package/dist/src/integrations/lsp/lsp.js.map +1 -0
- package/dist/src/integrations/lsp.d.ts.map +1 -1
- package/dist/src/integrations/lsp.js +5 -4
- package/dist/src/integrations/lsp.js.map +1 -1
- package/dist/src/integrations/mcp/mcp-client.d.ts +279 -0
- package/dist/src/integrations/mcp/mcp-client.d.ts.map +1 -0
- package/dist/src/integrations/mcp/mcp-client.js +755 -0
- package/dist/src/integrations/mcp/mcp-client.js.map +1 -0
- package/dist/src/integrations/mcp/mcp-custom-tools.d.ts +102 -0
- package/dist/src/integrations/mcp/mcp-custom-tools.d.ts.map +1 -0
- package/dist/src/integrations/mcp/mcp-custom-tools.js +232 -0
- package/dist/src/integrations/mcp/mcp-custom-tools.js.map +1 -0
- package/dist/src/integrations/mcp/mcp-tool-search.d.ts +77 -0
- package/dist/src/integrations/mcp/mcp-tool-search.d.ts.map +1 -0
- package/dist/src/integrations/mcp/mcp-tool-search.js +220 -0
- package/dist/src/integrations/mcp/mcp-tool-search.js.map +1 -0
- package/dist/src/integrations/mcp/mcp-tool-validator.d.ts +60 -0
- package/dist/src/integrations/mcp/mcp-tool-validator.d.ts.map +1 -0
- package/dist/src/integrations/mcp/mcp-tool-validator.js +141 -0
- package/dist/src/integrations/mcp/mcp-tool-validator.js.map +1 -0
- package/dist/src/integrations/mcp-client.d.ts.map +1 -1
- package/dist/src/integrations/mcp-client.js +8 -7
- package/dist/src/integrations/mcp-client.js.map +1 -1
- package/dist/src/integrations/observability.d.ts.map +1 -1
- package/dist/src/integrations/observability.js +5 -4
- package/dist/src/integrations/observability.js.map +1 -1
- package/dist/src/integrations/openrouter-pricing.d.ts.map +1 -1
- package/dist/src/integrations/openrouter-pricing.js +4 -3
- package/dist/src/integrations/openrouter-pricing.js.map +1 -1
- package/dist/src/integrations/persistence/codebase-repository.d.ts +45 -0
- package/dist/src/integrations/persistence/codebase-repository.d.ts.map +1 -0
- package/dist/src/integrations/persistence/codebase-repository.js +81 -0
- package/dist/src/integrations/persistence/codebase-repository.js.map +1 -0
- package/dist/src/integrations/persistence/goal-repository.d.ts +71 -0
- package/dist/src/integrations/persistence/goal-repository.d.ts.map +1 -0
- package/dist/src/integrations/persistence/goal-repository.js +184 -0
- package/dist/src/integrations/persistence/goal-repository.js.map +1 -0
- package/dist/src/integrations/persistence/history.d.ts +72 -0
- package/dist/src/integrations/persistence/history.d.ts.map +1 -0
- package/dist/src/integrations/persistence/history.js +165 -0
- package/dist/src/integrations/persistence/history.js.map +1 -0
- package/dist/src/integrations/persistence/persistence.d.ts +49 -0
- package/dist/src/integrations/persistence/persistence.d.ts.map +1 -0
- package/dist/src/integrations/persistence/persistence.js +197 -0
- package/dist/src/integrations/persistence/persistence.js.map +1 -0
- package/dist/src/integrations/persistence/session-repository.d.ts +212 -0
- package/dist/src/integrations/persistence/session-repository.d.ts.map +1 -0
- package/dist/src/integrations/persistence/session-repository.js +770 -0
- package/dist/src/integrations/persistence/session-repository.js.map +1 -0
- package/dist/src/integrations/persistence/session-store.d.ts +184 -0
- package/dist/src/integrations/persistence/session-store.d.ts.map +1 -0
- package/dist/src/integrations/persistence/session-store.js +346 -0
- package/dist/src/integrations/persistence/session-store.js.map +1 -0
- package/dist/src/integrations/persistence/sqlite-store.d.ts +453 -0
- package/dist/src/integrations/persistence/sqlite-store.d.ts.map +1 -0
- package/dist/src/integrations/persistence/sqlite-store.js +676 -0
- package/dist/src/integrations/persistence/sqlite-store.js.map +1 -0
- package/dist/src/integrations/persistence/worker-repository.d.ts +65 -0
- package/dist/src/integrations/persistence/worker-repository.d.ts.map +1 -0
- package/dist/src/integrations/persistence/worker-repository.js +183 -0
- package/dist/src/integrations/persistence/worker-repository.js.map +1 -0
- package/dist/src/integrations/persistence.d.ts.map +1 -1
- package/dist/src/integrations/persistence.js +5 -4
- package/dist/src/integrations/persistence.js.map +1 -1
- package/dist/src/integrations/planning.d.ts.map +1 -1
- package/dist/src/integrations/planning.js +5 -4
- package/dist/src/integrations/planning.js.map +1 -1
- package/dist/src/integrations/quality/auto-checkpoint.d.ts +98 -0
- package/dist/src/integrations/quality/auto-checkpoint.d.ts.map +1 -0
- package/dist/src/integrations/quality/auto-checkpoint.js +252 -0
- package/dist/src/integrations/quality/auto-checkpoint.js.map +1 -0
- package/dist/src/integrations/quality/dead-letter-queue.d.ts +233 -0
- package/dist/src/integrations/quality/dead-letter-queue.d.ts.map +1 -0
- package/dist/src/integrations/quality/dead-letter-queue.js +543 -0
- package/dist/src/integrations/quality/dead-letter-queue.js.map +1 -0
- package/dist/src/integrations/quality/health-check.d.ts +218 -0
- package/dist/src/integrations/quality/health-check.d.ts.map +1 -0
- package/dist/src/integrations/quality/health-check.js +415 -0
- package/dist/src/integrations/quality/health-check.js.map +1 -0
- package/dist/src/integrations/quality/learning-store.d.ts +291 -0
- package/dist/src/integrations/quality/learning-store.d.ts.map +1 -0
- package/dist/src/integrations/quality/learning-store.js +646 -0
- package/dist/src/integrations/quality/learning-store.js.map +1 -0
- package/dist/src/integrations/quality/self-improvement.d.ts +90 -0
- package/dist/src/integrations/quality/self-improvement.d.ts.map +1 -0
- package/dist/src/integrations/quality/self-improvement.js +229 -0
- package/dist/src/integrations/quality/self-improvement.js.map +1 -0
- package/dist/src/integrations/quality/tool-recommendation.d.ts +61 -0
- package/dist/src/integrations/quality/tool-recommendation.d.ts.map +1 -0
- package/dist/src/integrations/quality/tool-recommendation.js +268 -0
- package/dist/src/integrations/quality/tool-recommendation.js.map +1 -0
- package/dist/src/integrations/retry.d.ts +1 -0
- package/dist/src/integrations/retry.d.ts.map +1 -1
- package/dist/src/integrations/retry.js.map +1 -1
- package/dist/src/integrations/routing.d.ts.map +1 -1
- package/dist/src/integrations/routing.js +2 -1
- package/dist/src/integrations/routing.js.map +1 -1
- package/dist/src/integrations/safety/bash-policy.d.ts +33 -0
- package/dist/src/integrations/safety/bash-policy.d.ts.map +1 -0
- package/dist/src/integrations/safety/bash-policy.js +144 -0
- package/dist/src/integrations/safety/bash-policy.js.map +1 -0
- package/dist/src/integrations/safety/edit-validator.d.ts +30 -0
- package/dist/src/integrations/safety/edit-validator.d.ts.map +1 -0
- package/dist/src/integrations/safety/edit-validator.js +87 -0
- package/dist/src/integrations/safety/edit-validator.js.map +1 -0
- package/dist/src/integrations/safety/execution-policy.d.ts +189 -0
- package/dist/src/integrations/safety/execution-policy.d.ts.map +1 -0
- package/dist/src/integrations/safety/execution-policy.js +352 -0
- package/dist/src/integrations/safety/execution-policy.js.map +1 -0
- package/dist/src/integrations/safety/policy-engine.d.ts +55 -0
- package/dist/src/integrations/safety/policy-engine.d.ts.map +1 -0
- package/dist/src/integrations/safety/policy-engine.js +247 -0
- package/dist/src/integrations/safety/policy-engine.js.map +1 -0
- package/dist/src/integrations/safety/safety.d.ts +174 -0
- package/dist/src/integrations/safety/safety.d.ts.map +1 -0
- package/dist/src/integrations/safety/safety.js +470 -0
- package/dist/src/integrations/safety/safety.js.map +1 -0
- package/dist/src/integrations/safety/sandbox/basic.d.ts +81 -0
- package/dist/src/integrations/safety/sandbox/basic.d.ts.map +1 -0
- package/dist/src/integrations/safety/sandbox/basic.js +335 -0
- package/dist/src/integrations/safety/sandbox/basic.js.map +1 -0
- package/dist/src/integrations/safety/sandbox/docker.d.ts +94 -0
- package/dist/src/integrations/safety/sandbox/docker.d.ts.map +1 -0
- package/dist/src/integrations/safety/sandbox/docker.js +294 -0
- package/dist/src/integrations/safety/sandbox/docker.js.map +1 -0
- package/dist/src/integrations/safety/sandbox/index.d.ts +188 -0
- package/dist/src/integrations/safety/sandbox/index.d.ts.map +1 -0
- package/dist/src/integrations/safety/sandbox/index.js +386 -0
- package/dist/src/integrations/safety/sandbox/index.js.map +1 -0
- package/dist/src/integrations/safety/sandbox/landlock.d.ts +59 -0
- package/dist/src/integrations/safety/sandbox/landlock.d.ts.map +1 -0
- package/dist/src/integrations/safety/sandbox/landlock.js +329 -0
- package/dist/src/integrations/safety/sandbox/landlock.js.map +1 -0
- package/dist/src/integrations/safety/sandbox/seatbelt.d.ts +68 -0
- package/dist/src/integrations/safety/sandbox/seatbelt.d.ts.map +1 -0
- package/dist/src/integrations/safety/sandbox/seatbelt.js +298 -0
- package/dist/src/integrations/safety/sandbox/seatbelt.js.map +1 -0
- package/dist/src/integrations/safety/type-checker.d.ts +53 -0
- package/dist/src/integrations/safety/type-checker.d.ts.map +1 -0
- package/dist/src/integrations/safety/type-checker.js +142 -0
- package/dist/src/integrations/safety/type-checker.js.map +1 -0
- package/dist/src/integrations/safety.d.ts.map +1 -1
- package/dist/src/integrations/safety.js +13 -13
- package/dist/src/integrations/safety.js.map +1 -1
- package/dist/src/integrations/sandbox/docker.d.ts.map +1 -1
- package/dist/src/integrations/sandbox/docker.js +2 -1
- package/dist/src/integrations/sandbox/docker.js.map +1 -1
- package/dist/src/integrations/sandbox/index.d.ts.map +1 -1
- package/dist/src/integrations/sandbox/index.js +5 -4
- package/dist/src/integrations/sandbox/index.js.map +1 -1
- package/dist/src/integrations/session-store.d.ts +1 -0
- package/dist/src/integrations/session-store.d.ts.map +1 -1
- package/dist/src/integrations/session-store.js +1 -0
- package/dist/src/integrations/session-store.js.map +1 -1
- package/dist/src/integrations/shared-blackboard.d.ts +3 -0
- package/dist/src/integrations/shared-blackboard.d.ts.map +1 -1
- package/dist/src/integrations/shared-blackboard.js +47 -0
- package/dist/src/integrations/shared-blackboard.js.map +1 -1
- package/dist/src/integrations/skills/skill-executor.d.ts +113 -0
- package/dist/src/integrations/skills/skill-executor.d.ts.map +1 -0
- package/dist/src/integrations/skills/skill-executor.js +270 -0
- package/dist/src/integrations/skills/skill-executor.js.map +1 -0
- package/dist/src/integrations/skills/skills.d.ts +262 -0
- package/dist/src/integrations/skills/skills.d.ts.map +1 -0
- package/dist/src/integrations/skills/skills.js +602 -0
- package/dist/src/integrations/skills/skills.js.map +1 -0
- package/dist/src/integrations/smart-decomposer.d.ts +27 -0
- package/dist/src/integrations/smart-decomposer.d.ts.map +1 -1
- package/dist/src/integrations/smart-decomposer.js +414 -30
- package/dist/src/integrations/smart-decomposer.js.map +1 -1
- package/dist/src/integrations/sqlite-store.d.ts +2 -0
- package/dist/src/integrations/sqlite-store.d.ts.map +1 -1
- package/dist/src/integrations/sqlite-store.js +18 -6
- package/dist/src/integrations/sqlite-store.js.map +1 -1
- package/dist/src/integrations/streaming/pty-shell.d.ts +169 -0
- package/dist/src/integrations/streaming/pty-shell.d.ts.map +1 -0
- package/dist/src/integrations/streaming/pty-shell.js +367 -0
- package/dist/src/integrations/streaming/pty-shell.js.map +1 -0
- package/dist/src/integrations/streaming/streaming.d.ts +102 -0
- package/dist/src/integrations/streaming/streaming.d.ts.map +1 -0
- package/dist/src/integrations/streaming/streaming.js +362 -0
- package/dist/src/integrations/streaming/streaming.js.map +1 -0
- package/dist/src/integrations/swarm/failure-classifier.d.ts +11 -0
- package/dist/src/integrations/swarm/failure-classifier.d.ts.map +1 -0
- package/dist/src/integrations/swarm/failure-classifier.js +95 -0
- package/dist/src/integrations/swarm/failure-classifier.js.map +1 -0
- package/dist/src/integrations/swarm/index.d.ts +2 -1
- package/dist/src/integrations/swarm/index.d.ts.map +1 -1
- package/dist/src/integrations/swarm/index.js +2 -0
- package/dist/src/integrations/swarm/index.js.map +1 -1
- package/dist/src/integrations/swarm/model-selector.d.ts.map +1 -1
- package/dist/src/integrations/swarm/model-selector.js +2 -1
- package/dist/src/integrations/swarm/model-selector.js.map +1 -1
- package/dist/src/integrations/swarm/swarm-budget.d.ts +1 -1
- package/dist/src/integrations/swarm/swarm-budget.d.ts.map +1 -1
- package/dist/src/integrations/swarm/swarm-budget.js +1 -1
- package/dist/src/integrations/swarm/swarm-budget.js.map +1 -1
- package/dist/src/integrations/swarm/swarm-config-loader.d.ts +8 -0
- package/dist/src/integrations/swarm/swarm-config-loader.d.ts.map +1 -1
- package/dist/src/integrations/swarm/swarm-config-loader.js +102 -0
- package/dist/src/integrations/swarm/swarm-config-loader.js.map +1 -1
- package/dist/src/integrations/swarm/swarm-event-bridge.d.ts +74 -0
- package/dist/src/integrations/swarm/swarm-event-bridge.d.ts.map +1 -1
- package/dist/src/integrations/swarm/swarm-event-bridge.js +37 -0
- package/dist/src/integrations/swarm/swarm-event-bridge.js.map +1 -1
- package/dist/src/integrations/swarm/swarm-events.d.ts +4 -1
- package/dist/src/integrations/swarm/swarm-events.d.ts.map +1 -1
- package/dist/src/integrations/swarm/swarm-events.js +1 -1
- package/dist/src/integrations/swarm/swarm-events.js.map +1 -1
- package/dist/src/integrations/swarm/swarm-execution.d.ts +27 -0
- package/dist/src/integrations/swarm/swarm-execution.d.ts.map +1 -0
- package/dist/src/integrations/swarm/swarm-execution.js +1021 -0
- package/dist/src/integrations/swarm/swarm-execution.js.map +1 -0
- package/dist/src/integrations/swarm/swarm-helpers.d.ts +26 -0
- package/dist/src/integrations/swarm/swarm-helpers.d.ts.map +1 -0
- package/dist/src/integrations/swarm/swarm-helpers.js +95 -0
- package/dist/src/integrations/swarm/swarm-helpers.js.map +1 -0
- package/dist/src/integrations/swarm/swarm-lifecycle.d.ts +100 -0
- package/dist/src/integrations/swarm/swarm-lifecycle.d.ts.map +1 -0
- package/dist/src/integrations/swarm/swarm-lifecycle.js +922 -0
- package/dist/src/integrations/swarm/swarm-lifecycle.js.map +1 -0
- package/dist/src/integrations/swarm/swarm-orchestrator.d.ts +96 -192
- package/dist/src/integrations/swarm/swarm-orchestrator.d.ts.map +1 -1
- package/dist/src/integrations/swarm/swarm-orchestrator.js +384 -2528
- package/dist/src/integrations/swarm/swarm-orchestrator.js.map +1 -1
- package/dist/src/integrations/swarm/swarm-quality-gate.js +1 -1
- package/dist/src/integrations/swarm/swarm-quality-gate.js.map +1 -1
- package/dist/src/integrations/swarm/swarm-recovery.d.ts +75 -0
- package/dist/src/integrations/swarm/swarm-recovery.d.ts.map +1 -0
- package/dist/src/integrations/swarm/swarm-recovery.js +550 -0
- package/dist/src/integrations/swarm/swarm-recovery.js.map +1 -0
- package/dist/src/integrations/swarm/swarm-state-store.d.ts +4 -1
- package/dist/src/integrations/swarm/swarm-state-store.d.ts.map +1 -1
- package/dist/src/integrations/swarm/swarm-state-store.js +14 -1
- package/dist/src/integrations/swarm/swarm-state-store.js.map +1 -1
- package/dist/src/integrations/swarm/task-queue.d.ts +11 -1
- package/dist/src/integrations/swarm/task-queue.d.ts.map +1 -1
- package/dist/src/integrations/swarm/task-queue.js +64 -2
- package/dist/src/integrations/swarm/task-queue.js.map +1 -1
- package/dist/src/integrations/swarm/types.d.ts +57 -4
- package/dist/src/integrations/swarm/types.d.ts.map +1 -1
- package/dist/src/integrations/swarm/types.js +9 -0
- package/dist/src/integrations/swarm/types.js.map +1 -1
- package/dist/src/integrations/swarm/worker-pool.d.ts +13 -3
- package/dist/src/integrations/swarm/worker-pool.d.ts.map +1 -1
- package/dist/src/integrations/swarm/worker-pool.js +66 -13
- package/dist/src/integrations/swarm/worker-pool.js.map +1 -1
- package/dist/src/integrations/task-manager.d.ts +33 -1
- package/dist/src/integrations/task-manager.d.ts.map +1 -1
- package/dist/src/integrations/task-manager.js +78 -4
- package/dist/src/integrations/task-manager.js.map +1 -1
- package/dist/src/integrations/tasks/dependency-analyzer.d.ts +34 -0
- package/dist/src/integrations/tasks/dependency-analyzer.d.ts.map +1 -0
- package/dist/src/integrations/tasks/dependency-analyzer.js +232 -0
- package/dist/src/integrations/tasks/dependency-analyzer.js.map +1 -0
- package/dist/src/integrations/tasks/interactive-planning.d.ts +322 -0
- package/dist/src/integrations/tasks/interactive-planning.d.ts.map +1 -0
- package/dist/src/integrations/tasks/interactive-planning.js +655 -0
- package/dist/src/integrations/tasks/interactive-planning.js.map +1 -0
- package/dist/src/integrations/tasks/pending-plan.d.ts +196 -0
- package/dist/src/integrations/tasks/pending-plan.d.ts.map +1 -0
- package/dist/src/integrations/tasks/pending-plan.js +431 -0
- package/dist/src/integrations/tasks/pending-plan.js.map +1 -0
- package/dist/src/integrations/tasks/planning.d.ts +115 -0
- package/dist/src/integrations/tasks/planning.d.ts.map +1 -0
- package/dist/src/integrations/tasks/planning.js +413 -0
- package/dist/src/integrations/tasks/planning.js.map +1 -0
- package/dist/src/integrations/tasks/smart-decomposer.d.ts +316 -0
- package/dist/src/integrations/tasks/smart-decomposer.d.ts.map +1 -0
- package/dist/src/integrations/tasks/smart-decomposer.js +661 -0
- package/dist/src/integrations/tasks/smart-decomposer.js.map +1 -0
- package/dist/src/integrations/tasks/task-manager.d.ts +164 -0
- package/dist/src/integrations/tasks/task-manager.d.ts.map +1 -0
- package/dist/src/integrations/tasks/task-manager.js +383 -0
- package/dist/src/integrations/tasks/task-manager.js.map +1 -0
- package/dist/src/integrations/tasks/task-splitter.d.ts +56 -0
- package/dist/src/integrations/tasks/task-splitter.d.ts.map +1 -0
- package/dist/src/integrations/tasks/task-splitter.js +537 -0
- package/dist/src/integrations/tasks/task-splitter.js.map +1 -0
- package/dist/src/integrations/tasks/verification-gate.d.ts +103 -0
- package/dist/src/integrations/tasks/verification-gate.d.ts.map +1 -0
- package/dist/src/integrations/tasks/verification-gate.js +193 -0
- package/dist/src/integrations/tasks/verification-gate.js.map +1 -0
- package/dist/src/integrations/tasks/work-log.d.ts +87 -0
- package/dist/src/integrations/tasks/work-log.d.ts.map +1 -0
- package/dist/src/integrations/tasks/work-log.js +275 -0
- package/dist/src/integrations/tasks/work-log.js.map +1 -0
- package/dist/src/integrations/utilities/capabilities.d.ts +160 -0
- package/dist/src/integrations/utilities/capabilities.d.ts.map +1 -0
- package/dist/src/integrations/utilities/capabilities.js +426 -0
- package/dist/src/integrations/utilities/capabilities.js.map +1 -0
- package/dist/src/integrations/utilities/diff-utils.d.ts +105 -0
- package/dist/src/integrations/utilities/diff-utils.d.ts.map +1 -0
- package/dist/src/integrations/utilities/diff-utils.js +497 -0
- package/dist/src/integrations/utilities/diff-utils.js.map +1 -0
- package/dist/src/integrations/utilities/environment-facts.d.ts +52 -0
- package/dist/src/integrations/utilities/environment-facts.d.ts.map +1 -0
- package/dist/src/integrations/utilities/environment-facts.js +84 -0
- package/dist/src/integrations/utilities/environment-facts.js.map +1 -0
- package/dist/src/integrations/utilities/file-change-tracker.d.ts +162 -0
- package/dist/src/integrations/utilities/file-change-tracker.d.ts.map +1 -0
- package/dist/src/integrations/utilities/file-change-tracker.js +538 -0
- package/dist/src/integrations/utilities/file-change-tracker.js.map +1 -0
- package/dist/src/integrations/utilities/graph-visualization.d.ts +72 -0
- package/dist/src/integrations/utilities/graph-visualization.d.ts.map +1 -0
- package/dist/src/integrations/utilities/graph-visualization.js +383 -0
- package/dist/src/integrations/utilities/graph-visualization.js.map +1 -0
- package/dist/src/integrations/utilities/hierarchical-config.d.ts +215 -0
- package/dist/src/integrations/utilities/hierarchical-config.d.ts.map +1 -0
- package/dist/src/integrations/utilities/hierarchical-config.js +504 -0
- package/dist/src/integrations/utilities/hierarchical-config.js.map +1 -0
- package/dist/src/integrations/utilities/hooks.d.ts +116 -0
- package/dist/src/integrations/utilities/hooks.d.ts.map +1 -0
- package/dist/src/integrations/utilities/hooks.js +410 -0
- package/dist/src/integrations/utilities/hooks.js.map +1 -0
- package/dist/src/integrations/utilities/ignore.d.ts +143 -0
- package/dist/src/integrations/utilities/ignore.d.ts.map +1 -0
- package/dist/src/integrations/utilities/ignore.js +417 -0
- package/dist/src/integrations/utilities/ignore.js.map +1 -0
- package/dist/src/integrations/utilities/image-renderer.d.ts +119 -0
- package/dist/src/integrations/utilities/image-renderer.d.ts.map +1 -0
- package/dist/src/integrations/utilities/image-renderer.js +306 -0
- package/dist/src/integrations/utilities/image-renderer.js.map +1 -0
- package/dist/src/integrations/utilities/logger.d.ts +104 -0
- package/dist/src/integrations/utilities/logger.d.ts.map +1 -0
- package/dist/src/integrations/utilities/logger.js +219 -0
- package/dist/src/integrations/utilities/logger.js.map +1 -0
- package/dist/src/integrations/utilities/memory.d.ts +116 -0
- package/dist/src/integrations/utilities/memory.d.ts.map +1 -0
- package/dist/src/integrations/utilities/memory.js +311 -0
- package/dist/src/integrations/utilities/memory.js.map +1 -0
- package/dist/src/integrations/utilities/observability.d.ts +162 -0
- package/dist/src/integrations/utilities/observability.d.ts.map +1 -0
- package/dist/src/integrations/utilities/observability.js +407 -0
- package/dist/src/integrations/utilities/observability.js.map +1 -0
- package/dist/src/integrations/utilities/openrouter-pricing.d.ts +67 -0
- package/dist/src/integrations/utilities/openrouter-pricing.d.ts.map +1 -0
- package/dist/src/integrations/utilities/openrouter-pricing.js +166 -0
- package/dist/src/integrations/utilities/openrouter-pricing.js.map +1 -0
- package/dist/src/integrations/utilities/react.d.ts +139 -0
- package/dist/src/integrations/utilities/react.d.ts.map +1 -0
- package/dist/src/integrations/utilities/react.js +273 -0
- package/dist/src/integrations/utilities/react.js.map +1 -0
- package/dist/src/integrations/utilities/retry.d.ts +132 -0
- package/dist/src/integrations/utilities/retry.d.ts.map +1 -0
- package/dist/src/integrations/utilities/retry.js +233 -0
- package/dist/src/integrations/utilities/retry.js.map +1 -0
- package/dist/src/integrations/utilities/routing.d.ts +118 -0
- package/dist/src/integrations/utilities/routing.d.ts.map +1 -0
- package/dist/src/integrations/utilities/routing.js +348 -0
- package/dist/src/integrations/utilities/routing.js.map +1 -0
- package/dist/src/integrations/utilities/rules.d.ts +131 -0
- package/dist/src/integrations/utilities/rules.d.ts.map +1 -0
- package/dist/src/integrations/utilities/rules.js +284 -0
- package/dist/src/integrations/utilities/rules.js.map +1 -0
- package/dist/src/integrations/utilities/sourcegraph.d.ts +169 -0
- package/dist/src/integrations/utilities/sourcegraph.d.ts.map +1 -0
- package/dist/src/integrations/utilities/sourcegraph.js +379 -0
- package/dist/src/integrations/utilities/sourcegraph.js.map +1 -0
- package/dist/src/integrations/utilities/thinking-strategy.d.ts +52 -0
- package/dist/src/integrations/utilities/thinking-strategy.d.ts.map +1 -0
- package/dist/src/integrations/utilities/thinking-strategy.js +129 -0
- package/dist/src/integrations/utilities/thinking-strategy.js.map +1 -0
- package/dist/src/integrations/utilities/thread-manager.d.ts +199 -0
- package/dist/src/integrations/utilities/thread-manager.d.ts.map +1 -0
- package/dist/src/integrations/utilities/thread-manager.js +357 -0
- package/dist/src/integrations/utilities/thread-manager.js.map +1 -0
- package/dist/src/integrations/utilities/token-estimate.d.ts +11 -0
- package/dist/src/integrations/utilities/token-estimate.d.ts.map +1 -0
- package/dist/src/integrations/utilities/token-estimate.js +14 -0
- package/dist/src/integrations/utilities/token-estimate.js.map +1 -0
- package/dist/src/main.js +92 -35
- package/dist/src/main.js.map +1 -1
- package/dist/src/modes/repl.d.ts.map +1 -1
- package/dist/src/modes/repl.js +60 -11
- package/dist/src/modes/repl.js.map +1 -1
- package/dist/src/modes/tui.d.ts.map +1 -1
- package/dist/src/modes/tui.js +57 -10
- package/dist/src/modes/tui.js.map +1 -1
- package/dist/src/modes.js +1 -1
- package/dist/src/modes.js.map +1 -1
- package/dist/src/observability/tracer.d.ts.map +1 -1
- package/dist/src/observability/tracer.js +2 -1
- package/dist/src/observability/tracer.js.map +1 -1
- package/dist/src/persistence/schema.d.ts +2 -0
- package/dist/src/persistence/schema.d.ts.map +1 -1
- package/dist/src/persistence/schema.js +42 -0
- package/dist/src/persistence/schema.js.map +1 -1
- package/dist/src/providers/adapters/anthropic.d.ts +6 -0
- package/dist/src/providers/adapters/anthropic.d.ts.map +1 -1
- package/dist/src/providers/adapters/anthropic.js +101 -16
- package/dist/src/providers/adapters/anthropic.js.map +1 -1
- package/dist/src/providers/adapters/azure.d.ts +74 -0
- package/dist/src/providers/adapters/azure.d.ts.map +1 -0
- package/dist/src/providers/adapters/azure.js +354 -0
- package/dist/src/providers/adapters/azure.js.map +1 -0
- package/dist/src/providers/adapters/mock.d.ts +16 -2
- package/dist/src/providers/adapters/mock.d.ts.map +1 -1
- package/dist/src/providers/adapters/mock.js +44 -3
- package/dist/src/providers/adapters/mock.js.map +1 -1
- package/dist/src/providers/adapters/openai.d.ts +6 -1
- package/dist/src/providers/adapters/openai.d.ts.map +1 -1
- package/dist/src/providers/adapters/openai.js +41 -9
- package/dist/src/providers/adapters/openai.js.map +1 -1
- package/dist/src/providers/adapters/openrouter.d.ts +6 -0
- package/dist/src/providers/adapters/openrouter.d.ts.map +1 -1
- package/dist/src/providers/adapters/openrouter.js +83 -13
- package/dist/src/providers/adapters/openrouter.js.map +1 -1
- package/dist/src/providers/circuit-breaker.d.ts +1 -0
- package/dist/src/providers/circuit-breaker.d.ts.map +1 -1
- package/dist/src/providers/circuit-breaker.js.map +1 -1
- package/dist/src/providers/provider.d.ts.map +1 -1
- package/dist/src/providers/provider.js +2 -1
- package/dist/src/providers/provider.js.map +1 -1
- package/dist/src/providers/resilient-provider.d.ts.map +1 -1
- package/dist/src/providers/resilient-provider.js +2 -1
- package/dist/src/providers/resilient-provider.js.map +1 -1
- package/dist/src/providers/types.d.ts +23 -2
- package/dist/src/providers/types.d.ts.map +1 -1
- package/dist/src/session-picker.d.ts +1 -1
- package/dist/src/session-picker.d.ts.map +1 -1
- package/dist/src/session-picker.js +40 -5
- package/dist/src/session-picker.js.map +1 -1
- package/dist/src/shared/budget-tracker.d.ts +65 -0
- package/dist/src/shared/budget-tracker.d.ts.map +1 -0
- package/dist/src/shared/budget-tracker.js +128 -0
- package/dist/src/shared/budget-tracker.js.map +1 -0
- package/dist/src/shared/context-engine.d.ts +64 -0
- package/dist/src/shared/context-engine.d.ts.map +1 -0
- package/dist/src/shared/context-engine.js +117 -0
- package/dist/src/shared/context-engine.js.map +1 -0
- package/dist/src/shared/index.d.ts +12 -0
- package/dist/src/shared/index.d.ts.map +1 -0
- package/dist/src/shared/index.js +12 -0
- package/dist/src/shared/index.js.map +1 -0
- package/dist/src/shared/persistence.d.ts +57 -0
- package/dist/src/shared/persistence.d.ts.map +1 -0
- package/dist/src/shared/persistence.js +168 -0
- package/dist/src/shared/persistence.js.map +1 -0
- package/dist/src/shared/shared-context-state.d.ts +89 -0
- package/dist/src/shared/shared-context-state.d.ts.map +1 -0
- package/dist/src/shared/shared-context-state.js +175 -0
- package/dist/src/shared/shared-context-state.js.map +1 -0
- package/dist/src/shared/shared-economics-state.d.ts +61 -0
- package/dist/src/shared/shared-economics-state.d.ts.map +1 -0
- package/dist/src/shared/shared-economics-state.js +100 -0
- package/dist/src/shared/shared-economics-state.js.map +1 -0
- package/dist/src/tools/agent.d.ts +1 -1
- package/dist/src/tools/agent.d.ts.map +1 -1
- package/dist/src/tools/bash.d.ts +3 -3
- package/dist/src/tools/bash.d.ts.map +1 -1
- package/dist/src/tools/bash.js +2 -1
- package/dist/src/tools/bash.js.map +1 -1
- package/dist/src/tools/file.d.ts +3 -3
- package/dist/src/tools/file.js +1 -1
- package/dist/src/tools/file.js.map +1 -1
- package/dist/src/tools/permission.d.ts.map +1 -1
- package/dist/src/tools/permission.js +7 -6
- package/dist/src/tools/permission.js.map +1 -1
- package/dist/src/tools/registry.d.ts +1 -1
- package/dist/src/tools/registry.d.ts.map +1 -1
- package/dist/src/tools/registry.js +1 -1
- package/dist/src/tools/registry.js.map +1 -1
- package/dist/src/tools/tasks.d.ts +1 -1
- package/dist/src/tools/tasks.d.ts.map +1 -1
- package/dist/src/tools/types.d.ts +1 -0
- package/dist/src/tools/types.d.ts.map +1 -1
- package/dist/src/tools/types.js.map +1 -1
- package/dist/src/tools/undo.d.ts +1 -1
- package/dist/src/tools/undo.d.ts.map +1 -1
- package/dist/src/tracing/cache-boundary-tracker.d.ts.map +1 -1
- package/dist/src/tracing/cache-boundary-tracker.js +2 -2
- package/dist/src/tracing/cache-boundary-tracker.js.map +1 -1
- package/dist/src/tracing/trace-collector.d.ts +147 -0
- package/dist/src/tracing/trace-collector.d.ts.map +1 -1
- package/dist/src/tracing/trace-collector.js +138 -7
- package/dist/src/tracing/trace-collector.js.map +1 -1
- package/dist/src/tracing/types.d.ts +112 -1
- package/dist/src/tracing/types.d.ts.map +1 -1
- package/dist/src/tracing/types.js.map +1 -1
- package/dist/src/tricks/failure-evidence.d.ts.map +1 -1
- package/dist/src/tricks/failure-evidence.js +2 -1
- package/dist/src/tricks/failure-evidence.js.map +1 -1
- package/dist/src/tricks/recitation.d.ts.map +1 -1
- package/dist/src/tricks/recitation.js +2 -1
- package/dist/src/tricks/recitation.js.map +1 -1
- package/dist/src/tricks/recursive-context.d.ts.map +1 -1
- package/dist/src/tricks/recursive-context.js +2 -2
- package/dist/src/tricks/recursive-context.js.map +1 -1
- package/dist/src/tricks/reversible-compaction.d.ts.map +1 -1
- package/dist/src/tricks/reversible-compaction.js +6 -2
- package/dist/src/tricks/reversible-compaction.js.map +1 -1
- package/dist/src/tui/app.d.ts +16 -3
- package/dist/src/tui/app.d.ts.map +1 -1
- package/dist/src/tui/app.js +211 -25
- package/dist/src/tui/app.js.map +1 -1
- package/dist/src/tui/components/CollapsibleDiffView.d.ts +1 -1
- package/dist/src/tui/components/CollapsibleDiffView.d.ts.map +1 -1
- package/dist/src/tui/components/DiagnosticsPanel.d.ts +24 -0
- package/dist/src/tui/components/DiagnosticsPanel.d.ts.map +1 -0
- package/dist/src/tui/components/DiagnosticsPanel.js +47 -0
- package/dist/src/tui/components/DiagnosticsPanel.js.map +1 -0
- package/dist/src/tui/components/DiffView.d.ts +1 -1
- package/dist/src/tui/components/DiffView.d.ts.map +1 -1
- package/dist/src/tui/components/ErrorBoundary.d.ts.map +1 -1
- package/dist/src/tui/components/ErrorBoundary.js +3 -2
- package/dist/src/tui/components/ErrorBoundary.js.map +1 -1
- package/dist/src/tui/components/TasksPanel.d.ts +1 -1
- package/dist/src/tui/components/TasksPanel.d.ts.map +1 -1
- package/dist/src/tui/event-display.d.ts.map +1 -1
- package/dist/src/tui/event-display.js +36 -62
- package/dist/src/tui/event-display.js.map +1 -1
- package/dist/src/tui/index.d.ts +4 -0
- package/dist/src/tui/index.d.ts.map +1 -1
- package/dist/src/tui/index.js +17 -0
- package/dist/src/tui/index.js.map +1 -1
- package/dist/src/tui/transparency-aggregator.d.ts +13 -0
- package/dist/src/tui/transparency-aggregator.d.ts.map +1 -1
- package/dist/src/tui/transparency-aggregator.js +21 -0
- package/dist/src/tui/transparency-aggregator.js.map +1 -1
- package/dist/src/types.d.ts +170 -3
- package/dist/src/types.d.ts.map +1 -1
- package/package.json +18 -3
|
@@ -0,0 +1,922 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Swarm Lifecycle — Startup, shutdown, cleanup, and LLM-driven phases.
|
|
3
|
+
*
|
|
4
|
+
* Extracted from swarm-orchestrator.ts (Phase 3a).
|
|
5
|
+
* Contains: decomposition, planning, wave review, verification,
|
|
6
|
+
* resume, synthesis, checkpoint, and utility helpers.
|
|
7
|
+
*/
|
|
8
|
+
import * as fs from 'node:fs';
|
|
9
|
+
import * as path from 'node:path';
|
|
10
|
+
import { createSmartDecomposer, parseDecompositionResponse } from '../tasks/smart-decomposer.js';
|
|
11
|
+
import { taskResultToAgentOutput } from './types.js';
|
|
12
|
+
import { SwarmStateStore } from './swarm-state-store.js';
|
|
13
|
+
// ─── Decomposition ──────────────────────────────────────────────────────
|
|
14
|
+
export function classifyDecompositionFailure(message) {
|
|
15
|
+
const m = message.toLowerCase();
|
|
16
|
+
if (m.includes('429') || m.includes('too many requests') || m.includes('rate limit')) {
|
|
17
|
+
return 'rate_limit';
|
|
18
|
+
}
|
|
19
|
+
if (m.includes('402') || m.includes('spend limit') || m.includes('key limit exceeded') || m.includes('insufficient credits')) {
|
|
20
|
+
return 'provider_budget_limit';
|
|
21
|
+
}
|
|
22
|
+
if (m.includes('parse') || m.includes('json') || m.includes('subtasks')) {
|
|
23
|
+
return 'parse_failure';
|
|
24
|
+
}
|
|
25
|
+
if (m.includes('invalid') || m.includes('validation')) {
|
|
26
|
+
return 'validation_failure';
|
|
27
|
+
}
|
|
28
|
+
return 'other';
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Deterministic decomposition fallback when all LLM decomposition paths fail.
|
|
32
|
+
* Keeps swarm mode alive with visible scaffolding tasks instead of aborting.
|
|
33
|
+
*/
|
|
34
|
+
export function buildEmergencyDecomposition(ctx, task, _reason) {
|
|
35
|
+
const normalizer = createSmartDecomposer({ detectConflicts: true });
|
|
36
|
+
const taskLabel = task.trim().slice(0, 140) || 'requested task';
|
|
37
|
+
const repoMap = ctx.config.codebaseContext?.getRepoMap();
|
|
38
|
+
const topFiles = repoMap
|
|
39
|
+
? Array.from(repoMap.chunks.values())
|
|
40
|
+
.sort((a, b) => b.importance - a.importance)
|
|
41
|
+
.slice(0, 10)
|
|
42
|
+
.map(c => c.filePath)
|
|
43
|
+
: [];
|
|
44
|
+
const subtasks = [
|
|
45
|
+
{
|
|
46
|
+
id: 'task-fb-0',
|
|
47
|
+
description: `Scaffold implementation plan and identify target files for: ${taskLabel}`,
|
|
48
|
+
status: 'ready',
|
|
49
|
+
dependencies: [],
|
|
50
|
+
complexity: 2,
|
|
51
|
+
type: 'design',
|
|
52
|
+
parallelizable: true,
|
|
53
|
+
relevantFiles: topFiles.slice(0, 5),
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
id: 'task-fb-1',
|
|
57
|
+
description: `Implement core code changes for: ${taskLabel}`,
|
|
58
|
+
status: 'blocked',
|
|
59
|
+
dependencies: ['task-fb-0'],
|
|
60
|
+
complexity: 5,
|
|
61
|
+
type: 'implement',
|
|
62
|
+
parallelizable: false,
|
|
63
|
+
relevantFiles: topFiles.slice(0, 8),
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
id: 'task-fb-2',
|
|
67
|
+
description: `Add or update tests and run validation for: ${taskLabel}`,
|
|
68
|
+
status: 'blocked',
|
|
69
|
+
dependencies: ['task-fb-1'],
|
|
70
|
+
complexity: 3,
|
|
71
|
+
type: 'test',
|
|
72
|
+
parallelizable: false,
|
|
73
|
+
relevantFiles: topFiles.slice(0, 8),
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
id: 'task-fb-3',
|
|
77
|
+
description: `Integrate results and produce final summary for: ${taskLabel}`,
|
|
78
|
+
status: 'blocked',
|
|
79
|
+
dependencies: ['task-fb-1', 'task-fb-2'],
|
|
80
|
+
complexity: 2,
|
|
81
|
+
type: 'integrate',
|
|
82
|
+
parallelizable: false,
|
|
83
|
+
relevantFiles: topFiles.slice(0, 5),
|
|
84
|
+
},
|
|
85
|
+
];
|
|
86
|
+
const dependencyGraph = normalizer.buildDependencyGraph(subtasks);
|
|
87
|
+
const conflicts = normalizer.detectConflicts(subtasks);
|
|
88
|
+
return {
|
|
89
|
+
originalTask: task,
|
|
90
|
+
subtasks,
|
|
91
|
+
dependencyGraph,
|
|
92
|
+
conflicts,
|
|
93
|
+
strategy: 'adaptive',
|
|
94
|
+
totalComplexity: subtasks.reduce((sum, s) => sum + s.complexity, 0),
|
|
95
|
+
totalEstimatedTokens: subtasks.length * 4000,
|
|
96
|
+
metadata: {
|
|
97
|
+
decomposedAt: new Date(),
|
|
98
|
+
codebaseAware: !!repoMap,
|
|
99
|
+
llmAssisted: false,
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Last-resort decomposition: radically simplified prompt that even weak models can handle.
|
|
105
|
+
*/
|
|
106
|
+
export async function lastResortDecompose(ctx, task) {
|
|
107
|
+
let codebaseHint = '';
|
|
108
|
+
const repoMap = ctx.config.codebaseContext?.getRepoMap();
|
|
109
|
+
if (repoMap) {
|
|
110
|
+
const topFiles = Array.from(repoMap.chunks.values())
|
|
111
|
+
.sort((a, b) => b.importance - a.importance)
|
|
112
|
+
.slice(0, 10)
|
|
113
|
+
.map(c => c.filePath);
|
|
114
|
+
codebaseHint = `\nKey project files: ${topFiles.join(', ')}\nReference actual files in subtask descriptions.`;
|
|
115
|
+
}
|
|
116
|
+
const simplifiedPrompt = `Break this task into 2-6 subtasks. Return ONLY raw JSON, no markdown.
|
|
117
|
+
|
|
118
|
+
{"subtasks":[{"description":"...","type":"implement","complexity":3,"dependencies":[],"parallelizable":true,"relevantFiles":["src/..."]}],"strategy":"adaptive","reasoning":"..."}
|
|
119
|
+
|
|
120
|
+
Rules:
|
|
121
|
+
- dependencies: integer indices (e.g. [0] means depends on first subtask)
|
|
122
|
+
- type: one of research/implement/test/design/refactor/integrate/merge
|
|
123
|
+
- At least 2 subtasks${codebaseHint}`;
|
|
124
|
+
const response = await ctx.provider.chat([
|
|
125
|
+
{ role: 'system', content: simplifiedPrompt },
|
|
126
|
+
{ role: 'user', content: task },
|
|
127
|
+
], {
|
|
128
|
+
model: ctx.config.orchestratorModel,
|
|
129
|
+
maxTokens: 4096,
|
|
130
|
+
temperature: 0.1,
|
|
131
|
+
});
|
|
132
|
+
ctx.trackOrchestratorUsage(response, 'decompose-last-resort');
|
|
133
|
+
const parsed = parseDecompositionResponse(response.content);
|
|
134
|
+
if (parsed.subtasks.length < 2)
|
|
135
|
+
return null;
|
|
136
|
+
const decomposer = createSmartDecomposer({ detectConflicts: true });
|
|
137
|
+
const subtasks = parsed.subtasks.map((s, index) => ({
|
|
138
|
+
id: `task-lr-${index}`,
|
|
139
|
+
description: s.description,
|
|
140
|
+
status: (s.dependencies.length > 0 ? 'blocked' : 'ready'),
|
|
141
|
+
dependencies: s.dependencies.map((d) => `task-lr-${d}`),
|
|
142
|
+
complexity: s.complexity,
|
|
143
|
+
type: s.type,
|
|
144
|
+
parallelizable: s.parallelizable,
|
|
145
|
+
relevantFiles: s.relevantFiles,
|
|
146
|
+
suggestedRole: s.suggestedRole,
|
|
147
|
+
}));
|
|
148
|
+
const dependencyGraph = decomposer.buildDependencyGraph(subtasks);
|
|
149
|
+
const conflicts = decomposer.detectConflicts(subtasks);
|
|
150
|
+
return {
|
|
151
|
+
originalTask: task,
|
|
152
|
+
subtasks,
|
|
153
|
+
dependencyGraph,
|
|
154
|
+
conflicts,
|
|
155
|
+
strategy: parsed.strategy,
|
|
156
|
+
totalComplexity: subtasks.reduce((sum, t) => sum + t.complexity, 0),
|
|
157
|
+
totalEstimatedTokens: subtasks.length * 5000,
|
|
158
|
+
metadata: {
|
|
159
|
+
decomposedAt: new Date(),
|
|
160
|
+
codebaseAware: false,
|
|
161
|
+
llmAssisted: true,
|
|
162
|
+
},
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Phase 1: Decompose the task into subtasks.
|
|
167
|
+
*/
|
|
168
|
+
export async function decomposeTask(ctx, task) {
|
|
169
|
+
try {
|
|
170
|
+
const repoMap = ctx.config.codebaseContext?.getRepoMap() ?? undefined;
|
|
171
|
+
const result = await ctx.decomposer.decompose(task, {
|
|
172
|
+
repoMap,
|
|
173
|
+
});
|
|
174
|
+
if (result.subtasks.length < 2) {
|
|
175
|
+
const reason = result.subtasks.length === 0
|
|
176
|
+
? `Decomposition produced 0 subtasks (model: ${ctx.config.orchestratorModel}).`
|
|
177
|
+
: `Decomposition produced only ${result.subtasks.length} subtask — too few for swarm mode.`;
|
|
178
|
+
ctx.logDecision('decomposition', `Insufficient subtasks: ${result.subtasks.length}`, reason);
|
|
179
|
+
try {
|
|
180
|
+
const lastResortResult = await lastResortDecompose(ctx, task);
|
|
181
|
+
if (lastResortResult && lastResortResult.subtasks.length >= 2) {
|
|
182
|
+
ctx.logDecision('decomposition', `Last-resort decomposition succeeded: ${lastResortResult.subtasks.length} subtasks`, 'Recovered from insufficient primary decomposition');
|
|
183
|
+
return { result: lastResortResult };
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
catch (error) {
|
|
187
|
+
ctx.logDecision('decomposition', 'Last-resort decomposition failed after insufficient primary decomposition', error.message);
|
|
188
|
+
}
|
|
189
|
+
const fallback = buildEmergencyDecomposition(ctx, task, reason);
|
|
190
|
+
ctx.emit({
|
|
191
|
+
type: 'swarm.phase.progress',
|
|
192
|
+
phase: 'decomposing',
|
|
193
|
+
message: `Using emergency decomposition fallback (${classifyDecompositionFailure(reason)})`,
|
|
194
|
+
});
|
|
195
|
+
ctx.logDecision('decomposition', `Using emergency scaffold decomposition: ${fallback.subtasks.length} subtasks`, 'Swarm will continue with deterministic fallback tasks');
|
|
196
|
+
return { result: fallback };
|
|
197
|
+
}
|
|
198
|
+
if (!result.metadata.llmAssisted) {
|
|
199
|
+
ctx.logDecision('decomposition', 'Heuristic decomposition detected — attempting last-resort simplified LLM decomposition', `Model: ${ctx.config.orchestratorModel}`);
|
|
200
|
+
try {
|
|
201
|
+
const lastResortResult = await lastResortDecompose(ctx, task);
|
|
202
|
+
if (lastResortResult && lastResortResult.subtasks.length >= 2) {
|
|
203
|
+
ctx.logDecision('decomposition', `Last-resort decomposition succeeded: ${lastResortResult.subtasks.length} subtasks`, 'Simplified prompt worked');
|
|
204
|
+
return { result: lastResortResult };
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
catch (error) {
|
|
208
|
+
ctx.logDecision('decomposition', 'Last-resort decomposition also failed', error.message);
|
|
209
|
+
}
|
|
210
|
+
ctx.logDecision('decomposition', `Continuing with heuristic decomposition: ${result.subtasks.length} subtasks`, 'Fallback is acceptable; do not abort swarm');
|
|
211
|
+
ctx.emit({
|
|
212
|
+
type: 'swarm.phase.progress',
|
|
213
|
+
phase: 'decomposing',
|
|
214
|
+
message: `Continuing with heuristic decomposition (${classifyDecompositionFailure('heuristic fallback')})`,
|
|
215
|
+
});
|
|
216
|
+
return { result };
|
|
217
|
+
}
|
|
218
|
+
// Flat-DAG detection
|
|
219
|
+
const hasAnyDependency = result.subtasks.some(s => s.dependencies.length > 0);
|
|
220
|
+
if (!hasAnyDependency && result.subtasks.length >= 3) {
|
|
221
|
+
ctx.logDecision('decomposition', `Flat DAG: ${result.subtasks.length} tasks, zero dependencies`, 'All tasks will execute in wave 0 without ordering');
|
|
222
|
+
}
|
|
223
|
+
return { result };
|
|
224
|
+
}
|
|
225
|
+
catch (error) {
|
|
226
|
+
const message = error.message;
|
|
227
|
+
ctx.errors.push({
|
|
228
|
+
phase: 'decomposition',
|
|
229
|
+
message,
|
|
230
|
+
recovered: true,
|
|
231
|
+
});
|
|
232
|
+
const fallback = buildEmergencyDecomposition(ctx, task, `Decomposition threw an error: ${message}`);
|
|
233
|
+
ctx.emit({
|
|
234
|
+
type: 'swarm.phase.progress',
|
|
235
|
+
phase: 'decomposing',
|
|
236
|
+
message: `Decomposition fallback due to ${classifyDecompositionFailure(message)}`,
|
|
237
|
+
});
|
|
238
|
+
ctx.logDecision('decomposition', `Decomposition threw error; using emergency scaffold decomposition (${fallback.subtasks.length} subtasks)`, message);
|
|
239
|
+
return { result: fallback };
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
// ─── Planning Phase ─────────────────────────────────────────────────────
|
|
243
|
+
/**
|
|
244
|
+
* Create acceptance criteria and integration test plan.
|
|
245
|
+
* Graceful: if planning fails, continues without criteria.
|
|
246
|
+
*/
|
|
247
|
+
export async function planExecution(ctx, task, decomposition) {
|
|
248
|
+
try {
|
|
249
|
+
const plannerModel = ctx.config.hierarchy?.manager?.model
|
|
250
|
+
?? ctx.config.plannerModel ?? ctx.config.orchestratorModel;
|
|
251
|
+
ctx.emit({ type: 'swarm.role.action', role: 'manager', action: 'plan', model: plannerModel });
|
|
252
|
+
ctx.logDecision('planning', `Creating acceptance criteria (manager: ${plannerModel})`, `Task has ${decomposition.subtasks.length} subtasks, planning to ensure quality`);
|
|
253
|
+
const taskList = decomposition.subtasks
|
|
254
|
+
.map(s => `- [${s.id}] (${s.type}): ${s.description}`)
|
|
255
|
+
.join('\n');
|
|
256
|
+
const response = await ctx.provider.chat([
|
|
257
|
+
{
|
|
258
|
+
role: 'system',
|
|
259
|
+
content: `You are a project quality planner. Given a task and its decomposition into subtasks, create:
|
|
260
|
+
1. Acceptance criteria for each subtask (what "done" looks like)
|
|
261
|
+
2. An integration test plan (bash commands to verify the combined result works)
|
|
262
|
+
|
|
263
|
+
Respond with valid JSON:
|
|
264
|
+
{
|
|
265
|
+
"acceptanceCriteria": [
|
|
266
|
+
{ "taskId": "st-0", "criteria": ["criterion 1", "criterion 2"] }
|
|
267
|
+
],
|
|
268
|
+
"integrationTestPlan": {
|
|
269
|
+
"description": "What this test plan verifies",
|
|
270
|
+
"steps": [
|
|
271
|
+
{ "description": "Check if files exist", "command": "ls src/parser.js", "expectedResult": "file listed", "required": true }
|
|
272
|
+
],
|
|
273
|
+
"successCriteria": "All required steps pass"
|
|
274
|
+
},
|
|
275
|
+
"reasoning": "Why this plan was chosen"
|
|
276
|
+
}`,
|
|
277
|
+
},
|
|
278
|
+
{
|
|
279
|
+
role: 'user',
|
|
280
|
+
content: `Task: ${task}\n\nSubtasks:\n${taskList}`,
|
|
281
|
+
},
|
|
282
|
+
], {
|
|
283
|
+
model: plannerModel,
|
|
284
|
+
maxTokens: 3000,
|
|
285
|
+
temperature: 0.3,
|
|
286
|
+
});
|
|
287
|
+
ctx.trackOrchestratorUsage(response, 'plan');
|
|
288
|
+
const parsed = parseJSON(response.content);
|
|
289
|
+
if (parsed) {
|
|
290
|
+
ctx.plan = {
|
|
291
|
+
acceptanceCriteria: parsed.acceptanceCriteria ?? [],
|
|
292
|
+
integrationTestPlan: parsed.integrationTestPlan,
|
|
293
|
+
reasoning: parsed.reasoning ?? '',
|
|
294
|
+
};
|
|
295
|
+
ctx.emit({
|
|
296
|
+
type: 'swarm.plan.complete',
|
|
297
|
+
criteriaCount: ctx.plan.acceptanceCriteria.length,
|
|
298
|
+
hasIntegrationPlan: !!ctx.plan.integrationTestPlan,
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
catch (error) {
|
|
303
|
+
ctx.errors.push({
|
|
304
|
+
phase: 'planning',
|
|
305
|
+
message: `Planning failed (non-fatal): ${error.message}`,
|
|
306
|
+
recovered: true,
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
// ─── Wave Review ────────────────────────────────────────────────────────
|
|
311
|
+
/**
|
|
312
|
+
* Review completed wave outputs against acceptance criteria.
|
|
313
|
+
* May spawn fix-up tasks for issues found.
|
|
314
|
+
*/
|
|
315
|
+
export async function reviewWave(ctx, waveIndex) {
|
|
316
|
+
if (!ctx.config.enableWaveReview)
|
|
317
|
+
return null;
|
|
318
|
+
try {
|
|
319
|
+
const managerModel = ctx.config.hierarchy?.manager?.model
|
|
320
|
+
?? ctx.config.plannerModel ?? ctx.config.orchestratorModel;
|
|
321
|
+
const managerPersona = ctx.config.hierarchy?.manager?.persona;
|
|
322
|
+
ctx.emit({ type: 'swarm.role.action', role: 'manager', action: 'review', model: managerModel, wave: waveIndex + 1 });
|
|
323
|
+
ctx.emit({ type: 'swarm.review.start', wave: waveIndex + 1 });
|
|
324
|
+
ctx.logDecision('review', `Reviewing wave ${waveIndex + 1} outputs (manager: ${managerModel})`, 'Checking task outputs against acceptance criteria');
|
|
325
|
+
const completedTasks = ctx.taskQueue.getAllTasks()
|
|
326
|
+
.filter(t => t.status === 'completed' && t.wave === waveIndex);
|
|
327
|
+
if (completedTasks.length === 0) {
|
|
328
|
+
return { wave: waveIndex, assessment: 'good', taskAssessments: [], fixupTasks: [] };
|
|
329
|
+
}
|
|
330
|
+
const taskSummaries = completedTasks.map(t => {
|
|
331
|
+
const criteria = ctx.plan?.acceptanceCriteria.find(c => c.taskId === t.id);
|
|
332
|
+
return `Task ${t.id}: ${t.description}
|
|
333
|
+
Output: ${t.result?.output?.slice(0, 500) ?? 'No output'}
|
|
334
|
+
Acceptance criteria: ${criteria?.criteria.join('; ') ?? 'None set'}`;
|
|
335
|
+
}).join('\n\n');
|
|
336
|
+
const reviewModel = managerModel;
|
|
337
|
+
const reviewSystemPrompt = managerPersona
|
|
338
|
+
? `${managerPersona}\n\nYou are reviewing completed worker outputs. Assess each task against its acceptance criteria.\nRespond with JSON:`
|
|
339
|
+
: `You are reviewing completed worker outputs. Assess each task against its acceptance criteria.\nRespond with JSON:`;
|
|
340
|
+
const response = await ctx.provider.chat([
|
|
341
|
+
{
|
|
342
|
+
role: 'system',
|
|
343
|
+
content: `${reviewSystemPrompt}
|
|
344
|
+
{
|
|
345
|
+
"assessment": "good" | "needs-fixes" | "critical-issues",
|
|
346
|
+
"taskAssessments": [
|
|
347
|
+
{ "taskId": "st-0", "passed": true, "feedback": "optional feedback" }
|
|
348
|
+
],
|
|
349
|
+
"fixupInstructions": [
|
|
350
|
+
{ "fixesTaskId": "st-0", "description": "What to fix", "instructions": "Specific fix instructions" }
|
|
351
|
+
]
|
|
352
|
+
}`,
|
|
353
|
+
},
|
|
354
|
+
{ role: 'user', content: `Review these wave ${waveIndex + 1} outputs:\n\n${taskSummaries}` },
|
|
355
|
+
], { model: reviewModel, maxTokens: 2000, temperature: 0.3 });
|
|
356
|
+
ctx.trackOrchestratorUsage(response, 'review');
|
|
357
|
+
const parsed = parseJSON(response.content);
|
|
358
|
+
if (!parsed)
|
|
359
|
+
return null;
|
|
360
|
+
const fixupTasks = [];
|
|
361
|
+
if (parsed.fixupInstructions) {
|
|
362
|
+
for (const fix of parsed.fixupInstructions) {
|
|
363
|
+
const fixupId = `fixup-${fix.fixesTaskId}-${Date.now()}`;
|
|
364
|
+
const originalTask = ctx.taskQueue.getTask(fix.fixesTaskId);
|
|
365
|
+
const fixupTask = {
|
|
366
|
+
id: fixupId,
|
|
367
|
+
description: fix.description,
|
|
368
|
+
type: originalTask?.type ?? 'implement',
|
|
369
|
+
dependencies: [fix.fixesTaskId],
|
|
370
|
+
status: 'ready',
|
|
371
|
+
complexity: 3,
|
|
372
|
+
wave: waveIndex,
|
|
373
|
+
attempts: 0,
|
|
374
|
+
fixesTaskId: fix.fixesTaskId,
|
|
375
|
+
fixInstructions: fix.instructions,
|
|
376
|
+
};
|
|
377
|
+
fixupTasks.push(fixupTask);
|
|
378
|
+
ctx.emit({ type: 'swarm.fixup.spawned', taskId: fixupId, fixesTaskId: fix.fixesTaskId, description: fix.description });
|
|
379
|
+
}
|
|
380
|
+
if (fixupTasks.length > 0) {
|
|
381
|
+
ctx.taskQueue.addFixupTasks(fixupTasks);
|
|
382
|
+
ctx.emit({
|
|
383
|
+
type: 'swarm.tasks.loaded',
|
|
384
|
+
tasks: ctx.taskQueue.getAllTasks(),
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
const result = {
|
|
389
|
+
wave: waveIndex,
|
|
390
|
+
assessment: parsed.assessment ?? 'good',
|
|
391
|
+
taskAssessments: parsed.taskAssessments ?? [],
|
|
392
|
+
fixupTasks,
|
|
393
|
+
};
|
|
394
|
+
ctx.waveReviews.push(result);
|
|
395
|
+
ctx.emit({
|
|
396
|
+
type: 'swarm.review.complete',
|
|
397
|
+
wave: waveIndex + 1,
|
|
398
|
+
assessment: result.assessment,
|
|
399
|
+
fixupCount: fixupTasks.length,
|
|
400
|
+
});
|
|
401
|
+
return result;
|
|
402
|
+
}
|
|
403
|
+
catch (error) {
|
|
404
|
+
ctx.errors.push({
|
|
405
|
+
phase: 'review',
|
|
406
|
+
message: `Wave review failed (non-fatal): ${error.message}`,
|
|
407
|
+
recovered: true,
|
|
408
|
+
});
|
|
409
|
+
return null;
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
// ─── Verification ───────────────────────────────────────────────────────
|
|
413
|
+
/**
|
|
414
|
+
* Run integration verification steps.
|
|
415
|
+
*/
|
|
416
|
+
export async function verifyIntegration(ctx, testPlan) {
|
|
417
|
+
const verifyModel = ctx.config.hierarchy?.judge?.model
|
|
418
|
+
?? ctx.config.qualityGateModel ?? ctx.config.orchestratorModel;
|
|
419
|
+
ctx.emit({ type: 'swarm.role.action', role: 'judge', action: 'verify', model: verifyModel });
|
|
420
|
+
ctx.emit({ type: 'swarm.verify.start', stepCount: testPlan.steps.length });
|
|
421
|
+
ctx.logDecision('verification', `Running ${testPlan.steps.length} verification steps (judge: ${verifyModel})`, testPlan.description);
|
|
422
|
+
const stepResults = [];
|
|
423
|
+
let allRequiredPassed = true;
|
|
424
|
+
for (let i = 0; i < testPlan.steps.length; i++) {
|
|
425
|
+
const step = testPlan.steps[i];
|
|
426
|
+
try {
|
|
427
|
+
const verifierName = `swarm-verifier-${i}`;
|
|
428
|
+
const result = await ctx.spawnAgentFn(verifierName, `Run this command and report the result: ${step.command}\nExpected: ${step.expectedResult ?? 'success'}`);
|
|
429
|
+
const passed = result.success;
|
|
430
|
+
stepResults.push({ step, passed, output: result.output.slice(0, 500) });
|
|
431
|
+
if (!passed && step.required) {
|
|
432
|
+
allRequiredPassed = false;
|
|
433
|
+
}
|
|
434
|
+
ctx.emit({ type: 'swarm.verify.step', stepIndex: i, description: step.description, passed });
|
|
435
|
+
}
|
|
436
|
+
catch (error) {
|
|
437
|
+
const output = `Error: ${error.message}`;
|
|
438
|
+
stepResults.push({ step, passed: false, output });
|
|
439
|
+
if (step.required)
|
|
440
|
+
allRequiredPassed = false;
|
|
441
|
+
ctx.emit({ type: 'swarm.verify.step', stepIndex: i, description: step.description, passed: false });
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
const verificationResult = {
|
|
445
|
+
passed: allRequiredPassed,
|
|
446
|
+
stepResults,
|
|
447
|
+
summary: allRequiredPassed
|
|
448
|
+
? `All ${stepResults.filter(r => r.passed).length}/${stepResults.length} steps passed`
|
|
449
|
+
: `${stepResults.filter(r => !r.passed).length}/${stepResults.length} steps failed`,
|
|
450
|
+
};
|
|
451
|
+
ctx.verificationResult = verificationResult;
|
|
452
|
+
ctx.emit({ type: 'swarm.verify.complete', result: verificationResult });
|
|
453
|
+
return verificationResult;
|
|
454
|
+
}
|
|
455
|
+
/**
|
|
456
|
+
* Handle verification failure: create fix-up tasks and re-verify.
|
|
457
|
+
*/
|
|
458
|
+
export async function handleVerificationFailure(ctx, verification, task) {
|
|
459
|
+
const maxRetries = ctx.config.maxVerificationRetries ?? 2;
|
|
460
|
+
for (let attempt = 0; attempt < maxRetries; attempt++) {
|
|
461
|
+
ctx.logDecision('verification', `Verification failed, fix-up attempt ${attempt + 1}/${maxRetries}`, `${verification.stepResults.filter(r => !r.passed).length} steps failed`);
|
|
462
|
+
try {
|
|
463
|
+
const failedSteps = verification.stepResults
|
|
464
|
+
.filter(r => !r.passed)
|
|
465
|
+
.map(r => `- ${r.step.description}: ${r.output}`)
|
|
466
|
+
.join('\n');
|
|
467
|
+
const response = await ctx.provider.chat([
|
|
468
|
+
{
|
|
469
|
+
role: 'system',
|
|
470
|
+
content: `Verification failed. Analyze the failures and create fix-up tasks.
|
|
471
|
+
Respond with JSON: { "fixups": [{ "description": "what to fix", "type": "implement" }] }`,
|
|
472
|
+
},
|
|
473
|
+
{ role: 'user', content: `Original task: ${task}\n\nFailed verifications:\n${failedSteps}` },
|
|
474
|
+
], { model: ctx.config.plannerModel ?? ctx.config.orchestratorModel, maxTokens: 1500, temperature: 0.3 });
|
|
475
|
+
ctx.trackOrchestratorUsage(response, 'verification-fixup');
|
|
476
|
+
const parsed = parseJSON(response.content);
|
|
477
|
+
if (parsed?.fixups && parsed.fixups.length > 0) {
|
|
478
|
+
const fixupTasks = parsed.fixups.map((f, i) => ({
|
|
479
|
+
id: `verify-fix-${attempt}-${i}-${Date.now()}`,
|
|
480
|
+
description: f.description,
|
|
481
|
+
type: (f.type ?? 'implement'),
|
|
482
|
+
dependencies: [],
|
|
483
|
+
status: 'ready',
|
|
484
|
+
complexity: 4,
|
|
485
|
+
wave: ctx.taskQueue.getCurrentWave(),
|
|
486
|
+
attempts: 0,
|
|
487
|
+
fixesTaskId: 'verification',
|
|
488
|
+
fixInstructions: f.description,
|
|
489
|
+
}));
|
|
490
|
+
ctx.taskQueue.addFixupTasks(fixupTasks);
|
|
491
|
+
ctx.emit({
|
|
492
|
+
type: 'swarm.tasks.loaded',
|
|
493
|
+
tasks: ctx.taskQueue.getAllTasks(),
|
|
494
|
+
});
|
|
495
|
+
ctx.currentPhase = 'executing';
|
|
496
|
+
await ctx.executeWave(fixupTasks);
|
|
497
|
+
ctx.currentPhase = 'verifying';
|
|
498
|
+
verification = await verifyIntegration(ctx, ctx.plan.integrationTestPlan);
|
|
499
|
+
if (verification.passed)
|
|
500
|
+
return;
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
catch {
|
|
504
|
+
// Continue to next attempt
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
// ─── Resume ─────────────────────────────────────────────────────────────
|
|
509
|
+
/**
|
|
510
|
+
* Resume execution from a saved checkpoint.
|
|
511
|
+
* Returns null if no checkpoint found (caller should fall through to normal execute).
|
|
512
|
+
*/
|
|
513
|
+
export async function resumeExecution(ctx, task, midSwarmReplan) {
|
|
514
|
+
const checkpoint = SwarmStateStore.loadLatest(ctx.config.stateDir ?? '.agent/swarm-state', ctx.config.resumeSessionId);
|
|
515
|
+
if (!checkpoint) {
|
|
516
|
+
ctx.logDecision('resume', 'No checkpoint found, starting fresh', `Session: ${ctx.config.resumeSessionId}`);
|
|
517
|
+
ctx.config.resumeSessionId = undefined;
|
|
518
|
+
return null;
|
|
519
|
+
}
|
|
520
|
+
ctx.logDecision('resume', `Resuming from wave ${checkpoint.currentWave}`, `Session: ${checkpoint.sessionId}`);
|
|
521
|
+
ctx.emit({ type: 'swarm.state.resume', sessionId: checkpoint.sessionId, fromWave: checkpoint.currentWave });
|
|
522
|
+
// Restore state
|
|
523
|
+
if (checkpoint.originalPrompt)
|
|
524
|
+
ctx.originalPrompt = checkpoint.originalPrompt;
|
|
525
|
+
if (checkpoint.plan)
|
|
526
|
+
ctx.plan = checkpoint.plan;
|
|
527
|
+
if (checkpoint.modelHealth.length > 0)
|
|
528
|
+
ctx.healthTracker.restore(checkpoint.modelHealth);
|
|
529
|
+
ctx.orchestratorDecisions = checkpoint.decisions ?? [];
|
|
530
|
+
ctx.errors = checkpoint.errors ?? [];
|
|
531
|
+
ctx.totalTokens = checkpoint.stats.totalTokens;
|
|
532
|
+
ctx.totalCost = checkpoint.stats.totalCost;
|
|
533
|
+
ctx.qualityRejections = checkpoint.stats.qualityRejections;
|
|
534
|
+
ctx.retries = checkpoint.stats.retries;
|
|
535
|
+
if (checkpoint.sharedContext) {
|
|
536
|
+
ctx.sharedContextState.restoreFrom(checkpoint.sharedContext);
|
|
537
|
+
}
|
|
538
|
+
if (checkpoint.sharedEconomics) {
|
|
539
|
+
ctx.sharedEconomicsState.restoreFrom(checkpoint.sharedEconomics);
|
|
540
|
+
}
|
|
541
|
+
ctx.taskQueue.restoreFromCheckpoint({
|
|
542
|
+
taskStates: checkpoint.taskStates,
|
|
543
|
+
waves: checkpoint.waves,
|
|
544
|
+
currentWave: checkpoint.currentWave,
|
|
545
|
+
});
|
|
546
|
+
const resetIds = ctx.taskQueue.reconcileStaleDispatched({
|
|
547
|
+
staleAfterMs: 0,
|
|
548
|
+
activeTaskIds: new Set(),
|
|
549
|
+
});
|
|
550
|
+
const resetCount = resetIds.length;
|
|
551
|
+
for (const taskId of resetIds) {
|
|
552
|
+
const t = ctx.taskQueue.getTask(taskId);
|
|
553
|
+
if (!t)
|
|
554
|
+
continue;
|
|
555
|
+
t.attempts = Math.min(t.attempts, Math.max(0, ctx.config.workerRetries - 1));
|
|
556
|
+
}
|
|
557
|
+
if (resetCount > 0) {
|
|
558
|
+
ctx.logDecision('resume', `Reset ${resetCount} orphaned dispatched tasks to ready`, 'Workers died with previous process');
|
|
559
|
+
}
|
|
560
|
+
let unskippedCount = 0;
|
|
561
|
+
for (const t of ctx.taskQueue.getAllTasks()) {
|
|
562
|
+
if (t.status === 'skipped') {
|
|
563
|
+
const deps = t.dependencies.map(id => ctx.taskQueue.getTask(id));
|
|
564
|
+
const allDepsSatisfied = deps.every(d => d && (d.status === 'completed' || d.status === 'decomposed'));
|
|
565
|
+
if (allDepsSatisfied) {
|
|
566
|
+
t.status = 'ready';
|
|
567
|
+
t.attempts = 0;
|
|
568
|
+
t.rescueContext = 'Recovered on resume — dependencies now satisfied';
|
|
569
|
+
unskippedCount++;
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
for (const t of ctx.taskQueue.getAllTasks()) {
|
|
574
|
+
if (t.status === 'failed') {
|
|
575
|
+
t.status = 'ready';
|
|
576
|
+
t.attempts = Math.min(t.attempts, Math.max(0, ctx.config.workerRetries - 1));
|
|
577
|
+
unskippedCount++;
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
if (unskippedCount > 0) {
|
|
581
|
+
ctx.logDecision('resume', `Recovered ${unskippedCount} skipped/failed tasks`, 'Fresh retry on resume');
|
|
582
|
+
}
|
|
583
|
+
const resumeStats = ctx.taskQueue.getStats();
|
|
584
|
+
const stuckCount = resumeStats.failed + resumeStats.skipped;
|
|
585
|
+
const totalAttempted = resumeStats.completed + stuckCount;
|
|
586
|
+
if (totalAttempted > 0 && stuckCount / totalAttempted > 0.4) {
|
|
587
|
+
ctx.logDecision('resume-replan', `${stuckCount}/${totalAttempted} tasks still stuck after resume — triggering re-plan`, '');
|
|
588
|
+
ctx.hasReplanned = false;
|
|
589
|
+
await midSwarmReplan();
|
|
590
|
+
}
|
|
591
|
+
ctx.currentPhase = 'executing';
|
|
592
|
+
await ctx.executeWaves();
|
|
593
|
+
if (!ctx.cancelled)
|
|
594
|
+
await ctx.finalRescuePass();
|
|
595
|
+
ctx.artifactInventory = buildArtifactInventory(ctx);
|
|
596
|
+
if (ctx.config.enableVerification && ctx.plan?.integrationTestPlan) {
|
|
597
|
+
ctx.currentPhase = 'verifying';
|
|
598
|
+
const ver = await verifyIntegration(ctx, ctx.plan.integrationTestPlan);
|
|
599
|
+
if (!ver.passed) {
|
|
600
|
+
await handleVerificationFailure(ctx, ver, task);
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
ctx.currentPhase = 'synthesizing';
|
|
604
|
+
const synthesisResult = await synthesizeOutputs(ctx);
|
|
605
|
+
ctx.currentPhase = 'completed';
|
|
606
|
+
const executionStats = buildStats(ctx);
|
|
607
|
+
saveCheckpoint(ctx, 'final');
|
|
608
|
+
const hasArtifacts = (ctx.artifactInventory?.totalFiles ?? 0) > 0;
|
|
609
|
+
ctx.emit({ type: 'swarm.complete', stats: executionStats, errors: ctx.errors, artifactInventory: ctx.artifactInventory });
|
|
610
|
+
const completionRatio = executionStats.totalTasks > 0
|
|
611
|
+
? executionStats.completedTasks / executionStats.totalTasks
|
|
612
|
+
: 0;
|
|
613
|
+
const isSuccess = completionRatio >= 0.7;
|
|
614
|
+
const isPartialSuccess = !isSuccess && executionStats.completedTasks > 0;
|
|
615
|
+
return {
|
|
616
|
+
success: isSuccess,
|
|
617
|
+
partialSuccess: isPartialSuccess || (!executionStats.completedTasks && hasArtifacts),
|
|
618
|
+
partialFailure: executionStats.failedTasks > 0,
|
|
619
|
+
synthesisResult: synthesisResult ?? undefined,
|
|
620
|
+
artifactInventory: ctx.artifactInventory,
|
|
621
|
+
summary: buildSummary(ctx, executionStats),
|
|
622
|
+
tasks: ctx.taskQueue.getAllTasks(),
|
|
623
|
+
stats: executionStats,
|
|
624
|
+
errors: ctx.errors,
|
|
625
|
+
};
|
|
626
|
+
}
|
|
627
|
+
// ─── Synthesis ──────────────────────────────────────────────────────────
|
|
628
|
+
/**
|
|
629
|
+
* Phase 4: Synthesize all completed task outputs.
|
|
630
|
+
*/
|
|
631
|
+
export async function synthesizeOutputs(ctx) {
|
|
632
|
+
const tasks = ctx.taskQueue.getAllTasks();
|
|
633
|
+
const outputs = tasks
|
|
634
|
+
.filter(t => t.status === 'completed')
|
|
635
|
+
.map(t => taskResultToAgentOutput(t, ctx.config))
|
|
636
|
+
.filter((o) => o !== null);
|
|
637
|
+
if (outputs.length === 0)
|
|
638
|
+
return null;
|
|
639
|
+
try {
|
|
640
|
+
return await ctx.synthesizer.synthesize(outputs);
|
|
641
|
+
}
|
|
642
|
+
catch (error) {
|
|
643
|
+
ctx.errors.push({
|
|
644
|
+
phase: 'synthesis',
|
|
645
|
+
message: error.message,
|
|
646
|
+
recovered: true,
|
|
647
|
+
});
|
|
648
|
+
return ctx.synthesizer.synthesizeFindings(outputs);
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
// ─── Persistence ────────────────────────────────────────────────────────
|
|
652
|
+
export function saveCheckpoint(ctx, _label) {
|
|
653
|
+
if (!ctx.config.enablePersistence || !ctx.stateStore)
|
|
654
|
+
return;
|
|
655
|
+
try {
|
|
656
|
+
const queueState = ctx.taskQueue.getCheckpointState();
|
|
657
|
+
ctx.stateStore.saveCheckpoint({
|
|
658
|
+
sessionId: ctx.stateStore.id,
|
|
659
|
+
timestamp: Date.now(),
|
|
660
|
+
phase: ctx.currentPhase,
|
|
661
|
+
plan: ctx.plan,
|
|
662
|
+
taskStates: queueState.taskStates,
|
|
663
|
+
waves: queueState.waves,
|
|
664
|
+
currentWave: queueState.currentWave,
|
|
665
|
+
stats: {
|
|
666
|
+
totalTokens: ctx.totalTokens + ctx.orchestratorTokens,
|
|
667
|
+
totalCost: ctx.totalCost + ctx.orchestratorCost,
|
|
668
|
+
qualityRejections: ctx.qualityRejections,
|
|
669
|
+
retries: ctx.retries,
|
|
670
|
+
},
|
|
671
|
+
modelHealth: ctx.healthTracker.getAllRecords(),
|
|
672
|
+
decisions: ctx.orchestratorDecisions,
|
|
673
|
+
errors: ctx.errors,
|
|
674
|
+
originalPrompt: ctx.originalPrompt,
|
|
675
|
+
sharedContext: ctx.sharedContextState.toJSON(),
|
|
676
|
+
sharedEconomics: ctx.sharedEconomicsState.toJSON(),
|
|
677
|
+
});
|
|
678
|
+
ctx.emit({
|
|
679
|
+
type: 'swarm.state.checkpoint',
|
|
680
|
+
sessionId: ctx.stateStore.id,
|
|
681
|
+
wave: ctx.taskQueue.getCurrentWave(),
|
|
682
|
+
});
|
|
683
|
+
}
|
|
684
|
+
catch (error) {
|
|
685
|
+
ctx.errors.push({
|
|
686
|
+
phase: 'persistence',
|
|
687
|
+
message: `Checkpoint failed (non-fatal): ${error.message}`,
|
|
688
|
+
recovered: true,
|
|
689
|
+
});
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
// ─── Utility Helpers ────────────────────────────────────────────────────
|
|
693
|
+
/** Parse JSON from LLM response, handling markdown code blocks. */
|
|
694
|
+
export function parseJSON(content) {
|
|
695
|
+
try {
|
|
696
|
+
let json = content;
|
|
697
|
+
const codeBlockMatch = content.match(/```(?:json)?\s*\n?([\s\S]*?)\n?```/);
|
|
698
|
+
if (codeBlockMatch) {
|
|
699
|
+
json = codeBlockMatch[1];
|
|
700
|
+
}
|
|
701
|
+
return JSON.parse(json);
|
|
702
|
+
}
|
|
703
|
+
catch {
|
|
704
|
+
return null;
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
export function buildStats(ctx) {
|
|
708
|
+
const queueStats = ctx.taskQueue.getStats();
|
|
709
|
+
return {
|
|
710
|
+
totalTasks: queueStats.total,
|
|
711
|
+
completedTasks: queueStats.completed,
|
|
712
|
+
failedTasks: queueStats.failed,
|
|
713
|
+
skippedTasks: queueStats.skipped,
|
|
714
|
+
totalWaves: ctx.taskQueue.getTotalWaves(),
|
|
715
|
+
totalTokens: ctx.totalTokens + ctx.orchestratorTokens,
|
|
716
|
+
totalCost: ctx.totalCost + ctx.orchestratorCost,
|
|
717
|
+
totalDurationMs: Date.now() - ctx.startTime,
|
|
718
|
+
qualityRejections: ctx.qualityRejections,
|
|
719
|
+
retries: ctx.retries,
|
|
720
|
+
modelUsage: ctx.modelUsage,
|
|
721
|
+
};
|
|
722
|
+
}
|
|
723
|
+
export function buildSummary(ctx, stats) {
|
|
724
|
+
const parts = [
|
|
725
|
+
`Swarm execution complete:`,
|
|
726
|
+
` Tasks: ${stats.completedTasks}/${stats.totalTasks} completed, ${stats.failedTasks} failed, ${stats.skippedTasks} skipped`,
|
|
727
|
+
` Waves: ${stats.totalWaves}`,
|
|
728
|
+
` Tokens: ${(stats.totalTokens / 1000).toFixed(0)}k`,
|
|
729
|
+
` Cost: $${stats.totalCost.toFixed(4)}`,
|
|
730
|
+
` Duration: ${(stats.totalDurationMs / 1000).toFixed(1)}s`,
|
|
731
|
+
];
|
|
732
|
+
if (stats.qualityRejections > 0) {
|
|
733
|
+
parts.push(` Quality rejections: ${stats.qualityRejections}`);
|
|
734
|
+
}
|
|
735
|
+
if (stats.retries > 0) {
|
|
736
|
+
parts.push(` Retries: ${stats.retries}`);
|
|
737
|
+
}
|
|
738
|
+
if (ctx.verificationResult) {
|
|
739
|
+
parts.push(` Verification: ${ctx.verificationResult.passed ? 'PASSED' : 'FAILED'}`);
|
|
740
|
+
}
|
|
741
|
+
if (ctx.artifactInventory && ctx.artifactInventory.totalFiles > 0) {
|
|
742
|
+
parts.push(` Files on disk: ${ctx.artifactInventory.totalFiles} files (${(ctx.artifactInventory.totalBytes / 1024).toFixed(1)}KB)`);
|
|
743
|
+
for (const f of ctx.artifactInventory.files.slice(0, 15)) {
|
|
744
|
+
parts.push(` ${f.path}: ${f.sizeBytes}B`);
|
|
745
|
+
}
|
|
746
|
+
if (ctx.artifactInventory.files.length > 15) {
|
|
747
|
+
parts.push(` ... and ${ctx.artifactInventory.files.length - 15} more`);
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
return parts.join('\n');
|
|
751
|
+
}
|
|
752
|
+
export function buildErrorResult(ctx, message) {
|
|
753
|
+
return {
|
|
754
|
+
success: false,
|
|
755
|
+
summary: `Swarm failed: ${message}`,
|
|
756
|
+
tasks: ctx.taskQueue.getAllTasks(),
|
|
757
|
+
stats: buildStats(ctx),
|
|
758
|
+
errors: ctx.errors,
|
|
759
|
+
};
|
|
760
|
+
}
|
|
761
|
+
/**
|
|
762
|
+
* Detect foundation tasks: tasks that are a dependency of 2+ downstream tasks.
|
|
763
|
+
*/
|
|
764
|
+
export function detectFoundationTasks(ctx) {
|
|
765
|
+
const allTasks = ctx.taskQueue.getAllTasks();
|
|
766
|
+
const dependentCounts = new Map();
|
|
767
|
+
for (const task of allTasks) {
|
|
768
|
+
for (const depId of task.dependencies) {
|
|
769
|
+
dependentCounts.set(depId, (dependentCounts.get(depId) ?? 0) + 1);
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
for (const task of allTasks) {
|
|
773
|
+
const dependentCount = dependentCounts.get(task.id) ?? 0;
|
|
774
|
+
if (dependentCount >= 2) {
|
|
775
|
+
task.isFoundation = true;
|
|
776
|
+
ctx.logDecision('scheduling', `Foundation task: ${task.id} (${dependentCount} dependents)`, 'Extra retries and relaxed quality threshold applied');
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
/**
|
|
781
|
+
* Extract file artifacts from a worker's output for quality gate visibility.
|
|
782
|
+
*/
|
|
783
|
+
export function extractFileArtifacts(ctx, task, taskResult) {
|
|
784
|
+
const artifacts = [];
|
|
785
|
+
const seen = new Set();
|
|
786
|
+
const candidatePaths = [];
|
|
787
|
+
if (taskResult.filesModified) {
|
|
788
|
+
candidatePaths.push(...taskResult.filesModified);
|
|
789
|
+
}
|
|
790
|
+
if (task.targetFiles) {
|
|
791
|
+
candidatePaths.push(...task.targetFiles);
|
|
792
|
+
}
|
|
793
|
+
const filePathPattern = /(?:created|wrote|modified|edited|updated)\s+["`']?([^\s"`',]+\.\w+)/gi;
|
|
794
|
+
let match;
|
|
795
|
+
while ((match = filePathPattern.exec(taskResult.output)) !== null) {
|
|
796
|
+
candidatePaths.push(match[1]);
|
|
797
|
+
}
|
|
798
|
+
const baseDir = ctx.config.facts?.workingDirectory ?? process.cwd();
|
|
799
|
+
for (const filePath of candidatePaths) {
|
|
800
|
+
if (seen.has(filePath))
|
|
801
|
+
continue;
|
|
802
|
+
seen.add(filePath);
|
|
803
|
+
try {
|
|
804
|
+
const resolved = path.resolve(baseDir, filePath);
|
|
805
|
+
if (fs.existsSync(resolved)) {
|
|
806
|
+
const content = fs.readFileSync(resolved, 'utf-8');
|
|
807
|
+
if (content.length > 0) {
|
|
808
|
+
artifacts.push({ path: filePath, preview: content.slice(0, 2000) });
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
catch {
|
|
813
|
+
// Skip unreadable files
|
|
814
|
+
}
|
|
815
|
+
if (artifacts.length >= 10)
|
|
816
|
+
break;
|
|
817
|
+
}
|
|
818
|
+
return artifacts;
|
|
819
|
+
}
|
|
820
|
+
/**
|
|
821
|
+
* Build an inventory of filesystem artifacts produced during swarm execution.
|
|
822
|
+
*/
|
|
823
|
+
export function buildArtifactInventory(ctx) {
|
|
824
|
+
const allFiles = new Set();
|
|
825
|
+
for (const task of ctx.taskQueue.getAllTasks()) {
|
|
826
|
+
for (const f of (task.targetFiles ?? []))
|
|
827
|
+
allFiles.add(f);
|
|
828
|
+
for (const f of (task.readFiles ?? []))
|
|
829
|
+
allFiles.add(f);
|
|
830
|
+
}
|
|
831
|
+
const baseDir = ctx.config.facts?.workingDirectory ?? process.cwd();
|
|
832
|
+
const artifacts = [];
|
|
833
|
+
for (const filePath of allFiles) {
|
|
834
|
+
try {
|
|
835
|
+
const resolved = path.resolve(baseDir, filePath);
|
|
836
|
+
if (fs.existsSync(resolved)) {
|
|
837
|
+
const stats = fs.statSync(resolved);
|
|
838
|
+
if (stats.isFile() && stats.size > 0) {
|
|
839
|
+
artifacts.push({ path: filePath, sizeBytes: stats.size, exists: true });
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
catch { /* skip unreadable files */ }
|
|
844
|
+
}
|
|
845
|
+
return {
|
|
846
|
+
files: artifacts,
|
|
847
|
+
totalFiles: artifacts.length,
|
|
848
|
+
totalBytes: artifacts.reduce((s, a) => s + a.sizeBytes, 0),
|
|
849
|
+
};
|
|
850
|
+
}
|
|
851
|
+
/**
|
|
852
|
+
* Skip all remaining pending/ready tasks (used for early termination).
|
|
853
|
+
*/
|
|
854
|
+
export function skipRemainingTasks(ctx, reason) {
|
|
855
|
+
for (const task of ctx.taskQueue.getAllTasks()) {
|
|
856
|
+
if (task.status === 'pending' || task.status === 'ready') {
|
|
857
|
+
task.status = 'skipped';
|
|
858
|
+
ctx.emit({ type: 'swarm.task.skipped', taskId: task.id, reason });
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
export function emitBudgetUpdate(ctx) {
|
|
863
|
+
ctx.emit({
|
|
864
|
+
type: 'swarm.budget.update',
|
|
865
|
+
tokensUsed: ctx.totalTokens + ctx.orchestratorTokens,
|
|
866
|
+
tokensTotal: ctx.config.totalBudget,
|
|
867
|
+
costUsed: ctx.totalCost + ctx.orchestratorCost,
|
|
868
|
+
costTotal: ctx.config.maxCost,
|
|
869
|
+
});
|
|
870
|
+
}
|
|
871
|
+
/**
|
|
872
|
+
* V7: Compute effective retry limit for a task.
|
|
873
|
+
*/
|
|
874
|
+
export function getEffectiveRetries(ctx, task) {
|
|
875
|
+
const isFixup = 'fixesTaskId' in task;
|
|
876
|
+
if (isFixup)
|
|
877
|
+
return 2;
|
|
878
|
+
return task.isFoundation ? ctx.config.workerRetries + 1 : ctx.config.workerRetries;
|
|
879
|
+
}
|
|
880
|
+
/**
|
|
881
|
+
* F22: Build a brief summary of swarm progress for retry context.
|
|
882
|
+
*/
|
|
883
|
+
export function getSwarmProgressSummary(ctx) {
|
|
884
|
+
const allTasks = ctx.taskQueue.getAllTasks();
|
|
885
|
+
const completed = allTasks.filter(t => t.status === 'completed');
|
|
886
|
+
if (completed.length === 0)
|
|
887
|
+
return '';
|
|
888
|
+
const lines = [];
|
|
889
|
+
for (const task of completed) {
|
|
890
|
+
const score = task.result?.qualityScore ? ` (${task.result.qualityScore}/5)` : '';
|
|
891
|
+
lines.push(`- ${task.id}: ${task.description.slice(0, 80)}${score}`);
|
|
892
|
+
}
|
|
893
|
+
const files = new Set();
|
|
894
|
+
const baseDir = ctx.config.facts?.workingDirectory ?? process.cwd();
|
|
895
|
+
for (const task of completed) {
|
|
896
|
+
for (const f of (task.result?.filesModified ?? []))
|
|
897
|
+
files.add(f);
|
|
898
|
+
for (const f of (task.targetFiles ?? [])) {
|
|
899
|
+
try {
|
|
900
|
+
const resolved = path.resolve(baseDir, f);
|
|
901
|
+
if (fs.existsSync(resolved))
|
|
902
|
+
files.add(f);
|
|
903
|
+
}
|
|
904
|
+
catch { /* skip */ }
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
const parts = [`The following tasks have completed successfully:\n${lines.join('\n')}`];
|
|
908
|
+
if (files.size > 0) {
|
|
909
|
+
parts.push(`Files already created/modified: ${[...files].slice(0, 20).join(', ')}`);
|
|
910
|
+
parts.push('You can build on these existing files.');
|
|
911
|
+
}
|
|
912
|
+
return parts.join('\n');
|
|
913
|
+
}
|
|
914
|
+
/** Get a model health summary for emitting events. */
|
|
915
|
+
export function getModelHealthSummary(ctx, model) {
|
|
916
|
+
const records = ctx.healthTracker.getAllRecords();
|
|
917
|
+
const record = records.find(r => r.model === model);
|
|
918
|
+
return record
|
|
919
|
+
? { successes: record.successes, failures: record.failures, rateLimits: record.rateLimits, lastRateLimit: record.lastRateLimit, averageLatencyMs: record.averageLatencyMs, healthy: record.healthy }
|
|
920
|
+
: { successes: 0, failures: 0, rateLimits: 0, averageLatencyMs: 0, healthy: true };
|
|
921
|
+
}
|
|
922
|
+
//# sourceMappingURL=swarm-lifecycle.js.map
|