attocode 0.2.4 → 0.2.6
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 +88 -1
- package/dist/src/adapters.d.ts +39 -1
- package/dist/src/adapters.d.ts.map +1 -1
- package/dist/src/adapters.js +201 -16
- 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 +676 -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 +176 -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 +264 -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-tools/lsp-file-tools.js +17 -13
- package/dist/src/agent-tools/lsp-file-tools.js.map +1 -1
- package/dist/src/agent.d.ts +26 -117
- package/dist/src/agent.d.ts.map +1 -1
- package/dist/src/agent.js +239 -1249
- package/dist/src/agent.js.map +1 -1
- package/dist/src/analysis/feedback-loop.d.ts.map +1 -1
- package/dist/src/analysis/feedback-loop.js +13 -9
- package/dist/src/analysis/feedback-loop.js.map +1 -1
- package/dist/src/analysis/index.d.ts +1 -1
- package/dist/src/analysis/index.d.ts.map +1 -1
- package/dist/src/analysis/index.js +1 -1
- package/dist/src/analysis/index.js.map +1 -1
- package/dist/src/analysis/prompt-templates.d.ts.map +1 -1
- package/dist/src/analysis/prompt-templates.js.map +1 -1
- package/dist/src/analysis/trace-summary.d.ts.map +1 -1
- package/dist/src/analysis/trace-summary.js +25 -9
- package/dist/src/analysis/trace-summary.js.map +1 -1
- package/dist/src/cli.d.ts.map +1 -1
- package/dist/src/cli.js +4 -2
- package/dist/src/cli.js.map +1 -1
- package/dist/src/commands/agents-commands.d.ts.map +1 -1
- package/dist/src/commands/agents-commands.js +3 -3
- package/dist/src/commands/agents-commands.js.map +1 -1
- package/dist/src/commands/handler.d.ts.map +1 -1
- package/dist/src/commands/handler.js +68 -44
- 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 +8 -10
- package/dist/src/commands/init-commands.js.map +1 -1
- package/dist/src/commands/init.js +17 -17
- package/dist/src/commands/init.js.map +1 -1
- package/dist/src/commands/skills-commands.d.ts.map +1 -1
- package/dist/src/commands/skills-commands.js +10 -7
- package/dist/src/commands/skills-commands.js.map +1 -1
- package/dist/src/commands/types.d.ts.map +1 -1
- package/dist/src/config/config-manager.d.ts.map +1 -1
- package/dist/src/config/config-manager.js +4 -1
- package/dist/src/config/config-manager.js.map +1 -1
- package/dist/src/config/index.d.ts +1 -1
- package/dist/src/config/index.d.ts.map +1 -1
- package/dist/src/config/schema.d.ts +6 -6
- package/dist/src/config/schema.d.ts.map +1 -1
- package/dist/src/config/schema.js +6 -2
- package/dist/src/config/schema.js.map +1 -1
- package/dist/src/core/agent-state-machine.d.ts.map +1 -1
- package/dist/src/core/agent-state-machine.js +5 -2
- package/dist/src/core/agent-state-machine.js.map +1 -1
- package/dist/src/core/completion-analyzer.d.ts.map +1 -1
- package/dist/src/core/completion-analyzer.js +2 -2
- package/dist/src/core/completion-analyzer.js.map +1 -1
- package/dist/src/core/execution-loop.d.ts +172 -1
- package/dist/src/core/execution-loop.d.ts.map +1 -1
- package/dist/src/core/execution-loop.js +597 -360
- package/dist/src/core/execution-loop.js.map +1 -1
- package/dist/src/core/index.d.ts +2 -2
- package/dist/src/core/index.d.ts.map +1 -1
- package/dist/src/core/index.js +1 -1
- package/dist/src/core/index.js.map +1 -1
- package/dist/src/core/queues/event-queue.d.ts.map +1 -1
- package/dist/src/core/queues/event-queue.js.map +1 -1
- package/dist/src/core/response-handler.d.ts.map +1 -1
- package/dist/src/core/response-handler.js +20 -10
- package/dist/src/core/response-handler.js.map +1 -1
- package/dist/src/core/subagent-spawner.d.ts.map +1 -1
- package/dist/src/core/subagent-spawner.js +98 -59
- package/dist/src/core/subagent-spawner.js.map +1 -1
- package/dist/src/core/tool-executor.d.ts.map +1 -1
- package/dist/src/core/tool-executor.js +63 -27
- package/dist/src/core/tool-executor.js.map +1 -1
- package/dist/src/core/types.d.ts +1 -0
- package/dist/src/core/types.d.ts.map +1 -1
- package/dist/src/core/types.js.map +1 -1
- package/dist/src/costs/model-registry.js +6 -6
- package/dist/src/costs/model-registry.js.map +1 -1
- package/dist/src/defaults.d.ts.map +1 -1
- package/dist/src/defaults.js +67 -20
- package/dist/src/defaults.js.map +1 -1
- package/dist/src/errors/index.d.ts.map +1 -1
- package/dist/src/errors/index.js +6 -8
- package/dist/src/errors/index.js.map +1 -1
- package/dist/src/first-run.d.ts.map +1 -1
- package/dist/src/first-run.js +11 -11
- package/dist/src/first-run.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 +211 -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 +264 -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 +302 -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 +953 -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 +256 -0
- package/dist/src/integrations/agents/subagent-output-store.js.map +1 -0
- package/dist/src/integrations/budget/budget-pool.d.ts +115 -0
- package/dist/src/integrations/budget/budget-pool.d.ts.map +1 -0
- package/dist/src/integrations/budget/budget-pool.js +201 -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 +534 -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 +149 -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 +1039 -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 +304 -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 +265 -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 +362 -0
- package/dist/src/integrations/budget/resources.js.map +1 -0
- package/dist/src/integrations/context/auto-compaction.d.ts +210 -0
- package/dist/src/integrations/context/auto-compaction.d.ts.map +1 -0
- package/dist/src/integrations/context/auto-compaction.js +485 -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 +445 -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 +668 -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 +881 -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 +694 -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 +391 -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 +377 -0
- package/dist/src/integrations/context/semantic-cache.js.map +1 -0
- package/dist/src/integrations/index.d.ts +72 -68
- package/dist/src/integrations/index.d.ts.map +1 -1
- package/dist/src/integrations/index.js +76 -68
- package/dist/src/integrations/index.js.map +1 -1
- package/dist/src/integrations/lsp/lsp.d.ts +196 -0
- package/dist/src/integrations/lsp/lsp.d.ts.map +1 -0
- package/dist/src/integrations/lsp/lsp.js +583 -0
- package/dist/src/integrations/lsp/lsp.js.map +1 -0
- package/dist/src/integrations/mcp/mcp-client.d.ts +279 -0
- package/dist/src/integrations/mcp/mcp-client.d.ts.map +1 -0
- package/dist/src/integrations/mcp/mcp-client.js +776 -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 +139 -0
- package/dist/src/integrations/mcp/mcp-tool-validator.js.map +1 -0
- package/dist/src/integrations/persistence/codebase-repository.d.ts +45 -0
- package/dist/src/integrations/persistence/codebase-repository.d.ts.map +1 -0
- package/dist/src/integrations/persistence/codebase-repository.js +85 -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 +187 -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 +163 -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 +200 -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 +781 -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 +680 -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 +181 -0
- package/dist/src/integrations/persistence/worker-repository.js.map +1 -0
- package/dist/src/integrations/quality/auto-checkpoint.d.ts +98 -0
- package/dist/src/integrations/quality/auto-checkpoint.d.ts.map +1 -0
- package/dist/src/integrations/quality/auto-checkpoint.js +250 -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 +549 -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 +418 -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 +723 -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 +298 -0
- package/dist/src/integrations/quality/tool-recommendation.js.map +1 -0
- package/dist/src/integrations/safety/bash-policy.d.ts +33 -0
- package/dist/src/integrations/safety/bash-policy.d.ts.map +1 -0
- package/dist/src/integrations/safety/bash-policy.js +147 -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 +362 -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 +287 -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 +473 -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 +333 -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 +410 -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 +333 -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 +291 -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 +146 -0
- package/dist/src/integrations/safety/type-checker.js.map +1 -0
- package/dist/src/integrations/skills/skill-executor.d.ts +113 -0
- package/dist/src/integrations/skills/skill-executor.d.ts.map +1 -0
- package/dist/src/integrations/skills/skill-executor.js +266 -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 +611 -0
- package/dist/src/integrations/skills/skills.js.map +1 -0
- package/dist/src/integrations/streaming/pty-shell.d.ts +169 -0
- package/dist/src/integrations/streaming/pty-shell.d.ts.map +1 -0
- package/dist/src/integrations/streaming/pty-shell.js +371 -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 +364 -0
- package/dist/src/integrations/streaming/streaming.js.map +1 -0
- package/dist/src/integrations/swarm/failure-classifier.d.ts.map +1 -1
- package/dist/src/integrations/swarm/failure-classifier.js +18 -3
- package/dist/src/integrations/swarm/failure-classifier.js.map +1 -1
- package/dist/src/integrations/swarm/index.d.ts +6 -5
- package/dist/src/integrations/swarm/index.d.ts.map +1 -1
- package/dist/src/integrations/swarm/index.js +5 -3
- 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 +21 -24
- package/dist/src/integrations/swarm/model-selector.js.map +1 -1
- package/dist/src/integrations/swarm/request-throttle.d.ts.map +1 -1
- package/dist/src/integrations/swarm/request-throttle.js +7 -4
- package/dist/src/integrations/swarm/request-throttle.js.map +1 -1
- package/dist/src/integrations/swarm/swarm-budget.d.ts +1 -1
- package/dist/src/integrations/swarm/swarm-budget.d.ts.map +1 -1
- package/dist/src/integrations/swarm/swarm-budget.js +1 -1
- package/dist/src/integrations/swarm/swarm-budget.js.map +1 -1
- package/dist/src/integrations/swarm/swarm-config-loader.d.ts.map +1 -1
- package/dist/src/integrations/swarm/swarm-config-loader.js +53 -17
- package/dist/src/integrations/swarm/swarm-config-loader.js.map +1 -1
- package/dist/src/integrations/swarm/swarm-event-bridge.d.ts.map +1 -1
- package/dist/src/integrations/swarm/swarm-event-bridge.js +69 -23
- package/dist/src/integrations/swarm/swarm-event-bridge.js.map +1 -1
- package/dist/src/integrations/swarm/swarm-events.d.ts +1 -1
- package/dist/src/integrations/swarm/swarm-events.d.ts.map +1 -1
- package/dist/src/integrations/swarm/swarm-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 +1071 -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 +108 -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 +977 -0
- package/dist/src/integrations/swarm/swarm-lifecycle.js.map +1 -0
- package/dist/src/integrations/swarm/swarm-orchestrator.d.ts +84 -203
- package/dist/src/integrations/swarm/swarm-orchestrator.d.ts.map +1 -1
- package/dist/src/integrations/swarm/swarm-orchestrator.js +338 -2899
- package/dist/src/integrations/swarm/swarm-orchestrator.js.map +1 -1
- package/dist/src/integrations/swarm/swarm-quality-gate.d.ts.map +1 -1
- package/dist/src/integrations/swarm/swarm-quality-gate.js +19 -15
- 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 +563 -0
- package/dist/src/integrations/swarm/swarm-recovery.js.map +1 -0
- package/dist/src/integrations/swarm/swarm-state-store.d.ts.map +1 -1
- package/dist/src/integrations/swarm/swarm-state-store.js +8 -0
- package/dist/src/integrations/swarm/swarm-state-store.js.map +1 -1
- package/dist/src/integrations/swarm/task-queue.d.ts +8 -2
- package/dist/src/integrations/swarm/task-queue.d.ts.map +1 -1
- package/dist/src/integrations/swarm/task-queue.js +60 -26
- package/dist/src/integrations/swarm/task-queue.js.map +1 -1
- package/dist/src/integrations/swarm/types.d.ts +17 -5
- package/dist/src/integrations/swarm/types.d.ts.map +1 -1
- package/dist/src/integrations/swarm/types.js +89 -12
- package/dist/src/integrations/swarm/types.js.map +1 -1
- package/dist/src/integrations/swarm/worker-pool.d.ts +1 -1
- package/dist/src/integrations/swarm/worker-pool.d.ts.map +1 -1
- package/dist/src/integrations/swarm/worker-pool.js +43 -31
- package/dist/src/integrations/swarm/worker-pool.js.map +1 -1
- package/dist/src/integrations/tasks/dependency-analyzer.d.ts +34 -0
- package/dist/src/integrations/tasks/dependency-analyzer.d.ts.map +1 -0
- package/dist/src/integrations/tasks/dependency-analyzer.js +231 -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 +648 -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 +432 -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 +668 -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 +390 -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 +542 -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 +195 -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 +287 -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 +464 -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 +496 -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 +94 -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 +537 -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 +385 -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 +508 -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 +301 -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 +217 -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 +309 -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 +408 -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 +269 -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 +360 -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 +282 -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 +377 -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 +359 -0
- package/dist/src/integrations/utilities/thread-manager.js.map +1 -0
- package/dist/src/integrations/utilities/token-estimate.d.ts +16 -0
- package/dist/src/integrations/utilities/token-estimate.d.ts.map +1 -0
- package/dist/src/integrations/utilities/token-estimate.js +20 -0
- package/dist/src/integrations/utilities/token-estimate.js.map +1 -0
- package/dist/src/main.js +50 -27
- package/dist/src/main.js.map +1 -1
- package/dist/src/modes/repl.d.ts.map +1 -1
- package/dist/src/modes/repl.js +73 -22
- 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 +93 -16
- package/dist/src/modes/tui.js.map +1 -1
- package/dist/src/modes.d.ts.map +1 -1
- package/dist/src/modes.js +14 -14
- package/dist/src/modes.js.map +1 -1
- package/dist/src/observability/tracer.d.ts.map +1 -1
- package/dist/src/observability/tracer.js +8 -4
- package/dist/src/observability/tracer.js.map +1 -1
- package/dist/src/observability/types.d.ts.map +1 -1
- package/dist/src/observability/types.js.map +1 -1
- package/dist/src/paths.d.ts.map +1 -1
- package/dist/src/paths.js +2 -6
- package/dist/src/paths.js.map +1 -1
- package/dist/src/persistence/migrator.d.ts.map +1 -1
- package/dist/src/persistence/migrator.js +7 -7
- package/dist/src/persistence/migrator.js.map +1 -1
- package/dist/src/persistence/schema.d.ts +2 -0
- package/dist/src/persistence/schema.d.ts.map +1 -1
- package/dist/src/persistence/schema.js +31 -0
- package/dist/src/persistence/schema.js.map +1 -1
- package/dist/src/providers/adapters/anthropic.d.ts +6 -0
- package/dist/src/providers/adapters/anthropic.d.ts.map +1 -1
- package/dist/src/providers/adapters/anthropic.js +132 -36
- 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 +369 -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 +51 -10
- 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 +57 -19
- 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 +127 -30
- package/dist/src/providers/adapters/openrouter.js.map +1 -1
- package/dist/src/providers/circuit-breaker.d.ts.map +1 -1
- package/dist/src/providers/circuit-breaker.js +4 -3
- package/dist/src/providers/circuit-breaker.js.map +1 -1
- package/dist/src/providers/fallback-chain.d.ts.map +1 -1
- package/dist/src/providers/fallback-chain.js +3 -3
- package/dist/src/providers/fallback-chain.js.map +1 -1
- package/dist/src/providers/llm-resilience.d.ts.map +1 -1
- package/dist/src/providers/llm-resilience.js +2 -2
- package/dist/src/providers/llm-resilience.js.map +1 -1
- package/dist/src/providers/provider.d.ts.map +1 -1
- package/dist/src/providers/provider.js +2 -3
- package/dist/src/providers/provider.js.map +1 -1
- package/dist/src/providers/resilient-fetch.d.ts.map +1 -1
- package/dist/src/providers/resilient-fetch.js +3 -4
- package/dist/src/providers/resilient-fetch.js.map +1 -1
- package/dist/src/providers/resilient-provider.d.ts.map +1 -1
- package/dist/src/providers/resilient-provider.js +9 -6
- 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 +10 -6
- package/dist/src/session-picker.js.map +1 -1
- package/dist/src/shared/budget-tracker.d.ts.map +1 -1
- package/dist/src/shared/budget-tracker.js +2 -2
- package/dist/src/shared/budget-tracker.js.map +1 -1
- package/dist/src/shared/context-engine.d.ts.map +1 -1
- package/dist/src/shared/context-engine.js +1 -1
- package/dist/src/shared/context-engine.js.map +1 -1
- package/dist/src/shared/persistence.d.ts.map +1 -1
- package/dist/src/shared/persistence.js +2 -6
- package/dist/src/shared/persistence.js.map +1 -1
- package/dist/src/shared/shared-context-state.d.ts.map +1 -1
- package/dist/src/shared/shared-context-state.js.map +1 -1
- package/dist/src/shared/shared-economics-state.d.ts.map +1 -1
- package/dist/src/shared/shared-economics-state.js.map +1 -1
- package/dist/src/tools/agent.d.ts +2 -2
- package/dist/src/tools/agent.d.ts.map +1 -1
- package/dist/src/tools/agent.js +10 -7
- package/dist/src/tools/agent.js.map +1 -1
- package/dist/src/tools/bash.d.ts.map +1 -1
- package/dist/src/tools/bash.js +1 -1
- package/dist/src/tools/bash.js.map +1 -1
- package/dist/src/tools/coercion.js +1 -1
- package/dist/src/tools/coercion.js.map +1 -1
- package/dist/src/tools/file.d.ts.map +1 -1
- package/dist/src/tools/file.js +2 -2
- package/dist/src/tools/file.js.map +1 -1
- package/dist/src/tools/permission.js +7 -8
- 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 +4 -6
- package/dist/src/tools/registry.js.map +1 -1
- package/dist/src/tools/standard.d.ts.map +1 -1
- package/dist/src/tools/standard.js +1 -3
- package/dist/src/tools/standard.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/tasks.js +4 -4
- package/dist/src/tools/tasks.js.map +1 -1
- package/dist/src/tools/types.d.ts.map +1 -1
- package/dist/src/tools/types.js +5 -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/tools/undo.js +4 -2
- package/dist/src/tools/undo.js.map +1 -1
- package/dist/src/tracing/cache-boundary-tracker.d.ts.map +1 -1
- package/dist/src/tracing/cache-boundary-tracker.js +9 -13
- package/dist/src/tracing/cache-boundary-tracker.js.map +1 -1
- package/dist/src/tracing/trace-collector.d.ts +22 -0
- package/dist/src/tracing/trace-collector.d.ts.map +1 -1
- package/dist/src/tracing/trace-collector.js +55 -31
- package/dist/src/tracing/trace-collector.js.map +1 -1
- package/dist/src/tracing/types.d.ts +17 -1
- package/dist/src/tracing/types.d.ts.map +1 -1
- package/dist/src/tracing/types.js.map +1 -1
- package/dist/src/tricks/failure-evidence.d.ts.map +1 -1
- package/dist/src/tricks/failure-evidence.js +17 -27
- package/dist/src/tricks/failure-evidence.js.map +1 -1
- package/dist/src/tricks/json-utils.d.ts.map +1 -1
- package/dist/src/tricks/json-utils.js +1 -4
- package/dist/src/tricks/json-utils.js.map +1 -1
- package/dist/src/tricks/kv-cache-context.d.ts.map +1 -1
- package/dist/src/tricks/kv-cache-context.js +2 -3
- package/dist/src/tricks/kv-cache-context.js.map +1 -1
- package/dist/src/tricks/recitation.d.ts.map +1 -1
- package/dist/src/tricks/recitation.js +24 -19
- 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 +10 -7
- 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 +17 -9
- package/dist/src/tricks/reversible-compaction.js.map +1 -1
- package/dist/src/tricks/serialization-diversity.d.ts.map +1 -1
- package/dist/src/tricks/serialization-diversity.js +12 -12
- package/dist/src/tricks/serialization-diversity.js.map +1 -1
- package/dist/src/tui/app.d.ts +9 -5
- package/dist/src/tui/app.d.ts.map +1 -1
- package/dist/src/tui/app.js +690 -565
- package/dist/src/tui/app.js.map +1 -1
- package/dist/src/tui/components/ActiveAgentsPanel.d.ts +2 -0
- package/dist/src/tui/components/ActiveAgentsPanel.d.ts.map +1 -1
- package/dist/src/tui/components/ActiveAgentsPanel.js +5 -5
- package/dist/src/tui/components/ActiveAgentsPanel.js.map +1 -1
- package/dist/src/tui/components/ApprovalDialog.d.ts.map +1 -1
- package/dist/src/tui/components/ApprovalDialog.js +14 -0
- package/dist/src/tui/components/ApprovalDialog.js.map +1 -1
- package/dist/src/tui/components/BudgetExtensionDialog.d.ts +18 -0
- package/dist/src/tui/components/BudgetExtensionDialog.d.ts.map +1 -0
- package/dist/src/tui/components/BudgetExtensionDialog.js +40 -0
- package/dist/src/tui/components/BudgetExtensionDialog.js.map +1 -0
- 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/CollapsibleDiffView.js +18 -13
- package/dist/src/tui/components/CollapsibleDiffView.js.map +1 -1
- package/dist/src/tui/components/DebugPanel.d.ts.map +1 -1
- package/dist/src/tui/components/DebugPanel.js +46 -26
- package/dist/src/tui/components/DebugPanel.js.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 +63 -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/DiffView.js +21 -14
- package/dist/src/tui/components/DiffView.js.map +1 -1
- package/dist/src/tui/components/ErrorBoundary.d.ts.map +1 -1
- package/dist/src/tui/components/ErrorBoundary.js +8 -3
- package/dist/src/tui/components/ErrorBoundary.js.map +1 -1
- package/dist/src/tui/components/ErrorDetailPanel.d.ts.map +1 -1
- package/dist/src/tui/components/ErrorDetailPanel.js +4 -4
- package/dist/src/tui/components/ErrorDetailPanel.js.map +1 -1
- package/dist/src/tui/components/FileChangeSummary.d.ts.map +1 -1
- package/dist/src/tui/components/FileChangeSummary.js +3 -3
- package/dist/src/tui/components/FileChangeSummary.js.map +1 -1
- package/dist/src/tui/components/InputArea.d.ts.map +1 -1
- package/dist/src/tui/components/InputArea.js +32 -15
- package/dist/src/tui/components/InputArea.js.map +1 -1
- package/dist/src/tui/components/LearningValidationDialog.d.ts +25 -0
- package/dist/src/tui/components/LearningValidationDialog.d.ts.map +1 -0
- package/dist/src/tui/components/LearningValidationDialog.js +35 -0
- package/dist/src/tui/components/LearningValidationDialog.js.map +1 -0
- package/dist/src/tui/components/MessageItem.d.ts.map +1 -1
- package/dist/src/tui/components/MessageItem.js.map +1 -1
- package/dist/src/tui/components/PlanPanel.d.ts +27 -0
- package/dist/src/tui/components/PlanPanel.d.ts.map +1 -0
- package/dist/src/tui/components/PlanPanel.js +45 -0
- package/dist/src/tui/components/PlanPanel.js.map +1 -0
- package/dist/src/tui/components/ScrollableBox.d.ts.map +1 -1
- package/dist/src/tui/components/ScrollableBox.js +2 -2
- package/dist/src/tui/components/ScrollableBox.js.map +1 -1
- package/dist/src/tui/components/SideBySideDiff.d.ts.map +1 -1
- package/dist/src/tui/components/SideBySideDiff.js +20 -18
- package/dist/src/tui/components/SideBySideDiff.js.map +1 -1
- package/dist/src/tui/components/StatusBar.d.ts +41 -0
- package/dist/src/tui/components/StatusBar.d.ts.map +1 -0
- package/dist/src/tui/components/StatusBar.js +114 -0
- package/dist/src/tui/components/StatusBar.js.map +1 -0
- package/dist/src/tui/components/SwarmStatusPanel.d.ts.map +1 -1
- package/dist/src/tui/components/SwarmStatusPanel.js +25 -17
- package/dist/src/tui/components/SwarmStatusPanel.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/components/TasksPanel.js +12 -11
- package/dist/src/tui/components/TasksPanel.js.map +1 -1
- package/dist/src/tui/components/ToolCallItem.d.ts.map +1 -1
- package/dist/src/tui/components/ToolCallItem.js +19 -6
- package/dist/src/tui/components/ToolCallItem.js.map +1 -1
- package/dist/src/tui/components/ToolCallsPanel.d.ts +15 -0
- package/dist/src/tui/components/ToolCallsPanel.d.ts.map +1 -0
- package/dist/src/tui/components/ToolCallsPanel.js +34 -0
- package/dist/src/tui/components/ToolCallsPanel.js.map +1 -0
- package/dist/src/tui/components/TransparencyPanel.d.ts +15 -0
- package/dist/src/tui/components/TransparencyPanel.d.ts.map +1 -0
- package/dist/src/tui/components/TransparencyPanel.js +46 -0
- package/dist/src/tui/components/TransparencyPanel.js.map +1 -0
- package/dist/src/tui/components/index.d.ts +8 -2
- package/dist/src/tui/components/index.d.ts.map +1 -1
- package/dist/src/tui/components/index.js +14 -2
- package/dist/src/tui/components/index.js.map +1 -1
- package/dist/src/tui/event-display.d.ts.map +1 -1
- package/dist/src/tui/event-display.js +13 -4
- package/dist/src/tui/event-display.js.map +1 -1
- package/dist/src/tui/hooks/index.d.ts +1 -0
- package/dist/src/tui/hooks/index.d.ts.map +1 -1
- package/dist/src/tui/hooks/index.js +1 -0
- package/dist/src/tui/hooks/index.js.map +1 -1
- package/dist/src/tui/hooks/use-agent-events.d.ts +53 -0
- package/dist/src/tui/hooks/use-agent-events.d.ts.map +1 -0
- package/dist/src/tui/hooks/use-agent-events.js +444 -0
- package/dist/src/tui/hooks/use-agent-events.js.map +1 -0
- package/dist/src/tui/hooks/use-throttled-state.d.ts +18 -0
- package/dist/src/tui/hooks/use-throttled-state.d.ts.map +1 -0
- package/dist/src/tui/hooks/use-throttled-state.js +93 -0
- package/dist/src/tui/hooks/use-throttled-state.js.map +1 -0
- package/dist/src/tui/hooks/useMessagePruning.d.ts.map +1 -1
- package/dist/src/tui/hooks/useMessagePruning.js.map +1 -1
- package/dist/src/tui/index.d.ts +2 -2
- package/dist/src/tui/index.d.ts.map +1 -1
- package/dist/src/tui/index.js +102 -7
- package/dist/src/tui/index.js.map +1 -1
- package/dist/src/tui/input/CommandPalette.d.ts.map +1 -1
- package/dist/src/tui/input/CommandPalette.js +2 -2
- package/dist/src/tui/input/CommandPalette.js.map +1 -1
- package/dist/src/tui/input/index.d.ts +1 -1
- package/dist/src/tui/input/index.d.ts.map +1 -1
- package/dist/src/tui/input/index.js +1 -1
- package/dist/src/tui/input/index.js.map +1 -1
- package/dist/src/tui/syntax/languages/bash.js +94 -16
- package/dist/src/tui/syntax/languages/bash.js.map +1 -1
- package/dist/src/tui/syntax/languages/javascript.js +65 -12
- package/dist/src/tui/syntax/languages/javascript.js.map +1 -1
- package/dist/src/tui/syntax/languages/json.js.map +1 -1
- package/dist/src/tui/syntax/languages/python.js +81 -15
- package/dist/src/tui/syntax/languages/python.js.map +1 -1
- package/dist/src/tui/theme/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 +39 -4
- package/dist/src/tui/transparency-aggregator.js.map +1 -1
- package/dist/src/tui/types.d.ts.map +1 -1
- package/dist/src/tui/types.js.map +1 -1
- package/dist/src/tui/utils/keyboard.d.ts.map +1 -1
- package/dist/src/tui/utils/keyboard.js.map +1 -1
- package/dist/src/types.d.ts +39 -2
- package/dist/src/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Persistent PTY Shell
|
|
3
|
+
*
|
|
4
|
+
* Provides a persistent shell session that maintains state between commands.
|
|
5
|
+
* Uses Node.js child_process with PTY-like behavior.
|
|
6
|
+
*
|
|
7
|
+
* Key features:
|
|
8
|
+
* - Persistent shell process (bash/zsh)
|
|
9
|
+
* - Command history tracking
|
|
10
|
+
* - Environment inheritance
|
|
11
|
+
* - Working directory state
|
|
12
|
+
* - Output buffering with timeout
|
|
13
|
+
*/
|
|
14
|
+
export interface PTYShellConfig {
|
|
15
|
+
/** Shell to use (default: auto-detect) */
|
|
16
|
+
shell?: string;
|
|
17
|
+
/** Initial working directory */
|
|
18
|
+
cwd?: string;
|
|
19
|
+
/** Environment variables */
|
|
20
|
+
env?: Record<string, string>;
|
|
21
|
+
/** Command timeout in ms (default: 30000) */
|
|
22
|
+
timeout?: number;
|
|
23
|
+
/** Maximum output buffer size (default: 1MB) */
|
|
24
|
+
maxOutputSize?: number;
|
|
25
|
+
/** Shell prompt to detect command completion */
|
|
26
|
+
promptPattern?: string;
|
|
27
|
+
}
|
|
28
|
+
export interface CommandResult {
|
|
29
|
+
output: string;
|
|
30
|
+
exitCode: number | null;
|
|
31
|
+
duration: number;
|
|
32
|
+
timedOut: boolean;
|
|
33
|
+
}
|
|
34
|
+
export interface ShellState {
|
|
35
|
+
cwd: string;
|
|
36
|
+
env: Record<string, string>;
|
|
37
|
+
history: string[];
|
|
38
|
+
isRunning: boolean;
|
|
39
|
+
pid?: number;
|
|
40
|
+
}
|
|
41
|
+
export type PTYEvent = {
|
|
42
|
+
type: 'shell.started';
|
|
43
|
+
pid: number;
|
|
44
|
+
shell: string;
|
|
45
|
+
} | {
|
|
46
|
+
type: 'shell.stopped';
|
|
47
|
+
exitCode: number | null;
|
|
48
|
+
} | {
|
|
49
|
+
type: 'command.start';
|
|
50
|
+
command: string;
|
|
51
|
+
} | {
|
|
52
|
+
type: 'command.output';
|
|
53
|
+
data: string;
|
|
54
|
+
} | {
|
|
55
|
+
type: 'command.complete';
|
|
56
|
+
result: CommandResult;
|
|
57
|
+
} | {
|
|
58
|
+
type: 'command.timeout';
|
|
59
|
+
command: string;
|
|
60
|
+
} | {
|
|
61
|
+
type: 'error';
|
|
62
|
+
error: string;
|
|
63
|
+
};
|
|
64
|
+
export type PTYEventListener = (event: PTYEvent) => void;
|
|
65
|
+
/**
|
|
66
|
+
* Manages persistent shell sessions.
|
|
67
|
+
*/
|
|
68
|
+
export declare class PTYShellManager {
|
|
69
|
+
private config;
|
|
70
|
+
private process;
|
|
71
|
+
private outputBuffer;
|
|
72
|
+
private commandHistory;
|
|
73
|
+
private currentCwd;
|
|
74
|
+
private currentEnv;
|
|
75
|
+
private commandResolve;
|
|
76
|
+
private commandStartTime;
|
|
77
|
+
private commandTimeoutId;
|
|
78
|
+
private eventListeners;
|
|
79
|
+
private readonly endMarker;
|
|
80
|
+
constructor(config?: PTYShellConfig);
|
|
81
|
+
/**
|
|
82
|
+
* Auto-detect the user's preferred shell.
|
|
83
|
+
*/
|
|
84
|
+
private detectShell;
|
|
85
|
+
/**
|
|
86
|
+
* Start the persistent shell.
|
|
87
|
+
*/
|
|
88
|
+
start(): Promise<void>;
|
|
89
|
+
/**
|
|
90
|
+
* Handle output from the shell.
|
|
91
|
+
*/
|
|
92
|
+
private handleOutput;
|
|
93
|
+
/**
|
|
94
|
+
* Handle command completion.
|
|
95
|
+
*/
|
|
96
|
+
private handleCommandComplete;
|
|
97
|
+
/**
|
|
98
|
+
* Execute a command in the persistent shell.
|
|
99
|
+
*/
|
|
100
|
+
execute(command: string): Promise<CommandResult>;
|
|
101
|
+
/**
|
|
102
|
+
* Change the working directory.
|
|
103
|
+
*/
|
|
104
|
+
cd(directory: string): Promise<CommandResult>;
|
|
105
|
+
/**
|
|
106
|
+
* Set an environment variable.
|
|
107
|
+
*/
|
|
108
|
+
setEnv(key: string, value: string): Promise<void>;
|
|
109
|
+
/**
|
|
110
|
+
* Get the current state.
|
|
111
|
+
*/
|
|
112
|
+
getState(): ShellState;
|
|
113
|
+
/**
|
|
114
|
+
* Get command history.
|
|
115
|
+
*/
|
|
116
|
+
getHistory(): string[];
|
|
117
|
+
/**
|
|
118
|
+
* Clear command history.
|
|
119
|
+
*/
|
|
120
|
+
clearHistory(): void;
|
|
121
|
+
/**
|
|
122
|
+
* Subscribe to events.
|
|
123
|
+
*/
|
|
124
|
+
subscribe(listener: PTYEventListener): () => void;
|
|
125
|
+
/**
|
|
126
|
+
* Emit an event.
|
|
127
|
+
*/
|
|
128
|
+
private emitEvent;
|
|
129
|
+
/**
|
|
130
|
+
* Stop the shell.
|
|
131
|
+
*/
|
|
132
|
+
stop(): Promise<void>;
|
|
133
|
+
/**
|
|
134
|
+
* Cleanup resources.
|
|
135
|
+
*/
|
|
136
|
+
cleanup(): Promise<void>;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Create a PTY shell manager.
|
|
140
|
+
*/
|
|
141
|
+
export declare function createPTYShell(config?: PTYShellConfig): PTYShellManager;
|
|
142
|
+
/**
|
|
143
|
+
* Create and start a PTY shell.
|
|
144
|
+
*/
|
|
145
|
+
export declare function createAndStartPTYShell(config?: PTYShellConfig): Promise<PTYShellManager>;
|
|
146
|
+
/**
|
|
147
|
+
* Create a shell execution tool that uses the persistent PTY.
|
|
148
|
+
*/
|
|
149
|
+
export declare function createPTYShellTool(shell: PTYShellManager): {
|
|
150
|
+
name: string;
|
|
151
|
+
description: string;
|
|
152
|
+
parameters: {
|
|
153
|
+
type: string;
|
|
154
|
+
properties: {
|
|
155
|
+
command: {
|
|
156
|
+
type: string;
|
|
157
|
+
description: string;
|
|
158
|
+
};
|
|
159
|
+
};
|
|
160
|
+
required: string[];
|
|
161
|
+
};
|
|
162
|
+
dangerLevel: "dangerous";
|
|
163
|
+
execute(args: Record<string, unknown>): Promise<string>;
|
|
164
|
+
};
|
|
165
|
+
/**
|
|
166
|
+
* Format shell state for display.
|
|
167
|
+
*/
|
|
168
|
+
export declare function formatShellState(state: ShellState): string;
|
|
169
|
+
//# sourceMappingURL=pty-shell.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pty-shell.d.ts","sourceRoot":"","sources":["../../../../src/integrations/streaming/pty-shell.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AASH,MAAM,WAAW,cAAc;IAC7B,0CAA0C;IAC1C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gCAAgC;IAChC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,4BAA4B;IAC5B,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,6CAA6C;IAC7C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gDAAgD;IAChD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gDAAgD;IAChD,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,UAAU;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5B,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;IACnB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,MAAM,MAAM,QAAQ,GAChB;IAAE,IAAI,EAAE,eAAe,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACrD;IAAE,IAAI,EAAE,eAAe,CAAC;IAAC,QAAQ,E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Aa,CAAC;IAQnD;;OAEG;IACG,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAKvD;;OAEG;IACH,QAAQ,IAAI,UAAU;IAUtB;;OAEG;IACH,UAAU,IAAI,MAAM,EAAE;IAItB;;OAEG;IACH,YAAY,IAAI,IAAI;IAIpB;;OAEG;IACH,SAAS,CAAC,QAAQ,EAAE,gBAAgB,GAAG,MAAM,IAAI;IAKjD;;OAEG;IACH,OAAO,CAAC,SAAS;IAUjB;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAwB3B;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAO/B;AAMD;;GAEG;AACH,wBAAgB,cAAc,CAAC,MAAM,CAAC,EAAE,cAAc,GAAG,eAAe,CAEvE;AAED;;GAEG;AACH,wBAAsB,sBAAsB,CAAC,MAAM,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC,CAI9F;AAMD;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,eAAe;;;;;;;;;;;;;;kBAgBjC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;EAgB9C;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAe1D"}
|
|
@@ -0,0 +1,371 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Persistent PTY Shell
|
|
3
|
+
*
|
|
4
|
+
* Provides a persistent shell session that maintains state between commands.
|
|
5
|
+
* Uses Node.js child_process with PTY-like behavior.
|
|
6
|
+
*
|
|
7
|
+
* Key features:
|
|
8
|
+
* - Persistent shell process (bash/zsh)
|
|
9
|
+
* - Command history tracking
|
|
10
|
+
* - Environment inheritance
|
|
11
|
+
* - Working directory state
|
|
12
|
+
* - Output buffering with timeout
|
|
13
|
+
*/
|
|
14
|
+
import { spawn } from 'node:child_process';
|
|
15
|
+
import { platform } from 'node:os';
|
|
16
|
+
// =============================================================================
|
|
17
|
+
// PTY SHELL MANAGER
|
|
18
|
+
// =============================================================================
|
|
19
|
+
/**
|
|
20
|
+
* Manages persistent shell sessions.
|
|
21
|
+
*/
|
|
22
|
+
export class PTYShellManager {
|
|
23
|
+
config;
|
|
24
|
+
process = null;
|
|
25
|
+
outputBuffer = '';
|
|
26
|
+
commandHistory = [];
|
|
27
|
+
currentCwd;
|
|
28
|
+
currentEnv;
|
|
29
|
+
commandResolve = null;
|
|
30
|
+
commandStartTime = 0;
|
|
31
|
+
commandTimeoutId = null;
|
|
32
|
+
eventListeners = new Set();
|
|
33
|
+
endMarker;
|
|
34
|
+
constructor(config = {}) {
|
|
35
|
+
this.config = {
|
|
36
|
+
shell: config.shell || this.detectShell(),
|
|
37
|
+
cwd: config.cwd || process.cwd(),
|
|
38
|
+
env: config.env || {},
|
|
39
|
+
timeout: config.timeout ?? 30000,
|
|
40
|
+
maxOutputSize: config.maxOutputSize ?? 1024 * 1024, // 1MB
|
|
41
|
+
promptPattern: config.promptPattern || '__CMD_DONE__',
|
|
42
|
+
};
|
|
43
|
+
this.currentCwd = this.config.cwd;
|
|
44
|
+
this.currentEnv = { ...process.env, ...this.config.env };
|
|
45
|
+
this.endMarker = `\necho "${this.config.promptPattern} $?"`;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Auto-detect the user's preferred shell.
|
|
49
|
+
*/
|
|
50
|
+
detectShell() {
|
|
51
|
+
const userShell = process.env.SHELL;
|
|
52
|
+
if (userShell)
|
|
53
|
+
return userShell;
|
|
54
|
+
if (platform() === 'win32') {
|
|
55
|
+
return 'cmd.exe';
|
|
56
|
+
}
|
|
57
|
+
return '/bin/bash';
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Start the persistent shell.
|
|
61
|
+
*/
|
|
62
|
+
async start() {
|
|
63
|
+
if (this.process && !this.process.killed) {
|
|
64
|
+
return; // Already running
|
|
65
|
+
}
|
|
66
|
+
return new Promise((resolve, reject) => {
|
|
67
|
+
const env = {
|
|
68
|
+
...process.env,
|
|
69
|
+
...this.config.env,
|
|
70
|
+
// Disable shell prompt customization that might interfere
|
|
71
|
+
PS1: '$ ',
|
|
72
|
+
PROMPT_COMMAND: '',
|
|
73
|
+
};
|
|
74
|
+
this.process = spawn(this.config.shell, [], {
|
|
75
|
+
cwd: this.config.cwd,
|
|
76
|
+
env,
|
|
77
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
78
|
+
shell: false, // We're spawning a shell directly
|
|
79
|
+
});
|
|
80
|
+
// Set up output handlers
|
|
81
|
+
this.process.stdout?.on('data', (data) => {
|
|
82
|
+
const output = data.toString();
|
|
83
|
+
this.handleOutput(output);
|
|
84
|
+
});
|
|
85
|
+
this.process.stderr?.on('data', (data) => {
|
|
86
|
+
const output = data.toString();
|
|
87
|
+
this.handleOutput(output);
|
|
88
|
+
});
|
|
89
|
+
this.process.on('error', (error) => {
|
|
90
|
+
this.emitEvent({ type: 'error', error: error.message });
|
|
91
|
+
reject(error);
|
|
92
|
+
});
|
|
93
|
+
this.process.on('exit', (code) => {
|
|
94
|
+
this.emitEvent({ type: 'shell.stopped', exitCode: code });
|
|
95
|
+
this.process = null;
|
|
96
|
+
});
|
|
97
|
+
// Wait a bit for shell to initialize
|
|
98
|
+
setTimeout(() => {
|
|
99
|
+
if (this.process && this.process.pid) {
|
|
100
|
+
this.emitEvent({
|
|
101
|
+
type: 'shell.started',
|
|
102
|
+
pid: this.process.pid,
|
|
103
|
+
shell: this.config.shell,
|
|
104
|
+
});
|
|
105
|
+
resolve();
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
reject(new Error('Failed to start shell'));
|
|
109
|
+
}
|
|
110
|
+
}, 100);
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Handle output from the shell.
|
|
115
|
+
*/
|
|
116
|
+
handleOutput(data) {
|
|
117
|
+
this.outputBuffer += data;
|
|
118
|
+
this.emitEvent({ type: 'command.output', data });
|
|
119
|
+
// Trim buffer if too large
|
|
120
|
+
if (this.outputBuffer.length > this.config.maxOutputSize) {
|
|
121
|
+
this.outputBuffer = this.outputBuffer.slice(-this.config.maxOutputSize);
|
|
122
|
+
}
|
|
123
|
+
// Check for command completion
|
|
124
|
+
if (this.commandResolve && this.outputBuffer.includes(this.config.promptPattern)) {
|
|
125
|
+
this.handleCommandComplete();
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Handle command completion.
|
|
130
|
+
*/
|
|
131
|
+
handleCommandComplete() {
|
|
132
|
+
if (!this.commandResolve)
|
|
133
|
+
return;
|
|
134
|
+
// Clear timeout
|
|
135
|
+
if (this.commandTimeoutId) {
|
|
136
|
+
clearTimeout(this.commandTimeoutId);
|
|
137
|
+
this.commandTimeoutId = null;
|
|
138
|
+
}
|
|
139
|
+
// Extract output and exit code
|
|
140
|
+
const markerIndex = this.outputBuffer.lastIndexOf(this.config.promptPattern);
|
|
141
|
+
let output = this.outputBuffer.slice(0, markerIndex).trim();
|
|
142
|
+
const exitCodeMatch = this.outputBuffer.slice(markerIndex).match(/(\d+)/);
|
|
143
|
+
const exitCode = exitCodeMatch ? parseInt(exitCodeMatch[1], 10) : null;
|
|
144
|
+
// Remove the echo command from output
|
|
145
|
+
const echoIndex = output.lastIndexOf('echo "');
|
|
146
|
+
if (echoIndex !== -1) {
|
|
147
|
+
output = output.slice(0, echoIndex).trim();
|
|
148
|
+
}
|
|
149
|
+
// Also remove any command echo (bash echoes input commands)
|
|
150
|
+
const lines = output.split('\n');
|
|
151
|
+
if (lines.length > 1 && this.commandHistory.length > 0) {
|
|
152
|
+
const lastCmd = this.commandHistory[this.commandHistory.length - 1];
|
|
153
|
+
if (lines[0].endsWith(lastCmd) || lines[0].includes(lastCmd)) {
|
|
154
|
+
lines.shift();
|
|
155
|
+
output = lines.join('\n');
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
const result = {
|
|
159
|
+
output: output.trim(),
|
|
160
|
+
exitCode,
|
|
161
|
+
duration: Date.now() - this.commandStartTime,
|
|
162
|
+
timedOut: false,
|
|
163
|
+
};
|
|
164
|
+
this.emitEvent({ type: 'command.complete', result });
|
|
165
|
+
const resolve = this.commandResolve;
|
|
166
|
+
this.commandResolve = null;
|
|
167
|
+
this.outputBuffer = '';
|
|
168
|
+
resolve(result);
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Execute a command in the persistent shell.
|
|
172
|
+
*/
|
|
173
|
+
async execute(command) {
|
|
174
|
+
if (!this.process || this.process.killed) {
|
|
175
|
+
await this.start();
|
|
176
|
+
}
|
|
177
|
+
if (!this.process?.stdin) {
|
|
178
|
+
throw new Error('Shell not running');
|
|
179
|
+
}
|
|
180
|
+
// Track command
|
|
181
|
+
this.commandHistory.push(command);
|
|
182
|
+
this.commandStartTime = Date.now();
|
|
183
|
+
this.outputBuffer = '';
|
|
184
|
+
this.emitEvent({ type: 'command.start', command });
|
|
185
|
+
return new Promise((resolve) => {
|
|
186
|
+
this.commandResolve = resolve;
|
|
187
|
+
// Set timeout
|
|
188
|
+
this.commandTimeoutId = setTimeout(() => {
|
|
189
|
+
if (this.commandResolve) {
|
|
190
|
+
this.emitEvent({ type: 'command.timeout', command });
|
|
191
|
+
const result = {
|
|
192
|
+
output: this.outputBuffer.trim(),
|
|
193
|
+
exitCode: null,
|
|
194
|
+
duration: Date.now() - this.commandStartTime,
|
|
195
|
+
timedOut: true,
|
|
196
|
+
};
|
|
197
|
+
this.commandResolve = null;
|
|
198
|
+
this.outputBuffer = '';
|
|
199
|
+
resolve(result);
|
|
200
|
+
}
|
|
201
|
+
}, this.config.timeout);
|
|
202
|
+
// Write command with completion marker
|
|
203
|
+
const fullCommand = `${command}${this.endMarker}\n`;
|
|
204
|
+
this.process.stdin.write(fullCommand);
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Change the working directory.
|
|
209
|
+
*/
|
|
210
|
+
async cd(directory) {
|
|
211
|
+
const result = await this.execute(`cd "${directory}" && pwd`);
|
|
212
|
+
if (result.exitCode === 0) {
|
|
213
|
+
this.currentCwd = result.output.trim();
|
|
214
|
+
}
|
|
215
|
+
return result;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Set an environment variable.
|
|
219
|
+
*/
|
|
220
|
+
async setEnv(key, value) {
|
|
221
|
+
await this.execute(`export ${key}="${value}"`);
|
|
222
|
+
this.currentEnv[key] = value;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Get the current state.
|
|
226
|
+
*/
|
|
227
|
+
getState() {
|
|
228
|
+
return {
|
|
229
|
+
cwd: this.currentCwd,
|
|
230
|
+
env: this.currentEnv,
|
|
231
|
+
history: [...this.commandHistory],
|
|
232
|
+
isRunning: this.process !== null && !this.process.killed,
|
|
233
|
+
pid: this.process?.pid,
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Get command history.
|
|
238
|
+
*/
|
|
239
|
+
getHistory() {
|
|
240
|
+
return [...this.commandHistory];
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Clear command history.
|
|
244
|
+
*/
|
|
245
|
+
clearHistory() {
|
|
246
|
+
this.commandHistory = [];
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Subscribe to events.
|
|
250
|
+
*/
|
|
251
|
+
subscribe(listener) {
|
|
252
|
+
this.eventListeners.add(listener);
|
|
253
|
+
return () => this.eventListeners.delete(listener);
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Emit an event.
|
|
257
|
+
*/
|
|
258
|
+
emitEvent(event) {
|
|
259
|
+
for (const listener of this.eventListeners) {
|
|
260
|
+
try {
|
|
261
|
+
listener(event);
|
|
262
|
+
}
|
|
263
|
+
catch {
|
|
264
|
+
// Ignore listener errors
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Stop the shell.
|
|
270
|
+
*/
|
|
271
|
+
async stop() {
|
|
272
|
+
if (!this.process)
|
|
273
|
+
return;
|
|
274
|
+
return new Promise((resolve) => {
|
|
275
|
+
if (!this.process) {
|
|
276
|
+
resolve();
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
const timeout = setTimeout(() => {
|
|
280
|
+
this.process?.kill('SIGKILL');
|
|
281
|
+
resolve();
|
|
282
|
+
}, 1000);
|
|
283
|
+
this.process.once('exit', () => {
|
|
284
|
+
clearTimeout(timeout);
|
|
285
|
+
resolve();
|
|
286
|
+
});
|
|
287
|
+
// Try graceful exit first
|
|
288
|
+
this.process.stdin?.write('exit\n');
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Cleanup resources.
|
|
293
|
+
*/
|
|
294
|
+
async cleanup() {
|
|
295
|
+
if (this.commandTimeoutId) {
|
|
296
|
+
clearTimeout(this.commandTimeoutId);
|
|
297
|
+
}
|
|
298
|
+
await this.stop();
|
|
299
|
+
this.eventListeners.clear();
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
// =============================================================================
|
|
303
|
+
// FACTORY FUNCTIONS
|
|
304
|
+
// =============================================================================
|
|
305
|
+
/**
|
|
306
|
+
* Create a PTY shell manager.
|
|
307
|
+
*/
|
|
308
|
+
export function createPTYShell(config) {
|
|
309
|
+
return new PTYShellManager(config);
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Create and start a PTY shell.
|
|
313
|
+
*/
|
|
314
|
+
export async function createAndStartPTYShell(config) {
|
|
315
|
+
const shell = new PTYShellManager(config);
|
|
316
|
+
await shell.start();
|
|
317
|
+
return shell;
|
|
318
|
+
}
|
|
319
|
+
// =============================================================================
|
|
320
|
+
// TOOL FACTORY
|
|
321
|
+
// =============================================================================
|
|
322
|
+
/**
|
|
323
|
+
* Create a shell execution tool that uses the persistent PTY.
|
|
324
|
+
*/
|
|
325
|
+
export function createPTYShellTool(shell) {
|
|
326
|
+
return {
|
|
327
|
+
name: 'shell_exec',
|
|
328
|
+
description: 'Execute a command in the persistent shell session. Maintains state between calls (working directory, environment variables, etc.)',
|
|
329
|
+
parameters: {
|
|
330
|
+
type: 'object',
|
|
331
|
+
properties: {
|
|
332
|
+
command: {
|
|
333
|
+
type: 'string',
|
|
334
|
+
description: 'The command to execute',
|
|
335
|
+
},
|
|
336
|
+
},
|
|
337
|
+
required: ['command'],
|
|
338
|
+
},
|
|
339
|
+
dangerLevel: 'dangerous',
|
|
340
|
+
async execute(args) {
|
|
341
|
+
const command = args.command;
|
|
342
|
+
if (!command) {
|
|
343
|
+
return 'Error: command is required';
|
|
344
|
+
}
|
|
345
|
+
const result = await shell.execute(command);
|
|
346
|
+
if (result.timedOut) {
|
|
347
|
+
return `Command timed out after ${result.duration}ms. Partial output:\n${result.output}`;
|
|
348
|
+
}
|
|
349
|
+
const exitInfo = result.exitCode !== 0 ? ` (exit code: ${result.exitCode})` : '';
|
|
350
|
+
return `${result.output}${exitInfo}`;
|
|
351
|
+
},
|
|
352
|
+
};
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Format shell state for display.
|
|
356
|
+
*/
|
|
357
|
+
export function formatShellState(state) {
|
|
358
|
+
const lines = [
|
|
359
|
+
`Shell: ${state.isRunning ? 'Running' : 'Stopped'}${state.pid ? ` (PID: ${state.pid})` : ''}`,
|
|
360
|
+
`CWD: ${state.cwd}`,
|
|
361
|
+
`History: ${state.history.length} commands`,
|
|
362
|
+
];
|
|
363
|
+
if (state.history.length > 0) {
|
|
364
|
+
lines.push('Recent commands:');
|
|
365
|
+
for (const cmd of state.history.slice(-5)) {
|
|
366
|
+
lines.push(` $ ${cmd}`);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
return lines.join('\n');
|
|
370
|
+
}
|
|
371
|
+
//# sourceMappingURL=pty-shell.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"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,wBAAwB,MAAM,CAAC,MAAM,EAAE,CAAC;YAC3F,CAAC;YAED,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,KAAK,CAAC,CAAC,CAAC,CAAC,gBAAgB,MAAM,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;YACjF,OAAO,GAAG,MAAM,CAAC,MAAM,GAAG,QAAQ,EAAE,CAAC;QACvC,CAAC;KACF,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAiB;IAChD,MAAM,KAAK,GAAG;QACZ,UAAU,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,UAAU,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QAC7F,QAAQ,KAAK,CAAC,GAAG,EAAE;QACnB,YAAY,KAAK,CAAC,OAAO,CAAC,MAAM,WAAW;KAC5C,CAAC;IAEF,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC7B,KAAK,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;QAC/B,KAAK,MAAM,GAAG,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAC1C,KAAK,CAAC,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC,CAAC;QAC3B,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lesson 25: Streaming Response Handler
|
|
3
|
+
*
|
|
4
|
+
* Handles streaming LLM responses for real-time output.
|
|
5
|
+
* Supports text chunks, tool calls, and usage tracking.
|
|
6
|
+
*/
|
|
7
|
+
import type { ToolCall, ChatResponse } from '../../types.js';
|
|
8
|
+
/**
|
|
9
|
+
* A chunk from a streaming response.
|
|
10
|
+
*/
|
|
11
|
+
export interface StreamChunk {
|
|
12
|
+
type: 'text' | 'tool_call_start' | 'tool_call_delta' | 'tool_call_end' | 'usage' | 'done' | 'error';
|
|
13
|
+
content?: string;
|
|
14
|
+
toolCall?: Partial<ToolCall>;
|
|
15
|
+
toolCallId?: string;
|
|
16
|
+
usage?: {
|
|
17
|
+
inputTokens: number;
|
|
18
|
+
outputTokens: number;
|
|
19
|
+
};
|
|
20
|
+
error?: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Callback for stream chunks.
|
|
24
|
+
*/
|
|
25
|
+
export type StreamCallback = (chunk: StreamChunk) => void;
|
|
26
|
+
/**
|
|
27
|
+
* Streaming configuration.
|
|
28
|
+
*/
|
|
29
|
+
export interface StreamConfig {
|
|
30
|
+
/** Enable streaming (default: true) */
|
|
31
|
+
enabled?: boolean;
|
|
32
|
+
/** Buffer size before flushing (default: 50 chars for batched updates) */
|
|
33
|
+
bufferSize?: number;
|
|
34
|
+
/** Show typing indicator (default: true) */
|
|
35
|
+
showTypingIndicator?: boolean;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Stream events.
|
|
39
|
+
*/
|
|
40
|
+
export type StreamEvent = {
|
|
41
|
+
type: 'stream.start';
|
|
42
|
+
} | {
|
|
43
|
+
type: 'stream.text';
|
|
44
|
+
content: string;
|
|
45
|
+
} | {
|
|
46
|
+
type: 'stream.tool_call';
|
|
47
|
+
toolCall: ToolCall;
|
|
48
|
+
} | {
|
|
49
|
+
type: 'stream.complete';
|
|
50
|
+
response: ChatResponse;
|
|
51
|
+
} | {
|
|
52
|
+
type: 'stream.error';
|
|
53
|
+
error: string;
|
|
54
|
+
};
|
|
55
|
+
export type StreamEventListener = (event: StreamEvent) => void;
|
|
56
|
+
/**
|
|
57
|
+
* Handles streaming responses from LLM providers.
|
|
58
|
+
*/
|
|
59
|
+
export declare class StreamHandler {
|
|
60
|
+
private config;
|
|
61
|
+
private listeners;
|
|
62
|
+
private buffer;
|
|
63
|
+
constructor(config?: StreamConfig);
|
|
64
|
+
/**
|
|
65
|
+
* Process a streaming response.
|
|
66
|
+
* Accumulates chunks and returns the final ChatResponse.
|
|
67
|
+
*/
|
|
68
|
+
processStream(stream: AsyncIterable<StreamChunk>, onChunk?: StreamCallback): Promise<ChatResponse>;
|
|
69
|
+
/**
|
|
70
|
+
* Process a single chunk.
|
|
71
|
+
*/
|
|
72
|
+
private processChunk;
|
|
73
|
+
/**
|
|
74
|
+
* Subscribe to events.
|
|
75
|
+
*/
|
|
76
|
+
on(listener: StreamEventListener): () => void;
|
|
77
|
+
/**
|
|
78
|
+
* Emit an event.
|
|
79
|
+
*/
|
|
80
|
+
private emit;
|
|
81
|
+
/**
|
|
82
|
+
* Check if streaming is enabled.
|
|
83
|
+
*/
|
|
84
|
+
isEnabled(): boolean;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Create a stream handler.
|
|
88
|
+
*/
|
|
89
|
+
export declare function createStreamHandler(config?: StreamConfig): StreamHandler;
|
|
90
|
+
/**
|
|
91
|
+
* Format a stream chunk for terminal output.
|
|
92
|
+
*/
|
|
93
|
+
export declare function formatChunkForTerminal(chunk: StreamChunk): string;
|
|
94
|
+
/**
|
|
95
|
+
* Convert OpenRouter SSE stream to StreamChunk iterator.
|
|
96
|
+
*/
|
|
97
|
+
export declare function adaptOpenRouterStream(response: Response): AsyncIterable<StreamChunk>;
|
|
98
|
+
/**
|
|
99
|
+
* Convert Anthropic stream to StreamChunk iterator.
|
|
100
|
+
*/
|
|
101
|
+
export declare function adaptAnthropicStream(response: Response): AsyncIterable<StreamChunk>;
|
|
102
|
+
//# sourceMappingURL=streaming.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"streaming.d.ts","sourceRoot":"","sources":["../../../../src/integrations/streaming/streaming.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AA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