@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,276 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useWorkingMemory Hook
|
|
3
|
+
*
|
|
4
|
+
* React hook for managing working memory in client components.
|
|
5
|
+
*/
|
|
6
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
7
|
+
const isRecord = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
8
|
+
const isSessionStatus = (value) => value === 'active' || value === 'paused' || value === 'completed';
|
|
9
|
+
const isTaskStatus = (value) => value === 'pending' || value === 'running' || value === 'completed' || value === 'failed';
|
|
10
|
+
const isActiveAgent = (value) => {
|
|
11
|
+
if (!isRecord(value))
|
|
12
|
+
return false;
|
|
13
|
+
return (typeof value.id === 'string' &&
|
|
14
|
+
typeof value.name === 'string' &&
|
|
15
|
+
typeof value.description === 'string' &&
|
|
16
|
+
typeof value.model === 'string' &&
|
|
17
|
+
typeof value.systemPrompt === 'string' &&
|
|
18
|
+
Array.isArray(value.tools) &&
|
|
19
|
+
Array.isArray(value.capabilities) &&
|
|
20
|
+
value.capabilities.every((capability) => typeof capability === 'string') &&
|
|
21
|
+
typeof value.temperature === 'number' &&
|
|
22
|
+
typeof value.maxTokens === 'number');
|
|
23
|
+
};
|
|
24
|
+
const parseSessionState = (value) => {
|
|
25
|
+
if (!isRecord(value)) {
|
|
26
|
+
return { status: 'active' };
|
|
27
|
+
}
|
|
28
|
+
const status = isSessionStatus(value.status) ? value.status : 'active';
|
|
29
|
+
const sessionState = { status };
|
|
30
|
+
if (isRecord(value.focus)) {
|
|
31
|
+
const focusValue = value.focus;
|
|
32
|
+
const selection = Array.isArray(focusValue.selection)
|
|
33
|
+
? focusValue.selection.filter((item) => typeof item === 'string')
|
|
34
|
+
: undefined;
|
|
35
|
+
const focus = {
|
|
36
|
+
siteId: typeof focusValue.siteId === 'string' ? focusValue.siteId : undefined,
|
|
37
|
+
pageId: typeof focusValue.pageId === 'string' ? focusValue.pageId : undefined,
|
|
38
|
+
blockId: typeof focusValue.blockId === 'string' ? focusValue.blockId : undefined,
|
|
39
|
+
selection: selection && selection.length > 0 ? selection : undefined,
|
|
40
|
+
};
|
|
41
|
+
if (focus.siteId || focus.pageId || focus.blockId || focus.selection) {
|
|
42
|
+
sessionState.focus = focus;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (isRecord(value.currentTask)) {
|
|
46
|
+
const taskValue = value.currentTask;
|
|
47
|
+
const id = typeof taskValue.id === 'string' ? taskValue.id : undefined;
|
|
48
|
+
const description = typeof taskValue.description === 'string' ? taskValue.description : undefined;
|
|
49
|
+
let taskStatus;
|
|
50
|
+
if (isTaskStatus(taskValue.status)) {
|
|
51
|
+
taskStatus = taskValue.status;
|
|
52
|
+
}
|
|
53
|
+
const progress = typeof taskValue.progress === 'number' ? taskValue.progress : undefined;
|
|
54
|
+
if (id && description && taskStatus) {
|
|
55
|
+
sessionState.currentTask = {
|
|
56
|
+
id,
|
|
57
|
+
description,
|
|
58
|
+
status: taskStatus,
|
|
59
|
+
progress,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return sessionState;
|
|
64
|
+
};
|
|
65
|
+
const parseContextPayload = (payload) => {
|
|
66
|
+
if (!isRecord(payload))
|
|
67
|
+
return {};
|
|
68
|
+
return isRecord(payload.context) ? payload.context : {};
|
|
69
|
+
};
|
|
70
|
+
const parseSessionPayload = (payload) => {
|
|
71
|
+
if (!isRecord(payload))
|
|
72
|
+
return { status: 'active' };
|
|
73
|
+
return parseSessionState(payload.sessionState);
|
|
74
|
+
};
|
|
75
|
+
const parseActiveAgentsPayload = (payload) => {
|
|
76
|
+
if (!isRecord(payload))
|
|
77
|
+
return [];
|
|
78
|
+
return Array.isArray(payload.activeAgents) ? payload.activeAgents.filter(isActiveAgent) : [];
|
|
79
|
+
};
|
|
80
|
+
const parseWorkingPayload = (payload) => ({
|
|
81
|
+
context: parseContextPayload(payload),
|
|
82
|
+
sessionState: parseSessionPayload(payload),
|
|
83
|
+
activeAgents: parseActiveAgentsPayload(payload),
|
|
84
|
+
});
|
|
85
|
+
// =============================================================================
|
|
86
|
+
// Hook
|
|
87
|
+
// =============================================================================
|
|
88
|
+
/**
|
|
89
|
+
* React hook for working memory management.
|
|
90
|
+
*
|
|
91
|
+
* @param sessionId - Session identifier
|
|
92
|
+
* @param options - Hook options
|
|
93
|
+
* @returns Working memory state and operations
|
|
94
|
+
*/
|
|
95
|
+
export function useWorkingMemory(sessionId, options = {}) {
|
|
96
|
+
const { autoSync = false, syncInterval = 5000 } = options;
|
|
97
|
+
const [context, setContextState] = useState({});
|
|
98
|
+
const [sessionState, setSessionStateState] = useState({
|
|
99
|
+
status: 'active',
|
|
100
|
+
});
|
|
101
|
+
const [activeAgents, setActiveAgents] = useState([]);
|
|
102
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
103
|
+
const [error, setError] = useState(null);
|
|
104
|
+
// Load initial state
|
|
105
|
+
useEffect(() => {
|
|
106
|
+
let mounted = true;
|
|
107
|
+
async function load() {
|
|
108
|
+
try {
|
|
109
|
+
setIsLoading(true);
|
|
110
|
+
setError(null);
|
|
111
|
+
const response = await fetch(`/api/memory/working/${sessionId}`);
|
|
112
|
+
if (!response.ok) {
|
|
113
|
+
throw new Error(`Failed to load working memory: ${response.statusText}`);
|
|
114
|
+
}
|
|
115
|
+
const payload = (await response.json());
|
|
116
|
+
if (!mounted)
|
|
117
|
+
return;
|
|
118
|
+
const parsed = parseWorkingPayload(payload);
|
|
119
|
+
setContextState(parsed.context);
|
|
120
|
+
setSessionStateState(parsed.sessionState);
|
|
121
|
+
setActiveAgents(parsed.activeAgents);
|
|
122
|
+
}
|
|
123
|
+
catch (err) {
|
|
124
|
+
if (!mounted)
|
|
125
|
+
return;
|
|
126
|
+
setError(err instanceof Error ? err : new Error('Unknown error'));
|
|
127
|
+
}
|
|
128
|
+
finally {
|
|
129
|
+
if (mounted) {
|
|
130
|
+
setIsLoading(false);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
void load();
|
|
135
|
+
return () => {
|
|
136
|
+
mounted = false;
|
|
137
|
+
};
|
|
138
|
+
}, [sessionId]);
|
|
139
|
+
// Sync function
|
|
140
|
+
const sync = useCallback(async () => {
|
|
141
|
+
try {
|
|
142
|
+
const response = await fetch(`/api/memory/working/${sessionId}`);
|
|
143
|
+
if (!response.ok) {
|
|
144
|
+
throw new Error(`Failed to sync working memory: ${response.statusText}`);
|
|
145
|
+
}
|
|
146
|
+
const payload = (await response.json());
|
|
147
|
+
const parsed = parseWorkingPayload(payload);
|
|
148
|
+
setContextState(parsed.context);
|
|
149
|
+
setSessionStateState(parsed.sessionState);
|
|
150
|
+
setActiveAgents(parsed.activeAgents);
|
|
151
|
+
setError(null);
|
|
152
|
+
}
|
|
153
|
+
catch (err) {
|
|
154
|
+
setError(err instanceof Error ? err : new Error('Unknown error'));
|
|
155
|
+
}
|
|
156
|
+
}, [sessionId]);
|
|
157
|
+
// Auto-sync
|
|
158
|
+
useEffect(() => {
|
|
159
|
+
if (!autoSync)
|
|
160
|
+
return;
|
|
161
|
+
const interval = setInterval(() => {
|
|
162
|
+
void sync();
|
|
163
|
+
}, syncInterval);
|
|
164
|
+
return () => clearInterval(interval);
|
|
165
|
+
}, [autoSync, syncInterval, sync]);
|
|
166
|
+
// Set context
|
|
167
|
+
const setContext = useCallback(async (newContext) => {
|
|
168
|
+
try {
|
|
169
|
+
setError(null);
|
|
170
|
+
const response = await fetch(`/api/memory/working/${sessionId}`, {
|
|
171
|
+
method: 'POST',
|
|
172
|
+
headers: { 'Content-Type': 'application/json' },
|
|
173
|
+
body: JSON.stringify({ context: newContext }),
|
|
174
|
+
});
|
|
175
|
+
if (!response.ok) {
|
|
176
|
+
throw new Error(`Failed to update context: ${response.statusText}`);
|
|
177
|
+
}
|
|
178
|
+
const payload = (await response.json());
|
|
179
|
+
setContextState(parseContextPayload(payload));
|
|
180
|
+
}
|
|
181
|
+
catch (err) {
|
|
182
|
+
setError(err instanceof Error ? err : new Error('Unknown error'));
|
|
183
|
+
throw err;
|
|
184
|
+
}
|
|
185
|
+
}, [sessionId]);
|
|
186
|
+
// Update context
|
|
187
|
+
const updateContext = useCallback(async (updates) => {
|
|
188
|
+
const newContext = { ...context, ...updates };
|
|
189
|
+
await setContext(newContext);
|
|
190
|
+
}, [context, setContext]);
|
|
191
|
+
// Get context value
|
|
192
|
+
const getContextValue = useCallback((key) => {
|
|
193
|
+
return context[key];
|
|
194
|
+
}, [context]);
|
|
195
|
+
// Set context value
|
|
196
|
+
const setContextValue = useCallback(async (key, value) => {
|
|
197
|
+
await updateContext({ [key]: value });
|
|
198
|
+
}, [updateContext]);
|
|
199
|
+
// Update session state
|
|
200
|
+
const updateSessionState = useCallback(async (state) => {
|
|
201
|
+
try {
|
|
202
|
+
setError(null);
|
|
203
|
+
const response = await fetch(`/api/memory/working/${sessionId}`, {
|
|
204
|
+
method: 'POST',
|
|
205
|
+
headers: { 'Content-Type': 'application/json' },
|
|
206
|
+
body: JSON.stringify({ sessionState: state }),
|
|
207
|
+
});
|
|
208
|
+
if (!response.ok) {
|
|
209
|
+
throw new Error(`Failed to update session state: ${response.statusText}`);
|
|
210
|
+
}
|
|
211
|
+
const payload = (await response.json());
|
|
212
|
+
setSessionStateState(parseSessionPayload(payload));
|
|
213
|
+
}
|
|
214
|
+
catch (err) {
|
|
215
|
+
setError(err instanceof Error ? err : new Error('Unknown error'));
|
|
216
|
+
throw err;
|
|
217
|
+
}
|
|
218
|
+
}, [sessionId]);
|
|
219
|
+
// Add agent
|
|
220
|
+
const addAgent = useCallback(async (agent) => {
|
|
221
|
+
try {
|
|
222
|
+
setError(null);
|
|
223
|
+
const newAgents = [...activeAgents, agent];
|
|
224
|
+
const response = await fetch(`/api/memory/working/${sessionId}`, {
|
|
225
|
+
method: 'POST',
|
|
226
|
+
headers: { 'Content-Type': 'application/json' },
|
|
227
|
+
body: JSON.stringify({ activeAgents: newAgents }),
|
|
228
|
+
});
|
|
229
|
+
if (!response.ok) {
|
|
230
|
+
throw new Error(`Failed to add agent: ${response.statusText}`);
|
|
231
|
+
}
|
|
232
|
+
const payload = (await response.json());
|
|
233
|
+
setActiveAgents(parseActiveAgentsPayload(payload));
|
|
234
|
+
}
|
|
235
|
+
catch (err) {
|
|
236
|
+
setError(err instanceof Error ? err : new Error('Unknown error'));
|
|
237
|
+
throw err;
|
|
238
|
+
}
|
|
239
|
+
}, [sessionId, activeAgents]);
|
|
240
|
+
// Remove agent
|
|
241
|
+
const removeAgent = useCallback(async (agentId) => {
|
|
242
|
+
try {
|
|
243
|
+
setError(null);
|
|
244
|
+
const newAgents = activeAgents.filter((agent) => agent.id !== agentId);
|
|
245
|
+
const response = await fetch(`/api/memory/working/${sessionId}`, {
|
|
246
|
+
method: 'POST',
|
|
247
|
+
headers: { 'Content-Type': 'application/json' },
|
|
248
|
+
body: JSON.stringify({ activeAgents: newAgents }),
|
|
249
|
+
});
|
|
250
|
+
if (!response.ok) {
|
|
251
|
+
throw new Error(`Failed to remove agent: ${response.statusText}`);
|
|
252
|
+
}
|
|
253
|
+
const payload = (await response.json());
|
|
254
|
+
setActiveAgents(parseActiveAgentsPayload(payload));
|
|
255
|
+
}
|
|
256
|
+
catch (err) {
|
|
257
|
+
setError(err instanceof Error ? err : new Error('Unknown error'));
|
|
258
|
+
throw err;
|
|
259
|
+
}
|
|
260
|
+
}, [sessionId, activeAgents]);
|
|
261
|
+
return {
|
|
262
|
+
context,
|
|
263
|
+
setContext,
|
|
264
|
+
updateContext,
|
|
265
|
+
getContextValue,
|
|
266
|
+
setContextValue,
|
|
267
|
+
sessionState,
|
|
268
|
+
updateSessionState,
|
|
269
|
+
activeAgents,
|
|
270
|
+
addAgent,
|
|
271
|
+
removeAgent,
|
|
272
|
+
isLoading,
|
|
273
|
+
error,
|
|
274
|
+
sync,
|
|
275
|
+
};
|
|
276
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @revealui/ai/client - Client-side AI System
|
|
3
|
+
*
|
|
4
|
+
* React Hooks for AI System - Client-side integration:
|
|
5
|
+
* - useMemory: CRUD operations for memory
|
|
6
|
+
* - useAgentConfig: Agent configuration management
|
|
7
|
+
* - useVectorSearch: Semantic search queries
|
|
8
|
+
*
|
|
9
|
+
* These are client-side React hooks for use in browser environments.
|
|
10
|
+
*
|
|
11
|
+
* @packageDocumentation
|
|
12
|
+
*/
|
|
13
|
+
export * from './hooks/index.js';
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,cAAc,kBAAkB,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @revealui/ai/client - Client-side AI System
|
|
3
|
+
*
|
|
4
|
+
* React Hooks for AI System - Client-side integration:
|
|
5
|
+
* - useMemory: CRUD operations for memory
|
|
6
|
+
* - useAgentConfig: Agent configuration management
|
|
7
|
+
* - useVectorSearch: Semantic search queries
|
|
8
|
+
*
|
|
9
|
+
* These are client-side React hooks for use in browser environments.
|
|
10
|
+
*
|
|
11
|
+
* @packageDocumentation
|
|
12
|
+
*/
|
|
13
|
+
export * from './hooks/index.js';
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Embedding Generation Utilities
|
|
3
|
+
*
|
|
4
|
+
* Functions for generating embeddings using the configured LLM provider.
|
|
5
|
+
* Provider is auto-detected from env vars (OLLAMA_BASE_URL → GROQ → ANTHROPIC).
|
|
6
|
+
* For local/free inference use Ollama with `nomic-embed-text`.
|
|
7
|
+
* Note: Groq and Anthropic do not support embeddings — use Ollama for embedding tasks.
|
|
8
|
+
*/
|
|
9
|
+
import z from 'zod/v4';
|
|
10
|
+
declare const EmbeddingSchema: z.ZodObject<{
|
|
11
|
+
model: z.ZodString;
|
|
12
|
+
vector: z.ZodArray<z.ZodNumber>;
|
|
13
|
+
dimension: z.ZodNumber;
|
|
14
|
+
generatedAt: z.ZodString;
|
|
15
|
+
}, z.core.$strip>;
|
|
16
|
+
type Embedding = z.infer<typeof EmbeddingSchema>;
|
|
17
|
+
export interface GenerateEmbeddingOptions {
|
|
18
|
+
/**
|
|
19
|
+
* Embedding model to use. Provider-specific:
|
|
20
|
+
* - Ollama: 'nomic-embed-text' (default), 'mxbai-embed-large', etc.
|
|
21
|
+
* - OpenAI: 'text-embedding-3-small', 'text-embedding-3-large', 'text-embedding-ada-002'
|
|
22
|
+
* If omitted, the provider uses its own default (Ollama → nomic-embed-text).
|
|
23
|
+
*/
|
|
24
|
+
model?: string;
|
|
25
|
+
cache?: boolean;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Generate an embedding for the given text using the configured LLM provider.
|
|
29
|
+
*
|
|
30
|
+
* @param text - Text to generate embedding for
|
|
31
|
+
* @param options - Options for embedding generation
|
|
32
|
+
* @returns Embedding object with vector and metadata
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```typescript
|
|
36
|
+
* // With Ollama (OLLAMA_BASE_URL set):
|
|
37
|
+
* const embedding = await generateEmbedding('user prefers dark theme')
|
|
38
|
+
* // Returns: { vector: number[], model: 'nomic-embed-text', dimension: 768, generatedAt: '...' }
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export declare function generateEmbedding(text: string, options?: GenerateEmbeddingOptions): Promise<Embedding>;
|
|
42
|
+
/**
|
|
43
|
+
* Generate embeddings for multiple texts in batch.
|
|
44
|
+
*
|
|
45
|
+
* @param texts - Array of texts to generate embeddings for
|
|
46
|
+
* @param options - Options for embedding generation
|
|
47
|
+
* @returns Array of embeddings in the same order as input texts
|
|
48
|
+
*/
|
|
49
|
+
export declare function generateEmbeddings(texts: string[], options?: GenerateEmbeddingOptions): Promise<Embedding[]>;
|
|
50
|
+
export {};
|
|
51
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/embeddings/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,CAAC,MAAM,QAAQ,CAAA;AAGtB,QAAA,MAAM,eAAe;;;;;iBAgBjB,CAAA;AACJ,KAAK,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAA;AAEhD,MAAM,WAAW,wBAAwB;IACvC;;;;;OAKG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,wBAA6B,GACrC,OAAO,CAAC,SAAS,CAAC,CA4BpB;AAED;;;;;;GAMG;AACH,wBAAsB,kBAAkB,CACtC,KAAK,EAAE,MAAM,EAAE,EACf,OAAO,GAAE,wBAA6B,GACrC,OAAO,CAAC,SAAS,EAAE,CAAC,CAMtB"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Embedding Generation Utilities
|
|
3
|
+
*
|
|
4
|
+
* Functions for generating embeddings using the configured LLM provider.
|
|
5
|
+
* Provider is auto-detected from env vars (OLLAMA_BASE_URL → GROQ → ANTHROPIC).
|
|
6
|
+
* For local/free inference use Ollama with `nomic-embed-text`.
|
|
7
|
+
* Note: Groq and Anthropic do not support embeddings — use Ollama for embedding tasks.
|
|
8
|
+
*/
|
|
9
|
+
import z from 'zod/v4';
|
|
10
|
+
import { createLLMClientFromEnv } from '../llm/client.js';
|
|
11
|
+
const EmbeddingSchema = z
|
|
12
|
+
.object({
|
|
13
|
+
/** The embedding model used */
|
|
14
|
+
model: z.string(),
|
|
15
|
+
/** The embedding vector */
|
|
16
|
+
vector: z.array(z.number()),
|
|
17
|
+
/** Dimension of the vector (for validation) */
|
|
18
|
+
dimension: z.number().int().positive(),
|
|
19
|
+
/** When this embedding was generated */
|
|
20
|
+
generatedAt: z.string().datetime(),
|
|
21
|
+
})
|
|
22
|
+
.refine((data) => data.vector.length === data.dimension, {
|
|
23
|
+
message: 'Embedding vector length must match specified dimension',
|
|
24
|
+
});
|
|
25
|
+
/**
|
|
26
|
+
* Generate an embedding for the given text using the configured LLM provider.
|
|
27
|
+
*
|
|
28
|
+
* @param text - Text to generate embedding for
|
|
29
|
+
* @param options - Options for embedding generation
|
|
30
|
+
* @returns Embedding object with vector and metadata
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* // With Ollama (OLLAMA_BASE_URL set):
|
|
35
|
+
* const embedding = await generateEmbedding('user prefers dark theme')
|
|
36
|
+
* // Returns: { vector: number[], model: 'nomic-embed-text', dimension: 768, generatedAt: '...' }
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export async function generateEmbedding(text, options = {}) {
|
|
40
|
+
const { model } = options;
|
|
41
|
+
if (!text || typeof text !== 'string' || text.trim().length === 0) {
|
|
42
|
+
throw new Error('Text must be a non-empty string');
|
|
43
|
+
}
|
|
44
|
+
// Use unified LLM client — auto-detects provider from env vars
|
|
45
|
+
const client = createLLMClientFromEnv();
|
|
46
|
+
// Ask client to embed — each provider uses its own default model when model is undefined
|
|
47
|
+
const result = await client.embed(text, model ? { model } : undefined);
|
|
48
|
+
// If provider returned batch, pick first
|
|
49
|
+
const embeddingResult = Array.isArray(result) ? result[0] : result;
|
|
50
|
+
if (!(embeddingResult && Array.isArray(embeddingResult.vector))) {
|
|
51
|
+
throw new Error('Invalid embedding response from LLM provider');
|
|
52
|
+
}
|
|
53
|
+
const embedding = {
|
|
54
|
+
vector: embeddingResult.vector,
|
|
55
|
+
model: String(embeddingResult.model || model),
|
|
56
|
+
dimension: embeddingResult.dimension || embeddingResult.vector.length,
|
|
57
|
+
generatedAt: new Date().toISOString(),
|
|
58
|
+
};
|
|
59
|
+
return embedding;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Generate embeddings for multiple texts in batch.
|
|
63
|
+
*
|
|
64
|
+
* @param texts - Array of texts to generate embeddings for
|
|
65
|
+
* @param options - Options for embedding generation
|
|
66
|
+
* @returns Array of embeddings in the same order as input texts
|
|
67
|
+
*/
|
|
68
|
+
export async function generateEmbeddings(texts, options = {}) {
|
|
69
|
+
// Generate in parallel — providers that support batch (Ollama, OpenAI) can be
|
|
70
|
+
// optimised later by passing the full array directly to client.embed()
|
|
71
|
+
const embeddings = await Promise.all(texts.map((text) => generateEmbedding(text, options)));
|
|
72
|
+
return embeddings;
|
|
73
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @revealui/ai - AI System for RevealUI
|
|
3
|
+
*
|
|
4
|
+
* A comprehensive AI system that provides:
|
|
5
|
+
* - Memory management (Working, Episodic, Semantic)
|
|
6
|
+
* - LLM provider abstractions (OpenAI, Anthropic, etc.)
|
|
7
|
+
* - Agent orchestration and execution
|
|
8
|
+
* - Tool calling system
|
|
9
|
+
* - Vector similarity search
|
|
10
|
+
* - CRDT-based persistent state
|
|
11
|
+
*
|
|
12
|
+
* ## Quick Start
|
|
13
|
+
*
|
|
14
|
+
* ```typescript
|
|
15
|
+
* import { EpisodicMemory } from '@revealui/ai/memory/stores'
|
|
16
|
+
* import { NodeIdService } from '@revealui/ai/memory/services'
|
|
17
|
+
*
|
|
18
|
+
* // Memory operations
|
|
19
|
+
* const memory = new EpisodicMemory(userId, nodeId, db)
|
|
20
|
+
* await memory.add(agentMemory)
|
|
21
|
+
*
|
|
22
|
+
* // LLM, orchestration, and tools coming soon
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* ## Architecture
|
|
26
|
+
*
|
|
27
|
+
* ```
|
|
28
|
+
* ┌─────────────────────────────────────┐
|
|
29
|
+
* │ React Hooks (useMemory, etc.) │
|
|
30
|
+
* ├─────────────────────────────────────┤
|
|
31
|
+
* │ AI System │
|
|
32
|
+
* │ ├── Memory (Working, Episodic) │
|
|
33
|
+
* │ ├── LLM (Providers, Client) │
|
|
34
|
+
* │ ├── Orchestration (Agents) │
|
|
35
|
+
* │ ├── Tools (Registry, Executor) │
|
|
36
|
+
* │ └── Skills (Agent Skills) │
|
|
37
|
+
* ├─────────────────────────────────────┤
|
|
38
|
+
* │ CRDT Core (LWW, OR-Set, Counter) │
|
|
39
|
+
* ├─────────────────────────────────────┤
|
|
40
|
+
* │ Vector Search (pgvector) │
|
|
41
|
+
* ├─────────────────────────────────────┤
|
|
42
|
+
* │ Persistence (Drizzle/NeonDB) │
|
|
43
|
+
* └─────────────────────────────────────┘
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
46
|
+
* @packageDocumentation
|
|
47
|
+
*/
|
|
48
|
+
/**
|
|
49
|
+
* Check if the AI package is licensed for use.
|
|
50
|
+
* Returns false with a warning log if no Pro/Enterprise license is active.
|
|
51
|
+
* Call at application startup to verify licensing.
|
|
52
|
+
*/
|
|
53
|
+
export declare function checkAiLicense(): boolean;
|
|
54
|
+
export * from './a2a/index.js';
|
|
55
|
+
export * from './audit/index.js';
|
|
56
|
+
export * from './embeddings/index.js';
|
|
57
|
+
export * from './ingestion/index.js';
|
|
58
|
+
export * from './llm/client.js';
|
|
59
|
+
export * from './llm/provider-health.js';
|
|
60
|
+
export * from './llm/providers/anthropic.js';
|
|
61
|
+
export * from './llm/providers/base.js';
|
|
62
|
+
export * from './llm/providers/openai.js';
|
|
63
|
+
export * from './llm/token-counter.js';
|
|
64
|
+
export * from './llm/workspace-provider-config.js';
|
|
65
|
+
export * from './memory/index.js';
|
|
66
|
+
export * from './orchestration/agent.js';
|
|
67
|
+
export * from './orchestration/defaults.js';
|
|
68
|
+
export * from './orchestration/memory-integration.js';
|
|
69
|
+
export * from './orchestration/orchestrator.js';
|
|
70
|
+
export * from './orchestration/runtime.js';
|
|
71
|
+
export * from './orchestration/streaming-runtime.js';
|
|
72
|
+
export * from './orchestration/ticket-agent.js';
|
|
73
|
+
export * from './skills/index.js';
|
|
74
|
+
export * from './templates/index.js';
|
|
75
|
+
export * from './tools/base.js';
|
|
76
|
+
export * from './tools/deduplicator.js';
|
|
77
|
+
export * from './tools/document-summarizer.js';
|
|
78
|
+
export * from './tools/mcp-adapter.js';
|
|
79
|
+
export * from './tools/memory/index.js';
|
|
80
|
+
export * from './tools/registry.js';
|
|
81
|
+
export * from './tools/ticket-tools.js';
|
|
82
|
+
export * from './tools/web/index.js';
|
|
83
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AAKH;;;;GAIG;AACH,wBAAgB,cAAc,IAAI,OAAO,CASxC;AAGD,cAAc,gBAAgB,CAAA;AAE9B,cAAc,kBAAkB,CAAA;AAIhC,cAAc,uBAAuB,CAAA;AAErC,cAAc,sBAAsB,CAAA;AAEpC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,0BAA0B,CAAA;AACxC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,yBAAyB,CAAA;AACvC,cAAc,2BAA2B,CAAA;AACzC,cAAc,wBAAwB,CAAA;AACtC,cAAc,oCAAoC,CAAA;AAElD,cAAc,mBAAmB,CAAA;AAEjC,cAAc,0BAA0B,CAAA;AACxC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,uCAAuC,CAAA;AACrD,cAAc,iCAAiC,CAAA;AAC/C,cAAc,4BAA4B,CAAA;AAC1C,cAAc,sCAAsC,CAAA;AACpD,cAAc,iCAAiC,CAAA;AAE/C,cAAc,mBAAmB,CAAA;AAEjC,cAAc,sBAAsB,CAAA;AAEpC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,yBAAyB,CAAA;AACvC,cAAc,gCAAgC,CAAA;AAC9C,cAAc,wBAAwB,CAAA;AACtC,cAAc,yBAAyB,CAAA;AACvC,cAAc,qBAAqB,CAAA;AACnC,cAAc,yBAAyB,CAAA;AACvC,cAAc,sBAAsB,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @revealui/ai - AI System for RevealUI
|
|
3
|
+
*
|
|
4
|
+
* A comprehensive AI system that provides:
|
|
5
|
+
* - Memory management (Working, Episodic, Semantic)
|
|
6
|
+
* - LLM provider abstractions (OpenAI, Anthropic, etc.)
|
|
7
|
+
* - Agent orchestration and execution
|
|
8
|
+
* - Tool calling system
|
|
9
|
+
* - Vector similarity search
|
|
10
|
+
* - CRDT-based persistent state
|
|
11
|
+
*
|
|
12
|
+
* ## Quick Start
|
|
13
|
+
*
|
|
14
|
+
* ```typescript
|
|
15
|
+
* import { EpisodicMemory } from '@revealui/ai/memory/stores'
|
|
16
|
+
* import { NodeIdService } from '@revealui/ai/memory/services'
|
|
17
|
+
*
|
|
18
|
+
* // Memory operations
|
|
19
|
+
* const memory = new EpisodicMemory(userId, nodeId, db)
|
|
20
|
+
* await memory.add(agentMemory)
|
|
21
|
+
*
|
|
22
|
+
* // LLM, orchestration, and tools coming soon
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* ## Architecture
|
|
26
|
+
*
|
|
27
|
+
* ```
|
|
28
|
+
* ┌─────────────────────────────────────┐
|
|
29
|
+
* │ React Hooks (useMemory, etc.) │
|
|
30
|
+
* ├─────────────────────────────────────┤
|
|
31
|
+
* │ AI System │
|
|
32
|
+
* │ ├── Memory (Working, Episodic) │
|
|
33
|
+
* │ ├── LLM (Providers, Client) │
|
|
34
|
+
* │ ├── Orchestration (Agents) │
|
|
35
|
+
* │ ├── Tools (Registry, Executor) │
|
|
36
|
+
* │ └── Skills (Agent Skills) │
|
|
37
|
+
* ├─────────────────────────────────────┤
|
|
38
|
+
* │ CRDT Core (LWW, OR-Set, Counter) │
|
|
39
|
+
* ├─────────────────────────────────────┤
|
|
40
|
+
* │ Vector Search (pgvector) │
|
|
41
|
+
* ├─────────────────────────────────────┤
|
|
42
|
+
* │ Persistence (Drizzle/NeonDB) │
|
|
43
|
+
* └─────────────────────────────────────┘
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
46
|
+
* @packageDocumentation
|
|
47
|
+
*/
|
|
48
|
+
import { isFeatureEnabled } from '@revealui/core/features';
|
|
49
|
+
import { logger } from '@revealui/core/observability/logger';
|
|
50
|
+
/**
|
|
51
|
+
* Check if the AI package is licensed for use.
|
|
52
|
+
* Returns false with a warning log if no Pro/Enterprise license is active.
|
|
53
|
+
* Call at application startup to verify licensing.
|
|
54
|
+
*/
|
|
55
|
+
export function checkAiLicense() {
|
|
56
|
+
if (!isFeatureEnabled('ai')) {
|
|
57
|
+
logger.warn('[@revealui/ai] AI features require a Pro or Enterprise license. ' +
|
|
58
|
+
'Visit https://revealui.com/pricing for details.');
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
// Re-export A2A protocol
|
|
64
|
+
export * from './a2a/index.js';
|
|
65
|
+
// Re-export audit trail
|
|
66
|
+
export * from './audit/index.js';
|
|
67
|
+
// Client-side React hooks are intentionally NOT re-exported here.
|
|
68
|
+
// This main entry is server-safe. Use @revealui/ai/client for React hooks.
|
|
69
|
+
// Re-export embeddings
|
|
70
|
+
export * from './embeddings/index.js';
|
|
71
|
+
// Re-export ingestion pipeline (RAG document indexing + hybrid search)
|
|
72
|
+
export * from './ingestion/index.js';
|
|
73
|
+
// Re-export LLM providers and client
|
|
74
|
+
export * from './llm/client.js';
|
|
75
|
+
export * from './llm/provider-health.js';
|
|
76
|
+
export * from './llm/providers/anthropic.js';
|
|
77
|
+
export * from './llm/providers/base.js';
|
|
78
|
+
export * from './llm/providers/openai.js';
|
|
79
|
+
export * from './llm/token-counter.js';
|
|
80
|
+
export * from './llm/workspace-provider-config.js';
|
|
81
|
+
// Re-export memory system
|
|
82
|
+
export * from './memory/index.js';
|
|
83
|
+
// Re-export orchestration
|
|
84
|
+
export * from './orchestration/agent.js';
|
|
85
|
+
export * from './orchestration/defaults.js';
|
|
86
|
+
export * from './orchestration/memory-integration.js';
|
|
87
|
+
export * from './orchestration/orchestrator.js';
|
|
88
|
+
export * from './orchestration/runtime.js';
|
|
89
|
+
export * from './orchestration/streaming-runtime.js';
|
|
90
|
+
export * from './orchestration/ticket-agent.js';
|
|
91
|
+
// Re-export skills
|
|
92
|
+
export * from './skills/index.js';
|
|
93
|
+
// Re-export specification templates
|
|
94
|
+
export * from './templates/index.js';
|
|
95
|
+
// Re-export tools
|
|
96
|
+
export * from './tools/base.js';
|
|
97
|
+
export * from './tools/deduplicator.js';
|
|
98
|
+
export * from './tools/document-summarizer.js';
|
|
99
|
+
export * from './tools/mcp-adapter.js';
|
|
100
|
+
export * from './tools/memory/index.js';
|
|
101
|
+
export * from './tools/registry.js';
|
|
102
|
+
export * from './tools/ticket-tools.js';
|
|
103
|
+
export * from './tools/web/index.js';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Context Assembly with Smart Trimming
|
|
3
|
+
*
|
|
4
|
+
* Blends relevance (cosine similarity) and recency (createdAt) to rank chunks,
|
|
5
|
+
* then greedily assembles them up to a token budget.
|
|
6
|
+
* Auto-compresses single chunks that exceed half the budget.
|
|
7
|
+
*
|
|
8
|
+
* AnythingLLM lesson: plain cosine-only retrieval without recency weighting
|
|
9
|
+
* produces stale, misleading context in long-running knowledge bases.
|
|
10
|
+
*/
|
|
11
|
+
import type { RagSearchResult } from '../ingestion/rag-vector-service.js';
|
|
12
|
+
export interface AssembleContextOptions {
|
|
13
|
+
/** Maximum token budget for the assembled context */
|
|
14
|
+
maxTokens: number;
|
|
15
|
+
/** Weight for recency score (default 0.3) */
|
|
16
|
+
recencyWeight?: number;
|
|
17
|
+
/** Weight for cosine similarity (default 0.7) */
|
|
18
|
+
relevanceWeight?: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Assemble RAG context from search results.
|
|
22
|
+
*
|
|
23
|
+
* Returns a formatted string of numbered references, trimmed to maxTokens.
|
|
24
|
+
* Returns '' if results is empty.
|
|
25
|
+
*/
|
|
26
|
+
export declare function assembleContext(results: RagSearchResult[], options: AssembleContextOptions): string;
|
|
27
|
+
//# sourceMappingURL=context-assembly.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-assembly.d.ts","sourceRoot":"","sources":["../../src/inference/context-assembly.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAA;AAEzE,MAAM,WAAW,sBAAsB;IACrC,qDAAqD;IACrD,SAAS,EAAE,MAAM,CAAA;IACjB,6CAA6C;IAC7C,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,iDAAiD;IACjD,eAAe,CAAC,EAAE,MAAM,CAAA;CACzB;AA+BD;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,eAAe,EAAE,EAC1B,OAAO,EAAE,sBAAsB,GAC9B,MAAM,CAiDR"}
|