@warlock.js/ai-groq 4.8.2 → 4.9.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 CHANGED
@@ -1,7 +1,7 @@
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 ../@warlock.js/ai-groq/src/known-models.ts
4
+ //#region ../ai-groq/src/known-models.ts
5
5
  /**
6
6
  * Default base URL for Groq's OpenAI-compatible Chat Completions
7
7
  * endpoint. Groq exposes the same wire protocol as OpenAI under this
@@ -123,7 +123,7 @@ const GROQ_KNOWN_MODELS = [
123
123
  ];
124
124
 
125
125
  //#endregion
126
- //#region ../@warlock.js/ai-groq/src/sdk.ts
126
+ //#region ../ai-groq/src/sdk.ts
127
127
  /**
128
128
  * Groq-backed implementation of `SDKAdapterContract`.
129
129
  *
package/cjs/index.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["OpenAISDK"],"sources":["../../../../../../@warlock.js/ai-groq/src/known-models.ts","../../../../../../@warlock.js/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 EmbedderContract,\n ModelContract,\n ModelPricing,\n SDKAdapterContract,\n} from \"@warlock.js/ai\";\nimport { OpenAISDK } from \"@warlock.js/ai-openai\";\nimport type {\n GroqEmbedderConfig,\n GroqModelConfig,\n GroqSDKConfig,\n} 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\n/**\n * Built-in default USD-per-1,000,000-token rates for the current Groq\n * production models (mid-2026), used as the last fallback in `model()`'s\n * pricing resolution. A per-model or SDK-level `pricing` entry always\n * wins over these. Returns `undefined` for any unlisted id so cost stays\n * an honest absence rather than a false zero. Update when Groq revises\n * its public price list.\n */\nfunction defaultPricingFor(name: string): ModelPricing | undefined {\n return GROQ_DEFAULT_PRICING[name];\n}\n\n/**\n * Default per-million-token USD rates for known Groq models. Kept inline\n * (not exported) so the public surface stays the inference helpers; a\n * caller who wants different numbers supplies `pricing` on the SDK or\n * per model.\n */\nconst GROQ_DEFAULT_PRICING: Record<string, ModelPricing> = {\n \"llama-3.3-70b-versatile\": { input: 0.59, output: 0.79 },\n \"llama-3.1-8b-instant\": { input: 0.05, output: 0.08 },\n \"openai/gpt-oss-120b\": { input: 0.15, output: 0.75 },\n \"openai/gpt-oss-20b\": { input: 0.1, output: 0.5 },\n \"deepseek-r1-distill-llama-70b\": { input: 0.75, output: 0.99 },\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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC9DA,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;AAOF;;;;;;;;;AAUA,SAAS,kBAAkB,MAAwC;CACjE,OAAO,qBAAqB;AAC9B;;;;;;;AAQA,MAAM,uBAAqD;CACzD,2BAA2B;EAAE,OAAO;EAAM,QAAQ;CAAK;CACvD,wBAAwB;EAAE,OAAO;EAAM,QAAQ;CAAK;CACpD,uBAAuB;EAAE,OAAO;EAAM,QAAQ;CAAK;CACnD,sBAAsB;EAAE,OAAO;EAAK,QAAQ;CAAI;CAChD,iCAAiC;EAAE,OAAO;EAAM,QAAQ;CAAK;AAC/D"}
1
+ {"version":3,"file":"index.cjs","names":["OpenAISDK"],"sources":["../../../../../../ai-groq/src/known-models.ts","../../../../../../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 EmbedderContract,\n ModelContract,\n ModelPricing,\n SDKAdapterContract,\n} from \"@warlock.js/ai\";\nimport { OpenAISDK } from \"@warlock.js/ai-openai\";\nimport type {\n GroqEmbedderConfig,\n GroqModelConfig,\n GroqSDKConfig,\n} 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\n/**\n * Built-in default USD-per-1,000,000-token rates for the current Groq\n * production models (mid-2026), used as the last fallback in `model()`'s\n * pricing resolution. A per-model or SDK-level `pricing` entry always\n * wins over these. Returns `undefined` for any unlisted id so cost stays\n * an honest absence rather than a false zero. Update when Groq revises\n * its public price list.\n */\nfunction defaultPricingFor(name: string): ModelPricing | undefined {\n return GROQ_DEFAULT_PRICING[name];\n}\n\n/**\n * Default per-million-token USD rates for known Groq models. Kept inline\n * (not exported) so the public surface stays the inference helpers; a\n * caller who wants different numbers supplies `pricing` on the SDK or\n * per model.\n */\nconst GROQ_DEFAULT_PRICING: Record<string, ModelPricing> = {\n \"llama-3.3-70b-versatile\": { input: 0.59, output: 0.79 },\n \"llama-3.1-8b-instant\": { input: 0.05, output: 0.08 },\n \"openai/gpt-oss-120b\": { input: 0.15, output: 0.75 },\n \"openai/gpt-oss-20b\": { input: 0.1, output: 0.5 },\n \"deepseek-r1-distill-llama-70b\": { input: 0.75, output: 0.99 },\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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC9DA,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;AAOF;;;;;;;;;AAUA,SAAS,kBAAkB,MAAwC;CACjE,OAAO,qBAAqB;AAC9B;;;;;;;AAQA,MAAM,uBAAqD;CACzD,2BAA2B;EAAE,OAAO;EAAM,QAAQ;CAAK;CACvD,wBAAwB;EAAE,OAAO;EAAM,QAAQ;CAAK;CACpD,uBAAuB;EAAE,OAAO;EAAM,QAAQ;CAAK;CACnD,sBAAsB;EAAE,OAAO;EAAK,QAAQ;CAAI;CAChD,iCAAiC;EAAE,OAAO;EAAM,QAAQ;CAAK;AAC/D"}
@@ -1,7 +1,7 @@
1
1
  import { OpenAISDKConfig } from "@warlock.js/ai-openai";
2
2
  import { EmbedderConfig, ModelConfig, ModelPricing } from "@warlock.js/ai";
3
3
 
4
- //#region ../@warlock.js/ai-groq/src/config.type.d.ts
4
+ //#region ../ai-groq/src/config.type.d.ts
5
5
  /**
6
6
  * Configuration for the Groq SDK adapter.
7
7
  *
@@ -1 +1 @@
1
- {"version":3,"file":"config.type.d.mts","names":[],"sources":["../../../../../../@warlock.js/ai-groq/src/config.type.ts"],"mappings":";;;;;;AAsCA;;;;;;;;;;;;;;;;;AAmBuC;AAoBvC;;;;;;;;;AAyBkB;AAiBlB;;;;AAA+C;KAjFnC,aAAA,GAAgB,IAAA,CAAK,eAAA;;;;;;EAM/B,OAAA;;;;;;EAMA,QAAA;;;;;;;EAOA,OAAA,GAAU,MAAA,SAAe,YAAA;AAAA;;;;;;;;;;;;;;;;;;KAoBf,eAAA,GAAkB,WAAW;;;;;;;;EAQvC,MAAA;;;;;;;;;EASA,SAAA;;;;;;;;EAQA,gBAAA;AAAA;;;;;;;;;;;;;;;KAiBU,kBAAA,GAAqB,cAAc"}
1
+ {"version":3,"file":"config.type.d.mts","names":[],"sources":["../../../../../../ai-groq/src/config.type.ts"],"mappings":";;;;;;AAsCA;;;;;;;;;;;;;;;;;AAmBuC;AAoBvC;;;;;;;;;AAyBkB;AAiBlB;;;;AAA+C;KAjFnC,aAAA,GAAgB,IAAA,CAAK,eAAA;;;;;;EAM/B,OAAA;;;;;;EAMA,QAAA;;;;;;;EAOA,OAAA,GAAU,MAAA,SAAe,YAAA;AAAA;;;;;;;;;;;;;;;;;;KAoBf,eAAA,GAAkB,WAAW;;;;;;;;EAQvC,MAAA;;;;;;;;;EASA,SAAA;;;;;;;;EAQA,gBAAA;AAAA;;;;;;;;;;;;;;;KAiBU,kBAAA,GAAqB,cAAc"}
@@ -1,4 +1,4 @@
1
- //#region ../@warlock.js/ai-groq/src/known-models.d.ts
1
+ //#region ../ai-groq/src/known-models.d.ts
2
2
  /**
3
3
  * Default base URL for Groq's OpenAI-compatible Chat Completions
4
4
  * endpoint. Groq exposes the same wire protocol as OpenAI under this
@@ -1 +1 @@
1
- {"version":3,"file":"known-models.d.mts","names":[],"sources":["../../../../../../@warlock.js/ai-groq/src/known-models.ts"],"mappings":";;AASA;;;;AAA0B;AAQ1B;;;cARa,aAAA;AAQa;AAkE1B;;;;AAAqD;AAlE3B,cAAb,aAAA;;;;AAmF2C;AAoBxD;;;;AAMU;;;;;iBA3CM,qBAAA,CAAsB,OAAe;;;;;;;;;;;;iBAiBrC,wBAAA,CAAyB,OAAe;;;;;;;;;;;;;;;cAoB3C,iBAAA"}
1
+ {"version":3,"file":"known-models.d.mts","names":[],"sources":["../../../../../../ai-groq/src/known-models.ts"],"mappings":";;AASA;;;;AAA0B;AAQ1B;;;cARa,aAAA;AAQa;AAkE1B;;;;AAAqD;AAlE3B,cAAb,aAAA;;;;AAmF2C;AAoBxD;;;;AAMU;;;;;iBA3CM,qBAAA,CAAsB,OAAe;;;;;;;;;;;;iBAiBrC,wBAAA,CAAyB,OAAe;;;;;;;;;;;;;;;cAoB3C,iBAAA"}
@@ -1,4 +1,4 @@
1
- //#region ../@warlock.js/ai-groq/src/known-models.ts
1
+ //#region ../ai-groq/src/known-models.ts
2
2
  /**
3
3
  * Default base URL for Groq's OpenAI-compatible Chat Completions
4
4
  * endpoint. Groq exposes the same wire protocol as OpenAI under this
@@ -1 +1 @@
1
- {"version":3,"file":"known-models.mjs","names":[],"sources":["../../../../../../@warlock.js/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 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"],"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"}
1
+ {"version":3,"file":"known-models.mjs","names":[],"sources":["../../../../../../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 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"],"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"}
package/esm/sdk.d.mts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { GroqEmbedderConfig, GroqModelConfig, GroqSDKConfig } from "./config.type.mjs";
2
2
  import { EmbedderContract, ModelContract, SDKAdapterContract } from "@warlock.js/ai";
3
3
 
4
- //#region ../@warlock.js/ai-groq/src/sdk.d.ts
4
+ //#region ../ai-groq/src/sdk.d.ts
5
5
  /**
6
6
  * Groq-backed implementation of `SDKAdapterContract`.
7
7
  *
package/esm/sdk.d.mts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"sdk.d.mts","names":[],"sources":["../../../../../../@warlock.js/ai-groq/src/sdk.ts"],"mappings":";;;;;;AAgEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoF+D;;;;;;;;;;;cApFlD,OAAA,YAAmB,kBAAA;;;;;;;mBAOb,MAAA;EAAA,iBACA,QAAA;EAAA,iBACA,OAAA;cAEE,MAAA,EAAQ,aAAA;;;;;;;;;;;;;;;;;;EAqCpB,KAAA,CAAM,MAAA,EAAQ,eAAA,GAAkB,aAAA;;;;;;;EAsB1B,KAAA,CAAM,IAAA,UAAc,KAAA,YAAiB,OAAA;;;;;;;;;;;EAc3C,QAAA,CAAS,MAAA,EAAQ,kBAAA,GAAqB,gBAAA;AAAA"}
1
+ {"version":3,"file":"sdk.d.mts","names":[],"sources":["../../../../../../ai-groq/src/sdk.ts"],"mappings":";;;;;;AAgEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoF+D;;;;;;;;;;;cApFlD,OAAA,YAAmB,kBAAA;;;;;;;mBAOb,MAAA;EAAA,iBACA,QAAA;EAAA,iBACA,OAAA;cAEE,MAAA,EAAQ,aAAA;;;;;;;;;;;;;;;;;;EAqCpB,KAAA,CAAM,MAAA,EAAQ,eAAA,GAAkB,aAAA;;;;;;;EAsB1B,KAAA,CAAM,IAAA,UAAc,KAAA,YAAiB,OAAA;;;;;;;;;;;EAc3C,QAAA,CAAS,MAAA,EAAQ,kBAAA,GAAqB,gBAAA;AAAA"}
package/esm/sdk.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { GROQ_BASE_URL, GROQ_PROVIDER, inferReasoningCapability, inferVisionCapability } from "./known-models.mjs";
2
2
  import { OpenAISDK } from "@warlock.js/ai-openai";
3
3
 
4
- //#region ../@warlock.js/ai-groq/src/sdk.ts
4
+ //#region ../ai-groq/src/sdk.ts
5
5
  /**
6
6
  * Groq-backed implementation of `SDKAdapterContract`.
7
7
  *
package/esm/sdk.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"sdk.mjs","names":[],"sources":["../../../../../../@warlock.js/ai-groq/src/sdk.ts"],"sourcesContent":["import type {\n EmbedderContract,\n ModelContract,\n ModelPricing,\n SDKAdapterContract,\n} from \"@warlock.js/ai\";\nimport { OpenAISDK } from \"@warlock.js/ai-openai\";\nimport type {\n GroqEmbedderConfig,\n GroqModelConfig,\n GroqSDKConfig,\n} 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\n/**\n * Built-in default USD-per-1,000,000-token rates for the current Groq\n * production models (mid-2026), used as the last fallback in `model()`'s\n * pricing resolution. A per-model or SDK-level `pricing` entry always\n * wins over these. Returns `undefined` for any unlisted id so cost stays\n * an honest absence rather than a false zero. Update when Groq revises\n * its public price list.\n */\nfunction defaultPricingFor(name: string): ModelPricing | undefined {\n return GROQ_DEFAULT_PRICING[name];\n}\n\n/**\n * Default per-million-token USD rates for known Groq models. Kept inline\n * (not exported) so the public surface stays the inference helpers; a\n * caller who wants different numbers supplies `pricing` on the SDK or\n * per model.\n */\nconst GROQ_DEFAULT_PRICING: Record<string, ModelPricing> = {\n \"llama-3.3-70b-versatile\": { input: 0.59, output: 0.79 },\n \"llama-3.1-8b-instant\": { input: 0.05, output: 0.08 },\n \"openai/gpt-oss-120b\": { input: 0.15, output: 0.75 },\n \"openai/gpt-oss-20b\": { input: 0.1, output: 0.5 },\n \"deepseek-r1-distill-llama-70b\": { input: 0.75, output: 0.99 },\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgEA,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;AAOF;;;;;;;;;AAUA,SAAS,kBAAkB,MAAwC;CACjE,OAAO,qBAAqB;AAC9B;;;;;;;AAQA,MAAM,uBAAqD;CACzD,2BAA2B;EAAE,OAAO;EAAM,QAAQ;CAAK;CACvD,wBAAwB;EAAE,OAAO;EAAM,QAAQ;CAAK;CACpD,uBAAuB;EAAE,OAAO;EAAM,QAAQ;CAAK;CACnD,sBAAsB;EAAE,OAAO;EAAK,QAAQ;CAAI;CAChD,iCAAiC;EAAE,OAAO;EAAM,QAAQ;CAAK;AAC/D"}
1
+ {"version":3,"file":"sdk.mjs","names":[],"sources":["../../../../../../ai-groq/src/sdk.ts"],"sourcesContent":["import type {\n EmbedderContract,\n ModelContract,\n ModelPricing,\n SDKAdapterContract,\n} from \"@warlock.js/ai\";\nimport { OpenAISDK } from \"@warlock.js/ai-openai\";\nimport type {\n GroqEmbedderConfig,\n GroqModelConfig,\n GroqSDKConfig,\n} 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\n/**\n * Built-in default USD-per-1,000,000-token rates for the current Groq\n * production models (mid-2026), used as the last fallback in `model()`'s\n * pricing resolution. A per-model or SDK-level `pricing` entry always\n * wins over these. Returns `undefined` for any unlisted id so cost stays\n * an honest absence rather than a false zero. Update when Groq revises\n * its public price list.\n */\nfunction defaultPricingFor(name: string): ModelPricing | undefined {\n return GROQ_DEFAULT_PRICING[name];\n}\n\n/**\n * Default per-million-token USD rates for known Groq models. Kept inline\n * (not exported) so the public surface stays the inference helpers; a\n * caller who wants different numbers supplies `pricing` on the SDK or\n * per model.\n */\nconst GROQ_DEFAULT_PRICING: Record<string, ModelPricing> = {\n \"llama-3.3-70b-versatile\": { input: 0.59, output: 0.79 },\n \"llama-3.1-8b-instant\": { input: 0.05, output: 0.08 },\n \"openai/gpt-oss-120b\": { input: 0.15, output: 0.75 },\n \"openai/gpt-oss-20b\": { input: 0.1, output: 0.5 },\n \"deepseek-r1-distill-llama-70b\": { input: 0.75, output: 0.99 },\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgEA,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;AAOF;;;;;;;;;AAUA,SAAS,kBAAkB,MAAwC;CACjE,OAAO,qBAAqB;AAC9B;;;;;;;AAQA,MAAM,uBAAqD;CACzD,2BAA2B;EAAE,OAAO;EAAM,QAAQ;CAAK;CACvD,wBAAwB;EAAE,OAAO;EAAM,QAAQ;CAAK;CACpD,uBAAuB;EAAE,OAAO;EAAM,QAAQ;CAAK;CACnD,sBAAsB;EAAE,OAAO;EAAK,QAAQ;CAAI;CAChD,iCAAiC;EAAE,OAAO;EAAM,QAAQ;CAAK;AAC/D"}
package/package.json CHANGED
@@ -15,13 +15,13 @@
15
15
  "url": "https://github.com/warlockjs/ai-groq"
16
16
  },
17
17
  "dependencies": {
18
- "@warlock.js/ai-openai": "4.8.2",
19
- "@warlock.js/logger": "4.8.2"
18
+ "@warlock.js/ai-openai": "4.9.0",
19
+ "@warlock.js/logger": "4.9.0"
20
20
  },
21
21
  "peerDependencies": {
22
- "@warlock.js/ai": "4.8.2"
22
+ "@warlock.js/ai": "4.9.0"
23
23
  },
24
- "version": "4.8.2",
24
+ "version": "4.9.0",
25
25
  "main": "./cjs/index.cjs",
26
26
  "module": "./esm/index.mjs",
27
27
  "types": "./esm/index.d.mts",