@warlock.js/ai-groq 5.43.0 → 5.45.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/CHANGELOG.md CHANGED
@@ -4,6 +4,12 @@ All notable changes to `@warlock.js/ai-groq` are documented in this file.
4
4
 
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). `@warlock.js/*` packages are released in lockstep — every package shares the same version number, so a version below may list only the changes that affected this package.
6
6
 
7
+ ## 5.45.0 - 2026-11-05
8
+
9
+ ### Added
10
+
11
+ - `capabilities.contextWindow` is reported for Groq-hosted Llama, gpt-oss, Qwen3 and DeepSeek-R1 distill ids (131,072) and Kimi K2 (262,144). New `contextWindow` option on `groq.model`.
12
+
7
13
  ## 5.40.0 - 2026-10-29
8
14
 
9
15
  ### Added
package/cjs/index.cjs CHANGED
@@ -1,6 +1,33 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  let _warlock_js_ai_openai = require("@warlock.js/ai-openai");
3
3
 
4
+ //#region ../../packages/ai-groq/src/known-context-windows.ts
5
+ const KNOWN_WINDOWS = [
6
+ ["llama-3", 131072],
7
+ ["llama-4", 131072],
8
+ ["gpt-oss", 131072],
9
+ ["qwen3", 131072],
10
+ ["deepseek-r1-distill", 131072],
11
+ ["kimi-k2", 262144]
12
+ ];
13
+ /**
14
+ * The known context window (tokens, input plus output) of a Groq-hosted chat
15
+ * model id, or `undefined` when it is not in the table.
16
+ *
17
+ * @example
18
+ * inferContextWindow("llama-3"); // → 131072
19
+ */
20
+ function inferContextWindow(modelId) {
21
+ const id = modelId.toLowerCase();
22
+ let best;
23
+ for (const entry of KNOWN_WINDOWS) {
24
+ const fragment = entry[0];
25
+ if (id.includes(fragment) && (!best || fragment.length > best[0].length)) best = entry;
26
+ }
27
+ return best?.[1];
28
+ }
29
+
30
+ //#endregion
4
31
  //#region ../../packages/ai-groq/src/known-models.ts
5
32
  /**
6
33
  * Default base URL for Groq's OpenAI-compatible Chat Completions
@@ -200,8 +227,10 @@ var GroqSDK = class {
200
227
  */
201
228
  model(config) {
202
229
  const resolvedPricing = config.pricing ?? this.pricing?.[config.name] ?? defaultPricingFor(config.name);
230
+ const window = config.contextWindow ?? inferContextWindow(config.name);
203
231
  return this.openai.model({
204
232
  ...config,
233
+ ...window !== void 0 ? { contextWindow: window } : {},
205
234
  vision: config.vision ?? inferVisionCapability(config.name),
206
235
  reasoning: config.reasoning ?? inferReasoningCapability(config.name),
207
236
  structuredOutput: config.structuredOutput ?? true,
package/cjs/index.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["OpenAISDK"],"sources":["../../../../../../../packages/ai-groq/src/known-models.ts","../../../../../../../packages/ai-groq/src/sdk.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 production chat model ids (mid-2026),\n * for autocomplete, docs, and default selection. NOT exhaustive and NOT\n * a runtime allow-list — `groq.model({ name })` accepts any string, so\n * a newly launched id works the moment Groq ships it without a package\n * bump. Deprecated ids (e.g. several `llama-4` variants retired in 2026)\n * are intentionally excluded.\n *\n * - `llama-3.3-70b-versatile` — flagship general-purpose text model.\n * - `llama-3.1-8b-instant` — fastest/cheapest small text model.\n * - `openai/gpt-oss-120b` / `openai/gpt-oss-20b` — OpenAI open-weight\n * family; vision + reasoning capable.\n * - `deepseek-r1-distill-llama-70b` — DeepSeek-R1-style reasoning.\n */\nexport const GROQ_KNOWN_MODELS = [\n \"llama-3.3-70b-versatile\",\n \"llama-3.1-8b-instant\",\n \"openai/gpt-oss-120b\",\n \"openai/gpt-oss-20b\",\n \"deepseek-r1-distill-llama-70b\",\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 {\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 return this.openai.model({\n ...config,\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/**\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), fetched 2026-10-17. 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; 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":";;;;;;;;;;;;;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;;;;;;;;;;;;;;;AAgBA,MAAa,oBAAoB;CAC/B;CACA;CACA;CACA;CACA;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AChEA,IAAa,UAAb,MAAmD;CAWjD,AAAO,YAAY,QAAuB;EACxC,MAAM,EAAE,SAAS,UAAU,SAAS,GAAG,kBAAkB;EAEzD,KAAK,WAAW;EAChB,KAAK,UAAU;EAQf,KAAK,SAAS,IAAIA,gCAAU;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,OAAO,KAAK,OAAO,MAAM;GACvB,GAAG;GAIH,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;;;;;;;;;;;AAYA,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":"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"],"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 production chat model ids (mid-2026),\n * for autocomplete, docs, and default selection. NOT exhaustive and NOT\n * a runtime allow-list — `groq.model({ name })` accepts any string, so\n * a newly launched id works the moment Groq ships it without a package\n * bump. Deprecated ids (e.g. several `llama-4` variants retired in 2026)\n * are intentionally excluded.\n *\n * - `llama-3.3-70b-versatile` — flagship general-purpose text model.\n * - `llama-3.1-8b-instant` — fastest/cheapest small text model.\n * - `openai/gpt-oss-120b` / `openai/gpt-oss-20b` — OpenAI open-weight\n * family; vision + reasoning capable.\n * - `deepseek-r1-distill-llama-70b` — DeepSeek-R1-style reasoning.\n */\nexport const GROQ_KNOWN_MODELS = [\n \"llama-3.3-70b-versatile\",\n \"llama-3.1-8b-instant\",\n \"openai/gpt-oss-120b\",\n \"openai/gpt-oss-20b\",\n \"deepseek-r1-distill-llama-70b\",\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/**\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), fetched 2026-10-17. 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; 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":";;;;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,aAAa,WAAW,SAAS,QAAQ,CAAC;AACtF;;;;;;;;;;;;;;;AAgBA,MAAa,oBAAoB;CAC/B;CACA;CACA;CACA;CACA;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC/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,IAAIA,gCAAU;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;;;;;;;;;;;AAYA,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"}
@@ -75,6 +75,14 @@ export type GroqSDKConfig = Omit<OpenAISDKConfig, "baseURL" | "provider"> & {
75
75
  * groq.model({ name: "custom-llama", vision: true }); // explicit override
76
76
  */
77
77
  export type GroqModelConfig = ModelConfig & {
78
+ /**
79
+ * The model's context window in tokens (input + output). Surfaces as
80
+ * `capabilities.contextWindow`, which window-relative triggers
81
+ * (`compaction.afterTokens: { share }`) resolve against. When omitted it is
82
+ * taken from a table of known models; unknown models stay unset. An
83
+ * explicit value always wins.
84
+ */
85
+ contextWindow?: number;
78
86
  /**
79
87
  * Override the auto-inferred vision capability. When omitted, the
80
88
  * adapter checks the model id against Groq's known multimodal families
@@ -1 +1 @@
1
- {"version":3,"file":"config.type.d.mts","names":[],"sources":["../../../../../../../packages/ai-groq/src/config.type.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAsCY,gBAAgB,KAAK;;;;;;EAM/B;;;;;;EAMA;;;;;;;EAOA,UAAU,eAAe;;;;;;;;;;;;;;;;;;;YAoBf,kBAAkB;;;;;;;;EAQ5B;;;;;;;;;EASA;;;;;;;;EAQA;;;;;;;;;;;;;;;;YAiBU,qBAAqB"}
1
+ {"version":3,"file":"config.type.d.mts","names":[],"sources":["../../../../../../../packages/ai-groq/src/config.type.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAsCY,gBAAgB,KAAK;;;;;;EAM/B;;;;;;EAMA;;;;;;;EAOA,UAAU,eAAe;;;;;;;;;;;;;;;;;;;YAoBf,kBAAkB;;;;;;;;EAQ5B;;;;;;;;EAQA;;;;;;;;;EASA;;;;;;;;EAQA;;;;;;;;;;;;;;;;YAiBU,qBAAqB"}
@@ -0,0 +1,29 @@
1
+ //#region ../../packages/ai-groq/src/known-context-windows.ts
2
+ const KNOWN_WINDOWS = [
3
+ ["llama-3", 131072],
4
+ ["llama-4", 131072],
5
+ ["gpt-oss", 131072],
6
+ ["qwen3", 131072],
7
+ ["deepseek-r1-distill", 131072],
8
+ ["kimi-k2", 262144]
9
+ ];
10
+ /**
11
+ * The known context window (tokens, input plus output) of a Groq-hosted chat
12
+ * model id, or `undefined` when it is not in the table.
13
+ *
14
+ * @example
15
+ * inferContextWindow("llama-3"); // → 131072
16
+ */
17
+ function inferContextWindow(modelId) {
18
+ const id = modelId.toLowerCase();
19
+ let best;
20
+ for (const entry of KNOWN_WINDOWS) {
21
+ const fragment = entry[0];
22
+ if (id.includes(fragment) && (!best || fragment.length > best[0].length)) best = entry;
23
+ }
24
+ return best?.[1];
25
+ }
26
+
27
+ //#endregion
28
+ export { inferContextWindow };
29
+ //# sourceMappingURL=known-context-windows.mjs.map
@@ -0,0 +1 @@
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"}
package/esm/sdk.d.mts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"sdk.d.mts","names":[],"sources":["../../../../../../../packages/ai-groq/src/sdk.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBA8Da,mBAAmB;;;;;;;mBAOb;mBACA;mBACA;EAEjB,YAAmB,QAAQ;;;;;;;;;;;;;;;;;;EAqCpB,MAAM,QAAQ,kBAAkB;;;;;;;EAsB1B,MAAM,cAAc,iBAAiB;;;;;;;;;;;EAc3C,SAAS,QAAQ,qBAAqB;;;;;;;;;;;EAmBhC,OAAO,UAAU,oBAAoB,QAAQ;;;;;;;;;;;;qBA0B/C,sBAAsB,SAAS,eAAe"}
1
+ {"version":3,"file":"sdk.d.mts","names":[],"sources":["../../../../../../../packages/ai-groq/src/sdk.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBA+Da,mBAAmB;;;;;;;mBAOb;mBACA;mBACA;EAEjB,YAAmB,QAAQ;;;;;;;;;;;;;;;;;;EAqCpB,MAAM,QAAQ,kBAAkB;;;;;;;EAyB1B,MAAM,cAAc,iBAAiB;;;;;;;;;;;EAc3C,SAAS,QAAQ,qBAAqB;;;;;;;;;;;EAmBhC,OAAO,UAAU,oBAAoB,QAAQ;;;;;;;;;;;;qBA0B/C,sBAAsB,SAAS,eAAe"}
package/esm/sdk.mjs CHANGED
@@ -1,3 +1,4 @@
1
+ import { inferContextWindow } from "./known-context-windows.mjs";
1
2
  import { GROQ_BASE_URL, GROQ_PROVIDER, inferReasoningCapability, inferVisionCapability } from "./known-models.mjs";
2
3
  import { OpenAISDK } from "@warlock.js/ai-openai";
3
4
 
@@ -78,8 +79,10 @@ var GroqSDK = class {
78
79
  */
79
80
  model(config) {
80
81
  const resolvedPricing = config.pricing ?? this.pricing?.[config.name] ?? defaultPricingFor(config.name);
82
+ const window = config.contextWindow ?? inferContextWindow(config.name);
81
83
  return this.openai.model({
82
84
  ...config,
85
+ ...window !== void 0 ? { contextWindow: window } : {},
83
86
  vision: config.vision ?? inferVisionCapability(config.name),
84
87
  reasoning: config.reasoning ?? inferReasoningCapability(config.name),
85
88
  structuredOutput: config.structuredOutput ?? true,
package/esm/sdk.mjs.map CHANGED
@@ -1 +1 @@
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 {\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 return this.openai.model({\n ...config,\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/**\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), fetched 2026-10-17. 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; 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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8DA,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,OAAO,KAAK,OAAO,MAAM;GACvB,GAAG;GAIH,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;;;;;;;;;;;AAYA,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/**\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), fetched 2026-10-17. 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; 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;;;;;;;;;;;AAYA,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/llms-full.txt CHANGED
@@ -151,4 +151,8 @@ Models from this adapter have no native `countTokens` method. Check
151
151
 
152
152
  `await groq.models()` returns `ModelInfo[]` with `contextWindow`; inactive models are left out.
153
153
 
154
+ ## Context window
155
+
156
+ Groq ids report `capabilities.contextWindow` (131,072 for Llama, gpt-oss, Qwen3 and DeepSeek-R1 distill, 262,144 for Kimi K2); `groq.model({ name, contextWindow })` wins.
157
+
154
158
 
package/package.json CHANGED
@@ -16,13 +16,13 @@
16
16
  "directory": "packages/ai-groq"
17
17
  },
18
18
  "peerDependencies": {
19
- "@warlock.js/ai": "5.43.0"
19
+ "@warlock.js/ai": "5.45.0"
20
20
  },
21
21
  "dependencies": {
22
- "@warlock.js/ai-openai": "5.43.0",
23
- "@warlock.js/logger": "5.43.0"
22
+ "@warlock.js/ai-openai": "5.45.0",
23
+ "@warlock.js/logger": "5.45.0"
24
24
  },
25
- "version": "5.43.0",
25
+ "version": "5.45.0",
26
26
  "main": "./cjs/index.cjs",
27
27
  "module": "./esm/index.mjs",
28
28
  "types": "./esm/index.d.mts",
package/skills/SKILL.md CHANGED
@@ -142,3 +142,7 @@ Models from this adapter have no native `countTokens` method. Check
142
142
  ## List models
143
143
 
144
144
  `await groq.models()` returns `ModelInfo[]` with `contextWindow`; inactive models are left out.
145
+
146
+ ## Context window
147
+
148
+ Groq ids report `capabilities.contextWindow` (131,072 for Llama, gpt-oss, Qwen3 and DeepSeek-R1 distill, 262,144 for Kimi K2); `groq.model({ name, contextWindow })` wins.