Fix: Amazon Bedrock provider still ships broken in the release bundle — missing dist/bundle/amazon-bedrock.js chunk (#751) #1763
Replies: 3 comments
|
Hi @badlogic and @kevinjosethomas, Could you please vouch/invite @kaluli123123 to contribute this focused fix, or apply it internally? PR #1874 was automatically closed by the contribution gate because the author was not vouched. The patch addresses the missing |
|
Confirmed on the v0.8.1 release tarball ( One additional data point for the fix: after emitting the missing chunk from the |
|
Hi @badlogic and @kevinjosethomas, Here is a concise contributor profile for @kaluli123123, in case it helps you evaluate a vouch or contributor invitation:
Would you please consider vouching this account or inviting a focused contribution when appropriate? If you prefer another path, I will follow the repository's process. Thank you for maintaining Prime Agent and for considering this request. Best, |
Uh oh!
There was an error while loading. Please reload this page.
Summary
The Amazon Bedrock provider has been broken in every release built from the Node bundle path (
dist/bundle/, the actual npm/Homebrew/binary install path) since the lazy-provider-loading refactor. The originally reported v0.7.0 release tarball shipped withoutdist/bundle/amazon-bedrock.jsat all (#751, one of the "related reports" under the still-open tracker #1379, Complete CI and release compatibility hardening — "verify the emitted provider bundle closure, including Amazon Bedrock"). The exact same gap still reproduces on currentmain(06860844e) — confirmed by actually running the build and inspecting the output, not just reading source.Root cause
packages/ai/src/providers/register-builtins.tsreaches Bedrock through a specifier built at runtime, not a string literal:Git history (
668ebc094) shows this is deliberate: the specifier is built at runtime (there was even anew Function("specifier", "return import(specifier)")at one point, and a"./amazon-" + "bedrock.js"string split later) specifically so bundlers never eagerly pull@aws-sdkinto every build for consumers who never use Bedrock. Every other provider uses a plainimport("./provider.js")literal, which esbuild's code splitting can see, split into its own chunk, and rewrite the call site to reference (that's whyanthropic-<hash>.js,google-vertex-<hash>.js, etc. all exist and work). Because Bedrock's import is opaque to static analysis, esbuild never bundles the module or its@aws-sdkclosure and never emitsdist/bundle/amazon-bedrock.js— but the compiled call site still requests exactly that relative path at runtime. First use throwsCannot find moduleinstead of a credentials/config error.Why the Bun path already works
packages/coding-agent/src/bun/register-bedrock.tssidesteps this entirely by eagerly, statically importing@earendil-works/pi-ai/bedrock-providerand registering it viasetBedrockProviderModule()before startup — fine there because a compiled Bun binary already embeds everything regardless. Doing the same unconditionally for the Node CLI would regress the startup-latency win lazy provider loading was built for (fixes #2297), so the fix keeps loading lazy for Node and instead makes esbuild aware of the module.Fix
In
packages/coding-agent/scripts/bundle.mjs, declare@earendil-works/pi-ai/bedrock-provider(the same static entry point the Bun path already registers) as a second esbuild entry point, resolved viaimport.meta.resolveand named to the exact literal filename (amazon-bedrock.js, no content hash via esbuild's{in, out}entry point form) the runtime specifier expects:esbuild now compiles and bundles the module and its
@aws-sdkdependency closure into that file (~1.3 MB, in line with other bundled providers, e.g.mistral-*.jsat ~1.1 MB). Loading stays lazy at runtime: the chunk is only fetched on first actual use of the Bedrock provider, exactly as before.Also added a post-build check that fails the build if a provider chunk reachable only through a non-literal dynamic import is missing from the output — so a future occurrence of this exact failure mode (silent at build time, only surfacing for a user at first use) fails
npm run build, which already runs directly in CI (.github/workflows/ci.yml), instead of shipping. This directly satisfies the "verify the emitted provider bundle closure, including Amazon Bedrock" acceptance criterion tracked in #1379.Validation
amazon-bedrock.js; manually dynamic-importing it from the referencing chunk's own directory throws the exact reported error:Cannot find module '.../dist/bundle/amazon-bedrock.js' imported from .../dist/bundle/chunk-*.js.{ bedrockProviderModule }export.node scripts/bundle.mjssucceeds; the new closure check passes;dist/bundle/amazon-bedrock.jsis emitted.npx tsgo -p tsconfig.json --noEmitpasses.npm run check(biome,tsgo --noEmit, installer render, browser smoke) passes.npm run buildfor validation: itsgenerate-modelsstep does a live network fetch of current provider catalogs and rewritespackages/ai/src/models.generated.tsnondeterministically — unrelated to this change. Confirmed unmodifiedmainalso produces this same dirty diff from a plainnpm run build, and confirmedtsgo --noEmitpasses cleanly on unmodifiedmainwithout that step, isolating it as pre-existing environment noise rather than something this fix caused.Patch
Branch: https://github.com/kaluli123123/prime-agent/tree/fix/bundle-amazon-bedrock-chunk-closure
Diff: main...kaluli123123:prime-agent:fix/bundle-amazon-bedrock-chunk-closure
Happy to open a PR from this branch if a maintainer wants to invite implementation, per CONTRIBUTING.md.
All reactions