@undefineds.co/xpod 0.3.58 → 0.3.62
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/config/cli.json +88 -0
- package/config/cloud.json +32 -1
- package/config/components-ignore.json +3 -0
- package/config/extensions.local.initializer.json +44 -0
- package/config/resolver.json +86 -0
- package/config/xpod.base.json +4 -0
- package/dist/agents/AgentExecutorFactory.d.ts +3 -3
- package/dist/agents/AgentExecutorFactory.js +28 -15
- package/dist/agents/AgentExecutorFactory.js.map +1 -1
- package/dist/agents/BaseAgentExecutor.d.ts +2 -1
- package/dist/agents/BaseAgentExecutor.js +1 -0
- package/dist/agents/BaseAgentExecutor.js.map +1 -1
- package/dist/agents/ClaudeExecutor.d.ts +3 -1
- package/dist/agents/ClaudeExecutor.js +18 -12
- package/dist/agents/ClaudeExecutor.js.map +1 -1
- package/dist/agents/config/resolve.js +0 -21
- package/dist/agents/config/resolve.js.map +1 -1
- package/dist/agents/config/types.d.ts +2 -7
- package/dist/agents/config/types.js +2 -1
- package/dist/agents/config/types.js.map +1 -1
- package/dist/agents/types.d.ts +18 -0
- package/dist/agents/types.js.map +1 -1
- package/dist/ai/schema/types.d.ts +2 -1
- package/dist/ai/schema/types.js +1 -0
- package/dist/ai/schema/types.js.map +1 -1
- package/dist/ai/service/CredentialReader.d.ts +3 -1
- package/dist/ai/service/CredentialReader.js.map +1 -1
- package/dist/ai/service/CredentialReaderImpl.d.ts +3 -1
- package/dist/ai/service/CredentialReaderImpl.js +24 -2
- package/dist/ai/service/CredentialReaderImpl.js.map +1 -1
- package/dist/ai/service/EmbeddingServiceImpl.js +13 -2
- package/dist/ai/service/EmbeddingServiceImpl.js.map +1 -1
- package/dist/ai/service/ProviderRegistry.d.ts +4 -0
- package/dist/ai/service/ProviderRegistry.js.map +1 -1
- package/dist/ai/service/ProviderRegistry.jsonld +4 -0
- package/dist/ai/service/ProviderRegistryImpl.d.ts +4 -1
- package/dist/ai/service/ProviderRegistryImpl.js +26 -4
- package/dist/ai/service/ProviderRegistryImpl.js.map +1 -1
- package/dist/ai/service/ProviderRegistryImpl.jsonld +12 -0
- package/dist/ai/service/defaultEmbeddingProfile.d.ts +5 -0
- package/dist/ai/service/defaultEmbeddingProfile.js +31 -0
- package/dist/ai/service/defaultEmbeddingProfile.js.map +1 -0
- package/dist/ai/service/index.d.ts +1 -0
- package/dist/ai/service/index.js +1 -0
- package/dist/ai/service/index.js.map +1 -1
- package/dist/ai/service/types.d.ts +1 -0
- package/dist/ai/service/types.js.map +1 -1
- package/dist/api/ApiServer.js +17 -2
- package/dist/api/ApiServer.js.map +1 -1
- package/dist/api/ai-gateway/AiGatewayService.d.ts +106 -0
- package/dist/api/ai-gateway/AiGatewayService.js +527 -0
- package/dist/api/ai-gateway/AiGatewayService.js.map +1 -0
- package/dist/api/ai-gateway/auth/AiConnectionInvocationKeyIssuer.d.ts +38 -0
- package/dist/api/ai-gateway/auth/AiConnectionInvocationKeyIssuer.js +128 -0
- package/dist/api/ai-gateway/auth/AiConnectionInvocationKeyIssuer.js.map +1 -0
- package/dist/api/ai-gateway/auth/ClientCredentialsInternalPodAccessTokenProvider.d.ts +25 -0
- package/dist/api/ai-gateway/auth/ClientCredentialsInternalPodAccessTokenProvider.js +91 -0
- package/dist/api/ai-gateway/auth/ClientCredentialsInternalPodAccessTokenProvider.js.map +1 -0
- package/dist/api/ai-gateway/auth/GatewayApiKey.d.ts +28 -0
- package/dist/api/ai-gateway/auth/GatewayApiKey.js +162 -0
- package/dist/api/ai-gateway/auth/GatewayApiKey.js.map +1 -0
- package/dist/api/ai-gateway/auth/GatewayApiKeyAuthenticator.d.ts +56 -0
- package/dist/api/ai-gateway/auth/GatewayApiKeyAuthenticator.js +143 -0
- package/dist/api/ai-gateway/auth/GatewayApiKeyAuthenticator.js.map +1 -0
- package/dist/api/ai-gateway/auth/GatewayKeyLocatorCodec.d.ts +26 -0
- package/dist/api/ai-gateway/auth/GatewayKeyLocatorCodec.js +97 -0
- package/dist/api/ai-gateway/auth/GatewayKeyLocatorCodec.js.map +1 -0
- package/dist/api/ai-gateway/auth/GatewayPrincipal.d.ts +20 -0
- package/dist/api/ai-gateway/auth/GatewayPrincipal.js +37 -0
- package/dist/api/ai-gateway/auth/GatewayPrincipal.js.map +1 -0
- package/dist/api/ai-gateway/auth/InvocationTokenCodec.d.ts +41 -0
- package/dist/api/ai-gateway/auth/InvocationTokenCodec.js +221 -0
- package/dist/api/ai-gateway/auth/InvocationTokenCodec.js.map +1 -0
- package/dist/api/ai-gateway/auth/PodGatewayAccessKeyRepository.d.ts +54 -0
- package/dist/api/ai-gateway/auth/PodGatewayAccessKeyRepository.js +152 -0
- package/dist/api/ai-gateway/auth/PodGatewayAccessKeyRepository.js.map +1 -0
- package/dist/api/ai-gateway/connect/index.d.ts +367 -0
- package/dist/api/ai-gateway/connect/index.js +1061 -0
- package/dist/api/ai-gateway/connect/index.js.map +1 -0
- package/dist/api/ai-gateway/credentials/CloudKmsWrapper.d.ts +40 -0
- package/dist/api/ai-gateway/credentials/CloudKmsWrapper.js +59 -0
- package/dist/api/ai-gateway/credentials/CloudKmsWrapper.js.map +1 -0
- package/dist/api/ai-gateway/credentials/CredentialVault.d.ts +14 -0
- package/dist/api/ai-gateway/credentials/CredentialVault.js +11 -0
- package/dist/api/ai-gateway/credentials/CredentialVault.js.map +1 -0
- package/dist/api/ai-gateway/credentials/KeyWrapper.d.ts +27 -0
- package/dist/api/ai-gateway/credentials/KeyWrapper.js +3 -0
- package/dist/api/ai-gateway/credentials/KeyWrapper.js.map +1 -0
- package/dist/api/ai-gateway/credentials/LocalKeychainWrapper.d.ts +27 -0
- package/dist/api/ai-gateway/credentials/LocalKeychainWrapper.js +145 -0
- package/dist/api/ai-gateway/credentials/LocalKeychainWrapper.js.map +1 -0
- package/dist/api/ai-gateway/credentials/SecretCellCredentialVault.d.ts +13 -0
- package/dist/api/ai-gateway/credentials/SecretCellCredentialVault.js +133 -0
- package/dist/api/ai-gateway/credentials/SecretCellCredentialVault.js.map +1 -0
- package/dist/api/ai-gateway/credentials/SecretCellKeyWrapper.d.ts +23 -0
- package/dist/api/ai-gateway/credentials/SecretCellKeyWrapper.js +62 -0
- package/dist/api/ai-gateway/credentials/SecretCellKeyWrapper.js.map +1 -0
- package/dist/api/ai-gateway/credentials/WebCryptoCredentialVault.d.ts +23 -0
- package/dist/api/ai-gateway/credentials/WebCryptoCredentialVault.js +173 -0
- package/dist/api/ai-gateway/credentials/WebCryptoCredentialVault.js.map +1 -0
- package/dist/api/ai-gateway/errors.d.ts +21 -0
- package/dist/api/ai-gateway/errors.js +50 -0
- package/dist/api/ai-gateway/errors.js.map +1 -0
- package/dist/api/ai-gateway/protocol/ChatCompletionsFrontend.d.ts +6 -0
- package/dist/api/ai-gateway/protocol/ChatCompletionsFrontend.js +111 -0
- package/dist/api/ai-gateway/protocol/ChatCompletionsFrontend.js.map +1 -0
- package/dist/api/ai-gateway/protocol/MessagesFrontend.d.ts +6 -0
- package/dist/api/ai-gateway/protocol/MessagesFrontend.js +99 -0
- package/dist/api/ai-gateway/protocol/MessagesFrontend.js.map +1 -0
- package/dist/api/ai-gateway/protocol/ResponsesFrontend.d.ts +6 -0
- package/dist/api/ai-gateway/protocol/ResponsesFrontend.js +232 -0
- package/dist/api/ai-gateway/protocol/ResponsesFrontend.js.map +1 -0
- package/dist/api/ai-gateway/protocol/index.d.ts +3 -0
- package/dist/api/ai-gateway/protocol/index.js +10 -0
- package/dist/api/ai-gateway/protocol/index.js.map +1 -0
- package/dist/api/ai-gateway/providers/AnthropicRuntimeAdapter.d.ts +7 -0
- package/dist/api/ai-gateway/providers/AnthropicRuntimeAdapter.js +37 -0
- package/dist/api/ai-gateway/providers/AnthropicRuntimeAdapter.js.map +1 -0
- package/dist/api/ai-gateway/providers/BailianRuntimeAdapter.d.ts +9 -0
- package/dist/api/ai-gateway/providers/BailianRuntimeAdapter.js +127 -0
- package/dist/api/ai-gateway/providers/BailianRuntimeAdapter.js.map +1 -0
- package/dist/api/ai-gateway/providers/DeepSeekRuntimeAdapter.d.ts +8 -0
- package/dist/api/ai-gateway/providers/DeepSeekRuntimeAdapter.js +47 -0
- package/dist/api/ai-gateway/providers/DeepSeekRuntimeAdapter.js.map +1 -0
- package/dist/api/ai-gateway/providers/KimiRuntimeAdapter.d.ts +8 -0
- package/dist/api/ai-gateway/providers/KimiRuntimeAdapter.js +57 -0
- package/dist/api/ai-gateway/providers/KimiRuntimeAdapter.js.map +1 -0
- package/dist/api/ai-gateway/providers/OpenAiCompatibleRuntimeAdapter.d.ts +1 -0
- package/dist/api/ai-gateway/providers/OpenAiCompatibleRuntimeAdapter.js +6 -0
- package/dist/api/ai-gateway/providers/OpenAiCompatibleRuntimeAdapter.js.map +1 -0
- package/dist/api/ai-gateway/providers/OpenAiRuntimeAdapter.d.ts +13 -0
- package/dist/api/ai-gateway/providers/OpenAiRuntimeAdapter.js +34 -0
- package/dist/api/ai-gateway/providers/OpenAiRuntimeAdapter.js.map +1 -0
- package/dist/api/ai-gateway/providers/ProviderRegistry.d.ts +68 -0
- package/dist/api/ai-gateway/providers/ProviderRegistry.js +288 -0
- package/dist/api/ai-gateway/providers/ProviderRegistry.js.map +1 -0
- package/dist/api/ai-gateway/providers/ProviderRuntimeAdapter.d.ts +88 -0
- package/dist/api/ai-gateway/providers/ProviderRuntimeAdapter.js +645 -0
- package/dist/api/ai-gateway/providers/ProviderRuntimeAdapter.js.map +1 -0
- package/dist/api/ai-gateway/providers/ProviderRuntimeRegistry.d.ts +13 -0
- package/dist/api/ai-gateway/providers/ProviderRuntimeRegistry.js +48 -0
- package/dist/api/ai-gateway/providers/ProviderRuntimeRegistry.js.map +1 -0
- package/dist/api/ai-gateway/providers/index.d.ts +9 -0
- package/dist/api/ai-gateway/providers/index.js +26 -0
- package/dist/api/ai-gateway/providers/index.js.map +1 -0
- package/dist/api/ai-gateway/quota/AnthropicQuotaAdapter.d.ts +5 -0
- package/dist/api/ai-gateway/quota/AnthropicQuotaAdapter.js +21 -0
- package/dist/api/ai-gateway/quota/AnthropicQuotaAdapter.js.map +1 -0
- package/dist/api/ai-gateway/quota/BailianQuotaAdapter.d.ts +5 -0
- package/dist/api/ai-gateway/quota/BailianQuotaAdapter.js +21 -0
- package/dist/api/ai-gateway/quota/BailianQuotaAdapter.js.map +1 -0
- package/dist/api/ai-gateway/quota/DeepSeekQuotaAdapter.d.ts +10 -0
- package/dist/api/ai-gateway/quota/DeepSeekQuotaAdapter.js +83 -0
- package/dist/api/ai-gateway/quota/DeepSeekQuotaAdapter.js.map +1 -0
- package/dist/api/ai-gateway/quota/KimiQuotaAdapter.d.ts +10 -0
- package/dist/api/ai-gateway/quota/KimiQuotaAdapter.js +70 -0
- package/dist/api/ai-gateway/quota/KimiQuotaAdapter.js.map +1 -0
- package/dist/api/ai-gateway/quota/OpenAiQuotaAdapter.d.ts +5 -0
- package/dist/api/ai-gateway/quota/OpenAiQuotaAdapter.js +21 -0
- package/dist/api/ai-gateway/quota/OpenAiQuotaAdapter.js.map +1 -0
- package/dist/api/ai-gateway/quota/ProviderQuotaAdapter.d.ts +214 -0
- package/dist/api/ai-gateway/quota/ProviderQuotaAdapter.js +511 -0
- package/dist/api/ai-gateway/quota/ProviderQuotaAdapter.js.map +1 -0
- package/dist/api/ai-gateway/quota/index.d.ts +6 -0
- package/dist/api/ai-gateway/quota/index.js +23 -0
- package/dist/api/ai-gateway/quota/index.js.map +1 -0
- package/dist/api/ai-gateway/routing/InMemorySessionAffinityStore.d.ts +26 -0
- package/dist/api/ai-gateway/routing/InMemorySessionAffinityStore.js +67 -0
- package/dist/api/ai-gateway/routing/InMemorySessionAffinityStore.js.map +1 -0
- package/dist/api/ai-gateway/routing/ModelRouter.d.ts +84 -0
- package/dist/api/ai-gateway/routing/ModelRouter.js +274 -0
- package/dist/api/ai-gateway/routing/ModelRouter.js.map +1 -0
- package/dist/api/ai-gateway/routing/RedisSessionAffinityStore.d.ts +39 -0
- package/dist/api/ai-gateway/routing/RedisSessionAffinityStore.js +122 -0
- package/dist/api/ai-gateway/routing/RedisSessionAffinityStore.js.map +1 -0
- package/dist/api/ai-gateway/routing/SessionAffinityStore.d.ts +49 -0
- package/dist/api/ai-gateway/routing/SessionAffinityStore.js +66 -0
- package/dist/api/ai-gateway/routing/SessionAffinityStore.js.map +1 -0
- package/dist/api/ai-gateway/service-access/AiConnectionServiceAccess.d.ts +25 -0
- package/dist/api/ai-gateway/service-access/AiConnectionServiceAccess.js +50 -0
- package/dist/api/ai-gateway/service-access/AiConnectionServiceAccess.js.map +1 -0
- package/dist/api/ai-gateway/types.d.ts +112 -0
- package/dist/api/ai-gateway/types.js +305 -0
- package/dist/api/ai-gateway/types.js.map +1 -0
- package/dist/api/auth/AuthContext.d.ts +18 -3
- package/dist/api/auth/AuthContext.js +13 -2
- package/dist/api/auth/AuthContext.js.map +1 -1
- package/dist/api/auth/Authenticator.d.ts +3 -0
- package/dist/api/auth/Authenticator.js.map +1 -1
- package/dist/api/auth/ClientCredentialsAuthenticator.d.ts +2 -6
- package/dist/api/auth/ClientCredentialsAuthenticator.js +12 -30
- package/dist/api/auth/ClientCredentialsAuthenticator.js.map +1 -1
- package/dist/api/auth/SolidTokenAuthenticator.d.ts +2 -0
- package/dist/api/auth/SolidTokenAuthenticator.js +88 -2
- package/dist/api/auth/SolidTokenAuthenticator.js.map +1 -1
- package/dist/api/auth/TokenIdentity.d.ts +6 -0
- package/dist/api/auth/TokenIdentity.js +31 -0
- package/dist/api/auth/TokenIdentity.js.map +1 -0
- package/dist/api/chatkit/ai-provider.d.ts +9 -23
- package/dist/api/chatkit/ai-provider.js +30 -153
- package/dist/api/chatkit/ai-provider.js.map +1 -1
- package/dist/api/chatkit/default-agent.d.ts +24 -15
- package/dist/api/chatkit/default-agent.js +24 -83
- package/dist/api/chatkit/default-agent.js.map +1 -1
- package/dist/api/chatkit/index.d.ts +2 -1
- package/dist/api/chatkit/index.js +3 -1
- package/dist/api/chatkit/index.js.map +1 -1
- package/dist/api/chatkit/pod-store.d.ts +13 -1
- package/dist/api/chatkit/pod-store.js +127 -7
- package/dist/api/chatkit/pod-store.js.map +1 -1
- package/dist/api/chatkit/runtime/AcpAgentRuntime.d.ts +0 -1
- package/dist/api/chatkit/runtime/AcpAgentRuntime.js +14 -51
- package/dist/api/chatkit/runtime/AcpAgentRuntime.js.map +1 -1
- package/dist/api/chatkit/runtime/AcpRunner.js +2 -1
- package/dist/api/chatkit/runtime/AcpRunner.js.map +1 -1
- package/dist/api/chatkit/runtime/CodexRuntimeProjector.d.ts +15 -1
- package/dist/api/chatkit/runtime/CodexRuntimeProjector.js +52 -34
- package/dist/api/chatkit/runtime/CodexRuntimeProjector.js.map +1 -1
- package/dist/api/chatkit/service.d.ts +8 -1
- package/dist/api/chatkit/service.js +46 -5
- package/dist/api/chatkit/service.js.map +1 -1
- package/dist/api/chatkit/store.d.ts +23 -1
- package/dist/api/chatkit/store.js +56 -0
- package/dist/api/chatkit/store.js.map +1 -1
- package/dist/api/chatkit/types.d.ts +1 -0
- package/dist/api/chatkit/types.js.map +1 -1
- package/dist/api/container/common.js +286 -13
- package/dist/api/container/common.js.map +1 -1
- package/dist/api/container/index.js +126 -6
- package/dist/api/container/index.js.map +1 -1
- package/dist/api/container/local.js +50 -6
- package/dist/api/container/local.js.map +1 -1
- package/dist/api/container/rdf.d.ts +15 -0
- package/dist/api/container/rdf.js +90 -0
- package/dist/api/container/rdf.js.map +1 -0
- package/dist/api/container/routes.js +151 -11
- package/dist/api/container/routes.js.map +1 -1
- package/dist/api/container/types.d.ts +96 -0
- package/dist/api/container/types.js.map +1 -1
- package/dist/api/handlers/AdminHandler.d.ts +25 -2
- package/dist/api/handlers/AdminHandler.js +60 -10
- package/dist/api/handlers/AdminHandler.js.map +1 -1
- package/dist/api/handlers/AiClientConfigurationHandler.d.ts +7 -0
- package/dist/api/handlers/AiClientConfigurationHandler.js +202 -0
- package/dist/api/handlers/AiClientConfigurationHandler.js.map +1 -0
- package/dist/api/handlers/AiGatewayHandler.d.ts +23 -0
- package/dist/api/handlers/AiGatewayHandler.js +231 -0
- package/dist/api/handlers/AiGatewayHandler.js.map +1 -0
- package/dist/api/handlers/AiGatewayManagementHandler.d.ts +24 -0
- package/dist/api/handlers/AiGatewayManagementHandler.js +503 -0
- package/dist/api/handlers/AiGatewayManagementHandler.js.map +1 -0
- package/dist/api/handlers/ChatHandler.d.ts +11 -12
- package/dist/api/handlers/ChatHandler.js +12 -219
- package/dist/api/handlers/ChatHandler.js.map +1 -1
- package/dist/api/handlers/DashboardHandler.js +22 -116
- package/dist/api/handlers/DashboardHandler.js.map +1 -1
- package/dist/api/handlers/NetworkSettingsHandler.d.ts +97 -0
- package/dist/api/handlers/NetworkSettingsHandler.js +511 -0
- package/dist/api/handlers/NetworkSettingsHandler.js.map +1 -0
- package/dist/api/handlers/PodSettingsHandler.d.ts +79 -0
- package/dist/api/handlers/PodSettingsHandler.js +162 -0
- package/dist/api/handlers/PodSettingsHandler.js.map +1 -0
- package/dist/api/handlers/ProvisionHandler.d.ts +3 -1
- package/dist/api/handlers/ProvisionHandler.js +22 -87
- package/dist/api/handlers/ProvisionHandler.js.map +1 -1
- package/dist/api/handlers/RdfStatsHandler.d.ts +6 -0
- package/dist/api/handlers/RdfStatsHandler.js +85 -0
- package/dist/api/handlers/RdfStatsHandler.js.map +1 -0
- package/dist/api/handlers/SettingsHandler.d.ts +5 -0
- package/dist/api/handlers/SettingsHandler.js +13 -0
- package/dist/api/handlers/SettingsHandler.js.map +1 -0
- package/dist/api/handlers/StaticSpaHandler.d.ts +8 -0
- package/dist/api/handlers/StaticSpaHandler.js +102 -0
- package/dist/api/handlers/StaticSpaHandler.js.map +1 -0
- package/dist/api/handlers/index.d.ts +1 -0
- package/dist/api/handlers/index.js +1 -0
- package/dist/api/handlers/index.js.map +1 -1
- package/dist/api/http/readBoundedJsonBody.d.ts +14 -0
- package/dist/api/http/readBoundedJsonBody.js +58 -0
- package/dist/api/http/readBoundedJsonBody.js.map +1 -0
- package/dist/api/middleware/AuthMiddleware.d.ts +1 -0
- package/dist/api/middleware/AuthMiddleware.js +33 -4
- package/dist/api/middleware/AuthMiddleware.js.map +1 -1
- package/dist/api/runs/AgentRuntimeTypes.d.ts +18 -3
- package/dist/api/runs/AgentRuntimeTypes.js +61 -0
- package/dist/api/runs/AgentRuntimeTypes.js.map +1 -1
- package/dist/api/runs/InngestRunExecutionBackend.d.ts +28 -3
- package/dist/api/runs/InngestRunExecutionBackend.js +26 -3
- package/dist/api/runs/InngestRunExecutionBackend.js.map +1 -1
- package/dist/api/runs/ManagedRunWorker.d.ts +4 -1
- package/dist/api/runs/ManagedRunWorker.js +39 -8
- package/dist/api/runs/ManagedRunWorker.js.map +1 -1
- package/dist/api/runs/PiAgentRuntimeDriver.d.ts +5 -1
- package/dist/api/runs/PiAgentRuntimeDriver.js +94 -57
- package/dist/api/runs/PiAgentRuntimeDriver.js.map +1 -1
- package/dist/api/runs/RdfRunContextRetriever.d.ts +46 -0
- package/dist/api/runs/RdfRunContextRetriever.js +277 -0
- package/dist/api/runs/RdfRunContextRetriever.js.map +1 -0
- package/dist/api/runs/RunExecutionBackend.d.ts +38 -0
- package/dist/api/runs/RunExecutionBackend.js.map +1 -1
- package/dist/api/runs/RunStateCenter.d.ts +18 -3
- package/dist/api/runs/RunStateCenter.js +85 -24
- package/dist/api/runs/RunStateCenter.js.map +1 -1
- package/dist/api/runtime.js +163 -3
- package/dist/api/runtime.js.map +1 -1
- package/dist/api/service/AiClientConfigurationService.d.ts +97 -0
- package/dist/api/service/AiClientConfigurationService.js +379 -0
- package/dist/api/service/AiClientConfigurationService.js.map +1 -0
- package/dist/api/service/RdfBenchmarkReportCatalog.d.ts +86 -0
- package/dist/api/service/RdfBenchmarkReportCatalog.js +349 -0
- package/dist/api/service/RdfBenchmarkReportCatalog.js.map +1 -0
- package/dist/api/service/RdfBenchmarkReportGate.d.ts +78 -0
- package/dist/api/service/RdfBenchmarkReportGate.js +197 -0
- package/dist/api/service/RdfBenchmarkReportGate.js.map +1 -0
- package/dist/api/service/RdfSearchIndexingService.d.ts +113 -0
- package/dist/api/service/RdfSearchIndexingService.js +272 -0
- package/dist/api/service/RdfSearchIndexingService.js.map +1 -0
- package/dist/api/service/RdfSearchIndexingSolidFsSyncer.d.ts +27 -0
- package/dist/api/service/RdfSearchIndexingSolidFsSyncer.js +90 -0
- package/dist/api/service/RdfSearchIndexingSolidFsSyncer.js.map +1 -0
- package/dist/api/service/RdfStorageStatsService.d.ts +31 -0
- package/dist/api/service/RdfStorageStatsService.js +97 -0
- package/dist/api/service/RdfStorageStatsService.js.map +1 -0
- package/dist/api/service/VectorStoreService.d.ts +2 -0
- package/dist/api/service/VectorStoreService.js +70 -2
- package/dist/api/service/VectorStoreService.js.map +1 -1
- package/dist/api/service/VercelChatService.d.ts +27 -38
- package/dist/api/service/VercelChatService.js +153 -505
- package/dist/api/service/VercelChatService.js.map +1 -1
- package/dist/api/service/provider-http-transport.d.ts +21 -0
- package/dist/api/service/provider-http-transport.js +108 -2
- package/dist/api/service/provider-http-transport.js.map +1 -1
- package/dist/api/service/provider-registry.d.ts +5 -7
- package/dist/api/service/provider-registry.js +81 -64
- package/dist/api/service/provider-registry.js.map +1 -1
- package/dist/api/tasks/InngestTaskScheduler.d.ts +44 -4
- package/dist/api/tasks/TaskMaterializer.d.ts +10 -1
- package/dist/api/tasks/TaskMaterializer.js +39 -4
- package/dist/api/tasks/TaskMaterializer.js.map +1 -1
- package/dist/api/tasks/TaskService.d.ts +5 -1
- package/dist/api/tasks/TaskService.js +3 -0
- package/dist/api/tasks/TaskService.js.map +1 -1
- package/dist/cli/commands/rdf.d.ts +9 -0
- package/dist/cli/commands/rdf.js +66 -1
- package/dist/cli/commands/rdf.js.map +1 -1
- package/dist/cli/commands/start.js +3 -0
- package/dist/cli/commands/start.js.map +1 -1
- package/dist/cli/lib/solid-auth.d.ts +3 -3
- package/dist/cli/lib/solid-auth.js +4 -4
- package/dist/cli/lib/solid-auth.js.map +1 -1
- package/dist/components/components.jsonld +16 -0
- package/dist/components/context.jsonld +815 -28
- package/dist/document/Chunker.jsonld +110 -0
- package/dist/document/{DocumentParser.d.ts → DocumentReader.d.ts} +23 -11
- package/dist/document/{DocumentParser.js → DocumentReader.js} +2 -2
- package/dist/document/DocumentReader.js.map +1 -0
- package/dist/document/DocumentReader.jsonld +82 -0
- package/dist/document/HeadingChunker.jsonld +41 -0
- package/dist/document/{JinaDocumentParser.d.ts → JinaReader.d.ts} +7 -7
- package/dist/document/{JinaDocumentParser.js → JinaReader.js} +12 -12
- package/dist/document/JinaReader.js.map +1 -0
- package/dist/document/JinaReader.jsonld +133 -0
- package/dist/document/L0SourceSummary.d.ts +103 -0
- package/dist/document/L0SourceSummary.js +157 -0
- package/dist/document/L0SourceSummary.js.map +1 -0
- package/dist/document/L0SourceSummary.jsonld +326 -0
- package/dist/document/PaddleOcrReader.d.ts +40 -0
- package/dist/document/PaddleOcrReader.js +53 -0
- package/dist/document/PaddleOcrReader.js.map +1 -0
- package/dist/document/PaddleOcrReader.jsonld +234 -0
- package/dist/document/ReaderAiConfig.d.ts +50 -0
- package/dist/document/ReaderAiConfig.js +109 -0
- package/dist/document/ReaderAiConfig.js.map +1 -0
- package/dist/document/ReaderAiConfig.jsonld +185 -0
- package/dist/document/ReaderPolicy.d.ts +89 -0
- package/dist/document/ReaderPolicy.js +158 -0
- package/dist/document/ReaderPolicy.js.map +1 -0
- package/dist/document/ReaderPolicy.jsonld +218 -0
- package/dist/document/index.d.ts +6 -2
- package/dist/document/index.js +6 -2
- package/dist/document/index.js.map +1 -1
- package/dist/edge/DdnsManager.d.ts +1 -1
- package/dist/edge/DdnsManager.js.map +1 -1
- package/dist/edge/EdgeNodeAgent.d.ts +4 -0
- package/dist/edge/EdgeNodeAgent.js +6 -0
- package/dist/edge/EdgeNodeAgent.js.map +1 -1
- package/dist/edge/EdgeNodeAgent.jsonld +8 -0
- package/dist/edge/EdgeNodeAgentInitializer.d.ts +16 -0
- package/dist/edge/EdgeNodeAgentInitializer.js +51 -0
- package/dist/edge/EdgeNodeAgentInitializer.js.map +1 -1
- package/dist/edge/EdgeNodeAgentInitializer.jsonld +250 -0
- package/dist/edge/EdgeNodeCertificateCapabilityBridge.d.ts +34 -0
- package/dist/edge/EdgeNodeCertificateCapabilityBridge.js +111 -0
- package/dist/edge/EdgeNodeCertificateCapabilityBridge.js.map +1 -0
- package/dist/edge/acme/AcmeCertificateManager.d.ts +14 -1
- package/dist/edge/acme/AcmeCertificateManager.js +67 -7
- package/dist/edge/acme/AcmeCertificateManager.js.map +1 -1
- package/dist/edge/acme/AcmeCertificateManager.jsonld +22 -2
- package/dist/edge/acme/ClusterCertificateManager.d.ts +12 -0
- package/dist/edge/acme/ClusterCertificateManager.js +38 -0
- package/dist/edge/acme/ClusterCertificateManager.js.map +1 -1
- package/dist/extensions/ExtensionRuntime.d.ts +17 -0
- package/dist/extensions/ExtensionRuntime.js +171 -0
- package/dist/extensions/ExtensionRuntime.js.map +1 -0
- package/dist/extensions/PodCredentialResolver.d.ts +23 -0
- package/dist/extensions/PodCredentialResolver.js +139 -0
- package/dist/extensions/PodCredentialResolver.js.map +1 -0
- package/dist/extensions/index.d.ts +3 -0
- package/dist/extensions/index.js +20 -0
- package/dist/extensions/index.js.map +1 -0
- package/dist/extensions/types.d.ts +73 -0
- package/dist/extensions/types.js +3 -0
- package/dist/extensions/types.js.map +1 -0
- package/dist/http/SubgraphSparqlHttpHandler.d.ts +20 -1
- package/dist/http/SubgraphSparqlHttpHandler.js +324 -43
- package/dist/http/SubgraphSparqlHttpHandler.js.map +1 -1
- package/dist/http/SubgraphSparqlHttpHandler.jsonld +87 -0
- package/dist/identity/drizzle/EdgeNodeRepository.js +3 -2
- package/dist/identity/drizzle/EdgeNodeRepository.js.map +1 -1
- package/dist/identity/drizzle/schema.pg.js +1 -1
- package/dist/identity/drizzle/schema.pg.js.map +1 -1
- package/dist/identity/drizzle/schema.sqlite.js +1 -1
- package/dist/identity/drizzle/schema.sqlite.js.map +1 -1
- package/dist/identity/oidc/ScopedPickWebIdHandler.js +5 -5
- package/dist/identity/oidc/ScopedPickWebIdHandler.js.map +1 -1
- package/dist/index.d.ts +12 -2
- package/dist/index.js +13 -1
- package/dist/index.js.map +1 -1
- package/dist/main.js +3 -0
- package/dist/main.js.map +1 -1
- package/dist/provision/LocalProvisionState.d.ts +28 -0
- package/dist/provision/LocalProvisionState.js +124 -0
- package/dist/provision/LocalProvisionState.js.map +1 -0
- package/dist/provision/ProvisionCodeCodec.d.ts +7 -3
- package/dist/provision/ProvisionCodeCodec.js +10 -3
- package/dist/provision/ProvisionCodeCodec.js.map +1 -1
- package/dist/provision/ProvisionPodCreator.d.ts +15 -1
- package/dist/provision/ProvisionPodCreator.js +68 -1
- package/dist/provision/ProvisionPodCreator.js.map +1 -1
- package/dist/provision/ProvisionPodCreator.jsonld +31 -0
- package/dist/provision/ServiceAccessTokenCodec.d.ts +45 -0
- package/dist/provision/ServiceAccessTokenCodec.js +86 -0
- package/dist/provision/ServiceAccessTokenCodec.js.map +1 -0
- package/dist/runtime/GatewayAdminProxyAuth.d.ts +29 -0
- package/dist/runtime/GatewayAdminProxyAuth.js +108 -0
- package/dist/runtime/GatewayAdminProxyAuth.js.map +1 -0
- package/dist/runtime/Proxy.d.ts +10 -0
- package/dist/runtime/Proxy.js +64 -6
- package/dist/runtime/Proxy.js.map +1 -1
- package/dist/runtime/XpodRuntime.js +1 -0
- package/dist/runtime/XpodRuntime.js.map +1 -1
- package/dist/runtime/bootstrap.d.ts +1 -0
- package/dist/runtime/bootstrap.js +29 -0
- package/dist/runtime/bootstrap.js.map +1 -1
- package/dist/runtime/css-process.d.ts +1 -0
- package/dist/runtime/css-process.js +1 -0
- package/dist/runtime/css-process.js.map +1 -1
- package/dist/runtime/index.d.ts +1 -0
- package/dist/runtime/index.js +3 -1
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/lifecycle.d.ts +3 -1
- package/dist/runtime/lifecycle.js +3 -1
- package/dist/runtime/lifecycle.js.map +1 -1
- package/dist/runtime/runner/node/NodeGatewayRuntimeRunner.js +2 -0
- package/dist/runtime/runner/node/NodeGatewayRuntimeRunner.js.map +1 -1
- package/dist/runtime/runner/types.d.ts +3 -0
- package/dist/runtime/runner/types.js.map +1 -1
- package/dist/runtime/runtime-types.d.ts +2 -0
- package/dist/runtime/runtime-types.js.map +1 -1
- package/dist/runtime/safe-env.d.ts +15 -0
- package/dist/runtime/safe-env.js +109 -0
- package/dist/runtime/safe-env.js.map +1 -0
- package/dist/security/index.d.ts +1 -0
- package/dist/security/index.js +18 -0
- package/dist/security/index.js.map +1 -0
- package/dist/security/secret-cell/DeploymentRootKeyProvider.d.ts +17 -0
- package/dist/security/secret-cell/DeploymentRootKeyProvider.js +61 -0
- package/dist/security/secret-cell/DeploymentRootKeyProvider.js.map +1 -0
- package/dist/security/secret-cell/DeploymentRootKeyProvider.jsonld +124 -0
- package/dist/security/secret-cell/SecretCellVault.d.ts +55 -0
- package/dist/security/secret-cell/SecretCellVault.js +242 -0
- package/dist/security/secret-cell/SecretCellVault.js.map +1 -0
- package/dist/security/secret-cell/SecretCellVault.jsonld +207 -0
- package/dist/security/secret-cell/index.d.ts +2 -0
- package/dist/security/secret-cell/index.js +11 -0
- package/dist/security/secret-cell/index.js.map +1 -0
- package/dist/solidfs/CompositeSolidFsSyncer.d.ts +18 -0
- package/dist/solidfs/CompositeSolidFsSyncer.js +32 -0
- package/dist/solidfs/CompositeSolidFsSyncer.js.map +1 -0
- package/dist/solidfs/LocalSolidFS.js +25 -1
- package/dist/solidfs/LocalSolidFS.js.map +1 -1
- package/dist/solidfs/RdfIndexSolidFsSyncer.d.ts +41 -2
- package/dist/solidfs/RdfIndexSolidFsSyncer.js +331 -21
- package/dist/solidfs/RdfIndexSolidFsSyncer.js.map +1 -1
- package/dist/solidfs/SolidFsMetaNotes.d.ts +25 -0
- package/dist/solidfs/SolidFsMetaNotes.js +103 -0
- package/dist/solidfs/SolidFsMetaNotes.js.map +1 -0
- package/dist/solidfs/SolidFsSyncJournal.d.ts +2 -2
- package/dist/solidfs/SolidFsSyncJournal.js +9 -4
- package/dist/solidfs/SolidFsSyncJournal.js.map +1 -1
- package/dist/solidfs/SolidFsSyncJournal.jsonld +119 -0
- package/dist/solidfs/WorkspacePrompt.d.ts +13 -0
- package/dist/solidfs/WorkspacePrompt.js +42 -0
- package/dist/solidfs/WorkspacePrompt.js.map +1 -0
- package/dist/solidfs/index.d.ts +3 -0
- package/dist/solidfs/index.js +3 -0
- package/dist/solidfs/index.js.map +1 -1
- package/dist/solidfs/types.d.ts +12 -2
- package/dist/solidfs/types.js.map +1 -1
- package/dist/storage/accessors/MixDataAccessor.d.ts +36 -4
- package/dist/storage/accessors/MixDataAccessor.js +222 -23
- package/dist/storage/accessors/MixDataAccessor.js.map +1 -1
- package/dist/storage/accessors/MixDataAccessor.jsonld +89 -0
- package/dist/storage/accessors/SolidRdfDataAccessor.d.ts +6 -1
- package/dist/storage/accessors/SolidRdfDataAccessor.js +35 -0
- package/dist/storage/accessors/SolidRdfDataAccessor.js.map +1 -1
- package/dist/storage/accessors/SolidRdfDataAccessor.jsonld +20 -0
- package/dist/storage/database/PostgresPoolManager.d.ts +1 -0
- package/dist/storage/database/PostgresPoolManager.js +2 -2
- package/dist/storage/database/PostgresPoolManager.js.map +1 -1
- package/dist/storage/locking/UrlAwareRedisLocker.d.ts +2 -0
- package/dist/storage/locking/UrlAwareRedisLocker.js +65 -0
- package/dist/storage/locking/UrlAwareRedisLocker.js.map +1 -1
- package/dist/storage/locking/UrlAwareRedisLocker.jsonld +19 -0
- package/dist/storage/rdf/PostgresRdfEngine.d.ts +286 -9
- package/dist/storage/rdf/PostgresRdfEngine.js +10773 -2084
- package/dist/storage/rdf/PostgresRdfEngine.js.map +1 -1
- package/dist/storage/rdf/PostgresRdfEngine.jsonld +1693 -89
- package/dist/storage/rdf/PostgresRdfSqlExecutor.d.ts +24 -0
- package/dist/storage/rdf/PostgresRdfSqlExecutor.js +131 -0
- package/dist/storage/rdf/PostgresRdfSqlExecutor.js.map +1 -0
- package/dist/storage/rdf/PostgresRdfTextIndex.d.ts +54 -0
- package/dist/storage/rdf/PostgresRdfTextIndex.js +1255 -0
- package/dist/storage/rdf/PostgresRdfTextIndex.js.map +1 -0
- package/dist/storage/rdf/PostgresRdfTextIndex.jsonld +487 -0
- package/dist/storage/rdf/PostgresRdfVectorIndex.d.ts +46 -0
- package/dist/storage/rdf/PostgresRdfVectorIndex.js +1165 -0
- package/dist/storage/rdf/PostgresRdfVectorIndex.js.map +1 -0
- package/dist/storage/rdf/PostgresRdfVectorIndex.jsonld +423 -0
- package/dist/storage/rdf/Rdf3xIndex.d.ts +14 -1
- package/dist/storage/rdf/Rdf3xIndex.js +286 -2
- package/dist/storage/rdf/Rdf3xIndex.js.map +1 -1
- package/dist/storage/rdf/Rdf3xIndex.jsonld +36 -0
- package/dist/storage/rdf/Rdf3xSchema.d.ts +5 -1
- package/dist/storage/rdf/Rdf3xSchema.js +17 -3
- package/dist/storage/rdf/Rdf3xSchema.js.map +1 -1
- package/dist/storage/rdf/RdfAccessScope.d.ts +22 -0
- package/dist/storage/rdf/RdfAccessScope.js +345 -0
- package/dist/storage/rdf/RdfAccessScope.js.map +1 -0
- package/dist/storage/rdf/RdfAccessScope.jsonld +45 -0
- package/dist/storage/rdf/RdfFusionRankPlan.d.ts +2 -0
- package/dist/storage/rdf/RdfFusionRankPlan.js +186 -0
- package/dist/storage/rdf/RdfFusionRankPlan.js.map +1 -0
- package/dist/storage/rdf/RdfJoinShape.d.ts +8 -0
- package/dist/storage/rdf/RdfJoinShape.js +31 -0
- package/dist/storage/rdf/RdfJoinShape.js.map +1 -0
- package/dist/storage/rdf/RdfQuadIndex.d.ts +5 -2
- package/dist/storage/rdf/RdfQuadIndex.js +94 -6
- package/dist/storage/rdf/RdfQuadIndex.js.map +1 -1
- package/dist/storage/rdf/RdfQuadIndex.jsonld +12 -0
- package/dist/storage/rdf/RdfQueryExecutor.d.ts +3 -4
- package/dist/storage/rdf/RdfQueryExecutor.js +235 -8
- package/dist/storage/rdf/RdfQueryExecutor.js.map +1 -1
- package/dist/storage/rdf/RdfSearchSourceFilter.d.ts +10 -0
- package/dist/storage/rdf/RdfSearchSourceFilter.js +83 -0
- package/dist/storage/rdf/RdfSearchSourceFilter.js.map +1 -0
- package/dist/storage/rdf/RdfSparqlAdapter.d.ts +27 -1
- package/dist/storage/rdf/RdfSparqlAdapter.js +265 -3
- package/dist/storage/rdf/RdfSparqlAdapter.js.map +1 -1
- package/dist/storage/rdf/RdfSparqlAdapter.jsonld +8 -0
- package/dist/storage/rdf/RdfTermDictionary.d.ts +7 -1
- package/dist/storage/rdf/RdfTermDictionary.js +139 -0
- package/dist/storage/rdf/RdfTermDictionary.js.map +1 -1
- package/dist/storage/rdf/RdfTermDictionary.jsonld +4 -0
- package/dist/storage/rdf/RdfTextIndex.d.ts +45 -2
- package/dist/storage/rdf/RdfTextIndex.js +810 -114
- package/dist/storage/rdf/RdfTextIndex.js.map +1 -1
- package/dist/storage/rdf/RdfTextIndex.jsonld +193 -0
- package/dist/storage/rdf/RdfTextProjection.d.ts +10 -0
- package/dist/storage/rdf/RdfTextProjection.js +258 -0
- package/dist/storage/rdf/RdfTextProjection.js.map +1 -0
- package/dist/storage/rdf/RdfVectorIndex.d.ts +30 -2
- package/dist/storage/rdf/RdfVectorIndex.js +461 -38
- package/dist/storage/rdf/RdfVectorIndex.js.map +1 -1
- package/dist/storage/rdf/RdfVectorIndex.jsonld +163 -0
- package/dist/storage/rdf/SolidRdfEngine.d.ts +12 -9
- package/dist/storage/rdf/SolidRdfEngine.js +48 -22
- package/dist/storage/rdf/SolidRdfEngine.js.map +1 -1
- package/dist/storage/rdf/SolidRdfEngine.jsonld +33 -43
- package/dist/storage/rdf/SolidRdfSparqlEngine.d.ts +19 -8
- package/dist/storage/rdf/SolidRdfSparqlEngine.js +674 -44
- package/dist/storage/rdf/SolidRdfSparqlEngine.js.map +1 -1
- package/dist/storage/rdf/SolidRdfSparqlEngine.jsonld +51 -0
- package/dist/storage/rdf/index.d.ts +9 -5
- package/dist/storage/rdf/index.js +42 -1
- package/dist/storage/rdf/index.js.map +1 -1
- package/dist/storage/rdf/models-benchmark.d.ts +264 -2
- package/dist/storage/rdf/models-benchmark.js +4207 -155
- package/dist/storage/rdf/models-benchmark.js.map +1 -1
- package/dist/storage/rdf/types.d.ts +833 -4
- package/dist/storage/rdf/types.js.map +1 -1
- package/dist/storage/rdf/types.jsonld +348 -0
- package/dist/storage/sparql/CompatibilitySparqlEngine.d.ts +14 -13
- package/dist/storage/sparql/CompatibilitySparqlEngine.js +24 -24
- package/dist/storage/sparql/CompatibilitySparqlEngine.js.map +1 -1
- package/dist/storage/sparql/CompatibilitySparqlEngineImpl.d.ts +14 -13
- package/dist/storage/sparql/CompatibilitySparqlEngineImpl.js +30 -18
- package/dist/storage/sparql/CompatibilitySparqlEngineImpl.js.map +1 -1
- package/dist/storage/sparql/SubgraphQueryEngine.d.ts +21 -12
- package/dist/storage/sparql/SubgraphQueryEngine.js +12 -12
- package/dist/storage/sparql/SubgraphQueryEngine.js.map +1 -1
- package/dist/terminal/sandbox/MacOSSandbox.js +2 -1
- package/dist/terminal/sandbox/MacOSSandbox.js.map +1 -1
- package/dist/terminal/sandbox/index.js +2 -1
- package/dist/terminal/sandbox/index.js.map +1 -1
- package/dist/test-utils/no-auth-xpod.js +3 -0
- package/dist/test-utils/no-auth-xpod.js.map +1 -1
- package/dist/tunnel/LocalTunnelProvider.d.ts +3 -0
- package/dist/tunnel/LocalTunnelProvider.js +17 -1
- package/dist/tunnel/LocalTunnelProvider.js.map +1 -1
- package/dist/tunnel/LocalTunnelProvider.jsonld +23 -0
- package/dist/tunnel/SakuraFrpTunnelProvider.d.ts +3 -0
- package/dist/tunnel/SakuraFrpTunnelProvider.js +18 -2
- package/dist/tunnel/SakuraFrpTunnelProvider.js.map +1 -1
- package/dist/tunnel/TunnelProfiles.d.ts +22 -0
- package/dist/tunnel/TunnelProfiles.js +208 -0
- package/dist/tunnel/TunnelProfiles.js.map +1 -0
- package/dist/tunnel/index.d.ts +2 -0
- package/dist/tunnel/index.js +4 -1
- package/dist/tunnel/index.js.map +1 -1
- package/dist/util/identifiers/ClusterIdentifierStrategy.d.ts +3 -0
- package/dist/util/identifiers/ClusterIdentifierStrategy.js +18 -2
- package/dist/util/identifiers/ClusterIdentifierStrategy.js.map +1 -1
- package/dist/util/identifiers/ClusterIdentifierStrategy.jsonld +5 -1
- package/node_modules/@undefineds.co/ai-connection/dist/AiClientConfigurationSection.d.ts +55 -0
- package/node_modules/@undefineds.co/ai-connection/dist/AiClientConfigurationSection.js +167 -0
- package/node_modules/@undefineds.co/ai-connection/dist/AiConnectionHeader.d.ts +3 -0
- package/node_modules/@undefineds.co/ai-connection/dist/AiConnectionHeader.js +8 -0
- package/node_modules/@undefineds.co/ai-connection/dist/AiConnectionList.d.ts +4 -0
- package/node_modules/@undefineds.co/ai-connection/dist/AiConnectionList.js +36 -0
- package/node_modules/@undefineds.co/ai-connection/dist/AiConnectionMain.d.ts +4 -0
- package/node_modules/@undefineds.co/ai-connection/dist/AiConnectionMain.js +37 -0
- package/node_modules/@undefineds.co/ai-connection/dist/AiConnectionMainHeader.d.ts +3 -0
- package/node_modules/@undefineds.co/ai-connection/dist/AiConnectionMainHeader.js +7 -0
- package/node_modules/@undefineds.co/ai-connection/dist/AiConnectionPanel.d.ts +14 -0
- package/node_modules/@undefineds.co/ai-connection/dist/AiConnectionPanel.js +333 -0
- package/node_modules/@undefineds.co/ai-connection/dist/AiProviderCard.d.ts +22 -0
- package/node_modules/@undefineds.co/ai-connection/dist/AiProviderCard.js +43 -0
- package/node_modules/@undefineds.co/ai-connection/dist/AiQuotaCard.d.ts +8 -0
- package/node_modules/@undefineds.co/ai-connection/dist/AiQuotaCard.js +6 -0
- package/node_modules/@undefineds.co/ai-connection/dist/ai-connection-client.d.ts +120 -0
- package/node_modules/@undefineds.co/ai-connection/dist/ai-connection-client.js +414 -0
- package/node_modules/@undefineds.co/ai-connection/dist/client-config/base-adapter.d.ts +32 -0
- package/node_modules/@undefineds.co/ai-connection/dist/client-config/base-adapter.js +212 -0
- package/node_modules/@undefineds.co/ai-connection/dist/client-config/codex.d.ts +14 -0
- package/node_modules/@undefineds.co/ai-connection/dist/client-config/codex.js +90 -0
- package/node_modules/@undefineds.co/ai-connection/dist/client-config/index.cjs +668 -0
- package/node_modules/@undefineds.co/ai-connection/dist/client-config/index.d.ts +6 -0
- package/node_modules/@undefineds.co/ai-connection/dist/client-config/index.js +6 -0
- package/node_modules/@undefineds.co/ai-connection/dist/client-config/json-env-adapter.d.ts +21 -0
- package/node_modules/@undefineds.co/ai-connection/dist/client-config/json-env-adapter.js +82 -0
- package/node_modules/@undefineds.co/ai-connection/dist/client-config/pi.d.ts +13 -0
- package/node_modules/@undefineds.co/ai-connection/dist/client-config/pi.js +83 -0
- package/node_modules/@undefineds.co/ai-connection/dist/client-config/transaction.d.ts +17 -0
- package/node_modules/@undefineds.co/ai-connection/dist/client-config/transaction.js +153 -0
- package/node_modules/@undefineds.co/ai-connection/dist/client-config/types.d.ts +40 -0
- package/node_modules/@undefineds.co/ai-connection/dist/client-config/types.js +1 -0
- package/node_modules/@undefineds.co/ai-connection/dist/controller.d.ts +42 -0
- package/node_modules/@undefineds.co/ai-connection/dist/controller.js +289 -0
- package/node_modules/@undefineds.co/ai-connection/dist/index.d.ts +16 -0
- package/node_modules/@undefineds.co/ai-connection/dist/index.js +41 -0
- package/node_modules/@undefineds.co/ai-connection/dist/manifest.d.ts +1 -0
- package/node_modules/@undefineds.co/ai-connection/dist/manifest.js +18 -0
- package/node_modules/@undefineds.co/ai-connection/dist/service-access.d.ts +3 -0
- package/node_modules/@undefineds.co/ai-connection/dist/service-access.js +133 -0
- package/node_modules/@undefineds.co/ai-connection/package.json +50 -0
- package/node_modules/@undefineds.co/extension-sdk/README.md +299 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/index.d.ts +5 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/index.js +5 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/layout.d.ts +16 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/layout.js +36 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/manifest.d.ts +27 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/manifest.js +79 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/react/app-layout.d.ts +7 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/react/app-layout.js +8 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/react/auth-boundary.d.ts +27 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/react/auth-boundary.js +49 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/react/layout-context.d.ts +11 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/react/layout-context.js +9 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/react/workspace-layout.d.ts +38 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/react/workspace-layout.js +132 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/react.d.ts +12 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/react.js +19 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/testing.d.ts +7 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/testing.js +27 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/web.d.ts +225 -0
- package/node_modules/@undefineds.co/extension-sdk/dist/web.js +142 -0
- package/node_modules/@undefineds.co/extension-sdk/package.json +49 -0
- package/node_modules/@undefineds.co/extensions/README.md +101 -0
- package/node_modules/@undefineds.co/extensions/dist/adapters/langchain.d.ts +25 -0
- package/node_modules/@undefineds.co/extensions/dist/adapters/langchain.d.ts.map +1 -0
- package/node_modules/@undefineds.co/extensions/dist/adapters/langchain.js +45 -0
- package/node_modules/@undefineds.co/extensions/dist/adapters/langchain.js.map +1 -0
- package/node_modules/@undefineds.co/extensions/dist/adapters/llamaindex.d.ts +31 -0
- package/node_modules/@undefineds.co/extensions/dist/adapters/llamaindex.d.ts.map +1 -0
- package/node_modules/@undefineds.co/extensions/dist/adapters/llamaindex.js +50 -0
- package/node_modules/@undefineds.co/extensions/dist/adapters/llamaindex.js.map +1 -0
- package/node_modules/@undefineds.co/extensions/dist/index.d.ts +7 -0
- package/node_modules/@undefineds.co/extensions/dist/index.d.ts.map +1 -0
- package/node_modules/@undefineds.co/extensions/dist/index.js +7 -0
- package/node_modules/@undefineds.co/extensions/dist/index.js.map +1 -0
- package/node_modules/@undefineds.co/extensions/dist/paddleocr.d.ts +16 -0
- package/node_modules/@undefineds.co/extensions/dist/paddleocr.d.ts.map +1 -0
- package/node_modules/@undefineds.co/extensions/dist/paddleocr.js +267 -0
- package/node_modules/@undefineds.co/extensions/dist/paddleocr.js.map +1 -0
- package/node_modules/@undefineds.co/extensions/dist/reader.d.ts +18 -0
- package/node_modules/@undefineds.co/extensions/dist/reader.d.ts.map +1 -0
- package/node_modules/@undefineds.co/extensions/dist/reader.js +39 -0
- package/node_modules/@undefineds.co/extensions/dist/reader.js.map +1 -0
- package/node_modules/@undefineds.co/extensions/dist/registry.d.ts +16 -0
- package/node_modules/@undefineds.co/extensions/dist/registry.d.ts.map +1 -0
- package/node_modules/@undefineds.co/extensions/dist/registry.js +97 -0
- package/node_modules/@undefineds.co/extensions/dist/registry.js.map +1 -0
- package/node_modules/@undefineds.co/extensions/dist/types.d.ts +141 -0
- package/node_modules/@undefineds.co/extensions/dist/types.d.ts.map +1 -0
- package/node_modules/@undefineds.co/extensions/dist/types.js +2 -0
- package/node_modules/@undefineds.co/extensions/dist/types.js.map +1 -0
- package/node_modules/@undefineds.co/extensions/package.json +38 -0
- package/node_modules/@undefineds.co/shared-ui/dist/badge.d.ts +8 -0
- package/node_modules/@undefineds.co/shared-ui/dist/badge.js +17 -0
- package/node_modules/@undefineds.co/shared-ui/dist/button.d.ts +10 -0
- package/node_modules/@undefineds.co/shared-ui/dist/button.js +30 -0
- package/node_modules/@undefineds.co/shared-ui/dist/card.d.ts +7 -0
- package/node_modules/@undefineds.co/shared-ui/dist/card.js +15 -0
- package/node_modules/@undefineds.co/shared-ui/dist/index.d.ts +6 -0
- package/node_modules/@undefineds.co/shared-ui/dist/index.js +6 -0
- package/node_modules/@undefineds.co/shared-ui/dist/input.d.ts +4 -0
- package/node_modules/@undefineds.co/shared-ui/dist/input.js +5 -0
- package/node_modules/@undefineds.co/shared-ui/dist/theme.css +121 -0
- package/node_modules/@undefineds.co/shared-ui/dist/utils.d.ts +2 -0
- package/node_modules/@undefineds.co/shared-ui/dist/utils.js +5 -0
- package/node_modules/@undefineds.co/shared-ui/dist/workspace.d.ts +23 -0
- package/node_modules/@undefineds.co/shared-ui/dist/workspace.js +38 -0
- package/node_modules/@undefineds.co/shared-ui/package.json +39 -0
- package/node_modules/@undefineds.co/solid-sdk/dist/index.d.ts +3 -0
- package/node_modules/@undefineds.co/solid-sdk/dist/index.js +3 -0
- package/node_modules/@undefineds.co/solid-sdk/dist/pod-runtime.d.ts +45 -0
- package/node_modules/@undefineds.co/solid-sdk/dist/pod-runtime.js +147 -0
- package/node_modules/@undefineds.co/solid-sdk/dist/react.d.ts +15 -0
- package/node_modules/@undefineds.co/solid-sdk/dist/react.js +15 -0
- package/node_modules/@undefineds.co/solid-sdk/dist/session.d.ts +42 -0
- package/node_modules/@undefineds.co/solid-sdk/dist/session.js +127 -0
- package/node_modules/@undefineds.co/solid-sdk/package.json +45 -0
- package/package.json +31 -13
- package/static/app/assets/index-BoYHJ6si.js +230 -0
- package/static/app/assets/inrupt-smoke.js +2 -2
- package/static/app/assets/main.css +1 -1
- package/static/app/assets/main.js +9 -9
- package/static/dashboard/assets/NetworkPage-Brt79fuQ.js +2 -0
- package/static/dashboard/assets/PaneListHeader-57nvMwH6.js +1 -0
- package/static/dashboard/assets/PodPage-CM6do1vB.js +2 -0
- package/static/dashboard/assets/ServicesPage-BUNxGJRz.js +1 -0
- package/static/dashboard/assets/card-B9Zjf_2p.js +1 -0
- package/static/dashboard/assets/dashboard-8C6o666W.js +305 -0
- package/static/dashboard/assets/dashboard-CSdewNeA.css +1 -0
- package/static/dashboard/assets/database-DPh9wDY9.js +1 -0
- package/static/dashboard/assets/external-link-VbMQvVMz.js +1 -0
- package/static/dashboard/assets/index-RfiFckzb.js +51 -0
- package/static/dashboard/assets/refresh-cw-BxVxNxNr.js +1 -0
- package/static/dashboard/assets/services-status-context-DKmJ7ISr.js +1 -0
- package/static/dashboard/dashboard.html +2 -2
- package/static/settings/assets/ModelsPage-D_IH7AH3.js +1 -0
- package/static/settings/assets/PaneListHeader-Bgaze006.js +1 -0
- package/static/settings/assets/PodPage-Cy1VNObw.js +2 -0
- package/static/settings/assets/ServicesPage-BsFaxVWC.js +1 -0
- package/static/settings/assets/SettingsPage-UafNWE_p.js +48 -0
- package/static/settings/assets/card-B_bXSIn-.js +1 -0
- package/static/settings/assets/services-status-context-DiX-AbrP.js +1 -0
- package/static/settings/assets/settings-B30oMfZq.js +305 -0
- package/static/settings/assets/settings-CSdewNeA.css +1 -0
- package/static/settings/assets/workspace-layout-Dv1Yn9Ci.js +1 -0
- package/static/settings/auth.html +21 -0
- package/static/settings/reachability.html +221 -0
- package/static/settings/reachability.svg +7 -0
- package/static/settings/reachability.webmanifest +18 -0
- package/static/settings/settings.html +13 -0
- package/static/settings/signal-pod.html +293 -0
- package/static/settings/vite.svg +1 -0
- package/dist/api/service/ai-gateway-transport.d.ts +0 -25
- package/dist/api/service/ai-gateway-transport.js +0 -136
- package/dist/api/service/ai-gateway-transport.js.map +0 -1
- package/dist/api/service/chat-protocol-adapters.d.ts +0 -5
- package/dist/api/service/chat-protocol-adapters.js +0 -146
- package/dist/api/service/chat-protocol-adapters.js.map +0 -1
- package/dist/api/service/chat-routing.d.ts +0 -8
- package/dist/api/service/chat-routing.js +0 -16
- package/dist/api/service/chat-routing.js.map +0 -1
- package/dist/api/service/platform-ai-config.d.ts +0 -10
- package/dist/api/service/platform-ai-config.js +0 -76
- package/dist/api/service/platform-ai-config.js.map +0 -1
- package/dist/document/DocumentParser.js.map +0 -1
- package/dist/document/JinaDocumentParser.js.map +0 -1
- package/static/app/assets/index-C1yksyT4.js +0 -171
- package/static/dashboard/assets/dashboard-BssaVKTn.css +0 -1
- package/static/dashboard/assets/dashboard-Ckuadl3C.js +0 -54
|
@@ -1,556 +1,119 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.VercelChatService = void 0;
|
|
4
|
-
const openai_1 = require("@ai-sdk/openai");
|
|
5
|
-
const ai_1 = require("ai");
|
|
6
4
|
const global_logger_factory_1 = require("global-logger-factory");
|
|
7
|
-
const undici_1 = require("undici");
|
|
8
5
|
const AuthContext_1 = require("../auth/AuthContext");
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
// Create a proxy-aware fetch function
|
|
17
|
-
function createProxyFetch(proxyUrl) {
|
|
18
|
-
const agent = new undici_1.ProxyAgent(proxyUrl);
|
|
19
|
-
return (url, init) => fetch(url, { ...init, dispatcher: agent });
|
|
20
|
-
}
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated Compatibility facade for legacy internal ChatService callers.
|
|
8
|
+
*
|
|
9
|
+
* Public `/v1/*` routes are owned by AiGatewayHandler. This class only keeps
|
|
10
|
+
* older ChatKit/internal call sites working while routing every inference and
|
|
11
|
+
* model-list request through the unified AI Connection gateway runtime.
|
|
12
|
+
*/
|
|
21
13
|
class VercelChatService {
|
|
22
|
-
constructor(
|
|
23
|
-
this.
|
|
14
|
+
constructor(_store, options = {}) {
|
|
15
|
+
this._store = _store;
|
|
24
16
|
this.logger = (0, global_logger_factory_1.getLoggerFor)(this);
|
|
25
|
-
this.
|
|
26
|
-
this.
|
|
27
|
-
this.aiGatewayTransport = new ai_gateway_transport_1.AiGatewayTransport({
|
|
28
|
-
getBaseUrl: () => this.getAiGatewayBaseUrl(),
|
|
29
|
-
getApiKey: () => this.getAiGatewayApiKey(),
|
|
30
|
-
getQueryTimeoutMs: () => this.getAiGatewayQueryTimeoutMs(),
|
|
31
|
-
getGenerationTimeoutMs: () => this.getAiGatewayGenerationTimeoutMs(),
|
|
32
|
-
});
|
|
17
|
+
this.logger.info('Initializing legacy VercelChatService facade with AI Connection gateway runtime');
|
|
18
|
+
this.aiGatewayService = options.aiGatewayService;
|
|
33
19
|
}
|
|
34
20
|
/**
|
|
35
|
-
* Set optional usage tracking dependencies (injected after construction)
|
|
21
|
+
* Set optional usage tracking dependencies (injected after construction).
|
|
36
22
|
*/
|
|
37
23
|
setUsageTracking(usageRepo, quotaService) {
|
|
38
24
|
this.usageRepo = usageRepo;
|
|
39
25
|
this.quotaService = quotaService;
|
|
40
26
|
}
|
|
41
|
-
/**
|
|
42
|
-
* Create a StoreContext from AuthContext for Pod operations
|
|
43
|
-
*/
|
|
44
|
-
createStoreContext(auth) {
|
|
45
|
-
return {
|
|
46
|
-
userId: (0, AuthContext_1.getWebId)(auth) ?? (0, AuthContext_1.getAccountId)(auth) ?? 'anonymous',
|
|
47
|
-
auth,
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
getAiGatewayBaseUrl() {
|
|
51
|
-
return (0, platform_ai_config_1.getAiGatewayBaseUrl)() ?? null;
|
|
52
|
-
}
|
|
53
|
-
getAiGatewayQueryTimeoutMs() {
|
|
54
|
-
return (0, platform_ai_config_1.getPlatformQueryTimeoutMs)();
|
|
55
|
-
}
|
|
56
|
-
getAiGatewayGenerationTimeoutMs() {
|
|
57
|
-
return (0, platform_ai_config_1.getPlatformGenerationTimeoutMs)();
|
|
58
|
-
}
|
|
59
|
-
getAiGatewayApiKey() {
|
|
60
|
-
return (0, platform_ai_config_1.getAiGatewayApiKey)() ?? null;
|
|
61
|
-
}
|
|
62
|
-
async shouldUseAiGateway(model) {
|
|
63
|
-
return this.aiGatewayTransport.shouldHandleModel(model);
|
|
64
|
-
}
|
|
65
|
-
toModelId(model) {
|
|
66
|
-
return typeof model?.id === 'string' ? model.id : JSON.stringify(model);
|
|
67
|
-
}
|
|
68
|
-
pushModelsWithDedup(models, seenModelIds, items) {
|
|
69
|
-
for (const model of items) {
|
|
70
|
-
const modelId = this.toModelId(model);
|
|
71
|
-
if (seenModelIds.has(modelId)) {
|
|
72
|
-
continue;
|
|
73
|
-
}
|
|
74
|
-
seenModelIds.add(modelId);
|
|
75
|
-
models.push(model);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
async forwardAiGatewayJson(path, body, _auth) {
|
|
79
|
-
return this.aiGatewayTransport.sendJson(path, body);
|
|
80
|
-
}
|
|
81
|
-
async forwardAiGatewayStream(path, body, _auth) {
|
|
82
|
-
return this.aiGatewayTransport.sendStream(path, body);
|
|
83
|
-
}
|
|
84
|
-
getProviderChatCompletionsUrl(baseURL) {
|
|
85
|
-
const cleanBaseUrl = baseURL.endsWith('/') ? baseURL.slice(0, -1) : baseURL;
|
|
86
|
-
return cleanBaseUrl.endsWith('/chat/completions')
|
|
87
|
-
? cleanBaseUrl
|
|
88
|
-
: `${cleanBaseUrl}/chat/completions`;
|
|
89
|
-
}
|
|
90
|
-
extractTotalTokens(usage) {
|
|
91
|
-
if (!usage || typeof usage !== 'object') {
|
|
92
|
-
return 0;
|
|
93
|
-
}
|
|
94
|
-
if (typeof usage.total_tokens === 'number') {
|
|
95
|
-
return usage.total_tokens;
|
|
96
|
-
}
|
|
97
|
-
if (typeof usage.totalTokens === 'number') {
|
|
98
|
-
return usage.totalTokens;
|
|
99
|
-
}
|
|
100
|
-
if (typeof usage.input_tokens === 'number' || typeof usage.output_tokens === 'number') {
|
|
101
|
-
return (usage.input_tokens ?? 0) + (usage.output_tokens ?? 0);
|
|
102
|
-
}
|
|
103
|
-
if (typeof usage.prompt_tokens === 'number' || typeof usage.completion_tokens === 'number') {
|
|
104
|
-
return (usage.prompt_tokens ?? 0) + (usage.completion_tokens ?? 0);
|
|
105
|
-
}
|
|
106
|
-
return 0;
|
|
107
|
-
}
|
|
108
|
-
recordForwardedUsage(accountId, podId, payload) {
|
|
109
|
-
const totalTokens = this.extractTotalTokens(payload?.usage);
|
|
110
|
-
if (accountId && totalTokens > 0) {
|
|
111
|
-
this.recordTokenUsage(accountId, podId, totalTokens);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
async getProviderConfig(context) {
|
|
115
|
-
let config;
|
|
116
|
-
try {
|
|
117
|
-
config = await this.store.getAiConfig(context);
|
|
118
|
-
this.logger.info(`Pod config: ${JSON.stringify(config)}`);
|
|
119
|
-
}
|
|
120
|
-
catch (error) {
|
|
121
|
-
this.logger.warn(`Failed to get Pod config, falling back to defaults: ${error}`);
|
|
122
|
-
config = undefined;
|
|
123
|
-
}
|
|
124
|
-
// Priority: Pod config > Platform Provider
|
|
125
|
-
if (config?.apiKey) {
|
|
126
|
-
const baseURL = config.baseUrl || (0, provider_registry_1.getDefaultBaseUrl)();
|
|
127
|
-
const proxy = config.proxyUrl;
|
|
128
|
-
this.logger.info(`Provider config: baseURL=${baseURL}, proxy=${proxy || 'none'} (source=pod)`);
|
|
129
|
-
return { baseURL, apiKey: config.apiKey, proxy, credentialId: config.credentialId };
|
|
130
|
-
}
|
|
131
|
-
// 平台 Provider
|
|
132
|
-
const platformBase = (0, platform_ai_config_1.getPlatformApiBaseUrl)();
|
|
133
|
-
if (platformBase) {
|
|
134
|
-
this.logger.info(`Provider config: baseURL=${platformBase}, proxy=none (source=platform)`);
|
|
135
|
-
return { baseURL: platformBase, apiKey: (0, platform_ai_config_1.getPlatformApiKey)(), proxy: undefined, credentialId: undefined };
|
|
136
|
-
}
|
|
137
|
-
this.logger.warn('No AI provider config found in Pod or DEFAULT_API_BASE');
|
|
138
|
-
return null;
|
|
139
|
-
}
|
|
140
|
-
async getProvider(context) {
|
|
141
|
-
const providerConfig = await this.getProviderConfig(context);
|
|
142
|
-
if (!providerConfig) {
|
|
143
|
-
const err = new Error('No AI provider configured. Please configure Pod AI provider or set DEFAULT_API_BASE.');
|
|
144
|
-
err.code = 'model_not_configured';
|
|
145
|
-
throw err;
|
|
146
|
-
}
|
|
147
|
-
const { baseURL, apiKey, proxy } = providerConfig;
|
|
148
|
-
this.logger.debug(`Using AI Provider: ${baseURL} (key length: ${apiKey?.length || 0}, proxy: ${proxy || 'none'})`);
|
|
149
|
-
const options = { baseURL, apiKey };
|
|
150
|
-
if (proxy) {
|
|
151
|
-
options.fetch = createProxyFetch(proxy);
|
|
152
|
-
}
|
|
153
|
-
return (0, openai_1.createOpenAI)(options);
|
|
154
|
-
}
|
|
155
27
|
async complete(request, auth) {
|
|
156
|
-
const { model } = request;
|
|
157
|
-
const context = this.createStoreContext(auth);
|
|
158
28
|
const accountId = (0, AuthContext_1.getAccountId)(auth);
|
|
159
29
|
if (accountId) {
|
|
160
30
|
await this.checkTokenQuota(accountId);
|
|
161
31
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
this.recordForwardedUsage(accountId, String(context.userId), result);
|
|
166
|
-
return result;
|
|
167
|
-
}
|
|
168
|
-
const config = await this.getProviderConfig(context);
|
|
169
|
-
if (!config) {
|
|
170
|
-
const err = new Error('No AI provider configured. Please configure Pod AI provider or set DEFAULT_API_BASE.');
|
|
171
|
-
err.code = 'model_not_configured';
|
|
172
|
-
throw err;
|
|
173
|
-
}
|
|
174
|
-
try {
|
|
175
|
-
const result = await this.providerHttpTransport.postJson({
|
|
176
|
-
url: this.getProviderChatCompletionsUrl(config.baseURL),
|
|
177
|
-
apiKey: config.apiKey,
|
|
178
|
-
proxy: config.proxy,
|
|
179
|
-
body: request,
|
|
180
|
-
});
|
|
181
|
-
// Record successful API call
|
|
182
|
-
if (config?.credentialId) {
|
|
183
|
-
this.store.recordCredentialSuccess(context, config.credentialId).catch((err) => {
|
|
184
|
-
this.logger.debug(`Failed to record credential success: ${err}`);
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
// Record token usage
|
|
188
|
-
const totalTokens = this.extractTotalTokens(result.usage);
|
|
189
|
-
if (accountId && totalTokens > 0) {
|
|
190
|
-
this.recordTokenUsage(accountId, String(context.userId), totalTokens);
|
|
191
|
-
}
|
|
192
|
-
return result;
|
|
193
|
-
}
|
|
194
|
-
catch (error) {
|
|
195
|
-
this.logger.error(`AI completion failed: ${error}`);
|
|
196
|
-
// Handle error and update credential status
|
|
197
|
-
if (config?.credentialId) {
|
|
198
|
-
await this.handleApiError(error, context, config.credentialId);
|
|
199
|
-
}
|
|
200
|
-
throw error;
|
|
201
|
-
}
|
|
32
|
+
const result = await this.completeViaGateway('chatCompletions', request, auth);
|
|
33
|
+
this.recordForwardedUsage(accountId, this.podUsageScope(auth), result);
|
|
34
|
+
return result;
|
|
202
35
|
}
|
|
203
36
|
async stream(request, auth) {
|
|
204
|
-
const
|
|
205
|
-
const context = this.createStoreContext(auth);
|
|
206
|
-
if (await (0, chat_routing_1.resolveChatExecutionRoute)({ model, shouldUseAiGateway: this.shouldUseAiGateway.bind(this) }) === 'ai-gateway') {
|
|
207
|
-
this.logger.info(`Forwarding chat stream for model ${model} to ai-gateway`);
|
|
208
|
-
return this.forwardAiGatewayStream('/v1/chat/completions', request, auth);
|
|
209
|
-
}
|
|
210
|
-
const config = await this.getProviderConfig(context);
|
|
211
|
-
if (!config) {
|
|
212
|
-
const err = new Error('No AI provider configured. Please configure Pod AI provider or set DEFAULT_API_BASE.');
|
|
213
|
-
err.code = 'model_not_configured';
|
|
214
|
-
throw err;
|
|
215
|
-
}
|
|
216
|
-
const response = await this.providerHttpTransport.postStream({
|
|
217
|
-
url: this.getProviderChatCompletionsUrl(config.baseURL),
|
|
218
|
-
apiKey: config.apiKey,
|
|
219
|
-
proxy: config.proxy,
|
|
220
|
-
body: request,
|
|
221
|
-
headers: {
|
|
222
|
-
Accept: 'text/event-stream',
|
|
223
|
-
},
|
|
224
|
-
});
|
|
37
|
+
const gateway = this.requireAiGatewayService();
|
|
225
38
|
return {
|
|
226
|
-
toTextStreamResponse: () =>
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
39
|
+
toTextStreamResponse: () => gatewayExecutionToTextStreamResponse(gateway, {
|
|
40
|
+
auth,
|
|
41
|
+
protocol: 'chatCompletions',
|
|
42
|
+
body: request,
|
|
230
43
|
}),
|
|
231
44
|
};
|
|
232
45
|
}
|
|
233
46
|
async responses(body, auth) {
|
|
234
|
-
const
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
if (await (0, chat_routing_1.resolveChatExecutionRoute)({ model: body?.model, shouldUseAiGateway: this.shouldUseAiGateway.bind(this) }) === 'ai-gateway') {
|
|
238
|
-
this.logger.info(`Forwarding responses request for model ${body?.model} to ai-gateway for ${displayName} (acc: ${accountId})`);
|
|
239
|
-
const sanitizedBody = (0, chat_protocol_adapters_1.sanitizeAiGatewayResponsesBody)(body);
|
|
240
|
-
const result = await this.forwardAiGatewayJson('/v1/responses', sanitizedBody, auth);
|
|
241
|
-
this.recordForwardedUsage(accountId, String(context.userId), result);
|
|
242
|
-
return result;
|
|
243
|
-
}
|
|
244
|
-
const providerConfig = await this.getProviderConfig(context);
|
|
245
|
-
if (!providerConfig) {
|
|
246
|
-
const err = new Error('No AI provider configured. Please configure Pod AI provider or set DEFAULT_API_BASE.');
|
|
247
|
-
err.code = 'model_not_configured';
|
|
248
|
-
throw err;
|
|
249
|
-
}
|
|
250
|
-
const { baseURL } = providerConfig;
|
|
251
|
-
// Only OpenAI natively supports /v1/responses; all others go through Chat Completions
|
|
252
|
-
if ((0, chat_routing_1.resolveResponsesProviderRoute)(baseURL) === 'chat-fallback') {
|
|
253
|
-
this.logger.info(`Provider ${baseURL} does not support Responses API, converting to Chat Completions for ${displayName} (acc: ${accountId})`);
|
|
254
|
-
return this.responsesViaCompletions(body, context, providerConfig);
|
|
255
|
-
}
|
|
256
|
-
const { apiKey, proxy, credentialId } = providerConfig;
|
|
257
|
-
// Remove trailing slash if present
|
|
258
|
-
const cleanBaseUrl = baseURL.endsWith('/') ? baseURL.slice(0, -1) : baseURL;
|
|
259
|
-
const url = `${cleanBaseUrl}/responses`;
|
|
260
|
-
this.logger.info(`Proxying responses request to ${url} for ${displayName} (acc: ${accountId}), proxy: ${proxy || 'none'}`);
|
|
261
|
-
try {
|
|
262
|
-
const result = await this.providerHttpTransport.postJson({
|
|
263
|
-
url,
|
|
264
|
-
apiKey,
|
|
265
|
-
proxy,
|
|
266
|
-
body,
|
|
267
|
-
});
|
|
268
|
-
if (credentialId) {
|
|
269
|
-
this.store.recordCredentialSuccess(context, credentialId).catch(() => { });
|
|
270
|
-
}
|
|
271
|
-
return result;
|
|
272
|
-
}
|
|
273
|
-
catch (error) {
|
|
274
|
-
const status = error?.status;
|
|
275
|
-
const headers = error?.headers;
|
|
276
|
-
const bodyText = error?.body;
|
|
277
|
-
if (typeof status === 'number') {
|
|
278
|
-
this.logger.error(`Responses API failed: ${status} ${bodyText ?? ''}`);
|
|
279
|
-
if (credentialId) {
|
|
280
|
-
await this.handleApiError({ status, headers }, context, credentialId);
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
else if (credentialId) {
|
|
284
|
-
await this.handleApiError(error, context, credentialId);
|
|
285
|
-
}
|
|
286
|
-
throw error;
|
|
287
|
-
}
|
|
47
|
+
const result = await this.completeViaGateway('responses', body, auth);
|
|
48
|
+
this.recordForwardedUsage((0, AuthContext_1.getAccountId)(auth), this.podUsageScope(auth), result);
|
|
49
|
+
return result;
|
|
288
50
|
}
|
|
289
51
|
async messages(body, auth) {
|
|
290
|
-
const
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
if (await (0, chat_routing_1.resolveChatExecutionRoute)({ model: body?.model, shouldUseAiGateway: this.shouldUseAiGateway.bind(this) }) === 'ai-gateway') {
|
|
294
|
-
this.logger.info(`Forwarding messages request for model ${body?.model} to ai-gateway for ${displayName} (acc: ${accountId})`);
|
|
295
|
-
const completionBody = (0, chat_protocol_adapters_1.buildChatCompletionsBodyFromMessages)(body);
|
|
296
|
-
const completion = await this.forwardAiGatewayJson('/v1/chat/completions', completionBody, auth);
|
|
297
|
-
const result = (0, chat_protocol_adapters_1.mapChatCompletionToMessagesResponse)(body, completion);
|
|
298
|
-
this.recordForwardedUsage(accountId, String(context.userId), result);
|
|
299
|
-
return result;
|
|
300
|
-
}
|
|
301
|
-
const providerConfig = await this.getProviderConfig(context);
|
|
302
|
-
if (!providerConfig) {
|
|
303
|
-
const err = new Error('No AI provider configured. Please configure Pod AI provider or set DEFAULT_API_BASE.');
|
|
304
|
-
err.code = 'model_not_configured';
|
|
305
|
-
throw err;
|
|
306
|
-
}
|
|
307
|
-
const { baseURL } = providerConfig;
|
|
308
|
-
// Only Anthropic natively supports /v1/messages; all others go through Chat Completions
|
|
309
|
-
if ((0, chat_routing_1.resolveMessagesProviderRoute)(baseURL) === 'chat-fallback') {
|
|
310
|
-
this.logger.info(`Provider ${baseURL} does not support Messages API, converting to Chat Completions for ${displayName} (acc: ${accountId})`);
|
|
311
|
-
return this.messagesViaCompletions(body, context, providerConfig);
|
|
312
|
-
}
|
|
313
|
-
const { apiKey, proxy, credentialId } = providerConfig;
|
|
314
|
-
// Remove trailing slash if present
|
|
315
|
-
const cleanBaseUrl = baseURL.endsWith('/') ? baseURL.slice(0, -1) : baseURL;
|
|
316
|
-
const url = `${cleanBaseUrl}/messages`;
|
|
317
|
-
this.logger.info(`Proxying messages request to ${url} for ${displayName} (acc: ${accountId}), proxy: ${proxy || 'none'}`);
|
|
318
|
-
try {
|
|
319
|
-
const result = await this.providerHttpTransport.postJson({
|
|
320
|
-
url,
|
|
321
|
-
apiKey,
|
|
322
|
-
proxy,
|
|
323
|
-
body,
|
|
324
|
-
headers: {
|
|
325
|
-
'x-api-key': apiKey,
|
|
326
|
-
'anthropic-version': '2023-06-01',
|
|
327
|
-
},
|
|
328
|
-
});
|
|
329
|
-
if (credentialId) {
|
|
330
|
-
this.store.recordCredentialSuccess(context, credentialId).catch(() => { });
|
|
331
|
-
}
|
|
332
|
-
return result;
|
|
333
|
-
}
|
|
334
|
-
catch (error) {
|
|
335
|
-
const status = error?.status;
|
|
336
|
-
const headers = error?.headers;
|
|
337
|
-
const bodyText = error?.body;
|
|
338
|
-
if (typeof status === 'number') {
|
|
339
|
-
this.logger.error(`Messages API failed: ${status} ${bodyText ?? ''}`);
|
|
340
|
-
if (credentialId) {
|
|
341
|
-
await this.handleApiError({ status, headers }, context, credentialId);
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
else if (credentialId) {
|
|
345
|
-
await this.handleApiError(error, context, credentialId);
|
|
346
|
-
}
|
|
347
|
-
throw error;
|
|
348
|
-
}
|
|
52
|
+
const result = await this.completeViaGateway('anthropic', body, auth);
|
|
53
|
+
this.recordForwardedUsage((0, AuthContext_1.getAccountId)(auth), this.podUsageScope(auth), result);
|
|
54
|
+
return result;
|
|
349
55
|
}
|
|
350
|
-
async
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
const provider = await this.getProvider(context);
|
|
354
|
-
const result = await (0, ai_1.generateText)({
|
|
355
|
-
model: provider.chat(model),
|
|
356
|
-
messages: [{ role: 'user', content: prompt }],
|
|
357
|
-
...(body?.temperature != null ? { temperature: body.temperature } : {}),
|
|
358
|
-
...(body?.max_output_tokens != null ? { maxTokens: body.max_output_tokens } : {}),
|
|
359
|
-
});
|
|
360
|
-
if (providerConfig.credentialId) {
|
|
361
|
-
this.store.recordCredentialSuccess(context, providerConfig.credentialId).catch(() => { });
|
|
56
|
+
async listModels(auth) {
|
|
57
|
+
if (!auth) {
|
|
58
|
+
return [];
|
|
362
59
|
}
|
|
363
|
-
|
|
364
|
-
const now = Math.floor(Date.now() / 1000);
|
|
365
|
-
return {
|
|
366
|
-
id: `resp_${Date.now()}`,
|
|
367
|
-
object: 'response',
|
|
368
|
-
created: now,
|
|
369
|
-
status: 'completed',
|
|
370
|
-
model,
|
|
371
|
-
output: [{
|
|
372
|
-
type: 'message',
|
|
373
|
-
role: 'assistant',
|
|
374
|
-
content: [{ type: 'output_text', text: outputText }],
|
|
375
|
-
}],
|
|
376
|
-
usage: {
|
|
377
|
-
input_tokens: result.usage?.promptTokens ?? prompt.length,
|
|
378
|
-
output_tokens: result.usage?.completionTokens ?? outputText.length,
|
|
379
|
-
total_tokens: result.usage?.totalTokens ?? (prompt.length + outputText.length),
|
|
380
|
-
},
|
|
381
|
-
};
|
|
60
|
+
return await this.requireAiGatewayService().listModels(auth);
|
|
382
61
|
}
|
|
383
|
-
async
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
const systemText = typeof body.system === 'string'
|
|
389
|
-
? body.system
|
|
390
|
-
: Array.isArray(body.system)
|
|
391
|
-
? body.system.map((b) => b?.text ?? '').join('\n')
|
|
392
|
-
: '';
|
|
393
|
-
if (systemText) {
|
|
394
|
-
coreMessages.push({ role: 'system', content: systemText });
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
|
-
if (Array.isArray(body?.messages)) {
|
|
398
|
-
for (const msg of body.messages) {
|
|
399
|
-
if (msg?.role && msg?.content != null) {
|
|
400
|
-
const content = typeof msg.content === 'string'
|
|
401
|
-
? msg.content
|
|
402
|
-
: Array.isArray(msg.content)
|
|
403
|
-
? msg.content.filter((p) => p?.type === 'text').map((p) => p.text).join('\n')
|
|
404
|
-
: String(msg.content);
|
|
405
|
-
coreMessages.push({ role: msg.role, content });
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
if (coreMessages.length === 0) {
|
|
410
|
-
coreMessages.push({ role: 'user', content: prompt });
|
|
411
|
-
}
|
|
412
|
-
const provider = await this.getProvider(context);
|
|
413
|
-
const result = await (0, ai_1.generateText)({
|
|
414
|
-
model: provider.chat(model),
|
|
415
|
-
messages: coreMessages,
|
|
416
|
-
...(body?.temperature != null ? { temperature: body.temperature } : {}),
|
|
417
|
-
...(body?.max_tokens != null ? { maxTokens: body.max_tokens } : {}),
|
|
62
|
+
async completeViaGateway(protocol, body, auth) {
|
|
63
|
+
return await this.requireAiGatewayService().complete({
|
|
64
|
+
auth,
|
|
65
|
+
protocol,
|
|
66
|
+
body,
|
|
418
67
|
});
|
|
419
|
-
|
|
420
|
-
|
|
68
|
+
}
|
|
69
|
+
requireAiGatewayService() {
|
|
70
|
+
if (!this.aiGatewayService) {
|
|
71
|
+
throw new Error('AiGatewayService is required for legacy ChatKit AI inference');
|
|
421
72
|
}
|
|
422
|
-
|
|
423
|
-
return {
|
|
424
|
-
id: `msg_${Date.now()}`,
|
|
425
|
-
type: 'message',
|
|
426
|
-
role: 'assistant',
|
|
427
|
-
model,
|
|
428
|
-
content: [{ type: 'text', text }],
|
|
429
|
-
stop_reason: 'end_turn',
|
|
430
|
-
stop_sequence: null,
|
|
431
|
-
usage: {
|
|
432
|
-
input_tokens: result.usage?.promptTokens ?? prompt.length,
|
|
433
|
-
output_tokens: result.usage?.completionTokens ?? text.length,
|
|
434
|
-
},
|
|
435
|
-
};
|
|
73
|
+
return this.aiGatewayService;
|
|
436
74
|
}
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
const userModels = await this.store.listAvailableModels(context);
|
|
444
|
-
this.pushModelsWithDedup(models, seenModelIds, userModels);
|
|
445
|
-
}
|
|
446
|
-
catch (error) {
|
|
447
|
-
this.logger.warn(`Failed to load user Pod models: ${error}`);
|
|
448
|
-
}
|
|
75
|
+
podUsageScope(auth) {
|
|
76
|
+
return (0, AuthContext_1.getWebId)(auth) ?? (0, AuthContext_1.getAccountId)(auth) ?? 'anonymous';
|
|
77
|
+
}
|
|
78
|
+
extractTotalTokens(usage) {
|
|
79
|
+
if (!usage || typeof usage !== 'object') {
|
|
80
|
+
return 0;
|
|
449
81
|
}
|
|
450
|
-
const
|
|
451
|
-
if (
|
|
452
|
-
|
|
82
|
+
const record = usage;
|
|
83
|
+
if (typeof record.total_tokens === 'number') {
|
|
84
|
+
return record.total_tokens;
|
|
453
85
|
}
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
const platformKey = (0, platform_ai_config_1.getPlatformApiKey)();
|
|
457
|
-
const aiGatewayBase = this.getAiGatewayBaseUrl();
|
|
458
|
-
const normalizedAiGatewayModelsUrl = aiGatewayBase
|
|
459
|
-
? this.aiGatewayTransport.buildUrl('/v1/models')
|
|
460
|
-
: undefined;
|
|
461
|
-
const normalizedPlatformModelsUrl = platformBase
|
|
462
|
-
? `${platformBase.replace(/\/$/, '')}/models`
|
|
463
|
-
: undefined;
|
|
464
|
-
if (platformBase && normalizedPlatformModelsUrl !== normalizedAiGatewayModelsUrl) {
|
|
465
|
-
try {
|
|
466
|
-
const url = normalizedPlatformModelsUrl;
|
|
467
|
-
const headers = { 'Content-Type': 'application/json' };
|
|
468
|
-
if (platformKey) {
|
|
469
|
-
headers['Authorization'] = `Bearer ${platformKey}`;
|
|
470
|
-
}
|
|
471
|
-
const resp = await fetch(url, { headers });
|
|
472
|
-
if (resp.ok) {
|
|
473
|
-
const data = await resp.json();
|
|
474
|
-
if (Array.isArray(data.data)) {
|
|
475
|
-
this.pushModelsWithDedup(models, seenModelIds, data.data);
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
else {
|
|
479
|
-
this.logger.warn(`Failed to fetch platform models: ${resp.status}`);
|
|
480
|
-
}
|
|
481
|
-
}
|
|
482
|
-
catch (error) {
|
|
483
|
-
this.logger.warn(`Failed to fetch platform models: ${error}`);
|
|
484
|
-
}
|
|
86
|
+
if (typeof record.totalTokens === 'number') {
|
|
87
|
+
return record.totalTokens;
|
|
485
88
|
}
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
/**
|
|
489
|
-
* Handle API errors and update credential status accordingly
|
|
490
|
-
*/
|
|
491
|
-
async handleApiError(error, context, credentialId) {
|
|
492
|
-
const errorInfo = this.parseApiError(error);
|
|
493
|
-
if (errorInfo.statusCode === 429) {
|
|
494
|
-
// Rate limit error - mark credential as rate limited
|
|
495
|
-
const resetAt = errorInfo.retryAfter
|
|
496
|
-
? new Date(Date.now() + errorInfo.retryAfter * 1000)
|
|
497
|
-
: new Date(Date.now() + 60000); // Default 1 minute cooldown
|
|
498
|
-
this.logger.warn(`Rate limit hit for credential ${credentialId}, reset at: ${resetAt.toISOString()}`);
|
|
499
|
-
await this.store.updateCredentialStatus(context, credentialId, types_1.CredentialStatus.RATE_LIMITED, { rateLimitResetAt: resetAt });
|
|
89
|
+
if (typeof record.input_tokens === 'number' || typeof record.output_tokens === 'number') {
|
|
90
|
+
return (Number(record.input_tokens) || 0) + (Number(record.output_tokens) || 0);
|
|
500
91
|
}
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
this.logger.warn(`Auth error for credential ${credentialId}, marking as inactive`);
|
|
504
|
-
await this.store.updateCredentialStatus(context, credentialId, types_1.CredentialStatus.INACTIVE, { incrementFailCount: true });
|
|
505
|
-
}
|
|
506
|
-
else if (errorInfo.statusCode >= 500) {
|
|
507
|
-
// Server error - increment fail count but keep active
|
|
508
|
-
this.logger.warn(`Server error ${errorInfo.statusCode} for credential ${credentialId}`);
|
|
509
|
-
await this.store.updateCredentialStatus(context, credentialId, types_1.CredentialStatus.ACTIVE, { incrementFailCount: true });
|
|
92
|
+
if (typeof record.prompt_tokens === 'number' || typeof record.completion_tokens === 'number') {
|
|
93
|
+
return (Number(record.prompt_tokens) || 0) + (Number(record.completion_tokens) || 0);
|
|
510
94
|
}
|
|
95
|
+
return 0;
|
|
511
96
|
}
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
if (
|
|
518
|
-
|
|
519
|
-
// Direct status code
|
|
520
|
-
if (typeof err.status === 'number') {
|
|
521
|
-
return {
|
|
522
|
-
statusCode: err.status,
|
|
523
|
-
retryAfter: err.retryAfter || err.headers?.['retry-after'],
|
|
524
|
-
};
|
|
525
|
-
}
|
|
526
|
-
// Nested response object
|
|
527
|
-
if (err.response && typeof err.response.status === 'number') {
|
|
528
|
-
return {
|
|
529
|
-
statusCode: err.response.status,
|
|
530
|
-
retryAfter: err.response.headers?.get?.('retry-after'),
|
|
531
|
-
};
|
|
532
|
-
}
|
|
533
|
-
// Error message parsing (fallback)
|
|
534
|
-
if (err.message) {
|
|
535
|
-
const match = err.message.match(/(\d{3})/);
|
|
536
|
-
if (match) {
|
|
537
|
-
return { statusCode: parseInt(match[1], 10) };
|
|
538
|
-
}
|
|
539
|
-
}
|
|
97
|
+
recordForwardedUsage(accountId, podId, payload) {
|
|
98
|
+
const usage = payload && typeof payload === 'object'
|
|
99
|
+
? payload.usage
|
|
100
|
+
: undefined;
|
|
101
|
+
const totalTokens = this.extractTotalTokens(usage);
|
|
102
|
+
if (accountId && totalTokens > 0) {
|
|
103
|
+
this.recordTokenUsage(accountId, podId, totalTokens);
|
|
540
104
|
}
|
|
541
|
-
return { statusCode: 0 };
|
|
542
105
|
}
|
|
543
106
|
/**
|
|
544
|
-
* Check if account has remaining token quota
|
|
107
|
+
* Check if account has remaining token quota.
|
|
545
108
|
*/
|
|
546
109
|
async checkTokenQuota(accountId) {
|
|
547
110
|
if (!this.quotaService || !this.usageRepo) {
|
|
548
|
-
return;
|
|
111
|
+
return;
|
|
549
112
|
}
|
|
550
113
|
try {
|
|
551
114
|
const quota = await this.quotaService.getAccountQuota(accountId);
|
|
552
115
|
if (!quota.tokenLimitMonthly) {
|
|
553
|
-
return;
|
|
116
|
+
return;
|
|
554
117
|
}
|
|
555
118
|
const usage = await this.usageRepo.getAccountUsage(accountId);
|
|
556
119
|
const tokensUsed = usage?.tokensUsed ?? 0;
|
|
@@ -564,12 +127,11 @@ class VercelChatService {
|
|
|
564
127
|
if (error.code === 'quota_exceeded') {
|
|
565
128
|
throw error;
|
|
566
129
|
}
|
|
567
|
-
// Log but don't block on quota check errors
|
|
568
130
|
this.logger.warn(`Token quota check failed: ${error}`);
|
|
569
131
|
}
|
|
570
132
|
}
|
|
571
133
|
/**
|
|
572
|
-
* Record token usage (fire-and-forget)
|
|
134
|
+
* Record token usage (fire-and-forget).
|
|
573
135
|
*/
|
|
574
136
|
recordTokenUsage(accountId, podId, tokens) {
|
|
575
137
|
if (!this.usageRepo) {
|
|
@@ -581,4 +143,90 @@ class VercelChatService {
|
|
|
581
143
|
}
|
|
582
144
|
}
|
|
583
145
|
exports.VercelChatService = VercelChatService;
|
|
146
|
+
function gatewayExecutionToTextStreamResponse(gateway, input) {
|
|
147
|
+
const encoder = new TextEncoder();
|
|
148
|
+
const abortController = new AbortController();
|
|
149
|
+
let iterator;
|
|
150
|
+
let cancelRequested = false;
|
|
151
|
+
let iteratorReturned = false;
|
|
152
|
+
const returnIterator = async () => {
|
|
153
|
+
if (!iterator) {
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
if (iteratorReturned) {
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
iteratorReturned = true;
|
|
160
|
+
await iterator?.return?.();
|
|
161
|
+
};
|
|
162
|
+
const pump = async (controller) => {
|
|
163
|
+
try {
|
|
164
|
+
const execution = await gateway.execute({
|
|
165
|
+
...input,
|
|
166
|
+
signal: abortController.signal,
|
|
167
|
+
});
|
|
168
|
+
const serializer = execution.frontend.createEventSerializer();
|
|
169
|
+
iterator = execution.events[Symbol.asyncIterator]();
|
|
170
|
+
if (cancelRequested) {
|
|
171
|
+
await returnIterator();
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
while (true) {
|
|
175
|
+
if (cancelRequested) {
|
|
176
|
+
break;
|
|
177
|
+
}
|
|
178
|
+
const result = await iterator.next();
|
|
179
|
+
if (result.done) {
|
|
180
|
+
break;
|
|
181
|
+
}
|
|
182
|
+
if (cancelRequested) {
|
|
183
|
+
break;
|
|
184
|
+
}
|
|
185
|
+
const event = result.value;
|
|
186
|
+
const serialized = serializer.serializeEvent(event);
|
|
187
|
+
for (const item of Array.isArray(serialized) ? serialized : [serialized]) {
|
|
188
|
+
controller.enqueue(encoder.encode(`data: ${JSON.stringify(item)}\n\n`));
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
if (cancelRequested) {
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
controller.enqueue(encoder.encode('data: [DONE]\n\n'));
|
|
195
|
+
controller.close();
|
|
196
|
+
}
|
|
197
|
+
catch (error) {
|
|
198
|
+
if (abortController.signal.aborted) {
|
|
199
|
+
try {
|
|
200
|
+
controller.close();
|
|
201
|
+
}
|
|
202
|
+
catch {
|
|
203
|
+
// Stream may already be closed by cancel().
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
else {
|
|
207
|
+
controller.error(error);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
finally {
|
|
211
|
+
await returnIterator();
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
const stream = new ReadableStream({
|
|
215
|
+
start(controller) {
|
|
216
|
+
void pump(controller);
|
|
217
|
+
},
|
|
218
|
+
async cancel() {
|
|
219
|
+
cancelRequested = true;
|
|
220
|
+
abortController.abort();
|
|
221
|
+
await returnIterator();
|
|
222
|
+
},
|
|
223
|
+
});
|
|
224
|
+
return new Response(stream, {
|
|
225
|
+
status: 200,
|
|
226
|
+
headers: {
|
|
227
|
+
'Content-Type': 'text/event-stream; charset=utf-8',
|
|
228
|
+
'Cache-Control': 'no-cache, no-transform',
|
|
229
|
+
},
|
|
230
|
+
});
|
|
231
|
+
}
|
|
584
232
|
//# sourceMappingURL=VercelChatService.js.map
|