Skip to content

feat(cli): make built-in providers opt-in#190

Closed
FredKSchott wants to merge 1 commit into
mainfrom
feat/provider-bundle-allowlist
Closed

feat(cli): make built-in providers opt-in#190
FredKSchott wants to merge 1 commit into
mainfrom
feat/provider-bundle-allowlist

Conversation

@FredKSchott
Copy link
Copy Markdown
Member

Summary

  • add a build-time providers allowlist so Flue only bundles selected Pi provider transports and SDK chunks
  • keep Cloudflare Workers AI binding support automatic while excluding unrelated provider chunks by default
  • add Node-only amazon-bedrock opt-in through Pi's public Bedrock injection hook and reject it for Cloudflare builds
  • pin the audited Pi dependency versions and align the Node requirement to >=22.19.0
  • update examples and docs for the provider opt-in migration

Intent

Reduce generated bundle size by preventing every Pi SDK-backed provider implementation from becoming reachable in every Flue build.

Migration

Catalog-backed providers are now opt-in in flue.config.ts:

export default defineConfig({
  providers: ['anthropic'],
});

Cloudflare builds continue to include the binding-backed cloudflare/... provider automatically. Custom providers that use a built-in transport, such as openai-completions, should include a provider that enables that transport, such as openai.

amazon-bedrock is Node-only and intentionally includes the AWS SDK when selected.

Verification

  • pnpm run check:lint
  • pnpm run build && pnpm run check:types in packages/runtime
  • pnpm run build && pnpm run check:types in packages/cli
  • pnpm run check:types in packages/sdk
  • pnpm run check:types in packages/opentelemetry
  • pnpm run check:types in apps/docs
  • pnpm exec vitest run test/build-plugin-node.test.ts test/build-plugin-cloudflare.test.ts test/config.test.ts in packages/runtime
  • pnpm exec vitest run --config vitest.integration.cloudflare.config.ts --no-file-parallelism test/vite-cloudflare-build.test.ts in packages/runtime
  • pnpm --dir packages/runtime run test:integration:release
  • git diff --check

@FredKSchott
Copy link
Copy Markdown
Member Author

Closing this in favor of the upstream Pi approach in earendil-works/pi#5348.

If that PR merges, Flue can keep accepting model-provider IDs in config, such as anthropic, groq, cloudflare-workers-ai, or cloudflare-ai-gateway, while generating only the required transport imports at build time:

  1. Read the configured model-provider IDs.
  2. Call getModels(providerId) from @earendil-works/pi-ai/base.
  3. Collect and deduplicate the resulting model.api values.
  4. Emit static imports and register() calls only for those API transports.

For example, groq and cloudflare-workers-ai resolve to openai-completions. cloudflare-ai-gateway currently resolves to multiple transports: anthropic-messages, openai-responses, and openai-completions. The generated JavaScript would include only the corresponding direct registration imports.

This avoids a runtime registration table that statically imports every transport and preserves the bundle-size goal without maintaining provider-to-transport mappings in Flue. If the Pi PR does not merge, we can reopen this fallback approach.

This comment is AI-generated by opencode.

@FredKSchott FredKSchott closed this Jun 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant