blackriver-gateway 3.8.46 → 3.8.47
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/package.json +1 -1
- package/src/domain/assessment/migration.ts +2 -2
- package/src/domain/connectionModelRules.ts +1 -1
- package/src/domain/modelAvailability.ts +1 -1
- package/src/domain/omnirouteResponseMeta.ts +30 -30
- package/src/domain/quotaCache.ts +3 -3
- package/src/domain/types.ts +1 -1
- package/src/lib/a2a/routingLogger.ts +1 -1
- package/src/lib/a2a/skills/costAnalysis.ts +5 -5
- package/src/lib/a2a/skills/healthReport.ts +5 -5
- package/src/lib/a2a/skills/listCapabilities.ts +2 -2
- package/src/lib/a2a/skills/providerDiscovery.ts +1 -1
- package/src/lib/a2a/skills/quotaManagement.ts +5 -5
- package/src/lib/a2a/skills/smartRouting.ts +6 -6
- package/src/lib/accessTokens/scopes.ts +2 -2
- package/src/lib/acp/manager.ts +1 -1
- package/src/lib/acp/registry.ts +1 -1
- package/src/lib/agentSkills/generator.ts +4 -4
- package/src/lib/api/comboErrorResponse.ts +1 -1
- package/src/lib/api/modelTestRunner.ts +7 -7
- package/src/lib/api/proxyRegistryRouteHandlers.ts +1 -1
- package/src/lib/api/serverErrorMessage.ts +1 -1
- package/src/lib/apiBridgeServer.ts +3 -3
- package/src/lib/arenaEloSync.ts +5 -5
- package/src/lib/build-profile/featureDisabled.ts +3 -3
- package/src/lib/cacheControlSettings.ts +1 -1
- package/src/lib/catalog/openrouterCatalog.ts +1 -1
- package/src/lib/cli-helper/claudeProfileAutoSync.ts +4 -4
- package/src/lib/cli-helper/codexProfileAutoSync.ts +3 -3
- package/src/lib/cli-helper/config-generator/continue.ts +1 -1
- package/src/lib/cli-helper/config-generator/hermes-agent.ts +10 -10
- package/src/lib/cli-helper/config-generator/hermes.ts +2 -2
- package/src/lib/cli-helper/config-generator/hermesHome.ts +1 -1
- package/src/lib/cli-helper/config-generator/opencode.ts +10 -10
- package/src/lib/cli-helper/doctor/checks.ts +1 -1
- package/src/lib/cli-helper/tool-detector.ts +4 -4
- package/src/lib/cliTools/checkToolConfigStatus.ts +13 -13
- package/src/lib/cloudSync.stub.ts +1 -1
- package/src/lib/cloudSync.ts +6 -6
- package/src/lib/cloudflaredTunnel.ts +1 -1
- package/src/lib/combos/autoPromote.ts +1 -1
- package/src/lib/combos/builderOptions.ts +1 -1
- package/src/lib/compression/judgeModelClient.ts +3 -3
- package/src/lib/config/hotReload.ts +1 -1
- package/src/lib/config/runtimeSettings.ts +11 -11
- package/src/lib/consoleInterceptor.ts +3 -3
- package/src/lib/copilot/engine.ts +16 -16
- package/src/lib/copilot/systemPrompt.ts +12 -12
- package/src/lib/copilot/tools.ts +13 -13
- package/src/lib/credentialHealth/cache.ts +4 -4
- package/src/lib/credentialHealth/scheduler.ts +5 -5
- package/src/lib/dataPaths.ts +1 -1
- package/src/lib/db/adapters/driverFactory.ts +4 -4
- package/src/lib/db/apiKeys/modelPermissions.ts +1 -1
- package/src/lib/db/apiKeys.ts +5 -5
- package/src/lib/db/backup.ts +1 -1
- package/src/lib/db/cliToolState.ts +2 -2
- package/src/lib/db/compression.ts +3 -3
- package/src/lib/db/compressionCombos.ts +1 -1
- package/src/lib/db/core.ts +13 -13
- package/src/lib/db/databaseSettings.ts +1 -1
- package/src/lib/db/detailedLogs.ts +1 -1
- package/src/lib/db/encryption.ts +3 -3
- package/src/lib/db/healthCheck.ts +2 -2
- package/src/lib/db/jsonMigration.ts +1 -1
- package/src/lib/db/migrationRunner.ts +29 -29
- package/src/lib/db/settings/pricing.ts +1 -1
- package/src/lib/db/settings.ts +3 -3
- package/src/lib/db/tierConfig.ts +1 -1
- package/src/lib/db/usageAnalytics.ts +1 -1
- package/src/lib/db/webhookDeliveries.ts +1 -1
- package/src/lib/discovery/index.ts +2 -2
- package/src/lib/embeddings/familyGuard.ts +2 -2
- package/src/lib/embeddings/service.ts +9 -9
- package/src/lib/env/runtimeEnv.ts +4 -4
- package/src/lib/evals/evalRunner/builtinSuites.ts +1 -1
- package/src/lib/events/eventBus.ts +4 -4
- package/src/lib/freeProviderRankings.ts +1 -1
- package/src/lib/gamification/badges.ts +2 -2
- package/src/lib/gamification/servers.ts +1 -1
- package/src/lib/gamification/streaks.ts +1 -1
- package/src/lib/gamification/xp.ts +2 -2
- package/src/lib/gracefulShutdown.ts +5 -5
- package/src/lib/guardrails/registry.ts +1 -1
- package/src/lib/guardrails/visionBridge.ts +1 -1
- package/src/lib/guardrails/visionBridgeHelpers.ts +15 -15
- package/src/lib/guardrails/visionBridgeRouter.ts +1 -1
- package/src/lib/headroom/detect.ts +1 -1
- package/src/lib/images/imageRouteModel.ts +2 -2
- package/src/lib/initCloudSync.ts +2 -2
- package/src/lib/inspector/harExport.ts +5 -5
- package/src/lib/jobs/budgetResetJob.ts +1 -1
- package/src/lib/jobs/reasoningCacheCleanupJob.ts +1 -1
- package/src/lib/localHealthCheck.ts +5 -5
- package/src/lib/machineToken.ts +2 -2
- package/src/lib/memory/embedding/index.ts +1 -1
- package/src/lib/memory/embedding/remote.ts +1 -1
- package/src/lib/memory/embedding/staticPotion.ts +2 -2
- package/src/lib/memory/embedding/transformersLocal.ts +1 -1
- package/src/lib/memory/qdrant.ts +4 -4
- package/src/lib/memory/settings.ts +1 -1
- package/src/lib/memory/types.ts +1 -1
- package/src/lib/middleware/cliTokenAuth.ts +4 -4
- package/src/lib/middleware/registry.ts +5 -5
- package/src/lib/modelCapabilities.ts +2 -2
- package/src/lib/modelMetadataRegistry.ts +1 -1
- package/src/lib/modelsDevSync/transform.ts +14 -14
- package/src/lib/monitoring/providerHealthAutopilot.ts +3 -3
- package/src/lib/monitoring/providerHealthMatrix.ts +2 -2
- package/src/lib/oauth/codexDeviceFlow.ts +1 -1
- package/src/lib/oauth/config/index.ts +4 -4
- package/src/lib/oauth/constants/oauth.ts +5 -5
- package/src/lib/oauth/credentialBlob.ts +2 -2
- package/src/lib/oauth/providers/antigravity.ts +2 -2
- package/src/lib/oauth/providers/claude.ts +1 -1
- package/src/lib/oauth/providers/windsurf.ts +1 -1
- package/src/lib/oauth/providers/zed-hosted.ts +1 -1
- package/src/lib/oauth/providers/zed.ts +1 -1
- package/src/lib/oauth/providers.ts +3 -3
- package/src/lib/oauth/services/cursor.ts +1 -1
- package/src/lib/oauth/utils/agyAuthImport.ts +2 -2
- package/src/lib/oauth/utils/claudeAuthFile.ts +1 -1
- package/src/lib/oauth/utils/cliProxyAuthImport.ts +1 -1
- package/src/lib/oauth/utils/codexAuthFile.ts +1 -1
- package/src/lib/oauth/utils/codexAuthImport.ts +1 -1
- package/src/lib/obsidian/api.ts +1 -1
- package/src/lib/obsidianSync.ts +1 -1
- package/src/lib/playground/codeExport.ts +5 -5
- package/src/lib/plugins/hooks.ts +1 -1
- package/src/lib/plugins/loader.ts +1 -1
- package/src/lib/plugins/manifest.ts +3 -3
- package/src/lib/plugins/marketplace.ts +4 -4
- package/src/lib/plugins/pluginWorker.ts +3 -3
- package/src/lib/plugins/scanner.ts +3 -3
- package/src/lib/plugins/sdk.ts +3 -3
- package/src/lib/pricingSync.ts +9 -9
- package/src/lib/providerModels/geminiModelsParser.ts +1 -1
- package/src/lib/providerModels/managedModelImport.ts +1 -1
- package/src/lib/providers/imageValidation.ts +1 -1
- package/src/lib/providers/requestDefaults.ts +1 -1
- package/src/lib/providers/serviceKindIndex.ts +0 -0
- package/src/lib/providers/staticModels.ts +7 -7
- package/src/lib/providers/validation/anthropicFormat.ts +2 -2
- package/src/lib/providers/validation/audioMiscProviders.ts +4 -4
- package/src/lib/providers/validation/cloudProviders.ts +6 -6
- package/src/lib/providers/validation/openaiFormat.ts +3 -3
- package/src/lib/providers/validation/transport.ts +1 -1
- package/src/lib/providers/validation/urlHelpers.ts +1 -1
- package/src/lib/providers/validation/webProvidersA.ts +3 -3
- package/src/lib/providers/validation/webProvidersB.ts +2 -2
- package/src/lib/providers/validation.ts +7 -7
- package/src/lib/proxyEgress.ts +2 -2
- package/src/lib/proxyHealth/scheduler.ts +3 -3
- package/src/lib/proxyHealth.ts +2 -2
- package/src/lib/proxyRelay/cloudflareWorkerScript.ts +3 -3
- package/src/lib/quota/connectionRecovery.ts +9 -9
- package/src/lib/quota/quotaCombos.ts +1 -1
- package/src/lib/quota/redisQuotaStore.ts +2 -2
- package/src/lib/quota/saturationSignals.ts +4 -4
- package/src/lib/resilience/settings.ts +1 -1
- package/src/lib/runtime/ports.ts +2 -2
- package/src/lib/search/executeWebSearch.ts +3 -3
- package/src/lib/security/localEndpoints.ts +5 -5
- package/src/lib/semanticCache.ts +3 -3
- package/src/lib/services/ServiceSupervisor.ts +1 -1
- package/src/lib/services/embedWsProxy.ts +4 -4
- package/src/lib/services/htmlRewriter.ts +1 -1
- package/src/lib/services/installers/bifrost.ts +1 -1
- package/src/lib/services/installers/mux.ts +1 -1
- package/src/lib/services/installers/ninerouter.stub.ts +1 -1
- package/src/lib/services/installers/ninerouter.ts +2 -2
- package/src/lib/services/installers/utils.ts +2 -2
- package/src/lib/services/modelSync.ts +1 -1
- package/src/lib/services/reverseProxy.ts +7 -7
- package/src/lib/skills/builtins.ts +1 -1
- package/src/lib/skills/interception.ts +3 -3
- package/src/lib/skills/sandbox.ts +3 -3
- package/src/lib/spend/batchWriter.ts +2 -2
- package/src/lib/system/autoUpdate.ts +9 -9
- package/src/lib/system/globalPackagePath.ts +5 -5
- package/src/lib/system/versionCheck.ts +5 -5
- package/src/lib/tailscaleTunnel.ts +4 -4
- package/src/lib/tokenHealthCheck.ts +10 -10
- package/src/lib/translator/streamTransform.ts +1 -1
- package/src/lib/usage/apiKeyUsageLimits.ts +1 -1
- package/src/lib/usage/callLogArtifacts.ts +4 -4
- package/src/lib/usage/callLogs/format.ts +1 -1
- package/src/lib/usage/callLogs.ts +1 -1
- package/src/lib/usage/codexResetCredits.ts +3 -3
- package/src/lib/usage/comboForecast.ts +1 -1
- package/src/lib/usage/comboHealth.ts +2 -2
- package/src/lib/usage/comboScoringInspector.ts +2 -2
- package/src/lib/usage/fetcher.ts +8 -8
- package/src/lib/usage/flatRateProviders.ts +1 -1
- package/src/lib/usage/internalUsageCommand.ts +4 -4
- package/src/lib/usage/providerLimits/quotaNormalize.ts +2 -2
- package/src/lib/usage/providerLimits.ts +5 -5
- package/src/lib/usage/resilienceExplain.ts +1 -1
- package/src/lib/usage/routeExplain.ts +2 -2
- package/src/lib/usage/usageStats.ts +4 -4
- package/src/lib/versionManager/binaryManager.ts +1 -1
- package/src/lib/versionManager/healthMonitor.ts +1 -1
- package/src/lib/vscode/modelPresentation.ts +1 -1
- package/src/lib/vscode/reasoningMetadata.ts +2 -2
- package/src/lib/webhookDispatcher.ts +2 -2
- package/src/lib/webhooks/eventDescriptions.ts +1 -1
- package/src/lib/webhooks/integrations/discord.ts +1 -1
- package/src/lib/webhooks/integrations/slack.ts +1 -1
- package/src/lib/webhooks/integrations/telegram.ts +1 -1
- package/src/lib/zed-oauth/dockerDetect.ts +1 -1
- package/src/lib/zed-oauth/keychain-reader.stub.ts +1 -1
- package/src/lib/zed-oauth/keychain-reader.ts +1 -1
- package/src/mitm/cert/install.stub.ts +1 -1
- package/src/mitm/cert/install.ts +7 -7
- package/src/mitm/dataDir.ts +1 -1
- package/src/mitm/handlers/antigravity.ts +4 -4
- package/src/mitm/handlers/base.ts +9 -9
- package/src/mitm/handlers/claudeCode.ts +2 -2
- package/src/mitm/handlers/codex.ts +2 -2
- package/src/mitm/handlers/copilot.ts +2 -2
- package/src/mitm/handlers/cursor.ts +2 -2
- package/src/mitm/handlers/kiro.ts +2 -2
- package/src/mitm/handlers/openCode.ts +2 -2
- package/src/mitm/handlers/zed.ts +2 -2
- package/src/mitm/inspector/agentBridgeHook.ts +1 -1
- package/src/mitm/inspector/httpProxyServer.ts +1 -1
- package/src/mitm/inspector/llmMetadataExtractor.ts +2 -2
- package/src/mitm/inspector/systemProxyConfig.ts +2 -2
- package/src/mitm/manager.ts +4 -4
- package/src/mitm/systemCommands.ts +10 -10
- package/src/mitm/targets/antigravity.ts +3 -3
- package/src/mitm/targets/claudeCode.ts +2 -2
- package/src/mitm/targets/codex.ts +1 -1
- package/src/mitm/targets/copilot.ts +1 -1
- package/src/mitm/targets/cursor.ts +2 -2
- package/src/mitm/targets/kiro.ts +5 -5
- package/src/mitm/targets/openCode.ts +2 -2
- package/src/mitm/targets/zed.ts +2 -2
- package/src/mitm/tproxy/caTrust.ts +7 -7
- package/src/mitm/tproxy/dynamicCert.ts +2 -2
- package/src/mitm/tproxy/tlsCapture.ts +1 -1
- package/src/server/authz/csrf.ts +1 -1
- package/src/server/authz/headers.ts +11 -11
- package/src/server/authz/peerStamp.ts +1 -1
- package/src/server/authz/pipeline.ts +3 -3
- package/src/server/authz/policies/clientApi.ts +2 -2
- package/src/server/authz/policies/management.ts +5 -5
- package/src/server/cors/origins.ts +2 -2
- package/src/server/origin/publicOrigin.ts +4 -4
- package/src/server/ws/liveServer.ts +3 -3
- package/src/server/ws/liveServerAllowList.ts +1 -1
- package/src/shared/components/Collapsible.tsx +1 -1
- package/src/shared/components/ConsoleLogViewer.tsx +1 -1
- package/src/shared/components/Footer.tsx +8 -8
- package/src/shared/components/Header.tsx +1 -1
- package/src/shared/components/OAuthModal.tsx +7 -7
- package/src/shared/components/OmniRouteLogo.tsx +3 -3
- package/src/shared/components/RequestLoggerDetail.tsx +3 -3
- package/src/shared/components/Sidebar.tsx +3 -3
- package/src/shared/components/compression/EngineConfigForm.tsx +1 -1
- package/src/shared/components/compression/EngineConfigPage.tsx +1 -1
- package/src/shared/components/docs/CodeBlock.stories.tsx +1 -1
- package/src/shared/components/docs/DocsSidebar.tsx +1 -1
- package/src/shared/components/flow/FlowCanvas.tsx +1 -1
- package/src/shared/components/layouts/DashboardLayout.tsx +1 -1
- package/src/shared/components/oauthBlobSubmit.ts +1 -1
- package/src/shared/constants/agentSkills.ts +14 -14
- package/src/shared/constants/appConfig.ts +1 -1
- package/src/shared/constants/cliCompatProviders.ts +1 -1
- package/src/shared/constants/cliTools.ts +12 -12
- package/src/shared/constants/dashboardCsrf.ts +1 -1
- package/src/shared/constants/featureFlagDefinitions.ts +31 -31
- package/src/shared/constants/headers.ts +15 -15
- package/src/shared/constants/mcpScopes.ts +36 -36
- package/src/shared/constants/models.ts +2 -2
- package/src/shared/constants/providers/apikey/enterprise-cloud.ts +5 -5
- package/src/shared/constants/providers/apikey/frontier-labs.ts +3 -3
- package/src/shared/constants/providers/apikey/gateways.ts +7 -7
- package/src/shared/constants/providers/apikey/specialty-media.ts +5 -5
- package/src/shared/constants/providers/noauth.ts +3 -3
- package/src/shared/constants/providers/oauth.ts +2 -2
- package/src/shared/constants/providers.ts +1 -1
- package/src/shared/constants/sidebarVisibility/sections.ts +1 -1
- package/src/shared/constants/sidebarVisibility.ts +1 -1
- package/src/shared/hooks/useDisplayBaseUrl.ts +1 -1
- package/src/shared/http/apiErrorMessage.ts +1 -1
- package/src/shared/middleware/chatBodyAdmission.ts +3 -3
- package/src/shared/network/outboundUrlGuard.ts +6 -6
- package/src/shared/network/safeOutboundFetch.ts +1 -1
- package/src/shared/reasoning/effortStandardization.ts +1 -1
- package/src/shared/schemas/qdrant.ts +1 -1
- package/src/shared/services/apiKeyResolver.ts +2 -2
- package/src/shared/services/cliRuntime.ts +1 -1
- package/src/shared/services/droidCustomModels.ts +8 -8
- package/src/shared/services/modelSyncScheduler.ts +6 -6
- package/src/shared/services/opencodeConfig.ts +5 -5
- package/src/shared/utils/apiKeyPolicy.ts +5 -5
- package/src/shared/utils/classify429.ts +1 -1
- package/src/shared/utils/clineAuth.ts +2 -2
- package/src/shared/utils/codexConfig.ts +1 -1
- package/src/shared/utils/compressionHeaderEcho.ts +7 -7
- package/src/shared/utils/cors.ts +1 -1
- package/src/shared/utils/featureFlags.ts +2 -2
- package/src/shared/utils/fetchError.ts +1 -1
- package/src/shared/utils/fetchTimeout.ts +1 -1
- package/src/shared/utils/freeModels.ts +1 -1
- package/src/shared/utils/logger.ts +2 -2
- package/src/shared/utils/nodeRuntimeSupport.ts +3 -3
- package/src/shared/utils/releaseNotes.ts +3 -3
- package/src/shared/utils/resolveOmniRouteBaseUrl.ts +7 -7
- package/src/shared/utils/secretsValidator.ts +1 -1
- package/src/shared/utils/secureRandom.ts +1 -1
- package/src/shared/validation/freeProxySchemas.ts +3 -3
- package/src/shared/validation/schemas/auth.ts +1 -1
- package/src/shared/validation/settingsSchemas.ts +1 -1
- package/src/sse/handlers/chat.ts +36 -36
- package/src/sse/handlers/chatHelpers.ts +14 -14
- package/src/sse/services/auth.ts +13 -13
- package/src/sse/services/cooldownAwareRetry.ts +1 -1
- package/src/sse/services/model.ts +2 -2
- package/src/sse/services/sessionAffinityPin.ts +1 -1
- package/src/sse/services/tokenRefresh.ts +1 -1
- package/src/types/global.d.ts +7 -7
- package/src/types/index.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "blackriver-gateway",
|
|
3
|
-
"version": "3.8.
|
|
3
|
+
"version": "3.8.47",
|
|
4
4
|
"description": "BlackRiver Gateway — AI routing infrastructure by BlackRiver AI. 237 providers, one endpoint, auto-fallback, RTK+Caveman compression, MCP/A2A, desktop, PWA, and OpenAI-compatible APIs.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -97,11 +97,11 @@ export async function runAssessmentMigration(dbPath: string): Promise<void> {
|
|
|
97
97
|
db.exec(MIGRATION_SQL);
|
|
98
98
|
|
|
99
99
|
const versionRow = db
|
|
100
|
-
.prepare("SELECT COUNT(*) as count FROM
|
|
100
|
+
.prepare("SELECT COUNT(*) as count FROM _BlackRiver Gateway_migrations WHERE name = ?")
|
|
101
101
|
.get("assessment_engine") as { count: number };
|
|
102
102
|
if (versionRow.count === 0) {
|
|
103
103
|
db.prepare(
|
|
104
|
-
"INSERT INTO
|
|
104
|
+
"INSERT INTO _BlackRiver Gateway_migrations (name, applied_at) VALUES (?, datetime('now'))"
|
|
105
105
|
).run("assessment_engine");
|
|
106
106
|
}
|
|
107
107
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getProviderAlias } from "@/shared/constants/providers";
|
|
2
|
-
import {
|
|
2
|
+
import { BlackRiver Gateway_RESPONSE_HEADERS } from "@/shared/constants/headers";
|
|
3
3
|
import { APP_CONFIG } from "@/shared/constants/appConfig";
|
|
4
4
|
|
|
5
5
|
type UsageLike = Record<string, unknown> | null | undefined;
|
|
@@ -51,7 +51,7 @@ function toHeaderValue(value: string): string {
|
|
|
51
51
|
return encodeURIComponent(toWellFormedUnicode(withoutControls));
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
export function
|
|
54
|
+
export function getBlackRiver GatewayTokenCounts(usage: UsageLike): { input: number; output: number } {
|
|
55
55
|
if (!usage || typeof usage !== "object") {
|
|
56
56
|
return { input: 0, output: 0 };
|
|
57
57
|
}
|
|
@@ -74,12 +74,12 @@ export function getOmniRouteTokenCounts(usage: UsageLike): { input: number; outp
|
|
|
74
74
|
};
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
export function
|
|
77
|
+
export function formatBlackRiver GatewayCost(costUsd: unknown): string {
|
|
78
78
|
const normalized = toFiniteNumber(costUsd);
|
|
79
79
|
return normalized > 0 ? normalized.toFixed(10) : "0.0000000000";
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
export function
|
|
82
|
+
export function buildBlackRiver GatewayResponseMetaHeaders({
|
|
83
83
|
cacheHit = false,
|
|
84
84
|
costUsd = 0,
|
|
85
85
|
costSavedUsd = undefined,
|
|
@@ -96,7 +96,7 @@ export function buildOmniRouteResponseMetaHeaders({
|
|
|
96
96
|
* Cost the cache AVOIDED. A semantic-cache HIT serves at ≈0 incremental cost
|
|
97
97
|
* (`costUsd: 0`) but saved the original call's cost — surface it here so billing
|
|
98
98
|
* consumers don't charge for hits while analytics can still see what was saved.
|
|
99
|
-
* Emitted as `X-
|
|
99
|
+
* Emitted as `X-BlackRiver Gateway-Cost-Saved` only when provided (omitted on normal
|
|
100
100
|
* responses); pass `0` to explicitly mark a free-model HIT that saved nothing.
|
|
101
101
|
*/
|
|
102
102
|
costSavedUsd?: unknown;
|
|
@@ -107,48 +107,48 @@ export function buildOmniRouteResponseMetaHeaders({
|
|
|
107
107
|
requestId?: string | null;
|
|
108
108
|
usage?: UsageLike;
|
|
109
109
|
}): Record<string, string> {
|
|
110
|
-
const tokens =
|
|
110
|
+
const tokens = getBlackRiver GatewayTokenCounts(usage);
|
|
111
111
|
const headers: Record<string, string> = {
|
|
112
|
-
[
|
|
113
|
-
[
|
|
114
|
-
[
|
|
115
|
-
[
|
|
116
|
-
[
|
|
117
|
-
[
|
|
112
|
+
[BlackRiver Gateway_RESPONSE_HEADERS.cacheHit]: toHeaderValue(String(cacheHit)),
|
|
113
|
+
[BlackRiver Gateway_RESPONSE_HEADERS.latencyMs]: toHeaderValue(String(toNonNegativeInteger(latencyMs))),
|
|
114
|
+
[BlackRiver Gateway_RESPONSE_HEADERS.responseCost]: toHeaderValue(formatBlackRiver GatewayCost(costUsd)),
|
|
115
|
+
[BlackRiver Gateway_RESPONSE_HEADERS.tokensIn]: toHeaderValue(String(tokens.input)),
|
|
116
|
+
[BlackRiver Gateway_RESPONSE_HEADERS.tokensOut]: toHeaderValue(String(tokens.output)),
|
|
117
|
+
[BlackRiver Gateway_RESPONSE_HEADERS.version]: toHeaderValue(APP_CONFIG.version),
|
|
118
118
|
};
|
|
119
119
|
|
|
120
120
|
if (typeof model === "string" && model.trim().length > 0) {
|
|
121
|
-
headers[
|
|
121
|
+
headers[BlackRiver Gateway_RESPONSE_HEADERS.model] = toHeaderValue(model);
|
|
122
122
|
}
|
|
123
123
|
|
|
124
124
|
if (typeof requestId === "string" && requestId.trim().length > 0) {
|
|
125
|
-
headers[
|
|
125
|
+
headers[BlackRiver Gateway_RESPONSE_HEADERS.requestId] = toHeaderValue(requestId);
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
if (typeof provider === "string" && provider.trim().length > 0) {
|
|
129
|
-
headers[
|
|
129
|
+
headers[BlackRiver Gateway_RESPONSE_HEADERS.provider] = toHeaderValue(getProviderAlias(provider));
|
|
130
130
|
}
|
|
131
131
|
|
|
132
132
|
// Cache-saved cost: emitted only when the caller passes a value (cache HITs), so
|
|
133
133
|
// non-cache responses keep their existing header shape. `0` is a valid saved cost.
|
|
134
134
|
if (costSavedUsd != null) {
|
|
135
|
-
headers[
|
|
136
|
-
|
|
135
|
+
headers[BlackRiver Gateway_RESPONSE_HEADERS.costSaved] = toHeaderValue(
|
|
136
|
+
formatBlackRiver GatewayCost(costSavedUsd)
|
|
137
137
|
);
|
|
138
138
|
}
|
|
139
139
|
|
|
140
140
|
const attempts = toNonNegativeInteger(fallbackAttempts);
|
|
141
141
|
if (attempts > 0) {
|
|
142
|
-
headers[
|
|
142
|
+
headers[BlackRiver Gateway_RESPONSE_HEADERS.fallbackAttempts] = toHeaderValue(String(attempts));
|
|
143
143
|
}
|
|
144
144
|
|
|
145
145
|
return headers;
|
|
146
146
|
}
|
|
147
147
|
|
|
148
|
-
export function
|
|
149
|
-
options: Parameters<typeof
|
|
148
|
+
export function buildBlackRiver GatewaySseMetadataComment(
|
|
149
|
+
options: Parameters<typeof buildBlackRiver GatewayResponseMetaHeaders>[0]
|
|
150
150
|
): string {
|
|
151
|
-
const headers =
|
|
151
|
+
const headers = buildBlackRiver GatewayResponseMetaHeaders(options);
|
|
152
152
|
const lines = Object.entries(headers)
|
|
153
153
|
.filter(([, value]) => typeof value === "string" && value.trim().length > 0)
|
|
154
154
|
.map(([name, value]) => `: ${name.toLowerCase()}=${value}`);
|
|
@@ -157,15 +157,15 @@ export function buildOmniRouteSseMetadataComment(
|
|
|
157
157
|
}
|
|
158
158
|
|
|
159
159
|
/**
|
|
160
|
-
* Single choke-point for attaching the X-
|
|
160
|
+
* Single choke-point for attaching the X-BlackRiver Gateway-* response meta headers.
|
|
161
161
|
* Mutates `headers` in place (accepts a Headers instance OR a plain Record).
|
|
162
162
|
* Use at EVERY non-streaming success return so no route forgets the telemetry.
|
|
163
163
|
*/
|
|
164
|
-
export function
|
|
164
|
+
export function attachBlackRiver GatewayMetaHeaders(
|
|
165
165
|
headers: Headers | Record<string, string>,
|
|
166
|
-
meta: Parameters<typeof
|
|
166
|
+
meta: Parameters<typeof buildBlackRiver GatewayResponseMetaHeaders>[0]
|
|
167
167
|
): void {
|
|
168
|
-
const built =
|
|
168
|
+
const built = buildBlackRiver GatewayResponseMetaHeaders(meta);
|
|
169
169
|
if (headers instanceof Headers) {
|
|
170
170
|
for (const [name, value] of Object.entries(built)) headers.set(name, value);
|
|
171
171
|
} else {
|
|
@@ -174,21 +174,21 @@ export function attachOmniRouteMetaHeaders(
|
|
|
174
174
|
}
|
|
175
175
|
|
|
176
176
|
/**
|
|
177
|
-
* Attach the X-
|
|
177
|
+
* Attach the X-BlackRiver Gateway-* meta headers onto an already-built Response, ADDING
|
|
178
178
|
* (never replacing) headers so the original Content-Type / body stay intact.
|
|
179
179
|
* Tries to mutate in place; if the Response headers are immutable, clones the
|
|
180
180
|
* Response carrying over body + status + headers (mirrors
|
|
181
181
|
* `chatHelpers.ts::withSessionHeader`). Use for opaque handler-built Responses
|
|
182
182
|
* (audio streams, passthrough proxies) where the body cannot be re-serialized.
|
|
183
183
|
*/
|
|
184
|
-
export function
|
|
184
|
+
export function attachBlackRiver GatewayMetaToResponse(
|
|
185
185
|
response: Response,
|
|
186
|
-
meta: Parameters<typeof
|
|
186
|
+
meta: Parameters<typeof buildBlackRiver GatewayResponseMetaHeaders>[0]
|
|
187
187
|
): Response {
|
|
188
188
|
if (!response) return response;
|
|
189
189
|
|
|
190
190
|
try {
|
|
191
|
-
|
|
191
|
+
attachBlackRiver GatewayMetaHeaders(response.headers, meta);
|
|
192
192
|
return response;
|
|
193
193
|
} catch {
|
|
194
194
|
const cloned = new Response(response.body, {
|
|
@@ -196,7 +196,7 @@ export function attachOmniRouteMetaToResponse(
|
|
|
196
196
|
statusText: response.statusText,
|
|
197
197
|
headers: response.headers,
|
|
198
198
|
});
|
|
199
|
-
|
|
199
|
+
attachBlackRiver GatewayMetaHeaders(cloned.headers, meta);
|
|
200
200
|
return cloned;
|
|
201
201
|
}
|
|
202
202
|
}
|
package/src/domain/quotaCache.ts
CHANGED
|
@@ -13,9 +13,9 @@
|
|
|
13
13
|
* @module domain/quotaCache
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
|
-
import { getUsageForProvider } from "@
|
|
16
|
+
import { getUsageForProvider } from "@BlackRiver Gateway/open-sse/services/usage.ts";
|
|
17
17
|
import { getProviderConnectionById, resolveProxyForConnection } from "@/lib/localDb";
|
|
18
|
-
import { runWithProxyContext } from "@
|
|
18
|
+
import { runWithProxyContext } from "@BlackRiver Gateway/open-sse/utils/proxyFetch.ts";
|
|
19
19
|
import { safePercentage } from "@/shared/utils/formatting";
|
|
20
20
|
import {
|
|
21
21
|
saveQuotaSnapshot,
|
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
getLatestQuotaSnapshotsForConnection,
|
|
24
24
|
} from "@/lib/db/quotaSnapshots";
|
|
25
25
|
import { recordProviderQuotaResetEventIfChanged } from "@/lib/db/quotaResetEvents";
|
|
26
|
-
import { getCodexQuotaWindowFilterForModel } from "@
|
|
26
|
+
import { getCodexQuotaWindowFilterForModel } from "@BlackRiver Gateway/open-sse/config/codexQuotaScopes.ts";
|
|
27
27
|
|
|
28
28
|
// ─── Types ──────────────────────────────────────────────────────────────────
|
|
29
29
|
|
package/src/domain/types.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Domain Types — FASE-03 Architecture Refactoring
|
|
3
3
|
*
|
|
4
|
-
* Centralized type definitions for the
|
|
4
|
+
* Centralized type definitions for the BlackRiver Gateway domain layer.
|
|
5
5
|
* Uses JSDoc for type safety without TypeScript compilation.
|
|
6
6
|
*
|
|
7
7
|
* @module domain/types
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* A2A Routing Decision Logger
|
|
3
3
|
*
|
|
4
4
|
* Records every routing decision to the `routing_decisions` SQLite table.
|
|
5
|
-
* Used by `
|
|
5
|
+
* Used by `BlackRiver Gateway_explain_route` (T03) and future learning router.
|
|
6
6
|
* Retention: 7 days default.
|
|
7
7
|
*/
|
|
8
8
|
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import type { A2ATask, TaskArtifact } from "../taskManager";
|
|
8
|
-
import {
|
|
8
|
+
import { resolveBlackRiver GatewayBaseUrl } from "@/shared/utils/resolveBlackRiver GatewayBaseUrl";
|
|
9
9
|
import { formatCost } from "@/shared/utils/formatting";
|
|
10
10
|
|
|
11
11
|
type AnalyticsRecord = Record<string, unknown>;
|
|
@@ -17,8 +17,8 @@ type CostEntry = {
|
|
|
17
17
|
tokens: number;
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
-
const
|
|
21
|
-
const
|
|
20
|
+
const BlackRiver Gateway_BASE_URL = resolveBlackRiver GatewayBaseUrl();
|
|
21
|
+
const BlackRiver Gateway_API_KEY = process.env.BlackRiver Gateway_API_KEY || "";
|
|
22
22
|
|
|
23
23
|
function detectRange(task: A2ATask): string {
|
|
24
24
|
const metadataRange = task.input.metadata?.range;
|
|
@@ -33,10 +33,10 @@ function detectRange(task: A2ATask): string {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
async function costFetch(path: string): Promise<AnalyticsRecord> {
|
|
36
|
-
const url = `${
|
|
36
|
+
const url = `${BlackRiver Gateway_BASE_URL}${path}`;
|
|
37
37
|
const headers: Record<string, string> = {
|
|
38
38
|
"Content-Type": "application/json",
|
|
39
|
-
...(
|
|
39
|
+
...(BlackRiver Gateway_API_KEY ? { Authorization: `Bearer ${BlackRiver Gateway_API_KEY}` } : {}),
|
|
40
40
|
};
|
|
41
41
|
const response = await fetch(url, { headers, signal: AbortSignal.timeout(15000) });
|
|
42
42
|
if (!response.ok) {
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import type { A2ATask, TaskArtifact } from "../taskManager";
|
|
8
|
-
import {
|
|
8
|
+
import { resolveBlackRiver GatewayBaseUrl } from "@/shared/utils/resolveBlackRiver GatewayBaseUrl";
|
|
9
9
|
|
|
10
10
|
type JsonRecord = Record<string, unknown>;
|
|
11
11
|
|
|
@@ -16,14 +16,14 @@ type ProviderHealthEntry = {
|
|
|
16
16
|
lastFailure?: string | null;
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
-
const
|
|
20
|
-
const
|
|
19
|
+
const BlackRiver Gateway_BASE_URL = resolveBlackRiver GatewayBaseUrl();
|
|
20
|
+
const BlackRiver Gateway_API_KEY = process.env.BlackRiver Gateway_API_KEY || "";
|
|
21
21
|
|
|
22
22
|
async function healthFetch(path: string): Promise<JsonRecord> {
|
|
23
|
-
const url = `${
|
|
23
|
+
const url = `${BlackRiver Gateway_BASE_URL}${path}`;
|
|
24
24
|
const headers: Record<string, string> = {
|
|
25
25
|
"Content-Type": "application/json",
|
|
26
|
-
...(
|
|
26
|
+
...(BlackRiver Gateway_API_KEY ? { Authorization: `Bearer ${BlackRiver Gateway_API_KEY}` } : {}),
|
|
27
27
|
};
|
|
28
28
|
const response = await fetch(url, { headers, signal: AbortSignal.timeout(10000) });
|
|
29
29
|
if (!response.ok) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* A2A Skill: List Capabilities
|
|
3
3
|
*
|
|
4
|
-
* Returns the full catalog of
|
|
4
|
+
* Returns the full catalog of BlackRiver Gateway agent skills (22 API + 20 CLI + config)
|
|
5
5
|
* as a markdown table with raw SKILL.md URLs for orchestrating agents.
|
|
6
6
|
*/
|
|
7
7
|
|
|
@@ -45,7 +45,7 @@ export async function executeListCapabilities(_task: A2ATask): Promise<ListCapab
|
|
|
45
45
|
const table = buildMarkdownTable(catalog);
|
|
46
46
|
|
|
47
47
|
const content = [
|
|
48
|
-
`#
|
|
48
|
+
`# BlackRiver Gateway Agent Skills Catalog`,
|
|
49
49
|
``,
|
|
50
50
|
`Total: ${catalog.length} skills (${coverage.api.total} API + ${coverage.cli.total} CLI)`,
|
|
51
51
|
``,
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
SEARCH_PROVIDERS,
|
|
15
15
|
VIDEO_PROVIDER_IDS,
|
|
16
16
|
} from "@/shared/constants/providers";
|
|
17
|
-
import { REGISTRY } from "@
|
|
17
|
+
import { REGISTRY } from "@BlackRiver Gateway/open-sse/config/providerRegistry.ts";
|
|
18
18
|
|
|
19
19
|
type ProviderConnectionLike = {
|
|
20
20
|
id?: string;
|
|
@@ -7,16 +7,16 @@
|
|
|
7
7
|
|
|
8
8
|
import type { A2ATask, TaskArtifact } from "../taskManager";
|
|
9
9
|
import { normalizeQuotaResponse } from "@/shared/contracts/quota";
|
|
10
|
-
import {
|
|
10
|
+
import { resolveBlackRiver GatewayBaseUrl } from "@/shared/utils/resolveBlackRiver GatewayBaseUrl";
|
|
11
11
|
|
|
12
|
-
const
|
|
13
|
-
const
|
|
12
|
+
const BlackRiver Gateway_BASE_URL = resolveBlackRiver GatewayBaseUrl();
|
|
13
|
+
const BlackRiver Gateway_API_KEY = process.env.BlackRiver Gateway_API_KEY || "";
|
|
14
14
|
|
|
15
15
|
async function quotaFetch(path: string): Promise<any> {
|
|
16
|
-
const url = `${
|
|
16
|
+
const url = `${BlackRiver Gateway_BASE_URL}${path}`;
|
|
17
17
|
const headers: Record<string, string> = {
|
|
18
18
|
"Content-Type": "application/json",
|
|
19
|
-
...(
|
|
19
|
+
...(BlackRiver Gateway_API_KEY ? { Authorization: `Bearer ${BlackRiver Gateway_API_KEY}` } : {}),
|
|
20
20
|
};
|
|
21
21
|
const res = await fetch(url, { headers, signal: AbortSignal.timeout(10000) });
|
|
22
22
|
if (!res.ok) throw new Error(`API [${res.status}]`);
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* A2A Skill: Smart Routing
|
|
3
3
|
*
|
|
4
|
-
* Receives a prompt + metadata → routes via
|
|
4
|
+
* Receives a prompt + metadata → routes via BlackRiver Gateway pipeline →
|
|
5
5
|
* returns response with routing_explanation, cost_envelope, resilience_trace, policy_verdict.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import type { A2ATask, TaskArtifact } from "../taskManager";
|
|
9
|
-
import {
|
|
9
|
+
import { resolveBlackRiver GatewayBaseUrl } from "@/shared/utils/resolveBlackRiver GatewayBaseUrl";
|
|
10
10
|
|
|
11
|
-
const
|
|
12
|
-
const
|
|
11
|
+
const BlackRiver Gateway_BASE_URL = resolveBlackRiver GatewayBaseUrl();
|
|
12
|
+
const BlackRiver Gateway_API_KEY = process.env.BlackRiver Gateway_API_KEY || "";
|
|
13
13
|
|
|
14
14
|
async function routeFetch(path: string, options: RequestInit = {}): Promise<any> {
|
|
15
|
-
const url = `${
|
|
15
|
+
const url = `${BlackRiver Gateway_BASE_URL}${path}`;
|
|
16
16
|
const headers: Record<string, string> = {
|
|
17
17
|
"Content-Type": "application/json",
|
|
18
|
-
...(
|
|
18
|
+
...(BlackRiver Gateway_API_KEY ? { Authorization: `Bearer ${BlackRiver Gateway_API_KEY}` } : {}),
|
|
19
19
|
};
|
|
20
20
|
const res = await fetch(url, { ...options, headers, signal: AbortSignal.timeout(30000) });
|
|
21
21
|
if (!res.ok) throw new Error(`API [${res.status}]: ${await res.text().catch(() => "error")}`);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* CLI access-token scopes — the 3-level hierarchy used by remote mode.
|
|
3
3
|
*
|
|
4
|
-
* These tokens authorize the `
|
|
5
|
-
* commands against a (possibly remote)
|
|
4
|
+
* These tokens authorize the `BlackRiver Gateway` CLI (and dashboard) to run *management*
|
|
5
|
+
* commands against a (possibly remote) BlackRiver Gateway server. They are distinct from
|
|
6
6
|
* inference API keys (`api_keys`), which authorize `/v1/chat/completions` traffic.
|
|
7
7
|
*
|
|
8
8
|
* Hierarchy (admin ⊃ write ⊃ read):
|
package/src/lib/acp/manager.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Communication happens via stdin/stdout (JSON-RPC style) or piped HTTP.
|
|
6
6
|
*
|
|
7
7
|
* This module provides a "CLI-as-backend" transport: instead of intercepting
|
|
8
|
-
* HTTP API calls,
|
|
8
|
+
* HTTP API calls, BlackRiver Gateway spawns the CLI directly and feeds prompts through
|
|
9
9
|
* its native interface.
|
|
10
10
|
*/
|
|
11
11
|
|
package/src/lib/acp/registry.ts
CHANGED
|
@@ -26,7 +26,7 @@ export interface CliAgentInfo {
|
|
|
26
26
|
version: string | null;
|
|
27
27
|
/** Whether the agent is installed and available */
|
|
28
28
|
installed: boolean;
|
|
29
|
-
/** Provider ID that this agent maps to in
|
|
29
|
+
/** Provider ID that this agent maps to in BlackRiver Gateway */
|
|
30
30
|
providerAlias: string;
|
|
31
31
|
/** Arguments to pass when spawning for ACP */
|
|
32
32
|
spawnArgs: string[];
|
|
@@ -109,7 +109,7 @@ function buildApiBody(skill: AgentSkill, sources: BuildSources): string {
|
|
|
109
109
|
const curlMethod = op.method === "GET" ? "" : `-X ${op.method} `;
|
|
110
110
|
lines.push("```bash");
|
|
111
111
|
lines.push(`curl ${curlMethod}https://localhost:20128${op.path} \\`);
|
|
112
|
-
lines.push(' -H "Authorization: Bearer $
|
|
112
|
+
lines.push(' -H "Authorization: Bearer $BlackRiver Gateway_TOKEN"');
|
|
113
113
|
if (["POST", "PUT", "PATCH"].includes(op.method)) {
|
|
114
114
|
lines.push(' -H "Content-Type: application/json" \\');
|
|
115
115
|
lines.push(" -d '{}'");
|
|
@@ -141,8 +141,8 @@ function buildCliBody(skill: AgentSkill, sources: BuildSources): string {
|
|
|
141
141
|
|
|
142
142
|
lines.push("## Quick install\n");
|
|
143
143
|
lines.push("```bash");
|
|
144
|
-
lines.push("npm install -g
|
|
145
|
-
lines.push("
|
|
144
|
+
lines.push("npm install -g BlackRiver Gateway # or: npx BlackRiver Gateway");
|
|
145
|
+
lines.push("BlackRiver Gateway --version");
|
|
146
146
|
lines.push("```");
|
|
147
147
|
lines.push("");
|
|
148
148
|
|
|
@@ -169,7 +169,7 @@ function buildCliBody(skill: AgentSkill, sources: BuildSources): string {
|
|
|
169
169
|
|
|
170
170
|
lines.push("**Example:**\n");
|
|
171
171
|
lines.push("```bash");
|
|
172
|
-
lines.push(`
|
|
172
|
+
lines.push(`BlackRiver Gateway ${cmd.name}`);
|
|
173
173
|
lines.push("```");
|
|
174
174
|
lines.push("");
|
|
175
175
|
}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* optional `details` payload, and the current `requestId` for log
|
|
8
8
|
* correlation. The prior shape returned `{ error: <string|object> }` with
|
|
9
9
|
* no `code` field, which forced clients to string-match English error
|
|
10
|
-
* messages. See `plans/2026-06-23-
|
|
10
|
+
* messages. See `plans/2026-06-23-BlackRiver Gateway-v3.8.34-deep-audit.md` (Bug #3).
|
|
11
11
|
*
|
|
12
12
|
* Usage:
|
|
13
13
|
* return comboErrorResponse("COMBO_002", 400, { issues: validation.issues });
|
|
@@ -4,10 +4,10 @@ import { handleValidatedEmbeddingRequestBody } from "@/app/api/v1/embeddings/rou
|
|
|
4
4
|
import { POST as postRerank } from "@/app/api/v1/rerank/route";
|
|
5
5
|
import { buildComboTestRequestBody, extractComboTestResponseText } from "@/lib/combos/testHealth";
|
|
6
6
|
import { getCustomModels } from "@/lib/localDb";
|
|
7
|
-
import { sanitizeErrorMessage } from "@
|
|
8
|
-
import { withRateLimit } from "@
|
|
7
|
+
import { sanitizeErrorMessage } from "@BlackRiver Gateway/open-sse/utils/error";
|
|
8
|
+
import { withRateLimit } from "@BlackRiver Gateway/open-sse/services/rateLimitManager";
|
|
9
9
|
|
|
10
|
-
const INTERNAL_ORIGIN = "http://
|
|
10
|
+
const INTERNAL_ORIGIN = "http://BlackRiver Gateway.internal";
|
|
11
11
|
const DEFAULT_TEST_TIMEOUT_MS = 10_000;
|
|
12
12
|
const DOLA_PRO_TEST_TIMEOUT_MS = 90_000;
|
|
13
13
|
const DOUBAO_WEB_PROVIDER_ID = "doubao-web";
|
|
@@ -120,7 +120,7 @@ function buildInternalChatRequest(testBody: Record<string, unknown>, signal: Abo
|
|
|
120
120
|
"Content-Type": "application/json",
|
|
121
121
|
// Reuse the existing strict-mode internal bypass for live health checks.
|
|
122
122
|
"X-Internal-Test": "combo-health-check",
|
|
123
|
-
"X-
|
|
123
|
+
"X-BlackRiver Gateway-No-Cache": "true",
|
|
124
124
|
"X-Request-Id": `model-test-${randomUUID()}`,
|
|
125
125
|
},
|
|
126
126
|
body: JSON.stringify(testBody),
|
|
@@ -134,7 +134,7 @@ function buildInternalRerankRequest(testBody: Record<string, unknown>, signal: A
|
|
|
134
134
|
headers: {
|
|
135
135
|
"Content-Type": "application/json",
|
|
136
136
|
"X-Internal-Test": "combo-health-check",
|
|
137
|
-
"X-
|
|
137
|
+
"X-BlackRiver Gateway-No-Cache": "true",
|
|
138
138
|
"X-Request-Id": `model-test-${randomUUID()}`,
|
|
139
139
|
},
|
|
140
140
|
body: JSON.stringify(testBody),
|
|
@@ -230,9 +230,9 @@ export async function runSingleModelTest(
|
|
|
230
230
|
const testBody = isRerank
|
|
231
231
|
? {
|
|
232
232
|
model: fullModelStr,
|
|
233
|
-
query: "What is
|
|
233
|
+
query: "What is BlackRiver Gateway?",
|
|
234
234
|
documents: [
|
|
235
|
-
"
|
|
235
|
+
"BlackRiver Gateway routes AI requests across configured providers.",
|
|
236
236
|
"This document is unrelated to the test query.",
|
|
237
237
|
],
|
|
238
238
|
top_n: 1,
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
import { createErrorResponse, createErrorResponseFromUnknown } from "@/lib/api/errorResponse";
|
|
11
11
|
import { createProxyRegistrySchema, updateProxyRegistrySchema } from "@/shared/validation/schemas";
|
|
12
12
|
import { isValidationFailure, validateBody } from "@/shared/validation/helpers";
|
|
13
|
-
import { clearDispatcherCache } from "@
|
|
13
|
+
import { clearDispatcherCache } from "@BlackRiver Gateway/open-sse/utils/proxyDispatcher";
|
|
14
14
|
|
|
15
15
|
async function readJsonBody(request: Request) {
|
|
16
16
|
try {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Extract a human-readable message from a parsed API error body.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* BlackRiver Gateway API error bodies follow the shape produced by
|
|
5
5
|
* `comboErrorResponse`/`buildErrorBody`:
|
|
6
6
|
*
|
|
7
7
|
* { error: { message: string, details?: Array<{ message?: string }> } }
|
|
@@ -165,11 +165,11 @@ function proxyUpgrade(
|
|
|
165
165
|
}
|
|
166
166
|
|
|
167
167
|
declare global {
|
|
168
|
-
var
|
|
168
|
+
var __BlackRiver GatewayApiBridgeStarted: boolean | undefined;
|
|
169
169
|
}
|
|
170
170
|
|
|
171
171
|
export function initApiBridgeServer(): void {
|
|
172
|
-
if (globalThis.
|
|
172
|
+
if (globalThis.__BlackRiver GatewayApiBridgeStarted) return;
|
|
173
173
|
|
|
174
174
|
const { apiPort, dashboardPort } = getRuntimePorts();
|
|
175
175
|
if (apiPort === dashboardPort) return;
|
|
@@ -227,7 +227,7 @@ export function initApiBridgeServer(): void {
|
|
|
227
227
|
});
|
|
228
228
|
|
|
229
229
|
server.listen(apiPort, host, () => {
|
|
230
|
-
globalThis.
|
|
230
|
+
globalThis.__BlackRiver GatewayApiBridgeStarted = true;
|
|
231
231
|
console.log(`[API Bridge] Listening on ${host}:${apiPort} -> dashboard:${dashboardPort}`);
|
|
232
232
|
});
|
|
233
233
|
}
|
package/src/lib/arenaEloSync.ts
CHANGED
|
@@ -104,7 +104,7 @@ const ARENA_ELO_API_BASE = "https://api.wulong.dev/arena-ai-leaderboards/v1/lead
|
|
|
104
104
|
const FETCH_CATEGORIES = ["text", "code"] as const;
|
|
105
105
|
|
|
106
106
|
/**
|
|
107
|
-
* Maps Arena leaderboard categories to
|
|
107
|
+
* Maps Arena leaderboard categories to BlackRiver Gateway task-type categories.
|
|
108
108
|
*
|
|
109
109
|
* - "text" leaderboard → default, review, documentation, debugging
|
|
110
110
|
* - "code" leaderboard → coding
|
|
@@ -140,9 +140,9 @@ const VENDOR_PREFIXES = [
|
|
|
140
140
|
] as const;
|
|
141
141
|
|
|
142
142
|
/**
|
|
143
|
-
*
|
|
143
|
+
* BlackRiver Gateway model aliases: canonical name → known aliases.
|
|
144
144
|
* Creates additional DB entries for each alias so that models
|
|
145
|
-
* are findable under any name
|
|
145
|
+
* are findable under any name BlackRiver Gateway uses internally.
|
|
146
146
|
*/
|
|
147
147
|
const MODEL_ALIAS_MAP: Record<string, string[]> = {
|
|
148
148
|
"claude-opus-4-6-thinking": ["claude-opus-4", "anthropic/claude-opus-4"],
|
|
@@ -291,11 +291,11 @@ function computeConfidence(votes: number): "high" | "medium" | "low" {
|
|
|
291
291
|
* This ensures scores never reach 0 or 1, leaving room for user overrides.
|
|
292
292
|
* Models with fewer than 100 votes are marked as confidence="low".
|
|
293
293
|
*
|
|
294
|
-
* Leaderboard categories are mapped to
|
|
294
|
+
* Leaderboard categories are mapped to BlackRiver Gateway task types:
|
|
295
295
|
* - "text" → default, review, documentation, debugging
|
|
296
296
|
* - "code" → coding
|
|
297
297
|
*
|
|
298
|
-
* Known
|
|
298
|
+
* Known BlackRiver Gateway model aliases are also expanded into additional entries.
|
|
299
299
|
*
|
|
300
300
|
* @param data - Map of leaderboard category → Arena leaderboard data.
|
|
301
301
|
* @returns Array of model intelligence entries ready for DB upsert.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Helper used by the `
|
|
2
|
+
* Helper used by the `BlackRiver Gateway_BUILD_PROFILE=minimal` stubs to surface a
|
|
3
3
|
* consistent "this feature was compiled out" error. Routes that depend on a
|
|
4
4
|
* stubbed module should catch the error and return HTTP 503 with a clear
|
|
5
5
|
* message; we don't want the bundle to silently fail.
|
|
@@ -10,8 +10,8 @@ export class FeatureDisabledError extends Error {
|
|
|
10
10
|
readonly featureName: string;
|
|
11
11
|
constructor(featureName: string) {
|
|
12
12
|
super(
|
|
13
|
-
`Feature "${featureName}" is disabled in this build (
|
|
14
|
-
`Install the full
|
|
13
|
+
`Feature "${featureName}" is disabled in this build (BlackRiver Gateway_BUILD_PROFILE=minimal). ` +
|
|
14
|
+
`Install the full BlackRiver Gateway artifact instead of BlackRiver Gateway-secure if you need this feature.`
|
|
15
15
|
);
|
|
16
16
|
this.name = "FeatureDisabledError";
|
|
17
17
|
this.featureName = featureName;
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { getSettings } from "./db/settings";
|
|
9
|
-
import type { CacheControlMode } from "@
|
|
9
|
+
import type { CacheControlMode } from "@BlackRiver Gateway/open-sse/utils/cacheControlPolicy";
|
|
10
10
|
|
|
11
11
|
let cachedSettings: CacheControlMode | null = null;
|
|
12
12
|
|
|
@@ -88,7 +88,7 @@ function writeCache(data: CatalogEntry[]): void {
|
|
|
88
88
|
async function fetchFromAPI(): Promise<CatalogEntry[]> {
|
|
89
89
|
const res = await fetch(OPENROUTER_API_URL, {
|
|
90
90
|
headers: {
|
|
91
|
-
"User-Agent": "
|
|
91
|
+
"User-Agent": "BlackRiver Gateway/2.0",
|
|
92
92
|
Accept: "application/json",
|
|
93
93
|
},
|
|
94
94
|
signal: AbortSignal.timeout(15_000),
|