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,973 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Subagent Spawner Module (Phase 2.1)
|
|
3
|
+
*
|
|
4
|
+
* Extracted from ProductionAgent.spawnAgent(), getSubagentBudget(),
|
|
5
|
+
* and spawnAgentsParallel(). Handles the full subagent lifecycle:
|
|
6
|
+
* config, budget, delegation, timeout, cleanup.
|
|
7
|
+
*
|
|
8
|
+
* Uses SubAgentFactory to create subagent instances without importing
|
|
9
|
+
* ProductionAgent directly — avoids circular dependencies.
|
|
10
|
+
*/
|
|
11
|
+
import { estimateTokenCount } from '../integrations/utilities/token-estimate.js';
|
|
12
|
+
import { getSubagentTimeout, getSubagentMaxIterations, } from '../defaults.js';
|
|
13
|
+
import { calculateTaskSimilarity, SUBAGENT_PLAN_MODE_ADDITION, } from '../modes.js';
|
|
14
|
+
import { SUBAGENT_BUDGET, filterToolsForAgent, isCancellationError, createLinkedToken, createGracefulTimeout, race, createDynamicBudgetPool, buildDelegationPrompt, createMinimalDelegationSpec, getSubagentQualityPrompt, ToolRecommendationEngine, createSubagentSupervisor, createSubagentHandle, } from '../integrations/index.js';
|
|
15
|
+
import { mergeApprovalScopeWithProfile, resolvePolicyProfile, } from '../integrations/safety/policy-engine.js';
|
|
16
|
+
/** Duplicate spawn prevention window (60 seconds). */
|
|
17
|
+
const SPAWN_DEDUP_WINDOW_MS = 60000;
|
|
18
|
+
/**
|
|
19
|
+
* Parse a structured closure report from a subagent's text response.
|
|
20
|
+
* The subagent may have produced JSON in response to a TIMEOUT_WRAPUP_PROMPT.
|
|
21
|
+
*/
|
|
22
|
+
export function parseStructuredClosureReport(text, defaultExitReason, fallbackTask) {
|
|
23
|
+
if (!text) {
|
|
24
|
+
if (fallbackTask) {
|
|
25
|
+
return {
|
|
26
|
+
findings: [],
|
|
27
|
+
actionsTaken: [],
|
|
28
|
+
failures: ['Timeout before producing structured summary'],
|
|
29
|
+
remainingWork: [fallbackTask],
|
|
30
|
+
exitReason: 'timeout_hard',
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
try {
|
|
36
|
+
const jsonMatch = text.match(/\{[\s\S]*\}/);
|
|
37
|
+
if (jsonMatch) {
|
|
38
|
+
const parsed = JSON.parse(jsonMatch[0]);
|
|
39
|
+
if (parsed.findings || parsed.actionsTaken || parsed.failures || parsed.remainingWork) {
|
|
40
|
+
return {
|
|
41
|
+
findings: Array.isArray(parsed.findings) ? parsed.findings : [],
|
|
42
|
+
actionsTaken: Array.isArray(parsed.actionsTaken) ? parsed.actionsTaken : [],
|
|
43
|
+
failures: Array.isArray(parsed.failures) ? parsed.failures : [],
|
|
44
|
+
remainingWork: Array.isArray(parsed.remainingWork) ? parsed.remainingWork : [],
|
|
45
|
+
exitReason: defaultExitReason,
|
|
46
|
+
suggestedNextSteps: Array.isArray(parsed.suggestedNextSteps) ? parsed.suggestedNextSteps : undefined,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
// JSON parse failed — fall through to fallback
|
|
53
|
+
}
|
|
54
|
+
if (defaultExitReason !== 'completed') {
|
|
55
|
+
return {
|
|
56
|
+
findings: [text.slice(0, 500)],
|
|
57
|
+
actionsTaken: [],
|
|
58
|
+
failures: ['Did not produce structured JSON summary'],
|
|
59
|
+
remainingWork: fallbackTask ? [fallbackTask] : [],
|
|
60
|
+
exitReason: defaultExitReason === 'timeout_graceful' ? 'timeout_hard' : defaultExitReason,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
return undefined;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Get budget for a subagent, using the pooled budget when available.
|
|
67
|
+
* Falls back to the static SUBAGENT_BUDGET if no pool is configured.
|
|
68
|
+
*/
|
|
69
|
+
export function getSubagentBudget(ctx, agentName, constraints) {
|
|
70
|
+
if (constraints?.maxTokens) {
|
|
71
|
+
return {
|
|
72
|
+
budget: { ...SUBAGENT_BUDGET, maxTokens: constraints.maxTokens },
|
|
73
|
+
allocationId: null,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
if (ctx.budgetPool) {
|
|
77
|
+
const allocationId = `${agentName}-${Date.now()}`;
|
|
78
|
+
const allocation = ctx.budgetPool.reserve(allocationId);
|
|
79
|
+
if (allocation) {
|
|
80
|
+
return {
|
|
81
|
+
budget: {
|
|
82
|
+
...SUBAGENT_BUDGET,
|
|
83
|
+
maxTokens: allocation.tokenBudget,
|
|
84
|
+
softTokenLimit: Math.floor(allocation.tokenBudget * 0.7),
|
|
85
|
+
maxCost: allocation.costBudget,
|
|
86
|
+
},
|
|
87
|
+
allocationId,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
budget: {
|
|
92
|
+
...SUBAGENT_BUDGET,
|
|
93
|
+
maxTokens: 5000,
|
|
94
|
+
softTokenLimit: 3000,
|
|
95
|
+
maxCost: 0.01,
|
|
96
|
+
},
|
|
97
|
+
allocationId: null,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
return { budget: SUBAGENT_BUDGET, allocationId: null };
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Spawn a single subagent to handle a delegated task.
|
|
104
|
+
* Extracted from ProductionAgent.spawnAgent().
|
|
105
|
+
*/
|
|
106
|
+
export async function spawnAgent(agentName, task, ctx, createSubAgent, constraints) {
|
|
107
|
+
if (!ctx.agentRegistry) {
|
|
108
|
+
return {
|
|
109
|
+
success: false,
|
|
110
|
+
output: 'Agent registry not initialized',
|
|
111
|
+
metrics: { tokens: 0, duration: 0, toolCalls: 0 },
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
const agentDef = ctx.agentRegistry.getAgent(agentName);
|
|
115
|
+
if (!agentDef) {
|
|
116
|
+
return {
|
|
117
|
+
success: false,
|
|
118
|
+
output: `Agent not found: ${agentName}`,
|
|
119
|
+
metrics: { tokens: 0, duration: 0, toolCalls: 0 },
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
// DUPLICATE SPAWN PREVENTION with SEMANTIC SIMILARITY
|
|
123
|
+
const isSwarmWorker = agentName.startsWith('swarm-');
|
|
124
|
+
const SEMANTIC_SIMILARITY_THRESHOLD = 0.75;
|
|
125
|
+
const taskKey = `${agentName}:${task.slice(0, 150).toLowerCase().replace(/\s+/g, ' ').trim()}`;
|
|
126
|
+
const now = Date.now();
|
|
127
|
+
// Clean up old entries
|
|
128
|
+
for (const [key, entry] of ctx.spawnedTasks.entries()) {
|
|
129
|
+
if (now - entry.timestamp > SPAWN_DEDUP_WINDOW_MS) {
|
|
130
|
+
ctx.spawnedTasks.delete(key);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
let existingMatch;
|
|
134
|
+
let matchType = 'exact';
|
|
135
|
+
if (!isSwarmWorker) {
|
|
136
|
+
existingMatch = ctx.spawnedTasks.get(taskKey);
|
|
137
|
+
if (!existingMatch) {
|
|
138
|
+
for (const [key, entry] of ctx.spawnedTasks.entries()) {
|
|
139
|
+
if (!key.startsWith(`${agentName}:`))
|
|
140
|
+
continue;
|
|
141
|
+
if (now - entry.timestamp >= SPAWN_DEDUP_WINDOW_MS)
|
|
142
|
+
continue;
|
|
143
|
+
const existingTask = key.slice(agentName.length + 1);
|
|
144
|
+
const similarity = calculateTaskSimilarity(task, existingTask);
|
|
145
|
+
if (similarity >= SEMANTIC_SIMILARITY_THRESHOLD) {
|
|
146
|
+
existingMatch = entry;
|
|
147
|
+
matchType = 'semantic';
|
|
148
|
+
ctx.observability?.logger?.debug('Semantic duplicate detected', {
|
|
149
|
+
agent: agentName,
|
|
150
|
+
newTask: task.slice(0, 80),
|
|
151
|
+
existingTask: existingTask.slice(0, 80),
|
|
152
|
+
similarity: (similarity * 100).toFixed(1) + '%',
|
|
153
|
+
});
|
|
154
|
+
break;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
if (existingMatch && now - existingMatch.timestamp < SPAWN_DEDUP_WINDOW_MS) {
|
|
160
|
+
ctx.observability?.logger?.warn('Duplicate spawn prevented', {
|
|
161
|
+
agent: agentName,
|
|
162
|
+
task: task.slice(0, 100),
|
|
163
|
+
matchType,
|
|
164
|
+
originalTimestamp: existingMatch.timestamp,
|
|
165
|
+
elapsedMs: now - existingMatch.timestamp,
|
|
166
|
+
});
|
|
167
|
+
const duplicateMessage = `[DUPLICATE SPAWN PREVENTED${matchType === 'semantic' ? ' - SEMANTIC MATCH' : ''}]\n` +
|
|
168
|
+
`This task was already spawned ${Math.round((now - existingMatch.timestamp) / 1000)}s ago.\n` +
|
|
169
|
+
`${existingMatch.queuedChanges > 0
|
|
170
|
+
? `The previous spawn queued ${existingMatch.queuedChanges} change(s) to the pending plan.\n` +
|
|
171
|
+
`These changes are already in your plan - do NOT spawn again.\n`
|
|
172
|
+
: ''}Previous result summary:\n${existingMatch.result.slice(0, 500)}`;
|
|
173
|
+
return {
|
|
174
|
+
success: true,
|
|
175
|
+
output: duplicateMessage,
|
|
176
|
+
metrics: { tokens: 0, duration: 0, toolCalls: 0 },
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
const agentId = `spawn-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
180
|
+
ctx.emit({ type: 'agent.spawn', agentId, name: agentName, task });
|
|
181
|
+
ctx.observability?.logger?.info('Spawning agent', { name: agentName, task });
|
|
182
|
+
const startTime = Date.now();
|
|
183
|
+
const childSessionId = `subagent-${agentName}-${Date.now()}`;
|
|
184
|
+
const childTraceId = `trace-${childSessionId}`;
|
|
185
|
+
let workerResultId;
|
|
186
|
+
try {
|
|
187
|
+
// Filter tools for this agent
|
|
188
|
+
let agentTools = filterToolsForAgent(agentDef, Array.from(ctx.tools.values()));
|
|
189
|
+
// Resolve policy profile
|
|
190
|
+
const inferredTaskType = agentDef.taskType ?? ToolRecommendationEngine.inferTaskType(agentName);
|
|
191
|
+
const policyResolution = resolvePolicyProfile({
|
|
192
|
+
policyEngine: ctx.config.policyEngine,
|
|
193
|
+
requestedProfile: agentDef.policyProfile,
|
|
194
|
+
swarmConfig: isSwarmWorker && ctx.config.swarm && typeof ctx.config.swarm === 'object'
|
|
195
|
+
? ctx.config.swarm
|
|
196
|
+
: undefined,
|
|
197
|
+
taskType: inferredTaskType,
|
|
198
|
+
isSwarmWorker,
|
|
199
|
+
sandboxConfig: ctx.config.sandbox && typeof ctx.config.sandbox === 'object'
|
|
200
|
+
? ctx.config.sandbox
|
|
201
|
+
: undefined,
|
|
202
|
+
});
|
|
203
|
+
ctx.emit({
|
|
204
|
+
type: 'policy.profile.resolved',
|
|
205
|
+
profile: policyResolution.profileName,
|
|
206
|
+
context: isSwarmWorker ? 'swarm' : 'subagent',
|
|
207
|
+
selectionSource: policyResolution.metadata.selectionSource,
|
|
208
|
+
usedLegacyMappings: policyResolution.metadata.usedLegacyMappings,
|
|
209
|
+
legacySources: policyResolution.metadata.legacyMappingSources,
|
|
210
|
+
});
|
|
211
|
+
if (policyResolution.metadata.usedLegacyMappings) {
|
|
212
|
+
ctx.emit({
|
|
213
|
+
type: 'policy.legacy.fallback.used',
|
|
214
|
+
profile: policyResolution.profileName,
|
|
215
|
+
sources: policyResolution.metadata.legacyMappingSources,
|
|
216
|
+
warnings: policyResolution.metadata.warnings,
|
|
217
|
+
});
|
|
218
|
+
ctx.observability?.logger?.warn('Policy legacy mappings used', {
|
|
219
|
+
agent: agentName,
|
|
220
|
+
profile: policyResolution.profileName,
|
|
221
|
+
sources: policyResolution.metadata.legacyMappingSources,
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
// Apply tool recommendations
|
|
225
|
+
if (ctx.toolRecommendation && agentTools.length > 15) {
|
|
226
|
+
const taskType = ToolRecommendationEngine.inferTaskType(agentName);
|
|
227
|
+
const recommendations = ctx.toolRecommendation.recommendTools(task, taskType, agentTools.map(t => t.name));
|
|
228
|
+
if (recommendations.length > 0) {
|
|
229
|
+
const recommendedNames = new Set(recommendations.map(r => r.toolName));
|
|
230
|
+
const alwaysKeep = new Set(['spawn_agent', 'spawn_agents_parallel']);
|
|
231
|
+
if (policyResolution.profile.allowedTools) {
|
|
232
|
+
for (const t of policyResolution.profile.allowedTools)
|
|
233
|
+
alwaysKeep.add(t);
|
|
234
|
+
}
|
|
235
|
+
agentTools = agentTools.filter(t => recommendedNames.has(t.name) || alwaysKeep.has(t.name));
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
// Enforce unified tool policy
|
|
239
|
+
if (policyResolution.profile.toolAccessMode === 'whitelist' && policyResolution.profile.allowedTools) {
|
|
240
|
+
const allowed = new Set(policyResolution.profile.allowedTools);
|
|
241
|
+
agentTools = agentTools.filter(t => allowed.has(t.name));
|
|
242
|
+
}
|
|
243
|
+
else if (policyResolution.profile.deniedTools && policyResolution.profile.deniedTools.length > 0) {
|
|
244
|
+
const denied = new Set(policyResolution.profile.deniedTools);
|
|
245
|
+
agentTools = agentTools.filter(t => !denied.has(t.name));
|
|
246
|
+
}
|
|
247
|
+
if (agentTools.length === 0) {
|
|
248
|
+
throw new Error(`Worker '${agentName}' has zero available tools after filtering. Check toolAccessMode and policy profile '${policyResolution.profileName}'.`);
|
|
249
|
+
}
|
|
250
|
+
// Resolve model
|
|
251
|
+
const resolvedModel = (agentDef.model && agentDef.model.includes('/'))
|
|
252
|
+
? agentDef.model
|
|
253
|
+
: ctx.config.model;
|
|
254
|
+
// Persist subagent task lifecycle
|
|
255
|
+
if (ctx.store?.hasWorkerResultsFeature()) {
|
|
256
|
+
try {
|
|
257
|
+
workerResultId = ctx.store.createWorkerResult(agentId, task.slice(0, 500), resolvedModel || 'default');
|
|
258
|
+
}
|
|
259
|
+
catch (storeErr) {
|
|
260
|
+
ctx.observability?.logger?.warn('Failed to create worker result record', {
|
|
261
|
+
agentId,
|
|
262
|
+
error: storeErr.message,
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
// Get subagent config with agent-type-specific timeouts and iteration limits
|
|
267
|
+
const subagentConfig = ctx.config.subagent;
|
|
268
|
+
const hasSubagentConfig = subagentConfig !== false && subagentConfig !== undefined;
|
|
269
|
+
// Timeout precedence
|
|
270
|
+
const agentTypeTimeout = getSubagentTimeout(agentName);
|
|
271
|
+
const rawPerTypeTimeout = hasSubagentConfig
|
|
272
|
+
? subagentConfig.timeouts?.[agentName]
|
|
273
|
+
: undefined;
|
|
274
|
+
const rawGlobalTimeout = hasSubagentConfig
|
|
275
|
+
? subagentConfig.defaultTimeout
|
|
276
|
+
: undefined;
|
|
277
|
+
const isValidTimeout = (v) => v !== undefined && Number.isFinite(v) && v > 0;
|
|
278
|
+
const agentDefTimeout = isValidTimeout(agentDef.timeout) ? agentDef.timeout : undefined;
|
|
279
|
+
const perTypeConfigTimeout = isValidTimeout(rawPerTypeTimeout) ? rawPerTypeTimeout : undefined;
|
|
280
|
+
const globalConfigTimeout = isValidTimeout(rawGlobalTimeout) ? rawGlobalTimeout : undefined;
|
|
281
|
+
const subagentTimeout = agentDefTimeout ?? perTypeConfigTimeout ?? agentTypeTimeout ?? globalConfigTimeout ?? 300000;
|
|
282
|
+
// Iteration precedence
|
|
283
|
+
const agentTypeMaxIter = getSubagentMaxIterations(agentName);
|
|
284
|
+
const rawPerTypeMaxIter = hasSubagentConfig
|
|
285
|
+
? subagentConfig.maxIterations?.[agentName]
|
|
286
|
+
: undefined;
|
|
287
|
+
const rawGlobalMaxIter = hasSubagentConfig
|
|
288
|
+
? subagentConfig.defaultMaxIterations
|
|
289
|
+
: undefined;
|
|
290
|
+
const isValidIter = (v) => v !== undefined && Number.isFinite(v) && v > 0 && Number.isInteger(v);
|
|
291
|
+
const perTypeConfigMaxIter = isValidIter(rawPerTypeMaxIter) ? rawPerTypeMaxIter : undefined;
|
|
292
|
+
const globalConfigMaxIter = isValidIter(rawGlobalMaxIter) ? rawGlobalMaxIter : undefined;
|
|
293
|
+
const defaultMaxIterations = agentDef.maxIterations ?? perTypeConfigMaxIter ?? agentTypeMaxIter ?? globalConfigMaxIter ?? 15;
|
|
294
|
+
// BLACKBOARD CONTEXT INJECTION
|
|
295
|
+
let blackboardContext = '';
|
|
296
|
+
let blackboardFindingsCount = 0;
|
|
297
|
+
const parentAgentId = `parent-${Date.now()}`;
|
|
298
|
+
if (ctx.blackboard) {
|
|
299
|
+
ctx.blackboard.post(parentAgentId, {
|
|
300
|
+
topic: 'spawn.parent_context',
|
|
301
|
+
content: `Parent spawning ${agentName} for task: ${task.slice(0, 200)}`,
|
|
302
|
+
type: 'progress',
|
|
303
|
+
confidence: 1,
|
|
304
|
+
metadata: { agentName, taskPreview: task.slice(0, 100) },
|
|
305
|
+
});
|
|
306
|
+
const recentFindings = ctx.blackboard.query({
|
|
307
|
+
limit: 5,
|
|
308
|
+
types: ['discovery', 'analysis', 'progress'],
|
|
309
|
+
minConfidence: 0.7,
|
|
310
|
+
});
|
|
311
|
+
blackboardFindingsCount = recentFindings.length;
|
|
312
|
+
if (recentFindings.length > 0) {
|
|
313
|
+
const findingsSummary = recentFindings
|
|
314
|
+
.map(f => `- [${f.agentId}] ${f.topic}: ${f.content.slice(0, 150)}${f.content.length > 150 ? '...' : ''}`)
|
|
315
|
+
.join('\n');
|
|
316
|
+
blackboardContext = `\n\n**BLACKBOARD CONTEXT (from parent/sibling agents):**\n${findingsSummary}\n`;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
// Check for files already in parent's pending plan
|
|
320
|
+
const currentPlan = ctx.pendingPlanManager.getPendingPlan();
|
|
321
|
+
if (currentPlan && currentPlan.proposedChanges.length > 0) {
|
|
322
|
+
const pendingFiles = currentPlan.proposedChanges
|
|
323
|
+
.filter((c) => c.tool === 'write_file' || c.tool === 'edit_file')
|
|
324
|
+
.map((c) => c.args.path || c.args.file_path)
|
|
325
|
+
.filter(Boolean);
|
|
326
|
+
if (pendingFiles.length > 0) {
|
|
327
|
+
blackboardContext += `\n**FILES ALREADY IN PENDING PLAN (do not duplicate):**\n${pendingFiles.slice(0, 10).join('\n')}\n`;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
// CONSTRAINT INJECTION
|
|
331
|
+
const constraintParts = [];
|
|
332
|
+
const subagentBudgetTokens = constraints?.maxTokens ?? SUBAGENT_BUDGET.maxTokens ?? 100000;
|
|
333
|
+
const subagentBudgetMinutes = Math.round((SUBAGENT_BUDGET.maxDuration ?? 240000) / 60000);
|
|
334
|
+
if (isSwarmWorker) {
|
|
335
|
+
constraintParts.push(`**Execution Mode:** You are a focused worker agent.\n` +
|
|
336
|
+
`- Complete your assigned task using tool calls.\n` +
|
|
337
|
+
`- Your FIRST action must be a tool call (read_file, write_file, edit_file, grep, glob, etc.).\n` +
|
|
338
|
+
`- To create files use write_file. To modify files use edit_file. Do NOT use bash for file operations.\n` +
|
|
339
|
+
`- You will receive a system message if you need to wrap up. Until then, work normally.\n` +
|
|
340
|
+
`- Do NOT produce summaries or reports — produce CODE and FILE CHANGES.`);
|
|
341
|
+
}
|
|
342
|
+
else {
|
|
343
|
+
constraintParts.push(`**RESOURCE AWARENESS (CRITICAL):**\n` +
|
|
344
|
+
`- Token budget: ~${(subagentBudgetTokens / 1000).toFixed(0)}k tokens\n` +
|
|
345
|
+
`- Time limit: ~${subagentBudgetMinutes} minutes\n` +
|
|
346
|
+
`- You will receive warnings at 70% usage. When warned, WRAP UP immediately.\n` +
|
|
347
|
+
`- Do not explore indefinitely - be focused and efficient.\n` +
|
|
348
|
+
`- If approaching limits, summarize findings and return.\n` +
|
|
349
|
+
`- **STRUCTURED WRAPUP:** When told to wrap up, respond with ONLY this JSON (no tool calls):\n` +
|
|
350
|
+
` {"findings":[...], "actionsTaken":[...], "failures":[...], "remainingWork":[...], "suggestedNextSteps":[...]}`);
|
|
351
|
+
}
|
|
352
|
+
if (constraints) {
|
|
353
|
+
if (constraints.focusAreas && constraints.focusAreas.length > 0) {
|
|
354
|
+
constraintParts.push(`**FOCUS AREAS (limit exploration to these paths):**\n${constraints.focusAreas.map(a => ` - ${a}`).join('\n')}`);
|
|
355
|
+
}
|
|
356
|
+
if (constraints.excludeAreas && constraints.excludeAreas.length > 0) {
|
|
357
|
+
constraintParts.push(`**EXCLUDED AREAS (do NOT explore these):**\n${constraints.excludeAreas.map(a => ` - ${a}`).join('\n')}`);
|
|
358
|
+
}
|
|
359
|
+
if (constraints.requiredDeliverables && constraints.requiredDeliverables.length > 0) {
|
|
360
|
+
constraintParts.push(`**REQUIRED DELIVERABLES (you must produce these):**\n${constraints.requiredDeliverables.map(d => ` - ${d}`).join('\n')}`);
|
|
361
|
+
}
|
|
362
|
+
if (constraints.timeboxMinutes) {
|
|
363
|
+
constraintParts.push(`**TIME LIMIT:** ${constraints.timeboxMinutes} minutes (soft limit - wrap up if approaching)`);
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
const constraintContext = `\n\n**EXECUTION CONSTRAINTS:**\n${constraintParts.join('\n\n')}\n`;
|
|
367
|
+
// Build delegation-enhanced system prompt
|
|
368
|
+
let delegationContext = '';
|
|
369
|
+
if (ctx.lastComplexityAssessment && ctx.lastComplexityAssessment.tier !== 'simple') {
|
|
370
|
+
const spec = createMinimalDelegationSpec(task, agentName);
|
|
371
|
+
delegationContext = '\n\n' + buildDelegationPrompt(spec);
|
|
372
|
+
}
|
|
373
|
+
const qualityPrompt = '\n\n' + getSubagentQualityPrompt();
|
|
374
|
+
// REPO CONTEXT INJECTION — give subagents a lightweight file structure map
|
|
375
|
+
let repoContextStr = '';
|
|
376
|
+
if (ctx.codebaseContext) {
|
|
377
|
+
const repoMap = ctx.codebaseContext.getRepoMap();
|
|
378
|
+
if (repoMap) {
|
|
379
|
+
// Lightweight repo map: file tree with key symbols (capped at 3000 tokens)
|
|
380
|
+
const { generateLightweightRepoMap } = await import('../integrations/context/codebase-context.js');
|
|
381
|
+
repoContextStr = '\n\n**REPOSITORY STRUCTURE:**\n' + generateLightweightRepoMap(repoMap, 3000);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
// Inject parent's recently modified files so subagent knows the working context
|
|
385
|
+
let recentFilesStr = '';
|
|
386
|
+
let modifiedFilesList = [];
|
|
387
|
+
if (ctx.economics) {
|
|
388
|
+
const modifiedPaths = ctx.economics.getModifiedFilePaths();
|
|
389
|
+
modifiedFilesList = modifiedPaths.slice(0, 15);
|
|
390
|
+
if (modifiedPaths.length > 0) {
|
|
391
|
+
recentFilesStr = '\n\n**RECENTLY MODIFIED FILES (by parent agent):**\n' +
|
|
392
|
+
modifiedPaths.slice(0, 15).map(f => `- ${f}`).join('\n');
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
// Build subagent system prompt
|
|
396
|
+
const parentMode = ctx.modeManager.getMode();
|
|
397
|
+
const subagentSystemPrompt = parentMode === 'plan'
|
|
398
|
+
? `${agentDef.systemPrompt}\n\n${SUBAGENT_PLAN_MODE_ADDITION}${blackboardContext}${repoContextStr}${recentFilesStr}${constraintContext}${delegationContext}${qualityPrompt}`
|
|
399
|
+
: `${agentDef.systemPrompt}${blackboardContext}${repoContextStr}${recentFilesStr}${constraintContext}${delegationContext}${qualityPrompt}`;
|
|
400
|
+
// Trace context injection for subagent prompt
|
|
401
|
+
ctx.traceCollector?.record({
|
|
402
|
+
type: 'context.injection',
|
|
403
|
+
data: {
|
|
404
|
+
agentId: agentName,
|
|
405
|
+
parentAgentId: ctx.traceCollector.getSessionId() || 'unknown',
|
|
406
|
+
repoMapTokens: estimateTokenCount(repoContextStr),
|
|
407
|
+
blackboardFindings: blackboardFindingsCount,
|
|
408
|
+
modifiedFiles: modifiedFilesList,
|
|
409
|
+
toolCount: agentTools.length,
|
|
410
|
+
model: resolvedModel || 'default',
|
|
411
|
+
},
|
|
412
|
+
});
|
|
413
|
+
// Allocate budget
|
|
414
|
+
const pooledBudget = getSubagentBudget(ctx, agentName, constraints);
|
|
415
|
+
const poolAllocationId = pooledBudget.allocationId;
|
|
416
|
+
const deniedByProfile = new Set(policyResolution.profile.deniedTools ?? []);
|
|
417
|
+
const policyToolPolicies = {};
|
|
418
|
+
for (const toolName of deniedByProfile) {
|
|
419
|
+
policyToolPolicies[toolName] = {
|
|
420
|
+
policy: 'forbidden',
|
|
421
|
+
reason: `Denied by policy profile '${policyResolution.profileName}'`,
|
|
422
|
+
};
|
|
423
|
+
}
|
|
424
|
+
if ((policyResolution.profile.bashMode ?? 'full') === 'disabled') {
|
|
425
|
+
policyToolPolicies.bash = {
|
|
426
|
+
policy: 'forbidden',
|
|
427
|
+
reason: `Bash is disabled by policy profile '${policyResolution.profileName}'`,
|
|
428
|
+
};
|
|
429
|
+
}
|
|
430
|
+
// Create the sub-agent via factory (avoids circular import)
|
|
431
|
+
const subAgent = createSubAgent({
|
|
432
|
+
provider: ctx.provider,
|
|
433
|
+
tools: agentTools,
|
|
434
|
+
toolResolver: ctx.toolResolver || undefined,
|
|
435
|
+
mcpToolSummaries: ctx.config.mcpToolSummaries,
|
|
436
|
+
systemPrompt: subagentSystemPrompt,
|
|
437
|
+
model: resolvedModel,
|
|
438
|
+
maxIterations: agentDef.maxIterations || defaultMaxIterations,
|
|
439
|
+
memory: false,
|
|
440
|
+
planning: false,
|
|
441
|
+
reflection: false,
|
|
442
|
+
compaction: {
|
|
443
|
+
enabled: true,
|
|
444
|
+
mode: 'auto',
|
|
445
|
+
tokenThreshold: 40000,
|
|
446
|
+
preserveRecentCount: 4,
|
|
447
|
+
preserveToolResults: false,
|
|
448
|
+
summaryMaxTokens: 500,
|
|
449
|
+
},
|
|
450
|
+
maxContextTokens: 80000,
|
|
451
|
+
observability: ctx.config.observability,
|
|
452
|
+
sandbox: (() => {
|
|
453
|
+
const swarm = ctx.config.swarm;
|
|
454
|
+
const extraCmds = swarm && typeof swarm === 'object' && swarm.permissions?.additionalAllowedCommands;
|
|
455
|
+
const baseSbx = ctx.config.sandbox;
|
|
456
|
+
if (baseSbx && typeof baseSbx === 'object') {
|
|
457
|
+
const sbx = baseSbx;
|
|
458
|
+
const allowedCommands = extraCmds
|
|
459
|
+
? [...(sbx.allowedCommands || []), ...extraCmds]
|
|
460
|
+
: sbx.allowedCommands;
|
|
461
|
+
return {
|
|
462
|
+
...sbx,
|
|
463
|
+
allowedCommands,
|
|
464
|
+
bashMode: policyResolution.profile.bashMode ?? sbx.bashMode,
|
|
465
|
+
bashWriteProtection: policyResolution.profile.bashWriteProtection ?? sbx.bashWriteProtection,
|
|
466
|
+
blockFileCreationViaBash: (policyResolution.profile.bashWriteProtection ?? 'off') === 'block_file_mutation'
|
|
467
|
+
? true
|
|
468
|
+
: sbx.blockFileCreationViaBash,
|
|
469
|
+
};
|
|
470
|
+
}
|
|
471
|
+
return baseSbx;
|
|
472
|
+
})(),
|
|
473
|
+
// Subagents: raise riskThreshold to 'high' so moderate-risk tools (write_file, edit_file)
|
|
474
|
+
// pass without approval dialogs. High-risk tools (delete_file) still require approval.
|
|
475
|
+
// The scopedApprove paths still constrain WHERE subagents can write.
|
|
476
|
+
humanInLoop: ctx.config.humanInLoop
|
|
477
|
+
? {
|
|
478
|
+
...ctx.config.humanInLoop,
|
|
479
|
+
riskThreshold: 'high',
|
|
480
|
+
}
|
|
481
|
+
: ctx.config.humanInLoop,
|
|
482
|
+
executionPolicy: (() => {
|
|
483
|
+
const hasPolicyOverrides = Object.keys(policyToolPolicies).length > 0;
|
|
484
|
+
if (ctx.config.executionPolicy) {
|
|
485
|
+
return {
|
|
486
|
+
...ctx.config.executionPolicy,
|
|
487
|
+
defaultPolicy: 'allow',
|
|
488
|
+
toolPolicies: {
|
|
489
|
+
...(ctx.config.executionPolicy.toolPolicies ?? {}),
|
|
490
|
+
...policyToolPolicies,
|
|
491
|
+
},
|
|
492
|
+
};
|
|
493
|
+
}
|
|
494
|
+
if (hasPolicyOverrides) {
|
|
495
|
+
return {
|
|
496
|
+
enabled: true,
|
|
497
|
+
defaultPolicy: 'allow',
|
|
498
|
+
toolPolicies: policyToolPolicies,
|
|
499
|
+
intentAware: false,
|
|
500
|
+
};
|
|
501
|
+
}
|
|
502
|
+
return { enabled: true, defaultPolicy: 'allow', toolPolicies: {}, intentAware: false };
|
|
503
|
+
})(),
|
|
504
|
+
policyEngine: ctx.config.policyEngine
|
|
505
|
+
? { ...ctx.config.policyEngine, defaultProfile: policyResolution.profileName }
|
|
506
|
+
: ctx.config.policyEngine,
|
|
507
|
+
threads: false,
|
|
508
|
+
hooks: ctx.config.hooks === false ? false : {
|
|
509
|
+
enabled: true,
|
|
510
|
+
builtIn: { logging: false, timing: false, metrics: false },
|
|
511
|
+
custom: [],
|
|
512
|
+
},
|
|
513
|
+
agentId,
|
|
514
|
+
blackboard: ctx.blackboard || undefined,
|
|
515
|
+
fileCache: ctx.fileCache || undefined,
|
|
516
|
+
budget: {
|
|
517
|
+
...pooledBudget.budget,
|
|
518
|
+
...(agentDef.economicsTuning ? { tuning: agentDef.economicsTuning } : {}),
|
|
519
|
+
...(agentDef.enforcementMode ? { enforcementMode: agentDef.enforcementMode } : {}),
|
|
520
|
+
},
|
|
521
|
+
sharedContextState: ctx.sharedContextState || undefined,
|
|
522
|
+
sharedEconomicsState: ctx.sharedEconomicsState || undefined,
|
|
523
|
+
});
|
|
524
|
+
// Inherit parent's mode
|
|
525
|
+
if (parentMode !== 'build') {
|
|
526
|
+
subAgent.setMode(parentMode);
|
|
527
|
+
}
|
|
528
|
+
// APPROVAL BATCHING
|
|
529
|
+
const swarmPerms = ctx.config.swarm && typeof ctx.config.swarm === 'object'
|
|
530
|
+
? ctx.config.swarm.permissions : undefined;
|
|
531
|
+
const baseAutoApprove = ['read_file', 'list_files', 'glob', 'grep', 'show_file_history', 'show_session_changes'];
|
|
532
|
+
const baseScopedApprove = isSwarmWorker
|
|
533
|
+
? {
|
|
534
|
+
write_file: { paths: ['src/', 'tests/', 'tools/'] },
|
|
535
|
+
edit_file: { paths: ['src/', 'tests/', 'tools/'] },
|
|
536
|
+
bash: { paths: ['src/', 'tests/', 'tools/'] },
|
|
537
|
+
}
|
|
538
|
+
: {
|
|
539
|
+
write_file: { paths: ['src/', 'tests/', 'tools/'] },
|
|
540
|
+
edit_file: { paths: ['src/', 'tests/', 'tools/'] },
|
|
541
|
+
};
|
|
542
|
+
const baseRequireApproval = isSwarmWorker ? ['delete_file'] : ['bash', 'delete_file'];
|
|
543
|
+
const mergedScope = mergeApprovalScopeWithProfile({
|
|
544
|
+
autoApprove: swarmPerms?.autoApprove
|
|
545
|
+
? [...new Set([...baseAutoApprove, ...swarmPerms.autoApprove])]
|
|
546
|
+
: baseAutoApprove,
|
|
547
|
+
scopedApprove: swarmPerms?.scopedApprove
|
|
548
|
+
? { ...baseScopedApprove, ...swarmPerms.scopedApprove }
|
|
549
|
+
: baseScopedApprove,
|
|
550
|
+
requireApproval: swarmPerms?.requireApproval
|
|
551
|
+
? swarmPerms.requireApproval
|
|
552
|
+
: baseRequireApproval,
|
|
553
|
+
}, policyResolution.profile);
|
|
554
|
+
subAgent.setApprovalScope(mergedScope);
|
|
555
|
+
subAgent.setParentIterations(ctx.getTotalIterations());
|
|
556
|
+
// UNIFIED TRACING
|
|
557
|
+
if (ctx.traceCollector) {
|
|
558
|
+
const subagentTraceView = ctx.traceCollector.createSubagentView({
|
|
559
|
+
parentSessionId: ctx.traceCollector.getSessionId() || 'unknown',
|
|
560
|
+
agentType: agentName,
|
|
561
|
+
spawnedAtIteration: ctx.state.iteration,
|
|
562
|
+
});
|
|
563
|
+
subAgent.setTraceCollector(subagentTraceView);
|
|
564
|
+
}
|
|
565
|
+
// GRACEFUL TIMEOUT with WRAPUP PHASE
|
|
566
|
+
const IDLE_TIMEOUT = agentDef.idleTimeout ?? 120000;
|
|
567
|
+
let WRAPUP_WINDOW = 30000;
|
|
568
|
+
let IDLE_CHECK_INTERVAL = 5000;
|
|
569
|
+
if (ctx.config.subagent) {
|
|
570
|
+
WRAPUP_WINDOW = ctx.config.subagent.wrapupWindowMs ?? WRAPUP_WINDOW;
|
|
571
|
+
IDLE_CHECK_INTERVAL = ctx.config.subagent.idleCheckIntervalMs ?? IDLE_CHECK_INTERVAL;
|
|
572
|
+
}
|
|
573
|
+
const progressAwareTimeout = createGracefulTimeout(subagentTimeout, IDLE_TIMEOUT, WRAPUP_WINDOW, IDLE_CHECK_INTERVAL);
|
|
574
|
+
progressAwareTimeout.onWrapupWarning(() => {
|
|
575
|
+
ctx.emit({
|
|
576
|
+
type: 'subagent.wrapup.started',
|
|
577
|
+
agentId,
|
|
578
|
+
agentType: agentName,
|
|
579
|
+
reason: 'Timeout approaching - graceful wrapup window opened',
|
|
580
|
+
elapsedMs: Date.now() - startTime,
|
|
581
|
+
});
|
|
582
|
+
subAgent.requestWrapup('Timeout approaching — produce structured summary');
|
|
583
|
+
});
|
|
584
|
+
// Forward events from subagent
|
|
585
|
+
const unsubSubAgent = subAgent.subscribe(event => {
|
|
586
|
+
const taggedEvent = { ...event, subagent: agentName, subagentId: agentId };
|
|
587
|
+
ctx.emit(taggedEvent);
|
|
588
|
+
const progressEvents = ['tool.start', 'tool.complete', 'llm.start', 'llm.complete'];
|
|
589
|
+
if (progressEvents.includes(event.type)) {
|
|
590
|
+
progressAwareTimeout.reportProgress();
|
|
591
|
+
}
|
|
592
|
+
});
|
|
593
|
+
// Link parent's cancellation
|
|
594
|
+
const parentSource = ctx.cancellation?.getSource();
|
|
595
|
+
const effectiveSource = parentSource
|
|
596
|
+
? createLinkedToken(parentSource, progressAwareTimeout)
|
|
597
|
+
: progressAwareTimeout;
|
|
598
|
+
subAgent.setExternalCancellation(effectiveSource.token);
|
|
599
|
+
// Pause parent's duration timer
|
|
600
|
+
ctx.economics?.pauseDuration();
|
|
601
|
+
try {
|
|
602
|
+
const result = await race(subAgent.run(task), effectiveSource.token);
|
|
603
|
+
const duration = Date.now() - startTime;
|
|
604
|
+
// Extract subagent's pending plan and merge into parent's plan
|
|
605
|
+
let queuedChangeSummary = '';
|
|
606
|
+
let queuedChangesCount = 0;
|
|
607
|
+
if (subAgent.hasPendingPlan()) {
|
|
608
|
+
const subPlan = subAgent.getPendingPlan();
|
|
609
|
+
if (subPlan && subPlan.proposedChanges.length > 0) {
|
|
610
|
+
queuedChangesCount = subPlan.proposedChanges.length;
|
|
611
|
+
ctx.emit({
|
|
612
|
+
type: 'agent.pending_plan',
|
|
613
|
+
agentId: agentName,
|
|
614
|
+
changes: subPlan.proposedChanges,
|
|
615
|
+
});
|
|
616
|
+
const changeSummaries = subPlan.proposedChanges.map(c => {
|
|
617
|
+
if (c.tool === 'write_file' || c.tool === 'edit_file') {
|
|
618
|
+
const path = c.args.path || c.args.file_path || '(unknown file)';
|
|
619
|
+
return ` - [${c.tool}] ${path}: ${c.reason}`;
|
|
620
|
+
}
|
|
621
|
+
else if (c.tool === 'bash') {
|
|
622
|
+
const cmd = String(c.args.command || '').slice(0, 60);
|
|
623
|
+
return ` - [bash] ${cmd}${String(c.args.command || '').length > 60 ? '...' : ''}: ${c.reason}`;
|
|
624
|
+
}
|
|
625
|
+
return ` - [${c.tool}]: ${c.reason}`;
|
|
626
|
+
});
|
|
627
|
+
queuedChangeSummary = `\n\n[PLAN MODE - CHANGES QUEUED TO PARENT]\n` +
|
|
628
|
+
`The following ${subPlan.proposedChanges.length} change(s) have been queued in the parent's pending plan:\n` +
|
|
629
|
+
changeSummaries.join('\n') + '\n' +
|
|
630
|
+
`\nThese changes are now in YOUR pending plan. The task for this subagent is COMPLETE.\n` +
|
|
631
|
+
`Do NOT spawn another agent for the same task - the changes are already queued.\n` +
|
|
632
|
+
`Use /show-plan to see all pending changes, /approve to execute them.`;
|
|
633
|
+
for (const change of subPlan.proposedChanges) {
|
|
634
|
+
ctx.pendingPlanManager.addProposedChange(change.tool, { ...change.args, _fromSubagent: agentName }, `[${agentName}] ${change.reason}`, change.toolCallId);
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
if (subPlan?.explorationSummary) {
|
|
638
|
+
ctx.pendingPlanManager.appendExplorationFinding(`[${agentName}] ${subPlan.explorationSummary}`);
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
const finalOutput = queuedChangeSummary
|
|
642
|
+
? (result.response || '') + queuedChangeSummary
|
|
643
|
+
: (result.response || result.error || '');
|
|
644
|
+
const structured = parseStructuredClosureReport(result.response || '', 'completed');
|
|
645
|
+
const subagentFilePaths = subAgent.getModifiedFilePaths();
|
|
646
|
+
const spawnResultFinal = {
|
|
647
|
+
success: result.success,
|
|
648
|
+
output: finalOutput,
|
|
649
|
+
metrics: {
|
|
650
|
+
tokens: result.metrics.totalTokens,
|
|
651
|
+
inputTokens: result.metrics.inputTokens,
|
|
652
|
+
outputTokens: result.metrics.outputTokens,
|
|
653
|
+
duration,
|
|
654
|
+
toolCalls: result.metrics.toolCalls,
|
|
655
|
+
},
|
|
656
|
+
structured,
|
|
657
|
+
filesModified: subagentFilePaths,
|
|
658
|
+
};
|
|
659
|
+
// Save to output store
|
|
660
|
+
if (ctx.subagentOutputStore) {
|
|
661
|
+
const outputEntry = {
|
|
662
|
+
id: agentId,
|
|
663
|
+
agentId,
|
|
664
|
+
agentName,
|
|
665
|
+
task,
|
|
666
|
+
fullOutput: finalOutput,
|
|
667
|
+
structured,
|
|
668
|
+
filesModified: subagentFilePaths,
|
|
669
|
+
filesCreated: [],
|
|
670
|
+
timestamp: new Date(),
|
|
671
|
+
tokensUsed: result.metrics.totalTokens,
|
|
672
|
+
durationMs: duration,
|
|
673
|
+
};
|
|
674
|
+
const storeId = ctx.subagentOutputStore.save(outputEntry);
|
|
675
|
+
spawnResultFinal.outputStoreId = storeId;
|
|
676
|
+
}
|
|
677
|
+
if (workerResultId && ctx.store?.hasWorkerResultsFeature()) {
|
|
678
|
+
try {
|
|
679
|
+
ctx.store.completeWorkerResult(workerResultId, {
|
|
680
|
+
fullOutput: finalOutput,
|
|
681
|
+
summary: finalOutput.slice(0, 500),
|
|
682
|
+
artifacts: structured ? [{ type: 'structured_report', data: structured }] : undefined,
|
|
683
|
+
metrics: {
|
|
684
|
+
tokens: result.metrics.totalTokens,
|
|
685
|
+
duration,
|
|
686
|
+
toolCalls: result.metrics.toolCalls,
|
|
687
|
+
},
|
|
688
|
+
});
|
|
689
|
+
}
|
|
690
|
+
catch (storeErr) {
|
|
691
|
+
ctx.observability?.logger?.warn('Failed to persist worker result', {
|
|
692
|
+
agentId,
|
|
693
|
+
error: storeErr.message,
|
|
694
|
+
});
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
ctx.emit({
|
|
698
|
+
type: 'agent.complete',
|
|
699
|
+
agentId,
|
|
700
|
+
agentType: agentName,
|
|
701
|
+
success: result.success,
|
|
702
|
+
output: finalOutput.slice(0, 500),
|
|
703
|
+
});
|
|
704
|
+
if (progressAwareTimeout.isInWrapupPhase()) {
|
|
705
|
+
ctx.emit({
|
|
706
|
+
type: 'subagent.wrapup.completed',
|
|
707
|
+
agentId,
|
|
708
|
+
agentType: agentName,
|
|
709
|
+
elapsedMs: Date.now() - startTime,
|
|
710
|
+
});
|
|
711
|
+
}
|
|
712
|
+
// Enhanced tracing
|
|
713
|
+
ctx.traceCollector?.record({
|
|
714
|
+
type: 'subagent.link',
|
|
715
|
+
data: {
|
|
716
|
+
parentSessionId: ctx.traceCollector.getSessionId() || 'unknown',
|
|
717
|
+
childSessionId,
|
|
718
|
+
childTraceId,
|
|
719
|
+
childConfig: {
|
|
720
|
+
agentType: agentName,
|
|
721
|
+
model: resolvedModel || 'default',
|
|
722
|
+
task,
|
|
723
|
+
tools: agentTools.map(t => t.name),
|
|
724
|
+
},
|
|
725
|
+
spawnContext: {
|
|
726
|
+
reason: `Delegated task: ${task.slice(0, 100)}`,
|
|
727
|
+
expectedOutcome: agentDef.description,
|
|
728
|
+
parentIteration: ctx.state.iteration,
|
|
729
|
+
},
|
|
730
|
+
result: {
|
|
731
|
+
success: result.success,
|
|
732
|
+
summary: (result.response || result.error || '').slice(0, 500),
|
|
733
|
+
tokensUsed: result.metrics.totalTokens,
|
|
734
|
+
durationMs: duration,
|
|
735
|
+
},
|
|
736
|
+
},
|
|
737
|
+
});
|
|
738
|
+
unsubSubAgent();
|
|
739
|
+
await subAgent.cleanup();
|
|
740
|
+
ctx.spawnedTasks.set(taskKey, {
|
|
741
|
+
timestamp: Date.now(),
|
|
742
|
+
result: finalOutput,
|
|
743
|
+
queuedChanges: queuedChangesCount,
|
|
744
|
+
});
|
|
745
|
+
return spawnResultFinal;
|
|
746
|
+
}
|
|
747
|
+
catch (err) {
|
|
748
|
+
// Handle cancellation
|
|
749
|
+
if (isCancellationError(err)) {
|
|
750
|
+
const duration = Date.now() - startTime;
|
|
751
|
+
const isUserCancellation = parentSource?.isCancellationRequested;
|
|
752
|
+
const reason = isUserCancellation
|
|
753
|
+
? 'User cancelled'
|
|
754
|
+
: err.reason || `Timed out after ${subagentTimeout}ms`;
|
|
755
|
+
ctx.emit({ type: 'agent.error', agentId, agentType: agentName, error: reason });
|
|
756
|
+
if (!isUserCancellation) {
|
|
757
|
+
ctx.emit({
|
|
758
|
+
type: 'subagent.timeout.hard_kill',
|
|
759
|
+
agentId,
|
|
760
|
+
agentType: agentName,
|
|
761
|
+
reason,
|
|
762
|
+
elapsedMs: Date.now() - startTime,
|
|
763
|
+
});
|
|
764
|
+
}
|
|
765
|
+
// PRESERVE PARTIAL RESULTS
|
|
766
|
+
const subagentState = subAgent.getState();
|
|
767
|
+
const subagentMetrics = subAgent.getMetrics();
|
|
768
|
+
const assistantMessages = subagentState.messages.filter(m => m.role === 'assistant');
|
|
769
|
+
const lastAssistantMsg = assistantMessages[assistantMessages.length - 1];
|
|
770
|
+
const partialResponse = typeof lastAssistantMsg?.content === 'string'
|
|
771
|
+
? lastAssistantMsg.content
|
|
772
|
+
: '';
|
|
773
|
+
let cancelledQueuedSummary = '';
|
|
774
|
+
if (subAgent.hasPendingPlan()) {
|
|
775
|
+
const subPlan = subAgent.getPendingPlan();
|
|
776
|
+
if (subPlan && subPlan.proposedChanges.length > 0) {
|
|
777
|
+
ctx.emit({
|
|
778
|
+
type: 'agent.pending_plan',
|
|
779
|
+
agentId: agentName,
|
|
780
|
+
changes: subPlan.proposedChanges,
|
|
781
|
+
});
|
|
782
|
+
const changeSummaries = subPlan.proposedChanges.map(c => {
|
|
783
|
+
if (c.tool === 'write_file' || c.tool === 'edit_file') {
|
|
784
|
+
const path = c.args.path || c.args.file_path || '(unknown file)';
|
|
785
|
+
return ` - [${c.tool}] ${path}: ${c.reason}`;
|
|
786
|
+
}
|
|
787
|
+
else if (c.tool === 'bash') {
|
|
788
|
+
const cmd = String(c.args.command || '').slice(0, 60);
|
|
789
|
+
return ` - [bash] ${cmd}...: ${c.reason}`;
|
|
790
|
+
}
|
|
791
|
+
return ` - [${c.tool}]: ${c.reason}`;
|
|
792
|
+
});
|
|
793
|
+
cancelledQueuedSummary = `\n\n[PLAN MODE - CHANGES QUEUED BEFORE CANCELLATION]\n` +
|
|
794
|
+
`${subPlan.proposedChanges.length} change(s) were queued to the parent plan:\n` +
|
|
795
|
+
changeSummaries.join('\n') + '\n' +
|
|
796
|
+
`These changes are preserved in your pending plan.`;
|
|
797
|
+
for (const change of subPlan.proposedChanges) {
|
|
798
|
+
ctx.pendingPlanManager.addProposedChange(change.tool, { ...change.args, _fromSubagent: agentName }, `[${agentName}] ${change.reason}`, change.toolCallId);
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
if (subPlan?.explorationSummary) {
|
|
802
|
+
ctx.pendingPlanManager.appendExplorationFinding(`[${agentName}] ${subPlan.explorationSummary}`);
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
const subagentFilePaths = subAgent.getModifiedFilePaths();
|
|
806
|
+
unsubSubAgent();
|
|
807
|
+
try {
|
|
808
|
+
await subAgent.cleanup();
|
|
809
|
+
}
|
|
810
|
+
catch {
|
|
811
|
+
// Ignore cleanup errors on cancellation
|
|
812
|
+
}
|
|
813
|
+
const baseOutput = isUserCancellation
|
|
814
|
+
? `Subagent '${agentName}' was cancelled by user.`
|
|
815
|
+
: `Subagent '${agentName}' timed out after ${Math.round(subagentTimeout / 1000)}s.`;
|
|
816
|
+
const partialResultSection = partialResponse
|
|
817
|
+
? `\n\n[PARTIAL RESULTS BEFORE TIMEOUT]\n${partialResponse.slice(0, 2000)}${partialResponse.length > 2000 ? '...(truncated)' : ''}`
|
|
818
|
+
: '';
|
|
819
|
+
ctx.traceCollector?.record({
|
|
820
|
+
type: 'subagent.link',
|
|
821
|
+
data: {
|
|
822
|
+
parentSessionId: ctx.traceCollector.getSessionId() || 'unknown',
|
|
823
|
+
childSessionId,
|
|
824
|
+
childTraceId,
|
|
825
|
+
childConfig: {
|
|
826
|
+
agentType: agentName,
|
|
827
|
+
model: resolvedModel || 'default',
|
|
828
|
+
task,
|
|
829
|
+
tools: agentTools.map(t => t.name),
|
|
830
|
+
},
|
|
831
|
+
spawnContext: {
|
|
832
|
+
reason: `Delegated task: ${task.slice(0, 100)}`,
|
|
833
|
+
expectedOutcome: agentDef.description,
|
|
834
|
+
parentIteration: ctx.state.iteration,
|
|
835
|
+
},
|
|
836
|
+
result: {
|
|
837
|
+
success: false,
|
|
838
|
+
summary: `[TIMEOUT] ${baseOutput}\n${partialResponse.slice(0, 200)}`,
|
|
839
|
+
tokensUsed: subagentMetrics.totalTokens,
|
|
840
|
+
durationMs: duration,
|
|
841
|
+
},
|
|
842
|
+
},
|
|
843
|
+
});
|
|
844
|
+
const exitReason = isUserCancellation ? 'cancelled' : 'timeout_graceful';
|
|
845
|
+
const structured = parseStructuredClosureReport(partialResponse, exitReason, task);
|
|
846
|
+
if (workerResultId && ctx.store?.hasWorkerResultsFeature()) {
|
|
847
|
+
try {
|
|
848
|
+
ctx.store.failWorkerResult(workerResultId, reason);
|
|
849
|
+
}
|
|
850
|
+
catch (storeErr) {
|
|
851
|
+
ctx.observability?.logger?.warn('Failed to mark cancelled worker result as failed', {
|
|
852
|
+
agentId,
|
|
853
|
+
error: storeErr.message,
|
|
854
|
+
});
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
return {
|
|
858
|
+
success: false,
|
|
859
|
+
output: baseOutput + partialResultSection + cancelledQueuedSummary,
|
|
860
|
+
metrics: {
|
|
861
|
+
tokens: subagentMetrics.totalTokens,
|
|
862
|
+
inputTokens: subagentMetrics.inputTokens,
|
|
863
|
+
outputTokens: subagentMetrics.outputTokens,
|
|
864
|
+
duration,
|
|
865
|
+
toolCalls: subagentMetrics.toolCalls,
|
|
866
|
+
},
|
|
867
|
+
structured,
|
|
868
|
+
filesModified: subagentFilePaths,
|
|
869
|
+
};
|
|
870
|
+
}
|
|
871
|
+
throw err;
|
|
872
|
+
}
|
|
873
|
+
finally {
|
|
874
|
+
ctx.economics?.resumeDuration();
|
|
875
|
+
effectiveSource.dispose();
|
|
876
|
+
progressAwareTimeout.dispose();
|
|
877
|
+
if (ctx.budgetPool && poolAllocationId) {
|
|
878
|
+
const subMetrics = subAgent.getMetrics();
|
|
879
|
+
ctx.budgetPool.recordUsage(poolAllocationId, subMetrics.totalTokens, subMetrics.estimatedCost);
|
|
880
|
+
ctx.budgetPool.release(poolAllocationId);
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
catch (err) {
|
|
885
|
+
const error = err instanceof Error ? err.message : String(err);
|
|
886
|
+
ctx.emit({ type: 'agent.error', agentId, agentType: agentName, error });
|
|
887
|
+
if (workerResultId && ctx.store?.hasWorkerResultsFeature()) {
|
|
888
|
+
try {
|
|
889
|
+
ctx.store.failWorkerResult(workerResultId, error);
|
|
890
|
+
}
|
|
891
|
+
catch (storeErr) {
|
|
892
|
+
ctx.observability?.logger?.warn('Failed to mark worker result as failed', {
|
|
893
|
+
agentId,
|
|
894
|
+
error: storeErr.message,
|
|
895
|
+
});
|
|
896
|
+
}
|
|
897
|
+
}
|
|
898
|
+
return {
|
|
899
|
+
success: false,
|
|
900
|
+
output: `Agent error: ${error}`,
|
|
901
|
+
metrics: { tokens: 0, duration: Date.now() - startTime, toolCalls: 0 },
|
|
902
|
+
};
|
|
903
|
+
}
|
|
904
|
+
}
|
|
905
|
+
/**
|
|
906
|
+
* Spawn multiple agents in parallel to work on independent tasks.
|
|
907
|
+
* Uses DynamicBudgetPool for parallel spawns and SubagentSupervisor for monitoring.
|
|
908
|
+
* Extracted from ProductionAgent.spawnAgentsParallel().
|
|
909
|
+
*/
|
|
910
|
+
export async function spawnAgentsParallel(tasks, ctx, mutators, createSubAgent) {
|
|
911
|
+
ctx.emit({
|
|
912
|
+
type: 'parallel.spawn.start',
|
|
913
|
+
count: tasks.length,
|
|
914
|
+
agents: tasks.map(t => t.agent),
|
|
915
|
+
});
|
|
916
|
+
let settled;
|
|
917
|
+
const originalPool = ctx.budgetPool;
|
|
918
|
+
const supervisor = tasks.length > 1 ? createSubagentSupervisor() : null;
|
|
919
|
+
if (ctx.budgetPool && tasks.length > 1) {
|
|
920
|
+
const poolStats = ctx.budgetPool.getStats();
|
|
921
|
+
const dynamicPool = createDynamicBudgetPool(poolStats.tokensRemaining, 0.1);
|
|
922
|
+
dynamicPool.setExpectedChildren(tasks.length);
|
|
923
|
+
// Temporarily replace the budget pool
|
|
924
|
+
mutators.setBudgetPool(dynamicPool);
|
|
925
|
+
try {
|
|
926
|
+
const promises = tasks.map(({ agent, task }) => {
|
|
927
|
+
const spawnPromise = spawnAgent(agent, task, ctx, createSubAgent);
|
|
928
|
+
if (supervisor) {
|
|
929
|
+
const handle = createSubagentHandle(`parallel-${agent}-${Date.now()}`, agent, task, spawnPromise, {});
|
|
930
|
+
supervisor.add(handle);
|
|
931
|
+
}
|
|
932
|
+
return spawnPromise;
|
|
933
|
+
});
|
|
934
|
+
settled = await Promise.allSettled(promises);
|
|
935
|
+
}
|
|
936
|
+
finally {
|
|
937
|
+
mutators.setBudgetPool(originalPool);
|
|
938
|
+
supervisor?.stop();
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
else {
|
|
942
|
+
const promises = tasks.map(({ agent, task }) => spawnAgent(agent, task, ctx, createSubAgent));
|
|
943
|
+
settled = await Promise.allSettled(promises);
|
|
944
|
+
}
|
|
945
|
+
const results = settled.map((result, i) => {
|
|
946
|
+
if (result.status === 'fulfilled') {
|
|
947
|
+
return result.value;
|
|
948
|
+
}
|
|
949
|
+
const error = result.reason instanceof Error ? result.reason.message : String(result.reason);
|
|
950
|
+
ctx.emit({
|
|
951
|
+
type: 'agent.error',
|
|
952
|
+
agentId: tasks[i].agent,
|
|
953
|
+
error: `Unexpected parallel spawn error: ${error}`,
|
|
954
|
+
});
|
|
955
|
+
return {
|
|
956
|
+
success: false,
|
|
957
|
+
output: `Parallel spawn error: ${error}`,
|
|
958
|
+
metrics: { tokens: 0, duration: 0, toolCalls: 0 },
|
|
959
|
+
};
|
|
960
|
+
});
|
|
961
|
+
ctx.emit({
|
|
962
|
+
type: 'parallel.spawn.complete',
|
|
963
|
+
count: tasks.length,
|
|
964
|
+
successCount: results.filter(r => r.success).length,
|
|
965
|
+
results: results.map((r, i) => ({
|
|
966
|
+
agent: tasks[i].agent,
|
|
967
|
+
success: r.success,
|
|
968
|
+
tokens: r.metrics?.tokens || 0,
|
|
969
|
+
})),
|
|
970
|
+
});
|
|
971
|
+
return results;
|
|
972
|
+
}
|
|
973
|
+
//# sourceMappingURL=subagent-spawner.js.map
|