@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.d.mts CHANGED
@@ -1298,7 +1298,7 @@ declare abstract class AbstractAgent {
1298
1298
  * Reasoning-depth knobs, resolved once from the catalog like maxOutputTokens and, like it,
1299
1299
  * overridable per instance for calls whose profile differs from a turn (story generation
1300
1300
  * 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
1301
+ * adaptive) or a token budget (Qwen, Claude Haiku 4.5) — and reads only the field it
1302
1302
  * understands; the other is ignored. Subclasses read these when building a request.
1303
1303
  */
1304
1304
  reasoningEffort?: ReasoningEffort;
@@ -1486,6 +1486,13 @@ declare class Gpt5Agent extends AbstractAgent {
1486
1486
 
1487
1487
  declare class GoogleAgent extends AbstractAgent {
1488
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;
1489
1496
  private readonly defaultConfig;
1490
1497
  private readonly logTemplates;
1491
1498
  private readonly errorMessages;
package/dist/index.d.ts CHANGED
@@ -1298,7 +1298,7 @@ declare abstract class AbstractAgent {
1298
1298
  * Reasoning-depth knobs, resolved once from the catalog like maxOutputTokens and, like it,
1299
1299
  * overridable per instance for calls whose profile differs from a turn (story generation
1300
1300
  * 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
1301
+ * adaptive) or a token budget (Qwen, Claude Haiku 4.5) — and reads only the field it
1302
1302
  * understands; the other is ignored. Subclasses read these when building a request.
1303
1303
  */
1304
1304
  reasoningEffort?: ReasoningEffort;
@@ -1486,6 +1486,13 @@ declare class Gpt5Agent extends AbstractAgent {
1486
1486
 
1487
1487
  declare class GoogleAgent extends AbstractAgent {
1488
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;
1489
1496
  private readonly defaultConfig;
1490
1497
  private readonly logTemplates;
1491
1498
  private readonly errorMessages;
package/dist/index.js CHANGED
@@ -1038,13 +1038,19 @@ var SupportedAiModels = {
1038
1038
  reasoningEffort: "high",
1039
1039
  tags: ["expensive"]
1040
1040
  },
1041
+ // Haiku moved 4.5 → 5.5 on 2026-10-08 (`claude-haiku-5-5`, verified live with the platform
1042
+ // key). 10x cheaper ($0.10/$0.50 up to 100K-token prompts), 1M context / 128K output.
1043
+ // Adaptive thinking now (the `enabled` + budget_tokens mode 4.5 used is rejected), API
1044
+ // default effort `medium`; we pin `high` like the other Claude entries. It reads Haiku 4.5
1045
+ // thinking blocks, so games moving onto it keep the bots' earlier reasoning. 'slow' tag
1046
+ // dropped: Anthropic lists it as the fastest model in the lineup.
1041
1047
  [LLM_CONSTANTS.CLAUDE_HAIKU]: {
1042
- displayName: "Claude 4.5 Haiku",
1043
- modelApiName: "claude-haiku-4-5",
1048
+ displayName: "Claude 5.5 Haiku",
1049
+ modelApiName: "claude-haiku-5-5",
1044
1050
  apiKeyName: API_KEY_CONSTANTS.ANTHROPIC,
1045
1051
  hasThinking: true,
1046
- thinkingBudgetTokens: 1024,
1047
- tags: ["slow", "cheap"]
1052
+ reasoningEffort: "high",
1053
+ tags: ["cheap"]
1048
1054
  },
1049
1055
  // DeepSeek V4 models — thinking-only entries (non-thinking variants retired 2026-08-05).
1050
1056
  // reasoningEffort pinned to 'low' 2026-08-30: at the provider default ('high', no budget
@@ -1139,6 +1145,10 @@ var SupportedAiModels = {
1139
1145
  apiKeyName: API_KEY_CONSTANTS.GOOGLE,
1140
1146
  hasThinking: true,
1141
1147
  reasoningEffort: "high",
1148
+ // Pre-3.6: still honours sampling params, so it keeps the 0.2 GoogleAgent always sent
1149
+ // before 2026-10-07. 3.6+ ignore them and future Gemini models reject them — leave
1150
+ // `temperature` unset on every newer Gemini entry (GoogleAgent then sends none).
1151
+ temperature: 0.2,
1142
1152
  tags: ["expensive"]
1143
1153
  },
1144
1154
  [LLM_CONSTANTS.GEMINI_FLASH]: {
@@ -1158,6 +1168,8 @@ var SupportedAiModels = {
1158
1168
  apiKeyName: API_KEY_CONSTANTS.GOOGLE,
1159
1169
  hasThinking: true,
1160
1170
  reasoningEffort: "minimal",
1171
+ // Pre-3.6, same as Pro: keeps the 0.2 it always had.
1172
+ temperature: 0.2,
1161
1173
  tags: ["fast", "cheap"]
1162
1174
  },
1163
1175
  // Always-on reasoning — no non-thinking sibling. Bumped 4.6 → 4.7 on 2026-09-22 (id verified
@@ -1556,9 +1568,16 @@ var MODEL_PRICING = {
1556
1568
  cacheHitPrice: 0.2
1557
1569
  },
1558
1570
  [SupportedAiModels[LLM_CONSTANTS.CLAUDE_HAIKU].modelApiName]: {
1559
- inputPrice: 1,
1560
- outputPrice: 5,
1561
- cacheHitPrice: 0.1
1571
+ // Haiku 5.5 (2026-10-07): the first Claude with a long-context tier — every rate is 5x
1572
+ // for prompts over 100K tokens (cache reads + writes count toward the prompt size,
1573
+ // which is what AnthropicAgent passes as inputTokens).
1574
+ inputPrice: 0.1,
1575
+ outputPrice: 0.5,
1576
+ cacheHitPrice: 0.01,
1577
+ extendedContextInputPrice: 0.5,
1578
+ extendedContextOutputPrice: 2.5,
1579
+ extendedContextCacheHitPrice: 0.05,
1580
+ extendedContextThresholdTokens: 1e5
1562
1581
  },
1563
1582
  // Google models
1564
1583
  [SupportedAiModels[LLM_CONSTANTS.GEMINI_PRO].modelApiName]: {
@@ -2408,7 +2427,7 @@ var AbstractAgent = class {
2408
2427
  * Reasoning-depth knobs, resolved once from the catalog like maxOutputTokens and, like it,
2409
2428
  * overridable per instance for calls whose profile differs from a turn (story generation
2410
2429
  * runs deeper). Each provider speaks one dialect — effort (DeepSeek, GLM, Gemini, Claude
2411
- * adaptive) or a token budget (Qwen, Claude Haiku) — and reads only the field it
2430
+ * adaptive) or a token budget (Qwen, Claude Haiku 4.5) — and reads only the field it
2412
2431
  * understands; the other is ignored. Subclasses read these when building a request.
2413
2432
  */
2414
2433
  reasoningEffort;
@@ -2808,6 +2827,7 @@ ${instruction}`);
2808
2827
  var import_sdk = require("@anthropic-ai/sdk");
2809
2828
  var rejectsDisabledThinking = (model) => model.includes("fable") || model.includes("opus-5-5");
2810
2829
  var usesBetweenToolsForOff = (model) => model.includes("sonnet-5-5");
2830
+ var usesAdaptiveThinking = (model) => !model.includes("haiku-4");
2811
2831
  var ClaudeAgent = class extends AbstractAgent {
2812
2832
  client;
2813
2833
  /**
@@ -2829,7 +2849,8 @@ var ClaudeAgent = class extends AbstractAgent {
2829
2849
  // state writes (a lynch, the night resolution, the summary rewrite, the new
2830
2850
  // day), so every call inside one of those windows reads it.
2831
2851
  // GM prompts have no marker → single block, same behavior as before. Haiku 4.5 needs a
2832
- // 4096-token cacheable prefix, so tiers below that silently no-op on Haiku — expected.
2852
+ // 4096-token cacheable prefix, so tiers below that silently no-op there; Haiku 5.5 caches
2853
+ // from ~1024 tokens (measured 2026-10-08: a 1,083-token prefix was written, 492 was not).
2833
2854
  // A getter, not a field: `maxOutputTokens` can be raised after construction, and a field
2834
2855
  // initializer would snapshot the default and silently ignore the override.
2835
2856
  get defaultParams() {
@@ -3014,16 +3035,16 @@ ${schemaDescription}`;
3014
3035
  ...this.defaultParams,
3015
3036
  messages: anthropicMessages
3016
3037
  };
3017
- const usesAdaptiveThinking = this.model.includes("fable") || this.model.includes("opus") || this.model.includes("sonnet");
3038
+ const adaptive = usesAdaptiveThinking(this.model);
3018
3039
  if (canUseThinking) {
3019
- if (usesAdaptiveThinking) {
3040
+ if (adaptive) {
3020
3041
  params.thinking = { type: "adaptive", display: "summarized" };
3021
3042
  params.output_config = { effort: toAnthropicEffort(this.reasoningEffort ?? "high") };
3022
3043
  } else {
3023
3044
  params.thinking = { type: "enabled", budget_tokens: this.thinkingBudgetTokens ?? 1024 };
3024
3045
  params.temperature = 1;
3025
3046
  }
3026
- } else if (usesAdaptiveThinking) {
3047
+ } else if (adaptive) {
3027
3048
  if (usesBetweenToolsForOff(this.model)) {
3028
3049
  params.thinking = { type: "between_tools" };
3029
3050
  } else if (!rejectsDisabledThinking(this.model)) {
@@ -3112,16 +3133,16 @@ ${schemaDescription}`;
3112
3133
  ...this.defaultParams,
3113
3134
  messages: anthropicMessages
3114
3135
  };
3115
- const usesAdaptiveThinking = this.model.includes("fable") || this.model.includes("opus") || this.model.includes("sonnet");
3136
+ const adaptive = usesAdaptiveThinking(this.model);
3116
3137
  if (canUseThinking) {
3117
- if (usesAdaptiveThinking) {
3138
+ if (adaptive) {
3118
3139
  params.thinking = { type: "adaptive", display: "summarized" };
3119
3140
  params.output_config = { effort: toAnthropicEffort(this.reasoningEffort ?? "high") };
3120
3141
  } else {
3121
3142
  params.thinking = { type: "enabled", budget_tokens: this.thinkingBudgetTokens ?? 1024 };
3122
3143
  params.temperature = 1;
3123
3144
  }
3124
- } else if (usesAdaptiveThinking) {
3145
+ } else if (adaptive) {
3125
3146
  if (usesBetweenToolsForOff(this.model)) {
3126
3147
  params.thinking = { type: "between_tools" };
3127
3148
  } else if (!rejectsDisabledThinking(this.model)) {
@@ -3235,6 +3256,13 @@ function throwForEmptyGeminiResponse(model, response, fallback) {
3235
3256
  }
3236
3257
  var GoogleAgent = class extends AbstractAgent {
3237
3258
  client;
3259
+ /**
3260
+ * Sampling temperature to send, or undefined to send none. Google deprecated custom sampling
3261
+ * (notice of 2026-10): since Gemini 3.6 Flash temperature/top_p/top_k are ignored, and its
3262
+ * upcoming models reject them with a 400. So it is sent only for a catalog entry that sets
3263
+ * `temperature` (the pre-3.6 models, to keep their behaviour) — never by default.
3264
+ */
3265
+ samplingTemperature;
3238
3266
  defaultConfig = {
3239
3267
  responseMimeType: "application/json"
3240
3268
  };
@@ -3250,7 +3278,9 @@ var GoogleAgent = class extends AbstractAgent {
3250
3278
  unsupportedRole: (role) => `Unsupported role type: ${role}`
3251
3279
  };
3252
3280
  constructor(name, instruction, model, apiKey, enableThinking = false, agentLoggingConfig = DEFAULT_LOGGING_CONFIG.agents) {
3253
- super(name, instruction, model, 0.2, enableThinking, agentLoggingConfig);
3281
+ const samplingTemperature = getModelConfigByApiName(model)?.temperature;
3282
+ super(name, instruction, model, samplingTemperature ?? 0, enableThinking, agentLoggingConfig);
3283
+ this.samplingTemperature = samplingTemperature;
3254
3284
  this.client = new import_genai3.GoogleGenAI({
3255
3285
  apiKey
3256
3286
  });
@@ -3349,7 +3379,7 @@ var GoogleAgent = class extends AbstractAgent {
3349
3379
  try {
3350
3380
  const googleSchema = ZodSchemaConverter.toGoogleSchema(zodSchema);
3351
3381
  const config = {
3352
- temperature: this.temperature,
3382
+ ...this.samplingTemperature !== void 0 ? { temperature: this.samplingTemperature } : {},
3353
3383
  responseMimeType: "application/json",
3354
3384
  responseSchema: googleSchema,
3355
3385
  maxOutputTokens: this.maxOutputTokens,
@@ -3439,7 +3469,7 @@ var GoogleAgent = class extends AbstractAgent {
3439
3469
  const contents = this.convertToContents(messages);
3440
3470
  try {
3441
3471
  const config = {
3442
- temperature: this.temperature,
3472
+ ...this.samplingTemperature !== void 0 ? { temperature: this.samplingTemperature } : {},
3443
3473
  maxOutputTokens: this.maxOutputTokens,
3444
3474
  systemInstruction: this.instruction
3445
3475
  };