mirror of
https://github.com/badlogic/pi-mono.git
synced 2026-11-05 23:37:25 +00:00
fix(coding-agent): bundle openai-chatgpt OAuth flow
The lazy OAuth entry list in the bundle build was missing openai-chatgpt, so /login with OpenAI failed with a missing module error. Also fail the build if any importOAuthModule() target in load.ts has no lazy entry.
This commit is contained in:
parent
12c416e1a6
commit
72abf01ba9
2 changed files with 30 additions and 14 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue