attocode 0.2.4 → 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 +56 -1
- package/dist/src/adapters.d.ts +2 -1
- package/dist/src/adapters.d.ts.map +1 -1
- package/dist/src/adapters.js +60 -2
- 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 +14 -115
- package/dist/src/agent.d.ts.map +1 -1
- package/dist/src/agent.js +36 -1177
- package/dist/src/agent.js.map +1 -1
- package/dist/src/cli.js +1 -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 +8 -7
- package/dist/src/commands/handler.js.map +1 -1
- package/dist/src/commands/init.js +1 -1
- package/dist/src/commands/init.js.map +1 -1
- package/dist/src/config/schema.d.ts +6 -6
- package/dist/src/core/execution-loop.d.ts.map +1 -1
- package/dist/src/core/execution-loop.js +155 -16
- package/dist/src/core/execution-loop.js.map +1 -1
- package/dist/src/core/response-handler.d.ts.map +1 -1
- package/dist/src/core/response-handler.js +3 -2
- package/dist/src/core/response-handler.js.map +1 -1
- package/dist/src/core/subagent-spawner.d.ts.map +1 -1
- package/dist/src/core/subagent-spawner.js +13 -6
- package/dist/src/core/subagent-spawner.js.map +1 -1
- package/dist/src/core/tool-executor.d.ts.map +1 -1
- package/dist/src/core/tool-executor.js +7 -2
- package/dist/src/core/tool-executor.js.map +1 -1
- package/dist/src/core/types.d.ts +1 -0
- package/dist/src/core/types.d.ts.map +1 -1
- package/dist/src/core/types.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/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/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/index.d.ts +72 -68
- package/dist/src/integrations/index.d.ts.map +1 -1
- package/dist/src/integrations/index.js +76 -68
- package/dist/src/integrations/index.js.map +1 -1
- 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/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/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/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/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/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/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/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.js +1 -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.map +1 -1
- package/dist/src/integrations/swarm/swarm-config-loader.js +7 -0
- package/dist/src/integrations/swarm/swarm-config-loader.js.map +1 -1
- package/dist/src/integrations/swarm/swarm-events.d.ts +1 -1
- package/dist/src/integrations/swarm/swarm-events.d.ts.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 +84 -203
- package/dist/src/integrations/swarm/swarm-orchestrator.d.ts.map +1 -1
- package/dist/src/integrations/swarm/swarm-orchestrator.js +251 -2870
- 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.map +1 -1
- package/dist/src/integrations/swarm/swarm-state-store.js +6 -0
- package/dist/src/integrations/swarm/swarm-state-store.js.map +1 -1
- package/dist/src/integrations/swarm/task-queue.d.ts +1 -1
- package/dist/src/integrations/swarm/task-queue.d.ts.map +1 -1
- package/dist/src/integrations/swarm/task-queue.js +28 -1
- package/dist/src/integrations/swarm/task-queue.js.map +1 -1
- package/dist/src/integrations/swarm/types.d.ts +17 -5
- package/dist/src/integrations/swarm/types.d.ts.map +1 -1
- package/dist/src/integrations/swarm/types.js.map +1 -1
- package/dist/src/integrations/swarm/worker-pool.d.ts +1 -1
- package/dist/src/integrations/swarm/worker-pool.d.ts.map +1 -1
- package/dist/src/integrations/swarm/worker-pool.js +13 -9
- package/dist/src/integrations/swarm/worker-pool.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 +10 -4
- package/dist/src/main.js.map +1 -1
- package/dist/src/modes/repl.d.ts.map +1 -1
- package/dist/src/modes/repl.js +22 -5
- 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 +23 -6
- 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.js +1 -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 +31 -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 +99 -15
- 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 +39 -8
- 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 +73 -3
- package/dist/src/providers/adapters/openrouter.js.map +1 -1
- package/dist/src/providers/provider.js +1 -1
- package/dist/src/providers/provider.js.map +1 -1
- package/dist/src/providers/resilient-provider.js +1 -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 +1 -1
- package/dist/src/session-picker.js.map +1 -1
- package/dist/src/shared/budget-tracker.js +1 -1
- package/dist/src/shared/budget-tracker.js.map +1 -1
- package/dist/src/tools/agent.d.ts +1 -1
- package/dist/src/tools/agent.d.ts.map +1 -1
- package/dist/src/tools/bash.js +1 -1
- package/dist/src/tools/bash.js.map +1 -1
- package/dist/src/tools/file.js +1 -1
- package/dist/src/tools/file.js.map +1 -1
- package/dist/src/tools/permission.js +2 -2
- 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/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 +22 -0
- package/dist/src/tracing/trace-collector.d.ts.map +1 -1
- package/dist/src/tracing/trace-collector.js +27 -3
- package/dist/src/tracing/trace-collector.js.map +1 -1
- package/dist/src/tracing/types.d.ts +17 -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.js +1 -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 +3 -3
- package/dist/src/tui/app.d.ts.map +1 -1
- package/dist/src/tui/app.js +86 -14
- 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.js +1 -1
- 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.js +1 -1
- package/dist/src/tui/event-display.js.map +1 -1
- package/dist/src/tui/index.js +1 -1
- 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 +27 -2
- package/dist/src/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,677 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Feature initialization logic extracted from ProductionAgent.
|
|
3
|
+
* Initializes all integration managers based on configuration.
|
|
4
|
+
*/
|
|
5
|
+
import { isFeatureEnabled, getEnabledFeatures, } from '../defaults.js';
|
|
6
|
+
import { HookManager, MemoryManager, PlanningManager, ObservabilityManager, SafetyManager, RoutingManager, MultiAgentManager, ReActManager, ExecutionPolicyManager, ThreadManager, RulesManager, DEFAULT_RULE_SOURCES, ExecutionEconomicsManager, STANDARD_BUDGET, AgentRegistry, createCancellationManager, createResourceManager, createLSPManager, createSemanticCacheManager, createSkillManager, createContextEngineering, createCodebaseContext, createSwarmOrchestrator, createThrottledProvider, FREE_TIER_THROTTLE, PAID_TIER_THROTTLE, createWorkLog, createVerificationGate, createTypeCheckerState, createInjectionBudgetManager, createSelfImprovementProtocol, createSubagentOutputStore, createAutoCheckpointManager, createToolRecommendationEngine, createInteractivePlanner, createRecursiveContext, createLearningStore, createCompactor, createAutoCompactionManager, createTaskManager, createSerperSearchTool, } from '../integrations/index.js';
|
|
7
|
+
import { resolvePolicyProfile, } from '../integrations/safety/policy-engine.js';
|
|
8
|
+
import { createTraceCollector } from '../tracing/trace-collector.js';
|
|
9
|
+
import { modelRegistry } from '../costs/index.js';
|
|
10
|
+
import { getModelContextLength } from '../integrations/utilities/openrouter-pricing.js';
|
|
11
|
+
import { createComponentLogger } from '../integrations/utilities/logger.js';
|
|
12
|
+
import { createBoundSpawnAgentTool, createBoundSpawnAgentsParallelTool, } from '../tools/agent.js';
|
|
13
|
+
import { createTaskTools, } from '../tools/tasks.js';
|
|
14
|
+
import { createAgentStateMachine } from '../core/agent-state-machine.js';
|
|
15
|
+
const log = createComponentLogger('FeatureInitializer');
|
|
16
|
+
// =============================================================================
|
|
17
|
+
// FEATURE INITIALIZATION
|
|
18
|
+
// =============================================================================
|
|
19
|
+
/**
|
|
20
|
+
* Initialize all enabled features on an agent.
|
|
21
|
+
* This is the extracted body of ProductionAgent.initializeFeatures().
|
|
22
|
+
* All `this.` references are replaced with `agent.`.
|
|
23
|
+
*/
|
|
24
|
+
export function initializeFeatures(agent) {
|
|
25
|
+
// Debug output only when DEBUG env var is set
|
|
26
|
+
if (process.env.DEBUG) {
|
|
27
|
+
const features = getEnabledFeatures(agent.config);
|
|
28
|
+
log.debug('Initializing with features', { features: features.join(', ') });
|
|
29
|
+
}
|
|
30
|
+
// Hooks & Plugins
|
|
31
|
+
if (isFeatureEnabled(agent.config.hooks) && isFeatureEnabled(agent.config.plugins)) {
|
|
32
|
+
agent.hooks = new HookManager(agent.config.hooks, agent.config.plugins);
|
|
33
|
+
}
|
|
34
|
+
// Memory
|
|
35
|
+
if (isFeatureEnabled(agent.config.memory)) {
|
|
36
|
+
agent.memory = new MemoryManager(agent.config.memory);
|
|
37
|
+
}
|
|
38
|
+
// Planning & Reflection
|
|
39
|
+
if (isFeatureEnabled(agent.config.planning) && isFeatureEnabled(agent.config.reflection)) {
|
|
40
|
+
agent.planning = new PlanningManager(agent.config.planning, agent.config.reflection);
|
|
41
|
+
}
|
|
42
|
+
// Observability
|
|
43
|
+
if (isFeatureEnabled(agent.config.observability)) {
|
|
44
|
+
agent.observability = new ObservabilityManager(agent.config.observability);
|
|
45
|
+
// Lesson 26: Full trace capture
|
|
46
|
+
const traceCaptureConfig = agent.config.observability.traceCapture;
|
|
47
|
+
if (traceCaptureConfig?.enabled) {
|
|
48
|
+
agent.traceCollector = createTraceCollector({
|
|
49
|
+
enabled: true,
|
|
50
|
+
outputDir: traceCaptureConfig.outputDir ?? '.traces',
|
|
51
|
+
captureMessageContent: traceCaptureConfig.captureMessageContent ?? true,
|
|
52
|
+
captureToolResults: traceCaptureConfig.captureToolResults ?? true,
|
|
53
|
+
analyzeCacheBoundaries: traceCaptureConfig.analyzeCacheBoundaries ?? true,
|
|
54
|
+
filePattern: traceCaptureConfig.filePattern ?? 'trace-{sessionId}-{timestamp}.jsonl',
|
|
55
|
+
enableConsoleOutput: false,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
// Safety (Sandbox + Human-in-Loop)
|
|
60
|
+
if (isFeatureEnabled(agent.config.sandbox) || isFeatureEnabled(agent.config.humanInLoop)) {
|
|
61
|
+
agent.safety = new SafetyManager(isFeatureEnabled(agent.config.sandbox) ? agent.config.sandbox : false, isFeatureEnabled(agent.config.humanInLoop) ? agent.config.humanInLoop : false, isFeatureEnabled(agent.config.policyEngine) ? agent.config.policyEngine : false);
|
|
62
|
+
}
|
|
63
|
+
if (isFeatureEnabled(agent.config.policyEngine)) {
|
|
64
|
+
const rootPolicy = resolvePolicyProfile({
|
|
65
|
+
policyEngine: agent.config.policyEngine,
|
|
66
|
+
sandboxConfig: isFeatureEnabled(agent.config.sandbox) ? agent.config.sandbox : undefined,
|
|
67
|
+
});
|
|
68
|
+
agent.emit({
|
|
69
|
+
type: 'policy.profile.resolved',
|
|
70
|
+
profile: rootPolicy.profileName,
|
|
71
|
+
context: 'root',
|
|
72
|
+
selectionSource: rootPolicy.metadata.selectionSource,
|
|
73
|
+
usedLegacyMappings: rootPolicy.metadata.usedLegacyMappings,
|
|
74
|
+
legacySources: rootPolicy.metadata.legacyMappingSources,
|
|
75
|
+
});
|
|
76
|
+
if (rootPolicy.metadata.usedLegacyMappings) {
|
|
77
|
+
agent.emit({
|
|
78
|
+
type: 'policy.legacy.fallback.used',
|
|
79
|
+
profile: rootPolicy.profileName,
|
|
80
|
+
sources: rootPolicy.metadata.legacyMappingSources,
|
|
81
|
+
warnings: rootPolicy.metadata.warnings,
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
// Routing
|
|
86
|
+
if (isFeatureEnabled(agent.config.routing)) {
|
|
87
|
+
agent.routing = new RoutingManager(agent.config.routing);
|
|
88
|
+
}
|
|
89
|
+
// Multi-Agent (Lesson 17)
|
|
90
|
+
if (isFeatureEnabled(agent.config.multiAgent)) {
|
|
91
|
+
const roles = (agent.config.multiAgent.roles || []).map((r) => ({
|
|
92
|
+
name: r.name,
|
|
93
|
+
description: r.description,
|
|
94
|
+
systemPrompt: r.systemPrompt,
|
|
95
|
+
capabilities: r.capabilities,
|
|
96
|
+
authority: r.authority,
|
|
97
|
+
model: r.model,
|
|
98
|
+
}));
|
|
99
|
+
agent.multiAgent = new MultiAgentManager(agent.provider, Array.from(agent.tools.values()), roles);
|
|
100
|
+
}
|
|
101
|
+
// ReAct (Lesson 18)
|
|
102
|
+
if (isFeatureEnabled(agent.config.react)) {
|
|
103
|
+
agent.react = new ReActManager(agent.provider, Array.from(agent.tools.values()), {
|
|
104
|
+
maxSteps: agent.config.react.maxSteps,
|
|
105
|
+
stopOnAnswer: agent.config.react.stopOnAnswer,
|
|
106
|
+
includeReasoning: agent.config.react.includeReasoning,
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
// Execution Policies (Lesson 23)
|
|
110
|
+
if (isFeatureEnabled(agent.config.executionPolicy)) {
|
|
111
|
+
agent.executionPolicy = new ExecutionPolicyManager({
|
|
112
|
+
defaultPolicy: agent.config.executionPolicy.defaultPolicy,
|
|
113
|
+
toolPolicies: agent.config.executionPolicy.toolPolicies,
|
|
114
|
+
intentAware: agent.config.executionPolicy.intentAware,
|
|
115
|
+
intentConfidenceThreshold: agent.config.executionPolicy.intentConfidenceThreshold,
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
// Thread Management (Lesson 24)
|
|
119
|
+
if (isFeatureEnabled(agent.config.threads)) {
|
|
120
|
+
agent.threadManager = new ThreadManager();
|
|
121
|
+
}
|
|
122
|
+
// Rules System (Lesson 12)
|
|
123
|
+
if (isFeatureEnabled(agent.config.rules)) {
|
|
124
|
+
const ruleSources = agent.config.rules.sources || DEFAULT_RULE_SOURCES;
|
|
125
|
+
agent.rules = new RulesManager({
|
|
126
|
+
enabled: true,
|
|
127
|
+
sources: ruleSources,
|
|
128
|
+
watch: agent.config.rules.watch,
|
|
129
|
+
});
|
|
130
|
+
// Load rules asynchronously - tracked for ensureReady()
|
|
131
|
+
agent.initPromises.push(agent.rules.loadRules().catch(err => {
|
|
132
|
+
log.warn('Failed to load rules', { error: String(err) });
|
|
133
|
+
}));
|
|
134
|
+
}
|
|
135
|
+
// Economics System (Token Budget) - always enabled
|
|
136
|
+
// Use custom budget if provided (subagents use SUBAGENT_BUDGET), otherwise STANDARD_BUDGET
|
|
137
|
+
const baseBudget = agent.config.budget ?? STANDARD_BUDGET;
|
|
138
|
+
agent.economics = new ExecutionEconomicsManager({
|
|
139
|
+
...baseBudget,
|
|
140
|
+
// Use maxIterations from config as absolute safety cap
|
|
141
|
+
maxIterations: agent.config.maxIterations,
|
|
142
|
+
targetIterations: Math.min(baseBudget.targetIterations ?? 20, agent.config.maxIterations),
|
|
143
|
+
}, agent._sharedEconomicsState ?? undefined, agent.agentId);
|
|
144
|
+
// Enable incremental token accounting for the root agent.
|
|
145
|
+
// Estimate baseline from system prompt size (~4 chars/token).
|
|
146
|
+
// This activates incremental mode in recordLLMUsage() so only marginal
|
|
147
|
+
// tokens per call are counted toward the budget, preventing quadratic growth.
|
|
148
|
+
const systemPromptLength = agent.config.systemPrompt?.length ?? 0;
|
|
149
|
+
const estimatedBaselineTokens = Math.ceil(systemPromptLength / 4);
|
|
150
|
+
if (estimatedBaselineTokens > 0) {
|
|
151
|
+
agent.economics.setBaseline(estimatedBaselineTokens);
|
|
152
|
+
}
|
|
153
|
+
// Phase 2.2: Agent State Machine - formalizes phase tracking
|
|
154
|
+
// Always enabled - provides structured phase transitions with metrics
|
|
155
|
+
agent.stateMachine = createAgentStateMachine();
|
|
156
|
+
// Forward state machine phase transitions as subagent.phase events
|
|
157
|
+
const phaseMap = {
|
|
158
|
+
exploring: 'exploring', planning: 'planning', acting: 'executing', verifying: 'completing',
|
|
159
|
+
};
|
|
160
|
+
const unsubStateMachine = agent.stateMachine.subscribe(event => {
|
|
161
|
+
if (event.type === 'phase.changed') {
|
|
162
|
+
agent.emit({
|
|
163
|
+
type: 'subagent.phase',
|
|
164
|
+
agentId: agent.agentId,
|
|
165
|
+
phase: phaseMap[event.transition.to] ?? 'exploring',
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
agent.unsubscribers.push(unsubStateMachine);
|
|
170
|
+
// Work Log - compaction-resilient summary of agent work
|
|
171
|
+
// Always enabled - minimal overhead and critical for long-running tasks
|
|
172
|
+
agent.workLog = createWorkLog();
|
|
173
|
+
// Verification Gate - opt-in completion verification
|
|
174
|
+
if (agent.config.verificationCriteria) {
|
|
175
|
+
agent.verificationGate = createVerificationGate(agent.config.verificationCriteria);
|
|
176
|
+
}
|
|
177
|
+
// TypeScript compilation checking — auto-detect and enable
|
|
178
|
+
{
|
|
179
|
+
const cwd = agent.config.workingDirectory || process.cwd();
|
|
180
|
+
const tcState = createTypeCheckerState(cwd);
|
|
181
|
+
agent.typeCheckerState = tcState;
|
|
182
|
+
if (tcState.tsconfigDir && !agent.verificationGate) {
|
|
183
|
+
agent.verificationGate = createVerificationGate({
|
|
184
|
+
requireCompilation: true,
|
|
185
|
+
compilationMaxAttempts: 8,
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
// Phase 2-4: Orchestration & Advanced modules (always enabled, lightweight)
|
|
190
|
+
agent.injectionBudget = createInjectionBudgetManager();
|
|
191
|
+
agent.selfImprovement = createSelfImprovementProtocol(undefined, agent.learningStore ?? undefined);
|
|
192
|
+
agent.subagentOutputStore = createSubagentOutputStore({ persistToFile: false });
|
|
193
|
+
agent.autoCheckpointManager = createAutoCheckpointManager({ enabled: true });
|
|
194
|
+
agent.toolRecommendation = createToolRecommendationEngine();
|
|
195
|
+
// Agent Registry - always enabled for subagent support
|
|
196
|
+
agent.agentRegistry = new AgentRegistry();
|
|
197
|
+
// Load user agents asynchronously - tracked for ensureReady()
|
|
198
|
+
agent.initPromises.push(agent.agentRegistry.loadUserAgents().catch(err => {
|
|
199
|
+
log.warn('Failed to load user agents', { error: String(err) });
|
|
200
|
+
}));
|
|
201
|
+
// Register spawn_agent tool so LLM can delegate to subagents
|
|
202
|
+
const boundSpawnTool = createBoundSpawnAgentTool((name, task, constraints) => agent.spawnAgent(name, task, constraints));
|
|
203
|
+
agent.tools.set(boundSpawnTool.name, boundSpawnTool);
|
|
204
|
+
// Register spawn_agents_parallel tool for parallel subagent execution
|
|
205
|
+
const boundParallelSpawnTool = createBoundSpawnAgentsParallelTool((tasks) => agent.spawnAgentsParallel(tasks));
|
|
206
|
+
agent.tools.set(boundParallelSpawnTool.name, boundParallelSpawnTool);
|
|
207
|
+
// Task Manager - Claude Code-style task system for coordination
|
|
208
|
+
agent.taskManager = createTaskManager();
|
|
209
|
+
// Forward task events (with cleanup tracking for EventEmitter-based managers)
|
|
210
|
+
const taskCreatedHandler = (data) => {
|
|
211
|
+
agent.emit({ type: 'task.created', task: data.task });
|
|
212
|
+
};
|
|
213
|
+
agent.taskManager.on('task.created', taskCreatedHandler);
|
|
214
|
+
agent.unsubscribers.push(() => agent.taskManager?.off('task.created', taskCreatedHandler));
|
|
215
|
+
const taskUpdatedHandler = (data) => {
|
|
216
|
+
agent.emit({ type: 'task.updated', task: data.task });
|
|
217
|
+
};
|
|
218
|
+
agent.taskManager.on('task.updated', taskUpdatedHandler);
|
|
219
|
+
agent.unsubscribers.push(() => agent.taskManager?.off('task.updated', taskUpdatedHandler));
|
|
220
|
+
// Register task tools
|
|
221
|
+
const taskTools = createTaskTools(agent.taskManager);
|
|
222
|
+
for (const tool of taskTools) {
|
|
223
|
+
agent.tools.set(tool.name, tool);
|
|
224
|
+
}
|
|
225
|
+
// Built-in web search (Serper API) — gracefully handles missing API key
|
|
226
|
+
const serperCustomTool = createSerperSearchTool();
|
|
227
|
+
agent.tools.set('web_search', {
|
|
228
|
+
name: serperCustomTool.name,
|
|
229
|
+
description: serperCustomTool.description,
|
|
230
|
+
parameters: serperCustomTool.inputSchema,
|
|
231
|
+
execute: serperCustomTool.execute,
|
|
232
|
+
dangerLevel: 'safe',
|
|
233
|
+
});
|
|
234
|
+
// Swarm Mode (experimental)
|
|
235
|
+
if (agent.config.swarm) {
|
|
236
|
+
const swarmConfig = agent.config.swarm;
|
|
237
|
+
// Wrap provider with request throttle to prevent 429 rate limiting.
|
|
238
|
+
// All subagents share agent.provider by reference (line 4398),
|
|
239
|
+
// so wrapping here throttles ALL downstream LLM calls.
|
|
240
|
+
if (swarmConfig.throttle !== false) {
|
|
241
|
+
const throttleConfig = swarmConfig.throttle === 'paid'
|
|
242
|
+
? PAID_TIER_THROTTLE
|
|
243
|
+
: swarmConfig.throttle === 'free' || swarmConfig.throttle === undefined
|
|
244
|
+
? FREE_TIER_THROTTLE
|
|
245
|
+
: swarmConfig.throttle;
|
|
246
|
+
agent.provider = createThrottledProvider(agent.provider, throttleConfig);
|
|
247
|
+
}
|
|
248
|
+
// Pass codebaseContext so the decomposer can ground tasks in actual project files
|
|
249
|
+
swarmConfig.codebaseContext = agent.codebaseContext ?? undefined;
|
|
250
|
+
agent.swarmOrchestrator = createSwarmOrchestrator(swarmConfig, agent.provider, agent.agentRegistry, (name, task) => agent.spawnAgent(name, task), agent.blackboard ?? undefined);
|
|
251
|
+
// Override parent budget pool with swarm's much larger pool so spawnAgent()
|
|
252
|
+
// allocates from the swarm budget (e.g. 10M tokens) instead of the parent's
|
|
253
|
+
// generic pool (200K tokens). Without this, workers get 5K emergency budget.
|
|
254
|
+
agent.budgetPool = agent.swarmOrchestrator.getBudgetPool().pool;
|
|
255
|
+
// Phase 3.1+3.2: Set shared state so workers inherit it via buildContext()
|
|
256
|
+
agent._sharedContextState = agent.swarmOrchestrator.getSharedContextState();
|
|
257
|
+
agent._sharedEconomicsState = agent.swarmOrchestrator.getSharedEconomicsState();
|
|
258
|
+
}
|
|
259
|
+
// Cancellation Support
|
|
260
|
+
if (isFeatureEnabled(agent.config.cancellation)) {
|
|
261
|
+
agent.cancellation = createCancellationManager();
|
|
262
|
+
// Forward cancellation events (with cleanup tracking)
|
|
263
|
+
const unsubCancellation = agent.cancellation.subscribe(event => {
|
|
264
|
+
if (event.type === 'cancellation.requested') {
|
|
265
|
+
agent.emit({ type: 'cancellation.requested', reason: event.reason });
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
agent.unsubscribers.push(unsubCancellation);
|
|
269
|
+
}
|
|
270
|
+
// Resource Monitoring
|
|
271
|
+
if (isFeatureEnabled(agent.config.resources)) {
|
|
272
|
+
agent.resourceManager = createResourceManager({
|
|
273
|
+
enabled: agent.config.resources.enabled,
|
|
274
|
+
maxMemoryMB: agent.config.resources.maxMemoryMB,
|
|
275
|
+
maxCpuTimeSec: agent.config.resources.maxCpuTimeSec,
|
|
276
|
+
maxConcurrentOps: agent.config.resources.maxConcurrentOps,
|
|
277
|
+
warnThreshold: agent.config.resources.warnThreshold,
|
|
278
|
+
criticalThreshold: agent.config.resources.criticalThreshold,
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
// LSP (Language Server Protocol) Support
|
|
282
|
+
if (isFeatureEnabled(agent.config.lsp)) {
|
|
283
|
+
agent.lspManager = createLSPManager({
|
|
284
|
+
enabled: agent.config.lsp.enabled,
|
|
285
|
+
autoDetect: agent.config.lsp.autoDetect,
|
|
286
|
+
servers: agent.config.lsp.servers,
|
|
287
|
+
timeout: agent.config.lsp.timeout,
|
|
288
|
+
});
|
|
289
|
+
// Auto-start is done lazily on first use to avoid startup delays
|
|
290
|
+
}
|
|
291
|
+
// Semantic Cache Support
|
|
292
|
+
if (isFeatureEnabled(agent.config.semanticCache)) {
|
|
293
|
+
agent.semanticCache = createSemanticCacheManager({
|
|
294
|
+
enabled: agent.config.semanticCache.enabled,
|
|
295
|
+
threshold: agent.config.semanticCache.threshold,
|
|
296
|
+
maxSize: agent.config.semanticCache.maxSize,
|
|
297
|
+
ttl: agent.config.semanticCache.ttl,
|
|
298
|
+
});
|
|
299
|
+
// Forward cache events (with cleanup tracking)
|
|
300
|
+
const unsubSemanticCache = agent.semanticCache.subscribe(event => {
|
|
301
|
+
if (event.type === 'cache.hit') {
|
|
302
|
+
agent.emit({ type: 'cache.hit', query: event.query, similarity: event.similarity });
|
|
303
|
+
}
|
|
304
|
+
else if (event.type === 'cache.miss') {
|
|
305
|
+
agent.emit({ type: 'cache.miss', query: event.query });
|
|
306
|
+
}
|
|
307
|
+
else if (event.type === 'cache.set') {
|
|
308
|
+
agent.emit({ type: 'cache.set', query: event.query });
|
|
309
|
+
}
|
|
310
|
+
});
|
|
311
|
+
agent.unsubscribers.push(unsubSemanticCache);
|
|
312
|
+
}
|
|
313
|
+
// Skills Support
|
|
314
|
+
if (isFeatureEnabled(agent.config.skills)) {
|
|
315
|
+
agent.skillManager = createSkillManager({
|
|
316
|
+
enabled: agent.config.skills.enabled,
|
|
317
|
+
directories: agent.config.skills.directories,
|
|
318
|
+
loadBuiltIn: agent.config.skills.loadBuiltIn,
|
|
319
|
+
autoActivate: agent.config.skills.autoActivate,
|
|
320
|
+
});
|
|
321
|
+
// Load skills asynchronously - tracked for ensureReady()
|
|
322
|
+
agent.initPromises.push(agent.skillManager.loadSkills()
|
|
323
|
+
.then(() => { }) // Convert to void
|
|
324
|
+
.catch(err => {
|
|
325
|
+
log.warn('Failed to load skills', { error: String(err) });
|
|
326
|
+
}));
|
|
327
|
+
}
|
|
328
|
+
// Context Engineering (Manus-inspired tricks P, Q, R, S, T)
|
|
329
|
+
// Always enabled - these are performance optimizations
|
|
330
|
+
agent.contextEngineering = createContextEngineering({
|
|
331
|
+
enableCacheOptimization: true,
|
|
332
|
+
enableRecitation: true,
|
|
333
|
+
enableReversibleCompaction: true,
|
|
334
|
+
enableFailureTracking: true,
|
|
335
|
+
enableDiversity: false, // Off by default - can cause unexpected behavior
|
|
336
|
+
staticPrefix: agent.config.systemPrompt,
|
|
337
|
+
recitationFrequency: 5,
|
|
338
|
+
maxFailures: 30,
|
|
339
|
+
maxReferences: 50,
|
|
340
|
+
});
|
|
341
|
+
// Bind shared context state for cross-worker failure learning (swarm workers only)
|
|
342
|
+
if (agent._sharedContextState) {
|
|
343
|
+
agent.contextEngineering.setSharedState(agent._sharedContextState);
|
|
344
|
+
}
|
|
345
|
+
// Codebase Context - intelligent code selection for context management
|
|
346
|
+
// Analyzes repo structure and selects relevant code within token budgets
|
|
347
|
+
if (agent.config.codebaseContext !== false) {
|
|
348
|
+
const codebaseConfig = typeof agent.config.codebaseContext === 'object'
|
|
349
|
+
? agent.config.codebaseContext
|
|
350
|
+
: {};
|
|
351
|
+
agent.codebaseContext = createCodebaseContext({
|
|
352
|
+
root: codebaseConfig.root ?? process.cwd(),
|
|
353
|
+
includePatterns: codebaseConfig.includePatterns,
|
|
354
|
+
excludePatterns: codebaseConfig.excludePatterns,
|
|
355
|
+
maxFileSize: codebaseConfig.maxFileSize ?? 100 * 1024, // 100KB
|
|
356
|
+
tokensPerChar: 0.25,
|
|
357
|
+
analyzeDependencies: true,
|
|
358
|
+
cacheResults: true,
|
|
359
|
+
cacheTTL: 5 * 60 * 1000, // 5 minutes
|
|
360
|
+
});
|
|
361
|
+
// Forward trace collector so codebase analysis can emit codebase.map entries.
|
|
362
|
+
if (agent.traceCollector) {
|
|
363
|
+
agent.codebaseContext.traceCollector = agent.traceCollector;
|
|
364
|
+
}
|
|
365
|
+
// Connect LSP manager to codebase context for enhanced code selection
|
|
366
|
+
// This enables LSP-based relevance boosting (Phase 4.1)
|
|
367
|
+
if (agent.lspManager) {
|
|
368
|
+
agent.codebaseContext.setLSPManager(agent.lspManager);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
// Forward context engineering events (with cleanup tracking)
|
|
372
|
+
const unsubContextEngineering = agent.contextEngineering.on(event => {
|
|
373
|
+
switch (event.type) {
|
|
374
|
+
case 'failure.recorded':
|
|
375
|
+
agent.observability?.logger?.warn('Failure recorded', {
|
|
376
|
+
action: event.failure.action,
|
|
377
|
+
category: event.failure.category,
|
|
378
|
+
});
|
|
379
|
+
break;
|
|
380
|
+
case 'failure.pattern':
|
|
381
|
+
agent.observability?.logger?.warn('Failure pattern detected', {
|
|
382
|
+
type: event.pattern.type,
|
|
383
|
+
description: event.pattern.description,
|
|
384
|
+
});
|
|
385
|
+
agent.emit({ type: 'error', error: `Pattern: ${event.pattern.description}` });
|
|
386
|
+
break;
|
|
387
|
+
case 'recitation.injected':
|
|
388
|
+
agent.observability?.logger?.debug('Recitation injected', {
|
|
389
|
+
iteration: event.iteration,
|
|
390
|
+
});
|
|
391
|
+
break;
|
|
392
|
+
}
|
|
393
|
+
});
|
|
394
|
+
agent.unsubscribers.push(unsubContextEngineering);
|
|
395
|
+
// Interactive Planning (conversational + editable planning)
|
|
396
|
+
if (isFeatureEnabled(agent.config.interactivePlanning)) {
|
|
397
|
+
const interactiveConfig = typeof agent.config.interactivePlanning === 'object'
|
|
398
|
+
? agent.config.interactivePlanning
|
|
399
|
+
: {};
|
|
400
|
+
agent.interactivePlanner = createInteractivePlanner({
|
|
401
|
+
autoCheckpoint: interactiveConfig.enableCheckpoints ?? true,
|
|
402
|
+
confirmBeforeExecute: interactiveConfig.requireApproval ?? true,
|
|
403
|
+
maxCheckpoints: 20,
|
|
404
|
+
autoPauseAtDecisions: true,
|
|
405
|
+
});
|
|
406
|
+
// Forward planner events to observability (with cleanup tracking)
|
|
407
|
+
const unsubInteractivePlanner = agent.interactivePlanner.on(event => {
|
|
408
|
+
switch (event.type) {
|
|
409
|
+
case 'plan.created':
|
|
410
|
+
agent.observability?.logger?.info('Interactive plan created', {
|
|
411
|
+
planId: event.plan.id,
|
|
412
|
+
stepCount: event.plan.steps.length,
|
|
413
|
+
});
|
|
414
|
+
break;
|
|
415
|
+
case 'step.completed':
|
|
416
|
+
agent.observability?.logger?.debug('Plan step completed', {
|
|
417
|
+
stepId: event.step.id,
|
|
418
|
+
status: event.step.status,
|
|
419
|
+
});
|
|
420
|
+
break;
|
|
421
|
+
case 'plan.cancelled':
|
|
422
|
+
agent.observability?.logger?.info('Plan cancelled', { reason: event.reason });
|
|
423
|
+
break;
|
|
424
|
+
case 'checkpoint.created':
|
|
425
|
+
agent.observability?.logger?.debug('Plan checkpoint created', {
|
|
426
|
+
checkpointId: event.checkpoint.id,
|
|
427
|
+
});
|
|
428
|
+
break;
|
|
429
|
+
}
|
|
430
|
+
});
|
|
431
|
+
agent.unsubscribers.push(unsubInteractivePlanner);
|
|
432
|
+
}
|
|
433
|
+
// Recursive Context (RLM - Recursive Language Models)
|
|
434
|
+
// Enables on-demand context exploration for large codebases
|
|
435
|
+
if (isFeatureEnabled(agent.config.recursiveContext)) {
|
|
436
|
+
const recursiveConfig = typeof agent.config.recursiveContext === 'object'
|
|
437
|
+
? agent.config.recursiveContext
|
|
438
|
+
: {};
|
|
439
|
+
agent.recursiveContext = createRecursiveContext({
|
|
440
|
+
maxDepth: recursiveConfig.maxRecursionDepth ?? 5,
|
|
441
|
+
snippetTokens: recursiveConfig.maxSnippetTokens ?? 2000,
|
|
442
|
+
synthesisTokens: 1000,
|
|
443
|
+
totalBudget: 50000,
|
|
444
|
+
cacheResults: recursiveConfig.cacheNavigationResults ?? true,
|
|
445
|
+
});
|
|
446
|
+
// Note: File system source should be registered when needed with proper glob/readFile functions
|
|
447
|
+
// This is deferred to allow flexible configuration
|
|
448
|
+
// Forward RLM events (with cleanup tracking)
|
|
449
|
+
const unsubRecursiveContext = agent.recursiveContext.on(event => {
|
|
450
|
+
switch (event.type) {
|
|
451
|
+
case 'process.started':
|
|
452
|
+
agent.observability?.logger?.debug('RLM process started', {
|
|
453
|
+
query: event.query,
|
|
454
|
+
depth: event.depth,
|
|
455
|
+
});
|
|
456
|
+
break;
|
|
457
|
+
case 'navigation.command':
|
|
458
|
+
agent.observability?.logger?.debug('RLM navigation command', {
|
|
459
|
+
command: event.command,
|
|
460
|
+
depth: event.depth,
|
|
461
|
+
});
|
|
462
|
+
break;
|
|
463
|
+
case 'process.completed':
|
|
464
|
+
agent.observability?.logger?.debug('RLM process completed', {
|
|
465
|
+
stats: event.stats,
|
|
466
|
+
});
|
|
467
|
+
break;
|
|
468
|
+
case 'budget.warning':
|
|
469
|
+
agent.observability?.logger?.warn('RLM budget warning', {
|
|
470
|
+
remaining: event.remaining,
|
|
471
|
+
total: event.total,
|
|
472
|
+
});
|
|
473
|
+
break;
|
|
474
|
+
}
|
|
475
|
+
});
|
|
476
|
+
agent.unsubscribers.push(unsubRecursiveContext);
|
|
477
|
+
}
|
|
478
|
+
// Learning Store (cross-session learning from failures)
|
|
479
|
+
// Connects to the failure tracker in contextEngineering for automatic learning extraction
|
|
480
|
+
if (isFeatureEnabled(agent.config.learningStore)) {
|
|
481
|
+
const learningConfig = typeof agent.config.learningStore === 'object'
|
|
482
|
+
? agent.config.learningStore
|
|
483
|
+
: {};
|
|
484
|
+
agent.learningStore = createLearningStore({
|
|
485
|
+
dbPath: learningConfig.dbPath ?? '.agent/learnings.db',
|
|
486
|
+
requireValidation: learningConfig.requireValidation ?? true,
|
|
487
|
+
autoValidateThreshold: learningConfig.autoValidateThreshold ?? 0.9,
|
|
488
|
+
maxLearnings: learningConfig.maxLearnings ?? 500,
|
|
489
|
+
});
|
|
490
|
+
// Connect to the failure tracker if available
|
|
491
|
+
if (agent.contextEngineering) {
|
|
492
|
+
const failureTracker = agent.contextEngineering.getFailureTracker();
|
|
493
|
+
if (failureTracker) {
|
|
494
|
+
agent.learningStore.connectFailureTracker(failureTracker);
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
// Forward learning events to observability (with cleanup tracking)
|
|
498
|
+
const unsubLearningStore = agent.learningStore.on(event => {
|
|
499
|
+
switch (event.type) {
|
|
500
|
+
case 'learning.proposed':
|
|
501
|
+
agent.observability?.logger?.info('Learning proposed', {
|
|
502
|
+
learningId: event.learning.id,
|
|
503
|
+
description: event.learning.description,
|
|
504
|
+
});
|
|
505
|
+
agent.emit({
|
|
506
|
+
type: 'learning.proposed',
|
|
507
|
+
learningId: event.learning.id,
|
|
508
|
+
description: event.learning.description,
|
|
509
|
+
});
|
|
510
|
+
break;
|
|
511
|
+
case 'learning.validated':
|
|
512
|
+
agent.observability?.logger?.info('Learning validated', {
|
|
513
|
+
learningId: event.learningId,
|
|
514
|
+
});
|
|
515
|
+
agent.emit({ type: 'learning.validated', learningId: event.learningId });
|
|
516
|
+
break;
|
|
517
|
+
case 'learning.applied':
|
|
518
|
+
agent.observability?.logger?.debug('Learning applied', {
|
|
519
|
+
learningId: event.learningId,
|
|
520
|
+
context: event.context,
|
|
521
|
+
});
|
|
522
|
+
agent.emit({
|
|
523
|
+
type: 'learning.applied',
|
|
524
|
+
learningId: event.learningId,
|
|
525
|
+
context: event.context,
|
|
526
|
+
});
|
|
527
|
+
break;
|
|
528
|
+
case 'pattern.extracted':
|
|
529
|
+
agent.observability?.logger?.info('Pattern extracted as learning', {
|
|
530
|
+
pattern: event.pattern.description,
|
|
531
|
+
learningId: event.learning.id,
|
|
532
|
+
});
|
|
533
|
+
break;
|
|
534
|
+
}
|
|
535
|
+
});
|
|
536
|
+
agent.unsubscribers.push(unsubLearningStore);
|
|
537
|
+
}
|
|
538
|
+
// Auto-Compaction Manager (sophisticated context compaction)
|
|
539
|
+
// Uses the Compactor for LLM-based summarization with threshold monitoring
|
|
540
|
+
if (isFeatureEnabled(agent.config.compaction)) {
|
|
541
|
+
const compactionConfig = typeof agent.config.compaction === 'object'
|
|
542
|
+
? agent.config.compaction
|
|
543
|
+
: {};
|
|
544
|
+
// Create the compactor (requires provider for LLM summarization)
|
|
545
|
+
agent.compactor = createCompactor(agent.provider, {
|
|
546
|
+
enabled: true,
|
|
547
|
+
tokenThreshold: compactionConfig.tokenThreshold ?? 80000,
|
|
548
|
+
preserveRecentCount: compactionConfig.preserveRecentCount ?? 10,
|
|
549
|
+
preserveToolResults: compactionConfig.preserveToolResults ?? true,
|
|
550
|
+
summaryMaxTokens: compactionConfig.summaryMaxTokens ?? 2000,
|
|
551
|
+
summaryModel: compactionConfig.summaryModel,
|
|
552
|
+
});
|
|
553
|
+
// Create the auto-compaction manager with threshold monitoring
|
|
554
|
+
// Wire reversible compaction through contextEngineering when available
|
|
555
|
+
const compactHandler = agent.contextEngineering
|
|
556
|
+
? async (messages) => {
|
|
557
|
+
// Use contextEngineering's reversible compaction to preserve references
|
|
558
|
+
const summarize = async (msgs) => {
|
|
559
|
+
// Use the basic compactor's summarization capability
|
|
560
|
+
const result = await agent.compactor.compact(msgs);
|
|
561
|
+
return result.summary;
|
|
562
|
+
};
|
|
563
|
+
const contextMsgs = messages.map(m => ({
|
|
564
|
+
role: m.role,
|
|
565
|
+
content: typeof m.content === 'string' ? m.content : JSON.stringify(m.content),
|
|
566
|
+
}));
|
|
567
|
+
const result = await agent.contextEngineering.compact(contextMsgs, summarize);
|
|
568
|
+
const tokensBefore = agent.compactor.estimateTokens(messages);
|
|
569
|
+
const tokensAfter = agent.compactor.estimateTokens([{ role: 'assistant', content: result.summary }]);
|
|
570
|
+
return {
|
|
571
|
+
summary: result.summary + (result.reconstructionPrompt ? `\n\n${result.reconstructionPrompt}` : ''),
|
|
572
|
+
tokensBefore,
|
|
573
|
+
tokensAfter,
|
|
574
|
+
preservedMessages: [{ role: 'assistant', content: result.summary }],
|
|
575
|
+
references: result.references,
|
|
576
|
+
};
|
|
577
|
+
}
|
|
578
|
+
: undefined;
|
|
579
|
+
// Get model's actual context window - try OpenRouter first (real API data),
|
|
580
|
+
// then fall back to hardcoded ModelRegistry, then config, then default
|
|
581
|
+
const openRouterContext = getModelContextLength(agent.config.model || '');
|
|
582
|
+
const registryInfo = modelRegistry.getModel(agent.config.model || '');
|
|
583
|
+
const registryContext = registryInfo?.capabilities?.maxContextTokens;
|
|
584
|
+
const maxContextTokens = agent.config.maxContextTokens
|
|
585
|
+
?? openRouterContext // From OpenRouter API (e.g., GLM-4.7 = 202752)
|
|
586
|
+
?? registryContext // From hardcoded registry (Claude, GPT-4o, etc.)
|
|
587
|
+
?? 200000; // Fallback to 200K
|
|
588
|
+
agent.autoCompactionManager = createAutoCompactionManager(agent.compactor, {
|
|
589
|
+
mode: compactionConfig.mode ?? 'auto',
|
|
590
|
+
warningThreshold: 0.70, // Warn at 70% of model's context
|
|
591
|
+
autoCompactThreshold: 0.80, // Compact at 80% (changed from 0.90)
|
|
592
|
+
hardLimitThreshold: 0.95, // Hard limit at 95%
|
|
593
|
+
preserveRecentUserMessages: Math.ceil((compactionConfig.preserveRecentCount ?? 10) / 2),
|
|
594
|
+
preserveRecentAssistantMessages: Math.ceil((compactionConfig.preserveRecentCount ?? 10) / 2),
|
|
595
|
+
cooldownMs: 60000, // 1 minute cooldown
|
|
596
|
+
maxContextTokens, // Dynamic from model registry or config
|
|
597
|
+
compactHandler, // Use reversible compaction when contextEngineering is available
|
|
598
|
+
});
|
|
599
|
+
// Forward compactor events to observability (with cleanup tracking)
|
|
600
|
+
const unsubCompactor = agent.compactor.on(event => {
|
|
601
|
+
switch (event.type) {
|
|
602
|
+
case 'compaction.start':
|
|
603
|
+
agent.observability?.logger?.info('Compaction started', {
|
|
604
|
+
messageCount: event.messageCount,
|
|
605
|
+
});
|
|
606
|
+
break;
|
|
607
|
+
case 'compaction.complete':
|
|
608
|
+
agent.observability?.logger?.info('Compaction complete', {
|
|
609
|
+
tokensBefore: event.result.tokensBefore,
|
|
610
|
+
tokensAfter: event.result.tokensAfter,
|
|
611
|
+
compactedCount: event.result.compactedCount,
|
|
612
|
+
});
|
|
613
|
+
break;
|
|
614
|
+
case 'compaction.error':
|
|
615
|
+
agent.observability?.logger?.error('Compaction error', {
|
|
616
|
+
error: event.error,
|
|
617
|
+
});
|
|
618
|
+
break;
|
|
619
|
+
}
|
|
620
|
+
});
|
|
621
|
+
agent.unsubscribers.push(unsubCompactor);
|
|
622
|
+
// Forward auto-compaction events (with cleanup tracking)
|
|
623
|
+
const unsubAutoCompaction = agent.autoCompactionManager.on((event) => {
|
|
624
|
+
switch (event.type) {
|
|
625
|
+
case 'autocompaction.warning':
|
|
626
|
+
agent.observability?.logger?.warn('Context approaching limit', {
|
|
627
|
+
currentTokens: event.currentTokens,
|
|
628
|
+
ratio: event.ratio,
|
|
629
|
+
});
|
|
630
|
+
agent.emit({
|
|
631
|
+
type: 'compaction.warning',
|
|
632
|
+
currentTokens: event.currentTokens,
|
|
633
|
+
threshold: Math.round(event.ratio * (agent.config.maxContextTokens ?? 200000)),
|
|
634
|
+
});
|
|
635
|
+
break;
|
|
636
|
+
case 'autocompaction.triggered':
|
|
637
|
+
agent.observability?.logger?.info('Auto-compaction triggered', {
|
|
638
|
+
mode: event.mode,
|
|
639
|
+
currentTokens: event.currentTokens,
|
|
640
|
+
});
|
|
641
|
+
break;
|
|
642
|
+
case 'autocompaction.completed':
|
|
643
|
+
agent.observability?.logger?.info('Auto-compaction completed', {
|
|
644
|
+
tokensBefore: event.tokensBefore,
|
|
645
|
+
tokensAfter: event.tokensAfter,
|
|
646
|
+
reduction: event.reduction,
|
|
647
|
+
});
|
|
648
|
+
agent.emit({
|
|
649
|
+
type: 'compaction.auto',
|
|
650
|
+
tokensBefore: event.tokensBefore,
|
|
651
|
+
tokensAfter: event.tokensAfter,
|
|
652
|
+
messagesCompacted: event.tokensBefore - event.tokensAfter,
|
|
653
|
+
});
|
|
654
|
+
break;
|
|
655
|
+
case 'autocompaction.hard_limit':
|
|
656
|
+
agent.observability?.logger?.error('Context hard limit reached', {
|
|
657
|
+
currentTokens: event.currentTokens,
|
|
658
|
+
ratio: event.ratio,
|
|
659
|
+
});
|
|
660
|
+
break;
|
|
661
|
+
case 'autocompaction.emergency_truncate':
|
|
662
|
+
agent.observability?.logger?.warn('Emergency truncation performed', {
|
|
663
|
+
reason: event.reason,
|
|
664
|
+
messagesBefore: event.messagesBefore,
|
|
665
|
+
messagesAfter: event.messagesAfter,
|
|
666
|
+
});
|
|
667
|
+
break;
|
|
668
|
+
}
|
|
669
|
+
});
|
|
670
|
+
agent.unsubscribers.push(unsubAutoCompaction);
|
|
671
|
+
}
|
|
672
|
+
// Note: FileChangeTracker requires a database instance which is not
|
|
673
|
+
// available at this point. Use initFileChangeTracker() to enable it
|
|
674
|
+
// after the agent is constructed with a database reference.
|
|
675
|
+
// This allows the feature to be optional and not require SQLite at all times.
|
|
676
|
+
}
|
|
677
|
+
//# sourceMappingURL=feature-initializer.js.map
|