From 5759491ca04c95f822b6c338e797ec8b16914bcb Mon Sep 17 00:00:00 2001 From: Dax Raad Date: Fri, 30 Oct 2026 11:24:33 -0400 Subject: [PATCH] fix(core): allow local config to override Console-supplied providers Reverts the lock from #60315 that ignored user, project and remote overrides on providers the Console supplies. It also blocked harmless overrides such as model limits, names and variants (#60597) and internal gateways. --- packages/core/src/config/plugin/provider.ts | 14 +------ .../test/plugin/provider-opencode.test.ts | 39 +++++++------------ services/www/src/docs/content/policies.mdx | 5 --- 3 files changed, 15 insertions(+), 43 deletions(-) diff --git a/packages/core/src/config/plugin/provider.ts b/packages/core/src/config/plugin/provider.ts index 327bf9e7354..e6c68668b15 100644 --- a/packages/core/src/config/plugin/provider.ts +++ b/packages/core/src/config/plugin/provider.ts @@ -12,7 +12,6 @@ import { Model } from "../../model.js" import { Provider } from "../../provider.js" import { Variant } from "../../variant.js" import { ConfigIntegration } from "../integration.js" -import { ConfigManaged } from "../managed.js" import { ConfigEntryObserver } from "./entry-observer.js" export const Plugin = define({ @@ -144,21 +143,10 @@ export const Plugin = define({ // Integration documents are left out: their providers authenticate with the integration's connection, so they add no // integration or method, and the integration's own plugin applies them earlier in the provider chain (`integrate`). -// A provider the Console supplies is shaped only by the Console and managed configuration: user, project, and remote -// documents cannot override any part of it, since it carries the org's token and a repository must not redirect it. function configuredProviders(entries: readonly Entry[]) { - const supplied = new Set( - entries - .filter((entry): entry is ConfigIntegration.Document => entry instanceof ConfigIntegration.Document) - .flatMap((document) => Object.keys(document.info.providers ?? {})), - ) return entries .filter((entry): entry is Document => entry.type === "document" && !(entry instanceof ConfigIntegration.Document)) - .flatMap((file) => - Object.entries(file.info.providers ?? {}).filter( - ([id]) => !supplied.has(id) || file instanceof ConfigManaged.Document, - ), - ) + .flatMap((file) => Object.entries(file.info.providers ?? {})) } /** diff --git a/packages/core/test/plugin/provider-opencode.test.ts b/packages/core/test/plugin/provider-opencode.test.ts index aba83b8b02a..866912a0df9 100644 --- a/packages/core/test/plugin/provider-opencode.test.ts +++ b/packages/core/test/plugin/provider-opencode.test.ts @@ -13,7 +13,6 @@ import { Bus } from "@opencode/core/bus" import { Config } from "@opencode/core/config" import { ConfigIntegration } from "@opencode/core/config/integration" import { ConfigPolicyPlugin } from "@opencode/core/config/plugin/policy" -import { ConfigManaged } from "@opencode/core/config/managed" import { ConfigProviderPlugin } from "@opencode/core/config/plugin/provider" import { ConfigWebSearchPlugin } from "@opencode/core/config/plugin/websearch" import { Credential } from "@opencode/core/credential" @@ -1901,7 +1900,7 @@ describe("OpencodePlugin with a Console config", () => { ), ) - it.live("keeps Console providers out of user and project config's reach, bound to the Console connection", () => + it.live("layers Console providers below user config, bound to the Console connection", () => Effect.acquireUseRelease( Effect.sync(() => Bun.serve({ @@ -1930,23 +1929,17 @@ describe("OpencodePlugin with a Console config", () => { const providers = yield* Provider.Service const models = yield* Model.Service const config = yield* Config.Test - const overlay = { - name: "Mine", - settings: { apiKey: "my-key", baseURL: "https://mine.example/v1" }, - headers: { "x-org-id": "mine" }, - models: { chat: { name: "My Chat" }, mine: { name: "My Model" } }, - } yield* config.setEntries([ - new ConfigManaged.Document({ - type: "document", - info: Schema.decodeUnknownSync(Info)({ providers: { remote: { headers: { "x-managed": "true" } } } }), - }), new Document({ type: "document", info: Schema.decodeUnknownSync(Info)({ providers: { - remote: overlay, - normal: { ...overlay, package: "aisdk:@ai-sdk/openai-compatible" }, + remote: { + name: "Mine", + settings: { apiKey: "my-key" }, + headers: { "x-org-id": "mine" }, + models: { chat: { name: "My Chat" } }, + }, }, }), }), @@ -1959,26 +1952,22 @@ describe("OpencodePlugin with a Console config", () => { yield* OpencodePlugin.effect(host) yield* ConfigProviderPlugin.Plugin.effect(host) - // Managed configuration may still shape a Console provider; a project or user file cannot. const provider = required(yield* providers.get(Provider.ID.make("remote"))) - expect(provider.name).toBe("Console") + expect(provider.name).toBe("Mine") expect(provider.integrationID).toBe(Integration.ID.make("opencode")) - expect(provider.headers).toEqual({ "x-org-id": "console", "x-console": "true", "x-managed": "true" }) + expect(provider.headers).toEqual({ "x-org-id": "mine", "x-console": "true" }) expect(provider.settings).toEqual({ baseURL: `${server.url.origin}/v1`, custom: "console", + apiKey: "my-key", provider: "remote", }) const chat = required(yield* models.get(Provider.ID.make("remote"), Model.ID.make("chat"))) - expect(chat.name).toBe("Console Chat") + expect(chat.name).toBe("My Chat") expect(chat.settings).toMatchObject({ temperature: 0.1 }) - expect(yield* models.get(Provider.ID.make("remote"), Model.ID.make("mine"))).toBeUndefined() - - // Providers the Console does not supply stay overridable. - const normal = required(yield* providers.get(Provider.ID.make("normal"))) - expect(normal.headers).toEqual({ "x-org-id": "mine" }) - expect(normal.settings).toMatchObject({ baseURL: "https://mine.example/v1", apiKey: "my-key" }) - expect(required(yield* models.get(Provider.ID.make("normal"), Model.ID.make("chat"))).name).toBe("My Chat") + expect(required(yield* models.get(Provider.ID.make("remote"), Model.ID.make("other"))).name).toBe( + "Console Other", + ) }), (server) => Effect.promise(() => server.stop(true)), ), diff --git a/services/www/src/docs/content/policies.mdx b/services/www/src/docs/content/policies.mdx index 21d4bff8776..d1998fe5129 100644 --- a/services/www/src/docs/content/policies.mdx +++ b/services/www/src/docs/content/policies.mdx @@ -192,11 +192,6 @@ web search work, and changing them in the Console needs no new MDM profile. Only managed policies can withhold the MCP servers and config an integration delivers; its own policies keep applying either way. -A provider the connected Console workspace supplies can't be changed by user, -project, or remote configuration: its settings, headers, models, and package come -only from the Console and managed configuration. Other providers stay configurable -as usual. - ## MCP servers, skills, and plugins | Action | Resource |