@hiper2d/ai-agents 0.10.0 → 0.11.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 +17 -3
- package/dist/index.d.ts +17 -3
- package/dist/index.js +24 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +22 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -537,8 +537,11 @@ 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
|
-
*
|
|
541
|
-
*
|
|
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
|
+
* Qwen accepts reasoning_effort but ignores it (thinking_budget is its knob); MiniMax and Kimi
|
|
544
|
+
* expose no effort parameter.
|
|
542
545
|
*/
|
|
543
546
|
type OpenAIReasoningEffort = 'minimal' | 'low' | 'medium' | 'high' | 'xhigh';
|
|
544
547
|
type AnthropicReasoningEffort = 'low' | 'medium' | 'high' | 'xhigh' | 'max';
|
|
@@ -548,6 +551,7 @@ type DeepSeekReasoningEffort = 'low' | 'high' | 'max';
|
|
|
548
551
|
type FuguReasoningEffort = 'high' | 'xhigh' | 'max';
|
|
549
552
|
type MetaReasoningEffort = 'minimal' | 'low' | 'medium' | 'high' | 'xhigh' | 'max';
|
|
550
553
|
type MistralReasoningEffort = 'minimal' | 'low' | 'medium' | 'high' | 'xhigh';
|
|
554
|
+
type XaiReasoningEffort = 'low' | 'medium' | 'high' | 'xhigh';
|
|
551
555
|
/** The shared scale, lowest first. */
|
|
552
556
|
declare const REASONING_EFFORT_SCALE: readonly ReasoningEffort[];
|
|
553
557
|
declare const OPENAI_REASONING_EFFORTS: readonly OpenAIReasoningEffort[];
|
|
@@ -558,6 +562,7 @@ declare const DEEPSEEK_REASONING_EFFORTS: readonly DeepSeekReasoningEffort[];
|
|
|
558
562
|
declare const FUGU_REASONING_EFFORTS: readonly FuguReasoningEffort[];
|
|
559
563
|
declare const META_REASONING_EFFORTS: readonly MetaReasoningEffort[];
|
|
560
564
|
declare const MISTRAL_REASONING_EFFORTS: readonly MistralReasoningEffort[];
|
|
565
|
+
declare const XAI_REASONING_EFFORTS: readonly XaiReasoningEffort[];
|
|
561
566
|
/** Clamps `effort` to the nearest level in `allowed` (by rank on the shared scale, ties go up). */
|
|
562
567
|
declare function clampReasoningEffort<T extends ReasoningEffort>(effort: ReasoningEffort, allowed: readonly T[]): T;
|
|
563
568
|
declare const toOpenAIEffort: (effort: ReasoningEffort) => OpenAIReasoningEffort;
|
|
@@ -568,6 +573,7 @@ declare const toDeepSeekEffort: (effort: ReasoningEffort) => DeepSeekReasoningEf
|
|
|
568
573
|
declare const toMetaEffort: (effort: ReasoningEffort) => MetaReasoningEffort;
|
|
569
574
|
declare const toFuguEffort: (effort: ReasoningEffort) => FuguReasoningEffort;
|
|
570
575
|
declare const toMistralEffort: (effort: ReasoningEffort) => MistralReasoningEffort;
|
|
576
|
+
declare const toXaiEffort: (effort: ReasoningEffort) => XaiReasoningEffort;
|
|
571
577
|
|
|
572
578
|
/**
|
|
573
579
|
* Unified token usage utilities for all AI providers
|
|
@@ -1535,6 +1541,14 @@ declare class GrokAgent extends AbstractAgent {
|
|
|
1535
1541
|
* Reasoning extraction and token accounting are identical to askWithZodSchema.
|
|
1536
1542
|
*/
|
|
1537
1543
|
doAskText(messages: AIMessage[]): Promise<[string, string, TokenUsage$1?, string?]>;
|
|
1544
|
+
/**
|
|
1545
|
+
* A stable key per (game, bot) so xAI routes this conversation's requests to the same
|
|
1546
|
+
* server. Without it a request often lands on a cache-cold machine and the whole prompt
|
|
1547
|
+
* bills at full input price — xAI calls this out as the most common caching mistake.
|
|
1548
|
+
* Falls back to the bot name alone outside a game (story generation, tests), which is
|
|
1549
|
+
* still stabler than sending nothing.
|
|
1550
|
+
*/
|
|
1551
|
+
private get promptCacheKey();
|
|
1538
1552
|
private createResponse;
|
|
1539
1553
|
/**
|
|
1540
1554
|
* Converts game history to Responses API input items. The system instruction is
|
|
@@ -1722,4 +1736,4 @@ declare class MiniMaxAgent extends AbstractAgent {
|
|
|
1722
1736
|
doAskText(messages: AIMessage[]): Promise<[string, string, TokenUsage$1?, string?]>;
|
|
1723
1737
|
}
|
|
1724
1738
|
|
|
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 };
|
|
1739
|
+
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, 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, toMetaEffort, toMistralEffort, toOpenAIEffort, toXaiEffort, transcribeWithGemini, transcribeWithOpenAi, validateResponse };
|
package/dist/index.d.ts
CHANGED
|
@@ -537,8 +537,11 @@ 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
|
-
*
|
|
541
|
-
*
|
|
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
|
+
* Qwen accepts reasoning_effort but ignores it (thinking_budget is its knob); MiniMax and Kimi
|
|
544
|
+
* expose no effort parameter.
|
|
542
545
|
*/
|
|
543
546
|
type OpenAIReasoningEffort = 'minimal' | 'low' | 'medium' | 'high' | 'xhigh';
|
|
544
547
|
type AnthropicReasoningEffort = 'low' | 'medium' | 'high' | 'xhigh' | 'max';
|
|
@@ -548,6 +551,7 @@ type DeepSeekReasoningEffort = 'low' | 'high' | 'max';
|
|
|
548
551
|
type FuguReasoningEffort = 'high' | 'xhigh' | 'max';
|
|
549
552
|
type MetaReasoningEffort = 'minimal' | 'low' | 'medium' | 'high' | 'xhigh' | 'max';
|
|
550
553
|
type MistralReasoningEffort = 'minimal' | 'low' | 'medium' | 'high' | 'xhigh';
|
|
554
|
+
type XaiReasoningEffort = 'low' | 'medium' | 'high' | 'xhigh';
|
|
551
555
|
/** The shared scale, lowest first. */
|
|
552
556
|
declare const REASONING_EFFORT_SCALE: readonly ReasoningEffort[];
|
|
553
557
|
declare const OPENAI_REASONING_EFFORTS: readonly OpenAIReasoningEffort[];
|
|
@@ -558,6 +562,7 @@ declare const DEEPSEEK_REASONING_EFFORTS: readonly DeepSeekReasoningEffort[];
|
|
|
558
562
|
declare const FUGU_REASONING_EFFORTS: readonly FuguReasoningEffort[];
|
|
559
563
|
declare const META_REASONING_EFFORTS: readonly MetaReasoningEffort[];
|
|
560
564
|
declare const MISTRAL_REASONING_EFFORTS: readonly MistralReasoningEffort[];
|
|
565
|
+
declare const XAI_REASONING_EFFORTS: readonly XaiReasoningEffort[];
|
|
561
566
|
/** Clamps `effort` to the nearest level in `allowed` (by rank on the shared scale, ties go up). */
|
|
562
567
|
declare function clampReasoningEffort<T extends ReasoningEffort>(effort: ReasoningEffort, allowed: readonly T[]): T;
|
|
563
568
|
declare const toOpenAIEffort: (effort: ReasoningEffort) => OpenAIReasoningEffort;
|
|
@@ -568,6 +573,7 @@ declare const toDeepSeekEffort: (effort: ReasoningEffort) => DeepSeekReasoningEf
|
|
|
568
573
|
declare const toMetaEffort: (effort: ReasoningEffort) => MetaReasoningEffort;
|
|
569
574
|
declare const toFuguEffort: (effort: ReasoningEffort) => FuguReasoningEffort;
|
|
570
575
|
declare const toMistralEffort: (effort: ReasoningEffort) => MistralReasoningEffort;
|
|
576
|
+
declare const toXaiEffort: (effort: ReasoningEffort) => XaiReasoningEffort;
|
|
571
577
|
|
|
572
578
|
/**
|
|
573
579
|
* Unified token usage utilities for all AI providers
|
|
@@ -1535,6 +1541,14 @@ declare class GrokAgent extends AbstractAgent {
|
|
|
1535
1541
|
* Reasoning extraction and token accounting are identical to askWithZodSchema.
|
|
1536
1542
|
*/
|
|
1537
1543
|
doAskText(messages: AIMessage[]): Promise<[string, string, TokenUsage$1?, string?]>;
|
|
1544
|
+
/**
|
|
1545
|
+
* A stable key per (game, bot) so xAI routes this conversation's requests to the same
|
|
1546
|
+
* server. Without it a request often lands on a cache-cold machine and the whole prompt
|
|
1547
|
+
* bills at full input price — xAI calls this out as the most common caching mistake.
|
|
1548
|
+
* Falls back to the bot name alone outside a game (story generation, tests), which is
|
|
1549
|
+
* still stabler than sending nothing.
|
|
1550
|
+
*/
|
|
1551
|
+
private get promptCacheKey();
|
|
1538
1552
|
private createResponse;
|
|
1539
1553
|
/**
|
|
1540
1554
|
* Converts game history to Responses API input items. The system instruction is
|
|
@@ -1722,4 +1736,4 @@ declare class MiniMaxAgent extends AbstractAgent {
|
|
|
1722
1736
|
doAskText(messages: AIMessage[]): Promise<[string, string, TokenUsage$1?, string?]>;
|
|
1723
1737
|
}
|
|
1724
1738
|
|
|
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 };
|
|
1739
|
+
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, 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, toMetaEffort, toMistralEffort, toOpenAIEffort, toXaiEffort, transcribeWithGemini, transcribeWithOpenAi, validateResponse };
|
package/dist/index.js
CHANGED
|
@@ -83,6 +83,7 @@ __export(src_exports, {
|
|
|
83
83
|
VOICE_MODEL_PRICING: () => VOICE_MODEL_PRICING,
|
|
84
84
|
VOICE_PROVIDER_API_KEY: () => VOICE_PROVIDER_API_KEY,
|
|
85
85
|
VoiceAgentFactory: () => VoiceAgentFactory,
|
|
86
|
+
XAI_REASONING_EFFORTS: () => XAI_REASONING_EFFORTS,
|
|
86
87
|
ZodSchemaConverter: () => ZodSchemaConverter,
|
|
87
88
|
applySpend: () => applySpend,
|
|
88
89
|
buildGoogleTtsPrompt: () => buildGoogleTtsPrompt,
|
|
@@ -163,6 +164,7 @@ __export(src_exports, {
|
|
|
163
164
|
toMetaEffort: () => toMetaEffort,
|
|
164
165
|
toMistralEffort: () => toMistralEffort,
|
|
165
166
|
toOpenAIEffort: () => toOpenAIEffort,
|
|
167
|
+
toXaiEffort: () => toXaiEffort,
|
|
166
168
|
transcribeWithGemini: () => transcribeWithGemini,
|
|
167
169
|
transcribeWithOpenAi: () => transcribeWithOpenAi,
|
|
168
170
|
validateResponse: () => validateResponse
|
|
@@ -1701,6 +1703,7 @@ var DEEPSEEK_REASONING_EFFORTS = ["low", "high", "max"];
|
|
|
1701
1703
|
var FUGU_REASONING_EFFORTS = ["high", "xhigh", "max"];
|
|
1702
1704
|
var META_REASONING_EFFORTS = ["minimal", "low", "medium", "high", "xhigh", "max"];
|
|
1703
1705
|
var MISTRAL_REASONING_EFFORTS = ["minimal", "low", "medium", "high", "xhigh"];
|
|
1706
|
+
var XAI_REASONING_EFFORTS = ["low", "medium", "high", "xhigh"];
|
|
1704
1707
|
function clampReasoningEffort(effort, allowed) {
|
|
1705
1708
|
const rank = REASONING_EFFORT_SCALE.indexOf(effort);
|
|
1706
1709
|
let best = allowed[0];
|
|
@@ -1722,6 +1725,7 @@ var toDeepSeekEffort = (effort) => clampReasoningEffort(effort, DEEPSEEK_REASONI
|
|
|
1722
1725
|
var toMetaEffort = (effort) => clampReasoningEffort(effort, META_REASONING_EFFORTS);
|
|
1723
1726
|
var toFuguEffort = (effort) => clampReasoningEffort(effort, FUGU_REASONING_EFFORTS);
|
|
1724
1727
|
var toMistralEffort = (effort) => clampReasoningEffort(effort, MISTRAL_REASONING_EFFORTS);
|
|
1728
|
+
var toXaiEffort = (effort) => clampReasoningEffort(effort, XAI_REASONING_EFFORTS);
|
|
1725
1729
|
|
|
1726
1730
|
// src/pricing/token-usage-utils.ts
|
|
1727
1731
|
function extractTokenUsage(response) {
|
|
@@ -3959,6 +3963,16 @@ ${schemaDescription}`;
|
|
|
3959
3963
|
throw new Error(this.errorMessages.apiError(error));
|
|
3960
3964
|
}
|
|
3961
3965
|
}
|
|
3966
|
+
/**
|
|
3967
|
+
* A stable key per (game, bot) so xAI routes this conversation's requests to the same
|
|
3968
|
+
* server. Without it a request often lands on a cache-cold machine and the whole prompt
|
|
3969
|
+
* bills at full input price — xAI calls this out as the most common caching mistake.
|
|
3970
|
+
* Falls back to the bot name alone outside a game (story generation, tests), which is
|
|
3971
|
+
* still stabler than sending nothing.
|
|
3972
|
+
*/
|
|
3973
|
+
get promptCacheKey() {
|
|
3974
|
+
return this.gameId ? `${this.gameId}:${this.name}` : this.name;
|
|
3975
|
+
}
|
|
3962
3976
|
createResponse(input, jsonMode) {
|
|
3963
3977
|
return this.client.responses.create({
|
|
3964
3978
|
model: this.model,
|
|
@@ -3969,9 +3983,16 @@ ${schemaDescription}`;
|
|
|
3969
3983
|
// ever starts truncating — measured turns peak far below the shared default.
|
|
3970
3984
|
max_output_tokens: this.maxOutputTokens,
|
|
3971
3985
|
// We manage conversation state ourselves; encrypted reasoning is only
|
|
3972
|
-
// returned for unstored responses.
|
|
3986
|
+
// returned for unstored responses. Grok 4.7 returns reasoning.encrypted_content
|
|
3987
|
+
// on the Responses API whether or not `include` asks for it; we keep asking so
|
|
3988
|
+
// the behaviour is identical if the model is ever pointed back at 4.6.
|
|
3973
3989
|
store: false,
|
|
3974
3990
|
include: ["reasoning.encrypted_content"],
|
|
3991
|
+
prompt_cache_key: this.promptCacheKey,
|
|
3992
|
+
// Grok 4.7 is the first Grok with an effort knob (4.6 had none) and defaults to
|
|
3993
|
+
// "high". Only send it when the catalog asks for a level, so an unset entry keeps
|
|
3994
|
+
// the provider default rather than us silently picking one.
|
|
3995
|
+
...this.reasoningEffort ? { reasoning: { effort: toXaiEffort(this.reasoningEffort) } } : {},
|
|
3975
3996
|
...jsonMode ? { text: { format: { type: "json_object" } } } : {}
|
|
3976
3997
|
});
|
|
3977
3998
|
}
|
|
@@ -5385,6 +5406,7 @@ var AgentFactory = class {
|
|
|
5385
5406
|
VOICE_MODEL_PRICING,
|
|
5386
5407
|
VOICE_PROVIDER_API_KEY,
|
|
5387
5408
|
VoiceAgentFactory,
|
|
5409
|
+
XAI_REASONING_EFFORTS,
|
|
5388
5410
|
ZodSchemaConverter,
|
|
5389
5411
|
applySpend,
|
|
5390
5412
|
buildGoogleTtsPrompt,
|
|
@@ -5465,6 +5487,7 @@ var AgentFactory = class {
|
|
|
5465
5487
|
toMetaEffort,
|
|
5466
5488
|
toMistralEffort,
|
|
5467
5489
|
toOpenAIEffort,
|
|
5490
|
+
toXaiEffort,
|
|
5468
5491
|
transcribeWithGemini,
|
|
5469
5492
|
transcribeWithOpenAi,
|
|
5470
5493
|
validateResponse
|