From 9b6c8e84285e570048ea331b0303086b677423bf Mon Sep 17 00:00:00 2001 From: Codebeast Date: Mon, 20 Apr 2026 17:48:48 -0500 Subject: [PATCH] =?UTF-8?q?fix:=20revert=20duplicate=20LLMProviders.fromEn?= =?UTF-8?q?v()=20=E2=80=94=20TS2393=20broke=20build?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reverts 33aaf53. That commit added a second `static fromEnv()` to `LLMProviders` without noticing the existing one (added 2026-04-01 in 743a1e04, PRs #7/#8). TypeScript correctly errored: src/index.ts(218,10): error TS2393: Duplicate function implementation. src/index.ts(381,10): error TS2393: Duplicate function implementation. This broke `npm run build` (the `prepare` script is `tsc`), which means publish was blocked AND every downstream consumer that builds llm-providers from main as a sibling-checkout dep had red CI. The reverted impl was a strict subset of the existing one — same pattern, fewer providers (no Anthropic, no OpenAI), no overrides support, silent on empty-env (existing throws `ConfigurationError`). Nothing salvageable; the existing fromEnv at line 218 already covers the use case the reverted commit's message describes. --- src/index.ts | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/src/index.ts b/src/index.ts index 55a2fee..8e7e077 100755 --- a/src/index.ts +++ b/src/index.ts @@ -373,26 +373,6 @@ export class LLMProviders { updateConfig(config: Partial): void { this.factory.updateConfig(config); } - - /** - * Create LLMProviders by auto-discovering providers from a Cloudflare Workers env object. - * Inspects well-known env keys: AI (CF Workers AI binding), GROQ_API_KEY, CEREBRAS_API_KEY. - */ - static fromEnv(env: Record): LLMProviders { - const config: ProviderFactoryConfig = { defaultProvider: 'auto' }; - - if (env['AI']) { - config.cloudflare = { ai: env['AI'] as Ai }; - } - if (typeof env['GROQ_API_KEY'] === 'string' && env['GROQ_API_KEY']) { - config.groq = { apiKey: env['GROQ_API_KEY'] }; - } - if (typeof env['CEREBRAS_API_KEY'] === 'string' && env['CEREBRAS_API_KEY']) { - config.cerebras = { apiKey: env['CEREBRAS_API_KEY'] }; - } - - return new LLMProviders(config); - } } /**