attocode 0.1.0
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 +48 -0
- package/LICENSE +21 -0
- package/README.md +164 -0
- package/dist/src/adapters.d.ts +83 -0
- package/dist/src/adapters.d.ts.map +1 -0
- package/dist/src/adapters.js +221 -0
- package/dist/src/adapters.js.map +1 -0
- package/dist/src/agent-tools/index.d.ts +7 -0
- package/dist/src/agent-tools/index.d.ts.map +1 -0
- package/dist/src/agent-tools/index.js +8 -0
- package/dist/src/agent-tools/index.js.map +1 -0
- package/dist/src/agent-tools/lsp-file-tools.d.ts +33 -0
- package/dist/src/agent-tools/lsp-file-tools.d.ts.map +1 -0
- package/dist/src/agent-tools/lsp-file-tools.js +200 -0
- package/dist/src/agent-tools/lsp-file-tools.js.map +1 -0
- package/dist/src/agent.d.ts +667 -0
- package/dist/src/agent.d.ts.map +1 -0
- package/dist/src/agent.js +2824 -0
- package/dist/src/agent.js.map +1 -0
- package/dist/src/cli.d.ts +36 -0
- package/dist/src/cli.d.ts.map +1 -0
- package/dist/src/cli.js +176 -0
- package/dist/src/cli.js.map +1 -0
- package/dist/src/commands/handler.d.ts +22 -0
- package/dist/src/commands/handler.d.ts.map +1 -0
- package/dist/src/commands/handler.js +1320 -0
- package/dist/src/commands/handler.js.map +1 -0
- package/dist/src/commands/init.d.ts +7 -0
- package/dist/src/commands/init.d.ts.map +1 -0
- package/dist/src/commands/init.js +153 -0
- package/dist/src/commands/init.js.map +1 -0
- package/dist/src/commands/types.d.ts +70 -0
- package/dist/src/commands/types.d.ts.map +1 -0
- package/dist/src/commands/types.js +8 -0
- package/dist/src/commands/types.js.map +1 -0
- package/dist/src/config.d.ts +22 -0
- package/dist/src/config.d.ts.map +1 -0
- package/dist/src/config.js +25 -0
- package/dist/src/config.js.map +1 -0
- package/dist/src/core/index.d.ts +32 -0
- package/dist/src/core/index.d.ts.map +1 -0
- package/dist/src/core/index.js +35 -0
- package/dist/src/core/index.js.map +1 -0
- package/dist/src/core/process-handlers.d.ts +43 -0
- package/dist/src/core/process-handlers.d.ts.map +1 -0
- package/dist/src/core/process-handlers.js +117 -0
- package/dist/src/core/process-handlers.js.map +1 -0
- package/dist/src/core/protocol/bridge.d.ts +117 -0
- package/dist/src/core/protocol/bridge.d.ts.map +1 -0
- package/dist/src/core/protocol/bridge.js +149 -0
- package/dist/src/core/protocol/bridge.js.map +1 -0
- package/dist/src/core/protocol/index.d.ts +8 -0
- package/dist/src/core/protocol/index.d.ts.map +1 -0
- package/dist/src/core/protocol/index.js +8 -0
- package/dist/src/core/protocol/index.js.map +1 -0
- package/dist/src/core/protocol/types.d.ts +539 -0
- package/dist/src/core/protocol/types.d.ts.map +1 -0
- package/dist/src/core/protocol/types.js +149 -0
- package/dist/src/core/protocol/types.js.map +1 -0
- package/dist/src/core/queues/atomic-counter.d.ts +36 -0
- package/dist/src/core/queues/atomic-counter.d.ts.map +1 -0
- package/dist/src/core/queues/atomic-counter.js +46 -0
- package/dist/src/core/queues/atomic-counter.js.map +1 -0
- package/dist/src/core/queues/event-queue.d.ts +126 -0
- package/dist/src/core/queues/event-queue.d.ts.map +1 -0
- package/dist/src/core/queues/event-queue.js +208 -0
- package/dist/src/core/queues/event-queue.js.map +1 -0
- package/dist/src/core/queues/index.d.ts +12 -0
- package/dist/src/core/queues/index.d.ts.map +1 -0
- package/dist/src/core/queues/index.js +15 -0
- package/dist/src/core/queues/index.js.map +1 -0
- package/dist/src/core/queues/submission-queue.d.ts +116 -0
- package/dist/src/core/queues/submission-queue.d.ts.map +1 -0
- package/dist/src/core/queues/submission-queue.js +236 -0
- package/dist/src/core/queues/submission-queue.js.map +1 -0
- package/dist/src/costs/index.d.ts +22 -0
- package/dist/src/costs/index.d.ts.map +1 -0
- package/dist/src/costs/index.js +22 -0
- package/dist/src/costs/index.js.map +1 -0
- package/dist/src/costs/model-registry.d.ts +80 -0
- package/dist/src/costs/model-registry.d.ts.map +1 -0
- package/dist/src/costs/model-registry.js +237 -0
- package/dist/src/costs/model-registry.js.map +1 -0
- package/dist/src/costs/types.d.ts +50 -0
- package/dist/src/costs/types.d.ts.map +1 -0
- package/dist/src/costs/types.js +2 -0
- package/dist/src/costs/types.js.map +1 -0
- package/dist/src/defaults.d.ts +114 -0
- package/dist/src/defaults.d.ts.map +1 -0
- package/dist/src/defaults.js +457 -0
- package/dist/src/defaults.js.map +1 -0
- package/dist/src/first-run.d.ts +35 -0
- package/dist/src/first-run.d.ts.map +1 -0
- package/dist/src/first-run.js +94 -0
- package/dist/src/first-run.js.map +1 -0
- package/dist/src/hello.d.ts +2 -0
- package/dist/src/hello.d.ts.map +1 -0
- package/dist/src/hello.js +4 -0
- package/dist/src/hello.js.map +1 -0
- package/dist/src/integrations/agent-registry.d.ts +160 -0
- package/dist/src/integrations/agent-registry.d.ts.map +1 -0
- package/dist/src/integrations/agent-registry.js +446 -0
- package/dist/src/integrations/agent-registry.js.map +1 -0
- package/dist/src/integrations/auto-compaction.d.ts +177 -0
- package/dist/src/integrations/auto-compaction.d.ts.map +1 -0
- package/dist/src/integrations/auto-compaction.js +428 -0
- package/dist/src/integrations/auto-compaction.js.map +1 -0
- package/dist/src/integrations/cancellation.d.ts +162 -0
- package/dist/src/integrations/cancellation.d.ts.map +1 -0
- package/dist/src/integrations/cancellation.js +339 -0
- package/dist/src/integrations/cancellation.js.map +1 -0
- package/dist/src/integrations/codebase-context.d.ts +319 -0
- package/dist/src/integrations/codebase-context.d.ts.map +1 -0
- package/dist/src/integrations/codebase-context.js +816 -0
- package/dist/src/integrations/codebase-context.js.map +1 -0
- package/dist/src/integrations/compaction.d.ts +192 -0
- package/dist/src/integrations/compaction.d.ts.map +1 -0
- package/dist/src/integrations/compaction.js +376 -0
- package/dist/src/integrations/compaction.js.map +1 -0
- package/dist/src/integrations/context-engineering.d.ts +246 -0
- package/dist/src/integrations/context-engineering.d.ts.map +1 -0
- package/dist/src/integrations/context-engineering.js +394 -0
- package/dist/src/integrations/context-engineering.js.map +1 -0
- package/dist/src/integrations/diff-utils.d.ts +105 -0
- package/dist/src/integrations/diff-utils.d.ts.map +1 -0
- package/dist/src/integrations/diff-utils.js +497 -0
- package/dist/src/integrations/diff-utils.js.map +1 -0
- package/dist/src/integrations/economics.d.ts +192 -0
- package/dist/src/integrations/economics.d.ts.map +1 -0
- package/dist/src/integrations/economics.js +431 -0
- package/dist/src/integrations/economics.js.map +1 -0
- package/dist/src/integrations/execution-policy.d.ts +189 -0
- package/dist/src/integrations/execution-policy.d.ts.map +1 -0
- package/dist/src/integrations/execution-policy.js +352 -0
- package/dist/src/integrations/execution-policy.js.map +1 -0
- package/dist/src/integrations/file-change-tracker.d.ts +161 -0
- package/dist/src/integrations/file-change-tracker.d.ts.map +1 -0
- package/dist/src/integrations/file-change-tracker.js +520 -0
- package/dist/src/integrations/file-change-tracker.js.map +1 -0
- package/dist/src/integrations/hierarchical-config.d.ts +212 -0
- package/dist/src/integrations/hierarchical-config.d.ts.map +1 -0
- package/dist/src/integrations/hierarchical-config.js +484 -0
- package/dist/src/integrations/hierarchical-config.js.map +1 -0
- package/dist/src/integrations/hooks.d.ts +114 -0
- package/dist/src/integrations/hooks.d.ts.map +1 -0
- package/dist/src/integrations/hooks.js +326 -0
- package/dist/src/integrations/hooks.js.map +1 -0
- package/dist/src/integrations/ignore.d.ts +143 -0
- package/dist/src/integrations/ignore.d.ts.map +1 -0
- package/dist/src/integrations/ignore.js +417 -0
- package/dist/src/integrations/ignore.js.map +1 -0
- package/dist/src/integrations/image-renderer.d.ts +119 -0
- package/dist/src/integrations/image-renderer.d.ts.map +1 -0
- package/dist/src/integrations/image-renderer.js +306 -0
- package/dist/src/integrations/image-renderer.js.map +1 -0
- package/dist/src/integrations/index.d.ts +42 -0
- package/dist/src/integrations/index.d.ts.map +1 -0
- package/dist/src/integrations/index.js +73 -0
- package/dist/src/integrations/index.js.map +1 -0
- package/dist/src/integrations/lsp.d.ts +196 -0
- package/dist/src/integrations/lsp.d.ts.map +1 -0
- package/dist/src/integrations/lsp.js +582 -0
- package/dist/src/integrations/lsp.js.map +1 -0
- package/dist/src/integrations/mcp-client.d.ts +270 -0
- package/dist/src/integrations/mcp-client.d.ts.map +1 -0
- package/dist/src/integrations/mcp-client.js +698 -0
- package/dist/src/integrations/mcp-client.js.map +1 -0
- package/dist/src/integrations/mcp-tool-search.d.ts +77 -0
- package/dist/src/integrations/mcp-tool-search.d.ts.map +1 -0
- package/dist/src/integrations/mcp-tool-search.js +220 -0
- package/dist/src/integrations/mcp-tool-search.js.map +1 -0
- package/dist/src/integrations/memory.d.ts +108 -0
- package/dist/src/integrations/memory.d.ts.map +1 -0
- package/dist/src/integrations/memory.js +288 -0
- package/dist/src/integrations/memory.js.map +1 -0
- package/dist/src/integrations/multi-agent.d.ts +150 -0
- package/dist/src/integrations/multi-agent.d.ts.map +1 -0
- package/dist/src/integrations/multi-agent.js +306 -0
- package/dist/src/integrations/multi-agent.js.map +1 -0
- package/dist/src/integrations/observability.d.ts +162 -0
- package/dist/src/integrations/observability.d.ts.map +1 -0
- package/dist/src/integrations/observability.js +406 -0
- package/dist/src/integrations/observability.js.map +1 -0
- package/dist/src/integrations/openrouter-pricing.d.ts +42 -0
- package/dist/src/integrations/openrouter-pricing.d.ts.map +1 -0
- package/dist/src/integrations/openrouter-pricing.js +124 -0
- package/dist/src/integrations/openrouter-pricing.js.map +1 -0
- package/dist/src/integrations/pending-plan.d.ts +171 -0
- package/dist/src/integrations/pending-plan.d.ts.map +1 -0
- package/dist/src/integrations/pending-plan.js +244 -0
- package/dist/src/integrations/pending-plan.js.map +1 -0
- package/dist/src/integrations/persistence.d.ts +48 -0
- package/dist/src/integrations/persistence.d.ts.map +1 -0
- package/dist/src/integrations/persistence.js +196 -0
- package/dist/src/integrations/persistence.js.map +1 -0
- package/dist/src/integrations/planning.d.ts +96 -0
- package/dist/src/integrations/planning.d.ts.map +1 -0
- package/dist/src/integrations/planning.js +338 -0
- package/dist/src/integrations/planning.js.map +1 -0
- package/dist/src/integrations/pty-shell.d.ts +169 -0
- package/dist/src/integrations/pty-shell.d.ts.map +1 -0
- package/dist/src/integrations/pty-shell.js +367 -0
- package/dist/src/integrations/pty-shell.js.map +1 -0
- package/dist/src/integrations/react.d.ts +139 -0
- package/dist/src/integrations/react.d.ts.map +1 -0
- package/dist/src/integrations/react.js +273 -0
- package/dist/src/integrations/react.js.map +1 -0
- package/dist/src/integrations/resources.d.ts +177 -0
- package/dist/src/integrations/resources.d.ts.map +1 -0
- package/dist/src/integrations/resources.js +311 -0
- package/dist/src/integrations/resources.js.map +1 -0
- package/dist/src/integrations/result-synthesizer.d.ts +389 -0
- package/dist/src/integrations/result-synthesizer.d.ts.map +1 -0
- package/dist/src/integrations/result-synthesizer.js +951 -0
- package/dist/src/integrations/result-synthesizer.js.map +1 -0
- package/dist/src/integrations/routing.d.ts +117 -0
- package/dist/src/integrations/routing.d.ts.map +1 -0
- package/dist/src/integrations/routing.js +347 -0
- package/dist/src/integrations/routing.js.map +1 -0
- package/dist/src/integrations/rules.d.ts +131 -0
- package/dist/src/integrations/rules.d.ts.map +1 -0
- package/dist/src/integrations/rules.js +284 -0
- package/dist/src/integrations/rules.js.map +1 -0
- package/dist/src/integrations/safety.d.ts +142 -0
- package/dist/src/integrations/safety.d.ts.map +1 -0
- package/dist/src/integrations/safety.js +342 -0
- package/dist/src/integrations/safety.js.map +1 -0
- package/dist/src/integrations/sandbox/basic.d.ts +74 -0
- package/dist/src/integrations/sandbox/basic.d.ts.map +1 -0
- package/dist/src/integrations/sandbox/basic.js +310 -0
- package/dist/src/integrations/sandbox/basic.js.map +1 -0
- package/dist/src/integrations/sandbox/docker.d.ts +94 -0
- package/dist/src/integrations/sandbox/docker.d.ts.map +1 -0
- package/dist/src/integrations/sandbox/docker.js +293 -0
- package/dist/src/integrations/sandbox/docker.js.map +1 -0
- package/dist/src/integrations/sandbox/index.d.ts +182 -0
- package/dist/src/integrations/sandbox/index.d.ts.map +1 -0
- package/dist/src/integrations/sandbox/index.js +382 -0
- package/dist/src/integrations/sandbox/index.js.map +1 -0
- package/dist/src/integrations/sandbox/landlock.d.ts +59 -0
- package/dist/src/integrations/sandbox/landlock.d.ts.map +1 -0
- package/dist/src/integrations/sandbox/landlock.js +326 -0
- package/dist/src/integrations/sandbox/landlock.js.map +1 -0
- package/dist/src/integrations/sandbox/seatbelt.d.ts +68 -0
- package/dist/src/integrations/sandbox/seatbelt.d.ts.map +1 -0
- package/dist/src/integrations/sandbox/seatbelt.js +298 -0
- package/dist/src/integrations/sandbox/seatbelt.js.map +1 -0
- package/dist/src/integrations/semantic-cache.d.ts +178 -0
- package/dist/src/integrations/semantic-cache.d.ts.map +1 -0
- package/dist/src/integrations/semantic-cache.js +372 -0
- package/dist/src/integrations/semantic-cache.js.map +1 -0
- package/dist/src/integrations/session-store.d.ts +183 -0
- package/dist/src/integrations/session-store.d.ts.map +1 -0
- package/dist/src/integrations/session-store.js +345 -0
- package/dist/src/integrations/session-store.js.map +1 -0
- package/dist/src/integrations/shared-blackboard.d.ts +403 -0
- package/dist/src/integrations/shared-blackboard.d.ts.map +1 -0
- package/dist/src/integrations/shared-blackboard.js +710 -0
- package/dist/src/integrations/shared-blackboard.js.map +1 -0
- package/dist/src/integrations/skills.d.ts +171 -0
- package/dist/src/integrations/skills.d.ts.map +1 -0
- package/dist/src/integrations/skills.js +403 -0
- package/dist/src/integrations/skills.js.map +1 -0
- package/dist/src/integrations/smart-decomposer.d.ts +322 -0
- package/dist/src/integrations/smart-decomposer.d.ts.map +1 -0
- package/dist/src/integrations/smart-decomposer.js +856 -0
- package/dist/src/integrations/smart-decomposer.js.map +1 -0
- package/dist/src/integrations/sourcegraph.d.ts +169 -0
- package/dist/src/integrations/sourcegraph.d.ts.map +1 -0
- package/dist/src/integrations/sourcegraph.js +379 -0
- package/dist/src/integrations/sourcegraph.js.map +1 -0
- package/dist/src/integrations/sqlite-store.d.ts +518 -0
- package/dist/src/integrations/sqlite-store.d.ts.map +1 -0
- package/dist/src/integrations/sqlite-store.js +1423 -0
- package/dist/src/integrations/sqlite-store.js.map +1 -0
- package/dist/src/integrations/streaming.d.ts +102 -0
- package/dist/src/integrations/streaming.d.ts.map +1 -0
- package/dist/src/integrations/streaming.js +362 -0
- package/dist/src/integrations/streaming.js.map +1 -0
- package/dist/src/integrations/thread-manager.d.ts +199 -0
- package/dist/src/integrations/thread-manager.d.ts.map +1 -0
- package/dist/src/integrations/thread-manager.js +357 -0
- package/dist/src/integrations/thread-manager.js.map +1 -0
- package/dist/src/main.d.ts +26 -0
- package/dist/src/main.d.ts.map +1 -0
- package/dist/src/main.js +170 -0
- package/dist/src/main.js.map +1 -0
- package/dist/src/modes/index.d.ts +10 -0
- package/dist/src/modes/index.d.ts.map +1 -0
- package/dist/src/modes/index.js +10 -0
- package/dist/src/modes/index.js.map +1 -0
- package/dist/src/modes/repl.d.ts +19 -0
- package/dist/src/modes/repl.d.ts.map +1 -0
- package/dist/src/modes/repl.js +393 -0
- package/dist/src/modes/repl.js.map +1 -0
- package/dist/src/modes/tui.d.ts +29 -0
- package/dist/src/modes/tui.d.ts.map +1 -0
- package/dist/src/modes/tui.js +272 -0
- package/dist/src/modes/tui.js.map +1 -0
- package/dist/src/modes.d.ts +179 -0
- package/dist/src/modes.d.ts.map +1 -0
- package/dist/src/modes.js +385 -0
- package/dist/src/modes.js.map +1 -0
- package/dist/src/observability/tracer.d.ts +111 -0
- package/dist/src/observability/tracer.d.ts.map +1 -0
- package/dist/src/observability/tracer.js +300 -0
- package/dist/src/observability/tracer.js.map +1 -0
- package/dist/src/observability/types.d.ts +271 -0
- package/dist/src/observability/types.d.ts.map +1 -0
- package/dist/src/observability/types.js +24 -0
- package/dist/src/observability/types.js.map +1 -0
- package/dist/src/paths.d.ts +101 -0
- package/dist/src/paths.d.ts.map +1 -0
- package/dist/src/paths.js +148 -0
- package/dist/src/paths.js.map +1 -0
- package/dist/src/persistence/index.d.ts +38 -0
- package/dist/src/persistence/index.d.ts.map +1 -0
- package/dist/src/persistence/index.js +48 -0
- package/dist/src/persistence/index.js.map +1 -0
- package/dist/src/persistence/migrator.d.ts +135 -0
- package/dist/src/persistence/migrator.d.ts.map +1 -0
- package/dist/src/persistence/migrator.js +303 -0
- package/dist/src/persistence/migrator.js.map +1 -0
- package/dist/src/persistence/schema.d.ts +101 -0
- package/dist/src/persistence/schema.d.ts.map +1 -0
- package/dist/src/persistence/schema.js +395 -0
- package/dist/src/persistence/schema.js.map +1 -0
- package/dist/src/providers/adapters/anthropic.d.ts +20 -0
- package/dist/src/providers/adapters/anthropic.d.ts.map +1 -0
- package/dist/src/providers/adapters/anthropic.js +124 -0
- package/dist/src/providers/adapters/anthropic.js.map +1 -0
- package/dist/src/providers/adapters/mock.d.ts +25 -0
- package/dist/src/providers/adapters/mock.d.ts.map +1 -0
- package/dist/src/providers/adapters/mock.js +133 -0
- package/dist/src/providers/adapters/mock.js.map +1 -0
- package/dist/src/providers/adapters/openai.d.ts +21 -0
- package/dist/src/providers/adapters/openai.d.ts.map +1 -0
- package/dist/src/providers/adapters/openai.js +126 -0
- package/dist/src/providers/adapters/openai.js.map +1 -0
- package/dist/src/providers/adapters/openrouter.d.ts +49 -0
- package/dist/src/providers/adapters/openrouter.d.ts.map +1 -0
- package/dist/src/providers/adapters/openrouter.js +363 -0
- package/dist/src/providers/adapters/openrouter.js.map +1 -0
- package/dist/src/providers/provider.d.ts +54 -0
- package/dist/src/providers/provider.d.ts.map +1 -0
- package/dist/src/providers/provider.js +111 -0
- package/dist/src/providers/provider.js.map +1 -0
- package/dist/src/providers/resilient-fetch.d.ts +99 -0
- package/dist/src/providers/resilient-fetch.d.ts.map +1 -0
- package/dist/src/providers/resilient-fetch.js +208 -0
- package/dist/src/providers/resilient-fetch.js.map +1 -0
- package/dist/src/providers/types.d.ts +227 -0
- package/dist/src/providers/types.d.ts.map +1 -0
- package/dist/src/providers/types.js +24 -0
- package/dist/src/providers/types.js.map +1 -0
- package/dist/src/session-picker.d.ts +28 -0
- package/dist/src/session-picker.d.ts.map +1 -0
- package/dist/src/session-picker.js +256 -0
- package/dist/src/session-picker.js.map +1 -0
- package/dist/src/test-sqlite.d.ts +2 -0
- package/dist/src/test-sqlite.d.ts.map +1 -0
- package/dist/src/test-sqlite.js +114 -0
- package/dist/src/test-sqlite.js.map +1 -0
- package/dist/src/tools/agent.d.ts +44 -0
- package/dist/src/tools/agent.d.ts.map +1 -0
- package/dist/src/tools/agent.js +110 -0
- package/dist/src/tools/agent.js.map +1 -0
- package/dist/src/tools/bash.d.ts +52 -0
- package/dist/src/tools/bash.d.ts.map +1 -0
- package/dist/src/tools/bash.js +141 -0
- package/dist/src/tools/bash.js.map +1 -0
- package/dist/src/tools/file.d.ts +47 -0
- package/dist/src/tools/file.d.ts.map +1 -0
- package/dist/src/tools/file.js +263 -0
- package/dist/src/tools/file.js.map +1 -0
- package/dist/src/tools/permission.d.ts +43 -0
- package/dist/src/tools/permission.d.ts.map +1 -0
- package/dist/src/tools/permission.js +216 -0
- package/dist/src/tools/permission.js.map +1 -0
- package/dist/src/tools/registry.d.ts +63 -0
- package/dist/src/tools/registry.d.ts.map +1 -0
- package/dist/src/tools/registry.js +250 -0
- package/dist/src/tools/registry.js.map +1 -0
- package/dist/src/tools/standard.d.ts +57 -0
- package/dist/src/tools/standard.d.ts.map +1 -0
- package/dist/src/tools/standard.js +113 -0
- package/dist/src/tools/standard.js.map +1 -0
- package/dist/src/tools/types.d.ts +146 -0
- package/dist/src/tools/types.d.ts.map +1 -0
- package/dist/src/tools/types.js +28 -0
- package/dist/src/tools/types.js.map +1 -0
- package/dist/src/tools/undo.d.ts +71 -0
- package/dist/src/tools/undo.d.ts.map +1 -0
- package/dist/src/tools/undo.js +123 -0
- package/dist/src/tools/undo.js.map +1 -0
- package/dist/src/tracing/cache-boundary-tracker.d.ts +189 -0
- package/dist/src/tracing/cache-boundary-tracker.d.ts.map +1 -0
- package/dist/src/tracing/cache-boundary-tracker.js +411 -0
- package/dist/src/tracing/cache-boundary-tracker.js.map +1 -0
- package/dist/src/tracing/trace-collector.d.ts +274 -0
- package/dist/src/tracing/trace-collector.d.ts.map +1 -0
- package/dist/src/tracing/trace-collector.js +727 -0
- package/dist/src/tracing/trace-collector.js.map +1 -0
- package/dist/src/tracing/types.d.ts +657 -0
- package/dist/src/tracing/types.d.ts.map +1 -0
- package/dist/src/tracing/types.js +39 -0
- package/dist/src/tracing/types.js.map +1 -0
- package/dist/src/tricks/failure-evidence.d.ts +268 -0
- package/dist/src/tricks/failure-evidence.d.ts.map +1 -0
- package/dist/src/tricks/failure-evidence.js +544 -0
- package/dist/src/tricks/failure-evidence.js.map +1 -0
- package/dist/src/tricks/json-utils.d.ts +77 -0
- package/dist/src/tricks/json-utils.d.ts.map +1 -0
- package/dist/src/tricks/json-utils.js +247 -0
- package/dist/src/tricks/json-utils.js.map +1 -0
- package/dist/src/tricks/kv-cache-context.d.ts +227 -0
- package/dist/src/tricks/kv-cache-context.d.ts.map +1 -0
- package/dist/src/tricks/kv-cache-context.js +377 -0
- package/dist/src/tricks/kv-cache-context.js.map +1 -0
- package/dist/src/tricks/recitation.d.ts +208 -0
- package/dist/src/tricks/recitation.d.ts.map +1 -0
- package/dist/src/tricks/recitation.js +374 -0
- package/dist/src/tricks/recitation.js.map +1 -0
- package/dist/src/tricks/reversible-compaction.d.ts +251 -0
- package/dist/src/tricks/reversible-compaction.d.ts.map +1 -0
- package/dist/src/tricks/reversible-compaction.js +555 -0
- package/dist/src/tricks/reversible-compaction.js.map +1 -0
- package/dist/src/tricks/serialization-diversity.d.ts +197 -0
- package/dist/src/tricks/serialization-diversity.d.ts.map +1 -0
- package/dist/src/tricks/serialization-diversity.js +460 -0
- package/dist/src/tricks/serialization-diversity.js.map +1 -0
- package/dist/src/tui/app.d.ts +42 -0
- package/dist/src/tui/app.d.ts.map +1 -0
- package/dist/src/tui/app.js +1076 -0
- package/dist/src/tui/app.js.map +1 -0
- package/dist/src/tui/components/ApprovalDialog.d.ts +28 -0
- package/dist/src/tui/components/ApprovalDialog.d.ts.map +1 -0
- package/dist/src/tui/components/ApprovalDialog.js +59 -0
- package/dist/src/tui/components/ApprovalDialog.js.map +1 -0
- package/dist/src/tui/components/InputArea.d.ts +35 -0
- package/dist/src/tui/components/InputArea.d.ts.map +1 -0
- package/dist/src/tui/components/InputArea.js +144 -0
- package/dist/src/tui/components/InputArea.js.map +1 -0
- package/dist/src/tui/components/MessageItem.d.ts +28 -0
- package/dist/src/tui/components/MessageItem.d.ts.map +1 -0
- package/dist/src/tui/components/MessageItem.js +27 -0
- package/dist/src/tui/components/MessageItem.js.map +1 -0
- package/dist/src/tui/components/ScrollableBox.d.ts +41 -0
- package/dist/src/tui/components/ScrollableBox.d.ts.map +1 -0
- package/dist/src/tui/components/ScrollableBox.js +101 -0
- package/dist/src/tui/components/ScrollableBox.js.map +1 -0
- package/dist/src/tui/components/ToolCallItem.d.ts +33 -0
- package/dist/src/tui/components/ToolCallItem.d.ts.map +1 -0
- package/dist/src/tui/components/ToolCallItem.js +91 -0
- package/dist/src/tui/components/ToolCallItem.js.map +1 -0
- package/dist/src/tui/components/index.d.ts +13 -0
- package/dist/src/tui/components/index.d.ts.map +1 -0
- package/dist/src/tui/components/index.js +15 -0
- package/dist/src/tui/components/index.js.map +1 -0
- package/dist/src/tui/event-display.d.ts +19 -0
- package/dist/src/tui/event-display.d.ts.map +1 -0
- package/dist/src/tui/event-display.js +178 -0
- package/dist/src/tui/event-display.js.map +1 -0
- package/dist/src/tui/index.d.ts +105 -0
- package/dist/src/tui/index.d.ts.map +1 -0
- package/dist/src/tui/index.js +214 -0
- package/dist/src/tui/index.js.map +1 -0
- package/dist/src/tui/input/CommandPalette.d.ts +55 -0
- package/dist/src/tui/input/CommandPalette.d.ts.map +1 -0
- package/dist/src/tui/input/CommandPalette.js +135 -0
- package/dist/src/tui/input/CommandPalette.js.map +1 -0
- package/dist/src/tui/input/index.d.ts +7 -0
- package/dist/src/tui/input/index.d.ts.map +1 -0
- package/dist/src/tui/input/index.js +7 -0
- package/dist/src/tui/input/index.js.map +1 -0
- package/dist/src/tui/theme/index.d.ts +45 -0
- package/dist/src/tui/theme/index.d.ts.map +1 -0
- package/dist/src/tui/theme/index.js +215 -0
- package/dist/src/tui/theme/index.js.map +1 -0
- package/dist/src/tui/types.d.ts +214 -0
- package/dist/src/tui/types.d.ts.map +1 -0
- package/dist/src/tui/types.js +27 -0
- package/dist/src/tui/types.js.map +1 -0
- package/dist/src/types.d.ts +905 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +9 -0
- package/dist/src/types.js.map +1 -0
- package/package.json +89 -0
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Process Error Handlers and Cleanup Management
|
|
3
|
+
*
|
|
4
|
+
* Provides graceful cleanup on process exit, signal handling,
|
|
5
|
+
* and resource registration for the application.
|
|
6
|
+
*/
|
|
7
|
+
let cleanupResources = {};
|
|
8
|
+
let isCleaningUp = false;
|
|
9
|
+
/**
|
|
10
|
+
* Gracefully clean up all resources before exit.
|
|
11
|
+
* Times out after 5 seconds to prevent hanging.
|
|
12
|
+
*/
|
|
13
|
+
export async function gracefulCleanup(reason) {
|
|
14
|
+
// Prevent recursive cleanup
|
|
15
|
+
if (isCleaningUp) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
isCleaningUp = true;
|
|
19
|
+
console.error(`\n[CLEANUP] Starting graceful cleanup (reason: ${reason})...`);
|
|
20
|
+
// Set a hard timeout to prevent hanging
|
|
21
|
+
const forceExitTimeout = setTimeout(() => {
|
|
22
|
+
console.error('[CLEANUP] Timeout reached, forcing exit');
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}, 5000);
|
|
25
|
+
try {
|
|
26
|
+
// Clean up in reverse initialization order
|
|
27
|
+
// 1. TUI (synchronous)
|
|
28
|
+
if (cleanupResources.tui) {
|
|
29
|
+
try {
|
|
30
|
+
cleanupResources.tui.cleanup();
|
|
31
|
+
}
|
|
32
|
+
catch (e) {
|
|
33
|
+
console.error('[CLEANUP] TUI cleanup error:', e);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
// 2. Readline (synchronous)
|
|
37
|
+
if (cleanupResources.rl) {
|
|
38
|
+
try {
|
|
39
|
+
cleanupResources.rl.close();
|
|
40
|
+
}
|
|
41
|
+
catch (e) {
|
|
42
|
+
console.error('[CLEANUP] Readline cleanup error:', e);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
// 3. Agent (async)
|
|
46
|
+
if (cleanupResources.agent) {
|
|
47
|
+
try {
|
|
48
|
+
await cleanupResources.agent.cleanup();
|
|
49
|
+
}
|
|
50
|
+
catch (e) {
|
|
51
|
+
console.error('[CLEANUP] Agent cleanup error:', e);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
// 4. MCP Client (async)
|
|
55
|
+
if (cleanupResources.mcpClient) {
|
|
56
|
+
try {
|
|
57
|
+
await cleanupResources.mcpClient.cleanup();
|
|
58
|
+
}
|
|
59
|
+
catch (e) {
|
|
60
|
+
console.error('[CLEANUP] MCP cleanup error:', e);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
console.error('[CLEANUP] Cleanup completed');
|
|
64
|
+
}
|
|
65
|
+
finally {
|
|
66
|
+
clearTimeout(forceExitTimeout);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Register a resource for cleanup on process exit.
|
|
71
|
+
*/
|
|
72
|
+
export function registerCleanupResource(key, resource) {
|
|
73
|
+
cleanupResources[key] = resource;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Reset cleanup state - useful for testing or re-initialization.
|
|
77
|
+
*/
|
|
78
|
+
export function resetCleanupState() {
|
|
79
|
+
cleanupResources = {};
|
|
80
|
+
isCleaningUp = false;
|
|
81
|
+
}
|
|
82
|
+
// =============================================================================
|
|
83
|
+
// PROCESS SIGNAL HANDLERS
|
|
84
|
+
// =============================================================================
|
|
85
|
+
/**
|
|
86
|
+
* Install process-level error handlers.
|
|
87
|
+
* Should be called once at application startup.
|
|
88
|
+
*/
|
|
89
|
+
export function installProcessHandlers() {
|
|
90
|
+
// Handle unhandled promise rejections
|
|
91
|
+
process.on('unhandledRejection', async (reason, _promise) => {
|
|
92
|
+
console.error('\n[FATAL] Unhandled Promise Rejection:');
|
|
93
|
+
console.error(' Reason:', reason);
|
|
94
|
+
if (reason instanceof Error && reason.stack) {
|
|
95
|
+
console.error(' Stack:', reason.stack.split('\n').slice(0, 5).join('\n'));
|
|
96
|
+
}
|
|
97
|
+
await gracefulCleanup('unhandled rejection');
|
|
98
|
+
process.exit(1);
|
|
99
|
+
});
|
|
100
|
+
// Handle uncaught exceptions
|
|
101
|
+
process.on('uncaughtException', async (error, origin) => {
|
|
102
|
+
console.error(`\n[FATAL] Uncaught Exception (${origin}):`);
|
|
103
|
+
console.error(' Error:', error.message);
|
|
104
|
+
if (error.stack) {
|
|
105
|
+
console.error(' Stack:', error.stack.split('\n').slice(0, 5).join('\n'));
|
|
106
|
+
}
|
|
107
|
+
await gracefulCleanup('uncaught exception');
|
|
108
|
+
process.exit(1);
|
|
109
|
+
});
|
|
110
|
+
// Handle SIGTERM for graceful shutdown (e.g., container orchestration)
|
|
111
|
+
process.on('SIGTERM', async () => {
|
|
112
|
+
console.error('\n[INFO] Received SIGTERM signal');
|
|
113
|
+
await gracefulCleanup('SIGTERM');
|
|
114
|
+
process.exit(0);
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
//# sourceMappingURL=process-handlers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"process-handlers.js","sourceRoot":"","sources":["../../../src/core/process-handlers.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAiBH,IAAI,gBAAgB,GAAqB,EAAE,CAAC;AAC5C,IAAI,YAAY,GAAG,KAAK,CAAC;AAEzB;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,MAAc;IAClD,4BAA4B;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6BAA6B;IAC7B,OAAO,CAAC,EAAE,CAAC,mBAAmB,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE;QACtD,OAAO,CAAC,KAAK,CAAC,iCAAiC,MAAM,IAAI,CAAC,CAAC;QAC3D,OAAO,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;QACzC,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;YAChB,OAAO,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAC5E,CAAC;QACD,MAAM,eAAe,CAAC,oBAAoB,CAAC,CAAC;QAC5C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;IAEH,uEAAuE;IACvE,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,KAAK,IAAI,EAAE;QAC/B,OAAO,CAAC,KAAK,CAAC,kCAAkC,CAAC,CAAC;QAClD,MAAM,eAAe,CAAC,SAAS,CAAC,CAAC;QACjC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Protocol Bridge
|
|
3
|
+
*
|
|
4
|
+
* Connects UI layer to Agent layer via queue-based communication.
|
|
5
|
+
* Maps internal agent events to protocol events with submission correlation.
|
|
6
|
+
*
|
|
7
|
+
* Architecture:
|
|
8
|
+
* ```
|
|
9
|
+
* UI (REPL/TUI) Agent Core
|
|
10
|
+
* | |
|
|
11
|
+
* └─── Op ──► SubmissionQueue ───► handleOperation()
|
|
12
|
+
* (64) |
|
|
13
|
+
* |
|
|
14
|
+
* ◄── Event ─ EventQueue ◄───────── emit()
|
|
15
|
+
* (unbounded)
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
import type { AgentEvent, Submission, SubmissionId } from './types.js';
|
|
19
|
+
import type { SubmissionQueue } from '../queues/submission-queue.js';
|
|
20
|
+
import type { EventQueue } from '../queues/event-queue.js';
|
|
21
|
+
/**
|
|
22
|
+
* Handler for incoming operations from the UI.
|
|
23
|
+
*/
|
|
24
|
+
export type OperationHandler = (submission: Submission) => Promise<void>;
|
|
25
|
+
/**
|
|
26
|
+
* Protocol bridge interface for UI/Agent communication.
|
|
27
|
+
*/
|
|
28
|
+
export interface IProtocolBridge {
|
|
29
|
+
/**
|
|
30
|
+
* Starts the bridge, consuming from the submission queue.
|
|
31
|
+
* @param submissionQueue - Queue for incoming operations from UI
|
|
32
|
+
* @param eventQueue - Queue for outgoing events to UI
|
|
33
|
+
*/
|
|
34
|
+
start(submissionQueue: SubmissionQueue, eventQueue: EventQueue): void;
|
|
35
|
+
/**
|
|
36
|
+
* Stops the bridge and cleans up resources.
|
|
37
|
+
*/
|
|
38
|
+
stop(): void;
|
|
39
|
+
/**
|
|
40
|
+
* Registers a handler for incoming operations.
|
|
41
|
+
* Only one handler is supported - subsequent calls replace the previous handler.
|
|
42
|
+
* @param handler - The handler function for operations
|
|
43
|
+
*/
|
|
44
|
+
onOperation(handler: OperationHandler): void;
|
|
45
|
+
/**
|
|
46
|
+
* Emits an event to the UI, correlated with a submission.
|
|
47
|
+
* @param submissionId - The submission this event relates to
|
|
48
|
+
* @param event - The event to emit
|
|
49
|
+
*/
|
|
50
|
+
emit(submissionId: SubmissionId, event: AgentEvent): void;
|
|
51
|
+
/**
|
|
52
|
+
* Returns true if the bridge is currently running.
|
|
53
|
+
*/
|
|
54
|
+
isRunning(): boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Returns a promise that resolves when the bridge stops.
|
|
57
|
+
* Useful for testing or waiting for graceful shutdown.
|
|
58
|
+
*/
|
|
59
|
+
waitForStop(): Promise<void>;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Protocol bridge implementation.
|
|
63
|
+
*
|
|
64
|
+
* Manages the async loop that consumes from the submission queue
|
|
65
|
+
* and dispatches to the registered operation handler.
|
|
66
|
+
*/
|
|
67
|
+
export declare class ProtocolBridge implements IProtocolBridge {
|
|
68
|
+
private submissionQueue;
|
|
69
|
+
private eventQueue;
|
|
70
|
+
private operationHandler;
|
|
71
|
+
private running;
|
|
72
|
+
private consumePromise;
|
|
73
|
+
/**
|
|
74
|
+
* Starts the bridge, consuming from the submission queue.
|
|
75
|
+
* @throws Error if the bridge is already running
|
|
76
|
+
*/
|
|
77
|
+
start(submissionQueue: SubmissionQueue, eventQueue: EventQueue): void;
|
|
78
|
+
/**
|
|
79
|
+
* Stops the bridge and cleans up resources.
|
|
80
|
+
* Waits for the current operation to complete before stopping.
|
|
81
|
+
*/
|
|
82
|
+
stop(): void;
|
|
83
|
+
/**
|
|
84
|
+
* Registers a handler for incoming operations.
|
|
85
|
+
* Only one handler is supported - subsequent calls replace the previous handler.
|
|
86
|
+
*/
|
|
87
|
+
onOperation(handler: OperationHandler): void;
|
|
88
|
+
/**
|
|
89
|
+
* Emits an event to the UI, correlated with a submission.
|
|
90
|
+
* @throws Error if the bridge is not started
|
|
91
|
+
*/
|
|
92
|
+
emit(submissionId: SubmissionId, event: AgentEvent): void;
|
|
93
|
+
/**
|
|
94
|
+
* Returns true if the bridge is currently running.
|
|
95
|
+
*/
|
|
96
|
+
isRunning(): boolean;
|
|
97
|
+
/**
|
|
98
|
+
* Returns a promise that resolves when the bridge stops.
|
|
99
|
+
* Useful for testing or waiting for graceful shutdown.
|
|
100
|
+
*/
|
|
101
|
+
waitForStop(): Promise<void>;
|
|
102
|
+
/**
|
|
103
|
+
* The main consume loop that processes submissions.
|
|
104
|
+
* Runs until stop() is called or the queue is closed.
|
|
105
|
+
*/
|
|
106
|
+
private consumeLoop;
|
|
107
|
+
/**
|
|
108
|
+
* Handles errors from the operation handler.
|
|
109
|
+
* Emits an error event to the UI.
|
|
110
|
+
*/
|
|
111
|
+
private handleOperationError;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Creates a new ProtocolBridge instance.
|
|
115
|
+
*/
|
|
116
|
+
export declare function createProtocolBridge(): ProtocolBridge;
|
|
117
|
+
//# sourceMappingURL=bridge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bridge.d.ts","sourceRoot":"","sources":["../../../../src/core/protocol/bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AACvE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAE3D;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,UAAU,EAAE,UAAU,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAEzE;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;;;OAIG;IACH,KAAK,CAAC,eAAe,EAAE,eAAe,EAAE,UAAU,EAAE,UAAU,GAAG,IAAI,CAAC;IAEtE;;OAEG;IACH,IAAI,IAAI,IAAI,CAAC;IAEb;;;;OAIG;IACH,WAAW,CAAC,OAAO,EAAE,gBAAgB,GAAG,IAAI,CAAC;IAE7C;;;;OAIG;IACH,IAAI,CAAC,YAAY,EAAE,YAAY,EAAE,KAAK,EAAE,UAAU,GAAG,IAAI,CAAC;IAE1D;;OAEG;IACH,SAAS,IAAI,OAAO,CAAC;IAErB;;;OAGG;IACH,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B;AAED;;;;;GAKG;AACH,qBAAa,cAAe,YAAW,eAAe;IACpD,OAAO,CAAC,eAAe,CAAgC;IACvD,OAAO,CAAC,UAAU,CAA2B;IAC7C,OAAO,CAAC,gBAAgB,CAAiC;IACzD,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,cAAc,CAA8B;IAEpD;;;OAGG;IACH,KAAK,CAAC,eAAe,EAAE,eAAe,EAAE,UAAU,EAAE,UAAU,GAAG,IAAI;IAarE;;;OAGG;IACH,IAAI,IAAI,IAAI;IAOZ;;;OAGG;IACH,WAAW,CAAC,OAAO,EAAE,gBAAgB,GAAG,IAAI;IAI5C;;;OAGG;IACH,IAAI,CAAC,YAAY,EAAE,YAAY,EAAE,KAAK,EAAE,UAAU,GAAG,IAAI;IAQzD;;OAEG;IACH,SAAS,IAAI,OAAO;IAIpB;;;OAGG;IACG,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;IAMlC;;;OAGG;YACW,WAAW;IAoCzB;;;OAGG;IACH,OAAO,CAAC,oBAAoB;CAiB7B;AAED;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,cAAc,CAErD"}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Protocol Bridge
|
|
3
|
+
*
|
|
4
|
+
* Connects UI layer to Agent layer via queue-based communication.
|
|
5
|
+
* Maps internal agent events to protocol events with submission correlation.
|
|
6
|
+
*
|
|
7
|
+
* Architecture:
|
|
8
|
+
* ```
|
|
9
|
+
* UI (REPL/TUI) Agent Core
|
|
10
|
+
* | |
|
|
11
|
+
* └─── Op ──► SubmissionQueue ───► handleOperation()
|
|
12
|
+
* (64) |
|
|
13
|
+
* |
|
|
14
|
+
* ◄── Event ─ EventQueue ◄───────── emit()
|
|
15
|
+
* (unbounded)
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* Protocol bridge implementation.
|
|
20
|
+
*
|
|
21
|
+
* Manages the async loop that consumes from the submission queue
|
|
22
|
+
* and dispatches to the registered operation handler.
|
|
23
|
+
*/
|
|
24
|
+
export class ProtocolBridge {
|
|
25
|
+
submissionQueue = null;
|
|
26
|
+
eventQueue = null;
|
|
27
|
+
operationHandler = null;
|
|
28
|
+
running = false;
|
|
29
|
+
consumePromise = null;
|
|
30
|
+
/**
|
|
31
|
+
* Starts the bridge, consuming from the submission queue.
|
|
32
|
+
* @throws Error if the bridge is already running
|
|
33
|
+
*/
|
|
34
|
+
start(submissionQueue, eventQueue) {
|
|
35
|
+
if (this.running) {
|
|
36
|
+
throw new Error('ProtocolBridge is already running');
|
|
37
|
+
}
|
|
38
|
+
this.submissionQueue = submissionQueue;
|
|
39
|
+
this.eventQueue = eventQueue;
|
|
40
|
+
this.running = true;
|
|
41
|
+
// Start the consume loop
|
|
42
|
+
this.consumePromise = this.consumeLoop();
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Stops the bridge and cleans up resources.
|
|
46
|
+
* Waits for the current operation to complete before stopping.
|
|
47
|
+
*/
|
|
48
|
+
stop() {
|
|
49
|
+
this.running = false;
|
|
50
|
+
// The consume loop will exit on the next iteration
|
|
51
|
+
// We don't close the queues - that's the caller's responsibility
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Registers a handler for incoming operations.
|
|
55
|
+
* Only one handler is supported - subsequent calls replace the previous handler.
|
|
56
|
+
*/
|
|
57
|
+
onOperation(handler) {
|
|
58
|
+
this.operationHandler = handler;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Emits an event to the UI, correlated with a submission.
|
|
62
|
+
* @throws Error if the bridge is not started
|
|
63
|
+
*/
|
|
64
|
+
emit(submissionId, event) {
|
|
65
|
+
if (!this.eventQueue) {
|
|
66
|
+
throw new Error('ProtocolBridge not started - cannot emit events');
|
|
67
|
+
}
|
|
68
|
+
this.eventQueue.emit(submissionId, event);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Returns true if the bridge is currently running.
|
|
72
|
+
*/
|
|
73
|
+
isRunning() {
|
|
74
|
+
return this.running;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Returns a promise that resolves when the bridge stops.
|
|
78
|
+
* Useful for testing or waiting for graceful shutdown.
|
|
79
|
+
*/
|
|
80
|
+
async waitForStop() {
|
|
81
|
+
if (this.consumePromise) {
|
|
82
|
+
await this.consumePromise;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* The main consume loop that processes submissions.
|
|
87
|
+
* Runs until stop() is called or the queue is closed.
|
|
88
|
+
*/
|
|
89
|
+
async consumeLoop() {
|
|
90
|
+
if (!this.submissionQueue) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
while (this.running) {
|
|
94
|
+
try {
|
|
95
|
+
// Take the next submission (blocks if empty)
|
|
96
|
+
const submission = await this.submissionQueue.take();
|
|
97
|
+
// null means the queue was closed
|
|
98
|
+
if (submission === null) {
|
|
99
|
+
this.running = false;
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
// Dispatch to handler if one is registered
|
|
103
|
+
if (this.operationHandler) {
|
|
104
|
+
try {
|
|
105
|
+
await this.operationHandler(submission);
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
// Log handler errors but don't crash the bridge
|
|
109
|
+
// The handler is responsible for emitting error events
|
|
110
|
+
this.handleOperationError(submission, error);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
// Queue errors (closed, etc.) - stop the loop
|
|
116
|
+
if (this.running) {
|
|
117
|
+
this.running = false;
|
|
118
|
+
}
|
|
119
|
+
break;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Handles errors from the operation handler.
|
|
125
|
+
* Emits an error event to the UI.
|
|
126
|
+
*/
|
|
127
|
+
handleOperationError(submission, error) {
|
|
128
|
+
// Only emit error event if we have an event queue
|
|
129
|
+
if (!this.eventQueue) {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
133
|
+
const errorStack = error instanceof Error ? error.stack : undefined;
|
|
134
|
+
this.eventQueue.emit(submission.id, {
|
|
135
|
+
type: 'error',
|
|
136
|
+
code: 'OPERATION_HANDLER_ERROR',
|
|
137
|
+
message: `Operation handler failed: ${errorMessage}`,
|
|
138
|
+
recoverable: true,
|
|
139
|
+
stack: errorStack,
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Creates a new ProtocolBridge instance.
|
|
145
|
+
*/
|
|
146
|
+
export function createProtocolBridge() {
|
|
147
|
+
return new ProtocolBridge();
|
|
148
|
+
}
|
|
149
|
+
//# sourceMappingURL=bridge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bridge.js","sourceRoot":"","sources":["../../../../src/core/protocol/bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAqDH;;;;;GAKG;AACH,MAAM,OAAO,cAAc;IACjB,eAAe,GAA2B,IAAI,CAAC;IAC/C,UAAU,GAAsB,IAAI,CAAC;IACrC,gBAAgB,GAA4B,IAAI,CAAC;IACjD,OAAO,GAAG,KAAK,CAAC;IAChB,cAAc,GAAyB,IAAI,CAAC;IAEpD;;;OAGG;IACH,KAAK,CAAC,eAAgC,EAAE,UAAsB;QAC5D,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;QACvD,CAAC;QAED,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QACvC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QAEpB,yBAAyB;QACzB,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;IAC3C,CAAC;IAED;;;OAGG;IACH,IAAI;QACF,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;QAErB,mDAAmD;QACnD,iEAAiE;IACnE,CAAC;IAED;;;O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AAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,8CAA8C;gBAC9C,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;oBACjB,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;gBACvB,CAAC;gBACD,MAAM;YACR,CAAC;QACH,CAAC;IACH,CAAC;IAED;;;OAGG;IACK,oBAAoB,CAAC,UAAsB,EAAE,KAAc;QACjE,kDAAkD;QAClD,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;YACrB,OAAO;QACT,CAAC;QAED,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC5E,MAAM,UAAU,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;QAEpE,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,EAAE;YAClC,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,yBAAyB;YAC/B,OAAO,EAAE,6BAA6B,YAAY,EAAE;YACpD,WAAW,EAAE,IAAI;YACjB,KAAK,EAAE,UAAU;SAClB,CAAC,CAAC;IACL,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,oBAAoB;IAClC,OAAO,IAAI,cAAc,EAAE,CAAC;AAC9B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/core/protocol/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/core/protocol/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,YAAY,CAAC"}
|