Skip to content

Commit 5759491

Browse files
committed
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.
1 parent 78dda62 commit 5759491

3 files changed

Lines changed: 15 additions & 43 deletions

File tree

‎packages/core/src/config/plugin/provider.ts‎

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import { Model } from "../../model.js"
1212
import { Provider } from "../../provider.js"
1313
import { Variant } from "../../variant.js"
1414
import { ConfigIntegration } from "../integration.js"
15-
import { ConfigManaged } from "../managed.js"
1615
import { ConfigEntryObserver } from "./entry-observer.js"
1716

1817
export const Plugin = define({
@@ -144,21 +143,10 @@ export const Plugin = define({
144143

145144
// Integration documents are left out: their providers authenticate with the integration's connection, so they add no
146145
// integration or method, and the integration's own plugin applies them earlier in the provider chain (`integrate`).
147-
// A provider the Console supplies is shaped only by the Console and managed configuration: user, project, and remote
148-
// documents cannot override any part of it, since it carries the org's token and a repository must not redirect it.
149146
function configuredProviders(entries: readonly Entry[]) {
150-
const supplied = new Set(
151-
entries
152-
.filter((entry): entry is ConfigIntegration.Document => entry instanceof ConfigIntegration.Document)
153-
.flatMap((document) => Object.keys(document.info.providers ?? {})),
154-
)
155147
return entries
156148
.filter((entry): entry is Document => entry.type === "document" && !(entry instanceof ConfigIntegration.Document))
157-
.flatMap((file) =>
158-
Object.entries(file.info.providers ?? {}).filter(
159-
([id]) => !supplied.has(id) || file instanceof ConfigManaged.Document,
160-
),
161-
)
149+
.flatMap((file) => Object.entries(file.info.providers ?? {}))
162150
}
163151

164152
/**

‎packages/core/test/plugin/provider-opencode.test.ts‎

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import { Bus } from "@opencode/core/bus"
1313
import { Config } from "@opencode/core/config"
1414
import { ConfigIntegration } from "@opencode/core/config/integration"
1515
import { ConfigPolicyPlugin } from "@opencode/core/config/plugin/policy"
16-
import { ConfigManaged } from "@opencode/core/config/managed"
1716
import { ConfigProviderPlugin } from "@opencode/core/config/plugin/provider"
1817
import { ConfigWebSearchPlugin } from "@opencode/core/config/plugin/websearch"
1918
import { Credential } from "@opencode/core/credential"
@@ -1901,7 +1900,7 @@ describe("OpencodePlugin with a Console config", () => {
19011900
),
19021901
)
19031902

1904-
it.live("keeps Console providers out of user and project config's reach, bound to the Console connection", () =>
1903+
it.live("layers Console providers below user config, bound to the Console connection", () =>
19051904
Effect.acquireUseRelease(
19061905
Effect.sync(() =>
19071906
Bun.serve({
@@ -1930,23 +1929,17 @@ describe("OpencodePlugin with a Console config", () => {
19301929
const providers = yield* Provider.Service
19311930
const models = yield* Model.Service
19321931
const config = yield* Config.Test
1933-
const overlay = {
1934-
name: "Mine",
1935-
settings: { apiKey: "my-key", baseURL: "https://mine.example/v1" },
1936-
headers: { "x-org-id": "mine" },
1937-
models: { chat: { name: "My Chat" }, mine: { name: "My Model" } },
1938-
}
19391932
yield* config.setEntries([
1940-
new ConfigManaged.Document({
1941-
type: "document",
1942-
info: Schema.decodeUnknownSync(Info)({ providers: { remote: { headers: { "x-managed": "true" } } } }),
1943-
}),
19441933
new Document({
19451934
type: "document",
19461935
info: Schema.decodeUnknownSync(Info)({
19471936
providers: {
1948-
remote: overlay,
1949-
normal: { ...overlay, package: "aisdk:@ai-sdk/openai-compatible" },
1937+
remote: {
1938+
name: "Mine",
1939+
settings: { apiKey: "my-key" },
1940+
headers: { "x-org-id": "mine" },
1941+
models: { chat: { name: "My Chat" } },
1942+
},
19501943
},
19511944
}),
19521945
}),
@@ -1959,26 +1952,22 @@ describe("OpencodePlugin with a Console config", () => {
19591952
yield* OpencodePlugin.effect(host)
19601953
yield* ConfigProviderPlugin.Plugin.effect(host)
19611954

1962-
// Managed configuration may still shape a Console provider; a project or user file cannot.
19631955
const provider = required(yield* providers.get(Provider.ID.make("remote")))
1964-
expect(provider.name).toBe("Console")
1956+
expect(provider.name).toBe("Mine")
19651957
expect(provider.integrationID).toBe(Integration.ID.make("opencode"))
1966-
expect(provider.headers).toEqual({ "x-org-id": "console", "x-console": "true", "x-managed": "true" })
1958+
expect(provider.headers).toEqual({ "x-org-id": "mine", "x-console": "true" })
19671959
expect(provider.settings).toEqual({
19681960
baseURL: `${server.url.origin}/v1`,
19691961
custom: "console",
1962+
apiKey: "my-key",
19701963
provider: "remote",
19711964
})
19721965
const chat = required(yield* models.get(Provider.ID.make("remote"), Model.ID.make("chat")))
1973-
expect(chat.name).toBe("Console Chat")
1966+
expect(chat.name).toBe("My Chat")
19741967
expect(chat.settings).toMatchObject({ temperature: 0.1 })
1975-
expect(yield* models.get(Provider.ID.make("remote"), Model.ID.make("mine"))).toBeUndefined()
1976-
1977-
// Providers the Console does not supply stay overridable.
1978-
const normal = required(yield* providers.get(Provider.ID.make("normal")))
1979-
expect(normal.headers).toEqual({ "x-org-id": "mine" })
1980-
expect(normal.settings).toMatchObject({ baseURL: "https://mine.example/v1", apiKey: "my-key" })
1981-
expect(required(yield* models.get(Provider.ID.make("normal"), Model.ID.make("chat"))).name).toBe("My Chat")
1968+
expect(required(yield* models.get(Provider.ID.make("remote"), Model.ID.make("other"))).name).toBe(
1969+
"Console Other",
1970+
)
19821971
}),
19831972
(server) => Effect.promise(() => server.stop(true)),
19841973
),

‎services/www/src/docs/content/policies.mdx‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -192,11 +192,6 @@ web search work, and changing them in the Console needs no new MDM profile.
192192
Only managed policies can withhold the MCP servers and config an integration
193193
delivers; its own policies keep applying either way.
194194

195-
A provider the connected Console workspace supplies can't be changed by user,
196-
project, or remote configuration: its settings, headers, models, and package come
197-
only from the Console and managed configuration. Other providers stay configurable
198-
as usual.
199-
200195
## MCP servers, skills, and plugins
201196

202197
| Action | Resource |

0 commit comments

Comments
 (0)