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,755 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lesson 25: MCP Client
|
|
3
|
+
*
|
|
4
|
+
* Connects to Model Context Protocol (MCP) servers to extend agent capabilities.
|
|
5
|
+
* Supports stdio-based servers (spawned as child processes).
|
|
6
|
+
*/
|
|
7
|
+
import { spawn } from 'node:child_process';
|
|
8
|
+
import { readFile } from 'node:fs/promises';
|
|
9
|
+
import { existsSync } from 'node:fs';
|
|
10
|
+
import { createInterface } from 'node:readline';
|
|
11
|
+
import { withRetry, MCP_RETRY_CONFIG } from '../utilities/retry.js';
|
|
12
|
+
import { MCPError, isRecoverable } from '../../errors/index.js';
|
|
13
|
+
import { validateAllTools, formatValidationSummary } from './mcp-tool-validator.js';
|
|
14
|
+
import { logger } from '../utilities/logger.js';
|
|
15
|
+
// =============================================================================
|
|
16
|
+
// MCP CLIENT
|
|
17
|
+
// =============================================================================
|
|
18
|
+
/**
|
|
19
|
+
* MCP Client manages connections to MCP servers.
|
|
20
|
+
*/
|
|
21
|
+
export class MCPClient {
|
|
22
|
+
config;
|
|
23
|
+
servers = new Map();
|
|
24
|
+
listeners = [];
|
|
25
|
+
dlq = null;
|
|
26
|
+
sessionId;
|
|
27
|
+
constructor(config = {}) {
|
|
28
|
+
this.config = {
|
|
29
|
+
configPath: config.configPath || '.mcp.json',
|
|
30
|
+
configPaths: config.configPaths ?? [],
|
|
31
|
+
requestTimeout: config.requestTimeout ?? 30000,
|
|
32
|
+
autoConnect: config.autoConnect ?? true,
|
|
33
|
+
lazyLoading: config.lazyLoading ?? false,
|
|
34
|
+
alwaysLoadTools: config.alwaysLoadTools ?? [],
|
|
35
|
+
summaryDescriptionLimit: config.summaryDescriptionLimit ?? 100,
|
|
36
|
+
maxToolsPerSearch: config.maxToolsPerSearch ?? 5,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Load servers from config file.
|
|
41
|
+
*/
|
|
42
|
+
async loadFromConfig(configPath) {
|
|
43
|
+
const path = configPath || this.config.configPath;
|
|
44
|
+
if (!existsSync(path)) {
|
|
45
|
+
return; // No config file, silently skip
|
|
46
|
+
}
|
|
47
|
+
try {
|
|
48
|
+
const content = await readFile(path, 'utf-8');
|
|
49
|
+
const mcpConfig = JSON.parse(content);
|
|
50
|
+
for (const [name, serverConfig] of Object.entries(mcpConfig.servers)) {
|
|
51
|
+
// Expand environment variables in config
|
|
52
|
+
const expandedConfig = this.expandEnvVars(serverConfig);
|
|
53
|
+
this.registerServer(name, expandedConfig);
|
|
54
|
+
if (this.config.autoConnect) {
|
|
55
|
+
await this.connectServer(name).catch(err => {
|
|
56
|
+
logger.warn('Failed to connect to MCP server', { server: name, error: String(err.message) });
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
catch (err) {
|
|
62
|
+
logger.warn('Failed to load MCP config', { path, error: String(err) });
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Load servers from multiple config files (hierarchical).
|
|
67
|
+
* Later configs override earlier ones for the same server name.
|
|
68
|
+
* Servers from all configs are merged together.
|
|
69
|
+
*/
|
|
70
|
+
async loadFromHierarchicalConfigs(configPaths) {
|
|
71
|
+
const mergedServers = {};
|
|
72
|
+
// Load and merge all configs
|
|
73
|
+
for (const configPath of configPaths) {
|
|
74
|
+
if (!existsSync(configPath)) {
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
try {
|
|
78
|
+
const content = await readFile(configPath, 'utf-8');
|
|
79
|
+
const mcpConfig = JSON.parse(content);
|
|
80
|
+
// Merge servers (later overrides earlier)
|
|
81
|
+
for (const [name, serverConfig] of Object.entries(mcpConfig.servers)) {
|
|
82
|
+
mergedServers[name] = this.expandEnvVars(serverConfig);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
catch (err) {
|
|
86
|
+
logger.warn('Failed to load MCP config', { configPath, error: String(err) });
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
// Register all merged servers
|
|
90
|
+
for (const [name, config] of Object.entries(mergedServers)) {
|
|
91
|
+
this.registerServer(name, config);
|
|
92
|
+
if (this.config.autoConnect) {
|
|
93
|
+
await this.connectServer(name).catch(err => {
|
|
94
|
+
logger.warn('Failed to connect to MCP server', { server: name, error: String(err.message) });
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Expand environment variables in config.
|
|
101
|
+
*/
|
|
102
|
+
expandEnvVars(config) {
|
|
103
|
+
const expand = (str) => {
|
|
104
|
+
return str.replace(/\$\{(\w+)\}/g, (_, name) => process.env[name] || '');
|
|
105
|
+
};
|
|
106
|
+
return {
|
|
107
|
+
command: expand(config.command),
|
|
108
|
+
args: config.args?.map(expand),
|
|
109
|
+
env: config.env
|
|
110
|
+
? Object.fromEntries(Object.entries(config.env).map(([k, v]) => [k, expand(v)]))
|
|
111
|
+
: undefined,
|
|
112
|
+
cwd: config.cwd ? expand(config.cwd) : undefined,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Register a server (without connecting).
|
|
117
|
+
*/
|
|
118
|
+
registerServer(name, config) {
|
|
119
|
+
this.servers.set(name, {
|
|
120
|
+
name,
|
|
121
|
+
config,
|
|
122
|
+
process: null,
|
|
123
|
+
readline: null,
|
|
124
|
+
tools: [],
|
|
125
|
+
status: 'disconnected',
|
|
126
|
+
pendingRequests: new Map(),
|
|
127
|
+
nextRequestId: 1,
|
|
128
|
+
loadedTools: new Set(),
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Connect to a registered server.
|
|
133
|
+
*/
|
|
134
|
+
async connectServer(name) {
|
|
135
|
+
const server = this.servers.get(name);
|
|
136
|
+
if (!server) {
|
|
137
|
+
throw MCPError.serverNotFound(name);
|
|
138
|
+
}
|
|
139
|
+
if (server.status === 'connected') {
|
|
140
|
+
return; // Already connected
|
|
141
|
+
}
|
|
142
|
+
server.status = 'connecting';
|
|
143
|
+
this.emit({ type: 'server.connecting', name });
|
|
144
|
+
try {
|
|
145
|
+
// Spawn the server process
|
|
146
|
+
const proc = spawn(server.config.command, server.config.args || [], {
|
|
147
|
+
env: { ...process.env, ...server.config.env },
|
|
148
|
+
cwd: server.config.cwd,
|
|
149
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
150
|
+
});
|
|
151
|
+
server.process = proc;
|
|
152
|
+
// Set up readline for stdout
|
|
153
|
+
server.readline = createInterface({
|
|
154
|
+
input: proc.stdout,
|
|
155
|
+
crlfDelay: Infinity,
|
|
156
|
+
});
|
|
157
|
+
// Handle incoming messages
|
|
158
|
+
server.readline.on('line', (line) => {
|
|
159
|
+
this.handleServerMessage(server, line);
|
|
160
|
+
});
|
|
161
|
+
// Handle errors
|
|
162
|
+
proc.stderr?.on('data', (data) => {
|
|
163
|
+
logger.error('MCP server stderr output', { server: name, output: data.toString() });
|
|
164
|
+
});
|
|
165
|
+
proc.on('error', (err) => {
|
|
166
|
+
server.status = 'error';
|
|
167
|
+
server.error = err.message;
|
|
168
|
+
// CRITICAL: Reject ALL pending requests before clearing
|
|
169
|
+
const errorMsg = new Error(`MCP server "${name}" process error: ${err.message}`);
|
|
170
|
+
for (const [_id, pending] of server.pendingRequests) {
|
|
171
|
+
pending.reject(errorMsg);
|
|
172
|
+
}
|
|
173
|
+
server.pendingRequests.clear();
|
|
174
|
+
this.emit({ type: 'server.error', name, error: err.message });
|
|
175
|
+
});
|
|
176
|
+
proc.on('exit', (code, signal) => {
|
|
177
|
+
// CRITICAL: Reject ALL pending requests before clearing
|
|
178
|
+
// This prevents orphaned promises that never resolve
|
|
179
|
+
const exitError = new Error(`MCP server "${name}" exited unexpectedly (code: ${code}, signal: ${signal})`);
|
|
180
|
+
for (const [_id, pending] of server.pendingRequests) {
|
|
181
|
+
pending.reject(exitError);
|
|
182
|
+
}
|
|
183
|
+
server.pendingRequests.clear();
|
|
184
|
+
server.status = 'disconnected';
|
|
185
|
+
server.process = null;
|
|
186
|
+
server.readline = null;
|
|
187
|
+
this.emit({ type: 'server.disconnected', name });
|
|
188
|
+
});
|
|
189
|
+
// Initialize the connection
|
|
190
|
+
await this.initializeServer(server);
|
|
191
|
+
server.status = 'connected';
|
|
192
|
+
this.emit({ type: 'server.connected', name, toolCount: server.tools.length });
|
|
193
|
+
}
|
|
194
|
+
catch (err) {
|
|
195
|
+
server.status = 'error';
|
|
196
|
+
server.error = err instanceof Error ? err.message : String(err);
|
|
197
|
+
this.emit({ type: 'server.error', name, error: server.error });
|
|
198
|
+
throw err;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Initialize MCP protocol with server.
|
|
203
|
+
*/
|
|
204
|
+
async initializeServer(server) {
|
|
205
|
+
// Send initialize request
|
|
206
|
+
const initResult = await this.sendRequest(server, 'initialize', {
|
|
207
|
+
protocolVersion: '2024-11-05',
|
|
208
|
+
capabilities: {},
|
|
209
|
+
clientInfo: {
|
|
210
|
+
name: 'first-principles-agent',
|
|
211
|
+
version: '1.0.0',
|
|
212
|
+
},
|
|
213
|
+
});
|
|
214
|
+
// Send initialized notification
|
|
215
|
+
this.sendNotification(server, 'notifications/initialized', {});
|
|
216
|
+
// List available tools
|
|
217
|
+
const toolsResult = await this.sendRequest(server, 'tools/list', {});
|
|
218
|
+
server.tools = toolsResult.tools || [];
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Send a JSON-RPC request and wait for response.
|
|
222
|
+
*/
|
|
223
|
+
sendRequest(server, method, params) {
|
|
224
|
+
return new Promise((resolve, reject) => {
|
|
225
|
+
const id = server.nextRequestId++;
|
|
226
|
+
const request = {
|
|
227
|
+
jsonrpc: '2.0',
|
|
228
|
+
id,
|
|
229
|
+
method,
|
|
230
|
+
params,
|
|
231
|
+
};
|
|
232
|
+
server.pendingRequests.set(id, { resolve, reject });
|
|
233
|
+
// Set timeout
|
|
234
|
+
const timeout = setTimeout(() => {
|
|
235
|
+
server.pendingRequests.delete(id);
|
|
236
|
+
reject(MCPError.timeout(server.name, method));
|
|
237
|
+
}, this.config.requestTimeout);
|
|
238
|
+
// Store timeout to clear later
|
|
239
|
+
const originalResolve = resolve;
|
|
240
|
+
server.pendingRequests.set(id, {
|
|
241
|
+
resolve: (result) => {
|
|
242
|
+
clearTimeout(timeout);
|
|
243
|
+
originalResolve(result);
|
|
244
|
+
},
|
|
245
|
+
reject: (error) => {
|
|
246
|
+
clearTimeout(timeout);
|
|
247
|
+
reject(error);
|
|
248
|
+
},
|
|
249
|
+
});
|
|
250
|
+
// Send request
|
|
251
|
+
server.process?.stdin?.write(JSON.stringify(request) + '\n');
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Send a JSON-RPC notification (no response expected).
|
|
256
|
+
*/
|
|
257
|
+
sendNotification(server, method, params) {
|
|
258
|
+
const notification = {
|
|
259
|
+
jsonrpc: '2.0',
|
|
260
|
+
method,
|
|
261
|
+
params,
|
|
262
|
+
};
|
|
263
|
+
server.process?.stdin?.write(JSON.stringify(notification) + '\n');
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Handle incoming message from server.
|
|
267
|
+
*/
|
|
268
|
+
handleServerMessage(server, line) {
|
|
269
|
+
let message;
|
|
270
|
+
try {
|
|
271
|
+
message = JSON.parse(line);
|
|
272
|
+
}
|
|
273
|
+
catch (parseError) {
|
|
274
|
+
// Log malformed JSON instead of silently ignoring
|
|
275
|
+
// This helps diagnose protocol desync issues
|
|
276
|
+
const preview = line.length > 100 ? line.substring(0, 100) + '...' : line;
|
|
277
|
+
logger.error('Malformed JSON-RPC message from MCP server', { server: server.name, preview });
|
|
278
|
+
this.emit({ type: 'server.error', name: server.name, error: 'Protocol error: malformed JSON' });
|
|
279
|
+
return; // Don't crash, just skip this malformed message
|
|
280
|
+
}
|
|
281
|
+
// Handle response
|
|
282
|
+
if (message.id !== undefined) {
|
|
283
|
+
const pending = server.pendingRequests.get(message.id);
|
|
284
|
+
if (pending) {
|
|
285
|
+
server.pendingRequests.delete(message.id);
|
|
286
|
+
if (message.error) {
|
|
287
|
+
pending.reject(new Error(message.error.message || 'Unknown error'));
|
|
288
|
+
}
|
|
289
|
+
else {
|
|
290
|
+
pending.resolve(message.result);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
// Handle notifications from server (if any)
|
|
295
|
+
// MCP servers can send notifications for things like resource updates
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Disconnect from a server.
|
|
299
|
+
*/
|
|
300
|
+
async disconnectServer(name) {
|
|
301
|
+
const server = this.servers.get(name);
|
|
302
|
+
if (!server) {
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
if (server.process) {
|
|
306
|
+
server.process.kill();
|
|
307
|
+
server.process = null;
|
|
308
|
+
}
|
|
309
|
+
if (server.readline) {
|
|
310
|
+
server.readline.close();
|
|
311
|
+
server.readline = null;
|
|
312
|
+
}
|
|
313
|
+
server.status = 'disconnected';
|
|
314
|
+
server.tools = [];
|
|
315
|
+
this.emit({ type: 'server.disconnected', name });
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Call a tool on a specific server.
|
|
319
|
+
* Includes automatic retry for transient failures (timeouts, connection resets).
|
|
320
|
+
*/
|
|
321
|
+
async callTool(serverName, toolName, args) {
|
|
322
|
+
const server = this.servers.get(serverName);
|
|
323
|
+
if (!server) {
|
|
324
|
+
throw MCPError.serverNotFound(serverName);
|
|
325
|
+
}
|
|
326
|
+
if (server.status !== 'connected') {
|
|
327
|
+
throw MCPError.serverNotConnected(serverName);
|
|
328
|
+
}
|
|
329
|
+
this.emit({ type: 'tool.call', server: serverName, tool: toolName });
|
|
330
|
+
try {
|
|
331
|
+
// Wrap the request with retry logic for transient failures
|
|
332
|
+
const result = await withRetry(async () => {
|
|
333
|
+
return await this.sendRequest(server, 'tools/call', {
|
|
334
|
+
name: toolName,
|
|
335
|
+
arguments: args,
|
|
336
|
+
});
|
|
337
|
+
}, {
|
|
338
|
+
maxAttempts: 2, // Initial + 1 retry
|
|
339
|
+
...MCP_RETRY_CONFIG,
|
|
340
|
+
onRetry: (attempt, error, delay) => {
|
|
341
|
+
this.emit({
|
|
342
|
+
type: 'tool.call',
|
|
343
|
+
server: serverName,
|
|
344
|
+
tool: toolName,
|
|
345
|
+
// @ts-expect-error Extended event with retry info
|
|
346
|
+
retry: { attempt, error: error.message, delayMs: delay },
|
|
347
|
+
});
|
|
348
|
+
},
|
|
349
|
+
});
|
|
350
|
+
this.emit({ type: 'tool.result', server: serverName, tool: toolName, success: true });
|
|
351
|
+
// Extract text content from result
|
|
352
|
+
const textContent = result.content
|
|
353
|
+
?.filter(c => c.type === 'text')
|
|
354
|
+
.map(c => c.text)
|
|
355
|
+
.join('\n');
|
|
356
|
+
return textContent || result;
|
|
357
|
+
}
|
|
358
|
+
catch (err) {
|
|
359
|
+
this.emit({ type: 'tool.result', server: serverName, tool: toolName, success: false });
|
|
360
|
+
// Write to DLQ if the error is not recoverable (permanent failure)
|
|
361
|
+
if (this.dlq?.isAvailable() && !isRecoverable(err)) {
|
|
362
|
+
try {
|
|
363
|
+
this.dlq.add({
|
|
364
|
+
operation: `mcp:${serverName}:${toolName}`,
|
|
365
|
+
args,
|
|
366
|
+
error: err,
|
|
367
|
+
sessionId: this.sessionId,
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
catch {
|
|
371
|
+
// Don't let DLQ errors affect MCP execution
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
throw err;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* List all servers and their status.
|
|
379
|
+
*/
|
|
380
|
+
listServers() {
|
|
381
|
+
return Array.from(this.servers.values()).map(s => ({
|
|
382
|
+
name: s.name,
|
|
383
|
+
status: s.status,
|
|
384
|
+
toolCount: s.tools.length,
|
|
385
|
+
error: s.error,
|
|
386
|
+
}));
|
|
387
|
+
}
|
|
388
|
+
/**
|
|
389
|
+
* Get tools from a specific server.
|
|
390
|
+
*/
|
|
391
|
+
getServerTools(serverName) {
|
|
392
|
+
const server = this.servers.get(serverName);
|
|
393
|
+
return server?.tools || [];
|
|
394
|
+
}
|
|
395
|
+
// ===========================================================================
|
|
396
|
+
// LAZY LOADING METHODS
|
|
397
|
+
// ===========================================================================
|
|
398
|
+
/**
|
|
399
|
+
* Get lightweight summaries for all tools (low token cost).
|
|
400
|
+
* Use this for initial context, then load full definitions on-demand.
|
|
401
|
+
*/
|
|
402
|
+
getAllToolSummaries() {
|
|
403
|
+
const summaries = [];
|
|
404
|
+
const descLimit = this.config.summaryDescriptionLimit;
|
|
405
|
+
for (const server of this.servers.values()) {
|
|
406
|
+
if (server.status !== 'connected')
|
|
407
|
+
continue;
|
|
408
|
+
for (const tool of server.tools) {
|
|
409
|
+
const fullName = `mcp_${server.name}_${tool.name}`;
|
|
410
|
+
const desc = tool.description || `MCP tool: ${tool.name}`;
|
|
411
|
+
summaries.push({
|
|
412
|
+
name: fullName,
|
|
413
|
+
description: desc.length > descLimit ? desc.slice(0, descLimit) + '...' : desc,
|
|
414
|
+
serverName: server.name,
|
|
415
|
+
originalName: tool.name,
|
|
416
|
+
});
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
return summaries;
|
|
420
|
+
}
|
|
421
|
+
/**
|
|
422
|
+
* Search tools by name or description with BM25-style scoring.
|
|
423
|
+
* Returns matching tool summaries sorted by relevance.
|
|
424
|
+
*/
|
|
425
|
+
searchTools(query, options = {}) {
|
|
426
|
+
const { limit = this.config.maxToolsPerSearch, regex = false } = options;
|
|
427
|
+
const summaries = this.getAllToolSummaries();
|
|
428
|
+
if (!query.trim()) {
|
|
429
|
+
return summaries.slice(0, limit);
|
|
430
|
+
}
|
|
431
|
+
// Normalize query
|
|
432
|
+
const queryLower = query.toLowerCase();
|
|
433
|
+
const queryTerms = queryLower.split(/\s+/).filter(t => t.length > 0);
|
|
434
|
+
// Score each tool
|
|
435
|
+
const scored = summaries.map(summary => {
|
|
436
|
+
let score = 0;
|
|
437
|
+
const nameLower = summary.name.toLowerCase();
|
|
438
|
+
const descLower = summary.description.toLowerCase();
|
|
439
|
+
const originalLower = summary.originalName.toLowerCase();
|
|
440
|
+
if (regex) {
|
|
441
|
+
try {
|
|
442
|
+
const re = new RegExp(query, 'i');
|
|
443
|
+
if (re.test(summary.name))
|
|
444
|
+
score += 10;
|
|
445
|
+
if (re.test(summary.description))
|
|
446
|
+
score += 5;
|
|
447
|
+
if (re.test(summary.originalName))
|
|
448
|
+
score += 8;
|
|
449
|
+
}
|
|
450
|
+
catch {
|
|
451
|
+
// Invalid regex, fall back to substring matching
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
// BM25-style term frequency scoring
|
|
455
|
+
for (const term of queryTerms) {
|
|
456
|
+
// Exact match bonuses
|
|
457
|
+
if (originalLower === term)
|
|
458
|
+
score += 20;
|
|
459
|
+
if (nameLower.includes(term))
|
|
460
|
+
score += 10;
|
|
461
|
+
if (originalLower.includes(term))
|
|
462
|
+
score += 8;
|
|
463
|
+
if (descLower.includes(term))
|
|
464
|
+
score += 3;
|
|
465
|
+
// Partial match (prefix)
|
|
466
|
+
if (originalLower.startsWith(term))
|
|
467
|
+
score += 5;
|
|
468
|
+
}
|
|
469
|
+
// Boost if all terms appear
|
|
470
|
+
const allTermsInName = queryTerms.every(t => nameLower.includes(t));
|
|
471
|
+
const allTermsInDesc = queryTerms.every(t => descLower.includes(t));
|
|
472
|
+
if (allTermsInName)
|
|
473
|
+
score += 15;
|
|
474
|
+
if (allTermsInDesc)
|
|
475
|
+
score += 5;
|
|
476
|
+
return { summary, score };
|
|
477
|
+
});
|
|
478
|
+
// Filter and sort by score
|
|
479
|
+
const results = scored
|
|
480
|
+
.filter(s => s.score > 0)
|
|
481
|
+
.sort((a, b) => b.score - a.score)
|
|
482
|
+
.slice(0, limit)
|
|
483
|
+
.map(s => s.summary);
|
|
484
|
+
this.emit({ type: 'tool.search', query, resultCount: results.length });
|
|
485
|
+
return results;
|
|
486
|
+
}
|
|
487
|
+
/**
|
|
488
|
+
* Get full tool definition for a specific tool.
|
|
489
|
+
* Marks the tool as loaded for context tracking.
|
|
490
|
+
*/
|
|
491
|
+
getFullToolDefinition(toolName) {
|
|
492
|
+
// Parse tool name: mcp_{serverName}_{originalToolName}
|
|
493
|
+
const match = toolName.match(/^mcp_([^_]+)_(.+)$/);
|
|
494
|
+
if (!match)
|
|
495
|
+
return null;
|
|
496
|
+
const [, serverName, originalName] = match;
|
|
497
|
+
const server = this.servers.get(serverName);
|
|
498
|
+
if (!server || server.status !== 'connected')
|
|
499
|
+
return null;
|
|
500
|
+
const mcpTool = server.tools.find(t => t.name === originalName);
|
|
501
|
+
if (!mcpTool)
|
|
502
|
+
return null;
|
|
503
|
+
// Mark as loaded
|
|
504
|
+
server.loadedTools.add(originalName);
|
|
505
|
+
this.emit({ type: 'tool.dynamicLoad', name: toolName, serverName });
|
|
506
|
+
return {
|
|
507
|
+
name: toolName,
|
|
508
|
+
description: mcpTool.description || `MCP tool: ${mcpTool.name} (from ${serverName})`,
|
|
509
|
+
parameters: mcpTool.inputSchema || { type: 'object', properties: {} },
|
|
510
|
+
execute: async (args) => {
|
|
511
|
+
return this.callTool(serverName, originalName, args);
|
|
512
|
+
},
|
|
513
|
+
};
|
|
514
|
+
}
|
|
515
|
+
/**
|
|
516
|
+
* Batch load multiple tools by name.
|
|
517
|
+
* Returns array of loaded ToolDefinitions.
|
|
518
|
+
*/
|
|
519
|
+
loadTools(toolNames) {
|
|
520
|
+
const loaded = [];
|
|
521
|
+
for (const name of toolNames) {
|
|
522
|
+
const tool = this.getFullToolDefinition(name);
|
|
523
|
+
if (tool) {
|
|
524
|
+
loaded.push(tool);
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
return loaded;
|
|
528
|
+
}
|
|
529
|
+
/**
|
|
530
|
+
* Get context statistics for MCP tools.
|
|
531
|
+
* Useful for monitoring token usage with lazy loading.
|
|
532
|
+
*/
|
|
533
|
+
getContextStats() {
|
|
534
|
+
let summaryCount = 0;
|
|
535
|
+
let loadedCount = 0;
|
|
536
|
+
let summaryTokens = 0;
|
|
537
|
+
let definitionTokens = 0;
|
|
538
|
+
for (const server of this.servers.values()) {
|
|
539
|
+
if (server.status !== 'connected')
|
|
540
|
+
continue;
|
|
541
|
+
for (const tool of server.tools) {
|
|
542
|
+
const isLoaded = server.loadedTools.has(tool.name);
|
|
543
|
+
if (isLoaded) {
|
|
544
|
+
loadedCount++;
|
|
545
|
+
// Full definition tokens: name + description + schema
|
|
546
|
+
const schemaStr = tool.inputSchema ? JSON.stringify(tool.inputSchema) : '{}';
|
|
547
|
+
const defChars = (tool.name.length) +
|
|
548
|
+
(tool.description?.length || 0) +
|
|
549
|
+
schemaStr.length;
|
|
550
|
+
definitionTokens += Math.ceil(defChars / 4); // ~4 chars per token
|
|
551
|
+
}
|
|
552
|
+
else {
|
|
553
|
+
summaryCount++;
|
|
554
|
+
// Summary tokens: name + truncated description
|
|
555
|
+
const descLen = Math.min(tool.description?.length || 0, this.config.summaryDescriptionLimit);
|
|
556
|
+
const sumChars = tool.name.length + descLen + server.name.length;
|
|
557
|
+
summaryTokens += Math.ceil(sumChars / 4);
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
return {
|
|
562
|
+
summaryTokens,
|
|
563
|
+
definitionTokens,
|
|
564
|
+
summaryCount,
|
|
565
|
+
loadedCount,
|
|
566
|
+
totalTools: summaryCount + loadedCount,
|
|
567
|
+
};
|
|
568
|
+
}
|
|
569
|
+
/**
|
|
570
|
+
* Check if a tool is fully loaded (has schema in context).
|
|
571
|
+
*/
|
|
572
|
+
isToolLoaded(toolName) {
|
|
573
|
+
const match = toolName.match(/^mcp_([^_]+)_(.+)$/);
|
|
574
|
+
if (!match)
|
|
575
|
+
return false;
|
|
576
|
+
const [, serverName, originalName] = match;
|
|
577
|
+
const server = this.servers.get(serverName);
|
|
578
|
+
return server?.loadedTools.has(originalName) ?? false;
|
|
579
|
+
}
|
|
580
|
+
/**
|
|
581
|
+
* Get all tools with lazy loading support.
|
|
582
|
+
* When lazyMode is true, only returns always-loaded tools + previously loaded tools.
|
|
583
|
+
* When lazyMode is false (default), returns all tools with full definitions.
|
|
584
|
+
*/
|
|
585
|
+
getAllTools(options = {}) {
|
|
586
|
+
const { lazyMode = this.config.lazyLoading } = options;
|
|
587
|
+
if (!lazyMode) {
|
|
588
|
+
// Original behavior: return all tools with full definitions
|
|
589
|
+
const tools = [];
|
|
590
|
+
for (const server of this.servers.values()) {
|
|
591
|
+
if (server.status !== 'connected')
|
|
592
|
+
continue;
|
|
593
|
+
for (const tool of server.tools) {
|
|
594
|
+
tools.push({
|
|
595
|
+
name: `mcp_${server.name}_${tool.name}`,
|
|
596
|
+
description: tool.description || `MCP tool: ${tool.name} (from ${server.name})`,
|
|
597
|
+
parameters: tool.inputSchema || { type: 'object', properties: {} },
|
|
598
|
+
execute: async (args) => {
|
|
599
|
+
return this.callTool(server.name, tool.name, args);
|
|
600
|
+
},
|
|
601
|
+
});
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
// Validate tool descriptions (non-invasive: logs warnings, doesn't reject tools)
|
|
605
|
+
if (tools.length > 0) {
|
|
606
|
+
try {
|
|
607
|
+
const results = validateAllTools(tools);
|
|
608
|
+
const poor = results.filter(r => r.score < 50);
|
|
609
|
+
if (poor.length > 0) {
|
|
610
|
+
logger.warn('MCP tool quality issues detected', { poorCount: poor.length, totalCount: tools.length, summary: formatValidationSummary(poor) });
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
catch {
|
|
614
|
+
// Validation is optional — don't fail if module has issues
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
return tools;
|
|
618
|
+
}
|
|
619
|
+
// Lazy mode: only return always-loaded tools + previously loaded tools
|
|
620
|
+
const tools = [];
|
|
621
|
+
for (const server of this.servers.values()) {
|
|
622
|
+
if (server.status !== 'connected')
|
|
623
|
+
continue;
|
|
624
|
+
for (const tool of server.tools) {
|
|
625
|
+
const fullName = `mcp_${server.name}_${tool.name}`;
|
|
626
|
+
const isAlwaysLoaded = this.config.alwaysLoadTools.some(pattern => fullName.includes(pattern) || tool.name.includes(pattern));
|
|
627
|
+
const isPreviouslyLoaded = server.loadedTools.has(tool.name);
|
|
628
|
+
if (isAlwaysLoaded || isPreviouslyLoaded) {
|
|
629
|
+
// Mark as loaded
|
|
630
|
+
server.loadedTools.add(tool.name);
|
|
631
|
+
tools.push({
|
|
632
|
+
name: fullName,
|
|
633
|
+
description: tool.description || `MCP tool: ${tool.name} (from ${server.name})`,
|
|
634
|
+
parameters: tool.inputSchema || { type: 'object', properties: {} },
|
|
635
|
+
execute: async (args) => {
|
|
636
|
+
return this.callTool(server.name, tool.name, args);
|
|
637
|
+
},
|
|
638
|
+
});
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
return tools;
|
|
643
|
+
}
|
|
644
|
+
/**
|
|
645
|
+
* Check if a server is connected.
|
|
646
|
+
*/
|
|
647
|
+
isConnected(serverName) {
|
|
648
|
+
const server = this.servers.get(serverName);
|
|
649
|
+
return server?.status === 'connected';
|
|
650
|
+
}
|
|
651
|
+
/**
|
|
652
|
+
* Subscribe to events.
|
|
653
|
+
*/
|
|
654
|
+
on(listener) {
|
|
655
|
+
this.listeners.push(listener);
|
|
656
|
+
return () => {
|
|
657
|
+
const idx = this.listeners.indexOf(listener);
|
|
658
|
+
if (idx >= 0)
|
|
659
|
+
this.listeners.splice(idx, 1);
|
|
660
|
+
};
|
|
661
|
+
}
|
|
662
|
+
/**
|
|
663
|
+
* Set the dead letter queue for failed operation tracking.
|
|
664
|
+
* When set, permanent failures will be logged to the DLQ for later retry.
|
|
665
|
+
*/
|
|
666
|
+
setDeadLetterQueue(dlq, sessionId) {
|
|
667
|
+
this.dlq = dlq;
|
|
668
|
+
this.sessionId = sessionId;
|
|
669
|
+
}
|
|
670
|
+
/**
|
|
671
|
+
* Emit an event.
|
|
672
|
+
*/
|
|
673
|
+
emit(event) {
|
|
674
|
+
for (const listener of this.listeners) {
|
|
675
|
+
try {
|
|
676
|
+
listener(event);
|
|
677
|
+
}
|
|
678
|
+
catch {
|
|
679
|
+
// Ignore listener errors
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
/**
|
|
684
|
+
* Cleanup - disconnect all servers.
|
|
685
|
+
*/
|
|
686
|
+
async cleanup() {
|
|
687
|
+
for (const name of this.servers.keys()) {
|
|
688
|
+
await this.disconnectServer(name);
|
|
689
|
+
}
|
|
690
|
+
this.servers.clear();
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
// =============================================================================
|
|
694
|
+
// FACTORY
|
|
695
|
+
// =============================================================================
|
|
696
|
+
/**
|
|
697
|
+
* Create and initialize an MCP client.
|
|
698
|
+
*/
|
|
699
|
+
export async function createMCPClient(config) {
|
|
700
|
+
const client = new MCPClient(config);
|
|
701
|
+
// Use hierarchical loading if configPaths provided, otherwise single config
|
|
702
|
+
if (config?.configPaths && config.configPaths.length > 0) {
|
|
703
|
+
await client.loadFromHierarchicalConfigs(config.configPaths);
|
|
704
|
+
}
|
|
705
|
+
else {
|
|
706
|
+
await client.loadFromConfig();
|
|
707
|
+
}
|
|
708
|
+
return client;
|
|
709
|
+
}
|
|
710
|
+
// =============================================================================
|
|
711
|
+
// UTILITIES
|
|
712
|
+
// =============================================================================
|
|
713
|
+
/**
|
|
714
|
+
* Format server list for display.
|
|
715
|
+
*/
|
|
716
|
+
export function formatServerList(servers) {
|
|
717
|
+
if (servers.length === 0) {
|
|
718
|
+
return 'No MCP servers configured.';
|
|
719
|
+
}
|
|
720
|
+
const lines = ['MCP Servers:'];
|
|
721
|
+
for (const server of servers) {
|
|
722
|
+
const statusIcon = server.status === 'connected' ? '✓' : server.status === 'error' ? '✗' : '○';
|
|
723
|
+
const statusColor = server.status === 'connected' ? 'green' : server.status === 'error' ? 'red' : 'dim';
|
|
724
|
+
lines.push(` ${statusIcon} ${server.name} (${server.status}) - ${server.toolCount} tools`);
|
|
725
|
+
if (server.error) {
|
|
726
|
+
lines.push(` Error: ${server.error}`);
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
return lines.join('\n');
|
|
730
|
+
}
|
|
731
|
+
/**
|
|
732
|
+
* Create a sample .mcp.json config file content.
|
|
733
|
+
*/
|
|
734
|
+
export function getSampleMCPConfig() {
|
|
735
|
+
return JSON.stringify({
|
|
736
|
+
servers: {
|
|
737
|
+
filesystem: {
|
|
738
|
+
command: 'npx',
|
|
739
|
+
args: ['-y', '@anthropic/mcp-server-filesystem', '/path/to/allowed/dir'],
|
|
740
|
+
},
|
|
741
|
+
sqlite: {
|
|
742
|
+
command: 'npx',
|
|
743
|
+
args: ['-y', '@anthropic/mcp-server-sqlite', '~/database.db'],
|
|
744
|
+
},
|
|
745
|
+
github: {
|
|
746
|
+
command: 'npx',
|
|
747
|
+
args: ['-y', '@anthropic/mcp-server-github'],
|
|
748
|
+
env: {
|
|
749
|
+
GITHUB_TOKEN: '${GITHUB_TOKEN}',
|
|
750
|
+
},
|
|
751
|
+
},
|
|
752
|
+
},
|
|
753
|
+
}, null, 2);
|
|
754
|
+
}
|
|
755
|
+
//# sourceMappingURL=mcp-client.js.map
|