@undefineds.co/xpod 0.3.58 → 0.3.62
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/README.md +3 -0
- package/config/cli.json +88 -0
- package/config/cloud.json +32 -1
- package/config/components-ignore.json +3 -0
- package/config/extensions.local.initializer.json +44 -0
- package/config/resolver.json +86 -0
- package/config/xpod.base.json +4 -0
- package/dist/agents/AgentExecutorFactory.d.ts +3 -3
- package/dist/agents/AgentExecutorFactory.js +28 -15
- package/dist/agents/AgentExecutorFactory.js.map +1 -1
- package/dist/agents/BaseAgentExecutor.d.ts +2 -1
- package/dist/agents/BaseAgentExecutor.js +1 -0
- package/dist/agents/BaseAgentExecutor.js.map +1 -1
- package/dist/agents/ClaudeExecutor.d.ts +3 -1
- package/dist/agents/ClaudeExecutor.js +18 -12
- package/dist/agents/ClaudeExecutor.js.map +1 -1
- package/dist/agents/config/resolve.js +0 -21
- package/dist/agents/config/resolve.js.map +1 -1
- package/dist/agents/config/types.d.ts +2 -7
- package/dist/agents/config/types.js +2 -1
- package/dist/agents/config/types.js.map +1 -1
- package/dist/agents/types.d.ts +18 -0
- package/dist/agents/types.js.map +1 -1
- package/dist/ai/schema/types.d.ts +2 -1
- package/dist/ai/schema/types.js +1 -0
- package/dist/ai/schema/types.js.map +1 -1
- package/dist/ai/service/CredentialReader.d.ts +3 -1
- package/dist/ai/service/CredentialReader.js.map +1 -1
- package/dist/ai/service/CredentialReaderImpl.d.ts +3 -1
- package/dist/ai/service/CredentialReaderImpl.js +24 -2
- package/dist/ai/service/CredentialReaderImpl.js.map +1 -1
- package/dist/ai/service/EmbeddingServiceImpl.js +13 -2
- package/dist/ai/service/EmbeddingServiceImpl.js.map +1 -1
- package/dist/ai/service/ProviderRegistry.d.ts +4 -0
- package/dist/ai/service/ProviderRegistry.js.map +1 -1
- package/dist/ai/service/ProviderRegistry.jsonld +4 -0
- package/dist/ai/service/ProviderRegistryImpl.d.ts +4 -1
- package/dist/ai/service/ProviderRegistryImpl.js +26 -4
- package/dist/ai/service/ProviderRegistryImpl.js.map +1 -1
- package/dist/ai/service/ProviderRegistryImpl.jsonld +12 -0
- package/dist/ai/service/defaultEmbeddingProfile.d.ts +5 -0
- package/dist/ai/service/defaultEmbeddingProfile.js +31 -0
- package/dist/ai/service/defaultEmbeddingProfile.js.map +1 -0
- package/dist/ai/service/index.d.ts +1 -0
- package/dist/ai/service/index.js +1 -0
- package/dist/ai/service/index.js.map +1 -1
- package/dist/ai/service/types.d.ts +1 -0
- package/dist/ai/service/types.js.map +1 -1
- package/dist/api/ApiServer.js +17 -2
- package/dist/api/ApiServer.js.map +1 -1
- package/dist/api/ai-gateway/AiGatewayService.d.ts +106 -0
- package/dist/api/ai-gateway/AiGatewayService.js +527 -0
- package/dist/api/ai-gateway/AiGatewayService.js.map +1 -0
- package/dist/api/ai-gateway/auth/AiConnectionInvocationKeyIssuer.d.ts +38 -0
- package/dist/api/ai-gateway/auth/AiConnectionInvocationKeyIssuer.js +128 -0
- package/dist/api/ai-gateway/auth/AiConnectionInvocationKeyIssuer.js.map +1 -0
- package/dist/api/ai-gateway/auth/ClientCredentialsInternalPodAccessTokenProvider.d.ts +25 -0
- package/dist/api/ai-gateway/auth/ClientCredentialsInternalPodAccessTokenProvider.js +91 -0
- package/dist/api/ai-gateway/auth/ClientCredentialsInternalPodAccessTokenProvider.js.map +1 -0
- package/dist/api/ai-gateway/auth/GatewayApiKey.d.ts +28 -0
- package/dist/api/ai-gateway/auth/GatewayApiKey.js +162 -0
- package/dist/api/ai-gateway/auth/GatewayApiKey.js.map +1 -0
- package/dist/api/ai-gateway/auth/GatewayApiKeyAuthenticator.d.ts +56 -0
- package/dist/api/ai-gateway/auth/GatewayApiKeyAuthenticator.js +143 -0
- package/dist/api/ai-gateway/auth/GatewayApiKeyAuthenticator.js.map +1 -0
- package/dist/api/ai-gateway/auth/GatewayKeyLocatorCodec.d.ts +26 -0
- package/dist/api/ai-gateway/auth/GatewayKeyLocatorCodec.js +97 -0
- package/dist/api/ai-gateway/auth/GatewayKeyLocatorCodec.js.map +1 -0
- package/dist/api/ai-gateway/auth/GatewayPrincipal.d.ts +20 -0
- package/dist/api/ai-gateway/auth/GatewayPrincipal.js +37 -0
- package/dist/api/ai-gateway/auth/GatewayPrincipal.js.map +1 -0
- package/dist/api/ai-gateway/auth/InvocationTokenCodec.d.ts +41 -0
- package/dist/api/ai-gateway/auth/InvocationTokenCodec.js +221 -0
- package/dist/api/ai-gateway/auth/InvocationTokenCodec.js.map +1 -0
- package/dist/api/ai-gateway/auth/PodGatewayAccessKeyRepository.d.ts +54 -0
- package/dist/api/ai-gateway/auth/PodGatewayAccessKeyRepository.js +152 -0
- package/dist/api/ai-gateway/auth/PodGatewayAccessKeyRepository.js.map +1 -0
- package/dist/api/ai-gateway/connect/index.d.ts +367 -0
- package/dist/api/ai-gateway/connect/index.js +1061 -0
- package/dist/api/ai-gateway/connect/index.js.map +1 -0
- package/dist/api/ai-gateway/credentials/CloudKmsWrapper.d.ts +40 -0
- package/dist/api/ai-gateway/credentials/CloudKmsWrapper.js +59 -0
- package/dist/api/ai-gateway/credentials/CloudKmsWrapper.js.map +1 -0
- package/dist/api/ai-gateway/credentials/CredentialVault.d.ts +14 -0
- package/dist/api/ai-gateway/credentials/CredentialVault.js +11 -0
- package/dist/api/ai-gateway/credentials/CredentialVault.js.map +1 -0
- package/dist/api/ai-gateway/credentials/KeyWrapper.d.ts +27 -0
- package/dist/api/ai-gateway/credentials/KeyWrapper.js +3 -0
- package/dist/api/ai-gateway/credentials/KeyWrapper.js.map +1 -0
- package/dist/api/ai-gateway/credentials/LocalKeychainWrapper.d.ts +27 -0
- package/dist/api/ai-gateway/credentials/LocalKeychainWrapper.js +145 -0
- package/dist/api/ai-gateway/credentials/LocalKeychainWrapper.js.map +1 -0
- package/dist/api/ai-gateway/credentials/SecretCellCredentialVault.d.ts +13 -0
- package/dist/api/ai-gateway/credentials/SecretCellCredentialVault.js +133 -0
- package/dist/api/ai-gateway/credentials/SecretCellCredentialVault.js.map +1 -0
- package/dist/api/ai-gateway/credentials/SecretCellKeyWrapper.d.ts +23 -0
- package/dist/api/ai-gateway/credentials/SecretCellKeyWrapper.js +62 -0
- package/dist/api/ai-gateway/credentials/SecretCellKeyWrapper.js.map +1 -0
- package/dist/api/ai-gateway/credentials/WebCryptoCredentialVault.d.ts +23 -0
- package/dist/api/ai-gateway/credentials/WebCryptoCredentialVault.js +173 -0
- package/dist/api/ai-gateway/credentials/WebCryptoCredentialVault.js.map +1 -0
- package/dist/api/ai-gateway/errors.d.ts +21 -0
- package/dist/api/ai-gateway/errors.js +50 -0
- package/dist/api/ai-gateway/errors.js.map +1 -0
- package/dist/api/ai-gateway/protocol/ChatCompletionsFrontend.d.ts +6 -0
- package/dist/api/ai-gateway/protocol/ChatCompletionsFrontend.js +111 -0
- package/dist/api/ai-gateway/protocol/ChatCompletionsFrontend.js.map +1 -0
- package/dist/api/ai-gateway/protocol/MessagesFrontend.d.ts +6 -0
- package/dist/api/ai-gateway/protocol/MessagesFrontend.js +99 -0
- package/dist/api/ai-gateway/protocol/MessagesFrontend.js.map +1 -0
- package/dist/api/ai-gateway/protocol/ResponsesFrontend.d.ts +6 -0
- package/dist/api/ai-gateway/protocol/ResponsesFrontend.js +232 -0
- package/dist/api/ai-gateway/protocol/ResponsesFrontend.js.map +1 -0
- package/dist/api/ai-gateway/protocol/index.d.ts +3 -0
- package/dist/api/ai-gateway/protocol/index.js +10 -0
- package/dist/api/ai-gateway/protocol/index.js.map +1 -0
- package/dist/api/ai-gateway/providers/AnthropicRuntimeAdapter.d.ts +7 -0
- package/dist/api/ai-gateway/providers/AnthropicRuntimeAdapter.js +37 -0
- package/dist/api/ai-gateway/providers/AnthropicRuntimeAdapter.js.map +1 -0
- package/dist/api/ai-gateway/providers/BailianRuntimeAdapter.d.ts +9 -0
- package/dist/api/ai-gateway/providers/BailianRuntimeAdapter.js +127 -0
- package/dist/api/ai-gateway/providers/BailianRuntimeAdapter.js.map +1 -0
- package/dist/api/ai-gateway/providers/DeepSeekRuntimeAdapter.d.ts +8 -0
- package/dist/api/ai-gateway/providers/DeepSeekRuntimeAdapter.js +47 -0
- package/dist/api/ai-gateway/providers/DeepSeekRuntimeAdapter.js.map +1 -0
- package/dist/api/ai-gateway/providers/KimiRuntimeAdapter.d.ts +8 -0
- package/dist/api/ai-gateway/providers/KimiRuntimeAdapter.js +57 -0
- package/dist/api/ai-gateway/providers/KimiRuntimeAdapter.js.map +1 -0
- package/dist/api/ai-gateway/providers/OpenAiCompatibleRuntimeAdapter.d.ts +1 -0
- package/dist/api/ai-gateway/providers/OpenAiCompatibleRuntimeAdapter.js +6 -0
- package/dist/api/ai-gateway/providers/OpenAiCompatibleRuntimeAdapter.js.map +1 -0
- package/dist/api/ai-gateway/providers/OpenAiRuntimeAdapter.d.ts +13 -0
- package/dist/api/ai-gateway/providers/OpenAiRuntimeAdapter.js +34 -0
- package/dist/api/ai-gateway/providers/OpenAiRuntimeAdapter.js.map +1 -0
- package/dist/api/ai-gateway/providers/ProviderRegistry.d.ts +68 -0
- package/dist/api/ai-gateway/providers/ProviderRegistry.js +288 -0
- package/dist/api/ai-gateway/providers/ProviderRegistry.js.map +1 -0
- package/dist/api/ai-gateway/providers/ProviderRuntimeAdapter.d.ts +88 -0
- package/dist/api/ai-gateway/providers/ProviderRuntimeAdapter.js +645 -0
- package/dist/api/ai-gateway/providers/ProviderRuntimeAdapter.js.map +1 -0
- package/dist/api/ai-gateway/providers/ProviderRuntimeRegistry.d.ts +13 -0
- package/dist/api/ai-gateway/providers/ProviderRuntimeRegistry.js +48 -0
- package/dist/api/ai-gateway/providers/ProviderRuntimeRegistry.js.map +1 -0
- package/dist/api/ai-gateway/providers/index.d.ts +9 -0
- package/dist/api/ai-gateway/providers/index.js +26 -0
- package/dist/api/ai-gateway/providers/index.js.map +1 -0
- package/dist/api/ai-gateway/quota/AnthropicQuotaAdapter.d.ts +5 -0
- package/dist/api/ai-gateway/quota/AnthropicQuotaAdapter.js +21 -0
- package/dist/api/ai-gateway/quota/AnthropicQuotaAdapter.js.map +1 -0
- package/dist/api/ai-gateway/quota/BailianQuotaAdapter.d.ts +5 -0
- package/dist/api/ai-gateway/quota/BailianQuotaAdapter.js +21 -0
- package/dist/api/ai-gateway/quota/BailianQuotaAdapter.js.map +1 -0
- package/dist/api/ai-gateway/quota/DeepSeekQuotaAdapter.d.ts +10 -0
- package/dist/api/ai-gateway/quota/DeepSeekQuotaAdapter.js +83 -0
- package/dist/api/ai-gateway/quota/DeepSeekQuotaAdapter.js.map +1 -0
- package/dist/api/ai-gateway/quota/KimiQuotaAdapter.d.ts +10 -0
- package/dist/api/ai-gateway/quota/KimiQuotaAdapter.js +70 -0
- package/dist/api/ai-gateway/quota/KimiQuotaAdapter.js.map +1 -0
- package/dist/api/ai-gateway/quota/OpenAiQuotaAdapter.d.ts +5 -0
- package/dist/api/ai-gateway/quota/OpenAiQuotaAdapter.js +21 -0
- package/dist/api/ai-gateway/quota/OpenAiQuotaAdapter.js.map +1 -0
- package/dist/api/ai-gateway/quota/ProviderQuotaAdapter.d.ts +214 -0
- package/dist/api/ai-gateway/quota/ProviderQuotaAdapter.js +511 -0
- package/dist/api/ai-gateway/quota/ProviderQuotaAdapter.js.map +1 -0
- package/dist/api/ai-gateway/quota/index.d.ts +6 -0
- package/dist/api/ai-gateway/quota/index.js +23 -0
- package/dist/api/ai-gateway/quota/index.js.map +1 -0
- package/dist/api/ai-gateway/routing/InMemorySessionAffinityStore.d.ts +26 -0
- package/dist/api/ai-gateway/routing/InMemorySessionAffinityStore.js +67 -0
- package/dist/api/ai-gateway/routing/InMemorySessionAffinityStore.js.map +1 -0
- package/dist/api/ai-gateway/routing/ModelRouter.d.ts +84 -0
- package/dist/api/ai-gateway/routing/ModelRouter.js +274 -0
- package/dist/api/ai-gateway/routing/ModelRouter.js.map +1 -0
- package/dist/api/ai-gateway/routing/RedisSessionAffinityStore.d.ts +39 -0
- package/dist/api/ai-gateway/routing/RedisSessionAffinityStore.js +122 -0
- package/dist/api/ai-gateway/routing/RedisSessionAffinityStore.js.map +1 -0
- package/dist/api/ai-gateway/routing/SessionAffinityStore.d.ts +49 -0
- package/dist/api/ai-gateway/routing/SessionAffinityStore.js +66 -0
- package/dist/api/ai-gateway/routing/SessionAffinityStore.js.map +1 -0
- package/dist/api/ai-gateway/service-access/AiConnectionServiceAccess.d.ts +25 -0
- package/dist/api/ai-gateway/service-access/AiConnectionServiceAccess.js +50 -0
- package/dist/api/ai-gateway/service-access/AiConnectionServiceAccess.js.map +1 -0
- package/dist/api/ai-gateway/types.d.ts +112 -0
- package/dist/api/ai-gateway/types.js +305 -0
- package/dist/api/ai-gateway/types.js.map +1 -0
- package/dist/api/auth/AuthContext.d.ts +18 -3
- package/dist/api/auth/AuthContext.js +13 -2
- package/dist/api/auth/AuthContext.js.map +1 -1
- package/dist/api/auth/Authenticator.d.ts +3 -0
- package/dist/api/auth/Authenticator.js.map +1 -1
- package/dist/api/auth/ClientCredentialsAuthenticator.d.ts +2 -6
- package/dist/api/auth/ClientCredentialsAuthenticator.js +12 -30
- package/dist/api/auth/ClientCredentialsAuthenticator.js.map +1 -1
- package/dist/api/auth/SolidTokenAuthenticator.d.ts +2 -0
- package/dist/api/auth/SolidTokenAuthenticator.js +88 -2
- package/dist/api/auth/SolidTokenAuthenticator.js.map +1 -1
- package/dist/api/auth/TokenIdentity.d.ts +6 -0
- package/dist/api/auth/TokenIdentity.js +31 -0
- package/dist/api/auth/TokenIdentity.js.map +1 -0
- package/dist/api/chatkit/ai-provider.d.ts +9 -23
- package/dist/api/chatkit/ai-provider.js +30 -153
- package/dist/api/chatkit/ai-provider.js.map +1 -1
- package/dist/api/chatkit/default-agent.d.ts +24 -15
- package/dist/api/chatkit/default-agent.js +24 -83
- package/dist/api/chatkit/default-agent.js.map +1 -1
- package/dist/api/chatkit/index.d.ts +2 -1
- package/dist/api/chatkit/index.js +3 -1
- package/dist/api/chatkit/index.js.map +1 -1
- package/dist/api/chatkit/pod-store.d.ts +13 -1
- package/dist/api/chatkit/pod-store.js +127 -7
- package/dist/api/chatkit/pod-store.js.map +1 -1
- package/dist/api/chatkit/runtime/AcpAgentRuntime.d.ts +0 -1
- package/dist/api/chatkit/runtime/AcpAgentRuntime.js +14 -51
- package/dist/api/chatkit/runtime/AcpAgentRuntime.js.map +1 -1
- package/dist/api/chatkit/runtime/AcpRunner.js +2 -1
- package/dist/api/chatkit/runtime/AcpRunner.js.map +1 -1
- package/dist/api/chatkit/runtime/CodexRuntimeProjector.d.ts +15 -1
- package/dist/api/chatkit/runtime/CodexRuntimeProjector.js +52 -34
- package/dist/api/chatkit/runtime/CodexRuntimeProjector.js.map +1 -1
- package/dist/api/chatkit/service.d.ts +8 -1
- package/dist/api/chatkit/service.js +46 -5
- package/dist/api/chatkit/service.js.map +1 -1
- package/dist/api/chatkit/store.d.ts +23 -1
- package/dist/api/chatkit/store.js +56 -0
- package/dist/api/chatkit/store.js.map +1 -1
- package/dist/api/chatkit/types.d.ts +1 -0
- package/dist/api/chatkit/types.js.map +1 -1
- package/dist/api/container/common.js +286 -13
- package/dist/api/container/common.js.map +1 -1
- package/dist/api/container/index.js +126 -6
- package/dist/api/container/index.js.map +1 -1
- package/dist/api/container/local.js +50 -6
- package/dist/api/container/local.js.map +1 -1
- package/dist/api/container/rdf.d.ts +15 -0
- package/dist/api/container/rdf.js +90 -0
- package/dist/api/container/rdf.js.map +1 -0
- package/dist/api/container/routes.js +151 -11
- package/dist/api/container/routes.js.map +1 -1
- package/dist/api/container/types.d.ts +96 -0
- package/dist/api/container/types.js.map +1 -1
- package/dist/api/handlers/AdminHandler.d.ts +25 -2
- package/dist/api/handlers/AdminHandler.js +60 -10
- package/dist/api/handlers/AdminHandler.js.map +1 -1
- package/dist/api/handlers/AiClientConfigurationHandler.d.ts +7 -0
- package/dist/api/handlers/AiClientConfigurationHandler.js +202 -0
- package/dist/api/handlers/AiClientConfigurationHandler.js.map +1 -0
- package/dist/api/handlers/AiGatewayHandler.d.ts +23 -0
- package/dist/api/handlers/AiGatewayHandler.js +231 -0
- package/dist/api/handlers/AiGatewayHandler.js.map +1 -0
- package/dist/api/handlers/AiGatewayManagementHandler.d.ts +24 -0
- package/dist/api/handlers/AiGatewayManagementHandler.js +503 -0
- package/dist/api/handlers/AiGatewayManagementHandler.js.map +1 -0
- package/dist/api/handlers/ChatHandler.d.ts +11 -12
- package/dist/api/handlers/ChatHandler.js +12 -219
- package/dist/api/handlers/ChatHandler.js.map +1 -1
- package/dist/api/handlers/DashboardHandler.js +22 -116
- package/dist/api/handlers/DashboardHandler.js.map +1 -1
- package/dist/api/handlers/NetworkSettingsHandler.d.ts +97 -0
- package/dist/api/handlers/NetworkSettingsHandler.js +511 -0
- package/dist/api/handlers/NetworkSettingsHandler.js.map +1 -0
- package/dist/api/handlers/PodSettingsHandler.d.ts +79 -0
- package/dist/api/handlers/PodSettingsHandler.js +162 -0
- package/dist/api/handlers/PodSettingsHandler.js.map +1 -0
- package/dist/api/handlers/ProvisionHandler.d.ts +3 -1
- package/dist/api/handlers/ProvisionHandler.js +22 -87
- package/dist/api/handlers/ProvisionHandler.js.map +1 -1
- package/dist/api/handlers/RdfStatsHandler.d.ts +6 -0
- package/dist/api/handlers/RdfStatsHandler.js +85 -0
- package/dist/api/handlers/RdfStatsHandler.js.map +1 -0
- package/dist/api/handlers/SettingsHandler.d.ts +5 -0
- package/dist/api/handlers/SettingsHandler.js +13 -0
- package/dist/api/handlers/SettingsHandler.js.map +1 -0
- package/dist/api/handlers/StaticSpaHandler.d.ts +8 -0
- package/dist/api/handlers/StaticSpaHandler.js +102 -0
- package/dist/api/handlers/StaticSpaHandler.js.map +1 -0
- package/dist/api/handlers/index.d.ts +1 -0
- package/dist/api/handlers/index.js +1 -0
- package/dist/api/handlers/index.js.map +1 -1
- package/dist/api/http/readBoundedJsonBody.d.ts +14 -0
- package/dist/api/http/readBoundedJsonBody.js +58 -0
- package/dist/api/http/readBoundedJsonBody.js.map +1 -0
- package/dist/api/middleware/AuthMiddleware.d.ts +1 -0
- package/dist/api/middleware/AuthMiddleware.js +33 -4
- package/dist/api/middleware/AuthMiddleware.js.map +1 -1
- package/dist/api/runs/AgentRuntimeTypes.d.ts +18 -3
- package/dist/api/runs/AgentRuntimeTypes.js +61 -0
- package/dist/api/runs/AgentRuntimeTypes.js.map +1 -1
- package/dist/api/runs/InngestRunExecutionBackend.d.ts +28 -3
- package/dist/api/runs/InngestRunExecutionBackend.js +26 -3
- package/dist/api/runs/InngestRunExecutionBackend.js.map +1 -1
- package/dist/api/runs/ManagedRunWorker.d.ts +4 -1
- package/dist/api/runs/ManagedRunWorker.js +39 -8
- package/dist/api/runs/ManagedRunWorker.js.map +1 -1
- package/dist/api/runs/PiAgentRuntimeDriver.d.ts +5 -1
- package/dist/api/runs/PiAgentRuntimeDriver.js +94 -57
- package/dist/api/runs/PiAgentRuntimeDriver.js.map +1 -1
- package/dist/api/runs/RdfRunContextRetriever.d.ts +46 -0
- package/dist/api/runs/RdfRunContextRetriever.js +277 -0
- package/dist/api/runs/RdfRunContextRetriever.js.map +1 -0
- package/dist/api/runs/RunExecutionBackend.d.ts +38 -0
- package/dist/api/runs/RunExecutionBackend.js.map +1 -1
- package/dist/api/runs/RunStateCenter.d.ts +18 -3
- package/dist/api/runs/RunStateCenter.js +85 -24
- package/dist/api/runs/RunStateCenter.js.map +1 -1
- package/dist/api/runtime.js +163 -3
- package/dist/api/runtime.js.map +1 -1
- package/dist/api/service/AiClientConfigurationService.d.ts +97 -0
- package/dist/api/service/AiClientConfigurationService.js +379 -0
- package/dist/api/service/AiClientConfigurationService.js.map +1 -0
- package/dist/api/service/RdfBenchmarkReportCatalog.d.ts +86 -0
- package/dist/api/service/RdfBenchmarkReportCatalog.js +349 -0
- package/dist/api/service/RdfBenchmarkReportCatalog.js.map +1 -0
- package/dist/api/service/RdfBenchmarkReportGate.d.ts +78 -0
- package/dist/api/service/RdfBenchmarkReportGate.js +197 -0
- package/dist/api/service/RdfBenchmarkReportGate.js.map +1 -0
- package/dist/api/service/RdfSearchIndexingService.d.ts +113 -0
- package/dist/api/service/RdfSearchIndexingService.js +272 -0
- package/dist/api/service/RdfSearchIndexingService.js.map +1 -0
- package/dist/api/service/RdfSearchIndexingSolidFsSyncer.d.ts +27 -0
- package/dist/api/service/RdfSearchIndexingSolidFsSyncer.js +90 -0
- package/dist/api/service/RdfSearchIndexingSolidFsSyncer.js.map +1 -0
- package/dist/api/service/RdfStorageStatsService.d.ts +31 -0
- package/dist/api/service/RdfStorageStatsService.js +97 -0
- package/dist/api/service/RdfStorageStatsService.js.map +1 -0
- package/dist/api/service/VectorStoreService.d.ts +2 -0
- package/dist/api/service/VectorStoreService.js +70 -2
- package/dist/api/service/VectorStoreService.js.map +1 -1
- package/dist/api/service/VercelChatService.d.ts +27 -38
- package/dist/api/service/VercelChatService.js +153 -505
- package/dist/api/service/VercelChatService.js.map +1 -1
- package/dist/api/service/provider-http-transport.d.ts +21 -0
- package/dist/api/service/provider-http-transport.js +108 -2
- package/dist/api/service/provider-http-transport.js.map +1 -1
- package/dist/api/service/provider-registry.d.ts +5 -7
- package/dist/api/service/provider-registry.js +81 -64
- package/dist/api/service/provider-registry.js.map +1 -1
- package/dist/api/tasks/InngestTaskScheduler.d.ts +44 -4
- package/dist/api/tasks/TaskMaterializer.d.ts +10 -1
- package/dist/api/tasks/TaskMaterializer.js +39 -4
- package/dist/api/tasks/TaskMaterializer.js.map +1 -1
- package/dist/api/tasks/TaskService.d.ts +5 -1
- package/dist/api/tasks/TaskService.js +3 -0
- package/dist/api/tasks/TaskService.js.map +1 -1
- package/dist/cli/commands/rdf.d.ts +9 -0
- package/dist/cli/commands/rdf.js +66 -1
- package/dist/cli/commands/rdf.js.map +1 -1
- package/dist/cli/commands/start.js +3 -0
- package/dist/cli/commands/start.js.map +1 -1
- package/dist/cli/lib/solid-auth.d.ts +3 -3
- package/dist/cli/lib/solid-auth.js +4 -4
- package/dist/cli/lib/solid-auth.js.map +1 -1
- package/dist/components/components.jsonld +16 -0
- package/dist/components/context.jsonld +815 -28
- package/dist/document/Chunker.jsonld +110 -0
- package/dist/document/{DocumentParser.d.ts → DocumentReader.d.ts} +23 -11
- package/dist/document/{DocumentParser.js → DocumentReader.js} +2 -2
- package/dist/document/DocumentReader.js.map +1 -0
- package/dist/document/DocumentReader.jsonld +82 -0
- package/dist/document/HeadingChunker.jsonld +41 -0
- package/dist/document/{JinaDocumentParser.d.ts → JinaReader.d.ts} +7 -7
- package/dist/document/{JinaDocumentParser.js → JinaReader.js} +12 -12
- package/dist/document/JinaReader.js.map +1 -0
- package/dist/document/JinaReader.jsonld +133 -0
- package/dist/document/L0SourceSummary.d.ts +103 -0
- package/dist/document/L0SourceSummary.js +157 -0
- package/dist/document/L0SourceSummary.js.map +1 -0
- package/dist/document/L0SourceSummary.jsonld +326 -0
- package/dist/document/PaddleOcrReader.d.ts +40 -0
- package/dist/document/PaddleOcrReader.js +53 -0
- package/dist/document/PaddleOcrReader.js.map +1 -0
- package/dist/document/PaddleOcrReader.jsonld +234 -0
- package/dist/document/ReaderAiConfig.d.ts +50 -0
- package/dist/document/ReaderAiConfig.js +109 -0
- package/dist/document/ReaderAiConfig.js.map +1 -0
- package/dist/document/ReaderAiConfig.jsonld +185 -0
- package/dist/document/ReaderPolicy.d.ts +89 -0
- package/dist/document/ReaderPolicy.js +158 -0
- package/dist/document/ReaderPolicy.js.map +1 -0
- package/dist/document/ReaderPolicy.jsonld +218 -0
- package/dist/document/index.d.ts +6 -2
- package/dist/document/index.js +6 -2
- package/dist/document/index.js.map +1 -1
- package/dist/edge/DdnsManager.d.ts +1 -1
- package/dist/edge/DdnsManager.js.map +1 -1
- package/dist/edge/EdgeNodeAgent.d.ts +4 -0
- package/dist/edge/EdgeNodeAgent.js +6 -0
- package/dist/edge/EdgeNodeAgent.js.map +1 -1
- package/dist/edge/EdgeNodeAgent.jsonld +8 -0
- package/dist/edge/EdgeNodeAgentInitializer.d.ts +16 -0
- package/dist/edge/EdgeNodeAgentInitializer.js +51 -0
- package/dist/edge/EdgeNodeAgentInitializer.js.map +1 -1
- package/dist/edge/EdgeNodeAgentInitializer.jsonld +250 -0
- package/dist/edge/EdgeNodeCertificateCapabilityBridge.d.ts +34 -0
- package/dist/edge/EdgeNodeCertificateCapabilityBridge.js +111 -0
- package/dist/edge/EdgeNodeCertificateCapabilityBridge.js.map +1 -0
- package/dist/edge/acme/AcmeCertificateManager.d.ts +14 -1
- package/dist/edge/acme/AcmeCertificateManager.js +67 -7
- package/dist/edge/acme/AcmeCertificateManager.js.map +1 -1
- package/dist/edge/acme/AcmeCertificateManager.jsonld +22 -2
- package/dist/edge/acme/ClusterCertificateManager.d.ts +12 -0
- package/dist/edge/acme/ClusterCertificateManager.js +38 -0
- package/dist/edge/acme/ClusterCertificateManager.js.map +1 -1
- package/dist/extensions/ExtensionRuntime.d.ts +17 -0
- package/dist/extensions/ExtensionRuntime.js +171 -0
- package/dist/extensions/ExtensionRuntime.js.map +1 -0
- package/dist/extensions/PodCredentialResolver.d.ts +23 -0
- package/dist/extensions/PodCredentialResolver.js +139 -0
- package/dist/extensions/PodCredentialResolver.js.map +1 -0
- package/dist/extensions/index.d.ts +3 -0
- package/dist/extensions/index.js +20 -0
- package/dist/extensions/index.js.map +1 -0
- package/dist/extensions/types.d.ts +73 -0
- package/dist/extensions/types.js +3 -0
- package/dist/extensions/types.js.map +1 -0
- package/dist/http/SubgraphSparqlHttpHandler.d.ts +20 -1
- package/dist/http/SubgraphSparqlHttpHandler.js +324 -43
- package/dist/http/SubgraphSparqlHttpHandler.js.map +1 -1
- package/dist/http/SubgraphSparqlHttpHandler.jsonld +87 -0
- package/dist/identity/drizzle/EdgeNodeRepository.js +3 -2
- package/dist/identity/drizzle/EdgeNodeRepository.js.map +1 -1
- package/dist/identity/drizzle/schema.pg.js +1 -1
- package/dist/identity/drizzle/schema.pg.js.map +1 -1
- package/dist/identity/drizzle/schema.sqlite.js +1 -1
- package/dist/identity/drizzle/schema.sqlite.js.map +1 -1
- package/dist/identity/oidc/ScopedPickWebIdHandler.js +5 -5
- package/dist/identity/oidc/ScopedPickWebIdHandler.js.map +1 -1
- package/dist/index.d.ts +12 -2
- package/dist/index.js +13 -1
- package/dist/index.js.map +1 -1
- package/dist/main.js +3 -0
- package/dist/main.js.map +1 -1
- package/dist/provision/LocalProvisionState.d.ts +28 -0
- package/dist/provision/LocalProvisionState.js +124 -0
- package/dist/provision/LocalProvisionState.js.map +1 -0
- package/dist/provision/ProvisionCodeCodec.d.ts +7 -3
- package/dist/provision/ProvisionCodeCodec.js +10 -3
- package/dist/provision/ProvisionCodeCodec.js.map +1 -1
- package/dist/provision/ProvisionPodCreator.d.ts +15 -1
- package/dist/provision/ProvisionPodCreator.js +68 -1
- package/dist/provision/ProvisionPodCreator.js.map +1 -1
- package/dist/provision/ProvisionPodCreator.jsonld +31 -0
- package/dist/provision/ServiceAccessTokenCodec.d.ts +45 -0
- package/dist/provision/ServiceAccessTokenCodec.js +86 -0
- package/dist/provision/ServiceAccessTokenCodec.js.map +1 -0
- package/dist/runtime/GatewayAdminProxyAuth.d.ts +29 -0
- package/dist/runtime/GatewayAdminProxyAuth.js +108 -0
- package/dist/runtime/GatewayAdminProxyAuth.js.map +1 -0
- package/dist/runtime/Proxy.d.ts +10 -0
- package/dist/runtime/Proxy.js +64 -6
- package/dist/runtime/Proxy.js.map +1 -1
- package/dist/runtime/XpodRuntime.js +1 -0
- package/dist/runtime/XpodRuntime.js.map +1 -1
- package/dist/runtime/bootstrap.d.ts +1 -0
- package/dist/runtime/bootstrap.js +29 -0
- package/dist/runtime/bootstrap.js.map +1 -1
- package/dist/runtime/css-process.d.ts +1 -0
- package/dist/runtime/css-process.js +1 -0
- package/dist/runtime/css-process.js.map +1 -1
- package/dist/runtime/index.d.ts +1 -0
- package/dist/runtime/index.js +3 -1
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/lifecycle.d.ts +3 -1
- package/dist/runtime/lifecycle.js +3 -1
- package/dist/runtime/lifecycle.js.map +1 -1
- package/dist/runtime/runner/node/NodeGatewayRuntimeRunner.js +2 -0
- package/dist/runtime/runner/node/NodeGatewayRuntimeRunner.js.map +1 -1
- package/dist/runtime/runner/types.d.ts +3 -0
- package/dist/runtime/runner/types.js.map +1 -1
- package/dist/runtime/runtime-types.d.ts +2 -0
- package/dist/runtime/runtime-types.js.map +1 -1
- package/dist/runtime/safe-env.d.ts +15 -0
- package/dist/runtime/safe-env.js +109 -0
- package/dist/runtime/safe-env.js.map +1 -0
- package/dist/security/index.d.ts +1 -0
- package/dist/security/index.js +18 -0
- package/dist/security/index.js.map +1 -0
- package/dist/security/secret-cell/DeploymentRootKeyProvider.d.ts +17 -0
- package/dist/security/secret-cell/DeploymentRootKeyProvider.js +61 -0
- package/dist/security/secret-cell/DeploymentRootKeyProvider.js.map +1 -0
- package/dist/security/secret-cell/DeploymentRootKeyProvider.jsonld +124 -0
- package/dist/security/secret-cell/SecretCellVault.d.ts +55 -0
- package/dist/security/secret-cell/SecretCellVault.js +242 -0
- package/dist/security/secret-cell/SecretCellVault.js.map +1 -0
- package/dist/security/secret-cell/SecretCellVault.jsonld +207 -0
- package/dist/security/secret-cell/index.d.ts +2 -0
- package/dist/security/secret-cell/index.js +11 -0
- package/dist/security/secret-cell/index.js.map +1 -0
- package/dist/solidfs/CompositeSolidFsSyncer.d.ts +18 -0
- package/dist/solidfs/CompositeSolidFsSyncer.js +32 -0
- package/dist/solidfs/CompositeSolidFsSyncer.js.map +1 -0
- package/dist/solidfs/LocalSolidFS.js +25 -1
- package/dist/solidfs/LocalSolidFS.js.map +1 -1
- package/dist/solidfs/RdfIndexSolidFsSyncer.d.ts +41 -2
- package/dist/solidfs/RdfIndexSolidFsSyncer.js +331 -21
- package/dist/solidfs/RdfIndexSolidFsSyncer.js.map +1 -1
- package/dist/solidfs/SolidFsMetaNotes.d.ts +25 -0
- package/dist/solidfs/SolidFsMetaNotes.js +103 -0
- package/dist/solidfs/SolidFsMetaNotes.js.map +1 -0
- package/dist/solidfs/SolidFsSyncJournal.d.ts +2 -2
- package/dist/solidfs/SolidFsSyncJournal.js +9 -4
- package/dist/solidfs/SolidFsSyncJournal.js.map +1 -1
- package/dist/solidfs/SolidFsSyncJournal.jsonld +119 -0
- package/dist/solidfs/WorkspacePrompt.d.ts +13 -0
- package/dist/solidfs/WorkspacePrompt.js +42 -0
- package/dist/solidfs/WorkspacePrompt.js.map +1 -0
- package/dist/solidfs/index.d.ts +3 -0
- package/dist/solidfs/index.js +3 -0
- package/dist/solidfs/index.js.map +1 -1
- package/dist/solidfs/types.d.ts +12 -2
- package/dist/solidfs/types.js.map +1 -1
- package/dist/storage/accessors/MixDataAccessor.d.ts +36 -4
- package/dist/storage/accessors/MixDataAccessor.js +222 -23
- package/dist/storage/accessors/MixDataAccessor.js.map +1 -1
- package/dist/storage/accessors/MixDataAccessor.jsonld +89 -0
- package/dist/storage/accessors/SolidRdfDataAccessor.d.ts +6 -1
- package/dist/storage/accessors/SolidRdfDataAccessor.js +35 -0
- package/dist/storage/accessors/SolidRdfDataAccessor.js.map +1 -1
- package/dist/storage/accessors/SolidRdfDataAccessor.jsonld +20 -0
- package/dist/storage/database/PostgresPoolManager.d.ts +1 -0
- package/dist/storage/database/PostgresPoolManager.js +2 -2
- package/dist/storage/database/PostgresPoolManager.js.map +1 -1
- package/dist/storage/locking/UrlAwareRedisLocker.d.ts +2 -0
- package/dist/storage/locking/UrlAwareRedisLocker.js +65 -0
- package/dist/storage/locking/UrlAwareRedisLocker.js.map +1 -1
- package/dist/storage/locking/UrlAwareRedisLocker.jsonld +19 -0
- package/dist/storage/rdf/PostgresRdfEngine.d.ts +286 -9
- package/dist/storage/rdf/PostgresRdfEngine.js +10773 -2084
- package/dist/storage/rdf/PostgresRdfEngine.js.map +1 -1
- package/dist/storage/rdf/PostgresRdfEngine.jsonld +1693 -89
- package/dist/storage/rdf/PostgresRdfSqlExecutor.d.ts +24 -0
- package/dist/storage/rdf/PostgresRdfSqlExecutor.js +131 -0
- package/dist/storage/rdf/PostgresRdfSqlExecutor.js.map +1 -0
- package/dist/storage/rdf/PostgresRdfTextIndex.d.ts +54 -0
- package/dist/storage/rdf/PostgresRdfTextIndex.js +1255 -0
- package/dist/storage/rdf/PostgresRdfTextIndex.js.map +1 -0
- package/dist/storage/rdf/PostgresRdfTextIndex.jsonld +487 -0
- package/dist/storage/rdf/PostgresRdfVectorIndex.d.ts +46 -0
- package/dist/storage/rdf/PostgresRdfVectorIndex.js +1165 -0
- package/dist/storage/rdf/PostgresRdfVectorIndex.js.map +1 -0
- package/dist/storage/rdf/PostgresRdfVectorIndex.jsonld +423 -0
- package/dist/storage/rdf/Rdf3xIndex.d.ts +14 -1
- package/dist/storage/rdf/Rdf3xIndex.js +286 -2
- package/dist/storage/rdf/Rdf3xIndex.js.map +1 -1
- package/dist/storage/rdf/Rdf3xIndex.jsonld +36 -0
- package/dist/storage/rdf/Rdf3xSchema.d.ts +5 -1
- package/dist/storage/rdf/Rdf3xSchema.js +17 -3
- package/dist/storage/rdf/Rdf3xSchema.js.map +1 -1
- package/dist/storage/rdf/RdfAccessScope.d.ts +22 -0
- package/dist/storage/rdf/RdfAccessScope.js +345 -0
- package/dist/storage/rdf/RdfAccessScope.js.map +1 -0
- package/dist/storage/rdf/RdfAccessScope.jsonld +45 -0
- package/dist/storage/rdf/RdfFusionRankPlan.d.ts +2 -0
- package/dist/storage/rdf/RdfFusionRankPlan.js +186 -0
- package/dist/storage/rdf/RdfFusionRankPlan.js.map +1 -0
- package/dist/storage/rdf/RdfJoinShape.d.ts +8 -0
- package/dist/storage/rdf/RdfJoinShape.js +31 -0
- package/dist/storage/rdf/RdfJoinShape.js.map +1 -0
- package/dist/storage/rdf/RdfQuadIndex.d.ts +5 -2
- package/dist/storage/rdf/RdfQuadIndex.js +94 -6
- package/dist/storage/rdf/RdfQuadIndex.js.map +1 -1
- package/dist/storage/rdf/RdfQuadIndex.jsonld +12 -0
- package/dist/storage/rdf/RdfQueryExecutor.d.ts +3 -4
- package/dist/storage/rdf/RdfQueryExecutor.js +235 -8
- package/dist/storage/rdf/RdfQueryExecutor.js.map +1 -1
- package/dist/storage/rdf/RdfSearchSourceFilter.d.ts +10 -0
- package/dist/storage/rdf/RdfSearchSourceFilter.js +83 -0
- package/dist/storage/rdf/RdfSearchSourceFilter.js.map +1 -0
- package/dist/storage/rdf/RdfSparqlAdapter.d.ts +27 -1
- package/dist/storage/rdf/RdfSparqlAdapter.js +265 -3
- package/dist/storage/rdf/RdfSparqlAdapter.js.map +1 -1
- package/dist/storage/rdf/RdfSparqlAdapter.jsonld +8 -0
- package/dist/storage/rdf/RdfTermDictionary.d.ts +7 -1
- package/dist/storage/rdf/RdfTermDictionary.js +139 -0
- package/dist/storage/rdf/RdfTermDictionary.js.map +1 -1
- package/dist/storage/rdf/RdfTermDictionary.jsonld +4 -0
- package/dist/storage/rdf/RdfTextIndex.d.ts +45 -2
- package/dist/storage/rdf/RdfTextIndex.js +810 -114
- package/dist/storage/rdf/RdfTextIndex.js.map +1 -1
- package/dist/storage/rdf/RdfTextIndex.jsonld +193 -0
- package/dist/storage/rdf/RdfTextProjection.d.ts +10 -0
- package/dist/storage/rdf/RdfTextProjection.js +258 -0
- package/dist/storage/rdf/RdfTextProjection.js.map +1 -0
- package/dist/storage/rdf/RdfVectorIndex.d.ts +30 -2
- package/dist/storage/rdf/RdfVectorIndex.js +461 -38
- package/dist/storage/rdf/RdfVectorIndex.js.map +1 -1
- package/dist/storage/rdf/RdfVectorIndex.jsonld +163 -0
- package/dist/storage/rdf/SolidRdfEngine.d.ts +12 -9
- package/dist/storage/rdf/SolidRdfEngine.js +48 -22
- package/dist/storage/rdf/SolidRdfEngine.js.map +1 -1
- package/dist/storage/rdf/SolidRdfEngine.jsonld +33 -43
- package/dist/storage/rdf/SolidRdfSparqlEngine.d.ts +19 -8
- package/dist/storage/rdf/SolidRdfSparqlEngine.js +674 -44
- package/dist/storage/rdf/SolidRdfSparqlEngine.js.map +1 -1
- package/dist/storage/rdf/SolidRdfSparqlEngine.jsonld +51 -0
- package/dist/storage/rdf/index.d.ts +9 -5
- package/dist/storage/rdf/index.js +42 -1
- package/dist/storage/rdf/index.js.map +1 -1
- package/dist/storage/rdf/models-benchmark.d.ts +264 -2
- package/dist/storage/rdf/models-benchmark.js +4207 -155
- package/dist/storage/rdf/models-benchmark.js.map +1 -1
- package/dist/storage/rdf/types.d.ts +833 -4
- package/dist/storage/rdf/types.js.map +1 -1
- package/dist/storage/rdf/types.jsonld +348 -0
- package/dist/storage/sparql/CompatibilitySparqlEngine.d.ts +14 -13
- package/dist/storage/sparql/CompatibilitySparqlEngine.js +24 -24
- package/dist/storage/sparql/CompatibilitySparqlEngine.js.map +1 -1
- package/dist/storage/sparql/CompatibilitySparqlEngineImpl.d.ts +14 -13
- package/dist/storage/sparql/CompatibilitySparqlEngineImpl.js +30 -18
- package/dist/storage/sparql/CompatibilitySparqlEngineImpl.js.map +1 -1
- package/dist/storage/sparql/SubgraphQueryEngine.d.ts +21 -12
- package/dist/storage/sparql/SubgraphQueryEngine.js +12 -12
- package/dist/storage/sparql/SubgraphQueryEngine.js.map +1 -1
- package/dist/terminal/sandbox/MacOSSandbox.js +2 -1
- package/dist/terminal/sandbox/MacOSSandbox.js.map +1 -1
- package/dist/terminal/sandbox/index.js +2 -1
- package/dist/terminal/sandbox/index.js.map +1 -1
- package/dist/test-utils/no-auth-xpod.js +3 -0
- package/dist/test-utils/no-auth-xpod.js.map +1 -1
- package/dist/tunnel/LocalTunnelProvider.d.ts +3 -0
- package/dist/tunnel/LocalTunnelProvider.js +17 -1
- package/dist/tunnel/LocalTunnelProvider.js.map +1 -1
- package/dist/tunnel/LocalTunnelProvider.jsonld +23 -0
- package/dist/tunnel/SakuraFrpTunnelProvider.d.ts +3 -0
- package/dist/tunnel/SakuraFrpTunnelProvider.js +18 -2
- package/dist/tunnel/SakuraFrpTunnelProvider.js.map +1 -1
- package/dist/tunnel/TunnelProfiles.d.ts +22 -0
- package/dist/tunnel/TunnelProfiles.js +208 -0
- package/dist/tunnel/TunnelProfiles.js.map +1 -0
- package/dist/tunnel/index.d.ts +2 -0
- package/dist/tunnel/index.js +4 -1
- package/dist/tunnel/index.js.map +1 -1
- package/dist/util/identifiers/ClusterIdentifierStrategy.d.ts +3 -0
- package/dist/util/identifiers/ClusterIdentifierStrategy.js +18 -2
- package/dist/util/identifiers/ClusterIdentifierStrategy.js.map +1 -1
- package/dist/util/identifiers/ClusterIdentifierStrategy.jsonld +5 -1
- package/node_modules/@undefineds.co/ai-connection/dist/AiClientConfigurationSection.d.ts +55 -0
- package/node_modules/@undefineds.co/ai-connection/dist/AiClientConfigurationSection.js +167 -0
- package/node_modules/@undefineds.co/ai-connection/dist/AiConnectionHeader.d.ts +3 -0
- package/node_modules/@undefineds.co/ai-connection/dist/AiConnectionHeader.js +8 -0
- package/node_modules/@undefineds.co/ai-connection/dist/AiConnectionList.d.ts +4 -0
- package/node_modules/@undefineds.co/ai-connection/dist/AiConnectionList.js +36 -0
- package/node_modules/@undefineds.co/ai-connection/dist/AiConnectionMain.d.ts +4 -0
- package/node_modules/@undefineds.co/ai-connection/dist/AiConnectionMain.js +37 -0
- package/node_modules/@undefineds.co/ai-connection/dist/AiConnectionMainHeader.d.ts +3 -0
- package/node_modules/@undefineds.co/ai-connection/dist/AiConnectionMainHeader.js +7 -0
- package/node_modules/@undefineds.co/ai-connection/dist/AiConnectionPanel.d.ts +14 -0
- package/node_modules/@undefineds.co/ai-connection/dist/AiConnectionPanel.js +333 -0
- package/node_modules/@undefineds.co/ai-connection/dist/AiProviderCard.d.ts +22 -0
- package/node_modules/@undefineds.co/ai-connection/dist/AiProviderCard.js +43 -0
- package/node_modules/@undefineds.co/ai-connection/dist/AiQuotaCard.d.ts +8 -0
- package/node_modules/@undefineds.co/ai-connection/dist/AiQuotaCard.js +6 -0
- package/node_modules/@undefineds.co/ai-connection/dist/ai-connection-client.d.ts +120 -0
- package/node_modules/@undefineds.co/ai-connection/dist/ai-connection-client.js +414 -0
- package/node_modules/@undefineds.co/ai-connection/dist/client-config/base-adapter.d.ts +32 -0
- package/node_modules/@undefineds.co/ai-connection/dist/client-config/base-adapter.js +212 -0
- package/node_modules/@undefineds.co/ai-connection/dist/client-config/codex.d.ts +14 -0
- package/node_modules/@undefineds.co/ai-connection/dist/client-config/codex.js +90 -0
- package/node_modules/@undefineds.co/ai-connection/dist/client-config/index.cjs +668 -0
- package/node_modules/@undefineds.co/ai-connection/dist/client-config/index.d.ts +6 -0
- package/node_modules/@undefineds.co/ai-connection/dist/client-config/index.js +6 -0
- package/node_modules/@undefineds.co/ai-connection/dist/client-config/json-env-adapter.d.ts +21 -0
- package/node_modules/@undefineds.co/ai-connection/dist/client-config/json-env-adapter.js +82 -0
- package/node_modules/@undefineds.co/ai-connection/dist/client-config/pi.d.ts +13 -0
- package/node_modules/@undefineds.co/ai-connection/dist/client-config/pi.js +83 -0
- package/node_modules/@undefineds.co/ai-connection/dist/client-config/transaction.d.ts +17 -0
- package/node_modules/@undefineds.co/ai-connection/dist/client-config/transaction.js +153 -0
- package/node_modules/@undefineds.co/ai-connection/dist/client-config/types.d.ts +40 -0
- package/node_modules/@undefineds.co/ai-connection/dist/client-config/types.js +1 -0
- package/node_modules/@undefineds.co/ai-connection/dist/controller.d.ts +42 -0
- package/node_modules/@undefineds.co/ai-connection/dist/controller.js +289 -0
- package/node_modules/@undefineds.co/ai-connection/dist/index.d.ts +16 -0
- package/node_modules/@undefineds.co/ai-connection/dist/index.js +41 -0
- package/node_modules/@undefineds.co/ai-connection/dist/manifest.d.ts +1 -0
- package/node_modules/@undefineds.co/ai-connection/dist/manifest.js +18 -0
- package/node_modules/@undefineds.co/ai-connection/dist/service-access.d.ts +3 -0
- package/node_modules/@undefineds.co/ai-connection/dist/service-access.js +133 -0
- package/node_modules/@undefineds.co/ai-connection/package.json +50 -0
- package/node_modules/@undefineds.co/extension-sdk/README.md +299 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/index.d.ts +5 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/index.js +5 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/layout.d.ts +16 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/layout.js +36 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/manifest.d.ts +27 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/manifest.js +79 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/react/app-layout.d.ts +7 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/react/app-layout.js +8 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/react/auth-boundary.d.ts +27 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/react/auth-boundary.js +49 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/react/layout-context.d.ts +11 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/react/layout-context.js +9 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/react/workspace-layout.d.ts +38 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/react/workspace-layout.js +132 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/react.d.ts +12 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/react.js +19 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/testing.d.ts +7 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/testing.js +27 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/web.d.ts +225 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/web.js +142 -0
- package/node_modules/@undefineds.co/extension-sdk/package.json +49 -0
- package/node_modules/@undefineds.co/extensions/README.md +101 -0
- package/node_modules/@undefineds.co/extensions/dist/adapters/langchain.d.ts +25 -0
- package/node_modules/@undefineds.co/extensions/dist/adapters/langchain.d.ts.map +1 -0
- package/node_modules/@undefineds.co/extensions/dist/adapters/langchain.js +45 -0
- package/node_modules/@undefineds.co/extensions/dist/adapters/langchain.js.map +1 -0
- package/node_modules/@undefineds.co/extensions/dist/adapters/llamaindex.d.ts +31 -0
- package/node_modules/@undefineds.co/extensions/dist/adapters/llamaindex.d.ts.map +1 -0
- package/node_modules/@undefineds.co/extensions/dist/adapters/llamaindex.js +50 -0
- package/node_modules/@undefineds.co/extensions/dist/adapters/llamaindex.js.map +1 -0
- package/node_modules/@undefineds.co/extensions/dist/index.d.ts +7 -0
- package/node_modules/@undefineds.co/extensions/dist/index.d.ts.map +1 -0
- package/node_modules/@undefineds.co/extensions/dist/index.js +7 -0
- package/node_modules/@undefineds.co/extensions/dist/index.js.map +1 -0
- package/node_modules/@undefineds.co/extensions/dist/paddleocr.d.ts +16 -0
- package/node_modules/@undefineds.co/extensions/dist/paddleocr.d.ts.map +1 -0
- package/node_modules/@undefineds.co/extensions/dist/paddleocr.js +267 -0
- package/node_modules/@undefineds.co/extensions/dist/paddleocr.js.map +1 -0
- package/node_modules/@undefineds.co/extensions/dist/reader.d.ts +18 -0
- package/node_modules/@undefineds.co/extensions/dist/reader.d.ts.map +1 -0
- package/node_modules/@undefineds.co/extensions/dist/reader.js +39 -0
- package/node_modules/@undefineds.co/extensions/dist/reader.js.map +1 -0
- package/node_modules/@undefineds.co/extensions/dist/registry.d.ts +16 -0
- package/node_modules/@undefineds.co/extensions/dist/registry.d.ts.map +1 -0
- package/node_modules/@undefineds.co/extensions/dist/registry.js +97 -0
- package/node_modules/@undefineds.co/extensions/dist/registry.js.map +1 -0
- package/node_modules/@undefineds.co/extensions/dist/types.d.ts +141 -0
- package/node_modules/@undefineds.co/extensions/dist/types.d.ts.map +1 -0
- package/node_modules/@undefineds.co/extensions/dist/types.js +2 -0
- package/node_modules/@undefineds.co/extensions/dist/types.js.map +1 -0
- package/node_modules/@undefineds.co/extensions/package.json +38 -0
- package/node_modules/@undefineds.co/shared-ui/dist/badge.d.ts +8 -0
- package/node_modules/@undefineds.co/shared-ui/dist/badge.js +17 -0
- package/node_modules/@undefineds.co/shared-ui/dist/button.d.ts +10 -0
- package/node_modules/@undefineds.co/shared-ui/dist/button.js +30 -0
- package/node_modules/@undefineds.co/shared-ui/dist/card.d.ts +7 -0
- package/node_modules/@undefineds.co/shared-ui/dist/card.js +15 -0
- package/node_modules/@undefineds.co/shared-ui/dist/index.d.ts +6 -0
- package/node_modules/@undefineds.co/shared-ui/dist/index.js +6 -0
- package/node_modules/@undefineds.co/shared-ui/dist/input.d.ts +4 -0
- package/node_modules/@undefineds.co/shared-ui/dist/input.js +5 -0
- package/node_modules/@undefineds.co/shared-ui/dist/theme.css +121 -0
- package/node_modules/@undefineds.co/shared-ui/dist/utils.d.ts +2 -0
- package/node_modules/@undefineds.co/shared-ui/dist/utils.js +5 -0
- package/node_modules/@undefineds.co/shared-ui/dist/workspace.d.ts +23 -0
- package/node_modules/@undefineds.co/shared-ui/dist/workspace.js +38 -0
- package/node_modules/@undefineds.co/shared-ui/package.json +39 -0
- package/node_modules/@undefineds.co/solid-sdk/dist/index.d.ts +3 -0
- package/node_modules/@undefineds.co/solid-sdk/dist/index.js +3 -0
- package/node_modules/@undefineds.co/solid-sdk/dist/pod-runtime.d.ts +45 -0
- package/node_modules/@undefineds.co/solid-sdk/dist/pod-runtime.js +147 -0
- package/node_modules/@undefineds.co/solid-sdk/dist/react.d.ts +15 -0
- package/node_modules/@undefineds.co/solid-sdk/dist/react.js +15 -0
- package/node_modules/@undefineds.co/solid-sdk/dist/session.d.ts +42 -0
- package/node_modules/@undefineds.co/solid-sdk/dist/session.js +127 -0
- package/node_modules/@undefineds.co/solid-sdk/package.json +45 -0
- package/package.json +31 -13
- package/static/app/assets/index-BoYHJ6si.js +230 -0
- package/static/app/assets/inrupt-smoke.js +2 -2
- package/static/app/assets/main.css +1 -1
- package/static/app/assets/main.js +9 -9
- package/static/dashboard/assets/NetworkPage-Brt79fuQ.js +2 -0
- package/static/dashboard/assets/PaneListHeader-57nvMwH6.js +1 -0
- package/static/dashboard/assets/PodPage-CM6do1vB.js +2 -0
- package/static/dashboard/assets/ServicesPage-BUNxGJRz.js +1 -0
- package/static/dashboard/assets/card-B9Zjf_2p.js +1 -0
- package/static/dashboard/assets/dashboard-8C6o666W.js +305 -0
- package/static/dashboard/assets/dashboard-CSdewNeA.css +1 -0
- package/static/dashboard/assets/database-DPh9wDY9.js +1 -0
- package/static/dashboard/assets/external-link-VbMQvVMz.js +1 -0
- package/static/dashboard/assets/index-RfiFckzb.js +51 -0
- package/static/dashboard/assets/refresh-cw-BxVxNxNr.js +1 -0
- package/static/dashboard/assets/services-status-context-DKmJ7ISr.js +1 -0
- package/static/dashboard/dashboard.html +2 -2
- package/static/settings/assets/ModelsPage-D_IH7AH3.js +1 -0
- package/static/settings/assets/PaneListHeader-Bgaze006.js +1 -0
- package/static/settings/assets/PodPage-Cy1VNObw.js +2 -0
- package/static/settings/assets/ServicesPage-BsFaxVWC.js +1 -0
- package/static/settings/assets/SettingsPage-UafNWE_p.js +48 -0
- package/static/settings/assets/card-B_bXSIn-.js +1 -0
- package/static/settings/assets/services-status-context-DiX-AbrP.js +1 -0
- package/static/settings/assets/settings-B30oMfZq.js +305 -0
- package/static/settings/assets/settings-CSdewNeA.css +1 -0
- package/static/settings/assets/workspace-layout-Dv1Yn9Ci.js +1 -0
- package/static/settings/auth.html +21 -0
- package/static/settings/reachability.html +221 -0
- package/static/settings/reachability.svg +7 -0
- package/static/settings/reachability.webmanifest +18 -0
- package/static/settings/settings.html +13 -0
- package/static/settings/signal-pod.html +293 -0
- package/static/settings/vite.svg +1 -0
- package/dist/api/service/ai-gateway-transport.d.ts +0 -25
- package/dist/api/service/ai-gateway-transport.js +0 -136
- package/dist/api/service/ai-gateway-transport.js.map +0 -1
- package/dist/api/service/chat-protocol-adapters.d.ts +0 -5
- package/dist/api/service/chat-protocol-adapters.js +0 -146
- package/dist/api/service/chat-protocol-adapters.js.map +0 -1
- package/dist/api/service/chat-routing.d.ts +0 -8
- package/dist/api/service/chat-routing.js +0 -16
- package/dist/api/service/chat-routing.js.map +0 -1
- package/dist/api/service/platform-ai-config.d.ts +0 -10
- package/dist/api/service/platform-ai-config.js +0 -76
- package/dist/api/service/platform-ai-config.js.map +0 -1
- package/dist/document/DocumentParser.js.map +0 -1
- package/dist/document/JinaDocumentParser.js.map +0 -1
- package/static/app/assets/index-C1yksyT4.js +0 -171
- package/static/dashboard/assets/dashboard-BssaVKTn.css +0 -1
- package/static/dashboard/assets/dashboard-Ckuadl3C.js +0 -54
|
@@ -0,0 +1,1165 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PostgresRdfVectorIndex = void 0;
|
|
4
|
+
const pglite_1 = require("@electric-sql/pglite");
|
|
5
|
+
const PostgresPoolManager_1 = require("../database/PostgresPoolManager");
|
|
6
|
+
const RdfSearchSourceFilter_1 = require("./RdfSearchSourceFilter");
|
|
7
|
+
const PostgresRdfSqlExecutor_1 = require("./PostgresRdfSqlExecutor");
|
|
8
|
+
const RdfVectorIndex_1 = require("./RdfVectorIndex");
|
|
9
|
+
class PostgresRdfVectorIndex {
|
|
10
|
+
constructor(options = {}) {
|
|
11
|
+
this.executor = null;
|
|
12
|
+
this.pglite = null;
|
|
13
|
+
this.pgPool = null;
|
|
14
|
+
this.sharedPoolConfig = null;
|
|
15
|
+
this.initializing = null;
|
|
16
|
+
this.ensuredPgVectorIndexes = new Set();
|
|
17
|
+
this.options = {
|
|
18
|
+
...options,
|
|
19
|
+
driver: options.driver ?? (options.connectionString || options.pool ? 'pg' : 'pglite'),
|
|
20
|
+
};
|
|
21
|
+
if (options.autoOpen) {
|
|
22
|
+
void this.open();
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
async open() {
|
|
26
|
+
if (this.executor) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
this.initializing ??= this.openInternal();
|
|
30
|
+
await this.initializing;
|
|
31
|
+
}
|
|
32
|
+
async close() {
|
|
33
|
+
const executor = this.executor;
|
|
34
|
+
this.executor = null;
|
|
35
|
+
this.initializing = null;
|
|
36
|
+
if (this.sharedPoolConfig) {
|
|
37
|
+
(0, PostgresPoolManager_1.releaseSharedPool)(this.sharedPoolConfig);
|
|
38
|
+
this.sharedPoolConfig = null;
|
|
39
|
+
this.pgPool = null;
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
if (executor) {
|
|
43
|
+
await executor.close();
|
|
44
|
+
}
|
|
45
|
+
this.pglite = null;
|
|
46
|
+
this.pgPool = null;
|
|
47
|
+
}
|
|
48
|
+
async clear() {
|
|
49
|
+
await this.requireExecutor().exec('DELETE FROM rdf_vector_components; DELETE FROM rdf_vector_chunks; DELETE FROM rdf_vector_sources;');
|
|
50
|
+
}
|
|
51
|
+
async indexVector(source, chunks) {
|
|
52
|
+
const executor = this.requireExecutor();
|
|
53
|
+
await executor.transaction(async (tx) => {
|
|
54
|
+
const sourceId = await this.upsertSource(tx, source);
|
|
55
|
+
if (chunks.length === 0) {
|
|
56
|
+
await tx.exec(`
|
|
57
|
+
DELETE FROM rdf_vector_components
|
|
58
|
+
WHERE chunk_id IN (
|
|
59
|
+
SELECT id FROM rdf_vector_chunks WHERE source_id = $1
|
|
60
|
+
)
|
|
61
|
+
`, [sourceId]);
|
|
62
|
+
await tx.exec('DELETE FROM rdf_vector_chunks WHERE source_id = $1', [sourceId]);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
const deletedIdentities = new Set();
|
|
66
|
+
for (const chunk of chunks) {
|
|
67
|
+
const identity = normalizeVectorIdentity(chunk);
|
|
68
|
+
const identityKey = vectorIdentityKey(identity);
|
|
69
|
+
if (!deletedIdentities.has(identityKey)) {
|
|
70
|
+
await tx.exec(`
|
|
71
|
+
DELETE FROM rdf_vector_components
|
|
72
|
+
WHERE chunk_id IN (
|
|
73
|
+
SELECT id FROM rdf_vector_chunks
|
|
74
|
+
WHERE source_id = $1
|
|
75
|
+
AND provider = $2
|
|
76
|
+
AND model = $3
|
|
77
|
+
AND model_version = $4
|
|
78
|
+
AND input_kind = $5
|
|
79
|
+
AND projection_policy_version = $6
|
|
80
|
+
)
|
|
81
|
+
`, [
|
|
82
|
+
sourceId,
|
|
83
|
+
identity.provider,
|
|
84
|
+
identity.model,
|
|
85
|
+
identity.modelVersion,
|
|
86
|
+
identity.inputKind,
|
|
87
|
+
identity.projectionPolicyVersion,
|
|
88
|
+
]);
|
|
89
|
+
await tx.exec(`
|
|
90
|
+
DELETE FROM rdf_vector_chunks
|
|
91
|
+
WHERE source_id = $1
|
|
92
|
+
AND provider = $2
|
|
93
|
+
AND model = $3
|
|
94
|
+
AND model_version = $4
|
|
95
|
+
AND input_kind = $5
|
|
96
|
+
AND projection_policy_version = $6
|
|
97
|
+
`, [
|
|
98
|
+
sourceId,
|
|
99
|
+
identity.provider,
|
|
100
|
+
identity.model,
|
|
101
|
+
identity.modelVersion,
|
|
102
|
+
identity.inputKind,
|
|
103
|
+
identity.projectionPolicyVersion,
|
|
104
|
+
]);
|
|
105
|
+
deletedIdentities.add(identityKey);
|
|
106
|
+
}
|
|
107
|
+
const embedding = (0, RdfVectorIndex_1.normalizeEmbedding)(chunk.embedding);
|
|
108
|
+
const usePgVector = this.usesPgVectorBackend();
|
|
109
|
+
const embeddingJson = JSON.stringify(embedding);
|
|
110
|
+
const pgVectorColumnSql = usePgVector ? 'embedding_vector,' : '';
|
|
111
|
+
const pgVectorValueSql = usePgVector ? ', $20::vector' : '';
|
|
112
|
+
const insertParams = [
|
|
113
|
+
sourceId,
|
|
114
|
+
chunk.chunkKey,
|
|
115
|
+
chunk.ordinal,
|
|
116
|
+
chunk.level,
|
|
117
|
+
chunk.heading || null,
|
|
118
|
+
JSON.stringify(chunk.path ?? []),
|
|
119
|
+
chunk.content,
|
|
120
|
+
chunk.startOffset,
|
|
121
|
+
chunk.endOffset,
|
|
122
|
+
embeddingJson,
|
|
123
|
+
chunk.summaryMetadata ? JSON.stringify(chunk.summaryMetadata) : null,
|
|
124
|
+
embedding.length,
|
|
125
|
+
(0, RdfVectorIndex_1.vectorMagnitude)(embedding),
|
|
126
|
+
identity.provider,
|
|
127
|
+
identity.model,
|
|
128
|
+
identity.modelVersion,
|
|
129
|
+
identity.inputKind,
|
|
130
|
+
chunk.inputHash ?? '',
|
|
131
|
+
identity.projectionPolicyVersion,
|
|
132
|
+
];
|
|
133
|
+
if (usePgVector) {
|
|
134
|
+
insertParams.push(formatPgVectorLiteral(embedding));
|
|
135
|
+
}
|
|
136
|
+
const rows = await tx.query(`
|
|
137
|
+
INSERT INTO rdf_vector_chunks (
|
|
138
|
+
source_id,
|
|
139
|
+
chunk_key,
|
|
140
|
+
ordinal,
|
|
141
|
+
level,
|
|
142
|
+
heading,
|
|
143
|
+
path,
|
|
144
|
+
content,
|
|
145
|
+
start_offset,
|
|
146
|
+
end_offset,
|
|
147
|
+
embedding_json,
|
|
148
|
+
summary_metadata,
|
|
149
|
+
dimensions,
|
|
150
|
+
magnitude,
|
|
151
|
+
provider,
|
|
152
|
+
model,
|
|
153
|
+
model_version,
|
|
154
|
+
input_kind,
|
|
155
|
+
input_hash,
|
|
156
|
+
projection_policy_version,
|
|
157
|
+
${pgVectorColumnSql}
|
|
158
|
+
updated_at
|
|
159
|
+
)
|
|
160
|
+
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19${pgVectorValueSql}, now())
|
|
161
|
+
RETURNING id
|
|
162
|
+
`, insertParams);
|
|
163
|
+
const chunkId = Number(rows[0]?.id);
|
|
164
|
+
if (!Number.isFinite(chunkId)) {
|
|
165
|
+
throw new Error(`Failed to insert RDF vector chunk for source: ${source.source}`);
|
|
166
|
+
}
|
|
167
|
+
if (!this.usesPgVectorBackend()) {
|
|
168
|
+
await insertVectorComponents(tx, chunkId, embedding);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
async deleteSource(source) {
|
|
174
|
+
const executor = this.requireExecutor();
|
|
175
|
+
const rows = await executor.query('SELECT id FROM rdf_vector_sources WHERE source = $1', [source]);
|
|
176
|
+
const id = Number(rows[0]?.id);
|
|
177
|
+
if (!Number.isFinite(id)) {
|
|
178
|
+
return 0;
|
|
179
|
+
}
|
|
180
|
+
return await executor.transaction(async (tx) => {
|
|
181
|
+
await tx.exec(`
|
|
182
|
+
DELETE FROM rdf_vector_components
|
|
183
|
+
WHERE chunk_id IN (
|
|
184
|
+
SELECT id FROM rdf_vector_chunks WHERE source_id = $1
|
|
185
|
+
)
|
|
186
|
+
`, [id]);
|
|
187
|
+
const deletedRows = await tx.query('SELECT COUNT(*) AS count FROM rdf_vector_chunks WHERE source_id = $1', [id]);
|
|
188
|
+
await tx.exec('DELETE FROM rdf_vector_chunks WHERE source_id = $1', [id]);
|
|
189
|
+
await tx.exec('DELETE FROM rdf_vector_sources WHERE id = $1', [id]);
|
|
190
|
+
return Number(deletedRows[0]?.count ?? 0);
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
async search(options) {
|
|
194
|
+
const embedding = (0, RdfVectorIndex_1.normalizeEmbedding)(options.embedding);
|
|
195
|
+
if (embedding.length === 0) {
|
|
196
|
+
return [];
|
|
197
|
+
}
|
|
198
|
+
const metric = options.metric ?? this.options.defaultMetric ?? 'cosine';
|
|
199
|
+
if (metric === 'cosine' && (0, RdfVectorIndex_1.vectorMagnitude)(embedding) === 0) {
|
|
200
|
+
return [];
|
|
201
|
+
}
|
|
202
|
+
await this.ensurePgVectorSearchIndex(embedding.length, metric);
|
|
203
|
+
const scoredQuery = this.usesPgVectorBackend()
|
|
204
|
+
? buildPgVectorNativeScoredRowsQuery(embedding, metric, options)
|
|
205
|
+
: buildPgVectorScoredRowsQuery(embedding, metric, options);
|
|
206
|
+
const rows = await this.requireExecutor().query(scoredQuery.sql, scoredQuery.params);
|
|
207
|
+
const backend = this.usesPgVectorBackend() ? 'pg-vector' : 'component';
|
|
208
|
+
return rows.map((rawRow) => {
|
|
209
|
+
const row = normalizeVectorScoredChunkRow(rawRow);
|
|
210
|
+
const rowEmbedding = (0, RdfVectorIndex_1.parseEmbedding)(row.embedding_json);
|
|
211
|
+
const distance = (0, RdfVectorIndex_1.scoredVectorDistance)(row, metric);
|
|
212
|
+
return toSearchResult(row, rowEmbedding, metric, (0, RdfVectorIndex_1.vectorMagnitude)(embedding), (0, RdfVectorIndex_1.vectorScore)(distance, metric), distance, backend);
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
async summaryLifecycle(options = {}) {
|
|
216
|
+
const params = [];
|
|
217
|
+
const conditions = ['chunk.summary_metadata IS NOT NULL'];
|
|
218
|
+
if (options.workspace) {
|
|
219
|
+
conditions.push(`source.workspace = ${addParam(params, options.workspace)}`);
|
|
220
|
+
}
|
|
221
|
+
(0, RdfSearchSourceFilter_1.appendPgRdfSearchSourceFilters)(options, conditions, params);
|
|
222
|
+
appendPgVectorIdentityFilters(options, conditions, params);
|
|
223
|
+
const limitSql = options.limit === undefined ? '' : `LIMIT ${addParam(params, Math.max(0, options.limit), 'integer')}`;
|
|
224
|
+
const rows = await this.requireExecutor().query(`
|
|
225
|
+
SELECT
|
|
226
|
+
chunk.id,
|
|
227
|
+
chunk.source_id,
|
|
228
|
+
source.source_key,
|
|
229
|
+
source.source,
|
|
230
|
+
source.workspace,
|
|
231
|
+
source.local_path,
|
|
232
|
+
source.content_type,
|
|
233
|
+
source.source_version,
|
|
234
|
+
source.source_hash,
|
|
235
|
+
chunk.chunk_key,
|
|
236
|
+
chunk.ordinal,
|
|
237
|
+
chunk.level,
|
|
238
|
+
chunk.heading,
|
|
239
|
+
chunk.path,
|
|
240
|
+
chunk.content,
|
|
241
|
+
chunk.start_offset,
|
|
242
|
+
chunk.end_offset,
|
|
243
|
+
chunk.embedding_json,
|
|
244
|
+
chunk.summary_metadata,
|
|
245
|
+
chunk.dimensions,
|
|
246
|
+
chunk.magnitude,
|
|
247
|
+
chunk.provider,
|
|
248
|
+
chunk.model,
|
|
249
|
+
chunk.model_version,
|
|
250
|
+
chunk.input_kind,
|
|
251
|
+
chunk.input_hash,
|
|
252
|
+
chunk.projection_policy_version,
|
|
253
|
+
chunk.updated_at
|
|
254
|
+
FROM rdf_vector_chunks chunk
|
|
255
|
+
JOIN rdf_vector_sources source ON source.id = chunk.source_id
|
|
256
|
+
WHERE ${conditions.join(' AND ')}
|
|
257
|
+
ORDER BY source.source ASC, chunk.ordinal ASC, chunk.chunk_key ASC
|
|
258
|
+
${limitSql}
|
|
259
|
+
`, params);
|
|
260
|
+
return rows.flatMap((rawRow) => {
|
|
261
|
+
const entry = toSummaryLifecycleEntry(normalizeVectorChunkRow(rawRow));
|
|
262
|
+
return entry ? [entry] : [];
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
async estimateSearchCardinality(options) {
|
|
266
|
+
const embedding = (0, RdfVectorIndex_1.normalizeEmbedding)(options.embedding);
|
|
267
|
+
if (embedding.length === 0) {
|
|
268
|
+
return {
|
|
269
|
+
rows: 0,
|
|
270
|
+
source: 'vector-candidate-count',
|
|
271
|
+
indexChoice: 'vector-candidate-count',
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
const metric = options.metric ?? this.options.defaultMetric ?? 'cosine';
|
|
275
|
+
if (metric === 'cosine' && (0, RdfVectorIndex_1.vectorMagnitude)(embedding) === 0) {
|
|
276
|
+
return {
|
|
277
|
+
rows: 0,
|
|
278
|
+
source: 'vector-candidate-count',
|
|
279
|
+
indexChoice: 'vector-candidate-count',
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
if (options.threshold !== undefined) {
|
|
283
|
+
const usesPgVector = this.usesPgVectorBackend();
|
|
284
|
+
const countQuery = usesPgVector
|
|
285
|
+
? buildPgVectorNativeScoredCountQuery(embedding, metric, options)
|
|
286
|
+
: buildPgVectorScoredCountQuery(embedding, metric, options);
|
|
287
|
+
const rows = await this.requireExecutor().query(countQuery.sql, countQuery.params);
|
|
288
|
+
return {
|
|
289
|
+
rows: (0, RdfVectorIndex_1.applyResultWindow)(Number(rows[0]?.count ?? 0), options.offset, options.limit),
|
|
290
|
+
source: usesPgVector ? 'pg-vector-score' : 'vector-component-score',
|
|
291
|
+
indexChoice: usesPgVector ? 'pg-vector-score' : 'vector-component-score',
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
const params = [];
|
|
295
|
+
const conditions = [`chunk.dimensions = ${addParam(params, embedding.length)}`];
|
|
296
|
+
if (options.workspace) {
|
|
297
|
+
conditions.push(`source.workspace = ${addParam(params, options.workspace)}`);
|
|
298
|
+
}
|
|
299
|
+
(0, RdfSearchSourceFilter_1.appendPgRdfSearchSourceFilters)(options, conditions, params);
|
|
300
|
+
appendPgVectorIdentityFilters(options, conditions, params);
|
|
301
|
+
const rows = await this.requireExecutor().query(`
|
|
302
|
+
SELECT COUNT(*) AS count
|
|
303
|
+
FROM rdf_vector_chunks chunk
|
|
304
|
+
JOIN rdf_vector_sources source ON source.id = chunk.source_id
|
|
305
|
+
WHERE ${conditions.join(' AND ')}
|
|
306
|
+
`, params);
|
|
307
|
+
return {
|
|
308
|
+
rows: (0, RdfVectorIndex_1.applyResultWindow)(Number(rows[0]?.count ?? 0), options.offset, options.limit),
|
|
309
|
+
source: 'vector-candidate-count',
|
|
310
|
+
indexChoice: 'vector-candidate-count',
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
async stats() {
|
|
314
|
+
const [sourceRows, chunkRows, componentRows] = await Promise.all([
|
|
315
|
+
this.requireExecutor().query('SELECT COUNT(*) AS count FROM rdf_vector_sources'),
|
|
316
|
+
this.requireExecutor().query('SELECT COUNT(*) AS count FROM rdf_vector_chunks'),
|
|
317
|
+
this.requireExecutor().query('SELECT COUNT(*) AS count FROM rdf_vector_components'),
|
|
318
|
+
]);
|
|
319
|
+
return {
|
|
320
|
+
sourceCount: Number(sourceRows[0]?.count ?? 0),
|
|
321
|
+
chunkCount: Number(chunkRows[0]?.count ?? 0),
|
|
322
|
+
componentCount: Number(componentRows[0]?.count ?? 0),
|
|
323
|
+
databaseBytes: await this.estimateDatabaseBytes(),
|
|
324
|
+
modelDistribution: await this.modelDistribution(),
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
async modelDistribution() {
|
|
328
|
+
const rows = await this.requireExecutor().query(`
|
|
329
|
+
SELECT
|
|
330
|
+
chunk.provider,
|
|
331
|
+
chunk.model,
|
|
332
|
+
chunk.model_version,
|
|
333
|
+
chunk.input_kind,
|
|
334
|
+
chunk.projection_policy_version,
|
|
335
|
+
chunk.dimensions,
|
|
336
|
+
COUNT(DISTINCT chunk.source_id) AS source_count,
|
|
337
|
+
COUNT(*) AS chunk_count,
|
|
338
|
+
MIN(chunk.magnitude) AS min_magnitude,
|
|
339
|
+
MAX(chunk.magnitude) AS max_magnitude,
|
|
340
|
+
AVG(chunk.magnitude) AS average_magnitude
|
|
341
|
+
FROM rdf_vector_chunks chunk
|
|
342
|
+
GROUP BY chunk.provider, chunk.model, chunk.model_version, chunk.input_kind, chunk.projection_policy_version, chunk.dimensions
|
|
343
|
+
ORDER BY chunk_count DESC, source_count DESC, chunk.provider ASC, chunk.model ASC, chunk.model_version ASC, chunk.input_kind ASC, chunk.projection_policy_version ASC, chunk.dimensions ASC
|
|
344
|
+
`);
|
|
345
|
+
return rows.map((row) => ({
|
|
346
|
+
provider: row.provider || undefined,
|
|
347
|
+
model: row.model,
|
|
348
|
+
modelVersion: row.model_version || undefined,
|
|
349
|
+
inputKind: row.input_kind || undefined,
|
|
350
|
+
projectionPolicyVersion: row.projection_policy_version || undefined,
|
|
351
|
+
dimensions: Number(row.dimensions),
|
|
352
|
+
sourceCount: Number(row.source_count),
|
|
353
|
+
chunkCount: Number(row.chunk_count),
|
|
354
|
+
minMagnitude: Number(row.min_magnitude ?? 0),
|
|
355
|
+
maxMagnitude: Number(row.max_magnitude ?? 0),
|
|
356
|
+
averageMagnitude: Number(row.average_magnitude ?? 0),
|
|
357
|
+
}));
|
|
358
|
+
}
|
|
359
|
+
async openInternal() {
|
|
360
|
+
if (this.options.driver === 'pglite') {
|
|
361
|
+
this.pglite = new pglite_1.PGlite(this.options.dataDir);
|
|
362
|
+
this.executor = new PostgresRdfSqlExecutor_1.PgliteRdfSqlExecutor(this.pglite);
|
|
363
|
+
}
|
|
364
|
+
else if (this.options.pool) {
|
|
365
|
+
this.pgPool = this.options.pool;
|
|
366
|
+
this.executor = new PostgresRdfSqlExecutor_1.PgPoolRdfSqlExecutor(this.pgPool);
|
|
367
|
+
}
|
|
368
|
+
else {
|
|
369
|
+
this.sharedPoolConfig = {
|
|
370
|
+
connectionString: this.options.connectionString,
|
|
371
|
+
host: this.options.host,
|
|
372
|
+
port: this.options.port,
|
|
373
|
+
database: this.options.database,
|
|
374
|
+
user: this.options.user,
|
|
375
|
+
password: this.options.password,
|
|
376
|
+
};
|
|
377
|
+
this.pgPool = (0, PostgresPoolManager_1.getSharedPool)(this.sharedPoolConfig);
|
|
378
|
+
this.executor = new PostgresRdfSqlExecutor_1.PgPoolRdfSqlExecutor(this.pgPool);
|
|
379
|
+
}
|
|
380
|
+
await this.initializeSchema();
|
|
381
|
+
}
|
|
382
|
+
async initializeSchema() {
|
|
383
|
+
if (this.usesPgVectorBackend()) {
|
|
384
|
+
await this.requireExecutor().exec('CREATE EXTENSION IF NOT EXISTS vector');
|
|
385
|
+
}
|
|
386
|
+
await this.requireExecutor().exec(`
|
|
387
|
+
CREATE TABLE IF NOT EXISTS rdf_vector_sources (
|
|
388
|
+
id BIGSERIAL PRIMARY KEY,
|
|
389
|
+
source_key TEXT,
|
|
390
|
+
source TEXT NOT NULL UNIQUE,
|
|
391
|
+
workspace TEXT NOT NULL,
|
|
392
|
+
local_path TEXT,
|
|
393
|
+
content_type TEXT,
|
|
394
|
+
source_version TEXT,
|
|
395
|
+
source_hash TEXT,
|
|
396
|
+
updated_at TIMESTAMPTZ NOT NULL DEFAULT now()
|
|
397
|
+
);
|
|
398
|
+
|
|
399
|
+
CREATE TABLE IF NOT EXISTS rdf_vector_chunks (
|
|
400
|
+
id BIGSERIAL PRIMARY KEY,
|
|
401
|
+
source_id BIGINT NOT NULL REFERENCES rdf_vector_sources(id) ON DELETE CASCADE,
|
|
402
|
+
chunk_key TEXT NOT NULL,
|
|
403
|
+
ordinal INTEGER NOT NULL,
|
|
404
|
+
level INTEGER NOT NULL,
|
|
405
|
+
heading TEXT,
|
|
406
|
+
path TEXT,
|
|
407
|
+
content TEXT NOT NULL,
|
|
408
|
+
start_offset INTEGER NOT NULL,
|
|
409
|
+
end_offset INTEGER NOT NULL,
|
|
410
|
+
embedding_json TEXT NOT NULL,
|
|
411
|
+
summary_metadata TEXT,
|
|
412
|
+
dimensions INTEGER NOT NULL,
|
|
413
|
+
magnitude DOUBLE PRECISION NOT NULL,
|
|
414
|
+
provider TEXT NOT NULL DEFAULT '',
|
|
415
|
+
model TEXT NOT NULL,
|
|
416
|
+
model_version TEXT NOT NULL DEFAULT '',
|
|
417
|
+
input_kind TEXT NOT NULL DEFAULT '',
|
|
418
|
+
input_hash TEXT NOT NULL DEFAULT '',
|
|
419
|
+
projection_policy_version TEXT NOT NULL DEFAULT '',
|
|
420
|
+
updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
|
421
|
+
UNIQUE (
|
|
422
|
+
source_id,
|
|
423
|
+
chunk_key,
|
|
424
|
+
provider,
|
|
425
|
+
model,
|
|
426
|
+
model_version,
|
|
427
|
+
input_kind,
|
|
428
|
+
projection_policy_version,
|
|
429
|
+
input_hash
|
|
430
|
+
)
|
|
431
|
+
);
|
|
432
|
+
|
|
433
|
+
CREATE TABLE IF NOT EXISTS rdf_vector_components (
|
|
434
|
+
chunk_id BIGINT NOT NULL REFERENCES rdf_vector_chunks(id) ON DELETE CASCADE,
|
|
435
|
+
dimension INTEGER NOT NULL,
|
|
436
|
+
value DOUBLE PRECISION NOT NULL,
|
|
437
|
+
updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
|
438
|
+
PRIMARY KEY (chunk_id, dimension)
|
|
439
|
+
);
|
|
440
|
+
|
|
441
|
+
CREATE INDEX IF NOT EXISTS rdf_vector_sources_workspace ON rdf_vector_sources(workspace);
|
|
442
|
+
CREATE INDEX IF NOT EXISTS rdf_vector_sources_source ON rdf_vector_sources(source);
|
|
443
|
+
CREATE INDEX IF NOT EXISTS rdf_vector_chunks_source ON rdf_vector_chunks(source_id, ordinal);
|
|
444
|
+
CREATE INDEX IF NOT EXISTS rdf_vector_components_dimension ON rdf_vector_components(dimension, chunk_id);
|
|
445
|
+
`);
|
|
446
|
+
await this.ensureSourceKeyColumn();
|
|
447
|
+
await this.ensureVectorIdentityColumns();
|
|
448
|
+
if (this.usesPgVectorBackend()) {
|
|
449
|
+
await this.ensurePgVectorColumn();
|
|
450
|
+
}
|
|
451
|
+
else {
|
|
452
|
+
await this.backfillVectorComponents();
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
async ensurePgVectorColumn() {
|
|
456
|
+
await this.requireExecutor().exec('ALTER TABLE rdf_vector_chunks ADD COLUMN IF NOT EXISTS embedding_vector vector');
|
|
457
|
+
await this.requireExecutor().exec(`
|
|
458
|
+
UPDATE rdf_vector_chunks
|
|
459
|
+
SET embedding_vector = embedding_json::vector
|
|
460
|
+
WHERE embedding_vector IS NULL
|
|
461
|
+
AND embedding_json IS NOT NULL
|
|
462
|
+
`);
|
|
463
|
+
}
|
|
464
|
+
async ensurePgVectorSearchIndex(dimensions, metric) {
|
|
465
|
+
if (!this.usesPgVectorBackend()) {
|
|
466
|
+
return;
|
|
467
|
+
}
|
|
468
|
+
const safeDimensions = pgVectorDimensions(dimensions);
|
|
469
|
+
const key = `${metric}:${safeDimensions}`;
|
|
470
|
+
if (this.ensuredPgVectorIndexes.has(key)) {
|
|
471
|
+
return;
|
|
472
|
+
}
|
|
473
|
+
const indexName = quotePgIdentifier(`rdf_vector_chunks_embedding_${metric}_${safeDimensions}_hnsw`);
|
|
474
|
+
await this.requireExecutor().exec(`
|
|
475
|
+
CREATE INDEX IF NOT EXISTS ${indexName}
|
|
476
|
+
ON rdf_vector_chunks
|
|
477
|
+
USING hnsw ((embedding_vector::vector(${safeDimensions})) ${pgVectorOperatorClass(metric)})
|
|
478
|
+
WHERE dimensions = ${safeDimensions}
|
|
479
|
+
AND embedding_vector IS NOT NULL
|
|
480
|
+
`);
|
|
481
|
+
this.ensuredPgVectorIndexes.add(key);
|
|
482
|
+
}
|
|
483
|
+
async ensureSourceKeyColumn() {
|
|
484
|
+
await this.requireExecutor().exec('ALTER TABLE rdf_vector_sources ADD COLUMN IF NOT EXISTS source_key TEXT');
|
|
485
|
+
await this.requireExecutor().exec('UPDATE rdf_vector_sources SET source_key = source WHERE source_key IS NULL OR source_key = \'\'');
|
|
486
|
+
}
|
|
487
|
+
async ensureVectorIdentityColumns() {
|
|
488
|
+
await this.requireExecutor().exec(`
|
|
489
|
+
ALTER TABLE rdf_vector_chunks ADD COLUMN IF NOT EXISTS provider TEXT NOT NULL DEFAULT '';
|
|
490
|
+
ALTER TABLE rdf_vector_chunks ADD COLUMN IF NOT EXISTS model_version TEXT NOT NULL DEFAULT '';
|
|
491
|
+
ALTER TABLE rdf_vector_chunks ADD COLUMN IF NOT EXISTS input_kind TEXT NOT NULL DEFAULT '';
|
|
492
|
+
ALTER TABLE rdf_vector_chunks ADD COLUMN IF NOT EXISTS input_hash TEXT NOT NULL DEFAULT '';
|
|
493
|
+
ALTER TABLE rdf_vector_chunks ADD COLUMN IF NOT EXISTS projection_policy_version TEXT NOT NULL DEFAULT '';
|
|
494
|
+
ALTER TABLE rdf_vector_chunks ADD COLUMN IF NOT EXISTS summary_metadata TEXT;
|
|
495
|
+
UPDATE rdf_vector_chunks
|
|
496
|
+
SET
|
|
497
|
+
provider = COALESCE(provider, ''),
|
|
498
|
+
model_version = COALESCE(model_version, ''),
|
|
499
|
+
input_kind = COALESCE(input_kind, ''),
|
|
500
|
+
input_hash = COALESCE(input_hash, ''),
|
|
501
|
+
projection_policy_version = COALESCE(projection_policy_version, '');
|
|
502
|
+
`);
|
|
503
|
+
await this.ensureVectorChunkIdentityUniqueConstraint();
|
|
504
|
+
await this.requireExecutor().exec(`
|
|
505
|
+
CREATE INDEX IF NOT EXISTS rdf_vector_chunks_model_dimensions
|
|
506
|
+
ON rdf_vector_chunks(provider, model, model_version, input_kind, projection_policy_version, dimensions);
|
|
507
|
+
`);
|
|
508
|
+
}
|
|
509
|
+
async ensureVectorChunkIdentityUniqueConstraint() {
|
|
510
|
+
const rows = await this.requireExecutor().query(`
|
|
511
|
+
SELECT
|
|
512
|
+
constraint_info.conname,
|
|
513
|
+
string_agg(attribute.attname, ',' ORDER BY constraint_key.ordinality) AS columns
|
|
514
|
+
FROM pg_constraint constraint_info
|
|
515
|
+
JOIN unnest(constraint_info.conkey) WITH ORDINALITY AS constraint_key(attnum, ordinality) ON TRUE
|
|
516
|
+
JOIN pg_attribute attribute
|
|
517
|
+
ON attribute.attrelid = constraint_info.conrelid
|
|
518
|
+
AND attribute.attnum = constraint_key.attnum
|
|
519
|
+
WHERE constraint_info.conrelid = 'rdf_vector_chunks'::regclass
|
|
520
|
+
AND constraint_info.contype = 'u'
|
|
521
|
+
GROUP BY constraint_info.conname
|
|
522
|
+
`);
|
|
523
|
+
let hasIdentityUnique = false;
|
|
524
|
+
for (const row of rows) {
|
|
525
|
+
if (row.columns === 'source_id,chunk_key') {
|
|
526
|
+
await this.requireExecutor().exec(`ALTER TABLE rdf_vector_chunks DROP CONSTRAINT ${quotePgIdentifier(row.conname)}`);
|
|
527
|
+
}
|
|
528
|
+
else if (row.columns === 'source_id,chunk_key,provider,model,model_version,input_kind,projection_policy_version,input_hash') {
|
|
529
|
+
hasIdentityUnique = true;
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
if (hasIdentityUnique) {
|
|
533
|
+
return;
|
|
534
|
+
}
|
|
535
|
+
await this.requireExecutor().exec(`
|
|
536
|
+
CREATE UNIQUE INDEX IF NOT EXISTS rdf_vector_chunks_identity_unique
|
|
537
|
+
ON rdf_vector_chunks (
|
|
538
|
+
source_id,
|
|
539
|
+
chunk_key,
|
|
540
|
+
provider,
|
|
541
|
+
model,
|
|
542
|
+
model_version,
|
|
543
|
+
input_kind,
|
|
544
|
+
projection_policy_version,
|
|
545
|
+
input_hash
|
|
546
|
+
)
|
|
547
|
+
`);
|
|
548
|
+
}
|
|
549
|
+
async backfillVectorComponents() {
|
|
550
|
+
const rows = await this.requireExecutor().query(`
|
|
551
|
+
SELECT
|
|
552
|
+
chunk.id,
|
|
553
|
+
chunk.dimensions,
|
|
554
|
+
chunk.embedding_json,
|
|
555
|
+
COUNT(component.dimension) AS component_count
|
|
556
|
+
FROM rdf_vector_chunks chunk
|
|
557
|
+
LEFT JOIN rdf_vector_components component ON component.chunk_id = chunk.id
|
|
558
|
+
WHERE chunk.dimensions > 0
|
|
559
|
+
GROUP BY chunk.id
|
|
560
|
+
HAVING COUNT(component.dimension) <> chunk.dimensions
|
|
561
|
+
`);
|
|
562
|
+
if (rows.length === 0) {
|
|
563
|
+
return;
|
|
564
|
+
}
|
|
565
|
+
await this.requireExecutor().transaction(async (tx) => {
|
|
566
|
+
for (const row of rows) {
|
|
567
|
+
const chunkId = Number(row.id);
|
|
568
|
+
await tx.exec('DELETE FROM rdf_vector_components WHERE chunk_id = $1', [chunkId]);
|
|
569
|
+
await insertVectorComponents(tx, chunkId, (0, RdfVectorIndex_1.parseEmbedding)(row.embedding_json));
|
|
570
|
+
}
|
|
571
|
+
});
|
|
572
|
+
}
|
|
573
|
+
async upsertSource(tx, source) {
|
|
574
|
+
const rows = await tx.query(`
|
|
575
|
+
INSERT INTO rdf_vector_sources (
|
|
576
|
+
source_key,
|
|
577
|
+
source,
|
|
578
|
+
workspace,
|
|
579
|
+
local_path,
|
|
580
|
+
content_type,
|
|
581
|
+
source_version,
|
|
582
|
+
source_hash,
|
|
583
|
+
updated_at
|
|
584
|
+
)
|
|
585
|
+
VALUES ($1, $2, $3, $4, $5, $6, $7, now())
|
|
586
|
+
ON CONFLICT (source)
|
|
587
|
+
DO UPDATE SET
|
|
588
|
+
source_key = COALESCE(EXCLUDED.source_key, rdf_vector_sources.source_key, EXCLUDED.source),
|
|
589
|
+
workspace = EXCLUDED.workspace,
|
|
590
|
+
local_path = EXCLUDED.local_path,
|
|
591
|
+
content_type = EXCLUDED.content_type,
|
|
592
|
+
source_version = EXCLUDED.source_version,
|
|
593
|
+
source_hash = EXCLUDED.source_hash,
|
|
594
|
+
updated_at = EXCLUDED.updated_at
|
|
595
|
+
RETURNING id
|
|
596
|
+
`, [
|
|
597
|
+
source.sourceKey ?? source.source,
|
|
598
|
+
source.source,
|
|
599
|
+
source.workspace,
|
|
600
|
+
source.localPath ?? null,
|
|
601
|
+
source.contentType ?? null,
|
|
602
|
+
source.sourceVersion ?? null,
|
|
603
|
+
source.sourceHash ?? null,
|
|
604
|
+
]);
|
|
605
|
+
const id = Number(rows[0]?.id);
|
|
606
|
+
if (!Number.isFinite(id)) {
|
|
607
|
+
throw new Error(`Failed to upsert RDF vector source: ${source.source}`);
|
|
608
|
+
}
|
|
609
|
+
return id;
|
|
610
|
+
}
|
|
611
|
+
async estimateDatabaseBytes() {
|
|
612
|
+
try {
|
|
613
|
+
const rows = await this.requireExecutor().query(`
|
|
614
|
+
SELECT COALESCE(SUM(pg_total_relation_size(('"' || schemaname || '"."' || tablename || '"')::regclass)), 0)::bigint AS bytes
|
|
615
|
+
FROM pg_tables
|
|
616
|
+
WHERE tablename IN ('rdf_vector_sources', 'rdf_vector_chunks', 'rdf_vector_components')
|
|
617
|
+
`);
|
|
618
|
+
return Number(rows[0]?.bytes ?? 0);
|
|
619
|
+
}
|
|
620
|
+
catch {
|
|
621
|
+
return 0;
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
requireExecutor() {
|
|
625
|
+
if (!this.executor) {
|
|
626
|
+
throw new Error('PostgresRdfVectorIndex is not open');
|
|
627
|
+
}
|
|
628
|
+
return this.executor;
|
|
629
|
+
}
|
|
630
|
+
usesPgVectorBackend() {
|
|
631
|
+
return this.options.driver === 'pg';
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
exports.PostgresRdfVectorIndex = PostgresRdfVectorIndex;
|
|
635
|
+
function normalizeVectorIdentity(chunk) {
|
|
636
|
+
return {
|
|
637
|
+
provider: chunk.provider ?? '',
|
|
638
|
+
model: chunk.model ?? '',
|
|
639
|
+
modelVersion: chunk.modelVersion ?? '',
|
|
640
|
+
inputKind: chunk.inputKind ?? '',
|
|
641
|
+
projectionPolicyVersion: chunk.projectionPolicyVersion ?? '',
|
|
642
|
+
};
|
|
643
|
+
}
|
|
644
|
+
function vectorIdentityKey(identity) {
|
|
645
|
+
return [
|
|
646
|
+
identity.provider,
|
|
647
|
+
identity.model,
|
|
648
|
+
identity.modelVersion,
|
|
649
|
+
identity.inputKind,
|
|
650
|
+
identity.projectionPolicyVersion,
|
|
651
|
+
].join('\u0000');
|
|
652
|
+
}
|
|
653
|
+
function appendPgVectorIdentityFilters(options, conditions, params) {
|
|
654
|
+
if (options.provider !== undefined) {
|
|
655
|
+
conditions.push(`chunk.provider = ${addParam(params, options.provider)}`);
|
|
656
|
+
}
|
|
657
|
+
if (options.model !== undefined) {
|
|
658
|
+
conditions.push(`chunk.model = ${addParam(params, options.model)}`);
|
|
659
|
+
}
|
|
660
|
+
if (options.modelVersion !== undefined) {
|
|
661
|
+
conditions.push(`chunk.model_version = ${addParam(params, options.modelVersion)}`);
|
|
662
|
+
}
|
|
663
|
+
if (options.inputKind !== undefined) {
|
|
664
|
+
conditions.push(`chunk.input_kind = ${addParam(params, options.inputKind)}`);
|
|
665
|
+
}
|
|
666
|
+
if (options.inputHash !== undefined) {
|
|
667
|
+
conditions.push(`chunk.input_hash = ${addParam(params, options.inputHash)}`);
|
|
668
|
+
}
|
|
669
|
+
if (options.projectionPolicyVersion !== undefined) {
|
|
670
|
+
conditions.push(`chunk.projection_policy_version = ${addParam(params, options.projectionPolicyVersion)}`);
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
function buildPgVectorNativeScoredRowsQuery(embedding, metric, options) {
|
|
674
|
+
if (canUsePgVectorAnnTopK(options)) {
|
|
675
|
+
return buildPgVectorNativeAnnScoredRowsQuery(embedding, metric, options);
|
|
676
|
+
}
|
|
677
|
+
const base = buildPgVectorNativeBaseQuery(embedding, metric, options);
|
|
678
|
+
const orderBy = buildPgVectorNativeOrderClause(options.orderBy, base.distanceExpression);
|
|
679
|
+
const window = buildPgVectorWindowClause(base.params, options.limit, options.offset);
|
|
680
|
+
return {
|
|
681
|
+
sql: `
|
|
682
|
+
SELECT
|
|
683
|
+
${base.selectSql}
|
|
684
|
+
${base.fromSql}
|
|
685
|
+
ORDER BY ${orderBy}
|
|
686
|
+
${window}
|
|
687
|
+
`,
|
|
688
|
+
params: base.params,
|
|
689
|
+
};
|
|
690
|
+
}
|
|
691
|
+
function buildPgVectorNativeAnnScoredRowsQuery(embedding, metric, options) {
|
|
692
|
+
const base = buildPgVectorNativeBaseQuery(embedding, metric, options);
|
|
693
|
+
const limit = options.limit ?? 0;
|
|
694
|
+
const innerLimit = addParam(base.params, Math.max(0, limit), 'integer');
|
|
695
|
+
const orderBy = buildPgVectorNativeOrderClause(options.orderBy, 'candidate_chunks.native_distance');
|
|
696
|
+
return {
|
|
697
|
+
sql: `
|
|
698
|
+
WITH candidate_chunks AS (
|
|
699
|
+
SELECT
|
|
700
|
+
chunk.id,
|
|
701
|
+
${base.distanceExpression} AS native_distance
|
|
702
|
+
${base.fromSql}
|
|
703
|
+
ORDER BY ${base.distanceExpression} ASC, source.id ASC, chunk.ordinal ASC
|
|
704
|
+
LIMIT ${innerLimit}
|
|
705
|
+
)
|
|
706
|
+
SELECT
|
|
707
|
+
${base.selectSql}
|
|
708
|
+
${base.outerFromSql}
|
|
709
|
+
ORDER BY ${orderBy}
|
|
710
|
+
`,
|
|
711
|
+
params: base.params,
|
|
712
|
+
};
|
|
713
|
+
}
|
|
714
|
+
function buildPgVectorNativeScoredCountQuery(embedding, metric, options) {
|
|
715
|
+
const base = buildPgVectorNativeBaseQuery(embedding, metric, options);
|
|
716
|
+
return {
|
|
717
|
+
sql: `
|
|
718
|
+
SELECT COUNT(*) AS count
|
|
719
|
+
${base.fromSql}
|
|
720
|
+
`,
|
|
721
|
+
params: base.params,
|
|
722
|
+
};
|
|
723
|
+
}
|
|
724
|
+
function buildPgVectorNativeBaseQuery(embedding, metric, options) {
|
|
725
|
+
const params = [];
|
|
726
|
+
const dimensions = pgVectorDimensions(embedding.length);
|
|
727
|
+
const vectorExpression = `(chunk.embedding_vector::vector(${dimensions}))`;
|
|
728
|
+
const queryVector = addParam(params, formatPgVectorLiteral(embedding), `vector(${dimensions})`);
|
|
729
|
+
const distanceExpression = pgVectorNativeDistanceExpression(metric, vectorExpression, queryVector);
|
|
730
|
+
const dotProductExpression = `-(${vectorExpression} <#> ${queryVector})`;
|
|
731
|
+
const nativeDistanceExpression = canUsePgVectorAnnTopK(options)
|
|
732
|
+
? 'candidate_chunks.native_distance'
|
|
733
|
+
: distanceExpression;
|
|
734
|
+
const vectorScoreExpression = pgVectorNativeScoreExpression(metric, nativeDistanceExpression);
|
|
735
|
+
const vectorDistanceExpression = metric === 'euclidean' ? 'NULL' : nativeDistanceExpression;
|
|
736
|
+
const vectorDistanceSquaredExpression = metric === 'euclidean'
|
|
737
|
+
? `(${nativeDistanceExpression} * ${nativeDistanceExpression})`
|
|
738
|
+
: `(chunk.magnitude * chunk.magnitude + ${(0, RdfVectorIndex_1.vectorMagnitude)(embedding) * (0, RdfVectorIndex_1.vectorMagnitude)(embedding)} - 2 * ${dotProductExpression})`;
|
|
739
|
+
const conditions = [
|
|
740
|
+
`chunk.dimensions = ${addParam(params, embedding.length, 'integer')}`,
|
|
741
|
+
'chunk.embedding_vector IS NOT NULL',
|
|
742
|
+
];
|
|
743
|
+
if (metric === 'cosine') {
|
|
744
|
+
conditions.push('chunk.magnitude > 0');
|
|
745
|
+
}
|
|
746
|
+
if (options.workspace) {
|
|
747
|
+
conditions.push(`source.workspace = ${addParam(params, options.workspace)}`);
|
|
748
|
+
}
|
|
749
|
+
(0, RdfSearchSourceFilter_1.appendPgRdfSearchSourceFilters)(options, conditions, params);
|
|
750
|
+
appendPgVectorIdentityFilters(options, conditions, params);
|
|
751
|
+
if (options.threshold !== undefined) {
|
|
752
|
+
conditions.push(pgVectorNativeThresholdExpression(metric, distanceExpression, options.threshold));
|
|
753
|
+
}
|
|
754
|
+
return {
|
|
755
|
+
selectSql: `
|
|
756
|
+
chunk.id,
|
|
757
|
+
chunk.source_id,
|
|
758
|
+
source.source_key,
|
|
759
|
+
source.source,
|
|
760
|
+
source.workspace,
|
|
761
|
+
source.local_path,
|
|
762
|
+
source.content_type,
|
|
763
|
+
source.source_version,
|
|
764
|
+
source.source_hash,
|
|
765
|
+
chunk.chunk_key,
|
|
766
|
+
chunk.ordinal,
|
|
767
|
+
chunk.level,
|
|
768
|
+
chunk.heading,
|
|
769
|
+
chunk.path,
|
|
770
|
+
chunk.content,
|
|
771
|
+
chunk.start_offset,
|
|
772
|
+
chunk.end_offset,
|
|
773
|
+
chunk.embedding_json,
|
|
774
|
+
chunk.summary_metadata,
|
|
775
|
+
chunk.dimensions,
|
|
776
|
+
chunk.magnitude,
|
|
777
|
+
chunk.provider,
|
|
778
|
+
chunk.model,
|
|
779
|
+
chunk.model_version,
|
|
780
|
+
chunk.input_kind,
|
|
781
|
+
chunk.input_hash,
|
|
782
|
+
chunk.projection_policy_version,
|
|
783
|
+
chunk.updated_at,
|
|
784
|
+
${dotProductExpression} AS dot_product,
|
|
785
|
+
${vectorScoreExpression} AS vector_score,
|
|
786
|
+
${vectorDistanceExpression} AS vector_distance,
|
|
787
|
+
${vectorDistanceSquaredExpression} AS vector_distance_squared,
|
|
788
|
+
${nativeDistanceExpression} AS native_distance
|
|
789
|
+
`,
|
|
790
|
+
fromSql: `
|
|
791
|
+
FROM rdf_vector_chunks chunk
|
|
792
|
+
JOIN rdf_vector_sources source ON source.id = chunk.source_id
|
|
793
|
+
WHERE ${conditions.join(' AND ')}
|
|
794
|
+
`,
|
|
795
|
+
outerFromSql: `
|
|
796
|
+
FROM candidate_chunks
|
|
797
|
+
JOIN rdf_vector_chunks chunk ON chunk.id = candidate_chunks.id
|
|
798
|
+
JOIN rdf_vector_sources source ON source.id = chunk.source_id
|
|
799
|
+
`,
|
|
800
|
+
params,
|
|
801
|
+
distanceExpression,
|
|
802
|
+
};
|
|
803
|
+
}
|
|
804
|
+
function canUsePgVectorAnnTopK(options) {
|
|
805
|
+
if (options.limit === undefined || options.offset !== undefined) {
|
|
806
|
+
return false;
|
|
807
|
+
}
|
|
808
|
+
const order = options.orderBy?.length ? options.orderBy : [{ field: 'score', direction: 'desc' }];
|
|
809
|
+
const first = order[0];
|
|
810
|
+
if (!first) {
|
|
811
|
+
return false;
|
|
812
|
+
}
|
|
813
|
+
if (first.field === 'score') {
|
|
814
|
+
return first.direction === 'desc';
|
|
815
|
+
}
|
|
816
|
+
if (first.field === 'distance') {
|
|
817
|
+
return first.direction !== 'desc';
|
|
818
|
+
}
|
|
819
|
+
return false;
|
|
820
|
+
}
|
|
821
|
+
function buildPgVectorScoredRowsQuery(embedding, metric, options) {
|
|
822
|
+
const scored = buildPgVectorScoredBaseQuery(embedding, metric, options);
|
|
823
|
+
const orderBy = (0, RdfVectorIndex_1.buildVectorOrderClause)(metric, options.orderBy);
|
|
824
|
+
const window = buildPgVectorWindowClause(scored.params, options.limit, options.offset);
|
|
825
|
+
return {
|
|
826
|
+
sql: `
|
|
827
|
+
${scored.withSql}
|
|
828
|
+
SELECT
|
|
829
|
+
scored.*,
|
|
830
|
+
scored.dot_product AS dot_product,
|
|
831
|
+
${(0, RdfVectorIndex_1.vectorScoreSql)(metric, scored.queryMagnitude)} AS vector_score,
|
|
832
|
+
${(0, RdfVectorIndex_1.vectorDistanceSql)(metric, scored.queryMagnitude)} AS vector_distance,
|
|
833
|
+
${(0, RdfVectorIndex_1.vectorSquaredDistanceSql)(scored.queryMagnitude)} AS vector_distance_squared
|
|
834
|
+
FROM scored
|
|
835
|
+
${scored.thresholdWhere}
|
|
836
|
+
ORDER BY ${orderBy}
|
|
837
|
+
${window}
|
|
838
|
+
`,
|
|
839
|
+
params: scored.params,
|
|
840
|
+
};
|
|
841
|
+
}
|
|
842
|
+
function buildPgVectorScoredCountQuery(embedding, metric, options) {
|
|
843
|
+
const scored = buildPgVectorScoredBaseQuery(embedding, metric, options);
|
|
844
|
+
return {
|
|
845
|
+
sql: `
|
|
846
|
+
${scored.withSql}
|
|
847
|
+
SELECT COUNT(*) AS count
|
|
848
|
+
FROM scored
|
|
849
|
+
${scored.thresholdWhere}
|
|
850
|
+
`,
|
|
851
|
+
params: scored.params,
|
|
852
|
+
};
|
|
853
|
+
}
|
|
854
|
+
function buildPgVectorScoredBaseQuery(embedding, metric, options) {
|
|
855
|
+
const queryMagnitude = (0, RdfVectorIndex_1.vectorMagnitude)(embedding);
|
|
856
|
+
const params = [];
|
|
857
|
+
const vectorValues = embedding
|
|
858
|
+
.map((value, dimension) => `(${addParam(params, dimension, 'integer')}, ${addParam(params, value, 'double precision')})`)
|
|
859
|
+
.join(', ');
|
|
860
|
+
const conditions = [`chunk.dimensions = ${addParam(params, embedding.length, 'integer')}`];
|
|
861
|
+
if (metric === 'cosine') {
|
|
862
|
+
conditions.push('chunk.magnitude > 0');
|
|
863
|
+
}
|
|
864
|
+
if (options.workspace) {
|
|
865
|
+
conditions.push(`source.workspace = ${addParam(params, options.workspace)}`);
|
|
866
|
+
}
|
|
867
|
+
(0, RdfSearchSourceFilter_1.appendPgRdfSearchSourceFilters)(options, conditions, params);
|
|
868
|
+
appendPgVectorIdentityFilters(options, conditions, params);
|
|
869
|
+
const thresholdWhere = options.threshold === undefined
|
|
870
|
+
? ''
|
|
871
|
+
: `WHERE ${(0, RdfVectorIndex_1.vectorThresholdSql)(metric, queryMagnitude, options.threshold)}`;
|
|
872
|
+
return {
|
|
873
|
+
withSql: `
|
|
874
|
+
WITH query_vector(dimension, value) AS (
|
|
875
|
+
VALUES ${vectorValues}
|
|
876
|
+
),
|
|
877
|
+
scored AS (
|
|
878
|
+
SELECT
|
|
879
|
+
chunk.id,
|
|
880
|
+
chunk.source_id,
|
|
881
|
+
source.source_key,
|
|
882
|
+
source.source,
|
|
883
|
+
source.workspace,
|
|
884
|
+
source.local_path,
|
|
885
|
+
source.content_type,
|
|
886
|
+
source.source_version,
|
|
887
|
+
source.source_hash,
|
|
888
|
+
chunk.chunk_key,
|
|
889
|
+
chunk.ordinal,
|
|
890
|
+
chunk.level,
|
|
891
|
+
chunk.heading,
|
|
892
|
+
chunk.path,
|
|
893
|
+
chunk.content,
|
|
894
|
+
chunk.start_offset,
|
|
895
|
+
chunk.end_offset,
|
|
896
|
+
chunk.embedding_json,
|
|
897
|
+
chunk.summary_metadata,
|
|
898
|
+
chunk.dimensions,
|
|
899
|
+
chunk.magnitude,
|
|
900
|
+
chunk.provider,
|
|
901
|
+
chunk.model,
|
|
902
|
+
chunk.model_version,
|
|
903
|
+
chunk.input_kind,
|
|
904
|
+
chunk.input_hash,
|
|
905
|
+
chunk.projection_policy_version,
|
|
906
|
+
chunk.updated_at,
|
|
907
|
+
SUM(component.value * query_vector.value) AS dot_product
|
|
908
|
+
FROM rdf_vector_chunks chunk
|
|
909
|
+
JOIN rdf_vector_sources source ON source.id = chunk.source_id
|
|
910
|
+
JOIN rdf_vector_components component ON component.chunk_id = chunk.id
|
|
911
|
+
JOIN query_vector ON query_vector.dimension = component.dimension
|
|
912
|
+
WHERE ${conditions.join(' AND ')}
|
|
913
|
+
GROUP BY
|
|
914
|
+
chunk.id,
|
|
915
|
+
source.source_key,
|
|
916
|
+
source.source,
|
|
917
|
+
source.workspace,
|
|
918
|
+
source.local_path,
|
|
919
|
+
source.content_type,
|
|
920
|
+
source.source_version,
|
|
921
|
+
source.source_hash
|
|
922
|
+
HAVING COUNT(component.dimension) = ${embedding.length}
|
|
923
|
+
)
|
|
924
|
+
`,
|
|
925
|
+
params,
|
|
926
|
+
thresholdWhere,
|
|
927
|
+
queryMagnitude,
|
|
928
|
+
};
|
|
929
|
+
}
|
|
930
|
+
function buildPgVectorWindowClause(params, limit, offset) {
|
|
931
|
+
const hasLimit = limit !== undefined;
|
|
932
|
+
const hasOffset = offset !== undefined;
|
|
933
|
+
if (!hasLimit && !hasOffset) {
|
|
934
|
+
return '';
|
|
935
|
+
}
|
|
936
|
+
if (hasLimit) {
|
|
937
|
+
const limitParam = addParam(params, Math.max(0, limit), 'integer');
|
|
938
|
+
if (hasOffset) {
|
|
939
|
+
return `LIMIT ${limitParam} OFFSET ${addParam(params, Math.max(0, offset), 'integer')}`;
|
|
940
|
+
}
|
|
941
|
+
return `LIMIT ${limitParam}`;
|
|
942
|
+
}
|
|
943
|
+
return `OFFSET ${addParam(params, Math.max(0, offset ?? 0), 'integer')}`;
|
|
944
|
+
}
|
|
945
|
+
function pgVectorNativeDistanceExpression(metric, vectorExpression, queryVector) {
|
|
946
|
+
switch (metric) {
|
|
947
|
+
case 'cosine':
|
|
948
|
+
return `${vectorExpression} <=> ${queryVector}`;
|
|
949
|
+
case 'euclidean':
|
|
950
|
+
return `${vectorExpression} <-> ${queryVector}`;
|
|
951
|
+
case 'dot':
|
|
952
|
+
return `${vectorExpression} <#> ${queryVector}`;
|
|
953
|
+
default: {
|
|
954
|
+
const exhaustive = metric;
|
|
955
|
+
throw new Error(`Unsupported RDF vector distance metric: ${exhaustive}`);
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
function pgVectorNativeScoreExpression(metric, distanceExpression) {
|
|
960
|
+
switch (metric) {
|
|
961
|
+
case 'cosine':
|
|
962
|
+
return `1 - (${distanceExpression})`;
|
|
963
|
+
case 'euclidean':
|
|
964
|
+
return `-(${distanceExpression} * ${distanceExpression})`;
|
|
965
|
+
case 'dot':
|
|
966
|
+
return `-(${distanceExpression})`;
|
|
967
|
+
default: {
|
|
968
|
+
const exhaustive = metric;
|
|
969
|
+
throw new Error(`Unsupported RDF vector distance metric: ${exhaustive}`);
|
|
970
|
+
}
|
|
971
|
+
}
|
|
972
|
+
}
|
|
973
|
+
function pgVectorNativeThresholdExpression(metric, distanceExpression, threshold) {
|
|
974
|
+
if (!Number.isFinite(threshold)) {
|
|
975
|
+
return threshold === Number.NEGATIVE_INFINITY ? '1 = 1' : '1 = 0';
|
|
976
|
+
}
|
|
977
|
+
switch (metric) {
|
|
978
|
+
case 'cosine':
|
|
979
|
+
return `${distanceExpression} <= ${1 - threshold}`;
|
|
980
|
+
case 'dot':
|
|
981
|
+
return `${distanceExpression} <= ${-threshold}`;
|
|
982
|
+
case 'euclidean':
|
|
983
|
+
return threshold <= 0 ? `${distanceExpression} <= ${Math.abs(threshold)}` : '1 = 0';
|
|
984
|
+
default: {
|
|
985
|
+
const exhaustive = metric;
|
|
986
|
+
throw new Error(`Unsupported RDF vector distance metric: ${exhaustive}`);
|
|
987
|
+
}
|
|
988
|
+
}
|
|
989
|
+
}
|
|
990
|
+
function buildPgVectorNativeOrderClause(orderBy, distanceExpression) {
|
|
991
|
+
const order = orderBy?.length ? orderBy : [{ field: 'score', direction: 'desc' }];
|
|
992
|
+
const entries = order.map((entry) => {
|
|
993
|
+
if (entry.field === 'score') {
|
|
994
|
+
const direction = entry.direction === 'desc' ? 'ASC' : 'DESC';
|
|
995
|
+
return `${distanceExpression} ${direction}`;
|
|
996
|
+
}
|
|
997
|
+
if (entry.field === 'distance') {
|
|
998
|
+
return `${distanceExpression} ${entry.direction === 'desc' ? 'DESC' : 'ASC'}`;
|
|
999
|
+
}
|
|
1000
|
+
return `${pgVectorNativeOrderExpression(entry.field)} ${entry.direction === 'desc' ? 'DESC' : 'ASC'}`;
|
|
1001
|
+
});
|
|
1002
|
+
return [...entries, 'source.id ASC', 'chunk.ordinal ASC'].join(', ');
|
|
1003
|
+
}
|
|
1004
|
+
function pgVectorNativeOrderExpression(field) {
|
|
1005
|
+
switch (field) {
|
|
1006
|
+
case 'score':
|
|
1007
|
+
return 'vector_score';
|
|
1008
|
+
case 'distance':
|
|
1009
|
+
return 'native_distance';
|
|
1010
|
+
case 'source':
|
|
1011
|
+
return 'source.source';
|
|
1012
|
+
case 'localPath':
|
|
1013
|
+
return "COALESCE(source.local_path, '')";
|
|
1014
|
+
case 'ordinal':
|
|
1015
|
+
return 'chunk.ordinal';
|
|
1016
|
+
case 'startOffset':
|
|
1017
|
+
return 'chunk.start_offset';
|
|
1018
|
+
case 'endOffset':
|
|
1019
|
+
return 'chunk.end_offset';
|
|
1020
|
+
default: {
|
|
1021
|
+
const exhaustive = field;
|
|
1022
|
+
throw new Error(`Unsupported RDF vector search order field: ${exhaustive}`);
|
|
1023
|
+
}
|
|
1024
|
+
}
|
|
1025
|
+
}
|
|
1026
|
+
async function insertVectorComponents(executor, chunkId, embedding) {
|
|
1027
|
+
for (let dimension = 0; dimension < embedding.length; dimension++) {
|
|
1028
|
+
await executor.exec(`
|
|
1029
|
+
INSERT INTO rdf_vector_components (
|
|
1030
|
+
chunk_id,
|
|
1031
|
+
dimension,
|
|
1032
|
+
value,
|
|
1033
|
+
updated_at
|
|
1034
|
+
)
|
|
1035
|
+
VALUES ($1, $2, $3, now())
|
|
1036
|
+
`, [chunkId, dimension, embedding[dimension]]);
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
function addParam(params, value, cast) {
|
|
1040
|
+
params.push(value);
|
|
1041
|
+
return `$${params.length}${cast ? `::${cast}` : ''}`;
|
|
1042
|
+
}
|
|
1043
|
+
function formatPgVectorLiteral(embedding) {
|
|
1044
|
+
return `[${embedding.map((value) => {
|
|
1045
|
+
if (!Number.isFinite(value)) {
|
|
1046
|
+
throw new Error(`Invalid RDF vector value: ${value}`);
|
|
1047
|
+
}
|
|
1048
|
+
return String(value);
|
|
1049
|
+
}).join(',')}]`;
|
|
1050
|
+
}
|
|
1051
|
+
function pgVectorDimensions(dimensions) {
|
|
1052
|
+
if (!Number.isSafeInteger(dimensions) || dimensions <= 0) {
|
|
1053
|
+
throw new Error(`Invalid RDF vector dimensions: ${dimensions}`);
|
|
1054
|
+
}
|
|
1055
|
+
return dimensions;
|
|
1056
|
+
}
|
|
1057
|
+
function pgVectorOperatorClass(metric) {
|
|
1058
|
+
switch (metric) {
|
|
1059
|
+
case 'cosine':
|
|
1060
|
+
return 'vector_cosine_ops';
|
|
1061
|
+
case 'euclidean':
|
|
1062
|
+
return 'vector_l2_ops';
|
|
1063
|
+
case 'dot':
|
|
1064
|
+
return 'vector_ip_ops';
|
|
1065
|
+
default: {
|
|
1066
|
+
const exhaustive = metric;
|
|
1067
|
+
throw new Error(`Unsupported RDF vector distance metric: ${exhaustive}`);
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
function quotePgIdentifier(value) {
|
|
1072
|
+
return `"${value.replace(/"/g, '""')}"`;
|
|
1073
|
+
}
|
|
1074
|
+
function toSearchResult(row, embedding, metric, queryMagnitude, score, distance, backend) {
|
|
1075
|
+
return {
|
|
1076
|
+
source: row.source,
|
|
1077
|
+
workspace: row.workspace,
|
|
1078
|
+
localPath: row.local_path ?? undefined,
|
|
1079
|
+
contentType: row.content_type ?? undefined,
|
|
1080
|
+
sourceVersion: row.source_version ?? undefined,
|
|
1081
|
+
sourceHash: row.source_hash ?? undefined,
|
|
1082
|
+
sourceKey: row.source_key || row.source,
|
|
1083
|
+
chunkKey: row.chunk_key,
|
|
1084
|
+
retrievalPointKey: row.chunk_key,
|
|
1085
|
+
ordinal: row.ordinal,
|
|
1086
|
+
level: row.level,
|
|
1087
|
+
heading: row.heading ?? undefined,
|
|
1088
|
+
path: (0, RdfVectorIndex_1.parsePath)(row.path),
|
|
1089
|
+
content: row.content,
|
|
1090
|
+
startOffset: row.start_offset,
|
|
1091
|
+
endOffset: row.end_offset,
|
|
1092
|
+
embedding,
|
|
1093
|
+
provider: row.provider || undefined,
|
|
1094
|
+
model: row.model || undefined,
|
|
1095
|
+
modelVersion: row.model_version || undefined,
|
|
1096
|
+
inputKind: row.input_kind || undefined,
|
|
1097
|
+
inputHash: row.input_hash || undefined,
|
|
1098
|
+
projectionPolicyVersion: row.projection_policy_version || undefined,
|
|
1099
|
+
summaryMetadata: (0, RdfVectorIndex_1.parseSummaryMetadata)(row.summary_metadata),
|
|
1100
|
+
scoreComponents: (0, RdfVectorIndex_1.vectorScoreComponents)(row, metric, queryMagnitude, score, distance, backend),
|
|
1101
|
+
score,
|
|
1102
|
+
distance,
|
|
1103
|
+
};
|
|
1104
|
+
}
|
|
1105
|
+
function toSummaryLifecycleEntry(row) {
|
|
1106
|
+
const summaryMetadata = (0, RdfVectorIndex_1.parseSummaryMetadata)(row.summary_metadata);
|
|
1107
|
+
if (!summaryMetadata) {
|
|
1108
|
+
return undefined;
|
|
1109
|
+
}
|
|
1110
|
+
return {
|
|
1111
|
+
source: row.source,
|
|
1112
|
+
workspace: row.workspace,
|
|
1113
|
+
localPath: row.local_path ?? undefined,
|
|
1114
|
+
contentType: row.content_type ?? undefined,
|
|
1115
|
+
sourceVersion: row.source_version ?? undefined,
|
|
1116
|
+
sourceHash: row.source_hash ?? undefined,
|
|
1117
|
+
sourceKey: row.source_key || row.source,
|
|
1118
|
+
chunkKey: row.chunk_key,
|
|
1119
|
+
retrievalPointKey: row.chunk_key,
|
|
1120
|
+
ordinal: row.ordinal,
|
|
1121
|
+
level: row.level,
|
|
1122
|
+
heading: row.heading ?? undefined,
|
|
1123
|
+
path: (0, RdfVectorIndex_1.parsePath)(row.path),
|
|
1124
|
+
content: row.content,
|
|
1125
|
+
startOffset: row.start_offset,
|
|
1126
|
+
endOffset: row.end_offset,
|
|
1127
|
+
provider: row.provider || undefined,
|
|
1128
|
+
model: row.model || undefined,
|
|
1129
|
+
modelVersion: row.model_version || undefined,
|
|
1130
|
+
inputKind: row.input_kind || undefined,
|
|
1131
|
+
inputHash: row.input_hash || undefined,
|
|
1132
|
+
projectionPolicyVersion: row.projection_policy_version || undefined,
|
|
1133
|
+
summaryMetadata,
|
|
1134
|
+
updatedAt: formatPgTimestamp(row.updated_at),
|
|
1135
|
+
};
|
|
1136
|
+
}
|
|
1137
|
+
function normalizeVectorChunkRow(row) {
|
|
1138
|
+
return {
|
|
1139
|
+
...row,
|
|
1140
|
+
id: Number(row.id),
|
|
1141
|
+
source_id: Number(row.source_id),
|
|
1142
|
+
ordinal: Number(row.ordinal),
|
|
1143
|
+
level: Number(row.level),
|
|
1144
|
+
start_offset: Number(row.start_offset),
|
|
1145
|
+
end_offset: Number(row.end_offset),
|
|
1146
|
+
dimensions: Number(row.dimensions),
|
|
1147
|
+
magnitude: Number(row.magnitude),
|
|
1148
|
+
};
|
|
1149
|
+
}
|
|
1150
|
+
function normalizeVectorScoredChunkRow(row) {
|
|
1151
|
+
return {
|
|
1152
|
+
...normalizeVectorChunkRow(row),
|
|
1153
|
+
dot_product: Number(row.dot_product),
|
|
1154
|
+
vector_score: Number(row.vector_score),
|
|
1155
|
+
vector_distance: row.vector_distance === null ? null : Number(row.vector_distance),
|
|
1156
|
+
vector_distance_squared: row.vector_distance_squared === null ? null : Number(row.vector_distance_squared),
|
|
1157
|
+
};
|
|
1158
|
+
}
|
|
1159
|
+
function formatPgTimestamp(value) {
|
|
1160
|
+
if (value instanceof Date) {
|
|
1161
|
+
return value.toISOString();
|
|
1162
|
+
}
|
|
1163
|
+
return String(value);
|
|
1164
|
+
}
|
|
1165
|
+
//# sourceMappingURL=PostgresRdfVectorIndex.js.map
|