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,710 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared Blackboard Integration
|
|
3
|
+
*
|
|
4
|
+
* Implements the Blackboard pattern for subagent coordination.
|
|
5
|
+
* Enables real-time knowledge sharing between parallel agents without
|
|
6
|
+
* tight coupling.
|
|
7
|
+
*
|
|
8
|
+
* Key features:
|
|
9
|
+
* - Finding posting: Agents share discoveries as they work
|
|
10
|
+
* - Topic subscriptions: Agents subscribe to relevant findings
|
|
11
|
+
* - Resource claiming: Prevent file edit conflicts
|
|
12
|
+
* - Deduplication: Avoid researching what another agent already found
|
|
13
|
+
* - Query interface: Search findings by topic, agent, or content
|
|
14
|
+
*/
|
|
15
|
+
// =============================================================================
|
|
16
|
+
// SHARED BLACKBOARD
|
|
17
|
+
// =============================================================================
|
|
18
|
+
/**
|
|
19
|
+
* Shared blackboard for subagent coordination.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* const blackboard = createSharedBlackboard();
|
|
24
|
+
*
|
|
25
|
+
* // Agent A posts a finding
|
|
26
|
+
* blackboard.post('agent-a', {
|
|
27
|
+
* topic: 'authentication',
|
|
28
|
+
* content: 'Found JWT implementation in src/auth/jwt.ts',
|
|
29
|
+
* type: 'discovery',
|
|
30
|
+
* confidence: 0.9,
|
|
31
|
+
* relatedFiles: ['src/auth/jwt.ts'],
|
|
32
|
+
* });
|
|
33
|
+
*
|
|
34
|
+
* // Agent B subscribes to authentication findings
|
|
35
|
+
* blackboard.subscribe({
|
|
36
|
+
* agentId: 'agent-b',
|
|
37
|
+
* topicPattern: 'auth*',
|
|
38
|
+
* callback: (finding) => {
|
|
39
|
+
* console.log('Got finding:', finding.content);
|
|
40
|
+
* },
|
|
41
|
+
* });
|
|
42
|
+
*
|
|
43
|
+
* // Agent A claims a file for editing
|
|
44
|
+
* const claimed = blackboard.claim('src/auth/jwt.ts', 'agent-a', 'write');
|
|
45
|
+
* if (claimed) {
|
|
46
|
+
* // Safe to edit
|
|
47
|
+
* }
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export class SharedBlackboard {
|
|
51
|
+
config;
|
|
52
|
+
findings = new Map();
|
|
53
|
+
claims = new Map();
|
|
54
|
+
subscriptions = new Map();
|
|
55
|
+
listeners = [];
|
|
56
|
+
duplicatesAvoided = 0;
|
|
57
|
+
findingCounter = 0;
|
|
58
|
+
subscriptionCounter = 0;
|
|
59
|
+
constructor(config = {}) {
|
|
60
|
+
this.config = {
|
|
61
|
+
maxFindings: config.maxFindings ?? 1000,
|
|
62
|
+
defaultClaimTTL: config.defaultClaimTTL ?? 60000, // 1 minute
|
|
63
|
+
deduplicateFindings: config.deduplicateFindings ?? true,
|
|
64
|
+
deduplicationThreshold: config.deduplicationThreshold ?? 0.85,
|
|
65
|
+
persistToFile: config.persistToFile ?? false,
|
|
66
|
+
persistencePath: config.persistencePath ?? '.blackboard.json',
|
|
67
|
+
};
|
|
68
|
+
// Start claim expiry checker
|
|
69
|
+
this.startClaimExpiryChecker();
|
|
70
|
+
}
|
|
71
|
+
// ===========================================================================
|
|
72
|
+
// FINDINGS
|
|
73
|
+
// ===========================================================================
|
|
74
|
+
/**
|
|
75
|
+
* Post a finding to the blackboard.
|
|
76
|
+
*/
|
|
77
|
+
post(agentId, input) {
|
|
78
|
+
// Check for duplicates
|
|
79
|
+
if (this.config.deduplicateFindings) {
|
|
80
|
+
const duplicate = this.findDuplicate(input);
|
|
81
|
+
if (duplicate) {
|
|
82
|
+
this.duplicatesAvoided++;
|
|
83
|
+
return duplicate;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
const finding = {
|
|
87
|
+
...input,
|
|
88
|
+
id: `finding-${++this.findingCounter}-${Date.now()}`,
|
|
89
|
+
agentId,
|
|
90
|
+
timestamp: new Date(),
|
|
91
|
+
};
|
|
92
|
+
// Handle supersession
|
|
93
|
+
if (finding.supersedesId) {
|
|
94
|
+
this.emit({
|
|
95
|
+
type: 'finding.superseded',
|
|
96
|
+
oldId: finding.supersedesId,
|
|
97
|
+
newId: finding.id,
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
// Enforce max findings
|
|
101
|
+
if (this.findings.size >= this.config.maxFindings) {
|
|
102
|
+
this.evictOldestFinding();
|
|
103
|
+
}
|
|
104
|
+
this.findings.set(finding.id, finding);
|
|
105
|
+
this.emit({ type: 'finding.posted', finding });
|
|
106
|
+
// Notify subscribers
|
|
107
|
+
this.notifySubscribers(finding);
|
|
108
|
+
return finding;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Update an existing finding.
|
|
112
|
+
*/
|
|
113
|
+
update(findingId, updates) {
|
|
114
|
+
const existing = this.findings.get(findingId);
|
|
115
|
+
if (!existing)
|
|
116
|
+
return null;
|
|
117
|
+
const updated = {
|
|
118
|
+
...existing,
|
|
119
|
+
...updates,
|
|
120
|
+
};
|
|
121
|
+
this.findings.set(findingId, updated);
|
|
122
|
+
this.emit({ type: 'finding.updated', finding: updated });
|
|
123
|
+
return updated;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Get a finding by ID.
|
|
127
|
+
*/
|
|
128
|
+
getFinding(id) {
|
|
129
|
+
return this.findings.get(id);
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Query findings with filters.
|
|
133
|
+
*/
|
|
134
|
+
query(filter = {}) {
|
|
135
|
+
let results = Array.from(this.findings.values());
|
|
136
|
+
// Apply filters
|
|
137
|
+
if (filter.agentId) {
|
|
138
|
+
results = results.filter((f) => f.agentId === filter.agentId);
|
|
139
|
+
}
|
|
140
|
+
if (filter.topic) {
|
|
141
|
+
const pattern = this.topicToRegex(filter.topic);
|
|
142
|
+
results = results.filter((f) => pattern.test(f.topic));
|
|
143
|
+
}
|
|
144
|
+
if (filter.types && filter.types.length > 0) {
|
|
145
|
+
results = results.filter((f) => filter.types.includes(f.type));
|
|
146
|
+
}
|
|
147
|
+
if (filter.tags && filter.tags.length > 0) {
|
|
148
|
+
results = results.filter((f) => f.tags?.some((tag) => filter.tags.includes(tag)));
|
|
149
|
+
}
|
|
150
|
+
if (filter.minConfidence !== undefined) {
|
|
151
|
+
results = results.filter((f) => f.confidence >= filter.minConfidence);
|
|
152
|
+
}
|
|
153
|
+
if (filter.since) {
|
|
154
|
+
results = results.filter((f) => f.timestamp >= filter.since);
|
|
155
|
+
}
|
|
156
|
+
if (filter.relatedFiles && filter.relatedFiles.length > 0) {
|
|
157
|
+
results = results.filter((f) => f.relatedFiles?.some((file) => filter.relatedFiles.includes(file)));
|
|
158
|
+
}
|
|
159
|
+
if (filter.contentSearch) {
|
|
160
|
+
const searchLower = filter.contentSearch.toLowerCase();
|
|
161
|
+
results = results.filter((f) => f.content.toLowerCase().includes(searchLower));
|
|
162
|
+
}
|
|
163
|
+
// Sort by timestamp (newest first)
|
|
164
|
+
results.sort((a, b) => b.timestamp.getTime() - a.timestamp.getTime());
|
|
165
|
+
// Apply limit
|
|
166
|
+
if (filter.limit) {
|
|
167
|
+
results = results.slice(0, filter.limit);
|
|
168
|
+
}
|
|
169
|
+
return results;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Get all findings.
|
|
173
|
+
*/
|
|
174
|
+
getAllFindings() {
|
|
175
|
+
return Array.from(this.findings.values());
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Get findings by topic.
|
|
179
|
+
*/
|
|
180
|
+
getByTopic(topic) {
|
|
181
|
+
return this.query({ topic });
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Get findings by agent.
|
|
185
|
+
*/
|
|
186
|
+
getByAgent(agentId) {
|
|
187
|
+
return this.query({ agentId });
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Check if a finding similar to the input already exists.
|
|
191
|
+
*/
|
|
192
|
+
findDuplicate(input) {
|
|
193
|
+
for (const existing of this.findings.values()) {
|
|
194
|
+
if (existing.topic === input.topic && existing.type === input.type) {
|
|
195
|
+
const similarity = this.calculateSimilarity(existing.content, input.content);
|
|
196
|
+
if (similarity >= this.config.deduplicationThreshold) {
|
|
197
|
+
return existing;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
return null;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Calculate content similarity (simple Jaccard index).
|
|
205
|
+
*/
|
|
206
|
+
calculateSimilarity(a, b) {
|
|
207
|
+
const wordsA = new Set(a.toLowerCase().split(/\s+/));
|
|
208
|
+
const wordsB = new Set(b.toLowerCase().split(/\s+/));
|
|
209
|
+
const intersection = new Set([...wordsA].filter((x) => wordsB.has(x)));
|
|
210
|
+
const union = new Set([...wordsA, ...wordsB]);
|
|
211
|
+
return intersection.size / union.size;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Evict the oldest finding.
|
|
215
|
+
*/
|
|
216
|
+
evictOldestFinding() {
|
|
217
|
+
let oldest = null;
|
|
218
|
+
let oldestTime = Infinity;
|
|
219
|
+
for (const finding of this.findings.values()) {
|
|
220
|
+
const time = finding.timestamp.getTime();
|
|
221
|
+
if (time < oldestTime) {
|
|
222
|
+
oldestTime = time;
|
|
223
|
+
oldest = finding;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
if (oldest) {
|
|
227
|
+
this.findings.delete(oldest.id);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
// ===========================================================================
|
|
231
|
+
// SUBSCRIPTIONS
|
|
232
|
+
// ===========================================================================
|
|
233
|
+
/**
|
|
234
|
+
* Subscribe to findings matching a pattern.
|
|
235
|
+
*/
|
|
236
|
+
subscribe(options) {
|
|
237
|
+
const subscription = {
|
|
238
|
+
...options,
|
|
239
|
+
id: `sub-${++this.subscriptionCounter}-${Date.now()}`,
|
|
240
|
+
createdAt: new Date(),
|
|
241
|
+
};
|
|
242
|
+
this.subscriptions.set(subscription.id, subscription);
|
|
243
|
+
return subscription.id;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Unsubscribe from findings.
|
|
247
|
+
*/
|
|
248
|
+
unsubscribe(subscriptionId) {
|
|
249
|
+
return this.subscriptions.delete(subscriptionId);
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Unsubscribe all subscriptions for an agent.
|
|
253
|
+
*/
|
|
254
|
+
unsubscribeAgent(agentId) {
|
|
255
|
+
let count = 0;
|
|
256
|
+
for (const [id, sub] of this.subscriptions) {
|
|
257
|
+
if (sub.agentId === agentId) {
|
|
258
|
+
this.subscriptions.delete(id);
|
|
259
|
+
count++;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
return count;
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Notify matching subscribers of a new finding.
|
|
266
|
+
*/
|
|
267
|
+
notifySubscribers(finding) {
|
|
268
|
+
for (const [id, sub] of this.subscriptions) {
|
|
269
|
+
if (this.matchesSubscription(finding, sub)) {
|
|
270
|
+
try {
|
|
271
|
+
sub.callback(finding);
|
|
272
|
+
this.emit({
|
|
273
|
+
type: 'subscription.matched',
|
|
274
|
+
subscriptionId: id,
|
|
275
|
+
findingId: finding.id,
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
catch {
|
|
279
|
+
// Ignore callback errors
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Check if a finding matches a subscription.
|
|
286
|
+
*/
|
|
287
|
+
matchesSubscription(finding, sub) {
|
|
288
|
+
// Don't notify the posting agent
|
|
289
|
+
if (finding.agentId === sub.agentId) {
|
|
290
|
+
return false;
|
|
291
|
+
}
|
|
292
|
+
// Check topic pattern
|
|
293
|
+
if (sub.topicPattern) {
|
|
294
|
+
const pattern = this.topicToRegex(sub.topicPattern);
|
|
295
|
+
if (!pattern.test(finding.topic)) {
|
|
296
|
+
return false;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
// Check types
|
|
300
|
+
if (sub.types && sub.types.length > 0) {
|
|
301
|
+
if (!sub.types.includes(finding.type)) {
|
|
302
|
+
return false;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
// Check tags
|
|
306
|
+
if (sub.tags && sub.tags.length > 0) {
|
|
307
|
+
if (!finding.tags?.some((tag) => sub.tags.includes(tag))) {
|
|
308
|
+
return false;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
return true;
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Convert a topic pattern to a regex.
|
|
315
|
+
*/
|
|
316
|
+
topicToRegex(pattern) {
|
|
317
|
+
const escaped = pattern
|
|
318
|
+
.replace(/[.+^${}()|[\]\\]/g, '\\$&')
|
|
319
|
+
.replace(/\*/g, '.*')
|
|
320
|
+
.replace(/\?/g, '.');
|
|
321
|
+
return new RegExp(`^${escaped}$`, 'i');
|
|
322
|
+
}
|
|
323
|
+
// ===========================================================================
|
|
324
|
+
// RESOURCE CLAIMS
|
|
325
|
+
// ===========================================================================
|
|
326
|
+
/**
|
|
327
|
+
* Claim a resource for exclusive or shared access.
|
|
328
|
+
*/
|
|
329
|
+
claim(resource, agentId, type, options = {}) {
|
|
330
|
+
const existing = this.claims.get(resource);
|
|
331
|
+
// Check for conflicts
|
|
332
|
+
if (existing) {
|
|
333
|
+
// Same agent can upgrade/extend claim
|
|
334
|
+
if (existing.agentId === agentId) {
|
|
335
|
+
const newClaim = {
|
|
336
|
+
resource,
|
|
337
|
+
agentId,
|
|
338
|
+
type,
|
|
339
|
+
claimedAt: existing.claimedAt,
|
|
340
|
+
expiresAt: new Date(Date.now() + (options.ttl ?? this.config.defaultClaimTTL)),
|
|
341
|
+
intent: options.intent,
|
|
342
|
+
};
|
|
343
|
+
this.claims.set(resource, newClaim);
|
|
344
|
+
return true;
|
|
345
|
+
}
|
|
346
|
+
// Check if claims are compatible
|
|
347
|
+
if (existing.type === 'exclusive' || type === 'exclusive' || type === 'write') {
|
|
348
|
+
this.emit({
|
|
349
|
+
type: 'claim.conflict',
|
|
350
|
+
resource,
|
|
351
|
+
existingAgent: existing.agentId,
|
|
352
|
+
requestingAgent: agentId,
|
|
353
|
+
});
|
|
354
|
+
return false;
|
|
355
|
+
}
|
|
356
|
+
// Read claims are compatible with other read claims
|
|
357
|
+
if (existing.type === 'read' && type === 'read') {
|
|
358
|
+
// Allow multiple read claims - but track the latest
|
|
359
|
+
// In a full implementation, we'd track multiple claims
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
const claim = {
|
|
363
|
+
resource,
|
|
364
|
+
agentId,
|
|
365
|
+
type,
|
|
366
|
+
claimedAt: new Date(),
|
|
367
|
+
expiresAt: new Date(Date.now() + (options.ttl ?? this.config.defaultClaimTTL)),
|
|
368
|
+
intent: options.intent,
|
|
369
|
+
};
|
|
370
|
+
this.claims.set(resource, claim);
|
|
371
|
+
this.emit({ type: 'claim.acquired', claim });
|
|
372
|
+
return true;
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* Release a resource claim.
|
|
376
|
+
*/
|
|
377
|
+
release(resource, agentId) {
|
|
378
|
+
const existing = this.claims.get(resource);
|
|
379
|
+
if (!existing || existing.agentId !== agentId) {
|
|
380
|
+
return false;
|
|
381
|
+
}
|
|
382
|
+
this.claims.delete(resource);
|
|
383
|
+
this.emit({ type: 'claim.released', resource, agentId });
|
|
384
|
+
return true;
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* Release all claims for an agent.
|
|
388
|
+
*/
|
|
389
|
+
releaseAll(agentId) {
|
|
390
|
+
let count = 0;
|
|
391
|
+
for (const [resource, claim] of this.claims) {
|
|
392
|
+
if (claim.agentId === agentId) {
|
|
393
|
+
this.claims.delete(resource);
|
|
394
|
+
this.emit({ type: 'claim.released', resource, agentId });
|
|
395
|
+
count++;
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
return count;
|
|
399
|
+
}
|
|
400
|
+
/**
|
|
401
|
+
* Check if a resource is claimed.
|
|
402
|
+
*/
|
|
403
|
+
isClaimed(resource) {
|
|
404
|
+
const claim = this.claims.get(resource);
|
|
405
|
+
if (!claim)
|
|
406
|
+
return false;
|
|
407
|
+
// Check expiry
|
|
408
|
+
if (claim.expiresAt < new Date()) {
|
|
409
|
+
this.claims.delete(resource);
|
|
410
|
+
this.emit({ type: 'claim.expired', claim });
|
|
411
|
+
return false;
|
|
412
|
+
}
|
|
413
|
+
return true;
|
|
414
|
+
}
|
|
415
|
+
/**
|
|
416
|
+
* Get the claim on a resource.
|
|
417
|
+
*/
|
|
418
|
+
getClaim(resource) {
|
|
419
|
+
const claim = this.claims.get(resource);
|
|
420
|
+
if (!claim)
|
|
421
|
+
return undefined;
|
|
422
|
+
// Check expiry
|
|
423
|
+
if (claim.expiresAt < new Date()) {
|
|
424
|
+
this.claims.delete(resource);
|
|
425
|
+
this.emit({ type: 'claim.expired', claim });
|
|
426
|
+
return undefined;
|
|
427
|
+
}
|
|
428
|
+
return claim;
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* Get all claims by an agent.
|
|
432
|
+
*/
|
|
433
|
+
getAgentClaims(agentId) {
|
|
434
|
+
const claims = [];
|
|
435
|
+
const now = new Date();
|
|
436
|
+
for (const claim of this.claims.values()) {
|
|
437
|
+
if (claim.agentId === agentId) {
|
|
438
|
+
if (claim.expiresAt < now) {
|
|
439
|
+
this.claims.delete(claim.resource);
|
|
440
|
+
this.emit({ type: 'claim.expired', claim });
|
|
441
|
+
}
|
|
442
|
+
else {
|
|
443
|
+
claims.push(claim);
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
return claims;
|
|
448
|
+
}
|
|
449
|
+
/**
|
|
450
|
+
* Start periodic claim expiry checking.
|
|
451
|
+
*/
|
|
452
|
+
startClaimExpiryChecker() {
|
|
453
|
+
setInterval(() => {
|
|
454
|
+
const now = new Date();
|
|
455
|
+
for (const [resource, claim] of this.claims) {
|
|
456
|
+
if (claim.expiresAt < now) {
|
|
457
|
+
this.claims.delete(resource);
|
|
458
|
+
this.emit({ type: 'claim.expired', claim });
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
}, 10000); // Check every 10 seconds
|
|
462
|
+
}
|
|
463
|
+
// ===========================================================================
|
|
464
|
+
// COORDINATION HELPERS
|
|
465
|
+
// ===========================================================================
|
|
466
|
+
/**
|
|
467
|
+
* Check if an agent has already researched a topic.
|
|
468
|
+
*/
|
|
469
|
+
hasResearched(topic, options = {}) {
|
|
470
|
+
const findings = this.query({
|
|
471
|
+
topic,
|
|
472
|
+
types: ['discovery', 'analysis'],
|
|
473
|
+
minConfidence: options.minConfidence ?? 0.7,
|
|
474
|
+
});
|
|
475
|
+
return findings.length > 0;
|
|
476
|
+
}
|
|
477
|
+
/**
|
|
478
|
+
* Get the best finding for a topic.
|
|
479
|
+
*/
|
|
480
|
+
getBestFinding(topic) {
|
|
481
|
+
const findings = this.query({ topic });
|
|
482
|
+
if (findings.length === 0)
|
|
483
|
+
return undefined;
|
|
484
|
+
// Return highest confidence
|
|
485
|
+
return findings.reduce((best, current) => current.confidence > best.confidence ? current : best);
|
|
486
|
+
}
|
|
487
|
+
/**
|
|
488
|
+
* Ask a question to other agents.
|
|
489
|
+
*/
|
|
490
|
+
askQuestion(agentId, topic, question, tags) {
|
|
491
|
+
return this.post(agentId, {
|
|
492
|
+
topic,
|
|
493
|
+
content: question,
|
|
494
|
+
type: 'question',
|
|
495
|
+
confidence: 1,
|
|
496
|
+
tags,
|
|
497
|
+
});
|
|
498
|
+
}
|
|
499
|
+
/**
|
|
500
|
+
* Answer a question.
|
|
501
|
+
*/
|
|
502
|
+
answerQuestion(agentId, questionId, answer, confidence) {
|
|
503
|
+
const question = this.getFinding(questionId);
|
|
504
|
+
if (!question) {
|
|
505
|
+
throw new Error(`Question ${questionId} not found`);
|
|
506
|
+
}
|
|
507
|
+
return this.post(agentId, {
|
|
508
|
+
topic: question.topic,
|
|
509
|
+
content: answer,
|
|
510
|
+
type: 'answer',
|
|
511
|
+
confidence,
|
|
512
|
+
tags: question.tags,
|
|
513
|
+
metadata: { answersQuestionId: questionId },
|
|
514
|
+
});
|
|
515
|
+
}
|
|
516
|
+
/**
|
|
517
|
+
* Report a blocker.
|
|
518
|
+
*/
|
|
519
|
+
reportBlocker(agentId, topic, description, relatedFiles) {
|
|
520
|
+
return this.post(agentId, {
|
|
521
|
+
topic,
|
|
522
|
+
content: description,
|
|
523
|
+
type: 'blocker',
|
|
524
|
+
confidence: 1,
|
|
525
|
+
relatedFiles,
|
|
526
|
+
});
|
|
527
|
+
}
|
|
528
|
+
/**
|
|
529
|
+
* Report progress.
|
|
530
|
+
*/
|
|
531
|
+
reportProgress(agentId, topic, description, metadata) {
|
|
532
|
+
return this.post(agentId, {
|
|
533
|
+
topic,
|
|
534
|
+
content: description,
|
|
535
|
+
type: 'progress',
|
|
536
|
+
confidence: 1,
|
|
537
|
+
metadata,
|
|
538
|
+
});
|
|
539
|
+
}
|
|
540
|
+
// ===========================================================================
|
|
541
|
+
// STATISTICS & UTILITIES
|
|
542
|
+
// ===========================================================================
|
|
543
|
+
/**
|
|
544
|
+
* Get blackboard statistics.
|
|
545
|
+
*/
|
|
546
|
+
getStats() {
|
|
547
|
+
const findingsByType = new Map();
|
|
548
|
+
const findingsByAgent = new Map();
|
|
549
|
+
for (const finding of this.findings.values()) {
|
|
550
|
+
findingsByType.set(finding.type, (findingsByType.get(finding.type) ?? 0) + 1);
|
|
551
|
+
findingsByAgent.set(finding.agentId, (findingsByAgent.get(finding.agentId) ?? 0) + 1);
|
|
552
|
+
}
|
|
553
|
+
return {
|
|
554
|
+
totalFindings: this.findings.size,
|
|
555
|
+
findingsByType,
|
|
556
|
+
findingsByAgent,
|
|
557
|
+
activeClaims: this.claims.size,
|
|
558
|
+
activeSubscriptions: this.subscriptions.size,
|
|
559
|
+
duplicatesAvoided: this.duplicatesAvoided,
|
|
560
|
+
};
|
|
561
|
+
}
|
|
562
|
+
/**
|
|
563
|
+
* Generate a summary of the blackboard state.
|
|
564
|
+
*/
|
|
565
|
+
summarize() {
|
|
566
|
+
const stats = this.getStats();
|
|
567
|
+
const lines = [
|
|
568
|
+
`Blackboard Summary`,
|
|
569
|
+
`==================`,
|
|
570
|
+
`Total findings: ${stats.totalFindings}`,
|
|
571
|
+
`Active claims: ${stats.activeClaims}`,
|
|
572
|
+
`Active subscriptions: ${stats.activeSubscriptions}`,
|
|
573
|
+
`Duplicates avoided: ${stats.duplicatesAvoided}`,
|
|
574
|
+
``,
|
|
575
|
+
`Findings by type:`,
|
|
576
|
+
];
|
|
577
|
+
for (const [type, count] of stats.findingsByType) {
|
|
578
|
+
lines.push(` - ${type}: ${count}`);
|
|
579
|
+
}
|
|
580
|
+
lines.push(``, `Findings by agent:`);
|
|
581
|
+
for (const [agent, count] of stats.findingsByAgent) {
|
|
582
|
+
lines.push(` - ${agent}: ${count}`);
|
|
583
|
+
}
|
|
584
|
+
// Recent findings
|
|
585
|
+
const recent = this.query({ limit: 5 });
|
|
586
|
+
if (recent.length > 0) {
|
|
587
|
+
lines.push(``, `Recent findings:`);
|
|
588
|
+
for (const f of recent) {
|
|
589
|
+
lines.push(` - [${f.type}] ${f.topic}: ${f.content.slice(0, 50)}...`);
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
return lines.join('\n');
|
|
593
|
+
}
|
|
594
|
+
/**
|
|
595
|
+
* Clear all data.
|
|
596
|
+
*/
|
|
597
|
+
clear() {
|
|
598
|
+
this.findings.clear();
|
|
599
|
+
this.claims.clear();
|
|
600
|
+
this.subscriptions.clear();
|
|
601
|
+
this.duplicatesAvoided = 0;
|
|
602
|
+
}
|
|
603
|
+
/**
|
|
604
|
+
* Clear findings only (keep claims and subscriptions).
|
|
605
|
+
*/
|
|
606
|
+
clearFindings() {
|
|
607
|
+
this.findings.clear();
|
|
608
|
+
this.duplicatesAvoided = 0;
|
|
609
|
+
}
|
|
610
|
+
/**
|
|
611
|
+
* Subscribe to blackboard events.
|
|
612
|
+
*/
|
|
613
|
+
on(listener) {
|
|
614
|
+
this.listeners.push(listener);
|
|
615
|
+
return () => {
|
|
616
|
+
const idx = this.listeners.indexOf(listener);
|
|
617
|
+
if (idx >= 0)
|
|
618
|
+
this.listeners.splice(idx, 1);
|
|
619
|
+
};
|
|
620
|
+
}
|
|
621
|
+
emit(event) {
|
|
622
|
+
for (const listener of this.listeners) {
|
|
623
|
+
try {
|
|
624
|
+
listener(event);
|
|
625
|
+
}
|
|
626
|
+
catch {
|
|
627
|
+
// Ignore listener errors
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
// =============================================================================
|
|
633
|
+
// FACTORY FUNCTIONS
|
|
634
|
+
// =============================================================================
|
|
635
|
+
/**
|
|
636
|
+
* Create a shared blackboard.
|
|
637
|
+
*
|
|
638
|
+
* @example
|
|
639
|
+
* ```typescript
|
|
640
|
+
* // Create blackboard for a multi-agent task
|
|
641
|
+
* const blackboard = createSharedBlackboard({
|
|
642
|
+
* maxFindings: 500,
|
|
643
|
+
* deduplicateFindings: true,
|
|
644
|
+
* });
|
|
645
|
+
*
|
|
646
|
+
* // Agent A posts discovery
|
|
647
|
+
* blackboard.post('agent-a', {
|
|
648
|
+
* topic: 'database.schema',
|
|
649
|
+
* content: 'Found User table with columns: id, email, password_hash',
|
|
650
|
+
* type: 'discovery',
|
|
651
|
+
* confidence: 0.95,
|
|
652
|
+
* relatedFiles: ['migrations/001_users.sql'],
|
|
653
|
+
* });
|
|
654
|
+
*
|
|
655
|
+
* // Agent B subscribes to database findings
|
|
656
|
+
* blackboard.subscribe({
|
|
657
|
+
* agentId: 'agent-b',
|
|
658
|
+
* topicPattern: 'database.*',
|
|
659
|
+
* callback: (finding) => {
|
|
660
|
+
* // Use the finding in context
|
|
661
|
+
* },
|
|
662
|
+
* });
|
|
663
|
+
*
|
|
664
|
+
* // Agent A claims a file for editing
|
|
665
|
+
* if (blackboard.claim('src/models/user.ts', 'agent-a', 'write')) {
|
|
666
|
+
* // Safe to edit
|
|
667
|
+
* // ... make changes ...
|
|
668
|
+
* blackboard.release('src/models/user.ts', 'agent-a');
|
|
669
|
+
* }
|
|
670
|
+
* ```
|
|
671
|
+
*/
|
|
672
|
+
export function createSharedBlackboard(config = {}) {
|
|
673
|
+
return new SharedBlackboard(config);
|
|
674
|
+
}
|
|
675
|
+
/**
|
|
676
|
+
* Create a context-aware finding from agent output.
|
|
677
|
+
*/
|
|
678
|
+
export function createFindingFromOutput(_agentId, output, options) {
|
|
679
|
+
return {
|
|
680
|
+
topic: options.topic,
|
|
681
|
+
content: output,
|
|
682
|
+
type: options.type ?? 'analysis',
|
|
683
|
+
confidence: options.confidence ?? 0.8,
|
|
684
|
+
relatedFiles: options.relatedFiles,
|
|
685
|
+
};
|
|
686
|
+
}
|
|
687
|
+
/**
|
|
688
|
+
* Extract key findings from a text summary.
|
|
689
|
+
*/
|
|
690
|
+
export function extractFindings(text, topic) {
|
|
691
|
+
const findings = [];
|
|
692
|
+
// Look for bullet points or numbered items
|
|
693
|
+
const lines = text.split('\n');
|
|
694
|
+
for (const line of lines) {
|
|
695
|
+
const trimmed = line.trim();
|
|
696
|
+
if (trimmed.match(/^[-*•]\s+/) || trimmed.match(/^\d+\.\s+/)) {
|
|
697
|
+
const content = trimmed.replace(/^[-*•\d.]+\s+/, '');
|
|
698
|
+
if (content.length > 10) {
|
|
699
|
+
findings.push({
|
|
700
|
+
topic,
|
|
701
|
+
content,
|
|
702
|
+
type: 'discovery',
|
|
703
|
+
confidence: 0.7,
|
|
704
|
+
});
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
return findings;
|
|
709
|
+
}
|
|
710
|
+
//# sourceMappingURL=shared-blackboard.js.map
|