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,520 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cancellation Token Integration
|
|
3
|
+
*
|
|
4
|
+
* Provides graceful cancellation support for long-running agent operations.
|
|
5
|
+
* Based on the .NET CancellationToken pattern, adapted from tricks/cancellation.ts.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* const cts = createCancellationTokenSource();
|
|
9
|
+
* agent.run(task, { cancellationToken: cts.token });
|
|
10
|
+
* // Later: cts.cancel('User requested cancellation');
|
|
11
|
+
*/
|
|
12
|
+
// =============================================================================
|
|
13
|
+
// IMPLEMENTATION
|
|
14
|
+
// =============================================================================
|
|
15
|
+
class CancellationTokenImpl {
|
|
16
|
+
_cancelled = false;
|
|
17
|
+
_reason;
|
|
18
|
+
_callbacks = new Set();
|
|
19
|
+
_promise;
|
|
20
|
+
_resolve;
|
|
21
|
+
constructor() {
|
|
22
|
+
this._promise = new Promise((r) => {
|
|
23
|
+
this._resolve = r;
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
get isCancellationRequested() {
|
|
27
|
+
return this._cancelled;
|
|
28
|
+
}
|
|
29
|
+
get cancellationReason() {
|
|
30
|
+
return this._reason;
|
|
31
|
+
}
|
|
32
|
+
get onCancellationRequested() {
|
|
33
|
+
return this._promise;
|
|
34
|
+
}
|
|
35
|
+
register(callback) {
|
|
36
|
+
if (this._cancelled) {
|
|
37
|
+
// Already cancelled, invoke immediately
|
|
38
|
+
try {
|
|
39
|
+
callback(this._reason);
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
// Ignore callback errors
|
|
43
|
+
}
|
|
44
|
+
return { dispose: () => { } };
|
|
45
|
+
}
|
|
46
|
+
this._callbacks.add(callback);
|
|
47
|
+
return { dispose: () => this._callbacks.delete(callback) };
|
|
48
|
+
}
|
|
49
|
+
throwIfCancellationRequested() {
|
|
50
|
+
if (this._cancelled) {
|
|
51
|
+
throw new CancellationError(this._reason);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/** @internal */
|
|
55
|
+
_cancel(reason) {
|
|
56
|
+
if (this._cancelled)
|
|
57
|
+
return;
|
|
58
|
+
this._cancelled = true;
|
|
59
|
+
this._reason = reason;
|
|
60
|
+
this._resolve(reason);
|
|
61
|
+
for (const cb of this._callbacks) {
|
|
62
|
+
try {
|
|
63
|
+
cb(reason);
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
// Ignore callback errors to ensure all callbacks run
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
this._callbacks.clear();
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
class CancellationTokenSourceImpl {
|
|
73
|
+
_token = new CancellationTokenImpl();
|
|
74
|
+
_timeoutId;
|
|
75
|
+
_disposed = false;
|
|
76
|
+
get token() {
|
|
77
|
+
return this._token;
|
|
78
|
+
}
|
|
79
|
+
get isCancellationRequested() {
|
|
80
|
+
return this._token.isCancellationRequested;
|
|
81
|
+
}
|
|
82
|
+
cancel(reason) {
|
|
83
|
+
if (this._disposed)
|
|
84
|
+
return;
|
|
85
|
+
this._token._cancel(reason);
|
|
86
|
+
}
|
|
87
|
+
cancelAfter(ms) {
|
|
88
|
+
if (this._disposed || this._token.isCancellationRequested)
|
|
89
|
+
return this;
|
|
90
|
+
this._timeoutId = setTimeout(() => this.cancel('Operation timed out'), ms);
|
|
91
|
+
return this;
|
|
92
|
+
}
|
|
93
|
+
dispose() {
|
|
94
|
+
if (this._disposed)
|
|
95
|
+
return;
|
|
96
|
+
this._disposed = true;
|
|
97
|
+
if (this._timeoutId) {
|
|
98
|
+
clearTimeout(this._timeoutId);
|
|
99
|
+
this._timeoutId = undefined;
|
|
100
|
+
}
|
|
101
|
+
// Don't cancel on dispose - the operation completed successfully
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
// =============================================================================
|
|
105
|
+
// ERROR
|
|
106
|
+
// =============================================================================
|
|
107
|
+
/**
|
|
108
|
+
* Error thrown when an operation is cancelled.
|
|
109
|
+
*/
|
|
110
|
+
export class CancellationError extends Error {
|
|
111
|
+
isCancellation = true;
|
|
112
|
+
reason;
|
|
113
|
+
constructor(reason) {
|
|
114
|
+
super(reason || 'Operation cancelled');
|
|
115
|
+
this.name = 'CancellationError';
|
|
116
|
+
this.reason = reason;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Check if an error is a cancellation error.
|
|
121
|
+
*/
|
|
122
|
+
export function isCancellationError(error) {
|
|
123
|
+
return (error instanceof CancellationError ||
|
|
124
|
+
(error instanceof Error && 'isCancellation' in error && error.isCancellation === true));
|
|
125
|
+
}
|
|
126
|
+
// =============================================================================
|
|
127
|
+
// FACTORY FUNCTIONS
|
|
128
|
+
// =============================================================================
|
|
129
|
+
/**
|
|
130
|
+
* Create a new cancellation token source.
|
|
131
|
+
*/
|
|
132
|
+
export function createCancellationTokenSource() {
|
|
133
|
+
return new CancellationTokenSourceImpl();
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Create a token source that auto-cancels after timeout.
|
|
137
|
+
*/
|
|
138
|
+
export function createTimeoutToken(ms) {
|
|
139
|
+
return createCancellationTokenSource().cancelAfter(ms);
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Create a linked token that cancels when any source cancels.
|
|
143
|
+
*/
|
|
144
|
+
export function createLinkedToken(...sources) {
|
|
145
|
+
const linked = createCancellationTokenSource();
|
|
146
|
+
for (const source of sources) {
|
|
147
|
+
if (source.isCancellationRequested) {
|
|
148
|
+
linked.cancel(source.token.cancellationReason);
|
|
149
|
+
break;
|
|
150
|
+
}
|
|
151
|
+
source.token.register((reason) => linked.cancel(reason));
|
|
152
|
+
}
|
|
153
|
+
return linked;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Create a progress-aware timeout token.
|
|
157
|
+
*
|
|
158
|
+
* @param maxTimeout - Maximum total execution time (hard limit)
|
|
159
|
+
* @param idleTimeout - Time without progress before cancellation (soft limit)
|
|
160
|
+
* @param checkInterval - How often to check for idle timeout (default: 5000ms)
|
|
161
|
+
*
|
|
162
|
+
* The token will be cancelled when either:
|
|
163
|
+
* 1. maxTimeout is reached (regardless of progress)
|
|
164
|
+
* 2. idleTimeout passes without any progress reported
|
|
165
|
+
*
|
|
166
|
+
* @example
|
|
167
|
+
* ```ts
|
|
168
|
+
* const timeout = createProgressAwareTimeout(300000, 60000); // 5 min max, 1 min idle
|
|
169
|
+
*
|
|
170
|
+
* // In event handler:
|
|
171
|
+
* subAgent.subscribe(event => {
|
|
172
|
+
* if (['tool.start', 'tool.complete', 'llm.start', 'llm.complete'].includes(event.type)) {
|
|
173
|
+
* timeout.reportProgress();
|
|
174
|
+
* }
|
|
175
|
+
* });
|
|
176
|
+
* ```
|
|
177
|
+
*/
|
|
178
|
+
export function createProgressAwareTimeout(maxTimeout, idleTimeout, checkInterval = 5000) {
|
|
179
|
+
const source = createCancellationTokenSource();
|
|
180
|
+
const startTime = Date.now();
|
|
181
|
+
let lastProgressTime = Date.now();
|
|
182
|
+
let checkTimer;
|
|
183
|
+
let maxTimer;
|
|
184
|
+
// Hard limit - cancel after maxTimeout regardless of progress
|
|
185
|
+
maxTimer = setTimeout(() => {
|
|
186
|
+
if (!source.isCancellationRequested) {
|
|
187
|
+
source.cancel(`Maximum timeout exceeded (${Math.round(maxTimeout / 1000)}s)`);
|
|
188
|
+
}
|
|
189
|
+
}, maxTimeout);
|
|
190
|
+
// Periodic check for idle timeout
|
|
191
|
+
checkTimer = setInterval(() => {
|
|
192
|
+
const idleTime = Date.now() - lastProgressTime;
|
|
193
|
+
if (idleTime >= idleTimeout && !source.isCancellationRequested) {
|
|
194
|
+
source.cancel(`Idle timeout - no progress for ${Math.round(idleTime / 1000)}s`);
|
|
195
|
+
}
|
|
196
|
+
}, checkInterval);
|
|
197
|
+
// Cleanup timers on dispose
|
|
198
|
+
const originalDispose = source.dispose.bind(source);
|
|
199
|
+
source.dispose = () => {
|
|
200
|
+
if (checkTimer)
|
|
201
|
+
clearInterval(checkTimer);
|
|
202
|
+
if (maxTimer)
|
|
203
|
+
clearTimeout(maxTimer);
|
|
204
|
+
originalDispose();
|
|
205
|
+
};
|
|
206
|
+
// Return extended source with progress reporting
|
|
207
|
+
return Object.assign(source, {
|
|
208
|
+
reportProgress() {
|
|
209
|
+
lastProgressTime = Date.now();
|
|
210
|
+
},
|
|
211
|
+
getIdleTime() {
|
|
212
|
+
return Date.now() - lastProgressTime;
|
|
213
|
+
},
|
|
214
|
+
getElapsedTime() {
|
|
215
|
+
return Date.now() - startTime;
|
|
216
|
+
},
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Create a graceful timeout that fires a wrapup warning before hard cancellation.
|
|
221
|
+
*
|
|
222
|
+
* The lifecycle is:
|
|
223
|
+
* 1. Normal operation — progress extends the idle timer (same as createProgressAwareTimeout)
|
|
224
|
+
* 2. Wrapup phase — `wrapupWindow` ms before hard kill, wrapup callbacks fire
|
|
225
|
+
* - Progress during wrapup does NOT extend the deadline (wrapping up, not working)
|
|
226
|
+
* 3. Hard kill — `race()` throws CancellationError after wrapup window expires
|
|
227
|
+
*
|
|
228
|
+
* @param maxTimeout - Maximum total execution time (hard limit)
|
|
229
|
+
* @param idleTimeout - Time without progress before cancellation (soft limit)
|
|
230
|
+
* @param wrapupWindow - Time between wrapup warning and hard kill (default: 30000ms)
|
|
231
|
+
* @param checkInterval - How often to check for idle timeout (default: 5000ms)
|
|
232
|
+
*/
|
|
233
|
+
export function createGracefulTimeout(maxTimeout, idleTimeout, wrapupWindow = 30000, checkInterval = 5000) {
|
|
234
|
+
const source = createCancellationTokenSource();
|
|
235
|
+
const startTime = Date.now();
|
|
236
|
+
let lastProgressTime = Date.now();
|
|
237
|
+
let checkTimer;
|
|
238
|
+
let maxTimer;
|
|
239
|
+
let wrapupTimer;
|
|
240
|
+
let hardKillTimer;
|
|
241
|
+
let inWrapupPhase = false;
|
|
242
|
+
const wrapupCallbacks = [];
|
|
243
|
+
function fireWrapup() {
|
|
244
|
+
if (inWrapupPhase || source.isCancellationRequested)
|
|
245
|
+
return;
|
|
246
|
+
inWrapupPhase = true;
|
|
247
|
+
// Fire all wrapup callbacks
|
|
248
|
+
for (const cb of wrapupCallbacks) {
|
|
249
|
+
try {
|
|
250
|
+
cb();
|
|
251
|
+
}
|
|
252
|
+
catch {
|
|
253
|
+
// Ignore callback errors
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
// Schedule hard kill after wrapup window
|
|
257
|
+
hardKillTimer = setTimeout(() => {
|
|
258
|
+
if (!source.isCancellationRequested) {
|
|
259
|
+
source.cancel(`Timeout after graceful wrapup (${Math.round((Date.now() - startTime) / 1000)}s total)`);
|
|
260
|
+
}
|
|
261
|
+
}, wrapupWindow);
|
|
262
|
+
}
|
|
263
|
+
// Compute effective timeouts: fire wrapup `wrapupWindow` ms before hard kill
|
|
264
|
+
const effectiveMaxTimeout = Math.max(0, maxTimeout - wrapupWindow);
|
|
265
|
+
// Hard limit wrapup — fires wrapup `wrapupWindow` ms before maxTimeout
|
|
266
|
+
wrapupTimer = setTimeout(() => {
|
|
267
|
+
fireWrapup();
|
|
268
|
+
}, effectiveMaxTimeout);
|
|
269
|
+
// Absolute hard limit — cancel after maxTimeout regardless (safety net)
|
|
270
|
+
maxTimer = setTimeout(() => {
|
|
271
|
+
if (!source.isCancellationRequested) {
|
|
272
|
+
source.cancel(`Maximum timeout exceeded (${Math.round(maxTimeout / 1000)}s)`);
|
|
273
|
+
}
|
|
274
|
+
}, maxTimeout);
|
|
275
|
+
// Periodic check for idle timeout
|
|
276
|
+
checkTimer = setInterval(() => {
|
|
277
|
+
if (inWrapupPhase)
|
|
278
|
+
return; // Don't check idle during wrapup
|
|
279
|
+
const idleTime = Date.now() - lastProgressTime;
|
|
280
|
+
if (idleTime >= idleTimeout && !source.isCancellationRequested) {
|
|
281
|
+
// Fire wrapup instead of immediate cancel
|
|
282
|
+
fireWrapup();
|
|
283
|
+
}
|
|
284
|
+
}, checkInterval);
|
|
285
|
+
// Cleanup timers on dispose
|
|
286
|
+
const originalDispose = source.dispose.bind(source);
|
|
287
|
+
source.dispose = () => {
|
|
288
|
+
if (checkTimer)
|
|
289
|
+
clearInterval(checkTimer);
|
|
290
|
+
if (maxTimer)
|
|
291
|
+
clearTimeout(maxTimer);
|
|
292
|
+
if (wrapupTimer)
|
|
293
|
+
clearTimeout(wrapupTimer);
|
|
294
|
+
if (hardKillTimer)
|
|
295
|
+
clearTimeout(hardKillTimer);
|
|
296
|
+
originalDispose();
|
|
297
|
+
};
|
|
298
|
+
// Return extended source with progress reporting and wrapup support
|
|
299
|
+
return Object.assign(source, {
|
|
300
|
+
reportProgress() {
|
|
301
|
+
// Progress during wrapup does NOT extend the deadline
|
|
302
|
+
if (!inWrapupPhase) {
|
|
303
|
+
lastProgressTime = Date.now();
|
|
304
|
+
}
|
|
305
|
+
},
|
|
306
|
+
getIdleTime() {
|
|
307
|
+
return Date.now() - lastProgressTime;
|
|
308
|
+
},
|
|
309
|
+
getElapsedTime() {
|
|
310
|
+
return Date.now() - startTime;
|
|
311
|
+
},
|
|
312
|
+
onWrapupWarning(callback) {
|
|
313
|
+
wrapupCallbacks.push(callback);
|
|
314
|
+
// If already in wrapup phase, fire immediately
|
|
315
|
+
if (inWrapupPhase) {
|
|
316
|
+
try {
|
|
317
|
+
callback();
|
|
318
|
+
}
|
|
319
|
+
catch {
|
|
320
|
+
// Ignore
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
},
|
|
324
|
+
isInWrapupPhase() {
|
|
325
|
+
return inWrapupPhase;
|
|
326
|
+
},
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Create a "none" token that is never cancelled.
|
|
331
|
+
* Useful as a default when no cancellation is needed.
|
|
332
|
+
*/
|
|
333
|
+
export const CancellationToken = {
|
|
334
|
+
None: {
|
|
335
|
+
isCancellationRequested: false,
|
|
336
|
+
cancellationReason: undefined,
|
|
337
|
+
onCancellationRequested: new Promise(() => { }),
|
|
338
|
+
register: () => ({ dispose: () => { } }),
|
|
339
|
+
throwIfCancellationRequested: () => { },
|
|
340
|
+
},
|
|
341
|
+
};
|
|
342
|
+
// =============================================================================
|
|
343
|
+
// UTILITIES
|
|
344
|
+
// =============================================================================
|
|
345
|
+
/**
|
|
346
|
+
* Run a function with cancellation support.
|
|
347
|
+
*/
|
|
348
|
+
export async function withCancellation(fn, options = {}) {
|
|
349
|
+
const { token, timeout } = options;
|
|
350
|
+
let timeoutSource;
|
|
351
|
+
let effectiveToken;
|
|
352
|
+
if (timeout && !token) {
|
|
353
|
+
timeoutSource = createTimeoutToken(timeout);
|
|
354
|
+
effectiveToken = timeoutSource.token;
|
|
355
|
+
}
|
|
356
|
+
else if (timeout && token) {
|
|
357
|
+
// Link user token with timeout
|
|
358
|
+
timeoutSource = createTimeoutToken(timeout);
|
|
359
|
+
const linkedSource = createLinkedToken({ token, isCancellationRequested: token.isCancellationRequested, cancel: () => { }, cancelAfter: () => ({ token, isCancellationRequested: false, cancel: () => { }, cancelAfter: () => ({}), dispose: () => { } }), dispose: () => { } }, timeoutSource);
|
|
360
|
+
effectiveToken = linkedSource.token;
|
|
361
|
+
}
|
|
362
|
+
else {
|
|
363
|
+
effectiveToken = token || CancellationToken.None;
|
|
364
|
+
}
|
|
365
|
+
try {
|
|
366
|
+
effectiveToken.throwIfCancellationRequested();
|
|
367
|
+
return await fn(effectiveToken);
|
|
368
|
+
}
|
|
369
|
+
finally {
|
|
370
|
+
timeoutSource?.dispose();
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* Sleep with cancellation support.
|
|
375
|
+
*/
|
|
376
|
+
export function sleep(ms, token) {
|
|
377
|
+
return new Promise((resolve, reject) => {
|
|
378
|
+
if (token?.isCancellationRequested) {
|
|
379
|
+
reject(new CancellationError(token.cancellationReason));
|
|
380
|
+
return;
|
|
381
|
+
}
|
|
382
|
+
const id = setTimeout(resolve, ms);
|
|
383
|
+
const registration = token?.register((reason) => {
|
|
384
|
+
clearTimeout(id);
|
|
385
|
+
reject(new CancellationError(reason));
|
|
386
|
+
});
|
|
387
|
+
// Cleanup registration after timeout completes
|
|
388
|
+
if (registration) {
|
|
389
|
+
setTimeout(() => registration.dispose(), ms + 1);
|
|
390
|
+
}
|
|
391
|
+
});
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* Race a promise against cancellation.
|
|
395
|
+
*/
|
|
396
|
+
export function race(promise, token) {
|
|
397
|
+
if (token.isCancellationRequested) {
|
|
398
|
+
return Promise.reject(new CancellationError(token.cancellationReason));
|
|
399
|
+
}
|
|
400
|
+
return Promise.race([
|
|
401
|
+
promise,
|
|
402
|
+
token.onCancellationRequested.then((reason) => {
|
|
403
|
+
throw new CancellationError(reason);
|
|
404
|
+
}),
|
|
405
|
+
]);
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* Create an AbortSignal from a CancellationToken.
|
|
409
|
+
* Useful for integrating with fetch and other AbortSignal-based APIs.
|
|
410
|
+
*/
|
|
411
|
+
export function toAbortSignal(token) {
|
|
412
|
+
const controller = new AbortController();
|
|
413
|
+
if (token.isCancellationRequested) {
|
|
414
|
+
controller.abort(token.cancellationReason);
|
|
415
|
+
}
|
|
416
|
+
else {
|
|
417
|
+
token.register((reason) => controller.abort(reason));
|
|
418
|
+
}
|
|
419
|
+
return controller.signal;
|
|
420
|
+
}
|
|
421
|
+
// =============================================================================
|
|
422
|
+
// CANCELLATION MANAGER (for agent integration)
|
|
423
|
+
// =============================================================================
|
|
424
|
+
/**
|
|
425
|
+
* Manager that handles cancellation for agent operations.
|
|
426
|
+
* Provides a clean interface for the ProductionAgent to use.
|
|
427
|
+
*/
|
|
428
|
+
export class CancellationManager {
|
|
429
|
+
currentSource = null;
|
|
430
|
+
eventListeners = new Set();
|
|
431
|
+
/**
|
|
432
|
+
* Create a new cancellation context for an operation.
|
|
433
|
+
* Disposes the previous context if one exists.
|
|
434
|
+
*/
|
|
435
|
+
createContext(timeout) {
|
|
436
|
+
// Dispose previous context
|
|
437
|
+
this.disposeContext();
|
|
438
|
+
// Create new source
|
|
439
|
+
this.currentSource = timeout ? createTimeoutToken(timeout) : createCancellationTokenSource();
|
|
440
|
+
return this.currentSource.token;
|
|
441
|
+
}
|
|
442
|
+
/**
|
|
443
|
+
* Get the current cancellation token.
|
|
444
|
+
*/
|
|
445
|
+
get token() {
|
|
446
|
+
return this.currentSource?.token || CancellationToken.None;
|
|
447
|
+
}
|
|
448
|
+
/**
|
|
449
|
+
* Check if cancellation has been requested.
|
|
450
|
+
*/
|
|
451
|
+
get isCancelled() {
|
|
452
|
+
return this.currentSource?.isCancellationRequested ?? false;
|
|
453
|
+
}
|
|
454
|
+
/**
|
|
455
|
+
* Request cancellation of the current operation.
|
|
456
|
+
*/
|
|
457
|
+
cancel(reason) {
|
|
458
|
+
if (!this.currentSource)
|
|
459
|
+
return;
|
|
460
|
+
const effectiveReason = reason || 'User requested cancellation';
|
|
461
|
+
this.emit({ type: 'cancellation.requested', reason: effectiveReason, timestamp: new Date() });
|
|
462
|
+
this.currentSource.cancel(effectiveReason);
|
|
463
|
+
}
|
|
464
|
+
/**
|
|
465
|
+
* Dispose the current cancellation context.
|
|
466
|
+
*/
|
|
467
|
+
disposeContext() {
|
|
468
|
+
if (this.currentSource) {
|
|
469
|
+
this.currentSource.dispose();
|
|
470
|
+
this.currentSource = null;
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
/**
|
|
474
|
+
* Check if there's an active cancellation context.
|
|
475
|
+
*/
|
|
476
|
+
hasActiveContext() {
|
|
477
|
+
return this.currentSource !== null;
|
|
478
|
+
}
|
|
479
|
+
/**
|
|
480
|
+
* Get the current cancellation source for linking with other tokens.
|
|
481
|
+
* Returns null if no active context.
|
|
482
|
+
*/
|
|
483
|
+
getSource() {
|
|
484
|
+
return this.currentSource;
|
|
485
|
+
}
|
|
486
|
+
/**
|
|
487
|
+
* Subscribe to cancellation events.
|
|
488
|
+
*/
|
|
489
|
+
subscribe(listener) {
|
|
490
|
+
this.eventListeners.add(listener);
|
|
491
|
+
return () => this.eventListeners.delete(listener);
|
|
492
|
+
}
|
|
493
|
+
/**
|
|
494
|
+
* Emit a cancellation event.
|
|
495
|
+
*/
|
|
496
|
+
emit(event) {
|
|
497
|
+
for (const listener of this.eventListeners) {
|
|
498
|
+
try {
|
|
499
|
+
listener(event);
|
|
500
|
+
}
|
|
501
|
+
catch {
|
|
502
|
+
// Ignore listener errors
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
/**
|
|
507
|
+
* Cleanup all resources.
|
|
508
|
+
*/
|
|
509
|
+
cleanup() {
|
|
510
|
+
this.disposeContext();
|
|
511
|
+
this.eventListeners.clear();
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
/**
|
|
515
|
+
* Create a cancellation manager.
|
|
516
|
+
*/
|
|
517
|
+
export function createCancellationManager() {
|
|
518
|
+
return new CancellationManager();
|
|
519
|
+
}
|
|
520
|
+
//# sourceMappingURL=cancellation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cancellation.js","sourceRoot":"","sources":["../../../../src/integrations/budget/cancellation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAyDH,gFAAgF;AAChF,iBAAiB;AACjB,gFAAgF;AAEhF,MAAM,qBAAqB;IACjB,UAAU,GAAG,KAAK,CAAC;IACnB,OAAO,CAAU;IACjB,UAAU,GAAG,IAAI,GAAG,EAA6B,CAAC;IAClD,QAAQ,CAAyB;IACjC,QAAQ,CAA6B;IAE7C;QACE,IAAI,CAAC,QAAQ,GAAG,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;YAChC,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC;QACpB,CAAC,CAAC,CAAC;IACL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AAC;QAC5B,CAAC;IACH,CAAC;IAED;;OAEG;IACH,gBAAgB;QACd,OAAO,IAAI,CAAC,aAAa,KAAK,IAAI,CAAC;IACrC,CAAC;IAED;;;OAGG;IACH,SAAS;QACP,OAAO,IAAI,CAAC,aAAa,CAAC;IAC5B,CAAC;IAED;;OAEG;IACH,SAAS,CAAC,QAAmC;QAC3C,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAClC,OAAO,GAAG,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IACpD,CAAC;IAED;;OAEG;IACK,IAAI,CAAC,KAAwB;QACnC,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;YAC3C,IAAI,CAAC;gBACH,QAAQ,CAAC,KAAK,CAAC,CAAC;YAClB,CAAC;YAAC,MAAM,CAAC;gBACP,yBAAyB;YAC3B,CAAC;QACH,CAAC;IACH,CAAC;IAED;;OAEG;IACH,OAAO;QACL,IAAI,CAAC,cAAc,EAAE,CAAC;QACtB,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,CAAC;IAC9B,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,yBAAyB;IACvC,OAAO,IAAI,mBAAmB,EAAE,CAAC;AACnC,CAAC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dynamic Budget Rebalancing
|
|
3
|
+
*
|
|
4
|
+
* Extends SharedBudgetPool with dynamic rebalancing that prevents
|
|
5
|
+
* starvation when spawning subagents sequentially.
|
|
6
|
+
*
|
|
7
|
+
* Key features:
|
|
8
|
+
* - setExpectedChildren(count) for upfront capacity planning
|
|
9
|
+
* - Sequential spawn cap: never take >60% of remaining budget
|
|
10
|
+
* - Rebalance on child completion (return unused budget to pool)
|
|
11
|
+
* - Priority-based allocation (critical children get more)
|
|
12
|
+
*/
|
|
13
|
+
import { SharedBudgetPool, type BudgetPoolConfig, type BudgetAllocation, type BudgetPoolStats } from './budget-pool.js';
|
|
14
|
+
export interface DynamicBudgetConfig extends BudgetPoolConfig {
|
|
15
|
+
/** Maximum percentage of remaining budget for any single child (default: 0.6) */
|
|
16
|
+
maxRemainingRatio: number;
|
|
17
|
+
/** Minimum tokens to reserve for each expected child (default: 10000) */
|
|
18
|
+
minPerExpectedChild: number;
|
|
19
|
+
/** Enable automatic rebalancing on release (default: true) */
|
|
20
|
+
autoRebalance: boolean;
|
|
21
|
+
}
|
|
22
|
+
export interface ChildPriority {
|
|
23
|
+
/** Child ID */
|
|
24
|
+
childId: string;
|
|
25
|
+
/** Priority level (higher = more budget) */
|
|
26
|
+
priority: 'low' | 'normal' | 'high' | 'critical';
|
|
27
|
+
/** Expected token usage (optional hint) */
|
|
28
|
+
expectedTokens?: number;
|
|
29
|
+
}
|
|
30
|
+
export interface RebalanceResult {
|
|
31
|
+
/** Children that had their allocations adjusted */
|
|
32
|
+
adjusted: Array<{
|
|
33
|
+
childId: string;
|
|
34
|
+
oldBudget: number;
|
|
35
|
+
newBudget: number;
|
|
36
|
+
}>;
|
|
37
|
+
/** Tokens freed by rebalancing */
|
|
38
|
+
tokensFreed: number;
|
|
39
|
+
}
|
|
40
|
+
export declare class DynamicBudgetPool extends SharedBudgetPool {
|
|
41
|
+
private dynamicConfig;
|
|
42
|
+
private expectedChildren;
|
|
43
|
+
private spawnedCount;
|
|
44
|
+
private completedCount;
|
|
45
|
+
private childPriorities;
|
|
46
|
+
constructor(config: BudgetPoolConfig & Partial<DynamicBudgetConfig>);
|
|
47
|
+
/**
|
|
48
|
+
* Set the expected number of children for capacity planning.
|
|
49
|
+
* This adjusts maxPerChild to ensure fair distribution.
|
|
50
|
+
*/
|
|
51
|
+
setExpectedChildren(count: number): void;
|
|
52
|
+
/**
|
|
53
|
+
* Set priority for a child agent.
|
|
54
|
+
*/
|
|
55
|
+
setChildPriority(priority: ChildPriority): void;
|
|
56
|
+
/**
|
|
57
|
+
* Reserve with dynamic capacity planning.
|
|
58
|
+
* Respects expected children and remaining ratio cap.
|
|
59
|
+
*/
|
|
60
|
+
reserveDynamic(childId: string, priority?: ChildPriority['priority']): BudgetAllocation | null;
|
|
61
|
+
/**
|
|
62
|
+
* Release with optional auto-rebalancing.
|
|
63
|
+
*/
|
|
64
|
+
releaseDynamic(childId: string): void;
|
|
65
|
+
/**
|
|
66
|
+
* Get enhanced stats including dynamic info.
|
|
67
|
+
*/
|
|
68
|
+
getDynamicStats(): BudgetPoolStats & {
|
|
69
|
+
expectedChildren: number;
|
|
70
|
+
spawnedCount: number;
|
|
71
|
+
completedCount: number;
|
|
72
|
+
pendingCount: number;
|
|
73
|
+
avgPerChild: number;
|
|
74
|
+
};
|
|
75
|
+
private updateMaxPerChild;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Create a dynamic budget pool from a parent's budget.
|
|
79
|
+
*/
|
|
80
|
+
export declare function createDynamicBudgetPool(parentBudgetTokens: number, parentReserveRatio?: number, config?: Partial<DynamicBudgetConfig>): DynamicBudgetPool;
|
|
81
|
+
//# sourceMappingURL=dynamic-budget.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dynamic-budget.d.ts","sourceRoot":"","sources":["../../../../src/integrations/budget/dynamic-budget.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,gBAAgB,EAAE,KAAK,gBAAgB,EAAE,KAAK,gBAAgB,EAAE,KAAK,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAMxH,MAAM,WAAW,mBAAoB,SAAQ,gBAAgB;IAC3D,iFAAiF;IACjF,iBAAiB,EAAE,MAAM,CAAC;IAC1B,yEAAyE;IACzE,mBAAmB,EAAE,MAAM,CAAC;IAC5B,8DAA8D;IAC9D,aAAa,EAAE,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,aAAa;IAC5B,eAAe;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,4CAA4C;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