@hiper2d/ai-agents 0.19.0 → 0.19.2

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,14 +375,12 @@ declare const LLM_CONSTANTS: {
375
375
  GEMINI_PRO: string;
376
376
  GEMINI_FLASH: string;
377
377
  GEMINI_LITE: string;
378
- MISTRAL_LARGE: string;
379
378
  MISTRAL_MEDIUM: string;
380
379
  MISTRAL_SMALL: string;
381
380
  GROK: string;
382
381
  KIMI: string;
383
382
  GLM: string;
384
383
  GLM_FLASH: string;
385
- FUGU_ULTRA: string;
386
384
  FUGU_MAX: string;
387
385
  QWEN_MAX: string;
388
386
  QWEN_FLASH: string;
@@ -553,11 +551,11 @@ declare function getProviderSignatureFields(aiType: string, signature?: string):
553
551
  * exactly that enum). The server default is xhigh for fugu-ultra and high for the rest.
554
552
  * - Meta Muse Spark (verified 2026-09-12): minimal|low|medium|high|xhigh|max ("none" → 400; max is
555
553
  * Standard tier only)
556
- * - Mistral Small 4 / Medium 3.5 (verified 2026-09-18): the API enum is
557
- * none|minimal|low|medium|high|xhigh, with reasoning OFF unless the field is sent. "none" is
558
- * not on the shared scale and means "don't reason", which an agent expresses by omitting the
559
- * field, so the exported slice starts at minimal. Only "high" is documented to return the
560
- * thinking chunk; the intermediate levels are accepted but unverified.
554
+ * - Mistral Small 4 / Medium 3.5 / Large 4: the documented API enum is
555
+ * none|minimal|low|medium|high|xhigh, but every model we run accepts only "none" and "high"
556
+ * (each other value is a 400 "not supported for this model, supported values: [high, none]",
557
+ * checked on all three 2026-10-06). Reasoning is OFF unless the field is sent; "none" means
558
+ * "don't reason", which an agent expresses by omitting the field, so the slice is just high.
561
559
  * - xAI Grok 4.7 (docs.x.ai/developers/model-capabilities/text/reasoning, 2026-09-22):
562
560
  * low|medium|high|xhigh, default high, sent on the Responses API as `reasoning: {effort}`.
563
561
  * Chat Completions has no equivalent. Grok 4.6 and earlier had no knob at all.
@@ -1488,6 +1486,13 @@ declare class Gpt5Agent extends AbstractAgent {
1488
1486
 
1489
1487
  declare class GoogleAgent extends AbstractAgent {
1490
1488
  private readonly client;
1489
+ /**
1490
+ * Sampling temperature to send, or undefined to send none. Google deprecated custom sampling
1491
+ * (notice of 2026-10): since Gemini 3.6 Flash temperature/top_p/top_k are ignored, and its
1492
+ * upcoming models reject them with a 400. So it is sent only for a catalog entry that sets
1493
+ * `temperature` (the pre-3.6 models, to keep their behaviour) — never by default.
1494
+ */
1495
+ private readonly samplingTemperature;
1491
1496
  private readonly defaultConfig;
1492
1497
  private readonly logTemplates;
1493
1498
  private readonly errorMessages;
package/dist/index.d.ts CHANGED
@@ -375,14 +375,12 @@ declare const LLM_CONSTANTS: {
375
375
  GEMINI_PRO: string;
376
376
  GEMINI_FLASH: string;
377
377
  GEMINI_LITE: string;
378
- MISTRAL_LARGE: string;
379
378
  MISTRAL_MEDIUM: string;
380
379
  MISTRAL_SMALL: string;
381
380
  GROK: string;
382
381
  KIMI: string;
383
382
  GLM: string;
384
383
  GLM_FLASH: string;
385
- FUGU_ULTRA: string;
386
384
  FUGU_MAX: string;
387
385
  QWEN_MAX: string;
388
386
  QWEN_FLASH: string;
@@ -553,11 +551,11 @@ declare function getProviderSignatureFields(aiType: string, signature?: string):
553
551
  * exactly that enum). The server default is xhigh for fugu-ultra and high for the rest.
554
552
  * - Meta Muse Spark (verified 2026-09-12): minimal|low|medium|high|xhigh|max ("none" → 400; max is
555
553
  * Standard tier only)
556
- * - Mistral Small 4 / Medium 3.5 (verified 2026-09-18): the API enum is
557
- * none|minimal|low|medium|high|xhigh, with reasoning OFF unless the field is sent. "none" is
558
- * not on the shared scale and means "don't reason", which an agent expresses by omitting the
559
- * field, so the exported slice starts at minimal. Only "high" is documented to return the
560
- * thinking chunk; the intermediate levels are accepted but unverified.
554
+ * - Mistral Small 4 / Medium 3.5 / Large 4: the documented API enum is
555
+ * none|minimal|low|medium|high|xhigh, but every model we run accepts only "none" and "high"
556
+ * (each other value is a 400 "not supported for this model, supported values: [high, none]",
557
+ * checked on all three 2026-10-06). Reasoning is OFF unless the field is sent; "none" means
558
+ * "don't reason", which an agent expresses by omitting the field, so the slice is just high.
561
559
  * - xAI Grok 4.7 (docs.x.ai/developers/model-capabilities/text/reasoning, 2026-09-22):
562
560
  * low|medium|high|xhigh, default high, sent on the Responses API as `reasoning: {effort}`.
563
561
  * Chat Completions has no equivalent. Grok 4.6 and earlier had no knob at all.
@@ -1488,6 +1486,13 @@ declare class Gpt5Agent extends AbstractAgent {
1488
1486
 
1489
1487
  declare class GoogleAgent extends AbstractAgent {
1490
1488
  private readonly client;
1489
+ /**
1490
+ * Sampling temperature to send, or undefined to send none. Google deprecated custom sampling
1491
+ * (notice of 2026-10): since Gemini 3.6 Flash temperature/top_p/top_k are ignored, and its
1492
+ * upcoming models reject them with a 400. So it is sent only for a catalog entry that sets
1493
+ * `temperature` (the pre-3.6 models, to keep their behaviour) — never by default.
1494
+ */
1495
+ private readonly samplingTemperature;
1491
1496
  private readonly defaultConfig;
1492
1497
  private readonly logTemplates;
1493
1498
  private readonly errorMessages;
package/dist/index.js CHANGED
@@ -984,16 +984,12 @@ var LLM_CONSTANTS = {
984
984
  GEMINI_PRO: "gemini-pro",
985
985
  GEMINI_FLASH: "gemini-flash",
986
986
  GEMINI_LITE: "gemini-lite",
987
- // Reused 2026-10-06 for Mistral Large 4: the old id (Large 3) was retired 2026-09-18 and
988
- // consumers had mapped it away, so the version-free id was free again.
989
- MISTRAL_LARGE: "mistral-large",
990
987
  MISTRAL_MEDIUM: "mistral-medium",
991
988
  MISTRAL_SMALL: "mistral-small",
992
989
  GROK: "grok",
993
990
  KIMI: "kimi",
994
991
  GLM: "glm",
995
992
  GLM_FLASH: "glm-flash",
996
- FUGU_ULTRA: "fugu-ultra",
997
993
  FUGU_MAX: "fugu-max",
998
994
  // Qwen (QwenCloud/DashScope). Stable picker ids without the version, matching the gpt/gemini
999
995
  // pattern, so future repoints don't orphan persisted ids.
@@ -1143,6 +1139,10 @@ var SupportedAiModels = {
1143
1139
  apiKeyName: API_KEY_CONSTANTS.GOOGLE,
1144
1140
  hasThinking: true,
1145
1141
  reasoningEffort: "high",
1142
+ // Pre-3.6: still honours sampling params, so it keeps the 0.2 GoogleAgent always sent
1143
+ // before 2026-10-07. 3.6+ ignore them and future Gemini models reject them — leave
1144
+ // `temperature` unset on every newer Gemini entry (GoogleAgent then sends none).
1145
+ temperature: 0.2,
1146
1146
  tags: ["expensive"]
1147
1147
  },
1148
1148
  [LLM_CONSTANTS.GEMINI_FLASH]: {
@@ -1162,20 +1162,26 @@ var SupportedAiModels = {
1162
1162
  apiKeyName: API_KEY_CONSTANTS.GOOGLE,
1163
1163
  hasThinking: true,
1164
1164
  reasoningEffort: "minimal",
1165
+ // Pre-3.6, same as Pro: keeps the 0.2 it always had.
1166
+ temperature: 0.2,
1165
1167
  tags: ["fast", "cheap"]
1166
1168
  },
1167
1169
  // Always-on reasoning — no non-thinking sibling. Bumped 4.6 → 4.7 on 2026-09-22 (id verified
1168
1170
  // against GET /v1/models). Same price, same 200K extended-context boundary; the context
1169
- // window is 500K. NOTE 4.7 newly accepts `reasoning_effort` (low | medium | high | xhigh,
1170
- // default high) where 4.6 had no knob at all. GrokAgent still sends none, so behaviour is
1171
- // unchanged — but Grok is the app's most expensive model per turn (94% of its output is
1172
- // reasoning), so a lower pin is the obvious lever to measure before anything else.
1171
+ // window is 500K. 4.7 accepts `reasoning: {effort}` (low | medium | high | xhigh, default
1172
+ // high) where 4.6 had no knob at all; GrokAgent sends the pin below.
1173
+ //
1174
+ // Pinned medium 2026-10-06. At high, production day summaries ran ~2 min and the werewolf
1175
+ // day-2 fixture measured votes 27-55s and summaries 44-55s (1.5-3k output tokens) — too
1176
+ // close to the 60s per-call timeout. At medium the same prompts took votes 5-8s and
1177
+ // summaries 23-25s (3-5x fewer output tokens) with the same vote target and summaries just
1178
+ // as specific.
1173
1179
  [LLM_CONSTANTS.GROK]: {
1174
1180
  displayName: "Grok 4.7",
1175
1181
  modelApiName: "grok-4.7",
1176
1182
  apiKeyName: API_KEY_CONSTANTS.GROK,
1177
1183
  hasThinking: true,
1178
- reasoningEffort: "high",
1184
+ reasoningEffort: "medium",
1179
1185
  temperature: 0.7
1180
1186
  },
1181
1187
  // Mistral models. Two hybrid entries since 2026-09-18: reasoning is off by default on the
@@ -1195,20 +1201,12 @@ var SupportedAiModels = {
1195
1201
  // `magistral-medium-latest` as one entry — so Magistral seats had silently become Medium
1196
1202
  // seats already. Consumers map both retired ids onto the surviving pair.
1197
1203
  //
1198
- // Mistral Large 4 added 2026-10-06 under the freed `mistral-large` picker id. The model list
1199
- // reports reasoning: true (Large 3 said false), 512K context; same reasoning_effort switch,
1200
- // but only 'high' and 'none' are accepted (medium/low are a 400). Live 2026-10-06 at high:
1201
- // a chat-turn schema ask took 14-21s with 1.3-2k output tokens (~$0.003), one constrained
1202
- // pick took 49s — it thinks long, so it is cheap but slow.
1203
- [LLM_CONSTANTS.MISTRAL_LARGE]: {
1204
- displayName: "Mistral Large 4",
1205
- // `mistral-large-4-0` is the same entry; `mistral-large-latest` still points at Large 3.
1206
- modelApiName: "mistral-large-4",
1207
- apiKeyName: API_KEY_CONSTANTS.MISTRAL,
1208
- hasThinking: true,
1209
- reasoningEffort: "high",
1210
- tags: ["slow", "cheap"]
1211
- },
1204
+ // Mistral Large 4 (`mistral-large-4`, $0.68/$2.09, $0.07 cached) was added in 0.19.0 and
1205
+ // removed in 0.19.1 (2026-10-06/07): too slow to play. Like Small/Medium it accepts only
1206
+ // reasoning_effort high|none, and unlike them it reasons when the field is omitted. At high
1207
+ // a realistic day-2 vote took 25-154s (half past the 60s timeout) and its parallel story
1208
+ // batches finished ~100s apart (Mistral served them one at a time: ~6 min per story). Off,
1209
+ // it answers in ~1s with no trace. Re-test before re-adding.
1212
1210
  [LLM_CONSTANTS.MISTRAL_MEDIUM]: {
1213
1211
  displayName: "Mistral Medium 3.5",
1214
1212
  // The docs' explicit 3.5 id. It was `mistral-medium-3` until 2026-09-18, which Mistral
@@ -1293,9 +1291,9 @@ var SupportedAiModels = {
1293
1291
  // real against $0.85 tracked, a 5.7x undercharge. It is a router with no published price,
1294
1292
  // so the rate is not even guaranteed stable, and its cache hit rate was 9.3% — effectively
1295
1293
  // zero, since every hit came from a duplicate call seconds apart rather than turn-to-turn
1296
- // prefix reuse. Ultra costs the same and is predictable.
1294
+ // prefix reuse.
1297
1295
  //
1298
- // reasoningEffort is PINNED on both entries because the server default differs per model:
1296
+ // reasoningEffort was PINNED on both entries because the server default differs per model:
1299
1297
  // fugu-ultra defaults to `xhigh` (console.sakana.ai/models), fugu-max to `high`. Until
1300
1298
  // 2026-09-20 the agent sent no effort at all, so every Ultra turn ran at xhigh. Measured that
1301
1299
  // day on a 2k-token three-day game prompt (two samples each, chat completions, json mode):
@@ -1305,17 +1303,17 @@ var SupportedAiModels = {
1305
1303
  // max xhigh 41s / 47s $0.02
1306
1304
  // `max_tokens` is not a latency lever for Ultra: Sakana applies it to the final response only,
1307
1305
  // the orchestrator "still uses maximum token limit". Effort is the only knob.
1308
- [LLM_CONSTANTS.FUGU_ULTRA]: {
1309
- displayName: "Sakana Fugu Ultra",
1310
- modelApiName: "fugu-ultra",
1311
- apiKeyName: API_KEY_CONSTANTS.FUGU,
1312
- hasThinking: false,
1313
- reasoningEffort: "high",
1314
- tags: ["extremely-slow", "expensive"]
1315
- },
1306
+ //
1307
+ // Fugu Ultra (`fugu-ultra`, $5/$30, $0.50 cached; ×~2 above 272K) was REMOVED in 0.19.1
1308
+ // (2026-10-07): too slow and too expensive for what it played. At `high` a day-2 vote took
1309
+ // 39s and a turn 65-78s (past the 60s request timeout), and as Game Master its four parallel
1310
+ // story batches ran past 240s each. It also billed "orchestration" tokens (its internal expert
1311
+ // calls) on top of the visible counts; FuguAgent still folds those in, in case Max ever
1312
+ // reports them. Consumers map the id to Max.
1316
1313
  // Fugu Max (2026-09-20, fugu-max → fugu-max-v1.0): Sakana's "largest pool of models on the
1317
- // cost–performance Pareto frontier" — the everyday Fugu at 5x less than Ultra's output rate
1318
- // and a fraction of its latency. It reasons (reasoning_tokens 80-500 a turn) but, like
1314
+ // cost–performance Pareto frontier" — 5x less than Ultra's output rate and a fraction of its
1315
+ // latency; the only Fugu since 0.19.1. Live 2026-10-06: day-2 vote 11s, 15-character story
1316
+ // pipeline 100s. It reasons (reasoning_tokens 80-500 a turn) but, like
1319
1317
  // Ultra, never returns reasoning_content, hence hasThinking: false. No orchestration
1320
1318
  // tokens observed on any call.
1321
1319
  [LLM_CONSTANTS.FUGU_MAX]: {
@@ -1598,13 +1596,7 @@ var MODEL_PRICING = {
1598
1596
  // Mistral models (mistral.ai/pricing/api, verified 2026-09-18). Cached tokens bill at 10% of
1599
1597
  // the input price (documented on the prompt_cache_key param; no per-model cached prices
1600
1598
  // published). Reasoning tokens are counted inside completion_tokens — no separate
1601
- // reasoning_tokens field — so the output rate already covers the trace. Large 4 added
1602
- // 2026-10-06 at its published rates ($0.07 cached, not an exact 10%).
1603
- [SupportedAiModels[LLM_CONSTANTS.MISTRAL_LARGE].modelApiName]: {
1604
- inputPrice: 0.68,
1605
- outputPrice: 2.09,
1606
- cacheHitPrice: 0.07
1607
- },
1599
+ // reasoning_tokens field — so the output rate already covers the trace.
1608
1600
  [SupportedAiModels[LLM_CONSTANTS.MISTRAL_MEDIUM].modelApiName]: {
1609
1601
  inputPrice: 1.5,
1610
1602
  outputPrice: 7.5,
@@ -1628,21 +1620,10 @@ var MODEL_PRICING = {
1628
1620
  extendedContextCacheHitPrice: 1,
1629
1621
  extendedContextThresholdTokens: 2e5
1630
1622
  },
1631
- // Sakana Fugu models (console.sakana.ai/pricing, read 2026-09-20). Base `fugu` was retired
1632
- // 2026-08-04 — it had no published price and measured out at these same ultra rates, so it
1633
- // has no pricing entry. fugu-ultra: above 272K context the rates roughly double. Ultra also
1634
- // reports "orchestration" tokens (its internal expert calls) in prompt_tokens_details /
1635
- // completion_tokens_details, billed at these same input/output rates — FuguAgent folds them
1636
- // into the token counts before pricing.
1637
- [SupportedAiModels[LLM_CONSTANTS.FUGU_ULTRA].modelApiName]: {
1638
- inputPrice: 5,
1639
- outputPrice: 30,
1640
- cacheHitPrice: 0.5,
1641
- extendedContextInputPrice: 10,
1642
- extendedContextOutputPrice: 45,
1643
- extendedContextCacheHitPrice: 1,
1644
- extendedContextThresholdTokens: 272e3
1645
- },
1623
+ // Sakana Fugu (console.sakana.ai/pricing, read 2026-09-20). Base `fugu` (retired 2026-08-04)
1624
+ // and `fugu-ultra` (removed 0.19.1) have no entries. Any "orchestration" tokens reported in
1625
+ // prompt_tokens_details / completion_tokens_details bill at these same rates — FuguAgent
1626
+ // folds them into the token counts before pricing.
1646
1627
  // fugu-max: flat rates, no context tiers.
1647
1628
  [SupportedAiModels[LLM_CONSTANTS.FUGU_MAX].modelApiName]: {
1648
1629
  inputPrice: 2,
@@ -1702,7 +1683,6 @@ var HYBRID_THINKING_API_NAMES = /* @__PURE__ */ new Set([
1702
1683
  SupportedAiModels[LLM_CONSTANTS.MINIMAX].modelApiName,
1703
1684
  // Mistral reasons only when asked (`reasoning_effort`), and we always ask — hybrid by the
1704
1685
  // same definition as Qwen. Added 2026-09-18 when the two entries went thinking-on.
1705
- SupportedAiModels[LLM_CONSTANTS.MISTRAL_LARGE].modelApiName,
1706
1686
  SupportedAiModels[LLM_CONSTANTS.MISTRAL_MEDIUM].modelApiName,
1707
1687
  SupportedAiModels[LLM_CONSTANTS.MISTRAL_SMALL].modelApiName
1708
1688
  ]);
@@ -1771,7 +1751,7 @@ var GLM_REASONING_EFFORTS = ["low", "high", "max"];
1771
1751
  var DEEPSEEK_REASONING_EFFORTS = ["low", "high", "max"];
1772
1752
  var FUGU_REASONING_EFFORTS = ["high", "xhigh", "max"];
1773
1753
  var META_REASONING_EFFORTS = ["minimal", "low", "medium", "high", "xhigh", "max"];
1774
- var MISTRAL_REASONING_EFFORTS = ["minimal", "low", "medium", "high", "xhigh"];
1754
+ var MISTRAL_REASONING_EFFORTS = ["high"];
1775
1755
  var XAI_REASONING_EFFORTS = ["low", "medium", "high", "xhigh"];
1776
1756
  var KIMI_REASONING_EFFORTS = ["low", "high", "max"];
1777
1757
  function clampReasoningEffort(effort, allowed) {
@@ -3261,6 +3241,13 @@ function throwForEmptyGeminiResponse(model, response, fallback) {
3261
3241
  }
3262
3242
  var GoogleAgent = class extends AbstractAgent {
3263
3243
  client;
3244
+ /**
3245
+ * Sampling temperature to send, or undefined to send none. Google deprecated custom sampling
3246
+ * (notice of 2026-10): since Gemini 3.6 Flash temperature/top_p/top_k are ignored, and its
3247
+ * upcoming models reject them with a 400. So it is sent only for a catalog entry that sets
3248
+ * `temperature` (the pre-3.6 models, to keep their behaviour) — never by default.
3249
+ */
3250
+ samplingTemperature;
3264
3251
  defaultConfig = {
3265
3252
  responseMimeType: "application/json"
3266
3253
  };
@@ -3276,7 +3263,9 @@ var GoogleAgent = class extends AbstractAgent {
3276
3263
  unsupportedRole: (role) => `Unsupported role type: ${role}`
3277
3264
  };
3278
3265
  constructor(name, instruction, model, apiKey, enableThinking = false, agentLoggingConfig = DEFAULT_LOGGING_CONFIG.agents) {
3279
- super(name, instruction, model, 0.2, enableThinking, agentLoggingConfig);
3266
+ const samplingTemperature = getModelConfigByApiName(model)?.temperature;
3267
+ super(name, instruction, model, samplingTemperature ?? 0, enableThinking, agentLoggingConfig);
3268
+ this.samplingTemperature = samplingTemperature;
3280
3269
  this.client = new import_genai3.GoogleGenAI({
3281
3270
  apiKey
3282
3271
  });
@@ -3375,7 +3364,7 @@ var GoogleAgent = class extends AbstractAgent {
3375
3364
  try {
3376
3365
  const googleSchema = ZodSchemaConverter.toGoogleSchema(zodSchema);
3377
3366
  const config = {
3378
- temperature: this.temperature,
3367
+ ...this.samplingTemperature !== void 0 ? { temperature: this.samplingTemperature } : {},
3379
3368
  responseMimeType: "application/json",
3380
3369
  responseSchema: googleSchema,
3381
3370
  maxOutputTokens: this.maxOutputTokens,
@@ -3465,7 +3454,7 @@ var GoogleAgent = class extends AbstractAgent {
3465
3454
  const contents = this.convertToContents(messages);
3466
3455
  try {
3467
3456
  const config = {
3468
- temperature: this.temperature,
3457
+ ...this.samplingTemperature !== void 0 ? { temperature: this.samplingTemperature } : {},
3469
3458
  maxOutputTokens: this.maxOutputTokens,
3470
3459
  systemInstruction: this.instruction
3471
3460
  };
@@ -5524,7 +5513,6 @@ var AgentFactory = class {
5524
5513
  case LLM_CONSTANTS.DEEPSEEK_PRO:
5525
5514
  return new DeepSeekV2Agent(name, instruction, model.modelApiName, key, model.temperature ?? 0, shouldEnableThinking);
5526
5515
  // Mistral models
5527
- case LLM_CONSTANTS.MISTRAL_LARGE:
5528
5516
  case LLM_CONSTANTS.MISTRAL_MEDIUM:
5529
5517
  case LLM_CONSTANTS.MISTRAL_SMALL:
5530
5518
  return new MistralAgent(name, instruction, model.modelApiName, key, shouldEnableThinking);
@@ -5535,7 +5523,6 @@ var AgentFactory = class {
5535
5523
  case LLM_CONSTANTS.GLM_FLASH:
5536
5524
  return new GlmAgent(name, instruction, model.modelApiName, key, model.temperature, shouldEnableThinking);
5537
5525
  // Sakana Fugu models — always-on reasoning, no temperature (ignored by the model)
5538
- case LLM_CONSTANTS.FUGU_ULTRA:
5539
5526
  case LLM_CONSTANTS.FUGU_MAX:
5540
5527
  return new FuguAgent(name, instruction, model.modelApiName, key, shouldEnableThinking);
5541
5528
  // Qwen models — thinking-only (enable_thinking always sent)