@undefineds.co/xpod 0.3.57 → 0.3.61
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/obj.d.ts +9 -0
- package/dist/cli/commands/obj.js +74 -3
- package/dist/cli/commands/obj.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/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 +32 -12
- 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
|
@@ -1,12 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RdfTextIndex = void 0;
|
|
3
|
+
exports.RdfTextIndex = exports.RDF_TEXT_SCHEMA_VERSION = exports.RDF_TEXT_TERM_MAX_INDEX_LENGTH = void 0;
|
|
4
|
+
exports.chunkRdfTextSource = chunkRdfTextSource;
|
|
5
|
+
exports.deterministicRdfTextChunkKey = deterministicRdfTextChunkKey;
|
|
6
|
+
exports.rdfTextSha256 = rdfTextSha256;
|
|
7
|
+
exports.normalizeRdfText = normalizeRdfText;
|
|
8
|
+
exports.normalizedRdfTextTokenCount = normalizedRdfTextTokenCount;
|
|
9
|
+
exports.tokenizeNormalizedRdfText = tokenizeNormalizedRdfText;
|
|
10
|
+
exports.rdfTextTermOccurrences = rdfTextTermOccurrences;
|
|
11
|
+
exports.rdfTextOccurrenceCount = rdfTextOccurrenceCount;
|
|
12
|
+
exports.applyRdfTextResultWindow = applyRdfTextResultWindow;
|
|
13
|
+
exports.compareRdfTextSearchHits = compareRdfTextSearchHits;
|
|
14
|
+
exports.normalizeRdfTextPerSourceLimit = normalizeRdfTextPerSourceLimit;
|
|
15
|
+
exports.escapeRdfTextLikePattern = escapeRdfTextLikePattern;
|
|
16
|
+
exports.parseRdfTextPath = parseRdfTextPath;
|
|
17
|
+
exports.normalizeRdfTextRetrievalKind = normalizeRdfTextRetrievalKind;
|
|
18
|
+
exports.rdfTextIndexBudgetSkip = rdfTextIndexBudgetSkip;
|
|
19
|
+
exports.rdfTextIndexChunkCap = rdfTextIndexChunkCap;
|
|
4
20
|
const node_crypto_1 = require("node:crypto");
|
|
5
21
|
const node_fs_1 = require("node:fs");
|
|
6
22
|
const node_path_1 = require("node:path");
|
|
7
23
|
const HeadingChunker_1 = require("../../document/HeadingChunker");
|
|
8
24
|
const SqliteRuntime_1 = require("../SqliteRuntime");
|
|
9
|
-
const
|
|
25
|
+
const RdfSearchSourceFilter_1 = require("./RdfSearchSourceFilter");
|
|
26
|
+
exports.RDF_TEXT_TERM_MAX_INDEX_LENGTH = 256;
|
|
27
|
+
exports.RDF_TEXT_SCHEMA_VERSION = 2;
|
|
10
28
|
class RdfTextIndex {
|
|
11
29
|
constructor(options) {
|
|
12
30
|
this.options = options;
|
|
@@ -31,19 +49,80 @@ class RdfTextIndex {
|
|
|
31
49
|
this.db = null;
|
|
32
50
|
}
|
|
33
51
|
clear() {
|
|
34
|
-
this.requireDb().exec('DELETE FROM rdf_text_terms; DELETE FROM rdf_text_chunks; DELETE FROM rdf_text_sources;');
|
|
52
|
+
this.requireDb().exec('DELETE FROM rdf_text_rebuild_status; DELETE FROM rdf_text_entities; DELETE FROM rdf_text_terms; DELETE FROM rdf_text_chunks; DELETE FROM rdf_text_sources;');
|
|
53
|
+
}
|
|
54
|
+
schemaVersion() {
|
|
55
|
+
const row = this.requireDb()
|
|
56
|
+
.prepare("SELECT value FROM rdf_text_metadata WHERE key = 'schema_version'")
|
|
57
|
+
.get();
|
|
58
|
+
return Number(row?.value ?? 0) || 0;
|
|
59
|
+
}
|
|
60
|
+
sourceMetadata(source) {
|
|
61
|
+
const row = this.requireDb()
|
|
62
|
+
.prepare('SELECT * FROM rdf_text_sources WHERE source = ?')
|
|
63
|
+
.get(source);
|
|
64
|
+
return row ? rdfTextSourceMetadata(row) : undefined;
|
|
65
|
+
}
|
|
66
|
+
recordRebuildStatus(input) {
|
|
67
|
+
this.requireDb().prepare(`
|
|
68
|
+
INSERT INTO rdf_text_rebuild_status (
|
|
69
|
+
source,
|
|
70
|
+
workspace,
|
|
71
|
+
local_path,
|
|
72
|
+
content_type,
|
|
73
|
+
source_version,
|
|
74
|
+
source_hash,
|
|
75
|
+
status,
|
|
76
|
+
reason,
|
|
77
|
+
message,
|
|
78
|
+
updated_at
|
|
79
|
+
)
|
|
80
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, strftime('%Y-%m-%dT%H:%M:%fZ', 'now'))
|
|
81
|
+
ON CONFLICT (source)
|
|
82
|
+
DO UPDATE SET
|
|
83
|
+
workspace = excluded.workspace,
|
|
84
|
+
local_path = excluded.local_path,
|
|
85
|
+
content_type = excluded.content_type,
|
|
86
|
+
source_version = excluded.source_version,
|
|
87
|
+
source_hash = excluded.source_hash,
|
|
88
|
+
status = excluded.status,
|
|
89
|
+
reason = excluded.reason,
|
|
90
|
+
message = excluded.message,
|
|
91
|
+
updated_at = excluded.updated_at
|
|
92
|
+
`).run(input.source, input.workspace, input.localPath ?? null, input.contentType ?? null, input.sourceVersion ?? null, input.sourceHash ?? null, input.status, input.reason ?? null, input.message ?? null);
|
|
93
|
+
}
|
|
94
|
+
rebuildStatus(source) {
|
|
95
|
+
const row = this.requireDb()
|
|
96
|
+
.prepare('SELECT * FROM rdf_text_rebuild_status WHERE source = ?')
|
|
97
|
+
.get(source);
|
|
98
|
+
return row ? rdfTextRebuildStatus(row) : undefined;
|
|
35
99
|
}
|
|
36
100
|
indexText(source, text, chunks) {
|
|
37
101
|
const db = this.requireDb();
|
|
38
|
-
const
|
|
102
|
+
const sourceHash = source.sourceHash ?? sha256(text);
|
|
103
|
+
const budgetSkip = rdfTextIndexBudgetSkip(this.options.maxSourceBytes, text);
|
|
104
|
+
if (budgetSkip) {
|
|
105
|
+
this.deleteSource(source.source);
|
|
106
|
+
this.recordRebuildStatus({
|
|
107
|
+
...source,
|
|
108
|
+
sourceHash,
|
|
109
|
+
status: 'skipped',
|
|
110
|
+
reason: budgetSkip.reason,
|
|
111
|
+
message: budgetSkip.message,
|
|
112
|
+
});
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
const chunkCap = rdfTextIndexChunkCap(this.options.maxChunksPerSource, chunks ?? this.chunkText(source, text));
|
|
116
|
+
const indexedChunks = chunkCap.chunks;
|
|
39
117
|
const sourceId = this.upsertSource({
|
|
40
118
|
...source,
|
|
41
|
-
sourceHash
|
|
119
|
+
sourceHash,
|
|
42
120
|
});
|
|
43
121
|
const insertChunk = db.prepare(`
|
|
44
122
|
INSERT INTO rdf_text_chunks (
|
|
45
123
|
source_id,
|
|
46
124
|
chunk_key,
|
|
125
|
+
retrieval_kind,
|
|
47
126
|
ordinal,
|
|
48
127
|
level,
|
|
49
128
|
heading,
|
|
@@ -55,7 +134,7 @@ class RdfTextIndex {
|
|
|
55
134
|
token_count,
|
|
56
135
|
updated_at
|
|
57
136
|
)
|
|
58
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, strftime('%Y-%m-%dT%H:%M:%fZ', 'now'))
|
|
137
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, strftime('%Y-%m-%dT%H:%M:%fZ', 'now'))
|
|
59
138
|
`);
|
|
60
139
|
const insertTerm = db.prepare(`
|
|
61
140
|
INSERT INTO rdf_text_terms (
|
|
@@ -66,16 +145,91 @@ class RdfTextIndex {
|
|
|
66
145
|
updated_at
|
|
67
146
|
)
|
|
68
147
|
VALUES (?, ?, ?, ?, strftime('%Y-%m-%dT%H:%M:%fZ', 'now'))
|
|
148
|
+
`);
|
|
149
|
+
const insertEntity = db.prepare(`
|
|
150
|
+
INSERT INTO rdf_text_entities (
|
|
151
|
+
entity,
|
|
152
|
+
source_id,
|
|
153
|
+
chunk_id,
|
|
154
|
+
predicate,
|
|
155
|
+
label,
|
|
156
|
+
value,
|
|
157
|
+
datatype,
|
|
158
|
+
language,
|
|
159
|
+
policy_role,
|
|
160
|
+
occurrences,
|
|
161
|
+
updated_at
|
|
162
|
+
)
|
|
163
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, strftime('%Y-%m-%dT%H:%M:%fZ', 'now'))
|
|
69
164
|
`);
|
|
70
165
|
db.transaction(() => {
|
|
166
|
+
db.prepare('DELETE FROM rdf_text_entities WHERE source_id = ?').run(sourceId);
|
|
71
167
|
db.prepare('DELETE FROM rdf_text_terms WHERE source_id = ?').run(sourceId);
|
|
72
168
|
db.prepare('DELETE FROM rdf_text_chunks WHERE source_id = ?').run(sourceId);
|
|
73
169
|
for (const chunk of indexedChunks) {
|
|
74
170
|
const normalizedText = normalizeText(chunk.content);
|
|
75
|
-
const result = insertChunk.run(sourceId, chunk.chunkKey, chunk.ordinal, chunk.level, chunk.heading || null, JSON.stringify(chunk.path ?? []), chunk.content, chunk.startOffset, chunk.endOffset, normalizedText, tokenCountNormalized(normalizedText));
|
|
76
|
-
|
|
171
|
+
const result = insertChunk.run(sourceId, chunk.chunkKey, chunk.retrievalKind ?? 'file-chunk', chunk.ordinal, chunk.level, chunk.heading || null, JSON.stringify(chunk.path ?? []), chunk.content, chunk.startOffset, chunk.endOffset, normalizedText, tokenCountNormalized(normalizedText));
|
|
172
|
+
const chunkId = Number(result.lastInsertRowid);
|
|
173
|
+
insertTermOccurrences(insertTerm, sourceId, chunkId, normalizedText);
|
|
174
|
+
insertEntityMentions(insertEntity, sourceId, chunkId, chunk.entities);
|
|
175
|
+
}
|
|
176
|
+
})();
|
|
177
|
+
if (chunkCap.capped) {
|
|
178
|
+
this.recordRebuildStatus({
|
|
179
|
+
...source,
|
|
180
|
+
sourceHash,
|
|
181
|
+
status: 'capped',
|
|
182
|
+
reason: chunkCap.capped.reason,
|
|
183
|
+
message: chunkCap.capped.message,
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
moveSource(oldSource, next) {
|
|
188
|
+
const db = this.requireDb();
|
|
189
|
+
let affectedRows = 0;
|
|
190
|
+
db.transaction(() => {
|
|
191
|
+
const oldRow = db.prepare('SELECT * FROM rdf_text_sources WHERE source = ?').get(oldSource);
|
|
192
|
+
if (!oldRow) {
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
const chunkCount = db
|
|
196
|
+
.prepare('SELECT COUNT(*) AS count FROM rdf_text_chunks WHERE source_id = ?')
|
|
197
|
+
.get(oldRow.id)?.count ?? 0;
|
|
198
|
+
const targetRow = db.prepare('SELECT * FROM rdf_text_sources WHERE source = ?').get(next.source);
|
|
199
|
+
if (targetRow && targetRow.id !== oldRow.id) {
|
|
200
|
+
db.prepare('DELETE FROM rdf_text_entities WHERE source_id = ?').run(targetRow.id);
|
|
201
|
+
db.prepare('DELETE FROM rdf_text_terms WHERE source_id = ?').run(targetRow.id);
|
|
202
|
+
db.prepare('DELETE FROM rdf_text_chunks WHERE source_id = ?').run(targetRow.id);
|
|
203
|
+
db.prepare('DELETE FROM rdf_text_sources WHERE id = ?').run(targetRow.id);
|
|
77
204
|
}
|
|
205
|
+
db.prepare(`
|
|
206
|
+
UPDATE rdf_text_sources
|
|
207
|
+
SET
|
|
208
|
+
source_key = ?,
|
|
209
|
+
source = ?,
|
|
210
|
+
workspace = ?,
|
|
211
|
+
local_path = ?,
|
|
212
|
+
content_type = ?,
|
|
213
|
+
source_version = ?,
|
|
214
|
+
source_hash = ?,
|
|
215
|
+
updated_at = strftime('%Y-%m-%dT%H:%M:%fZ', 'now')
|
|
216
|
+
WHERE id = ?
|
|
217
|
+
`).run(next.sourceKey ?? oldRow.source_key ?? oldRow.source, next.source, next.workspace, next.localPath ?? null, next.contentType ?? null, next.sourceVersion ?? null, next.sourceHash ?? null, oldRow.id);
|
|
218
|
+
db.prepare(`
|
|
219
|
+
UPDATE rdf_text_rebuild_status
|
|
220
|
+
SET
|
|
221
|
+
source = ?,
|
|
222
|
+
workspace = ?,
|
|
223
|
+
local_path = ?,
|
|
224
|
+
content_type = ?,
|
|
225
|
+
source_version = ?,
|
|
226
|
+
source_hash = ?,
|
|
227
|
+
updated_at = strftime('%Y-%m-%dT%H:%M:%fZ', 'now')
|
|
228
|
+
WHERE source = ?
|
|
229
|
+
`).run(next.source, next.workspace, next.localPath ?? null, next.contentType ?? null, next.sourceVersion ?? null, next.sourceHash ?? null, oldSource);
|
|
230
|
+
affectedRows = Math.max(chunkCount, 1);
|
|
78
231
|
})();
|
|
232
|
+
return affectedRows;
|
|
79
233
|
}
|
|
80
234
|
deleteSource(source) {
|
|
81
235
|
const db = this.requireDb();
|
|
@@ -84,6 +238,7 @@ class RdfTextIndex {
|
|
|
84
238
|
return 0;
|
|
85
239
|
}
|
|
86
240
|
return db.transaction(() => {
|
|
241
|
+
db.prepare('DELETE FROM rdf_text_entities WHERE source_id = ?').run(row.id);
|
|
87
242
|
db.prepare('DELETE FROM rdf_text_terms WHERE source_id = ?').run(row.id);
|
|
88
243
|
const deletedChunks = db.prepare('DELETE FROM rdf_text_chunks WHERE source_id = ?').run(row.id).changes;
|
|
89
244
|
db.prepare('DELETE FROM rdf_text_sources WHERE id = ?').run(row.id);
|
|
@@ -92,92 +247,175 @@ class RdfTextIndex {
|
|
|
92
247
|
}
|
|
93
248
|
search(options) {
|
|
94
249
|
const query = normalizeText(options.query);
|
|
95
|
-
|
|
250
|
+
const entityFilter = normalizeEntityFilter(options.entities);
|
|
251
|
+
if (!query && entityFilter.length === 0) {
|
|
96
252
|
return [];
|
|
97
253
|
}
|
|
98
|
-
const predicate = buildTextSearchPredicate(query);
|
|
99
|
-
const params = [...predicate.params];
|
|
100
|
-
const conditions = [predicate.sql];
|
|
254
|
+
const predicate = query ? buildTextSearchPredicate(query) : undefined;
|
|
255
|
+
const params = predicate ? [...predicate.params] : [];
|
|
256
|
+
const conditions = predicate ? [predicate.sql] : ['1 = 1'];
|
|
257
|
+
appendEntitySearchFilter(entityFilter, conditions, params);
|
|
101
258
|
if (options.workspace) {
|
|
102
259
|
conditions.push('source.workspace = ?');
|
|
103
260
|
params.push(options.workspace);
|
|
104
261
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
262
|
+
(0, RdfSearchSourceFilter_1.appendRdfSearchSourceFilters)(options, conditions, params);
|
|
263
|
+
const scoreExpression = query
|
|
264
|
+
? `
|
|
265
|
+
CAST((length(chunk.normalized_text) - length(replace(chunk.normalized_text, ?, ''))) / length(?) AS INTEGER)
|
|
266
|
+
+ CASE
|
|
267
|
+
WHEN lower(COALESCE(chunk.heading, '')) LIKE ? ESCAPE '\\' THEN 100
|
|
268
|
+
ELSE 0
|
|
269
|
+
END
|
|
270
|
+
`
|
|
271
|
+
: '1';
|
|
272
|
+
const orderBy = sqliteTextSearchOrderBy(options.orderBy);
|
|
273
|
+
const window = sqliteTextSearchWindow(options);
|
|
274
|
+
const perSourceLimit = normalizeRdfTextPerSourceLimit(options.perSourceLimit);
|
|
275
|
+
const sql = perSourceLimit === undefined
|
|
276
|
+
? `
|
|
277
|
+
SELECT
|
|
278
|
+
chunk.id,
|
|
279
|
+
chunk.source_id,
|
|
280
|
+
source.source_key,
|
|
281
|
+
source.source,
|
|
282
|
+
source.workspace,
|
|
283
|
+
source.local_path,
|
|
284
|
+
source.content_type,
|
|
285
|
+
source.source_version,
|
|
286
|
+
source.source_hash,
|
|
287
|
+
chunk.chunk_key,
|
|
288
|
+
chunk.retrieval_kind,
|
|
289
|
+
chunk.ordinal,
|
|
290
|
+
chunk.level,
|
|
291
|
+
chunk.heading,
|
|
292
|
+
chunk.path,
|
|
293
|
+
chunk.content,
|
|
294
|
+
chunk.start_offset,
|
|
295
|
+
chunk.end_offset,
|
|
296
|
+
chunk.normalized_text,
|
|
297
|
+
chunk.token_count,
|
|
298
|
+
chunk.updated_at,
|
|
299
|
+
${scoreExpression} AS score
|
|
300
|
+
FROM rdf_text_chunks chunk
|
|
301
|
+
JOIN rdf_text_sources source ON source.id = chunk.source_id
|
|
302
|
+
WHERE ${conditions.join(' AND ')}
|
|
303
|
+
ORDER BY ${orderBy}, chunk.source_id ASC, chunk.ordinal ASC
|
|
304
|
+
${window.sql}
|
|
305
|
+
`
|
|
306
|
+
: `
|
|
307
|
+
WITH matched AS (
|
|
308
|
+
SELECT
|
|
309
|
+
chunk.id,
|
|
310
|
+
chunk.source_id,
|
|
311
|
+
source.source_key,
|
|
312
|
+
source.source,
|
|
313
|
+
source.workspace,
|
|
314
|
+
source.local_path,
|
|
315
|
+
source.content_type,
|
|
316
|
+
source.source_version,
|
|
317
|
+
source.source_hash,
|
|
318
|
+
chunk.chunk_key,
|
|
319
|
+
chunk.retrieval_kind,
|
|
320
|
+
chunk.ordinal,
|
|
321
|
+
chunk.level,
|
|
322
|
+
chunk.heading,
|
|
323
|
+
chunk.path,
|
|
324
|
+
chunk.content,
|
|
325
|
+
chunk.start_offset,
|
|
326
|
+
chunk.end_offset,
|
|
327
|
+
chunk.normalized_text,
|
|
328
|
+
chunk.token_count,
|
|
329
|
+
chunk.updated_at,
|
|
330
|
+
${scoreExpression} AS score
|
|
331
|
+
FROM rdf_text_chunks chunk
|
|
332
|
+
JOIN rdf_text_sources source ON source.id = chunk.source_id
|
|
333
|
+
WHERE ${conditions.join(' AND ')}
|
|
334
|
+
),
|
|
335
|
+
ranked AS (
|
|
336
|
+
SELECT
|
|
337
|
+
matched.*,
|
|
338
|
+
ROW_NUMBER() OVER (
|
|
339
|
+
PARTITION BY source
|
|
340
|
+
ORDER BY ${sqliteTextSearchResultOrderBy(options.orderBy)}, source_id ASC, ordinal ASC
|
|
341
|
+
) AS source_rank
|
|
342
|
+
FROM matched
|
|
343
|
+
)
|
|
344
|
+
SELECT
|
|
345
|
+
id,
|
|
346
|
+
source_id,
|
|
347
|
+
source_key,
|
|
348
|
+
source,
|
|
349
|
+
workspace,
|
|
350
|
+
local_path,
|
|
351
|
+
content_type,
|
|
352
|
+
source_version,
|
|
353
|
+
source_hash,
|
|
354
|
+
chunk_key,
|
|
355
|
+
retrieval_kind,
|
|
356
|
+
ordinal,
|
|
357
|
+
level,
|
|
358
|
+
heading,
|
|
359
|
+
path,
|
|
360
|
+
content,
|
|
361
|
+
start_offset,
|
|
362
|
+
end_offset,
|
|
363
|
+
normalized_text,
|
|
364
|
+
token_count,
|
|
365
|
+
updated_at,
|
|
366
|
+
score
|
|
367
|
+
FROM ranked
|
|
368
|
+
WHERE source_rank <= ?
|
|
369
|
+
ORDER BY ${sqliteTextSearchResultOrderBy(options.orderBy)}, source_id ASC, ordinal ASC
|
|
370
|
+
${window.sql}
|
|
371
|
+
`;
|
|
372
|
+
const scoreParams = query ? [query, query, `%${escapeLikePattern(query)}%`] : [];
|
|
373
|
+
const perSourceParams = perSourceLimit === undefined ? [] : [perSourceLimit];
|
|
374
|
+
const rows = this.requireDb().prepare(sql).all(...scoreParams, ...params, ...perSourceParams, ...window.params);
|
|
375
|
+
const entities = this.entitiesForChunks(rows.map((row) => row.id));
|
|
376
|
+
return rows.map((row) => this.toSearchResult(row, query, row.score, entities.get(row.id) ?? []));
|
|
146
377
|
}
|
|
147
378
|
estimateSearchCardinality(options) {
|
|
148
379
|
const query = normalizeText(options.query);
|
|
149
|
-
|
|
380
|
+
const entityFilter = normalizeEntityFilter(options.entities);
|
|
381
|
+
if (!query && entityFilter.length === 0) {
|
|
150
382
|
return {
|
|
151
383
|
rows: 0,
|
|
152
384
|
source: 'text-normalized-scan',
|
|
153
385
|
indexChoice: 'text-normalized-scan',
|
|
154
386
|
};
|
|
155
387
|
}
|
|
156
|
-
const predicate = buildTextSearchPredicate(query);
|
|
157
|
-
const params = [...predicate.params];
|
|
158
|
-
const conditions = [predicate.sql];
|
|
388
|
+
const predicate = query ? buildTextSearchPredicate(query) : undefined;
|
|
389
|
+
const params = predicate ? [...predicate.params] : [];
|
|
390
|
+
const conditions = predicate ? [predicate.sql] : ['1 = 1'];
|
|
391
|
+
appendEntitySearchFilter(entityFilter, conditions, params);
|
|
159
392
|
if (options.workspace) {
|
|
160
393
|
conditions.push('source.workspace = ?');
|
|
161
394
|
params.push(options.workspace);
|
|
162
395
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
396
|
+
(0, RdfSearchSourceFilter_1.appendRdfSearchSourceFilters)(options, conditions, params);
|
|
397
|
+
const perSourceLimit = normalizeRdfTextPerSourceLimit(options.perSourceLimit);
|
|
398
|
+
const rows = perSourceLimit === undefined
|
|
399
|
+
? this.requireDb().prepare(`
|
|
400
|
+
SELECT COUNT(*) AS count
|
|
401
|
+
FROM rdf_text_chunks chunk
|
|
402
|
+
JOIN rdf_text_sources source ON source.id = chunk.source_id
|
|
403
|
+
WHERE ${conditions.join(' AND ')}
|
|
404
|
+
`).get(...params)?.count ?? 0
|
|
405
|
+
: this.requireDb().prepare(`
|
|
406
|
+
SELECT COALESCE(SUM(CASE WHEN source_count > ? THEN ? ELSE source_count END), 0) AS count
|
|
407
|
+
FROM (
|
|
408
|
+
SELECT chunk.source_id, COUNT(*) AS source_count
|
|
409
|
+
FROM rdf_text_chunks chunk
|
|
410
|
+
JOIN rdf_text_sources source ON source.id = chunk.source_id
|
|
411
|
+
WHERE ${conditions.join(' AND ')}
|
|
412
|
+
GROUP BY chunk.source_id
|
|
413
|
+
)
|
|
414
|
+
`).get(perSourceLimit, perSourceLimit, ...params)?.count ?? 0;
|
|
177
415
|
return {
|
|
178
416
|
rows: applyResultWindow(rows, options.offset, options.limit),
|
|
179
|
-
source: predicate
|
|
180
|
-
indexChoice: predicate
|
|
417
|
+
source: predicate?.indexChoice ?? 'text-term-posting',
|
|
418
|
+
indexChoice: predicate?.indexChoice ?? 'text-entity-posting',
|
|
181
419
|
};
|
|
182
420
|
}
|
|
183
421
|
stats() {
|
|
@@ -185,6 +423,7 @@ class RdfTextIndex {
|
|
|
185
423
|
return {
|
|
186
424
|
sourceCount: db.prepare('SELECT COUNT(*) AS count FROM rdf_text_sources').get()?.count ?? 0,
|
|
187
425
|
chunkCount: db.prepare('SELECT COUNT(*) AS count FROM rdf_text_chunks').get()?.count ?? 0,
|
|
426
|
+
entityMentionCount: db.prepare('SELECT COUNT(*) AS count FROM rdf_text_entities').get()?.count ?? 0,
|
|
188
427
|
databaseBytes: this.estimateDatabaseBytes(),
|
|
189
428
|
termDocumentFrequency: this.termDocumentFrequency(),
|
|
190
429
|
};
|
|
@@ -211,8 +450,14 @@ class RdfTextIndex {
|
|
|
211
450
|
}
|
|
212
451
|
initializeSchema() {
|
|
213
452
|
this.requireDb().exec(`
|
|
453
|
+
CREATE TABLE IF NOT EXISTS rdf_text_metadata (
|
|
454
|
+
key TEXT PRIMARY KEY,
|
|
455
|
+
value TEXT NOT NULL
|
|
456
|
+
);
|
|
457
|
+
|
|
214
458
|
CREATE TABLE IF NOT EXISTS rdf_text_sources (
|
|
215
459
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
460
|
+
source_key TEXT,
|
|
216
461
|
source TEXT NOT NULL UNIQUE,
|
|
217
462
|
workspace TEXT NOT NULL,
|
|
218
463
|
local_path TEXT,
|
|
@@ -222,10 +467,24 @@ class RdfTextIndex {
|
|
|
222
467
|
updated_at TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ', 'now'))
|
|
223
468
|
);
|
|
224
469
|
|
|
470
|
+
CREATE TABLE IF NOT EXISTS rdf_text_rebuild_status (
|
|
471
|
+
source TEXT PRIMARY KEY,
|
|
472
|
+
workspace TEXT NOT NULL,
|
|
473
|
+
local_path TEXT,
|
|
474
|
+
content_type TEXT,
|
|
475
|
+
source_version TEXT,
|
|
476
|
+
source_hash TEXT,
|
|
477
|
+
status TEXT NOT NULL,
|
|
478
|
+
reason TEXT,
|
|
479
|
+
message TEXT,
|
|
480
|
+
updated_at TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ', 'now'))
|
|
481
|
+
);
|
|
482
|
+
|
|
225
483
|
CREATE TABLE IF NOT EXISTS rdf_text_chunks (
|
|
226
484
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
227
485
|
source_id INTEGER NOT NULL,
|
|
228
486
|
chunk_key TEXT NOT NULL,
|
|
487
|
+
retrieval_kind TEXT NOT NULL DEFAULT 'file-chunk',
|
|
229
488
|
ordinal INTEGER NOT NULL,
|
|
230
489
|
level INTEGER NOT NULL,
|
|
231
490
|
heading TEXT,
|
|
@@ -242,7 +501,7 @@ class RdfTextIndex {
|
|
|
242
501
|
|
|
243
502
|
CREATE TABLE IF NOT EXISTS rdf_text_terms (
|
|
244
503
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
245
|
-
term TEXT NOT NULL CHECK (length(term) <= ${RDF_TEXT_TERM_MAX_INDEX_LENGTH}),
|
|
504
|
+
term TEXT NOT NULL CHECK (length(term) <= ${exports.RDF_TEXT_TERM_MAX_INDEX_LENGTH}),
|
|
246
505
|
source_id INTEGER NOT NULL,
|
|
247
506
|
chunk_id INTEGER NOT NULL,
|
|
248
507
|
occurrences INTEGER NOT NULL,
|
|
@@ -252,18 +511,82 @@ class RdfTextIndex {
|
|
|
252
511
|
FOREIGN KEY (chunk_id) REFERENCES rdf_text_chunks(id)
|
|
253
512
|
);
|
|
254
513
|
|
|
514
|
+
CREATE TABLE IF NOT EXISTS rdf_text_entities (
|
|
515
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
516
|
+
entity TEXT NOT NULL,
|
|
517
|
+
source_id INTEGER NOT NULL,
|
|
518
|
+
chunk_id INTEGER NOT NULL,
|
|
519
|
+
predicate TEXT,
|
|
520
|
+
label TEXT,
|
|
521
|
+
value TEXT,
|
|
522
|
+
datatype TEXT,
|
|
523
|
+
language TEXT,
|
|
524
|
+
policy_role TEXT,
|
|
525
|
+
occurrences INTEGER NOT NULL DEFAULT 1,
|
|
526
|
+
updated_at TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')),
|
|
527
|
+
FOREIGN KEY (source_id) REFERENCES rdf_text_sources(id),
|
|
528
|
+
FOREIGN KEY (chunk_id) REFERENCES rdf_text_chunks(id)
|
|
529
|
+
);
|
|
530
|
+
|
|
255
531
|
CREATE INDEX IF NOT EXISTS rdf_text_sources_workspace ON rdf_text_sources(workspace);
|
|
256
532
|
CREATE INDEX IF NOT EXISTS rdf_text_sources_source ON rdf_text_sources(source);
|
|
533
|
+
CREATE INDEX IF NOT EXISTS rdf_text_sources_local_path ON rdf_text_sources(local_path);
|
|
534
|
+
CREATE INDEX IF NOT EXISTS rdf_text_sources_workspace_local_path ON rdf_text_sources(workspace, local_path);
|
|
257
535
|
CREATE INDEX IF NOT EXISTS rdf_text_chunks_source ON rdf_text_chunks(source_id, ordinal);
|
|
258
|
-
DELETE FROM rdf_text_terms WHERE length(term) > ${RDF_TEXT_TERM_MAX_INDEX_LENGTH};
|
|
536
|
+
DELETE FROM rdf_text_terms WHERE length(term) > ${exports.RDF_TEXT_TERM_MAX_INDEX_LENGTH};
|
|
259
537
|
CREATE INDEX IF NOT EXISTS rdf_text_terms_term ON rdf_text_terms(term);
|
|
260
538
|
CREATE INDEX IF NOT EXISTS rdf_text_terms_source_term ON rdf_text_terms(source_id, term);
|
|
261
539
|
CREATE INDEX IF NOT EXISTS rdf_text_terms_chunk ON rdf_text_terms(chunk_id);
|
|
540
|
+
CREATE INDEX IF NOT EXISTS rdf_text_entities_entity ON rdf_text_entities(entity);
|
|
541
|
+
CREATE INDEX IF NOT EXISTS rdf_text_entities_source_entity ON rdf_text_entities(source_id, entity);
|
|
542
|
+
CREATE INDEX IF NOT EXISTS rdf_text_entities_chunk ON rdf_text_entities(chunk_id);
|
|
262
543
|
|
|
263
544
|
DROP INDEX IF EXISTS rdf_text_chunks_normalized;
|
|
545
|
+
|
|
546
|
+
INSERT INTO rdf_text_metadata (key, value)
|
|
547
|
+
VALUES ('schema_version', '${exports.RDF_TEXT_SCHEMA_VERSION}')
|
|
548
|
+
ON CONFLICT (key) DO UPDATE SET value = excluded.value;
|
|
264
549
|
`);
|
|
550
|
+
this.ensureSourceKeyColumn();
|
|
551
|
+
this.ensureChunkRetrievalColumns();
|
|
552
|
+
this.ensureEntityProvenanceColumns();
|
|
265
553
|
this.backfillTermPostings();
|
|
266
554
|
}
|
|
555
|
+
ensureSourceKeyColumn() {
|
|
556
|
+
const columns = new Set(this.requireDb()
|
|
557
|
+
.prepare('PRAGMA table_info(rdf_text_sources)')
|
|
558
|
+
.all()
|
|
559
|
+
.map((column) => column.name));
|
|
560
|
+
if (!columns.has('source_key')) {
|
|
561
|
+
this.requireDb().exec('ALTER TABLE rdf_text_sources ADD COLUMN source_key TEXT;');
|
|
562
|
+
}
|
|
563
|
+
this.requireDb().exec('UPDATE rdf_text_sources SET source_key = source WHERE source_key IS NULL;');
|
|
564
|
+
}
|
|
565
|
+
ensureChunkRetrievalColumns() {
|
|
566
|
+
const columns = new Set(this.requireDb()
|
|
567
|
+
.prepare('PRAGMA table_info(rdf_text_chunks)')
|
|
568
|
+
.all()
|
|
569
|
+
.map((column) => column.name));
|
|
570
|
+
if (!columns.has('retrieval_kind')) {
|
|
571
|
+
this.requireDb().exec("ALTER TABLE rdf_text_chunks ADD COLUMN retrieval_kind TEXT NOT NULL DEFAULT 'file-chunk';");
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
ensureEntityProvenanceColumns() {
|
|
575
|
+
const columns = new Set(this.requireDb()
|
|
576
|
+
.prepare('PRAGMA table_info(rdf_text_entities)')
|
|
577
|
+
.all()
|
|
578
|
+
.map((column) => column.name));
|
|
579
|
+
for (const [name, type] of [
|
|
580
|
+
['value', 'TEXT'],
|
|
581
|
+
['datatype', 'TEXT'],
|
|
582
|
+
['language', 'TEXT'],
|
|
583
|
+
['policy_role', 'TEXT'],
|
|
584
|
+
]) {
|
|
585
|
+
if (!columns.has(name)) {
|
|
586
|
+
this.requireDb().exec(`ALTER TABLE rdf_text_entities ADD COLUMN ${name} ${type};`);
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
}
|
|
267
590
|
backfillTermPostings() {
|
|
268
591
|
const db = this.requireDb();
|
|
269
592
|
const rows = db.prepare(`
|
|
@@ -284,6 +607,22 @@ class RdfTextIndex {
|
|
|
284
607
|
updated_at
|
|
285
608
|
)
|
|
286
609
|
VALUES (?, ?, ?, ?, strftime('%Y-%m-%dT%H:%M:%fZ', 'now'))
|
|
610
|
+
`);
|
|
611
|
+
const insertEntity = db.prepare(`
|
|
612
|
+
INSERT INTO rdf_text_entities (
|
|
613
|
+
entity,
|
|
614
|
+
source_id,
|
|
615
|
+
chunk_id,
|
|
616
|
+
predicate,
|
|
617
|
+
label,
|
|
618
|
+
value,
|
|
619
|
+
datatype,
|
|
620
|
+
language,
|
|
621
|
+
policy_role,
|
|
622
|
+
occurrences,
|
|
623
|
+
updated_at
|
|
624
|
+
)
|
|
625
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, strftime('%Y-%m-%dT%H:%M:%fZ', 'now'))
|
|
287
626
|
`);
|
|
288
627
|
db.transaction(() => {
|
|
289
628
|
for (const row of rows) {
|
|
@@ -295,6 +634,7 @@ class RdfTextIndex {
|
|
|
295
634
|
const db = this.requireDb();
|
|
296
635
|
db.prepare(`
|
|
297
636
|
INSERT INTO rdf_text_sources (
|
|
637
|
+
source_key,
|
|
298
638
|
source,
|
|
299
639
|
workspace,
|
|
300
640
|
local_path,
|
|
@@ -303,16 +643,17 @@ class RdfTextIndex {
|
|
|
303
643
|
source_hash,
|
|
304
644
|
updated_at
|
|
305
645
|
)
|
|
306
|
-
VALUES (?, ?, ?, ?, ?, ?, strftime('%Y-%m-%dT%H:%M:%fZ', 'now'))
|
|
646
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, strftime('%Y-%m-%dT%H:%M:%fZ', 'now'))
|
|
307
647
|
ON CONFLICT (source)
|
|
308
648
|
DO UPDATE SET
|
|
649
|
+
source_key = excluded.source_key,
|
|
309
650
|
workspace = excluded.workspace,
|
|
310
651
|
local_path = excluded.local_path,
|
|
311
652
|
content_type = excluded.content_type,
|
|
312
653
|
source_version = excluded.source_version,
|
|
313
654
|
source_hash = excluded.source_hash,
|
|
314
655
|
updated_at = excluded.updated_at
|
|
315
|
-
`).run(source.source, source.workspace, source.localPath ?? null, source.contentType ?? null, source.sourceVersion ?? null, source.sourceHash ?? null);
|
|
656
|
+
`).run(source.sourceKey ?? source.source, source.source, source.workspace, source.localPath ?? null, source.contentType ?? null, source.sourceVersion ?? null, source.sourceHash ?? null);
|
|
316
657
|
const row = db.prepare('SELECT * FROM rdf_text_sources WHERE source = ?').get(source.source);
|
|
317
658
|
if (!row) {
|
|
318
659
|
throw new Error(`Failed to upsert RDF text source: ${source.source}`);
|
|
@@ -320,25 +661,7 @@ class RdfTextIndex {
|
|
|
320
661
|
return row.id;
|
|
321
662
|
}
|
|
322
663
|
chunkText(source, text) {
|
|
323
|
-
|
|
324
|
-
return [];
|
|
325
|
-
}
|
|
326
|
-
if (isMarkdownSource(source)) {
|
|
327
|
-
const chunker = new HeadingChunker_1.HeadingChunker();
|
|
328
|
-
return chunker.flatten(chunker.chunk(text))
|
|
329
|
-
.filter((chunk) => chunk.content.trim().length > 0)
|
|
330
|
-
.map((chunk, index) => ({
|
|
331
|
-
chunkKey: deterministicChunkKey(source.source, index),
|
|
332
|
-
ordinal: index,
|
|
333
|
-
level: chunk.level,
|
|
334
|
-
heading: chunk.heading || undefined,
|
|
335
|
-
path: chunk.path,
|
|
336
|
-
content: chunk.content,
|
|
337
|
-
startOffset: chunk.startOffset,
|
|
338
|
-
endOffset: chunk.endOffset,
|
|
339
|
-
}));
|
|
340
|
-
}
|
|
341
|
-
return chunkPlainText(source.source, text);
|
|
664
|
+
return chunkRdfTextSource(source, text);
|
|
342
665
|
}
|
|
343
666
|
estimateDatabaseBytes() {
|
|
344
667
|
const db = this.requireDb();
|
|
@@ -351,7 +674,7 @@ class RdfTextIndex {
|
|
|
351
674
|
return 0;
|
|
352
675
|
}
|
|
353
676
|
}
|
|
354
|
-
toSearchResult(row, score) {
|
|
677
|
+
toSearchResult(row, normalizedQuery, score, entities) {
|
|
355
678
|
return {
|
|
356
679
|
source: row.source,
|
|
357
680
|
workspace: row.workspace,
|
|
@@ -359,7 +682,10 @@ class RdfTextIndex {
|
|
|
359
682
|
contentType: row.content_type ?? undefined,
|
|
360
683
|
sourceVersion: row.source_version ?? undefined,
|
|
361
684
|
sourceHash: row.source_hash ?? undefined,
|
|
685
|
+
sourceKey: row.source_key ?? row.source,
|
|
362
686
|
chunkKey: row.chunk_key,
|
|
687
|
+
retrievalPointKey: row.chunk_key,
|
|
688
|
+
retrievalKind: normalizeRdfTextRetrievalKind(row.retrieval_kind),
|
|
363
689
|
ordinal: row.ordinal,
|
|
364
690
|
level: row.level,
|
|
365
691
|
heading: row.heading ?? undefined,
|
|
@@ -367,9 +693,61 @@ class RdfTextIndex {
|
|
|
367
693
|
content: row.content,
|
|
368
694
|
startOffset: row.start_offset,
|
|
369
695
|
endOffset: row.end_offset,
|
|
696
|
+
scoreComponents: textScoreComponents(row, normalizedQuery, score),
|
|
370
697
|
score,
|
|
698
|
+
entities,
|
|
371
699
|
};
|
|
372
700
|
}
|
|
701
|
+
entitiesForChunks(chunkIds) {
|
|
702
|
+
const uniqueIds = [...new Set(chunkIds)];
|
|
703
|
+
const mentions = new Map();
|
|
704
|
+
if (uniqueIds.length === 0) {
|
|
705
|
+
return mentions;
|
|
706
|
+
}
|
|
707
|
+
const rows = this.requireDb().prepare(`
|
|
708
|
+
SELECT chunk_id, entity, predicate, label, value, datatype, language, policy_role, occurrences
|
|
709
|
+
FROM rdf_text_entities
|
|
710
|
+
WHERE chunk_id IN (${uniqueIds.map(() => '?').join(', ')})
|
|
711
|
+
ORDER BY chunk_id ASC, entity ASC, predicate ASC, label ASC
|
|
712
|
+
`).all(...uniqueIds);
|
|
713
|
+
for (const row of rows) {
|
|
714
|
+
const chunkId = row.chunk_id;
|
|
715
|
+
if (chunkId === undefined) {
|
|
716
|
+
continue;
|
|
717
|
+
}
|
|
718
|
+
const chunkMentions = mentions.get(chunkId) ?? [];
|
|
719
|
+
chunkMentions.push({
|
|
720
|
+
entity: row.entity,
|
|
721
|
+
predicate: row.predicate ?? undefined,
|
|
722
|
+
label: row.label ?? undefined,
|
|
723
|
+
value: row.value ?? undefined,
|
|
724
|
+
datatype: row.datatype ?? undefined,
|
|
725
|
+
language: row.language ?? undefined,
|
|
726
|
+
policyRole: row.policy_role ?? undefined,
|
|
727
|
+
occurrences: row.occurrences,
|
|
728
|
+
});
|
|
729
|
+
mentions.set(chunkId, chunkMentions);
|
|
730
|
+
}
|
|
731
|
+
return mentions;
|
|
732
|
+
}
|
|
733
|
+
entitiesForChunk(chunkId) {
|
|
734
|
+
const rows = this.requireDb().prepare(`
|
|
735
|
+
SELECT entity, predicate, label, value, datatype, language, policy_role, occurrences
|
|
736
|
+
FROM rdf_text_entities
|
|
737
|
+
WHERE chunk_id = ?
|
|
738
|
+
ORDER BY entity ASC, predicate ASC, label ASC
|
|
739
|
+
`).all(chunkId);
|
|
740
|
+
return rows.map((row) => ({
|
|
741
|
+
entity: row.entity,
|
|
742
|
+
predicate: row.predicate ?? undefined,
|
|
743
|
+
label: row.label ?? undefined,
|
|
744
|
+
value: row.value ?? undefined,
|
|
745
|
+
datatype: row.datatype ?? undefined,
|
|
746
|
+
language: row.language ?? undefined,
|
|
747
|
+
policyRole: row.policy_role ?? undefined,
|
|
748
|
+
occurrences: row.occurrences,
|
|
749
|
+
}));
|
|
750
|
+
}
|
|
373
751
|
requireDb() {
|
|
374
752
|
if (!this.db) {
|
|
375
753
|
throw new Error('RdfTextIndex is not open');
|
|
@@ -378,6 +756,80 @@ class RdfTextIndex {
|
|
|
378
756
|
}
|
|
379
757
|
}
|
|
380
758
|
exports.RdfTextIndex = RdfTextIndex;
|
|
759
|
+
function rdfTextSourceMetadata(row) {
|
|
760
|
+
return {
|
|
761
|
+
sourceKey: row.source_key ?? row.source,
|
|
762
|
+
source: row.source,
|
|
763
|
+
workspace: row.workspace,
|
|
764
|
+
localPath: row.local_path ?? undefined,
|
|
765
|
+
contentType: row.content_type ?? undefined,
|
|
766
|
+
sourceVersion: row.source_version ?? undefined,
|
|
767
|
+
sourceHash: row.source_hash ?? undefined,
|
|
768
|
+
updatedAt: row.updated_at,
|
|
769
|
+
};
|
|
770
|
+
}
|
|
771
|
+
function rdfTextRebuildStatus(row) {
|
|
772
|
+
return {
|
|
773
|
+
source: row.source,
|
|
774
|
+
workspace: row.workspace,
|
|
775
|
+
localPath: row.local_path ?? undefined,
|
|
776
|
+
contentType: row.content_type ?? undefined,
|
|
777
|
+
sourceVersion: row.source_version ?? undefined,
|
|
778
|
+
sourceHash: row.source_hash ?? undefined,
|
|
779
|
+
status: row.status,
|
|
780
|
+
reason: row.reason ?? undefined,
|
|
781
|
+
message: row.message ?? undefined,
|
|
782
|
+
updatedAt: row.updated_at,
|
|
783
|
+
};
|
|
784
|
+
}
|
|
785
|
+
function chunkRdfTextSource(source, text) {
|
|
786
|
+
if (!text) {
|
|
787
|
+
return [];
|
|
788
|
+
}
|
|
789
|
+
if (isFolderSource(source)) {
|
|
790
|
+
return chunkFolderCard(source, text);
|
|
791
|
+
}
|
|
792
|
+
if (isMarkdownSource(source)) {
|
|
793
|
+
const chunker = new HeadingChunker_1.HeadingChunker();
|
|
794
|
+
return chunker.flatten(chunker.chunk(text))
|
|
795
|
+
.filter((chunk) => chunk.content.trim().length > 0)
|
|
796
|
+
.map((chunk, index) => ({
|
|
797
|
+
chunkKey: deterministicChunkKey(source.source, index),
|
|
798
|
+
ordinal: index,
|
|
799
|
+
level: chunk.level,
|
|
800
|
+
heading: chunk.heading || undefined,
|
|
801
|
+
path: chunk.path,
|
|
802
|
+
content: chunk.content,
|
|
803
|
+
startOffset: chunk.startOffset,
|
|
804
|
+
endOffset: chunk.endOffset,
|
|
805
|
+
}));
|
|
806
|
+
}
|
|
807
|
+
return chunkPlainText(source.source, text);
|
|
808
|
+
}
|
|
809
|
+
function isFolderSource(source) {
|
|
810
|
+
const contentType = source.contentType?.split(';', 1)[0]?.trim().toLowerCase();
|
|
811
|
+
return contentType === 'inode/directory' ||
|
|
812
|
+
source.localPath?.endsWith('/') === true ||
|
|
813
|
+
source.source.endsWith('/');
|
|
814
|
+
}
|
|
815
|
+
function chunkFolderCard(source, text) {
|
|
816
|
+
const content = text.trim();
|
|
817
|
+
if (!content) {
|
|
818
|
+
return [];
|
|
819
|
+
}
|
|
820
|
+
const path = folderPathParts(source.localPath ?? source.source);
|
|
821
|
+
return [{
|
|
822
|
+
chunkKey: deterministicChunkKey(source.source, 0),
|
|
823
|
+
retrievalKind: 'folder-card',
|
|
824
|
+
ordinal: 0,
|
|
825
|
+
level: 0,
|
|
826
|
+
heading: path[path.length - 1],
|
|
827
|
+
path,
|
|
828
|
+
content,
|
|
829
|
+
startOffset: 0,
|
|
830
|
+
endOffset: text.length,
|
|
831
|
+
}];
|
|
832
|
+
}
|
|
381
833
|
function isMarkdownSource(source) {
|
|
382
834
|
const contentType = source.contentType?.split(';', 1)[0]?.trim().toLowerCase();
|
|
383
835
|
if (contentType === 'text/markdown' || contentType === 'text/x-markdown') {
|
|
@@ -386,6 +838,18 @@ function isMarkdownSource(source) {
|
|
|
386
838
|
const path = source.localPath ?? source.source;
|
|
387
839
|
return ['.md', '.markdown', '.mdown'].includes((0, node_path_1.extname)(path).toLowerCase());
|
|
388
840
|
}
|
|
841
|
+
function folderPathParts(value) {
|
|
842
|
+
const path = value.includes('://') ? safeUrlPathname(value) : value;
|
|
843
|
+
return path.split('/').map((part) => part.trim()).filter(Boolean);
|
|
844
|
+
}
|
|
845
|
+
function safeUrlPathname(value) {
|
|
846
|
+
try {
|
|
847
|
+
return new URL(value).pathname;
|
|
848
|
+
}
|
|
849
|
+
catch {
|
|
850
|
+
return value;
|
|
851
|
+
}
|
|
852
|
+
}
|
|
389
853
|
function chunkPlainText(source, text) {
|
|
390
854
|
const chunks = [];
|
|
391
855
|
const paragraphPattern = /[^\S\r\n]*(?:\r?\n){2,}[^\S\r\n]*/g;
|
|
@@ -432,7 +896,7 @@ function pushPlainChunk(chunks, source, ordinal, text, start, end) {
|
|
|
432
896
|
});
|
|
433
897
|
return ordinal + 1;
|
|
434
898
|
}
|
|
435
|
-
function
|
|
899
|
+
function deterministicRdfTextChunkKey(source, ordinal) {
|
|
436
900
|
return (0, node_crypto_1.createHash)('sha256')
|
|
437
901
|
.update(source)
|
|
438
902
|
.update('\0')
|
|
@@ -440,36 +904,110 @@ function deterministicChunkKey(source, ordinal) {
|
|
|
440
904
|
.digest('hex')
|
|
441
905
|
.slice(0, 24);
|
|
442
906
|
}
|
|
443
|
-
|
|
907
|
+
const deterministicChunkKey = deterministicRdfTextChunkKey;
|
|
908
|
+
function rdfTextSha256(value) {
|
|
444
909
|
return (0, node_crypto_1.createHash)('sha256').update(value).digest('hex');
|
|
445
910
|
}
|
|
446
|
-
|
|
447
|
-
|
|
911
|
+
const sha256 = rdfTextSha256;
|
|
912
|
+
function textScoreComponents(row, normalizedQuery, score) {
|
|
913
|
+
if (!normalizedQuery) {
|
|
914
|
+
return {
|
|
915
|
+
sourceType: 'text',
|
|
916
|
+
algorithm: 'occurrence-heading-boost',
|
|
917
|
+
normalizedQuery,
|
|
918
|
+
occurrenceScore: 1,
|
|
919
|
+
headingBoost: 0,
|
|
920
|
+
score,
|
|
921
|
+
};
|
|
922
|
+
}
|
|
923
|
+
const occurrenceScore = occurrenceCount(row.normalized_text, normalizedQuery);
|
|
924
|
+
const headingBoost = normalizeText(row.heading ?? '').includes(normalizedQuery) ? 100 : 0;
|
|
925
|
+
return {
|
|
926
|
+
sourceType: 'text',
|
|
927
|
+
algorithm: 'occurrence-heading-boost',
|
|
928
|
+
normalizedQuery,
|
|
929
|
+
occurrenceScore,
|
|
930
|
+
headingBoost,
|
|
931
|
+
score,
|
|
932
|
+
};
|
|
933
|
+
}
|
|
934
|
+
function normalizeRdfText(value) {
|
|
935
|
+
return value.normalize('NFKC').toLowerCase().replace(/\s+/g, ' ').trim();
|
|
448
936
|
}
|
|
449
|
-
|
|
937
|
+
const normalizeText = normalizeRdfText;
|
|
938
|
+
function normalizedRdfTextTokenCount(value) {
|
|
450
939
|
return tokenizeNormalizedText(value).length;
|
|
451
940
|
}
|
|
452
|
-
|
|
453
|
-
|
|
941
|
+
const tokenCountNormalized = normalizedRdfTextTokenCount;
|
|
942
|
+
function tokenizeNormalizedRdfText(value) {
|
|
943
|
+
const terms = [];
|
|
944
|
+
let word = '';
|
|
945
|
+
let cjk = '';
|
|
946
|
+
const flushWord = () => {
|
|
947
|
+
if (word) {
|
|
948
|
+
terms.push(word);
|
|
949
|
+
word = '';
|
|
950
|
+
}
|
|
951
|
+
};
|
|
952
|
+
const flushCjk = () => {
|
|
953
|
+
if (!cjk) {
|
|
954
|
+
return;
|
|
955
|
+
}
|
|
956
|
+
const chars = Array.from(cjk);
|
|
957
|
+
if (chars.length === 1) {
|
|
958
|
+
terms.push(chars[0]);
|
|
959
|
+
}
|
|
960
|
+
else {
|
|
961
|
+
for (let index = 0; index < chars.length - 1; index += 1) {
|
|
962
|
+
terms.push(`${chars[index]}${chars[index + 1]}`);
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
cjk = '';
|
|
966
|
+
};
|
|
967
|
+
for (const char of Array.from(value)) {
|
|
968
|
+
if (isCjkTextChar(char)) {
|
|
969
|
+
flushWord();
|
|
970
|
+
cjk += char;
|
|
971
|
+
continue;
|
|
972
|
+
}
|
|
973
|
+
if (isRdfTextTokenChar(char)) {
|
|
974
|
+
flushCjk();
|
|
975
|
+
word += char;
|
|
976
|
+
continue;
|
|
977
|
+
}
|
|
978
|
+
flushWord();
|
|
979
|
+
flushCjk();
|
|
980
|
+
}
|
|
981
|
+
flushWord();
|
|
982
|
+
flushCjk();
|
|
983
|
+
return terms.filter(Boolean);
|
|
984
|
+
}
|
|
985
|
+
const tokenizeNormalizedText = tokenizeNormalizedRdfText;
|
|
986
|
+
function isCjkTextChar(char) {
|
|
987
|
+
return /\p{Script=Han}|\p{Script=Hiragana}|\p{Script=Katakana}|\p{Script=Hangul}/u.test(char);
|
|
988
|
+
}
|
|
989
|
+
function isRdfTextTokenChar(char) {
|
|
990
|
+
return /[\p{Letter}\p{Mark}\p{Number}]/u.test(char);
|
|
454
991
|
}
|
|
455
992
|
function insertTermOccurrences(insertTerm, sourceId, chunkId, normalizedText) {
|
|
456
993
|
for (const [term, occurrences] of termOccurrences(normalizedText)) {
|
|
457
|
-
if (term.length > RDF_TEXT_TERM_MAX_INDEX_LENGTH) {
|
|
994
|
+
if (term.length > exports.RDF_TEXT_TERM_MAX_INDEX_LENGTH) {
|
|
458
995
|
continue;
|
|
459
996
|
}
|
|
460
997
|
insertTerm.run(term, sourceId, chunkId, occurrences);
|
|
461
998
|
}
|
|
462
999
|
}
|
|
463
|
-
function
|
|
1000
|
+
function rdfTextTermOccurrences(normalizedText) {
|
|
464
1001
|
const terms = new Map();
|
|
465
1002
|
for (const term of tokenizeNormalizedText(normalizedText)) {
|
|
466
1003
|
terms.set(term, (terms.get(term) ?? 0) + 1);
|
|
467
1004
|
}
|
|
468
1005
|
return terms;
|
|
469
1006
|
}
|
|
1007
|
+
const termOccurrences = rdfTextTermOccurrences;
|
|
470
1008
|
function buildTextSearchPredicate(query) {
|
|
471
1009
|
const terms = [...new Set(tokenizeNormalizedText(query))]
|
|
472
|
-
.filter((term) => term.length <= RDF_TEXT_TERM_MAX_INDEX_LENGTH);
|
|
1010
|
+
.filter((term) => term.length <= exports.RDF_TEXT_TERM_MAX_INDEX_LENGTH);
|
|
473
1011
|
const phraseCondition = "chunk.normalized_text LIKE ? ESCAPE '\\'";
|
|
474
1012
|
const phrasePattern = `%${escapeLikePattern(query)}%`;
|
|
475
1013
|
if (terms.length === 0) {
|
|
@@ -487,7 +1025,7 @@ function buildTextSearchPredicate(query) {
|
|
|
487
1025
|
${terms.map(() => `
|
|
488
1026
|
SELECT term.chunk_id, ? AS query_term
|
|
489
1027
|
FROM rdf_text_terms term
|
|
490
|
-
WHERE term.term
|
|
1028
|
+
WHERE term.term = ?
|
|
491
1029
|
`).join(' UNION ALL ')}
|
|
492
1030
|
) candidate
|
|
493
1031
|
GROUP BY candidate.chunk_id
|
|
@@ -496,14 +1034,14 @@ function buildTextSearchPredicate(query) {
|
|
|
496
1034
|
AND ${phraseCondition}
|
|
497
1035
|
`,
|
|
498
1036
|
params: [
|
|
499
|
-
...terms.flatMap((term) => [term,
|
|
1037
|
+
...terms.flatMap((term) => [term, term]),
|
|
500
1038
|
terms.length,
|
|
501
1039
|
phrasePattern,
|
|
502
1040
|
],
|
|
503
1041
|
indexChoice: 'text-term-posting',
|
|
504
1042
|
};
|
|
505
1043
|
}
|
|
506
|
-
function
|
|
1044
|
+
function rdfTextOccurrenceCount(haystack, needle) {
|
|
507
1045
|
if (!needle) {
|
|
508
1046
|
return 0;
|
|
509
1047
|
}
|
|
@@ -519,7 +1057,8 @@ function occurrenceCount(haystack, needle) {
|
|
|
519
1057
|
}
|
|
520
1058
|
return count;
|
|
521
1059
|
}
|
|
522
|
-
|
|
1060
|
+
const occurrenceCount = rdfTextOccurrenceCount;
|
|
1061
|
+
function applyRdfTextResultWindow(rows, offset, limit) {
|
|
523
1062
|
const start = Math.max(0, offset ?? 0);
|
|
524
1063
|
if (rows <= start) {
|
|
525
1064
|
return 0;
|
|
@@ -527,7 +1066,8 @@ function applyResultWindow(rows, offset, limit) {
|
|
|
527
1066
|
const remaining = rows - start;
|
|
528
1067
|
return limit === undefined ? remaining : Math.min(remaining, Math.max(0, limit));
|
|
529
1068
|
}
|
|
530
|
-
|
|
1069
|
+
const applyResultWindow = applyRdfTextResultWindow;
|
|
1070
|
+
function compareRdfTextSearchHits(left, right, orderBy) {
|
|
531
1071
|
const order = orderBy?.length ? orderBy : [{ field: 'score', direction: 'desc' }];
|
|
532
1072
|
for (const entry of order) {
|
|
533
1073
|
const direction = entry.direction === 'desc' ? -1 : 1;
|
|
@@ -538,6 +1078,71 @@ function compareTextSearchHits(left, right, orderBy) {
|
|
|
538
1078
|
}
|
|
539
1079
|
return left.row.source_id - right.row.source_id || left.row.ordinal - right.row.ordinal;
|
|
540
1080
|
}
|
|
1081
|
+
const compareTextSearchHits = compareRdfTextSearchHits;
|
|
1082
|
+
function sqliteTextSearchOrderBy(orderBy) {
|
|
1083
|
+
const order = orderBy?.length ? orderBy : [{ field: 'score', direction: 'desc' }];
|
|
1084
|
+
return order.map((entry) => `${sqliteTextSearchOrderField(entry.field)} ${entry.direction === 'desc' ? 'DESC' : 'ASC'}`).join(', ');
|
|
1085
|
+
}
|
|
1086
|
+
function sqliteTextSearchOrderField(field) {
|
|
1087
|
+
switch (field) {
|
|
1088
|
+
case 'score':
|
|
1089
|
+
return 'score';
|
|
1090
|
+
case 'source':
|
|
1091
|
+
return 'source.source';
|
|
1092
|
+
case 'localPath':
|
|
1093
|
+
return 'COALESCE(source.local_path, \'\')';
|
|
1094
|
+
case 'ordinal':
|
|
1095
|
+
return 'chunk.ordinal';
|
|
1096
|
+
case 'startOffset':
|
|
1097
|
+
return 'chunk.start_offset';
|
|
1098
|
+
case 'endOffset':
|
|
1099
|
+
return 'chunk.end_offset';
|
|
1100
|
+
default: {
|
|
1101
|
+
const exhaustive = field;
|
|
1102
|
+
throw new Error(`Unsupported RDF text search order field: ${exhaustive}`);
|
|
1103
|
+
}
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
function sqliteTextSearchResultOrderBy(orderBy) {
|
|
1107
|
+
const order = orderBy?.length ? orderBy : [{ field: 'score', direction: 'desc' }];
|
|
1108
|
+
return order.map((entry) => `${sqliteTextSearchResultOrderField(entry.field)} ${entry.direction === 'desc' ? 'DESC' : 'ASC'}`).join(', ');
|
|
1109
|
+
}
|
|
1110
|
+
function sqliteTextSearchResultOrderField(field) {
|
|
1111
|
+
switch (field) {
|
|
1112
|
+
case 'score':
|
|
1113
|
+
return 'score';
|
|
1114
|
+
case 'source':
|
|
1115
|
+
return 'source';
|
|
1116
|
+
case 'localPath':
|
|
1117
|
+
return 'COALESCE(local_path, \'\')';
|
|
1118
|
+
case 'ordinal':
|
|
1119
|
+
return 'ordinal';
|
|
1120
|
+
case 'startOffset':
|
|
1121
|
+
return 'start_offset';
|
|
1122
|
+
case 'endOffset':
|
|
1123
|
+
return 'end_offset';
|
|
1124
|
+
default: {
|
|
1125
|
+
const exhaustive = field;
|
|
1126
|
+
throw new Error(`Unsupported RDF text search order field: ${exhaustive}`);
|
|
1127
|
+
}
|
|
1128
|
+
}
|
|
1129
|
+
}
|
|
1130
|
+
function sqliteTextSearchWindow(options) {
|
|
1131
|
+
const offset = Math.max(0, options.offset ?? 0);
|
|
1132
|
+
if (options.limit === undefined) {
|
|
1133
|
+
return offset > 0 ? { sql: 'LIMIT -1 OFFSET ?', params: [offset] } : { sql: '', params: [] };
|
|
1134
|
+
}
|
|
1135
|
+
return {
|
|
1136
|
+
sql: 'LIMIT ? OFFSET ?',
|
|
1137
|
+
params: [Math.max(0, options.limit), offset],
|
|
1138
|
+
};
|
|
1139
|
+
}
|
|
1140
|
+
function normalizeRdfTextPerSourceLimit(limit) {
|
|
1141
|
+
if (limit === undefined || !Number.isFinite(limit)) {
|
|
1142
|
+
return undefined;
|
|
1143
|
+
}
|
|
1144
|
+
return Math.max(0, Math.trunc(limit));
|
|
1145
|
+
}
|
|
541
1146
|
function compareTextSearchField(left, right, field) {
|
|
542
1147
|
switch (field) {
|
|
543
1148
|
case 'score':
|
|
@@ -558,10 +1163,11 @@ function compareTextSearchField(left, right, field) {
|
|
|
558
1163
|
}
|
|
559
1164
|
}
|
|
560
1165
|
}
|
|
561
|
-
function
|
|
1166
|
+
function escapeRdfTextLikePattern(value) {
|
|
562
1167
|
return value.replace(/[\\%_]/g, (match) => `\\${match}`);
|
|
563
1168
|
}
|
|
564
|
-
|
|
1169
|
+
const escapeLikePattern = escapeRdfTextLikePattern;
|
|
1170
|
+
function parseRdfTextPath(value) {
|
|
565
1171
|
if (!value) {
|
|
566
1172
|
return [];
|
|
567
1173
|
}
|
|
@@ -573,4 +1179,94 @@ function parsePath(value) {
|
|
|
573
1179
|
return [];
|
|
574
1180
|
}
|
|
575
1181
|
}
|
|
1182
|
+
const parsePath = parseRdfTextPath;
|
|
1183
|
+
function normalizeRdfTextRetrievalKind(value) {
|
|
1184
|
+
switch (value) {
|
|
1185
|
+
case 'entity-card':
|
|
1186
|
+
case 'field-chunk':
|
|
1187
|
+
case 'folder-card':
|
|
1188
|
+
case 'file-chunk':
|
|
1189
|
+
return value;
|
|
1190
|
+
default:
|
|
1191
|
+
return 'file-chunk';
|
|
1192
|
+
}
|
|
1193
|
+
}
|
|
1194
|
+
function rdfTextIndexBudgetSkip(maxSourceBytes, text) {
|
|
1195
|
+
if (maxSourceBytes === undefined || !Number.isFinite(maxSourceBytes)) {
|
|
1196
|
+
return undefined;
|
|
1197
|
+
}
|
|
1198
|
+
const maxBytes = Math.max(0, Math.trunc(maxSourceBytes));
|
|
1199
|
+
const sourceBytes = Buffer.byteLength(text);
|
|
1200
|
+
if (sourceBytes <= maxBytes) {
|
|
1201
|
+
return undefined;
|
|
1202
|
+
}
|
|
1203
|
+
return {
|
|
1204
|
+
reason: 'maxSourceBytes',
|
|
1205
|
+
message: `source text is ${sourceBytes} bytes; maxSourceBytes is ${maxBytes}`,
|
|
1206
|
+
};
|
|
1207
|
+
}
|
|
1208
|
+
function rdfTextIndexChunkCap(maxChunksPerSource, chunks) {
|
|
1209
|
+
if (maxChunksPerSource === undefined || !Number.isFinite(maxChunksPerSource)) {
|
|
1210
|
+
return { chunks };
|
|
1211
|
+
}
|
|
1212
|
+
const maxChunks = Math.max(0, Math.trunc(maxChunksPerSource));
|
|
1213
|
+
if (chunks.length <= maxChunks) {
|
|
1214
|
+
return { chunks };
|
|
1215
|
+
}
|
|
1216
|
+
return {
|
|
1217
|
+
chunks: chunks.slice(0, maxChunks),
|
|
1218
|
+
capped: {
|
|
1219
|
+
reason: 'maxChunksPerSource',
|
|
1220
|
+
message: `source produced ${chunks.length} chunks; maxChunksPerSource is ${maxChunks}`,
|
|
1221
|
+
},
|
|
1222
|
+
};
|
|
1223
|
+
}
|
|
1224
|
+
function appendEntitySearchFilter(entities, conditions, params) {
|
|
1225
|
+
if (entities.length === 0) {
|
|
1226
|
+
return;
|
|
1227
|
+
}
|
|
1228
|
+
conditions.push(`
|
|
1229
|
+
chunk.id IN (
|
|
1230
|
+
SELECT entity.chunk_id
|
|
1231
|
+
FROM rdf_text_entities entity
|
|
1232
|
+
WHERE entity.entity IN (${entities.map(() => '?').join(', ')})
|
|
1233
|
+
GROUP BY entity.chunk_id
|
|
1234
|
+
HAVING COUNT(DISTINCT entity.entity) = ?
|
|
1235
|
+
)
|
|
1236
|
+
`);
|
|
1237
|
+
params.push(...entities, entities.length);
|
|
1238
|
+
}
|
|
1239
|
+
function insertEntityMentions(insertEntity, sourceId, chunkId, entities) {
|
|
1240
|
+
for (const entity of normalizeEntityMentions(entities)) {
|
|
1241
|
+
insertEntity.run(entity.entity, sourceId, chunkId, entity.predicate ?? null, entity.label ?? null, entity.value ?? null, entity.datatype ?? null, entity.language ?? null, entity.policyRole ?? null, entity.occurrences);
|
|
1242
|
+
}
|
|
1243
|
+
}
|
|
1244
|
+
function normalizeEntityFilter(entities) {
|
|
1245
|
+
return [...new Set((entities ?? []).map((entity) => entity.trim()).filter(Boolean))].sort();
|
|
1246
|
+
}
|
|
1247
|
+
function normalizeEntityMentions(entities) {
|
|
1248
|
+
const mentions = new Map();
|
|
1249
|
+
for (const entity of entities ?? []) {
|
|
1250
|
+
const iri = entity.entity.trim();
|
|
1251
|
+
if (!iri) {
|
|
1252
|
+
continue;
|
|
1253
|
+
}
|
|
1254
|
+
const predicate = entity.predicate?.trim() || undefined;
|
|
1255
|
+
const label = entity.label?.trim() || undefined;
|
|
1256
|
+
const value = entity.value;
|
|
1257
|
+
const datatype = entity.datatype?.trim() || undefined;
|
|
1258
|
+
const language = entity.language?.trim() || undefined;
|
|
1259
|
+
const policyRole = entity.policyRole?.trim() || undefined;
|
|
1260
|
+
const key = JSON.stringify([iri, predicate ?? '', label ?? '', value ?? '', datatype ?? '', language ?? '', policyRole ?? '']);
|
|
1261
|
+
const existing = mentions.get(key);
|
|
1262
|
+
const occurrences = Math.max(1, Math.trunc(entity.occurrences ?? 1));
|
|
1263
|
+
if (existing) {
|
|
1264
|
+
existing.occurrences += occurrences;
|
|
1265
|
+
}
|
|
1266
|
+
else {
|
|
1267
|
+
mentions.set(key, { entity: iri, predicate, label, value, datatype, language, policyRole, occurrences });
|
|
1268
|
+
}
|
|
1269
|
+
}
|
|
1270
|
+
return [...mentions.values()].sort((left, right) => left.entity.localeCompare(right.entity) || (left.predicate ?? '').localeCompare(right.predicate ?? '') || (left.label ?? '').localeCompare(right.label ?? ''));
|
|
1271
|
+
}
|
|
576
1272
|
//# sourceMappingURL=RdfTextIndex.js.map
|