@revealui/ai 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -0
- package/LICENSE.commercial +112 -0
- package/README.md +314 -0
- package/dist/a2a/card.d.ts +26 -0
- package/dist/a2a/card.d.ts.map +1 -0
- package/dist/a2a/card.js +173 -0
- package/dist/a2a/handler.d.ts +26 -0
- package/dist/a2a/handler.d.ts.map +1 -0
- package/dist/a2a/handler.js +170 -0
- package/dist/a2a/index.d.ts +10 -0
- package/dist/a2a/index.d.ts.map +1 -0
- package/dist/a2a/index.js +9 -0
- package/dist/a2a/task-store.d.ts +42 -0
- package/dist/a2a/task-store.d.ts.map +1 -0
- package/dist/a2a/task-store.js +99 -0
- package/dist/audit/emitter.d.ts +34 -0
- package/dist/audit/emitter.d.ts.map +1 -0
- package/dist/audit/emitter.js +34 -0
- package/dist/audit/index.d.ts +44 -0
- package/dist/audit/index.d.ts.map +1 -0
- package/dist/audit/index.js +48 -0
- package/dist/audit/observer.d.ts +108 -0
- package/dist/audit/observer.d.ts.map +1 -0
- package/dist/audit/observer.js +271 -0
- package/dist/audit/policy.d.ts +70 -0
- package/dist/audit/policy.d.ts.map +1 -0
- package/dist/audit/policy.js +209 -0
- package/dist/audit/store.d.ts +42 -0
- package/dist/audit/store.d.ts.map +1 -0
- package/dist/audit/store.js +80 -0
- package/dist/audit/types.d.ts +169 -0
- package/dist/audit/types.d.ts.map +1 -0
- package/dist/audit/types.js +80 -0
- package/dist/client/hooks/index.d.ts +22 -0
- package/dist/client/hooks/index.d.ts.map +1 -0
- package/dist/client/hooks/index.js +21 -0
- package/dist/client/hooks/useAgentContext.d.ts +30 -0
- package/dist/client/hooks/useAgentContext.d.ts.map +1 -0
- package/dist/client/hooks/useAgentContext.js +161 -0
- package/dist/client/hooks/useAgentEvents.d.ts +126 -0
- package/dist/client/hooks/useAgentEvents.d.ts.map +1 -0
- package/dist/client/hooks/useAgentEvents.js +232 -0
- package/dist/client/hooks/useAgentStream.d.ts +44 -0
- package/dist/client/hooks/useAgentStream.d.ts.map +1 -0
- package/dist/client/hooks/useAgentStream.js +101 -0
- package/dist/client/hooks/useEpisodicMemory.d.ts +25 -0
- package/dist/client/hooks/useEpisodicMemory.d.ts.map +1 -0
- package/dist/client/hooks/useEpisodicMemory.js +174 -0
- package/dist/client/hooks/useWorkingMemory.d.ts +57 -0
- package/dist/client/hooks/useWorkingMemory.d.ts.map +1 -0
- package/dist/client/hooks/useWorkingMemory.js +276 -0
- package/dist/client/index.d.ts +14 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +13 -0
- package/dist/embeddings/index.d.ts +51 -0
- package/dist/embeddings/index.d.ts.map +1 -0
- package/dist/embeddings/index.js +73 -0
- package/dist/index.d.ts +83 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +103 -0
- package/dist/inference/context-assembly.d.ts +27 -0
- package/dist/inference/context-assembly.d.ts.map +1 -0
- package/dist/inference/context-assembly.js +81 -0
- package/dist/inference/overflow-compressor.d.ts +17 -0
- package/dist/inference/overflow-compressor.d.ts.map +1 -0
- package/dist/inference/overflow-compressor.js +40 -0
- package/dist/inference/runRag.d.ts +35 -0
- package/dist/inference/runRag.d.ts.map +1 -0
- package/dist/inference/runRag.js +53 -0
- package/dist/ingestion/bm25.d.ts +29 -0
- package/dist/ingestion/bm25.d.ts.map +1 -0
- package/dist/ingestion/bm25.js +161 -0
- package/dist/ingestion/cms-indexer.d.ts +39 -0
- package/dist/ingestion/cms-indexer.d.ts.map +1 -0
- package/dist/ingestion/cms-indexer.js +74 -0
- package/dist/ingestion/file-parsers.d.ts +51 -0
- package/dist/ingestion/file-parsers.d.ts.map +1 -0
- package/dist/ingestion/file-parsers.js +247 -0
- package/dist/ingestion/hybrid-search.d.ts +22 -0
- package/dist/ingestion/hybrid-search.d.ts.map +1 -0
- package/dist/ingestion/hybrid-search.js +63 -0
- package/dist/ingestion/index.d.ts +9 -0
- package/dist/ingestion/index.d.ts.map +1 -0
- package/dist/ingestion/index.js +8 -0
- package/dist/ingestion/pipeline.d.ts +35 -0
- package/dist/ingestion/pipeline.d.ts.map +1 -0
- package/dist/ingestion/pipeline.js +114 -0
- package/dist/ingestion/rag-vector-service.d.ts +34 -0
- package/dist/ingestion/rag-vector-service.d.ts.map +1 -0
- package/dist/ingestion/rag-vector-service.js +98 -0
- package/dist/ingestion/reranker.d.ts +10 -0
- package/dist/ingestion/reranker.d.ts.map +1 -0
- package/dist/ingestion/reranker.js +41 -0
- package/dist/ingestion/text-splitter.d.ts +25 -0
- package/dist/ingestion/text-splitter.d.ts.map +1 -0
- package/dist/ingestion/text-splitter.js +119 -0
- package/dist/llm/cache-utils.d.ts +146 -0
- package/dist/llm/cache-utils.d.ts.map +1 -0
- package/dist/llm/cache-utils.js +204 -0
- package/dist/llm/client.d.ts +134 -0
- package/dist/llm/client.d.ts.map +1 -0
- package/dist/llm/client.js +497 -0
- package/dist/llm/key-validator.d.ts +25 -0
- package/dist/llm/key-validator.d.ts.map +1 -0
- package/dist/llm/key-validator.js +101 -0
- package/dist/llm/provider-health.d.ts +40 -0
- package/dist/llm/provider-health.d.ts.map +1 -0
- package/dist/llm/provider-health.js +97 -0
- package/dist/llm/providers/anthropic.d.ts +31 -0
- package/dist/llm/providers/anthropic.d.ts.map +1 -0
- package/dist/llm/providers/anthropic.js +248 -0
- package/dist/llm/providers/base.d.ts +111 -0
- package/dist/llm/providers/base.d.ts.map +1 -0
- package/dist/llm/providers/base.js +6 -0
- package/dist/llm/providers/groq.d.ts +23 -0
- package/dist/llm/providers/groq.d.ts.map +1 -0
- package/dist/llm/providers/groq.js +27 -0
- package/dist/llm/providers/ollama.d.ts +27 -0
- package/dist/llm/providers/ollama.d.ts.map +1 -0
- package/dist/llm/providers/ollama.js +48 -0
- package/dist/llm/providers/openai.d.ts +19 -0
- package/dist/llm/providers/openai.d.ts.map +1 -0
- package/dist/llm/providers/openai.js +245 -0
- package/dist/llm/providers/vultr.d.ts +18 -0
- package/dist/llm/providers/vultr.d.ts.map +1 -0
- package/dist/llm/providers/vultr.js +168 -0
- package/dist/llm/response-cache.d.ts +166 -0
- package/dist/llm/response-cache.d.ts.map +1 -0
- package/dist/llm/response-cache.js +233 -0
- package/dist/llm/semantic-cache.d.ts +179 -0
- package/dist/llm/semantic-cache.d.ts.map +1 -0
- package/dist/llm/semantic-cache.js +306 -0
- package/dist/llm/server.d.ts +14 -0
- package/dist/llm/server.d.ts.map +1 -0
- package/dist/llm/server.js +15 -0
- package/dist/llm/token-counter.d.ts +48 -0
- package/dist/llm/token-counter.d.ts.map +1 -0
- package/dist/llm/token-counter.js +77 -0
- package/dist/llm/workspace-provider-config.d.ts +38 -0
- package/dist/llm/workspace-provider-config.d.ts.map +1 -0
- package/dist/llm/workspace-provider-config.js +47 -0
- package/dist/memory/agent/context-manager.d.ts +148 -0
- package/dist/memory/agent/context-manager.d.ts.map +1 -0
- package/dist/memory/agent/context-manager.js +284 -0
- package/dist/memory/agent/index.d.ts +7 -0
- package/dist/memory/agent/index.d.ts.map +1 -0
- package/dist/memory/agent/index.js +6 -0
- package/dist/memory/crdt/index.d.ts +13 -0
- package/dist/memory/crdt/index.d.ts.map +1 -0
- package/dist/memory/crdt/index.js +12 -0
- package/dist/memory/crdt/lww-register.d.ts +108 -0
- package/dist/memory/crdt/lww-register.d.ts.map +1 -0
- package/dist/memory/crdt/lww-register.js +169 -0
- package/dist/memory/crdt/or-set.d.ts +141 -0
- package/dist/memory/crdt/or-set.d.ts.map +1 -0
- package/dist/memory/crdt/or-set.js +291 -0
- package/dist/memory/crdt/pn-counter.d.ts +116 -0
- package/dist/memory/crdt/pn-counter.d.ts.map +1 -0
- package/dist/memory/crdt/pn-counter.js +174 -0
- package/dist/memory/crdt/vector-clock.d.ts +115 -0
- package/dist/memory/crdt/vector-clock.d.ts.map +1 -0
- package/dist/memory/crdt/vector-clock.js +179 -0
- package/dist/memory/errors/index.d.ts +56 -0
- package/dist/memory/errors/index.d.ts.map +1 -0
- package/dist/memory/errors/index.js +85 -0
- package/dist/memory/index.d.ts +21 -0
- package/dist/memory/index.d.ts.map +1 -0
- package/dist/memory/index.js +20 -0
- package/dist/memory/persistence/crdt-persistence.d.ts +85 -0
- package/dist/memory/persistence/crdt-persistence.d.ts.map +1 -0
- package/dist/memory/persistence/crdt-persistence.js +204 -0
- package/dist/memory/persistence/index.d.ts +7 -0
- package/dist/memory/persistence/index.d.ts.map +1 -0
- package/dist/memory/persistence/index.js +6 -0
- package/dist/memory/preferences/index.d.ts +7 -0
- package/dist/memory/preferences/index.d.ts.map +1 -0
- package/dist/memory/preferences/index.js +6 -0
- package/dist/memory/preferences/user-preferences-manager.d.ts +133 -0
- package/dist/memory/preferences/user-preferences-manager.d.ts.map +1 -0
- package/dist/memory/preferences/user-preferences-manager.js +342 -0
- package/dist/memory/services/index.d.ts +8 -0
- package/dist/memory/services/index.d.ts.map +1 -0
- package/dist/memory/services/index.js +6 -0
- package/dist/memory/services/node-id-service.d.ts +75 -0
- package/dist/memory/services/node-id-service.d.ts.map +1 -0
- package/dist/memory/services/node-id-service.js +190 -0
- package/dist/memory/stores/episodic-memory.d.ts +182 -0
- package/dist/memory/stores/episodic-memory.d.ts.map +1 -0
- package/dist/memory/stores/episodic-memory.js +378 -0
- package/dist/memory/stores/index.d.ts +16 -0
- package/dist/memory/stores/index.d.ts.map +1 -0
- package/dist/memory/stores/index.js +15 -0
- package/dist/memory/stores/procedural-memory.d.ts +89 -0
- package/dist/memory/stores/procedural-memory.d.ts.map +1 -0
- package/dist/memory/stores/procedural-memory.js +152 -0
- package/dist/memory/stores/semantic-memory.d.ts +92 -0
- package/dist/memory/stores/semantic-memory.d.ts.map +1 -0
- package/dist/memory/stores/semantic-memory.js +155 -0
- package/dist/memory/stores/working-memory.d.ts +225 -0
- package/dist/memory/stores/working-memory.d.ts.map +1 -0
- package/dist/memory/stores/working-memory.js +336 -0
- package/dist/memory/utils/deep-clone.d.ts +10 -0
- package/dist/memory/utils/deep-clone.d.ts.map +1 -0
- package/dist/memory/utils/deep-clone.js +9 -0
- package/dist/memory/utils/index.d.ts +8 -0
- package/dist/memory/utils/index.d.ts.map +1 -0
- package/dist/memory/utils/index.js +7 -0
- package/dist/memory/utils/logger.d.ts +21 -0
- package/dist/memory/utils/logger.d.ts.map +1 -0
- package/dist/memory/utils/logger.js +62 -0
- package/dist/memory/utils/sql-helpers.d.ts +97 -0
- package/dist/memory/utils/sql-helpers.d.ts.map +1 -0
- package/dist/memory/utils/sql-helpers.js +214 -0
- package/dist/memory/utils/validation.d.ts +62 -0
- package/dist/memory/utils/validation.d.ts.map +1 -0
- package/dist/memory/utils/validation.js +244 -0
- package/dist/memory/vector/index.d.ts +12 -0
- package/dist/memory/vector/index.d.ts.map +1 -0
- package/dist/memory/vector/index.js +14 -0
- package/dist/memory/vector/vector-memory-service.d.ts +88 -0
- package/dist/memory/vector/vector-memory-service.d.ts.map +1 -0
- package/dist/memory/vector/vector-memory-service.js +335 -0
- package/dist/observability/logger.d.ts +79 -0
- package/dist/observability/logger.d.ts.map +1 -0
- package/dist/observability/logger.js +165 -0
- package/dist/observability/metrics.d.ts +43 -0
- package/dist/observability/metrics.d.ts.map +1 -0
- package/dist/observability/metrics.js +197 -0
- package/dist/observability/query.d.ts +150 -0
- package/dist/observability/query.d.ts.map +1 -0
- package/dist/observability/query.js +339 -0
- package/dist/observability/types.d.ts +140 -0
- package/dist/observability/types.d.ts.map +1 -0
- package/dist/observability/types.js +6 -0
- package/dist/orchestration/agent.d.ts +98 -0
- package/dist/orchestration/agent.d.ts.map +1 -0
- package/dist/orchestration/agent.js +6 -0
- package/dist/orchestration/defaults.d.ts +21 -0
- package/dist/orchestration/defaults.d.ts.map +1 -0
- package/dist/orchestration/defaults.js +22 -0
- package/dist/orchestration/memory-integration.d.ts +58 -0
- package/dist/orchestration/memory-integration.d.ts.map +1 -0
- package/dist/orchestration/memory-integration.js +130 -0
- package/dist/orchestration/orchestrator.d.ts +67 -0
- package/dist/orchestration/orchestrator.d.ts.map +1 -0
- package/dist/orchestration/orchestrator.js +174 -0
- package/dist/orchestration/runtime.d.ts +82 -0
- package/dist/orchestration/runtime.d.ts.map +1 -0
- package/dist/orchestration/runtime.js +251 -0
- package/dist/orchestration/streaming-runtime.d.ts +36 -0
- package/dist/orchestration/streaming-runtime.d.ts.map +1 -0
- package/dist/orchestration/streaming-runtime.js +175 -0
- package/dist/orchestration/ticket-agent.d.ts +70 -0
- package/dist/orchestration/ticket-agent.d.ts.map +1 -0
- package/dist/orchestration/ticket-agent.js +146 -0
- package/dist/skills/activation/index.d.ts +7 -0
- package/dist/skills/activation/index.d.ts.map +1 -0
- package/dist/skills/activation/index.js +6 -0
- package/dist/skills/activation/skill-activator.d.ts +68 -0
- package/dist/skills/activation/skill-activator.d.ts.map +1 -0
- package/dist/skills/activation/skill-activator.js +224 -0
- package/dist/skills/catalog/catalog-search.d.ts +55 -0
- package/dist/skills/catalog/catalog-search.d.ts.map +1 -0
- package/dist/skills/catalog/catalog-search.js +111 -0
- package/dist/skills/catalog/catalog-types.d.ts +81 -0
- package/dist/skills/catalog/catalog-types.d.ts.map +1 -0
- package/dist/skills/catalog/catalog-types.js +66 -0
- package/dist/skills/catalog/index.d.ts +9 -0
- package/dist/skills/catalog/index.d.ts.map +1 -0
- package/dist/skills/catalog/index.js +7 -0
- package/dist/skills/catalog/vercel-catalog.d.ts +42 -0
- package/dist/skills/catalog/vercel-catalog.d.ts.map +1 -0
- package/dist/skills/catalog/vercel-catalog.js +189 -0
- package/dist/skills/compat/index.d.ts +9 -0
- package/dist/skills/compat/index.d.ts.map +1 -0
- package/dist/skills/compat/index.js +8 -0
- package/dist/skills/compat/skill-enhancer.d.ts +37 -0
- package/dist/skills/compat/skill-enhancer.d.ts.map +1 -0
- package/dist/skills/compat/skill-enhancer.js +76 -0
- package/dist/skills/compat/tool-mapper.d.ts +61 -0
- package/dist/skills/compat/tool-mapper.d.ts.map +1 -0
- package/dist/skills/compat/tool-mapper.js +168 -0
- package/dist/skills/compat/vercel-compat.d.ts +33 -0
- package/dist/skills/compat/vercel-compat.d.ts.map +1 -0
- package/dist/skills/compat/vercel-compat.js +132 -0
- package/dist/skills/index.d.ts +40 -0
- package/dist/skills/index.d.ts.map +1 -0
- package/dist/skills/index.js +47 -0
- package/dist/skills/integration/agent-skill-provider.d.ts +94 -0
- package/dist/skills/integration/agent-skill-provider.d.ts.map +1 -0
- package/dist/skills/integration/agent-skill-provider.js +161 -0
- package/dist/skills/integration/index.d.ts +7 -0
- package/dist/skills/integration/index.d.ts.map +1 -0
- package/dist/skills/integration/index.js +6 -0
- package/dist/skills/loader/github-loader.d.ts +61 -0
- package/dist/skills/loader/github-loader.d.ts.map +1 -0
- package/dist/skills/loader/github-loader.js +176 -0
- package/dist/skills/loader/index.d.ts +10 -0
- package/dist/skills/loader/index.d.ts.map +1 -0
- package/dist/skills/loader/index.js +9 -0
- package/dist/skills/loader/local-loader.d.ts +56 -0
- package/dist/skills/loader/local-loader.d.ts.map +1 -0
- package/dist/skills/loader/local-loader.js +186 -0
- package/dist/skills/loader/vercel-loader.d.ts +64 -0
- package/dist/skills/loader/vercel-loader.d.ts.map +1 -0
- package/dist/skills/loader/vercel-loader.js +313 -0
- package/dist/skills/loader/vercel-types.d.ts +64 -0
- package/dist/skills/loader/vercel-types.d.ts.map +1 -0
- package/dist/skills/loader/vercel-types.js +55 -0
- package/dist/skills/parser/index.d.ts +7 -0
- package/dist/skills/parser/index.d.ts.map +1 -0
- package/dist/skills/parser/index.js +6 -0
- package/dist/skills/parser/skill-md-parser.d.ts +64 -0
- package/dist/skills/parser/skill-md-parser.d.ts.map +1 -0
- package/dist/skills/parser/skill-md-parser.js +242 -0
- package/dist/skills/registry/index.d.ts +7 -0
- package/dist/skills/registry/index.d.ts.map +1 -0
- package/dist/skills/registry/index.js +6 -0
- package/dist/skills/registry/skill-registry.d.ts +133 -0
- package/dist/skills/registry/skill-registry.d.ts.map +1 -0
- package/dist/skills/registry/skill-registry.js +373 -0
- package/dist/skills/types.d.ts +216 -0
- package/dist/skills/types.d.ts.map +1 -0
- package/dist/skills/types.js +176 -0
- package/dist/templates/agent-spec.d.ts +138 -0
- package/dist/templates/agent-spec.d.ts.map +1 -0
- package/dist/templates/agent-spec.js +138 -0
- package/dist/templates/index.d.ts +56 -0
- package/dist/templates/index.d.ts.map +1 -0
- package/dist/templates/index.js +58 -0
- package/dist/templates/prompt-spec.d.ts +140 -0
- package/dist/templates/prompt-spec.d.ts.map +1 -0
- package/dist/templates/prompt-spec.js +210 -0
- package/dist/templates/skill-spec.d.ts +106 -0
- package/dist/templates/skill-spec.d.ts.map +1 -0
- package/dist/templates/skill-spec.js +119 -0
- package/dist/tools/base.d.ts +74 -0
- package/dist/tools/base.d.ts.map +1 -0
- package/dist/tools/base.js +6 -0
- package/dist/tools/cms/collection-tools.d.ts +36 -0
- package/dist/tools/cms/collection-tools.d.ts.map +1 -0
- package/dist/tools/cms/collection-tools.js +178 -0
- package/dist/tools/cms/factory.d.ts +89 -0
- package/dist/tools/cms/factory.d.ts.map +1 -0
- package/dist/tools/cms/factory.js +462 -0
- package/dist/tools/cms/global-tools.d.ts +21 -0
- package/dist/tools/cms/global-tools.d.ts.map +1 -0
- package/dist/tools/cms/global-tools.js +92 -0
- package/dist/tools/cms/index.d.ts +11 -0
- package/dist/tools/cms/index.d.ts.map +1 -0
- package/dist/tools/cms/index.js +11 -0
- package/dist/tools/cms/media-tools.d.ts +31 -0
- package/dist/tools/cms/media-tools.d.ts.map +1 -0
- package/dist/tools/cms/media-tools.js +140 -0
- package/dist/tools/cms/user-tools.d.ts +31 -0
- package/dist/tools/cms/user-tools.d.ts.map +1 -0
- package/dist/tools/cms/user-tools.js +135 -0
- package/dist/tools/deduplicator.d.ts +19 -0
- package/dist/tools/deduplicator.d.ts.map +1 -0
- package/dist/tools/deduplicator.js +53 -0
- package/dist/tools/document-summarizer.d.ts +11 -0
- package/dist/tools/document-summarizer.d.ts.map +1 -0
- package/dist/tools/document-summarizer.js +82 -0
- package/dist/tools/mcp-adapter.d.ts +66 -0
- package/dist/tools/mcp-adapter.d.ts.map +1 -0
- package/dist/tools/mcp-adapter.js +152 -0
- package/dist/tools/memory/index.d.ts +3 -0
- package/dist/tools/memory/index.d.ts.map +1 -0
- package/dist/tools/memory/index.js +1 -0
- package/dist/tools/memory/store-memory.d.ts +39 -0
- package/dist/tools/memory/store-memory.d.ts.map +1 -0
- package/dist/tools/memory/store-memory.js +94 -0
- package/dist/tools/registry.d.ts +14 -0
- package/dist/tools/registry.d.ts.map +1 -0
- package/dist/tools/registry.js +48 -0
- package/dist/tools/ticket-tools.d.ts +31 -0
- package/dist/tools/ticket-tools.d.ts.map +1 -0
- package/dist/tools/ticket-tools.js +74 -0
- package/dist/tools/web/duck-duck-go.d.ts +52 -0
- package/dist/tools/web/duck-duck-go.d.ts.map +1 -0
- package/dist/tools/web/duck-duck-go.js +202 -0
- package/dist/tools/web/exa.d.ts +34 -0
- package/dist/tools/web/exa.d.ts.map +1 -0
- package/dist/tools/web/exa.js +80 -0
- package/dist/tools/web/index.d.ts +6 -0
- package/dist/tools/web/index.d.ts.map +1 -0
- package/dist/tools/web/index.js +4 -0
- package/dist/tools/web/scraper.d.ts +9 -0
- package/dist/tools/web/scraper.d.ts.map +1 -0
- package/dist/tools/web/scraper.js +118 -0
- package/dist/tools/web/tavily.d.ts +32 -0
- package/dist/tools/web/tavily.d.ts.map +1 -0
- package/dist/tools/web/tavily.js +73 -0
- package/dist/tools/web/types.d.ts +31 -0
- package/dist/tools/web/types.d.ts.map +1 -0
- package/dist/tools/web/types.js +9 -0
- package/package.json +143 -0
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Working Memory
|
|
3
|
+
*
|
|
4
|
+
* Short-term, session-scoped memory for AI agents.
|
|
5
|
+
* Uses CRDTs for conflict-free state management across distributed nodes.
|
|
6
|
+
*
|
|
7
|
+
* - Context: LWWRegister for single-valued state (last writer wins)
|
|
8
|
+
* - Active Agents: ORSet for collection of active agent configurations
|
|
9
|
+
* - Session State: LWWRegister for session metadata
|
|
10
|
+
*/
|
|
11
|
+
import { LWWRegister } from '../crdt/lww-register.js';
|
|
12
|
+
import { ORSet } from '../crdt/or-set.js';
|
|
13
|
+
import { deepClone } from '../utils/deep-clone.js';
|
|
14
|
+
// =============================================================================
|
|
15
|
+
// Working Memory
|
|
16
|
+
// =============================================================================
|
|
17
|
+
/**
|
|
18
|
+
* Working Memory for session-scoped agent state.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* const memory = new WorkingMemory('session-123', 'node-abc')
|
|
23
|
+
* await memory.load()
|
|
24
|
+
*
|
|
25
|
+
* memory.setContext({ userId: 'user-1', theme: 'dark' })
|
|
26
|
+
* const agentTag = memory.addAgent(agentConfig)
|
|
27
|
+
* memory.updateSessionState({ status: 'active' })
|
|
28
|
+
*
|
|
29
|
+
* await memory.save()
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export class WorkingMemory {
|
|
33
|
+
context;
|
|
34
|
+
sessionState;
|
|
35
|
+
activeAgents;
|
|
36
|
+
sessionId;
|
|
37
|
+
nodeId;
|
|
38
|
+
persistence;
|
|
39
|
+
/**
|
|
40
|
+
* Creates a new WorkingMemory instance.
|
|
41
|
+
*
|
|
42
|
+
* @param sessionId - Unique session identifier
|
|
43
|
+
* @param nodeId - Unique node identifier (for CRDT operations)
|
|
44
|
+
* @param persistence - Optional persistence adapter
|
|
45
|
+
*/
|
|
46
|
+
constructor(sessionId, nodeId, persistence) {
|
|
47
|
+
this.sessionId = sessionId;
|
|
48
|
+
this.nodeId = nodeId;
|
|
49
|
+
this.persistence = persistence;
|
|
50
|
+
// Initialize CRDTs
|
|
51
|
+
this.context = new LWWRegister(nodeId, {});
|
|
52
|
+
this.sessionState = new LWWRegister(nodeId, {
|
|
53
|
+
status: 'active',
|
|
54
|
+
});
|
|
55
|
+
this.activeAgents = new ORSet(nodeId);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Sets the entire context object.
|
|
59
|
+
*
|
|
60
|
+
* @param context - Context data to set
|
|
61
|
+
*/
|
|
62
|
+
/**
|
|
63
|
+
* Sets the entire context object.
|
|
64
|
+
*
|
|
65
|
+
* **Performance Note**: This replaces the entire context. For partial updates,
|
|
66
|
+
* use `updateContext()` or `setContextValue()`.
|
|
67
|
+
*
|
|
68
|
+
* **Validation**: The context is validated by LWWRegister (which clones values),
|
|
69
|
+
* but for additional security, consider validating before calling this method.
|
|
70
|
+
*
|
|
71
|
+
* @param context - The complete context object
|
|
72
|
+
*/
|
|
73
|
+
setContext(context) {
|
|
74
|
+
this.context.set(context);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Gets the current context.
|
|
78
|
+
*
|
|
79
|
+
* @returns Current context object
|
|
80
|
+
*/
|
|
81
|
+
getContext() {
|
|
82
|
+
return this.context.get();
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Updates context with partial data.
|
|
86
|
+
* Merges with existing context.
|
|
87
|
+
*
|
|
88
|
+
* @param updates - Partial context updates
|
|
89
|
+
*/
|
|
90
|
+
updateContext(updates) {
|
|
91
|
+
const current = this.context.get();
|
|
92
|
+
this.context.set({
|
|
93
|
+
...current,
|
|
94
|
+
...updates,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Gets a specific context value.
|
|
99
|
+
*
|
|
100
|
+
* @param key - Context key
|
|
101
|
+
* @returns Context value or undefined
|
|
102
|
+
*/
|
|
103
|
+
/**
|
|
104
|
+
* Gets a specific context value by key.
|
|
105
|
+
*
|
|
106
|
+
* **Immutability Guarantee**: Returns a deep clone of object/array values to prevent external mutations.
|
|
107
|
+
* Primitives (strings, numbers, booleans, null) are returned as-is.
|
|
108
|
+
*
|
|
109
|
+
* @param key - The context key to retrieve
|
|
110
|
+
* @returns The context value (cloned if object/array, direct reference if primitive)
|
|
111
|
+
*/
|
|
112
|
+
getContextValue(key) {
|
|
113
|
+
const context = this.context.get(); // Already cloned by LWWRegister.get()
|
|
114
|
+
const value = context[key];
|
|
115
|
+
// Explicitly clone the value for clarity and to ensure immutability
|
|
116
|
+
// Note: This may result in double cloning (context is already cloned),
|
|
117
|
+
// but it makes the API contract explicit and safe
|
|
118
|
+
if (value !== null && typeof value === 'object') {
|
|
119
|
+
return deepClone(value);
|
|
120
|
+
}
|
|
121
|
+
return value;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Sets a specific context value.
|
|
125
|
+
*
|
|
126
|
+
* **Performance Note**: This method clones the entire context object to update
|
|
127
|
+
* a single key. For multiple updates, use `updateContext()` instead.
|
|
128
|
+
*
|
|
129
|
+
* @param key - Context key
|
|
130
|
+
* @param value - Context value
|
|
131
|
+
*/
|
|
132
|
+
setContextValue(key, value) {
|
|
133
|
+
const current = this.context.get();
|
|
134
|
+
this.context.set({
|
|
135
|
+
...current,
|
|
136
|
+
[key]: value,
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Adds an agent to the active agents set.
|
|
141
|
+
*
|
|
142
|
+
* @param agent - Agent configuration
|
|
143
|
+
* @returns Unique tag for this agent addition
|
|
144
|
+
*/
|
|
145
|
+
addAgent(agent) {
|
|
146
|
+
return this.activeAgents.add(agent);
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Removes an agent by tag.
|
|
150
|
+
*
|
|
151
|
+
* @param tag - Tag returned from addAgent
|
|
152
|
+
* @returns true if agent was removed
|
|
153
|
+
*/
|
|
154
|
+
removeAgent(tag) {
|
|
155
|
+
return this.activeAgents.remove(tag);
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Removes an agent by ID (removes all instances).
|
|
159
|
+
*
|
|
160
|
+
* @param agentId - Agent ID to remove
|
|
161
|
+
* @returns Number of instances removed
|
|
162
|
+
*/
|
|
163
|
+
removeAgentById(agentId) {
|
|
164
|
+
const agents = this.activeAgents.values();
|
|
165
|
+
let count = 0;
|
|
166
|
+
for (const agent of agents) {
|
|
167
|
+
if (agent.id === agentId) {
|
|
168
|
+
const entries = this.activeAgents.entries();
|
|
169
|
+
for (const [tag, agentValue] of entries) {
|
|
170
|
+
if (agentValue.id === agentId) {
|
|
171
|
+
this.activeAgents.remove(tag);
|
|
172
|
+
count++;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
break;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
return count;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Gets all active agents.
|
|
182
|
+
*
|
|
183
|
+
* @returns Array of active agent configurations
|
|
184
|
+
*/
|
|
185
|
+
getActiveAgents() {
|
|
186
|
+
return this.activeAgents.values();
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Checks if an agent is active.
|
|
190
|
+
*
|
|
191
|
+
* @param agentId - Agent ID to check
|
|
192
|
+
* @returns true if agent is active
|
|
193
|
+
*/
|
|
194
|
+
hasAgent(agentId) {
|
|
195
|
+
return this.activeAgents.values().some((agent) => agent.id === agentId);
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Updates session state with partial data.
|
|
199
|
+
*
|
|
200
|
+
* @param state - Partial session state
|
|
201
|
+
*/
|
|
202
|
+
updateSessionState(state) {
|
|
203
|
+
const current = this.sessionState.get();
|
|
204
|
+
this.sessionState.set({
|
|
205
|
+
...current,
|
|
206
|
+
...state,
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Gets the current session state.
|
|
211
|
+
*
|
|
212
|
+
* @returns Current session state
|
|
213
|
+
*/
|
|
214
|
+
getSessionState() {
|
|
215
|
+
return this.sessionState.get();
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Merges another WorkingMemory into this one.
|
|
219
|
+
* Uses CRDT merge operations for conflict resolution.
|
|
220
|
+
*
|
|
221
|
+
* @param other - WorkingMemory to merge
|
|
222
|
+
* @returns New merged WorkingMemory
|
|
223
|
+
*/
|
|
224
|
+
merge(other) {
|
|
225
|
+
const merged = new WorkingMemory(this.sessionId, this.nodeId, this.persistence);
|
|
226
|
+
// Merge CRDTs
|
|
227
|
+
merged.context = this.context.merge(other.context);
|
|
228
|
+
merged.sessionState = this.sessionState.merge(other.sessionState);
|
|
229
|
+
merged.activeAgents = this.activeAgents.merge(other.activeAgents);
|
|
230
|
+
return merged;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Loads state from database.
|
|
234
|
+
*
|
|
235
|
+
* @throws Error if persistence is not configured
|
|
236
|
+
*/
|
|
237
|
+
async load() {
|
|
238
|
+
if (!this.persistence) {
|
|
239
|
+
throw new Error('Persistence not configured. Pass persistence to constructor.');
|
|
240
|
+
}
|
|
241
|
+
const crdtId = `working-memory:${this.sessionId}`;
|
|
242
|
+
const states = await this.persistence.loadCompositeState(crdtId);
|
|
243
|
+
// Restore context
|
|
244
|
+
const contextData = states.get('lww_register:context');
|
|
245
|
+
if (contextData && 'value' in contextData) {
|
|
246
|
+
const contextReg = LWWRegister.fromData(contextData);
|
|
247
|
+
this.context = contextReg;
|
|
248
|
+
}
|
|
249
|
+
// Restore session state
|
|
250
|
+
const sessionStateData = states.get('lww_register:sessionState');
|
|
251
|
+
if (sessionStateData && 'value' in sessionStateData) {
|
|
252
|
+
const sessionStateReg = LWWRegister.fromData(sessionStateData);
|
|
253
|
+
this.sessionState = sessionStateReg;
|
|
254
|
+
}
|
|
255
|
+
// Restore active agents
|
|
256
|
+
const agentsData = states.get('or_set:activeAgents');
|
|
257
|
+
if (agentsData && 'added' in agentsData) {
|
|
258
|
+
const agentsSet = ORSet.fromData(agentsData);
|
|
259
|
+
this.activeAgents = agentsSet;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Saves state to database.
|
|
264
|
+
*
|
|
265
|
+
* @throws Error if persistence is not configured
|
|
266
|
+
*/
|
|
267
|
+
async save() {
|
|
268
|
+
if (!this.persistence) {
|
|
269
|
+
throw new Error('Persistence not configured. Pass persistence to constructor.');
|
|
270
|
+
}
|
|
271
|
+
const crdtId = `working-memory:${this.sessionId}`;
|
|
272
|
+
const states = new Map();
|
|
273
|
+
// Save all CRDTs with composite keys
|
|
274
|
+
states.set('lww_register:context', this.context.toData());
|
|
275
|
+
states.set('lww_register:sessionState', this.sessionState.toData());
|
|
276
|
+
states.set('or_set:activeAgents', this.activeAgents.toData());
|
|
277
|
+
await this.persistence.saveCompositeState(crdtId, states);
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Serializes WorkingMemory to plain object.
|
|
281
|
+
*
|
|
282
|
+
* @returns Serialized data
|
|
283
|
+
*/
|
|
284
|
+
toData() {
|
|
285
|
+
return {
|
|
286
|
+
sessionId: this.sessionId,
|
|
287
|
+
nodeId: this.nodeId,
|
|
288
|
+
context: this.context.toData(),
|
|
289
|
+
sessionState: this.sessionState.toData(),
|
|
290
|
+
activeAgents: this.activeAgents.toData(),
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Deserializes WorkingMemory from plain object.
|
|
295
|
+
*
|
|
296
|
+
* @param data - Serialized data
|
|
297
|
+
* @param persistence - Optional persistence adapter
|
|
298
|
+
* @returns New WorkingMemory instance
|
|
299
|
+
*/
|
|
300
|
+
static fromData(data, persistence) {
|
|
301
|
+
const memory = new WorkingMemory(data.sessionId, data.nodeId, persistence);
|
|
302
|
+
memory.context = LWWRegister.fromData(data.context);
|
|
303
|
+
memory.sessionState = LWWRegister.fromData(data.sessionState);
|
|
304
|
+
memory.activeAgents = ORSet.fromData(data.activeAgents);
|
|
305
|
+
return memory;
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Creates a copy of this WorkingMemory.
|
|
309
|
+
*
|
|
310
|
+
* @returns New WorkingMemory with same state
|
|
311
|
+
*/
|
|
312
|
+
clone() {
|
|
313
|
+
return WorkingMemory.fromData(this.toData(), this.persistence);
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* Gets the session ID.
|
|
317
|
+
*/
|
|
318
|
+
getSessionId() {
|
|
319
|
+
return this.sessionId;
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Gets the node ID.
|
|
323
|
+
*/
|
|
324
|
+
getNodeId() {
|
|
325
|
+
return this.nodeId;
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* Gets the context register's timestamp.
|
|
329
|
+
* Used for proper CRDT merge semantics.
|
|
330
|
+
*
|
|
331
|
+
* @returns Timestamp of the last context update
|
|
332
|
+
*/
|
|
333
|
+
getContextTimestamp() {
|
|
334
|
+
return this.context.getTimestamp();
|
|
335
|
+
}
|
|
336
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deep Clone Utility
|
|
3
|
+
*
|
|
4
|
+
* @deprecated This file has been moved to @revealui/core/utils/deep-clone.ts
|
|
5
|
+
* Re-exporting from core for backward compatibility during migration.
|
|
6
|
+
*
|
|
7
|
+
* Import directly from '@revealui/core/utils/deep-clone' instead.
|
|
8
|
+
*/
|
|
9
|
+
export { deepClone } from '@revealui/core/utils/deep-clone';
|
|
10
|
+
//# sourceMappingURL=deep-clone.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deep-clone.d.ts","sourceRoot":"","sources":["../../../src/memory/utils/deep-clone.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deep Clone Utility
|
|
3
|
+
*
|
|
4
|
+
* @deprecated This file has been moved to @revealui/core/utils/deep-clone.ts
|
|
5
|
+
* Re-exporting from core for backward compatibility during migration.
|
|
6
|
+
*
|
|
7
|
+
* Import directly from '@revealui/core/utils/deep-clone' instead.
|
|
8
|
+
*/
|
|
9
|
+
export { deepClone } from '@revealui/core/utils/deep-clone';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility functions
|
|
3
|
+
*/
|
|
4
|
+
export { deepClone } from './deep-clone.js';
|
|
5
|
+
export { createLogger, defaultLogger, type Logger } from './logger.js';
|
|
6
|
+
export { findAgentContextById, findAgentMemoriesByUserId, findAgentMemoryById, findNodeIdMappingByEntity, findNodeIdMappingByHash, findUserById, } from './sql-helpers.js';
|
|
7
|
+
export { estimateObjectSize, hasCircularReference, validateContext, validateContextKey, validateContextSize, validateContextValue, validateObjectDepth, } from './validation.js';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/memory/utils/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,KAAK,MAAM,EAAE,MAAM,aAAa,CAAA;AACtE,OAAO,EACL,oBAAoB,EACpB,yBAAyB,EACzB,mBAAmB,EACnB,yBAAyB,EACzB,uBAAuB,EACvB,YAAY,GACb,MAAM,kBAAkB,CAAA;AACzB,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,eAAe,EACf,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,iBAAiB,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility functions
|
|
3
|
+
*/
|
|
4
|
+
export { deepClone } from './deep-clone.js';
|
|
5
|
+
export { createLogger, defaultLogger } from './logger.js';
|
|
6
|
+
export { findAgentContextById, findAgentMemoriesByUserId, findAgentMemoryById, findNodeIdMappingByEntity, findNodeIdMappingByHash, findUserById, } from './sql-helpers.js';
|
|
7
|
+
export { estimateObjectSize, hasCircularReference, validateContext, validateContextKey, validateContextSize, validateContextValue, validateObjectDepth, } from './validation.js';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Simple Logger Utility
|
|
3
|
+
*
|
|
4
|
+
* Provides a minimal logging interface that can be easily replaced
|
|
5
|
+
* with a proper logging service later. Respects environment and log levels.
|
|
6
|
+
*/
|
|
7
|
+
export interface Logger {
|
|
8
|
+
info: (...args: unknown[]) => void;
|
|
9
|
+
warn: (...args: unknown[]) => void;
|
|
10
|
+
error: (...args: unknown[]) => void;
|
|
11
|
+
debug: (...args: unknown[]) => void;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Creates a logger instance with optional prefix
|
|
15
|
+
*/
|
|
16
|
+
export declare function createLogger(prefix?: string): Logger;
|
|
17
|
+
/**
|
|
18
|
+
* Default logger instance
|
|
19
|
+
*/
|
|
20
|
+
export declare const defaultLogger: Logger;
|
|
21
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../src/memory/utils/logger.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,WAAW,MAAM;IACrB,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAA;IAClC,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAA;IAClC,KAAK,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAA;IACnC,KAAK,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAA;CACpC;AA0DD;;GAEG;AACH,wBAAgB,YAAY,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED;;GAEG;AACH,eAAO,MAAM,aAAa,EAAE,MAAqC,CAAA"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Simple Logger Utility
|
|
3
|
+
*
|
|
4
|
+
* Provides a minimal logging interface that can be easily replaced
|
|
5
|
+
* with a proper logging service later. Respects environment and log levels.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Environment-aware logger implementation
|
|
9
|
+
* Only logs when appropriate for the environment and log level
|
|
10
|
+
*/
|
|
11
|
+
class SimpleLogger {
|
|
12
|
+
prefix;
|
|
13
|
+
minLevel;
|
|
14
|
+
isProduction;
|
|
15
|
+
constructor(prefix = '[Memory]') {
|
|
16
|
+
this.prefix = prefix;
|
|
17
|
+
this.isProduction = process.env.NODE_ENV === 'production';
|
|
18
|
+
this.minLevel = process.env.LOG_LEVEL || (this.isProduction ? 'warn' : 'debug');
|
|
19
|
+
}
|
|
20
|
+
shouldLog(level) {
|
|
21
|
+
// Never log debug or info in production
|
|
22
|
+
if (this.isProduction && (level === 'debug' || level === 'info')) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
const levels = ['debug', 'info', 'warn', 'error'];
|
|
26
|
+
return levels.indexOf(level) >= levels.indexOf(this.minLevel);
|
|
27
|
+
}
|
|
28
|
+
info(...args) {
|
|
29
|
+
// Info logs are never shown in production
|
|
30
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
31
|
+
console.log(this.prefix, ...args);
|
|
32
|
+
}
|
|
33
|
+
// In production: complete no-op
|
|
34
|
+
}
|
|
35
|
+
warn(...args) {
|
|
36
|
+
// Warning logs are never shown in production
|
|
37
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
38
|
+
console.warn(this.prefix, ...args);
|
|
39
|
+
}
|
|
40
|
+
// In production: complete no-op
|
|
41
|
+
}
|
|
42
|
+
error(...args) {
|
|
43
|
+
if (this.shouldLog('error')) {
|
|
44
|
+
console.error(this.prefix, ...args);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
debug(...args) {
|
|
48
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
49
|
+
console.debug(this.prefix, ...args);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Creates a logger instance with optional prefix
|
|
55
|
+
*/
|
|
56
|
+
export function createLogger(prefix) {
|
|
57
|
+
return new SimpleLogger(prefix);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Default logger instance
|
|
61
|
+
*/
|
|
62
|
+
export const defaultLogger = new SimpleLogger('[Memory]');
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SQL Helper Utilities
|
|
3
|
+
*
|
|
4
|
+
* Provides type-safe raw SQL query helpers to work around Neon HTTP driver
|
|
5
|
+
* compatibility issues with Drizzle's relational query builder.
|
|
6
|
+
*
|
|
7
|
+
* These helpers use Drizzle's sql tagged template for type safety and
|
|
8
|
+
* SQL injection prevention.
|
|
9
|
+
*/
|
|
10
|
+
import type { AgentMemory } from '@revealui/contracts/agents';
|
|
11
|
+
import type { NodeIdMappingsRow } from '@revealui/contracts/generated';
|
|
12
|
+
import type { Database } from '@revealui/db/client';
|
|
13
|
+
/**
|
|
14
|
+
* Finds a node ID mapping by hash (primary key).
|
|
15
|
+
*
|
|
16
|
+
* @param db - Database client
|
|
17
|
+
* @param hash - SHA-256 hash of entity ID
|
|
18
|
+
* @returns Node ID mapping or undefined if not found
|
|
19
|
+
*/
|
|
20
|
+
export declare function findNodeIdMappingByHash(db: Database, hash: string): Promise<NodeIdMappingsRow | undefined>;
|
|
21
|
+
/**
|
|
22
|
+
* Finds a node ID mapping by entity ID and type.
|
|
23
|
+
*
|
|
24
|
+
* @param db - Database client
|
|
25
|
+
* @param entityType - Type of entity ('session' or 'user')
|
|
26
|
+
* @param entityId - Entity identifier
|
|
27
|
+
* @returns Node ID mapping or undefined if not found
|
|
28
|
+
*/
|
|
29
|
+
export declare function findNodeIdMappingByEntity(db: Database, entityType: 'session' | 'user', entityId: string): Promise<NodeIdMappingsRow | undefined>;
|
|
30
|
+
/**
|
|
31
|
+
* Finds an agent memory by ID (returns raw database record format).
|
|
32
|
+
*
|
|
33
|
+
* @deprecated Use VectorMemoryService.getById() instead. This function queries
|
|
34
|
+
* agent_memories which is now in the vector database (Supabase), not REST database.
|
|
35
|
+
* If you need to query memories, use VectorMemoryService which uses the correct database.
|
|
36
|
+
*
|
|
37
|
+
* @param db - Database client (NOTE: Should be vector client, but type doesn't enforce this)
|
|
38
|
+
* @param memoryId - Memory identifier
|
|
39
|
+
* @returns Raw database memory record or undefined if not found
|
|
40
|
+
*/
|
|
41
|
+
export declare function findAgentMemoryById(db: Database, memoryId: string): Promise<{
|
|
42
|
+
id: string;
|
|
43
|
+
version: number;
|
|
44
|
+
content: string;
|
|
45
|
+
type: string;
|
|
46
|
+
source: unknown;
|
|
47
|
+
embedding: number[] | null;
|
|
48
|
+
embeddingMetadata: unknown;
|
|
49
|
+
metadata: unknown;
|
|
50
|
+
accessCount: number | null;
|
|
51
|
+
accessedAt: Date | null;
|
|
52
|
+
verified: boolean | null;
|
|
53
|
+
createdAt: Date;
|
|
54
|
+
expiresAt: Date | null;
|
|
55
|
+
} | undefined>;
|
|
56
|
+
/**
|
|
57
|
+
* Finds agent memories by user ID.
|
|
58
|
+
*
|
|
59
|
+
* @deprecated Use VectorMemoryService.searchSimilar() or VectorMemoryService with filters instead.
|
|
60
|
+
* This function queries agent_memories which is now in the vector database (Supabase).
|
|
61
|
+
* If you need to query memories, use VectorMemoryService which uses the correct database.
|
|
62
|
+
*
|
|
63
|
+
* @param db - Database client (NOTE: Should be vector client, but type doesn't enforce this)
|
|
64
|
+
* @param userId - User identifier
|
|
65
|
+
* @returns Array of agent memories
|
|
66
|
+
*/
|
|
67
|
+
export declare function findAgentMemoriesByUserId(db: Database, userId: string): Promise<AgentMemory[]>;
|
|
68
|
+
/**
|
|
69
|
+
* Finds an agent context by CRDT ID (returns raw database record format).
|
|
70
|
+
*
|
|
71
|
+
* @param db - Database client
|
|
72
|
+
* @param crdtId - CRDT identifier (format: sessionId:agentId)
|
|
73
|
+
* @returns Raw database context record or undefined if not found
|
|
74
|
+
*/
|
|
75
|
+
export declare function findAgentContextById(db: Database, crdtId: string): Promise<{
|
|
76
|
+
id: string;
|
|
77
|
+
version: number;
|
|
78
|
+
sessionId: string;
|
|
79
|
+
agentId: string;
|
|
80
|
+
context: unknown;
|
|
81
|
+
priority: number | null;
|
|
82
|
+
embedding: number[] | null;
|
|
83
|
+
createdAt: Date;
|
|
84
|
+
updatedAt: Date;
|
|
85
|
+
} | undefined>;
|
|
86
|
+
/**
|
|
87
|
+
* Finds a user by ID.
|
|
88
|
+
*
|
|
89
|
+
* @param db - Database client
|
|
90
|
+
* @param userId - User identifier
|
|
91
|
+
* @returns User record or undefined if not found
|
|
92
|
+
*/
|
|
93
|
+
export declare function findUserById(db: Database, userId: string): Promise<{
|
|
94
|
+
id: string;
|
|
95
|
+
preferences: unknown;
|
|
96
|
+
} | undefined>;
|
|
97
|
+
//# sourceMappingURL=sql-helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sql-helpers.d.ts","sourceRoot":"","sources":["../../../src/memory/utils/sql-helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AAC7D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAA;AACtE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAmDnD;;;;;;GAMG;AACH,wBAAsB,uBAAuB,CAC3C,EAAE,EAAE,QAAQ,EACZ,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,iBAAiB,GAAG,SAAS,CAAC,CA8BxC;AAED;;;;;;;GAOG;AACH,wBAAsB,yBAAyB,CAC7C,EAAE,EAAE,QAAQ,EACZ,UAAU,EAAE,SAAS,GAAG,MAAM,EAC9B,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,iBAAiB,GAAG,SAAS,CAAC,CA6BxC;AAMD;;;;;;;;;;GAUG;AACH,wBAAsB,mBAAmB,CACvC,EAAE,EAAE,QAAQ,EACZ,QAAQ,EAAE,MAAM,GACf,OAAO,CACN;IACE,EAAE,EAAE,MAAM,CAAA;IACV,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,OAAO,CAAA;IACf,SAAS,EAAE,MAAM,EAAE,GAAG,IAAI,CAAA;IAC1B,iBAAiB,EAAE,OAAO,CAAA;IAC1B,QAAQ,EAAE,OAAO,CAAA;IACjB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,UAAU,EAAE,IAAI,GAAG,IAAI,CAAA;IACvB,QAAQ,EAAE,OAAO,GAAG,IAAI,CAAA;IACxB,SAAS,EAAE,IAAI,CAAA;IACf,SAAS,EAAE,IAAI,GAAG,IAAI,CAAA;CACvB,GACD,SAAS,CACZ,CA+BA;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,yBAAyB,CAC7C,EAAE,EAAE,QAAQ,EACZ,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,WAAW,EAAE,CAAC,CAoCxB;AAMD;;;;;;GAMG;AACH,wBAAsB,oBAAoB,CACxC,EAAE,EAAE,QAAQ,EACZ,MAAM,EAAE,MAAM,GACb,OAAO,CACN;IACE,EAAE,EAAE,MAAM,CAAA;IACV,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,OAAO,CAAA;IAChB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,SAAS,EAAE,MAAM,EAAE,GAAG,IAAI,CAAA;IAC1B,SAAS,EAAE,IAAI,CAAA;IACf,SAAS,EAAE,IAAI,CAAA;CAChB,GACD,SAAS,CACZ,CAwBA;AAMD;;;;;;GAMG;AACH,wBAAsB,YAAY,CAChC,EAAE,EAAE,QAAQ,EACZ,MAAM,EAAE,MAAM,GACb,OAAO,CAAC;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,OAAO,CAAA;CAAE,GAAG,SAAS,CAAC,CAU3D"}
|