refactor(core): keep Codex routing in plugin

This commit is contained in:
Aiden Cline 2026-07-28 04:38:46 +00:00 committed by opencode-agent[bot]
commit aef37e4514
4 changed files with 39 additions and 72 deletions

View file

@ -307,7 +307,7 @@ describe("ModelResolver", () => {
}),
)
it.effect("keeps an explicit endpoint for ChatGPT OAuth credentials", () =>
it.effect("does not reinterpret an explicit endpoint based on the OAuth method", () =>
Effect.gen(function* () {
const resolved = yield* ModelResolver.fromCatalogModel(
model(Provider.aisdk("@ai-sdk/openai"), {
@ -338,7 +338,7 @@ describe("ModelResolver", () => {
endpoint: { baseURL: "https://openai.example/v1" },
})
expect(headers.authorization).toBe("Bearer chatgpt-token")
expect(headers["chatgpt-account-id"]).toBe("acct_123")
expect(headers["chatgpt-account-id"]).toBeUndefined()
}),
)
@ -367,7 +367,7 @@ describe("ModelResolver", () => {
expect(resolved.route.endpoint.baseURL).toBe("https://openai.example/v1")
expect(headers.authorization).toBe("Bearer chatgpt-token")
expect(headers["chatgpt-account-id"]).toBe("acct_123")
expect(headers["chatgpt-account-id"]).toBeUndefined()
}),
)
@ -407,37 +407,6 @@ describe("ModelResolver", () => {
}),
)
it.effect("keeps an explicit endpoint for ChatGPT OAuth credentials without an account id", () =>
Effect.gen(function* () {
const resolved = yield* ModelResolver.fromCatalogModel(
model(Provider.aisdk("@ai-sdk/openai"), {
settings: { baseURL: "https://openai.example/v1" },
headers: {},
body: {},
}),
Credential.OAuth.make({
type: "oauth",
methodID: Integration.MethodID.make("chatgpt-headless"),
access: "chatgpt-token",
refresh: "refresh",
expires: Date.now() + 60_000,
}),
)
const request = LLM.request({ model: resolved, prompt: "Hello" })
const headers = yield* resolved.route.auth.apply({
request,
method: "POST",
url: "https://openai.example/v1/responses",
body: "{}",
headers: Headers.empty,
})
expect(resolved.route.endpoint.baseURL).toBe("https://openai.example/v1")
expect(headers.authorization).toBe("Bearer chatgpt-token")
expect(headers["chatgpt-account-id"]).toBeUndefined()
}),
)
it.effect("keeps non-ChatGPT OAuth credentials on the configured endpoint", () =>
Effect.gen(function* () {
const resolved = yield* ModelResolver.fromCatalogModel(