@warlock.js/ai-groq 5.53.0 → 5.54.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/cjs/index.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["OpenAISDK"],"sources":["../../../../../../../packages/ai-groq/src/known-context-windows.ts","../../../../../../../packages/ai-groq/src/known-models.ts","../../../../../../../packages/ai-groq/src/sdk.ts","../../../../../../../packages/ai-groq/src/known-lifecycle.ts"],"mappings":";;;;AAQA,MAAM,gBAA4E;CAChF,CAAC,WAAW,MAAO;CACnB,CAAC,WAAW,MAAO;CACnB,CAAC,WAAW,MAAO;CACnB,CAAC,SAAS,MAAO;CACjB,CAAC,uBAAuB,MAAO;CAC/B,CAAC,WAAW,MAAO;AACrB;;;;;;;;AASA,SAAgB,mBAAmB,SAAqC;CACtE,MAAM,KAAK,QAAQ,YAAY;CAC/B,IAAI;CAEJ,KAAK,MAAM,SAAS,eAAe;EACjC,MAAM,WAAW,MAAM;EAEvB,IAAI,GAAG,SAAS,QAAQ,MAAM,CAAC,QAAQ,SAAS,SAAS,KAAK,EAAE,CAAC,SAC/D,OAAO;CAEX;CAEA,OAAO,OAAO;AAChB;;;;;;;;;;;;;AC5BA,MAAa,gBAAgB;;;;;;;AAQ7B,MAAa,gBAAgB;;;;;;;;;;;;;;;;;;;;;;AAuB7B,MAAM,4BAA4B;CAChC;CACA;CACA;CACA;CACA;AACF;;;;;;;;;;;;;;;AAgBA,MAAM,+BAA+B;CACnC;CACA;CACA;CACA;CACA;AACF;;;;;;;;;;;;;;AAeA,SAAgB,sBAAsB,SAA0B;CAC9D,MAAM,aAAa,QAAQ,YAAY;CAEvC,OAAO,0BAA0B,MAAM,aAAa,WAAW,SAAS,QAAQ,CAAC;AACnF;;;;;;;;;;;;AAaA,SAAgB,yBAAyB,SAA0B;CACjE,MAAM,aAAa,QAAQ,YAAY;CAEvC,OAAO,6BAA6B,MAAM,aAA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M;CACtE,sBAAsB;EAAE,OAAO;EAAO,QAAQ;EAAK,aAAa;CAAO;CACvE,gCAAgC;EAAE,OAAO;EAAO,QAAQ;EAAK,aAAa;CAAO;CACjF,oBAAoB;EAAE,OAAO;EAAK,QAAQ;CAAE;AAC9C;;;;;;;;;;;;;;;;AC7LA,MAAa,uBAAiE;CAC5E,uBAAuB,EAAE,QAAQ,UAAU;CAC3C,sBAAsB,EAAE,QAAQ,UAAU;CAC1C,gCAAgC,EAAE,QAAQ,UAAU;CACpD,oBAAoB,EAAE,QAAQ,UAAU;CACxC,2BAA2B;EACzB,QAAQ;EACR,WAAW;EACX,aAAa;CACf;CACA,wBAAwB;EACtB,QAAQ;EACR,WAAW;EACX,aAAa;CACf;CACA,iCAAiC;EAC/B,QAAQ;EACR,WAAW;EACX,aAAa;CACf;CACA,oBAAoB;EAClB,QAAQ;EACR,WAAW;EACX,aAAa;CACf;CACA,kBAAkB;EAChB,QAAQ;EACR,WAAW;EACX,aAAa;CACf;CACA,6CAA6C;EAC3C,QAAQ;EACR,WAAW;EACX,aAAa;CACf;CACA,iDAAiD;EAC/C,QAAQ;EACR,WAAW;EACX,aAAa;CACf;CACA,oCAAoC;EAClC,QAAQ;EACR,WAAW;EACX,aAAa;CACf;CACA,+BAA+B;EAC7B,QAAQ;EACR,WAAW;EACX,aAAa;CACf;CACA,iBAAiB;EAAE,QAAQ;EAAW,WAAW;CAAa;CAC9D,sBAAsB;EAAE,QAAQ;EAAW,WAAW;CAAa;AACrE;;AAGA,MAAa,6BAA6B;;;;;;;;AAS1C,SAAgB,iBAAiB,WAA+C;CAC9E,OAAO,OAAO,OAAO,sBAAsB,SAAS,IAChD,qBAAqB,aACrB;AACN"}
1
+ {"version":3,"file":"index.cjs","names":["OpenAISDK"],"sources":["../../../../../../../packages/ai-groq/src/known-context-windows.ts","../../../../../../../packages/ai-groq/src/known-models.ts","../../../../../../../packages/ai-groq/src/sdk.ts","../../../../../../../packages/ai-groq/src/known-lifecycle.ts"],"sourcesContent":["/*\n * Context windows of the chat models Groq hosts, from its model catalog:\n * the Llama, gpt-oss, Qwen3 and DeepSeek-R1 distill ids document 131,072\n * tokens, Kimi K2 262,144.\n * The longest matching fragment wins; ids that match nothing resolve to `undefined`, so a\n * window-relative trigger stays inert until the window is set with\n * `groq.model({ name, contextWindow })`.\n */\nconst KNOWN_WINDOWS: ReadonlyArray<readonly [fragment: string, window: number]> = [\n [\"llama-3\", 131_072],\n [\"llama-4\", 131_072],\n [\"gpt-oss\", 131_072],\n [\"qwen3\", 131_072],\n [\"deepseek-r1-distill\", 131_072],\n [\"kimi-k2\", 262_144],\n];\n\n/**\n * The known context window (tokens, input plus output) of a Groq-hosted chat\n * model id, or `undefined` when it is not in the table.\n *\n * @example\n * inferContextWindow(\"llama-3\"); // → 131072\n */\nexport function inferContextWindow(modelId: string): number | undefined {\n const id = modelId.toLowerCase();\n let best: readonly [string, number] | undefined;\n\n for (const entry of KNOWN_WINDOWS) {\n const fragment = entry[0];\n\n if (id.includes(fragment) && (!best || fragment.length > best[0].length)) {\n best = entry;\n }\n }\n\n return best?.[1];\n}\n","/**\n * Default base URL for Groq's OpenAI-compatible Chat Completions\n * endpoint. Groq exposes the same wire protocol as OpenAI under this\n * prefix, which is exactly why `GroqSDK` can delegate to the\n * battle-tested `OpenAISDK` instead of reimplementing the transport.\n *\n * Verified against Groq's \"OpenAI Compatibility\" docs (mid-2026).\n * Override via `new GroqSDK({ baseURL })` if Groq ever relocates it.\n */\nexport const GROQ_BASE_URL = \"https://api.groq.com/openai/v1\";\n\n/**\n * The provider label every model produced by `GroqSDK` self-identifies\n * with. Flows through to `ModelContract.provider`, `AgentReport.model`,\n * logs, and any provider-aware middleware. Kept as a constant so the\n * wrapper and the inner `OpenAISDK` agree on one spelling.\n */\nexport const GROQ_PROVIDER = \"groq\";\n\n/**\n * Substrings identifying Groq-hosted model ids whose family accepts\n * image input (vision).\n *\n * Groq hosts *open* models on its LPU hardware, so the ids are the\n * upstream open-weight names rather than OpenAI's — which is why the\n * OpenAI adapter's `gpt-4o*` prefix inference would never fire here and\n * this provider must carry its OWN list. Verified against Groq's\n * supported-models catalog (mid-2026):\n *\n * - `openai/gpt-oss-*` — natively multimodal OpenAI open-weight family\n * (the current production vision + reasoning models on Groq).\n * - `llama-4` / `llama-3.2-*-vision` — Meta's multimodal Llama families.\n * Kept as substrings so any still-hosted or re-introduced variant is\n * covered even though some `llama-4` ids were deprecated in 2026.\n *\n * Matched as a substring (not a prefix) because Groq prefixes several\n * ids with an org segment (`openai/`, `meta-llama/`) and appends size /\n * date suffixes. Override per-model via\n * `groq.model({ name, vision: true | false })`.\n */\nconst VISION_CAPABLE_SUBSTRINGS = [\n \"gpt-oss\",\n \"llama-4\",\n \"llama-3.2-11b-vision\",\n \"llama-3.2-90b-vision\",\n \"vision\",\n];\n\n/**\n * Substrings identifying Groq-hosted model ids that expose an internal\n * reasoning / thinking channel and accept the `reasoning_effort`\n * request parameter on the OpenAI-compatible Chat Completions endpoint.\n *\n * Verified against Groq's catalog (mid-2026):\n * - `gpt-oss` — the OpenAI open-weight family reasons by default.\n * - `deepseek-r1-distill` — DeepSeek-R1-style reasoning at Groq speed.\n * - `qwq` / `qwen3` — Qwen reasoning families (when hosted).\n *\n * Matched as a substring for the same org-prefix / suffix reason as the\n * vision list. Override per-model via\n * `groq.model({ name, reasoning: true | false })`.\n */\nconst REASONING_CAPABLE_SUBSTRINGS = [\n \"gpt-oss\",\n \"deepseek-r1\",\n \"deepseek-r1-distill\",\n \"qwq\",\n \"qwen3\",\n];\n\n/**\n * Infer whether a Groq-hosted model id supports vision based on the\n * known multimodal-family substrings. Unknown ids default to `false`\n * so passing an image attachment to a text-only model (e.g.\n * `llama-3.3-70b-versatile`) surfaces a clear, agent-side capability\n * error instead of an opaque upstream 400.\n *\n * @example\n * inferVisionCapability(\"openai/gpt-oss-120b\"); // → true\n * inferVisionCapability(\"meta-llama/llama-4-scout\"); // → true\n * inferVisionCapability(\"llama-3.3-70b-versatile\"); // → false\n * inferVisionCapability(\"llama-3.1-8b-instant\"); // → false\n */\nexport function inferVisionCapability(modelId: string): boolean {\n const normalized = modelId.toLowerCase();\n\n return VISION_CAPABLE_SUBSTRINGS.some((fragment) => normalized.includes(fragment));\n}\n\n/**\n * Infer whether a Groq-hosted model id is a reasoning model based on\n * the known reasoning-family substrings. Unknown ids default to `false`\n * so the adapter never forwards an unsupported `reasoning_effort` param\n * to a non-reasoning model (which would 400).\n *\n * @example\n * inferReasoningCapability(\"openai/gpt-oss-20b\"); // → true\n * inferReasoningCapability(\"deepseek-r1-distill-llama-70b\"); // → true\n * inferReasoningCapability(\"llama-3.3-70b-versatile\"); // → false\n */\nexport function inferReasoningCapability(modelId: string): boolean {\n const normalized = modelId.toLowerCase();\n\n return REASONING_CAPABLE_SUBSTRINGS.some((fragment) => normalized.includes(fragment));\n}\n\n/**\n * Curated list of current Groq chat model ids, for autocomplete, docs, and\n * default selection. NOT exhaustive and NOT a runtime allow-list —\n * `groq.model({ name })` accepts any string, so a newly launched id works\n * the moment Groq ships it without a package bump. Ids Groq has shut down\n * are left out here and recorded as `retired` in\n * {@link GROQ_MODEL_LIFECYCLE}.\n *\n * - `openai/gpt-oss-120b` / `openai/gpt-oss-20b` — OpenAI open-weight\n * family; vision + reasoning capable.\n * - `qwen/qwen3.8-27b` — Qwen 3.8 (a preview model on Groq).\n */\nexport const GROQ_KNOWN_MODELS = [\n \"openai/gpt-oss-120b\",\n \"openai/gpt-oss-20b\",\n \"qwen/qwen3.8-27b\",\n] as const;\n","import type {\n ListModelsOptions,\n ModelInfo,\n EmbedderContract,\n ModelContract,\n ModelPricing,\n SDKAdapterContract,\n} from \"@warlock.js/ai\";\nimport { OpenAISDK } from \"@warlock.js/ai-openai\";\nimport type { GroqEmbedderConfig, GroqModelConfig, GroqSDKConfig } from \"./config.type\";\nimport { inferContextWindow } from \"./known-context-windows\";\nimport {\n GROQ_BASE_URL,\n GROQ_PROVIDER,\n inferReasoningCapability,\n inferVisionCapability,\n} from \"./known-models\";\n\n/**\n * Groq-backed implementation of `SDKAdapterContract`.\n *\n * **Role.** The package entry point for Groq-hosted open models\n * (`llama-3.3-70b-versatile`, `llama-3.1-8b-instant`,\n * `openai/gpt-oss-*`, `deepseek-r1-distill-*`, …) served on Groq's fast\n * LPU hardware. Because Groq exposes the OpenAI Chat Completions wire\n * protocol verbatim, `GroqSDK` is a **thin wrapper over the already\n * battle-tested {@link OpenAISDK}** rather than a fresh transport\n * implementation — it owns one internal `OpenAISDK` pointed at Groq's\n * `baseURL` with the `\"groq\"` provider label, and delegates `model()` /\n * `embedder()` / `count()` to it.\n *\n * **Why a wrapper and not `OpenAISDK` directly?** Groq hosts *open*\n * models whose ids are the upstream open-weight names (`llama-…`,\n * `openai/gpt-oss-…`), not OpenAI's (`gpt-4o`, `o3`). The OpenAI\n * adapter's capability inference keys on OpenAI prefixes and would never\n * fire here, so every Groq model would come back with `vision`/\n * `reasoning` silently `false`. `GroqSDK` fixes that by computing\n * **this provider's own** vision/reasoning inference (see\n * `known-models.ts`) and injecting the result as explicit capability\n * config — which wins over the inner adapter's inference — plus a set of\n * default per-model pricing rates. Everything else (transport, retries,\n * streaming, structured output, error wrapping, usage accounting) is\n * inherited unchanged from `OpenAISDK`.\n *\n * **Responsibility.**\n * - Owns: one long-lived internal `OpenAISDK` (auth + Groq base URL) and\n * this provider's capability + default-pricing inference.\n * - Does NOT own: the wire protocol, streaming loop, structured-output\n * mapping, or error wrapping — all inherited from `OpenAISDK`.\n *\n * Modeled as a class (see §4.2 of code-style.md — \"long-lived state\n * across many calls\"), fronted by FP usage like the other adapters.\n *\n * @example\n * const groq = new GroqSDK({ apiKey: process.env.GROQ_API_KEY! });\n * const model = groq.model({ name: \"llama-3.3-70b-versatile\", temperature: 0.7 });\n * const reasoner = groq.model({ name: \"openai/gpt-oss-120b\" }); // vision + reasoning auto-true\n *\n * @example\n * // Compose into an `ai.groq` namespace for ergonomic agent wiring\n * const ai = { agent, tool, systemPrompt, groq: new GroqSDK({ apiKey }) };\n * const myAgent = ai.agent({ model: ai.groq.model({ name: \"llama-3.1-8b-instant\" }) });\n */\nexport class GroqSDK implements SDKAdapterContract {\n /**\n * The wrapped OpenAI-compatible adapter, pre-pointed at Groq's\n * `baseURL` and labeled with the `\"groq\"` provider. All real wire work\n * happens here; `GroqSDK` only enriches the per-model config before\n * delegating.\n */\n private readonly openai: OpenAISDK;\n private readonly provider: string;\n private readonly pricing?: Record<string, ModelPricing>;\n\n public constructor(config: GroqSDKConfig) {\n const { baseURL, provider, pricing, ...clientOptions } = config;\n\n this.provider = provider ?? GROQ_PROVIDER;\n this.pricing = pricing;\n\n // Build the inner OpenAI-compatible client pointed at Groq. Forward\n // every other upstream ClientOptions (timeout, maxRetries,\n // defaultHeaders, fetch, …) verbatim — they type-check, so dropping\n // them would be a silent footgun. We pass `pricing` through too so\n // the inner registry stays a fallback, while THIS class's `model()`\n // layers Groq default rates on top.\n this.openai = new OpenAISDK({\n ...clientOptions,\n baseURL: baseURL ?? GROQ_BASE_URL,\n provider: this.provider,\n pricing,\n });\n }\n\n /**\n * Build a `ModelContract` bound to the internal Groq-pointed client.\n *\n * The wrapper's whole job lives here: it computes **Groq's** vision /\n * reasoning inference from the model id and forwards the result as\n * *explicit* `vision` / `reasoning` config to the inner\n * `OpenAISDK.model()`. Because explicit capability config wins over the\n * inner adapter's OpenAI-prefix inference, the returned model reports\n * the right capabilities even though the id isn't an OpenAI name. A\n * caller-supplied `vision` / `reasoning` still wins over this\n * inference (we only fill the gap when the field is omitted).\n *\n * Pricing resolution: per-model `config.pricing` wins; otherwise this\n * SDK's `pricing` registry keyed by `config.name`; otherwise the\n * adapter's built-in default rate for the model; otherwise `undefined`\n * (no cost computed).\n */\n public model(config: GroqModelConfig): ModelContract {\n const resolvedPricing =\n config.pricing ?? this.pricing?.[config.name] ?? defaultPricingFor(config.name);\n\n const window = config.contextWindow ?? inferContextWindow(config.name);\n\n return this.openai.model({\n ...config,\n ...(window !== undefined ? { contextWindow: window } : {}),\n // Fill capability inference only when the caller didn't pin it —\n // explicit caller config always wins, then Groq inference, then\n // (inside OpenAISDK) the harmless OpenAI inference that won't match.\n vision: config.vision ?? inferVisionCapability(config.name),\n reasoning: config.reasoning ?? inferReasoningCapability(config.name),\n structuredOutput: config.structuredOutput ?? true,\n pricing: resolvedPricing,\n });\n }\n\n /**\n * Rough offline token-count estimate. Delegated straight to the inner\n * `OpenAISDK`, which uses the core character-heuristic\n * (`approximateTokenCount`). Good for budgeting / quota guards, not for\n * billing.\n */\n public async count(text: string, model?: string): Promise<number> {\n return this.openai.count(text, model);\n }\n\n /**\n * Build an embedder bound to the internal client. Delegated to the\n * inner `OpenAISDK`.\n *\n * IMPORTANT: as of mid-2026 Groq does **not** expose an\n * OpenAI-compatible embeddings endpoint, so a live `.embed()` /\n * `.embedMany()` call will fail at the provider. The method is kept for\n * adapter symmetry; use `@warlock.js/ai-openai` or\n * `@warlock.js/ai-google` for retrieval embeddings.\n */\n public embedder(config: GroqEmbedderConfig): EmbedderContract {\n return this.openai.embedder(config);\n }\n\n // NOTE: `image()` is intentionally NOT implemented. Groq hosts no\n // image-generation API, and `SDKAdapterContract.image` is optional —\n // its structural absence IS the capability guard, so\n // `ai.groq.image(...)` is a compile-time error rather than a runtime\n // surprise (mirrors Anthropic / Bedrock / Ollama).\n /**\n * List the models this Groq account can use, live from the provider's\n * OpenAI-compatible `GET /models`, mapped to the common `ModelInfo`\n * shape. Groq models marked inactive are left out; `contextWindow` comes from `context_window`. Failures are thrown as the adapter's usual provider\n * errors, never an empty list.\n *\n * @example\n * const models = await groq.models();\n * models.map((model) => model.id);\n */\n public async models(options?: ListModelsOptions): Promise<ModelInfo[]> {\n return this.openai.models(options);\n }\n}\n\n/**\n * Built-in default USD-per-1,000,000-token rates for the Groq models with\n * a published price, used as the last fallback in `model()`'s pricing\n * resolution. A per-model or SDK-level `pricing` entry always wins over\n * these. Returns `undefined` for any unlisted id so cost stays an honest\n * absence rather than a false zero.\n */\nfunction defaultPricingFor(name: string): ModelPricing | undefined {\n return GROQ_DEFAULT_PRICING[name];\n}\n\n/** The date the {@link GROQ_DEFAULT_PRICING} token rates were last checked against Groq's model page. */\nexport const GROQ_DEFAULT_PRICING_AS_OF = \"2026-11-06\";\n\n/**\n * Default per-million-token USD rates for Groq models.\n *\n * Source: https://console.groq.com/docs/models (groq.com/pricing now\n * redirects to the home page), as of {@link GROQ_DEFAULT_PRICING_AS_OF}. Cached input is 50%\n * of the input rate for the gpt-oss models, the only ones Groq caches\n * (https://console.groq.com/docs/prompt-caching, checked 2026-10-17; no write charge). The\n * Llama models are listed as \"Enterprise – Contact Sales\" with no public\n * price, so they stay unpriced — pass `pricing` for them.\n */\nexport const GROQ_DEFAULT_PRICING: Readonly<Record<string, ModelPricing>> = {\n \"openai/gpt-oss-120b\": { input: 0.15, output: 0.6, cachedInput: 0.075 },\n \"openai/gpt-oss-20b\": { input: 0.075, output: 0.3, cachedInput: 0.0375 },\n \"openai/gpt-oss-safeguard-20b\": { input: 0.075, output: 0.3, cachedInput: 0.0375 },\n \"qwen/qwen3.8-27b\": { input: 0.8, output: 4 },\n};\n","import type { ModelLifecycle } from \"@warlock.js/ai\";\n\n/**\n * Where Groq's deprecations page and model catalog put the chat models the\n * adapter knows, as of {@link GROQ_MODEL_LIFECYCLE_AS_OF}. `retired` ids\n * are past their shutdown date; Groq applies several of these shutdowns to\n * free and developer-tier usage only, so a committed-spend enterprise\n * contract can still serve them.\n *\n * Sources: https://console.groq.com/docs/deprecations and\n * https://console.groq.com/docs/models. Preview models (`qwen/qwen3.8-27b`,\n * `openai/gpt-oss-safeguard-20b`) are listed as `current` while Groq\n * serves them, but Groq may discontinue previews at short notice.\n */\nexport const GROQ_MODEL_LIFECYCLE: Readonly<Record<string, ModelLifecycle>> = {\n \"openai/gpt-oss-120b\": { status: \"current\" },\n \"openai/gpt-oss-20b\": { status: \"current\" },\n \"openai/gpt-oss-safeguard-20b\": { status: \"current\" },\n \"qwen/qwen3.8-27b\": { status: \"current\" },\n \"llama-3.3-70b-versatile\": {\n status: \"retired\",\n retiresOn: \"2026-08-16\",\n replacement: \"openai/gpt-oss-120b\",\n },\n \"llama-3.1-8b-instant\": {\n status: \"retired\",\n retiresOn: \"2026-08-16\",\n replacement: \"openai/gpt-oss-20b\",\n },\n \"deepseek-r1-distill-llama-70b\": {\n status: \"retired\",\n retiresOn: \"2025-10-02\",\n replacement: \"openai/gpt-oss-120b\",\n },\n \"qwen/qwen3.6-27b\": {\n status: \"retired\",\n retiresOn: \"2026-09-14\",\n replacement: \"qwen/qwen3.8-27b\",\n },\n \"qwen/qwen3-32b\": {\n status: \"retired\",\n retiresOn: \"2026-07-17\",\n replacement: \"openai/gpt-oss-120b\",\n },\n \"meta-llama/llama-4-scout-17b-16e-instruct\": {\n status: \"retired\",\n retiresOn: \"2026-07-17\",\n replacement: \"openai/gpt-oss-120b\",\n },\n \"meta-llama/llama-4-maverick-17b-128e-instruct\": {\n status: \"retired\",\n retiresOn: \"2026-03-09\",\n replacement: \"openai/gpt-oss-120b\",\n },\n \"moonshotai/kimi-k2-instruct-0905\": {\n status: \"retired\",\n retiresOn: \"2026-04-15\",\n replacement: \"openai/gpt-oss-120b\",\n },\n \"moonshotai/kimi-k2-instruct\": {\n status: \"retired\",\n retiresOn: \"2025-10-10\",\n replacement: \"openai/gpt-oss-120b\",\n },\n \"groq/compound\": { status: \"retired\", retiresOn: \"2026-09-21\" },\n \"groq/compound-mini\": { status: \"retired\", retiresOn: \"2026-09-21\" },\n};\n\n/** The date {@link GROQ_MODEL_LIFECYCLE} was last checked against Groq's deprecations page. */\nexport const GROQ_MODEL_LIFECYCLE_AS_OF = \"2026-11-06\";\n\n/**\n * Look up the lifecycle of a Groq model id (exact match), or `undefined`\n * when the table does not cover it.\n *\n * @example\n * groqLifecycleFor(\"llama-3.3-70b-versatile\"); // { status: \"retired\", retiresOn: \"2026-08-16\", … }\n */\nexport function groqLifecycleFor(modelName: string): ModelLifecycle | undefined {\n return Object.hasOw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AC3C,sBAAsB,EAAE,QAAQ,UAAU;CAC1C,gCAAgC,EAAE,QAAQ,UAAU;CACpD,oBAAoB,EAAE,QAAQ,UAAU;CACxC,2BAA2B;EACzB,QAAQ;EACR,WAAW;EACX,aAAa;CACf;CACA,wBAAwB;EACtB,QAAQ;EACR,WAAW;EACX,aAAa;CACf;CACA,iCAAiC;EAC/B,QAAQ;EACR,WAAW;EACX,aAAa;CACf;CACA,oBAAoB;EAClB,QAAQ;EACR,WAAW;EACX,aAAa;CACf;CACA,kBAAkB;EAChB,QAAQ;EACR,WAAW;EACX,aAAa;CACf;CACA,6CAA6C;EAC3C,QAAQ;EACR,WAAW;EACX,aAAa;CACf;CACA,iDAAiD;EAC/C,QAAQ;EACR,WAAW;EACX,aAAa;CACf;CACA,oCAAoC;EAClC,QAAQ;EACR,WAAW;EACX,aAAa;CACf;CACA,+BAA+B;EAC7B,QAAQ;EACR,WAAW;EACX,aAAa;CACf;CACA,iBAAiB;EAAE,QAAQ;EAAW,WAAW;CAAa;CAC9D,sBAAsB;EAAE,QAAQ;EAAW,WAAW;CAAa;AACrE;;AAGA,MAAa,6BAA6B;;;;;;;;AAS1C,SAAgB,iBAAiB,WAA+C;CAC9E,OAAO,OAAO,OAAO,sBAAsB,SAAS,IAChD,qBAAqB,aACrB;AACN"}
@@ -1 +1 @@
1
- {"version":3,"file":"known-context-windows.mjs","names":[],"sources":["../../../../../../../packages/ai-groq/src/known-context-windows.ts"],"mappings":";AAQA,MAAM,gBAA4E;CAChF,CAAC,WAAW,MAAO;CACnB,CAAC,WAAW,MAAO;CACnB,CAAC,WAAW,MAAO;CACnB,CAAC,SAAS,MAAO;CACjB,CAAC,uBAAuB,MAAO;CAC/B,CAAC,WAAW,MAAO;AACrB;;;;;;;;AASA,SAAgB,mBAAmB,SAAqC;CACtE,MAAM,KAAK,QAAQ,YAAY;CAC/B,IAAI;CAEJ,KAAK,MAAM,SAAS,eAAe;EACjC,MAAM,WAAW,MAAM;EAEvB,IAAI,GAAG,SAAS,QAAQ,MAAM,CAAC,QAAQ,SAAS,SAAS,KAAK,EAAE,CAAC,SAC/D,OAAO;CAEX;CAEA,OAAO,OAAO;AAChB"}
1
+ {"version":3,"file":"known-context-windows.mjs","names":[],"sources":["../../../../../../../packages/ai-groq/src/known-context-windows.ts"],"sourcesContent":["/*\n * Context windows of the chat models Groq hosts, from its model catalog:\n * the Llama, gpt-oss, Qwen3 and DeepSeek-R1 distill ids document 131,072\n * tokens, Kimi K2 262,144.\n * The longest matching fragment wins; ids that match nothing resolve to `undefined`, so a\n * window-relative trigger stays inert until the window is set with\n * `groq.model({ name, contextWindow })`.\n */\nconst KNOWN_WINDOWS: ReadonlyArray<readonly [fragment: string, window: number]> = [\n [\"llama-3\", 131_072],\n [\"llama-4\", 131_072],\n [\"gpt-oss\", 131_072],\n [\"qwen3\", 131_072],\n [\"deepseek-r1-distill\", 131_072],\n [\"kimi-k2\", 262_144],\n];\n\n/**\n * The known context window (tokens, input plus output) of a Groq-hosted chat\n * model id, or `undefined` when it is not in the table.\n *\n * @example\n * inferContextWindow(\"llama-3\"); // → 131072\n */\nexport function inferContextWindow(modelId: string): number | undefined {\n const id = modelId.toLowerCase();\n let best: readonly [string, number] | undefined;\n\n for (const entry of KNOWN_WINDOWS) {\n const fragment = entry[0];\n\n if (id.includes(fragment) && (!best || fragment.length > best[0].length)) {\n best = entry;\n }\n }\n\n return best?.[1];\n}\n"],"mappings":";AAQA,MAAM,gBAA4E;CAChF,CAAC,WAAW,MAAO;CACnB,CAAC,WAAW,MAAO;CACnB,CAAC,WAAW,MAAO;CACnB,CAAC,SAAS,MAAO;CACjB,CAAC,uBAAuB,MAAO;CAC/B,CAAC,WAAW,MAAO;AACrB;;;;;;;;AASA,SAAgB,mBAAmB,SAAqC;CACtE,MAAM,KAAK,QAAQ,YAAY;CAC/B,IAAI;CAEJ,KAAK,MAAM,SAAS,eAAe;EACjC,MAAM,WAAW,MAAM;EAEvB,IAAI,GAAG,SAAS,QAAQ,MAAM,CAAC,QAAQ,SAAS,SAAS,KAAK,EAAE,CAAC,SAC/D,OAAO;CAEX;CAEA,OAAO,OAAO;AAChB"}
@@ -1 +1 @@
1
- {"version":3,"file":"known-lifecycle.mjs","names":[],"sources":["../../../../../../../packages/ai-groq/src/known-lifecycle.ts"],"mappings":";;;;;;;;;;;;;AAcA,MAAa,uBAAiE;CAC5E,uBAAuB,EAAE,QAAQ,UAAU;CAC3C,sBAAsB,EAAE,QAAQ,UAAU;CAC1C,gCAAgC,EAAE,QAAQ,UAAU;CACpD,oBAAoB,EAAE,QAAQ,UAAU;CACxC,2BAA2B;EACzB,QAAQ;EACR,WAAW;EACX,aAAa;CACf;CACA,wBAAwB;EACtB,QAAQ;EACR,WAAW;EACX,aAAa;CACf;CACA,iCAAiC;EAC/B,QAAQ;EACR,WAAW;EACX,aAAa;CACf;CACA,oBAAoB;EAClB,QAAQ;EACR,WAAW;EACX,aAAa;CACf;CACA,kBAAkB;EAChB,QAAQ;EACR,WAAW;EACX,aAAa;CACf;CACA,6CAA6C;EAC3C,QAAQ;EACR,WAAW;EACX,aAAa;CACf;CACA,iDAAiD;EAC/C,QAAQ;EACR,WAAW;EACX,aAAa;CACf;CACA,oCAAoC;EAClC,QAAQ;EACR,WAAW;EACX,aAAa;CACf;CACA,+BAA+B;EAC7B,QAAQ;EACR,WAAW;EACX,aAAa;CACf;CACA,iBAAiB;EAAE,QAAQ;EAAW,WAAW;CAAa;CAC9D,sBAAsB;EAAE,QAAQ;EAAW,WAAW;CAAa;AACrE;;AAGA,MAAa,6BAA6B;;;;;;;;AAS1C,SAAgB,iBAAiB,WAA+C;CAC9E,OAAO,OAAO,OAAO,sBAAsB,SAAS,IAChD,qBAAqB,aACrB;AACN"}
1
+ {"version":3,"file":"known-lifecycle.mjs","names":[],"sources":["../../../../../../../packages/ai-groq/src/known-lifecycle.ts"],"sourcesContent":["import type { ModelLifecycle } from \"@warlock.js/ai\";\n\n/**\n * Where Groq's deprecations page and model catalog put the chat models the\n * adapter knows, as of {@link GROQ_MODEL_LIFECYCLE_AS_OF}. `retired` ids\n * are past their shutdown date; Groq applies several of these shutdowns to\n * free and developer-tier usage only, so a committed-spend enterprise\n * contract can still serve them.\n *\n * Sources: https://console.groq.com/docs/deprecations and\n * https://console.groq.com/docs/models. Preview models (`qwen/qwen3.8-27b`,\n * `openai/gpt-oss-safeguard-20b`) are listed as `current` while Groq\n * serves them, but Groq may discontinue previews at short notice.\n */\nexport const GROQ_MODEL_LIFECYCLE: Readonly<Record<string, ModelLifecycle>> = {\n \"openai/gpt-oss-120b\": { status: \"current\" },\n \"openai/gpt-oss-20b\": { status: \"current\" },\n \"openai/gpt-oss-safeguard-20b\": { status: \"current\" },\n \"qwen/qwen3.8-27b\": { status: \"current\" },\n \"llama-3.3-70b-versatile\": {\n status: \"retired\",\n retiresOn: \"2026-08-16\",\n replacement: \"openai/gpt-oss-120b\",\n },\n \"llama-3.1-8b-instant\": {\n status: \"retired\",\n retiresOn: \"2026-08-16\",\n replacement: \"openai/gpt-oss-20b\",\n },\n \"deepseek-r1-distill-llama-70b\": {\n status: \"retired\",\n retiresOn: \"2025-10-02\",\n replacement: \"openai/gpt-oss-120b\",\n },\n \"qwen/qwen3.6-27b\": {\n status: \"retired\",\n retiresOn: \"2026-09-14\",\n replacement: \"qwen/qwen3.8-27b\",\n },\n \"qwen/qwen3-32b\": {\n status: \"retired\",\n retiresOn: \"2026-07-17\",\n replacement: \"openai/gpt-oss-120b\",\n },\n \"meta-llama/llama-4-scout-17b-16e-instruct\": {\n status: \"retired\",\n retiresOn: \"2026-07-17\",\n replacement: \"openai/gpt-oss-120b\",\n },\n \"meta-llama/llama-4-maverick-17b-128e-instruct\": {\n status: \"retired\",\n retiresOn: \"2026-03-09\",\n replacement: \"openai/gpt-oss-120b\",\n },\n \"moonshotai/kimi-k2-instruct-0905\": {\n status: \"retired\",\n retiresOn: \"2026-04-15\",\n replacement: \"openai/gpt-oss-120b\",\n },\n \"moonshotai/kimi-k2-instruct\": {\n status: \"retired\",\n retiresOn: \"2025-10-10\",\n replacement: \"openai/gpt-oss-120b\",\n },\n \"groq/compound\": { status: \"retired\", retiresOn: \"2026-09-21\" },\n \"groq/compound-mini\": { status: \"retired\", retiresOn: \"2026-09-21\" },\n};\n\n/** The date {@link GROQ_MODEL_LIFECYCLE} was last checked against Groq's deprecations page. */\nexport const GROQ_MODEL_LIFECYCLE_AS_OF = \"2026-11-06\";\n\n/**\n * Look up the lifecycle of a Groq model id (exact match), or `undefined`\n * when the table does not cover it.\n *\n * @example\n * groqLifecycleFor(\"llama-3.3-70b-versatile\"); // { status: \"retired\", retiresOn: \"2026-08-16\", … }\n */\nexport function groqLifecycleFor(modelName: string): ModelLifecycle | undefined {\n return Object.hasOwn(GROQ_MODEL_LIFECYCLE, modelName)\n ? GROQ_MODEL_LIFECYCLE[modelName]\n : undefined;\n}\n"],"mappings":";;;;;;;;;;;;;AAcA,MAAa,uBAAiE;CAC5E,uBAAuB,EAAE,QAAQ,UAAU;CAC3C,sBAAsB,EAAE,QAAQ,UAAU;CAC1C,gCAAgC,EAAE,QAAQ,UAAU;CACpD,oBAAoB,EAAE,QAAQ,UAAU;CACxC,2BAA2B;EACzB,QAAQ;EACR,WAAW;EACX,aAAa;CACf;CACA,wBAAwB;EACtB,QAAQ;EACR,WAAW;EACX,aAAa;CACf;CACA,iCAAiC;EAC/B,QAAQ;EACR,WAAW;EACX,aAAa;CACf;CACA,oBAAoB;EAClB,QAAQ;EACR,WAAW;EACX,aAAa;CACf;CACA,kBAAkB;EAChB,QAAQ;EACR,WAAW;EACX,aAAa;CACf;CACA,6CAA6C;EAC3C,QAAQ;EACR,WAAW;EACX,aAAa;CACf;CACA,iDAAiD;EAC/C,QAAQ;EACR,WAAW;EACX,aAAa;CACf;CACA,oCAAoC;EAClC,QAAQ;EACR,WAAW;EACX,aAAa;CACf;CACA,+BAA+B;EAC7B,QAAQ;EACR,WAAW;EACX,aAAa;CACf;CACA,iBAAiB;EAAE,QAAQ;EAAW,WAAW;CAAa;CAC9D,sBAAsB;EAAE,QAAQ;EAAW,WAAW;CAAa;AACrE;;AAGA,MAAa,6BAA6B;;;;;;;;AAS1C,SAAgB,iBAAiB,WAA+C;CAC9E,OAAO,OAAO,OAAO,sBAAsB,SAAS,IAChD,qBAAqB,aACrB;AACN"}
@@ -1 +1 @@
1
- {"version":3,"file":"known-models.mjs","names":[],"sources":["../../../../../../../packages/ai-groq/src/known-models.ts"],"mappings":";;;;;;;;;;AASA,MAAa,gBAAgB;;;;;;;AAQ7B,MAAa,gBAAgB;;;;;;;;;;;;;;;;;;;;;;AAuB7B,MAAM,4BAA4B;CAChC;CACA;CACA;CACA;CACA;AACF;;;;;;;;;;;;;;;AAgBA,MAAM,+BAA+B;CACnC;CACA;CACA;CACA;CACA;AACF;;;;;;;;;;;;;;AAeA,SAAgB,sBAAsB,SAA0B;CAC9D,MAAM,aAAa,QAAQ,YAAY;CAEvC,OAAO,0BAA0B,MAAM,aAAa,WAAW,SAAS,QAAQ,CAAC;AACnF;;;;;;;;;;;;AAaA,SAAgB,yBAAyB,SAA0B;CACjE,MAAM,aAAa,QAAQ,YAAY;CAEvC,OAAO,6BAA6B,MAAM,aAAa,WAAW,SAAS,QAAQ,CAAC;AACtF;;;;;;;;;;;;;AAcA,MAAa,oBAAoB;CAC/B;CACA;CACA;AACF"}
1
+ {"version":3,"file":"known-models.mjs","names":[],"sources":["../../../../../../../packages/ai-groq/src/known-models.ts"],"sourcesContent":["/**\n * Default base URL for Groq's OpenAI-compatible Chat Completions\n * endpoint. Groq exposes the same wire protocol as OpenAI under this\n * prefix, which is exactly why `GroqSDK` can delegate to the\n * battle-tested `OpenAISDK` instead of reimplementing the transport.\n *\n * Verified against Groq's \"OpenAI Compatibility\" docs (mid-2026).\n * Override via `new GroqSDK({ baseURL })` if Groq ever relocates it.\n */\nexport const GROQ_BASE_URL = \"https://api.groq.com/openai/v1\";\n\n/**\n * The provider label every model produced by `GroqSDK` self-identifies\n * with. Flows through to `ModelContract.provider`, `AgentReport.model`,\n * logs, and any provider-aware middleware. Kept as a constant so the\n * wrapper and the inner `OpenAISDK` agree on one spelling.\n */\nexport const GROQ_PROVIDER = \"groq\";\n\n/**\n * Substrings identifying Groq-hosted model ids whose family accepts\n * image input (vision).\n *\n * Groq hosts *open* models on its LPU hardware, so the ids are the\n * upstream open-weight names rather than OpenAI's — which is why the\n * OpenAI adapter's `gpt-4o*` prefix inference would never fire here and\n * this provider must carry its OWN list. Verified against Groq's\n * supported-models catalog (mid-2026):\n *\n * - `openai/gpt-oss-*` — natively multimodal OpenAI open-weight family\n * (the current production vision + reasoning models on Groq).\n * - `llama-4` / `llama-3.2-*-vision` — Meta's multimodal Llama families.\n * Kept as substrings so any still-hosted or re-introduced variant is\n * covered even though some `llama-4` ids were deprecated in 2026.\n *\n * Matched as a substring (not a prefix) because Groq prefixes several\n * ids with an org segment (`openai/`, `meta-llama/`) and appends size /\n * date suffixes. Override per-model via\n * `groq.model({ name, vision: true | false })`.\n */\nconst VISION_CAPABLE_SUBSTRINGS = [\n \"gpt-oss\",\n \"llama-4\",\n \"llama-3.2-11b-vision\",\n \"llama-3.2-90b-vision\",\n \"vision\",\n];\n\n/**\n * Substrings identifying Groq-hosted model ids that expose an internal\n * reasoning / thinking channel and accept the `reasoning_effort`\n * request parameter on the OpenAI-compatible Chat Completions endpoint.\n *\n * Verified against Groq's catalog (mid-2026):\n * - `gpt-oss` — the OpenAI open-weight family reasons by default.\n * - `deepseek-r1-distill` — DeepSeek-R1-style reasoning at Groq speed.\n * - `qwq` / `qwen3` — Qwen reasoning families (when hosted).\n *\n * Matched as a substring for the same org-prefix / suffix reason as the\n * vision list. Override per-model via\n * `groq.model({ name, reasoning: true | false })`.\n */\nconst REASONING_CAPABLE_SUBSTRINGS = [\n \"gpt-oss\",\n \"deepseek-r1\",\n \"deepseek-r1-distill\",\n \"qwq\",\n \"qwen3\",\n];\n\n/**\n * Infer whether a Groq-hosted model id supports vision based on the\n * known multimodal-family substrings. Unknown ids default to `false`\n * so passing an image attachment to a text-only model (e.g.\n * `llama-3.3-70b-versatile`) surfaces a clear, agent-side capability\n * error instead of an opaque upstream 400.\n *\n * @example\n * inferVisionCapability(\"openai/gpt-oss-120b\"); // → true\n * inferVisionCapability(\"meta-llama/llama-4-scout\"); // → true\n * inferVisionCapability(\"llama-3.3-70b-versatile\"); // → false\n * inferVisionCapability(\"llama-3.1-8b-instant\"); // → false\n */\nexport function inferVisionCapability(modelId: string): boolean {\n const normalized = modelId.toLowerCase();\n\n return VISION_CAPABLE_SUBSTRINGS.some((fragment) => normalized.includes(fragment));\n}\n\n/**\n * Infer whether a Groq-hosted model id is a reasoning model based on\n * the known reasoning-family substrings. Unknown ids default to `false`\n * so the adapter never forwards an unsupported `reasoning_effort` param\n * to a non-reasoning model (which would 400).\n *\n * @example\n * inferReasoningCapability(\"openai/gpt-oss-20b\"); // → true\n * inferReasoningCapability(\"deepseek-r1-distill-llama-70b\"); // → true\n * inferReasoningCapability(\"llama-3.3-70b-versatile\"); // → false\n */\nexport function inferReasoningCapability(modelId: string): boolean {\n const normalized = modelId.toLowerCase();\n\n return REASONING_CAPABLE_SUBSTRINGS.some((fragment) => normalized.includes(fragment));\n}\n\n/**\n * Curated list of current Groq chat model ids, for autocomplete, docs, and\n * default selection. NOT exhaustive and NOT a runtime allow-list —\n * `groq.model({ name })` accepts any string, so a newly launched id works\n * the moment Groq ships it without a package bump. Ids Groq has shut down\n * are left out here and recorded as `retired` in\n * {@link GROQ_MODEL_LIFECYCLE}.\n *\n * - `openai/gpt-oss-120b` / `openai/gpt-oss-20b` — OpenAI open-weight\n * family; vision + reasoning capable.\n * - `qwen/qwen3.8-27b` — Qwen 3.8 (a preview model on Groq).\n */\nexport const GROQ_KNOWN_MODELS = [\n \"openai/gpt-oss-120b\",\n \"openai/gpt-oss-20b\",\n \"qwen/qwen3.8-27b\",\n] as const;\n"],"mappings":";;;;;;;;;;AASA,MAAa,gBAAgB;;;;;;;AAQ7B,MAAa,gBA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,aAAa,yBAAyB,OAAO,IAAI;GACnE,kBAAkB,OAAO,oBAAoB;GAC7C,SAAS;EACX,CAAC;CACH;;;;;;;CAQA,MAAa,MAAM,MAAc,OAAiC;EAChE,OAAO,KAAK,OAAO,MAAM,MAAM,KAAK;CACtC;;;;;;;;;;;CAYA,AAAO,SAAS,QAA8C;EAC5D,OAAO,KAAK,OAAO,SAAS,MAAM;CACpC;;;;;;;;;;;CAiBA,MAAa,OAAO,SAAmD;EACrE,OAAO,KAAK,OAAO,OAAO,OAAO;CACnC;AACF;;;;;;;;AASA,SAAS,kBAAkB,MAAwC;CACjE,OAAO,qBAAqB;AAC9B;;AAGA,MAAa,6BAA6B;;;;;;;;;;;AAY1C,MAAa,uBAA+D;CAC1E,uBAAuB;EAAE,OAAO;EAAM,QAAQ;EAAK,aAAa;CAAM;CACtE,sBAAsB;EAAE,OAAO;EAAO,QAAQ;EAAK,aAAa;CAAO;CACvE,gCAAgC;EAAE,OAAO;EAAO,QAAQ;EAAK,aAAa;CAAO;CACjF,oBAAoB;EAAE,OAAO;EAAK,QAAQ;CAAE;AAC9C"}
1
+ {"version":3,"file":"sdk.mjs","names":[],"sources":["../../../../../../../packages/ai-groq/src/sdk.ts"],"sourcesContent":["import type {\n ListModelsOptions,\n ModelInfo,\n EmbedderContract,\n ModelContract,\n ModelPricing,\n SDKAdapterContract,\n} from \"@warlock.js/ai\";\nimport { OpenAISDK } from \"@warlock.js/ai-openai\";\nimport type { GroqEmbedderConfig, GroqModelConfig, GroqSDKConfig } from \"./config.type\";\nimport { inferContextWindow } from \"./known-context-windows\";\nimport {\n GROQ_BASE_URL,\n GROQ_PROVIDER,\n inferReasoningCapability,\n inferVisionCapability,\n} from \"./known-models\";\n\n/**\n * Groq-backed implementation of `SDKAdapterContract`.\n *\n * **Role.** The package entry point for Groq-hosted open models\n * (`llama-3.3-70b-versatile`, `llama-3.1-8b-instant`,\n * `openai/gpt-oss-*`, `deepseek-r1-distill-*`, …) served on Groq's fast\n * LPU hardware. Because Groq exposes the OpenAI Chat Completions wire\n * protocol verbatim, `GroqSDK` is a **thin wrapper over the already\n * battle-tested {@link OpenAISDK}** rather than a fresh transport\n * implementation — it owns one internal `OpenAISDK` pointed at Groq's\n * `baseURL` with the `\"groq\"` provider label, and delegates `model()` /\n * `embedder()` / `count()` to it.\n *\n * **Why a wrapper and not `OpenAISDK` directly?** Groq hosts *open*\n * models whose ids are the upstream open-weight names (`llama-…`,\n * `openai/gpt-oss-…`), not OpenAI's (`gpt-4o`, `o3`). The OpenAI\n * adapter's capability inference keys on OpenAI prefixes and would never\n * fire here, so every Groq model would come back with `vision`/\n * `reasoning` silently `false`. `GroqSDK` fixes that by computing\n * **this provider's own** vision/reasoning inference (see\n * `known-models.ts`) and injecting the result as explicit capability\n * config — which wins over the inner adapter's inference — plus a set of\n * default per-model pricing rates. Everything else (transport, retries,\n * streaming, structured output, error wrapping, usage accounting) is\n * inherited unchanged from `OpenAISDK`.\n *\n * **Responsibility.**\n * - Owns: one long-lived internal `OpenAISDK` (auth + Groq base URL) and\n * this provider's capability + default-pricing inference.\n * - Does NOT own: the wire protocol, streaming loop, structured-output\n * mapping, or error wrapping — all inherited from `OpenAISDK`.\n *\n * Modeled as a class (see §4.2 of code-style.md — \"long-lived state\n * across many calls\"), fronted by FP usage like the other adapters.\n *\n * @example\n * const groq = new GroqSDK({ apiKey: process.env.GROQ_API_KEY! });\n * const model = groq.model({ name: \"llama-3.3-70b-versatile\", temperature: 0.7 });\n * const reasoner = groq.model({ name: \"openai/gpt-oss-120b\" }); // vision + reasoning auto-true\n *\n * @example\n * // Compose into an `ai.groq` namespace for ergonomic agent wiring\n * const ai = { agent, tool, systemPrompt, groq: new GroqSDK({ apiKey }) };\n * const myAgent = ai.agent({ model: ai.groq.model({ name: \"llama-3.1-8b-instant\" }) });\n */\nexport class GroqSDK implements SDKAdapterContract {\n /**\n * The wrapped OpenAI-compatible adapter, pre-pointed at Groq's\n * `baseURL` and labeled with the `\"groq\"` provider. All real wire work\n * happens here; `GroqSDK` only enriches the per-model config before\n * delegating.\n */\n private readonly openai: OpenAISDK;\n private readonly provider: string;\n private readonly pricing?: Record<string, ModelPricing>;\n\n public constructor(config: GroqSDKConfig) {\n const { baseURL, provider, pricing, ...clientOptions } = config;\n\n this.provider = provider ?? GROQ_PROVIDER;\n this.pricing = pricing;\n\n // Build the inner OpenAI-compatible client pointed at Groq. Forward\n // every other upstream ClientOptions (timeout, maxRetries,\n // defaultHeaders, fetch, …) verbatim — they type-check, so dropping\n // them would be a silent footgun. We pass `pricing` through too so\n // the inner registry stays a fallback, while THIS class's `model()`\n // layers Groq default rates on top.\n this.openai = new OpenAISDK({\n ...clientOptions,\n baseURL: baseURL ?? GROQ_BASE_URL,\n provider: this.provider,\n pricing,\n });\n }\n\n /**\n * Build a `ModelContract` bound to the internal Groq-pointed client.\n *\n * The wrapper's whole job lives here: it computes **Groq's** vision /\n * reasoning inference from the model id and forwards the result as\n * *explicit* `vision` / `reasoning` config to the inner\n * `OpenAISDK.model()`. Because explicit capability config wins over the\n * inner adapter's OpenAI-prefix inference, the returned model reports\n * the right capabilities even though the id isn't an OpenAI name. A\n * caller-supplied `vision` / `reasoning` still wins over this\n * inference (we only fill the gap when the field is omitted).\n *\n * Pricing resolution: per-model `config.pricing` wins; otherwise this\n * SDK's `pricing` registry keyed by `config.name`; otherwise the\n * adapter's built-in default rate for the model; otherwise `undefined`\n * (no cost computed).\n */\n public model(config: GroqModelConfig): ModelContract {\n const resolvedPricing =\n config.pricing ?? this.pricing?.[config.name] ?? defaultPricingFor(config.name);\n\n const window = config.contextWindow ?? inferContextWindow(config.name);\n\n return this.openai.model({\n ...config,\n ...(window !== undefined ? { contextWindow: window } : {}),\n // Fill capability inference only when the caller didn't pin it —\n // explicit caller config always wins, then Groq inference, then\n // (inside OpenAISDK) the harmless OpenAI inference that won't match.\n vision: config.vision ?? inferVisionCapability(config.name),\n reasoning: config.reasoning ?? inferReasoningCapability(config.name),\n structuredOutput: config.structuredOutput ?? true,\n pricing: resolvedPricing,\n });\n }\n\n /**\n * Rough offline token-count estimate. Delegated straight to the inner\n * `OpenAISDK`, which uses the core character-heuristic\n * (`approximateTokenCount`). Good for budgeting / quota guards, not for\n * billing.\n */\n public async count(text: string, model?: string): Promise<number> {\n return this.openai.count(text, model);\n }\n\n /**\n * Build an embedder bound to the internal client. Delegated to the\n * inner `OpenAISDK`.\n *\n * IMPORTANT: as of mid-2026 Groq does **not** expose an\n * OpenAI-compatible embeddings endpoint, so a live `.embed()` /\n * `.embedMany()` call will fail at the provider. The method is kept for\n * adapter symmetry; use `@warlock.js/ai-openai` or\n * `@warlock.js/ai-google` for retrieval embeddings.\n */\n public embedder(config: GroqEmbedderConfig): EmbedderContract {\n return this.openai.embedder(config);\n }\n\n // NOTE: `image()` is intentionally NOT implemented. Groq hosts no\n // image-generation API, and `SDKAdapterContract.image` is optional —\n // its structural absence IS the capability guard, so\n // `ai.groq.image(...)` is a compile-time error rather than a runtime\n // surprise (mirrors Anthropic / Bedrock / Ollama).\n /**\n * List the models this Groq account can use, live from the provider's\n * OpenAI-compatible `GET /models`, mapped to the common `ModelInfo`\n * shape. Groq models marked inactive are left out; `contextWindow` comes from `context_window`. Failures are thrown as the adapter's usual provider\n * errors, never an empty list.\n *\n * @example\n * const models = await groq.models();\n * models.map((model) => model.id);\n */\n public async models(options?: ListModelsOptions): Promise<ModelInfo[]> {\n return this.openai.models(options);\n }\n}\n\n/**\n * Built-in default USD-per-1,000,000-token rates for the Groq models with\n * a published price, used as the last fallback in `model()`'s pricing\n * resolution. A per-model or SDK-level `pricing` entry always wins over\n * these. Returns `undefined` for any unlisted id so cost stays an honest\n * absence rather than a false zero.\n */\nfunction defaultPricingFor(name: string): ModelPricing | undefined {\n return GROQ_DEFAULT_PRICING[name];\n}\n\n/** The date the {@link GROQ_DEFAULT_PRICING} token rates were last checked against Groq's model page. */\nexport const GROQ_DEFAULT_PRICING_AS_OF = \"2026-11-06\";\n\n/**\n * Default per-million-token USD rates for Groq models.\n *\n * Source: https://console.groq.com/docs/models (groq.com/pricing now\n * redirects to the home page), as of {@link GROQ_DEFAULT_PRICING_AS_OF}. Cached input is 50%\n * of the input rate for the gpt-oss models, the only ones Groq caches\n * (https://console.groq.com/docs/prompt-caching, checked 2026-10-17; no write charge). The\n * Llama models are listed as \"Enterprise – Contact Sales\" with no public\n * price, so they stay unpriced — pass `pricing` for them.\n */\nexport const GROQ_DEFAULT_PRICING: Readonly<Record<string, ModelPricing>> = {\n \"openai/gpt-oss-120b\": { input: 0.15, output: 0.6, cachedInput: 0.075 },\n \"openai/gpt-oss-20b\": { input: 0.075, output: 0.3, cachedInput: 0.0375 },\n \"openai/gpt-oss-safeguard-20b\": { input: 0.075, output: 0.3, cachedInput: 0.0375 },\n \"qwen/qwen3.8-27b\": { input: 0.8, output: 4 },\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+DA,IAAa,UAAb,MAAmD;CAWjD,AAAO,YAAY,QAAuB;EACxC,MAAM,EAAE,SAAS,UAAU,SAAS,GAAG,kBAAkB;EAEzD,KAAK,WAAW;EAChB,KAAK,UAAU;EAQf,KAAK,SAAS,IAAI,UAAU;GAC1B,GAAG;GACH,SAAS;GACT,UAAU,KAAK;GACf;EACF,CAAC;CACH;;;;;;;;;;;;;;;;;;CAmBA,AAAO,MAAM,QAAwC;EACnD,MAAM,kBACJ,OAAO,WAAW,KAAK,UAAU,OAAO,SAAS,kBAAkB,OAAO,IAAI;EAEhF,MAAM,SAAS,OAAO,iBAAiB,mBAAmB,OAAO,IAAI;EAErE,OAAO,KAAK,OAAO,MAAM;GACvB,GAAG;GACH,GAAI,WAAW,SAAY,EAAE,eAAe,OAAO,IAAI,CAAC;GAIxD,QAAQ,OAAO,UAAU,sBAAsB,OAAO,IAAI;GAC1D,WAAW,OAAO,aAAa,yBAAyB,OAAO,IAAI;GACnE,kBAAkB,OAAO,oBAAoB;GAC7C,SAAS;EACX,CAAC;CACH;;;;;;;CAQA,MAAa,MAAM,MAAc,OAAiC;EAChE,OAAO,KAAK,OAAO,MAAM,MAAM,KAAK;CACtC;;;;;;;;;;;CAYA,AAAO,SAAS,QAA8C;EAC5D,OAAO,KAAK,OAAO,SAAS,MAAM;CACpC;;;;;;;;;;;CAiBA,MAAa,OAAO,SAAmD;EACrE,OAAO,KAAK,OAAO,OAAO,OAAO;CACnC;AACF;;;;;;;;AASA,SAAS,kBAAkB,MAAwC;CACjE,OAAO,qBAAqB;AAC9B;;AAGA,MAAa,6BAA6B;;;;;;;;;;;AAY1C,MAAa,uBAA+D;CAC1E,uBAAuB;EAAE,OAAO;EAAM,QAAQ;EAAK,aAAa;CAAM;CACtE,sBAAsB;EAAE,OAAO;EAAO,QAAQ;EAAK,aAAa;CAAO;CACvE,gCAAgC;EAAE,OAAO;EAAO,QAAQ;EAAK,aAAa;CAAO;CACjF,oBAAoB;EAAE,OAAO;EAAK,QAAQ;CAAE;AAC9C"}
package/package.json CHANGED
@@ -16,13 +16,13 @@
16
16
  "directory": "packages/ai-groq"
17
17
  },
18
18
  "peerDependencies": {
19
- "@warlock.js/ai": "5.53.0"
19
+ "@warlock.js/ai": "5.54.0"
20
20
  },
21
21
  "dependencies": {
22
- "@warlock.js/ai-openai": "5.53.0",
23
- "@warlock.js/logger": "5.53.0"
22
+ "@warlock.js/ai-openai": "5.54.0",
23
+ "@warlock.js/logger": "5.54.0"
24
24
  },
25
- "version": "5.53.0",
25
+ "version": "5.54.0",
26
26
  "main": "./cjs/index.cjs",
27
27
  "module": "./esm/index.mjs",
28
28
  "types": "./esm/index.d.mts",