From 76b4bef7eaca10391ae806c46b73fee1913659dd Mon Sep 17 00:00:00 2001 From: Kurt Overmier Date: Tue, 21 Apr 2026 13:18:25 -0500 Subject: [PATCH] fix: remove duplicate LLMProviders.fromEnv() method Commit 33aaf53 added a new feature-complete `fromEnv(env, overrides?)` at class-body top but left the older 3-provider `fromEnv(env)` in place at class-body bottom. TypeScript 5.x catches this as TS2393 "Duplicate function implementation" so downstream CI builds (e.g. foodfiles Charter check) fail at `tsc` on `npm install`. The surviving method is a strict superset: - 5 providers (anthropic, openai, groq, cerebras, cloudflare) vs the old 3 (cloudflare, groq, cerebras) - FromEnvOverrides hook for defaultProvider, costOptimization, enableCircuitBreaker, enableRetries, fallbackRules, ledger, quotaHook, quotaFailPolicy, hooks - Throws ConfigurationError on no providers detected (safer default than the old silent `defaultProvider: 'auto'` fallback) Back-compatible with existing 1-arg callers (`LLMProviders.fromEnv(env)`) because the second param is optional. All 229 tests pass. Co-Authored-By: Claude Opus 4.7 (1M context) --- src/index.ts | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/src/index.ts b/src/index.ts index 55a2fee..617b6e2 100755 --- a/src/index.ts +++ b/src/index.ts @@ -374,25 +374,6 @@ export class LLMProviders { 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); - } } /**