diff --git a/config/quality/file-size-baseline.json b/config/quality/file-size-baseline.json index 0c7d6db2a5f6..b89dbe34fa97 100644 --- a/config/quality/file-size-baseline.json +++ b/config/quality/file-size-baseline.json @@ -1,5 +1,5 @@ { - "_rebaseline_2026_07_18_pr7360_quota_visibility_resync": "PR #7360 (JxnLexn, per-connection Provider Quota visibility) release-resync: merging origin/release/v3.8.49 into the PR's own branch to resolve its 3-file conflict (ConnectionRow.tsx/ConnectionsListPanel.tsx/useProviderConnections.ts import unions) surfaced ProviderDetailPageClient.tsx 785->791 (measured via check-file-size.mjs's split('\\n').length; wc -l reports 790). Both parents were individually within the 786 cap: release tip alone measures 785 (its own confirm-delete-account #7361 wiring), and the PR's own pre-merge tip also measured 785 (its own quota-visibility wiring) — the two independent, already-cohesive features simply sum past the frozen ceiling once unioned in this same already-oversized god-component (tracked for decomposition under #3501). No new logic was written during the resync; the only edits were import-statement unions. Frozen raised 786->791.", + "_rebaseline_2026_07_18_v3849_provider_detail_wiring": "Merge campaign R2/R3 (2026-07-18): three authorized PRs each add irreducible call-site wiring to ProviderDetailPageClient.tsx — #7360 +5 (ProviderQuotaVisibilityToggle render, component extracted), #7419 +4 (NoAuthProviderControls wiring), #7062 +3 (Dahl provider hook) = 786->798. All three follow the extracted-component pattern (AgentrouterConsoleFields precedent); the frozen file only takes the wiring. Structural shrink tracked in #3501.", "_rebaseline_2026_07_18_pr7653_chat_tracker_import": "PR #7653 merge-interaction growth: release moved chat.ts to its 1796 cap while this PR adds the single side-effect import 'quotaTrackersBatch.ts' (line 130) — chat.ts IS the canonical quota-fetcher registration point (codex/bailian/deepseek/openrouter/opencode/generic all import+register there), so the +1 is irreducible call-site wiring. 1796->1797. Covered by tests/unit/{agentrouter,v0,freemodel}-quota-fetcher.test.ts.", "_rebaseline_2026_07_17_pr7653_agentrouter_console_fields": "PR #7653 own growth (missing acceptance criterion: the AgentRouter quota tracker (#6850) read providerSpecificData.consoleApiKey/newApiUserId but neither field had dashboard UI for provider agentrouter — consoleApiKey was gated to bailian-coding-plan only and newApiUserId had zero UI). AddApiKeyModal.tsx 961->967 (+6) and EditConnectionModal.tsx 1278->1286 (+8) = import + a single render call plus the newApiUserId formData init field. The actual Input rendering (both consoleApiKey reuse + the new newApiUserId field) was EXTRACTED into a new leaf src/app/(dashboard)/dashboard/providers/[id]/components/modals/AgentrouterConsoleFields.tsx (48 LOC, 2462 (+1, irreducible at the existing model-aware preflight chokepoint — the `provider === \"codex\"` check that forwards requestedModel into the connection arg is extended to also cover `openrouter`, one added boolean + a doc comment, offset to a single net line by dropping the now-redundant inline condition). Enforcement itself lives in open-sse/services/openrouterQuotaFetcher.ts (not frozen) and the dispatch-time record/correct hooks live in open-sse/executors/base.ts (not frozen). Covered by tests/unit/openrouter-free-window-wiring-6842.test.ts.", @@ -215,7 +215,7 @@ "src/app/(dashboard)/dashboard/endpoint/EndpointPageClient.tsx": 2612, "src/app/(dashboard)/dashboard/health/page.tsx": 1091, "src/app/(dashboard)/dashboard/playground/components/tabs/ApiTab.tsx": 847, - "src/app/(dashboard)/dashboard/providers/[id]/ProviderDetailPageClient.tsx": 791, + "src/app/(dashboard)/dashboard/providers/[id]/ProviderDetailPageClient.tsx": 798, "src/app/(dashboard)/dashboard/providers/[id]/components/ConnectionRow.tsx": 942, "src/app/(dashboard)/dashboard/providers/[id]/components/modals/AddApiKeyModal.tsx": 967, "src/app/(dashboard)/dashboard/providers/[id]/components/modals/EditConnectionModal.tsx": 1286, diff --git a/src/app/(dashboard)/dashboard/providers/[id]/ProviderDetailPageClient.tsx b/src/app/(dashboard)/dashboard/providers/[id]/ProviderDetailPageClient.tsx index 7340e7e6fcea..6e2bb5f2c373 100644 --- a/src/app/(dashboard)/dashboard/providers/[id]/ProviderDetailPageClient.tsx +++ b/src/app/(dashboard)/dashboard/providers/[id]/ProviderDetailPageClient.tsx @@ -424,8 +424,6 @@ export default function ProviderDetailPageClient() { providerNode, }); - // renderModelsSection → components/ProviderModelsSection.tsx (Phase 1m) - if (loading) { return (
@@ -448,7 +446,6 @@ export default function ProviderDetailPageClient() { return (
- {/* Header — Phase 1t.1: extracted to components/ProviderPageHeader.tsx */} )} - - {/* CompatibleNodeCard — Phase 1t.2: extracted to components/CompatibleNodeCard.tsx */} {isCompatible && providerNode && ( )} - - {/* Connections */} {!isUpstreamProxyProvider && isFreeNoAuth && ( + setProxyTarget({ + level: "provider", + id: providerId, + label: providerInfo?.name || providerId, + }) + } /> )} {!isUpstreamProxyProvider && !isFreeNoAuth && ( diff --git a/src/app/(dashboard)/dashboard/providers/[id]/components/NoAuthProviderControls.tsx b/src/app/(dashboard)/dashboard/providers/[id]/components/NoAuthProviderControls.tsx index 7ae5305d9107..1d2decf08494 100644 --- a/src/app/(dashboard)/dashboard/providers/[id]/components/NoAuthProviderControls.tsx +++ b/src/app/(dashboard)/dashboard/providers/[id]/components/NoAuthProviderControls.tsx @@ -2,8 +2,9 @@ import { useCallback, useEffect, useState } from "react"; import { NoAuthAccountCard, NoAuthProviderCard } from "@/shared/components"; -import { getProviderAlias } from "@/shared/constants/providers"; +import { getProviderAlias, supportsNoAuthProviderProxy } from "@/shared/constants/providers"; import { useNotificationStore } from "@/store/notificationStore"; +import { useTranslations } from "next-intl"; const ACCOUNT_PROVIDER_NAMES: Record = { mimocode: "MiMoCode", @@ -13,13 +14,18 @@ const ACCOUNT_PROVIDER_NAMES: Record = { interface NoAuthProviderControlsProps { providerId: string; providerName: string; + providerProxy?: { host?: string | null } | null; + onConfigureProviderProxy: () => void; } export default function NoAuthProviderControls({ providerId, providerName, + providerProxy, + onConfigureProviderProxy, }: NoAuthProviderControlsProps) { const notify = useNotificationStore(); + const t = useTranslations("providers"); const [blockedProviders, setBlockedProviders] = useState([]); const [savingEnabled, setSavingEnabled] = useState(false); const providerAlias = getProviderAlias(providerId); @@ -82,6 +88,23 @@ export default function NoAuthProviderControls({ ); const accountProviderName = ACCOUNT_PROVIDER_NAMES[providerId]; + const host = providerProxy?.host; + const providerProxyControl = supportsNoAuthProviderProxy(providerId) ? ( + + ) : null; + if (accountProviderName) { return ( ); } @@ -100,6 +124,7 @@ export default function NoAuthProviderControls({ enabled={enabled} saving={savingEnabled} onEnabledChange={handleEnabledChange} + providerProxyControl={providerProxyControl} /> ); } diff --git a/src/app/api/v1/messages/count_tokens/route.ts b/src/app/api/v1/messages/count_tokens/route.ts index 6a92bebed5f4..7ae269e95dfd 100644 --- a/src/app/api/v1/messages/count_tokens/route.ts +++ b/src/app/api/v1/messages/count_tokens/route.ts @@ -65,7 +65,11 @@ export async function POST(request) { const executor = await getExecutor(modelInfo.provider); // The provider-side count is a real upstream call — it must honor the // connection's proxy assignment exactly like chat execution does. - const proxyInfo = await safeResolveProxy(credentials.connectionId); + const proxyInfo = await safeResolveProxy( + credentials.connectionId, + undefined, + modelInfo.provider + ); const counted = await runWithProxyContext(proxyInfo?.proxy || null, () => executor?.countTokens?.({ model: modelInfo.model, diff --git a/src/lib/db/proxies/guards.ts b/src/lib/db/proxies/guards.ts index d0fd7c5069f8..1032e5b47c8e 100644 --- a/src/lib/db/proxies/guards.ts +++ b/src/lib/db/proxies/guards.ts @@ -23,7 +23,7 @@ export function isGlobalProxyEnabled(db: ReturnType): bool * #6246 fail-closed guard for a connection with an assigned dead proxy pool. * Explicitly disabling proxying globally or for the connection allows direct egress. */ -export function hasBlockingProxyAssignment(connectionId: string): boolean { +export function hasBlockingProxyAssignment(connectionId: string, providerId?: string): boolean { try { const db = getDbInstance(); if (!isGlobalProxyEnabled(db)) return false; @@ -32,7 +32,7 @@ export function hasBlockingProxyAssignment(connectionId: string): boolean { .prepare("SELECT provider, proxy_enabled FROM provider_connections WHERE id = ?") .get(connectionId) as { provider?: string | null; proxy_enabled?: number } | undefined; if (conn && conn.proxy_enabled === 0) return false; - const provider = conn?.provider ?? null; + const provider = conn?.provider ?? providerId ?? null; const dead = db .prepare( `SELECT 1 FROM proxy_assignments a JOIN proxy_registry p ON p.id = a.proxy_id diff --git a/src/lib/db/settings.ts b/src/lib/db/settings.ts index a8a3d8dfe91d..75827333bc88 100644 --- a/src/lib/db/settings.ts +++ b/src/lib/db/settings.ts @@ -411,8 +411,16 @@ export async function deleteProxyForLevel(level: string, id: string | null) { return setProxyForLevel(level, id, null); } -export async function resolveProxyForConnection(connectionId: string, apiKeyId?: string) { - const cacheKey = apiKeyId ? `${connectionId}:${apiKeyId}` : connectionId; +export async function resolveProxyForConnection( + connectionId: string, + apiKeyId?: string, + providerId?: string +) { + const cacheKey = providerId + ? `${connectionId}:${apiKeyId || ""}:${providerId}` + : apiKeyId + ? `${connectionId}:${apiKeyId}` + : connectionId; const startGeneration = proxyConfigGeneration; const startRegistryGeneration = getProxyRegistryGeneration(); const cached = proxyResolutionCache.get(cacheKey); @@ -633,7 +641,7 @@ export async function resolveProxyForConnection(connectionId: string, apiKeyId?: // them — a provider-level proxy assigned to a no-auth provider was silently // ignored. Best-effort fallback: scan the known no-auth provider ids directly. if (!connectionRecord) { - const noAuthFallback = await resolveNoAuthSharedProviderProxy(config.providers); + const noAuthFallback = await resolveNoAuthSharedProviderProxy(config.providers, providerId); if (noAuthFallback) { cacheProxyResolution(cacheKey, startGeneration, startRegistryGeneration, noAuthFallback); return noAuthFallback; diff --git a/src/lib/db/settings/noAuthProxyFallback.ts b/src/lib/db/settings/noAuthProxyFallback.ts index 14fcabd1ec15..c682f292d308 100644 --- a/src/lib/db/settings/noAuthProxyFallback.ts +++ b/src/lib/db/settings/noAuthProxyFallback.ts @@ -55,8 +55,10 @@ async function resolveOneNoAuthProviderProxy( } export async function resolveNoAuthSharedProviderProxy( - legacyProviders: LegacyProviderProxyMap + legacyProviders: LegacyProviderProxyMap, + providerId?: string ): Promise { + if (providerId) return resolveOneNoAuthProviderProxy(providerId, legacyProviders); for (const providerId of Object.keys(NOAUTH_PROVIDERS)) { const resolved = await resolveOneNoAuthProviderProxy(providerId, legacyProviders); if (resolved) return resolved; diff --git a/src/mitm/dns/dnsConfig.ts b/src/mitm/dns/dnsConfig.ts index 6b6f78a52387..7d11c1e05f8b 100644 --- a/src/mitm/dns/dnsConfig.ts +++ b/src/mitm/dns/dnsConfig.ts @@ -18,7 +18,7 @@ const ANTIGRAVITY_HOSTS = [ "autopush-cloudcode-pa.sandbox.googleapis.com", ]; -function resolveHostsForAgent(agentId?: string): string[] { +export function resolveHostsForAgent(agentId?: string): string[] { if (!agentId) return ANTIGRAVITY_HOSTS; const target = ALL_TARGETS.find((t) => t.id === agentId); return target?.hosts ?? ANTIGRAVITY_HOSTS; diff --git a/src/shared/components/NoAuthAccountCard.tsx b/src/shared/components/NoAuthAccountCard.tsx index d4e182c5c460..f721fde5d792 100644 --- a/src/shared/components/NoAuthAccountCard.tsx +++ b/src/shared/components/NoAuthAccountCard.tsx @@ -1,6 +1,6 @@ "use client"; -import { useState, useEffect, useCallback, useRef } from "react"; +import { useState, useEffect, useCallback, useRef, type ReactNode } from "react"; import Card from "./Card"; import Button from "./Button"; import DistributeProxiesButton from "./DistributeProxiesButton"; @@ -16,6 +16,7 @@ interface NoAuthAccountCardProps { enabled?: boolean; savingEnabled?: boolean; onEnabledChange?: (enabled: boolean) => void; + providerProxyControl?: ReactNode; } interface Connection { @@ -94,6 +95,7 @@ export default function NoAuthAccountCard({ enabled = true, savingEnabled = false, onEnabledChange, + providerProxyControl, }: NoAuthAccountCardProps) { const [connections, setConnections] = useState([]); const [loading, setLoading] = useState(true); @@ -331,12 +333,15 @@ export default function NoAuthAccountCard({

{description}

- +
+ {providerProxyControl} + +
@@ -370,7 +375,10 @@ export default function NoAuthAccountCard({ className="grid max-h-72 grid-cols-1 gap-1.5 overflow-y-auto pr-1 sm:grid-cols-2 lg:grid-cols-3" > {allAccountIds.map((id, i) => { - const proxy = getDisplayProxy(getEntryForFingerprint(accountProxies, id), savedProxies); + const proxy = getDisplayProxy( + getEntryForFingerprint(accountProxies, id), + savedProxies + ); return (
void; + providerProxyControl?: ReactNode; } export default function NoAuthProviderCard({ enabled = true, saving = false, onEnabledChange, + providerProxyControl, }: NoAuthProviderCardProps) { return ( @@ -28,12 +31,15 @@ export default function NoAuthProviderCard({

- +
+ {providerProxyControl} + +
); diff --git a/src/shared/constants/providers.ts b/src/shared/constants/providers.ts index 93c7cc4ef8db..f522a64b7053 100644 --- a/src/shared/constants/providers.ts +++ b/src/shared/constants/providers.ts @@ -11,6 +11,7 @@ export interface ProviderRiskNoticeFields { } import { NOAUTH_PROVIDERS } from "./providers/noauth"; +export { supportsNoAuthProviderProxy } from "./providers/noauth"; import { OAUTH_PROVIDERS } from "./providers/oauth"; import { WEB_COOKIE_PROVIDERS, resolveWebProviderHost } from "./providers/web-cookie"; export { resolveWebProviderHost }; diff --git a/src/shared/constants/providers/noauth.ts b/src/shared/constants/providers/noauth.ts index 864ee048f1af..e959971eaa1c 100644 --- a/src/shared/constants/providers/noauth.ts +++ b/src/shared/constants/providers/noauth.ts @@ -138,3 +138,13 @@ export const NOAUTH_PROVIDERS = { }, }, }; + +// Provider-level proxy controls are exposed only for transports whose complete +// upstream path runs through OmniRoute's proxy-aware global fetch. Providers +// with browser, WebSocket, direct dispatcher, media, or local CLI paths stay +// hidden until those paths can guarantee the configured provider proxy. +export const NOAUTH_PROVIDER_PROXY_SUPPORTED = new Set(["opencode", "theoldllm"]); + +export function supportsNoAuthProviderProxy(providerId: string): boolean { + return NOAUTH_PROVIDER_PROXY_SUPPORTED.has(providerId); +} diff --git a/src/sse/handlers/chat.ts b/src/sse/handlers/chat.ts index 3f6396815925..499f2b01dbe6 100644 --- a/src/sse/handlers/chat.ts +++ b/src/sse/handlers/chat.ts @@ -1373,7 +1373,7 @@ async function handleSingleModelChat( refreshedCredentials ); } - const proxyInfo = await safeResolveProxy(credentials.connectionId, apiKeyInfo?.id); + const proxyInfo = await safeResolveProxy(credentials.connectionId, apiKeyInfo?.id, provider); // #5217: sink for the proxy the executor pins internally (e.g. OpencodeExecutor // rotation) so the egress log below reflects the real egress, not "direct". const appliedProxySink: { proxy: unknown } = { proxy: null }; diff --git a/src/sse/handlers/chatHelpers.ts b/src/sse/handlers/chatHelpers.ts index 603ac78cd6d3..5cd5b90b95fb 100644 --- a/src/sse/handlers/chatHelpers.ts +++ b/src/sse/handlers/chatHelpers.ts @@ -587,12 +587,9 @@ export function handleNoCredentials( return modelCooldownResponse({ model: cooldownModel, retryAfter: credentials.retryAfter, - retryAfterAt: - typeof credentials.retryAfter === "string" ? credentials.retryAfter : null, + retryAfterAt: typeof credentials.retryAfter === "string" ? credentials.retryAfter : null, credentialsCoolingCount: - typeof credentials.connectionsCount === "number" - ? credentials.connectionsCount - : null, + typeof credentials.connectionsCount === "number" ? credentials.connectionsCount : null, }); } @@ -680,11 +677,6 @@ export function shouldRetryStreamEarlyEof( return errorCode === "STREAM_EARLY_EOF" && attempt < STREAM_EARLY_EOF_MAX_RETRIES; } -/** - * Proxy-resolution failure policy. Default: fail-closed (rethrow) so a request - * with an assigned-but-unresolvable proxy never silently egresses on the real IP. - * Opt back into the legacy DIRECT fallback with PROXY_FAIL_OPEN=true. - */ export function decideProxyResolutionFailure( err: unknown, env: { PROXY_FAIL_OPEN?: string } = process.env @@ -701,14 +693,21 @@ export function decideProxyResolutionFailure( throw err instanceof Error ? err : new Error(String(err)); } -export async function safeResolveProxy(connectionId: string, apiKeyId?: string) { +export async function safeResolveProxy( + connectionId: string, + apiKeyId?: string, + providerId?: string +) { try { - const resolved = await resolveProxyForConnection(connectionId, apiKeyId); + const resolved = await resolveProxyForConnection(connectionId, apiKeyId, providerId); // #6246: a connection that resolves to DIRECT only because its assigned proxy // is dead/inactive must fail closed — egressing on the real IP leaks it. Reuse // the existing proxy-resolution-failure policy (blocks by default; PROXY_FAIL_OPEN // opts back into direct). Explicit "proxy off" is not a leak (see the guard). - if (!(resolved as { proxy?: unknown } | null)?.proxy && hasBlockingProxyAssignment(connectionId)) { + if ( + !(resolved as { proxy?: unknown } | null)?.proxy && + hasBlockingProxyAssignment(connectionId, providerId) + ) { return decideProxyResolutionFailure( Object.assign( new Error( diff --git a/tests/unit/dns-config-generic.test.ts b/tests/unit/dns-config-generic.test.ts index 2f77cd671d12..65fc978cfaa5 100644 --- a/tests/unit/dns-config-generic.test.ts +++ b/tests/unit/dns-config-generic.test.ts @@ -68,7 +68,14 @@ const tmpHostsFile = path.join(tmpDir, "hosts"); // Import the module under test AFTER all setup. const dnsModule = await import("../../src/mitm/dns/dnsConfig.ts"); -const { addDNSEntries, removeDNSEntries, addDNSEntry, removeDNSEntry, checkDNSEntry } = dnsModule; +const { + addDNSEntries, + removeDNSEntries, + addDNSEntry, + removeDNSEntry, + checkDNSEntry, + resolveHostsForAgent, +} = dnsModule; const { ALL_TARGETS } = await import("../../src/mitm/targets/index.ts"); // --------------------------------------------------------------------------- @@ -98,25 +105,32 @@ test("addDNSEntry (legacy) is a function that delegates for Antigravity hosts", test("addDNSEntry with agentId resolves agent-specific hosts from ALL_TARGETS", async () => { // Cursor target has hosts: ["api2.cursor.sh"] - // Verify that calling addDNSEntry with agentId="cursor" passes the right hosts. - // We call with [] to skip actual exec — just verifying the function signature accepts agentId. - await assert.doesNotReject( - addDNSEntry("fake-sudo", "cursor"), - "addDNSEntry must accept optional agentId parameter" + // Verify host selection without invoking the privileged /etc/hosts writer. + assert.deepEqual( + resolveHostsForAgent("cursor"), + ["api2.cursor.sh"], + "addDNSEntry must resolve hosts for the optional agentId" ); }); test("addDNSEntry without agentId falls back to Antigravity hosts (backward compat)", async () => { - await assert.doesNotReject( - addDNSEntry("fake-sudo"), - "addDNSEntry without agentId must still work for backward compat" + assert.deepEqual( + resolveHostsForAgent(), + [ + "daily-cloudcode-pa.googleapis.com", + "cloudcode-pa.googleapis.com", + "daily-cloudcode-pa.sandbox.googleapis.com", + "autopush-cloudcode-pa.sandbox.googleapis.com", + ], + "addDNSEntry without agentId must preserve backward-compatible hosts" ); }); test("addDNSEntry with unknown agentId falls back to Antigravity hosts", async () => { - await assert.doesNotReject( - addDNSEntry("fake-sudo", "__nonexistent_agent__"), - "addDNSEntry with unknown agentId must fall back to Antigravity hosts" + assert.deepEqual( + resolveHostsForAgent("__nonexistent_agent__"), + resolveHostsForAgent(), + "unknown agentId must fall back to Antigravity hosts" ); }); @@ -217,7 +231,9 @@ test("addDNSEntries: entry passed as stdin data, not shell-interpolated", () => "entry content must be built from missingEntries for stdin, not interpolated in args" ); assert.ok( - src.includes('execFileWithPassword("sudo", ["-S", "tee", "-a", HOSTS_FILE], sudoPassword, data)'), + src.includes( + 'execFileWithPassword("sudo", ["-S", "tee", "-a", HOSTS_FILE], sudoPassword, data)' + ), "entry data must be passed as stdin to tee, not interpolated in args" ); }); diff --git a/tests/unit/noauth-provider-validation.test.ts b/tests/unit/noauth-provider-validation.test.ts index fe28289d3088..0e05d76fc328 100644 --- a/tests/unit/noauth-provider-validation.test.ts +++ b/tests/unit/noauth-provider-validation.test.ts @@ -6,11 +6,22 @@ import test from "node:test"; import assert from "node:assert/strict"; -import { providerAllowsOptionalApiKey } from "../../src/shared/constants/providers.ts"; +import { + NOAUTH_PROVIDERS, + providerAllowsOptionalApiKey, + supportsNoAuthProviderProxy, +} from "../../src/shared/constants/providers.ts"; import { hasSpecializedExecutor } from "../../open-sse/executors/index.ts"; // Bug 1: all noAuth providers should allow optional API key -for (const provider of ["theoldllm", "chipotle", "mimocode", "opencode", "duckduckgo-web", "veoaifree-web"]) { +for (const provider of [ + "theoldllm", + "chipotle", + "mimocode", + "opencode", + "duckduckgo-web", + "veoaifree-web", +]) { test(`${provider} allows optional API key (noAuth provider)`, () => { assert.equal(providerAllowsOptionalApiKey(provider), true); }); @@ -29,3 +40,14 @@ test("kimi-web still has specialized executor", () => { test("kimi-coding-apikey still has specialized executor", () => { assert.equal(hasSpecializedExecutor("kimi-coding-apikey"), true); }); + +test("provider proxy controls use a centralized no-auth capability allowlist", () => { + assert.equal(supportsNoAuthProviderProxy("opencode"), true); + assert.equal(supportsNoAuthProviderProxy("theoldllm"), true); + + for (const providerId of Object.keys(NOAUTH_PROVIDERS)) { + if (providerId !== "opencode" && providerId !== "theoldllm") { + assert.equal(supportsNoAuthProviderProxy(providerId), false, providerId); + } + } +}); diff --git a/tests/unit/proxy-assigned-unavailable-6246.test.ts b/tests/unit/proxy-assigned-unavailable-6246.test.ts index 8aa52f319261..a3ca79e3e4e0 100644 --- a/tests/unit/proxy-assigned-unavailable-6246.test.ts +++ b/tests/unit/proxy-assigned-unavailable-6246.test.ts @@ -139,3 +139,21 @@ test("BLOCKS: a dead GLOBAL proxy assignment blocks any connection", async () => "a dead global proxy assignment must block, not leak direct" ); }); + +test("BLOCKS: a dead no-auth provider proxy assignment", async () => { + await resetStorage(); + const proxy = await proxiesDb.createProxy({ + name: "Dead no-auth proxy", + type: "http", + host: "127.0.0.1", + port: 9005, + }); + await proxiesDb.updateProxy(proxy!.id, { status: "inactive" }); + await proxiesDb.assignProxyToScope("provider", "mimocode", proxy!.id); + + assert.equal( + proxiesDb.hasBlockingProxyAssignment("noauth", "mimocode"), + true, + "a dead no-auth provider proxy must block instead of allowing direct egress" + ); +}); diff --git a/tests/unit/proxy-noauth-provider-6272.test.ts b/tests/unit/proxy-noauth-provider-6272.test.ts index 9df7217a44b1..314928443f42 100644 --- a/tests/unit/proxy-noauth-provider-6272.test.ts +++ b/tests/unit/proxy-noauth-provider-6272.test.ts @@ -11,6 +11,7 @@ delete process.env.INITIAL_PASSWORD; const core = await import("../../src/lib/db/core.ts"); const settingsDb = await import("../../src/lib/db/settings.ts"); +const { safeResolveProxy } = await import("../../src/sse/handlers/chatHelpers.ts"); test.after(async () => { core.resetDbInstance(); @@ -49,3 +50,44 @@ test("control: resolveProxyForConnection('noauth', ...) still honors the GLOBAL assert.equal(resolved?.proxy?.host, "10.0.0.1"); assert.equal(resolved?.level, "global"); }); + +test("resolveProxyForConnection keeps provider-level no-auth proxies isolated", async () => { + core.getDbInstance(); + await settingsDb.deleteProxyForLevel("global", null); + await settingsDb.setProxyForLevel("provider", "mimocode", { + type: "http", + host: "127.0.0.2", + port: 8889, + }); + await settingsDb.setProxyForLevel("provider", "theoldllm", { + type: "http", + host: "127.0.0.3", + port: 8890, + }); + + const mimocode = await settingsDb.resolveProxyForConnection("noauth", undefined, "mimocode"); + const theOldLlm = await settingsDb.resolveProxyForConnection("noauth", undefined, "theoldllm"); + + assert.equal(mimocode?.proxy?.host, "127.0.0.2"); + assert.equal(theOldLlm?.proxy?.host, "127.0.0.3"); +}); + +test("safeResolveProxy keeps the synthetic no-auth connection provider-specific", async () => { + core.getDbInstance(); + await settingsDb.setProxyForLevel("provider", "mimocode", { + type: "http", + host: "127.0.0.4", + port: 8891, + }); + await settingsDb.setProxyForLevel("provider", "theoldllm", { + type: "http", + host: "127.0.0.5", + port: 8892, + }); + + const mimocode = await safeResolveProxy("noauth", undefined, "mimocode"); + const theOldLlm = await safeResolveProxy("noauth", undefined, "theoldllm"); + + assert.equal(mimocode?.proxy?.host, "127.0.0.4"); + assert.equal(theOldLlm?.proxy?.host, "127.0.0.5"); +}); diff --git a/tests/unit/ui/noauth-account-card.test.tsx b/tests/unit/ui/noauth-account-card.test.tsx index 832ecd88cab1..7e9adcb8a868 100644 --- a/tests/unit/ui/noauth-account-card.test.tsx +++ b/tests/unit/ui/noauth-account-card.test.tsx @@ -5,9 +5,8 @@ import { describe, it, expect, vi, beforeEach, afterEach } from "vitest"; // ── Import component (no module-level mocks needed) ────────────────────────── -const { default: NoAuthAccountCard } = await import( - "../../../src/shared/components/NoAuthAccountCard" -); +const { default: NoAuthAccountCard } = + await import("../../../src/shared/components/NoAuthAccountCard"); // ── Helpers ──────────────────────────────────────────────────────────────────