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,287 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loop Detector - Doom loop and pattern detection for the economics system.
|
|
3
|
+
*
|
|
4
|
+
* Extracted from economics.ts (Phase 3b restructuring).
|
|
5
|
+
*
|
|
6
|
+
* Handles:
|
|
7
|
+
* - Exact and fuzzy doom loop detection (same tool+args repeated)
|
|
8
|
+
* - Bash file-read normalization (cat/head/tail targeting same file)
|
|
9
|
+
* - Structural fingerprinting for near-identical calls
|
|
10
|
+
* - Test-fix cycle detection
|
|
11
|
+
* - Bash failure cascade detection
|
|
12
|
+
* - Summary loop detection (consecutive text-only turns)
|
|
13
|
+
*/
|
|
14
|
+
import { stableStringify } from '../context/context-engineering.js';
|
|
15
|
+
// =============================================================================
|
|
16
|
+
// CONSTANTS
|
|
17
|
+
// =============================================================================
|
|
18
|
+
/**
|
|
19
|
+
* Regex for common bash file-read commands (simple, no pipes/redirects).
|
|
20
|
+
* Captures the file path for normalized doom loop fingerprinting.
|
|
21
|
+
*/
|
|
22
|
+
const BASH_FILE_READ_RE = /^\s*(cat|head|tail|wc|less|more|file|stat|md5sum|sha256sum)\b(?:\s+-[^\s]+)*\s+((?:\/|\.\/|\.\.\/)[\w.\/\-@]+|[\w.\-@][\w.\/\-@]*)\s*$/;
|
|
23
|
+
/** Detect bash commands that are doing file write operations (write/append/redirect/heredoc). */
|
|
24
|
+
const BASH_FILE_WRITE_RE = /^\s*(cat|echo|printf)\b.*(?:>>?|<<)\s*/;
|
|
25
|
+
/**
|
|
26
|
+
* Primary argument keys that identify the *target* of a tool call.
|
|
27
|
+
* Used for fuzzy doom loop detection -- ignoring secondary/optional args.
|
|
28
|
+
*/
|
|
29
|
+
const PRIMARY_KEYS = ['path', 'file_path', 'command', 'pattern', 'query', 'url', 'content', 'filename', 'offset', 'limit'];
|
|
30
|
+
// =============================================================================
|
|
31
|
+
// PROMPT TEMPLATES
|
|
32
|
+
// =============================================================================
|
|
33
|
+
/**
|
|
34
|
+
* Doom loop prompt - injected when same tool called repeatedly.
|
|
35
|
+
*/
|
|
36
|
+
export const DOOM_LOOP_PROMPT = (tool, count) => {
|
|
37
|
+
if (count >= 6) {
|
|
38
|
+
return `[System] CRITICAL: You've called ${tool} with the same arguments ${count} times. You are in a doom loop. You MUST:
|
|
39
|
+
1. STOP calling ${tool} immediately
|
|
40
|
+
2. Explain what you're stuck on
|
|
41
|
+
3. Try a completely different approach
|
|
42
|
+
Further identical calls will be rejected.`;
|
|
43
|
+
}
|
|
44
|
+
if (count >= 4) {
|
|
45
|
+
return `[System] WARNING: You've called ${tool} ${count} times with identical arguments. This is a stuck state.
|
|
46
|
+
1. Try a DIFFERENT approach or tool
|
|
47
|
+
2. If blocked, explain the blocker`;
|
|
48
|
+
}
|
|
49
|
+
return `[System] You've called ${tool} with the same arguments ${count} times. This indicates a stuck state. Either:
|
|
50
|
+
1. Try a DIFFERENT approach or tool
|
|
51
|
+
2. If blocked, explain what's preventing progress
|
|
52
|
+
3. If the task is complete, say so explicitly`;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Global doom loop prompt - injected when the same tool call is repeated across multiple workers.
|
|
56
|
+
*/
|
|
57
|
+
export const GLOBAL_DOOM_LOOP_PROMPT = (tool, workerCount, totalCalls) => `[System] GLOBAL DOOM LOOP: ${totalCalls} calls to ${tool} across ${workerCount} workers. The entire swarm is stuck on this approach.
|
|
58
|
+
1. Try a fundamentally different strategy
|
|
59
|
+
2. Do NOT retry the same tool/parameters
|
|
60
|
+
3. Consider whether the task goal itself needs re-evaluation`;
|
|
61
|
+
/**
|
|
62
|
+
* Test-fix rethink prompt - injected after consecutive test failures.
|
|
63
|
+
*/
|
|
64
|
+
export const TEST_FIX_RETHINK_PROMPT = (failures) => `[System] You've had ${failures} consecutive test failures. Step back and rethink:
|
|
65
|
+
1. Re-read the error messages carefully
|
|
66
|
+
2. Consider whether your approach is fundamentally wrong
|
|
67
|
+
3. Try a DIFFERENT fix strategy instead of iterating on the same one
|
|
68
|
+
Do not retry the same fix. Try a new approach.`;
|
|
69
|
+
/** Check whether a bash command is attempting file operations that should use dedicated tools. */
|
|
70
|
+
export function isBashFileOperation(command) {
|
|
71
|
+
return BASH_FILE_READ_RE.test(command) || BASH_FILE_WRITE_RE.test(command) || /heredoc|EOF/i.test(command);
|
|
72
|
+
}
|
|
73
|
+
export const BASH_FAILURE_CASCADE_PROMPT = (failures, lastCommand) => {
|
|
74
|
+
const isFileOp = lastCommand && isBashFileOperation(lastCommand);
|
|
75
|
+
if (isFileOp) {
|
|
76
|
+
return `[System] ${failures} consecutive bash commands have failed trying to do file operations.
|
|
77
|
+
STOP using bash for file operations. Use the correct tool:
|
|
78
|
+
- To CREATE a file: write_file (not cat/echo with redirect)
|
|
79
|
+
- To MODIFY a file: edit_file (not sed/awk)
|
|
80
|
+
- To READ a file: read_file (not cat/head/tail)
|
|
81
|
+
Switch to the correct tool NOW.`;
|
|
82
|
+
}
|
|
83
|
+
return `[System] ${failures} consecutive bash commands have failed. STOP and:
|
|
84
|
+
1. Explain what you're trying to accomplish
|
|
85
|
+
2. Try a DIFFERENT approach or tool
|
|
86
|
+
3. Do not run another bash command with the same pattern`;
|
|
87
|
+
};
|
|
88
|
+
export const SUMMARY_LOOP_PROMPT = `[System] You've produced text-only responses without using tools. You should be DOING work, not summarizing it.
|
|
89
|
+
Pick the most important remaining task and start working on it NOW using your tools (write_file, edit_file, bash, etc.).
|
|
90
|
+
Do NOT output another status summary or task list.`;
|
|
91
|
+
// =============================================================================
|
|
92
|
+
// HELPER FUNCTIONS (exported for external use)
|
|
93
|
+
// =============================================================================
|
|
94
|
+
/**
|
|
95
|
+
* Extract success and output from a bash tool result.
|
|
96
|
+
* In production, bash results are objects `{ success, output, metadata }`.
|
|
97
|
+
* Tests may pass strings directly. This normalizes both.
|
|
98
|
+
*/
|
|
99
|
+
export function extractBashResult(result) {
|
|
100
|
+
if (result && typeof result === 'object') {
|
|
101
|
+
const obj = result;
|
|
102
|
+
return {
|
|
103
|
+
success: obj.success !== false,
|
|
104
|
+
output: typeof obj.output === 'string' ? obj.output : '',
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
if (typeof result === 'string') {
|
|
108
|
+
return { success: true, output: result };
|
|
109
|
+
}
|
|
110
|
+
return { success: true, output: '' };
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Extract the file target from a simple bash file-read command.
|
|
114
|
+
* Returns null for complex commands (pipes, redirects, non-file-read commands).
|
|
115
|
+
* Used to normalize doom loop fingerprints across cat/head/tail/wc targeting the same file.
|
|
116
|
+
*/
|
|
117
|
+
export function extractBashFileTarget(command) {
|
|
118
|
+
if (/[|;&<>]/.test(command))
|
|
119
|
+
return null; // pipes/redirects = complex, skip
|
|
120
|
+
const match = command.match(BASH_FILE_READ_RE);
|
|
121
|
+
return match ? match[2] : null;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Compute a structural fingerprint for a tool call.
|
|
125
|
+
* Extracts only the primary argument (path, command, pattern, query) and ignores
|
|
126
|
+
* secondary arguments (encoding, timeout, flags). This catches near-identical calls
|
|
127
|
+
* that differ only in optional parameters.
|
|
128
|
+
*/
|
|
129
|
+
export function computeToolFingerprint(toolName, argsStr) {
|
|
130
|
+
try {
|
|
131
|
+
const args = JSON.parse(argsStr || '{}');
|
|
132
|
+
// W1: Normalize bash file-read commands so cat/head/tail/wc targeting the same file
|
|
133
|
+
// produce the same fingerprint, triggering doom loop detection.
|
|
134
|
+
if (toolName === 'bash' && typeof args.command === 'string') {
|
|
135
|
+
const fileTarget = extractBashFileTarget(args.command);
|
|
136
|
+
if (fileTarget)
|
|
137
|
+
return `bash:file_read:${fileTarget}`;
|
|
138
|
+
}
|
|
139
|
+
const primaryArgs = {};
|
|
140
|
+
for (const key of PRIMARY_KEYS) {
|
|
141
|
+
if (key in args) {
|
|
142
|
+
primaryArgs[key] = args[key];
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
// If no primary keys found, fall back to full args
|
|
146
|
+
if (Object.keys(primaryArgs).length === 0) {
|
|
147
|
+
return `${toolName}:${stableStringify(args)}`;
|
|
148
|
+
}
|
|
149
|
+
return `${toolName}:${stableStringify(primaryArgs)}`;
|
|
150
|
+
}
|
|
151
|
+
catch {
|
|
152
|
+
// If args can't be parsed, use raw string
|
|
153
|
+
return `${toolName}:${argsStr}`;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* LoopDetector handles doom loop detection and pattern-based stuck state identification.
|
|
158
|
+
*
|
|
159
|
+
* Two-tier detection:
|
|
160
|
+
* 1. Exact match: same tool+args string (threshold: 3 by default)
|
|
161
|
+
* 2. Fuzzy match: same tool + same primary args, ignoring optional params (threshold: 4 by default)
|
|
162
|
+
*/
|
|
163
|
+
export class LoopDetector {
|
|
164
|
+
loopState;
|
|
165
|
+
constructor(tuning) {
|
|
166
|
+
this.loopState = {
|
|
167
|
+
doomLoopDetected: false,
|
|
168
|
+
lastTool: null,
|
|
169
|
+
consecutiveCount: 0,
|
|
170
|
+
threshold: tuning?.doomLoopThreshold ?? 3,
|
|
171
|
+
fuzzyThreshold: tuning?.doomLoopFuzzyThreshold ?? (tuning?.doomLoopThreshold ? tuning.doomLoopThreshold + 1 : 4),
|
|
172
|
+
lastWarningTime: 0,
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Update doom loop detection state given recent tool calls.
|
|
177
|
+
* Returns true if a NEW doom loop was just detected (first time).
|
|
178
|
+
*/
|
|
179
|
+
updateDoomLoopState(toolName, argsStr, recentCalls) {
|
|
180
|
+
const currentCall = `${toolName}:${argsStr}`;
|
|
181
|
+
// === EXACT MATCH: Count consecutive identical calls from the end ===
|
|
182
|
+
let consecutiveCount = 0;
|
|
183
|
+
for (let i = recentCalls.length - 1; i >= 0; i--) {
|
|
184
|
+
const call = recentCalls[i];
|
|
185
|
+
if (`${call.tool}:${call.args}` === currentCall) {
|
|
186
|
+
consecutiveCount++;
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
break;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
// === FUZZY MATCH: Catches near-identical calls that differ only in optional params ===
|
|
193
|
+
// Only check if exact match didn't already trigger
|
|
194
|
+
if (consecutiveCount < this.loopState.threshold) {
|
|
195
|
+
const currentFingerprint = computeToolFingerprint(toolName, argsStr);
|
|
196
|
+
let fuzzyCount = 0;
|
|
197
|
+
for (let i = recentCalls.length - 1; i >= 0; i--) {
|
|
198
|
+
const call = recentCalls[i];
|
|
199
|
+
const callFingerprint = computeToolFingerprint(call.tool, call.args);
|
|
200
|
+
if (callFingerprint === currentFingerprint) {
|
|
201
|
+
fuzzyCount++;
|
|
202
|
+
}
|
|
203
|
+
else {
|
|
204
|
+
break;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
// Use fuzzy count if it exceeds the fuzzy threshold
|
|
208
|
+
if (fuzzyCount >= this.loopState.fuzzyThreshold) {
|
|
209
|
+
consecutiveCount = Math.max(consecutiveCount, fuzzyCount);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
this.loopState.consecutiveCount = consecutiveCount;
|
|
213
|
+
this.loopState.lastTool = toolName;
|
|
214
|
+
// Detect doom loop when threshold reached
|
|
215
|
+
const wasDoomLoop = this.loopState.doomLoopDetected;
|
|
216
|
+
this.loopState.doomLoopDetected = consecutiveCount >= this.loopState.threshold;
|
|
217
|
+
// Return true when doom loop first detected (not on every check)
|
|
218
|
+
return this.loopState.doomLoopDetected && !wasDoomLoop;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Get the current loop detection state (copy).
|
|
222
|
+
*/
|
|
223
|
+
getState() {
|
|
224
|
+
return { ...this.loopState };
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Whether a doom loop is currently detected.
|
|
228
|
+
*/
|
|
229
|
+
get isDoomLoop() {
|
|
230
|
+
return this.loopState.doomLoopDetected;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* The tool that is currently being repeated.
|
|
234
|
+
*/
|
|
235
|
+
get lastTool() {
|
|
236
|
+
return this.loopState.lastTool;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* How many consecutive times the same call has been made.
|
|
240
|
+
*/
|
|
241
|
+
get consecutiveCount() {
|
|
242
|
+
return this.loopState.consecutiveCount;
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Reset the loop detection state (preserves tuning thresholds).
|
|
246
|
+
*/
|
|
247
|
+
reset(tuning) {
|
|
248
|
+
this.loopState = {
|
|
249
|
+
doomLoopDetected: false,
|
|
250
|
+
lastTool: null,
|
|
251
|
+
consecutiveCount: 0,
|
|
252
|
+
threshold: tuning?.doomLoopThreshold ?? 3,
|
|
253
|
+
fuzzyThreshold: tuning?.doomLoopFuzzyThreshold ?? (tuning?.doomLoopThreshold ? tuning.doomLoopThreshold + 1 : 4),
|
|
254
|
+
lastWarningTime: 0,
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Check if recent tool calls indicate a stuck state (same call 3x in a row).
|
|
259
|
+
*/
|
|
260
|
+
isStuckByRepetition(recentCalls) {
|
|
261
|
+
if (recentCalls.length >= 3) {
|
|
262
|
+
const last3 = recentCalls.slice(-3);
|
|
263
|
+
const unique = new Set(last3.map(tc => `${tc.tool}:${tc.args}`));
|
|
264
|
+
if (unique.size === 1) {
|
|
265
|
+
return true;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
return false;
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Extract the last bash command from recent tool calls (for remediation prompts).
|
|
272
|
+
*/
|
|
273
|
+
extractLastBashCommand(recentCalls) {
|
|
274
|
+
for (let i = recentCalls.length - 1; i >= 0; i--) {
|
|
275
|
+
if (recentCalls[i].tool === 'bash') {
|
|
276
|
+
try {
|
|
277
|
+
const parsed = JSON.parse(recentCalls[i].args);
|
|
278
|
+
return parsed.command;
|
|
279
|
+
}
|
|
280
|
+
catch { /* ignore parse errors */ }
|
|
281
|
+
break;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
return undefined;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
//# sourceMappingURL=loop-detector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loop-detector.js","sourceRoot":"","sources":["../../../../src/integrations/budget/loop-detector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AAGpE,gFAAgF;AAChF,YAAY;AACZ,gFAAgF;AAEhF;;;GAGG;AACH,MAAM,iBAAiB,GAAG,wIAAwI,CAAC;AAEnK,iGAAiG;AACjG,MAAM,kBAAkB,GAAG,wCAAwC,CAAC;AAEpE;;;GAGG;AACH,MAAM,YAAY,GAAG,CAAC,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;AAE3H,gFAAgF;AAChF,mBAAmB;AACnB,gFAAgF;AAEhF;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,IAAY,EAAE,KAAa,EAAE,EAAE;IAC9D,IAAI,KAAK,IAAI,CAAC,EAAE,CAAC;QACf,OAAO,oCAAoC,IAAI,4BAA4B,KAAK;kBAClE,IAAI;;;0CAGoB,CAAC;IACzC,CAAC;IACD,IAAI,KAAK,IAAI,CAAC,EAAE,CAAC;QACf,OAAO,mCAAmC,IAAI,IAAI,KAAK;;mCAExB,CAAC;IAClC,CAAC;IACD,OAAO,0BAA0B,IAAI,4BAA4B,KAAK;;;8CAG1B,CAAC;AAC/C,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,GA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,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;YACjD,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;gBACnC,IAAI,CAAC;oBACH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;oBAC/C,OAAO,MAAM,CAAC,OAAO,CAAC;gBACxB,CAAC;gBAAC,MAAM,CAAC,CAAC,yBAAyB,CAAC,CAAC;gBACrC,MAAM;YACR,CAAC;QACH,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;CACF"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Phase Tracker - Phase transitions and nudge generation for the economics system.
|
|
3
|
+
*
|
|
4
|
+
* Extracted from economics.ts (Phase 3b restructuring).
|
|
5
|
+
*
|
|
6
|
+
* Handles:
|
|
7
|
+
* - Phase state management (exploring -> planning -> acting -> verifying)
|
|
8
|
+
* - Phase transition triggers
|
|
9
|
+
* - Exploration saturation detection
|
|
10
|
+
* - Test outcome parsing (pass/fail tracking)
|
|
11
|
+
* - Nudge prompt generation for exploration budget, verification reserve
|
|
12
|
+
*/
|
|
13
|
+
import type { PhaseState, EconomicsTuning, EconomicsEvent } from './economics.js';
|
|
14
|
+
/**
|
|
15
|
+
* Exploration saturation prompt - gentle nudge to start making edits.
|
|
16
|
+
*/
|
|
17
|
+
export declare const EXPLORATION_NUDGE_PROMPT: (filesRead: number, iterations: number) => string;
|
|
18
|
+
/**
|
|
19
|
+
* Phase budget exploration exceeded prompt.
|
|
20
|
+
*/
|
|
21
|
+
export declare const EXPLORATION_BUDGET_EXCEEDED_PROMPT: (pct: number) => string;
|
|
22
|
+
/**
|
|
23
|
+
* Phase budget verification reserve prompt.
|
|
24
|
+
*/
|
|
25
|
+
export declare const VERIFICATION_RESERVE_PROMPT = "[System] You are running low on iterations. Run your tests NOW to verify your changes.\nDo not make more edits until you've confirmed whether the current fix works.";
|
|
26
|
+
/**
|
|
27
|
+
* Callback for emitting economics events from the phase tracker.
|
|
28
|
+
*/
|
|
29
|
+
export type PhaseEventEmitter = (event: EconomicsEvent) => void;
|
|
30
|
+
/**
|
|
31
|
+
* PhaseTracker manages execution phase state and transitions.
|
|
32
|
+
*
|
|
33
|
+
* Phases: exploring -> planning -> acting -> verifying
|
|
34
|
+
*
|
|
35
|
+
* Provides:
|
|
36
|
+
* - Automatic phase transitions based on tool calls (first edit -> acting, tests after edits -> verifying)
|
|
37
|
+
* - Exploration saturation detection (too many files read without edits)
|
|
38
|
+
* - Test outcome tracking (consecutive failures, test-fix cycles)
|
|
39
|
+
* - Bash failure cascade tracking
|
|
40
|
+
* - Summary loop detection (consecutive text-only turns)
|
|
41
|
+
*/
|
|
42
|
+
export declare class PhaseTracker {
|
|
43
|
+
private state;
|
|
44
|
+
private tuning;
|
|
45
|
+
private emit;
|
|
46
|
+
constructor(tuning: EconomicsTuning | undefined, emit: PhaseEventEmitter);
|
|
47
|
+
/**
|
|
48
|
+
* Create the initial phase state.
|
|
49
|
+
*/
|
|
50
|
+
static createInitialState(): PhaseState;
|
|
51
|
+
/**
|
|
52
|
+
* Record a text-only turn (LLM response with no tool calls).
|
|
53
|
+
* Increments the consecutive text-only turn counter for summary-loop detection.
|
|
54
|
+
*/
|
|
55
|
+
recordTextOnlyTurn(): void;
|
|
56
|
+
/**
|
|
57
|
+
* Called on every tool call to reset text-only counter and update phase iteration.
|
|
58
|
+
*/
|
|
59
|
+
onToolCall(): void;
|
|
60
|
+
/**
|
|
61
|
+
* Track a file read operation and return whether it was a new file.
|
|
62
|
+
*/
|
|
63
|
+
trackFileRead(path: string): boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Track a search operation.
|
|
66
|
+
*/
|
|
67
|
+
trackSearch(query: string): void;
|
|
68
|
+
/**
|
|
69
|
+
* Track a file modification and trigger phase transition if needed.
|
|
70
|
+
*/
|
|
71
|
+
trackFileModified(path: string): void;
|
|
72
|
+
/**
|
|
73
|
+
* Track a bash command execution result.
|
|
74
|
+
*/
|
|
75
|
+
trackBashResult(command: string, success: boolean, output: string): void;
|
|
76
|
+
/**
|
|
77
|
+
* Check for exploration saturation (reading too many files without action).
|
|
78
|
+
*/
|
|
79
|
+
checkExplorationSaturation(): void;
|
|
80
|
+
/**
|
|
81
|
+
* Get a serializable snapshot of the phase state (for getPhaseState() API).
|
|
82
|
+
*/
|
|
83
|
+
getSnapshot(): {
|
|
84
|
+
phase: string;
|
|
85
|
+
uniqueFilesRead: number;
|
|
86
|
+
uniqueSearches: number;
|
|
87
|
+
filesModified: number;
|
|
88
|
+
testsRun: number;
|
|
89
|
+
shouldTransition: boolean;
|
|
90
|
+
iterationsInPhase: number;
|
|
91
|
+
lastTestPassed: boolean | null;
|
|
92
|
+
consecutiveTestFailures: number;
|
|
93
|
+
inTestFixCycle: boolean;
|
|
94
|
+
consecutiveBashFailures: number;
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* Direct access to the raw phase state (for internal economics manager use).
|
|
98
|
+
*/
|
|
99
|
+
get rawState(): PhaseState;
|
|
100
|
+
/**
|
|
101
|
+
* Reset the phase tracker to initial state.
|
|
102
|
+
*/
|
|
103
|
+
reset(): void;
|
|
104
|
+
/**
|
|
105
|
+
* Transition to a new phase.
|
|
106
|
+
*/
|
|
107
|
+
private transitionPhase;
|
|
108
|
+
/**
|
|
109
|
+
* Parse test outcome from bash command output.
|
|
110
|
+
* Updates test tracking fields.
|
|
111
|
+
*/
|
|
112
|
+
private parseTestOutcome;
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=phase-tracker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"phase-tracker.d.ts","sourceRoot":"","sources":["../../../../src/integrations/budget/phase-tracker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,UA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CAAC;QAC1B,iBAAiB,EAAE,MAAM,CAAC;QAC1B,cAAc,EAAE,OAAO,GAAG,IAAI,CAAC;QAC/B,uBAAuB,EAAE,MAAM,CAAC;QAChC,cAAc,EAAE,OAAO,CAAC;QACxB,uBAAuB,EAAE,MAAM,CAAC;KACjC;IAgBD;;OAEG;IACH,IAAI,QAAQ,IAAI,UAAU,CAEzB;IAED;;OAEG;IACH,KAAK,IAAI,IAAI;IAQb;;OAEG;IACH,OAAO,CAAC,eAAe;IAqBvB;;;OAGG;IACH,OAAO,CAAC,gBAAgB;CAyBzB"}
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Phase Tracker - Phase transitions and nudge generation for the economics system.
|
|
3
|
+
*
|
|
4
|
+
* Extracted from economics.ts (Phase 3b restructuring).
|
|
5
|
+
*
|
|
6
|
+
* Handles:
|
|
7
|
+
* - Phase state management (exploring -> planning -> acting -> verifying)
|
|
8
|
+
* - Phase transition triggers
|
|
9
|
+
* - Exploration saturation detection
|
|
10
|
+
* - Test outcome parsing (pass/fail tracking)
|
|
11
|
+
* - Nudge prompt generation for exploration budget, verification reserve
|
|
12
|
+
*/
|
|
13
|
+
// =============================================================================
|
|
14
|
+
// PROMPT TEMPLATES
|
|
15
|
+
// =============================================================================
|
|
16
|
+
/**
|
|
17
|
+
* Exploration saturation prompt - gentle nudge to start making edits.
|
|
18
|
+
*/
|
|
19
|
+
export const EXPLORATION_NUDGE_PROMPT = (filesRead, iterations) => `[System] You've read ${filesRead} files across ${iterations} iterations. If you understand the issue:
|
|
20
|
+
- Make the code changes now
|
|
21
|
+
- Run tests to verify
|
|
22
|
+
If you're still gathering context, briefly explain what you're looking for.`;
|
|
23
|
+
/**
|
|
24
|
+
* Phase budget exploration exceeded prompt.
|
|
25
|
+
*/
|
|
26
|
+
export const EXPLORATION_BUDGET_EXCEEDED_PROMPT = (pct) => `[System] You've spent ${pct}% of your iterations in exploration. Start making edits NOW.
|
|
27
|
+
Do not read more files. Use what you know to make the fix.`;
|
|
28
|
+
/**
|
|
29
|
+
* Phase budget verification reserve prompt.
|
|
30
|
+
*/
|
|
31
|
+
export const VERIFICATION_RESERVE_PROMPT = `[System] You are running low on iterations. Run your tests NOW to verify your changes.
|
|
32
|
+
Do not make more edits until you've confirmed whether the current fix works.`;
|
|
33
|
+
/**
|
|
34
|
+
* PhaseTracker manages execution phase state and transitions.
|
|
35
|
+
*
|
|
36
|
+
* Phases: exploring -> planning -> acting -> verifying
|
|
37
|
+
*
|
|
38
|
+
* Provides:
|
|
39
|
+
* - Automatic phase transitions based on tool calls (first edit -> acting, tests after edits -> verifying)
|
|
40
|
+
* - Exploration saturation detection (too many files read without edits)
|
|
41
|
+
* - Test outcome tracking (consecutive failures, test-fix cycles)
|
|
42
|
+
* - Bash failure cascade tracking
|
|
43
|
+
* - Summary loop detection (consecutive text-only turns)
|
|
44
|
+
*/
|
|
45
|
+
export class PhaseTracker {
|
|
46
|
+
state;
|
|
47
|
+
tuning;
|
|
48
|
+
emit;
|
|
49
|
+
constructor(tuning, emit) {
|
|
50
|
+
this.tuning = tuning;
|
|
51
|
+
this.emit = emit;
|
|
52
|
+
this.state = PhaseTracker.createInitialState();
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Create the initial phase state.
|
|
56
|
+
*/
|
|
57
|
+
static createInitialState() {
|
|
58
|
+
return {
|
|
59
|
+
phase: 'exploring',
|
|
60
|
+
explorationStartIteration: 0,
|
|
61
|
+
uniqueFilesRead: new Set(),
|
|
62
|
+
uniqueSearches: new Set(),
|
|
63
|
+
filesModified: new Set(),
|
|
64
|
+
testsRun: 0,
|
|
65
|
+
shouldTransition: false,
|
|
66
|
+
iterationsInPhase: 0,
|
|
67
|
+
recentNewFiles: 0,
|
|
68
|
+
lastTestPassed: null,
|
|
69
|
+
consecutiveTestFailures: 0,
|
|
70
|
+
inTestFixCycle: false,
|
|
71
|
+
consecutiveBashFailures: 0,
|
|
72
|
+
consecutiveTextOnlyTurns: 0,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Record a text-only turn (LLM response with no tool calls).
|
|
77
|
+
* Increments the consecutive text-only turn counter for summary-loop detection.
|
|
78
|
+
*/
|
|
79
|
+
recordTextOnlyTurn() {
|
|
80
|
+
this.state.consecutiveTextOnlyTurns++;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Called on every tool call to reset text-only counter and update phase iteration.
|
|
84
|
+
*/
|
|
85
|
+
onToolCall() {
|
|
86
|
+
this.state.consecutiveTextOnlyTurns = 0;
|
|
87
|
+
this.state.iterationsInPhase++;
|
|
88
|
+
// Reset recentNewFiles counter every 3 iterations for diminishing returns check
|
|
89
|
+
if (this.state.iterationsInPhase % 3 === 0) {
|
|
90
|
+
this.state.recentNewFiles = 0;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Track a file read operation and return whether it was a new file.
|
|
95
|
+
*/
|
|
96
|
+
trackFileRead(path) {
|
|
97
|
+
const isNew = !this.state.uniqueFilesRead.has(path);
|
|
98
|
+
this.state.uniqueFilesRead.add(path);
|
|
99
|
+
if (isNew) {
|
|
100
|
+
this.state.recentNewFiles++;
|
|
101
|
+
}
|
|
102
|
+
return isNew;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Track a search operation.
|
|
106
|
+
*/
|
|
107
|
+
trackSearch(query) {
|
|
108
|
+
this.state.uniqueSearches.add(query);
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Track a file modification and trigger phase transition if needed.
|
|
112
|
+
*/
|
|
113
|
+
trackFileModified(path) {
|
|
114
|
+
this.state.filesModified.add(path);
|
|
115
|
+
// Transition to acting phase when first edit is made
|
|
116
|
+
if (this.state.phase === 'exploring' || this.state.phase === 'planning') {
|
|
117
|
+
this.transitionPhase('acting', 'First file edit made');
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Track a bash command execution result.
|
|
122
|
+
*/
|
|
123
|
+
trackBashResult(command, success, output) {
|
|
124
|
+
// Track consecutive bash failures
|
|
125
|
+
if (!success) {
|
|
126
|
+
this.state.consecutiveBashFailures++;
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
this.state.consecutiveBashFailures = 0;
|
|
130
|
+
}
|
|
131
|
+
// Detect test runs and track outcomes
|
|
132
|
+
if (command.includes('test') || command.includes('pytest') || command.includes('npm test') || command.includes('jest')) {
|
|
133
|
+
this.state.testsRun++;
|
|
134
|
+
// Transition to verifying phase when tests are run after edits
|
|
135
|
+
if (this.state.phase === 'acting' && this.state.filesModified.size > 0) {
|
|
136
|
+
this.transitionPhase('verifying', 'Tests run after edits');
|
|
137
|
+
}
|
|
138
|
+
if (output) {
|
|
139
|
+
this.parseTestOutcome(command, output);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Check for exploration saturation (reading too many files without action).
|
|
145
|
+
*/
|
|
146
|
+
checkExplorationSaturation() {
|
|
147
|
+
const { phase, uniqueFilesRead, iterationsInPhase, recentNewFiles, filesModified } = this.state;
|
|
148
|
+
// Only check during exploration phase
|
|
149
|
+
if (phase !== 'exploring') {
|
|
150
|
+
this.state.shouldTransition = false;
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
// After N+ unique files without edits, suggest transition (configurable, default: 10)
|
|
154
|
+
const fileThreshold = this.tuning?.explorationFileThreshold ?? 10;
|
|
155
|
+
if (uniqueFilesRead.size >= fileThreshold && filesModified.size === 0) {
|
|
156
|
+
this.state.shouldTransition = true;
|
|
157
|
+
this.emit({
|
|
158
|
+
type: 'exploration.saturation',
|
|
159
|
+
filesRead: uniqueFilesRead.size,
|
|
160
|
+
iterations: iterationsInPhase,
|
|
161
|
+
});
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
// After N+ iterations in exploration with diminishing returns (configurable, default: 15)
|
|
165
|
+
const iterThreshold = this.tuning?.explorationIterThreshold ?? 15;
|
|
166
|
+
if (iterationsInPhase >= iterThreshold && recentNewFiles < 2 && filesModified.size === 0) {
|
|
167
|
+
this.state.shouldTransition = true;
|
|
168
|
+
this.emit({
|
|
169
|
+
type: 'exploration.saturation',
|
|
170
|
+
filesRead: uniqueFilesRead.size,
|
|
171
|
+
iterations: iterationsInPhase,
|
|
172
|
+
});
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
this.state.shouldTransition = false;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Get a serializable snapshot of the phase state (for getPhaseState() API).
|
|
179
|
+
*/
|
|
180
|
+
getSnapshot() {
|
|
181
|
+
return {
|
|
182
|
+
phase: this.state.phase,
|
|
183
|
+
uniqueFilesRead: this.state.uniqueFilesRead.size,
|
|
184
|
+
uniqueSearches: this.state.uniqueSearches.size,
|
|
185
|
+
filesModified: this.state.filesModified.size,
|
|
186
|
+
testsRun: this.state.testsRun,
|
|
187
|
+
shouldTransition: this.state.shouldTransition,
|
|
188
|
+
iterationsInPhase: this.state.iterationsInPhase,
|
|
189
|
+
lastTestPassed: this.state.lastTestPassed,
|
|
190
|
+
consecutiveTestFailures: this.state.consecutiveTestFailures,
|
|
191
|
+
inTestFixCycle: this.state.inTestFixCycle,
|
|
192
|
+
consecutiveBashFailures: this.state.consecutiveBashFailures,
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Direct access to the raw phase state (for internal economics manager use).
|
|
197
|
+
*/
|
|
198
|
+
get rawState() {
|
|
199
|
+
return this.state;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Reset the phase tracker to initial state.
|
|
203
|
+
*/
|
|
204
|
+
reset() {
|
|
205
|
+
this.state = PhaseTracker.createInitialState();
|
|
206
|
+
}
|
|
207
|
+
// ---------------------------------------------------------------------------
|
|
208
|
+
// PRIVATE METHODS
|
|
209
|
+
// ---------------------------------------------------------------------------
|
|
210
|
+
/**
|
|
211
|
+
* Transition to a new phase.
|
|
212
|
+
*/
|
|
213
|
+
transitionPhase(newPhase, reason) {
|
|
214
|
+
const oldPhase = this.state.phase;
|
|
215
|
+
if (oldPhase === newPhase)
|
|
216
|
+
return;
|
|
217
|
+
this.emit({
|
|
218
|
+
type: 'phase.transition',
|
|
219
|
+
from: oldPhase,
|
|
220
|
+
to: newPhase,
|
|
221
|
+
reason,
|
|
222
|
+
});
|
|
223
|
+
this.state.phase = newPhase;
|
|
224
|
+
this.state.iterationsInPhase = 0;
|
|
225
|
+
this.state.recentNewFiles = 0;
|
|
226
|
+
if (newPhase === 'exploring') {
|
|
227
|
+
// explorationStartIteration is set by the caller (economics manager)
|
|
228
|
+
// since it knows the current iteration count
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Parse test outcome from bash command output.
|
|
233
|
+
* Updates test tracking fields.
|
|
234
|
+
*/
|
|
235
|
+
parseTestOutcome(_command, output) {
|
|
236
|
+
if (!output)
|
|
237
|
+
return;
|
|
238
|
+
// Detect pass/fail from pytest-style output
|
|
239
|
+
const hasPassed = /(\d+)\s+passed/.test(output) || output.includes('PASSED');
|
|
240
|
+
const hasFailed = /(\d+)\s+failed/.test(output) || output.includes('FAILED') || output.includes('ERROR');
|
|
241
|
+
if (hasFailed && !hasPassed) {
|
|
242
|
+
// Pure failure
|
|
243
|
+
this.state.lastTestPassed = false;
|
|
244
|
+
this.state.consecutiveTestFailures++;
|
|
245
|
+
this.state.inTestFixCycle = true;
|
|
246
|
+
}
|
|
247
|
+
else if (hasPassed && !hasFailed) {
|
|
248
|
+
// Pure pass
|
|
249
|
+
this.state.lastTestPassed = true;
|
|
250
|
+
this.state.consecutiveTestFailures = 0;
|
|
251
|
+
this.state.inTestFixCycle = false;
|
|
252
|
+
}
|
|
253
|
+
else if (hasPassed && hasFailed) {
|
|
254
|
+
// Mixed - some passed, some failed
|
|
255
|
+
this.state.lastTestPassed = false;
|
|
256
|
+
this.state.consecutiveTestFailures++;
|
|
257
|
+
this.state.inTestFixCycle = true;
|
|
258
|
+
}
|
|
259
|
+
// If no clear signal, don't update
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
//# sourceMappingURL=phase-tracker.js.map
|