@warlock.js/ai-mistral 5.28.0 → 5.30.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,18 @@ All notable changes to `@warlock.js/ai-mistral` 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.30.0 - 2026-10-16
8
+
9
+ ### Changed
10
+
11
+ - Lockstep release; package APIs are unchanged.
12
+
13
+ ## 5.29.0 - 2026-10-01
14
+
15
+ ### Changed
16
+
17
+ - Lockstep release; package APIs are unchanged. Skills refer to other topics by name instead of file paths, so cross-references keep working after `agent-kit` copies them into an app.
18
+
7
19
  ## 5.28.0 - 2026-10-01
8
20
 
9
21
  ### Changed
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 ../ai-mistral/src/known-models.ts
4
+ //#region ../../packages/ai-mistral/src/known-models.ts
5
5
  /**
6
6
  * Model-name fragments identifying Mistral families that accept image
7
7
  * input (vision / multimodal).
@@ -153,7 +153,7 @@ const MISTRAL_DEFAULT_PRICING = {
153
153
  };
154
154
 
155
155
  //#endregion
156
- //#region ../ai-mistral/src/sdk.ts
156
+ //#region ../../packages/ai-mistral/src/sdk.ts
157
157
  /** Default OpenAI-compatible base URL for the Mistral API. */
158
158
  const MISTRAL_BASE_URL = "https://api.mistral.ai/v1";
159
159
  /** Default provider label stamped onto every model this SDK produces. */
package/cjs/index.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["OpenAISDK"],"sources":["../../../../../../ai-mistral/src/known-models.ts","../../../../../../ai-mistral/src/sdk.ts"],"sourcesContent":["import type { ModelPricing } from \"@warlock.js/ai\";\n\n/**\n * Model-name fragments identifying Mistral families that accept image\n * input (vision / multimodal).\n *\n * - `pixtral` — Mistral's dedicated multimodal family\n * (`pixtral-large-latest`, `pixtral-12b`); documents, charts, and\n * natural images.\n * - `mistral-large` / `mistral-medium` — the recent frontier generations\n * (Large 3, Medium 3.5) are natively multimodal.\n * - `ministral-3` — the current small open-weight line ships with\n * best-in-class text + vision.\n *\n * Matched as a **substring** (not a strict prefix) so the date / version\n * suffixes Mistral appends (`pixtral-large-2411`, `mistral-large-2512`)\n * and the `-latest` aliases are all covered without enumerating every\n * release tag. Override per-model via\n * `mistral.model({ name, vision: true | false })` — explicit config\n * always wins over inference.\n *\n * Maintenance: append a fragment when Mistral ships a multimodal family\n * that doesn't already match.\n */\nconst VISION_CAPABLE_SUBSTRINGS = [\n \"pixtral\",\n \"mistral-large\",\n \"mistral-medium\",\n \"ministral-3\",\n] as const;\n\n/**\n * Model-name fragments identifying Mistral families that perform\n * explicit chain-of-thought reasoning.\n *\n * - `magistral` — Mistral's dedicated reasoning family\n * (`magistral-medium-latest`, `magistral-small-latest`); emits\n * tokenized thinking chunks.\n * - `mistral-small-4` / `mistral-small` — the current Small generation\n * is a hybrid model that unifies instruct + reasoning + coding.\n *\n * Matched as a **substring** so version-tagged ids\n * (`magistral-medium-2509`, `mistral-small-2603`) and `-latest` aliases\n * are covered. Override per-model via\n * `mistral.model({ name, reasoning: true | false })` — explicit config\n * always wins over inference.\n *\n * Maintenance: append a fragment when Mistral ships a reasoning family\n * that doesn't already match.\n */\nconst REASONING_CAPABLE_SUBSTRINGS = [\"magistral\", \"mistral-small\"] as const;\n\n/**\n * Infer whether a Mistral model id accepts image input (vision) based on\n * the known multimodal-family fragments. Unknown ids default to `false`\n * so passing an image attachment to a text-only model surfaces a clear,\n * agent-side capability error instead of an opaque Mistral 400.\n *\n * @example\n * inferVisionCapability(\"pixtral-large-latest\"); // → true\n * inferVisionCapability(\"mistral-large-2512\"); // → true\n * inferVisionCapability(\"magistral-medium-latest\");// → false\n * inferVisionCapability(\"mistral-embed\"); // → false\n */\nexport function inferVisionCapability(modelName: string): boolean {\n const normalized = modelName.toLowerCase();\n\n return VISION_CAPABLE_SUBSTRINGS.some((fragment) => normalized.includes(fragment));\n}\n\n/**\n * Infer whether a Mistral model id is a reasoning model (the `magistral`\n * family plus the hybrid `mistral-small` generation) based on the known\n * fragments. Unknown ids default to `false` so the adapter never forwards\n * an unsupported `reasoning_effort` param to a non-reasoning model.\n *\n * @example\n * inferReasoningCapability(\"magistral-medium-latest\"); // → true\n * inferReasoningCapability(\"mistral-small-2603\"); // → true\n * inferReasoningCapability(\"mistral-large-latest\"); // → false\n * inferReasoningCapability(\"pixtral-12b\"); // → false\n */\nexport function inferReasoningCapability(modelName: string): boolean {\n const normalized = modelName.toLowerCase();\n\n return REASONING_CAPABLE_SUBSTRINGS.some((fragment) => normalized.includes(fragment));\n}\n\n/**\n * Stable `-latest` alias ids for the headline Mistral chat / embeddings\n * models, grouped by role. Convenience constants only — `mistral.model()`\n * accepts any id string, so a version-pinned id\n * (`mistral-large-2512`, `magistral-medium-2509`) works just as well.\n * Capability inference keys off the family fragment, not this list, so a\n * newer alias is recognized the moment its name matches a fragment in\n * {@link inferVisionCapability} / {@link inferReasoningCapability}.\n */\nexport const MISTRAL_MODELS = {\n /** General-purpose multimodal flagship / mid / small chat aliases. */\n chat: [\"mistral-large-latest\", \"mistral-medium-latest\", \"mistral-small-latest\"],\n /** Dedicated multimodal (vision) aliases — the `pixtral` family. */\n vision: [\"pixtral-large-latest\", \"pixtral-12b\"],\n /** Dedicated reasoning aliases — the `magistral` family. */\n reasoning: [\"magistral-medium-latest\", \"magistral-small-latest\"],\n /** Embeddings model reachable via the OpenAI-compatible `/v1/embeddings`. */\n embedding: [\"mistral-embed\"],\n} as const;\n\n/**\n * Conservative default USD pricing registry (per 1,000,000 tokens),\n * keyed by stable `-latest` alias, surfaced onto every model unless the\n * caller overrides it via SDK-level or per-model `pricing`.\n *\n * These are sane published-list approximations for budgeting / cost-truth\n * out of the box — Mistral revises rates and ships new generations, so\n * pass an explicit `pricing` registry to `new MistralSDK({ pricing })`\n * for billing-grade numbers. Resolution at `model()` time always lets a\n * caller-supplied rate win: per-model `pricing` > SDK `pricing` > these\n * defaults > `undefined`.\n */\nexport const MISTRAL_DEFAULT_PRICING: Record<string, ModelPricing> = {\n \"mistral-large-latest\": { input: 2, output: 6 },\n \"mistral-medium-latest\": { input: 0.4, output: 2 },\n \"mistral-small-latest\": { input: 0.1, output: 0.3 },\n \"pixtral-large-latest\": { input: 2, output: 6 },\n \"pixtral-12b\": { input: 0.15, output: 0.15 },\n \"magistral-medium-latest\": { input: 2, output: 5 },\n \"magistral-small-latest\": { input: 0.5, output: 1.5 },\n \"mistral-embed\": { input: 0.1, output: 0 },\n};\n","import type {\n EmbedderConfig,\n EmbedderContract,\n ModelContract,\n ModelPricing,\n SDKAdapterContract,\n} from \"@warlock.js/ai\";\nimport { OpenAISDK } from \"@warlock.js/ai-openai\";\nimport type { MistralModelConfig, MistralSDKConfig } from \"./config.type\";\nimport {\n inferReasoningCapability,\n inferVisionCapability,\n MISTRAL_DEFAULT_PRICING,\n} from \"./known-models\";\n\n/** Default OpenAI-compatible base URL for the Mistral API. */\nconst MISTRAL_BASE_URL = \"https://api.mistral.ai/v1\";\n\n/** Default provider label stamped onto every model this SDK produces. */\nconst MISTRAL_PROVIDER = \"mistral\";\n\n/**\n * Mistral-backed implementation of `SDKAdapterContract`.\n *\n * **Role.** The package entry point for Mistral AI chat + embeddings.\n * Mistral exposes an **OpenAI-compatible** API (`/v1/chat/completions`,\n * `/v1/embeddings`), so `MistralSDK` is a *thin wrapper* over the\n * battle-tested {@link OpenAISDK} — it does NOT re-implement the wire\n * protocol, streaming loop, tool-call accumulation, structured-output\n * mapping, error wrapping, or token accounting. It constructs one\n * internal `OpenAISDK` pointed at Mistral's `baseURL` with\n * `provider: \"mistral\"`, and delegates `model()` / `embedder()` /\n * `count()` straight to it.\n *\n * **What this wrapper adds on top of the OpenAI adapter:**\n * - **Defaults.** Injects Mistral's `baseURL` + `provider` label and a\n * default {@link MISTRAL_DEFAULT_PRICING} registry so cost truth works\n * out of the box. All are overridable via config.\n * - **Provider-correct capability inference.** Mistral's model names\n * aren't OpenAI names, so the OpenAI prefix lists never match. Before\n * delegating `model()`, this wrapper infers `vision` (the `pixtral`\n * family + recent multimodal generations) and `reasoning` (the\n * `magistral` family + hybrid `mistral-small`) from *this provider's*\n * fragment lists and passes them as explicit overrides — which the\n * inner `OpenAISDK` honors verbatim. A caller-supplied explicit\n * `vision` / `reasoning` still wins.\n *\n * Construct one SDK per account and reuse it everywhere; the single\n * underlying `OpenAI` client (connection pool, auth, rate-limit state)\n * is shared by every model / embedder produced here.\n *\n * **Note — no image generation.** Mistral has no OpenAI-compatible image\n * endpoint, so `image()` is intentionally NOT exposed. The structural\n * absence of the method IS the capability guard (see\n * `SDKAdapterContract.image`): `ai.mistral.image(...)` is a compile-time\n * error rather than a runtime failure.\n *\n * @example\n * const mistral = new MistralSDK({ apiKey: process.env.MISTRAL_API_KEY! });\n * const model = mistral.model({ name: \"mistral-large-latest\", temperature: 0.7 });\n * const embedder = mistral.embedder({ name: \"mistral-embed\" });\n *\n * @example\n * // Compose into an `ai.mistral` namespace for ergonomic agent wiring.\n * const ai = { agent, tool, systemPrompt, mistral: new MistralSDK({ apiKey }) };\n * const reasoner = ai.agent({ model: ai.mistral.model({ name: \"magistral-medium-latest\" }) });\n */\nexport class MistralSDK implements SDKAdapterContract {\n /**\n * The wrapped OpenAI-compatible adapter doing all the real work. Built\n * once in the constructor with Mistral's `baseURL`, `provider` label,\n * and merged pricing registry; every public method delegates to it.\n */\n private readonly openai: OpenAISDK;\n\n public constructor(config: MistralSDKConfig) {\n const { provider, baseURL, pricing, ...clientOptions } = config;\n\n // Caller pricing wins per model id; otherwise fall back to this\n // provider's published-list defaults so cost truth works out of the box.\n const mergedPricing: Record<string, ModelPricing> = {\n ...MISTRAL_DEFAULT_PRICING,\n ...pricing,\n };\n\n this.openai = new OpenAISDK({\n ...clientOptions,\n baseURL: baseURL ?? MISTRAL_BASE_URL,\n provider: provider ?? MISTRAL_PROVIDER,\n pricing: mergedPricing,\n });\n }\n\n /**\n * Build a `ModelContract` for a Mistral chat model.\n *\n * Delegates to the inner `OpenAISDK.model()` but first injects\n * **Mistral-aware capability inference**: when the caller omits\n * `vision` / `reasoning`, they're inferred from this provider's family\n * fragments (`pixtral` → vision, `magistral` / `mistral-small` →\n * reasoning, see `known-models.ts`) and passed down as explicit\n * overrides. Without this step the wrapped OpenAI adapter would check\n * Mistral ids against OpenAI prefixes (`gpt-4o`, `o3`, …) and wrongly\n * report every Mistral model as non-vision / non-reasoning.\n *\n * A caller-supplied explicit `vision` / `reasoning` is preserved as-is\n * (explicit config always wins over inference). Pricing resolution is\n * handled downstream by `OpenAISDK` against the merged registry:\n * per-model `pricing` > SDK registry (caller + Mistral defaults) >\n * `undefined`.\n */\n public model(config: MistralModelConfig): ModelContract {\n const resolvedConfig: MistralModelConfig = {\n ...config,\n vision: config.vision ?? inferVisionCapability(config.name),\n reasoning: config.reasoning ?? inferReasoningCapability(config.name),\n };\n\n return this.openai.model(resolvedConfig);\n }\n\n /**\n * Rough offline token-count estimate. Delegates to the wrapped\n * `OpenAISDK.count()` (the shared character-heuristic from the core\n * package) — good for budgeting / quota guards, not billing. The\n * optional model id is forwarded but currently ignored.\n */\n public async count(text: string, model?: string): Promise<number> {\n return this.openai.count(text, model);\n }\n\n /**\n * Build an `EmbedderContract` bound to this SDK's client. Mistral\n * serves embeddings (`mistral-embed`) through the OpenAI-compatible\n * `/v1/embeddings` endpoint, so this delegates straight to\n * `OpenAISDK.embedder()`.\n *\n * @example\n * const embedder = mistral.embedder({ name: \"mistral-embed\" });\n * const { vector } = await embedder.embed(\"Hello world\");\n */\n public embedder(config: EmbedderConfig): EmbedderContract {\n // `embedder` is optional on the contract but always present on the\n // wrapped OpenAI adapter — assert it for the delegation.\n return this.openai.embedder!(config);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAwBA,MAAM,4BAA4B;CAChC;CACA;CACA;CACA;AACF;;;;;;;;;;;;;;;;;;;;AAqBA,MAAM,+BAA+B,CAAC,aAAa,eAAe;;;;;;;;;;;;;AAclE,SAAgB,sBAAsB,WAA4B;CAChE,MAAM,aAAa,UAAU,YAAY;CAEzC,OAAO,0BAA0B,MAAM,aAAa,WAAW,SAAS,QAAQ,CAAC;AACnF;;;;;;;;;;;;;AAcA,SAAgB,yBAAyB,WAA4B;CACnE,MAAM,aAAa,UAAU,YAAY;CAEzC,OAAO,6BAA6B,MAAM,aAAa,WAAW,SAAS,QAAQ,CAAC;AACtF;;;;;;;;;;AAWA,MAAa,iBAAiB;;CAE5B,MAAM;EAAC;EAAwB;EAAyB;CAAsB;;CAE9E,QAAQ,CAAC,wBAAwB,aAAa;;CAE9C,WAAW,CAAC,2BAA2B,wBAAwB;;CAE/D,WAAW,CAAC,eAAe;AAC7B;;;;;;;;;;;;;AAcA,MAAa,0BAAwD;CACnE,wBAAwB;EAAE,OAAO;EAAG,QAAQ;CAAE;CAC9C,yBAAyB;EAAE,OAAO;EAAK,QAAQ;CAAE;CACjD,wBAAwB;EAAE,OAAO;EAAK,QAAQ;CAAI;CAClD,wBAAwB;EAAE,OAAO;EAAG,QAAQ;CAAE;CAC9C,eAAe;EAAE,OAAO;EAAM,QAAQ;CAAK;CAC3C,2BAA2B;EAAE,OAAO;EAAG,QAAQ;CAAE;CACjD,0BAA0B;EAAE,OAAO;EAAK,QAAQ;CAAI;CACpD,iBAAiB;EAAE,OAAO;EAAK,QAAQ;CAAE;AAC3C;;;;;ACjHA,MAAM,mBAAmB;;AAGzB,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgDzB,IAAa,aAAb,MAAsD;CAQpD,AAAO,YAAY,QAA0B;EAC3C,MAAM,EAAE,UAAU,SAAS,SAAS,GAAG,kBAAkB;EAIzD,MAAM,gBAA8C;GAClD,GAAG;GACH,GAAG;EACL;EAEA,KAAK,SAAS,IAAIA,gCAAU;GAC1B,GAAG;GACH,SAAS,WAAW;GACpB,UAAU,YAAY;GACtB,SAAS;EACX,CAAC;CACH;;;;;;;;;;;;;;;;;;;CAoBA,AAAO,MAAM,QAA2C;EACtD,MAAM,iBAAqC;GACzC,GAAG;GACH,QAAQ,OAAO,UAAU,sBAAsB,OAAO,IAAI;GAC1D,WAAW,OAAO,aAAa,yBAAyB,OAAO,IAAI;EACrE;EAEA,OAAO,KAAK,OAAO,MAAM,cAAc;CACzC;;;;;;;CAQA,MAAa,MAAM,MAAc,OAAiC;EAChE,OAAO,KAAK,OAAO,MAAM,MAAM,KAAK;CACtC;;;;;;;;;;;CAYA,AAAO,SAAS,QAA0C;EAGxD,OAAO,KAAK,OAAO,SAAU,MAAM;CACrC;AACF"}
1
+ {"version":3,"file":"index.cjs","names":["OpenAISDK"],"sources":["../../../../../../../packages/ai-mistral/src/known-models.ts","../../../../../../../packages/ai-mistral/src/sdk.ts"],"sourcesContent":["import type { ModelPricing } from \"@warlock.js/ai\";\n\n/**\n * Model-name fragments identifying Mistral families that accept image\n * input (vision / multimodal).\n *\n * - `pixtral` — Mistral's dedicated multimodal family\n * (`pixtral-large-latest`, `pixtral-12b`); documents, charts, and\n * natural images.\n * - `mistral-large` / `mistral-medium` — the recent frontier generations\n * (Large 3, Medium 3.5) are natively multimodal.\n * - `ministral-3` — the current small open-weight line ships with\n * best-in-class text + vision.\n *\n * Matched as a **substring** (not a strict prefix) so the date / version\n * suffixes Mistral appends (`pixtral-large-2411`, `mistral-large-2512`)\n * and the `-latest` aliases are all covered without enumerating every\n * release tag. Override per-model via\n * `mistral.model({ name, vision: true | false })` — explicit config\n * always wins over inference.\n *\n * Maintenance: append a fragment when Mistral ships a multimodal family\n * that doesn't already match.\n */\nconst VISION_CAPABLE_SUBSTRINGS = [\n \"pixtral\",\n \"mistral-large\",\n \"mistral-medium\",\n \"ministral-3\",\n] as const;\n\n/**\n * Model-name fragments identifying Mistral families that perform\n * explicit chain-of-thought reasoning.\n *\n * - `magistral` — Mistral's dedicated reasoning family\n * (`magistral-medium-latest`, `magistral-small-latest`); emits\n * tokenized thinking chunks.\n * - `mistral-small-4` / `mistral-small` — the current Small generation\n * is a hybrid model that unifies instruct + reasoning + coding.\n *\n * Matched as a **substring** so version-tagged ids\n * (`magistral-medium-2509`, `mistral-small-2603`) and `-latest` aliases\n * are covered. Override per-model via\n * `mistral.model({ name, reasoning: true | false })` — explicit config\n * always wins over inference.\n *\n * Maintenance: append a fragment when Mistral ships a reasoning family\n * that doesn't already match.\n */\nconst REASONING_CAPABLE_SUBSTRINGS = [\"magistral\", \"mistral-small\"] as const;\n\n/**\n * Infer whether a Mistral model id accepts image input (vision) based on\n * the known multimodal-family fragments. Unknown ids default to `false`\n * so passing an image attachment to a text-only model surfaces a clear,\n * agent-side capability error instead of an opaque Mistral 400.\n *\n * @example\n * inferVisionCapability(\"pixtral-large-latest\"); // → true\n * inferVisionCapability(\"mistral-large-2512\"); // → true\n * inferVisionCapability(\"magistral-medium-latest\");// → false\n * inferVisionCapability(\"mistral-embed\"); // → false\n */\nexport function inferVisionCapability(modelName: string): boolean {\n const normalized = modelName.toLowerCase();\n\n return VISION_CAPABLE_SUBSTRINGS.some((fragment) => normalized.includes(fragment));\n}\n\n/**\n * Infer whether a Mistral model id is a reasoning model (the `magistral`\n * family plus the hybrid `mistral-small` generation) based on the known\n * fragments. Unknown ids default to `false` so the adapter never forwards\n * an unsupported `reasoning_effort` param to a non-reasoning model.\n *\n * @example\n * inferReasoningCapability(\"magistral-medium-latest\"); // → true\n * inferReasoningCapability(\"mistral-small-2603\"); // → true\n * inferReasoningCapability(\"mistral-large-latest\"); // → false\n * inferReasoningCapability(\"pixtral-12b\"); // → false\n */\nexport function inferReasoningCapability(modelName: string): boolean {\n const normalized = modelName.toLowerCase();\n\n return REASONING_CAPABLE_SUBSTRINGS.some((fragment) => normalized.includes(fragment));\n}\n\n/**\n * Stable `-latest` alias ids for the headline Mistral chat / embeddings\n * models, grouped by role. Convenience constants only — `mistral.model()`\n * accepts any id string, so a version-pinned id\n * (`mistral-large-2512`, `magistral-medium-2509`) works just as well.\n * Capability inference keys off the family fragment, not this list, so a\n * newer alias is recognized the moment its name matches a fragment in\n * {@link inferVisionCapability} / {@link inferReasoningCapability}.\n */\nexport const MISTRAL_MODELS = {\n /** General-purpose multimodal flagship / mid / small chat aliases. */\n chat: [\"mistral-large-latest\", \"mistral-medium-latest\", \"mistral-small-latest\"],\n /** Dedicated multimodal (vision) aliases — the `pixtral` family. */\n vision: [\"pixtral-large-latest\", \"pixtral-12b\"],\n /** Dedicated reasoning aliases — the `magistral` family. */\n reasoning: [\"magistral-medium-latest\", \"magistral-small-latest\"],\n /** Embeddings model reachable via the OpenAI-compatible `/v1/embeddings`. */\n embedding: [\"mistral-embed\"],\n} as const;\n\n/**\n * Conservative default USD pricing registry (per 1,000,000 tokens),\n * keyed by stable `-latest` alias, surfaced onto every model unless the\n * caller overrides it via SDK-level or per-model `pricing`.\n *\n * These are sane published-list approximations for budgeting / cost-truth\n * out of the box — Mistral revises rates and ships new generations, so\n * pass an explicit `pricing` registry to `new MistralSDK({ pricing })`\n * for billing-grade numbers. Resolution at `model()` time always lets a\n * caller-supplied rate win: per-model `pricing` > SDK `pricing` > these\n * defaults > `undefined`.\n */\nexport const MISTRAL_DEFAULT_PRICING: Record<string, ModelPricing> = {\n \"mistral-large-latest\": { input: 2, output: 6 },\n \"mistral-medium-latest\": { input: 0.4, output: 2 },\n \"mistral-small-latest\": { input: 0.1, output: 0.3 },\n \"pixtral-large-latest\": { input: 2, output: 6 },\n \"pixtral-12b\": { input: 0.15, output: 0.15 },\n \"magistral-medium-latest\": { input: 2, output: 5 },\n \"magistral-small-latest\": { input: 0.5, output: 1.5 },\n \"mistral-embed\": { input: 0.1, output: 0 },\n};\n","import type {\n EmbedderConfig,\n EmbedderContract,\n ModelContract,\n ModelPricing,\n SDKAdapterContract,\n} from \"@warlock.js/ai\";\nimport { OpenAISDK } from \"@warlock.js/ai-openai\";\nimport type { MistralModelConfig, MistralSDKConfig } from \"./config.type\";\nimport {\n inferReasoningCapability,\n inferVisionCapability,\n MISTRAL_DEFAULT_PRICING,\n} from \"./known-models\";\n\n/** Default OpenAI-compatible base URL for the Mistral API. */\nconst MISTRAL_BASE_URL = \"https://api.mistral.ai/v1\";\n\n/** Default provider label stamped onto every model this SDK produces. */\nconst MISTRAL_PROVIDER = \"mistral\";\n\n/**\n * Mistral-backed implementation of `SDKAdapterContract`.\n *\n * **Role.** The package entry point for Mistral AI chat + embeddings.\n * Mistral exposes an **OpenAI-compatible** API (`/v1/chat/completions`,\n * `/v1/embeddings`), so `MistralSDK` is a *thin wrapper* over the\n * battle-tested {@link OpenAISDK} — it does NOT re-implement the wire\n * protocol, streaming loop, tool-call accumulation, structured-output\n * mapping, error wrapping, or token accounting. It constructs one\n * internal `OpenAISDK` pointed at Mistral's `baseURL` with\n * `provider: \"mistral\"`, and delegates `model()` / `embedder()` /\n * `count()` straight to it.\n *\n * **What this wrapper adds on top of the OpenAI adapter:**\n * - **Defaults.** Injects Mistral's `baseURL` + `provider` label and a\n * default {@link MISTRAL_DEFAULT_PRICING} registry so cost truth works\n * out of the box. All are overridable via config.\n * - **Provider-correct capability inference.** Mistral's model names\n * aren't OpenAI names, so the OpenAI prefix lists never match. Before\n * delegating `model()`, this wrapper infers `vision` (the `pixtral`\n * family + recent multimodal generations) and `reasoning` (the\n * `magistral` family + hybrid `mistral-small`) from *this provider's*\n * fragment lists and passes them as explicit overrides — which the\n * inner `OpenAISDK` honors verbatim. A caller-supplied explicit\n * `vision` / `reasoning` still wins.\n *\n * Construct one SDK per account and reuse it everywhere; the single\n * underlying `OpenAI` client (connection pool, auth, rate-limit state)\n * is shared by every model / embedder produced here.\n *\n * **Note — no image generation.** Mistral has no OpenAI-compatible image\n * endpoint, so `image()` is intentionally NOT exposed. The structural\n * absence of the method IS the capability guard (see\n * `SDKAdapterContract.image`): `ai.mistral.image(...)` is a compile-time\n * error rather than a runtime failure.\n *\n * @example\n * const mistral = new MistralSDK({ apiKey: process.env.MISTRAL_API_KEY! });\n * const model = mistral.model({ name: \"mistral-large-latest\", temperature: 0.7 });\n * const embedder = mistral.embedder({ name: \"mistral-embed\" });\n *\n * @example\n * // Compose into an `ai.mistral` namespace for ergonomic agent wiring.\n * const ai = { agent, tool, systemPrompt, mistral: new MistralSDK({ apiKey }) };\n * const reasoner = ai.agent({ model: ai.mistral.model({ name: \"magistral-medium-latest\" }) });\n */\nexport class MistralSDK implements SDKAdapterContract {\n /**\n * The wrapped OpenAI-compatible adapter doing all the real work. Built\n * once in the constructor with Mistral's `baseURL`, `provider` label,\n * and merged pricing registry; every public method delegates to it.\n */\n private readonly openai: OpenAISDK;\n\n public constructor(config: MistralSDKConfig) {\n const { provider, baseURL, pricing, ...clientOptions } = config;\n\n // Caller pricing wins per model id; otherwise fall back to this\n // provider's published-list defaults so cost truth works out of the box.\n const mergedPricing: Record<string, ModelPricing> = {\n ...MISTRAL_DEFAULT_PRICING,\n ...pricing,\n };\n\n this.openai = new OpenAISDK({\n ...clientOptions,\n baseURL: baseURL ?? MISTRAL_BASE_URL,\n provider: provider ?? MISTRAL_PROVIDER,\n pricing: mergedPricing,\n });\n }\n\n /**\n * Build a `ModelContract` for a Mistral chat model.\n *\n * Delegates to the inner `OpenAISDK.model()` but first injects\n * **Mistral-aware capability inference**: when the caller omits\n * `vision` / `reasoning`, they're inferred from this provider's family\n * fragments (`pixtral` → vision, `magistral` / `mistral-small` →\n * reasoning, see `known-models.ts`) and passed down as explicit\n * overrides. Without this step the wrapped OpenAI adapter would check\n * Mistral ids against OpenAI prefixes (`gpt-4o`, `o3`, …) and wrongly\n * report every Mistral model as non-vision / non-reasoning.\n *\n * A caller-supplied explicit `vision` / `reasoning` is preserved as-is\n * (explicit config always wins over inference). Pricing resolution is\n * handled downstream by `OpenAISDK` against the merged registry:\n * per-model `pricing` > SDK registry (caller + Mistral defaults) >\n * `undefined`.\n */\n public model(config: MistralModelConfig): ModelContract {\n const resolvedConfig: MistralModelConfig = {\n ...config,\n vision: config.vision ?? inferVisionCapability(config.name),\n reasoning: config.reasoning ?? inferReasoningCapability(config.name),\n };\n\n return this.openai.model(resolvedConfig);\n }\n\n /**\n * Rough offline token-count estimate. Delegates to the wrapped\n * `OpenAISDK.count()` (the shared character-heuristic from the core\n * package) — good for budgeting / quota guards, not billing. The\n * optional model id is forwarded but currently ignored.\n */\n public async count(text: string, model?: string): Promise<number> {\n return this.openai.count(text, model);\n }\n\n /**\n * Build an `EmbedderContract` bound to this SDK's client. Mistral\n * serves embeddings (`mistral-embed`) through the OpenAI-compatible\n * `/v1/embeddings` endpoint, so this delegates straight to\n * `OpenAISDK.embedder()`.\n *\n * @example\n * const embedder = mistral.embedder({ name: \"mistral-embed\" });\n * const { vector } = await embedder.embed(\"Hello world\");\n */\n public embedder(config: EmbedderConfig): EmbedderContract {\n // `embedder` is optional on the contract but always present on the\n // wrapped OpenAI adapter — assert it for the delegation.\n return this.openai.embedder!(config);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAwBA,MAAM,4BAA4B;CAChC;CACA;CACA;CACA;AACF;;;;;;;;;;;;;;;;;;;;AAqBA,MAAM,+BAA+B,CAAC,aAAa,eAAe;;;;;;;;;;;;;AAclE,SAAgB,sBAAsB,WAA4B;CAChE,MAAM,aAAa,UAAU,YAAY;CAEzC,OAAO,0BAA0B,MAAM,aAAa,WAAW,SAAS,QAAQ,CAAC;AACnF;;;;;;;;;;;;;AAcA,SAAgB,yBAAyB,WAA4B;CACnE,MAAM,aAAa,UAAU,YAAY;CAEzC,OAAO,6BAA6B,MAAM,aAAa,WAAW,SAAS,QAAQ,CAAC;AACtF;;;;;;;;;;AAWA,MAAa,iBAAiB;;CAE5B,MAAM;EAAC;EAAwB;EAAyB;CAAsB;;CAE9E,QAAQ,CAAC,wBAAwB,aAAa;;CAE9C,WAAW,CAAC,2BAA2B,wBAAwB;;CAE/D,WAAW,CAAC,eAAe;AAC7B;;;;;;;;;;;;;AAcA,MAAa,0BAAwD;CACnE,wBAAwB;EAAE,OAAO;EAAG,QAAQ;CAAE;CAC9C,yBAAyB;EAAE,OAAO;EAAK,QAAQ;CAAE;CACjD,wBAAwB;EAAE,OAAO;EAAK,QAAQ;CAAI;CAClD,wBAAwB;EAAE,OAAO;EAAG,QAAQ;CAAE;CAC9C,eAAe;EAAE,OAAO;EAAM,QAAQ;CAAK;CAC3C,2BAA2B;EAAE,OAAO;EAAG,QAAQ;CAAE;CACjD,0BAA0B;EAAE,OAAO;EAAK,QAAQ;CAAI;CACpD,iBAAiB;EAAE,OAAO;EAAK,QAAQ;CAAE;AAC3C;;;;;ACjHA,MAAM,mBAAmB;;AAGzB,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgDzB,IAAa,aAAb,MAAsD;CAQpD,AAAO,YAAY,QAA0B;EAC3C,MAAM,EAAE,UAAU,SAAS,SAAS,GAAG,kBAAkB;EAIzD,MAAM,gBAA8C;GAClD,GAAG;GACH,GAAG;EACL;EAEA,KAAK,SAAS,IAAIA,gCAAU;GAC1B,GAAG;GACH,SAAS,WAAW;GACpB,UAAU,YAAY;GACtB,SAAS;EACX,CAAC;CACH;;;;;;;;;;;;;;;;;;;CAoBA,AAAO,MAAM,QAA2C;EACtD,MAAM,iBAAqC;GACzC,GAAG;GACH,QAAQ,OAAO,UAAU,sBAAsB,OAAO,IAAI;GAC1D,WAAW,OAAO,aAAa,yBAAyB,OAAO,IAAI;EACrE;EAEA,OAAO,KAAK,OAAO,MAAM,cAAc;CACzC;;;;;;;CAQA,MAAa,MAAM,MAAc,OAAiC;EAChE,OAAO,KAAK,OAAO,MAAM,MAAM,KAAK;CACtC;;;;;;;;;;;CAYA,AAAO,SAAS,QAA0C;EAGxD,OAAO,KAAK,OAAO,SAAU,MAAM;CACrC;AACF"}
@@ -1,7 +1,7 @@
1
1
  import { OpenAISDKConfig } from "@warlock.js/ai-openai";
2
2
  import { ModelConfig } from "@warlock.js/ai";
3
3
 
4
- //#region ../ai-mistral/src/config.type.d.ts
4
+ //#region ../../packages/ai-mistral/src/config.type.d.ts
5
5
  /**
6
6
  * Configuration for the Mistral SDK adapter.
7
7
  *
@@ -1 +1 @@
1
- {"version":3,"file":"config.type.d.mts","names":[],"sources":["../../../../../../ai-mistral/src/config.type.ts"],"mappings":";;;;;;AAmCA;;;;AAA8C;AAmB9C;;;;;;;;;;;;AA0CO;;;;;;;;;;;;;KA7DK,gBAAA,GAAmB,eAAe;;;;;;;;;;;;;;;;;;KAmBlC,kBAAA,GAAqB,WAAW;;;;;;;;EAQ1C,MAAA;;;;;;;;;EASA,SAAA;;;;;;EAMA,gBAAA;;;;;;;EAOA,cAAA;;;;;;EAMA,GAAA;;;;;;EAMA,KAAA;AAAA"}
1
+ {"version":3,"file":"config.type.d.mts","names":[],"sources":["../../../../../../../packages/ai-mistral/src/config.type.ts"],"mappings":";;;;;;AAmCA;;;;AAA8C;AAmB9C;;;;;;;;;;;;AA0CO;;;;;;;;;;;;;KA7DK,gBAAA,GAAmB,eAAe;;;;;;;;;;;;;;;;;;KAmBlC,kBAAA,GAAqB,WAAW;;;;;;;;EAQ1C,MAAA;;;;;;;;;EASA,SAAA;;;;;;EAMA,gBAAA;;;;;;;EAOA,cAAA;;;;;;EAMA,GAAA;;;;;;EAMA,KAAA;AAAA"}
@@ -1,6 +1,6 @@
1
1
  import { ModelPricing } from "@warlock.js/ai";
2
2
 
3
- //#region ../ai-mistral/src/known-models.d.ts
3
+ //#region ../../packages/ai-mistral/src/known-models.d.ts
4
4
  /**
5
5
  * Infer whether a Mistral model id accepts image input (vision) based on
6
6
  * the known multimodal-family fragments. Unknown ids default to `false`
@@ -1 +1 @@
1
- {"version":3,"file":"known-models.d.mts","names":[],"sources":["../../../../../../ai-mistral/src/known-models.ts"],"mappings":";;;;;AAgEA;;;;AAAuD;AAkBvD;;;;AAA0D;iBAlB1C,qBAAA,CAAsB,SAAiB;;;;;;;;;;AAwDvD;;;iBAtCgB,wBAAA,CAAyB,SAAiB;AAsCO;;;;;;;;;AAAA,cAvBpD,cAAA;;;;;;;;;;;;;;;;;;cAuBA,uBAAA,EAAyB,MAAM,SAAS,YAAA"}
1
+ {"version":3,"file":"known-models.d.mts","names":[],"sources":["../../../../../../../packages/ai-mistral/src/known-models.ts"],"mappings":";;;;;AAgEA;;;;AAAuD;AAkBvD;;;;AAA0D;iBAlB1C,qBAAA,CAAsB,SAAiB;;;;;;;;;;AAwDvD;;;iBAtCgB,wBAAA,CAAyB,SAAiB;AAsCO;;;;;;;;;AAAA,cAvBpD,cAAA;;;;;;;;;;;;;;;;;;cAuBA,uBAAA,EAAyB,MAAM,SAAS,YAAA"}
@@ -1,4 +1,4 @@
1
- //#region ../ai-mistral/src/known-models.ts
1
+ //#region ../../packages/ai-mistral/src/known-models.ts
2
2
  /**
3
3
  * Model-name fragments identifying Mistral families that accept image
4
4
  * input (vision / multimodal).
@@ -1 +1 @@
1
- {"version":3,"file":"known-models.mjs","names":[],"sources":["../../../../../../ai-mistral/src/known-models.ts"],"sourcesContent":["import type { ModelPricing } from \"@warlock.js/ai\";\n\n/**\n * Model-name fragments identifying Mistral families that accept image\n * input (vision / multimodal).\n *\n * - `pixtral` — Mistral's dedicated multimodal family\n * (`pixtral-large-latest`, `pixtral-12b`); documents, charts, and\n * natural images.\n * - `mistral-large` / `mistral-medium` — the recent frontier generations\n * (Large 3, Medium 3.5) are natively multimodal.\n * - `ministral-3` — the current small open-weight line ships with\n * best-in-class text + vision.\n *\n * Matched as a **substring** (not a strict prefix) so the date / version\n * suffixes Mistral appends (`pixtral-large-2411`, `mistral-large-2512`)\n * and the `-latest` aliases are all covered without enumerating every\n * release tag. Override per-model via\n * `mistral.model({ name, vision: true | false })` — explicit config\n * always wins over inference.\n *\n * Maintenance: append a fragment when Mistral ships a multimodal family\n * that doesn't already match.\n */\nconst VISION_CAPABLE_SUBSTRINGS = [\n \"pixtral\",\n \"mistral-large\",\n \"mistral-medium\",\n \"ministral-3\",\n] as const;\n\n/**\n * Model-name fragments identifying Mistral families that perform\n * explicit chain-of-thought reasoning.\n *\n * - `magistral` — Mistral's dedicated reasoning family\n * (`magistral-medium-latest`, `magistral-small-latest`); emits\n * tokenized thinking chunks.\n * - `mistral-small-4` / `mistral-small` — the current Small generation\n * is a hybrid model that unifies instruct + reasoning + coding.\n *\n * Matched as a **substring** so version-tagged ids\n * (`magistral-medium-2509`, `mistral-small-2603`) and `-latest` aliases\n * are covered. Override per-model via\n * `mistral.model({ name, reasoning: true | false })` — explicit config\n * always wins over inference.\n *\n * Maintenance: append a fragment when Mistral ships a reasoning family\n * that doesn't already match.\n */\nconst REASONING_CAPABLE_SUBSTRINGS = [\"magistral\", \"mistral-small\"] as const;\n\n/**\n * Infer whether a Mistral model id accepts image input (vision) based on\n * the known multimodal-family fragments. Unknown ids default to `false`\n * so passing an image attachment to a text-only model surfaces a clear,\n * agent-side capability error instead of an opaque Mistral 400.\n *\n * @example\n * inferVisionCapability(\"pixtral-large-latest\"); // → true\n * inferVisionCapability(\"mistral-large-2512\"); // → true\n * inferVisionCapability(\"magistral-medium-latest\");// → false\n * inferVisionCapability(\"mistral-embed\"); // → false\n */\nexport function inferVisionCapability(modelName: string): boolean {\n const normalized = modelName.toLowerCase();\n\n return VISION_CAPABLE_SUBSTRINGS.some((fragment) => normalized.includes(fragment));\n}\n\n/**\n * Infer whether a Mistral model id is a reasoning model (the `magistral`\n * family plus the hybrid `mistral-small` generation) based on the known\n * fragments. Unknown ids default to `false` so the adapter never forwards\n * an unsupported `reasoning_effort` param to a non-reasoning model.\n *\n * @example\n * inferReasoningCapability(\"magistral-medium-latest\"); // → true\n * inferReasoningCapability(\"mistral-small-2603\"); // → true\n * inferReasoningCapability(\"mistral-large-latest\"); // → false\n * inferReasoningCapability(\"pixtral-12b\"); // → false\n */\nexport function inferReasoningCapability(modelName: string): boolean {\n const normalized = modelName.toLowerCase();\n\n return REASONING_CAPABLE_SUBSTRINGS.some((fragment) => normalized.includes(fragment));\n}\n\n/**\n * Stable `-latest` alias ids for the headline Mistral chat / embeddings\n * models, grouped by role. Convenience constants only — `mistral.model()`\n * accepts any id string, so a version-pinned id\n * (`mistral-large-2512`, `magistral-medium-2509`) works just as well.\n * Capability inference keys off the family fragment, not this list, so a\n * newer alias is recognized the moment its name matches a fragment in\n * {@link inferVisionCapability} / {@link inferReasoningCapability}.\n */\nexport const MISTRAL_MODELS = {\n /** General-purpose multimodal flagship / mid / small chat aliases. */\n chat: [\"mistral-large-latest\", \"mistral-medium-latest\", \"mistral-small-latest\"],\n /** Dedicated multimodal (vision) aliases — the `pixtral` family. */\n vision: [\"pixtral-large-latest\", \"pixtral-12b\"],\n /** Dedicated reasoning aliases — the `magistral` family. */\n reasoning: [\"magistral-medium-latest\", \"magistral-small-latest\"],\n /** Embeddings model reachable via the OpenAI-compatible `/v1/embeddings`. */\n embedding: [\"mistral-embed\"],\n} as const;\n\n/**\n * Conservative default USD pricing registry (per 1,000,000 tokens),\n * keyed by stable `-latest` alias, surfaced onto every model unless the\n * caller overrides it via SDK-level or per-model `pricing`.\n *\n * These are sane published-list approximations for budgeting / cost-truth\n * out of the box — Mistral revises rates and ships new generations, so\n * pass an explicit `pricing` registry to `new MistralSDK({ pricing })`\n * for billing-grade numbers. Resolution at `model()` time always lets a\n * caller-supplied rate win: per-model `pricing` > SDK `pricing` > these\n * defaults > `undefined`.\n */\nexport const MISTRAL_DEFAULT_PRICING: Record<string, ModelPricing> = {\n \"mistral-large-latest\": { input: 2, output: 6 },\n \"mistral-medium-latest\": { input: 0.4, output: 2 },\n \"mistral-small-latest\": { input: 0.1, output: 0.3 },\n \"pixtral-large-latest\": { input: 2, output: 6 },\n \"pixtral-12b\": { input: 0.15, output: 0.15 },\n \"magistral-medium-latest\": { input: 2, output: 5 },\n \"magistral-small-latest\": { input: 0.5, output: 1.5 },\n \"mistral-embed\": { input: 0.1, output: 0 },\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAwBA,MAAM,4BAA4B;CAChC;CACA;CACA;CACA;AACF;;;;;;;;;;;;;;;;;;;;AAqBA,MAAM,+BAA+B,CAAC,aAAa,eAAe;;;;;;;;;;;;;AAclE,SAAgB,sBAAsB,WAA4B;CAChE,MAAM,aAAa,UAAU,YAAY;CAEzC,OAAO,0BAA0B,MAAM,aAAa,WAAW,SAAS,QAAQ,CAAC;AACnF;;;;;;;;;;;;;AAcA,SAAgB,yBAAyB,WAA4B;CACnE,MAAM,aAAa,UAAU,YAAY;CAEzC,OAAO,6BAA6B,MAAM,aAAa,WAAW,SAAS,QAAQ,CAAC;AACtF;;;;;;;;;;AAWA,MAAa,iBAAiB;;CAE5B,MAAM;EAAC;EAAwB;EAAyB;CAAsB;;CAE9E,QAAQ,CAAC,wBAAwB,aAAa;;CAE9C,WAAW,CAAC,2BAA2B,wBAAwB;;CAE/D,WAAW,CAAC,eAAe;AAC7B;;;;;;;;;;;;;AAcA,MAAa,0BAAwD;CACnE,wBAAwB;EAAE,OAAO;EAAG,QAAQ;CAAE;CAC9C,yBAAyB;EAAE,OAAO;EAAK,QAAQ;CAAE;CACjD,wBAAwB;EAAE,OAAO;EAAK,QAAQ;CAAI;CAClD,wBAAwB;EAAE,OAAO;EAAG,QAAQ;CAAE;CAC9C,eAAe;EAAE,OAAO;EAAM,QAAQ;CAAK;CAC3C,2BAA2B;EAAE,OAAO;EAAG,QAAQ;CAAE;CACjD,0BAA0B;EAAE,OAAO;EAAK,QAAQ;CAAI;CACpD,iBAAiB;EAAE,OAAO;EAAK,QAAQ;CAAE;AAC3C"}
1
+ {"version":3,"file":"known-models.mjs","names":[],"sources":["../../../../../../../packages/ai-mistral/src/known-models.ts"],"sourcesContent":["import type { ModelPricing } from \"@warlock.js/ai\";\n\n/**\n * Model-name fragments identifying Mistral families that accept image\n * input (vision / multimodal).\n *\n * - `pixtral` — Mistral's dedicated multimodal family\n * (`pixtral-large-latest`, `pixtral-12b`); documents, charts, and\n * natural images.\n * - `mistral-large` / `mistral-medium` — the recent frontier generations\n * (Large 3, Medium 3.5) are natively multimodal.\n * - `ministral-3` — the current small open-weight line ships with\n * best-in-class text + vision.\n *\n * Matched as a **substring** (not a strict prefix) so the date / version\n * suffixes Mistral appends (`pixtral-large-2411`, `mistral-large-2512`)\n * and the `-latest` aliases are all covered without enumerating every\n * release tag. Override per-model via\n * `mistral.model({ name, vision: true | false })` — explicit config\n * always wins over inference.\n *\n * Maintenance: append a fragment when Mistral ships a multimodal family\n * that doesn't already match.\n */\nconst VISION_CAPABLE_SUBSTRINGS = [\n \"pixtral\",\n \"mistral-large\",\n \"mistral-medium\",\n \"ministral-3\",\n] as const;\n\n/**\n * Model-name fragments identifying Mistral families that perform\n * explicit chain-of-thought reasoning.\n *\n * - `magistral` — Mistral's dedicated reasoning family\n * (`magistral-medium-latest`, `magistral-small-latest`); emits\n * tokenized thinking chunks.\n * - `mistral-small-4` / `mistral-small` — the current Small generation\n * is a hybrid model that unifies instruct + reasoning + coding.\n *\n * Matched as a **substring** so version-tagged ids\n * (`magistral-medium-2509`, `mistral-small-2603`) and `-latest` aliases\n * are covered. Override per-model via\n * `mistral.model({ name, reasoning: true | false })` — explicit config\n * always wins over inference.\n *\n * Maintenance: append a fragment when Mistral ships a reasoning family\n * that doesn't already match.\n */\nconst REASONING_CAPABLE_SUBSTRINGS = [\"magistral\", \"mistral-small\"] as const;\n\n/**\n * Infer whether a Mistral model id accepts image input (vision) based on\n * the known multimodal-family fragments. Unknown ids default to `false`\n * so passing an image attachment to a text-only model surfaces a clear,\n * agent-side capability error instead of an opaque Mistral 400.\n *\n * @example\n * inferVisionCapability(\"pixtral-large-latest\"); // → true\n * inferVisionCapability(\"mistral-large-2512\"); // → true\n * inferVisionCapability(\"magistral-medium-latest\");// → false\n * inferVisionCapability(\"mistral-embed\"); // → false\n */\nexport function inferVisionCapability(modelName: string): boolean {\n const normalized = modelName.toLowerCase();\n\n return VISION_CAPABLE_SUBSTRINGS.some((fragment) => normalized.includes(fragment));\n}\n\n/**\n * Infer whether a Mistral model id is a reasoning model (the `magistral`\n * family plus the hybrid `mistral-small` generation) based on the known\n * fragments. Unknown ids default to `false` so the adapter never forwards\n * an unsupported `reasoning_effort` param to a non-reasoning model.\n *\n * @example\n * inferReasoningCapability(\"magistral-medium-latest\"); // → true\n * inferReasoningCapability(\"mistral-small-2603\"); // → true\n * inferReasoningCapability(\"mistral-large-latest\"); // → false\n * inferReasoningCapability(\"pixtral-12b\"); // → false\n */\nexport function inferReasoningCapability(modelName: string): boolean {\n const normalized = modelName.toLowerCase();\n\n return REASONING_CAPABLE_SUBSTRINGS.some((fragment) => normalized.includes(fragment));\n}\n\n/**\n * Stable `-latest` alias ids for the headline Mistral chat / embeddings\n * models, grouped by role. Convenience constants only — `mistral.model()`\n * accepts any id string, so a version-pinned id\n * (`mistral-large-2512`, `magistral-medium-2509`) works just as well.\n * Capability inference keys off the family fragment, not this list, so a\n * newer alias is recognized the moment its name matches a fragment in\n * {@link inferVisionCapability} / {@link inferReasoningCapability}.\n */\nexport const MISTRAL_MODELS = {\n /** General-purpose multimodal flagship / mid / small chat aliases. */\n chat: [\"mistral-large-latest\", \"mistral-medium-latest\", \"mistral-small-latest\"],\n /** Dedicated multimodal (vision) aliases — the `pixtral` family. */\n vision: [\"pixtral-large-latest\", \"pixtral-12b\"],\n /** Dedicated reasoning aliases — the `magistral` family. */\n reasoning: [\"magistral-medium-latest\", \"magistral-small-latest\"],\n /** Embeddings model reachable via the OpenAI-compatible `/v1/embeddings`. */\n embedding: [\"mistral-embed\"],\n} as const;\n\n/**\n * Conservative default USD pricing registry (per 1,000,000 tokens),\n * keyed by stable `-latest` alias, surfaced onto every model unless the\n * caller overrides it via SDK-level or per-model `pricing`.\n *\n * These are sane published-list approximations for budgeting / cost-truth\n * out of the box — Mistral revises rates and ships new generations, so\n * pass an explicit `pricing` registry to `new MistralSDK({ pricing })`\n * for billing-grade numbers. Resolution at `model()` time always lets a\n * caller-supplied rate win: per-model `pricing` > SDK `pricing` > these\n * defaults > `undefined`.\n */\nexport const MISTRAL_DEFAULT_PRICING: Record<string, ModelPricing> = {\n \"mistral-large-latest\": { input: 2, output: 6 },\n \"mistral-medium-latest\": { input: 0.4, output: 2 },\n \"mistral-small-latest\": { input: 0.1, output: 0.3 },\n \"pixtral-large-latest\": { input: 2, output: 6 },\n \"pixtral-12b\": { input: 0.15, output: 0.15 },\n \"magistral-medium-latest\": { input: 2, output: 5 },\n \"magistral-small-latest\": { input: 0.5, output: 1.5 },\n \"mistral-embed\": { input: 0.1, output: 0 },\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAwBA,MAAM,4BAA4B;CAChC;CACA;CACA;CACA;AACF;;;;;;;;;;;;;;;;;;;;AAqBA,MAAM,+BAA+B,CAAC,aAAa,eAAe;;;;;;;;;;;;;AAclE,SAAgB,sBAAsB,WAA4B;CAChE,MAAM,aAAa,UAAU,YAAY;CAEzC,OAAO,0BAA0B,MAAM,aAAa,WAAW,SAAS,QAAQ,CAAC;AACnF;;;;;;;;;;;;;AAcA,SAAgB,yBAAyB,WAA4B;CACnE,MAAM,aAAa,UAAU,YAAY;CAEzC,OAAO,6BAA6B,MAAM,aAAa,WAAW,SAAS,QAAQ,CAAC;AACtF;;;;;;;;;;AAWA,MAAa,iBAAiB;;CAE5B,MAAM;EAAC;EAAwB;EAAyB;CAAsB;;CAE9E,QAAQ,CAAC,wBAAwB,aAAa;;CAE9C,WAAW,CAAC,2BAA2B,wBAAwB;;CAE/D,WAAW,CAAC,eAAe;AAC7B;;;;;;;;;;;;;AAcA,MAAa,0BAAwD;CACnE,wBAAwB;EAAE,OAAO;EAAG,QAAQ;CAAE;CAC9C,yBAAyB;EAAE,OAAO;EAAK,QAAQ;CAAE;CACjD,wBAAwB;EAAE,OAAO;EAAK,QAAQ;CAAI;CAClD,wBAAwB;EAAE,OAAO;EAAG,QAAQ;CAAE;CAC9C,eAAe;EAAE,OAAO;EAAM,QAAQ;CAAK;CAC3C,2BAA2B;EAAE,OAAO;EAAG,QAAQ;CAAE;CACjD,0BAA0B;EAAE,OAAO;EAAK,QAAQ;CAAI;CACpD,iBAAiB;EAAE,OAAO;EAAK,QAAQ;CAAE;AAC3C"}
package/esm/sdk.d.mts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { MistralModelConfig, MistralSDKConfig } from "./config.type.mjs";
2
2
  import { EmbedderConfig, EmbedderContract, ModelContract, SDKAdapterContract } from "@warlock.js/ai";
3
3
 
4
- //#region ../ai-mistral/src/sdk.d.ts
4
+ //#region ../../packages/ai-mistral/src/sdk.d.ts
5
5
  /**
6
6
  * Mistral-backed implementation of `SDKAdapterContract`.
7
7
  *
package/esm/sdk.d.mts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"sdk.d.mts","names":[],"sources":["../../../../../../ai-mistral/src/sdk.ts"],"mappings":";;;;;;AAmEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0E2D;;;;;;;;;;;;;;cA1E9C,UAAA,YAAsB,kBAAA;;;;;;mBAMhB,MAAA;cAEE,MAAA,EAAQ,gBAAA;;;;;;;;;;;;;;;;;;;EAoCpB,KAAA,CAAM,MAAA,EAAQ,kBAAA,GAAqB,aAAA;;;;;;;EAgB7B,KAAA,CAAM,IAAA,UAAc,KAAA,YAAiB,OAAA;;;;;;;;;;;EAc3C,QAAA,CAAS,MAAA,EAAQ,cAAA,GAAiB,gBAAA;AAAA"}
1
+ {"version":3,"file":"sdk.d.mts","names":[],"sources":["../../../../../../../packages/ai-mistral/src/sdk.ts"],"mappings":";;;;;;AAmEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0E2D;;;;;;;;;;;;;;cA1E9C,UAAA,YAAsB,kBAAA;;;;;;mBAMhB,MAAA;cAEE,MAAA,EAAQ,gBAAA;;;;;;;;;;;;;;;;;;;EAoCpB,KAAA,CAAM,MAAA,EAAQ,kBAAA,GAAqB,aAAA;;;;;;;EAgB7B,KAAA,CAAM,IAAA,UAAc,KAAA,YAAiB,OAAA;;;;;;;;;;;EAc3C,QAAA,CAAS,MAAA,EAAQ,cAAA,GAAiB,gBAAA;AAAA"}
package/esm/sdk.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { MISTRAL_DEFAULT_PRICING, inferReasoningCapability, inferVisionCapability } from "./known-models.mjs";
2
2
  import { OpenAISDK } from "@warlock.js/ai-openai";
3
3
 
4
- //#region ../ai-mistral/src/sdk.ts
4
+ //#region ../../packages/ai-mistral/src/sdk.ts
5
5
  /** Default OpenAI-compatible base URL for the Mistral API. */
6
6
  const MISTRAL_BASE_URL = "https://api.mistral.ai/v1";
7
7
  /** Default provider label stamped onto every model this SDK produces. */
package/esm/sdk.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"sdk.mjs","names":[],"sources":["../../../../../../ai-mistral/src/sdk.ts"],"sourcesContent":["import type {\n EmbedderConfig,\n EmbedderContract,\n ModelContract,\n ModelPricing,\n SDKAdapterContract,\n} from \"@warlock.js/ai\";\nimport { OpenAISDK } from \"@warlock.js/ai-openai\";\nimport type { MistralModelConfig, MistralSDKConfig } from \"./config.type\";\nimport {\n inferReasoningCapability,\n inferVisionCapability,\n MISTRAL_DEFAULT_PRICING,\n} from \"./known-models\";\n\n/** Default OpenAI-compatible base URL for the Mistral API. */\nconst MISTRAL_BASE_URL = \"https://api.mistral.ai/v1\";\n\n/** Default provider label stamped onto every model this SDK produces. */\nconst MISTRAL_PROVIDER = \"mistral\";\n\n/**\n * Mistral-backed implementation of `SDKAdapterContract`.\n *\n * **Role.** The package entry point for Mistral AI chat + embeddings.\n * Mistral exposes an **OpenAI-compatible** API (`/v1/chat/completions`,\n * `/v1/embeddings`), so `MistralSDK` is a *thin wrapper* over the\n * battle-tested {@link OpenAISDK} — it does NOT re-implement the wire\n * protocol, streaming loop, tool-call accumulation, structured-output\n * mapping, error wrapping, or token accounting. It constructs one\n * internal `OpenAISDK` pointed at Mistral's `baseURL` with\n * `provider: \"mistral\"`, and delegates `model()` / `embedder()` /\n * `count()` straight to it.\n *\n * **What this wrapper adds on top of the OpenAI adapter:**\n * - **Defaults.** Injects Mistral's `baseURL` + `provider` label and a\n * default {@link MISTRAL_DEFAULT_PRICING} registry so cost truth works\n * out of the box. All are overridable via config.\n * - **Provider-correct capability inference.** Mistral's model names\n * aren't OpenAI names, so the OpenAI prefix lists never match. Before\n * delegating `model()`, this wrapper infers `vision` (the `pixtral`\n * family + recent multimodal generations) and `reasoning` (the\n * `magistral` family + hybrid `mistral-small`) from *this provider's*\n * fragment lists and passes them as explicit overrides — which the\n * inner `OpenAISDK` honors verbatim. A caller-supplied explicit\n * `vision` / `reasoning` still wins.\n *\n * Construct one SDK per account and reuse it everywhere; the single\n * underlying `OpenAI` client (connection pool, auth, rate-limit state)\n * is shared by every model / embedder produced here.\n *\n * **Note — no image generation.** Mistral has no OpenAI-compatible image\n * endpoint, so `image()` is intentionally NOT exposed. The structural\n * absence of the method IS the capability guard (see\n * `SDKAdapterContract.image`): `ai.mistral.image(...)` is a compile-time\n * error rather than a runtime failure.\n *\n * @example\n * const mistral = new MistralSDK({ apiKey: process.env.MISTRAL_API_KEY! });\n * const model = mistral.model({ name: \"mistral-large-latest\", temperature: 0.7 });\n * const embedder = mistral.embedder({ name: \"mistral-embed\" });\n *\n * @example\n * // Compose into an `ai.mistral` namespace for ergonomic agent wiring.\n * const ai = { agent, tool, systemPrompt, mistral: new MistralSDK({ apiKey }) };\n * const reasoner = ai.agent({ model: ai.mistral.model({ name: \"magistral-medium-latest\" }) });\n */\nexport class MistralSDK implements SDKAdapterContract {\n /**\n * The wrapped OpenAI-compatible adapter doing all the real work. Built\n * once in the constructor with Mistral's `baseURL`, `provider` label,\n * and merged pricing registry; every public method delegates to it.\n */\n private readonly openai: OpenAISDK;\n\n public constructor(config: MistralSDKConfig) {\n const { provider, baseURL, pricing, ...clientOptions } = config;\n\n // Caller pricing wins per model id; otherwise fall back to this\n // provider's published-list defaults so cost truth works out of the box.\n const mergedPricing: Record<string, ModelPricing> = {\n ...MISTRAL_DEFAULT_PRICING,\n ...pricing,\n };\n\n this.openai = new OpenAISDK({\n ...clientOptions,\n baseURL: baseURL ?? MISTRAL_BASE_URL,\n provider: provider ?? MISTRAL_PROVIDER,\n pricing: mergedPricing,\n });\n }\n\n /**\n * Build a `ModelContract` for a Mistral chat model.\n *\n * Delegates to the inner `OpenAISDK.model()` but first injects\n * **Mistral-aware capability inference**: when the caller omits\n * `vision` / `reasoning`, they're inferred from this provider's family\n * fragments (`pixtral` → vision, `magistral` / `mistral-small` →\n * reasoning, see `known-models.ts`) and passed down as explicit\n * overrides. Without this step the wrapped OpenAI adapter would check\n * Mistral ids against OpenAI prefixes (`gpt-4o`, `o3`, …) and wrongly\n * report every Mistral model as non-vision / non-reasoning.\n *\n * A caller-supplied explicit `vision` / `reasoning` is preserved as-is\n * (explicit config always wins over inference). Pricing resolution is\n * handled downstream by `OpenAISDK` against the merged registry:\n * per-model `pricing` > SDK registry (caller + Mistral defaults) >\n * `undefined`.\n */\n public model(config: MistralModelConfig): ModelContract {\n const resolvedConfig: MistralModelConfig = {\n ...config,\n vision: config.vision ?? inferVisionCapability(config.name),\n reasoning: config.reasoning ?? inferReasoningCapability(config.name),\n };\n\n return this.openai.model(resolvedConfig);\n }\n\n /**\n * Rough offline token-count estimate. Delegates to the wrapped\n * `OpenAISDK.count()` (the shared character-heuristic from the core\n * package) — good for budgeting / quota guards, not billing. The\n * optional model id is forwarded but currently ignored.\n */\n public async count(text: string, model?: string): Promise<number> {\n return this.openai.count(text, model);\n }\n\n /**\n * Build an `EmbedderContract` bound to this SDK's client. Mistral\n * serves embeddings (`mistral-embed`) through the OpenAI-compatible\n * `/v1/embeddings` endpoint, so this delegates straight to\n * `OpenAISDK.embedder()`.\n *\n * @example\n * const embedder = mistral.embedder({ name: \"mistral-embed\" });\n * const { vector } = await embedder.embed(\"Hello world\");\n */\n public embedder(config: EmbedderConfig): EmbedderContract {\n // `embedder` is optional on the contract but always present on the\n // wrapped OpenAI adapter — assert it for the delegation.\n return this.openai.embedder!(config);\n }\n}\n"],"mappings":";;;;;AAgBA,MAAM,mBAAmB;;AAGzB,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgDzB,IAAa,aAAb,MAAsD;CAQpD,AAAO,YAAY,QAA0B;EAC3C,MAAM,EAAE,UAAU,SAAS,SAAS,GAAG,kBAAkB;EAIzD,MAAM,gBAA8C;GAClD,GAAG;GACH,GAAG;EACL;EAEA,KAAK,SAAS,IAAI,UAAU;GAC1B,GAAG;GACH,SAAS,WAAW;GACpB,UAAU,YAAY;GACtB,SAAS;EACX,CAAC;CACH;;;;;;;;;;;;;;;;;;;CAoBA,AAAO,MAAM,QAA2C;EACtD,MAAM,iBAAqC;GACzC,GAAG;GACH,QAAQ,OAAO,UAAU,sBAAsB,OAAO,IAAI;GAC1D,WAAW,OAAO,aAAa,yBAAyB,OAAO,IAAI;EACrE;EAEA,OAAO,KAAK,OAAO,MAAM,cAAc;CACzC;;;;;;;CAQA,MAAa,MAAM,MAAc,OAAiC;EAChE,OAAO,KAAK,OAAO,MAAM,MAAM,KAAK;CACtC;;;;;;;;;;;CAYA,AAAO,SAAS,QAA0C;EAGxD,OAAO,KAAK,OAAO,SAAU,MAAM;CACrC;AACF"}
1
+ {"version":3,"file":"sdk.mjs","names":[],"sources":["../../../../../../../packages/ai-mistral/src/sdk.ts"],"sourcesContent":["import type {\n EmbedderConfig,\n EmbedderContract,\n ModelContract,\n ModelPricing,\n SDKAdapterContract,\n} from \"@warlock.js/ai\";\nimport { OpenAISDK } from \"@warlock.js/ai-openai\";\nimport type { MistralModelConfig, MistralSDKConfig } from \"./config.type\";\nimport {\n inferReasoningCapability,\n inferVisionCapability,\n MISTRAL_DEFAULT_PRICING,\n} from \"./known-models\";\n\n/** Default OpenAI-compatible base URL for the Mistral API. */\nconst MISTRAL_BASE_URL = \"https://api.mistral.ai/v1\";\n\n/** Default provider label stamped onto every model this SDK produces. */\nconst MISTRAL_PROVIDER = \"mistral\";\n\n/**\n * Mistral-backed implementation of `SDKAdapterContract`.\n *\n * **Role.** The package entry point for Mistral AI chat + embeddings.\n * Mistral exposes an **OpenAI-compatible** API (`/v1/chat/completions`,\n * `/v1/embeddings`), so `MistralSDK` is a *thin wrapper* over the\n * battle-tested {@link OpenAISDK} — it does NOT re-implement the wire\n * protocol, streaming loop, tool-call accumulation, structured-output\n * mapping, error wrapping, or token accounting. It constructs one\n * internal `OpenAISDK` pointed at Mistral's `baseURL` with\n * `provider: \"mistral\"`, and delegates `model()` / `embedder()` /\n * `count()` straight to it.\n *\n * **What this wrapper adds on top of the OpenAI adapter:**\n * - **Defaults.** Injects Mistral's `baseURL` + `provider` label and a\n * default {@link MISTRAL_DEFAULT_PRICING} registry so cost truth works\n * out of the box. All are overridable via config.\n * - **Provider-correct capability inference.** Mistral's model names\n * aren't OpenAI names, so the OpenAI prefix lists never match. Before\n * delegating `model()`, this wrapper infers `vision` (the `pixtral`\n * family + recent multimodal generations) and `reasoning` (the\n * `magistral` family + hybrid `mistral-small`) from *this provider's*\n * fragment lists and passes them as explicit overrides — which the\n * inner `OpenAISDK` honors verbatim. A caller-supplied explicit\n * `vision` / `reasoning` still wins.\n *\n * Construct one SDK per account and reuse it everywhere; the single\n * underlying `OpenAI` client (connection pool, auth, rate-limit state)\n * is shared by every model / embedder produced here.\n *\n * **Note — no image generation.** Mistral has no OpenAI-compatible image\n * endpoint, so `image()` is intentionally NOT exposed. The structural\n * absence of the method IS the capability guard (see\n * `SDKAdapterContract.image`): `ai.mistral.image(...)` is a compile-time\n * error rather than a runtime failure.\n *\n * @example\n * const mistral = new MistralSDK({ apiKey: process.env.MISTRAL_API_KEY! });\n * const model = mistral.model({ name: \"mistral-large-latest\", temperature: 0.7 });\n * const embedder = mistral.embedder({ name: \"mistral-embed\" });\n *\n * @example\n * // Compose into an `ai.mistral` namespace for ergonomic agent wiring.\n * const ai = { agent, tool, systemPrompt, mistral: new MistralSDK({ apiKey }) };\n * const reasoner = ai.agent({ model: ai.mistral.model({ name: \"magistral-medium-latest\" }) });\n */\nexport class MistralSDK implements SDKAdapterContract {\n /**\n * The wrapped OpenAI-compatible adapter doing all the real work. Built\n * once in the constructor with Mistral's `baseURL`, `provider` label,\n * and merged pricing registry; every public method delegates to it.\n */\n private readonly openai: OpenAISDK;\n\n public constructor(config: MistralSDKConfig) {\n const { provider, baseURL, pricing, ...clientOptions } = config;\n\n // Caller pricing wins per model id; otherwise fall back to this\n // provider's published-list defaults so cost truth works out of the box.\n const mergedPricing: Record<string, ModelPricing> = {\n ...MISTRAL_DEFAULT_PRICING,\n ...pricing,\n };\n\n this.openai = new OpenAISDK({\n ...clientOptions,\n baseURL: baseURL ?? MISTRAL_BASE_URL,\n provider: provider ?? MISTRAL_PROVIDER,\n pricing: mergedPricing,\n });\n }\n\n /**\n * Build a `ModelContract` for a Mistral chat model.\n *\n * Delegates to the inner `OpenAISDK.model()` but first injects\n * **Mistral-aware capability inference**: when the caller omits\n * `vision` / `reasoning`, they're inferred from this provider's family\n * fragments (`pixtral` → vision, `magistral` / `mistral-small` →\n * reasoning, see `known-models.ts`) and passed down as explicit\n * overrides. Without this step the wrapped OpenAI adapter would check\n * Mistral ids against OpenAI prefixes (`gpt-4o`, `o3`, …) and wrongly\n * report every Mistral model as non-vision / non-reasoning.\n *\n * A caller-supplied explicit `vision` / `reasoning` is preserved as-is\n * (explicit config always wins over inference). Pricing resolution is\n * handled downstream by `OpenAISDK` against the merged registry:\n * per-model `pricing` > SDK registry (caller + Mistral defaults) >\n * `undefined`.\n */\n public model(config: MistralModelConfig): ModelContract {\n const resolvedConfig: MistralModelConfig = {\n ...config,\n vision: config.vision ?? inferVisionCapability(config.name),\n reasoning: config.reasoning ?? inferReasoningCapability(config.name),\n };\n\n return this.openai.model(resolvedConfig);\n }\n\n /**\n * Rough offline token-count estimate. Delegates to the wrapped\n * `OpenAISDK.count()` (the shared character-heuristic from the core\n * package) — good for budgeting / quota guards, not billing. The\n * optional model id is forwarded but currently ignored.\n */\n public async count(text: string, model?: string): Promise<number> {\n return this.openai.count(text, model);\n }\n\n /**\n * Build an `EmbedderContract` bound to this SDK's client. Mistral\n * serves embeddings (`mistral-embed`) through the OpenAI-compatible\n * `/v1/embeddings` endpoint, so this delegates straight to\n * `OpenAISDK.embedder()`.\n *\n * @example\n * const embedder = mistral.embedder({ name: \"mistral-embed\" });\n * const { vector } = await embedder.embed(\"Hello world\");\n */\n public embedder(config: EmbedderConfig): EmbedderContract {\n // `embedder` is optional on the contract but always present on the\n // wrapped OpenAI adapter — assert it for the delegation.\n return this.openai.embedder!(config);\n }\n}\n"],"mappings":";;;;;AAgBA,MAAM,mBAAmB;;AAGzB,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgDzB,IAAa,aAAb,MAAsD;CAQpD,AAAO,YAAY,QAA0B;EAC3C,MAAM,EAAE,UAAU,SAAS,SAAS,GAAG,kBAAkB;EAIzD,MAAM,gBAA8C;GAClD,GAAG;GACH,GAAG;EACL;EAEA,KAAK,SAAS,IAAI,UAAU;GAC1B,GAAG;GACH,SAAS,WAAW;GACpB,UAAU,YAAY;GACtB,SAAS;EACX,CAAC;CACH;;;;;;;;;;;;;;;;;;;CAoBA,AAAO,MAAM,QAA2C;EACtD,MAAM,iBAAqC;GACzC,GAAG;GACH,QAAQ,OAAO,UAAU,sBAAsB,OAAO,IAAI;GAC1D,WAAW,OAAO,aAAa,yBAAyB,OAAO,IAAI;EACrE;EAEA,OAAO,KAAK,OAAO,MAAM,cAAc;CACzC;;;;;;;CAQA,MAAa,MAAM,MAAc,OAAiC;EAChE,OAAO,KAAK,OAAO,MAAM,MAAM,KAAK;CACtC;;;;;;;;;;;CAYA,AAAO,SAAS,QAA0C;EAGxD,OAAO,KAAK,OAAO,SAAU,MAAM;CACrC;AACF"}
package/llms-full.txt CHANGED
@@ -8,12 +8,12 @@
8
8
 
9
9
  ---
10
10
  name: setup-mistral
11
- description: 'Wire @warlock.js/ai-mistral — new MistralSDK({apiKey, baseURL?, provider?, pricing?}) for Mistral AI, a thin wrapper over the OpenAI adapter that uses Mistral''s OpenAI-compatible endpoint (https://api.mistral.ai/v1). .model({name, vision?, reasoning?, structuredOutput?, responseFormat?, pdf?, audio?}) for a ModelContract with Mistral-aware capabilities (vision auto-inferred for the pixtral family, reasoning for the magistral family + hybrid mistral-small), .embedder({name, dimensions?}) for mistral-embed via /v1/embeddings. Triggers: `MistralSDK`, `mistral.model`, `mistral.embedder`, `pixtral`, `magistral`, `mistral-large`, `mistral-small`, `mistral-medium`, `ministral`, `mistral-embed`, `api.mistral.ai`, OpenAI-compatible Mistral, `reasoning_effort`, `responseFormat`, `pricing`; "use mistral", "wire mistral into a warlock agent", "configure mistral-large", "use magistral reasoning", "pixtral vision", "mistral embeddings with warlock". Skip: image generation (Mistral has no OpenAI-compatible image endpoint — `mistral.image()` does not exist); the wrapped adapter internals `@warlock.js/ai-openai`; agent wiring `@warlock.js/ai/run-ai-agent/SKILL.md`; embedder usage `@warlock.js/ai/embed-text/SKILL.md`; provider picking `@warlock.js/ai/pick-ai-provider/SKILL.md`; siblings `@warlock.js/ai-google`, `@warlock.js/ai-anthropic`, `@warlock.js/ai-bedrock`, `@warlock.js/ai-ollama`; raw `@mistralai/mistralai`, Vercel `@ai-sdk/mistral`.'
11
+ description: 'Wire @warlock.js/ai-mistral — new MistralSDK({apiKey, baseURL?, provider?, pricing?}) for Mistral AI, a thin wrapper over the OpenAI adapter that uses Mistral''s OpenAI-compatible endpoint (https://api.mistral.ai/v1). .model({name, vision?, reasoning?, structuredOutput?, responseFormat?, pdf?, audio?}) for a ModelContract with Mistral-aware capabilities (vision auto-inferred for the pixtral family, reasoning for the magistral family + hybrid mistral-small), .embedder({name, dimensions?}) for mistral-embed via /v1/embeddings. Triggers: `MistralSDK`, `mistral.model`, `mistral.embedder`, `pixtral`, `magistral`, `mistral-large`, `mistral-small`, `mistral-medium`, `ministral`, `mistral-embed`, `api.mistral.ai`, OpenAI-compatible Mistral, `reasoning_effort`, `responseFormat`, `pricing`; "use mistral", "wire mistral into a warlock agent", "configure mistral-large", "use magistral reasoning", "pixtral vision", "mistral embeddings with warlock". Skip: image generation (Mistral has no OpenAI-compatible image endpoint — `mistral.image()` does not exist); the wrapped adapter internals `@warlock.js/ai-openai`; agent wiring the `run-ai-agent` topic of the `warlock-js-ai` skill; embedder usage the `embed-text` topic of the `warlock-js-ai` skill; provider picking the `pick-ai-provider` topic of the `warlock-js-ai` skill; siblings `@warlock.js/ai-google`, `@warlock.js/ai-anthropic`, `@warlock.js/ai-bedrock`, `@warlock.js/ai-ollama`; raw `@mistralai/mistralai`, Vercel `@ai-sdk/mistral`.'
12
12
  ---
13
13
 
14
14
  # `@warlock.js/ai-mistral`
15
15
 
16
- Provider adapter for Mistral AI. Mistral exposes an **OpenAI-compatible** API, so `MistralSDK` is a **thin wrapper** over [`@warlock.js/ai-openai`](@warlock.js/ai-openai/skills/setup-openai/SKILL.md) — it does not re-implement the wire protocol, streaming, tool calls, structured output, error wrapping, or token accounting. It builds one internal `OpenAISDK` pointed at Mistral's `baseURL` with `provider: "mistral"`, then layers on this provider's own capability inference + default pricing. Pair with `@warlock.js/ai` for the agent / tool / system-prompt surface.
16
+ Provider adapter for Mistral AI. Mistral exposes an **OpenAI-compatible** API, so `MistralSDK` is a **thin wrapper** over `@warlock.js/ai-openai` (the `setup-openai` topic of the `warlock-js-ai-openai` skill) — it does not re-implement the wire protocol, streaming, tool calls, structured output, error wrapping, or token accounting. It builds one internal `OpenAISDK` pointed at Mistral's `baseURL` with `provider: "mistral"`, then layers on this provider's own capability inference + default pricing. Pair with `@warlock.js/ai` for the agent / tool / system-prompt surface.
17
17
 
18
18
  ## Construction
19
19
 
@@ -54,7 +54,7 @@ The headline `-latest` aliases are exported as `MISTRAL_MODELS` ({ chat, vision,
54
54
 
55
55
  ## Uses the OpenAI-compatible endpoint
56
56
 
57
- Because Mistral speaks the OpenAI Chat Completions + Embeddings protocol, everything the OpenAI adapter does applies unchanged: streaming deltas + consolidated tool calls, `response_format: json_schema` structured output (override per model with `responseFormat`), `reasoning_effort` for reasoning models, multipart image input, and the neutral `Usage` breakdown (`input` / `output` / `cachedTokens` / `reasoningTokens`). See [`@warlock.js/ai-openai`](@warlock.js/ai-openai/skills/setup-openai/SKILL.md) for the wire-level detail — it is identical here.
57
+ Because Mistral speaks the OpenAI Chat Completions + Embeddings protocol, everything the OpenAI adapter does applies unchanged: streaming deltas + consolidated tool calls, `response_format: json_schema` structured output (override per model with `responseFormat`), `reasoning_effort` for reasoning models, multipart image input, and the neutral `Usage` breakdown (`input` / `output` / `cachedTokens` / `reasoningTokens`). See `@warlock.js/ai-openai` (the `setup-openai` topic of the `warlock-js-ai-openai` skill) for the wire-level detail — it is identical here.
58
58
 
59
59
  **No image generation.** Mistral has no OpenAI-compatible image endpoint, so `MistralSDK` intentionally does **not** expose `image()` — the structural absence is the capability guard (`ai.mistral.image(...)` is a compile-time error).
60
60
 
@@ -88,7 +88,7 @@ Resolution at `model()` time: per-model `pricing` (`mistral.model({ name, pricin
88
88
 
89
89
  ## Errors
90
90
 
91
- Raw errors are wrapped into the typed `@warlock.js/ai` `AIError` hierarchy by the wrapped OpenAI adapter (dispatch keys on `APIError.status + code`) — see [`@warlock.js/ai/handle-ai-errors/SKILL.md`](@warlock.js/ai/handle-ai-errors/SKILL.md).
91
+ Raw errors are wrapped into the typed `@warlock.js/ai` `AIError` hierarchy by the wrapped OpenAI adapter (dispatch keys on `APIError.status + code`) — see the `handle-ai-errors` topic of the `warlock-js-ai` skill.
92
92
 
93
93
  ## When NOT to use this skill
94
94
 
@@ -98,8 +98,8 @@ Raw errors are wrapped into the typed `@warlock.js/ai` `AIError` hierarchy by th
98
98
 
99
99
  ## See also
100
100
 
101
- - [`@warlock.js/ai-openai/skills/setup-openai/SKILL.md`](@warlock.js/ai-openai/skills/setup-openai/SKILL.md) — the wrapped adapter; identical wire behavior.
102
- - [`@warlock.js/ai/run-ai-agent/SKILL.md`](@warlock.js/ai/run-ai-agent/SKILL.md) — passing the model into `ai.agent({...})`.
103
- - [`@warlock.js/ai/pick-ai-provider/SKILL.md`](@warlock.js/ai/pick-ai-provider/SKILL.md) — adapter comparison.
101
+ - The `setup-openai` topic of the `warlock-js-ai-openai` skill — the wrapped adapter; identical wire behavior.
102
+ - The `run-ai-agent` topic of the `warlock-js-ai` skill — passing the model into `ai.agent({...})`.
103
+ - The `pick-ai-provider` topic of the `warlock-js-ai` skill — adapter comparison.
104
104
 
105
105
 
package/llms.txt CHANGED
@@ -6,4 +6,4 @@
6
6
 
7
7
  ## Skills
8
8
 
9
- - [setup-mistral](@warlock.js/ai-mistral/setup-mistral/SKILL.md): Wire @warlock.js/ai-mistral — new MistralSDK({apiKey, baseURL?, provider?, pricing?}) for Mistral AI, a thin wrapper over the OpenAI adapter that uses Mistral's OpenAI-compatible endpoint (https://api.mistral.ai/v1). .model({name, vision?, reasoning?, structuredOutput?, responseFormat?, pdf?, audio?}) for a ModelContract with Mistral-aware capabilities (vision auto-inferred for the pixtral family, reasoning for the magistral family + hybrid mistral-small), .embedder({name, dimensions?}) for mistral-embed via /v1/embeddings. Triggers: `MistralSDK`, `mistral.model`, `mistral.embedder`, `pixtral`, `magistral`, `mistral-large`, `mistral-small`, `mistral-medium`, `ministral`, `mistral-embed`, `api.mistral.ai`, OpenAI-compatible Mistral, `reasoning_effort`, `responseFormat`, `pricing`; "use mistral", "wire mistral into a warlock agent", "configure mistral-large", "use magistral reasoning", "pixtral vision", "mistral embeddings with warlock". Skip: image generation (Mistral has no OpenAI-compatible image endpoint — `mistral.image()` does not exist); the wrapped adapter internals `@warlock.js/ai-openai`; agent wiring `@warlock.js/ai/run-ai-agent/SKILL.md`; embedder usage `@warlock.js/ai/embed-text/SKILL.md`; provider picking `@warlock.js/ai/pick-ai-provider/SKILL.md`; siblings `@warlock.js/ai-google`, `@warlock.js/ai-anthropic`, `@warlock.js/ai-bedrock`, `@warlock.js/ai-ollama`; raw `@mistralai/mistralai`, Vercel `@ai-sdk/mistral`.
9
+ - [setup-mistral](@warlock.js/ai-mistral/setup-mistral/SKILL.md): Wire @warlock.js/ai-mistral — new MistralSDK({apiKey, baseURL?, provider?, pricing?}) for Mistral AI, a thin wrapper over the OpenAI adapter that uses Mistral's OpenAI-compatible endpoint (https://api.mistral.ai/v1). .model({name, vision?, reasoning?, structuredOutput?, responseFormat?, pdf?, audio?}) for a ModelContract with Mistral-aware capabilities (vision auto-inferred for the pixtral family, reasoning for the magistral family + hybrid mistral-small), .embedder({name, dimensions?}) for mistral-embed via /v1/embeddings. Triggers: `MistralSDK`, `mistral.model`, `mistral.embedder`, `pixtral`, `magistral`, `mistral-large`, `mistral-small`, `mistral-medium`, `ministral`, `mistral-embed`, `api.mistral.ai`, OpenAI-compatible Mistral, `reasoning_effort`, `responseFormat`, `pricing`; "use mistral", "wire mistral into a warlock agent", "configure mistral-large", "use magistral reasoning", "pixtral vision", "mistral embeddings with warlock". Skip: image generation (Mistral has no OpenAI-compatible image endpoint — `mistral.image()` does not exist); the wrapped adapter internals `@warlock.js/ai-openai`; agent wiring the `run-ai-agent` topic of the `warlock-js-ai` skill; embedder usage the `embed-text` topic of the `warlock-js-ai` skill; provider picking the `pick-ai-provider` topic of the `warlock-js-ai` skill; siblings `@warlock.js/ai-google`, `@warlock.js/ai-anthropic`, `@warlock.js/ai-bedrock`, `@warlock.js/ai-ollama`; raw `@mistralai/mistralai`, Vercel `@ai-sdk/mistral`.
package/package.json CHANGED
@@ -12,16 +12,17 @@
12
12
  "license": "MIT",
13
13
  "repository": {
14
14
  "type": "git",
15
- "url": "https://github.com/warlockjs/ai-mistral"
15
+ "url": "git+https://github.com/warlockjs/framework.git",
16
+ "directory": "packages/ai-mistral"
16
17
  },
17
18
  "dependencies": {
18
- "@warlock.js/ai-openai": "5.28.0",
19
- "@warlock.js/logger": "5.28.0"
19
+ "@warlock.js/ai-openai": "5.30.0",
20
+ "@warlock.js/logger": "5.30.0"
20
21
  },
21
22
  "peerDependencies": {
22
- "@warlock.js/ai": "5.28.0"
23
+ "@warlock.js/ai": "5.30.0"
23
24
  },
24
- "version": "5.28.0",
25
+ "version": "5.30.0",
25
26
  "main": "./cjs/index.cjs",
26
27
  "module": "./esm/index.mjs",
27
28
  "types": "./esm/index.d.mts",
@@ -1,11 +1,11 @@
1
1
  ---
2
2
  name: setup-mistral
3
- description: 'Wire @warlock.js/ai-mistral — new MistralSDK({apiKey, baseURL?, provider?, pricing?}) for Mistral AI, a thin wrapper over the OpenAI adapter that uses Mistral''s OpenAI-compatible endpoint (https://api.mistral.ai/v1). .model({name, vision?, reasoning?, structuredOutput?, responseFormat?, pdf?, audio?}) for a ModelContract with Mistral-aware capabilities (vision auto-inferred for the pixtral family, reasoning for the magistral family + hybrid mistral-small), .embedder({name, dimensions?}) for mistral-embed via /v1/embeddings. Triggers: `MistralSDK`, `mistral.model`, `mistral.embedder`, `pixtral`, `magistral`, `mistral-large`, `mistral-small`, `mistral-medium`, `ministral`, `mistral-embed`, `api.mistral.ai`, OpenAI-compatible Mistral, `reasoning_effort`, `responseFormat`, `pricing`; "use mistral", "wire mistral into a warlock agent", "configure mistral-large", "use magistral reasoning", "pixtral vision", "mistral embeddings with warlock". Skip: image generation (Mistral has no OpenAI-compatible image endpoint — `mistral.image()` does not exist); the wrapped adapter internals `@warlock.js/ai-openai`; agent wiring `@warlock.js/ai/run-ai-agent/SKILL.md`; embedder usage `@warlock.js/ai/embed-text/SKILL.md`; provider picking `@warlock.js/ai/pick-ai-provider/SKILL.md`; siblings `@warlock.js/ai-google`, `@warlock.js/ai-anthropic`, `@warlock.js/ai-bedrock`, `@warlock.js/ai-ollama`; raw `@mistralai/mistralai`, Vercel `@ai-sdk/mistral`.'
3
+ description: 'Wire @warlock.js/ai-mistral — new MistralSDK({apiKey, baseURL?, provider?, pricing?}) for Mistral AI, a thin wrapper over the OpenAI adapter that uses Mistral''s OpenAI-compatible endpoint (https://api.mistral.ai/v1). .model({name, vision?, reasoning?, structuredOutput?, responseFormat?, pdf?, audio?}) for a ModelContract with Mistral-aware capabilities (vision auto-inferred for the pixtral family, reasoning for the magistral family + hybrid mistral-small), .embedder({name, dimensions?}) for mistral-embed via /v1/embeddings. Triggers: `MistralSDK`, `mistral.model`, `mistral.embedder`, `pixtral`, `magistral`, `mistral-large`, `mistral-small`, `mistral-medium`, `ministral`, `mistral-embed`, `api.mistral.ai`, OpenAI-compatible Mistral, `reasoning_effort`, `responseFormat`, `pricing`; "use mistral", "wire mistral into a warlock agent", "configure mistral-large", "use magistral reasoning", "pixtral vision", "mistral embeddings with warlock". Skip: image generation (Mistral has no OpenAI-compatible image endpoint — `mistral.image()` does not exist); the wrapped adapter internals `@warlock.js/ai-openai`; agent wiring the `run-ai-agent` topic of the `warlock-js-ai` skill; embedder usage the `embed-text` topic of the `warlock-js-ai` skill; provider picking the `pick-ai-provider` topic of the `warlock-js-ai` skill; siblings `@warlock.js/ai-google`, `@warlock.js/ai-anthropic`, `@warlock.js/ai-bedrock`, `@warlock.js/ai-ollama`; raw `@mistralai/mistralai`, Vercel `@ai-sdk/mistral`.'
4
4
  ---
5
5
 
6
6
  # `@warlock.js/ai-mistral`
7
7
 
8
- Provider adapter for Mistral AI. Mistral exposes an **OpenAI-compatible** API, so `MistralSDK` is a **thin wrapper** over [`@warlock.js/ai-openai`](@warlock.js/ai-openai/skills/setup-openai/SKILL.md) — it does not re-implement the wire protocol, streaming, tool calls, structured output, error wrapping, or token accounting. It builds one internal `OpenAISDK` pointed at Mistral's `baseURL` with `provider: "mistral"`, then layers on this provider's own capability inference + default pricing. Pair with `@warlock.js/ai` for the agent / tool / system-prompt surface.
8
+ Provider adapter for Mistral AI. Mistral exposes an **OpenAI-compatible** API, so `MistralSDK` is a **thin wrapper** over `@warlock.js/ai-openai` (the `setup-openai` topic of the `warlock-js-ai-openai` skill) — it does not re-implement the wire protocol, streaming, tool calls, structured output, error wrapping, or token accounting. It builds one internal `OpenAISDK` pointed at Mistral's `baseURL` with `provider: "mistral"`, then layers on this provider's own capability inference + default pricing. Pair with `@warlock.js/ai` for the agent / tool / system-prompt surface.
9
9
 
10
10
  ## Construction
11
11
 
@@ -46,7 +46,7 @@ The headline `-latest` aliases are exported as `MISTRAL_MODELS` ({ chat, vision,
46
46
 
47
47
  ## Uses the OpenAI-compatible endpoint
48
48
 
49
- Because Mistral speaks the OpenAI Chat Completions + Embeddings protocol, everything the OpenAI adapter does applies unchanged: streaming deltas + consolidated tool calls, `response_format: json_schema` structured output (override per model with `responseFormat`), `reasoning_effort` for reasoning models, multipart image input, and the neutral `Usage` breakdown (`input` / `output` / `cachedTokens` / `reasoningTokens`). See [`@warlock.js/ai-openai`](@warlock.js/ai-openai/skills/setup-openai/SKILL.md) for the wire-level detail — it is identical here.
49
+ Because Mistral speaks the OpenAI Chat Completions + Embeddings protocol, everything the OpenAI adapter does applies unchanged: streaming deltas + consolidated tool calls, `response_format: json_schema` structured output (override per model with `responseFormat`), `reasoning_effort` for reasoning models, multipart image input, and the neutral `Usage` breakdown (`input` / `output` / `cachedTokens` / `reasoningTokens`). See `@warlock.js/ai-openai` (the `setup-openai` topic of the `warlock-js-ai-openai` skill) for the wire-level detail — it is identical here.
50
50
 
51
51
  **No image generation.** Mistral has no OpenAI-compatible image endpoint, so `MistralSDK` intentionally does **not** expose `image()` — the structural absence is the capability guard (`ai.mistral.image(...)` is a compile-time error).
52
52
 
@@ -80,7 +80,7 @@ Resolution at `model()` time: per-model `pricing` (`mistral.model({ name, pricin
80
80
 
81
81
  ## Errors
82
82
 
83
- Raw errors are wrapped into the typed `@warlock.js/ai` `AIError` hierarchy by the wrapped OpenAI adapter (dispatch keys on `APIError.status + code`) — see [`@warlock.js/ai/handle-ai-errors/SKILL.md`](@warlock.js/ai/handle-ai-errors/SKILL.md).
83
+ Raw errors are wrapped into the typed `@warlock.js/ai` `AIError` hierarchy by the wrapped OpenAI adapter (dispatch keys on `APIError.status + code`) — see the `handle-ai-errors` topic of the `warlock-js-ai` skill.
84
84
 
85
85
  ## When NOT to use this skill
86
86
 
@@ -90,6 +90,6 @@ Raw errors are wrapped into the typed `@warlock.js/ai` `AIError` hierarchy by th
90
90
 
91
91
  ## See also
92
92
 
93
- - [`@warlock.js/ai-openai/skills/setup-openai/SKILL.md`](@warlock.js/ai-openai/skills/setup-openai/SKILL.md) — the wrapped adapter; identical wire behavior.
94
- - [`@warlock.js/ai/run-ai-agent/SKILL.md`](@warlock.js/ai/run-ai-agent/SKILL.md) — passing the model into `ai.agent({...})`.
95
- - [`@warlock.js/ai/pick-ai-provider/SKILL.md`](@warlock.js/ai/pick-ai-provider/SKILL.md) — adapter comparison.
93
+ - The `setup-openai` topic of the `warlock-js-ai-openai` skill — the wrapped adapter; identical wire behavior.
94
+ - The `run-ai-agent` topic of the `warlock-js-ai` skill — passing the model into `ai.agent({...})`.
95
+ - The `pick-ai-provider` topic of the `warlock-js-ai` skill — adapter comparison.