@cat-factory/worker 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/app.d.ts +22 -0
- package/dist/app.d.ts.map +1 -0
- package/dist/app.js +49 -0
- package/dist/app.js.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +234 -0
- package/dist/index.js.map +1 -0
- package/dist/infrastructure/ai/CloudflareModelProvider.d.ts +23 -0
- package/dist/infrastructure/ai/CloudflareModelProvider.d.ts.map +1 -0
- package/dist/infrastructure/ai/CloudflareModelProvider.js +62 -0
- package/dist/infrastructure/ai/CloudflareModelProvider.js.map +1 -0
- package/dist/infrastructure/ai/CompositeAgentExecutor.d.ts +2 -0
- package/dist/infrastructure/ai/CompositeAgentExecutor.d.ts.map +1 -0
- package/dist/infrastructure/ai/CompositeAgentExecutor.js +5 -0
- package/dist/infrastructure/ai/CompositeAgentExecutor.js.map +1 -0
- package/dist/infrastructure/ai/ContainerAgentExecutor.d.ts +2 -0
- package/dist/infrastructure/ai/ContainerAgentExecutor.d.ts.map +1 -0
- package/dist/infrastructure/ai/ContainerAgentExecutor.js +5 -0
- package/dist/infrastructure/ai/ContainerAgentExecutor.js.map +1 -0
- package/dist/infrastructure/ai/ContainerRepoBootstrapper.d.ts +2 -0
- package/dist/infrastructure/ai/ContainerRepoBootstrapper.d.ts.map +1 -0
- package/dist/infrastructure/ai/ContainerRepoBootstrapper.js +5 -0
- package/dist/infrastructure/ai/ContainerRepoBootstrapper.js.map +1 -0
- package/dist/infrastructure/ai/ContainerRepoScanner.d.ts +39 -0
- package/dist/infrastructure/ai/ContainerRepoScanner.d.ts.map +1 -0
- package/dist/infrastructure/ai/ContainerRepoScanner.js +115 -0
- package/dist/infrastructure/ai/ContainerRepoScanner.js.map +1 -0
- package/dist/infrastructure/ai/LlmFragmentSelector.d.ts +2 -0
- package/dist/infrastructure/ai/LlmFragmentSelector.d.ts.map +1 -0
- package/dist/infrastructure/ai/LlmFragmentSelector.js +4 -0
- package/dist/infrastructure/ai/LlmFragmentSelector.js.map +1 -0
- package/dist/infrastructure/ai/RunnerJobClient.d.ts +2 -0
- package/dist/infrastructure/ai/RunnerJobClient.d.ts.map +1 -0
- package/dist/infrastructure/ai/RunnerJobClient.js +5 -0
- package/dist/infrastructure/ai/RunnerJobClient.js.map +1 -0
- package/dist/infrastructure/ai/WorkersAiLlmUpstream.d.ts +28 -0
- package/dist/infrastructure/ai/WorkersAiLlmUpstream.d.ts.map +1 -0
- package/dist/infrastructure/ai/WorkersAiLlmUpstream.js +486 -0
- package/dist/infrastructure/ai/WorkersAiLlmUpstream.js.map +1 -0
- package/dist/infrastructure/ai/providerEndpoints.d.ts +17 -0
- package/dist/infrastructure/ai/providerEndpoints.d.ts.map +1 -0
- package/dist/infrastructure/ai/providerEndpoints.js +42 -0
- package/dist/infrastructure/ai/providerEndpoints.js.map +1 -0
- package/dist/infrastructure/ai/registries.d.ts +11 -0
- package/dist/infrastructure/ai/registries.d.ts.map +1 -0
- package/dist/infrastructure/ai/registries.js +14 -0
- package/dist/infrastructure/ai/registries.js.map +1 -0
- package/dist/infrastructure/auth/GitHubOAuth.d.ts +2 -0
- package/dist/infrastructure/auth/GitHubOAuth.d.ts.map +1 -0
- package/dist/infrastructure/auth/GitHubOAuth.js +3 -0
- package/dist/infrastructure/auth/GitHubOAuth.js.map +1 -0
- package/dist/infrastructure/auth/middleware.d.ts +2 -0
- package/dist/infrastructure/auth/middleware.d.ts.map +1 -0
- package/dist/infrastructure/auth/middleware.js +3 -0
- package/dist/infrastructure/auth/middleware.js.map +1 -0
- package/dist/infrastructure/auth/signing.d.ts +3 -0
- package/dist/infrastructure/auth/signing.d.ts.map +1 -0
- package/dist/infrastructure/auth/signing.js +3 -0
- package/dist/infrastructure/auth/signing.js.map +1 -0
- package/dist/infrastructure/config/agents.d.ts +6 -0
- package/dist/infrastructure/config/agents.d.ts.map +1 -0
- package/dist/infrastructure/config/agents.js +100 -0
- package/dist/infrastructure/config/agents.js.map +1 -0
- package/dist/infrastructure/config/auth.d.ts +13 -0
- package/dist/infrastructure/config/auth.d.ts.map +1 -0
- package/dist/infrastructure/config/auth.js +80 -0
- package/dist/infrastructure/config/auth.js.map +1 -0
- package/dist/infrastructure/config/cors.d.ts +2 -0
- package/dist/infrastructure/config/cors.d.ts.map +1 -0
- package/dist/infrastructure/config/cors.js +3 -0
- package/dist/infrastructure/config/cors.js.map +1 -0
- package/dist/infrastructure/config/datadog.d.ts +6 -0
- package/dist/infrastructure/config/datadog.d.ts.map +1 -0
- package/dist/infrastructure/config/datadog.js +22 -0
- package/dist/infrastructure/config/datadog.js.map +1 -0
- package/dist/infrastructure/config/documents.d.ts +5 -0
- package/dist/infrastructure/config/documents.d.ts.map +1 -0
- package/dist/infrastructure/config/documents.js +36 -0
- package/dist/infrastructure/config/documents.js.map +1 -0
- package/dist/infrastructure/config/email.d.ts +5 -0
- package/dist/infrastructure/config/email.d.ts.map +1 -0
- package/dist/infrastructure/config/email.js +12 -0
- package/dist/infrastructure/config/email.js.map +1 -0
- package/dist/infrastructure/config/environments.d.ts +5 -0
- package/dist/infrastructure/config/environments.d.ts.map +1 -0
- package/dist/infrastructure/config/environments.js +15 -0
- package/dist/infrastructure/config/environments.js.map +1 -0
- package/dist/infrastructure/config/execution.d.ts +5 -0
- package/dist/infrastructure/config/execution.d.ts.map +1 -0
- package/dist/infrastructure/config/execution.js +21 -0
- package/dist/infrastructure/config/execution.js.map +1 -0
- package/dist/infrastructure/config/fragmentLibrary.d.ts +5 -0
- package/dist/infrastructure/config/fragmentLibrary.d.ts.map +1 -0
- package/dist/infrastructure/config/fragmentLibrary.js +7 -0
- package/dist/infrastructure/config/fragmentLibrary.js.map +1 -0
- package/dist/infrastructure/config/github.d.ts +5 -0
- package/dist/infrastructure/config/github.d.ts.map +1 -0
- package/dist/infrastructure/config/github.js +25 -0
- package/dist/infrastructure/config/github.js.map +1 -0
- package/dist/infrastructure/config/index.d.ts +20 -0
- package/dist/infrastructure/config/index.d.ts.map +1 -0
- package/dist/infrastructure/config/index.js +52 -0
- package/dist/infrastructure/config/index.js.map +1 -0
- package/dist/infrastructure/config/langfuse.d.ts +10 -0
- package/dist/infrastructure/config/langfuse.d.ts.map +1 -0
- package/dist/infrastructure/config/langfuse.js +17 -0
- package/dist/infrastructure/config/langfuse.js.map +1 -0
- package/dist/infrastructure/config/observability.d.ts +10 -0
- package/dist/infrastructure/config/observability.d.ts.map +1 -0
- package/dist/infrastructure/config/observability.js +11 -0
- package/dist/infrastructure/config/observability.js.map +1 -0
- package/dist/infrastructure/config/retention.d.ts +5 -0
- package/dist/infrastructure/config/retention.d.ts.map +1 -0
- package/dist/infrastructure/config/retention.js +15 -0
- package/dist/infrastructure/config/retention.js.map +1 -0
- package/dist/infrastructure/config/runners.d.ts +5 -0
- package/dist/infrastructure/config/runners.d.ts.map +1 -0
- package/dist/infrastructure/config/runners.js +13 -0
- package/dist/infrastructure/config/runners.js.map +1 -0
- package/dist/infrastructure/config/slack.d.ts +5 -0
- package/dist/infrastructure/config/slack.d.ts.map +1 -0
- package/dist/infrastructure/config/slack.js +17 -0
- package/dist/infrastructure/config/slack.js.map +1 -0
- package/dist/infrastructure/config/spending.d.ts +4 -0
- package/dist/infrastructure/config/spending.d.ts.map +1 -0
- package/dist/infrastructure/config/spending.js +36 -0
- package/dist/infrastructure/config/spending.js.map +1 -0
- package/dist/infrastructure/config/tasks.d.ts +5 -0
- package/dist/infrastructure/config/tasks.d.ts.map +1 -0
- package/dist/infrastructure/config/tasks.js +31 -0
- package/dist/infrastructure/config/tasks.js.map +1 -0
- package/dist/infrastructure/config/utils.d.ts +6 -0
- package/dist/infrastructure/config/utils.d.ts.map +1 -0
- package/dist/infrastructure/config/utils.js +24 -0
- package/dist/infrastructure/config/utils.js.map +1 -0
- package/dist/infrastructure/container.d.ts +8 -0
- package/dist/infrastructure/container.d.ts.map +1 -0
- package/dist/infrastructure/container.js +1157 -0
- package/dist/infrastructure/container.js.map +1 -0
- package/dist/infrastructure/containers/CloudflareContainerTransport.d.ts +22 -0
- package/dist/infrastructure/containers/CloudflareContainerTransport.d.ts.map +1 -0
- package/dist/infrastructure/containers/CloudflareContainerTransport.js +129 -0
- package/dist/infrastructure/containers/CloudflareContainerTransport.js.map +1 -0
- package/dist/infrastructure/containers/ContainerInstanceRegistry.d.ts +62 -0
- package/dist/infrastructure/containers/ContainerInstanceRegistry.d.ts.map +1 -0
- package/dist/infrastructure/containers/ContainerInstanceRegistry.js +74 -0
- package/dist/infrastructure/containers/ContainerInstanceRegistry.js.map +1 -0
- package/dist/infrastructure/containers/ContainerSessionService.d.ts +2 -0
- package/dist/infrastructure/containers/ContainerSessionService.d.ts.map +1 -0
- package/dist/infrastructure/containers/ContainerSessionService.js +3 -0
- package/dist/infrastructure/containers/ContainerSessionService.js.map +1 -0
- package/dist/infrastructure/containers/ExecutionContainer.d.ts +48 -0
- package/dist/infrastructure/containers/ExecutionContainer.d.ts.map +1 -0
- package/dist/infrastructure/containers/ExecutionContainer.js +88 -0
- package/dist/infrastructure/containers/ExecutionContainer.js.map +1 -0
- package/dist/infrastructure/documents/ConfluenceProvider.d.ts +29 -0
- package/dist/infrastructure/documents/ConfluenceProvider.d.ts.map +1 -0
- package/dist/infrastructure/documents/ConfluenceProvider.js +179 -0
- package/dist/infrastructure/documents/ConfluenceProvider.js.map +1 -0
- package/dist/infrastructure/documents/GitHubDocsProvider.d.ts +42 -0
- package/dist/infrastructure/documents/GitHubDocsProvider.d.ts.map +1 -0
- package/dist/infrastructure/documents/GitHubDocsProvider.js +85 -0
- package/dist/infrastructure/documents/GitHubDocsProvider.js.map +1 -0
- package/dist/infrastructure/documents/NotionProvider.d.ts +32 -0
- package/dist/infrastructure/documents/NotionProvider.d.ts.map +1 -0
- package/dist/infrastructure/documents/NotionProvider.js +220 -0
- package/dist/infrastructure/documents/NotionProvider.js.map +1 -0
- package/dist/infrastructure/durable-objects/WorkspaceEventsHub.d.ts +20 -0
- package/dist/infrastructure/durable-objects/WorkspaceEventsHub.d.ts.map +1 -0
- package/dist/infrastructure/durable-objects/WorkspaceEventsHub.js +62 -0
- package/dist/infrastructure/durable-objects/WorkspaceEventsHub.js.map +1 -0
- package/dist/infrastructure/env.d.ts +370 -0
- package/dist/infrastructure/env.d.ts.map +1 -0
- package/dist/infrastructure/env.js +2 -0
- package/dist/infrastructure/env.js.map +1 -0
- package/dist/infrastructure/environments/HttpEnvironmentProvider.d.ts +27 -0
- package/dist/infrastructure/environments/HttpEnvironmentProvider.d.ts.map +1 -0
- package/dist/infrastructure/environments/HttpEnvironmentProvider.js +314 -0
- package/dist/infrastructure/environments/HttpEnvironmentProvider.js.map +1 -0
- package/dist/infrastructure/environments/WebCryptoSecretCipher.d.ts +2 -0
- package/dist/infrastructure/environments/WebCryptoSecretCipher.d.ts.map +1 -0
- package/dist/infrastructure/environments/WebCryptoSecretCipher.js +5 -0
- package/dist/infrastructure/environments/WebCryptoSecretCipher.js.map +1 -0
- package/dist/infrastructure/environments/sweep.d.ts +5 -0
- package/dist/infrastructure/environments/sweep.d.ts.map +1 -0
- package/dist/infrastructure/environments/sweep.js +16 -0
- package/dist/infrastructure/environments/sweep.js.map +1 -0
- package/dist/infrastructure/events/DurableObjectEventPublisher.d.ts +25 -0
- package/dist/infrastructure/events/DurableObjectEventPublisher.d.ts.map +1 -0
- package/dist/infrastructure/events/DurableObjectEventPublisher.js +64 -0
- package/dist/infrastructure/events/DurableObjectEventPublisher.js.map +1 -0
- package/dist/infrastructure/events/InAppNotificationChannel.d.ts +19 -0
- package/dist/infrastructure/events/InAppNotificationChannel.d.ts.map +1 -0
- package/dist/infrastructure/events/InAppNotificationChannel.js +22 -0
- package/dist/infrastructure/events/InAppNotificationChannel.js.map +1 -0
- package/dist/infrastructure/gateways/DoRealtimeGateway.d.ts +15 -0
- package/dist/infrastructure/gateways/DoRealtimeGateway.d.ts.map +1 -0
- package/dist/infrastructure/gateways/DoRealtimeGateway.js +20 -0
- package/dist/infrastructure/gateways/DoRealtimeGateway.js.map +1 -0
- package/dist/infrastructure/gateways/GitHubGateways.d.ts +27 -0
- package/dist/infrastructure/gateways/GitHubGateways.d.ts.map +1 -0
- package/dist/infrastructure/gateways/GitHubGateways.js +48 -0
- package/dist/infrastructure/gateways/GitHubGateways.js.map +1 -0
- package/dist/infrastructure/github/FetchGitHubClient.d.ts +2 -0
- package/dist/infrastructure/github/FetchGitHubClient.d.ts.map +1 -0
- package/dist/infrastructure/github/FetchGitHubClient.js +4 -0
- package/dist/infrastructure/github/FetchGitHubClient.js.map +1 -0
- package/dist/infrastructure/github/FetchGitHubProvisioningClient.d.ts +2 -0
- package/dist/infrastructure/github/FetchGitHubProvisioningClient.d.ts.map +1 -0
- package/dist/infrastructure/github/FetchGitHubProvisioningClient.js +5 -0
- package/dist/infrastructure/github/FetchGitHubProvisioningClient.js.map +1 -0
- package/dist/infrastructure/github/GitHubAppAuth.d.ts +2 -0
- package/dist/infrastructure/github/GitHubAppAuth.d.ts.map +1 -0
- package/dist/infrastructure/github/GitHubAppAuth.js +5 -0
- package/dist/infrastructure/github/GitHubAppAuth.js.map +1 -0
- package/dist/infrastructure/github/GitHubAppRegistry.d.ts +2 -0
- package/dist/infrastructure/github/GitHubAppRegistry.d.ts.map +1 -0
- package/dist/infrastructure/github/GitHubAppRegistry.js +4 -0
- package/dist/infrastructure/github/GitHubAppRegistry.js.map +1 -0
- package/dist/infrastructure/github/GitHubCiStatusProvider.d.ts +2 -0
- package/dist/infrastructure/github/GitHubCiStatusProvider.d.ts.map +1 -0
- package/dist/infrastructure/github/GitHubCiStatusProvider.js +4 -0
- package/dist/infrastructure/github/GitHubCiStatusProvider.js.map +1 -0
- package/dist/infrastructure/github/GitHubMergeabilityProvider.d.ts +2 -0
- package/dist/infrastructure/github/GitHubMergeabilityProvider.d.ts.map +1 -0
- package/dist/infrastructure/github/GitHubMergeabilityProvider.js +4 -0
- package/dist/infrastructure/github/GitHubMergeabilityProvider.js.map +1 -0
- package/dist/infrastructure/github/GitHubPullRequestMerger.d.ts +2 -0
- package/dist/infrastructure/github/GitHubPullRequestMerger.d.ts.map +1 -0
- package/dist/infrastructure/github/GitHubPullRequestMerger.js +4 -0
- package/dist/infrastructure/github/GitHubPullRequestMerger.js.map +1 -0
- package/dist/infrastructure/github/WebCryptoWebhookVerifier.d.ts +2 -0
- package/dist/infrastructure/github/WebCryptoWebhookVerifier.d.ts.map +1 -0
- package/dist/infrastructure/github/WebCryptoWebhookVerifier.js +5 -0
- package/dist/infrastructure/github/WebCryptoWebhookVerifier.js.map +1 -0
- package/dist/infrastructure/github/encoding.d.ts +2 -0
- package/dist/infrastructure/github/encoding.d.ts.map +1 -0
- package/dist/infrastructure/github/encoding.js +3 -0
- package/dist/infrastructure/github/encoding.js.map +1 -0
- package/dist/infrastructure/github/state.d.ts +2 -0
- package/dist/infrastructure/github/state.d.ts.map +1 -0
- package/dist/infrastructure/github/state.js +3 -0
- package/dist/infrastructure/github/state.js.map +1 -0
- package/dist/infrastructure/github/sync-consumer.d.ts +16 -0
- package/dist/infrastructure/github/sync-consumer.d.ts.map +1 -0
- package/dist/infrastructure/github/sync-consumer.js +130 -0
- package/dist/infrastructure/github/sync-consumer.js.map +1 -0
- package/dist/infrastructure/http/errorHandler.d.ts +2 -0
- package/dist/infrastructure/http/errorHandler.d.ts.map +1 -0
- package/dist/infrastructure/http/errorHandler.js +3 -0
- package/dist/infrastructure/http/errorHandler.js.map +1 -0
- package/dist/infrastructure/http/params.d.ts +2 -0
- package/dist/infrastructure/http/params.d.ts.map +1 -0
- package/dist/infrastructure/http/params.js +3 -0
- package/dist/infrastructure/http/params.js.map +1 -0
- package/dist/infrastructure/http/types.d.ts +12 -0
- package/dist/infrastructure/http/types.d.ts.map +1 -0
- package/dist/infrastructure/http/types.js +2 -0
- package/dist/infrastructure/http/types.js.map +1 -0
- package/dist/infrastructure/http/validation.d.ts +2 -0
- package/dist/infrastructure/http/validation.d.ts.map +1 -0
- package/dist/infrastructure/http/validation.js +3 -0
- package/dist/infrastructure/http/validation.js.map +1 -0
- package/dist/infrastructure/observability/logger.d.ts +3 -0
- package/dist/infrastructure/observability/logger.d.ts.map +1 -0
- package/dist/infrastructure/observability/logger.js +4 -0
- package/dist/infrastructure/observability/logger.js.map +1 -0
- package/dist/infrastructure/repositories/D1AccountInvitationRepository.d.ts +15 -0
- package/dist/infrastructure/repositories/D1AccountInvitationRepository.d.ts.map +1 -0
- package/dist/infrastructure/repositories/D1AccountInvitationRepository.js +63 -0
- package/dist/infrastructure/repositories/D1AccountInvitationRepository.js.map +1 -0
- package/dist/infrastructure/repositories/D1AccountRepository.d.ts +15 -0
- package/dist/infrastructure/repositories/D1AccountRepository.d.ts.map +1 -0
- package/dist/infrastructure/repositories/D1AccountRepository.js +52 -0
- package/dist/infrastructure/repositories/D1AccountRepository.js.map +1 -0
- package/dist/infrastructure/repositories/D1AgentRunRepository.d.ts +18 -0
- package/dist/infrastructure/repositories/D1AgentRunRepository.d.ts.map +1 -0
- package/dist/infrastructure/repositories/D1AgentRunRepository.js +34 -0
- package/dist/infrastructure/repositories/D1AgentRunRepository.js.map +1 -0
- package/dist/infrastructure/repositories/D1BlockRepository.d.ts +23 -0
- package/dist/infrastructure/repositories/D1BlockRepository.d.ts.map +1 -0
- package/dist/infrastructure/repositories/D1BlockRepository.js +101 -0
- package/dist/infrastructure/repositories/D1BlockRepository.js.map +1 -0
- package/dist/infrastructure/repositories/D1BootstrapJobRepository.d.ts +16 -0
- package/dist/infrastructure/repositories/D1BootstrapJobRepository.d.ts.map +1 -0
- package/dist/infrastructure/repositories/D1BootstrapJobRepository.js +209 -0
- package/dist/infrastructure/repositories/D1BootstrapJobRepository.js.map +1 -0
- package/dist/infrastructure/repositories/D1BranchProjectionRepository.d.ts +12 -0
- package/dist/infrastructure/repositories/D1BranchProjectionRepository.d.ts.map +1 -0
- package/dist/infrastructure/repositories/D1BranchProjectionRepository.js +29 -0
- package/dist/infrastructure/repositories/D1BranchProjectionRepository.js.map +1 -0
- package/dist/infrastructure/repositories/D1CheckRunProjectionRepository.d.ts +12 -0
- package/dist/infrastructure/repositories/D1CheckRunProjectionRepository.d.ts.map +1 -0
- package/dist/infrastructure/repositories/D1CheckRunProjectionRepository.js +29 -0
- package/dist/infrastructure/repositories/D1CheckRunProjectionRepository.js.map +1 -0
- package/dist/infrastructure/repositories/D1ClarityReviewRepository.d.ts +19 -0
- package/dist/infrastructure/repositories/D1ClarityReviewRepository.d.ts.map +1 -0
- package/dist/infrastructure/repositories/D1ClarityReviewRepository.js +75 -0
- package/dist/infrastructure/repositories/D1ClarityReviewRepository.js.map +1 -0
- package/dist/infrastructure/repositories/D1CommitProjectionRepository.d.ts +13 -0
- package/dist/infrastructure/repositories/D1CommitProjectionRepository.d.ts.map +1 -0
- package/dist/infrastructure/repositories/D1CommitProjectionRepository.js +48 -0
- package/dist/infrastructure/repositories/D1CommitProjectionRepository.js.map +1 -0
- package/dist/infrastructure/repositories/D1ConsensusSessionRepository.d.ts +19 -0
- package/dist/infrastructure/repositories/D1ConsensusSessionRepository.d.ts.map +1 -0
- package/dist/infrastructure/repositories/D1ConsensusSessionRepository.js +88 -0
- package/dist/infrastructure/repositories/D1ConsensusSessionRepository.js.map +1 -0
- package/dist/infrastructure/repositories/D1DatadogConnectionRepository.d.ts +17 -0
- package/dist/infrastructure/repositories/D1DatadogConnectionRepository.d.ts.map +1 -0
- package/dist/infrastructure/repositories/D1DatadogConnectionRepository.js +47 -0
- package/dist/infrastructure/repositories/D1DatadogConnectionRepository.js.map +1 -0
- package/dist/infrastructure/repositories/D1DocumentConnectionRepository.d.ts +27 -0
- package/dist/infrastructure/repositories/D1DocumentConnectionRepository.d.ts.map +1 -0
- package/dist/infrastructure/repositories/D1DocumentConnectionRepository.js +89 -0
- package/dist/infrastructure/repositories/D1DocumentConnectionRepository.js.map +1 -0
- package/dist/infrastructure/repositories/D1DocumentRepository.d.ts +15 -0
- package/dist/infrastructure/repositories/D1DocumentRepository.d.ts.map +1 -0
- package/dist/infrastructure/repositories/D1DocumentRepository.js +66 -0
- package/dist/infrastructure/repositories/D1DocumentRepository.js.map +1 -0
- package/dist/infrastructure/repositories/D1EmailConnectionRepository.d.ts +13 -0
- package/dist/infrastructure/repositories/D1EmailConnectionRepository.d.ts.map +1 -0
- package/dist/infrastructure/repositories/D1EmailConnectionRepository.js +46 -0
- package/dist/infrastructure/repositories/D1EmailConnectionRepository.js.map +1 -0
- package/dist/infrastructure/repositories/D1EnvironmentConnectionRepository.d.ts +13 -0
- package/dist/infrastructure/repositories/D1EnvironmentConnectionRepository.d.ts.map +1 -0
- package/dist/infrastructure/repositories/D1EnvironmentConnectionRepository.js +48 -0
- package/dist/infrastructure/repositories/D1EnvironmentConnectionRepository.js.map +1 -0
- package/dist/infrastructure/repositories/D1EnvironmentRegistryRepository.d.ts +17 -0
- package/dist/infrastructure/repositories/D1EnvironmentRegistryRepository.d.ts.map +1 -0
- package/dist/infrastructure/repositories/D1EnvironmentRegistryRepository.js +95 -0
- package/dist/infrastructure/repositories/D1EnvironmentRegistryRepository.js.map +1 -0
- package/dist/infrastructure/repositories/D1ExecutionRepository.d.ts +28 -0
- package/dist/infrastructure/repositories/D1ExecutionRepository.d.ts.map +1 -0
- package/dist/infrastructure/repositories/D1ExecutionRepository.js +113 -0
- package/dist/infrastructure/repositories/D1ExecutionRepository.js.map +1 -0
- package/dist/infrastructure/repositories/D1FragmentSourceRepository.d.ts +15 -0
- package/dist/infrastructure/repositories/D1FragmentSourceRepository.d.ts.map +1 -0
- package/dist/infrastructure/repositories/D1FragmentSourceRepository.js +66 -0
- package/dist/infrastructure/repositories/D1FragmentSourceRepository.js.map +1 -0
- package/dist/infrastructure/repositories/D1GitHubInstallationRepository.d.ts +17 -0
- package/dist/infrastructure/repositories/D1GitHubInstallationRepository.d.ts.map +1 -0
- package/dist/infrastructure/repositories/D1GitHubInstallationRepository.js +79 -0
- package/dist/infrastructure/repositories/D1GitHubInstallationRepository.js.map +1 -0
- package/dist/infrastructure/repositories/D1IssueProjectionRepository.d.ts +13 -0
- package/dist/infrastructure/repositories/D1IssueProjectionRepository.d.ts.map +1 -0
- package/dist/infrastructure/repositories/D1IssueProjectionRepository.js +36 -0
- package/dist/infrastructure/repositories/D1IssueProjectionRepository.js.map +1 -0
- package/dist/infrastructure/repositories/D1LiveContainerRepository.d.ts +17 -0
- package/dist/infrastructure/repositories/D1LiveContainerRepository.d.ts.map +1 -0
- package/dist/infrastructure/repositories/D1LiveContainerRepository.js +40 -0
- package/dist/infrastructure/repositories/D1LiveContainerRepository.js.map +1 -0
- package/dist/infrastructure/repositories/D1LlmCallMetricRepository.d.ts +15 -0
- package/dist/infrastructure/repositories/D1LlmCallMetricRepository.d.ts.map +1 -0
- package/dist/infrastructure/repositories/D1LlmCallMetricRepository.js +123 -0
- package/dist/infrastructure/repositories/D1LlmCallMetricRepository.js.map +1 -0
- package/dist/infrastructure/repositories/D1LocalModelEndpointRepository.d.ts +15 -0
- package/dist/infrastructure/repositories/D1LocalModelEndpointRepository.d.ts.map +1 -0
- package/dist/infrastructure/repositories/D1LocalModelEndpointRepository.js +63 -0
- package/dist/infrastructure/repositories/D1LocalModelEndpointRepository.js.map +1 -0
- package/dist/infrastructure/repositories/D1MembershipRepository.d.ts +15 -0
- package/dist/infrastructure/repositories/D1MembershipRepository.d.ts.map +1 -0
- package/dist/infrastructure/repositories/D1MembershipRepository.js +58 -0
- package/dist/infrastructure/repositories/D1MembershipRepository.js.map +1 -0
- package/dist/infrastructure/repositories/D1MergePresetRepository.d.ts +21 -0
- package/dist/infrastructure/repositories/D1MergePresetRepository.d.ts.map +1 -0
- package/dist/infrastructure/repositories/D1MergePresetRepository.js +88 -0
- package/dist/infrastructure/repositories/D1MergePresetRepository.js.map +1 -0
- package/dist/infrastructure/repositories/D1ModelDefaultsRepository.d.ts +18 -0
- package/dist/infrastructure/repositories/D1ModelDefaultsRepository.d.ts.map +1 -0
- package/dist/infrastructure/repositories/D1ModelDefaultsRepository.js +47 -0
- package/dist/infrastructure/repositories/D1ModelDefaultsRepository.js.map +1 -0
- package/dist/infrastructure/repositories/D1NotificationRepository.d.ts +20 -0
- package/dist/infrastructure/repositories/D1NotificationRepository.d.ts.map +1 -0
- package/dist/infrastructure/repositories/D1NotificationRepository.js +81 -0
- package/dist/infrastructure/repositories/D1NotificationRepository.js.map +1 -0
- package/dist/infrastructure/repositories/D1PersonalSubscriptionRepository.d.ts +28 -0
- package/dist/infrastructure/repositories/D1PersonalSubscriptionRepository.d.ts.map +1 -0
- package/dist/infrastructure/repositories/D1PersonalSubscriptionRepository.js +142 -0
- package/dist/infrastructure/repositories/D1PersonalSubscriptionRepository.js.map +1 -0
- package/dist/infrastructure/repositories/D1PipelineRepository.d.ts +15 -0
- package/dist/infrastructure/repositories/D1PipelineRepository.d.ts.map +1 -0
- package/dist/infrastructure/repositories/D1PipelineRepository.js +46 -0
- package/dist/infrastructure/repositories/D1PipelineRepository.js.map +1 -0
- package/dist/infrastructure/repositories/D1PipelineScheduleRepository.d.ts +26 -0
- package/dist/infrastructure/repositories/D1PipelineScheduleRepository.d.ts.map +1 -0
- package/dist/infrastructure/repositories/D1PipelineScheduleRepository.js +192 -0
- package/dist/infrastructure/repositories/D1PipelineScheduleRepository.js.map +1 -0
- package/dist/infrastructure/repositories/D1PromptFragmentRepository.d.ts +15 -0
- package/dist/infrastructure/repositories/D1PromptFragmentRepository.d.ts.map +1 -0
- package/dist/infrastructure/repositories/D1PromptFragmentRepository.js +90 -0
- package/dist/infrastructure/repositories/D1PromptFragmentRepository.js.map +1 -0
- package/dist/infrastructure/repositories/D1ProviderApiKeyRepository.d.ts +21 -0
- package/dist/infrastructure/repositories/D1ProviderApiKeyRepository.d.ts.map +1 -0
- package/dist/infrastructure/repositories/D1ProviderApiKeyRepository.js +108 -0
- package/dist/infrastructure/repositories/D1ProviderApiKeyRepository.js.map +1 -0
- package/dist/infrastructure/repositories/D1ProviderSubscriptionTokenRepository.d.ts +19 -0
- package/dist/infrastructure/repositories/D1ProviderSubscriptionTokenRepository.d.ts.map +1 -0
- package/dist/infrastructure/repositories/D1ProviderSubscriptionTokenRepository.js +78 -0
- package/dist/infrastructure/repositories/D1ProviderSubscriptionTokenRepository.js.map +1 -0
- package/dist/infrastructure/repositories/D1PullRequestProjectionRepository.d.ts +13 -0
- package/dist/infrastructure/repositories/D1PullRequestProjectionRepository.d.ts.map +1 -0
- package/dist/infrastructure/repositories/D1PullRequestProjectionRepository.js +32 -0
- package/dist/infrastructure/repositories/D1PullRequestProjectionRepository.js.map +1 -0
- package/dist/infrastructure/repositories/D1RateLimitRepository.d.ts +18 -0
- package/dist/infrastructure/repositories/D1RateLimitRepository.d.ts.map +1 -0
- package/dist/infrastructure/repositories/D1RateLimitRepository.js +30 -0
- package/dist/infrastructure/repositories/D1RateLimitRepository.js.map +1 -0
- package/dist/infrastructure/repositories/D1ReferenceArchitectureRepository.d.ts +15 -0
- package/dist/infrastructure/repositories/D1ReferenceArchitectureRepository.d.ts.map +1 -0
- package/dist/infrastructure/repositories/D1ReferenceArchitectureRepository.js +77 -0
- package/dist/infrastructure/repositories/D1ReferenceArchitectureRepository.js.map +1 -0
- package/dist/infrastructure/repositories/D1ReleaseHealthConfigRepository.d.ts +17 -0
- package/dist/infrastructure/repositories/D1ReleaseHealthConfigRepository.d.ts.map +1 -0
- package/dist/infrastructure/repositories/D1ReleaseHealthConfigRepository.js +64 -0
- package/dist/infrastructure/repositories/D1ReleaseHealthConfigRepository.js.map +1 -0
- package/dist/infrastructure/repositories/D1RepoBlueprintRepository.d.ts +20 -0
- package/dist/infrastructure/repositories/D1RepoBlueprintRepository.d.ts.map +1 -0
- package/dist/infrastructure/repositories/D1RepoBlueprintRepository.js +64 -0
- package/dist/infrastructure/repositories/D1RepoBlueprintRepository.js.map +1 -0
- package/dist/infrastructure/repositories/D1RepoProjectionRepository.d.ts +20 -0
- package/dist/infrastructure/repositories/D1RepoProjectionRepository.d.ts.map +1 -0
- package/dist/infrastructure/repositories/D1RepoProjectionRepository.js +121 -0
- package/dist/infrastructure/repositories/D1RepoProjectionRepository.js.map +1 -0
- package/dist/infrastructure/repositories/D1RequirementReviewRepository.d.ts +20 -0
- package/dist/infrastructure/repositories/D1RequirementReviewRepository.d.ts.map +1 -0
- package/dist/infrastructure/repositories/D1RequirementReviewRepository.js +76 -0
- package/dist/infrastructure/repositories/D1RequirementReviewRepository.js.map +1 -0
- package/dist/infrastructure/repositories/D1RunnerPoolConnectionRepository.d.ts +13 -0
- package/dist/infrastructure/repositories/D1RunnerPoolConnectionRepository.d.ts.map +1 -0
- package/dist/infrastructure/repositories/D1RunnerPoolConnectionRepository.js +48 -0
- package/dist/infrastructure/repositories/D1RunnerPoolConnectionRepository.js.map +1 -0
- package/dist/infrastructure/repositories/D1ServiceFragmentDefaultsRepository.d.ts +16 -0
- package/dist/infrastructure/repositories/D1ServiceFragmentDefaultsRepository.d.ts.map +1 -0
- package/dist/infrastructure/repositories/D1ServiceFragmentDefaultsRepository.js +27 -0
- package/dist/infrastructure/repositories/D1ServiceFragmentDefaultsRepository.js.map +1 -0
- package/dist/infrastructure/repositories/D1ServiceRepository.d.ts +19 -0
- package/dist/infrastructure/repositories/D1ServiceRepository.d.ts.map +1 -0
- package/dist/infrastructure/repositories/D1ServiceRepository.js +114 -0
- package/dist/infrastructure/repositories/D1ServiceRepository.js.map +1 -0
- package/dist/infrastructure/repositories/D1SlackRepositories.d.ts +29 -0
- package/dist/infrastructure/repositories/D1SlackRepositories.d.ts.map +1 -0
- package/dist/infrastructure/repositories/D1SlackRepositories.js +119 -0
- package/dist/infrastructure/repositories/D1SlackRepositories.js.map +1 -0
- package/dist/infrastructure/repositories/D1TaskConnectionRepository.d.ts +27 -0
- package/dist/infrastructure/repositories/D1TaskConnectionRepository.d.ts.map +1 -0
- package/dist/infrastructure/repositories/D1TaskConnectionRepository.js +89 -0
- package/dist/infrastructure/repositories/D1TaskConnectionRepository.js.map +1 -0
- package/dist/infrastructure/repositories/D1TaskRepository.d.ts +15 -0
- package/dist/infrastructure/repositories/D1TaskRepository.d.ts.map +1 -0
- package/dist/infrastructure/repositories/D1TaskRepository.js +90 -0
- package/dist/infrastructure/repositories/D1TaskRepository.js.map +1 -0
- package/dist/infrastructure/repositories/D1TokenUsageRepository.d.ts +13 -0
- package/dist/infrastructure/repositories/D1TokenUsageRepository.d.ts.map +1 -0
- package/dist/infrastructure/repositories/D1TokenUsageRepository.js +41 -0
- package/dist/infrastructure/repositories/D1TokenUsageRepository.js.map +1 -0
- package/dist/infrastructure/repositories/D1TrackerSettingsRepository.d.ts +12 -0
- package/dist/infrastructure/repositories/D1TrackerSettingsRepository.d.ts.map +1 -0
- package/dist/infrastructure/repositories/D1TrackerSettingsRepository.js +32 -0
- package/dist/infrastructure/repositories/D1TrackerSettingsRepository.js.map +1 -0
- package/dist/infrastructure/repositories/D1UserRepository.d.ts +19 -0
- package/dist/infrastructure/repositories/D1UserRepository.d.ts.map +1 -0
- package/dist/infrastructure/repositories/D1UserRepository.js +108 -0
- package/dist/infrastructure/repositories/D1UserRepository.js.map +1 -0
- package/dist/infrastructure/repositories/D1WorkspaceMountRepository.d.ts +19 -0
- package/dist/infrastructure/repositories/D1WorkspaceMountRepository.d.ts.map +1 -0
- package/dist/infrastructure/repositories/D1WorkspaceMountRepository.js +115 -0
- package/dist/infrastructure/repositories/D1WorkspaceMountRepository.js.map +1 -0
- package/dist/infrastructure/repositories/D1WorkspaceRepository.d.ts +18 -0
- package/dist/infrastructure/repositories/D1WorkspaceRepository.d.ts.map +1 -0
- package/dist/infrastructure/repositories/D1WorkspaceRepository.js +77 -0
- package/dist/infrastructure/repositories/D1WorkspaceRepository.js.map +1 -0
- package/dist/infrastructure/repositories/D1WorkspaceSettingsRepository.d.ts +17 -0
- package/dist/infrastructure/repositories/D1WorkspaceSettingsRepository.d.ts.map +1 -0
- package/dist/infrastructure/repositories/D1WorkspaceSettingsRepository.js +50 -0
- package/dist/infrastructure/repositories/D1WorkspaceSettingsRepository.js.map +1 -0
- package/dist/infrastructure/repositories/chunk.d.ts +11 -0
- package/dist/infrastructure/repositories/chunk.d.ts.map +1 -0
- package/dist/infrastructure/repositories/chunk.js +17 -0
- package/dist/infrastructure/repositories/chunk.js.map +1 -0
- package/dist/infrastructure/repositories/github-mappers/branch.d.ts +11 -0
- package/dist/infrastructure/repositories/github-mappers/branch.d.ts.map +1 -0
- package/dist/infrastructure/repositories/github-mappers/branch.js +22 -0
- package/dist/infrastructure/repositories/github-mappers/branch.js.map +1 -0
- package/dist/infrastructure/repositories/github-mappers/check-run.d.ts +13 -0
- package/dist/infrastructure/repositories/github-mappers/check-run.d.ts.map +1 -0
- package/dist/infrastructure/repositories/github-mappers/check-run.js +24 -0
- package/dist/infrastructure/repositories/github-mappers/check-run.js.map +1 -0
- package/dist/infrastructure/repositories/github-mappers/commit.d.ts +12 -0
- package/dist/infrastructure/repositories/github-mappers/commit.d.ts.map +1 -0
- package/dist/infrastructure/repositories/github-mappers/commit.js +22 -0
- package/dist/infrastructure/repositories/github-mappers/commit.js.map +1 -0
- package/dist/infrastructure/repositories/github-mappers/index.d.ts +11 -0
- package/dist/infrastructure/repositories/github-mappers/index.d.ts.map +1 -0
- package/dist/infrastructure/repositories/github-mappers/index.js +14 -0
- package/dist/infrastructure/repositories/github-mappers/index.js.map +1 -0
- package/dist/infrastructure/repositories/github-mappers/installation.d.ts +16 -0
- package/dist/infrastructure/repositories/github-mappers/installation.d.ts.map +1 -0
- package/dist/infrastructure/repositories/github-mappers/installation.js +29 -0
- package/dist/infrastructure/repositories/github-mappers/installation.js.map +1 -0
- package/dist/infrastructure/repositories/github-mappers/issue.d.ts +15 -0
- package/dist/infrastructure/repositories/github-mappers/issue.d.ts.map +1 -0
- package/dist/infrastructure/repositories/github-mappers/issue.js +29 -0
- package/dist/infrastructure/repositories/github-mappers/issue.js.map +1 -0
- package/dist/infrastructure/repositories/github-mappers/pull-request.d.ts +18 -0
- package/dist/infrastructure/repositories/github-mappers/pull-request.d.ts.map +1 -0
- package/dist/infrastructure/repositories/github-mappers/pull-request.js +36 -0
- package/dist/infrastructure/repositories/github-mappers/pull-request.js.map +1 -0
- package/dist/infrastructure/repositories/github-mappers/repo.d.ts +15 -0
- package/dist/infrastructure/repositories/github-mappers/repo.d.ts.map +1 -0
- package/dist/infrastructure/repositories/github-mappers/repo.js +31 -0
- package/dist/infrastructure/repositories/github-mappers/repo.js.map +1 -0
- package/dist/infrastructure/repositories/github-mappers/serialize.d.ts +3 -0
- package/dist/infrastructure/repositories/github-mappers/serialize.d.ts.map +1 -0
- package/dist/infrastructure/repositories/github-mappers/serialize.js +4 -0
- package/dist/infrastructure/repositories/github-mappers/serialize.js.map +1 -0
- package/dist/infrastructure/repositories/github-mappers/sync-cursor.d.ts +8 -0
- package/dist/infrastructure/repositories/github-mappers/sync-cursor.d.ts.map +1 -0
- package/dist/infrastructure/repositories/github-mappers/sync-cursor.js +4 -0
- package/dist/infrastructure/repositories/github-mappers/sync-cursor.js.map +1 -0
- package/dist/infrastructure/repositories/github-mappers/upsert.d.ts +11 -0
- package/dist/infrastructure/repositories/github-mappers/upsert.d.ts.map +1 -0
- package/dist/infrastructure/repositories/github-mappers/upsert.js +18 -0
- package/dist/infrastructure/repositories/github-mappers/upsert.js.map +1 -0
- package/dist/infrastructure/repositories/mappers.d.ts +2 -0
- package/dist/infrastructure/repositories/mappers.d.ts.map +1 -0
- package/dist/infrastructure/repositories/mappers.js +4 -0
- package/dist/infrastructure/repositories/mappers.js.map +1 -0
- package/dist/infrastructure/runners/HttpRunnerPoolProvider.d.ts +2 -0
- package/dist/infrastructure/runners/HttpRunnerPoolProvider.d.ts.map +1 -0
- package/dist/infrastructure/runners/HttpRunnerPoolProvider.js +5 -0
- package/dist/infrastructure/runners/HttpRunnerPoolProvider.js.map +1 -0
- package/dist/infrastructure/runners/RunnerPoolTransport.d.ts +2 -0
- package/dist/infrastructure/runners/RunnerPoolTransport.d.ts.map +1 -0
- package/dist/infrastructure/runners/RunnerPoolTransport.js +5 -0
- package/dist/infrastructure/runners/RunnerPoolTransport.js.map +1 -0
- package/dist/infrastructure/runtime.d.ts +8 -0
- package/dist/infrastructure/runtime.d.ts.map +1 -0
- package/dist/infrastructure/runtime.js +13 -0
- package/dist/infrastructure/runtime.js.map +1 -0
- package/dist/infrastructure/tasks/GitHubIssuesProvider.d.ts +50 -0
- package/dist/infrastructure/tasks/GitHubIssuesProvider.d.ts.map +1 -0
- package/dist/infrastructure/tasks/GitHubIssuesProvider.js +91 -0
- package/dist/infrastructure/tasks/GitHubIssuesProvider.js.map +1 -0
- package/dist/infrastructure/tasks/JiraProvider.d.ts +29 -0
- package/dist/infrastructure/tasks/JiraProvider.d.ts.map +1 -0
- package/dist/infrastructure/tasks/JiraProvider.js +109 -0
- package/dist/infrastructure/tasks/JiraProvider.js.map +1 -0
- package/dist/infrastructure/workflows/BootstrapWorkflow.d.ts +21 -0
- package/dist/infrastructure/workflows/BootstrapWorkflow.d.ts.map +1 -0
- package/dist/infrastructure/workflows/BootstrapWorkflow.js +72 -0
- package/dist/infrastructure/workflows/BootstrapWorkflow.js.map +1 -0
- package/dist/infrastructure/workflows/ExecutionWorkflow.d.ts +15 -0
- package/dist/infrastructure/workflows/ExecutionWorkflow.d.ts.map +1 -0
- package/dist/infrastructure/workflows/ExecutionWorkflow.js +169 -0
- package/dist/infrastructure/workflows/ExecutionWorkflow.js.map +1 -0
- package/dist/infrastructure/workflows/GitHubBackfillWorkflow.d.ts +17 -0
- package/dist/infrastructure/workflows/GitHubBackfillWorkflow.d.ts.map +1 -0
- package/dist/infrastructure/workflows/GitHubBackfillWorkflow.js +24 -0
- package/dist/infrastructure/workflows/GitHubBackfillWorkflow.js.map +1 -0
- package/dist/infrastructure/workflows/WorkflowsBootstrapRunner.d.ts +15 -0
- package/dist/infrastructure/workflows/WorkflowsBootstrapRunner.d.ts.map +1 -0
- package/dist/infrastructure/workflows/WorkflowsBootstrapRunner.js +34 -0
- package/dist/infrastructure/workflows/WorkflowsBootstrapRunner.js.map +1 -0
- package/dist/infrastructure/workflows/WorkflowsWorkRunner.d.ts +31 -0
- package/dist/infrastructure/workflows/WorkflowsWorkRunner.d.ts.map +1 -0
- package/dist/infrastructure/workflows/WorkflowsWorkRunner.js +55 -0
- package/dist/infrastructure/workflows/WorkflowsWorkRunner.js.map +1 -0
- package/dist/infrastructure/workflows/retention.d.ts +35 -0
- package/dist/infrastructure/workflows/retention.d.ts.map +1 -0
- package/dist/infrastructure/workflows/retention.js +26 -0
- package/dist/infrastructure/workflows/retention.js.map +1 -0
- package/dist/infrastructure/workflows/sweeper.d.ts +57 -0
- package/dist/infrastructure/workflows/sweeper.d.ts.map +1 -0
- package/dist/infrastructure/workflows/sweeper.js +62 -0
- package/dist/infrastructure/workflows/sweeper.js.map +1 -0
- package/migrations/0001_init.sql +677 -0
- package/migrations/0002_clarity_reviews.sql +19 -0
- package/migrations/0002_consensus.sql +38 -0
- package/migrations/0002_llm_reasoning_text.sql +6 -0
- package/migrations/0002_local_model_endpoints.sql +16 -0
- package/migrations/0003_pipeline_labels_archive.sql +13 -0
- package/migrations/0003_release_health.sql +34 -0
- package/migrations/0004_run_timing_task_types.sql +24 -0
- package/package.json +65 -0
|
@@ -0,0 +1,486 @@
|
|
|
1
|
+
import { generateText, jsonSchema, tool, } from 'ai';
|
|
2
|
+
import { createWorkersAI } from 'workers-ai-provider';
|
|
3
|
+
import { resolveOpenAiCompatibleUpstream } from './providerEndpoints';
|
|
4
|
+
// The Worker's LLM-upstream gateway: resolves OpenAI-compatible providers from `env`
|
|
5
|
+
// keys, and serves the `workers-ai` provider in-process via the Cloudflare `AI`
|
|
6
|
+
// binding — translating between the OpenAI Chat Completions shape Pi speaks and the
|
|
7
|
+
// AI SDK. A Node facade would resolve providers over HTTP and have no in-process path
|
|
8
|
+
// (its runInProcess returns null), forwarding `workers-ai` is therefore unavailable.
|
|
9
|
+
export class WorkersAiLlmUpstream {
|
|
10
|
+
env;
|
|
11
|
+
constructor(env) {
|
|
12
|
+
this.env = env;
|
|
13
|
+
}
|
|
14
|
+
resolveOpenAiCompatible(provider) {
|
|
15
|
+
return resolveOpenAiCompatibleUpstream(provider, this.env);
|
|
16
|
+
}
|
|
17
|
+
runInProcess(request) {
|
|
18
|
+
if (!this.env.AI)
|
|
19
|
+
return null;
|
|
20
|
+
// Two binding shapes share the `workers-ai` provider id. A native Workers AI id
|
|
21
|
+
// (`@cf/...`) runs through the AI SDK + workers-ai-provider, which translates its
|
|
22
|
+
// bespoke I/O. A `<provider>/<model>` catalog slug (e.g. `deepseek/deepseek-v4-pro`,
|
|
23
|
+
// a unified-billing run-catalog model Cloudflare serves via a partner) is plain
|
|
24
|
+
// OpenAI Chat Completions on the binding, so it runs directly via `binding.run`.
|
|
25
|
+
if (isCatalogSlug(request.model)) {
|
|
26
|
+
return runCatalogModel({ binding: this.env.AI, ...request });
|
|
27
|
+
}
|
|
28
|
+
return runWorkersAi({ binding: this.env.AI, ...request });
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* A `<provider>/<model>` AI-catalog slug (e.g. `deepseek/deepseek-v4-pro`) rather than a
|
|
33
|
+
* native Workers AI id (`@cf/...`). Cloudflare serves these as unified-billing run-catalog
|
|
34
|
+
* models on the binding (and the `/ai/v1` REST endpoint) in the OpenAI Chat Completions
|
|
35
|
+
* shape, with the account's own token — no AI Gateway, no BYOK.
|
|
36
|
+
*/
|
|
37
|
+
function isCatalogSlug(model) {
|
|
38
|
+
return model.includes('/') && !model.startsWith('@');
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Serve a chat completion from Cloudflare Workers AI via the `AI` binding (no
|
|
42
|
+
* external HTTP, no provider key), translating the OpenAI Chat Completions
|
|
43
|
+
* request/response so Pi sees the same shape as the proxied providers. Honours
|
|
44
|
+
* `stream` and always reports usage so spend is metered.
|
|
45
|
+
*/
|
|
46
|
+
async function runWorkersAi(args) {
|
|
47
|
+
const { binding, model: modelId, payload, streaming, record, recordMetric, log } = args;
|
|
48
|
+
// Model-execution clock for the observability split: the in-process work the proxy
|
|
49
|
+
// attributes to the model (everything else it does is transport overhead).
|
|
50
|
+
const upstreamStart = Date.now();
|
|
51
|
+
// Native Workers AI (`@cf/...`) only; `<provider>/<model>` catalog slugs take the
|
|
52
|
+
// direct `binding.run` path in `runCatalogModel`, not the AI SDK.
|
|
53
|
+
const workersai = createWorkersAI({ binding });
|
|
54
|
+
// workers-ai-provider must implement the same provider spec as `ai`
|
|
55
|
+
// (`@ai-sdk/provider`); workers-ai-provider@3 matches `ai` v6, so the model is used
|
|
56
|
+
// directly with no cast. Keep these majors in lockstep.
|
|
57
|
+
const model = workersai(modelId);
|
|
58
|
+
// The AI SDK wants the system prompt in the dedicated `system` option, not as a
|
|
59
|
+
// `role:'system'` entry in `messages`. Split it out: system text → `system`.
|
|
60
|
+
const system = systemFromMessages(payload.messages);
|
|
61
|
+
const messages = toModelMessages(payload.messages);
|
|
62
|
+
const temperature = typeof payload.temperature === 'number' ? payload.temperature : undefined;
|
|
63
|
+
const maxOutputTokens = typeof payload.max_tokens === 'number' ? payload.max_tokens : undefined;
|
|
64
|
+
// Forward tool definitions so a tool-using agent (Pi) can act. The tools are
|
|
65
|
+
// declared WITHOUT an `execute` fn: the model emits the calls and we relay them.
|
|
66
|
+
const tools = toAiSdkTools(payload.tools);
|
|
67
|
+
const toolChoice = tools ? toToolChoice(payload.tool_choice) : undefined;
|
|
68
|
+
const common = {
|
|
69
|
+
model,
|
|
70
|
+
messages,
|
|
71
|
+
...(system ? { system } : {}),
|
|
72
|
+
temperature,
|
|
73
|
+
maxOutputTokens,
|
|
74
|
+
...(tools ? { tools } : {}),
|
|
75
|
+
...(toolChoice ? { toolChoice } : {}),
|
|
76
|
+
};
|
|
77
|
+
const id = `chatcmpl-${crypto.randomUUID()}`;
|
|
78
|
+
const created = Math.floor(Date.now() / 1000);
|
|
79
|
+
const usageOf = (u) => ({
|
|
80
|
+
prompt_tokens: u.inputTokens ?? 0,
|
|
81
|
+
completion_tokens: u.outputTokens ?? 0,
|
|
82
|
+
});
|
|
83
|
+
// Both the buffered and the streaming response are built from ONE `generateText`
|
|
84
|
+
// (non-streaming `doGenerate`) call — we deliberately do NOT use
|
|
85
|
+
// `streamText`/`result.textStream` here.
|
|
86
|
+
//
|
|
87
|
+
// Why: production telemetry (an `@cf/qwen/qwen3-*` reasoning model, `stream:true`)
|
|
88
|
+
// showed the streamed reply arriving with every token duplicated
|
|
89
|
+
// (`serviceservice…`), which fails every downstream JSON parse
|
|
90
|
+
// (requirements/blueprint/merger). The metrics localise the fault precisely: the
|
|
91
|
+
// recorded text was ~2× the reported `completion_tokens`, so the MODEL emitted each
|
|
92
|
+
// token once and the duplication happened during streamed-delta assembly — not in
|
|
93
|
+
// generation, not truncation, and not our SSE encoding (`fullText` was accumulated
|
|
94
|
+
// one `+= delta` per chunk). The exact component in the streaming path that doubles
|
|
95
|
+
// (the AI SDK, the workers-ai-provider stream decode, or the binding's raw SSE for
|
|
96
|
+
// this reasoning model) is NOT pinned down, and no upstream issue confirms it. The
|
|
97
|
+
// buffered path sidesteps the entire streamed-delta assembly, so it is robust
|
|
98
|
+
// regardless of which one is at fault. When the caller asked to stream we replay the
|
|
99
|
+
// single generation as one content chunk; Pi (and any OpenAI client) concatenates
|
|
100
|
+
// deltas, so a one-shot chunk is equivalent — the harness reads the final message,
|
|
101
|
+
// and live progress comes from the todo tool, not token streaming.
|
|
102
|
+
const { text, reasoningText, toolCalls, finishReason: rawFinish, usage, } = await generateText(common);
|
|
103
|
+
const reasoning = typeof reasoningText === 'string' ? reasoningText : '';
|
|
104
|
+
const u = usageOf(usage);
|
|
105
|
+
const oaToolCalls = toOpenAiToolCalls(toolCalls);
|
|
106
|
+
const finishReason = toOpenAiFinish(rawFinish, oaToolCalls.length > 0);
|
|
107
|
+
log.info({
|
|
108
|
+
inputTokens: u.prompt_tokens,
|
|
109
|
+
outputTokens: u.completion_tokens,
|
|
110
|
+
textLength: text.length,
|
|
111
|
+
// A reasoning model can spend its whole output budget thinking and return empty
|
|
112
|
+
// text (the kimi-k2.7 empty-completion failure); log the reasoning size so that
|
|
113
|
+
// "N output tokens, 0 text" is no longer a black hole.
|
|
114
|
+
reasoningLength: reasoning.length,
|
|
115
|
+
toolCalls: oaToolCalls.length,
|
|
116
|
+
finishReason,
|
|
117
|
+
streaming,
|
|
118
|
+
}, 'llm proxy: Workers AI completion ok');
|
|
119
|
+
await record(u);
|
|
120
|
+
recordMetric?.({
|
|
121
|
+
usage: u,
|
|
122
|
+
finishReason,
|
|
123
|
+
responseText: text,
|
|
124
|
+
reasoningText: reasoning,
|
|
125
|
+
ok: true,
|
|
126
|
+
httpStatus: null,
|
|
127
|
+
errorMessage: null,
|
|
128
|
+
upstreamMs: Date.now() - upstreamStart,
|
|
129
|
+
});
|
|
130
|
+
if (!streaming) {
|
|
131
|
+
const message = {
|
|
132
|
+
role: 'assistant',
|
|
133
|
+
content: text.length > 0 ? text : null,
|
|
134
|
+
};
|
|
135
|
+
if (oaToolCalls.length > 0)
|
|
136
|
+
message.tool_calls = oaToolCalls;
|
|
137
|
+
const body = {
|
|
138
|
+
id,
|
|
139
|
+
object: 'chat.completion',
|
|
140
|
+
created,
|
|
141
|
+
model: modelId,
|
|
142
|
+
choices: [{ index: 0, message, finish_reason: finishReason }],
|
|
143
|
+
usage: { ...u, total_tokens: (u.prompt_tokens ?? 0) + (u.completion_tokens ?? 0) },
|
|
144
|
+
};
|
|
145
|
+
return Response.json(body);
|
|
146
|
+
}
|
|
147
|
+
// Streaming: replay the (single, authoritative) generation as OpenAI
|
|
148
|
+
// `chat.completion.chunk` SSE events (see `buildStreamChunks`), then `[DONE]`.
|
|
149
|
+
const encoder = new TextEncoder();
|
|
150
|
+
const sse = (obj) => encoder.encode(`data: ${JSON.stringify(obj)}\n\n`);
|
|
151
|
+
const chunks = buildStreamChunks({ id, created, model: modelId }, { text, toolCalls: oaToolCalls, finishReason, usage: u });
|
|
152
|
+
const stream = new ReadableStream({
|
|
153
|
+
start(controller) {
|
|
154
|
+
for (const c of chunks)
|
|
155
|
+
controller.enqueue(sse(c));
|
|
156
|
+
controller.enqueue(encoder.encode('data: [DONE]\n\n'));
|
|
157
|
+
controller.close();
|
|
158
|
+
},
|
|
159
|
+
});
|
|
160
|
+
return new Response(stream, { headers: { 'content-type': 'text/event-stream' } });
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Serve a chat completion from a Cloudflare AI-catalog model (`<provider>/<model>`,
|
|
164
|
+
* e.g. `deepseek/deepseek-v4-pro`) via the `AI` binding's run path. These are
|
|
165
|
+
* unified-billing run-catalog models Cloudflare proxies to a partner (DeepSeek V4 Pro
|
|
166
|
+
* is served via Fireworks), reached with the account's own token — no AI Gateway, no
|
|
167
|
+
* BYOK. Unlike the `@cf/...` path they speak OpenAI Chat Completions natively, so the
|
|
168
|
+
* proxy's already-OpenAI request body and the binding's OpenAI response pass through
|
|
169
|
+
* with no translation. Always run buffered then replay as one chunk when the caller
|
|
170
|
+
* asked to stream, matching `runWorkersAi`'s deliberate non-streamed-delta design.
|
|
171
|
+
*/
|
|
172
|
+
async function runCatalogModel(args) {
|
|
173
|
+
const { binding, model: modelId, payload, streaming, record, recordMetric, log } = args;
|
|
174
|
+
const upstreamStart = Date.now();
|
|
175
|
+
// The proxy's payload is already an OpenAI Chat Completions body (messages, tools,
|
|
176
|
+
// tool_choice, temperature, max_tokens). Force buffered: we replay as one chunk.
|
|
177
|
+
const input = { ...payload, model: modelId, stream: false };
|
|
178
|
+
// The binding's `run` is typed to the native `@cf/...` model union; a catalog slug is
|
|
179
|
+
// valid at runtime but not in that type, so go through a plain call signature here.
|
|
180
|
+
const run = binding.run;
|
|
181
|
+
const completion = (await run(modelId, input));
|
|
182
|
+
const choice = completion?.choices?.[0];
|
|
183
|
+
const message = choice?.message;
|
|
184
|
+
const text = typeof message?.content === 'string' ? message.content : '';
|
|
185
|
+
const rawReasoning = message?.reasoning_content ?? message?.reasoning;
|
|
186
|
+
const reasoning = typeof rawReasoning === 'string' ? rawReasoning : '';
|
|
187
|
+
const oaToolCalls = Array.isArray(message?.tool_calls) ? message.tool_calls : [];
|
|
188
|
+
const finishReason = choice?.finish_reason ?? (oaToolCalls.length > 0 ? 'tool_calls' : 'stop');
|
|
189
|
+
const u = {
|
|
190
|
+
prompt_tokens: completion?.usage?.prompt_tokens ?? 0,
|
|
191
|
+
completion_tokens: completion?.usage?.completion_tokens ?? 0,
|
|
192
|
+
};
|
|
193
|
+
log.info({
|
|
194
|
+
inputTokens: u.prompt_tokens,
|
|
195
|
+
outputTokens: u.completion_tokens,
|
|
196
|
+
textLength: text.length,
|
|
197
|
+
reasoningLength: reasoning.length,
|
|
198
|
+
toolCalls: oaToolCalls.length,
|
|
199
|
+
finishReason,
|
|
200
|
+
streaming,
|
|
201
|
+
}, 'llm proxy: AI-catalog completion ok');
|
|
202
|
+
await record(u);
|
|
203
|
+
recordMetric?.({
|
|
204
|
+
usage: u,
|
|
205
|
+
finishReason,
|
|
206
|
+
responseText: text,
|
|
207
|
+
reasoningText: reasoning,
|
|
208
|
+
ok: true,
|
|
209
|
+
httpStatus: null,
|
|
210
|
+
errorMessage: null,
|
|
211
|
+
upstreamMs: Date.now() - upstreamStart,
|
|
212
|
+
});
|
|
213
|
+
if (!streaming) {
|
|
214
|
+
// Relay the upstream completion verbatim (with usage normalized) — it is already
|
|
215
|
+
// the OpenAI shape Pi expects.
|
|
216
|
+
const body = {
|
|
217
|
+
id: completion?.id ?? `chatcmpl-${crypto.randomUUID()}`,
|
|
218
|
+
object: 'chat.completion',
|
|
219
|
+
created: completion?.created ?? Math.floor(Date.now() / 1000),
|
|
220
|
+
model: modelId,
|
|
221
|
+
choices: [
|
|
222
|
+
{
|
|
223
|
+
index: 0,
|
|
224
|
+
message: {
|
|
225
|
+
role: 'assistant',
|
|
226
|
+
content: text.length > 0 ? text : null,
|
|
227
|
+
...(oaToolCalls.length > 0 ? { tool_calls: oaToolCalls } : {}),
|
|
228
|
+
},
|
|
229
|
+
finish_reason: finishReason,
|
|
230
|
+
},
|
|
231
|
+
],
|
|
232
|
+
usage: { ...u, total_tokens: (u.prompt_tokens ?? 0) + (u.completion_tokens ?? 0) },
|
|
233
|
+
};
|
|
234
|
+
return Response.json(body);
|
|
235
|
+
}
|
|
236
|
+
const encoder = new TextEncoder();
|
|
237
|
+
const sse = (obj) => encoder.encode(`data: ${JSON.stringify(obj)}\n\n`);
|
|
238
|
+
const meta = {
|
|
239
|
+
id: completion?.id ?? `chatcmpl-${crypto.randomUUID()}`,
|
|
240
|
+
created: completion?.created ?? Math.floor(Date.now() / 1000),
|
|
241
|
+
model: modelId,
|
|
242
|
+
};
|
|
243
|
+
const chunks = buildStreamChunks(meta, { text, toolCalls: oaToolCalls, finishReason, usage: u });
|
|
244
|
+
const stream = new ReadableStream({
|
|
245
|
+
start(controller) {
|
|
246
|
+
for (const c of chunks)
|
|
247
|
+
controller.enqueue(sse(c));
|
|
248
|
+
controller.enqueue(encoder.encode('data: [DONE]\n\n'));
|
|
249
|
+
controller.close();
|
|
250
|
+
},
|
|
251
|
+
});
|
|
252
|
+
return new Response(stream, { headers: { 'content-type': 'text/event-stream' } });
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Build the ordered OpenAI `chat.completion.chunk` payloads for a single, completed
|
|
256
|
+
* generation, replayed as a stream: a role chunk, ONE content chunk (only when there
|
|
257
|
+
* is text — never per-token, which is the doubling regression this guards against),
|
|
258
|
+
* the tool-call chunk (if any), the finish chunk, then a trailing usage-only chunk
|
|
259
|
+
* (matching `stream_options.include_usage`). The `[DONE]` sentinel is appended by the
|
|
260
|
+
* caller. Pure + synchronous so the streamed shape can be unit-tested without the
|
|
261
|
+
* `AI` binding or `generateText`.
|
|
262
|
+
*/
|
|
263
|
+
export function buildStreamChunks(meta, gen) {
|
|
264
|
+
const chunk = (choices, usageChunk) => ({
|
|
265
|
+
id: meta.id,
|
|
266
|
+
object: 'chat.completion.chunk',
|
|
267
|
+
created: meta.created,
|
|
268
|
+
model: meta.model,
|
|
269
|
+
choices,
|
|
270
|
+
...(usageChunk
|
|
271
|
+
? {
|
|
272
|
+
usage: {
|
|
273
|
+
...usageChunk,
|
|
274
|
+
total_tokens: (usageChunk.prompt_tokens ?? 0) + (usageChunk.completion_tokens ?? 0),
|
|
275
|
+
},
|
|
276
|
+
}
|
|
277
|
+
: {}),
|
|
278
|
+
});
|
|
279
|
+
const chunks = [
|
|
280
|
+
chunk([{ index: 0, delta: { role: 'assistant' }, finish_reason: null }]),
|
|
281
|
+
];
|
|
282
|
+
if (gen.text.length > 0) {
|
|
283
|
+
chunks.push(chunk([{ index: 0, delta: { content: gen.text }, finish_reason: null }]));
|
|
284
|
+
}
|
|
285
|
+
if (gen.toolCalls.length > 0) {
|
|
286
|
+
chunks.push(chunk([{ index: 0, delta: { tool_calls: gen.toolCalls }, finish_reason: null }]));
|
|
287
|
+
}
|
|
288
|
+
chunks.push(chunk([{ index: 0, delta: {}, finish_reason: gen.finishReason }]));
|
|
289
|
+
chunks.push(chunk([], gen.usage));
|
|
290
|
+
return chunks;
|
|
291
|
+
}
|
|
292
|
+
// ---- OpenAI ⇄ AI SDK translation helpers (Workers AI in-process path) -------
|
|
293
|
+
function isObject(value) {
|
|
294
|
+
return typeof value === 'object' && value !== null;
|
|
295
|
+
}
|
|
296
|
+
/** Flatten OpenAI message content (string, or a text/parts array) to plain text. */
|
|
297
|
+
function contentText(content) {
|
|
298
|
+
if (typeof content === 'string')
|
|
299
|
+
return content;
|
|
300
|
+
if (Array.isArray(content)) {
|
|
301
|
+
return content
|
|
302
|
+
.map((part) => (isObject(part) && typeof part.text === 'string' ? part.text : ''))
|
|
303
|
+
.join('');
|
|
304
|
+
}
|
|
305
|
+
return '';
|
|
306
|
+
}
|
|
307
|
+
/** OpenAI user content → AI SDK user content (text + image-url parts). */
|
|
308
|
+
function toUserContent(content) {
|
|
309
|
+
if (typeof content === 'string')
|
|
310
|
+
return content;
|
|
311
|
+
if (Array.isArray(content)) {
|
|
312
|
+
const parts = content
|
|
313
|
+
.map((part) => {
|
|
314
|
+
if (!isObject(part))
|
|
315
|
+
return undefined;
|
|
316
|
+
if (part.type === 'text' && typeof part.text === 'string') {
|
|
317
|
+
return { type: 'text', text: part.text };
|
|
318
|
+
}
|
|
319
|
+
if (part.type === 'image_url' &&
|
|
320
|
+
isObject(part.image_url) &&
|
|
321
|
+
typeof part.image_url.url === 'string') {
|
|
322
|
+
return { type: 'image', image: part.image_url.url };
|
|
323
|
+
}
|
|
324
|
+
return undefined;
|
|
325
|
+
})
|
|
326
|
+
.filter((p) => p !== undefined);
|
|
327
|
+
if (parts.length > 0)
|
|
328
|
+
return parts;
|
|
329
|
+
}
|
|
330
|
+
return '';
|
|
331
|
+
}
|
|
332
|
+
function safeParseArgs(raw) {
|
|
333
|
+
if (typeof raw !== 'string')
|
|
334
|
+
return isObject(raw) ? raw : {};
|
|
335
|
+
if (raw.trim() === '')
|
|
336
|
+
return {};
|
|
337
|
+
try {
|
|
338
|
+
return JSON.parse(raw);
|
|
339
|
+
}
|
|
340
|
+
catch {
|
|
341
|
+
return {};
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* Concatenate every `role:'system'` message's text (in order) so it can be passed
|
|
346
|
+
* via the AI SDK's `system` option rather than inlined into `messages`. Returns
|
|
347
|
+
* undefined when there is no system content.
|
|
348
|
+
*/
|
|
349
|
+
function systemFromMessages(raw) {
|
|
350
|
+
if (!Array.isArray(raw))
|
|
351
|
+
return undefined;
|
|
352
|
+
const parts = raw
|
|
353
|
+
.filter((m) => isObject(m) && m.role === 'system')
|
|
354
|
+
.map((m) => contentText(m.content))
|
|
355
|
+
.filter((t) => t.length > 0);
|
|
356
|
+
return parts.length > 0 ? parts.join('\n\n') : undefined;
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* Convert OpenAI chat messages to AI SDK `ModelMessage`s, handling the tool
|
|
360
|
+
* round-trip: an assistant message's `tool_calls` become `tool-call` content parts,
|
|
361
|
+
* and a `tool` message becomes a `tool-result` (its tool name recovered by id from
|
|
362
|
+
* the matching assistant call, since OpenAI tool messages omit it).
|
|
363
|
+
*/
|
|
364
|
+
function toModelMessages(raw) {
|
|
365
|
+
if (!Array.isArray(raw))
|
|
366
|
+
return [];
|
|
367
|
+
const toolNameById = new Map();
|
|
368
|
+
for (const m of raw) {
|
|
369
|
+
if (isObject(m) && m.role === 'assistant' && Array.isArray(m.tool_calls)) {
|
|
370
|
+
for (const tc of m.tool_calls) {
|
|
371
|
+
if (isObject(tc) &&
|
|
372
|
+
typeof tc.id === 'string' &&
|
|
373
|
+
isObject(tc.function) &&
|
|
374
|
+
typeof tc.function.name === 'string') {
|
|
375
|
+
toolNameById.set(tc.id, tc.function.name);
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
const out = [];
|
|
381
|
+
for (const m of raw) {
|
|
382
|
+
if (!isObject(m))
|
|
383
|
+
continue;
|
|
384
|
+
if (m.role === 'system') {
|
|
385
|
+
// System content is hoisted to the `system` option (see systemFromMessages).
|
|
386
|
+
continue;
|
|
387
|
+
}
|
|
388
|
+
else if (m.role === 'user') {
|
|
389
|
+
out.push({ role: 'user', content: toUserContent(m.content) });
|
|
390
|
+
}
|
|
391
|
+
else if (m.role === 'assistant') {
|
|
392
|
+
const parts = [];
|
|
393
|
+
const text = contentText(m.content);
|
|
394
|
+
if (text)
|
|
395
|
+
parts.push({ type: 'text', text });
|
|
396
|
+
if (Array.isArray(m.tool_calls)) {
|
|
397
|
+
for (const tc of m.tool_calls) {
|
|
398
|
+
if (!isObject(tc) || !isObject(tc.function) || typeof tc.function.name !== 'string') {
|
|
399
|
+
continue;
|
|
400
|
+
}
|
|
401
|
+
parts.push({
|
|
402
|
+
type: 'tool-call',
|
|
403
|
+
toolCallId: typeof tc.id === 'string' ? tc.id : '',
|
|
404
|
+
toolName: tc.function.name,
|
|
405
|
+
input: safeParseArgs(tc.function.arguments),
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
out.push({ role: 'assistant', content: parts.length > 0 ? parts : text });
|
|
410
|
+
}
|
|
411
|
+
else if (m.role === 'tool') {
|
|
412
|
+
const toolCallId = typeof m.tool_call_id === 'string' ? m.tool_call_id : '';
|
|
413
|
+
out.push({
|
|
414
|
+
role: 'tool',
|
|
415
|
+
content: [
|
|
416
|
+
{
|
|
417
|
+
type: 'tool-result',
|
|
418
|
+
toolCallId,
|
|
419
|
+
toolName: toolNameById.get(toolCallId) ?? 'tool',
|
|
420
|
+
output: { type: 'text', value: contentText(m.content) },
|
|
421
|
+
},
|
|
422
|
+
],
|
|
423
|
+
});
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
return out;
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
429
|
+
* OpenAI `tools` → AI SDK client-side tools, declared WITHOUT `execute` so the
|
|
430
|
+
* model emits the call and we relay it to the caller. Returns undefined when there
|
|
431
|
+
* are no usable function tools, leaving plain chat untouched.
|
|
432
|
+
*/
|
|
433
|
+
function toAiSdkTools(raw) {
|
|
434
|
+
if (!Array.isArray(raw))
|
|
435
|
+
return undefined;
|
|
436
|
+
const tools = {};
|
|
437
|
+
for (const entry of raw) {
|
|
438
|
+
if (!isObject(entry))
|
|
439
|
+
continue;
|
|
440
|
+
const fn = isObject(entry.function) ? entry.function : undefined;
|
|
441
|
+
const name = typeof fn?.name === 'string' ? fn.name : undefined;
|
|
442
|
+
if (!name)
|
|
443
|
+
continue;
|
|
444
|
+
const parameters = isObject(fn?.parameters) ? fn.parameters : { type: 'object', properties: {} };
|
|
445
|
+
tools[name] = tool({
|
|
446
|
+
description: typeof fn?.description === 'string' ? fn.description : undefined,
|
|
447
|
+
inputSchema: jsonSchema(parameters),
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
return Object.keys(tools).length > 0 ? tools : undefined;
|
|
451
|
+
}
|
|
452
|
+
/** OpenAI `tool_choice` → AI SDK `toolChoice`. */
|
|
453
|
+
function toToolChoice(raw) {
|
|
454
|
+
if (raw === 'auto' || raw === 'none' || raw === 'required')
|
|
455
|
+
return raw;
|
|
456
|
+
if (isObject(raw) &&
|
|
457
|
+
raw.type === 'function' &&
|
|
458
|
+
isObject(raw.function) &&
|
|
459
|
+
typeof raw.function.name === 'string') {
|
|
460
|
+
return { type: 'tool', toolName: raw.function.name };
|
|
461
|
+
}
|
|
462
|
+
return undefined;
|
|
463
|
+
}
|
|
464
|
+
/** AI SDK tool calls → OpenAI `tool_calls` (complete `arguments` JSON strings). */
|
|
465
|
+
function toOpenAiToolCalls(calls) {
|
|
466
|
+
return calls.map((tc, index) => ({
|
|
467
|
+
index,
|
|
468
|
+
id: tc.toolCallId,
|
|
469
|
+
type: 'function',
|
|
470
|
+
function: {
|
|
471
|
+
name: tc.toolName,
|
|
472
|
+
arguments: typeof tc.input === 'string' ? tc.input : JSON.stringify(tc.input ?? {}),
|
|
473
|
+
},
|
|
474
|
+
}));
|
|
475
|
+
}
|
|
476
|
+
/** AI SDK finish reason → OpenAI `finish_reason`. */
|
|
477
|
+
function toOpenAiFinish(reason, hasToolCalls) {
|
|
478
|
+
if (hasToolCalls || reason === 'tool-calls')
|
|
479
|
+
return 'tool_calls';
|
|
480
|
+
if (reason === 'length')
|
|
481
|
+
return 'length';
|
|
482
|
+
if (reason === 'content-filter')
|
|
483
|
+
return 'content_filter';
|
|
484
|
+
return 'stop';
|
|
485
|
+
}
|
|
486
|
+
//# sourceMappingURL=WorkersAiLlmUpstream.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WorkersAiLlmUpstream.js","sourceRoot":"","sources":["../../../src/infrastructure/ai/WorkersAiLlmUpstream.ts"],"names":[],"mappings":"AAOA,OAAO,EAKL,YAAY,EACZ,UAAU,EACV,IAAI,GACL,MAAM,IAAI,CAAA;AACX,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AA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KACF,CAAC,CAAC,CAAA;AACL,CAAC;AAED,qDAAqD;AACrD,SAAS,cAAc,CAAC,MAAc,EAAE,YAAqB;IAC3D,IAAI,YAAY,IAAI,MAAM,KAAK,YAAY;QAAE,OAAO,YAAY,CAAA;IAChE,IAAI,MAAM,KAAK,QAAQ;QAAE,OAAO,QAAQ,CAAA;IACxC,IAAI,MAAM,KAAK,gBAAgB;QAAE,OAAO,gBAAgB,CAAA;IACxD,OAAO,MAAM,CAAA;AACf,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { DEEPSEEK_BASE_URL, MOONSHOT_BASE_URL, OPENAI_BASE_URL, OPENROUTER_BASE_URL, QWEN_BASE_URL } from '@cat-factory/agents';
|
|
2
|
+
import type { Env } from '../env';
|
|
3
|
+
export { DEEPSEEK_BASE_URL, MOONSHOT_BASE_URL, OPENAI_BASE_URL, OPENROUTER_BASE_URL, QWEN_BASE_URL };
|
|
4
|
+
/** The effective base URL for a provider: env override, else the built-in default. */
|
|
5
|
+
export declare function baseUrlFor(provider: string, env: Env): string | null;
|
|
6
|
+
/** A resolved OpenAI-compatible upstream: where to send the request (key-free). */
|
|
7
|
+
export interface UpstreamEndpoint {
|
|
8
|
+
baseURL: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Resolve a provider id to its OpenAI-compatible upstream base URL. Returns null for
|
|
12
|
+
* providers that are not OpenAI-compatible (e.g. `workers-ai`, `anthropic`). The API
|
|
13
|
+
* key is leased per call from the DB-backed pool by the proxy — it is no longer read
|
|
14
|
+
* from env here.
|
|
15
|
+
*/
|
|
16
|
+
export declare function resolveOpenAiCompatibleUpstream(provider: string, env: Env): UpstreamEndpoint | null;
|
|
17
|
+
//# sourceMappingURL=providerEndpoints.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"providerEndpoints.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/ai/providerEndpoints.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,mBAAmB,EACnB,aAAa,EACd,MAAM,qBAAqB,CAAA;AAC5B,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAA;AASjC,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,eAAe,EAAE,mBAAmB,EAAE,aAAa,EAAE,CAAA;AAEpG,sFAAsF;AACtF,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,GAAG,MAAM,GAAG,IAAI,CAkBpE;AAED,mFAAmF;AACnF,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAA;CAChB;AAED;;;;;GAKG;AACH,wBAAgB,+BAA+B,CAC7C,QAAQ,EAAE,MAAM,EAChB,GAAG,EAAE,GAAG,GACP,gBAAgB,GAAG,IAAI,CAIzB"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { DEEPSEEK_BASE_URL, MOONSHOT_BASE_URL, OPENAI_BASE_URL, OPENROUTER_BASE_URL, QWEN_BASE_URL, } from '@cat-factory/agents';
|
|
2
|
+
// The OpenAI-compatible chat endpoints behind the direct-provider flavours live in
|
|
3
|
+
// the shared AI provisioning facade (@cat-factory/agents) so the Vercel-AI model
|
|
4
|
+
// provider (CloudflareModelProvider), the container LLM proxy (LlmProxyController)
|
|
5
|
+
// and the Node service all resolve them from one source of truth. This module adds
|
|
6
|
+
// the Worker-specific `env` plumbing: each base URL is overridable via env (e.g.
|
|
7
|
+
// QWEN_BASE_URL) so a deployment can point a provider at a self-hosted gateway, a
|
|
8
|
+
// regional endpoint, or — in the acceptance tests — a local stub, without code changes.
|
|
9
|
+
export { DEEPSEEK_BASE_URL, MOONSHOT_BASE_URL, OPENAI_BASE_URL, OPENROUTER_BASE_URL, QWEN_BASE_URL };
|
|
10
|
+
/** The effective base URL for a provider: env override, else the built-in default. */
|
|
11
|
+
export function baseUrlFor(provider, env) {
|
|
12
|
+
switch (provider) {
|
|
13
|
+
case 'qwen':
|
|
14
|
+
return env.QWEN_BASE_URL ?? QWEN_BASE_URL;
|
|
15
|
+
case 'deepseek':
|
|
16
|
+
return env.DEEPSEEK_BASE_URL ?? DEEPSEEK_BASE_URL;
|
|
17
|
+
case 'moonshot':
|
|
18
|
+
return env.MOONSHOT_BASE_URL ?? MOONSHOT_BASE_URL;
|
|
19
|
+
case 'openai':
|
|
20
|
+
return env.OPENAI_BASE_URL ?? OPENAI_BASE_URL;
|
|
21
|
+
case 'openrouter':
|
|
22
|
+
return env.OPENROUTER_BASE_URL ?? OPENROUTER_BASE_URL;
|
|
23
|
+
// LiteLLM is operator-hosted: no public default, only the deployment's own gateway.
|
|
24
|
+
case 'litellm':
|
|
25
|
+
return env.LITELLM_BASE_URL ?? null;
|
|
26
|
+
default:
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Resolve a provider id to its OpenAI-compatible upstream base URL. Returns null for
|
|
32
|
+
* providers that are not OpenAI-compatible (e.g. `workers-ai`, `anthropic`). The API
|
|
33
|
+
* key is leased per call from the DB-backed pool by the proxy — it is no longer read
|
|
34
|
+
* from env here.
|
|
35
|
+
*/
|
|
36
|
+
export function resolveOpenAiCompatibleUpstream(provider, env) {
|
|
37
|
+
const baseURL = baseUrlFor(provider, env);
|
|
38
|
+
if (!baseURL)
|
|
39
|
+
return null;
|
|
40
|
+
return { baseURL };
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=providerEndpoints.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"providerEndpoints.js","sourceRoot":"","sources":["../../../src/infrastructure/ai/providerEndpoints.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,mBAAmB,EACnB,aAAa,GACd,MAAM,qBAAqB,CAAA;AAG5B,mFAAmF;AACnF,iFAAiF;AACjF,mFAAmF;AACnF,mFAAmF;AACnF,iFAAiF;AACjF,kFAAkF;AAClF,wFAAwF;AACxF,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,eAAe,EAAE,mBAAmB,EAAE,aAAa,EAAE,CAAA;AAEpG,sFAAsF;AACtF,MAAM,UAAU,UAAU,CAAC,QAAgB,EAAE,GAAQ;IACnD,QAAQ,QAAQ,EAAE,CAAC;QACjB,KAAK,MAAM;YACT,OAAO,GAAG,CAAC,aAAa,IAAI,aAAa,CAAA;QAC3C,KAAK,UAAU;YACb,OAAO,GAAG,CAAC,iBAAiB,IAAI,iBAAiB,CAAA;QACnD,KAAK,UAAU;YACb,OAAO,GAAG,CAAC,iBAAiB,IAAI,iBAAiB,CAAA;QACnD,KAAK,QAAQ;YACX,OAAO,GAAG,CAAC,eAAe,IAAI,eAAe,CAAA;QAC/C,KAAK,YAAY;YACf,OAAO,GAAG,CAAC,mBAAmB,IAAI,mBAAmB,CAAA;QACvD,oFAAoF;QACpF,KAAK,SAAS;YACZ,OAAO,GAAG,CAAC,gBAAgB,IAAI,IAAI,CAAA;QACrC;YACE,OAAO,IAAI,CAAA;IACf,CAAC;AACH,CAAC;AAOD;;;;;GAKG;AACH,MAAM,UAAU,+BAA+B,CAC7C,QAAgB,EAChB,GAAQ;IAER,MAAM,OAAO,GAAG,UAAU,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAA;IACzC,IAAI,CAAC,OAAO;QAAE,OAAO,IAAI,CAAA;IACzB,OAAO,EAAE,OAAO,EAAE,CAAA;AACpB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ProviderRegistry } from '@cat-factory/agents';
|
|
2
|
+
import type { Env } from '../env';
|
|
3
|
+
/** Turns the runtime `env` into a {@link ProviderRegistry} to mix in. */
|
|
4
|
+
export type ModelRegistryFactory = (env: Env) => ProviderRegistry;
|
|
5
|
+
/** Register an extra model-provider registry for this installation. */
|
|
6
|
+
export declare function registerModelRegistry(factory: ModelRegistryFactory): void;
|
|
7
|
+
/** Build the registered extra registries for a given `env` (empty when none registered). */
|
|
8
|
+
export declare function resolveExtraRegistries(env: Env): ProviderRegistry[];
|
|
9
|
+
/** Drop all registered registries. Intended for tests that exercise registration. */
|
|
10
|
+
export declare function clearModelRegistries(): void;
|
|
11
|
+
//# sourceMappingURL=registries.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registries.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/ai/registries.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAC3D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAA;AAiBjC,yEAAyE;AACzE,MAAM,MAAM,oBAAoB,GAAG,CAAC,GAAG,EAAE,GAAG,KAAK,gBAAgB,CAAA;AAIjE,uEAAuE;AACvE,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,oBAAoB,GAAG,IAAI,CAEzE;AAED,4FAA4F;AAC5F,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,GAAG,GAAG,gBAAgB,EAAE,CAEnE;AAED,qFAAqF;AACrF,wBAAgB,oBAAoB,IAAI,IAAI,CAE3C"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const factories = [];
|
|
2
|
+
/** Register an extra model-provider registry for this installation. */
|
|
3
|
+
export function registerModelRegistry(factory) {
|
|
4
|
+
factories.push(factory);
|
|
5
|
+
}
|
|
6
|
+
/** Build the registered extra registries for a given `env` (empty when none registered). */
|
|
7
|
+
export function resolveExtraRegistries(env) {
|
|
8
|
+
return factories.map((factory) => factory(env));
|
|
9
|
+
}
|
|
10
|
+
/** Drop all registered registries. Intended for tests that exercise registration. */
|
|
11
|
+
export function clearModelRegistries() {
|
|
12
|
+
factories.length = 0;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=registries.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registries.js","sourceRoot":"","sources":["../../../src/infrastructure/ai/registries.ts"],"names":[],"mappings":"AAqBA,MAAM,SAAS,GAA2B,EAAE,CAAA;AAE5C,uEAAuE;AACvE,MAAM,UAAU,qBAAqB,CAAC,OAA6B;IACjE,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;AACzB,CAAC;AAED,4FAA4F;AAC5F,MAAM,UAAU,sBAAsB,CAAC,GAAQ;IAC7C,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAA;AACjD,CAAC;AAED,qFAAqF;AACrF,MAAM,UAAU,oBAAoB;IAClC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAA;AACtB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GitHubOAuth.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/auth/GitHubOAuth.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,KAAK,uBAAuB,EAAE,MAAM,qBAAqB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GitHubOAuth.js","sourceRoot":"","sources":["../../../src/infrastructure/auth/GitHubOAuth.ts"],"names":[],"mappings":"AAAA,qFAAqF;AACrF,OAAO,EAAE,WAAW,EAAgC,MAAM,qBAAqB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/auth/middleware.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA"}
|