@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.mjs CHANGED
@@ -969,6 +969,7 @@ var SupportedAiModels = {
969
969
  modelApiName: "grok-4.7",
970
970
  apiKeyName: API_KEY_CONSTANTS.GROK,
971
971
  hasThinking: true,
972
+ reasoningEffort: "high",
972
973
  temperature: 0.7
973
974
  },
974
975
  // Mistral models. Two hybrid entries since 2026-09-18: reasoning is off by default on the
@@ -1017,6 +1018,9 @@ var SupportedAiModels = {
1017
1018
  hasThinking: true,
1018
1019
  // Temperature is omitted from the request: kimi-k3 rejects any value other than 1.
1019
1020
  // Speed samples: 17s (2026-08-04) and 28.9s (2026-08-05) — graded into the >25s tier.
1021
+ // Pinned 'high' 2026-09-22, down from Moonshot's 'max' default: K3 had no levels at
1022
+ // launch and the agent hardcoded max, so this is the first time the knob exists.
1023
+ reasoningEffort: "high",
1020
1024
  tags: ["very-slow", "expensive"]
1021
1025
  },
1022
1026
  // Z.AI models — thinking-only entry (non-thinking variant retired 2026-08-05)
@@ -1530,6 +1534,8 @@ var DEEPSEEK_REASONING_EFFORTS = ["low", "high", "max"];
1530
1534
  var FUGU_REASONING_EFFORTS = ["high", "xhigh", "max"];
1531
1535
  var META_REASONING_EFFORTS = ["minimal", "low", "medium", "high", "xhigh", "max"];
1532
1536
  var MISTRAL_REASONING_EFFORTS = ["minimal", "low", "medium", "high", "xhigh"];
1537
+ var XAI_REASONING_EFFORTS = ["low", "medium", "high", "xhigh"];
1538
+ var KIMI_REASONING_EFFORTS = ["low", "high", "max"];
1533
1539
  function clampReasoningEffort(effort, allowed) {
1534
1540
  const rank = REASONING_EFFORT_SCALE.indexOf(effort);
1535
1541
  let best = allowed[0];
@@ -1551,6 +1557,8 @@ var toDeepSeekEffort = (effort) => clampReasoningEffort(effort, DEEPSEEK_REASONI
1551
1557
  var toMetaEffort = (effort) => clampReasoningEffort(effort, META_REASONING_EFFORTS);
1552
1558
  var toFuguEffort = (effort) => clampReasoningEffort(effort, FUGU_REASONING_EFFORTS);
1553
1559
  var toMistralEffort = (effort) => clampReasoningEffort(effort, MISTRAL_REASONING_EFFORTS);
1560
+ var toXaiEffort = (effort) => clampReasoningEffort(effort, XAI_REASONING_EFFORTS);
1561
+ var toKimiEffort = (effort) => clampReasoningEffort(effort, KIMI_REASONING_EFFORTS);
1554
1562
 
1555
1563
  // src/pricing/token-usage-utils.ts
1556
1564
  function extractTokenUsage(response) {
@@ -3788,6 +3796,16 @@ ${schemaDescription}`;
3788
3796
  throw new Error(this.errorMessages.apiError(error));
3789
3797
  }
3790
3798
  }
3799
+ /**
3800
+ * A stable key per (game, bot) so xAI routes this conversation's requests to the same
3801
+ * server. Without it a request often lands on a cache-cold machine and the whole prompt
3802
+ * bills at full input price — xAI calls this out as the most common caching mistake.
3803
+ * Falls back to the bot name alone outside a game (story generation, tests), which is
3804
+ * still stabler than sending nothing.
3805
+ */
3806
+ get promptCacheKey() {
3807
+ return this.gameId ? `${this.gameId}:${this.name}` : this.name;
3808
+ }
3791
3809
  createResponse(input, jsonMode) {
3792
3810
  return this.client.responses.create({
3793
3811
  model: this.model,
@@ -3798,9 +3816,16 @@ ${schemaDescription}`;
3798
3816
  // ever starts truncating — measured turns peak far below the shared default.
3799
3817
  max_output_tokens: this.maxOutputTokens,
3800
3818
  // We manage conversation state ourselves; encrypted reasoning is only
3801
- // returned for unstored responses.
3819
+ // returned for unstored responses. Grok 4.7 returns reasoning.encrypted_content
3820
+ // on the Responses API whether or not `include` asks for it; we keep asking so
3821
+ // the behaviour is identical if the model is ever pointed back at 4.6.
3802
3822
  store: false,
3803
3823
  include: ["reasoning.encrypted_content"],
3824
+ prompt_cache_key: this.promptCacheKey,
3825
+ // Grok 4.7 is the first Grok with an effort knob (4.6 had none) and defaults to
3826
+ // "high". Only send it when the catalog asks for a level, so an unset entry keeps
3827
+ // the provider default rather than us silently picking one.
3828
+ ...this.reasoningEffort ? { reasoning: { effort: toXaiEffort(this.reasoningEffort) } } : {},
3804
3829
  ...jsonMode ? { text: { format: { type: "json_object" } } } : {}
3805
3830
  });
3806
3831
  }
@@ -3908,8 +3933,8 @@ var KimiAgent = class extends AbstractAgent {
3908
3933
  model: this.model,
3909
3934
  stream: false,
3910
3935
  max_tokens: this.maxOutputTokens,
3911
- // Moonshot's only accepted level; "max" is not in the OpenAI SDK's ReasoningEffort union.
3912
- reasoning_effort: "max"
3936
+ // "max" is not in the OpenAI SDK's ReasoningEffort union, hence the cast.
3937
+ reasoning_effort: toKimiEffort(this.reasoningEffort ?? "max")
3913
3938
  };
3914
3939
  }
3915
3940
  // Log message templates
@@ -5185,6 +5210,7 @@ export {
5185
5210
  Gpt5Agent,
5186
5211
  GrokAgent,
5187
5212
  InMemorySpendStore,
5213
+ KIMI_REASONING_EFFORTS,
5188
5214
  KimiAgent,
5189
5215
  LLM_CONSTANTS,
5190
5216
  MESSAGE_ROLE,
@@ -5213,6 +5239,7 @@ export {
5213
5239
  VOICE_MODEL_PRICING,
5214
5240
  VOICE_PROVIDER_API_KEY,
5215
5241
  VoiceAgentFactory,
5242
+ XAI_REASONING_EFFORTS,
5216
5243
  ZodSchemaConverter,
5217
5244
  applySpend,
5218
5245
  buildGoogleTtsPrompt,
@@ -5290,9 +5317,11 @@ export {
5290
5317
  toFuguEffort,
5291
5318
  toGeminiEffort,
5292
5319
  toGlmEffort,
5320
+ toKimiEffort,
5293
5321
  toMetaEffort,
5294
5322
  toMistralEffort,
5295
5323
  toOpenAIEffort,
5324
+ toXaiEffort,
5296
5325
  transcribeWithGemini,
5297
5326
  transcribeWithOpenAi,
5298
5327
  validateResponse