@hiper2d/ai-agents 0.10.0 → 0.12.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
@@ -537,8 +537,14 @@ declare function getProviderSignatureFields(aiType: string, signature?: string):
537
537
  * not on the shared scale and means "don't reason", which an agent expresses by omitting the
538
538
  * field, so the exported slice starts at minimal. Only "high" is documented to return the
539
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.
540
+ * - xAI Grok 4.7 (docs.x.ai/developers/model-capabilities/text/reasoning, 2026-09-22):
541
+ * low|medium|high|xhigh, default high, sent on the Responses API as `reasoning: {effort}`.
542
+ * Chat Completions has no equivalent. Grok 4.6 and earlier had no knob at all.
543
+ * - Moonshot Kimi K3 (platform.kimi.ai/docs/guide/use-reasoning-effort, 2026-09-22):
544
+ * low|high|max, default max, top-level on Chat Completions. Moonshot shipped the lower
545
+ * levels after launch; K3 accepted only "max" when this agent was written.
546
+ * Qwen accepts reasoning_effort but ignores it (thinking_budget is its knob); MiniMax exposes
547
+ * no effort parameter.
542
548
  */
543
549
  type OpenAIReasoningEffort = 'minimal' | 'low' | 'medium' | 'high' | 'xhigh';
544
550
  type AnthropicReasoningEffort = 'low' | 'medium' | 'high' | 'xhigh' | 'max';
@@ -548,6 +554,8 @@ type DeepSeekReasoningEffort = 'low' | 'high' | 'max';
548
554
  type FuguReasoningEffort = 'high' | 'xhigh' | 'max';
549
555
  type MetaReasoningEffort = 'minimal' | 'low' | 'medium' | 'high' | 'xhigh' | 'max';
550
556
  type MistralReasoningEffort = 'minimal' | 'low' | 'medium' | 'high' | 'xhigh';
557
+ type XaiReasoningEffort = 'low' | 'medium' | 'high' | 'xhigh';
558
+ type KimiReasoningEffort = 'low' | 'high' | 'max';
551
559
  /** The shared scale, lowest first. */
552
560
  declare const REASONING_EFFORT_SCALE: readonly ReasoningEffort[];
553
561
  declare const OPENAI_REASONING_EFFORTS: readonly OpenAIReasoningEffort[];
@@ -558,6 +566,8 @@ declare const DEEPSEEK_REASONING_EFFORTS: readonly DeepSeekReasoningEffort[];
558
566
  declare const FUGU_REASONING_EFFORTS: readonly FuguReasoningEffort[];
559
567
  declare const META_REASONING_EFFORTS: readonly MetaReasoningEffort[];
560
568
  declare const MISTRAL_REASONING_EFFORTS: readonly MistralReasoningEffort[];
569
+ declare const XAI_REASONING_EFFORTS: readonly XaiReasoningEffort[];
570
+ declare const KIMI_REASONING_EFFORTS: readonly KimiReasoningEffort[];
561
571
  /** Clamps `effort` to the nearest level in `allowed` (by rank on the shared scale, ties go up). */
562
572
  declare function clampReasoningEffort<T extends ReasoningEffort>(effort: ReasoningEffort, allowed: readonly T[]): T;
563
573
  declare const toOpenAIEffort: (effort: ReasoningEffort) => OpenAIReasoningEffort;
@@ -568,6 +578,8 @@ declare const toDeepSeekEffort: (effort: ReasoningEffort) => DeepSeekReasoningEf
568
578
  declare const toMetaEffort: (effort: ReasoningEffort) => MetaReasoningEffort;
569
579
  declare const toFuguEffort: (effort: ReasoningEffort) => FuguReasoningEffort;
570
580
  declare const toMistralEffort: (effort: ReasoningEffort) => MistralReasoningEffort;
581
+ declare const toXaiEffort: (effort: ReasoningEffort) => XaiReasoningEffort;
582
+ declare const toKimiEffort: (effort: ReasoningEffort) => KimiReasoningEffort;
571
583
 
572
584
  /**
573
585
  * Unified token usage utilities for all AI providers
@@ -1535,6 +1547,14 @@ declare class GrokAgent extends AbstractAgent {
1535
1547
  * Reasoning extraction and token accounting are identical to askWithZodSchema.
1536
1548
  */
1537
1549
  doAskText(messages: AIMessage[]): Promise<[string, string, TokenUsage$1?, string?]>;
1550
+ /**
1551
+ * A stable key per (game, bot) so xAI routes this conversation's requests to the same
1552
+ * server. Without it a request often lands on a cache-cold machine and the whole prompt
1553
+ * bills at full input price — xAI calls this out as the most common caching mistake.
1554
+ * Falls back to the bot name alone outside a game (story generation, tests), which is
1555
+ * still stabler than sending nothing.
1556
+ */
1557
+ private get promptCacheKey();
1538
1558
  private createResponse;
1539
1559
  /**
1540
1560
  * Converts game history to Responses API input items. The system instruction is
@@ -1722,4 +1742,4 @@ declare class MiniMaxAgent extends AbstractAgent {
1722
1742
  doAskText(messages: AIMessage[]): Promise<[string, string, TokenUsage$1?, string?]>;
1723
1743
  }
1724
1744
 
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 };
1745
+ 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, KIMI_REASONING_EFFORTS, KimiAgent, type KimiReasoningEffort, 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, XAI_REASONING_EFFORTS, type XaiReasoningEffort, 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, toKimiEffort, toMetaEffort, toMistralEffort, toOpenAIEffort, toXaiEffort, transcribeWithGemini, transcribeWithOpenAi, validateResponse };
package/dist/index.d.ts CHANGED
@@ -537,8 +537,14 @@ declare function getProviderSignatureFields(aiType: string, signature?: string):
537
537
  * not on the shared scale and means "don't reason", which an agent expresses by omitting the
538
538
  * field, so the exported slice starts at minimal. Only "high" is documented to return the
539
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.
540
+ * - xAI Grok 4.7 (docs.x.ai/developers/model-capabilities/text/reasoning, 2026-09-22):
541
+ * low|medium|high|xhigh, default high, sent on the Responses API as `reasoning: {effort}`.
542
+ * Chat Completions has no equivalent. Grok 4.6 and earlier had no knob at all.
543
+ * - Moonshot Kimi K3 (platform.kimi.ai/docs/guide/use-reasoning-effort, 2026-09-22):
544
+ * low|high|max, default max, top-level on Chat Completions. Moonshot shipped the lower
545
+ * levels after launch; K3 accepted only "max" when this agent was written.
546
+ * Qwen accepts reasoning_effort but ignores it (thinking_budget is its knob); MiniMax exposes
547
+ * no effort parameter.
542
548
  */
543
549
  type OpenAIReasoningEffort = 'minimal' | 'low' | 'medium' | 'high' | 'xhigh';
544
550
  type AnthropicReasoningEffort = 'low' | 'medium' | 'high' | 'xhigh' | 'max';
@@ -548,6 +554,8 @@ type DeepSeekReasoningEffort = 'low' | 'high' | 'max';
548
554
  type FuguReasoningEffort = 'high' | 'xhigh' | 'max';
549
555
  type MetaReasoningEffort = 'minimal' | 'low' | 'medium' | 'high' | 'xhigh' | 'max';
550
556
  type MistralReasoningEffort = 'minimal' | 'low' | 'medium' | 'high' | 'xhigh';
557
+ type XaiReasoningEffort = 'low' | 'medium' | 'high' | 'xhigh';
558
+ type KimiReasoningEffort = 'low' | 'high' | 'max';
551
559
  /** The shared scale, lowest first. */
552
560
  declare const REASONING_EFFORT_SCALE: readonly ReasoningEffort[];
553
561
  declare const OPENAI_REASONING_EFFORTS: readonly OpenAIReasoningEffort[];
@@ -558,6 +566,8 @@ declare const DEEPSEEK_REASONING_EFFORTS: readonly DeepSeekReasoningEffort[];
558
566
  declare const FUGU_REASONING_EFFORTS: readonly FuguReasoningEffort[];
559
567
  declare const META_REASONING_EFFORTS: readonly MetaReasoningEffort[];
560
568
  declare const MISTRAL_REASONING_EFFORTS: readonly MistralReasoningEffort[];
569
+ declare const XAI_REASONING_EFFORTS: readonly XaiReasoningEffort[];
570
+ declare const KIMI_REASONING_EFFORTS: readonly KimiReasoningEffort[];
561
571
  /** Clamps `effort` to the nearest level in `allowed` (by rank on the shared scale, ties go up). */
562
572
  declare function clampReasoningEffort<T extends ReasoningEffort>(effort: ReasoningEffort, allowed: readonly T[]): T;
563
573
  declare const toOpenAIEffort: (effort: ReasoningEffort) => OpenAIReasoningEffort;
@@ -568,6 +578,8 @@ declare const toDeepSeekEffort: (effort: ReasoningEffort) => DeepSeekReasoningEf
568
578
  declare const toMetaEffort: (effort: ReasoningEffort) => MetaReasoningEffort;
569
579
  declare const toFuguEffort: (effort: ReasoningEffort) => FuguReasoningEffort;
570
580
  declare const toMistralEffort: (effort: ReasoningEffort) => MistralReasoningEffort;
581
+ declare const toXaiEffort: (effort: ReasoningEffort) => XaiReasoningEffort;
582
+ declare const toKimiEffort: (effort: ReasoningEffort) => KimiReasoningEffort;
571
583
 
572
584
  /**
573
585
  * Unified token usage utilities for all AI providers
@@ -1535,6 +1547,14 @@ declare class GrokAgent extends AbstractAgent {
1535
1547
  * Reasoning extraction and token accounting are identical to askWithZodSchema.
1536
1548
  */
1537
1549
  doAskText(messages: AIMessage[]): Promise<[string, string, TokenUsage$1?, string?]>;
1550
+ /**
1551
+ * A stable key per (game, bot) so xAI routes this conversation's requests to the same
1552
+ * server. Without it a request often lands on a cache-cold machine and the whole prompt
1553
+ * bills at full input price — xAI calls this out as the most common caching mistake.
1554
+ * Falls back to the bot name alone outside a game (story generation, tests), which is
1555
+ * still stabler than sending nothing.
1556
+ */
1557
+ private get promptCacheKey();
1538
1558
  private createResponse;
1539
1559
  /**
1540
1560
  * Converts game history to Responses API input items. The system instruction is
@@ -1722,4 +1742,4 @@ declare class MiniMaxAgent extends AbstractAgent {
1722
1742
  doAskText(messages: AIMessage[]): Promise<[string, string, TokenUsage$1?, string?]>;
1723
1743
  }
1724
1744
 
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 };
1745
+ 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, KIMI_REASONING_EFFORTS, KimiAgent, type KimiReasoningEffort, 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, XAI_REASONING_EFFORTS, type XaiReasoningEffort, 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, toKimiEffort, toMetaEffort, toMistralEffort, toOpenAIEffort, toXaiEffort, transcribeWithGemini, transcribeWithOpenAi, validateResponse };
package/dist/index.js CHANGED
@@ -55,6 +55,7 @@ __export(src_exports, {
55
55
  Gpt5Agent: () => Gpt5Agent,
56
56
  GrokAgent: () => GrokAgent,
57
57
  InMemorySpendStore: () => InMemorySpendStore,
58
+ KIMI_REASONING_EFFORTS: () => KIMI_REASONING_EFFORTS,
58
59
  KimiAgent: () => KimiAgent,
59
60
  LLM_CONSTANTS: () => LLM_CONSTANTS,
60
61
  MESSAGE_ROLE: () => MESSAGE_ROLE,
@@ -83,6 +84,7 @@ __export(src_exports, {
83
84
  VOICE_MODEL_PRICING: () => VOICE_MODEL_PRICING,
84
85
  VOICE_PROVIDER_API_KEY: () => VOICE_PROVIDER_API_KEY,
85
86
  VoiceAgentFactory: () => VoiceAgentFactory,
87
+ XAI_REASONING_EFFORTS: () => XAI_REASONING_EFFORTS,
86
88
  ZodSchemaConverter: () => ZodSchemaConverter,
87
89
  applySpend: () => applySpend,
88
90
  buildGoogleTtsPrompt: () => buildGoogleTtsPrompt,
@@ -160,9 +162,11 @@ __export(src_exports, {
160
162
  toFuguEffort: () => toFuguEffort,
161
163
  toGeminiEffort: () => toGeminiEffort,
162
164
  toGlmEffort: () => toGlmEffort,
165
+ toKimiEffort: () => toKimiEffort,
163
166
  toMetaEffort: () => toMetaEffort,
164
167
  toMistralEffort: () => toMistralEffort,
165
168
  toOpenAIEffort: () => toOpenAIEffort,
169
+ toXaiEffort: () => toXaiEffort,
166
170
  transcribeWithGemini: () => transcribeWithGemini,
167
171
  transcribeWithOpenAi: () => transcribeWithOpenAi,
168
172
  validateResponse: () => validateResponse
@@ -1140,6 +1144,7 @@ var SupportedAiModels = {
1140
1144
  modelApiName: "grok-4.7",
1141
1145
  apiKeyName: API_KEY_CONSTANTS.GROK,
1142
1146
  hasThinking: true,
1147
+ reasoningEffort: "high",
1143
1148
  temperature: 0.7
1144
1149
  },
1145
1150
  // Mistral models. Two hybrid entries since 2026-09-18: reasoning is off by default on the
@@ -1188,6 +1193,9 @@ var SupportedAiModels = {
1188
1193
  hasThinking: true,
1189
1194
  // Temperature is omitted from the request: kimi-k3 rejects any value other than 1.
1190
1195
  // Speed samples: 17s (2026-08-04) and 28.9s (2026-08-05) — graded into the >25s tier.
1196
+ // Pinned 'high' 2026-09-22, down from Moonshot's 'max' default: K3 had no levels at
1197
+ // launch and the agent hardcoded max, so this is the first time the knob exists.
1198
+ reasoningEffort: "high",
1191
1199
  tags: ["very-slow", "expensive"]
1192
1200
  },
1193
1201
  // Z.AI models — thinking-only entry (non-thinking variant retired 2026-08-05)
@@ -1701,6 +1709,8 @@ var DEEPSEEK_REASONING_EFFORTS = ["low", "high", "max"];
1701
1709
  var FUGU_REASONING_EFFORTS = ["high", "xhigh", "max"];
1702
1710
  var META_REASONING_EFFORTS = ["minimal", "low", "medium", "high", "xhigh", "max"];
1703
1711
  var MISTRAL_REASONING_EFFORTS = ["minimal", "low", "medium", "high", "xhigh"];
1712
+ var XAI_REASONING_EFFORTS = ["low", "medium", "high", "xhigh"];
1713
+ var KIMI_REASONING_EFFORTS = ["low", "high", "max"];
1704
1714
  function clampReasoningEffort(effort, allowed) {
1705
1715
  const rank = REASONING_EFFORT_SCALE.indexOf(effort);
1706
1716
  let best = allowed[0];
@@ -1722,6 +1732,8 @@ var toDeepSeekEffort = (effort) => clampReasoningEffort(effort, DEEPSEEK_REASONI
1722
1732
  var toMetaEffort = (effort) => clampReasoningEffort(effort, META_REASONING_EFFORTS);
1723
1733
  var toFuguEffort = (effort) => clampReasoningEffort(effort, FUGU_REASONING_EFFORTS);
1724
1734
  var toMistralEffort = (effort) => clampReasoningEffort(effort, MISTRAL_REASONING_EFFORTS);
1735
+ var toXaiEffort = (effort) => clampReasoningEffort(effort, XAI_REASONING_EFFORTS);
1736
+ var toKimiEffort = (effort) => clampReasoningEffort(effort, KIMI_REASONING_EFFORTS);
1725
1737
 
1726
1738
  // src/pricing/token-usage-utils.ts
1727
1739
  function extractTokenUsage(response) {
@@ -3959,6 +3971,16 @@ ${schemaDescription}`;
3959
3971
  throw new Error(this.errorMessages.apiError(error));
3960
3972
  }
3961
3973
  }
3974
+ /**
3975
+ * A stable key per (game, bot) so xAI routes this conversation's requests to the same
3976
+ * server. Without it a request often lands on a cache-cold machine and the whole prompt
3977
+ * bills at full input price — xAI calls this out as the most common caching mistake.
3978
+ * Falls back to the bot name alone outside a game (story generation, tests), which is
3979
+ * still stabler than sending nothing.
3980
+ */
3981
+ get promptCacheKey() {
3982
+ return this.gameId ? `${this.gameId}:${this.name}` : this.name;
3983
+ }
3962
3984
  createResponse(input, jsonMode) {
3963
3985
  return this.client.responses.create({
3964
3986
  model: this.model,
@@ -3969,9 +3991,16 @@ ${schemaDescription}`;
3969
3991
  // ever starts truncating — measured turns peak far below the shared default.
3970
3992
  max_output_tokens: this.maxOutputTokens,
3971
3993
  // We manage conversation state ourselves; encrypted reasoning is only
3972
- // returned for unstored responses.
3994
+ // returned for unstored responses. Grok 4.7 returns reasoning.encrypted_content
3995
+ // on the Responses API whether or not `include` asks for it; we keep asking so
3996
+ // the behaviour is identical if the model is ever pointed back at 4.6.
3973
3997
  store: false,
3974
3998
  include: ["reasoning.encrypted_content"],
3999
+ prompt_cache_key: this.promptCacheKey,
4000
+ // Grok 4.7 is the first Grok with an effort knob (4.6 had none) and defaults to
4001
+ // "high". Only send it when the catalog asks for a level, so an unset entry keeps
4002
+ // the provider default rather than us silently picking one.
4003
+ ...this.reasoningEffort ? { reasoning: { effort: toXaiEffort(this.reasoningEffort) } } : {},
3975
4004
  ...jsonMode ? { text: { format: { type: "json_object" } } } : {}
3976
4005
  });
3977
4006
  }
@@ -4079,8 +4108,8 @@ var KimiAgent = class extends AbstractAgent {
4079
4108
  model: this.model,
4080
4109
  stream: false,
4081
4110
  max_tokens: this.maxOutputTokens,
4082
- // Moonshot's only accepted level; "max" is not in the OpenAI SDK's ReasoningEffort union.
4083
- reasoning_effort: "max"
4111
+ // "max" is not in the OpenAI SDK's ReasoningEffort union, hence the cast.
4112
+ reasoning_effort: toKimiEffort(this.reasoningEffort ?? "max")
4084
4113
  };
4085
4114
  }
4086
4115
  // Log message templates
@@ -5357,6 +5386,7 @@ var AgentFactory = class {
5357
5386
  Gpt5Agent,
5358
5387
  GrokAgent,
5359
5388
  InMemorySpendStore,
5389
+ KIMI_REASONING_EFFORTS,
5360
5390
  KimiAgent,
5361
5391
  LLM_CONSTANTS,
5362
5392
  MESSAGE_ROLE,
@@ -5385,6 +5415,7 @@ var AgentFactory = class {
5385
5415
  VOICE_MODEL_PRICING,
5386
5416
  VOICE_PROVIDER_API_KEY,
5387
5417
  VoiceAgentFactory,
5418
+ XAI_REASONING_EFFORTS,
5388
5419
  ZodSchemaConverter,
5389
5420
  applySpend,
5390
5421
  buildGoogleTtsPrompt,
@@ -5462,9 +5493,11 @@ var AgentFactory = class {
5462
5493
  toFuguEffort,
5463
5494
  toGeminiEffort,
5464
5495
  toGlmEffort,
5496
+ toKimiEffort,
5465
5497
  toMetaEffort,
5466
5498
  toMistralEffort,
5467
5499
  toOpenAIEffort,
5500
+ toXaiEffort,
5468
5501
  transcribeWithGemini,
5469
5502
  transcribeWithOpenAi,
5470
5503
  validateResponse