@hiper2d/ai-agents 0.30.0 → 0.31.1

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
@@ -394,6 +394,7 @@ declare const LLM_CONSTANTS: {
394
394
  GEMINI_FLASH: string;
395
395
  GEMINI_LITE: string;
396
396
  MISTRAL_SMALL: string;
397
+ MISTRAL_LARGE: string;
397
398
  GROK: string;
398
399
  KIMI: string;
399
400
  KIMI_HIGHSPEED: string;
@@ -571,10 +572,14 @@ declare function getProviderSignatureFields(aiType: string, signature?: string):
571
572
  * - Meta Muse Spark (verified 2026-09-12): minimal|low|medium|high|xhigh|max ("none" → 400; max is
572
573
  * Standard tier only)
573
574
  * - Mistral Small 4 / Medium 3.5 / Large 4: the documented API enum is
574
- * none|minimal|low|medium|high|xhigh, but every model we run accepts only "none" and "high"
575
- * (each other value is a 400 "not supported for this model, supported values: [high, none]",
576
- * checked on all three 2026-10-06). Reasoning is OFF unless the field is sent; "none" means
577
- * "don't reason", which an agent expresses by omitting the field, so the slice is just high.
575
+ * none|minimal|low|medium|high|xhigh, but Small 4 accepts only "none" and "high" (each other
576
+ * value is a 400 "not supported for this model, supported values: [high, none]", checked
577
+ * 2026-10-06). Large 4 takes low|medium|high since at least 2026-10-30 (its 400 for "none"
578
+ * lists exactly those), but the level barely changed its latency or trace size on real game
579
+ * turns and it is pinned to the documented "high" default, so the shared slice stays just
580
+ * high: a lower request on Large clamps up rather than risk a 400 on Small. Reasoning is OFF
581
+ * on Small unless the field is sent ("none" = "don't reason", which an agent expresses by
582
+ * omitting the field); Large reasons even when the field is omitted.
578
583
  * - xAI Grok 4.7 (docs.x.ai/developers/model-capabilities/text/reasoning, 2026-09-22):
579
584
  * low|medium|high|xhigh, default high, sent on the Responses API as `reasoning: {effort}`.
580
585
  * Chat Completions has no equivalent. Grok 4.6 and earlier had no knob at all.
@@ -1660,9 +1665,8 @@ declare class DeepSeekV2Agent extends AbstractAgent {
1660
1665
  * New method using Zod with DeepSeek API
1661
1666
  * This provides better schema handling and runtime validation
1662
1667
  *
1663
- * DeepSeek V4 uses thinking toggle via extra_body. JSON mode (response_format
1664
- * json_object) is supported with or without thinking, so we always request it.
1665
- * Thinking additionally surfaces reasoning via reasoning_content.
1668
+ * DeepSeek V4 uses thinking toggle via extra_body; reasoning comes back in
1669
+ * reasoning_content. No JSON mode (response_format json_object), see below.
1666
1670
  */
1667
1671
  doAskWithZodSchema<T>(zodSchema: z.ZodSchema<T>, messages: AIMessage[]): Promise<[T, string, TokenUsage$1?, string?]>;
1668
1672
  /**
package/dist/index.d.ts CHANGED
@@ -394,6 +394,7 @@ declare const LLM_CONSTANTS: {
394
394
  GEMINI_FLASH: string;
395
395
  GEMINI_LITE: string;
396
396
  MISTRAL_SMALL: string;
397
+ MISTRAL_LARGE: string;
397
398
  GROK: string;
398
399
  KIMI: string;
399
400
  KIMI_HIGHSPEED: string;
@@ -571,10 +572,14 @@ declare function getProviderSignatureFields(aiType: string, signature?: string):
571
572
  * - Meta Muse Spark (verified 2026-09-12): minimal|low|medium|high|xhigh|max ("none" → 400; max is
572
573
  * Standard tier only)
573
574
  * - Mistral Small 4 / Medium 3.5 / Large 4: the documented API enum is
574
- * none|minimal|low|medium|high|xhigh, but every model we run accepts only "none" and "high"
575
- * (each other value is a 400 "not supported for this model, supported values: [high, none]",
576
- * checked on all three 2026-10-06). Reasoning is OFF unless the field is sent; "none" means
577
- * "don't reason", which an agent expresses by omitting the field, so the slice is just high.
575
+ * none|minimal|low|medium|high|xhigh, but Small 4 accepts only "none" and "high" (each other
576
+ * value is a 400 "not supported for this model, supported values: [high, none]", checked
577
+ * 2026-10-06). Large 4 takes low|medium|high since at least 2026-10-30 (its 400 for "none"
578
+ * lists exactly those), but the level barely changed its latency or trace size on real game
579
+ * turns and it is pinned to the documented "high" default, so the shared slice stays just
580
+ * high: a lower request on Large clamps up rather than risk a 400 on Small. Reasoning is OFF
581
+ * on Small unless the field is sent ("none" = "don't reason", which an agent expresses by
582
+ * omitting the field); Large reasons even when the field is omitted.
578
583
  * - xAI Grok 4.7 (docs.x.ai/developers/model-capabilities/text/reasoning, 2026-09-22):
579
584
  * low|medium|high|xhigh, default high, sent on the Responses API as `reasoning: {effort}`.
580
585
  * Chat Completions has no equivalent. Grok 4.6 and earlier had no knob at all.
@@ -1660,9 +1665,8 @@ declare class DeepSeekV2Agent extends AbstractAgent {
1660
1665
  * New method using Zod with DeepSeek API
1661
1666
  * This provides better schema handling and runtime validation
1662
1667
  *
1663
- * DeepSeek V4 uses thinking toggle via extra_body. JSON mode (response_format
1664
- * json_object) is supported with or without thinking, so we always request it.
1665
- * Thinking additionally surfaces reasoning via reasoning_content.
1668
+ * DeepSeek V4 uses thinking toggle via extra_body; reasoning comes back in
1669
+ * reasoning_content. No JSON mode (response_format json_object), see below.
1666
1670
  */
1667
1671
  doAskWithZodSchema<T>(zodSchema: z.ZodSchema<T>, messages: AIMessage[]): Promise<[T, string, TokenUsage$1?, string?]>;
1668
1672
  /**
package/dist/index.js CHANGED
@@ -1026,6 +1026,8 @@ var LLM_CONSTANTS = {
1026
1026
  GEMINI_FLASH: "gemini-flash",
1027
1027
  GEMINI_LITE: "gemini-lite",
1028
1028
  MISTRAL_SMALL: "mistral-small",
1029
+ // Version-free id (Large 3 used it until 2026-09-18; Large 4 took it over 2026-10-06).
1030
+ MISTRAL_LARGE: "mistral-large",
1029
1031
  GROK: "grok",
1030
1032
  KIMI: "kimi",
1031
1033
  // Kimi K3.1 Pro Highspeed: the same model served 2-3x faster at 2x the price (added
@@ -1265,7 +1267,7 @@ var SupportedAiModels = {
1265
1267
  // at medium effort; the 15-character story pipeline took 213s on 2026-10-07.
1266
1268
  tags: ["very-slow"]
1267
1269
  },
1268
- // Mistral models. One hybrid entry: reasoning is off by default on the API and switched on
1270
+ // Mistral models. Two hybrid entries: reasoning is off by default on the API and switched on
1269
1271
  // per request with `reasoning_effort` (see mistral-agent.ts); the trace comes back as a
1270
1272
  // `thinking` content chunk and works with json_schema structured output (verified live
1271
1273
  // 2026-09-18). Pinned to 'high' — the only level Mistral's docs describe ("full thinking
@@ -1286,12 +1288,27 @@ var SupportedAiModels = {
1286
1288
  // `magistral-medium-latest` as one entry — so Magistral seats had silently become Medium
1287
1289
  // seats already. Consumers map both retired ids onto Small (Medium itself is gone since 0.21.0).
1288
1290
  //
1289
- // Mistral Large 4 (`mistral-large-4`, $0.68/$2.09, $0.07 cached) was added in 0.19.0 and
1290
- // removed in 0.19.1 (2026-10-06/07): too slow to play. Like Small/Medium it accepts only
1291
- // reasoning_effort high|none, and unlike them it reasons when the field is omitted. At high
1292
- // a realistic day-2 vote took 25-154s (half past the 60s timeout) and its parallel story
1293
- // batches finished ~100s apart (Mistral served them one at a time: ~6 min per story). Off,
1294
- // it answers in ~1s with no trace. Re-test before re-adding.
1291
+ // Mistral Large 4 (`mistral-large-4`, released 2026-10-06 in public preview) was added in
1292
+ // 0.19.0 and removed in 0.19.1 the next day: at launch a realistic day-2 vote took 25-154s
1293
+ // (half past the 60s timeout) and the story batches finished ~100s apart. Re-tested
1294
+ // 2026-10-30 on the same requests and RE-ADDED in 0.31.0: 19 day-2 votes ran 6-25s (median
1295
+ // ~14s, no timeouts, 760-3,100 output tokens, $0.002-0.011 each) and the 15-character story
1296
+ // pipeline 114-118s — the launch-week slowness was serving load, since `high` is fast now
1297
+ // too. Two things still hold: Mistral serves our parallel sheet batches one at a time
1298
+ // (~22-25s each, finishing 22/50/77/99s), so story time scales with the lobby; and the
1299
+ // model reasons when the field is omitted. The API now takes low|medium|high on Large 4
1300
+ // (the 400 for `none` lists exactly those; Small still takes only high|none); the level
1301
+ // barely moved latency or trace size (4-12k chars at every level), so it stays on the
1302
+ // documented 'high' default. Model list: 1M context. Tagged `slow`: the 15-25s band.
1303
+ [LLM_CONSTANTS.MISTRAL_LARGE]: {
1304
+ displayName: "Mistral Large 4",
1305
+ // `mistral-large-latest` still points at Large 3 (no reasoning); use the explicit id.
1306
+ modelApiName: "mistral-large-4",
1307
+ apiKeyName: API_KEY_CONSTANTS.MISTRAL,
1308
+ hasThinking: true,
1309
+ reasoningEffort: "high",
1310
+ tags: ["slow"]
1311
+ },
1295
1312
  [LLM_CONSTANTS.MISTRAL_SMALL]: {
1296
1313
  displayName: "Mistral 4 Small",
1297
1314
  // Resolves to mistral-small-2603 (Small 4), which also carries the magistral-small alias.
@@ -1749,6 +1766,13 @@ var MODEL_PRICING = {
1749
1766
  outputPrice: 0.6,
1750
1767
  cacheHitPrice: 0.015
1751
1768
  },
1769
+ // Large 4: docs.mistral.ai/models/mistral-large-4-0, read 2026-10-30 ($0.70 / $0.07 cached /
1770
+ // $2.10). The $0.68/$2.09 recorded in 0.19.0 was the two-week launch discount.
1771
+ [SupportedAiModels[LLM_CONSTANTS.MISTRAL_LARGE].modelApiName]: {
1772
+ inputPrice: 0.7,
1773
+ outputPrice: 2.1,
1774
+ cacheHitPrice: 0.07
1775
+ },
1752
1776
  // Grok models. Cached price is per-model on xAI (not a uniform ratio):
1753
1777
  // grok-4.7 is $0.50/M cached vs $2.00/M input, and all rates double for prompts
1754
1778
  // >= 200K tokens, per docs.x.ai/docs/models (re-verified 2026-09-22 for 4.7).
@@ -1828,7 +1852,8 @@ var HYBRID_THINKING_API_NAMES = /* @__PURE__ */ new Set([
1828
1852
  // MiniMax left the set 2026-10-27: M3.1 Flash cannot turn thinking off (M3 could).
1829
1853
  // Mistral reasons only when asked (`reasoning_effort`), and we always ask — hybrid by the
1830
1854
  // same definition as Qwen. Added 2026-09-18 when the Mistral entries went thinking-on.
1831
- SupportedAiModels[LLM_CONSTANTS.MISTRAL_SMALL].modelApiName
1855
+ SupportedAiModels[LLM_CONSTANTS.MISTRAL_SMALL].modelApiName,
1856
+ SupportedAiModels[LLM_CONSTANTS.MISTRAL_LARGE].modelApiName
1832
1857
  ]);
1833
1858
  function isHybridThinkingModel(modelApiName) {
1834
1859
  return HYBRID_THINKING_API_NAMES.has(modelApiName);
@@ -4131,9 +4156,8 @@ ${updatedMessages[0].content}`
4131
4156
  * New method using Zod with DeepSeek API
4132
4157
  * This provides better schema handling and runtime validation
4133
4158
  *
4134
- * DeepSeek V4 uses thinking toggle via extra_body. JSON mode (response_format
4135
- * json_object) is supported with or without thinking, so we always request it.
4136
- * Thinking additionally surfaces reasoning via reasoning_content.
4159
+ * DeepSeek V4 uses thinking toggle via extra_body; reasoning comes back in
4160
+ * reasoning_content. No JSON mode (response_format json_object), see below.
4137
4161
  */
4138
4162
  async doAskWithZodSchema(zodSchema, messages) {
4139
4163
  try {
@@ -4159,9 +4183,6 @@ ${schemaDescription}`
4159
4183
  };
4160
4184
  requestParams.messages = this.addSystemInstruction(modifiedInput);
4161
4185
  }
4162
- requestParams.response_format = {
4163
- type: "json_object"
4164
- };
4165
4186
  Object.assign(requestParams, this.thinkingParams());
4166
4187
  let response;
4167
4188
  try {
@@ -5752,6 +5773,7 @@ var AgentFactory = class {
5752
5773
  case LLM_CONSTANTS.DEEPSEEK_PRO:
5753
5774
  return new DeepSeekV2Agent(name, instruction, model.modelApiName, key, model.temperature ?? 0, shouldEnableThinking);
5754
5775
  // Mistral models
5776
+ case LLM_CONSTANTS.MISTRAL_LARGE:
5755
5777
  case LLM_CONSTANTS.MISTRAL_SMALL:
5756
5778
  return new MistralAgent(name, instruction, model.modelApiName, key, shouldEnableThinking);
5757
5779
  case LLM_CONSTANTS.KIMI: