diff --git a/packages/ai/src/api/bedrock-converse-stream.lazy.ts b/packages/ai/src/api/bedrock-converse-stream.lazy.ts index f9b30b35f..b0530a1fb 100644 --- a/packages/ai/src/api/bedrock-converse-stream.lazy.ts +++ b/packages/ai/src/api/bedrock-converse-stream.lazy.ts @@ -5,11 +5,13 @@ import { lazyApi } from "./lazy.ts"; * Loads the bedrock implementation through a variable specifier so bundlers * (browser smoke, Bun compile) cannot follow the import into the Node-only * AWS SDK. The `.ts`/`.js` rewrite keeps the trick working from both source - * and built output. + * and built output. The specifier is resolved against this module's URL, not + * left relative: a bundler inlining this file (Chord's worker base) keeps the + * variable import, which would otherwise resolve against the bundle's location. */ const importNodeOnlyApi = (specifier: string): Promise => { const runtimeSpecifier = import.meta.url.endsWith(".js") ? specifier.replace(/\.ts$/, ".js") : specifier; - return import(runtimeSpecifier); + return import(new URL(runtimeSpecifier, import.meta.url).href); }; let bedrockModuleOverride: ProviderStreams | undefined; diff --git a/packages/ai/src/auth/oauth/load.ts b/packages/ai/src/auth/oauth/load.ts index 839fe3152..be63e8acf 100644 --- a/packages/ai/src/auth/oauth/load.ts +++ b/packages/ai/src/auth/oauth/load.ts @@ -4,11 +4,14 @@ import type { OAuthAuth } from "../types.ts"; * Loads an OAuth flow module through a variable specifier so bundlers cannot * follow the import into Node-only flow code (`node:http` callback servers, * `node:crypto` PKCE). The `.ts`/`.js` rewrite keeps the trick working from - * both source and built output. + * both source and built output. The specifier is resolved against this + * module's URL, not left relative: a bundler inlining this file (Chord's + * worker base) keeps the variable import, which would otherwise resolve + * against the bundle's location. */ const importOAuthModule = (specifier: string): Promise => { const runtimeSpecifier = import.meta.url.endsWith(".js") ? specifier.replace(/\.ts$/, ".js") : specifier; - return import(runtimeSpecifier); + return import(new URL(runtimeSpecifier, import.meta.url).href); }; type OAuthFlowLoaders = {