@hiper2d/ai-agents 0.19.1 → 0.20.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
@@ -860,13 +860,19 @@ var SupportedAiModels = {
860
860
  reasoningEffort: "high",
861
861
  tags: ["expensive"]
862
862
  },
863
+ // Haiku moved 4.5 → 5.5 on 2026-10-08 (`claude-haiku-5-5`, verified live with the platform
864
+ // key). 10x cheaper ($0.10/$0.50 up to 100K-token prompts), 1M context / 128K output.
865
+ // Adaptive thinking now (the `enabled` + budget_tokens mode 4.5 used is rejected), API
866
+ // default effort `medium`; we pin `high` like the other Claude entries. It reads Haiku 4.5
867
+ // thinking blocks, so games moving onto it keep the bots' earlier reasoning. 'slow' tag
868
+ // dropped: Anthropic lists it as the fastest model in the lineup.
863
869
  [LLM_CONSTANTS.CLAUDE_HAIKU]: {
864
- displayName: "Claude 4.5 Haiku",
865
- modelApiName: "claude-haiku-4-5",
870
+ displayName: "Claude 5.5 Haiku",
871
+ modelApiName: "claude-haiku-5-5",
866
872
  apiKeyName: API_KEY_CONSTANTS.ANTHROPIC,
867
873
  hasThinking: true,
868
- thinkingBudgetTokens: 1024,
869
- tags: ["slow", "cheap"]
874
+ reasoningEffort: "high",
875
+ tags: ["cheap"]
870
876
  },
871
877
  // DeepSeek V4 models — thinking-only entries (non-thinking variants retired 2026-08-05).
872
878
  // reasoningEffort pinned to 'low' 2026-08-30: at the provider default ('high', no budget
@@ -961,6 +967,10 @@ var SupportedAiModels = {
961
967
  apiKeyName: API_KEY_CONSTANTS.GOOGLE,
962
968
  hasThinking: true,
963
969
  reasoningEffort: "high",
970
+ // Pre-3.6: still honours sampling params, so it keeps the 0.2 GoogleAgent always sent
971
+ // before 2026-10-07. 3.6+ ignore them and future Gemini models reject them — leave
972
+ // `temperature` unset on every newer Gemini entry (GoogleAgent then sends none).
973
+ temperature: 0.2,
964
974
  tags: ["expensive"]
965
975
  },
966
976
  [LLM_CONSTANTS.GEMINI_FLASH]: {
@@ -980,6 +990,8 @@ var SupportedAiModels = {
980
990
  apiKeyName: API_KEY_CONSTANTS.GOOGLE,
981
991
  hasThinking: true,
982
992
  reasoningEffort: "minimal",
993
+ // Pre-3.6, same as Pro: keeps the 0.2 it always had.
994
+ temperature: 0.2,
983
995
  tags: ["fast", "cheap"]
984
996
  },
985
997
  // Always-on reasoning — no non-thinking sibling. Bumped 4.6 → 4.7 on 2026-09-22 (id verified
@@ -1378,9 +1390,16 @@ var MODEL_PRICING = {
1378
1390
  cacheHitPrice: 0.2
1379
1391
  },
1380
1392
  [SupportedAiModels[LLM_CONSTANTS.CLAUDE_HAIKU].modelApiName]: {
1381
- inputPrice: 1,
1382
- outputPrice: 5,
1383
- cacheHitPrice: 0.1
1393
+ // Haiku 5.5 (2026-10-07): the first Claude with a long-context tier — every rate is 5x
1394
+ // for prompts over 100K tokens (cache reads + writes count toward the prompt size,
1395
+ // which is what AnthropicAgent passes as inputTokens).
1396
+ inputPrice: 0.1,
1397
+ outputPrice: 0.5,
1398
+ cacheHitPrice: 0.01,
1399
+ extendedContextInputPrice: 0.5,
1400
+ extendedContextOutputPrice: 2.5,
1401
+ extendedContextCacheHitPrice: 0.05,
1402
+ extendedContextThresholdTokens: 1e5
1384
1403
  },
1385
1404
  // Google models
1386
1405
  [SupportedAiModels[LLM_CONSTANTS.GEMINI_PRO].modelApiName]: {
@@ -2230,7 +2249,7 @@ var AbstractAgent = class {
2230
2249
  * Reasoning-depth knobs, resolved once from the catalog like maxOutputTokens and, like it,
2231
2250
  * overridable per instance for calls whose profile differs from a turn (story generation
2232
2251
  * runs deeper). Each provider speaks one dialect — effort (DeepSeek, GLM, Gemini, Claude
2233
- * adaptive) or a token budget (Qwen, Claude Haiku) — and reads only the field it
2252
+ * adaptive) or a token budget (Qwen, Claude Haiku 4.5) — and reads only the field it
2234
2253
  * understands; the other is ignored. Subclasses read these when building a request.
2235
2254
  */
2236
2255
  reasoningEffort;
@@ -2630,6 +2649,7 @@ ${instruction}`);
2630
2649
  import { Anthropic } from "@anthropic-ai/sdk";
2631
2650
  var rejectsDisabledThinking = (model) => model.includes("fable") || model.includes("opus-5-5");
2632
2651
  var usesBetweenToolsForOff = (model) => model.includes("sonnet-5-5");
2652
+ var usesAdaptiveThinking = (model) => !model.includes("haiku-4");
2633
2653
  var ClaudeAgent = class extends AbstractAgent {
2634
2654
  client;
2635
2655
  /**
@@ -2651,7 +2671,8 @@ var ClaudeAgent = class extends AbstractAgent {
2651
2671
  // state writes (a lynch, the night resolution, the summary rewrite, the new
2652
2672
  // day), so every call inside one of those windows reads it.
2653
2673
  // GM prompts have no marker → single block, same behavior as before. Haiku 4.5 needs a
2654
- // 4096-token cacheable prefix, so tiers below that silently no-op on Haiku — expected.
2674
+ // 4096-token cacheable prefix, so tiers below that silently no-op there; Haiku 5.5 caches
2675
+ // from ~1024 tokens (measured 2026-10-08: a 1,083-token prefix was written, 492 was not).
2655
2676
  // A getter, not a field: `maxOutputTokens` can be raised after construction, and a field
2656
2677
  // initializer would snapshot the default and silently ignore the override.
2657
2678
  get defaultParams() {
@@ -2836,16 +2857,16 @@ ${schemaDescription}`;
2836
2857
  ...this.defaultParams,
2837
2858
  messages: anthropicMessages
2838
2859
  };
2839
- const usesAdaptiveThinking = this.model.includes("fable") || this.model.includes("opus") || this.model.includes("sonnet");
2860
+ const adaptive = usesAdaptiveThinking(this.model);
2840
2861
  if (canUseThinking) {
2841
- if (usesAdaptiveThinking) {
2862
+ if (adaptive) {
2842
2863
  params.thinking = { type: "adaptive", display: "summarized" };
2843
2864
  params.output_config = { effort: toAnthropicEffort(this.reasoningEffort ?? "high") };
2844
2865
  } else {
2845
2866
  params.thinking = { type: "enabled", budget_tokens: this.thinkingBudgetTokens ?? 1024 };
2846
2867
  params.temperature = 1;
2847
2868
  }
2848
- } else if (usesAdaptiveThinking) {
2869
+ } else if (adaptive) {
2849
2870
  if (usesBetweenToolsForOff(this.model)) {
2850
2871
  params.thinking = { type: "between_tools" };
2851
2872
  } else if (!rejectsDisabledThinking(this.model)) {
@@ -2934,16 +2955,16 @@ ${schemaDescription}`;
2934
2955
  ...this.defaultParams,
2935
2956
  messages: anthropicMessages
2936
2957
  };
2937
- const usesAdaptiveThinking = this.model.includes("fable") || this.model.includes("opus") || this.model.includes("sonnet");
2958
+ const adaptive = usesAdaptiveThinking(this.model);
2938
2959
  if (canUseThinking) {
2939
- if (usesAdaptiveThinking) {
2960
+ if (adaptive) {
2940
2961
  params.thinking = { type: "adaptive", display: "summarized" };
2941
2962
  params.output_config = { effort: toAnthropicEffort(this.reasoningEffort ?? "high") };
2942
2963
  } else {
2943
2964
  params.thinking = { type: "enabled", budget_tokens: this.thinkingBudgetTokens ?? 1024 };
2944
2965
  params.temperature = 1;
2945
2966
  }
2946
- } else if (usesAdaptiveThinking) {
2967
+ } else if (adaptive) {
2947
2968
  if (usesBetweenToolsForOff(this.model)) {
2948
2969
  params.thinking = { type: "between_tools" };
2949
2970
  } else if (!rejectsDisabledThinking(this.model)) {
@@ -3057,6 +3078,13 @@ function throwForEmptyGeminiResponse(model, response, fallback) {
3057
3078
  }
3058
3079
  var GoogleAgent = class extends AbstractAgent {
3059
3080
  client;
3081
+ /**
3082
+ * Sampling temperature to send, or undefined to send none. Google deprecated custom sampling
3083
+ * (notice of 2026-10): since Gemini 3.6 Flash temperature/top_p/top_k are ignored, and its
3084
+ * upcoming models reject them with a 400. So it is sent only for a catalog entry that sets
3085
+ * `temperature` (the pre-3.6 models, to keep their behaviour) — never by default.
3086
+ */
3087
+ samplingTemperature;
3060
3088
  defaultConfig = {
3061
3089
  responseMimeType: "application/json"
3062
3090
  };
@@ -3072,7 +3100,9 @@ var GoogleAgent = class extends AbstractAgent {
3072
3100
  unsupportedRole: (role) => `Unsupported role type: ${role}`
3073
3101
  };
3074
3102
  constructor(name, instruction, model, apiKey, enableThinking = false, agentLoggingConfig = DEFAULT_LOGGING_CONFIG.agents) {
3075
- super(name, instruction, model, 0.2, enableThinking, agentLoggingConfig);
3103
+ const samplingTemperature = getModelConfigByApiName(model)?.temperature;
3104
+ super(name, instruction, model, samplingTemperature ?? 0, enableThinking, agentLoggingConfig);
3105
+ this.samplingTemperature = samplingTemperature;
3076
3106
  this.client = new GoogleGenAI3({
3077
3107
  apiKey
3078
3108
  });
@@ -3171,7 +3201,7 @@ var GoogleAgent = class extends AbstractAgent {
3171
3201
  try {
3172
3202
  const googleSchema = ZodSchemaConverter.toGoogleSchema(zodSchema);
3173
3203
  const config = {
3174
- temperature: this.temperature,
3204
+ ...this.samplingTemperature !== void 0 ? { temperature: this.samplingTemperature } : {},
3175
3205
  responseMimeType: "application/json",
3176
3206
  responseSchema: googleSchema,
3177
3207
  maxOutputTokens: this.maxOutputTokens,
@@ -3261,7 +3291,7 @@ var GoogleAgent = class extends AbstractAgent {
3261
3291
  const contents = this.convertToContents(messages);
3262
3292
  try {
3263
3293
  const config = {
3264
- temperature: this.temperature,
3294
+ ...this.samplingTemperature !== void 0 ? { temperature: this.samplingTemperature } : {},
3265
3295
  maxOutputTokens: this.maxOutputTokens,
3266
3296
  systemInstruction: this.instruction
3267
3297
  };