@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.mjs CHANGED
@@ -806,16 +806,12 @@ var LLM_CONSTANTS = {
806
806
  GEMINI_PRO: "gemini-pro",
807
807
  GEMINI_FLASH: "gemini-flash",
808
808
  GEMINI_LITE: "gemini-lite",
809
- // Reused 2026-10-06 for Mistral Large 4: the old id (Large 3) was retired 2026-09-18 and
810
- // consumers had mapped it away, so the version-free id was free again.
811
- MISTRAL_LARGE: "mistral-large",
812
809
  MISTRAL_MEDIUM: "mistral-medium",
813
810
  MISTRAL_SMALL: "mistral-small",
814
811
  GROK: "grok",
815
812
  KIMI: "kimi",
816
813
  GLM: "glm",
817
814
  GLM_FLASH: "glm-flash",
818
- FUGU_ULTRA: "fugu-ultra",
819
815
  FUGU_MAX: "fugu-max",
820
816
  // Qwen (QwenCloud/DashScope). Stable picker ids without the version, matching the gpt/gemini
821
817
  // pattern, so future repoints don't orphan persisted ids.
@@ -965,6 +961,10 @@ var SupportedAiModels = {
965
961
  apiKeyName: API_KEY_CONSTANTS.GOOGLE,
966
962
  hasThinking: true,
967
963
  reasoningEffort: "high",
964
+ // Pre-3.6: still honours sampling params, so it keeps the 0.2 GoogleAgent always sent
965
+ // before 2026-10-07. 3.6+ ignore them and future Gemini models reject them — leave
966
+ // `temperature` unset on every newer Gemini entry (GoogleAgent then sends none).
967
+ temperature: 0.2,
968
968
  tags: ["expensive"]
969
969
  },
970
970
  [LLM_CONSTANTS.GEMINI_FLASH]: {
@@ -984,20 +984,26 @@ var SupportedAiModels = {
984
984
  apiKeyName: API_KEY_CONSTANTS.GOOGLE,
985
985
  hasThinking: true,
986
986
  reasoningEffort: "minimal",
987
+ // Pre-3.6, same as Pro: keeps the 0.2 it always had.
988
+ temperature: 0.2,
987
989
  tags: ["fast", "cheap"]
988
990
  },
989
991
  // Always-on reasoning — no non-thinking sibling. Bumped 4.6 → 4.7 on 2026-09-22 (id verified
990
992
  // against GET /v1/models). Same price, same 200K extended-context boundary; the context
991
- // window is 500K. NOTE 4.7 newly accepts `reasoning_effort` (low | medium | high | xhigh,
992
- // default high) where 4.6 had no knob at all. GrokAgent still sends none, so behaviour is
993
- // unchanged — but Grok is the app's most expensive model per turn (94% of its output is
994
- // reasoning), so a lower pin is the obvious lever to measure before anything else.
993
+ // window is 500K. 4.7 accepts `reasoning: {effort}` (low | medium | high | xhigh, default
994
+ // high) where 4.6 had no knob at all; GrokAgent sends the pin below.
995
+ //
996
+ // Pinned medium 2026-10-06. At high, production day summaries ran ~2 min and the werewolf
997
+ // day-2 fixture measured votes 27-55s and summaries 44-55s (1.5-3k output tokens) — too
998
+ // close to the 60s per-call timeout. At medium the same prompts took votes 5-8s and
999
+ // summaries 23-25s (3-5x fewer output tokens) with the same vote target and summaries just
1000
+ // as specific.
995
1001
  [LLM_CONSTANTS.GROK]: {
996
1002
  displayName: "Grok 4.7",
997
1003
  modelApiName: "grok-4.7",
998
1004
  apiKeyName: API_KEY_CONSTANTS.GROK,
999
1005
  hasThinking: true,
1000
- reasoningEffort: "high",
1006
+ reasoningEffort: "medium",
1001
1007
  temperature: 0.7
1002
1008
  },
1003
1009
  // Mistral models. Two hybrid entries since 2026-09-18: reasoning is off by default on the
@@ -1017,20 +1023,12 @@ var SupportedAiModels = {
1017
1023
  // `magistral-medium-latest` as one entry — so Magistral seats had silently become Medium
1018
1024
  // seats already. Consumers map both retired ids onto the surviving pair.
1019
1025
  //
1020
- // Mistral Large 4 added 2026-10-06 under the freed `mistral-large` picker id. The model list
1021
- // reports reasoning: true (Large 3 said false), 512K context; same reasoning_effort switch,
1022
- // but only 'high' and 'none' are accepted (medium/low are a 400). Live 2026-10-06 at high:
1023
- // a chat-turn schema ask took 14-21s with 1.3-2k output tokens (~$0.003), one constrained
1024
- // pick took 49s — it thinks long, so it is cheap but slow.
1025
- [LLM_CONSTANTS.MISTRAL_LARGE]: {
1026
- displayName: "Mistral Large 4",
1027
- // `mistral-large-4-0` is the same entry; `mistral-large-latest` still points at Large 3.
1028
- modelApiName: "mistral-large-4",
1029
- apiKeyName: API_KEY_CONSTANTS.MISTRAL,
1030
- hasThinking: true,
1031
- reasoningEffort: "high",
1032
- tags: ["slow", "cheap"]
1033
- },
1026
+ // Mistral Large 4 (`mistral-large-4`, $0.68/$2.09, $0.07 cached) was added in 0.19.0 and
1027
+ // removed in 0.19.1 (2026-10-06/07): too slow to play. Like Small/Medium it accepts only
1028
+ // reasoning_effort high|none, and unlike them it reasons when the field is omitted. At high
1029
+ // a realistic day-2 vote took 25-154s (half past the 60s timeout) and its parallel story
1030
+ // batches finished ~100s apart (Mistral served them one at a time: ~6 min per story). Off,
1031
+ // it answers in ~1s with no trace. Re-test before re-adding.
1034
1032
  [LLM_CONSTANTS.MISTRAL_MEDIUM]: {
1035
1033
  displayName: "Mistral Medium 3.5",
1036
1034
  // The docs' explicit 3.5 id. It was `mistral-medium-3` until 2026-09-18, which Mistral
@@ -1115,9 +1113,9 @@ var SupportedAiModels = {
1115
1113
  // real against $0.85 tracked, a 5.7x undercharge. It is a router with no published price,
1116
1114
  // so the rate is not even guaranteed stable, and its cache hit rate was 9.3% — effectively
1117
1115
  // zero, since every hit came from a duplicate call seconds apart rather than turn-to-turn
1118
- // prefix reuse. Ultra costs the same and is predictable.
1116
+ // prefix reuse.
1119
1117
  //
1120
- // reasoningEffort is PINNED on both entries because the server default differs per model:
1118
+ // reasoningEffort was PINNED on both entries because the server default differs per model:
1121
1119
  // fugu-ultra defaults to `xhigh` (console.sakana.ai/models), fugu-max to `high`. Until
1122
1120
  // 2026-09-20 the agent sent no effort at all, so every Ultra turn ran at xhigh. Measured that
1123
1121
  // day on a 2k-token three-day game prompt (two samples each, chat completions, json mode):
@@ -1127,17 +1125,17 @@ var SupportedAiModels = {
1127
1125
  // max xhigh 41s / 47s $0.02
1128
1126
  // `max_tokens` is not a latency lever for Ultra: Sakana applies it to the final response only,
1129
1127
  // the orchestrator "still uses maximum token limit". Effort is the only knob.
1130
- [LLM_CONSTANTS.FUGU_ULTRA]: {
1131
- displayName: "Sakana Fugu Ultra",
1132
- modelApiName: "fugu-ultra",
1133
- apiKeyName: API_KEY_CONSTANTS.FUGU,
1134
- hasThinking: false,
1135
- reasoningEffort: "high",
1136
- tags: ["extremely-slow", "expensive"]
1137
- },
1128
+ //
1129
+ // Fugu Ultra (`fugu-ultra`, $5/$30, $0.50 cached; ×~2 above 272K) was REMOVED in 0.19.1
1130
+ // (2026-10-07): too slow and too expensive for what it played. At `high` a day-2 vote took
1131
+ // 39s and a turn 65-78s (past the 60s request timeout), and as Game Master its four parallel
1132
+ // story batches ran past 240s each. It also billed "orchestration" tokens (its internal expert
1133
+ // calls) on top of the visible counts; FuguAgent still folds those in, in case Max ever
1134
+ // reports them. Consumers map the id to Max.
1138
1135
  // Fugu Max (2026-09-20, fugu-max → fugu-max-v1.0): Sakana's "largest pool of models on the
1139
- // cost–performance Pareto frontier" — the everyday Fugu at 5x less than Ultra's output rate
1140
- // and a fraction of its latency. It reasons (reasoning_tokens 80-500 a turn) but, like
1136
+ // cost–performance Pareto frontier" — 5x less than Ultra's output rate and a fraction of its
1137
+ // latency; the only Fugu since 0.19.1. Live 2026-10-06: day-2 vote 11s, 15-character story
1138
+ // pipeline 100s. It reasons (reasoning_tokens 80-500 a turn) but, like
1141
1139
  // Ultra, never returns reasoning_content, hence hasThinking: false. No orchestration
1142
1140
  // tokens observed on any call.
1143
1141
  [LLM_CONSTANTS.FUGU_MAX]: {
@@ -1420,13 +1418,7 @@ var MODEL_PRICING = {
1420
1418
  // Mistral models (mistral.ai/pricing/api, verified 2026-09-18). Cached tokens bill at 10% of
1421
1419
  // the input price (documented on the prompt_cache_key param; no per-model cached prices
1422
1420
  // published). Reasoning tokens are counted inside completion_tokens — no separate
1423
- // reasoning_tokens field — so the output rate already covers the trace. Large 4 added
1424
- // 2026-10-06 at its published rates ($0.07 cached, not an exact 10%).
1425
- [SupportedAiModels[LLM_CONSTANTS.MISTRAL_LARGE].modelApiName]: {
1426
- inputPrice: 0.68,
1427
- outputPrice: 2.09,
1428
- cacheHitPrice: 0.07
1429
- },
1421
+ // reasoning_tokens field — so the output rate already covers the trace.
1430
1422
  [SupportedAiModels[LLM_CONSTANTS.MISTRAL_MEDIUM].modelApiName]: {
1431
1423
  inputPrice: 1.5,
1432
1424
  outputPrice: 7.5,
@@ -1450,21 +1442,10 @@ var MODEL_PRICING = {
1450
1442
  extendedContextCacheHitPrice: 1,
1451
1443
  extendedContextThresholdTokens: 2e5
1452
1444
  },
1453
- // Sakana Fugu models (console.sakana.ai/pricing, read 2026-09-20). Base `fugu` was retired
1454
- // 2026-08-04 — it had no published price and measured out at these same ultra rates, so it
1455
- // has no pricing entry. fugu-ultra: above 272K context the rates roughly double. Ultra also
1456
- // reports "orchestration" tokens (its internal expert calls) in prompt_tokens_details /
1457
- // completion_tokens_details, billed at these same input/output rates — FuguAgent folds them
1458
- // into the token counts before pricing.
1459
- [SupportedAiModels[LLM_CONSTANTS.FUGU_ULTRA].modelApiName]: {
1460
- inputPrice: 5,
1461
- outputPrice: 30,
1462
- cacheHitPrice: 0.5,
1463
- extendedContextInputPrice: 10,
1464
- extendedContextOutputPrice: 45,
1465
- extendedContextCacheHitPrice: 1,
1466
- extendedContextThresholdTokens: 272e3
1467
- },
1445
+ // Sakana Fugu (console.sakana.ai/pricing, read 2026-09-20). Base `fugu` (retired 2026-08-04)
1446
+ // and `fugu-ultra` (removed 0.19.1) have no entries. Any "orchestration" tokens reported in
1447
+ // prompt_tokens_details / completion_tokens_details bill at these same rates — FuguAgent
1448
+ // folds them into the token counts before pricing.
1468
1449
  // fugu-max: flat rates, no context tiers.
1469
1450
  [SupportedAiModels[LLM_CONSTANTS.FUGU_MAX].modelApiName]: {
1470
1451
  inputPrice: 2,
@@ -1524,7 +1505,6 @@ var HYBRID_THINKING_API_NAMES = /* @__PURE__ */ new Set([
1524
1505
  SupportedAiModels[LLM_CONSTANTS.MINIMAX].modelApiName,
1525
1506
  // Mistral reasons only when asked (`reasoning_effort`), and we always ask — hybrid by the
1526
1507
  // same definition as Qwen. Added 2026-09-18 when the two entries went thinking-on.
1527
- SupportedAiModels[LLM_CONSTANTS.MISTRAL_LARGE].modelApiName,
1528
1508
  SupportedAiModels[LLM_CONSTANTS.MISTRAL_MEDIUM].modelApiName,
1529
1509
  SupportedAiModels[LLM_CONSTANTS.MISTRAL_SMALL].modelApiName
1530
1510
  ]);
@@ -1593,7 +1573,7 @@ var GLM_REASONING_EFFORTS = ["low", "high", "max"];
1593
1573
  var DEEPSEEK_REASONING_EFFORTS = ["low", "high", "max"];
1594
1574
  var FUGU_REASONING_EFFORTS = ["high", "xhigh", "max"];
1595
1575
  var META_REASONING_EFFORTS = ["minimal", "low", "medium", "high", "xhigh", "max"];
1596
- var MISTRAL_REASONING_EFFORTS = ["minimal", "low", "medium", "high", "xhigh"];
1576
+ var MISTRAL_REASONING_EFFORTS = ["high"];
1597
1577
  var XAI_REASONING_EFFORTS = ["low", "medium", "high", "xhigh"];
1598
1578
  var KIMI_REASONING_EFFORTS = ["low", "high", "max"];
1599
1579
  function clampReasoningEffort(effort, allowed) {
@@ -3083,6 +3063,13 @@ function throwForEmptyGeminiResponse(model, response, fallback) {
3083
3063
  }
3084
3064
  var GoogleAgent = class extends AbstractAgent {
3085
3065
  client;
3066
+ /**
3067
+ * Sampling temperature to send, or undefined to send none. Google deprecated custom sampling
3068
+ * (notice of 2026-10): since Gemini 3.6 Flash temperature/top_p/top_k are ignored, and its
3069
+ * upcoming models reject them with a 400. So it is sent only for a catalog entry that sets
3070
+ * `temperature` (the pre-3.6 models, to keep their behaviour) — never by default.
3071
+ */
3072
+ samplingTemperature;
3086
3073
  defaultConfig = {
3087
3074
  responseMimeType: "application/json"
3088
3075
  };
@@ -3098,7 +3085,9 @@ var GoogleAgent = class extends AbstractAgent {
3098
3085
  unsupportedRole: (role) => `Unsupported role type: ${role}`
3099
3086
  };
3100
3087
  constructor(name, instruction, model, apiKey, enableThinking = false, agentLoggingConfig = DEFAULT_LOGGING_CONFIG.agents) {
3101
- super(name, instruction, model, 0.2, enableThinking, agentLoggingConfig);
3088
+ const samplingTemperature = getModelConfigByApiName(model)?.temperature;
3089
+ super(name, instruction, model, samplingTemperature ?? 0, enableThinking, agentLoggingConfig);
3090
+ this.samplingTemperature = samplingTemperature;
3102
3091
  this.client = new GoogleGenAI3({
3103
3092
  apiKey
3104
3093
  });
@@ -3197,7 +3186,7 @@ var GoogleAgent = class extends AbstractAgent {
3197
3186
  try {
3198
3187
  const googleSchema = ZodSchemaConverter.toGoogleSchema(zodSchema);
3199
3188
  const config = {
3200
- temperature: this.temperature,
3189
+ ...this.samplingTemperature !== void 0 ? { temperature: this.samplingTemperature } : {},
3201
3190
  responseMimeType: "application/json",
3202
3191
  responseSchema: googleSchema,
3203
3192
  maxOutputTokens: this.maxOutputTokens,
@@ -3287,7 +3276,7 @@ var GoogleAgent = class extends AbstractAgent {
3287
3276
  const contents = this.convertToContents(messages);
3288
3277
  try {
3289
3278
  const config = {
3290
- temperature: this.temperature,
3279
+ ...this.samplingTemperature !== void 0 ? { temperature: this.samplingTemperature } : {},
3291
3280
  maxOutputTokens: this.maxOutputTokens,
3292
3281
  systemInstruction: this.instruction
3293
3282
  };
@@ -5346,7 +5335,6 @@ var AgentFactory = class {
5346
5335
  case LLM_CONSTANTS.DEEPSEEK_PRO:
5347
5336
  return new DeepSeekV2Agent(name, instruction, model.modelApiName, key, model.temperature ?? 0, shouldEnableThinking);
5348
5337
  // Mistral models
5349
- case LLM_CONSTANTS.MISTRAL_LARGE:
5350
5338
  case LLM_CONSTANTS.MISTRAL_MEDIUM:
5351
5339
  case LLM_CONSTANTS.MISTRAL_SMALL:
5352
5340
  return new MistralAgent(name, instruction, model.modelApiName, key, shouldEnableThinking);
@@ -5357,7 +5345,6 @@ var AgentFactory = class {
5357
5345
  case LLM_CONSTANTS.GLM_FLASH:
5358
5346
  return new GlmAgent(name, instruction, model.modelApiName, key, model.temperature, shouldEnableThinking);
5359
5347
  // Sakana Fugu models — always-on reasoning, no temperature (ignored by the model)
5360
- case LLM_CONSTANTS.FUGU_ULTRA:
5361
5348
  case LLM_CONSTANTS.FUGU_MAX:
5362
5349
  return new FuguAgent(name, instruction, model.modelApiName, key, shouldEnableThinking);
5363
5350
  // Qwen models — thinking-only (enable_thinking always sent)