@hiper2d/ai-agents 0.19.2 → 0.21.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
@@ -375,7 +375,6 @@ declare const LLM_CONSTANTS: {
375
375
  GEMINI_PRO: string;
376
376
  GEMINI_FLASH: string;
377
377
  GEMINI_LITE: string;
378
- MISTRAL_MEDIUM: string;
379
378
  MISTRAL_SMALL: string;
380
379
  GROK: string;
381
380
  KIMI: string;
@@ -1298,7 +1297,7 @@ declare abstract class AbstractAgent {
1298
1297
  * Reasoning-depth knobs, resolved once from the catalog like maxOutputTokens and, like it,
1299
1298
  * overridable per instance for calls whose profile differs from a turn (story generation
1300
1299
  * runs deeper). Each provider speaks one dialect — effort (DeepSeek, GLM, Gemini, Claude
1301
- * adaptive) or a token budget (Qwen, Claude Haiku) — and reads only the field it
1300
+ * adaptive) or a token budget (Qwen, Claude Haiku 4.5) — and reads only the field it
1302
1301
  * understands; the other is ignored. Subclasses read these when building a request.
1303
1302
  */
1304
1303
  reasoningEffort?: ReasoningEffort;
package/dist/index.d.ts CHANGED
@@ -375,7 +375,6 @@ declare const LLM_CONSTANTS: {
375
375
  GEMINI_PRO: string;
376
376
  GEMINI_FLASH: string;
377
377
  GEMINI_LITE: string;
378
- MISTRAL_MEDIUM: string;
379
378
  MISTRAL_SMALL: string;
380
379
  GROK: string;
381
380
  KIMI: string;
@@ -1298,7 +1297,7 @@ declare abstract class AbstractAgent {
1298
1297
  * Reasoning-depth knobs, resolved once from the catalog like maxOutputTokens and, like it,
1299
1298
  * overridable per instance for calls whose profile differs from a turn (story generation
1300
1299
  * runs deeper). Each provider speaks one dialect — effort (DeepSeek, GLM, Gemini, Claude
1301
- * adaptive) or a token budget (Qwen, Claude Haiku) — and reads only the field it
1300
+ * adaptive) or a token budget (Qwen, Claude Haiku 4.5) — and reads only the field it
1302
1301
  * understands; the other is ignored. Subclasses read these when building a request.
1303
1302
  */
1304
1303
  reasoningEffort?: ReasoningEffort;
package/dist/index.js CHANGED
@@ -984,7 +984,6 @@ var LLM_CONSTANTS = {
984
984
  GEMINI_PRO: "gemini-pro",
985
985
  GEMINI_FLASH: "gemini-flash",
986
986
  GEMINI_LITE: "gemini-lite",
987
- MISTRAL_MEDIUM: "mistral-medium",
988
987
  MISTRAL_SMALL: "mistral-small",
989
988
  GROK: "grok",
990
989
  KIMI: "kimi",
@@ -1038,13 +1037,19 @@ var SupportedAiModels = {
1038
1037
  reasoningEffort: "high",
1039
1038
  tags: ["expensive"]
1040
1039
  },
1040
+ // Haiku moved 4.5 → 5.5 on 2026-10-08 (`claude-haiku-5-5`, verified live with the platform
1041
+ // key). 10x cheaper ($0.10/$0.50 up to 100K-token prompts), 1M context / 128K output.
1042
+ // Adaptive thinking now (the `enabled` + budget_tokens mode 4.5 used is rejected), API
1043
+ // default effort `medium`; we pin `high` like the other Claude entries. It reads Haiku 4.5
1044
+ // thinking blocks, so games moving onto it keep the bots' earlier reasoning. 'slow' tag
1045
+ // dropped: Anthropic lists it as the fastest model in the lineup.
1041
1046
  [LLM_CONSTANTS.CLAUDE_HAIKU]: {
1042
- displayName: "Claude 4.5 Haiku",
1043
- modelApiName: "claude-haiku-4-5",
1047
+ displayName: "Claude 5.5 Haiku",
1048
+ modelApiName: "claude-haiku-5-5",
1044
1049
  apiKeyName: API_KEY_CONSTANTS.ANTHROPIC,
1045
1050
  hasThinking: true,
1046
- thinkingBudgetTokens: 1024,
1047
- tags: ["slow", "cheap"]
1051
+ reasoningEffort: "high",
1052
+ tags: ["cheap"]
1048
1053
  },
1049
1054
  // DeepSeek V4 models — thinking-only entries (non-thinking variants retired 2026-08-05).
1050
1055
  // reasoningEffort pinned to 'low' 2026-08-30: at the provider default ('high', no budget
@@ -1184,14 +1189,18 @@ var SupportedAiModels = {
1184
1189
  reasoningEffort: "medium",
1185
1190
  temperature: 0.7
1186
1191
  },
1187
- // Mistral models. Two hybrid entries since 2026-09-18: reasoning is off by default on the
1188
- // API and switched on per request with `reasoning_effort` (see mistral-agent.ts); the trace
1189
- // comes back as a `thinking` content chunk and works with json_schema structured output
1190
- // (verified live 2026-09-18 on both). Pinned to 'high' — the only level Mistral's docs
1191
- // describe ("full thinking chunk before the final answer"); Small is cheap enough that the
1192
- // extra tokens don't matter, Medium's are priced into its free-tier band via the hybrid
1193
- // multiplier. Live 2026-09-18 (one short schema ask each): Small 1.7s with a ~600-char
1194
- // trace, Medium 3.8s with ~2000 chars — Medium's trace ran ~15x its answer length.
1192
+ // Mistral models. One hybrid entry: reasoning is off by default on the API and switched on
1193
+ // per request with `reasoning_effort` (see mistral-agent.ts); the trace comes back as a
1194
+ // `thinking` content chunk and works with json_schema structured output (verified live
1195
+ // 2026-09-18). Pinned to 'high' — the only level Mistral's docs describe ("full thinking
1196
+ // chunk before the final answer"); Small is cheap enough that the extra tokens don't
1197
+ // matter. Live 2026-09-18 (one short schema ask): 1.7s with a ~600-char trace.
1198
+ //
1199
+ // Mistral Medium 3.5 (`mistral-medium-3-5`, $1.5/$7.5, $0.15 cached) was removed in 0.21.0
1200
+ // (2026-10-10): too slow and too expensive at the only reasoning level it takes (high|none).
1201
+ // Production 2026-10-03..10: p50 15.9s, p90 35.1s, $0.036 a request (2x Gemini 3.1 Pro,
1202
+ // 19x Small; reasoning spiked to 15-24k tokens), ~6% of calls failed (60s timeouts, empty
1203
+ // replies, empty JSON), and a 15-player story pipeline took 277s. Wait for Medium 4.
1195
1204
  //
1196
1205
  // Mistral Large 3 and Magistral Medium 1.2 were dropped 2026-09-18. Large 3 was retired by
1197
1206
  // Mistral on 2026-08-31 (the `-latest` alias still answered, but its capabilities say
@@ -1199,7 +1208,7 @@ var SupportedAiModels = {
1199
1208
  // and `magistral-medium-latest` is now literally an alias of Medium 3.5 — the model list
1200
1209
  // returns `mistral-medium-3-5`, `mistral-medium-3`, `mistral-medium-latest` and
1201
1210
  // `magistral-medium-latest` as one entry — so Magistral seats had silently become Medium
1202
- // seats already. Consumers map both retired ids onto the surviving pair.
1211
+ // seats already. Consumers map both retired ids onto Small (Medium itself is gone since 0.21.0).
1203
1212
  //
1204
1213
  // Mistral Large 4 (`mistral-large-4`, $0.68/$2.09, $0.07 cached) was added in 0.19.0 and
1205
1214
  // removed in 0.19.1 (2026-10-06/07): too slow to play. Like Small/Medium it accepts only
@@ -1207,16 +1216,6 @@ var SupportedAiModels = {
1207
1216
  // a realistic day-2 vote took 25-154s (half past the 60s timeout) and its parallel story
1208
1217
  // batches finished ~100s apart (Mistral served them one at a time: ~6 min per story). Off,
1209
1218
  // it answers in ~1s with no trace. Re-test before re-adding.
1210
- [LLM_CONSTANTS.MISTRAL_MEDIUM]: {
1211
- displayName: "Mistral Medium 3.5",
1212
- // The docs' explicit 3.5 id. It was `mistral-medium-3` until 2026-09-18, which Mistral
1213
- // now serves as an alias of the same model (Medium 3 itself retired 2026-08-31).
1214
- modelApiName: "mistral-medium-3-5",
1215
- apiKeyName: API_KEY_CONSTANTS.MISTRAL,
1216
- hasThinking: true,
1217
- reasoningEffort: "high",
1218
- tags: ["fast", "expensive"]
1219
- },
1220
1219
  [LLM_CONSTANTS.MISTRAL_SMALL]: {
1221
1220
  displayName: "Mistral 4 Small",
1222
1221
  // Resolves to mistral-small-2603 (Small 4), which also carries the magistral-small alias.
@@ -1562,9 +1561,16 @@ var MODEL_PRICING = {
1562
1561
  cacheHitPrice: 0.2
1563
1562
  },
1564
1563
  [SupportedAiModels[LLM_CONSTANTS.CLAUDE_HAIKU].modelApiName]: {
1565
- inputPrice: 1,
1566
- outputPrice: 5,
1567
- cacheHitPrice: 0.1
1564
+ // Haiku 5.5 (2026-10-07): the first Claude with a long-context tier — every rate is 5x
1565
+ // for prompts over 100K tokens (cache reads + writes count toward the prompt size,
1566
+ // which is what AnthropicAgent passes as inputTokens).
1567
+ inputPrice: 0.1,
1568
+ outputPrice: 0.5,
1569
+ cacheHitPrice: 0.01,
1570
+ extendedContextInputPrice: 0.5,
1571
+ extendedContextOutputPrice: 2.5,
1572
+ extendedContextCacheHitPrice: 0.05,
1573
+ extendedContextThresholdTokens: 1e5
1568
1574
  },
1569
1575
  // Google models
1570
1576
  [SupportedAiModels[LLM_CONSTANTS.GEMINI_PRO].modelApiName]: {
@@ -1597,11 +1603,6 @@ var MODEL_PRICING = {
1597
1603
  // the input price (documented on the prompt_cache_key param; no per-model cached prices
1598
1604
  // published). Reasoning tokens are counted inside completion_tokens — no separate
1599
1605
  // reasoning_tokens field — so the output rate already covers the trace.
1600
- [SupportedAiModels[LLM_CONSTANTS.MISTRAL_MEDIUM].modelApiName]: {
1601
- inputPrice: 1.5,
1602
- outputPrice: 7.5,
1603
- cacheHitPrice: 0.15
1604
- },
1605
1606
  [SupportedAiModels[LLM_CONSTANTS.MISTRAL_SMALL].modelApiName]: {
1606
1607
  inputPrice: 0.15,
1607
1608
  outputPrice: 0.6,
@@ -1682,8 +1683,7 @@ var HYBRID_THINKING_API_NAMES = /* @__PURE__ */ new Set([
1682
1683
  SupportedAiModels[LLM_CONSTANTS.QWEN_FLASH].modelApiName,
1683
1684
  SupportedAiModels[LLM_CONSTANTS.MINIMAX].modelApiName,
1684
1685
  // Mistral reasons only when asked (`reasoning_effort`), and we always ask — hybrid by the
1685
- // same definition as Qwen. Added 2026-09-18 when the two entries went thinking-on.
1686
- SupportedAiModels[LLM_CONSTANTS.MISTRAL_MEDIUM].modelApiName,
1686
+ // same definition as Qwen. Added 2026-09-18 when the Mistral entries went thinking-on.
1687
1687
  SupportedAiModels[LLM_CONSTANTS.MISTRAL_SMALL].modelApiName
1688
1688
  ]);
1689
1689
  function isHybridThinkingModel(modelApiName) {
@@ -2414,7 +2414,7 @@ var AbstractAgent = class {
2414
2414
  * Reasoning-depth knobs, resolved once from the catalog like maxOutputTokens and, like it,
2415
2415
  * overridable per instance for calls whose profile differs from a turn (story generation
2416
2416
  * runs deeper). Each provider speaks one dialect — effort (DeepSeek, GLM, Gemini, Claude
2417
- * adaptive) or a token budget (Qwen, Claude Haiku) — and reads only the field it
2417
+ * adaptive) or a token budget (Qwen, Claude Haiku 4.5) — and reads only the field it
2418
2418
  * understands; the other is ignored. Subclasses read these when building a request.
2419
2419
  */
2420
2420
  reasoningEffort;
@@ -2814,6 +2814,7 @@ ${instruction}`);
2814
2814
  var import_sdk = require("@anthropic-ai/sdk");
2815
2815
  var rejectsDisabledThinking = (model) => model.includes("fable") || model.includes("opus-5-5");
2816
2816
  var usesBetweenToolsForOff = (model) => model.includes("sonnet-5-5");
2817
+ var usesAdaptiveThinking = (model) => !model.includes("haiku-4");
2817
2818
  var ClaudeAgent = class extends AbstractAgent {
2818
2819
  client;
2819
2820
  /**
@@ -2835,7 +2836,8 @@ var ClaudeAgent = class extends AbstractAgent {
2835
2836
  // state writes (a lynch, the night resolution, the summary rewrite, the new
2836
2837
  // day), so every call inside one of those windows reads it.
2837
2838
  // GM prompts have no marker → single block, same behavior as before. Haiku 4.5 needs a
2838
- // 4096-token cacheable prefix, so tiers below that silently no-op on Haiku — expected.
2839
+ // 4096-token cacheable prefix, so tiers below that silently no-op there; Haiku 5.5 caches
2840
+ // from ~1024 tokens (measured 2026-10-08: a 1,083-token prefix was written, 492 was not).
2839
2841
  // A getter, not a field: `maxOutputTokens` can be raised after construction, and a field
2840
2842
  // initializer would snapshot the default and silently ignore the override.
2841
2843
  get defaultParams() {
@@ -3020,16 +3022,16 @@ ${schemaDescription}`;
3020
3022
  ...this.defaultParams,
3021
3023
  messages: anthropicMessages
3022
3024
  };
3023
- const usesAdaptiveThinking = this.model.includes("fable") || this.model.includes("opus") || this.model.includes("sonnet");
3025
+ const adaptive = usesAdaptiveThinking(this.model);
3024
3026
  if (canUseThinking) {
3025
- if (usesAdaptiveThinking) {
3027
+ if (adaptive) {
3026
3028
  params.thinking = { type: "adaptive", display: "summarized" };
3027
3029
  params.output_config = { effort: toAnthropicEffort(this.reasoningEffort ?? "high") };
3028
3030
  } else {
3029
3031
  params.thinking = { type: "enabled", budget_tokens: this.thinkingBudgetTokens ?? 1024 };
3030
3032
  params.temperature = 1;
3031
3033
  }
3032
- } else if (usesAdaptiveThinking) {
3034
+ } else if (adaptive) {
3033
3035
  if (usesBetweenToolsForOff(this.model)) {
3034
3036
  params.thinking = { type: "between_tools" };
3035
3037
  } else if (!rejectsDisabledThinking(this.model)) {
@@ -3118,16 +3120,16 @@ ${schemaDescription}`;
3118
3120
  ...this.defaultParams,
3119
3121
  messages: anthropicMessages
3120
3122
  };
3121
- const usesAdaptiveThinking = this.model.includes("fable") || this.model.includes("opus") || this.model.includes("sonnet");
3123
+ const adaptive = usesAdaptiveThinking(this.model);
3122
3124
  if (canUseThinking) {
3123
- if (usesAdaptiveThinking) {
3125
+ if (adaptive) {
3124
3126
  params.thinking = { type: "adaptive", display: "summarized" };
3125
3127
  params.output_config = { effort: toAnthropicEffort(this.reasoningEffort ?? "high") };
3126
3128
  } else {
3127
3129
  params.thinking = { type: "enabled", budget_tokens: this.thinkingBudgetTokens ?? 1024 };
3128
3130
  params.temperature = 1;
3129
3131
  }
3130
- } else if (usesAdaptiveThinking) {
3132
+ } else if (adaptive) {
3131
3133
  if (usesBetweenToolsForOff(this.model)) {
3132
3134
  params.thinking = { type: "between_tools" };
3133
3135
  } else if (!rejectsDisabledThinking(this.model)) {
@@ -5513,7 +5515,6 @@ var AgentFactory = class {
5513
5515
  case LLM_CONSTANTS.DEEPSEEK_PRO:
5514
5516
  return new DeepSeekV2Agent(name, instruction, model.modelApiName, key, model.temperature ?? 0, shouldEnableThinking);
5515
5517
  // Mistral models
5516
- case LLM_CONSTANTS.MISTRAL_MEDIUM:
5517
5518
  case LLM_CONSTANTS.MISTRAL_SMALL:
5518
5519
  return new MistralAgent(name, instruction, model.modelApiName, key, shouldEnableThinking);
5519
5520
  case LLM_CONSTANTS.KIMI: