@hiper2d/ai-agents 0.5.3 → 0.7.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/dist/index.d.mts CHANGED
@@ -363,15 +363,14 @@ declare const LLM_CONSTANTS: {
363
363
  GEMINI_PRO: string;
364
364
  GEMINI_FLASH: string;
365
365
  GEMINI_LITE: string;
366
- MISTRAL_LARGE: string;
367
366
  MISTRAL_MEDIUM: string;
368
367
  MISTRAL_SMALL: string;
369
- MISTRAL_MAGISTRAL: string;
370
368
  GROK: string;
371
369
  KIMI: string;
372
370
  GLM: string;
373
371
  GLM_FLASH: string;
374
372
  FUGU_ULTRA: string;
373
+ FUGU_MAX: string;
375
374
  QWEN_MAX: string;
376
375
  QWEN_FLASH: string;
377
376
  MINIMAX: string;
@@ -482,7 +481,7 @@ declare const DEEPSEEK_PEAK_SCHEDULE: PeakPricing;
482
481
  declare const MODEL_PRICING: Record<string, ModelPricing>;
483
482
  /** True for hybrid thinking-only models — the ones whose effective output price is a known
484
483
  * multiple of the sticker price. Always-on reasoning models (GPT-5, Gemini, Grok, Kimi,
485
- * Fable, Magistral) also burn reasoning tokens, but their multiplier hasn't been measured. */
484
+ * Fable) also burn reasoning tokens, but their multiplier hasn't been measured. */
486
485
  declare function isHybridThinkingModel(modelApiName: string): boolean;
487
486
  interface CostCalculationOptions {
488
487
  cacheHitTokens?: number;
@@ -529,19 +528,26 @@ declare function getProviderSignatureFields(aiType: string, signature?: string):
529
528
  * - Gemini 3.x thinkingLevel: minimal|low|medium|high (3.1 Pro and 3.7 Flash reject minimal)
530
529
  * - Z.AI GLM-5.3 / 5.3-Flash: low|high|max only
531
530
  * - DeepSeek V4: low|high|max (the API itself aliases medium → high)
532
- * - Sakana Fugu: high|xhigh
531
+ * - Sakana Fugu (verified live 2026-09-20): high|xhigh|max on every model ("low" → 400 naming
532
+ * exactly that enum). The server default is xhigh for fugu-ultra and high for the rest.
533
533
  * - Meta Muse Spark (verified 2026-09-12): minimal|low|medium|high|xhigh|max ("none" → 400; max is
534
534
  * Standard tier only)
535
- * Qwen accepts reasoning_effort but ignores it (thinking_budget is its knob); MiniMax, Kimi,
536
- * Grok and Mistral expose no effort parameter.
535
+ * - Mistral Small 4 / Medium 3.5 (verified 2026-09-18): the API enum is
536
+ * none|minimal|low|medium|high|xhigh, with reasoning OFF unless the field is sent. "none" is
537
+ * not on the shared scale and means "don't reason", which an agent expresses by omitting the
538
+ * field, so the exported slice starts at minimal. Only "high" is documented to return the
539
+ * thinking chunk; the intermediate levels are accepted but unverified.
540
+ * Qwen accepts reasoning_effort but ignores it (thinking_budget is its knob); MiniMax, Kimi and
541
+ * Grok expose no effort parameter.
537
542
  */
538
543
  type OpenAIReasoningEffort = 'minimal' | 'low' | 'medium' | 'high' | 'xhigh';
539
544
  type AnthropicReasoningEffort = 'low' | 'medium' | 'high' | 'xhigh' | 'max';
540
545
  type GeminiReasoningEffort = 'minimal' | 'low' | 'medium' | 'high';
541
546
  type GlmReasoningEffort = 'low' | 'high' | 'max';
542
547
  type DeepSeekReasoningEffort = 'low' | 'high' | 'max';
543
- type FuguReasoningEffort = 'high' | 'xhigh';
548
+ type FuguReasoningEffort = 'high' | 'xhigh' | 'max';
544
549
  type MetaReasoningEffort = 'minimal' | 'low' | 'medium' | 'high' | 'xhigh' | 'max';
550
+ type MistralReasoningEffort = 'minimal' | 'low' | 'medium' | 'high' | 'xhigh';
545
551
  /** The shared scale, lowest first. */
546
552
  declare const REASONING_EFFORT_SCALE: readonly ReasoningEffort[];
547
553
  declare const OPENAI_REASONING_EFFORTS: readonly OpenAIReasoningEffort[];
@@ -551,6 +557,7 @@ declare const GLM_REASONING_EFFORTS: readonly GlmReasoningEffort[];
551
557
  declare const DEEPSEEK_REASONING_EFFORTS: readonly DeepSeekReasoningEffort[];
552
558
  declare const FUGU_REASONING_EFFORTS: readonly FuguReasoningEffort[];
553
559
  declare const META_REASONING_EFFORTS: readonly MetaReasoningEffort[];
560
+ declare const MISTRAL_REASONING_EFFORTS: readonly MistralReasoningEffort[];
554
561
  /** Clamps `effort` to the nearest level in `allowed` (by rank on the shared scale, ties go up). */
555
562
  declare function clampReasoningEffort<T extends ReasoningEffort>(effort: ReasoningEffort, allowed: readonly T[]): T;
556
563
  declare const toOpenAIEffort: (effort: ReasoningEffort) => OpenAIReasoningEffort;
@@ -560,6 +567,7 @@ declare const toGlmEffort: (effort: ReasoningEffort) => GlmReasoningEffort;
560
567
  declare const toDeepSeekEffort: (effort: ReasoningEffort) => DeepSeekReasoningEffort;
561
568
  declare const toMetaEffort: (effort: ReasoningEffort) => MetaReasoningEffort;
562
569
  declare const toFuguEffort: (effort: ReasoningEffort) => FuguReasoningEffort;
570
+ declare const toMistralEffort: (effort: ReasoningEffort) => MistralReasoningEffort;
563
571
 
564
572
  /**
565
573
  * Unified token usage utilities for all AI providers
@@ -641,8 +649,10 @@ declare function extractAnthropicTokenUsage(response: any): TokenUsage | null;
641
649
  declare function extractGoogleTokenUsage(response: any): TokenUsage | null;
642
650
  /**
643
651
  * Mistral-specific token usage extraction
644
- * Mistral SDK uses camelCase (promptTokens, completionTokens, totalTokens)
645
- * and reasoning tokens may be in additionalProperties for Magistral models
652
+ * Mistral SDK uses camelCase (promptTokens, completionTokens, totalTokens). Reasoning tokens
653
+ * are not itemised today (they sit inside completionTokens, observed 2026-09-18 on Small 4 and
654
+ * Medium 3.5 with reasoning_effort: high); the additionalProperties probe below stays in case
655
+ * a reasoning_tokens field ever appears.
646
656
  */
647
657
  declare function extractMistralTokenUsage(response: any): TokenUsage | null;
648
658
 
@@ -1417,12 +1427,36 @@ declare class GoogleAgent extends AbstractAgent {
1417
1427
  private handleGeminiError;
1418
1428
  }
1419
1429
 
1430
+ /**
1431
+ * Mistral agent (Mistral SDK chat.complete) for the hybrid Small 4 / Medium 3.5 models.
1432
+ *
1433
+ * Reasoning is off on the API by default and switched on per request with `reasoning_effort`
1434
+ * (docs.mistral.ai/studio/conversations/reasoning). SDK 1.x has no typed field for it, so it is
1435
+ * injected into the wire body by the same beforeRequest hook that adds `prompt_cache_key`.
1436
+ * With it set, the assistant message comes back as content chunks — a `thinking` chunk (a list
1437
+ * of text chunks holding the trace) followed by the `text` answer — and this works together
1438
+ * with json_schema structured output (verified live 2026-09-18 on both models). Without the
1439
+ * field the reply is a plain string and no trace exists.
1440
+ *
1441
+ * Multi-turn: Mistral asks that the full assistant message, thinking chunk included, be
1442
+ * replayed into history ("stripping reasoning traces degrades performance"). The trace is
1443
+ * plain text, so it rides on `AIMessage.thinking` — no provider signature field — and
1444
+ * convertToMistralMessages rebuilds each prior assistant turn as [thinking, text] chunks.
1445
+ *
1446
+ * Reasoning tokens are counted inside completion_tokens; no separate reasoning_tokens field
1447
+ * arrives, so cost accounting on the output rate already covers the trace.
1448
+ */
1420
1449
  declare class MistralAgent extends AbstractAgent {
1421
1450
  private readonly client;
1422
1451
  private get defaultParams();
1423
1452
  private readonly logTemplates;
1424
1453
  private readonly errorMessages;
1425
1454
  constructor(name: string, instruction: string, model: string, apiKey: string, enableThinking?: boolean, agentLoggingConfig?: AgentLoggingConfig);
1455
+ /**
1456
+ * History in Mistral's shape. A prior assistant turn that carries a stored trace is
1457
+ * replayed as [thinking, text] chunks, as Mistral's multi-turn guidance asks; every other
1458
+ * turn is a plain string.
1459
+ */
1426
1460
  private convertToMistralMessages;
1427
1461
  private processReply;
1428
1462
  private processStructuredReply;
@@ -1438,9 +1472,8 @@ declare class MistralAgent extends AbstractAgent {
1438
1472
  */
1439
1473
  doAskWithZodSchema<T>(zodSchema: z.ZodSchema<T>, messages: AIMessage[]): Promise<[T, string, TokenUsage$1?, string?]>;
1440
1474
  /**
1441
- * Plain-text ask: no schema appended, no responseFormat. Note that Magistral
1442
- * reasoning models only return thinking traces when responseFormat is NOT
1443
- * json_object, so unlike askWithZodSchema this path can surface thinking content.
1475
+ * Plain-text ask: no schema appended, no responseFormat. Reasoning (and the trace) works
1476
+ * the same way as on the schema path.
1444
1477
  */
1445
1478
  doAskText(messages: AIMessage[]): Promise<[string, string, TokenUsage$1?, string?]>;
1446
1479
  }
@@ -1620,7 +1653,6 @@ declare class FuguAgent extends AbstractAgent {
1620
1653
  private readonly errorMessages;
1621
1654
  constructor(name: string, instruction: string, model: string, apiKey: string, enableThinking?: boolean, agentLoggingConfig?: AgentLoggingConfig);
1622
1655
  private convertToOpenAIMessages;
1623
- private logRawUsageForCalibration;
1624
1656
  private extractThinkingAndUsage;
1625
1657
  private prependSystemInstruction;
1626
1658
  doAskWithZodSchema<T>(zodSchema: z.ZodSchema<T>, messages: AIMessage[]): Promise<[T, string, TokenUsage$1?, string?]>;
@@ -1690,4 +1722,4 @@ declare class MiniMaxAgent extends AbstractAgent {
1690
1722
  doAskText(messages: AIMessage[]): Promise<[string, string, TokenUsage$1?, string?]>;
1691
1723
  }
1692
1724
 
1693
- export { type AIMessage, ANTHROPIC_REASONING_EFFORTS, API_KEY_CONSTANTS, AbstractAgent, type AgentActivityData, AgentFactory, type AgentLoggingConfig, type AnthropicReasoningEffort, type AnthropicTokenUsage, type ApiKeyMap, type BeforeAskHook, BotResponseError, BudgetController, type BudgetControllerOptions, BudgetExceededError, type BudgetLimit, type BudgetVerdict, CACHE_TIER_MARKER, ClaudeAgent, type CostCalculationOptions, DEEPSEEK_PEAK_SCHEDULE, DEEPSEEK_REASONING_EFFORTS, DEFAULT_LOGGING_CONFIG, DEFAULT_MAX_OUTPUT_TOKENS, type DeepSeekReasoningEffort, type DeepSeekTokenUsage, DeepSeekV2Agent, FUGU_REASONING_EFFORTS, FuguAgent, type FuguReasoningEffort, GEMINI_AUDIO_TOKENS_PER_SECOND, GEMINI_REASONING_EFFORTS, GLM_REASONING_EFFORTS, type GeminiReasoningEffort, GlmAgent, type GlmReasoningEffort, GoogleAgent, type GoogleSttOptions, type GoogleSttResult, type GoogleTokenUsage, type GoogleTtsAudioOptions, type GoogleTtsResult, GoogleVoiceAgent, Gpt5Agent, GrokAgent, type GrokTokenUsage, InMemorySpendStore, type JsonSchemaOptions, KimiAgent, type KimiTokenUsage, type LLMModel, LLM_CONSTANTS, type LlmLogger, type LoggingConfig, MESSAGE_ROLE, META_REASONING_EFFORTS, MODEL_PRICING, MetaAgent, type MetaReasoningEffort, type MetaTokenUsage, MiniMaxAgent, MistralAgent, type MistralTokenUsage, type Modality, ModelAuthenticationError, type ModelConfig, ModelError, ModelInvalidResponseError, ModelOverloadError, type ModelPricing, ModelQuotaExceededError, ModelRateLimitError, ModelRefusalError, type ModelTag, ModelUnavailableError, OPENAI_REASONING_EFFORTS, type OpenAIReasoningEffort, type OpenAITokenUsage, type OpenAiSttOptions, type OpenAiSttResult, type OpenAiTtsAudioOptions, type OpenAiTtsVoice, OpenAiVoiceAgent, type PeakPricing, type PricingUnit, type ProviderSchema, type TokenUsage as ProviderTokenUsage, type ProviderType, QwenAgent, REASONING_EFFORT_SCALE, type ReasoningEffort, SUPPORTED_VOICE_PROVIDERS, type SpeechRequest, type SpeechResult, type SpeechUsage, type SpendInput, type SpendKind, type SpendLedger, type SpendLedgers, type SpendStore, type SpendWindow, SupportedAiKeyNames, SupportedAiModels, type TokenPairUsage, type TokenUsage$1 as TokenUsage, type TranscriptionRequest, type TranscriptionResult, type TranscriptionUsage, VOICE_MODEL_CONSTANTS, VOICE_MODEL_PRICING, VOICE_PROVIDER_API_KEY, type VoiceAgent, VoiceAgentFactory, type VoiceModelPricing, type VoiceProvider, ZodSchemaConverter, applySpend, buildGoogleTtsPrompt, calculateAnthropicCost, calculateCost, calculateDeepSeekCost, calculateGeminiSttCost, calculateGeminiTtsCost, calculateGoogleCost, calculateGrokCost, calculateKimiCost, calculateMetaCost, calculateMistralCost, calculateModelCost, calculateOpenAICost, calculateOpenAiSttCost, calculateOpenAiTtsCost, clampReasoningEffort, cleanResponse, createCatalog, createVoiceAgent, describeEmptyTtsResponse, evaluateBudget, extractAnthropicTokenUsage, extractTokenUsageFromResponse$2 as extractAnthropicTokenUsageFromResponse, extractDeepSeekTokenUsage, extractTokenUsageFromResponse$6 as extractDeepSeekTokenUsageFromResponse, extractFirstJsonObject, extractGoogleTokenUsage, extractTokenUsageFromResponse$1 as extractGoogleTokenUsageFromResponse, extractGrokTokenUsage, extractTokenUsageFromResponse$4 as extractGrokTokenUsageFromResponse, extractKimiTokenUsage, extractTokenUsageFromResponse$5 as extractKimiTokenUsageFromResponse, extractMetaTokenUsage, extractTokenUsageFromResponse$3 as extractMetaTokenUsageFromResponse, extractMistralTokenUsage, extractTokenUsageFromResponse as extractMistralTokenUsageFromResponse, extractOpenAITokenUsage, extractTokenUsageFromResponse$7 as extractOpenAITokenUsageFromResponse, extractTokenUsage, extractUsageAndCalculateCost, firstRefusal, generateGoogleTtsAudio, generateOpenAiTtsAudio, generateSchemaInstructions, getModelConfigByApiName, getModelDisplayName, getModelProviderName, getModelTags, getProviderSignatureFields, isBudgetExceededError, isHybridThinkingModel, isInPeakWindow, isPeakBilling, isWeekendAt, ledgerSpend, logger, mergeThinking, modelHasTag, modelIsFast, needsPromptBasedSchema, parseAndValidateLlmJson, pcmToWav, periodEnd, periodKey, safeValidateResponse, setBeforeAskHook, setLlmLogger, stableHashHex, stripInlineThinking, supportsNativeJsonSchema, toAnthropicEffort, toDeepSeekEffort, toFuguEffort, toGeminiEffort, toGlmEffort, toMetaEffort, toOpenAIEffort, transcribeWithGemini, transcribeWithOpenAi, validateResponse };
1725
+ export { type AIMessage, ANTHROPIC_REASONING_EFFORTS, API_KEY_CONSTANTS, AbstractAgent, type AgentActivityData, AgentFactory, type AgentLoggingConfig, type AnthropicReasoningEffort, type AnthropicTokenUsage, type ApiKeyMap, type BeforeAskHook, BotResponseError, BudgetController, type BudgetControllerOptions, BudgetExceededError, type BudgetLimit, type BudgetVerdict, CACHE_TIER_MARKER, ClaudeAgent, type CostCalculationOptions, DEEPSEEK_PEAK_SCHEDULE, DEEPSEEK_REASONING_EFFORTS, DEFAULT_LOGGING_CONFIG, DEFAULT_MAX_OUTPUT_TOKENS, type DeepSeekReasoningEffort, type DeepSeekTokenUsage, DeepSeekV2Agent, FUGU_REASONING_EFFORTS, FuguAgent, type FuguReasoningEffort, GEMINI_AUDIO_TOKENS_PER_SECOND, GEMINI_REASONING_EFFORTS, GLM_REASONING_EFFORTS, type GeminiReasoningEffort, GlmAgent, type GlmReasoningEffort, GoogleAgent, type GoogleSttOptions, type GoogleSttResult, type GoogleTokenUsage, type GoogleTtsAudioOptions, type GoogleTtsResult, GoogleVoiceAgent, Gpt5Agent, GrokAgent, type GrokTokenUsage, InMemorySpendStore, type JsonSchemaOptions, KimiAgent, type KimiTokenUsage, type LLMModel, LLM_CONSTANTS, type LlmLogger, type LoggingConfig, MESSAGE_ROLE, META_REASONING_EFFORTS, MISTRAL_REASONING_EFFORTS, MODEL_PRICING, MetaAgent, type MetaReasoningEffort, type MetaTokenUsage, MiniMaxAgent, MistralAgent, type MistralReasoningEffort, type MistralTokenUsage, type Modality, ModelAuthenticationError, type ModelConfig, ModelError, ModelInvalidResponseError, ModelOverloadError, type ModelPricing, ModelQuotaExceededError, ModelRateLimitError, ModelRefusalError, type ModelTag, ModelUnavailableError, OPENAI_REASONING_EFFORTS, type OpenAIReasoningEffort, type OpenAITokenUsage, type OpenAiSttOptions, type OpenAiSttResult, type OpenAiTtsAudioOptions, type OpenAiTtsVoice, OpenAiVoiceAgent, type PeakPricing, type PricingUnit, type ProviderSchema, type TokenUsage as ProviderTokenUsage, type ProviderType, QwenAgent, REASONING_EFFORT_SCALE, type ReasoningEffort, SUPPORTED_VOICE_PROVIDERS, type SpeechRequest, type SpeechResult, type SpeechUsage, type SpendInput, type SpendKind, type SpendLedger, type SpendLedgers, type SpendStore, type SpendWindow, SupportedAiKeyNames, SupportedAiModels, type TokenPairUsage, type TokenUsage$1 as TokenUsage, type TranscriptionRequest, type TranscriptionResult, type TranscriptionUsage, VOICE_MODEL_CONSTANTS, VOICE_MODEL_PRICING, VOICE_PROVIDER_API_KEY, type VoiceAgent, VoiceAgentFactory, type VoiceModelPricing, type VoiceProvider, ZodSchemaConverter, applySpend, buildGoogleTtsPrompt, calculateAnthropicCost, calculateCost, calculateDeepSeekCost, calculateGeminiSttCost, calculateGeminiTtsCost, calculateGoogleCost, calculateGrokCost, calculateKimiCost, calculateMetaCost, calculateMistralCost, calculateModelCost, calculateOpenAICost, calculateOpenAiSttCost, calculateOpenAiTtsCost, clampReasoningEffort, cleanResponse, createCatalog, createVoiceAgent, describeEmptyTtsResponse, evaluateBudget, extractAnthropicTokenUsage, extractTokenUsageFromResponse$2 as extractAnthropicTokenUsageFromResponse, extractDeepSeekTokenUsage, extractTokenUsageFromResponse$6 as extractDeepSeekTokenUsageFromResponse, extractFirstJsonObject, extractGoogleTokenUsage, extractTokenUsageFromResponse$1 as extractGoogleTokenUsageFromResponse, extractGrokTokenUsage, extractTokenUsageFromResponse$4 as extractGrokTokenUsageFromResponse, extractKimiTokenUsage, extractTokenUsageFromResponse$5 as extractKimiTokenUsageFromResponse, extractMetaTokenUsage, extractTokenUsageFromResponse$3 as extractMetaTokenUsageFromResponse, extractMistralTokenUsage, extractTokenUsageFromResponse as extractMistralTokenUsageFromResponse, extractOpenAITokenUsage, extractTokenUsageFromResponse$7 as extractOpenAITokenUsageFromResponse, extractTokenUsage, extractUsageAndCalculateCost, firstRefusal, generateGoogleTtsAudio, generateOpenAiTtsAudio, generateSchemaInstructions, getModelConfigByApiName, getModelDisplayName, getModelProviderName, getModelTags, getProviderSignatureFields, isBudgetExceededError, isHybridThinkingModel, isInPeakWindow, isPeakBilling, isWeekendAt, ledgerSpend, logger, mergeThinking, modelHasTag, modelIsFast, needsPromptBasedSchema, parseAndValidateLlmJson, pcmToWav, periodEnd, periodKey, safeValidateResponse, setBeforeAskHook, setLlmLogger, stableHashHex, stripInlineThinking, supportsNativeJsonSchema, toAnthropicEffort, toDeepSeekEffort, toFuguEffort, toGeminiEffort, toGlmEffort, toMetaEffort, toMistralEffort, toOpenAIEffort, transcribeWithGemini, transcribeWithOpenAi, validateResponse };
package/dist/index.d.ts CHANGED
@@ -363,15 +363,14 @@ declare const LLM_CONSTANTS: {
363
363
  GEMINI_PRO: string;
364
364
  GEMINI_FLASH: string;
365
365
  GEMINI_LITE: string;
366
- MISTRAL_LARGE: string;
367
366
  MISTRAL_MEDIUM: string;
368
367
  MISTRAL_SMALL: string;
369
- MISTRAL_MAGISTRAL: string;
370
368
  GROK: string;
371
369
  KIMI: string;
372
370
  GLM: string;
373
371
  GLM_FLASH: string;
374
372
  FUGU_ULTRA: string;
373
+ FUGU_MAX: string;
375
374
  QWEN_MAX: string;
376
375
  QWEN_FLASH: string;
377
376
  MINIMAX: string;
@@ -482,7 +481,7 @@ declare const DEEPSEEK_PEAK_SCHEDULE: PeakPricing;
482
481
  declare const MODEL_PRICING: Record<string, ModelPricing>;
483
482
  /** True for hybrid thinking-only models — the ones whose effective output price is a known
484
483
  * multiple of the sticker price. Always-on reasoning models (GPT-5, Gemini, Grok, Kimi,
485
- * Fable, Magistral) also burn reasoning tokens, but their multiplier hasn't been measured. */
484
+ * Fable) also burn reasoning tokens, but their multiplier hasn't been measured. */
486
485
  declare function isHybridThinkingModel(modelApiName: string): boolean;
487
486
  interface CostCalculationOptions {
488
487
  cacheHitTokens?: number;
@@ -529,19 +528,26 @@ declare function getProviderSignatureFields(aiType: string, signature?: string):
529
528
  * - Gemini 3.x thinkingLevel: minimal|low|medium|high (3.1 Pro and 3.7 Flash reject minimal)
530
529
  * - Z.AI GLM-5.3 / 5.3-Flash: low|high|max only
531
530
  * - DeepSeek V4: low|high|max (the API itself aliases medium → high)
532
- * - Sakana Fugu: high|xhigh
531
+ * - Sakana Fugu (verified live 2026-09-20): high|xhigh|max on every model ("low" → 400 naming
532
+ * exactly that enum). The server default is xhigh for fugu-ultra and high for the rest.
533
533
  * - Meta Muse Spark (verified 2026-09-12): minimal|low|medium|high|xhigh|max ("none" → 400; max is
534
534
  * Standard tier only)
535
- * Qwen accepts reasoning_effort but ignores it (thinking_budget is its knob); MiniMax, Kimi,
536
- * Grok and Mistral expose no effort parameter.
535
+ * - Mistral Small 4 / Medium 3.5 (verified 2026-09-18): the API enum is
536
+ * none|minimal|low|medium|high|xhigh, with reasoning OFF unless the field is sent. "none" is
537
+ * not on the shared scale and means "don't reason", which an agent expresses by omitting the
538
+ * field, so the exported slice starts at minimal. Only "high" is documented to return the
539
+ * thinking chunk; the intermediate levels are accepted but unverified.
540
+ * Qwen accepts reasoning_effort but ignores it (thinking_budget is its knob); MiniMax, Kimi and
541
+ * Grok expose no effort parameter.
537
542
  */
538
543
  type OpenAIReasoningEffort = 'minimal' | 'low' | 'medium' | 'high' | 'xhigh';
539
544
  type AnthropicReasoningEffort = 'low' | 'medium' | 'high' | 'xhigh' | 'max';
540
545
  type GeminiReasoningEffort = 'minimal' | 'low' | 'medium' | 'high';
541
546
  type GlmReasoningEffort = 'low' | 'high' | 'max';
542
547
  type DeepSeekReasoningEffort = 'low' | 'high' | 'max';
543
- type FuguReasoningEffort = 'high' | 'xhigh';
548
+ type FuguReasoningEffort = 'high' | 'xhigh' | 'max';
544
549
  type MetaReasoningEffort = 'minimal' | 'low' | 'medium' | 'high' | 'xhigh' | 'max';
550
+ type MistralReasoningEffort = 'minimal' | 'low' | 'medium' | 'high' | 'xhigh';
545
551
  /** The shared scale, lowest first. */
546
552
  declare const REASONING_EFFORT_SCALE: readonly ReasoningEffort[];
547
553
  declare const OPENAI_REASONING_EFFORTS: readonly OpenAIReasoningEffort[];
@@ -551,6 +557,7 @@ declare const GLM_REASONING_EFFORTS: readonly GlmReasoningEffort[];
551
557
  declare const DEEPSEEK_REASONING_EFFORTS: readonly DeepSeekReasoningEffort[];
552
558
  declare const FUGU_REASONING_EFFORTS: readonly FuguReasoningEffort[];
553
559
  declare const META_REASONING_EFFORTS: readonly MetaReasoningEffort[];
560
+ declare const MISTRAL_REASONING_EFFORTS: readonly MistralReasoningEffort[];
554
561
  /** Clamps `effort` to the nearest level in `allowed` (by rank on the shared scale, ties go up). */
555
562
  declare function clampReasoningEffort<T extends ReasoningEffort>(effort: ReasoningEffort, allowed: readonly T[]): T;
556
563
  declare const toOpenAIEffort: (effort: ReasoningEffort) => OpenAIReasoningEffort;
@@ -560,6 +567,7 @@ declare const toGlmEffort: (effort: ReasoningEffort) => GlmReasoningEffort;
560
567
  declare const toDeepSeekEffort: (effort: ReasoningEffort) => DeepSeekReasoningEffort;
561
568
  declare const toMetaEffort: (effort: ReasoningEffort) => MetaReasoningEffort;
562
569
  declare const toFuguEffort: (effort: ReasoningEffort) => FuguReasoningEffort;
570
+ declare const toMistralEffort: (effort: ReasoningEffort) => MistralReasoningEffort;
563
571
 
564
572
  /**
565
573
  * Unified token usage utilities for all AI providers
@@ -641,8 +649,10 @@ declare function extractAnthropicTokenUsage(response: any): TokenUsage | null;
641
649
  declare function extractGoogleTokenUsage(response: any): TokenUsage | null;
642
650
  /**
643
651
  * Mistral-specific token usage extraction
644
- * Mistral SDK uses camelCase (promptTokens, completionTokens, totalTokens)
645
- * and reasoning tokens may be in additionalProperties for Magistral models
652
+ * Mistral SDK uses camelCase (promptTokens, completionTokens, totalTokens). Reasoning tokens
653
+ * are not itemised today (they sit inside completionTokens, observed 2026-09-18 on Small 4 and
654
+ * Medium 3.5 with reasoning_effort: high); the additionalProperties probe below stays in case
655
+ * a reasoning_tokens field ever appears.
646
656
  */
647
657
  declare function extractMistralTokenUsage(response: any): TokenUsage | null;
648
658
 
@@ -1417,12 +1427,36 @@ declare class GoogleAgent extends AbstractAgent {
1417
1427
  private handleGeminiError;
1418
1428
  }
1419
1429
 
1430
+ /**
1431
+ * Mistral agent (Mistral SDK chat.complete) for the hybrid Small 4 / Medium 3.5 models.
1432
+ *
1433
+ * Reasoning is off on the API by default and switched on per request with `reasoning_effort`
1434
+ * (docs.mistral.ai/studio/conversations/reasoning). SDK 1.x has no typed field for it, so it is
1435
+ * injected into the wire body by the same beforeRequest hook that adds `prompt_cache_key`.
1436
+ * With it set, the assistant message comes back as content chunks — a `thinking` chunk (a list
1437
+ * of text chunks holding the trace) followed by the `text` answer — and this works together
1438
+ * with json_schema structured output (verified live 2026-09-18 on both models). Without the
1439
+ * field the reply is a plain string and no trace exists.
1440
+ *
1441
+ * Multi-turn: Mistral asks that the full assistant message, thinking chunk included, be
1442
+ * replayed into history ("stripping reasoning traces degrades performance"). The trace is
1443
+ * plain text, so it rides on `AIMessage.thinking` — no provider signature field — and
1444
+ * convertToMistralMessages rebuilds each prior assistant turn as [thinking, text] chunks.
1445
+ *
1446
+ * Reasoning tokens are counted inside completion_tokens; no separate reasoning_tokens field
1447
+ * arrives, so cost accounting on the output rate already covers the trace.
1448
+ */
1420
1449
  declare class MistralAgent extends AbstractAgent {
1421
1450
  private readonly client;
1422
1451
  private get defaultParams();
1423
1452
  private readonly logTemplates;
1424
1453
  private readonly errorMessages;
1425
1454
  constructor(name: string, instruction: string, model: string, apiKey: string, enableThinking?: boolean, agentLoggingConfig?: AgentLoggingConfig);
1455
+ /**
1456
+ * History in Mistral's shape. A prior assistant turn that carries a stored trace is
1457
+ * replayed as [thinking, text] chunks, as Mistral's multi-turn guidance asks; every other
1458
+ * turn is a plain string.
1459
+ */
1426
1460
  private convertToMistralMessages;
1427
1461
  private processReply;
1428
1462
  private processStructuredReply;
@@ -1438,9 +1472,8 @@ declare class MistralAgent extends AbstractAgent {
1438
1472
  */
1439
1473
  doAskWithZodSchema<T>(zodSchema: z.ZodSchema<T>, messages: AIMessage[]): Promise<[T, string, TokenUsage$1?, string?]>;
1440
1474
  /**
1441
- * Plain-text ask: no schema appended, no responseFormat. Note that Magistral
1442
- * reasoning models only return thinking traces when responseFormat is NOT
1443
- * json_object, so unlike askWithZodSchema this path can surface thinking content.
1475
+ * Plain-text ask: no schema appended, no responseFormat. Reasoning (and the trace) works
1476
+ * the same way as on the schema path.
1444
1477
  */
1445
1478
  doAskText(messages: AIMessage[]): Promise<[string, string, TokenUsage$1?, string?]>;
1446
1479
  }
@@ -1620,7 +1653,6 @@ declare class FuguAgent extends AbstractAgent {
1620
1653
  private readonly errorMessages;
1621
1654
  constructor(name: string, instruction: string, model: string, apiKey: string, enableThinking?: boolean, agentLoggingConfig?: AgentLoggingConfig);
1622
1655
  private convertToOpenAIMessages;
1623
- private logRawUsageForCalibration;
1624
1656
  private extractThinkingAndUsage;
1625
1657
  private prependSystemInstruction;
1626
1658
  doAskWithZodSchema<T>(zodSchema: z.ZodSchema<T>, messages: AIMessage[]): Promise<[T, string, TokenUsage$1?, string?]>;
@@ -1690,4 +1722,4 @@ declare class MiniMaxAgent extends AbstractAgent {
1690
1722
  doAskText(messages: AIMessage[]): Promise<[string, string, TokenUsage$1?, string?]>;
1691
1723
  }
1692
1724
 
1693
- export { type AIMessage, ANTHROPIC_REASONING_EFFORTS, API_KEY_CONSTANTS, AbstractAgent, type AgentActivityData, AgentFactory, type AgentLoggingConfig, type AnthropicReasoningEffort, type AnthropicTokenUsage, type ApiKeyMap, type BeforeAskHook, BotResponseError, BudgetController, type BudgetControllerOptions, BudgetExceededError, type BudgetLimit, type BudgetVerdict, CACHE_TIER_MARKER, ClaudeAgent, type CostCalculationOptions, DEEPSEEK_PEAK_SCHEDULE, DEEPSEEK_REASONING_EFFORTS, DEFAULT_LOGGING_CONFIG, DEFAULT_MAX_OUTPUT_TOKENS, type DeepSeekReasoningEffort, type DeepSeekTokenUsage, DeepSeekV2Agent, FUGU_REASONING_EFFORTS, FuguAgent, type FuguReasoningEffort, GEMINI_AUDIO_TOKENS_PER_SECOND, GEMINI_REASONING_EFFORTS, GLM_REASONING_EFFORTS, type GeminiReasoningEffort, GlmAgent, type GlmReasoningEffort, GoogleAgent, type GoogleSttOptions, type GoogleSttResult, type GoogleTokenUsage, type GoogleTtsAudioOptions, type GoogleTtsResult, GoogleVoiceAgent, Gpt5Agent, GrokAgent, type GrokTokenUsage, InMemorySpendStore, type JsonSchemaOptions, KimiAgent, type KimiTokenUsage, type LLMModel, LLM_CONSTANTS, type LlmLogger, type LoggingConfig, MESSAGE_ROLE, META_REASONING_EFFORTS, MODEL_PRICING, MetaAgent, type MetaReasoningEffort, type MetaTokenUsage, MiniMaxAgent, MistralAgent, type MistralTokenUsage, type Modality, ModelAuthenticationError, type ModelConfig, ModelError, ModelInvalidResponseError, ModelOverloadError, type ModelPricing, ModelQuotaExceededError, ModelRateLimitError, ModelRefusalError, type ModelTag, ModelUnavailableError, OPENAI_REASONING_EFFORTS, type OpenAIReasoningEffort, type OpenAITokenUsage, type OpenAiSttOptions, type OpenAiSttResult, type OpenAiTtsAudioOptions, type OpenAiTtsVoice, OpenAiVoiceAgent, type PeakPricing, type PricingUnit, type ProviderSchema, type TokenUsage as ProviderTokenUsage, type ProviderType, QwenAgent, REASONING_EFFORT_SCALE, type ReasoningEffort, SUPPORTED_VOICE_PROVIDERS, type SpeechRequest, type SpeechResult, type SpeechUsage, type SpendInput, type SpendKind, type SpendLedger, type SpendLedgers, type SpendStore, type SpendWindow, SupportedAiKeyNames, SupportedAiModels, type TokenPairUsage, type TokenUsage$1 as TokenUsage, type TranscriptionRequest, type TranscriptionResult, type TranscriptionUsage, VOICE_MODEL_CONSTANTS, VOICE_MODEL_PRICING, VOICE_PROVIDER_API_KEY, type VoiceAgent, VoiceAgentFactory, type VoiceModelPricing, type VoiceProvider, ZodSchemaConverter, applySpend, buildGoogleTtsPrompt, calculateAnthropicCost, calculateCost, calculateDeepSeekCost, calculateGeminiSttCost, calculateGeminiTtsCost, calculateGoogleCost, calculateGrokCost, calculateKimiCost, calculateMetaCost, calculateMistralCost, calculateModelCost, calculateOpenAICost, calculateOpenAiSttCost, calculateOpenAiTtsCost, clampReasoningEffort, cleanResponse, createCatalog, createVoiceAgent, describeEmptyTtsResponse, evaluateBudget, extractAnthropicTokenUsage, extractTokenUsageFromResponse$2 as extractAnthropicTokenUsageFromResponse, extractDeepSeekTokenUsage, extractTokenUsageFromResponse$6 as extractDeepSeekTokenUsageFromResponse, extractFirstJsonObject, extractGoogleTokenUsage, extractTokenUsageFromResponse$1 as extractGoogleTokenUsageFromResponse, extractGrokTokenUsage, extractTokenUsageFromResponse$4 as extractGrokTokenUsageFromResponse, extractKimiTokenUsage, extractTokenUsageFromResponse$5 as extractKimiTokenUsageFromResponse, extractMetaTokenUsage, extractTokenUsageFromResponse$3 as extractMetaTokenUsageFromResponse, extractMistralTokenUsage, extractTokenUsageFromResponse as extractMistralTokenUsageFromResponse, extractOpenAITokenUsage, extractTokenUsageFromResponse$7 as extractOpenAITokenUsageFromResponse, extractTokenUsage, extractUsageAndCalculateCost, firstRefusal, generateGoogleTtsAudio, generateOpenAiTtsAudio, generateSchemaInstructions, getModelConfigByApiName, getModelDisplayName, getModelProviderName, getModelTags, getProviderSignatureFields, isBudgetExceededError, isHybridThinkingModel, isInPeakWindow, isPeakBilling, isWeekendAt, ledgerSpend, logger, mergeThinking, modelHasTag, modelIsFast, needsPromptBasedSchema, parseAndValidateLlmJson, pcmToWav, periodEnd, periodKey, safeValidateResponse, setBeforeAskHook, setLlmLogger, stableHashHex, stripInlineThinking, supportsNativeJsonSchema, toAnthropicEffort, toDeepSeekEffort, toFuguEffort, toGeminiEffort, toGlmEffort, toMetaEffort, toOpenAIEffort, transcribeWithGemini, transcribeWithOpenAi, validateResponse };
1725
+ export { type AIMessage, ANTHROPIC_REASONING_EFFORTS, API_KEY_CONSTANTS, AbstractAgent, type AgentActivityData, AgentFactory, type AgentLoggingConfig, type AnthropicReasoningEffort, type AnthropicTokenUsage, type ApiKeyMap, type BeforeAskHook, BotResponseError, BudgetController, type BudgetControllerOptions, BudgetExceededError, type BudgetLimit, type BudgetVerdict, CACHE_TIER_MARKER, ClaudeAgent, type CostCalculationOptions, DEEPSEEK_PEAK_SCHEDULE, DEEPSEEK_REASONING_EFFORTS, DEFAULT_LOGGING_CONFIG, DEFAULT_MAX_OUTPUT_TOKENS, type DeepSeekReasoningEffort, type DeepSeekTokenUsage, DeepSeekV2Agent, FUGU_REASONING_EFFORTS, FuguAgent, type FuguReasoningEffort, GEMINI_AUDIO_TOKENS_PER_SECOND, GEMINI_REASONING_EFFORTS, GLM_REASONING_EFFORTS, type GeminiReasoningEffort, GlmAgent, type GlmReasoningEffort, GoogleAgent, type GoogleSttOptions, type GoogleSttResult, type GoogleTokenUsage, type GoogleTtsAudioOptions, type GoogleTtsResult, GoogleVoiceAgent, Gpt5Agent, GrokAgent, type GrokTokenUsage, InMemorySpendStore, type JsonSchemaOptions, KimiAgent, type KimiTokenUsage, type LLMModel, LLM_CONSTANTS, type LlmLogger, type LoggingConfig, MESSAGE_ROLE, META_REASONING_EFFORTS, MISTRAL_REASONING_EFFORTS, MODEL_PRICING, MetaAgent, type MetaReasoningEffort, type MetaTokenUsage, MiniMaxAgent, MistralAgent, type MistralReasoningEffort, type MistralTokenUsage, type Modality, ModelAuthenticationError, type ModelConfig, ModelError, ModelInvalidResponseError, ModelOverloadError, type ModelPricing, ModelQuotaExceededError, ModelRateLimitError, ModelRefusalError, type ModelTag, ModelUnavailableError, OPENAI_REASONING_EFFORTS, type OpenAIReasoningEffort, type OpenAITokenUsage, type OpenAiSttOptions, type OpenAiSttResult, type OpenAiTtsAudioOptions, type OpenAiTtsVoice, OpenAiVoiceAgent, type PeakPricing, type PricingUnit, type ProviderSchema, type TokenUsage as ProviderTokenUsage, type ProviderType, QwenAgent, REASONING_EFFORT_SCALE, type ReasoningEffort, SUPPORTED_VOICE_PROVIDERS, type SpeechRequest, type SpeechResult, type SpeechUsage, type SpendInput, type SpendKind, type SpendLedger, type SpendLedgers, type SpendStore, type SpendWindow, SupportedAiKeyNames, SupportedAiModels, type TokenPairUsage, type TokenUsage$1 as TokenUsage, type TranscriptionRequest, type TranscriptionResult, type TranscriptionUsage, VOICE_MODEL_CONSTANTS, VOICE_MODEL_PRICING, VOICE_PROVIDER_API_KEY, type VoiceAgent, VoiceAgentFactory, type VoiceModelPricing, type VoiceProvider, ZodSchemaConverter, applySpend, buildGoogleTtsPrompt, calculateAnthropicCost, calculateCost, calculateDeepSeekCost, calculateGeminiSttCost, calculateGeminiTtsCost, calculateGoogleCost, calculateGrokCost, calculateKimiCost, calculateMetaCost, calculateMistralCost, calculateModelCost, calculateOpenAICost, calculateOpenAiSttCost, calculateOpenAiTtsCost, clampReasoningEffort, cleanResponse, createCatalog, createVoiceAgent, describeEmptyTtsResponse, evaluateBudget, extractAnthropicTokenUsage, extractTokenUsageFromResponse$2 as extractAnthropicTokenUsageFromResponse, extractDeepSeekTokenUsage, extractTokenUsageFromResponse$6 as extractDeepSeekTokenUsageFromResponse, extractFirstJsonObject, extractGoogleTokenUsage, extractTokenUsageFromResponse$1 as extractGoogleTokenUsageFromResponse, extractGrokTokenUsage, extractTokenUsageFromResponse$4 as extractGrokTokenUsageFromResponse, extractKimiTokenUsage, extractTokenUsageFromResponse$5 as extractKimiTokenUsageFromResponse, extractMetaTokenUsage, extractTokenUsageFromResponse$3 as extractMetaTokenUsageFromResponse, extractMistralTokenUsage, extractTokenUsageFromResponse as extractMistralTokenUsageFromResponse, extractOpenAITokenUsage, extractTokenUsageFromResponse$7 as extractOpenAITokenUsageFromResponse, extractTokenUsage, extractUsageAndCalculateCost, firstRefusal, generateGoogleTtsAudio, generateOpenAiTtsAudio, generateSchemaInstructions, getModelConfigByApiName, getModelDisplayName, getModelProviderName, getModelTags, getProviderSignatureFields, isBudgetExceededError, isHybridThinkingModel, isInPeakWindow, isPeakBilling, isWeekendAt, ledgerSpend, logger, mergeThinking, modelHasTag, modelIsFast, needsPromptBasedSchema, parseAndValidateLlmJson, pcmToWav, periodEnd, periodKey, safeValidateResponse, setBeforeAskHook, setLlmLogger, stableHashHex, stripInlineThinking, supportsNativeJsonSchema, toAnthropicEffort, toDeepSeekEffort, toFuguEffort, toGeminiEffort, toGlmEffort, toMetaEffort, toMistralEffort, toOpenAIEffort, transcribeWithGemini, transcribeWithOpenAi, validateResponse };