@spinabot/brigade 0.1.2 → 1.0.1
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/LICENSE +1 -1
- package/README.md +748 -88
- package/brigade.mjs +150 -73
- package/dist/agents/a2a-policy-canonicalize.d.ts +60 -0
- package/dist/agents/a2a-policy-canonicalize.d.ts.map +1 -0
- package/dist/agents/a2a-policy-canonicalize.js +103 -0
- package/dist/agents/a2a-policy-canonicalize.js.map +1 -0
- package/dist/agents/agent-event-bus.d.ts +221 -0
- package/dist/agents/agent-event-bus.d.ts.map +1 -0
- package/dist/agents/agent-event-bus.js +88 -0
- package/dist/agents/agent-event-bus.js.map +1 -0
- package/dist/agents/agent-events.d.ts +84 -0
- package/dist/agents/agent-events.d.ts.map +1 -0
- package/dist/agents/agent-events.js +309 -0
- package/dist/agents/agent-events.js.map +1 -0
- package/dist/agents/agent-events.types.d.ts +139 -0
- package/dist/agents/agent-events.types.d.ts.map +1 -0
- package/dist/agents/agent-events.types.js +27 -0
- package/dist/agents/agent-events.types.js.map +1 -0
- package/dist/agents/agent-loop.d.ts +145 -0
- package/dist/agents/agent-loop.d.ts.map +1 -0
- package/dist/agents/agent-loop.js +1938 -0
- package/dist/agents/agent-loop.js.map +1 -0
- package/dist/agents/agent-scope.d.ts +28 -0
- package/dist/agents/agent-scope.d.ts.map +1 -0
- package/dist/agents/agent-scope.js +39 -0
- package/dist/agents/agent-scope.js.map +1 -0
- package/dist/agents/approval-bridge.d.ts +139 -0
- package/dist/agents/approval-bridge.d.ts.map +1 -0
- package/dist/agents/approval-bridge.js +178 -0
- package/dist/agents/approval-bridge.js.map +1 -0
- package/dist/agents/carrow.d.ts +49 -0
- package/dist/agents/carrow.d.ts.map +1 -0
- package/dist/agents/carrow.js +57 -0
- package/dist/agents/carrow.js.map +1 -0
- package/dist/agents/channels/abort-triggers.d.ts +17 -0
- package/dist/agents/channels/abort-triggers.d.ts.map +1 -0
- package/dist/agents/channels/abort-triggers.js +52 -0
- package/dist/agents/channels/abort-triggers.js.map +1 -0
- package/dist/agents/channels/access-control/index.d.ts +5 -0
- package/dist/agents/channels/access-control/index.d.ts.map +1 -0
- package/dist/agents/channels/access-control/index.js +4 -0
- package/dist/agents/channels/access-control/index.js.map +1 -0
- package/dist/agents/channels/access-control/policy.d.ts +69 -0
- package/dist/agents/channels/access-control/policy.d.ts.map +1 -0
- package/dist/agents/channels/access-control/policy.js +123 -0
- package/dist/agents/channels/access-control/policy.js.map +1 -0
- package/dist/agents/channels/access-control/store.d.ts +86 -0
- package/dist/agents/channels/access-control/store.d.ts.map +1 -0
- package/dist/agents/channels/access-control/store.js +482 -0
- package/dist/agents/channels/access-control/store.js.map +1 -0
- package/dist/agents/channels/access-control/types.d.ts +52 -0
- package/dist/agents/channels/access-control/types.d.ts.map +1 -0
- package/dist/agents/channels/access-control/types.js +20 -0
- package/dist/agents/channels/access-control/types.js.map +1 -0
- package/dist/agents/channels/active-manager.d.ts +31 -0
- package/dist/agents/channels/active-manager.d.ts.map +1 -0
- package/dist/agents/channels/active-manager.js +41 -0
- package/dist/agents/channels/active-manager.js.map +1 -0
- package/dist/agents/channels/agent-switch-command.d.ts +53 -0
- package/dist/agents/channels/agent-switch-command.d.ts.map +1 -0
- package/dist/agents/channels/agent-switch-command.js +349 -0
- package/dist/agents/channels/agent-switch-command.js.map +1 -0
- package/dist/agents/channels/approval-router.d.ts +158 -0
- package/dist/agents/channels/approval-router.d.ts.map +1 -0
- package/dist/agents/channels/approval-router.js +446 -0
- package/dist/agents/channels/approval-router.js.map +1 -0
- package/dist/agents/channels/channel-entry-contract.d.ts +70 -0
- package/dist/agents/channels/channel-entry-contract.d.ts.map +1 -0
- package/dist/agents/channels/channel-entry-contract.js +48 -0
- package/dist/agents/channels/channel-entry-contract.js.map +1 -0
- package/dist/agents/channels/channel-plugin-manager.d.ts +86 -0
- package/dist/agents/channels/channel-plugin-manager.d.ts.map +1 -0
- package/dist/agents/channels/channel-plugin-manager.js +345 -0
- package/dist/agents/channels/channel-plugin-manager.js.map +1 -0
- package/dist/agents/channels/chat-type.d.ts +27 -0
- package/dist/agents/channels/chat-type.d.ts.map +1 -0
- package/dist/agents/channels/chat-type.js +33 -0
- package/dist/agents/channels/chat-type.js.map +1 -0
- package/dist/agents/channels/dedupe.d.ts +44 -0
- package/dist/agents/channels/dedupe.d.ts.map +1 -0
- package/dist/agents/channels/dedupe.js +80 -0
- package/dist/agents/channels/dedupe.js.map +1 -0
- package/dist/agents/channels/inbound-pipeline.d.ts +90 -0
- package/dist/agents/channels/inbound-pipeline.d.ts.map +1 -0
- package/dist/agents/channels/inbound-pipeline.js +721 -0
- package/dist/agents/channels/inbound-pipeline.js.map +1 -0
- package/dist/agents/channels/last-channel.d.ts +56 -0
- package/dist/agents/channels/last-channel.d.ts.map +1 -0
- package/dist/agents/channels/last-channel.js +65 -0
- package/dist/agents/channels/last-channel.js.map +1 -0
- package/dist/agents/channels/manager.d.ts +76 -0
- package/dist/agents/channels/manager.d.ts.map +1 -0
- package/dist/agents/channels/manager.js +132 -0
- package/dist/agents/channels/manager.js.map +1 -0
- package/dist/agents/channels/media-capture.d.ts +23 -0
- package/dist/agents/channels/media-capture.d.ts.map +1 -0
- package/dist/agents/channels/media-capture.js +40 -0
- package/dist/agents/channels/media-capture.js.map +1 -0
- package/dist/agents/channels/plugin-channel-manager-facade.d.ts +18 -0
- package/dist/agents/channels/plugin-channel-manager-facade.d.ts.map +1 -0
- package/dist/agents/channels/plugin-channel-manager-facade.js +52 -0
- package/dist/agents/channels/plugin-channel-manager-facade.js.map +1 -0
- package/dist/agents/channels/reply-sanitizer.d.ts +38 -0
- package/dist/agents/channels/reply-sanitizer.d.ts.map +1 -0
- package/dist/agents/channels/reply-sanitizer.js +94 -0
- package/dist/agents/channels/reply-sanitizer.js.map +1 -0
- package/dist/agents/channels/retryable-inbound.d.ts +31 -0
- package/dist/agents/channels/retryable-inbound.d.ts.map +1 -0
- package/dist/agents/channels/retryable-inbound.js +37 -0
- package/dist/agents/channels/retryable-inbound.js.map +1 -0
- package/dist/agents/channels/types.adapters.d.ts +399 -0
- package/dist/agents/channels/types.adapters.d.ts.map +1 -0
- package/dist/agents/channels/types.adapters.js +33 -0
- package/dist/agents/channels/types.adapters.js.map +1 -0
- package/dist/agents/channels/types.core.d.ts +134 -0
- package/dist/agents/channels/types.core.d.ts.map +1 -0
- package/dist/agents/channels/types.core.js +32 -0
- package/dist/agents/channels/types.core.js.map +1 -0
- package/dist/agents/channels/types.plugin.d.ts +78 -0
- package/dist/agents/channels/types.plugin.d.ts.map +1 -0
- package/dist/agents/channels/types.plugin.js +30 -0
- package/dist/agents/channels/types.plugin.js.map +1 -0
- package/dist/agents/channels/whatsapp/account-config.d.ts +50 -0
- package/dist/agents/channels/whatsapp/account-config.d.ts.map +1 -0
- package/dist/agents/channels/whatsapp/account-config.js +105 -0
- package/dist/agents/channels/whatsapp/account-config.js.map +1 -0
- package/dist/agents/channels/whatsapp/adapter.d.ts +22 -0
- package/dist/agents/channels/whatsapp/adapter.d.ts.map +1 -0
- package/dist/agents/channels/whatsapp/adapter.js +270 -0
- package/dist/agents/channels/whatsapp/adapter.js.map +1 -0
- package/dist/agents/channels/whatsapp/chunk.d.ts +26 -0
- package/dist/agents/channels/whatsapp/chunk.d.ts.map +1 -0
- package/dist/agents/channels/whatsapp/chunk.js +123 -0
- package/dist/agents/channels/whatsapp/chunk.js.map +1 -0
- package/dist/agents/channels/whatsapp/connection.d.ts +249 -0
- package/dist/agents/channels/whatsapp/connection.d.ts.map +1 -0
- package/dist/agents/channels/whatsapp/connection.js +1628 -0
- package/dist/agents/channels/whatsapp/connection.js.map +1 -0
- package/dist/agents/channels/whatsapp/convex-auth-state.d.ts +34 -0
- package/dist/agents/channels/whatsapp/convex-auth-state.d.ts.map +1 -0
- package/dist/agents/channels/whatsapp/convex-auth-state.js +168 -0
- package/dist/agents/channels/whatsapp/convex-auth-state.js.map +1 -0
- package/dist/agents/channels/whatsapp/format.d.ts +15 -0
- package/dist/agents/channels/whatsapp/format.d.ts.map +1 -0
- package/dist/agents/channels/whatsapp/format.js +66 -0
- package/dist/agents/channels/whatsapp/format.js.map +1 -0
- package/dist/agents/channels/whatsapp/inbound-extras.d.ts +30 -0
- package/dist/agents/channels/whatsapp/inbound-extras.d.ts.map +1 -0
- package/dist/agents/channels/whatsapp/inbound-extras.js +146 -0
- package/dist/agents/channels/whatsapp/inbound-extras.js.map +1 -0
- package/dist/agents/channels/whatsapp/index.d.ts +7 -0
- package/dist/agents/channels/whatsapp/index.d.ts.map +1 -0
- package/dist/agents/channels/whatsapp/index.js +7 -0
- package/dist/agents/channels/whatsapp/index.js.map +1 -0
- package/dist/agents/channels/whatsapp/media.d.ts +47 -0
- package/dist/agents/channels/whatsapp/media.d.ts.map +1 -0
- package/dist/agents/channels/whatsapp/media.js +192 -0
- package/dist/agents/channels/whatsapp/media.js.map +1 -0
- package/dist/agents/channels/whatsapp/module.d.ts +10 -0
- package/dist/agents/channels/whatsapp/module.d.ts.map +1 -0
- package/dist/agents/channels/whatsapp/module.js +17 -0
- package/dist/agents/channels/whatsapp/module.js.map +1 -0
- package/dist/agents/channels/whatsapp/plugin.d.ts +60 -0
- package/dist/agents/channels/whatsapp/plugin.d.ts.map +1 -0
- package/dist/agents/channels/whatsapp/plugin.js +238 -0
- package/dist/agents/channels/whatsapp/plugin.js.map +1 -0
- package/dist/agents/cmd-ism-guard.d.ts +47 -0
- package/dist/agents/cmd-ism-guard.d.ts.map +1 -0
- package/dist/agents/cmd-ism-guard.js +100 -0
- package/dist/agents/cmd-ism-guard.js.map +1 -0
- package/dist/agents/config-write-guard.d.ts +25 -0
- package/dist/agents/config-write-guard.d.ts.map +1 -0
- package/dist/agents/config-write-guard.js +95 -0
- package/dist/agents/config-write-guard.js.map +1 -0
- package/dist/agents/content-quality-retry.d.ts +66 -0
- package/dist/agents/content-quality-retry.d.ts.map +1 -0
- package/dist/agents/content-quality-retry.js +140 -0
- package/dist/agents/content-quality-retry.js.map +1 -0
- package/dist/agents/error-classifier.d.ts +89 -0
- package/dist/agents/error-classifier.d.ts.map +1 -0
- package/dist/agents/error-classifier.js +630 -0
- package/dist/agents/error-classifier.js.map +1 -0
- package/dist/agents/exec-gate.d.ts +113 -0
- package/dist/agents/exec-gate.d.ts.map +1 -0
- package/dist/agents/exec-gate.js +335 -0
- package/dist/agents/exec-gate.js.map +1 -0
- package/dist/agents/exec-session-allow.d.ts +30 -0
- package/dist/agents/exec-session-allow.d.ts.map +1 -0
- package/dist/agents/exec-session-allow.js +50 -0
- package/dist/agents/exec-session-allow.js.map +1 -0
- package/dist/agents/extensions/active-registry.d.ts +4 -0
- package/dist/agents/extensions/active-registry.d.ts.map +1 -0
- package/dist/agents/extensions/active-registry.js +18 -0
- package/dist/agents/extensions/active-registry.js.map +1 -0
- package/dist/agents/extensions/discovery.d.ts +84 -0
- package/dist/agents/extensions/discovery.d.ts.map +1 -0
- package/dist/agents/extensions/discovery.js +249 -0
- package/dist/agents/extensions/discovery.js.map +1 -0
- package/dist/agents/extensions/hook-runner.d.ts +67 -0
- package/dist/agents/extensions/hook-runner.d.ts.map +1 -0
- package/dist/agents/extensions/hook-runner.js +155 -0
- package/dist/agents/extensions/hook-runner.js.map +1 -0
- package/dist/agents/extensions/index.d.ts +15 -0
- package/dist/agents/extensions/index.d.ts.map +1 -0
- package/dist/agents/extensions/index.js +14 -0
- package/dist/agents/extensions/index.js.map +1 -0
- package/dist/agents/extensions/loader.d.ts +38 -0
- package/dist/agents/extensions/loader.d.ts.map +1 -0
- package/dist/agents/extensions/loader.js +142 -0
- package/dist/agents/extensions/loader.js.map +1 -0
- package/dist/agents/extensions/modules/arxiv.d.ts +28 -0
- package/dist/agents/extensions/modules/arxiv.d.ts.map +1 -0
- package/dist/agents/extensions/modules/arxiv.js +145 -0
- package/dist/agents/extensions/modules/arxiv.js.map +1 -0
- package/dist/agents/extensions/modules/brave.d.ts +28 -0
- package/dist/agents/extensions/modules/brave.d.ts.map +1 -0
- package/dist/agents/extensions/modules/brave.js +489 -0
- package/dist/agents/extensions/modules/brave.js.map +1 -0
- package/dist/agents/extensions/modules/duckduckgo.d.ts +27 -0
- package/dist/agents/extensions/modules/duckduckgo.d.ts.map +1 -0
- package/dist/agents/extensions/modules/duckduckgo.js +263 -0
- package/dist/agents/extensions/modules/duckduckgo.js.map +1 -0
- package/dist/agents/extensions/modules/exa.d.ts +19 -0
- package/dist/agents/extensions/modules/exa.d.ts.map +1 -0
- package/dist/agents/extensions/modules/exa.js +208 -0
- package/dist/agents/extensions/modules/exa.js.map +1 -0
- package/dist/agents/extensions/modules/firecrawl.d.ts +51 -0
- package/dist/agents/extensions/modules/firecrawl.d.ts.map +1 -0
- package/dist/agents/extensions/modules/firecrawl.js +280 -0
- package/dist/agents/extensions/modules/firecrawl.js.map +1 -0
- package/dist/agents/extensions/modules/github-search.d.ts +29 -0
- package/dist/agents/extensions/modules/github-search.d.ts.map +1 -0
- package/dist/agents/extensions/modules/github-search.js +197 -0
- package/dist/agents/extensions/modules/github-search.js.map +1 -0
- package/dist/agents/extensions/modules/hackernews.d.ts +17 -0
- package/dist/agents/extensions/modules/hackernews.d.ts.map +1 -0
- package/dist/agents/extensions/modules/hackernews.js +144 -0
- package/dist/agents/extensions/modules/hackernews.js.map +1 -0
- package/dist/agents/extensions/modules/index.d.ts +11 -0
- package/dist/agents/extensions/modules/index.d.ts.map +1 -0
- package/dist/agents/extensions/modules/index.js +64 -0
- package/dist/agents/extensions/modules/index.js.map +1 -0
- package/dist/agents/extensions/modules/npm-search.d.ts +15 -0
- package/dist/agents/extensions/modules/npm-search.d.ts.map +1 -0
- package/dist/agents/extensions/modules/npm-search.js +126 -0
- package/dist/agents/extensions/modules/npm-search.js.map +1 -0
- package/dist/agents/extensions/modules/ollama-search.d.ts +30 -0
- package/dist/agents/extensions/modules/ollama-search.d.ts.map +1 -0
- package/dist/agents/extensions/modules/ollama-search.js +171 -0
- package/dist/agents/extensions/modules/ollama-search.js.map +1 -0
- package/dist/agents/extensions/modules/perplexity.d.ts +19 -0
- package/dist/agents/extensions/modules/perplexity.d.ts.map +1 -0
- package/dist/agents/extensions/modules/perplexity.js +358 -0
- package/dist/agents/extensions/modules/perplexity.js.map +1 -0
- package/dist/agents/extensions/modules/searxng.d.ts +43 -0
- package/dist/agents/extensions/modules/searxng.d.ts.map +1 -0
- package/dist/agents/extensions/modules/searxng.js +191 -0
- package/dist/agents/extensions/modules/searxng.js.map +1 -0
- package/dist/agents/extensions/modules/tavily.d.ts +71 -0
- package/dist/agents/extensions/modules/tavily.d.ts.map +1 -0
- package/dist/agents/extensions/modules/tavily.js +330 -0
- package/dist/agents/extensions/modules/tavily.js.map +1 -0
- package/dist/agents/extensions/modules/web-provider-helpers.d.ts +89 -0
- package/dist/agents/extensions/modules/web-provider-helpers.d.ts.map +1 -0
- package/dist/agents/extensions/modules/web-provider-helpers.js +146 -0
- package/dist/agents/extensions/modules/web-provider-helpers.js.map +1 -0
- package/dist/agents/extensions/modules/web-search-filters.d.ts +62 -0
- package/dist/agents/extensions/modules/web-search-filters.d.ts.map +1 -0
- package/dist/agents/extensions/modules/web-search-filters.js +179 -0
- package/dist/agents/extensions/modules/web-search-filters.js.map +1 -0
- package/dist/agents/extensions/modules/wikipedia.d.ts +16 -0
- package/dist/agents/extensions/modules/wikipedia.d.ts.map +1 -0
- package/dist/agents/extensions/modules/wikipedia.js +138 -0
- package/dist/agents/extensions/modules/wikipedia.js.map +1 -0
- package/dist/agents/extensions/registry-cache.d.ts +74 -0
- package/dist/agents/extensions/registry-cache.d.ts.map +1 -0
- package/dist/agents/extensions/registry-cache.js +117 -0
- package/dist/agents/extensions/registry-cache.js.map +1 -0
- package/dist/agents/extensions/registry.d.ts +184 -0
- package/dist/agents/extensions/registry.d.ts.map +1 -0
- package/dist/agents/extensions/registry.js +512 -0
- package/dist/agents/extensions/registry.js.map +1 -0
- package/dist/agents/extensions/types.d.ts +1195 -0
- package/dist/agents/extensions/types.d.ts.map +1 -0
- package/dist/agents/extensions/types.js +28 -0
- package/dist/agents/extensions/types.js.map +1 -0
- package/dist/agents/gateway-call.d.ts +171 -0
- package/dist/agents/gateway-call.d.ts.map +1 -0
- package/dist/agents/gateway-call.js +74 -0
- package/dist/agents/gateway-call.js.map +1 -0
- package/dist/agents/heartbeat-runner.d.ts +100 -0
- package/dist/agents/heartbeat-runner.d.ts.map +1 -0
- package/dist/agents/heartbeat-runner.js +268 -0
- package/dist/agents/heartbeat-runner.js.map +1 -0
- package/dist/agents/heartbeat-scheduler.d.ts +56 -0
- package/dist/agents/heartbeat-scheduler.d.ts.map +1 -0
- package/dist/agents/heartbeat-scheduler.js +366 -0
- package/dist/agents/heartbeat-scheduler.js.map +1 -0
- package/dist/agents/heartbeat-wake.d.ts +99 -0
- package/dist/agents/heartbeat-wake.d.ts.map +1 -0
- package/dist/agents/heartbeat-wake.js +304 -0
- package/dist/agents/heartbeat-wake.js.map +1 -0
- package/dist/agents/identity-file.d.ts +26 -0
- package/dist/agents/identity-file.d.ts.map +1 -0
- package/dist/agents/identity-file.js +86 -0
- package/dist/agents/identity-file.js.map +1 -0
- package/dist/agents/identity-links.d.ts +44 -0
- package/dist/agents/identity-links.d.ts.map +1 -0
- package/dist/agents/identity-links.js +51 -0
- package/dist/agents/identity-links.js.map +1 -0
- package/dist/agents/loop/autonomous-agent.d.ts +55 -0
- package/dist/agents/loop/autonomous-agent.d.ts.map +1 -0
- package/dist/agents/loop/autonomous-agent.js +91 -0
- package/dist/agents/loop/autonomous-agent.js.map +1 -0
- package/dist/agents/loop/loop-guards.d.ts +95 -0
- package/dist/agents/loop/loop-guards.d.ts.map +1 -0
- package/dist/agents/loop/loop-guards.js +169 -0
- package/dist/agents/loop/loop-guards.js.map +1 -0
- package/dist/agents/loop/loop-runner.d.ts +72 -0
- package/dist/agents/loop/loop-runner.d.ts.map +1 -0
- package/dist/agents/loop/loop-runner.js +114 -0
- package/dist/agents/loop/loop-runner.js.map +1 -0
- package/dist/agents/memory/auto-recall.d.ts +69 -0
- package/dist/agents/memory/auto-recall.d.ts.map +1 -0
- package/dist/agents/memory/auto-recall.js +147 -0
- package/dist/agents/memory/auto-recall.js.map +1 -0
- package/dist/agents/memory/behavior-review.d.ts +68 -0
- package/dist/agents/memory/behavior-review.d.ts.map +1 -0
- package/dist/agents/memory/behavior-review.js +131 -0
- package/dist/agents/memory/behavior-review.js.map +1 -0
- package/dist/agents/memory/consolidate.d.ts +62 -0
- package/dist/agents/memory/consolidate.d.ts.map +1 -0
- package/dist/agents/memory/consolidate.js +275 -0
- package/dist/agents/memory/consolidate.js.map +1 -0
- package/dist/agents/memory/contradiction.d.ts +44 -0
- package/dist/agents/memory/contradiction.d.ts.map +1 -0
- package/dist/agents/memory/contradiction.js +86 -0
- package/dist/agents/memory/contradiction.js.map +1 -0
- package/dist/agents/memory/curator.d.ts +22 -0
- package/dist/agents/memory/curator.d.ts.map +1 -0
- package/dist/agents/memory/curator.js +52 -0
- package/dist/agents/memory/curator.js.map +1 -0
- package/dist/agents/memory/decay.d.ts +32 -0
- package/dist/agents/memory/decay.d.ts.map +1 -0
- package/dist/agents/memory/decay.js +86 -0
- package/dist/agents/memory/decay.js.map +1 -0
- package/dist/agents/memory/dream.d.ts +52 -0
- package/dist/agents/memory/dream.d.ts.map +1 -0
- package/dist/agents/memory/dream.js +192 -0
- package/dist/agents/memory/dream.js.map +1 -0
- package/dist/agents/memory/embedder-providers.d.ts +114 -0
- package/dist/agents/memory/embedder-providers.d.ts.map +1 -0
- package/dist/agents/memory/embedder-providers.js +213 -0
- package/dist/agents/memory/embedder-providers.js.map +1 -0
- package/dist/agents/memory/embedder.d.ts +84 -0
- package/dist/agents/memory/embedder.d.ts.map +1 -0
- package/dist/agents/memory/embedder.js +218 -0
- package/dist/agents/memory/embedder.js.map +1 -0
- package/dist/agents/memory/eval/asr-bench.d.ts +33 -0
- package/dist/agents/memory/eval/asr-bench.d.ts.map +1 -0
- package/dist/agents/memory/eval/asr-bench.js +129 -0
- package/dist/agents/memory/eval/asr-bench.js.map +1 -0
- package/dist/agents/memory/eval/capabilities.d.ts +97 -0
- package/dist/agents/memory/eval/capabilities.d.ts.map +1 -0
- package/dist/agents/memory/eval/capabilities.js +210 -0
- package/dist/agents/memory/eval/capabilities.js.map +1 -0
- package/dist/agents/memory/eval/gold-export.d.ts +44 -0
- package/dist/agents/memory/eval/gold-export.d.ts.map +1 -0
- package/dist/agents/memory/eval/gold-export.js +85 -0
- package/dist/agents/memory/eval/gold-export.js.map +1 -0
- package/dist/agents/memory/eval/gold-hard.d.ts +35 -0
- package/dist/agents/memory/eval/gold-hard.d.ts.map +1 -0
- package/dist/agents/memory/eval/gold-hard.js +113 -0
- package/dist/agents/memory/eval/gold-hard.js.map +1 -0
- package/dist/agents/memory/eval/gold-rich.d.ts +33 -0
- package/dist/agents/memory/eval/gold-rich.d.ts.map +1 -0
- package/dist/agents/memory/eval/gold-rich.js +82 -0
- package/dist/agents/memory/eval/gold-rich.js.map +1 -0
- package/dist/agents/memory/eval/gold-synthetic.d.ts +19 -0
- package/dist/agents/memory/eval/gold-synthetic.d.ts.map +1 -0
- package/dist/agents/memory/eval/gold-synthetic.js +65 -0
- package/dist/agents/memory/eval/gold-synthetic.js.map +1 -0
- package/dist/agents/memory/eval/gold.d.ts +73 -0
- package/dist/agents/memory/eval/gold.d.ts.map +1 -0
- package/dist/agents/memory/eval/gold.js +174 -0
- package/dist/agents/memory/eval/gold.js.map +1 -0
- package/dist/agents/memory/eval/harness.d.ts +110 -0
- package/dist/agents/memory/eval/harness.d.ts.map +1 -0
- package/dist/agents/memory/eval/harness.js +123 -0
- package/dist/agents/memory/eval/harness.js.map +1 -0
- package/dist/agents/memory/eval/metrics.d.ts +71 -0
- package/dist/agents/memory/eval/metrics.d.ts.map +1 -0
- package/dist/agents/memory/eval/metrics.js +169 -0
- package/dist/agents/memory/eval/metrics.js.map +1 -0
- package/dist/agents/memory/event-log.d.ts +52 -0
- package/dist/agents/memory/event-log.d.ts.map +1 -0
- package/dist/agents/memory/event-log.js +65 -0
- package/dist/agents/memory/event-log.js.map +1 -0
- package/dist/agents/memory/extract.d.ts +155 -0
- package/dist/agents/memory/extract.d.ts.map +1 -0
- package/dist/agents/memory/extract.js +571 -0
- package/dist/agents/memory/extract.js.map +1 -0
- package/dist/agents/memory/governance.d.ts +45 -0
- package/dist/agents/memory/governance.d.ts.map +1 -0
- package/dist/agents/memory/governance.js +113 -0
- package/dist/agents/memory/governance.js.map +1 -0
- package/dist/agents/memory/graph-export.d.ts +59 -0
- package/dist/agents/memory/graph-export.d.ts.map +1 -0
- package/dist/agents/memory/graph-export.js +181 -0
- package/dist/agents/memory/graph-export.js.map +1 -0
- package/dist/agents/memory/graph-recall.d.ts +42 -0
- package/dist/agents/memory/graph-recall.d.ts.map +1 -0
- package/dist/agents/memory/graph-recall.js +165 -0
- package/dist/agents/memory/graph-recall.js.map +1 -0
- package/dist/agents/memory/graph.d.ts +92 -0
- package/dist/agents/memory/graph.d.ts.map +1 -0
- package/dist/agents/memory/graph.js +266 -0
- package/dist/agents/memory/graph.js.map +1 -0
- package/dist/agents/memory/host-ports.d.ts +27 -0
- package/dist/agents/memory/host-ports.d.ts.map +1 -0
- package/dist/agents/memory/host-ports.js +31 -0
- package/dist/agents/memory/host-ports.js.map +1 -0
- package/dist/agents/memory/hybrid.d.ts +46 -0
- package/dist/agents/memory/hybrid.d.ts.map +1 -0
- package/dist/agents/memory/hybrid.js +184 -0
- package/dist/agents/memory/hybrid.js.map +1 -0
- package/dist/agents/memory/index.d.ts +13 -0
- package/dist/agents/memory/index.d.ts.map +1 -0
- package/dist/agents/memory/index.js +13 -0
- package/dist/agents/memory/index.js.map +1 -0
- package/dist/agents/memory/json-scan.d.ts +14 -0
- package/dist/agents/memory/json-scan.d.ts.map +1 -0
- package/dist/agents/memory/json-scan.js +47 -0
- package/dist/agents/memory/json-scan.js.map +1 -0
- package/dist/agents/memory/links.d.ts +92 -0
- package/dist/agents/memory/links.d.ts.map +1 -0
- package/dist/agents/memory/links.js +140 -0
- package/dist/agents/memory/links.js.map +1 -0
- package/dist/agents/memory/maintenance.d.ts +18 -0
- package/dist/agents/memory/maintenance.d.ts.map +1 -0
- package/dist/agents/memory/maintenance.js +66 -0
- package/dist/agents/memory/maintenance.js.map +1 -0
- package/dist/agents/memory/memory-mcp-server.d.ts +39 -0
- package/dist/agents/memory/memory-mcp-server.d.ts.map +1 -0
- package/dist/agents/memory/memory-mcp-server.js +122 -0
- package/dist/agents/memory/memory-mcp-server.js.map +1 -0
- package/dist/agents/memory/memory-mcp.d.ts +34 -0
- package/dist/agents/memory/memory-mcp.d.ts.map +1 -0
- package/dist/agents/memory/memory-mcp.js +130 -0
- package/dist/agents/memory/memory-mcp.js.map +1 -0
- package/dist/agents/memory/plugin-runtime.d.ts +133 -0
- package/dist/agents/memory/plugin-runtime.d.ts.map +1 -0
- package/dist/agents/memory/plugin-runtime.js +149 -0
- package/dist/agents/memory/plugin-runtime.js.map +1 -0
- package/dist/agents/memory/query.d.ts +50 -0
- package/dist/agents/memory/query.d.ts.map +1 -0
- package/dist/agents/memory/query.js +94 -0
- package/dist/agents/memory/query.js.map +1 -0
- package/dist/agents/memory/records.d.ts +617 -0
- package/dist/agents/memory/records.d.ts.map +1 -0
- package/dist/agents/memory/records.js +1327 -0
- package/dist/agents/memory/records.js.map +1 -0
- package/dist/agents/memory/reembed.d.ts +42 -0
- package/dist/agents/memory/reembed.d.ts.map +1 -0
- package/dist/agents/memory/reembed.js +60 -0
- package/dist/agents/memory/reembed.js.map +1 -0
- package/dist/agents/memory/relationship-extract.d.ts +259 -0
- package/dist/agents/memory/relationship-extract.d.ts.map +1 -0
- package/dist/agents/memory/relationship-extract.js +454 -0
- package/dist/agents/memory/relationship-extract.js.map +1 -0
- package/dist/agents/memory/rerank.d.ts +37 -0
- package/dist/agents/memory/rerank.d.ts.map +1 -0
- package/dist/agents/memory/rerank.js +43 -0
- package/dist/agents/memory/rerank.js.map +1 -0
- package/dist/agents/memory/scoring.d.ts +85 -0
- package/dist/agents/memory/scoring.d.ts.map +1 -0
- package/dist/agents/memory/scoring.js +139 -0
- package/dist/agents/memory/scoring.js.map +1 -0
- package/dist/agents/memory/self-improve.d.ts +56 -0
- package/dist/agents/memory/self-improve.d.ts.map +1 -0
- package/dist/agents/memory/self-improve.js +98 -0
- package/dist/agents/memory/self-improve.js.map +1 -0
- package/dist/agents/memory/self-review.d.ts +68 -0
- package/dist/agents/memory/self-review.d.ts.map +1 -0
- package/dist/agents/memory/self-review.js +109 -0
- package/dist/agents/memory/self-review.js.map +1 -0
- package/dist/agents/memory/storage.d.ts +156 -0
- package/dist/agents/memory/storage.d.ts.map +1 -0
- package/dist/agents/memory/storage.js +359 -0
- package/dist/agents/memory/storage.js.map +1 -0
- package/dist/agents/memory/tideline.d.ts +203 -0
- package/dist/agents/memory/tideline.d.ts.map +1 -0
- package/dist/agents/memory/tideline.js +189 -0
- package/dist/agents/memory/tideline.js.map +1 -0
- package/dist/agents/memory/vault.d.ts +142 -0
- package/dist/agents/memory/vault.d.ts.map +1 -0
- package/dist/agents/memory/vault.js +787 -0
- package/dist/agents/memory/vault.js.map +1 -0
- package/dist/agents/memory/write-gate.d.ts +76 -0
- package/dist/agents/memory/write-gate.d.ts.map +1 -0
- package/dist/agents/memory/write-gate.js +140 -0
- package/dist/agents/memory/write-gate.js.map +1 -0
- package/dist/agents/mid-turn-switch.d.ts +25 -0
- package/dist/agents/mid-turn-switch.d.ts.map +1 -0
- package/dist/agents/mid-turn-switch.js +103 -0
- package/dist/agents/mid-turn-switch.js.map +1 -0
- package/dist/agents/model-fallback.d.ts +50 -0
- package/dist/agents/model-fallback.d.ts.map +1 -0
- package/dist/agents/model-fallback.js +226 -0
- package/dist/agents/model-fallback.js.map +1 -0
- package/dist/agents/model-resolution.d.ts +38 -0
- package/dist/agents/model-resolution.d.ts.map +1 -0
- package/dist/agents/model-resolution.js +155 -0
- package/dist/agents/model-resolution.js.map +1 -0
- package/dist/agents/org/a2a-adapter.d.ts +49 -0
- package/dist/agents/org/a2a-adapter.d.ts.map +1 -0
- package/dist/agents/org/a2a-adapter.js +92 -0
- package/dist/agents/org/a2a-adapter.js.map +1 -0
- package/dist/agents/org/assets/mascots/README.md +34 -0
- package/dist/agents/org/assets/mascots/Untitled-1.png +0 -0
- package/dist/agents/org/assets/mascots/brigade_biceps.png +0 -0
- package/dist/agents/org/audit-log.d.ts +22 -0
- package/dist/agents/org/audit-log.d.ts.map +1 -0
- package/dist/agents/org/audit-log.js +37 -0
- package/dist/agents/org/audit-log.js.map +1 -0
- package/dist/agents/org/auto-derive.d.ts +22 -0
- package/dist/agents/org/auto-derive.d.ts.map +1 -0
- package/dist/agents/org/auto-derive.js +66 -0
- package/dist/agents/org/auto-derive.js.map +1 -0
- package/dist/agents/org/delivery-kind.d.ts +89 -0
- package/dist/agents/org/delivery-kind.d.ts.map +1 -0
- package/dist/agents/org/delivery-kind.js +149 -0
- package/dist/agents/org/delivery-kind.js.map +1 -0
- package/dist/agents/org/derive-graph.d.ts +34 -0
- package/dist/agents/org/derive-graph.d.ts.map +1 -0
- package/dist/agents/org/derive-graph.js +266 -0
- package/dist/agents/org/derive-graph.js.map +1 -0
- package/dist/agents/org/lints.d.ts +21 -0
- package/dist/agents/org/lints.d.ts.map +1 -0
- package/dist/agents/org/lints.js +133 -0
- package/dist/agents/org/lints.js.map +1 -0
- package/dist/agents/org/pride-html.d.ts +61 -0
- package/dist/agents/org/pride-html.d.ts.map +1 -0
- package/dist/agents/org/pride-html.js +565 -0
- package/dist/agents/org/pride-html.js.map +1 -0
- package/dist/agents/org/pride-image.d.ts +101 -0
- package/dist/agents/org/pride-image.d.ts.map +1 -0
- package/dist/agents/org/pride-image.js +210 -0
- package/dist/agents/org/pride-image.js.map +1 -0
- package/dist/agents/org/pride-taunts.d.ts +47 -0
- package/dist/agents/org/pride-taunts.d.ts.map +1 -0
- package/dist/agents/org/pride-taunts.js +411 -0
- package/dist/agents/org/pride-taunts.js.map +1 -0
- package/dist/agents/org/pride-template.d.ts +272 -0
- package/dist/agents/org/pride-template.d.ts.map +1 -0
- package/dist/agents/org/pride-template.js +892 -0
- package/dist/agents/org/pride-template.js.map +1 -0
- package/dist/agents/org/pride-themes.d.ts +80 -0
- package/dist/agents/org/pride-themes.d.ts.map +1 -0
- package/dist/agents/org/pride-themes.js +7596 -0
- package/dist/agents/org/pride-themes.js.map +1 -0
- package/dist/agents/org/structured-errors.d.ts +47 -0
- package/dist/agents/org/structured-errors.d.ts.map +1 -0
- package/dist/agents/org/structured-errors.js +97 -0
- package/dist/agents/org/structured-errors.js.map +1 -0
- package/dist/agents/org/types.d.ts +139 -0
- package/dist/agents/org/types.d.ts.map +1 -0
- package/dist/agents/org/types.js +43 -0
- package/dist/agents/org/types.js.map +1 -0
- package/dist/agents/org/validate.d.ts +36 -0
- package/dist/agents/org/validate.d.ts.map +1 -0
- package/dist/agents/org/validate.js +135 -0
- package/dist/agents/org/validate.js.map +1 -0
- package/dist/agents/path-write-guard.d.ts +82 -0
- package/dist/agents/path-write-guard.d.ts.map +1 -0
- package/dist/agents/path-write-guard.js +722 -0
- package/dist/agents/path-write-guard.js.map +1 -0
- package/dist/agents/payload-mutators.d.ts +175 -0
- package/dist/agents/payload-mutators.d.ts.map +1 -0
- package/dist/agents/payload-mutators.js +994 -0
- package/dist/agents/payload-mutators.js.map +1 -0
- package/dist/agents/pending-system-events.d.ts +76 -0
- package/dist/agents/pending-system-events.d.ts.map +1 -0
- package/dist/agents/pending-system-events.js +115 -0
- package/dist/agents/pending-system-events.js.map +1 -0
- package/dist/agents/provider-attribution.d.ts +19 -0
- package/dist/agents/provider-attribution.d.ts.map +1 -0
- package/dist/agents/provider-attribution.js +62 -0
- package/dist/agents/provider-attribution.js.map +1 -0
- package/dist/agents/quality/slop-detector.d.ts +40 -0
- package/dist/agents/quality/slop-detector.d.ts.map +1 -0
- package/dist/agents/quality/slop-detector.js +108 -0
- package/dist/agents/quality/slop-detector.js.map +1 -0
- package/dist/agents/quality/slop-index.d.ts +27 -0
- package/dist/agents/quality/slop-index.d.ts.map +1 -0
- package/dist/agents/quality/slop-index.js +124 -0
- package/dist/agents/quality/slop-index.js.map +1 -0
- package/dist/agents/retry-policy.d.ts +38 -0
- package/dist/agents/retry-policy.d.ts.map +1 -0
- package/dist/agents/retry-policy.js +276 -0
- package/dist/agents/retry-policy.js.map +1 -0
- package/dist/agents/routing/account-id.d.ts +43 -0
- package/dist/agents/routing/account-id.d.ts.map +1 -0
- package/dist/agents/routing/account-id.js +103 -0
- package/dist/agents/routing/account-id.js.map +1 -0
- package/dist/agents/routing/bindings.d.ts +20 -0
- package/dist/agents/routing/bindings.d.ts.map +1 -0
- package/dist/agents/routing/bindings.js +22 -0
- package/dist/agents/routing/bindings.js.map +1 -0
- package/dist/agents/routing/dm-scope-warning.d.ts +37 -0
- package/dist/agents/routing/dm-scope-warning.d.ts.map +1 -0
- package/dist/agents/routing/dm-scope-warning.js +110 -0
- package/dist/agents/routing/dm-scope-warning.js.map +1 -0
- package/dist/agents/routing/identity-links.d.ts +45 -0
- package/dist/agents/routing/identity-links.d.ts.map +1 -0
- package/dist/agents/routing/identity-links.js +85 -0
- package/dist/agents/routing/identity-links.js.map +1 -0
- package/dist/agents/routing/resolve-route.d.ts +91 -0
- package/dist/agents/routing/resolve-route.d.ts.map +1 -0
- package/dist/agents/routing/resolve-route.js +653 -0
- package/dist/agents/routing/resolve-route.js.map +1 -0
- package/dist/agents/routing/session-key.d.ts +168 -0
- package/dist/agents/routing/session-key.d.ts.map +1 -0
- package/dist/agents/routing/session-key.js +268 -0
- package/dist/agents/routing/session-key.js.map +1 -0
- package/dist/agents/sanitize-surrogates.d.ts +30 -0
- package/dist/agents/sanitize-surrogates.d.ts.map +1 -0
- package/dist/agents/sanitize-surrogates.js +56 -0
- package/dist/agents/sanitize-surrogates.js.map +1 -0
- package/dist/agents/session-context.d.ts +80 -0
- package/dist/agents/session-context.d.ts.map +1 -0
- package/dist/agents/session-context.js +76 -0
- package/dist/agents/session-context.js.map +1 -0
- package/dist/agents/session-event-prompt.d.ts +124 -0
- package/dist/agents/session-event-prompt.d.ts.map +1 -0
- package/dist/agents/session-event-prompt.js +179 -0
- package/dist/agents/session-event-prompt.js.map +1 -0
- package/dist/agents/session-inbox.d.ts +129 -0
- package/dist/agents/session-inbox.d.ts.map +1 -0
- package/dist/agents/session-inbox.js +492 -0
- package/dist/agents/session-inbox.js.map +1 -0
- package/dist/agents/session-registry.d.ts +148 -0
- package/dist/agents/session-registry.d.ts.map +1 -0
- package/dist/agents/session-registry.js +405 -0
- package/dist/agents/session-registry.js.map +1 -0
- package/dist/agents/session-wiring.d.ts +214 -0
- package/dist/agents/session-wiring.d.ts.map +1 -0
- package/dist/agents/session-wiring.js +278 -0
- package/dist/agents/session-wiring.js.map +1 -0
- package/dist/agents/session-write-lock.d.ts +15 -0
- package/dist/agents/session-write-lock.d.ts.map +1 -0
- package/dist/agents/session-write-lock.js +15 -0
- package/dist/agents/session-write-lock.js.map +1 -0
- package/dist/agents/skills/agent-filter.d.ts +43 -0
- package/dist/agents/skills/agent-filter.d.ts.map +1 -0
- package/dist/agents/skills/agent-filter.js +89 -0
- package/dist/agents/skills/agent-filter.js.map +1 -0
- package/dist/agents/skills/discovery.d.ts +97 -0
- package/dist/agents/skills/discovery.d.ts.map +1 -0
- package/dist/agents/skills/discovery.js +136 -0
- package/dist/agents/skills/discovery.js.map +1 -0
- package/dist/agents/skills/eligibility.d.ts +118 -0
- package/dist/agents/skills/eligibility.d.ts.map +1 -0
- package/dist/agents/skills/eligibility.js +280 -0
- package/dist/agents/skills/eligibility.js.map +1 -0
- package/dist/agents/skills/grant.d.ts +70 -0
- package/dist/agents/skills/grant.d.ts.map +1 -0
- package/dist/agents/skills/grant.js +106 -0
- package/dist/agents/skills/grant.js.map +1 -0
- package/dist/agents/skills/index.d.ts +35 -0
- package/dist/agents/skills/index.d.ts.map +1 -0
- package/dist/agents/skills/index.js +88 -0
- package/dist/agents/skills/index.js.map +1 -0
- package/dist/agents/skills/install-spec.d.ts +51 -0
- package/dist/agents/skills/install-spec.d.ts.map +1 -0
- package/dist/agents/skills/install-spec.js +21 -0
- package/dist/agents/skills/install-spec.js.map +1 -0
- package/dist/agents/skills/install.d.ts +68 -0
- package/dist/agents/skills/install.d.ts.map +1 -0
- package/dist/agents/skills/install.js +206 -0
- package/dist/agents/skills/install.js.map +1 -0
- package/dist/agents/skills/org-access.d.ts +27 -0
- package/dist/agents/skills/org-access.d.ts.map +1 -0
- package/dist/agents/skills/org-access.js +87 -0
- package/dist/agents/skills/org-access.js.map +1 -0
- package/dist/agents/skills/skill-consolidate.d.ts +76 -0
- package/dist/agents/skills/skill-consolidate.d.ts.map +1 -0
- package/dist/agents/skills/skill-consolidate.js +264 -0
- package/dist/agents/skills/skill-consolidate.js.map +1 -0
- package/dist/agents/skills/skill-curator.d.ts +91 -0
- package/dist/agents/skills/skill-curator.d.ts.map +1 -0
- package/dist/agents/skills/skill-curator.js +239 -0
- package/dist/agents/skills/skill-curator.js.map +1 -0
- package/dist/agents/skills/skill-manifest.d.ts +35 -0
- package/dist/agents/skills/skill-manifest.d.ts.map +1 -0
- package/dist/agents/skills/skill-manifest.js +82 -0
- package/dist/agents/skills/skill-manifest.js.map +1 -0
- package/dist/agents/skills/skill-review.d.ts +91 -0
- package/dist/agents/skills/skill-review.d.ts.map +1 -0
- package/dist/agents/skills/skill-review.js +271 -0
- package/dist/agents/skills/skill-review.js.map +1 -0
- package/dist/agents/skills/skill-usage.d.ts +81 -0
- package/dist/agents/skills/skill-usage.d.ts.map +1 -0
- package/dist/agents/skills/skill-usage.js +208 -0
- package/dist/agents/skills/skill-usage.js.map +1 -0
- package/dist/agents/skills/status.d.ts +68 -0
- package/dist/agents/skills/status.d.ts.map +1 -0
- package/dist/agents/skills/status.js +147 -0
- package/dist/agents/skills/status.js.map +1 -0
- package/dist/agents/skills/update-config.d.ts +32 -0
- package/dist/agents/skills/update-config.d.ts.map +1 -0
- package/dist/agents/skills/update-config.js +53 -0
- package/dist/agents/skills/update-config.js.map +1 -0
- package/dist/agents/slash-commands.d.ts +25 -0
- package/dist/agents/slash-commands.d.ts.map +1 -0
- package/dist/agents/slash-commands.js +151 -0
- package/dist/agents/slash-commands.js.map +1 -0
- package/dist/agents/smart-compaction.d.ts +105 -0
- package/dist/agents/smart-compaction.d.ts.map +1 -0
- package/dist/agents/smart-compaction.js +355 -0
- package/dist/agents/smart-compaction.js.map +1 -0
- package/dist/agents/stream-wrappers.d.ts +20 -0
- package/dist/agents/stream-wrappers.d.ts.map +1 -0
- package/dist/agents/stream-wrappers.js +307 -0
- package/dist/agents/stream-wrappers.js.map +1 -0
- package/dist/agents/subagent-abort-cascade.d.ts +31 -0
- package/dist/agents/subagent-abort-cascade.d.ts.map +1 -0
- package/dist/agents/subagent-abort-cascade.js +124 -0
- package/dist/agents/subagent-abort-cascade.js.map +1 -0
- package/dist/agents/subagent-announce-delivery.d.ts +83 -0
- package/dist/agents/subagent-announce-delivery.d.ts.map +1 -0
- package/dist/agents/subagent-announce-delivery.js +159 -0
- package/dist/agents/subagent-announce-delivery.js.map +1 -0
- package/dist/agents/subagent-budget.d.ts +36 -0
- package/dist/agents/subagent-budget.d.ts.map +1 -0
- package/dist/agents/subagent-budget.js +93 -0
- package/dist/agents/subagent-budget.js.map +1 -0
- package/dist/agents/subagent-completion-bridge.d.ts +42 -0
- package/dist/agents/subagent-completion-bridge.d.ts.map +1 -0
- package/dist/agents/subagent-completion-bridge.js +338 -0
- package/dist/agents/subagent-completion-bridge.js.map +1 -0
- package/dist/agents/subagent-lifecycle-events.d.ts +31 -0
- package/dist/agents/subagent-lifecycle-events.d.ts.map +1 -0
- package/dist/agents/subagent-lifecycle-events.js +21 -0
- package/dist/agents/subagent-lifecycle-events.js.map +1 -0
- package/dist/agents/subagent-policy.d.ts +206 -0
- package/dist/agents/subagent-policy.d.ts.map +1 -0
- package/dist/agents/subagent-policy.js +295 -0
- package/dist/agents/subagent-policy.js.map +1 -0
- package/dist/agents/subagent-registry-completion.d.ts +69 -0
- package/dist/agents/subagent-registry-completion.d.ts.map +1 -0
- package/dist/agents/subagent-registry-completion.js +128 -0
- package/dist/agents/subagent-registry-completion.js.map +1 -0
- package/dist/agents/subagent-registry.d.ts +85 -0
- package/dist/agents/subagent-registry.d.ts.map +1 -0
- package/dist/agents/subagent-registry.js +215 -0
- package/dist/agents/subagent-registry.js.map +1 -0
- package/dist/agents/subagent-registry.types.d.ts +94 -0
- package/dist/agents/subagent-registry.types.d.ts.map +1 -0
- package/dist/agents/subagent-registry.types.js +19 -0
- package/dist/agents/subagent-registry.types.js.map +1 -0
- package/dist/agents/subagent-runner.d.ts +75 -0
- package/dist/agents/subagent-runner.d.ts.map +1 -0
- package/dist/agents/subagent-runner.js +358 -0
- package/dist/agents/subagent-runner.js.map +1 -0
- package/dist/agents/subagent-spawn-abort-marker.d.ts +46 -0
- package/dist/agents/subagent-spawn-abort-marker.d.ts.map +1 -0
- package/dist/agents/subagent-spawn-abort-marker.js +81 -0
- package/dist/agents/subagent-spawn-abort-marker.js.map +1 -0
- package/dist/agents/subagent-spawn.d.ts +104 -0
- package/dist/agents/subagent-spawn.d.ts.map +1 -0
- package/dist/agents/subagent-spawn.js +358 -0
- package/dist/agents/subagent-spawn.js.map +1 -0
- package/dist/agents/thinking-fallback.d.ts +49 -0
- package/dist/agents/thinking-fallback.d.ts.map +1 -0
- package/dist/agents/thinking-fallback.js +97 -0
- package/dist/agents/thinking-fallback.js.map +1 -0
- package/dist/agents/tool-guard.d.ts +71 -0
- package/dist/agents/tool-guard.d.ts.map +1 -0
- package/dist/agents/tool-guard.js +154 -0
- package/dist/agents/tool-guard.js.map +1 -0
- package/dist/agents/tool-loop-detector.d.ts +115 -0
- package/dist/agents/tool-loop-detector.d.ts.map +1 -0
- package/dist/agents/tool-loop-detector.js +0 -0
- package/dist/agents/tool-loop-detector.js.map +1 -0
- package/dist/agents/tool-summaries.d.ts +3 -0
- package/dist/agents/tool-summaries.d.ts.map +1 -0
- package/dist/agents/tool-summaries.js +78 -0
- package/dist/agents/tool-summaries.js.map +1 -0
- package/dist/agents/tools/agents-list-tool.d.ts +51 -0
- package/dist/agents/tools/agents-list-tool.d.ts.map +1 -0
- package/dist/agents/tools/agents-list-tool.js +167 -0
- package/dist/agents/tools/agents-list-tool.js.map +1 -0
- package/dist/agents/tools/browser.d.ts +144 -0
- package/dist/agents/tools/browser.d.ts.map +1 -0
- package/dist/agents/tools/browser.js +1538 -0
- package/dist/agents/tools/browser.js.map +1 -0
- package/dist/agents/tools/common.d.ts +208 -0
- package/dist/agents/tools/common.d.ts.map +1 -0
- package/dist/agents/tools/common.js +405 -0
- package/dist/agents/tools/common.js.map +1 -0
- package/dist/agents/tools/composio-tool.d.ts +179 -0
- package/dist/agents/tools/composio-tool.d.ts.map +1 -0
- package/dist/agents/tools/composio-tool.js +474 -0
- package/dist/agents/tools/composio-tool.js.map +1 -0
- package/dist/agents/tools/cron-tool.d.ts +187 -0
- package/dist/agents/tools/cron-tool.d.ts.map +1 -0
- package/dist/agents/tools/cron-tool.js +985 -0
- package/dist/agents/tools/cron-tool.js.map +1 -0
- package/dist/agents/tools/find-tool.d.ts +55 -0
- package/dist/agents/tools/find-tool.d.ts.map +1 -0
- package/dist/agents/tools/find-tool.js +163 -0
- package/dist/agents/tools/find-tool.js.map +1 -0
- package/dist/agents/tools/generate-image-tool.d.ts +77 -0
- package/dist/agents/tools/generate-image-tool.d.ts.map +1 -0
- package/dist/agents/tools/generate-image-tool.js +421 -0
- package/dist/agents/tools/generate-image-tool.js.map +1 -0
- package/dist/agents/tools/index.d.ts +14 -0
- package/dist/agents/tools/index.d.ts.map +1 -0
- package/dist/agents/tools/index.js +12 -0
- package/dist/agents/tools/index.js.map +1 -0
- package/dist/agents/tools/manage-access-tool.d.ts +64 -0
- package/dist/agents/tools/manage-access-tool.d.ts.map +1 -0
- package/dist/agents/tools/manage-access-tool.js +188 -0
- package/dist/agents/tools/manage-access-tool.js.map +1 -0
- package/dist/agents/tools/manage-agent-tool.d.ts +50 -0
- package/dist/agents/tools/manage-agent-tool.d.ts.map +1 -0
- package/dist/agents/tools/manage-agent-tool.js +232 -0
- package/dist/agents/tools/manage-agent-tool.js.map +1 -0
- package/dist/agents/tools/manage-channel-access-tool.d.ts +44 -0
- package/dist/agents/tools/manage-channel-access-tool.d.ts.map +1 -0
- package/dist/agents/tools/manage-channel-access-tool.js +144 -0
- package/dist/agents/tools/manage-channel-access-tool.js.map +1 -0
- package/dist/agents/tools/manage-memory-tool.d.ts +30 -0
- package/dist/agents/tools/manage-memory-tool.d.ts.map +1 -0
- package/dist/agents/tools/manage-memory-tool.js +309 -0
- package/dist/agents/tools/manage-memory-tool.js.map +1 -0
- package/dist/agents/tools/manage-provider-tool.d.ts +65 -0
- package/dist/agents/tools/manage-provider-tool.d.ts.map +1 -0
- package/dist/agents/tools/manage-provider-tool.js +249 -0
- package/dist/agents/tools/manage-provider-tool.js.map +1 -0
- package/dist/agents/tools/manage-skill-tool.d.ts +121 -0
- package/dist/agents/tools/manage-skill-tool.d.ts.map +1 -0
- package/dist/agents/tools/manage-skill-tool.js +722 -0
- package/dist/agents/tools/manage-skill-tool.js.map +1 -0
- package/dist/agents/tools/memory-tools.d.ts +172 -0
- package/dist/agents/tools/memory-tools.d.ts.map +1 -0
- package/dist/agents/tools/memory-tools.js +561 -0
- package/dist/agents/tools/memory-tools.js.map +1 -0
- package/dist/agents/tools/oauth-authorize-tool.d.ts +94 -0
- package/dist/agents/tools/oauth-authorize-tool.d.ts.map +1 -0
- package/dist/agents/tools/oauth-authorize-tool.js +670 -0
- package/dist/agents/tools/oauth-authorize-tool.js.map +1 -0
- package/dist/agents/tools/org-tool.d.ts +208 -0
- package/dist/agents/tools/org-tool.d.ts.map +1 -0
- package/dist/agents/tools/org-tool.js +790 -0
- package/dist/agents/tools/org-tool.js.map +1 -0
- package/dist/agents/tools/registry.d.ts +146 -0
- package/dist/agents/tools/registry.d.ts.map +1 -0
- package/dist/agents/tools/registry.js +396 -0
- package/dist/agents/tools/registry.js.map +1 -0
- package/dist/agents/tools/send-media-tool.d.ts +92 -0
- package/dist/agents/tools/send-media-tool.d.ts.map +1 -0
- package/dist/agents/tools/send-media-tool.js +512 -0
- package/dist/agents/tools/send-media-tool.js.map +1 -0
- package/dist/agents/tools/send-message-tool.d.ts +84 -0
- package/dist/agents/tools/send-message-tool.d.ts.map +1 -0
- package/dist/agents/tools/send-message-tool.js +226 -0
- package/dist/agents/tools/send-message-tool.js.map +1 -0
- package/dist/agents/tools/sessions/history.d.ts +53 -0
- package/dist/agents/tools/sessions/history.d.ts.map +1 -0
- package/dist/agents/tools/sessions/history.js +138 -0
- package/dist/agents/tools/sessions/history.js.map +1 -0
- package/dist/agents/tools/sessions/index.d.ts +92 -0
- package/dist/agents/tools/sessions/index.d.ts.map +1 -0
- package/dist/agents/tools/sessions/index.js +125 -0
- package/dist/agents/tools/sessions/index.js.map +1 -0
- package/dist/agents/tools/sessions/list.d.ts +53 -0
- package/dist/agents/tools/sessions/list.d.ts.map +1 -0
- package/dist/agents/tools/sessions/list.js +134 -0
- package/dist/agents/tools/sessions/list.js.map +1 -0
- package/dist/agents/tools/sessions/resolve-access.d.ts +34 -0
- package/dist/agents/tools/sessions/resolve-access.d.ts.map +1 -0
- package/dist/agents/tools/sessions/resolve-access.js +67 -0
- package/dist/agents/tools/sessions/resolve-access.js.map +1 -0
- package/dist/agents/tools/sessions/send.d.ts +68 -0
- package/dist/agents/tools/sessions/send.d.ts.map +1 -0
- package/dist/agents/tools/sessions/send.js +556 -0
- package/dist/agents/tools/sessions/send.js.map +1 -0
- package/dist/agents/tools/sessions/shared.d.ts +145 -0
- package/dist/agents/tools/sessions/shared.d.ts.map +1 -0
- package/dist/agents/tools/sessions/shared.js +352 -0
- package/dist/agents/tools/sessions/shared.js.map +1 -0
- package/dist/agents/tools/sessions/spawn.d.ts +71 -0
- package/dist/agents/tools/sessions/spawn.d.ts.map +1 -0
- package/dist/agents/tools/sessions/spawn.js +132 -0
- package/dist/agents/tools/sessions/spawn.js.map +1 -0
- package/dist/agents/tools/spawn-agent-tool.d.ts +87 -0
- package/dist/agents/tools/spawn-agent-tool.d.ts.map +1 -0
- package/dist/agents/tools/spawn-agent-tool.js +189 -0
- package/dist/agents/tools/spawn-agent-tool.js.map +1 -0
- package/dist/agents/tools/spawn-agents-tool.d.ts +75 -0
- package/dist/agents/tools/spawn-agents-tool.d.ts.map +1 -0
- package/dist/agents/tools/spawn-agents-tool.js +267 -0
- package/dist/agents/tools/spawn-agents-tool.js.map +1 -0
- package/dist/agents/tools/types.d.ts +55 -0
- package/dist/agents/tools/types.d.ts.map +1 -0
- package/dist/agents/tools/types.js +28 -0
- package/dist/agents/tools/types.js.map +1 -0
- package/dist/agents/tools/web-fetch-utils.d.ts +114 -0
- package/dist/agents/tools/web-fetch-utils.d.ts.map +1 -0
- package/dist/agents/tools/web-fetch-utils.js +560 -0
- package/dist/agents/tools/web-fetch-utils.js.map +1 -0
- package/dist/agents/tools/web-fetch.d.ts +97 -0
- package/dist/agents/tools/web-fetch.d.ts.map +1 -0
- package/dist/agents/tools/web-fetch.js +369 -0
- package/dist/agents/tools/web-fetch.js.map +1 -0
- package/dist/agents/tools/web-retry.d.ts +55 -0
- package/dist/agents/tools/web-retry.d.ts.map +1 -0
- package/dist/agents/tools/web-retry.js +172 -0
- package/dist/agents/tools/web-retry.js.map +1 -0
- package/dist/agents/tools/web-search.d.ts +96 -0
- package/dist/agents/tools/web-search.d.ts.map +1 -0
- package/dist/agents/tools/web-search.js +459 -0
- package/dist/agents/tools/web-search.js.map +1 -0
- package/dist/agents/tools/web-shared.d.ts +123 -0
- package/dist/agents/tools/web-shared.d.ts.map +1 -0
- package/dist/agents/tools/web-shared.js +207 -0
- package/dist/agents/tools/web-shared.js.map +1 -0
- package/dist/assets/brigade-favicon.png +0 -0
- package/dist/auth/profile-cooldown.d.ts +105 -0
- package/dist/auth/profile-cooldown.d.ts.map +1 -0
- package/dist/auth/profile-cooldown.js +466 -0
- package/dist/auth/profile-cooldown.js.map +1 -0
- package/dist/auth/profiles.d.ts +93 -0
- package/dist/auth/profiles.d.ts.map +1 -0
- package/dist/auth/profiles.js +321 -0
- package/dist/auth/profiles.js.map +1 -0
- package/dist/buildstamp.json +1 -0
- package/dist/cli/argv.d.ts +20 -0
- package/dist/cli/argv.d.ts.map +1 -0
- package/dist/cli/argv.js +47 -0
- package/dist/cli/argv.js.map +1 -0
- package/dist/cli/commands/agent.d.ts +19 -0
- package/dist/cli/commands/agent.d.ts.map +1 -0
- package/dist/cli/commands/agent.js +297 -0
- package/dist/cli/commands/agent.js.map +1 -0
- package/dist/cli/commands/agents-bindings.d.ts +80 -0
- package/dist/cli/commands/agents-bindings.d.ts.map +1 -0
- package/dist/cli/commands/agents-bindings.js +252 -0
- package/dist/cli/commands/agents-bindings.js.map +1 -0
- package/dist/cli/commands/agents-cmd.d.ts +160 -0
- package/dist/cli/commands/agents-cmd.d.ts.map +1 -0
- package/dist/cli/commands/agents-cmd.js +1199 -0
- package/dist/cli/commands/agents-cmd.js.map +1 -0
- package/dist/cli/commands/agents-config.d.ts +102 -0
- package/dist/cli/commands/agents-config.d.ts.map +1 -0
- package/dist/cli/commands/agents-config.js +294 -0
- package/dist/cli/commands/agents-config.js.map +1 -0
- package/dist/cli/commands/agents-shared.d.ts +57 -0
- package/dist/cli/commands/agents-shared.d.ts.map +1 -0
- package/dist/cli/commands/agents-shared.js +83 -0
- package/dist/cli/commands/agents-shared.js.map +1 -0
- package/dist/cli/commands/backup.d.ts +36 -0
- package/dist/cli/commands/backup.d.ts.map +1 -0
- package/dist/cli/commands/backup.js +244 -0
- package/dist/cli/commands/backup.js.map +1 -0
- package/dist/cli/commands/channels.d.ts +106 -0
- package/dist/cli/commands/channels.d.ts.map +1 -0
- package/dist/cli/commands/channels.js +830 -0
- package/dist/cli/commands/channels.js.map +1 -0
- package/dist/cli/commands/chat.d.ts +43 -0
- package/dist/cli/commands/chat.d.ts.map +1 -0
- package/dist/cli/commands/chat.js +84 -0
- package/dist/cli/commands/chat.js.map +1 -0
- package/dist/cli/commands/config-cmd.d.ts +62 -0
- package/dist/cli/commands/config-cmd.d.ts.map +1 -0
- package/dist/cli/commands/config-cmd.js +404 -0
- package/dist/cli/commands/config-cmd.js.map +1 -0
- package/dist/cli/commands/connect.d.ts +73 -0
- package/dist/cli/commands/connect.d.ts.map +1 -0
- package/dist/cli/commands/connect.js +1952 -0
- package/dist/cli/commands/connect.js.map +1 -0
- package/dist/cli/commands/cron.d.ts +58 -0
- package/dist/cli/commands/cron.d.ts.map +1 -0
- package/dist/cli/commands/cron.js +250 -0
- package/dist/cli/commands/cron.js.map +1 -0
- package/dist/cli/commands/doctor.d.ts +25 -0
- package/dist/cli/commands/doctor.d.ts.map +1 -0
- package/dist/cli/commands/doctor.js +618 -0
- package/dist/cli/commands/doctor.js.map +1 -0
- package/dist/cli/commands/encrypt-cmd.d.ts +12 -0
- package/dist/cli/commands/encrypt-cmd.d.ts.map +1 -0
- package/dist/cli/commands/encrypt-cmd.js +119 -0
- package/dist/cli/commands/encrypt-cmd.js.map +1 -0
- package/dist/cli/commands/exec-cmd.d.ts +55 -0
- package/dist/cli/commands/exec-cmd.d.ts.map +1 -0
- package/dist/cli/commands/exec-cmd.js +253 -0
- package/dist/cli/commands/exec-cmd.js.map +1 -0
- package/dist/cli/commands/gateway-install.d.ts +21 -0
- package/dist/cli/commands/gateway-install.d.ts.map +1 -0
- package/dist/cli/commands/gateway-install.js +71 -0
- package/dist/cli/commands/gateway-install.js.map +1 -0
- package/dist/cli/commands/gateway-supervise.d.ts +102 -0
- package/dist/cli/commands/gateway-supervise.d.ts.map +1 -0
- package/dist/cli/commands/gateway-supervise.js +194 -0
- package/dist/cli/commands/gateway-supervise.js.map +1 -0
- package/dist/cli/commands/gateway.d.ts +58 -0
- package/dist/cli/commands/gateway.d.ts.map +1 -0
- package/dist/cli/commands/gateway.js +497 -0
- package/dist/cli/commands/gateway.js.map +1 -0
- package/dist/cli/commands/logs.d.ts +14 -0
- package/dist/cli/commands/logs.d.ts.map +1 -0
- package/dist/cli/commands/logs.js +93 -0
- package/dist/cli/commands/logs.js.map +1 -0
- package/dist/cli/commands/mcp-cmd.d.ts +4 -0
- package/dist/cli/commands/mcp-cmd.d.ts.map +1 -0
- package/dist/cli/commands/mcp-cmd.js +30 -0
- package/dist/cli/commands/mcp-cmd.js.map +1 -0
- package/dist/cli/commands/onboard-config.d.ts +23 -0
- package/dist/cli/commands/onboard-config.d.ts.map +1 -0
- package/dist/cli/commands/onboard-config.js +33 -0
- package/dist/cli/commands/onboard-config.js.map +1 -0
- package/dist/cli/commands/onboard.d.ts +48 -0
- package/dist/cli/commands/onboard.d.ts.map +1 -0
- package/dist/cli/commands/onboard.js +397 -0
- package/dist/cli/commands/onboard.js.map +1 -0
- package/dist/cli/commands/org-cmd.d.ts +87 -0
- package/dist/cli/commands/org-cmd.d.ts.map +1 -0
- package/dist/cli/commands/org-cmd.js +394 -0
- package/dist/cli/commands/org-cmd.js.map +1 -0
- package/dist/cli/commands/org-cmd.templates.d.ts +66 -0
- package/dist/cli/commands/org-cmd.templates.d.ts.map +1 -0
- package/dist/cli/commands/org-cmd.templates.js +145 -0
- package/dist/cli/commands/org-cmd.templates.js.map +1 -0
- package/dist/cli/commands/org-slash.d.ts +107 -0
- package/dist/cli/commands/org-slash.d.ts.map +1 -0
- package/dist/cli/commands/org-slash.js +263 -0
- package/dist/cli/commands/org-slash.js.map +1 -0
- package/dist/cli/commands/pairing.d.ts +33 -0
- package/dist/cli/commands/pairing.d.ts.map +1 -0
- package/dist/cli/commands/pairing.js +155 -0
- package/dist/cli/commands/pairing.js.map +1 -0
- package/dist/cli/commands/secrets-audit.d.ts +17 -0
- package/dist/cli/commands/secrets-audit.d.ts.map +1 -0
- package/dist/cli/commands/secrets-audit.js +109 -0
- package/dist/cli/commands/secrets-audit.js.map +1 -0
- package/dist/cli/commands/sessions.d.ts +22 -0
- package/dist/cli/commands/sessions.d.ts.map +1 -0
- package/dist/cli/commands/sessions.js +99 -0
- package/dist/cli/commands/sessions.js.map +1 -0
- package/dist/cli/commands/skills.d.ts +17 -0
- package/dist/cli/commands/skills.d.ts.map +1 -0
- package/dist/cli/commands/skills.js +100 -0
- package/dist/cli/commands/skills.js.map +1 -0
- package/dist/cli/commands/status.d.ts +26 -0
- package/dist/cli/commands/status.d.ts.map +1 -0
- package/dist/cli/commands/status.js +252 -0
- package/dist/cli/commands/status.js.map +1 -0
- package/dist/cli/commands/store-cmd.d.ts +36 -0
- package/dist/cli/commands/store-cmd.d.ts.map +1 -0
- package/dist/cli/commands/store-cmd.js +405 -0
- package/dist/cli/commands/store-cmd.js.map +1 -0
- package/dist/cli/flows/web-setup.d.ts +47 -0
- package/dist/cli/flows/web-setup.d.ts.map +1 -0
- package/dist/cli/flows/web-setup.js +324 -0
- package/dist/cli/flows/web-setup.js.map +1 -0
- package/dist/cli/program/build-program.d.ts +3 -0
- package/dist/cli/program/build-program.d.ts.map +1 -0
- package/dist/cli/program/build-program.js +1326 -0
- package/dist/cli/program/build-program.js.map +1 -0
- package/dist/cli/run-main.d.ts +2 -0
- package/dist/cli/run-main.d.ts.map +1 -0
- package/dist/cli/run-main.js +63 -0
- package/dist/cli/run-main.js.map +1 -0
- package/dist/config/agent-limits.d.ts +22 -0
- package/dist/config/agent-limits.d.ts.map +1 -0
- package/dist/config/agent-limits.js +34 -0
- package/dist/config/agent-limits.js.map +1 -0
- package/dist/config/io.d.ts +378 -0
- package/dist/config/io.d.ts.map +1 -0
- package/dist/config/io.js +602 -0
- package/dist/config/io.js.map +1 -0
- package/dist/config/paths.d.ts +80 -0
- package/dist/config/paths.d.ts.map +1 -0
- package/dist/config/paths.js +342 -0
- package/dist/config/paths.js.map +1 -0
- package/dist/config/types.d.ts +12 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/config/types.js +12 -0
- package/dist/config/types.js.map +1 -0
- package/dist/core/agent-dispatcher.d.ts +91 -0
- package/dist/core/agent-dispatcher.d.ts.map +1 -0
- package/dist/core/agent-dispatcher.js +251 -0
- package/dist/core/agent-dispatcher.js.map +1 -0
- package/dist/core/agent-events-stream.d.ts +76 -0
- package/dist/core/agent-events-stream.d.ts.map +1 -0
- package/dist/core/agent-events-stream.js +185 -0
- package/dist/core/agent-events-stream.js.map +1 -0
- package/dist/core/agent-runtime-persist.d.ts +53 -0
- package/dist/core/agent-runtime-persist.d.ts.map +1 -0
- package/dist/core/agent-runtime-persist.js +114 -0
- package/dist/core/agent-runtime-persist.js.map +1 -0
- package/dist/core/auth-bridge.d.ts +8 -0
- package/dist/core/auth-bridge.d.ts.map +1 -0
- package/dist/core/auth-bridge.js +102 -0
- package/dist/core/auth-bridge.js.map +1 -0
- package/dist/core/auth-error.d.ts +49 -0
- package/dist/core/auth-error.d.ts.map +1 -0
- package/dist/core/auth-error.js.map +1 -0
- package/dist/core/brigade-config.d.ts +205 -0
- package/dist/core/brigade-config.d.ts.map +1 -0
- package/dist/core/brigade-config.js +58 -6
- package/dist/core/brigade-config.js.map +1 -0
- package/dist/core/config.d.ts +17 -0
- package/dist/core/config.d.ts.map +1 -0
- package/dist/core/config.js +92 -246
- package/dist/core/config.js.map +1 -0
- package/dist/core/console-stream.d.ts +52 -0
- package/dist/core/console-stream.d.ts.map +1 -0
- package/dist/core/console-stream.js +49 -3
- package/dist/core/console-stream.js.map +1 -0
- package/dist/core/daemon/launchd.d.ts +19 -0
- package/dist/core/daemon/launchd.d.ts.map +1 -0
- package/dist/core/daemon/launchd.js +117 -0
- package/dist/core/daemon/launchd.js.map +1 -0
- package/dist/core/daemon/schtasks.d.ts +23 -0
- package/dist/core/daemon/schtasks.d.ts.map +1 -0
- package/dist/core/daemon/schtasks.js +139 -0
- package/dist/core/daemon/schtasks.js.map +1 -0
- package/dist/core/daemon/service.d.ts +56 -0
- package/dist/core/daemon/service.d.ts.map +1 -0
- package/dist/core/daemon/service.js +54 -0
- package/dist/core/daemon/service.js.map +1 -0
- package/dist/core/daemon/systemd.d.ts +19 -0
- package/dist/core/daemon/systemd.d.ts.map +1 -0
- package/dist/core/daemon/systemd.js +117 -0
- package/dist/core/daemon/systemd.js.map +1 -0
- package/dist/core/event-logger.d.ts +74 -0
- package/dist/core/event-logger.d.ts.map +1 -0
- package/dist/core/event-logger.js +299 -6
- package/dist/core/event-logger.js.map +1 -0
- package/dist/core/exec-approvals.d.ts +178 -0
- package/dist/core/exec-approvals.d.ts.map +1 -0
- package/dist/core/exec-approvals.js +591 -266
- package/dist/core/exec-approvals.js.map +1 -0
- package/dist/core/extension-lifecycle.d.ts +27 -0
- package/dist/core/extension-lifecycle.d.ts.map +1 -0
- package/dist/core/extension-lifecycle.js +45 -0
- package/dist/core/extension-lifecycle.js.map +1 -0
- package/dist/core/gateway-caller-impl.d.ts +42 -0
- package/dist/core/gateway-caller-impl.d.ts.map +1 -0
- package/dist/core/gateway-caller-impl.js +95 -0
- package/dist/core/gateway-caller-impl.js.map +1 -0
- package/dist/core/gateway-lock.d.ts +88 -0
- package/dist/core/gateway-lock.d.ts.map +1 -0
- package/dist/core/gateway-lock.js +204 -0
- package/dist/core/gateway-lock.js.map +1 -0
- package/dist/core/gateway-probe.d.ts +148 -0
- package/dist/core/gateway-probe.d.ts.map +1 -0
- package/dist/core/gateway-probe.js +319 -0
- package/dist/core/gateway-probe.js.map +1 -0
- package/dist/core/gateway-spawn.d.ts +40 -0
- package/dist/core/gateway-spawn.d.ts.map +1 -0
- package/dist/core/gateway-spawn.js +156 -0
- package/dist/core/gateway-spawn.js.map +1 -0
- package/dist/core/model-caps.d.ts +85 -0
- package/dist/core/model-caps.d.ts.map +1 -0
- package/dist/core/model-caps.js +88 -2
- package/dist/core/model-caps.js.map +1 -0
- package/dist/core/port-inspect.d.ts +37 -0
- package/dist/core/port-inspect.d.ts.map +1 -0
- package/dist/core/port-inspect.js +165 -0
- package/dist/core/port-inspect.js.map +1 -0
- package/dist/core/server-lanes.d.ts +25 -0
- package/dist/core/server-lanes.d.ts.map +1 -0
- package/dist/core/server-lanes.js +31 -0
- package/dist/core/server-lanes.js.map +1 -0
- package/dist/core/server-methods/cron.d.ts +104 -0
- package/dist/core/server-methods/cron.d.ts.map +1 -0
- package/dist/core/server-methods/cron.js +183 -0
- package/dist/core/server-methods/cron.js.map +1 -0
- package/dist/core/server-methods/health.d.ts +36 -0
- package/dist/core/server-methods/health.d.ts.map +1 -0
- package/dist/core/server-methods/health.js +51 -0
- package/dist/core/server-methods/health.js.map +1 -0
- package/dist/core/server-methods/org.d.ts +93 -0
- package/dist/core/server-methods/org.d.ts.map +1 -0
- package/dist/core/server-methods/org.js +95 -0
- package/dist/core/server-methods/org.js.map +1 -0
- package/dist/core/server-methods/sessions.d.ts +133 -0
- package/dist/core/server-methods/sessions.d.ts.map +1 -0
- package/dist/core/server-methods/sessions.js +209 -0
- package/dist/core/server-methods/sessions.js.map +1 -0
- package/dist/core/server.d.ts +46 -0
- package/dist/core/server.d.ts.map +1 -0
- package/dist/core/server.js +4716 -249
- package/dist/core/server.js.map +1 -0
- package/dist/core/system-prompt.d.ts +92 -0
- package/dist/core/system-prompt.d.ts.map +1 -0
- package/dist/core/system-prompt.js +180 -1584
- package/dist/core/system-prompt.js.map +1 -0
- package/dist/core/version.d.ts +4 -0
- package/dist/core/version.d.ts.map +1 -0
- package/dist/core/version.js +8 -13
- package/dist/core/version.js.map +1 -0
- package/dist/core/webhook-guards.d.ts +131 -0
- package/dist/core/webhook-guards.d.ts.map +1 -0
- package/dist/core/webhook-guards.js +283 -0
- package/dist/core/webhook-guards.js.map +1 -0
- package/dist/core/ws-subscription-filter.d.ts +9 -0
- package/dist/core/ws-subscription-filter.d.ts.map +1 -0
- package/dist/core/ws-subscription-filter.js +39 -0
- package/dist/core/ws-subscription-filter.js.map +1 -0
- package/dist/cron/active-service.d.ts +30 -0
- package/dist/cron/active-service.d.ts.map +1 -0
- package/dist/cron/active-service.js +48 -0
- package/dist/cron/active-service.js.map +1 -0
- package/dist/cron/isolated-agent/run-executor.d.ts +49 -0
- package/dist/cron/isolated-agent/run-executor.d.ts.map +1 -0
- package/dist/cron/isolated-agent/run-executor.js +343 -0
- package/dist/cron/isolated-agent/run-executor.js.map +1 -0
- package/dist/cron/isolated-agent/run.d.ts +27 -0
- package/dist/cron/isolated-agent/run.d.ts.map +1 -0
- package/dist/cron/isolated-agent/run.js +29 -0
- package/dist/cron/isolated-agent/run.js.map +1 -0
- package/dist/cron/normalize.d.ts +103 -0
- package/dist/cron/normalize.d.ts.map +1 -0
- package/dist/cron/normalize.js +376 -0
- package/dist/cron/normalize.js.map +1 -0
- package/dist/cron/parse.d.ts +27 -0
- package/dist/cron/parse.d.ts.map +1 -0
- package/dist/cron/parse.js +55 -0
- package/dist/cron/parse.js.map +1 -0
- package/dist/cron/reminder-context.d.ts +78 -0
- package/dist/cron/reminder-context.d.ts.map +1 -0
- package/dist/cron/reminder-context.js +167 -0
- package/dist/cron/reminder-context.js.map +1 -0
- package/dist/cron/run-log.d.ts +48 -0
- package/dist/cron/run-log.d.ts.map +1 -0
- package/dist/cron/run-log.js +225 -0
- package/dist/cron/run-log.js.map +1 -0
- package/dist/cron/schedule.d.ts +46 -0
- package/dist/cron/schedule.d.ts.map +1 -0
- package/dist/cron/schedule.js +144 -0
- package/dist/cron/schedule.js.map +1 -0
- package/dist/cron/service/jobs.d.ts +138 -0
- package/dist/cron/service/jobs.d.ts.map +1 -0
- package/dist/cron/service/jobs.js +370 -0
- package/dist/cron/service/jobs.js.map +1 -0
- package/dist/cron/service/locked.d.ts +46 -0
- package/dist/cron/service/locked.d.ts.map +1 -0
- package/dist/cron/service/locked.js +54 -0
- package/dist/cron/service/locked.js.map +1 -0
- package/dist/cron/service/ops.d.ts +124 -0
- package/dist/cron/service/ops.d.ts.map +1 -0
- package/dist/cron/service/ops.js +415 -0
- package/dist/cron/service/ops.js.map +1 -0
- package/dist/cron/service/state.d.ts +254 -0
- package/dist/cron/service/state.d.ts.map +1 -0
- package/dist/cron/service/state.js +50 -0
- package/dist/cron/service/state.js.map +1 -0
- package/dist/cron/service/store.d.ts +65 -0
- package/dist/cron/service/store.d.ts.map +1 -0
- package/dist/cron/service/store.js +350 -0
- package/dist/cron/service/store.js.map +1 -0
- package/dist/cron/service/timer.d.ts +113 -0
- package/dist/cron/service/timer.d.ts.map +1 -0
- package/dist/cron/service/timer.js +1081 -0
- package/dist/cron/service/timer.js.map +1 -0
- package/dist/cron/session-reaper.d.ts +62 -0
- package/dist/cron/session-reaper.d.ts.map +1 -0
- package/dist/cron/session-reaper.js +152 -0
- package/dist/cron/session-reaper.js.map +1 -0
- package/dist/cron/session-target.d.ts +56 -0
- package/dist/cron/session-target.d.ts.map +1 -0
- package/dist/cron/session-target.js +96 -0
- package/dist/cron/session-target.js.map +1 -0
- package/dist/cron/stagger.d.ts +34 -0
- package/dist/cron/stagger.d.ts.map +1 -0
- package/dist/cron/stagger.js +69 -0
- package/dist/cron/stagger.js.map +1 -0
- package/dist/cron/types.d.ts +287 -0
- package/dist/cron/types.d.ts.map +1 -0
- package/dist/cron/types.js +22 -0
- package/dist/cron/types.js.map +1 -0
- package/dist/cron/validate-timestamp.d.ts +33 -0
- package/dist/cron/validate-timestamp.d.ts.map +1 -0
- package/dist/cron/validate-timestamp.js +54 -0
- package/dist/cron/validate-timestamp.js.map +1 -0
- package/dist/entry.d.ts +2 -0
- package/dist/entry.d.ts.map +1 -0
- package/dist/entry.js +57 -0
- package/dist/entry.js.map +1 -0
- package/dist/extension-sdk.d.ts +28 -0
- package/dist/extension-sdk.d.ts.map +1 -0
- package/dist/extension-sdk.js +26 -0
- package/dist/extension-sdk.js.map +1 -0
- package/dist/identity/device.d.ts +19 -0
- package/dist/identity/device.d.ts.map +1 -0
- package/dist/identity/device.js +88 -0
- package/dist/identity/device.js.map +1 -0
- package/dist/infra/backoff.d.ts +24 -0
- package/dist/infra/backoff.d.ts.map +1 -0
- package/dist/infra/backoff.js +48 -0
- package/dist/infra/backoff.js.map +1 -0
- package/dist/infra/errors.d.ts +35 -0
- package/dist/infra/errors.d.ts.map +1 -0
- package/dist/infra/errors.js +54 -0
- package/dist/infra/errors.js.map +1 -0
- package/dist/infra/fs/atomic-rename.d.ts +31 -0
- package/dist/infra/fs/atomic-rename.d.ts.map +1 -0
- package/dist/infra/fs/atomic-rename.js +75 -0
- package/dist/infra/fs/atomic-rename.js.map +1 -0
- package/dist/infra/json-file.d.ts +25 -0
- package/dist/infra/json-file.d.ts.map +1 -0
- package/dist/infra/json-file.js +49 -0
- package/dist/infra/json-file.js.map +1 -0
- package/dist/infra/json-utf8-bytes.d.ts +14 -0
- package/dist/infra/json-utf8-bytes.d.ts.map +1 -0
- package/dist/infra/json-utf8-bytes.js +20 -0
- package/dist/infra/json-utf8-bytes.js.map +1 -0
- package/dist/infra/net/dns-pinning.d.ts +66 -0
- package/dist/infra/net/dns-pinning.d.ts.map +1 -0
- package/dist/infra/net/dns-pinning.js +128 -0
- package/dist/infra/net/dns-pinning.js.map +1 -0
- package/dist/infra/net/fetch-guard.d.ts +85 -0
- package/dist/infra/net/fetch-guard.d.ts.map +1 -0
- package/dist/infra/net/fetch-guard.js +439 -0
- package/dist/infra/net/fetch-guard.js.map +1 -0
- package/dist/infra/prototype-keys.d.ts +19 -0
- package/dist/infra/prototype-keys.d.ts.map +1 -0
- package/dist/infra/prototype-keys.js +22 -0
- package/dist/infra/prototype-keys.js.map +1 -0
- package/dist/integrations/ollama.d.ts +67 -0
- package/dist/integrations/ollama.d.ts.map +1 -0
- package/dist/integrations/ollama.js +53 -0
- package/dist/integrations/ollama.js.map +1 -0
- package/dist/integrations/provider-discovery.d.ts +66 -0
- package/dist/integrations/provider-discovery.d.ts.map +1 -0
- package/dist/integrations/provider-discovery.js +166 -0
- package/dist/integrations/provider-discovery.js.map +1 -0
- package/dist/logging/redact.d.ts +28 -0
- package/dist/logging/redact.d.ts.map +1 -0
- package/dist/logging/redact.js +51 -0
- package/dist/logging/redact.js.map +1 -0
- package/dist/logging/subsystem-logger.d.ts +77 -0
- package/dist/logging/subsystem-logger.d.ts.map +1 -0
- package/dist/logging/subsystem-logger.js +577 -0
- package/dist/logging/subsystem-logger.js.map +1 -0
- package/dist/logging/subsystem.d.ts +13 -0
- package/dist/logging/subsystem.d.ts.map +1 -0
- package/dist/logging/subsystem.js +12 -0
- package/dist/logging/subsystem.js.map +1 -0
- package/dist/process/command-queue.d.ts +152 -0
- package/dist/process/command-queue.d.ts.map +1 -0
- package/dist/process/command-queue.js +420 -0
- package/dist/process/command-queue.js.map +1 -0
- package/dist/process/lanes.d.ts +102 -0
- package/dist/process/lanes.d.ts.map +1 -0
- package/dist/process/lanes.js +117 -0
- package/dist/process/lanes.js.map +1 -0
- package/dist/process/session-lane.d.ts +31 -0
- package/dist/process/session-lane.d.ts.map +1 -0
- package/dist/process/session-lane.js +45 -0
- package/dist/process/session-lane.js.map +1 -0
- package/dist/protocol/errors.d.ts +35 -0
- package/dist/protocol/errors.d.ts.map +1 -0
- package/dist/protocol/errors.js +36 -0
- package/dist/protocol/errors.js.map +1 -0
- package/dist/protocol/handshake.d.ts +101 -0
- package/dist/protocol/handshake.d.ts.map +1 -0
- package/dist/protocol/handshake.js +49 -0
- package/dist/protocol/handshake.js.map +1 -0
- package/dist/protocol/messages.d.ts +68 -0
- package/dist/protocol/messages.d.ts.map +1 -0
- package/dist/protocol/messages.js +20 -0
- package/dist/protocol/messages.js.map +1 -0
- package/dist/protocol/methods.d.ts +312 -0
- package/dist/protocol/methods.d.ts.map +1 -0
- package/dist/protocol/methods.js +16 -0
- package/dist/protocol/methods.js.map +1 -0
- package/dist/protocol.d.ts +598 -0
- package/dist/protocol.d.ts.map +1 -0
- package/dist/protocol.js +12 -0
- package/dist/protocol.js.map +1 -0
- package/dist/providers/auth-methods.d.ts +82 -0
- package/dist/providers/auth-methods.d.ts.map +1 -0
- package/dist/providers/auth-methods.js +180 -0
- package/dist/providers/auth-methods.js.map +1 -0
- package/dist/providers/catalog.d.ts +85 -0
- package/dist/providers/catalog.d.ts.map +1 -0
- package/dist/providers/catalog.js +41 -0
- package/dist/providers/catalog.js.map +1 -0
- package/dist/providers/validate-key.d.ts +42 -0
- package/dist/providers/validate-key.d.ts.map +1 -0
- package/dist/providers/validate-key.js.map +1 -0
- package/dist/security/external-content.d.ts +67 -0
- package/dist/security/external-content.d.ts.map +1 -0
- package/dist/security/external-content.js +80 -0
- package/dist/security/external-content.js.map +1 -0
- package/dist/security/injection-patterns.d.ts +33 -0
- package/dist/security/injection-patterns.d.ts.map +1 -0
- package/dist/security/injection-patterns.js +97 -0
- package/dist/security/injection-patterns.js.map +1 -0
- package/dist/security/media-path-guard.d.ts +25 -0
- package/dist/security/media-path-guard.d.ts.map +1 -0
- package/dist/security/media-path-guard.js +98 -0
- package/dist/security/media-path-guard.js.map +1 -0
- package/dist/security/terminal-input-sanitizer.d.ts +30 -0
- package/dist/security/terminal-input-sanitizer.d.ts.map +1 -0
- package/dist/security/terminal-input-sanitizer.js +70 -0
- package/dist/security/terminal-input-sanitizer.js.map +1 -0
- package/dist/sessions/bootstrap-marker.d.ts +5 -0
- package/dist/sessions/bootstrap-marker.d.ts.map +1 -0
- package/dist/sessions/bootstrap-marker.js +120 -0
- package/dist/sessions/bootstrap-marker.js.map +1 -0
- package/dist/sessions/session-file-repair.d.ts +12 -0
- package/dist/sessions/session-file-repair.d.ts.map +1 -0
- package/dist/sessions/session-file-repair.js +155 -0
- package/dist/sessions/session-file-repair.js.map +1 -0
- package/dist/sessions/session-key-utils.d.ts +54 -0
- package/dist/sessions/session-key-utils.d.ts.map +1 -0
- package/dist/sessions/session-key-utils.js +133 -0
- package/dist/sessions/session-key-utils.js.map +1 -0
- package/dist/sessions/session-manager-factory.d.ts +21 -0
- package/dist/sessions/session-manager-factory.d.ts.map +1 -0
- package/dist/sessions/session-manager-factory.js +142 -0
- package/dist/sessions/session-manager-factory.js.map +1 -0
- package/dist/sessions/session-store.d.ts +154 -0
- package/dist/sessions/session-store.d.ts.map +1 -0
- package/dist/sessions/session-store.js +498 -0
- package/dist/sessions/session-store.js.map +1 -0
- package/dist/sessions/session-write-lock.d.ts +10 -0
- package/dist/sessions/session-write-lock.d.ts.map +1 -0
- package/dist/sessions/session-write-lock.js +167 -0
- package/dist/sessions/session-write-lock.js.map +1 -0
- package/dist/sessions/transcript-reader.d.ts +37 -0
- package/dist/sessions/transcript-reader.d.ts.map +1 -0
- package/dist/sessions/transcript-reader.js +136 -0
- package/dist/sessions/transcript-reader.js.map +1 -0
- package/dist/sessions/transcript-repair.d.ts +16 -0
- package/dist/sessions/transcript-repair.d.ts.map +1 -0
- package/dist/sessions/transcript-repair.js +214 -0
- package/dist/sessions/transcript-repair.js.map +1 -0
- package/dist/shared/global-singleton.d.ts +27 -0
- package/dist/shared/global-singleton.d.ts.map +1 -0
- package/dist/shared/global-singleton.js +35 -0
- package/dist/shared/global-singleton.js.map +1 -0
- package/dist/shared/string-coerce.d.ts +12 -0
- package/dist/shared/string-coerce.d.ts.map +1 -0
- package/dist/shared/string-coerce.js +12 -0
- package/dist/shared/string-coerce.js.map +1 -0
- package/dist/storage/boot.d.ts +28 -0
- package/dist/storage/boot.d.ts.map +1 -0
- package/dist/storage/boot.js +588 -0
- package/dist/storage/boot.js.map +1 -0
- package/dist/storage/config-cache.d.ts +23 -0
- package/dist/storage/config-cache.d.ts.map +1 -0
- package/dist/storage/config-cache.js +58 -0
- package/dist/storage/config-cache.js.map +1 -0
- package/dist/storage/convex/auth-store.d.ts +52 -0
- package/dist/storage/convex/auth-store.d.ts.map +1 -0
- package/dist/storage/convex/auth-store.js +282 -0
- package/dist/storage/convex/auth-store.js.map +1 -0
- package/dist/storage/convex/blob-store.d.ts +20 -0
- package/dist/storage/convex/blob-store.d.ts.map +1 -0
- package/dist/storage/convex/blob-store.js +74 -0
- package/dist/storage/convex/blob-store.js.map +1 -0
- package/dist/storage/convex/channel-store.d.ts +112 -0
- package/dist/storage/convex/channel-store.d.ts.map +1 -0
- package/dist/storage/convex/channel-store.js +267 -0
- package/dist/storage/convex/channel-store.js.map +1 -0
- package/dist/storage/convex/client.d.ts +53 -0
- package/dist/storage/convex/client.d.ts.map +1 -0
- package/dist/storage/convex/client.js +121 -0
- package/dist/storage/convex/client.js.map +1 -0
- package/dist/storage/convex/config-store.d.ts +29 -0
- package/dist/storage/convex/config-store.d.ts.map +1 -0
- package/dist/storage/convex/config-store.js +205 -0
- package/dist/storage/convex/config-store.js.map +1 -0
- package/dist/storage/convex/cron-store.d.ts +86 -0
- package/dist/storage/convex/cron-store.d.ts.map +1 -0
- package/dist/storage/convex/cron-store.js +428 -0
- package/dist/storage/convex/cron-store.js.map +1 -0
- package/dist/storage/convex/exec-approval-store.d.ts +38 -0
- package/dist/storage/convex/exec-approval-store.d.ts.map +1 -0
- package/dist/storage/convex/exec-approval-store.js +147 -0
- package/dist/storage/convex/exec-approval-store.js.map +1 -0
- package/dist/storage/convex/extension-store.d.ts +28 -0
- package/dist/storage/convex/extension-store.d.ts.map +1 -0
- package/dist/storage/convex/extension-store.js +39 -0
- package/dist/storage/convex/extension-store.js.map +1 -0
- package/dist/storage/convex/index.d.ts +35 -0
- package/dist/storage/convex/index.d.ts.map +1 -0
- package/dist/storage/convex/index.js +141 -0
- package/dist/storage/convex/index.js.map +1 -0
- package/dist/storage/convex/instance-store.d.ts +37 -0
- package/dist/storage/convex/instance-store.d.ts.map +1 -0
- package/dist/storage/convex/instance-store.js +88 -0
- package/dist/storage/convex/instance-store.js.map +1 -0
- package/dist/storage/convex/log-store.d.ts +36 -0
- package/dist/storage/convex/log-store.d.ts.map +1 -0
- package/dist/storage/convex/log-store.js +213 -0
- package/dist/storage/convex/log-store.js.map +1 -0
- package/dist/storage/convex/memory-store.d.ts +50 -0
- package/dist/storage/convex/memory-store.d.ts.map +1 -0
- package/dist/storage/convex/memory-store.js +537 -0
- package/dist/storage/convex/memory-store.js.map +1 -0
- package/dist/storage/convex/message-store.d.ts +32 -0
- package/dist/storage/convex/message-store.d.ts.map +1 -0
- package/dist/storage/convex/message-store.js +272 -0
- package/dist/storage/convex/message-store.js.map +1 -0
- package/dist/storage/convex/org-store.d.ts +46 -0
- package/dist/storage/convex/org-store.d.ts.map +1 -0
- package/dist/storage/convex/org-store.js +101 -0
- package/dist/storage/convex/org-store.js.map +1 -0
- package/dist/storage/convex/session-store.d.ts +44 -0
- package/dist/storage/convex/session-store.d.ts.map +1 -0
- package/dist/storage/convex/session-store.js +257 -0
- package/dist/storage/convex/session-store.js.map +1 -0
- package/dist/storage/convex/skill-store.d.ts +49 -0
- package/dist/storage/convex/skill-store.d.ts.map +1 -0
- package/dist/storage/convex/skill-store.js +84 -0
- package/dist/storage/convex/skill-store.js.map +1 -0
- package/dist/storage/convex/subagent-store.d.ts +28 -0
- package/dist/storage/convex/subagent-store.d.ts.map +1 -0
- package/dist/storage/convex/subagent-store.js +83 -0
- package/dist/storage/convex/subagent-store.js.map +1 -0
- package/dist/storage/convex/workspace-store.d.ts +25 -0
- package/dist/storage/convex/workspace-store.d.ts.map +1 -0
- package/dist/storage/convex/workspace-store.js +127 -0
- package/dist/storage/convex/workspace-store.js.map +1 -0
- package/dist/storage/cron-cache.d.ts +17 -0
- package/dist/storage/cron-cache.d.ts.map +1 -0
- package/dist/storage/cron-cache.js +67 -0
- package/dist/storage/cron-cache.js.map +1 -0
- package/dist/storage/encryption.d.ts +69 -0
- package/dist/storage/encryption.d.ts.map +1 -0
- package/dist/storage/encryption.js +389 -0
- package/dist/storage/encryption.js.map +1 -0
- package/dist/storage/factory-reset.d.ts +7 -0
- package/dist/storage/factory-reset.d.ts.map +1 -0
- package/dist/storage/factory-reset.js +34 -0
- package/dist/storage/factory-reset.js.map +1 -0
- package/dist/storage/facts-cache.d.ts +24 -0
- package/dist/storage/facts-cache.d.ts.map +1 -0
- package/dist/storage/facts-cache.js +110 -0
- package/dist/storage/facts-cache.js.map +1 -0
- package/dist/storage/flush.d.ts +4 -0
- package/dist/storage/flush.d.ts.map +1 -0
- package/dist/storage/flush.js +128 -0
- package/dist/storage/flush.js.map +1 -0
- package/dist/storage/instance-admin.d.ts +52 -0
- package/dist/storage/instance-admin.d.ts.map +1 -0
- package/dist/storage/instance-admin.js +91 -0
- package/dist/storage/instance-admin.js.map +1 -0
- package/dist/storage/local/auth-store.d.ts +44 -0
- package/dist/storage/local/auth-store.d.ts.map +1 -0
- package/dist/storage/local/auth-store.js +252 -0
- package/dist/storage/local/auth-store.js.map +1 -0
- package/dist/storage/local/blob-store.d.ts +14 -0
- package/dist/storage/local/blob-store.d.ts.map +1 -0
- package/dist/storage/local/blob-store.js +87 -0
- package/dist/storage/local/blob-store.js.map +1 -0
- package/dist/storage/local/channel-store.d.ts +107 -0
- package/dist/storage/local/channel-store.d.ts.map +1 -0
- package/dist/storage/local/channel-store.js +147 -0
- package/dist/storage/local/channel-store.js.map +1 -0
- package/dist/storage/local/config-store.d.ts +23 -0
- package/dist/storage/local/config-store.d.ts.map +1 -0
- package/dist/storage/local/config-store.js +98 -0
- package/dist/storage/local/config-store.js.map +1 -0
- package/dist/storage/local/cron-store.d.ts +30 -0
- package/dist/storage/local/cron-store.d.ts.map +1 -0
- package/dist/storage/local/cron-store.js +186 -0
- package/dist/storage/local/cron-store.js.map +1 -0
- package/dist/storage/local/exec-approval-store.d.ts +41 -0
- package/dist/storage/local/exec-approval-store.d.ts.map +1 -0
- package/dist/storage/local/exec-approval-store.js +78 -0
- package/dist/storage/local/exec-approval-store.js.map +1 -0
- package/dist/storage/local/extension-store.d.ts +13 -0
- package/dist/storage/local/extension-store.d.ts.map +1 -0
- package/dist/storage/local/extension-store.js +36 -0
- package/dist/storage/local/extension-store.js.map +1 -0
- package/dist/storage/local/file-watcher.d.ts +24 -0
- package/dist/storage/local/file-watcher.d.ts.map +1 -0
- package/dist/storage/local/file-watcher.js +141 -0
- package/dist/storage/local/file-watcher.js.map +1 -0
- package/dist/storage/local/index.d.ts +33 -0
- package/dist/storage/local/index.d.ts.map +1 -0
- package/dist/storage/local/index.js +143 -0
- package/dist/storage/local/index.js.map +1 -0
- package/dist/storage/local/instance-store.d.ts +30 -0
- package/dist/storage/local/instance-store.d.ts.map +1 -0
- package/dist/storage/local/instance-store.js +83 -0
- package/dist/storage/local/instance-store.js.map +1 -0
- package/dist/storage/local/log-store.d.ts +27 -0
- package/dist/storage/local/log-store.d.ts.map +1 -0
- package/dist/storage/local/log-store.js +185 -0
- package/dist/storage/local/log-store.js.map +1 -0
- package/dist/storage/local/memory-store.d.ts +39 -0
- package/dist/storage/local/memory-store.d.ts.map +1 -0
- package/dist/storage/local/memory-store.js +258 -0
- package/dist/storage/local/memory-store.js.map +1 -0
- package/dist/storage/local/message-store.d.ts +27 -0
- package/dist/storage/local/message-store.d.ts.map +1 -0
- package/dist/storage/local/message-store.js +253 -0
- package/dist/storage/local/message-store.js.map +1 -0
- package/dist/storage/local/org-store.d.ts +39 -0
- package/dist/storage/local/org-store.d.ts.map +1 -0
- package/dist/storage/local/org-store.js +155 -0
- package/dist/storage/local/org-store.js.map +1 -0
- package/dist/storage/local/session-store.d.ts +30 -0
- package/dist/storage/local/session-store.d.ts.map +1 -0
- package/dist/storage/local/session-store.js +82 -0
- package/dist/storage/local/session-store.js.map +1 -0
- package/dist/storage/local/skill-store.d.ts +40 -0
- package/dist/storage/local/skill-store.d.ts.map +1 -0
- package/dist/storage/local/skill-store.js +121 -0
- package/dist/storage/local/skill-store.js.map +1 -0
- package/dist/storage/local/subagent-store.d.ts +20 -0
- package/dist/storage/local/subagent-store.d.ts.map +1 -0
- package/dist/storage/local/subagent-store.js +71 -0
- package/dist/storage/local/subagent-store.js.map +1 -0
- package/dist/storage/local/workspace-store.d.ts +22 -0
- package/dist/storage/local/workspace-store.d.ts.map +1 -0
- package/dist/storage/local/workspace-store.js +190 -0
- package/dist/storage/local/workspace-store.js.map +1 -0
- package/dist/storage/migrate.d.ts +64 -0
- package/dist/storage/migrate.d.ts.map +1 -0
- package/dist/storage/migrate.js +585 -0
- package/dist/storage/migrate.js.map +1 -0
- package/dist/storage/runtime-context.d.ts +35 -0
- package/dist/storage/runtime-context.d.ts.map +1 -0
- package/dist/storage/runtime-context.js +145 -0
- package/dist/storage/runtime-context.js.map +1 -0
- package/dist/storage/sentinel.d.ts +28 -0
- package/dist/storage/sentinel.d.ts.map +1 -0
- package/dist/storage/sentinel.js +98 -0
- package/dist/storage/sentinel.js.map +1 -0
- package/dist/storage/session-cache.d.ts +15 -0
- package/dist/storage/session-cache.d.ts.map +1 -0
- package/dist/storage/session-cache.js +81 -0
- package/dist/storage/session-cache.js.map +1 -0
- package/dist/storage/store.d.ts +745 -0
- package/dist/storage/store.d.ts.map +1 -0
- package/dist/storage/store.js +36 -0
- package/dist/storage/store.js.map +1 -0
- package/dist/storage/strict-guard.d.ts +17 -0
- package/dist/storage/strict-guard.d.ts.map +1 -0
- package/dist/storage/strict-guard.js +200 -0
- package/dist/storage/strict-guard.js.map +1 -0
- package/dist/storage/workspace-live-mirror.d.ts +33 -0
- package/dist/storage/workspace-live-mirror.d.ts.map +1 -0
- package/dist/storage/workspace-live-mirror.js +207 -0
- package/dist/storage/workspace-live-mirror.js.map +1 -0
- package/dist/system-prompt/assembler.d.ts +113 -0
- package/dist/system-prompt/assembler.d.ts.map +1 -0
- package/dist/system-prompt/assembler.js +649 -0
- package/dist/system-prompt/assembler.js.map +1 -0
- package/dist/system-prompt/bootstrap-budget.d.ts +22 -0
- package/dist/system-prompt/bootstrap-budget.d.ts.map +1 -0
- package/dist/system-prompt/bootstrap-budget.js +83 -0
- package/dist/system-prompt/bootstrap-budget.js.map +1 -0
- package/dist/system-prompt/cache-boundary.d.ts +13 -0
- package/dist/system-prompt/cache-boundary.d.ts.map +1 -0
- package/dist/system-prompt/cache-boundary.js +56 -0
- package/dist/system-prompt/cache-boundary.js.map +1 -0
- package/dist/system-prompt/cache-stability.d.ts +3 -0
- package/dist/system-prompt/cache-stability.d.ts.map +1 -0
- package/dist/system-prompt/cache-stability.js +18 -0
- package/dist/system-prompt/cache-stability.js.map +1 -0
- package/dist/system-prompt/guidance.d.ts +147 -0
- package/dist/system-prompt/guidance.d.ts.map +1 -0
- package/dist/system-prompt/guidance.js +352 -0
- package/dist/system-prompt/guidance.js.map +1 -0
- package/dist/system-prompt/identity-defaults.d.ts +50 -0
- package/dist/system-prompt/identity-defaults.d.ts.map +1 -0
- package/dist/system-prompt/identity-defaults.js +119 -0
- package/dist/system-prompt/identity-defaults.js.map +1 -0
- package/dist/system-prompt/org/escalation-inbox.d.ts +53 -0
- package/dist/system-prompt/org/escalation-inbox.d.ts.map +1 -0
- package/dist/system-prompt/org/escalation-inbox.js +71 -0
- package/dist/system-prompt/org/escalation-inbox.js.map +1 -0
- package/dist/system-prompt/org/receiver-hint.d.ts +72 -0
- package/dist/system-prompt/org/receiver-hint.d.ts.map +1 -0
- package/dist/system-prompt/org/receiver-hint.js +116 -0
- package/dist/system-prompt/org/receiver-hint.js.map +1 -0
- package/dist/system-prompt/org/render-org-block.d.ts +42 -0
- package/dist/system-prompt/org/render-org-block.d.ts.map +1 -0
- package/dist/system-prompt/org/render-org-block.js +57 -0
- package/dist/system-prompt/org/render-org-block.js.map +1 -0
- package/dist/system-prompt/org/sub-agent-anchor.d.ts +30 -0
- package/dist/system-prompt/org/sub-agent-anchor.d.ts.map +1 -0
- package/dist/system-prompt/org/sub-agent-anchor.js +36 -0
- package/dist/system-prompt/org/sub-agent-anchor.js.map +1 -0
- package/dist/system-prompt/override.d.ts +7 -0
- package/dist/system-prompt/override.d.ts.map +1 -0
- package/dist/system-prompt/override.js +13 -0
- package/dist/system-prompt/override.js.map +1 -0
- package/dist/system-prompt/pi-injection.d.ts +5 -0
- package/dist/system-prompt/pi-injection.d.ts.map +1 -0
- package/dist/system-prompt/pi-injection.js +33 -0
- package/dist/system-prompt/pi-injection.js.map +1 -0
- package/dist/system-prompt/runtime-params.d.ts +34 -0
- package/dist/system-prompt/runtime-params.d.ts.map +1 -0
- package/dist/system-prompt/runtime-params.js +108 -0
- package/dist/system-prompt/runtime-params.js.map +1 -0
- package/dist/system-prompt/sanitize.d.ts +7 -0
- package/dist/system-prompt/sanitize.d.ts.map +1 -0
- package/dist/system-prompt/sanitize.js +31 -0
- package/dist/system-prompt/sanitize.js.map +1 -0
- package/dist/system-prompt/types.d.ts +7 -0
- package/dist/system-prompt/types.d.ts.map +1 -0
- package/dist/system-prompt/types.js +3 -0
- package/dist/system-prompt/types.js.map +1 -0
- package/dist/system-prompt/workspace-loader.d.ts +12 -0
- package/dist/system-prompt/workspace-loader.d.ts.map +1 -0
- package/dist/system-prompt/workspace-loader.js +115 -0
- package/dist/system-prompt/workspace-loader.js.map +1 -0
- package/dist/tideline/advanced.d.ts +25 -0
- package/dist/tideline/advanced.d.ts.map +1 -0
- package/dist/tideline/advanced.js +34 -0
- package/dist/tideline/advanced.js.map +1 -0
- package/dist/tideline/eval.d.ts +19 -0
- package/dist/tideline/eval.d.ts.map +1 -0
- package/dist/tideline/eval.js +24 -0
- package/dist/tideline/eval.js.map +1 -0
- package/dist/tideline/host-ports.standalone.d.ts +49 -0
- package/dist/tideline/host-ports.standalone.d.ts.map +1 -0
- package/dist/tideline/host-ports.standalone.js +61 -0
- package/dist/tideline/host-ports.standalone.js.map +1 -0
- package/dist/tideline/index.d.ts +34 -0
- package/dist/tideline/index.d.ts.map +1 -0
- package/dist/tideline/index.js +42 -0
- package/dist/tideline/index.js.map +1 -0
- package/dist/tui/approval-prompt.d.ts +73 -0
- package/dist/tui/approval-prompt.d.ts.map +1 -0
- package/dist/tui/approval-prompt.js +272 -0
- package/dist/tui/approval-prompt.js.map +1 -0
- package/dist/tui/client.d.ts +89 -0
- package/dist/tui/client.d.ts.map +1 -0
- package/dist/tui/client.js.map +1 -0
- package/dist/ui/brand-frames-cli.d.ts +19 -0
- package/dist/ui/brand-frames-cli.d.ts.map +1 -0
- package/dist/ui/brand-frames-cli.js +8 -13
- package/dist/ui/brand-frames-cli.js.map +1 -0
- package/dist/ui/brand.d.ts +41 -0
- package/dist/ui/brand.d.ts.map +1 -0
- package/dist/ui/brand.js +28 -6
- package/dist/ui/brand.js.map +1 -0
- package/dist/ui/editor.d.ts +30 -0
- package/dist/ui/editor.d.ts.map +1 -0
- package/dist/ui/editor.js +73 -0
- package/dist/ui/editor.js.map +1 -0
- package/dist/ui/format-session.d.ts +68 -0
- package/dist/ui/format-session.d.ts.map +1 -0
- package/dist/ui/format-session.js +181 -0
- package/dist/ui/format-session.js.map +1 -0
- package/dist/ui/markdown.d.ts +48 -0
- package/dist/ui/markdown.d.ts.map +1 -0
- package/dist/ui/markdown.js +60 -0
- package/dist/ui/markdown.js.map +1 -0
- package/dist/ui/onboard-storage-mode.d.ts +17 -0
- package/dist/ui/onboard-storage-mode.d.ts.map +1 -0
- package/dist/ui/onboard-storage-mode.js +638 -0
- package/dist/ui/onboard-storage-mode.js.map +1 -0
- package/dist/ui/onboarding.d.ts +97 -0
- package/dist/ui/onboarding.d.ts.map +1 -0
- package/dist/ui/onboarding.js +259 -111
- package/dist/ui/onboarding.js.map +1 -0
- package/dist/ui/searchable-select.d.ts +48 -0
- package/dist/ui/searchable-select.d.ts.map +1 -0
- package/dist/ui/searchable-select.js +108 -0
- package/dist/ui/searchable-select.js.map +1 -0
- package/dist/ui/syntax-theme.d.ts +30 -0
- package/dist/ui/syntax-theme.d.ts.map +1 -0
- package/dist/ui/syntax-theme.js +72 -0
- package/dist/ui/syntax-theme.js.map +1 -0
- package/dist/ui/terminal-cleanup.d.ts +46 -0
- package/dist/ui/terminal-cleanup.d.ts.map +1 -0
- package/dist/ui/terminal-cleanup.js +17 -5
- package/dist/ui/terminal-cleanup.js.map +1 -0
- package/dist/ui/theme.d.ts +21 -0
- package/dist/ui/theme.d.ts.map +1 -0
- package/dist/ui/theme.js +66 -2
- package/dist/ui/theme.js.map +1 -0
- package/dist/ui/tool-result.d.ts +47 -0
- package/dist/ui/tool-result.d.ts.map +1 -0
- package/dist/ui/tool-result.js +100 -0
- package/dist/ui/tool-result.js.map +1 -0
- package/dist/utils/delivery-context.d.ts +50 -0
- package/dist/utils/delivery-context.d.ts.map +1 -0
- package/dist/utils/delivery-context.js +82 -0
- package/dist/utils/delivery-context.js.map +1 -0
- package/dist/utils/message-channel.d.ts +60 -0
- package/dist/utils/message-channel.d.ts.map +1 -0
- package/dist/utils/message-channel.js +103 -0
- package/dist/utils/message-channel.js.map +1 -0
- package/dist/utils/string-coerce.d.ts +50 -0
- package/dist/utils/string-coerce.d.ts.map +1 -0
- package/dist/utils/string-coerce.js +101 -0
- package/dist/utils/string-coerce.js.map +1 -0
- package/dist/version.d.ts +20 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +54 -0
- package/dist/version.js.map +1 -0
- package/dist/workspace/bootstrap.d.ts +12 -0
- package/dist/workspace/bootstrap.d.ts.map +1 -0
- package/dist/workspace/bootstrap.js +123 -0
- package/dist/workspace/bootstrap.js.map +1 -0
- package/dist/workspace/fs-utils.d.ts +2 -0
- package/dist/workspace/fs-utils.d.ts.map +1 -0
- package/dist/workspace/fs-utils.js +14 -0
- package/dist/workspace/fs-utils.js.map +1 -0
- package/dist/workspace/git-init.d.ts +5 -0
- package/dist/workspace/git-init.d.ts.map +1 -0
- package/dist/workspace/git-init.js +71 -0
- package/dist/workspace/git-init.js.map +1 -0
- package/dist/workspace/state.d.ts +13 -0
- package/dist/workspace/state.d.ts.map +1 -0
- package/dist/workspace/state.js +128 -0
- package/dist/workspace/state.js.map +1 -0
- package/dist/workspace/template-loader.d.ts +15 -0
- package/dist/workspace/template-loader.d.ts.map +1 -0
- package/dist/workspace/template-loader.js +214 -0
- package/dist/workspace/template-loader.js.map +1 -0
- package/package.json +173 -68
- package/scripts/build-done.mjs +125 -0
- package/scripts/run-brigade.mjs +208 -0
- package/skills/1password/SKILL.md +70 -0
- package/skills/1password/references/cli-examples.md +29 -0
- package/skills/1password/references/get-started.md +17 -0
- package/skills/apple-notes/SKILL.md +77 -0
- package/skills/apple-reminders/SKILL.md +118 -0
- package/skills/bear-notes/SKILL.md +107 -0
- package/skills/blogwatcher/SKILL.md +69 -0
- package/skills/blucli/SKILL.md +47 -0
- package/skills/bluebubbles/SKILL.md +136 -0
- package/skills/camsnap/SKILL.md +45 -0
- package/skills/canvas/SKILL.md +204 -0
- package/skills/coding-agent/SKILL.md +316 -0
- package/skills/discord/SKILL.md +197 -0
- package/skills/eightctl/SKILL.md +50 -0
- package/skills/gemini/SKILL.md +43 -0
- package/skills/gh-issues/SKILL.md +885 -0
- package/skills/gifgrep/SKILL.md +79 -0
- package/skills/git-commit/SKILL.md +40 -0
- package/skills/github/SKILL.md +163 -0
- package/skills/gog/SKILL.md +116 -0
- package/skills/goplaces/SKILL.md +52 -0
- package/skills/healthcheck/SKILL.md +245 -0
- package/skills/himalaya/SKILL.md +257 -0
- package/skills/himalaya/references/configuration.md +184 -0
- package/skills/himalaya/references/message-composition.md +199 -0
- package/skills/imsg/SKILL.md +122 -0
- package/skills/lead-scout/SKILL.md +46 -0
- package/skills/mcporter/SKILL.md +61 -0
- package/skills/model-usage/SKILL.md +69 -0
- package/skills/nano-pdf/SKILL.md +38 -0
- package/skills/node-connect/SKILL.md +142 -0
- package/skills/notion/SKILL.md +174 -0
- package/skills/oauth-setup/SKILL.md +55 -0
- package/skills/obsidian/SKILL.md +81 -0
- package/skills/openai-whisper/SKILL.md +38 -0
- package/skills/openai-whisper-api/SKILL.md +62 -0
- package/skills/openai-whisper-api/scripts/transcribe.sh +88 -0
- package/skills/openhue/SKILL.md +112 -0
- package/skills/oracle/SKILL.md +125 -0
- package/skills/ordercli/SKILL.md +78 -0
- package/skills/peekaboo/SKILL.md +190 -0
- package/skills/sag/SKILL.md +87 -0
- package/skills/session-logs/SKILL.md +151 -0
- package/skills/share-skills/SKILL.md +72 -0
- package/skills/sherpa-onnx-tts/SKILL.md +109 -0
- package/skills/sherpa-onnx-tts/bin/sherpa-onnx-tts +178 -0
- package/skills/skill-creator/SKILL.md +372 -0
- package/skills/skill-creator/license.txt +202 -0
- package/skills/skill-creator/scripts/init_skill.py +378 -0
- package/skills/skill-creator/scripts/package_skill.py +139 -0
- package/skills/skill-creator/scripts/quick_validate.py +159 -0
- package/skills/skill-creator/scripts/test_package_skill.py +160 -0
- package/skills/skill-creator/scripts/test_quick_validate.py +72 -0
- package/skills/slack/SKILL.md +144 -0
- package/skills/songsee/SKILL.md +49 -0
- package/skills/sonoscli/SKILL.md +65 -0
- package/skills/spotify-player/SKILL.md +64 -0
- package/skills/summarize/SKILL.md +87 -0
- package/skills/taskflow/SKILL.md +149 -0
- package/skills/taskflow-inbox-triage/SKILL.md +119 -0
- package/skills/things-mac/SKILL.md +86 -0
- package/skills/tmux/SKILL.md +170 -0
- package/skills/tmux/scripts/find-sessions.sh +112 -0
- package/skills/tmux/scripts/wait-for-text.sh +83 -0
- package/skills/trello/SKILL.md +108 -0
- package/skills/video-frames/SKILL.md +46 -0
- package/skills/video-frames/scripts/frame.sh +81 -0
- package/skills/voice-call/SKILL.md +45 -0
- package/skills/wacli/SKILL.md +72 -0
- package/skills/weather/SKILL.md +129 -0
- package/skills/xurl/SKILL.md +461 -0
- package/templates/workspace/AGENTS.md +223 -0
- package/templates/workspace/BOOTSTRAP.md +64 -0
- package/templates/workspace/HEARTBEAT.md +15 -0
- package/templates/workspace/IDENTITY.md +31 -0
- package/templates/workspace/SOUL.md +47 -0
- package/templates/workspace/TOOLS.md +48 -0
- package/templates/workspace/USER.md +25 -0
- package/CHANGELOG.md +0 -48
- package/SECURITY.md +0 -208
- package/assets/brigade-wordmark.png +0 -0
- package/dist/cli/chat-cmd.js +0 -191
- package/dist/cli/config-cmd.js +0 -171
- package/dist/cli/connect-cmd.js +0 -487
- package/dist/cli/doctor-cmd.js +0 -387
- package/dist/cli/gateway-cmd.js +0 -155
- package/dist/cli.js +0 -328
- package/dist/core/agent.js +0 -1123
- package/dist/core/auth-label.js +0 -147
- package/dist/core/cli-error.js +0 -94
- package/dist/core/error-classifier.js +0 -354
- package/dist/core/provider-payload-mutators.js +0 -517
- package/dist/core/provider-quirks.js +0 -285
- package/dist/core/smart-compaction.js +0 -209
- package/dist/core/system-prompt-defaults.js +0 -264
- package/dist/core/system-prompt-guidance.js +0 -271
- package/dist/index.js +0 -32
- package/dist/ui/brand-frames.js +0 -36
- package/dist/ui/chat.js +0 -1008
|
@@ -0,0 +1,1327 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structured memory records — an append-only JSONL file
|
|
3
|
+
* (`<workspace>/memory/facts.jsonl`). Single-user, so reads scan the whole
|
|
4
|
+
* file and writes are read-modify-write — no concurrency budget to fight.
|
|
5
|
+
*
|
|
6
|
+
* A "memory" here is a structured fact, NOT a raw note: one declarative
|
|
7
|
+
* sentence tagged with a `segment` (what kind of fact) and a `tier` +
|
|
8
|
+
* `importance` + `decayRate` derived from that segment. This is what the
|
|
9
|
+
* post-turn extraction subagent emits and what `write_memory` persists; the
|
|
10
|
+
* lexical recall layer (storage.ts) searches these alongside MEMORY.md +
|
|
11
|
+
* daily notes.
|
|
12
|
+
*
|
|
13
|
+
* Conflict resolution: `supersedes` archives older records, the
|
|
14
|
+
* `correction` segment overturns a prior belief, and a decay GC ages out
|
|
15
|
+
* neglected facts. (A heavier 3-LLM consolidation debate is intentionally
|
|
16
|
+
* NOT done in v1 — supersede + decay cover the common cases.)
|
|
17
|
+
*/
|
|
18
|
+
import * as fs from "node:fs";
|
|
19
|
+
import * as path from "node:path";
|
|
20
|
+
// Host seams (logger / convex cache / runtime-mode probe / write-time threat-scan)
|
|
21
|
+
// are routed through ONE swappable module — `./host-ports.js` — so the core has zero
|
|
22
|
+
// `../../` host imports and stays extractable. Brigade's host-ports forwards to the
|
|
23
|
+
// real modules (pure indirection, no behavior change); a standalone publish swaps it
|
|
24
|
+
// for an fs-only build. See host-ports.ts.
|
|
25
|
+
import { createSubsystemLogger, getCachedFacts, MemoryThreatError, primeFactsCache, scanForThreats, tryGetRuntimeContext, workspaceIdFromDir, writeThroughFactsCache, } from "./host-ports.js";
|
|
26
|
+
import { bm25Score, tokenize } from "./scoring.js";
|
|
27
|
+
import { evaluateWriteGate, isTrustedTarget, isUntrustedSource, WriteGateError } from "./write-gate.js";
|
|
28
|
+
import { inverseLinkKind } from "./links.js";
|
|
29
|
+
import { MemoryEventLog } from "./event-log.js";
|
|
30
|
+
import { cosine, getDefaultEmbedder } from "./embedder.js";
|
|
31
|
+
import { recallHybrid, recallHybridAsync } from "./hybrid.js";
|
|
32
|
+
/** Runtime list of every {@link MemorySourceType} — for validating
|
|
33
|
+
* externally-loaded data (e.g. the real-data gold path, where a typo'd source
|
|
34
|
+
* would otherwise be silently treated as TRUSTED by the write-gate). The
|
|
35
|
+
* `satisfies` clause makes a typo/extra value a COMPILE error; keep in sync with
|
|
36
|
+
* the type above if a source is ever added. */
|
|
37
|
+
export const MEMORY_SOURCE_TYPES = [
|
|
38
|
+
"user_instruction",
|
|
39
|
+
"owner_message",
|
|
40
|
+
"channel_message",
|
|
41
|
+
"tool_output",
|
|
42
|
+
"retrieved_document",
|
|
43
|
+
"compaction",
|
|
44
|
+
"extraction",
|
|
45
|
+
"dream",
|
|
46
|
+
];
|
|
47
|
+
/**
|
|
48
|
+
* Per-segment defaults. `identity` is the most durable (permanent, slow
|
|
49
|
+
* decay); `context` the most ephemeral (short tier, fast decay).
|
|
50
|
+
*/
|
|
51
|
+
export const SEGMENT_DEFAULTS = {
|
|
52
|
+
identity: { tier: "permanent", importance: 0.85, decayRate: 0.01 },
|
|
53
|
+
correction: { tier: "long", importance: 0.8, decayRate: 0.015 },
|
|
54
|
+
relationship: { tier: "long", importance: 0.75, decayRate: 0.02 },
|
|
55
|
+
preference: { tier: "long", importance: 0.7, decayRate: 0.02 },
|
|
56
|
+
project: { tier: "long", importance: 0.65, decayRate: 0.025 },
|
|
57
|
+
knowledge: { tier: "long", importance: 0.6, decayRate: 0.03 },
|
|
58
|
+
context: { tier: "short", importance: 0.4, decayRate: 0.08 },
|
|
59
|
+
};
|
|
60
|
+
export const MEMORY_SEGMENTS = Object.keys(SEGMENT_DEFAULTS);
|
|
61
|
+
/** Relative path of the structured fact store within a workspace. */
|
|
62
|
+
export const FACTS_RELATIVE_PATH = path.join("memory", "facts.jsonl");
|
|
63
|
+
const driftLog = createSubsystemLogger("memory/records");
|
|
64
|
+
/**
|
|
65
|
+
* Hard cap on a single fact's content. A fact is meant to be one sentence;
|
|
66
|
+
* this stops a misbehaving model (or pasted blob) from writing a megabyte
|
|
67
|
+
* "fact" that then bloats the always-read JSONL AND every auto-recall
|
|
68
|
+
* injection. Generous enough for any legitimate fact.
|
|
69
|
+
*/
|
|
70
|
+
export const MAX_FACT_CONTENT_CHARS = 1000;
|
|
71
|
+
/**
|
|
72
|
+
* Jaccard-similarity threshold above which two facts are treated as the same
|
|
73
|
+
* at write time (dedup). Deliberately HIGH (0.85) so only near-identical
|
|
74
|
+
* restatements collapse — distinct facts that merely share words (e.g. two
|
|
75
|
+
* different facts about the same topic) are kept separate.
|
|
76
|
+
*/
|
|
77
|
+
export const DEDUP_SIMILARITY = 0.85;
|
|
78
|
+
/**
|
|
79
|
+
* Idempotency bars for "is this extracted fact ALREADY known?" — looser than the
|
|
80
|
+
* write-time {@link DEDUP_SIMILARITY} because post-turn extraction REWORDS a fact
|
|
81
|
+
* the operator already taught (a paraphrase scores well below 0.85 on both lanes:
|
|
82
|
+
* measured ≈0.4–0.64 cosine / ≈0.2–0.6 Jaccard for real restatements). These bars
|
|
83
|
+
* apply ONLY when the existing candidate is SUBJECT-BEARING — the single-valued
|
|
84
|
+
* facts (`diet`, `ui_theme`, …) extraction must not churn a subject-less twin
|
|
85
|
+
* beside — so the looseness can't suppress an ADDITIVE fact (pets, skills: no
|
|
86
|
+
* subjectKey ⇒ they fall back to the strict {@link DEDUP_SIMILARITY} near-exact
|
|
87
|
+
* bar). Empirically these cleanly separate real restatements from distinct facts.
|
|
88
|
+
*/
|
|
89
|
+
export const IDEMPOTENT_COSINE_BAR = 0.45;
|
|
90
|
+
export const IDEMPOTENT_JACCARD_BAR = 0.4;
|
|
91
|
+
/** CONTENT-token SET of a fact (for dedup + slot-restate detection). Uses the
|
|
92
|
+
* SAME stopword-stripping tokenizer as recall (scoring.ts `tokenize`) so similarity
|
|
93
|
+
* is measured on MEANINGFUL tokens, not sentence scaffolding — a shared frame like
|
|
94
|
+
* "the user prefers to use the …" must not inflate overlap (it was inflating it to
|
|
95
|
+
* the point of wrongly superseding unrelated facts). One tokenizer, one basis. */
|
|
96
|
+
function tokenSet(content) {
|
|
97
|
+
return new Set(tokenize(content));
|
|
98
|
+
}
|
|
99
|
+
/** Normalize an attribute SLOT key: lowercase, non-alphanumeric runs → "_",
|
|
100
|
+
* trimmed of edge underscores. So "Deploy Day" / "deploy-day" / "deploy_day"
|
|
101
|
+
* all collapse to one slot, maximizing supersede matches across phrasings. */
|
|
102
|
+
function normalizeSubjectKey(raw) {
|
|
103
|
+
// Unicode-aware (lockstep with scoring.ts tokenize + embedder features): a
|
|
104
|
+
// non-Latin attribute name (e.g. a CJK/Cyrillic slot) keeps its characters
|
|
105
|
+
// instead of collapsing to empty, so same-slot supersede works across scripts.
|
|
106
|
+
return raw
|
|
107
|
+
.toLowerCase()
|
|
108
|
+
.replace(/[^\p{L}\p{N}]+/gu, "_")
|
|
109
|
+
.replace(/^_+|_+$/g, "");
|
|
110
|
+
}
|
|
111
|
+
/** Jaccard similarity |A∩B| / |A∪B| of two token sets (0 when both empty). */
|
|
112
|
+
function jaccard(a, b) {
|
|
113
|
+
if (a.size === 0 && b.size === 0)
|
|
114
|
+
return 0;
|
|
115
|
+
let inter = 0;
|
|
116
|
+
for (const t of a)
|
|
117
|
+
if (b.has(t))
|
|
118
|
+
inter += 1;
|
|
119
|
+
const union = a.size + b.size - inter;
|
|
120
|
+
return union === 0 ? 0 : inter / union;
|
|
121
|
+
}
|
|
122
|
+
/** Token-set Jaccard over two raw contents (the dedup/idempotency basis — same
|
|
123
|
+
* tokenizer as recall). Exposed so the extraction-idempotency check (extract.ts)
|
|
124
|
+
* measures "already-known" with the IDENTICAL near-duplicate basis the write-time
|
|
125
|
+
* dedup uses, instead of re-deriving a divergent one. */
|
|
126
|
+
export function contentSimilarity(a, b) {
|
|
127
|
+
return jaccard(tokenSet(a), tokenSet(b));
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Segment SPECIFICITY rank — higher = more specific / more authoritative about
|
|
131
|
+
* the operator's self-model. Drives "richest wins" so a reworded, subject-less
|
|
132
|
+
* `knowledge` copy emitted by post-turn extraction can never out-rank the
|
|
133
|
+
* `identity`/`preference`/`correction` original the operator actually taught.
|
|
134
|
+
* The authoritative self-model segments (the write-gate's PROTECTED set) sit at
|
|
135
|
+
* the top; descriptive/situational segments below; generic `knowledge` (the
|
|
136
|
+
* confinement target extraction lands in) is the floor with `context`.
|
|
137
|
+
*/
|
|
138
|
+
const SEGMENT_SPECIFICITY = {
|
|
139
|
+
identity: 5,
|
|
140
|
+
correction: 5,
|
|
141
|
+
preference: 5,
|
|
142
|
+
relationship: 3,
|
|
143
|
+
project: 3,
|
|
144
|
+
context: 1,
|
|
145
|
+
knowledge: 1,
|
|
146
|
+
};
|
|
147
|
+
/** The fields that make one record "richer" than a near-identical twin, in
|
|
148
|
+
* precedence order. A higher tuple wins; ties fall through to the next field.
|
|
149
|
+
* Recency is INTENTIONALLY NOT here — a fresher restatement must not beat a
|
|
150
|
+
* metadata-bearing original (the bug this fixes). The caller breaks a true
|
|
151
|
+
* all-equal tie by recency for stability. */
|
|
152
|
+
function richnessTuple(r) {
|
|
153
|
+
return [
|
|
154
|
+
r.subjectKey ? 1 : 0, // a subject-bearing fact anchors a vault hub — keep it
|
|
155
|
+
SEGMENT_SPECIFICITY[r.segment] ?? 0, // identity/preference/correction beat knowledge
|
|
156
|
+
typeof r.confidence === "number" ? r.confidence : 0, // more-confident wins
|
|
157
|
+
r.importance, // then importance
|
|
158
|
+
r.accessCount, // then confirmations (recall reinforcement / reasserts)
|
|
159
|
+
];
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Compare two records by metadata RICHNESS (NOT recency). Returns >0 when `a` is
|
|
163
|
+
* richer, <0 when `b` is, 0 when equal on every richness field. This is the
|
|
164
|
+
* survivor-selection ordering for every dedup / supersede / consolidation merge:
|
|
165
|
+
* the SURVIVING record must be the richest one, so a subject-less reworded copy
|
|
166
|
+
* never archives a subject-bearing `identity`/`preference` original.
|
|
167
|
+
*/
|
|
168
|
+
export function compareRichness(a, b) {
|
|
169
|
+
const ta = richnessTuple(a);
|
|
170
|
+
const tb = richnessTuple(b);
|
|
171
|
+
for (let i = 0; i < ta.length; i++) {
|
|
172
|
+
if (ta[i] !== tb[i])
|
|
173
|
+
return ta[i] - tb[i];
|
|
174
|
+
}
|
|
175
|
+
return 0;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Of two near-identical records, the one that should SURVIVE a merge: the richer
|
|
179
|
+
* by {@link compareRichness}; an exact richness tie breaks to the NEWER record
|
|
180
|
+
* (a genuine restatement refreshes the belief). Pure — picks, never mutates.
|
|
181
|
+
*/
|
|
182
|
+
export function richerSurvivor(a, b) {
|
|
183
|
+
const byRichness = compareRichness(a, b);
|
|
184
|
+
if (byRichness !== 0)
|
|
185
|
+
return byRichness > 0 ? a : b;
|
|
186
|
+
return a.createdAt >= b.createdAt ? a : b;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Fold the RICHER metadata of `loser` into `survivor`, in place — so collapsing a
|
|
190
|
+
* near-duplicate pair never DROPS hard-won metadata even when the survivor was the
|
|
191
|
+
* sparser record. Each field takes the more-informative value across BOTH records:
|
|
192
|
+
* a present `subjectKey` is never lost to none; the more-specific segment is kept;
|
|
193
|
+
* importance / confidence / accessCount take the max; `sourceTurn` / `validFrom`
|
|
194
|
+
* backfill if missing; links union (deduped). Provenance (`sourceType`, `createdBy`)
|
|
195
|
+
* is NOT merged — those are identity/trust, not richness, and the survivor keeps its
|
|
196
|
+
* own. Returns `survivor` for chaining. Mutates `survivor` only.
|
|
197
|
+
*/
|
|
198
|
+
export function inheritRicherMetadata(survivor, loser) {
|
|
199
|
+
// subjectKey — a subject anchor must never be lost to none (the vault-hub key).
|
|
200
|
+
if (!survivor.subjectKey && loser.subjectKey)
|
|
201
|
+
survivor.subjectKey = loser.subjectKey;
|
|
202
|
+
// segment — keep the more-specific of the two (identity/preference beat knowledge).
|
|
203
|
+
if ((SEGMENT_SPECIFICITY[loser.segment] ?? 0) > (SEGMENT_SPECIFICITY[survivor.segment] ?? 0)) {
|
|
204
|
+
survivor.segment = loser.segment;
|
|
205
|
+
// Re-base the segment-derived durability so a promoted segment isn't left with
|
|
206
|
+
// the weaker tier/decay of the segment it replaced (importance is maxed below).
|
|
207
|
+
const d = SEGMENT_DEFAULTS[survivor.segment] ?? SEGMENT_DEFAULTS.context;
|
|
208
|
+
survivor.tier = d.tier;
|
|
209
|
+
survivor.decayRate = d.decayRate;
|
|
210
|
+
}
|
|
211
|
+
survivor.importance = Math.max(survivor.importance, loser.importance);
|
|
212
|
+
if (typeof loser.confidence === "number") {
|
|
213
|
+
survivor.confidence = Math.max(survivor.confidence ?? 0, loser.confidence);
|
|
214
|
+
}
|
|
215
|
+
survivor.accessCount = Math.max(survivor.accessCount, loser.accessCount);
|
|
216
|
+
if (!survivor.sourceTurn && loser.sourceTurn)
|
|
217
|
+
survivor.sourceTurn = loser.sourceTurn;
|
|
218
|
+
if (survivor.validFrom === undefined && loser.validFrom !== undefined)
|
|
219
|
+
survivor.validFrom = loser.validFrom;
|
|
220
|
+
// Links union, deduped by kind|target (don't carry an edge that points at the
|
|
221
|
+
// survivor itself — a self-loop from a mirrored supersede).
|
|
222
|
+
if (loser.links && loser.links.length > 0) {
|
|
223
|
+
const seen = new Set((survivor.links ?? []).map((l) => `${l.kind}|${l.target}`));
|
|
224
|
+
const merged = [...(survivor.links ?? [])];
|
|
225
|
+
for (const l of loser.links) {
|
|
226
|
+
const key = `${l.kind}|${l.target}`;
|
|
227
|
+
if (l.target === survivor.memoryId || seen.has(key))
|
|
228
|
+
continue;
|
|
229
|
+
seen.add(key);
|
|
230
|
+
merged.push(l);
|
|
231
|
+
}
|
|
232
|
+
if (merged.length > 0)
|
|
233
|
+
survivor.links = merged;
|
|
234
|
+
}
|
|
235
|
+
return survivor;
|
|
236
|
+
}
|
|
237
|
+
/** `mem_<base36 time>_<rand>` — a time-sortable id shape. */
|
|
238
|
+
export function makeMemoryId() {
|
|
239
|
+
return `mem_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 8)}`;
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Treat a missing origin as owner (back-compat with records persisted
|
|
243
|
+
* before ownership tracking shipped). All recall + dedup logic should
|
|
244
|
+
* route through this helper rather than reading `createdBy` directly so
|
|
245
|
+
* the legacy default stays in one place.
|
|
246
|
+
*/
|
|
247
|
+
export function resolveRecordOrigin(origin) {
|
|
248
|
+
return origin ?? { kind: "owner" };
|
|
249
|
+
}
|
|
250
|
+
/** Origin-isolation bucket key. Owner (and legacy/undefined-origin) facts share
|
|
251
|
+
* one bucket; each channel peer (channelId+conversationId+sessionKey) is its
|
|
252
|
+
* OWN bucket — so any cross-fact operation (consolidation, dream merges) can
|
|
253
|
+
* group by this and never mix origins. The canonical key; consolidate.ts +
|
|
254
|
+
* dream.ts + FactStore.distinctOrigins all route through it. */
|
|
255
|
+
export function originBucketKey(r) {
|
|
256
|
+
const o = resolveRecordOrigin(r.createdBy);
|
|
257
|
+
if (o.kind !== "channel")
|
|
258
|
+
return "owner";
|
|
259
|
+
// JSON-encode the tuple so a ':' INSIDE a component (a WhatsApp JID conversationId,
|
|
260
|
+
// the ':'-structured sessionKey) can't shift the delimiter and collide two DISTINCT
|
|
261
|
+
// origins into ONE bucket (a cross-principal merge in dream/consolidate). accountId
|
|
262
|
+
// is in the key so two operator accounts of the same channel stay distinct origins.
|
|
263
|
+
return `channel:${JSON.stringify([o.channelId ?? "", o.accountId ?? "", o.conversationId ?? "", o.sessionKey ?? ""])}`;
|
|
264
|
+
}
|
|
265
|
+
/** Two origins are the same when both fields-by-fields match. */
|
|
266
|
+
export function sameOrigin(a, b) {
|
|
267
|
+
const resolvedA = resolveRecordOrigin(a);
|
|
268
|
+
const resolvedB = resolveRecordOrigin(b);
|
|
269
|
+
if (resolvedA.kind !== resolvedB.kind)
|
|
270
|
+
return false;
|
|
271
|
+
if (resolvedA.kind === "owner")
|
|
272
|
+
return true;
|
|
273
|
+
const channelA = resolvedA;
|
|
274
|
+
const channelB = resolvedB;
|
|
275
|
+
return (channelA.channelId === channelB.channelId &&
|
|
276
|
+
(channelA.accountId ?? "") === (channelB.accountId ?? "") &&
|
|
277
|
+
channelA.conversationId === channelB.conversationId &&
|
|
278
|
+
channelA.sessionKey === channelB.sessionKey);
|
|
279
|
+
}
|
|
280
|
+
/** True if the record matches the filter. `undefined` filter matches every record. */
|
|
281
|
+
export function recordMatchesOriginFilter(record, filter) {
|
|
282
|
+
if (filter === undefined)
|
|
283
|
+
return true;
|
|
284
|
+
return sameOrigin(record.createdBy, filter);
|
|
285
|
+
}
|
|
286
|
+
/** Clamp to [0,1], falling back to `fallback` when not a finite number. */
|
|
287
|
+
export function clampImportance(value, fallback) {
|
|
288
|
+
if (typeof value !== "number" || !Number.isFinite(value))
|
|
289
|
+
return fallback;
|
|
290
|
+
return Math.max(0, Math.min(1, value));
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Append-only-ish JSONL fact store. "Mutations" (markAccessed / supersede /
|
|
294
|
+
* setLifecycle / decay) are read-modify-write of the whole file — fine at
|
|
295
|
+
* single-user scale, and atomic via tmp+rename so a crash never leaves a
|
|
296
|
+
* half-written store.
|
|
297
|
+
*/
|
|
298
|
+
export class FactStore {
|
|
299
|
+
file;
|
|
300
|
+
/** Injectable wall-clock. Defaults to `Date.now`; the eval pins it (e.g. `() => 0`)
|
|
301
|
+
* so write-time `createdAt` AND score-time `now` share ONE deterministic clock —
|
|
302
|
+
* otherwise decay over the (load-dependent) gap between seeding and recall makes
|
|
303
|
+
* the hybrid/decay lanes non-reproducible. Production passes nothing → `Date.now`. */
|
|
304
|
+
clock;
|
|
305
|
+
eventLogCache;
|
|
306
|
+
/** Did the most recent readAll SKIP any non-empty line (unparseable JSON or an
|
|
307
|
+
* invalid record shape)? Such content — a hand-edit, a torn/concurrent write, a
|
|
308
|
+
* partial sync — would be silently DROPPED by the next writeAll (which rewrites
|
|
309
|
+
* only the parsed records). When set, writeAll snapshots the file to a `.bak`
|
|
310
|
+
* first so the skipped content stays recoverable. */
|
|
311
|
+
lastReadHadUnparseable = false;
|
|
312
|
+
constructor(workspaceDir, opts = {}) {
|
|
313
|
+
this.file = path.join(workspaceDir, FACTS_RELATIVE_PATH);
|
|
314
|
+
this.clock = opts.now ?? (() => Date.now());
|
|
315
|
+
}
|
|
316
|
+
/** Absolute path to the JSONL file (for diagnostics). */
|
|
317
|
+
get filePath() {
|
|
318
|
+
return this.file;
|
|
319
|
+
}
|
|
320
|
+
/** The append-only event log (sibling `events.jsonl` of the facts file). */
|
|
321
|
+
eventLog() {
|
|
322
|
+
if (!this.eventLogCache) {
|
|
323
|
+
this.eventLogCache = new MemoryEventLog(path.join(path.dirname(this.file), "events.jsonl"));
|
|
324
|
+
}
|
|
325
|
+
return this.eventLogCache;
|
|
326
|
+
}
|
|
327
|
+
/** Emit a provenance event. Filesystem mode appends to `events.jsonl`; convex mode
|
|
328
|
+
* appends to the convex audit trail via the OPTIONAL `appendMemoryEvent` store hook
|
|
329
|
+
* (best-effort + fire-and-forget — an audit-log write must never fail a memory
|
|
330
|
+
* write, and the log is additive, never affecting recall). When the hook is absent
|
|
331
|
+
* (a backend without the convex events table yet) it degrades to no audit trail. */
|
|
332
|
+
emit(event) {
|
|
333
|
+
const rctx = tryGetRuntimeContext();
|
|
334
|
+
if (rctx?.mode === "convex") {
|
|
335
|
+
const append = rctx.store.memory.appendMemoryEvent;
|
|
336
|
+
if (append) {
|
|
337
|
+
const wsId = workspaceIdFromDir(path.dirname(path.dirname(this.file)));
|
|
338
|
+
void append.call(rctx.store.memory, wsId, event).catch(() => { });
|
|
339
|
+
}
|
|
340
|
+
return;
|
|
341
|
+
}
|
|
342
|
+
this.eventLog().append(event);
|
|
343
|
+
}
|
|
344
|
+
/** The append-only provenance history. SYNC — filesystem only (convex reads are
|
|
345
|
+
* async; use {@link readEventsAsync}). Empty in convex mode. Ordered oldest-first. */
|
|
346
|
+
readEvents() {
|
|
347
|
+
if (tryGetRuntimeContext()?.mode === "convex")
|
|
348
|
+
return [];
|
|
349
|
+
return this.eventLog().readAll();
|
|
350
|
+
}
|
|
351
|
+
/** The append-only provenance history, working in BOTH modes — fs reads
|
|
352
|
+
* `events.jsonl`; convex reads the audit trail via the optional `listMemoryEvents`
|
|
353
|
+
* store hook (empty when the hook is absent). Ordered oldest-first. */
|
|
354
|
+
async readEventsAsync() {
|
|
355
|
+
const rctx = tryGetRuntimeContext();
|
|
356
|
+
if (rctx?.mode === "convex") {
|
|
357
|
+
const list = rctx.store.memory.listMemoryEvents;
|
|
358
|
+
if (!list)
|
|
359
|
+
return [];
|
|
360
|
+
const wsId = workspaceIdFromDir(path.dirname(path.dirname(this.file)));
|
|
361
|
+
return (await list.call(rctx.store.memory, wsId));
|
|
362
|
+
}
|
|
363
|
+
return this.eventLog().readAll();
|
|
364
|
+
}
|
|
365
|
+
/** Read every record. Malformed lines are skipped (never throws on a bad line). */
|
|
366
|
+
readAll() {
|
|
367
|
+
// Convex mode — serve from the boot-hydrated per-workspace cache. An
|
|
368
|
+
// unprimed workspace genuinely has no facts (boot hydrates every
|
|
369
|
+
// config agent's workspace + main); prime the empty shape so later
|
|
370
|
+
// writes diff against it.
|
|
371
|
+
const rctx = tryGetRuntimeContext();
|
|
372
|
+
if (rctx?.mode === "convex") {
|
|
373
|
+
const wsId = workspaceIdFromDir(path.dirname(path.dirname(this.file)));
|
|
374
|
+
const cached = getCachedFacts(wsId);
|
|
375
|
+
if (cached)
|
|
376
|
+
return structuredClone(cached);
|
|
377
|
+
// MISS SELF-HEAL: a workspace that wasn't boot-hydrated (a key mismatch, an
|
|
378
|
+
// agent added AFTER boot, or a hydration race) would otherwise read EMPTY
|
|
379
|
+
// forever. Prime [] for this synchronous read, but kick off a one-shot backfill
|
|
380
|
+
// so the NEXT read serves the real rows instead of permanent amnesia. Guarded
|
|
381
|
+
// (a fake store may omit the method). Best-effort.
|
|
382
|
+
primeFactsCache(wsId, []);
|
|
383
|
+
if (typeof rctx.store.memory.listAllFactRecordsRaw === "function") {
|
|
384
|
+
void rctx.store.memory
|
|
385
|
+
.listAllFactRecordsRaw(wsId)
|
|
386
|
+
.then((records) => {
|
|
387
|
+
if (records.length === 0)
|
|
388
|
+
return;
|
|
389
|
+
// MERGE, don't clobber: a write that landed DURING the fetch must not be
|
|
390
|
+
// lost (priming the fetched rows over it would drop it), and the
|
|
391
|
+
// pre-existing rows must not be lost either. Backfilled rows fill the
|
|
392
|
+
// cache; any locally-written row WINS on memoryId conflict.
|
|
393
|
+
const byId = new Map(records.map((r) => [r.memoryId, r]));
|
|
394
|
+
for (const local of getCachedFacts(wsId) ?? [])
|
|
395
|
+
byId.set(local.memoryId, local);
|
|
396
|
+
primeFactsCache(wsId, [...byId.values()]);
|
|
397
|
+
})
|
|
398
|
+
.catch(() => { });
|
|
399
|
+
}
|
|
400
|
+
return [];
|
|
401
|
+
}
|
|
402
|
+
let raw;
|
|
403
|
+
try {
|
|
404
|
+
raw = fs.readFileSync(this.file, "utf8");
|
|
405
|
+
}
|
|
406
|
+
catch {
|
|
407
|
+
return [];
|
|
408
|
+
}
|
|
409
|
+
const out = [];
|
|
410
|
+
let nonEmpty = 0;
|
|
411
|
+
for (const line of raw.split("\n")) {
|
|
412
|
+
const trimmed = line.trim();
|
|
413
|
+
if (!trimmed)
|
|
414
|
+
continue;
|
|
415
|
+
nonEmpty++;
|
|
416
|
+
try {
|
|
417
|
+
const rec = JSON.parse(trimmed);
|
|
418
|
+
if (rec && typeof rec.memoryId === "string" && typeof rec.content === "string") {
|
|
419
|
+
out.push(rec);
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
catch {
|
|
423
|
+
// Skip a corrupt line rather than failing the whole read.
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
// Flag for the drift guard: any non-empty line we couldn't turn into a record
|
|
427
|
+
// is content the next writeAll would silently drop — snapshot before that.
|
|
428
|
+
this.lastReadHadUnparseable = nonEmpty > out.length;
|
|
429
|
+
return out;
|
|
430
|
+
}
|
|
431
|
+
/** Active records, optionally filtered, most-recent-first, capped by `limit`. */
|
|
432
|
+
list(filter = {}) {
|
|
433
|
+
const lifecycle = filter.lifecycle ?? "active";
|
|
434
|
+
let recs = this.readAll().filter((r) => r.lifecycle === lifecycle);
|
|
435
|
+
if (filter.segment)
|
|
436
|
+
recs = recs.filter((r) => r.segment === filter.segment);
|
|
437
|
+
if (filter.origin !== undefined) {
|
|
438
|
+
recs = recs.filter((r) => recordMatchesOriginFilter(r, filter.origin));
|
|
439
|
+
}
|
|
440
|
+
recs.sort((a, b) => b.createdAt - a.createdAt);
|
|
441
|
+
return filter.limit && filter.limit > 0 ? recs.slice(0, filter.limit) : recs;
|
|
442
|
+
}
|
|
443
|
+
/**
|
|
444
|
+
* Persist a new fact. Derives tier/importance/decay from the segment
|
|
445
|
+
* defaults (writer may override tier/importance). Archives any `supersedes`
|
|
446
|
+
* targets. Returns the stored record.
|
|
447
|
+
*/
|
|
448
|
+
write(fact) {
|
|
449
|
+
const defaults = SEGMENT_DEFAULTS[fact.segment] ?? SEGMENT_DEFAULTS.context;
|
|
450
|
+
const now = this.clock();
|
|
451
|
+
const record = {
|
|
452
|
+
memoryId: makeMemoryId(),
|
|
453
|
+
content: fact.content.trim().slice(0, MAX_FACT_CONTENT_CHARS),
|
|
454
|
+
segment: fact.segment,
|
|
455
|
+
tier: fact.tier ?? defaults.tier,
|
|
456
|
+
importance: clampImportance(fact.importance, defaults.importance),
|
|
457
|
+
decayRate: defaults.decayRate,
|
|
458
|
+
accessCount: 0,
|
|
459
|
+
lastAccessedAt: now,
|
|
460
|
+
createdAt: now,
|
|
461
|
+
sourceTurn: fact.sourceTurn,
|
|
462
|
+
supersedes: fact.supersedes && fact.supersedes.length > 0 ? fact.supersedes : undefined,
|
|
463
|
+
lifecycle: "active",
|
|
464
|
+
...(fact.createdBy !== undefined ? { createdBy: fact.createdBy } : {}),
|
|
465
|
+
...(fact.sourceType !== undefined ? { sourceType: fact.sourceType } : {}),
|
|
466
|
+
...(fact.links !== undefined && fact.links.length > 0 ? { links: fact.links } : {}),
|
|
467
|
+
...(fact.validFrom !== undefined ? { validFrom: fact.validFrom } : {}),
|
|
468
|
+
...(fact.validTo !== undefined ? { validTo: fact.validTo } : {}),
|
|
469
|
+
...(fact.confidence !== undefined ? { confidence: fact.confidence } : {}),
|
|
470
|
+
...(fact.status !== undefined ? { status: fact.status } : {}),
|
|
471
|
+
...(fact.sourcePointers !== undefined && fact.sourcePointers.length > 0
|
|
472
|
+
? { sourcePointers: fact.sourcePointers }
|
|
473
|
+
: {}),
|
|
474
|
+
...(fact.modality !== undefined ? { modality: fact.modality } : {}),
|
|
475
|
+
...(fact.mediaPointer !== undefined ? { mediaPointer: fact.mediaPointer } : {}),
|
|
476
|
+
...(fact.subjectKey && fact.subjectKey.trim() ? { subjectKey: normalizeSubjectKey(fact.subjectKey) } : {}),
|
|
477
|
+
metadata: fact.metadata,
|
|
478
|
+
};
|
|
479
|
+
const all = this.readAll();
|
|
480
|
+
// Write-gate (Tideline Step 12) — an UNTRUSTED source (tool_output /
|
|
481
|
+
// retrieved_document) must not poison the authoritative store: it can't
|
|
482
|
+
// author an identity/preference/correction fact, nor supersede an
|
|
483
|
+
// owner-authored one. Dormant for trusted/legacy writes (sourceType
|
|
484
|
+
// undefined). Evaluated BEFORE any mutation so a blocked write is a
|
|
485
|
+
// clean no-op (throws WriteGateError; the caller surfaces it).
|
|
486
|
+
if (isUntrustedSource(record.sourceType)) {
|
|
487
|
+
const supersedeIds = new Set(record.supersedes ?? []);
|
|
488
|
+
const verdict = evaluateWriteGate({
|
|
489
|
+
sourceType: record.sourceType,
|
|
490
|
+
segment: record.segment,
|
|
491
|
+
supersedeTargets: all
|
|
492
|
+
// Match the origin-gated archive loop below (~line 791): a cross-origin
|
|
493
|
+
// supersede silently no-ops there, so the gate must NOT hard-block on it —
|
|
494
|
+
// only same-origin targets are real supersede candidates to evaluate.
|
|
495
|
+
.filter((r) => supersedeIds.has(r.memoryId) && sameOrigin(r.createdBy, record.createdBy))
|
|
496
|
+
.map((r) => ({ memoryId: r.memoryId, sourceType: r.sourceType })),
|
|
497
|
+
});
|
|
498
|
+
if (!verdict.allow) {
|
|
499
|
+
this.emit({
|
|
500
|
+
at: now,
|
|
501
|
+
kind: "blocked",
|
|
502
|
+
memoryId: record.memoryId,
|
|
503
|
+
segment: record.segment,
|
|
504
|
+
...(record.sourceType !== undefined ? { sourceType: record.sourceType } : {}),
|
|
505
|
+
reason: verdict.reason,
|
|
506
|
+
});
|
|
507
|
+
throw new WriteGateError(verdict.reason);
|
|
508
|
+
}
|
|
509
|
+
// CONTENT threat-scan — the write-gate above confines WHICH segment an
|
|
510
|
+
// untrusted source may author (provenance); this confines WHAT the text
|
|
511
|
+
// SAYS. An untrusted source may legitimately write `knowledge`, so an
|
|
512
|
+
// injection/exfil/C2 payload ("ignore prior instructions…", a beacon, an
|
|
513
|
+
// exfil curl) can ride a permitted write — block it at the source so it
|
|
514
|
+
// never persists. Owner/model-authored writes are NOT content-blocked here
|
|
515
|
+
// (the owner is trusted; the recall-time scan is the net for owner-pasted
|
|
516
|
+
// attacker text). Evaluated pre-mutation → a blocked write is a clean no-op.
|
|
517
|
+
const threats = scanForThreats(record.content, "strict");
|
|
518
|
+
if (threats.length > 0) {
|
|
519
|
+
this.emit({
|
|
520
|
+
at: now,
|
|
521
|
+
kind: "blocked",
|
|
522
|
+
memoryId: record.memoryId,
|
|
523
|
+
segment: record.segment,
|
|
524
|
+
...(record.sourceType !== undefined ? { sourceType: record.sourceType } : {}),
|
|
525
|
+
reason: `content matched threat pattern(s): ${threats.join(", ")}`,
|
|
526
|
+
});
|
|
527
|
+
throw new MemoryThreatError(threats);
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
// SUPERSEDE the prior belief(s) this write replaces — WITHOUT relying on the
|
|
531
|
+
// model recalling ids. Trigger: an explicit attribute SLOT (subjectKey) →
|
|
532
|
+
// supersede same-slot, same-origin values (precise; segment-independent — a
|
|
533
|
+
// `correction` supersedes a `preference`). Soft-archive (bi-temporal close +
|
|
534
|
+
// `contradicts`/`transition` link), history kept. A near-identical prior
|
|
535
|
+
// (restated, not changed) is reinforced, not churned. An UNTRUSTED source can't
|
|
536
|
+
// archive a TRUSTED prior (the write-gate override guard).
|
|
537
|
+
//
|
|
538
|
+
// We deliberately do NOT auto-supersede by CONTENT overlap: a slot-less
|
|
539
|
+
// `correction` shares a sentence frame with unrelated facts, and (MEASURED) no
|
|
540
|
+
// overlap threshold separates a same-subject value change ("deploys Fridays"→
|
|
541
|
+
// "Mondays", ≈0.5) from a DIFFERENT-subject one ("dark theme editor"→"light
|
|
542
|
+
// theme terminal", ≈0.5) — they fully overlap, so the old content gate silently
|
|
543
|
+
// archived still-true facts (data loss). A slot-less correction now COEXISTS
|
|
544
|
+
// with the prior (freshest wins at recall; dream consolidates near-duplicates);
|
|
545
|
+
// to auto-replace a single-valued attribute, the writer sets a `subjectKey`.
|
|
546
|
+
const slotSuperseded = [];
|
|
547
|
+
if (record.subjectKey && !record.supersedes) {
|
|
548
|
+
const incoming = tokenSet(record.content);
|
|
549
|
+
const priors = all.filter((r) => r.lifecycle === "active" &&
|
|
550
|
+
r.memoryId !== record.memoryId &&
|
|
551
|
+
sameOrigin(r.createdBy, record.createdBy) &&
|
|
552
|
+
r.subjectKey === record.subjectKey);
|
|
553
|
+
// Same write-gate guard as the archive loop + dedup below: an
|
|
554
|
+
// UNTRUSTED source must not reinforce (bump importance / refresh
|
|
555
|
+
// access on) a TRUSTED, owner-authored prior through this restate
|
|
556
|
+
// back door — that's an unsuperseded mutation the write-gate never
|
|
557
|
+
// sees. When incoming is untrusted and the match is trusted, it
|
|
558
|
+
// falls through to a separate record, leaving the owner fact as-is.
|
|
559
|
+
const restated = priors.find((r) => jaccard(incoming, tokenSet(r.content)) >= DEDUP_SIMILARITY &&
|
|
560
|
+
!(isUntrustedSource(record.sourceType) && isTrustedTarget(r.sourceType)));
|
|
561
|
+
if (restated) {
|
|
562
|
+
// Inherit the RICHER metadata of the incoming restatement so a reinforce
|
|
563
|
+
// never DROPS hard-won metadata (a more-specific segment, a higher
|
|
564
|
+
// confidence, links). subjectKey already matches by construction; the
|
|
565
|
+
// accessCount bump below is the reinforcement signal.
|
|
566
|
+
inheritRicherMetadata(restated, record);
|
|
567
|
+
restated.lastAccessedAt = now;
|
|
568
|
+
restated.accessCount += 1;
|
|
569
|
+
if (!restated.sourceTurn && record.sourceTurn)
|
|
570
|
+
restated.sourceTurn = record.sourceTurn;
|
|
571
|
+
this.writeAll(all);
|
|
572
|
+
this.emit({ at: now, kind: "reinforced", memoryId: restated.memoryId, segment: restated.segment });
|
|
573
|
+
return restated;
|
|
574
|
+
}
|
|
575
|
+
for (const r of priors) {
|
|
576
|
+
if (isUntrustedSource(record.sourceType) && isTrustedTarget(r.sourceType))
|
|
577
|
+
continue;
|
|
578
|
+
r.lifecycle = "archived";
|
|
579
|
+
r.validTo = now;
|
|
580
|
+
slotSuperseded.push(r.memoryId);
|
|
581
|
+
}
|
|
582
|
+
if (slotSuperseded.length > 0) {
|
|
583
|
+
// `contradicts` flags the conflict for consolidation; `transition`
|
|
584
|
+
// records the temporal evolution (Step 19) so the graph walk + the
|
|
585
|
+
// dream can trace what this belief BECAME and count repeated changes.
|
|
586
|
+
record.links = [
|
|
587
|
+
...(record.links ?? []),
|
|
588
|
+
...slotSuperseded.flatMap((target) => [
|
|
589
|
+
{ kind: "contradicts", target },
|
|
590
|
+
{ kind: "transition", target },
|
|
591
|
+
]),
|
|
592
|
+
];
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
// Write-time dedup (no LLM). A near-identical ACTIVE fact already exists
|
|
596
|
+
// (e.g. the model called write_memory AND the post-turn extraction sweep
|
|
597
|
+
// distilled the same fact) → don't add a parallel copy. Instead reinforce
|
|
598
|
+
// the existing one: keep the higher importance, refresh access, inherit a
|
|
599
|
+
// sourceTurn if it lacked one. Skipped for explicit corrections/updates
|
|
600
|
+
// (they carry `supersedes` and intentionally replace prior beliefs). This
|
|
601
|
+
// is the cheap layer; semantic contradictions are handled by consolidation.
|
|
602
|
+
//
|
|
603
|
+
// Origin guard: dedup ONLY merges with records of the same origin. A
|
|
604
|
+
// peer's "I prefer dark mode" must not merge into an owner's identical
|
|
605
|
+
// note (which would lift the peer's fact to owner-visible) or into
|
|
606
|
+
// another peer's identical note (which would cross-pollinate
|
|
607
|
+
// session-scoped state). Different-origin facts stay separate even if
|
|
608
|
+
// the text matches.
|
|
609
|
+
if (!record.supersedes && !record.subjectKey) {
|
|
610
|
+
const incoming = tokenSet(record.content);
|
|
611
|
+
const dup = all.find((r) => r.lifecycle === "active" &&
|
|
612
|
+
sameOrigin(r.createdBy, record.createdBy) &&
|
|
613
|
+
jaccard(incoming, tokenSet(r.content)) >= DEDUP_SIMILARITY &&
|
|
614
|
+
// Write-gate blind-spot guard: dedup-merge reinforces the matched
|
|
615
|
+
// fact (bumps importance + refreshes access). An UNTRUSTED source
|
|
616
|
+
// (tool_output / retrieved_document / compaction) must not be able to
|
|
617
|
+
// reinforce a TRUSTED, owner-authored fact through this back door —
|
|
618
|
+
// that is an unsuperseded mutation the write-gate never sees. When the
|
|
619
|
+
// incoming write is untrusted and the match is owner-authored/trusted,
|
|
620
|
+
// skip the merge: the untrusted write falls through to a separate
|
|
621
|
+
// record (subject to the gate's segment rule), leaving the owner fact
|
|
622
|
+
// exactly as the operator left it.
|
|
623
|
+
!(isUntrustedSource(record.sourceType) && isTrustedTarget(r.sourceType)));
|
|
624
|
+
if (dup) {
|
|
625
|
+
// Inherit the RICHER metadata of the incoming copy into the surviving
|
|
626
|
+
// `dup` so a reinforce never DROPS metadata. The incoming carries no
|
|
627
|
+
// subjectKey here (a subject-bearing write takes the slot path above),
|
|
628
|
+
// but it MAY be a more-specific segment / higher confidence — keep the
|
|
629
|
+
// richer of each. `dup` keeps its stable id + accessCount history; the
|
|
630
|
+
// bump below is the reinforcement signal.
|
|
631
|
+
inheritRicherMetadata(dup, record);
|
|
632
|
+
dup.lastAccessedAt = now;
|
|
633
|
+
dup.accessCount += 1;
|
|
634
|
+
if (!dup.sourceTurn && record.sourceTurn)
|
|
635
|
+
dup.sourceTurn = record.sourceTurn;
|
|
636
|
+
this.writeAll(all);
|
|
637
|
+
this.emit({ at: now, kind: "reinforced", memoryId: dup.memoryId, segment: dup.segment });
|
|
638
|
+
return dup;
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
// Embed-on-write (HYBRID recall vector lane, BOTH modes) — store a vector
|
|
642
|
+
// for the vector lane. fs mode cosine-scans it in-app; convex mode ALSO
|
|
643
|
+
// ANN-serves it via the built-in `by_embedding` vectorIndex at scale.
|
|
644
|
+
// Embedding both modes keeps recall IDENTICAL across them (cross-mode
|
|
645
|
+
// parity). Runs AFTER the write-gate AND after the dedup early-return so a
|
|
646
|
+
// blocked (poisoned) OR deduped-away write pays no embedding cost; GUARDED
|
|
647
|
+
// so a custom/learned embedder that throws degrades to no-vector (graceful
|
|
648
|
+
// BM25-only recall for this fact) rather than failing the write. The bundled
|
|
649
|
+
// embedder is synchronous + can't throw; an async model uses the async write
|
|
650
|
+
// path (future).
|
|
651
|
+
try {
|
|
652
|
+
const emb = getDefaultEmbedder();
|
|
653
|
+
const v = emb.embed([record.content]);
|
|
654
|
+
// Exact-width gate (not just truthy): a misconfigured learned embedder
|
|
655
|
+
// emitting a wrong-width vector would otherwise reach the convex by_embedding
|
|
656
|
+
// (fixed-dim) insert and THROW, losing the write. Drop the bad vector → the
|
|
657
|
+
// fact persists and recalls via BM25.
|
|
658
|
+
if (!(v instanceof Promise) && Array.isArray(v[0]) && v[0].length === emb.dims) {
|
|
659
|
+
record.embedding = v[0];
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
catch {
|
|
663
|
+
/* embedder failure → no vector; this fact recalls via BM25 only */
|
|
664
|
+
}
|
|
665
|
+
// Archive superseded records (corrections/updates overwrite prior beliefs).
|
|
666
|
+
// ORIGIN GUARD: a principal may only supersede ITS OWN facts. Without this, a
|
|
667
|
+
// channel peer's write_memory({supersedes:[ownerFactId]}) would archive the
|
|
668
|
+
// OWNER's fact (cross-origin data loss + recall blackout) — the write-gate's
|
|
669
|
+
// supersede rule doesn't catch it because a peer tool write carries no sourceType.
|
|
670
|
+
// Mirrors the sameOrigin guard the subjectKey + dedup paths already enforce;
|
|
671
|
+
// a cross-origin supersede id is silently ignored.
|
|
672
|
+
if (record.supersedes) {
|
|
673
|
+
const dead = new Set(record.supersedes);
|
|
674
|
+
for (const r of all) {
|
|
675
|
+
if (dead.has(r.memoryId) && r.lifecycle === "active" && sameOrigin(r.createdBy, record.createdBy)) {
|
|
676
|
+
r.lifecycle = "archived";
|
|
677
|
+
// Bi-temporal close — match the auto-supersede path: a superseded belief
|
|
678
|
+
// stopped being valid NOW, so the history records WHEN.
|
|
679
|
+
r.validTo = now;
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
all.push(record);
|
|
684
|
+
this.writeAll(all);
|
|
685
|
+
this.emit({
|
|
686
|
+
at: now,
|
|
687
|
+
kind: "created",
|
|
688
|
+
memoryId: record.memoryId,
|
|
689
|
+
segment: record.segment,
|
|
690
|
+
...(record.sourceType !== undefined ? { sourceType: record.sourceType } : {}),
|
|
691
|
+
...((record.supersedes?.length ?? 0) + slotSuperseded.length > 0
|
|
692
|
+
? { targets: [...(record.supersedes ?? []), ...slotSuperseded] }
|
|
693
|
+
: {}),
|
|
694
|
+
});
|
|
695
|
+
return record;
|
|
696
|
+
}
|
|
697
|
+
/**
|
|
698
|
+
* Extraction-idempotency probe (Fix 1). Given a candidate fact's content +
|
|
699
|
+
* origin, return an ALREADY-STORED active same-origin record that the
|
|
700
|
+
* candidate is merely a RESTATEMENT of — or `undefined` if it's genuinely new.
|
|
701
|
+
* The post-turn distiller calls this BEFORE writing so it never re-creates a
|
|
702
|
+
* fact the operator already taught (which would pile a subject-less `knowledge`
|
|
703
|
+
* churn copy beside a rich `identity`/`preference` original and then let
|
|
704
|
+
* consolidation archive the wrong one).
|
|
705
|
+
*
|
|
706
|
+
* Two match lanes (a candidate that hits EITHER is "already known"):
|
|
707
|
+
* 1. SUBJECT-ANCHORED restatement — the existing record is SUBJECT-BEARING
|
|
708
|
+
* (the single-valued kind extraction must not churn a twin beside) and the
|
|
709
|
+
* candidate is a paraphrase of it: embedding cosine ≥ {@link IDEMPOTENT_COSINE_BAR}
|
|
710
|
+
* OR content Jaccard ≥ {@link IDEMPOTENT_JACCARD_BAR}. The loose bar is safe
|
|
711
|
+
* here BECAUSE it's gated on an existing subjectKey — an ADDITIVE fact (no
|
|
712
|
+
* subjectKey: pets, skills) can't trip it.
|
|
713
|
+
* 2. NEAR-EXACT restatement of ANY existing fact — content Jaccard ≥
|
|
714
|
+
* {@link DEDUP_SIMILARITY} (the write-time dedup bar), so even an additive
|
|
715
|
+
* fact's verbatim re-extraction is recognised.
|
|
716
|
+
*
|
|
717
|
+
* Origin-isolated (only same-origin candidates) and embedder-guarded (a thrown/
|
|
718
|
+
* async embedder degrades to the Jaccard lanes). The richest of several matches
|
|
719
|
+
* is returned so a reinforcement lands on the best record.
|
|
720
|
+
*/
|
|
721
|
+
findEquivalentActive(content, origin) {
|
|
722
|
+
const text = content.trim();
|
|
723
|
+
if (!text)
|
|
724
|
+
return undefined;
|
|
725
|
+
const candidates = this.readAll().filter((r) => r.lifecycle === "active" && sameOrigin(r.createdBy, origin));
|
|
726
|
+
if (candidates.length === 0)
|
|
727
|
+
return undefined;
|
|
728
|
+
const incomingTokens = tokenSet(text);
|
|
729
|
+
// Embed the candidate once for the cosine lane (best-effort; the bundled
|
|
730
|
+
// embedder is sync + can't throw, a learned/async one degrades to Jaccard).
|
|
731
|
+
let incomingVec;
|
|
732
|
+
try {
|
|
733
|
+
const emb = getDefaultEmbedder();
|
|
734
|
+
const v = emb.embed([text]);
|
|
735
|
+
if (!(v instanceof Promise) && Array.isArray(v[0]) && v[0].length === emb.dims)
|
|
736
|
+
incomingVec = v[0];
|
|
737
|
+
}
|
|
738
|
+
catch {
|
|
739
|
+
/* no vector → Jaccard-only matching */
|
|
740
|
+
}
|
|
741
|
+
const matches = [];
|
|
742
|
+
for (const r of candidates) {
|
|
743
|
+
const jac = jaccard(incomingTokens, tokenSet(r.content));
|
|
744
|
+
if (jac >= DEDUP_SIMILARITY) {
|
|
745
|
+
matches.push(r);
|
|
746
|
+
continue;
|
|
747
|
+
}
|
|
748
|
+
if (r.subjectKey) {
|
|
749
|
+
const cos = incomingVec && r.embedding && r.embedding.length === incomingVec.length
|
|
750
|
+
? cosine(incomingVec, r.embedding)
|
|
751
|
+
: 0;
|
|
752
|
+
if (cos >= IDEMPOTENT_COSINE_BAR || jac >= IDEMPOTENT_JACCARD_BAR)
|
|
753
|
+
matches.push(r);
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
if (matches.length === 0)
|
|
757
|
+
return undefined;
|
|
758
|
+
// The richest match takes the reinforcement (so an `identity`+subjectKey
|
|
759
|
+
// original wins over a sparser twin if both somehow matched).
|
|
760
|
+
return matches.reduce((best, r) => (compareRichness(r, best) > 0 ? r : best));
|
|
761
|
+
}
|
|
762
|
+
/**
|
|
763
|
+
* Reinforce an existing record by id WITHOUT writing a new one (the
|
|
764
|
+
* idempotency no-op's "optionally reinforce" path). Bumps access (recall-
|
|
765
|
+
* reinforcement) and lifts confidence toward `minConfidence` if given — so a
|
|
766
|
+
* re-seen fact gets MORE durable rather than spawning a churn duplicate. No-op
|
|
767
|
+
* (undefined) if the id isn't an active record. Emits a `reinforced` event.
|
|
768
|
+
*/
|
|
769
|
+
reinforce(memoryId, opts = {}) {
|
|
770
|
+
const all = this.readAll();
|
|
771
|
+
const rec = all.find((r) => r.memoryId === memoryId);
|
|
772
|
+
if (!rec || rec.lifecycle !== "active")
|
|
773
|
+
return undefined;
|
|
774
|
+
const now = this.clock();
|
|
775
|
+
rec.accessCount += 1;
|
|
776
|
+
rec.lastAccessedAt = now;
|
|
777
|
+
if (typeof opts.minConfidence === "number") {
|
|
778
|
+
rec.confidence = Math.max(rec.confidence ?? 0, Math.min(1, Math.max(0, opts.minConfidence)));
|
|
779
|
+
}
|
|
780
|
+
this.writeAll(all);
|
|
781
|
+
this.emit({ at: now, kind: "reinforced", memoryId, segment: rec.segment });
|
|
782
|
+
return rec;
|
|
783
|
+
}
|
|
784
|
+
/**
|
|
785
|
+
* Lexical recall over active facts — Okapi BM25 × `effectiveScore`
|
|
786
|
+
* (decay + importance), origin-filtered (the shared scorer, scoring.ts).
|
|
787
|
+
* The SAME scorer runs in fs (these `readAll` records) and convex mode
|
|
788
|
+
* (the hydrated cache) ⇒ cross-mode parity by construction. Marks every
|
|
789
|
+
* returned record accessed (recall reinforcement) unless `markAccessed:
|
|
790
|
+
* false`. Returns at most `limit` hits (default 8), each with its score.
|
|
791
|
+
*/
|
|
792
|
+
search(query, opts = {}) {
|
|
793
|
+
const limit = opts.limit && opts.limit > 0 ? opts.limit : 8;
|
|
794
|
+
// Active + origin-matching candidates. Isolation is enforced HERE (never
|
|
795
|
+
// inside the scorer): the origin filter is mandatory on every tool-facing
|
|
796
|
+
// recall. `undefined` origin = the maintenance default (whole store) —
|
|
797
|
+
// tool callers always pass an explicit filter.
|
|
798
|
+
const now = this.clock();
|
|
799
|
+
// Active + origin + still-valid (bi-temporal valid-time): a fact whose
|
|
800
|
+
// `validTo` has passed is excluded from recall independent of lifecycle, so
|
|
801
|
+
// a future-dated expiry written ahead of time stops surfacing on its own.
|
|
802
|
+
const candidates = this.readAll().filter((r) => r.lifecycle === "active" &&
|
|
803
|
+
(r.validTo === undefined || r.validTo > now) &&
|
|
804
|
+
(opts.origin === undefined || recordMatchesOriginFilter(r, opts.origin)));
|
|
805
|
+
// BM25 × effectiveScore (the shared v1 scorer). Identical code in fs +
|
|
806
|
+
// convex (over readAll / the hydrated cache) ⇒ cross-mode parity by
|
|
807
|
+
// construction. Replaces the old substring term-overlap.
|
|
808
|
+
const top = bm25Score(candidates, query, now)
|
|
809
|
+
.slice(0, limit)
|
|
810
|
+
.map((s) => ({ ...s.record, score: s.score }));
|
|
811
|
+
if (opts.markAccessed !== false && top.length > 0) {
|
|
812
|
+
this.markAccessed(top.map((r) => r.memoryId));
|
|
813
|
+
}
|
|
814
|
+
return top;
|
|
815
|
+
}
|
|
816
|
+
/**
|
|
817
|
+
* Hybrid recall (Tideline v2) — BM25 ⊕ vector (cosine over each record's
|
|
818
|
+
* `embedding`), fused via `recallHybrid`. Embeddings are populated on write in
|
|
819
|
+
* BOTH modes (see embed-on-write in `write`), so the vector lane contributes
|
|
820
|
+
* IDENTICALLY in fs and convex mode — that's the cross-mode-parity guarantee.
|
|
821
|
+
* Convex additionally ANN-serves the SAME vectors via the built-in
|
|
822
|
+
* `by_embedding` vectorIndex at scale; this in-app cosine is the identical
|
|
823
|
+
* ranking over the hydrated cache. A record misses the vector lane only if its
|
|
824
|
+
* embedder threw on write (graceful BM25-only for that fact) or it predates
|
|
825
|
+
* embed-on-write (legacy). Same active+origin candidate filter + reinforcement
|
|
826
|
+
* semantics as `search`.
|
|
827
|
+
*/
|
|
828
|
+
searchHybrid(query, opts = {}) {
|
|
829
|
+
const limit = opts.limit && opts.limit > 0 ? opts.limit : 8;
|
|
830
|
+
const now = this.clock();
|
|
831
|
+
const candidates = this.readAll().filter((r) => r.lifecycle === "active" &&
|
|
832
|
+
(r.validTo === undefined || r.validTo > now) && // bi-temporal valid-time gate (see search)
|
|
833
|
+
(opts.origin === undefined || recordMatchesOriginFilter(r, opts.origin)));
|
|
834
|
+
const top = recallHybrid(candidates, query, getDefaultEmbedder(), now, { limit }).map((f) => ({
|
|
835
|
+
...f.record,
|
|
836
|
+
score: f.score,
|
|
837
|
+
}));
|
|
838
|
+
if (opts.markAccessed !== false && top.length > 0) {
|
|
839
|
+
this.markAccessed(top.map((r) => r.memoryId));
|
|
840
|
+
}
|
|
841
|
+
return top;
|
|
842
|
+
}
|
|
843
|
+
/**
|
|
844
|
+
* The recall entry point live callers (auto-recall, recall_memory) use →
|
|
845
|
+
* the HYBRID lane (BM25 ⊕ vector, {@link searchHybrid}) in BOTH modes, so
|
|
846
|
+
* recall is identical fs ↔ convex (parity by construction, same as v1). The
|
|
847
|
+
* lower-level `search` stays a pure-lexical primitive for callers that want
|
|
848
|
+
* just BM25 (the eval floor, transparency).
|
|
849
|
+
*/
|
|
850
|
+
recall(query, opts = {}) {
|
|
851
|
+
return this.searchHybrid(query, opts);
|
|
852
|
+
}
|
|
853
|
+
/**
|
|
854
|
+
* ASYNC hybrid recall — identical to {@link searchHybrid} but pre-embeds the
|
|
855
|
+
* query via {@link recallHybridAsync}, so it works with a LEARNED (async)
|
|
856
|
+
* embedder (OpenAI / local node-llama-cpp) as well as the sync HRR default
|
|
857
|
+
* (awaiting a sync embed is a no-op). This is the path that delivers true-
|
|
858
|
+
* synonymy recall when a learned embedder is selected; the sync `searchHybrid`/
|
|
859
|
+
* `recall` stay for callers that aren't async (and degrade to BM25-primary
|
|
860
|
+
* under a learned embedder — never crash). Same candidate filter + reinforcement.
|
|
861
|
+
*/
|
|
862
|
+
async searchHybridAsync(query, opts = {}) {
|
|
863
|
+
const limit = opts.limit && opts.limit > 0 ? opts.limit : 8;
|
|
864
|
+
const now = this.clock();
|
|
865
|
+
const candidates = this.readAll().filter((r) => r.lifecycle === "active" &&
|
|
866
|
+
(r.validTo === undefined || r.validTo > now) &&
|
|
867
|
+
(opts.origin === undefined || recordMatchesOriginFilter(r, opts.origin)));
|
|
868
|
+
const top = (await recallHybridAsync(candidates, query, getDefaultEmbedder(), now, { limit })).map((f) => ({
|
|
869
|
+
...f.record,
|
|
870
|
+
score: f.score,
|
|
871
|
+
}));
|
|
872
|
+
if (opts.markAccessed !== false && top.length > 0) {
|
|
873
|
+
this.markAccessed(top.map((r) => r.memoryId));
|
|
874
|
+
}
|
|
875
|
+
return top;
|
|
876
|
+
}
|
|
877
|
+
/** Async recall entry point (the learned-embedder-aware {@link searchHybridAsync}). */
|
|
878
|
+
async recallAsync(query, opts = {}) {
|
|
879
|
+
return this.searchHybridAsync(query, opts);
|
|
880
|
+
}
|
|
881
|
+
/**
|
|
882
|
+
* Recall transparency (Tideline Step 11) — like `search` but returns each
|
|
883
|
+
* hit's {@link ScoreBreakdown} and does NOT reinforce decay (diagnostic +
|
|
884
|
+
* passive). Same candidate filtering (active + origin) and the same scorer,
|
|
885
|
+
* so the ranking matches `search` exactly — this just exposes the arithmetic
|
|
886
|
+
* (bm25 × modulator) behind each rank, for "why did this surface?" tooling.
|
|
887
|
+
*/
|
|
888
|
+
explainRecall(query, opts = {}) {
|
|
889
|
+
const limit = opts.limit && opts.limit > 0 ? opts.limit : 8;
|
|
890
|
+
const now = this.clock();
|
|
891
|
+
const candidates = this.readAll().filter((r) => r.lifecycle === "active" &&
|
|
892
|
+
(r.validTo === undefined || r.validTo > now) && // bi-temporal valid-time gate (see search)
|
|
893
|
+
(opts.origin === undefined || recordMatchesOriginFilter(r, opts.origin)));
|
|
894
|
+
return bm25Score(candidates, query, now, { breakdown: true })
|
|
895
|
+
.slice(0, limit)
|
|
896
|
+
.map((s) => ({ ...s.record, score: s.score, breakdown: s.breakdown }));
|
|
897
|
+
}
|
|
898
|
+
/** Bump accessCount + lastAccessedAt for the given ids (recall reinforcement). */
|
|
899
|
+
markAccessed(ids) {
|
|
900
|
+
if (ids.length === 0)
|
|
901
|
+
return;
|
|
902
|
+
const set = new Set(ids);
|
|
903
|
+
const all = this.readAll();
|
|
904
|
+
let changed = false;
|
|
905
|
+
const now = this.clock();
|
|
906
|
+
for (const r of all) {
|
|
907
|
+
if (set.has(r.memoryId)) {
|
|
908
|
+
r.accessCount += 1;
|
|
909
|
+
r.lastAccessedAt = now;
|
|
910
|
+
changed = true;
|
|
911
|
+
}
|
|
912
|
+
}
|
|
913
|
+
if (changed)
|
|
914
|
+
this.writeAll(all);
|
|
915
|
+
}
|
|
916
|
+
/**
|
|
917
|
+
* Write embeddings onto existing records by id (the re-embed pass's apply-step).
|
|
918
|
+
* Used to fill vectors that embed-on-write SKIPPED because the selected embedder
|
|
919
|
+
* is async (a learned model) — see {@link reembedPending}. Read-mutate-write,
|
|
920
|
+
* so it flows through the convex write-through cache like any other mutation.
|
|
921
|
+
*/
|
|
922
|
+
applyEmbeddings(updates) {
|
|
923
|
+
if (updates.length === 0)
|
|
924
|
+
return;
|
|
925
|
+
const byId = new Map(updates.map((u) => [u.memoryId, u.embedding]));
|
|
926
|
+
const all = this.readAll();
|
|
927
|
+
// Exact-width gate: only accept vectors matching the active embedder's dims,
|
|
928
|
+
// so a wrong-width vector can't reach the fixed-dim convex by_embedding insert
|
|
929
|
+
// (which would throw + lose the fact). reembed.ts gates too; belt-and-suspenders.
|
|
930
|
+
const expectedDims = getDefaultEmbedder().dims;
|
|
931
|
+
let changed = false;
|
|
932
|
+
for (const r of all) {
|
|
933
|
+
const e = byId.get(r.memoryId);
|
|
934
|
+
if (e && e.length === expectedDims) {
|
|
935
|
+
r.embedding = e;
|
|
936
|
+
changed = true;
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
if (changed)
|
|
940
|
+
this.writeAll(all);
|
|
941
|
+
}
|
|
942
|
+
/**
|
|
943
|
+
* Feedback-driven self-learning (the continual-learning loop's signal). `up`
|
|
944
|
+
* nudges importance (+ confidence if set) UP and reinforces decay; `down`
|
|
945
|
+
* nudges them DOWN — ASYMMETRIC (+0.05 / −0.10), so a
|
|
946
|
+
* few bad recalls outweigh many lukewarm ones. Persisted + logged to the event
|
|
947
|
+
* track (telemetry). Recall's trust/importance modulation then adapts, closing
|
|
948
|
+
* the loop: recall → feedback → better recall. Returns the updated record.
|
|
949
|
+
*/
|
|
950
|
+
applyFeedback(memoryId, signal) {
|
|
951
|
+
const all = this.readAll();
|
|
952
|
+
const rec = all.find((r) => r.memoryId === memoryId);
|
|
953
|
+
// Only LIVE facts take feedback (consistent with invalidate) — feeding back
|
|
954
|
+
// an archived/pruned id would silently mutate a dead record to no effect.
|
|
955
|
+
if (!rec || rec.lifecycle !== "active")
|
|
956
|
+
return undefined;
|
|
957
|
+
const delta = signal === "up" ? 0.05 : -0.1;
|
|
958
|
+
const clamp = (x) => Math.max(0, Math.min(1, x));
|
|
959
|
+
rec.importance = clamp(rec.importance + delta);
|
|
960
|
+
if (typeof rec.confidence === "number")
|
|
961
|
+
rec.confidence = clamp(rec.confidence + delta);
|
|
962
|
+
const now = this.clock();
|
|
963
|
+
// `up` is a recall-and-keep → reinforce decay (bump access). `down` must NOT
|
|
964
|
+
// touch the access clock: refreshing lastAccessedAt would reset the decay
|
|
965
|
+
// timer and partly counteract the importance drop it just applied.
|
|
966
|
+
if (signal === "up") {
|
|
967
|
+
rec.lastAccessedAt = now;
|
|
968
|
+
rec.accessCount += 1;
|
|
969
|
+
}
|
|
970
|
+
this.writeAll(all);
|
|
971
|
+
this.emit({ at: now, kind: "feedback", memoryId, segment: rec.segment, signal });
|
|
972
|
+
return rec;
|
|
973
|
+
}
|
|
974
|
+
/**
|
|
975
|
+
* Metadata-preservation on reconcile (Fix 2). Fold the RICHER metadata of the
|
|
976
|
+
* `loserId` record into the `survivorId` record, in place — so a supersede /
|
|
977
|
+
* consolidation merge that ARCHIVES the loser doesn't DROP its hard-won metadata
|
|
978
|
+
* (a `subjectKey`, a more-specific segment, a higher importance/confidence). The
|
|
979
|
+
* caller invokes this on the KEEPER right before archiving the duplicate, so the
|
|
980
|
+
* survivor inherits from BOTH. No-op (false) if either id is missing or the
|
|
981
|
+
* survivor isn't active. Persists + returns whether anything changed.
|
|
982
|
+
*
|
|
983
|
+
* This is the store-level counterpart to {@link inheritRicherMetadata} (which
|
|
984
|
+
* the in-`write` reinforce paths call on their in-memory `all` array); the
|
|
985
|
+
* consolidation passes (dream / LLM consolidation) call THIS because their
|
|
986
|
+
* survivor lives in the store, not in a write-local array.
|
|
987
|
+
*/
|
|
988
|
+
mergeMetadataInto(survivorId, loserId) {
|
|
989
|
+
if (survivorId === loserId)
|
|
990
|
+
return false;
|
|
991
|
+
const all = this.readAll();
|
|
992
|
+
const survivor = all.find((r) => r.memoryId === survivorId);
|
|
993
|
+
const loser = all.find((r) => r.memoryId === loserId);
|
|
994
|
+
if (!survivor || survivor.lifecycle !== "active" || !loser)
|
|
995
|
+
return false;
|
|
996
|
+
const before = JSON.stringify([
|
|
997
|
+
survivor.subjectKey,
|
|
998
|
+
survivor.segment,
|
|
999
|
+
survivor.importance,
|
|
1000
|
+
survivor.confidence,
|
|
1001
|
+
survivor.accessCount,
|
|
1002
|
+
survivor.sourceTurn,
|
|
1003
|
+
survivor.validFrom,
|
|
1004
|
+
survivor.tier,
|
|
1005
|
+
survivor.decayRate,
|
|
1006
|
+
(survivor.links ?? []).map((l) => `${l.kind}|${l.target}`).sort(),
|
|
1007
|
+
]);
|
|
1008
|
+
inheritRicherMetadata(survivor, loser);
|
|
1009
|
+
const after = JSON.stringify([
|
|
1010
|
+
survivor.subjectKey,
|
|
1011
|
+
survivor.segment,
|
|
1012
|
+
survivor.importance,
|
|
1013
|
+
survivor.confidence,
|
|
1014
|
+
survivor.accessCount,
|
|
1015
|
+
survivor.sourceTurn,
|
|
1016
|
+
survivor.validFrom,
|
|
1017
|
+
survivor.tier,
|
|
1018
|
+
survivor.decayRate,
|
|
1019
|
+
(survivor.links ?? []).map((l) => `${l.kind}|${l.target}`).sort(),
|
|
1020
|
+
]);
|
|
1021
|
+
if (before === after)
|
|
1022
|
+
return false;
|
|
1023
|
+
this.writeAll(all);
|
|
1024
|
+
return true;
|
|
1025
|
+
}
|
|
1026
|
+
/**
|
|
1027
|
+
* Bi-temporally INVALIDATE a fact (Tideline v2, step 15) — close its valid
|
|
1028
|
+
* interval (`validTo = now`) + archive it, so recall drops it while HISTORY
|
|
1029
|
+
* keeps it (transaction time `createdAt` untouched). If `supersededBy` is
|
|
1030
|
+
* given, records a `contradicts` link on the superseder → the stale fact.
|
|
1031
|
+
* Persisted + logged. Returns the invalidated record, or `undefined` if it's
|
|
1032
|
+
* missing / already inactive.
|
|
1033
|
+
*/
|
|
1034
|
+
invalidate(staleId, opts = {}) {
|
|
1035
|
+
const all = this.readAll();
|
|
1036
|
+
const stale = all.find((r) => r.memoryId === staleId);
|
|
1037
|
+
if (!stale || stale.lifecycle !== "active")
|
|
1038
|
+
return undefined;
|
|
1039
|
+
const now = opts.now ?? this.clock();
|
|
1040
|
+
stale.validTo = now;
|
|
1041
|
+
stale.lifecycle = "archived";
|
|
1042
|
+
if (opts.supersededBy) {
|
|
1043
|
+
const by = all.find((r) => r.memoryId === opts.supersededBy);
|
|
1044
|
+
if (by) {
|
|
1045
|
+
// Idempotent: drop any prior contradicts/transition edge to this
|
|
1046
|
+
// stale id, then re-add both — `contradicts` (conflict flag) +
|
|
1047
|
+
// `transition` (Step 19 temporal evolution edge for the graph/dream).
|
|
1048
|
+
const kept = (by.links ?? []).filter((l) => !((l.kind === "contradicts" || l.kind === "transition") && l.target === staleId));
|
|
1049
|
+
const links = [
|
|
1050
|
+
...kept,
|
|
1051
|
+
{ kind: "contradicts", target: staleId },
|
|
1052
|
+
{ kind: "transition", target: staleId },
|
|
1053
|
+
];
|
|
1054
|
+
by.links = links;
|
|
1055
|
+
}
|
|
1056
|
+
}
|
|
1057
|
+
this.writeAll(all);
|
|
1058
|
+
this.emit({
|
|
1059
|
+
at: now,
|
|
1060
|
+
kind: "invalidated",
|
|
1061
|
+
memoryId: staleId,
|
|
1062
|
+
segment: stale.segment,
|
|
1063
|
+
...(opts.supersededBy ? { targets: [opts.supersededBy] } : {}),
|
|
1064
|
+
});
|
|
1065
|
+
return stale;
|
|
1066
|
+
}
|
|
1067
|
+
/**
|
|
1068
|
+
* Step 19 — persist TYPED association edges between fact pairs (where the
|
|
1069
|
+
* relationship extractor's typed taxonomy AND the dream's synonymy/relatedness
|
|
1070
|
+
* edges land). Bidirectional, deduped per (kind,target), and capped per record per
|
|
1071
|
+
* kind (a hub-fact fan-out guard); only ACTIVE facts are linked. Each edge carries
|
|
1072
|
+
* the edge `kind` (default `relates` for legacy synonymy callers), an optional
|
|
1073
|
+
* `reason` (the model's justification, for explainable rendering) and `strength`.
|
|
1074
|
+
* Idempotent — re-running adds nothing already present (a later write may BACKFILL a
|
|
1075
|
+
* reason onto a prior reason-less edge of the same kind, which is not counted as a
|
|
1076
|
+
* new edge). Goes through readAll/writeAll like every mutation, so it is fs↔convex
|
|
1077
|
+
* parity by construction. Returns the number of NEW link entries written.
|
|
1078
|
+
*
|
|
1079
|
+
* Callers MUST pass only SAME-ORIGIN pairs (the dream computes synonymy per origin
|
|
1080
|
+
* bucket; the extractor pre-filters to one origin) — a cross-principal edge would
|
|
1081
|
+
* leak one peer's facts into another principal's graph-recall walk.
|
|
1082
|
+
*
|
|
1083
|
+
* The edge is written DIRECTED on the kind the caller supplies, and the REVERSE
|
|
1084
|
+
* endpoint records the INVERSE kind (causes↔caused_by, precedes↔follows,
|
|
1085
|
+
* enables/blocks→caused_by/blocks, part_of→part_of, …) so the graph reads
|
|
1086
|
+
* correctly from either note; symmetric kinds (co_constrains/contrasts_with/
|
|
1087
|
+
* same_topic/relates/relates_to/uses/works_on/located_at) mirror unchanged.
|
|
1088
|
+
*/
|
|
1089
|
+
linkRelated(pairs, opts = {}) {
|
|
1090
|
+
if (pairs.length === 0)
|
|
1091
|
+
return 0;
|
|
1092
|
+
const maxPerRecord = opts.maxPerRecord && opts.maxPerRecord > 0 ? opts.maxPerRecord : 12;
|
|
1093
|
+
const all = this.readAll();
|
|
1094
|
+
const byId = new Map(all.map((r) => [r.memoryId, r]));
|
|
1095
|
+
let added = 0;
|
|
1096
|
+
const addOne = (fromId, toId, kind, reason, strength) => {
|
|
1097
|
+
if (fromId === toId)
|
|
1098
|
+
return;
|
|
1099
|
+
const rec = byId.get(fromId);
|
|
1100
|
+
if (!rec || rec.lifecycle !== "active")
|
|
1101
|
+
return;
|
|
1102
|
+
const links = rec.links ?? [];
|
|
1103
|
+
const existing = links.find((l) => l.kind === kind && l.target === toId);
|
|
1104
|
+
if (existing) {
|
|
1105
|
+
// Idempotent: edge already present. BACKFILL a reason/strength onto a
|
|
1106
|
+
// prior reason-less edge (a relink pass enriches an earlier bare edge)
|
|
1107
|
+
// without counting it as a new edge — keeps re-runs at 0 new.
|
|
1108
|
+
if (reason && !existing.reason)
|
|
1109
|
+
existing.reason = reason;
|
|
1110
|
+
if (strength !== undefined && existing.strength === undefined)
|
|
1111
|
+
existing.strength = strength;
|
|
1112
|
+
return;
|
|
1113
|
+
}
|
|
1114
|
+
if (links.filter((l) => l.kind === kind).length >= maxPerRecord)
|
|
1115
|
+
return; // per-kind fan-out cap
|
|
1116
|
+
rec.links = [
|
|
1117
|
+
...links,
|
|
1118
|
+
{ kind, target: toId, ...(reason ? { reason } : {}), ...(strength !== undefined ? { strength } : {}) },
|
|
1119
|
+
];
|
|
1120
|
+
added++;
|
|
1121
|
+
};
|
|
1122
|
+
for (const { a, b, kind, reason, strength } of pairs) {
|
|
1123
|
+
// Both endpoints must be ACTIVE — skip a pair where either was archived
|
|
1124
|
+
// (e.g. consolidated away this same dream pass): a relation to a dead fact
|
|
1125
|
+
// is noise, and a supersede already carries that pair's relationship.
|
|
1126
|
+
if (byId.get(a)?.lifecycle !== "active" || byId.get(b)?.lifecycle !== "active")
|
|
1127
|
+
continue;
|
|
1128
|
+
const fwd = kind ?? "relates";
|
|
1129
|
+
addOne(a, b, fwd, reason, strength);
|
|
1130
|
+
addOne(b, a, inverseLinkKind(fwd), reason, strength);
|
|
1131
|
+
}
|
|
1132
|
+
if (added > 0)
|
|
1133
|
+
this.writeAll(all);
|
|
1134
|
+
return added;
|
|
1135
|
+
}
|
|
1136
|
+
/**
|
|
1137
|
+
* Lane B (Step 25) — REVERSE a retraction: re-activate an `archived` fact and
|
|
1138
|
+
* clear its valid-time bound so it surfaces again. The reversible counterpart
|
|
1139
|
+
* to {@link invalidate} — the operator's "restore" after an over-eager
|
|
1140
|
+
* retraction. Persisted + logged (a `reinforced` event: the fact is reasserted
|
|
1141
|
+
* as valid). Returns the record, or `undefined` if it's missing / not archived.
|
|
1142
|
+
*/
|
|
1143
|
+
reactivate(id, opts = {}) {
|
|
1144
|
+
const all = this.readAll();
|
|
1145
|
+
const rec = all.find((r) => r.memoryId === id);
|
|
1146
|
+
if (!rec || rec.lifecycle !== "archived")
|
|
1147
|
+
return undefined;
|
|
1148
|
+
// Only restore a RETRACTED or decayed fact — NOT one SUPERSEDED or CONSOLIDATED
|
|
1149
|
+
// away. A superseded/consolidated record is the TARGET of a contradicts/transition
|
|
1150
|
+
// edge from an ACTIVE successor; resurrecting it would put two contradictory
|
|
1151
|
+
// beliefs live at once (breaking the single-value invariant — exactly what the
|
|
1152
|
+
// supersede mechanism exists to prevent). A pure retract / decay leaves no such
|
|
1153
|
+
// incoming edge, so it stays restorable.
|
|
1154
|
+
const supersededByActive = all.some((r) => r.lifecycle === "active" &&
|
|
1155
|
+
(r.links ?? []).some((l) => (l.kind === "contradicts" || l.kind === "transition") && l.target === id));
|
|
1156
|
+
if (supersededByActive)
|
|
1157
|
+
return undefined;
|
|
1158
|
+
// Belt-and-suspenders for the single-valued-slot invariant: if a same-origin fact
|
|
1159
|
+
// now occupies this subjectKey, restoring would create two live values — refuse.
|
|
1160
|
+
if (rec.subjectKey &&
|
|
1161
|
+
all.some((r) => r.lifecycle === "active" && r.subjectKey === rec.subjectKey && sameOrigin(r.createdBy, rec.createdBy)))
|
|
1162
|
+
return undefined;
|
|
1163
|
+
rec.lifecycle = "active";
|
|
1164
|
+
rec.validTo = undefined;
|
|
1165
|
+
this.writeAll(all);
|
|
1166
|
+
this.emit({ at: opts.now ?? this.clock(), kind: "reinforced", memoryId: id, segment: rec.segment });
|
|
1167
|
+
return rec;
|
|
1168
|
+
}
|
|
1169
|
+
/**
|
|
1170
|
+
* Records whose VAULT note must be preserved: every ACTIVE fact PLUS any ARCHIVED
|
|
1171
|
+
* fact that is still RESTORABLE — i.e. retracted/decayed, NOT superseded/consolidated
|
|
1172
|
+
* by an active successor (same edge test as {@link reactivate}). The vault prune
|
|
1173
|
+
* deletes notes outside this set, so a reversibly-retracted fact — and the operator's
|
|
1174
|
+
* hand-pinned edits on it — survives a re-render; only a hard-purged fact's note
|
|
1175
|
+
* (gone from the store entirely) is removed.
|
|
1176
|
+
*/
|
|
1177
|
+
listForVault(origin) {
|
|
1178
|
+
const all = this.readAll().filter((r) => origin === undefined || recordMatchesOriginFilter(r, origin));
|
|
1179
|
+
const supersededByActive = new Set(all
|
|
1180
|
+
.filter((r) => r.lifecycle === "active")
|
|
1181
|
+
.flatMap((r) => (r.links ?? []).filter((l) => l.kind === "contradicts" || l.kind === "transition").map((l) => l.target)));
|
|
1182
|
+
return all.filter((r) => r.lifecycle === "active" || (r.lifecycle === "archived" && !supersededByActive.has(r.memoryId)));
|
|
1183
|
+
}
|
|
1184
|
+
/**
|
|
1185
|
+
* Dream/curator lane (Step 22) — REVERSIBLE: patch cognition fields on an
|
|
1186
|
+
* ACTIVE record, used to PROMOTE a repeatedly-corrected belief to a confirmed
|
|
1187
|
+
* preference. Returns the PRIOR {confidence,status,importance} (also recorded
|
|
1188
|
+
* in the "confirmed" event) so a dream pass can be undone — Lane A is
|
|
1189
|
+
* reversible by design. No-op (undefined) if `memoryId` isn't an active record.
|
|
1190
|
+
*/
|
|
1191
|
+
promote(memoryId, patch, opts = {}) {
|
|
1192
|
+
const clamp01 = (x) => Math.max(0, Math.min(1, x));
|
|
1193
|
+
const all = this.readAll();
|
|
1194
|
+
const rec = all.find((r) => r.memoryId === memoryId);
|
|
1195
|
+
if (!rec || rec.lifecycle !== "active")
|
|
1196
|
+
return undefined;
|
|
1197
|
+
const prior = {
|
|
1198
|
+
...(rec.confidence !== undefined ? { confidence: rec.confidence } : {}),
|
|
1199
|
+
...(rec.status !== undefined ? { status: rec.status } : {}),
|
|
1200
|
+
importance: rec.importance,
|
|
1201
|
+
};
|
|
1202
|
+
if (patch.status !== undefined)
|
|
1203
|
+
rec.status = patch.status;
|
|
1204
|
+
if (patch.confidence !== undefined)
|
|
1205
|
+
rec.confidence = clamp01(patch.confidence);
|
|
1206
|
+
if (patch.importance !== undefined)
|
|
1207
|
+
rec.importance = clamp01(patch.importance);
|
|
1208
|
+
this.writeAll(all);
|
|
1209
|
+
this.emit({ at: opts.now ?? this.clock(), kind: "confirmed", memoryId, segment: rec.segment, prior });
|
|
1210
|
+
return prior;
|
|
1211
|
+
}
|
|
1212
|
+
/**
|
|
1213
|
+
* Dream/curator lane (Step 22): archive low-value decayed facts, emitting an
|
|
1214
|
+
* "evicted" event per fact. Returns the ids actually archived (skips already
|
|
1215
|
+
* non-active ones). Distinct from decay GC's `setLifecycle` in that it logs.
|
|
1216
|
+
*/
|
|
1217
|
+
evict(ids, opts = {}) {
|
|
1218
|
+
if (ids.length === 0)
|
|
1219
|
+
return [];
|
|
1220
|
+
const now = opts.now ?? this.clock();
|
|
1221
|
+
const set = new Set(ids);
|
|
1222
|
+
const all = this.readAll();
|
|
1223
|
+
const evicted = [];
|
|
1224
|
+
for (const r of all) {
|
|
1225
|
+
if (set.has(r.memoryId) && r.lifecycle === "active") {
|
|
1226
|
+
r.lifecycle = "archived";
|
|
1227
|
+
r.validTo = r.validTo ?? now;
|
|
1228
|
+
evicted.push(r.memoryId);
|
|
1229
|
+
}
|
|
1230
|
+
}
|
|
1231
|
+
if (evicted.length === 0)
|
|
1232
|
+
return [];
|
|
1233
|
+
this.writeAll(all);
|
|
1234
|
+
for (const id of evicted) {
|
|
1235
|
+
const seg = all.find((r) => r.memoryId === id)?.segment;
|
|
1236
|
+
this.emit({ at: now, kind: "evicted", memoryId: id, ...(seg ? { segment: seg } : {}) });
|
|
1237
|
+
}
|
|
1238
|
+
return evicted;
|
|
1239
|
+
}
|
|
1240
|
+
/**
|
|
1241
|
+
* Governance (Step 24) — HARD-delete records (crypto-shred: the sealed
|
|
1242
|
+
* content is REMOVED, not archived, so it's unrecoverable even with the key).
|
|
1243
|
+
* Returns the ids actually removed. Filesystem rewrites the JSONL without
|
|
1244
|
+
* them; convex mode realises the deletion through the write-through diff.
|
|
1245
|
+
* Distinct from evict/setLifecycle, which only flip lifecycle.
|
|
1246
|
+
*/
|
|
1247
|
+
purge(ids) {
|
|
1248
|
+
if (ids.length === 0)
|
|
1249
|
+
return [];
|
|
1250
|
+
const set = new Set(ids);
|
|
1251
|
+
const all = this.readAll();
|
|
1252
|
+
const removed = all.filter((r) => set.has(r.memoryId)).map((r) => r.memoryId);
|
|
1253
|
+
if (removed.length === 0)
|
|
1254
|
+
return [];
|
|
1255
|
+
this.writeAll(all.filter((r) => !set.has(r.memoryId)));
|
|
1256
|
+
return removed;
|
|
1257
|
+
}
|
|
1258
|
+
/**
|
|
1259
|
+
* The DISTINCT origins present in the active store (owner + each channel
|
|
1260
|
+
* peer). The per-origin fan-out seam: the curator/dream run one pass per
|
|
1261
|
+
* origin so a cross-fact operation never mixes principals. Deduped by
|
|
1262
|
+
* {@link originBucketKey}; owner first, then channels in stable key order.
|
|
1263
|
+
*/
|
|
1264
|
+
distinctOrigins() {
|
|
1265
|
+
const byKey = new Map();
|
|
1266
|
+
for (const r of this.readAll()) {
|
|
1267
|
+
if (r.lifecycle !== "active")
|
|
1268
|
+
continue;
|
|
1269
|
+
const key = originBucketKey(r);
|
|
1270
|
+
if (!byKey.has(key))
|
|
1271
|
+
byKey.set(key, resolveRecordOrigin(r.createdBy));
|
|
1272
|
+
}
|
|
1273
|
+
return [...byKey.entries()].sort((a, b) => (a[0] === "owner" ? -1 : b[0] === "owner" ? 1 : a[0].localeCompare(b[0]))).map(([, o]) => o);
|
|
1274
|
+
}
|
|
1275
|
+
/** Set the lifecycle of specific records (used by decay GC). */
|
|
1276
|
+
setLifecycle(ids, lifecycle) {
|
|
1277
|
+
if (ids.length === 0)
|
|
1278
|
+
return;
|
|
1279
|
+
const set = new Set(ids);
|
|
1280
|
+
const all = this.readAll();
|
|
1281
|
+
let changed = false;
|
|
1282
|
+
for (const r of all) {
|
|
1283
|
+
if (set.has(r.memoryId) && r.lifecycle !== lifecycle) {
|
|
1284
|
+
r.lifecycle = lifecycle;
|
|
1285
|
+
changed = true;
|
|
1286
|
+
}
|
|
1287
|
+
}
|
|
1288
|
+
if (changed)
|
|
1289
|
+
this.writeAll(all);
|
|
1290
|
+
}
|
|
1291
|
+
/** Atomic whole-file rewrite (tmp + rename) so a crash can't corrupt the store. */
|
|
1292
|
+
writeAll(records) {
|
|
1293
|
+
// Convex mode — prime the cache (next readAll sees this write) and
|
|
1294
|
+
// enqueue per-record mutations realising the diff. All FactStore
|
|
1295
|
+
// mutators (write/markAccessed/setLifecycle/dedup-reinforce) funnel
|
|
1296
|
+
// through here, so this one branch covers every memory write path.
|
|
1297
|
+
const rctx = tryGetRuntimeContext();
|
|
1298
|
+
if (rctx?.mode === "convex") {
|
|
1299
|
+
const wsId = workspaceIdFromDir(path.dirname(path.dirname(this.file)));
|
|
1300
|
+
writeThroughFactsCache(rctx.store, wsId, records);
|
|
1301
|
+
return;
|
|
1302
|
+
}
|
|
1303
|
+
fs.mkdirSync(path.dirname(this.file), { recursive: true });
|
|
1304
|
+
// DRIFT GUARD — the most recent read SKIPPED non-empty line(s) it couldn't
|
|
1305
|
+
// parse (a hand-edit, a torn/concurrent write, a partial convex→fs sync). The
|
|
1306
|
+
// atomic rewrite below keeps only the parsed records, so that content is about
|
|
1307
|
+
// to be SILENTLY LOST. Snapshot the current on-disk file to a sibling
|
|
1308
|
+
// `.bak-<pid>-<ts>` first so it stays recoverable, then proceed — refusing the
|
|
1309
|
+
// write would wedge the agent's own memory. Cheap single-operator insurance.
|
|
1310
|
+
if (this.lastReadHadUnparseable) {
|
|
1311
|
+
try {
|
|
1312
|
+
const bak = `${this.file}.bak-${process.pid}-${Math.round(this.clock())}`;
|
|
1313
|
+
fs.copyFileSync(this.file, bak);
|
|
1314
|
+
driftLog.warn("facts.jsonl had unparseable line(s); snapshotted before overwrite so nothing is silently dropped", { bak });
|
|
1315
|
+
}
|
|
1316
|
+
catch {
|
|
1317
|
+
/* best-effort snapshot — never block the write on a failed backup */
|
|
1318
|
+
}
|
|
1319
|
+
this.lastReadHadUnparseable = false; // consumed — the snapshot now holds it
|
|
1320
|
+
}
|
|
1321
|
+
const body = records.map((r) => JSON.stringify(r)).join("\n") + (records.length > 0 ? "\n" : "");
|
|
1322
|
+
const tmp = `${this.file}.tmp-${process.pid}-${Date.now()}`;
|
|
1323
|
+
fs.writeFileSync(tmp, body, "utf8");
|
|
1324
|
+
fs.renameSync(tmp, this.file);
|
|
1325
|
+
}
|
|
1326
|
+
}
|
|
1327
|
+
//# sourceMappingURL=records.js.map
|