diff --git a/packages/coding-agent/CHANGELOG.md b/packages/coding-agent/CHANGELOG.md index a6295f0e8..71263db99 100644 --- a/packages/coding-agent/CHANGELOG.md +++ b/packages/coding-agent/CHANGELOG.md @@ -6,6 +6,10 @@ - Changed the default OpenAI Codex model to GPT-6.1 Sol (`gpt-6.1-sol`). +### Fixed + +- Fixed `/login` with OpenAI failing in the bundled release with a missing `openai-chatgpt.js` module error. + ## [0.99.0] - 2026-09-29 ### New Features diff --git a/scripts/build-coding-agent-bundle.mjs b/scripts/build-coding-agent-bundle.mjs index 01f12b242..745bdab15 100644 --- a/scripts/build-coding-agent-bundle.mjs +++ b/scripts/build-coding-agent-bundle.mjs @@ -1,6 +1,6 @@ #!/usr/bin/env node -import { chmodSync, existsSync, mkdirSync, rmSync, writeFileSync } from "node:fs"; +import { chmodSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs"; import { isBuiltin } from "node:module"; import { dirname, join, relative, resolve } from "node:path"; import { fileURLToPath } from "node:url"; @@ -183,22 +183,34 @@ if (dirname(bedrockLoaderOutput) !== dirname(oauthLoaderOutput)) { // These implementations are reached through variable-specifier imports or a // worker URL, so the main bundle cannot follow them. Emit one self-contained // file per implementation beside the code that resolves it. +const lazyEntryPoints = { + anthropic: join(aiDistDir, "auth", "oauth", "anthropic.js"), + "bedrock-converse-stream": join(aiDistDir, "api", "bedrock-converse-stream.js"), + "codemode-worker": join(codingAgentDistDir, "extensions", "codemode", "worker.js"), + "github-copilot": join(aiDistDir, "auth", "oauth", "github-copilot.js"), + "image-resize-worker": join(codingAgentDistDir, "utils", "image-resize-worker.js"), + "kimi-coding": join(aiDistDir, "auth", "oauth", "kimi-coding.js"), + meta: join(aiDistDir, "auth", "oauth", "meta.js"), + "openai-chatgpt": join(aiDistDir, "auth", "oauth", "openai-chatgpt.js"), + "openai-codex": join(aiDistDir, "auth", "oauth", "openai-codex.js"), + openrouter: join(aiDistDir, "auth", "oauth", "openrouter.js"), + radius: join(aiDistDir, "auth", "oauth", "radius.js"), + xai: join(aiDistDir, "auth", "oauth", "xai.js"), +}; + +// Every OAuth flow loaded through importOAuthModule() must have a lazy entry, +// otherwise the flow fails at runtime with a missing module error. +const oauthLoadSource = readFileSync(join(repoRoot, "packages", "ai", "src", "auth", "oauth", "load.ts"), "utf8"); +for (const match of oauthLoadSource.matchAll(/importOAuthModule\("\.\/([^"]+)\.ts"\)/g)) { + if (!(match[1] in lazyEntryPoints)) { + throw new Error(`OAuth flow "${match[1]}" is lazily imported but has no lazy bundle entry`); + } +} + const lazyResult = await build({ ...commonBuildOptions(), entryNames: "[name]", - entryPoints: { - anthropic: join(aiDistDir, "auth", "oauth", "anthropic.js"), - "bedrock-converse-stream": join(aiDistDir, "api", "bedrock-converse-stream.js"), - "codemode-worker": join(codingAgentDistDir, "extensions", "codemode", "worker.js"), - "github-copilot": join(aiDistDir, "auth", "oauth", "github-copilot.js"), - "image-resize-worker": join(codingAgentDistDir, "utils", "image-resize-worker.js"), - "kimi-coding": join(aiDistDir, "auth", "oauth", "kimi-coding.js"), - meta: join(aiDistDir, "auth", "oauth", "meta.js"), - "openai-codex": join(aiDistDir, "auth", "oauth", "openai-codex.js"), - openrouter: join(aiDistDir, "auth", "oauth", "openrouter.js"), - radius: join(aiDistDir, "auth", "oauth", "radius.js"), - xai: join(aiDistDir, "auth", "oauth", "xai.js"), - }, + entryPoints: lazyEntryPoints, outdir: dirname(bedrockLoaderOutput), splitting: false, });