@genesislcap/ai-assistant 15.96.2-GENC-1665.4 → 15.96.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.
@@ -1218,13 +1218,10 @@ var SUPPORTED_GEMINI_MODEL_IDS = [
1218
1218
  ];
1219
1219
  var SUPPORTED_ANTHROPIC_MODEL_IDS = [
1220
1220
  "claude-fable-5",
1221
- "claude-opus-5-5",
1222
1221
  "claude-opus-4-8",
1223
1222
  "claude-opus-4-7",
1224
- "claude-sonnet-5-5",
1225
1223
  "claude-sonnet-5",
1226
1224
  "claude-sonnet-4-6",
1227
- "claude-haiku-5-5",
1228
1225
  "claude-haiku-4-5-20251001"
1229
1226
  ];
1230
1227
  var SUPPORTED_OPENAI_MODEL_IDS = [
@@ -1261,40 +1258,14 @@ function scaleTemperature(normalized, { defaultTemp, maxTemp }) {
1261
1258
 
1262
1259
  // ../../foundation-ai/dist/esm/utils/token-cost.js
1263
1260
  var TOKENS_PER_MILLION = 1e6;
1264
- var ANTHROPIC_LONG_CONTEXT_THRESHOLD = 1e5;
1265
1261
  var ANTHROPIC_PRICING = {
1266
- "claude-haiku-4-5-20251001": {
1267
- kind: "flat",
1268
- rate: { promptPerMillion: 1, candidatePerMillion: 5 }
1269
- },
1270
- // Haiku 5.5 has two rate cards chosen by prompt length; cache reads are 0.1× the input rate of
1271
- // whichever card applies, like every other model here.
1272
- "claude-haiku-5-5": {
1273
- kind: "tiered",
1274
- standard: { promptPerMillion: 0.1, candidatePerMillion: 0.5 },
1275
- longContext: { promptPerMillion: 0.5, candidatePerMillion: 2.5 }
1276
- },
1262
+ "claude-haiku-4-5-20251001": { promptPerMillion: 1, candidatePerMillion: 5 },
1277
1263
  // Fable 5 — Anthropic's most capable widely-released model; priced above Opus tier.
1278
- "claude-fable-5": { kind: "flat", rate: { promptPerMillion: 10, candidatePerMillion: 50 } },
1279
- // Opus 5.5 — $4 / $20, cheaper than Opus 4.8. Its cache reads are $0.20 / MTok, i.e. 0.05× the
1280
- // input rate (as on Sonnet 5.5), NOT the 0.1× every older model reads at: the global
1281
- // multiplier would bill its cache reads at double.
1282
- "claude-opus-5-5": {
1283
- kind: "flat",
1284
- rate: { promptPerMillion: 4, candidatePerMillion: 20 },
1285
- cacheReadMultiplier: 0.05
1286
- },
1264
+ "claude-fable-5": { promptPerMillion: 10, candidatePerMillion: 50 },
1287
1265
  // Opus 4.7 / 4.8 — same $5 / $25 per MTok. Stated per model rather than shared through a
1288
1266
  // fall-through, so neither is ever "whatever was left over".
1289
- "claude-opus-4-8": { kind: "flat", rate: { promptPerMillion: 5, candidatePerMillion: 25 } },
1290
- "claude-opus-4-7": { kind: "flat", rate: { promptPerMillion: 5, candidatePerMillion: 25 } },
1291
- // Sonnet 5.5 — same $2 / $10 as Sonnet 5, but its cache reads are $0.10 / MTok (0.05×, like
1292
- // Opus 5.5), half of Sonnet 5's $0.20.
1293
- "claude-sonnet-5-5": {
1294
- kind: "flat",
1295
- rate: { promptPerMillion: 2, candidatePerMillion: 10 },
1296
- cacheReadMultiplier: 0.05
1297
- },
1267
+ "claude-opus-4-8": { promptPerMillion: 5, candidatePerMillion: 25 },
1268
+ "claude-opus-4-7": { promptPerMillion: 5, candidatePerMillion: 25 },
1298
1269
  // Sonnet 5 is $2 / $10 — its OWN tier, and CHEAPER than the older Sonnet 4.6 below.
1299
1270
  //
1300
1271
  // This launched as an introductory rate through 2026-08-31, and an earlier version of this
@@ -1303,32 +1274,22 @@ var ANTHROPIC_PRICING = {
1303
1274
  // standard price and cancelled the scheduled increase, so that reasoning is dead and the old
1304
1275
  // figure over-charged every Sonnet 5 request by 50%.
1305
1276
  // https://platform.claude.com/docs/en/about-claude/pricing#model-pricing
1306
- "claude-sonnet-5": { kind: "flat", rate: { promptPerMillion: 2, candidatePerMillion: 10 } },
1277
+ "claude-sonnet-5": { promptPerMillion: 2, candidatePerMillion: 10 },
1307
1278
  // Sonnet 4.6 remains on the older $3 / $15 Sonnet tier — the newer model is the cheaper one.
1308
- "claude-sonnet-4-6": { kind: "flat", rate: { promptPerMillion: 3, candidatePerMillion: 15 } }
1279
+ "claude-sonnet-4-6": { promptPerMillion: 3, candidatePerMillion: 15 }
1309
1280
  };
1310
- function anthropicRatesFor(model, promptTokens = 0) {
1311
- const pricing = ANTHROPIC_PRICING[model];
1312
- if (pricing.kind === "flat") {
1313
- return pricing.rate;
1314
- }
1315
- return promptTokens > ANTHROPIC_LONG_CONTEXT_THRESHOLD ? pricing.longContext : pricing.standard;
1281
+ function anthropicRatesFor(model) {
1282
+ return ANTHROPIC_PRICING[model];
1316
1283
  }
1317
1284
  var ANTHROPIC_CACHE_READ_MULTIPLIER = 0.1;
1318
- function anthropicCacheReadMultiplierFor(model) {
1319
- var _a;
1320
- return (_a = ANTHROPIC_PRICING[model].cacheReadMultiplier) !== null && _a !== void 0 ? _a : ANTHROPIC_CACHE_READ_MULTIPLIER;
1321
- }
1322
1285
  var ANTHROPIC_CACHE_WRITE_5M_MULTIPLIER = 1.25;
1323
1286
  var ANTHROPIC_CACHE_WRITE_1H_MULTIPLIER = 2;
1324
1287
  function anthropicTokenCost(model, usage) {
1325
- const promptTokens = usage.uncachedInputTokens + usage.cacheReadTokens + usage.cacheWriteTokens;
1326
- const { promptPerMillion, candidatePerMillion } = anthropicRatesFor(model, promptTokens);
1327
- const cacheReadMultiplier = anthropicCacheReadMultiplierFor(model);
1288
+ const { promptPerMillion, candidatePerMillion } = anthropicRatesFor(model);
1328
1289
  const m = TOKENS_PER_MILLION;
1329
1290
  const cacheWrite5mTokens = Math.max(0, usage.cacheWriteTokens - usage.cacheWrite1hTokens);
1330
1291
  const promptCost = usage.uncachedInputTokens / m * promptPerMillion;
1331
- const cacheReadCost = usage.cacheReadTokens / m * promptPerMillion * cacheReadMultiplier;
1292
+ const cacheReadCost = usage.cacheReadTokens / m * promptPerMillion * ANTHROPIC_CACHE_READ_MULTIPLIER;
1332
1293
  const cacheWriteCost = cacheWrite5mTokens / m * promptPerMillion * ANTHROPIC_CACHE_WRITE_5M_MULTIPLIER + usage.cacheWrite1hTokens / m * promptPerMillion * ANTHROPIC_CACHE_WRITE_1H_MULTIPLIER;
1333
1294
  const candidateCost = usage.outputTokens / m * candidatePerMillion;
1334
1295
  const cacheReadFull = usage.cacheReadTokens / m * promptPerMillion;
@@ -2323,7 +2284,6 @@ var DEFAULT_MODEL = "claude-haiku-4-5-20251001";
2323
2284
  var DEFAULT_TIMEOUT = 3e5;
2324
2285
  var DEFAULT_STALL_TIMEOUT = 3e4;
2325
2286
  var DEFAULT_MAX_TOKENS = 4096;
2326
- var CLAUDE_55_DEFAULT_MAX_TOKENS = 64e3;
2327
2287
  var ANTHROPIC_DEFAULT_TEMPERATURE = 1;
2328
2288
  var ANTHROPIC_MAX_TEMPERATURE = 1;
2329
2289
  function toAnthropicToolChoice(choice) {
@@ -2337,60 +2297,38 @@ function toAnthropicToolChoice(choice) {
2337
2297
  }
2338
2298
  var ANTHROPIC_CONTEXT_LIMITS = {
2339
2299
  "claude-fable-5": 1e6,
2340
- "claude-opus-5-5": 1e6,
2341
2300
  "claude-opus-4-8": 1e6,
2342
2301
  "claude-opus-4-7": 1e6,
2343
- "claude-sonnet-5-5": 1e6,
2344
2302
  "claude-sonnet-5": 1e6,
2345
2303
  "claude-sonnet-4-6": 1e6,
2346
- "claude-haiku-5-5": 1e6,
2347
2304
  "claude-haiku-4-5-20251001": 2e5
2348
2305
  };
2349
2306
  var STRUCTURED_OUTPUT_TOOL_NAME = "emit_structured_response";
2350
2307
  var SERVER_SIDE_FALLBACK_BETA = "server-side-fallback-2026-06-01";
2351
- var THINKING_BINDING_CONTROLS_BETA = "thinking-binding-controls-2026-08-01";
2352
2308
  function assertSupportedAnthropicModel(model) {
2353
2309
  if (!SUPPORTED_ANTHROPIC_MODEL_IDS.includes(model)) {
2354
2310
  throw new Error(`AnthropicTransport: unsupported model "${model}". Use one of: ${SUPPORTED_ANTHROPIC_MODEL_IDS.join(", ")}.`);
2355
2311
  }
2356
2312
  }
2357
- function isClaude55(model) {
2358
- return model === "claude-opus-5-5" || model === "claude-sonnet-5-5" || model === "claude-haiku-5-5";
2359
- }
2360
2313
  function rejectsSamplingParams(model) {
2361
- return model === "claude-fable-5" || model === "claude-opus-4-8" || model === "claude-opus-4-7" || model === "claude-sonnet-5" || isClaude55(model);
2362
- }
2363
- function supportsForcedToolChoice(model) {
2364
- return model !== "claude-opus-5-5" && model !== "claude-sonnet-5-5";
2314
+ return model === "claude-fable-5" || model === "claude-opus-4-8" || model === "claude-opus-4-7" || model === "claude-sonnet-5";
2365
2315
  }
2366
2316
  function supportsNativeStructuredOutput(model) {
2367
- return model === "claude-fable-5" || model === "claude-opus-4-8" || model === "claude-sonnet-5" || model === "claude-haiku-4-5-20251001" || isClaude55(model);
2317
+ return model === "claude-fable-5" || model === "claude-opus-4-8" || model === "claude-sonnet-5" || model === "claude-haiku-4-5-20251001";
2368
2318
  }
2369
2319
  function supportsAdaptiveThinking(model) {
2370
2320
  return model !== "claude-haiku-4-5-20251001";
2371
2321
  }
2372
2322
  function thinkingIsMandatory(model) {
2373
- return model === "claude-fable-5" || model === "claude-opus-5-5";
2374
- }
2375
- function defaultsToThinking(model) {
2376
- return model === "claude-sonnet-5" || model === "claude-sonnet-5-5" || model === "claude-haiku-5-5" || thinkingIsMandatory(model);
2377
- }
2378
- function thinkingOff(model) {
2379
- return model === "claude-sonnet-5-5" ? { type: "between_tools" } : { type: "disabled" };
2380
- }
2381
- var POLICY_EFFORT = {
2382
- "claude-opus-5-5": { off: "low" }
2383
- };
2384
- function sendsBlockBinding(model) {
2385
- return isClaude55(model);
2323
+ return model === "claude-fable-5";
2386
2324
  }
2387
2325
  function anthropicThinking(model, policy) {
2388
- const thinksByDefault = defaultsToThinking(model);
2326
+ const defaultsToThinking = model === "claude-sonnet-5" || thinkingIsMandatory(model);
2389
2327
  const adaptive = { type: "adaptive", display: "summarized" };
2390
2328
  if (policy === "off") {
2391
2329
  if (thinkingIsMandatory(model))
2392
2330
  return adaptive;
2393
- return thinksByDefault ? thinkingOff(model) : void 0;
2331
+ return defaultsToThinking ? { type: "disabled" } : void 0;
2394
2332
  }
2395
2333
  if (policy === "auto") {
2396
2334
  return supportsAdaptiveThinking(model) ? adaptive : void 0;
@@ -2398,10 +2336,10 @@ function anthropicThinking(model, policy) {
2398
2336
  if (policy !== void 0) {
2399
2337
  return supportsAdaptiveThinking(model) ? adaptive : void 0;
2400
2338
  }
2401
- return thinksByDefault ? adaptive : void 0;
2339
+ return defaultsToThinking ? adaptive : void 0;
2402
2340
  }
2403
2341
  function supportsEffort(model) {
2404
- return model === "claude-fable-5" || model === "claude-opus-4-8" || model === "claude-sonnet-5" || isClaude55(model);
2342
+ return model === "claude-fable-5" || model === "claude-opus-4-8" || model === "claude-sonnet-5";
2405
2343
  }
2406
2344
  var ANTHROPIC_EFFORT = {
2407
2345
  minimal: "low",
@@ -2411,11 +2349,8 @@ var ANTHROPIC_EFFORT = {
2411
2349
  max: "max"
2412
2350
  };
2413
2351
  function anthropicEffort(model, policy) {
2414
- var _a;
2415
- if (policy === void 0)
2352
+ if (policy === void 0 || policy === "auto" || policy === "off")
2416
2353
  return void 0;
2417
- if (policy === "auto" || policy === "off")
2418
- return (_a = POLICY_EFFORT[model]) === null || _a === void 0 ? void 0 : _a[policy];
2419
2354
  if (!supportsEffort(model) || !supportsAdaptiveThinking(model))
2420
2355
  return void 0;
2421
2356
  return ANTHROPIC_EFFORT[policy];
@@ -2459,14 +2394,11 @@ var AnthropicTransport = class _AnthropicTransport {
2459
2394
  * outcome the type's own docs promise callers never happens.
2460
2395
  */
2461
2396
  clampWarning(policy) {
2462
- var _a, _b;
2463
2397
  switch (policy) {
2464
2398
  case void 0:
2465
2399
  return void 0;
2466
2400
  case "off":
2467
- if (!thinkingIsMandatory(this.model))
2468
- return void 0;
2469
- return ((_a = POLICY_EFFORT[this.model]) === null || _a === void 0 ? void 0 : _a.off) ? `AnthropicTransport: thinkingPolicy 'off' approximated \u2014 ${this.model} always thinks and rejects an explicit disable, so the turn runs at effort '${(_b = POLICY_EFFORT[this.model]) === null || _b === void 0 ? void 0 : _b.off}' instead. It may still think a little, billed as output.` : `AnthropicTransport: thinkingPolicy 'off' ignored \u2014 ${this.model} always thinks and rejects an explicit disable. Reasoning tokens are still billed as output; switch model if you need them gone.`;
2401
+ return thinkingIsMandatory(this.model) ? `AnthropicTransport: thinkingPolicy 'off' ignored \u2014 ${this.model} always thinks and rejects an explicit disable. Reasoning tokens are still billed as output; switch model if you need them gone.` : void 0;
2470
2402
  case "auto":
2471
2403
  return supportsAdaptiveThinking(this.model) ? void 0 : `AnthropicTransport: thinkingPolicy 'auto' ignored \u2014 ${this.model} does not support adaptive thinking, so this turn runs without reasoning. Use a Sonnet or Opus tier if the agent needs it.`;
2472
2404
  case "minimal":
@@ -2475,7 +2407,7 @@ var AnthropicTransport = class _AnthropicTransport {
2475
2407
  case "high":
2476
2408
  case "max":
2477
2409
  if (!supportsAdaptiveThinking(this.model) || !supportsEffort(this.model)) {
2478
- return `AnthropicTransport: thinkingPolicy '${policy}' ignored \u2014 ${this.model} predates output_config.effort, so this turn runs at its default posture. Use Opus 4.8 or later, Sonnet 5 or later, Haiku 5.5, or Fable 5 to set reasoning depth.`;
2410
+ return `AnthropicTransport: thinkingPolicy '${policy}' ignored \u2014 ${this.model} predates output_config.effort, so this turn runs at its default posture. Use Opus 4.8, Sonnet 5, or Fable 5 to set reasoning depth.`;
2479
2411
  }
2480
2412
  return void 0;
2481
2413
  default: {
@@ -2485,11 +2417,10 @@ var AnthropicTransport = class _AnthropicTransport {
2485
2417
  }
2486
2418
  }
2487
2419
  constructor(config = {}) {
2488
- var _a, _b, _c, _d, _e;
2420
+ var _a, _b, _c, _d;
2489
2421
  this.lifetimeCostUsd = 0;
2490
2422
  this.lifetimeSavingsUsd = 0;
2491
2423
  this.warnedThinkingClamped = false;
2492
- this.warnedToolChoiceDowngraded = false;
2493
2424
  this.warnedUnknownServingModels = /* @__PURE__ */ new Set();
2494
2425
  const model = (_a = config.model) !== null && _a !== void 0 ? _a : DEFAULT_MODEL;
2495
2426
  assertSupportedAnthropicModel(model);
@@ -2500,10 +2431,6 @@ var AnthropicTransport = class _AnthropicTransport {
2500
2431
  logger.warn("AnthropicTransport: using claude-sonnet-4-6 \u2014 higher cost than Haiku; use for stronger reasoning or agent tasks.");
2501
2432
  } else if (model === "claude-opus-4-7" || model === "claude-opus-4-8") {
2502
2433
  logger.warn(`AnthropicTransport: using ${model} \u2014 significantly higher cost; reserve for tasks where Sonnet reliability is insufficient.`);
2503
- } else if (model === "claude-opus-5-5") {
2504
- logger.warn("AnthropicTransport: using claude-opus-5-5 \u2014 Opus tier ($4 / $20 per MTok) with thinking always on (effort defaults to medium). Reserve for tasks where Sonnet reliability is insufficient.");
2505
- } else if (model === "claude-sonnet-5-5") {
2506
- logger.warn("AnthropicTransport: using claude-sonnet-5-5 \u2014 standard Sonnet tier ($2 / $10 per MTok), higher cost than Haiku, and adaptive thinking runs by default so reasoning tokens add to output cost. Use for stronger reasoning or agent tasks.");
2507
2434
  } else if (model === "claude-fable-5") {
2508
2435
  logger.warn(`AnthropicTransport: using claude-fable-5 \u2014 Anthropic's most capable model, priced above Opus tier ($10 / $50 per MTok) with thinking always on. Reserve for the hardest reasoning/long-horizon work. Requires \u226530-day data retention (unavailable under ZDR) and may return stop_reason "refusal"; pair with an Opus 4.8 fallback.`);
2509
2436
  }
@@ -2511,8 +2438,7 @@ var AnthropicTransport = class _AnthropicTransport {
2511
2438
  this.stallTimeout = (_c = config.stallTimeout) !== null && _c !== void 0 ? _c : DEFAULT_STALL_TIMEOUT;
2512
2439
  this.apiKey = config.apiKey;
2513
2440
  this.serverEndpoint = config.serverEndpoint;
2514
- this.maxTokens = (_d = config.maxTokens) !== null && _d !== void 0 ? _d : isClaude55(model) ? CLAUDE_55_DEFAULT_MAX_TOKENS : DEFAULT_MAX_TOKENS;
2515
- this.thinkingBlockBinding = (_e = config.thinkingBlockBinding) !== null && _e !== void 0 ? _e : "drop_block";
2441
+ this.maxTokens = (_d = config.maxTokens) !== null && _d !== void 0 ? _d : DEFAULT_MAX_TOKENS;
2516
2442
  }
2517
2443
  getConfig() {
2518
2444
  return {
@@ -2552,9 +2478,6 @@ var AnthropicTransport = class _AnthropicTransport {
2552
2478
  if (useNative) {
2553
2479
  body.output_config = Object.assign(Object.assign({}, body.output_config), { format: { type: "json_schema", schema: responseSchema } });
2554
2480
  } else if (useForcedTool) {
2555
- if (!supportsForcedToolChoice(this.model)) {
2556
- throw new Error(`AnthropicTransport: ${this.model} rejects forced tool_choice and must be listed in supportsNativeStructuredOutput.`);
2557
- }
2558
2481
  body.tools = [
2559
2482
  {
2560
2483
  name: STRUCTURED_OUTPUT_TOOL_NAME,
@@ -2564,9 +2487,8 @@ var AnthropicTransport = class _AnthropicTransport {
2564
2487
  ];
2565
2488
  body.tool_choice = { type: "tool", name: STRUCTURED_OUTPUT_TOOL_NAME };
2566
2489
  }
2567
- if (defaultsToThinking(this.model) && !thinkingIsMandatory(this.model)) {
2568
- body.thinking = thinkingOff(this.model);
2569
- }
2490
+ if (this.model === "claude-sonnet-5")
2491
+ body.thinking = { type: "disabled" };
2570
2492
  const response = yield this.post(body);
2571
2493
  if (useForcedTool) {
2572
2494
  const toolUse = ((_a = response.content) !== null && _a !== void 0 ? _a : []).find((b) => b.type === "tool_use" && b.name === STRUCTURED_OUTPUT_TOOL_NAME);
@@ -2595,11 +2517,15 @@ var AnthropicTransport = class _AnthropicTransport {
2595
2517
  if ((_c = options === null || options === void 0 ? void 0 : options.tools) === null || _c === void 0 ? void 0 : _c.length) {
2596
2518
  body.tools = options.tools.map((t) => Object.assign({ name: t.name, description: t.description, input_schema: t.enforceSchema ? enforceAnthropicToolSchema(t.parameters, t.name) : t.parameters }, t.enforceSchema ? { strict: true } : {}));
2597
2519
  }
2598
- const forcedToolNote = ((_d = body.tools) === null || _d === void 0 ? void 0 : _d.length) ? this.applyToolChoice(body, options === null || options === void 0 ? void 0 : options.toolChoice) : void 0;
2520
+ if ((_d = body.tools) === null || _d === void 0 ? void 0 : _d.length) {
2521
+ const toolChoice = toAnthropicToolChoice(options === null || options === void 0 ? void 0 : options.toolChoice);
2522
+ if (toolChoice)
2523
+ body.tool_choice = toolChoice;
2524
+ }
2599
2525
  this.warnIfThinkingUnclampable(options === null || options === void 0 ? void 0 : options.thinkingPolicy);
2600
2526
  const thinking = anthropicThinking(this.model, options === null || options === void 0 ? void 0 : options.thinkingPolicy);
2601
2527
  if (thinking)
2602
- body.thinking = this.withBlockBinding(thinking);
2528
+ body.thinking = thinking;
2603
2529
  const effort = anthropicEffort(this.model, options === null || options === void 0 ? void 0 : options.thinkingPolicy);
2604
2530
  if (effort)
2605
2531
  body.output_config = Object.assign(Object.assign({}, body.output_config), { effort });
@@ -2619,76 +2545,13 @@ var AnthropicTransport = class _AnthropicTransport {
2619
2545
  if (options === null || options === void 0 ? void 0 : options.cachePolicy) {
2620
2546
  this.applyCacheControl(body, options.cachePolicy);
2621
2547
  }
2622
- const tail = [options === null || options === void 0 ? void 0 : options.tailContext, forcedToolNote].filter(Boolean).join("\n\n");
2623
- if (tail) {
2624
- this.appendTailContext(body, tail);
2548
+ if (options === null || options === void 0 ? void 0 : options.tailContext) {
2549
+ this.appendTailContext(body, options.tailContext);
2625
2550
  }
2626
2551
  const response = yield this.post(body, options === null || options === void 0 ? void 0 : options.signal);
2627
- const message = this.fromAnthropicResponse(response, body.max_tokens);
2628
- if (forcedToolNote && message.responseMeta) {
2629
- message.responseMeta.toolChoiceDowngraded = true;
2630
- }
2631
- return message;
2552
+ return this.fromAnthropicResponse(response, body.max_tokens);
2632
2553
  });
2633
2554
  }
2634
- /**
2635
- * Set `tool_choice` from the caller's {@link ChatToolChoice}. `'required'`/`{ tool }` force a
2636
- * tool call so a turn can only end via one (e.g. a sub-agent's completion tool); on a model that
2637
- * rejects forcing they are downgraded (see `downgradeForcedToolChoice`), and the instruction
2638
- * that replaces them is returned for the tail.
2639
- */
2640
- applyToolChoice(body, choice) {
2641
- const toolChoice = toAnthropicToolChoice(choice);
2642
- if (!toolChoice)
2643
- return void 0;
2644
- const forced = toolChoice.type === "any" || toolChoice.type === "tool";
2645
- if (forced && !supportsForcedToolChoice(this.model)) {
2646
- return this.downgradeForcedToolChoice(toolChoice);
2647
- }
2648
- body.tool_choice = toolChoice;
2649
- return void 0;
2650
- }
2651
- /**
2652
- * Preserved thinking (5.5 family): say what a changed history does to replayed thinking, rather
2653
- * than inheriting the account default (a 400 on accounts created on or after 2026-08-31).
2654
- * Adaptive only — `between_tools` and `disabled` reject the field — and a fresh object, so the
2655
- * shared `adaptive` constant in `anthropicThinking` is never mutated.
2656
- */
2657
- withBlockBinding(thinking) {
2658
- if (thinking.type !== "adaptive" || !sendsBlockBinding(this.model) || this.thinkingBlockBinding === "omit") {
2659
- return thinking;
2660
- }
2661
- return Object.assign(Object.assign({}, thinking), { block_binding: { prefix_mismatch_behavior: this.thinkingBlockBinding } });
2662
- }
2663
- /**
2664
- * Stand-in for a forced tool call on a model that rejects `tool_choice` `any`/`tool` with a 400
2665
- * (Opus 5.5, Sonnet 5.5). The request goes out with `tool_choice` omitted (`auto`), and an
2666
- * instruction naming the tool is returned for the caller to append to the tail.
2667
- *
2668
- * **The tools array is left exactly as the caller built it.** It renders first in the prompt, so
2669
- * it heads both the prompt-cache prefix and the prefix preserved thinking is bound to. Rewriting
2670
- * a tool only on forced turns (making it `strict`, say) would change those bytes every time an
2671
- * agent moves between forced and `auto` turns: a cache miss, every replayed thinking block
2672
- * dropped (or a 400 under `block_binding: 'error'`), and a tool that accepts different arguments
2673
- * depending on the turn. Whether a tool's arguments are enforced is the caller's decision, made
2674
- * once per tool with `enforceSchema`, and holds on every turn; a completion tool that is forced
2675
- * is a good candidate for it.
2676
- *
2677
- * `auto` lets the model answer in text instead, so the caller is told: a one-time warning here,
2678
- * and `responseMeta.toolChoiceDowngraded` on every affected response. In the ChatDriver a
2679
- * sub-agent that answers in text is held open by the finish-guard completion nudge; a parent
2680
- * agent that relies on forcing should give itself a `finishGuard` that asks for the call.
2681
- */
2682
- downgradeForcedToolChoice(toolChoice) {
2683
- if (!this.warnedToolChoiceDowngraded) {
2684
- this.warnedToolChoiceDowngraded = true;
2685
- logger.warn(`AnthropicTransport: ${this.model} rejects a forced tool_choice; sending 'auto' with an instruction to call the tool instead. A reply may still come back without a tool call \u2014 check responseMeta.toolChoiceDowngraded.`);
2686
- }
2687
- if (toolChoice.type === "tool" && toolChoice.name) {
2688
- return `<system-reminder>Respond to this turn by calling the \`${toolChoice.name}\` tool. Do not reply with text alone.</system-reminder>`;
2689
- }
2690
- return "<system-reminder>Respond to this turn by calling one of your tools. Do not reply with text alone.</system-reminder>";
2691
- }
2692
2555
  /**
2693
2556
  * Place prompt-cache breakpoints on the outgoing request per the resolved {@link CachePolicy}.
2694
2557
  * A breakpoint is `cache_control: {type:'ephemeral'}` on a content block / tool / system block;
@@ -2988,7 +2851,7 @@ ${att.content}` });
2988
2851
  return this.logTokenUsage(model, (_e = usage.input_tokens) !== null && _e !== void 0 ? _e : 0, (_f = usage.output_tokens) !== null && _f !== void 0 ? _f : 0, cacheRead, cacheCreation, cacheCreation1h);
2989
2852
  }
2990
2853
  fromAnthropicResponse(response, effectiveMaxTokens = this.maxTokens) {
2991
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
2854
+ var _a, _b, _c, _d, _e, _f, _g;
2992
2855
  let inputTokens;
2993
2856
  let outputTokens;
2994
2857
  let cacheReadTokens;
@@ -3088,16 +2951,6 @@ ${att.content}` });
3088
2951
  };
3089
2952
  if (response.stop_reason)
3090
2953
  responseMeta.finishReason = response.stop_reason;
3091
- if ((_h = response.input_transformations) === null || _h === void 0 ? void 0 : _h.length) {
3092
- responseMeta.inputTransformations = response.input_transformations.map((t) => Object.assign(Object.assign({ type: t.type }, t.path != null ? { path: t.path } : {}), t.reason != null ? { reason: t.reason } : {}));
3093
- const dropped = response.input_transformations.filter((t) => t.type === "thinking_dropped");
3094
- if (dropped.length) {
3095
- logger.debug(`AnthropicTransport: ${dropped.length} thinking block(s) dropped by ${(_j = response.model) !== null && _j !== void 0 ? _j : this.model}: ${dropped.map((t) => {
3096
- var _a2, _b2;
3097
- return `${(_a2 = t.path) !== null && _a2 !== void 0 ? _a2 : "?"} (${(_b2 = t.reason) !== null && _b2 !== void 0 ? _b2 : "unknown"})`;
3098
- }).join(", ")}`);
3099
- }
3100
- }
3101
2954
  base.responseMeta = responseMeta;
3102
2955
  return base;
3103
2956
  }
@@ -3129,13 +2982,9 @@ ${att.content}` });
3129
2982
  }
3130
2983
  post(body, signal) {
3131
2984
  return __awaiter(this, void 0, void 0, function* () {
3132
- var _a, _b;
2985
+ var _a;
3133
2986
  const { url, headers, credentials } = this.buildEndpoint();
3134
- const betas = [
3135
- ((_a = body.fallbacks) === null || _a === void 0 ? void 0 : _a.length) ? SERVER_SIDE_FALLBACK_BETA : void 0,
3136
- ((_b = body.thinking) === null || _b === void 0 ? void 0 : _b.type) === "adaptive" && body.thinking.block_binding ? THINKING_BINDING_CONTROLS_BETA : void 0
3137
- ].filter((b) => Boolean(b));
3138
- const requestHeaders = betas.length ? Object.assign(Object.assign({}, headers), { "anthropic-beta": [headers["anthropic-beta"], ...betas].filter(Boolean).join(",") }) : headers;
2987
+ const requestHeaders = ((_a = body.fallbacks) === null || _a === void 0 ? void 0 : _a.length) ? Object.assign(Object.assign({}, headers), { "anthropic-beta": [headers["anthropic-beta"], SERVER_SIDE_FALLBACK_BETA].filter(Boolean).join(",") }) : headers;
3139
2988
  return yield postWithRetry({
3140
2989
  url,
3141
2990
  headers: requestHeaders,
@@ -13903,7 +13752,6 @@ export {
13903
13752
  ANTHROPIC_CACHE_READ_MULTIPLIER,
13904
13753
  ANTHROPIC_CACHE_WRITE_1H_MULTIPLIER,
13905
13754
  ANTHROPIC_CACHE_WRITE_5M_MULTIPLIER,
13906
- ANTHROPIC_LONG_CONTEXT_THRESHOLD,
13907
13755
  AgenticActivityBus,
13908
13756
  AnthropicProvider,
13909
13757
  AnthropicTransport,
@@ -13937,7 +13785,6 @@ export {
13937
13785
  agenticActivityBus,
13938
13786
  aiServiceAccessRefusalOf,
13939
13787
  aiServiceErrorCodeOf,
13940
- anthropicCacheReadMultiplierFor,
13941
13788
  anthropicRatesFor,
13942
13789
  anthropicTokenCost,
13943
13790
  assembleDebugLog,