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,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Worker Budget Tracker (Phase 3.2 completion)
|
|
3
|
+
*
|
|
4
|
+
* Lightweight per-worker budget + doom-loop tracker that reports to
|
|
5
|
+
* SharedEconomicsState for cross-worker doom loop aggregation.
|
|
6
|
+
*/
|
|
7
|
+
import { computeToolFingerprint } from '../integrations/budget/economics.js';
|
|
8
|
+
// =============================================================================
|
|
9
|
+
// WORKER BUDGET TRACKER
|
|
10
|
+
// =============================================================================
|
|
11
|
+
export class WorkerBudgetTracker {
|
|
12
|
+
workerId;
|
|
13
|
+
maxTokens;
|
|
14
|
+
maxIterations;
|
|
15
|
+
doomLoopThreshold;
|
|
16
|
+
inputTokens = 0;
|
|
17
|
+
outputTokens = 0;
|
|
18
|
+
iterations = 0;
|
|
19
|
+
toolCalls = [];
|
|
20
|
+
sharedEconomics;
|
|
21
|
+
constructor(config, sharedEconomics) {
|
|
22
|
+
this.workerId = config.workerId;
|
|
23
|
+
this.maxTokens = config.maxTokens;
|
|
24
|
+
this.maxIterations = config.maxIterations;
|
|
25
|
+
this.doomLoopThreshold = config.doomLoopThreshold ?? 3;
|
|
26
|
+
this.sharedEconomics = sharedEconomics;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Record LLM token usage.
|
|
30
|
+
*/
|
|
31
|
+
recordLLMUsage(inputTokens, outputTokens) {
|
|
32
|
+
this.inputTokens += inputTokens;
|
|
33
|
+
this.outputTokens += outputTokens;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Record a completed iteration.
|
|
37
|
+
*/
|
|
38
|
+
recordIteration() {
|
|
39
|
+
this.iterations++;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Record a tool call. Computes fingerprint and reports to SharedEconomicsState.
|
|
43
|
+
*/
|
|
44
|
+
recordToolCall(toolName, args) {
|
|
45
|
+
const fingerprint = computeToolFingerprint(toolName, args);
|
|
46
|
+
this.toolCalls.push({ fingerprint, timestamp: Date.now() });
|
|
47
|
+
// Report to shared economics for cross-worker doom loop detection
|
|
48
|
+
if (this.sharedEconomics) {
|
|
49
|
+
this.sharedEconomics.recordToolCall(this.workerId, fingerprint);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Check if the worker can continue within budget.
|
|
54
|
+
*/
|
|
55
|
+
checkBudget() {
|
|
56
|
+
// Token budget
|
|
57
|
+
const totalTokens = this.inputTokens + this.outputTokens;
|
|
58
|
+
if (totalTokens >= this.maxTokens) {
|
|
59
|
+
return {
|
|
60
|
+
canContinue: false,
|
|
61
|
+
reason: `Token budget exhausted: ${totalTokens.toLocaleString()} / ${this.maxTokens.toLocaleString()}`,
|
|
62
|
+
budgetType: 'tokens',
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
// Iteration budget
|
|
66
|
+
if (this.iterations >= this.maxIterations) {
|
|
67
|
+
return {
|
|
68
|
+
canContinue: false,
|
|
69
|
+
reason: `Iteration budget exhausted: ${this.iterations} / ${this.maxIterations}`,
|
|
70
|
+
budgetType: 'iterations',
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
// Local doom loop detection (consecutive identical tool calls)
|
|
74
|
+
if (this.toolCalls.length >= this.doomLoopThreshold) {
|
|
75
|
+
const recent = this.toolCalls.slice(-this.doomLoopThreshold);
|
|
76
|
+
const allSame = recent.every(tc => tc.fingerprint === recent[0].fingerprint);
|
|
77
|
+
if (allSame) {
|
|
78
|
+
return {
|
|
79
|
+
canContinue: false,
|
|
80
|
+
reason: `Doom loop detected: ${this.doomLoopThreshold} consecutive identical tool calls`,
|
|
81
|
+
budgetType: 'doom_loop',
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
// Cross-worker doom loop detection via SharedEconomicsState
|
|
86
|
+
if (this.sharedEconomics && this.toolCalls.length > 0) {
|
|
87
|
+
const lastFingerprint = this.toolCalls[this.toolCalls.length - 1].fingerprint;
|
|
88
|
+
if (this.sharedEconomics.isGlobalDoomLoop(lastFingerprint)) {
|
|
89
|
+
const info = this.sharedEconomics.getGlobalLoopInfo(lastFingerprint);
|
|
90
|
+
return {
|
|
91
|
+
canContinue: false,
|
|
92
|
+
reason: `Global doom loop: ${info?.count ?? 0} calls across ${info?.workerCount ?? 0} workers`,
|
|
93
|
+
budgetType: 'doom_loop',
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return { canContinue: true };
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Get current usage stats.
|
|
101
|
+
*/
|
|
102
|
+
getUsage() {
|
|
103
|
+
return {
|
|
104
|
+
inputTokens: this.inputTokens,
|
|
105
|
+
outputTokens: this.outputTokens,
|
|
106
|
+
totalTokens: this.inputTokens + this.outputTokens,
|
|
107
|
+
iterations: this.iterations,
|
|
108
|
+
toolCalls: this.toolCalls.length,
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Get budget utilization as a percentage (0-100).
|
|
113
|
+
*/
|
|
114
|
+
getUtilization() {
|
|
115
|
+
const totalTokens = this.inputTokens + this.outputTokens;
|
|
116
|
+
return {
|
|
117
|
+
tokenPercent: this.maxTokens > 0 ? Math.round((totalTokens / this.maxTokens) * 100) : 0,
|
|
118
|
+
iterationPercent: this.maxIterations > 0 ? Math.round((this.iterations / this.maxIterations) * 100) : 0,
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
// =============================================================================
|
|
123
|
+
// FACTORY
|
|
124
|
+
// =============================================================================
|
|
125
|
+
export function createWorkerBudgetTracker(config, sharedEconomics) {
|
|
126
|
+
return new WorkerBudgetTracker(config, sharedEconomics);
|
|
127
|
+
}
|
|
128
|
+
//# sourceMappingURL=budget-tracker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"budget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AI,CAAC,aAAa,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;SACxG,CAAC;IACJ,CAAC;CACF;AAED,gFAAgF;AAChF,UAAU;AACV,gFAAgF;AAEhF,MAAM,UAAU,yBAAyB,CACvC,MAA0B,EAC1B,eAAsC;IAEtC,OAAO,IAAI,mBAAmB,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;AAC1D,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared Context Engine (Phase 3.1)
|
|
3
|
+
*
|
|
4
|
+
* Orchestration layer that composes SharedContextState primitives into
|
|
5
|
+
* worker-optimized prompts. Workers get a single buildWorkerSystemPrompt()
|
|
6
|
+
* call instead of manually assembling prefix + failures + recitation.
|
|
7
|
+
*/
|
|
8
|
+
import type { SharedContextState } from './shared-context-state.js';
|
|
9
|
+
import type { FailureInput, Failure } from '../tricks/failure-evidence.js';
|
|
10
|
+
import type { Reference } from '../tricks/reversible-compaction.js';
|
|
11
|
+
export interface SharedContextEngineConfig {
|
|
12
|
+
/** Maximum failures to include in worker prompts (default: 5) */
|
|
13
|
+
maxFailuresInPrompt?: number;
|
|
14
|
+
/** Whether to include cross-worker insights (default: true) */
|
|
15
|
+
includeInsights?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export interface WorkerTask {
|
|
18
|
+
/** Unique task ID */
|
|
19
|
+
id: string;
|
|
20
|
+
/** Human-readable task description */
|
|
21
|
+
description: string;
|
|
22
|
+
/** The specific goal this worker should accomplish */
|
|
23
|
+
goal: string;
|
|
24
|
+
/** IDs of tasks this depends on */
|
|
25
|
+
dependencies?: string[];
|
|
26
|
+
/** Additional context for this specific task */
|
|
27
|
+
context?: string;
|
|
28
|
+
}
|
|
29
|
+
export declare class SharedContextEngine {
|
|
30
|
+
private contextState;
|
|
31
|
+
private maxFailuresInPrompt;
|
|
32
|
+
private includeInsights;
|
|
33
|
+
constructor(contextState: SharedContextState, config?: SharedContextEngineConfig);
|
|
34
|
+
/**
|
|
35
|
+
* Build a complete system prompt for a worker.
|
|
36
|
+
* Concatenates: shared prefix → task context → failure guidance → goal recitation.
|
|
37
|
+
* Empty sections are omitted.
|
|
38
|
+
*/
|
|
39
|
+
buildWorkerSystemPrompt(task: WorkerTask): string;
|
|
40
|
+
/**
|
|
41
|
+
* Get the shared static prefix for KV-cache alignment.
|
|
42
|
+
*/
|
|
43
|
+
getSharedPrefix(): string;
|
|
44
|
+
/**
|
|
45
|
+
* Report a failure from a worker. Delegates to SharedContextState.
|
|
46
|
+
*/
|
|
47
|
+
reportFailure(workerId: string, failure: FailureInput): Failure;
|
|
48
|
+
/**
|
|
49
|
+
* Get formatted failure guidance for inclusion in prompts.
|
|
50
|
+
* Returns empty string when no failures exist.
|
|
51
|
+
*/
|
|
52
|
+
getFailureGuidance(): string;
|
|
53
|
+
/**
|
|
54
|
+
* Get a goal recitation block for a worker task.
|
|
55
|
+
*/
|
|
56
|
+
getGoalRecitation(task: WorkerTask): string;
|
|
57
|
+
/**
|
|
58
|
+
* Search for relevant references. Delegates to SharedContextState.
|
|
59
|
+
*/
|
|
60
|
+
getRelevantReferences(query: string): Reference[];
|
|
61
|
+
private buildTaskSection;
|
|
62
|
+
}
|
|
63
|
+
export declare function createSharedContextEngine(contextState: SharedContextState, config?: SharedContextEngineConfig): SharedContextEngine;
|
|
64
|
+
//# sourceMappingURL=context-engine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-engine.d.ts","sourceRoot":"","sources":["../../../src/shared/context-engine.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,+BAA+B,C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
|
+
*
|
|
4
|
+
* Orchestration layer that composes SharedContextState primitives into
|
|
5
|
+
* worker-optimized prompts. Workers get a single buildWorkerSystemPrompt()
|
|
6
|
+
* call instead of manually assembling prefix + failures + recitation.
|
|
7
|
+
*/
|
|
8
|
+
// =============================================================================
|
|
9
|
+
// SHARED CONTEXT ENGINE
|
|
10
|
+
// =============================================================================
|
|
11
|
+
export class SharedContextEngine {
|
|
12
|
+
contextState;
|
|
13
|
+
maxFailuresInPrompt;
|
|
14
|
+
includeInsights;
|
|
15
|
+
constructor(contextState, config = {}) {
|
|
16
|
+
this.contextState = contextState;
|
|
17
|
+
this.maxFailuresInPrompt = config.maxFailuresInPrompt ?? 5;
|
|
18
|
+
this.includeInsights = config.includeInsights ?? true;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Build a complete system prompt for a worker.
|
|
22
|
+
* Concatenates: shared prefix → task context → failure guidance → goal recitation.
|
|
23
|
+
* Empty sections are omitted.
|
|
24
|
+
*/
|
|
25
|
+
buildWorkerSystemPrompt(task) {
|
|
26
|
+
const sections = [];
|
|
27
|
+
// 1. Shared prefix (cache-aligned, identical for all workers)
|
|
28
|
+
const prefix = this.getSharedPrefix();
|
|
29
|
+
if (prefix) {
|
|
30
|
+
sections.push(prefix);
|
|
31
|
+
}
|
|
32
|
+
// 2. Task context
|
|
33
|
+
const taskSection = this.buildTaskSection(task);
|
|
34
|
+
if (taskSection) {
|
|
35
|
+
sections.push(taskSection);
|
|
36
|
+
}
|
|
37
|
+
// 3. Failure guidance
|
|
38
|
+
const failureGuidance = this.getFailureGuidance();
|
|
39
|
+
if (failureGuidance) {
|
|
40
|
+
sections.push(failureGuidance);
|
|
41
|
+
}
|
|
42
|
+
// 4. Goal recitation
|
|
43
|
+
const goalRecitation = this.getGoalRecitation(task);
|
|
44
|
+
if (goalRecitation) {
|
|
45
|
+
sections.push(goalRecitation);
|
|
46
|
+
}
|
|
47
|
+
return sections.join('\n\n');
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Get the shared static prefix for KV-cache alignment.
|
|
51
|
+
*/
|
|
52
|
+
getSharedPrefix() {
|
|
53
|
+
return this.contextState.getStaticPrefix();
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Report a failure from a worker. Delegates to SharedContextState.
|
|
57
|
+
*/
|
|
58
|
+
reportFailure(workerId, failure) {
|
|
59
|
+
return this.contextState.recordFailure(workerId, failure);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Get formatted failure guidance for inclusion in prompts.
|
|
63
|
+
* Returns empty string when no failures exist.
|
|
64
|
+
*/
|
|
65
|
+
getFailureGuidance() {
|
|
66
|
+
const parts = [];
|
|
67
|
+
const failureContext = this.contextState.getFailureContext(this.maxFailuresInPrompt);
|
|
68
|
+
if (failureContext) {
|
|
69
|
+
parts.push(failureContext);
|
|
70
|
+
}
|
|
71
|
+
if (this.includeInsights) {
|
|
72
|
+
const insights = this.contextState.getFailureInsights();
|
|
73
|
+
if (insights.length > 0) {
|
|
74
|
+
parts.push('## Cross-Worker Insights\n' + insights.map(i => `- ${i}`).join('\n'));
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return parts.join('\n\n');
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Get a goal recitation block for a worker task.
|
|
81
|
+
*/
|
|
82
|
+
getGoalRecitation(task) {
|
|
83
|
+
const lines = [
|
|
84
|
+
'## Current Goal',
|
|
85
|
+
`**Task:** ${task.description}`,
|
|
86
|
+
`**Goal:** ${task.goal}`,
|
|
87
|
+
];
|
|
88
|
+
if (task.dependencies && task.dependencies.length > 0) {
|
|
89
|
+
lines.push(`**Depends on:** ${task.dependencies.join(', ')}`);
|
|
90
|
+
}
|
|
91
|
+
return lines.join('\n');
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Search for relevant references. Delegates to SharedContextState.
|
|
95
|
+
*/
|
|
96
|
+
getRelevantReferences(query) {
|
|
97
|
+
return this.contextState.searchReferences(query);
|
|
98
|
+
}
|
|
99
|
+
// ---------------------------------------------------------------------------
|
|
100
|
+
// Private helpers
|
|
101
|
+
// ---------------------------------------------------------------------------
|
|
102
|
+
buildTaskSection(task) {
|
|
103
|
+
const parts = ['## Task Assignment'];
|
|
104
|
+
parts.push(`You are working on task **${task.id}**: ${task.description}`);
|
|
105
|
+
if (task.context) {
|
|
106
|
+
parts.push(`\n### Additional Context\n${task.context}`);
|
|
107
|
+
}
|
|
108
|
+
return parts.join('\n');
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
// =============================================================================
|
|
112
|
+
// FACTORY
|
|
113
|
+
// =============================================================================
|
|
114
|
+
export function createSharedContextEngine(contextState, config) {
|
|
115
|
+
return new SharedContextEngine(contextState, config);
|
|
116
|
+
}
|
|
117
|
+
//# sourceMappingURL=context-engine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-engine.js","sourceRoot":"","sources":["../../../src/shared/context-engine.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AA8BH,gFAAgF;AAChF,wBAAwB;AACxB,gFAAgF;AAEhF,MAAM,OAAO,mBAAmB;IACtB,YAAY,CAAqB;IACjC,mBAAmB,CAAS;IAC5B,eAAe,CAAU;IAEjC,YACE,YAAgC,EAChC,SAAoC,EAAE;QAEtC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,mBAAmB,GAAG,MAAM,CAAC,mBAAmB,IAAI,CAAC,CAAC;QAC3D,IAAI,CAAC,eAAe,GAAG,MAAM,CAAC,eAAe,IAAI,IAAI,CAAC;IACxD,CAAC;IAED;;;;OAIG;IACH,uBAAuB,CAAC,IAAgB;QACtC,MAAM,QAAQ,GAAa,EAAE,CAAC;QAE9B,8DAA8D;QAC9D,MAAM,MAAM,GAAG,IAAI,CAAC,eAAe,EAAE,CAAC;QACtC,IAAI,MAAM,EAAE,CAAC;YACX,QAAQ,CAAC,IAAI,CAAC,M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AC1B,CAAC;CACF;AAED,gFAAgF;AAChF,UAAU;AACV,gFAAgF;AAEhF,MAAM,UAAU,yBAAyB,CACvC,YAAgC,EAChC,MAAkC;IAElC,OAAO,IAAI,mBAAmB,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;AACvD,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared State Modules
|
|
3
|
+
*
|
|
4
|
+
* Thin shared-state layers that swarm workers plug into for
|
|
5
|
+
* cross-worker failure learning, reference pooling, and doom loop aggregation.
|
|
6
|
+
*/
|
|
7
|
+
export { SharedContextState, createSharedContextState, type SharedContextConfig, } from './shared-context-state.js';
|
|
8
|
+
export { SharedEconomicsState, createSharedEconomicsState, type SharedEconomicsConfig, } from './shared-economics-state.js';
|
|
9
|
+
export { type PersistenceAdapter, JSONFilePersistenceAdapter, SQLitePersistenceAdapter, createPersistenceAdapter, } from './persistence.js';
|
|
10
|
+
export { SharedContextEngine, createSharedContextEngine, type SharedContextEngineConfig, type WorkerTask, } from './context-engine.js';
|
|
11
|
+
export { WorkerBudgetTracker, createWorkerBudgetTracker, type WorkerBudgetConfig, type WorkerBudgetCheckResult, } from './budget-tracker.js';
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/shared/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,kBAAkB,EAClB,wBAAwB,EACxB,KAAK,mBAAmB,GACzB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACL,oBAAoB,EACpB,0BAA0B,EAC1B,KAAK,qBAAqB,GAC3B,MAAM,6BAA6B,CAAC;AAErC,OAAO,EACL,KAAK,kBAAkB,EACvB,0BAA0B,EAC1B,wBAAwB,EACxB,wBAAwB,GACzB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,mBAAmB,EACnB,yBAAyB,EACzB,KAAK,yBAAyB,EAC9B,KAAK,UAAU,GAChB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,mBAAmB,EACnB,yBAAyB,EACzB,KAAK,kBAAkB,EACvB,KAAK,uBAAuB,GAC7B,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared State Modules
|
|
3
|
+
*
|
|
4
|
+
* Thin shared-state layers that swarm workers plug into for
|
|
5
|
+
* cross-worker failure learning, reference pooling, and doom loop aggregation.
|
|
6
|
+
*/
|
|
7
|
+
export { SharedContextState, createSharedContextState, } from './shared-context-state.js';
|
|
8
|
+
export { SharedEconomicsState, createSharedEconomicsState, } from './shared-economics-state.js';
|
|
9
|
+
export { JSONFilePersistenceAdapter, SQLitePersistenceAdapter, createPersistenceAdapter, } from './persistence.js';
|
|
10
|
+
export { SharedContextEngine, createSharedContextEngine, } from './context-engine.js';
|
|
11
|
+
export { WorkerBudgetTracker, createWorkerBudgetTracker, } from './budget-tracker.js';
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/shared/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,kBAAkB,EAClB,wBAAwB,GAEzB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACL,oBAAoB,EACpB,0BAA0B,GAE3B,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAEL,0BAA0B,EAC1B,wBAAwB,EACxB,wBAAwB,GACzB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,mBAAmB,EACnB,yBAAyB,GAG1B,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,mBAAmB,EACnB,yBAAyB,GAG1B,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified Persistence Adapters
|
|
3
|
+
*
|
|
4
|
+
* Thin interface over different storage backends (JSON files, SQLite).
|
|
5
|
+
* Provides a common API for save/load/list/delete operations.
|
|
6
|
+
*
|
|
7
|
+
* Existing stores (SQLiteStore, SwarmStateStore) continue unchanged.
|
|
8
|
+
* These adapters are opt-in wrappers for unified access patterns.
|
|
9
|
+
*/
|
|
10
|
+
export interface PersistenceAdapter {
|
|
11
|
+
/** Save data under a key within a namespace */
|
|
12
|
+
save(namespace: string, key: string, data: unknown): Promise<void>;
|
|
13
|
+
/** Load data by namespace + key */
|
|
14
|
+
load(namespace: string, key: string): Promise<unknown | null>;
|
|
15
|
+
/** List all keys in a namespace */
|
|
16
|
+
list(namespace: string): Promise<string[]>;
|
|
17
|
+
/** Delete a key */
|
|
18
|
+
delete(namespace: string, key: string): Promise<boolean>;
|
|
19
|
+
/** Check if a key exists */
|
|
20
|
+
exists(namespace: string, key: string): Promise<boolean>;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* JSON file-based persistence.
|
|
24
|
+
* Each namespace is a directory, each key is a JSON file.
|
|
25
|
+
*/
|
|
26
|
+
export declare class JSONFilePersistenceAdapter implements PersistenceAdapter {
|
|
27
|
+
private baseDir;
|
|
28
|
+
constructor(baseDir: string);
|
|
29
|
+
private keyPath;
|
|
30
|
+
private nsDir;
|
|
31
|
+
save(namespace: string, key: string, data: unknown): Promise<void>;
|
|
32
|
+
load(namespace: string, key: string): Promise<unknown | null>;
|
|
33
|
+
list(namespace: string): Promise<string[]>;
|
|
34
|
+
delete(namespace: string, key: string): Promise<boolean>;
|
|
35
|
+
exists(namespace: string, key: string): Promise<boolean>;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* SQLite-based persistence.
|
|
39
|
+
* Uses a generic key-value table with namespace partitioning.
|
|
40
|
+
*/
|
|
41
|
+
export declare class SQLitePersistenceAdapter implements PersistenceAdapter {
|
|
42
|
+
private db;
|
|
43
|
+
constructor(dbPath: string);
|
|
44
|
+
save(namespace: string, key: string, data: unknown): Promise<void>;
|
|
45
|
+
load(namespace: string, key: string): Promise<unknown | null>;
|
|
46
|
+
list(namespace: string): Promise<string[]>;
|
|
47
|
+
delete(namespace: string, key: string): Promise<boolean>;
|
|
48
|
+
exists(namespace: string, key: string): Promise<boolean>;
|
|
49
|
+
/** Close the database connection */
|
|
50
|
+
close(): void;
|
|
51
|
+
}
|
|
52
|
+
/** Create a persistence adapter of the given type */
|
|
53
|
+
export declare function createPersistenceAdapter(type: 'json' | 'sqlite', config: {
|
|
54
|
+
baseDir?: string;
|
|
55
|
+
dbPath?: string;
|
|
56
|
+
}): PersistenceAdapter;
|
|
57
|
+
//# sourceMappingURL=persistence.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"persistence.d.ts","sourceRoot":"","sources":["../../../src/shared/persistence.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAkCH,MAAM,WAAW,kBAAkB;IACjC,+CAA+C;IAC/C,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACnE,mCAAmC;IACnC,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;IAC9D,mCAAmC;IACnC,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IAC3C,mBAAmB;IACnB,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACzD,4BAA4B;IAC5B,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAC1D;AAMD;;;GAGG;AACH,qBAAa,0BAA2B,YAAW,kBAAkB;IACvD,OAAO,CAAC,OA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IAAI,EAAE,MAAM,GAAG,QAAQ,EACvB,MAAM,EAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GAC5C,kBAAkB,CAOpB"}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified Persistence Adapters
|
|
3
|
+
*
|
|
4
|
+
* Thin interface over different storage backends (JSON files, SQLite).
|
|
5
|
+
* Provides a common API for save/load/list/delete operations.
|
|
6
|
+
*
|
|
7
|
+
* Existing stores (SQLiteStore, SwarmStateStore) continue unchanged.
|
|
8
|
+
* These adapters are opt-in wrappers for unified access patterns.
|
|
9
|
+
*/
|
|
10
|
+
import fs from 'node:fs/promises';
|
|
11
|
+
import path from 'node:path';
|
|
12
|
+
import Database from 'better-sqlite3';
|
|
13
|
+
// =============================================================================
|
|
14
|
+
// MAP SERIALIZATION (reused from swarm-state-store pattern)
|
|
15
|
+
// =============================================================================
|
|
16
|
+
/** JSON replacer that serializes Maps as { __type: 'Map', entries: [...] } */
|
|
17
|
+
function mapReplacer(_key, value) {
|
|
18
|
+
if (value instanceof Map) {
|
|
19
|
+
return { __type: 'Map', entries: [...value.entries()] };
|
|
20
|
+
}
|
|
21
|
+
return value;
|
|
22
|
+
}
|
|
23
|
+
/** JSON reviver that deserializes Maps from { __type: 'Map', entries: [...] } */
|
|
24
|
+
function mapReviver(_key, value) {
|
|
25
|
+
if (value &&
|
|
26
|
+
typeof value === 'object' &&
|
|
27
|
+
value.__type === 'Map') {
|
|
28
|
+
return new Map(value.entries);
|
|
29
|
+
}
|
|
30
|
+
return value;
|
|
31
|
+
}
|
|
32
|
+
// =============================================================================
|
|
33
|
+
// JSON FILE ADAPTER
|
|
34
|
+
// =============================================================================
|
|
35
|
+
/**
|
|
36
|
+
* JSON file-based persistence.
|
|
37
|
+
* Each namespace is a directory, each key is a JSON file.
|
|
38
|
+
*/
|
|
39
|
+
export class JSONFilePersistenceAdapter {
|
|
40
|
+
baseDir;
|
|
41
|
+
constructor(baseDir) {
|
|
42
|
+
this.baseDir = baseDir;
|
|
43
|
+
}
|
|
44
|
+
keyPath(namespace, key) {
|
|
45
|
+
return path.join(this.baseDir, namespace, `${key}.json`);
|
|
46
|
+
}
|
|
47
|
+
nsDir(namespace) {
|
|
48
|
+
return path.join(this.baseDir, namespace);
|
|
49
|
+
}
|
|
50
|
+
async save(namespace, key, data) {
|
|
51
|
+
const filePath = this.keyPath(namespace, key);
|
|
52
|
+
await fs.mkdir(path.dirname(filePath), { recursive: true });
|
|
53
|
+
await fs.writeFile(filePath, JSON.stringify(data, mapReplacer, 2));
|
|
54
|
+
}
|
|
55
|
+
async load(namespace, key) {
|
|
56
|
+
try {
|
|
57
|
+
const content = await fs.readFile(this.keyPath(namespace, key), 'utf-8');
|
|
58
|
+
return JSON.parse(content, mapReviver);
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
async list(namespace) {
|
|
65
|
+
try {
|
|
66
|
+
const entries = await fs.readdir(this.nsDir(namespace));
|
|
67
|
+
return entries
|
|
68
|
+
.filter((e) => e.endsWith('.json'))
|
|
69
|
+
.map((e) => e.slice(0, -5));
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
return [];
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
async delete(namespace, key) {
|
|
76
|
+
try {
|
|
77
|
+
await fs.unlink(this.keyPath(namespace, key));
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
async exists(namespace, key) {
|
|
85
|
+
try {
|
|
86
|
+
await fs.access(this.keyPath(namespace, key));
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
// =============================================================================
|
|
95
|
+
// SQLITE ADAPTER
|
|
96
|
+
// =============================================================================
|
|
97
|
+
const CREATE_TABLE_SQL = `
|
|
98
|
+
CREATE TABLE IF NOT EXISTS kv_store (
|
|
99
|
+
namespace TEXT NOT NULL,
|
|
100
|
+
key TEXT NOT NULL,
|
|
101
|
+
data TEXT NOT NULL,
|
|
102
|
+
updated_at INTEGER NOT NULL,
|
|
103
|
+
PRIMARY KEY (namespace, key)
|
|
104
|
+
)
|
|
105
|
+
`;
|
|
106
|
+
/**
|
|
107
|
+
* SQLite-based persistence.
|
|
108
|
+
* Uses a generic key-value table with namespace partitioning.
|
|
109
|
+
*/
|
|
110
|
+
export class SQLitePersistenceAdapter {
|
|
111
|
+
db;
|
|
112
|
+
constructor(dbPath) {
|
|
113
|
+
this.db = new Database(dbPath);
|
|
114
|
+
this.db.pragma('journal_mode = WAL');
|
|
115
|
+
this.db.exec(CREATE_TABLE_SQL);
|
|
116
|
+
}
|
|
117
|
+
async save(namespace, key, data) {
|
|
118
|
+
this.db
|
|
119
|
+
.prepare(`INSERT OR REPLACE INTO kv_store (namespace, key, data, updated_at)
|
|
120
|
+
VALUES (?, ?, ?, ?)`)
|
|
121
|
+
.run(namespace, key, JSON.stringify(data, mapReplacer), Date.now());
|
|
122
|
+
}
|
|
123
|
+
async load(namespace, key) {
|
|
124
|
+
const row = this.db
|
|
125
|
+
.prepare(`SELECT data FROM kv_store WHERE namespace = ? AND key = ?`)
|
|
126
|
+
.get(namespace, key);
|
|
127
|
+
if (!row)
|
|
128
|
+
return null;
|
|
129
|
+
return JSON.parse(row.data, mapReviver);
|
|
130
|
+
}
|
|
131
|
+
async list(namespace) {
|
|
132
|
+
const rows = this.db
|
|
133
|
+
.prepare(`SELECT key FROM kv_store WHERE namespace = ? ORDER BY key`)
|
|
134
|
+
.all(namespace);
|
|
135
|
+
return rows.map((r) => r.key);
|
|
136
|
+
}
|
|
137
|
+
async delete(namespace, key) {
|
|
138
|
+
const result = this.db
|
|
139
|
+
.prepare(`DELETE FROM kv_store WHERE namespace = ? AND key = ?`)
|
|
140
|
+
.run(namespace, key);
|
|
141
|
+
return result.changes > 0;
|
|
142
|
+
}
|
|
143
|
+
async exists(namespace, key) {
|
|
144
|
+
const row = this.db
|
|
145
|
+
.prepare(`SELECT 1 FROM kv_store WHERE namespace = ? AND key = ? LIMIT 1`)
|
|
146
|
+
.get(namespace, key);
|
|
147
|
+
return row !== undefined;
|
|
148
|
+
}
|
|
149
|
+
/** Close the database connection */
|
|
150
|
+
close() {
|
|
151
|
+
this.db.close();
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
// =============================================================================
|
|
155
|
+
// FACTORY
|
|
156
|
+
// =============================================================================
|
|
157
|
+
/** Create a persistence adapter of the given type */
|
|
158
|
+
export function createPersistenceAdapter(type, config) {
|
|
159
|
+
if (type === 'json') {
|
|
160
|
+
if (!config.baseDir)
|
|
161
|
+
throw new Error('baseDir is required for json adapter');
|
|
162
|
+
return new JSONFilePersistenceAdapter(config.baseDir);
|
|
163
|
+
}
|
|
164
|
+
if (!config.dbPath)
|
|
165
|
+
throw new Error('dbPath is required for sqlite adapter');
|
|
166
|
+
return new SQLitePersistenceAdapter(config.dbPath);
|
|
167
|
+
}
|
|
168
|
+
//# sourceMappingURL=persistence.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"persistence.js","sourceRoot":"","sources":["../../../src/shared/persistence.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AAEtC,gFAAgF;AAChF,4DAA4D;AAC5D,gFAAgF;AAEhF,8EAA8E;AAC9E,SAAS,WAAW,CAAC,IAAY,EAAE,KAAc;IAC/C,IAAI,KAAK,YAAY,GAAG,EAAE,CAAC;QACzB,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,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