@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.
- package/dist/chat-driver.cjs +36 -191
- package/dist/chat-driver.cjs.map +3 -3
- package/dist/chat-driver.mjs +36 -189
- package/dist/chat-driver.mjs.map +3 -3
- package/dist/custom-elements.json +2490 -2506
- package/dist/dts/chat-driver-node.d.ts +1 -1
- package/dist/dts/chat-driver-node.d.ts.map +1 -1
- package/dist/esm/chat-driver-node.js +1 -1
- package/package.json +17 -17
package/dist/chat-driver.cjs
CHANGED
|
@@ -27,7 +27,6 @@ __export(chat_driver_node_exports, {
|
|
|
27
27
|
ANTHROPIC_CACHE_READ_MULTIPLIER: () => ANTHROPIC_CACHE_READ_MULTIPLIER,
|
|
28
28
|
ANTHROPIC_CACHE_WRITE_1H_MULTIPLIER: () => ANTHROPIC_CACHE_WRITE_1H_MULTIPLIER,
|
|
29
29
|
ANTHROPIC_CACHE_WRITE_5M_MULTIPLIER: () => ANTHROPIC_CACHE_WRITE_5M_MULTIPLIER,
|
|
30
|
-
ANTHROPIC_LONG_CONTEXT_THRESHOLD: () => ANTHROPIC_LONG_CONTEXT_THRESHOLD,
|
|
31
30
|
AgenticActivityBus: () => AgenticActivityBus,
|
|
32
31
|
AnthropicProvider: () => AnthropicProvider,
|
|
33
32
|
AnthropicTransport: () => AnthropicTransport,
|
|
@@ -61,7 +60,6 @@ __export(chat_driver_node_exports, {
|
|
|
61
60
|
agenticActivityBus: () => agenticActivityBus,
|
|
62
61
|
aiServiceAccessRefusalOf: () => aiServiceAccessRefusalOf,
|
|
63
62
|
aiServiceErrorCodeOf: () => aiServiceErrorCodeOf,
|
|
64
|
-
anthropicCacheReadMultiplierFor: () => anthropicCacheReadMultiplierFor,
|
|
65
63
|
anthropicRatesFor: () => anthropicRatesFor,
|
|
66
64
|
anthropicTokenCost: () => anthropicTokenCost,
|
|
67
65
|
assembleDebugLog: () => assembleDebugLog,
|
|
@@ -1317,13 +1315,10 @@ var SUPPORTED_GEMINI_MODEL_IDS = [
|
|
|
1317
1315
|
];
|
|
1318
1316
|
var SUPPORTED_ANTHROPIC_MODEL_IDS = [
|
|
1319
1317
|
"claude-fable-5",
|
|
1320
|
-
"claude-opus-5-5",
|
|
1321
1318
|
"claude-opus-4-8",
|
|
1322
1319
|
"claude-opus-4-7",
|
|
1323
|
-
"claude-sonnet-5-5",
|
|
1324
1320
|
"claude-sonnet-5",
|
|
1325
1321
|
"claude-sonnet-4-6",
|
|
1326
|
-
"claude-haiku-5-5",
|
|
1327
1322
|
"claude-haiku-4-5-20251001"
|
|
1328
1323
|
];
|
|
1329
1324
|
var SUPPORTED_OPENAI_MODEL_IDS = [
|
|
@@ -1360,40 +1355,14 @@ function scaleTemperature(normalized, { defaultTemp, maxTemp }) {
|
|
|
1360
1355
|
|
|
1361
1356
|
// ../../foundation-ai/dist/esm/utils/token-cost.js
|
|
1362
1357
|
var TOKENS_PER_MILLION = 1e6;
|
|
1363
|
-
var ANTHROPIC_LONG_CONTEXT_THRESHOLD = 1e5;
|
|
1364
1358
|
var ANTHROPIC_PRICING = {
|
|
1365
|
-
"claude-haiku-4-5-20251001": {
|
|
1366
|
-
kind: "flat",
|
|
1367
|
-
rate: { promptPerMillion: 1, candidatePerMillion: 5 }
|
|
1368
|
-
},
|
|
1369
|
-
// Haiku 5.5 has two rate cards chosen by prompt length; cache reads are 0.1× the input rate of
|
|
1370
|
-
// whichever card applies, like every other model here.
|
|
1371
|
-
"claude-haiku-5-5": {
|
|
1372
|
-
kind: "tiered",
|
|
1373
|
-
standard: { promptPerMillion: 0.1, candidatePerMillion: 0.5 },
|
|
1374
|
-
longContext: { promptPerMillion: 0.5, candidatePerMillion: 2.5 }
|
|
1375
|
-
},
|
|
1359
|
+
"claude-haiku-4-5-20251001": { promptPerMillion: 1, candidatePerMillion: 5 },
|
|
1376
1360
|
// Fable 5 — Anthropic's most capable widely-released model; priced above Opus tier.
|
|
1377
|
-
"claude-fable-5": {
|
|
1378
|
-
// Opus 5.5 — $4 / $20, cheaper than Opus 4.8. Its cache reads are $0.20 / MTok, i.e. 0.05× the
|
|
1379
|
-
// input rate (as on Sonnet 5.5), NOT the 0.1× every older model reads at: the global
|
|
1380
|
-
// multiplier would bill its cache reads at double.
|
|
1381
|
-
"claude-opus-5-5": {
|
|
1382
|
-
kind: "flat",
|
|
1383
|
-
rate: { promptPerMillion: 4, candidatePerMillion: 20 },
|
|
1384
|
-
cacheReadMultiplier: 0.05
|
|
1385
|
-
},
|
|
1361
|
+
"claude-fable-5": { promptPerMillion: 10, candidatePerMillion: 50 },
|
|
1386
1362
|
// Opus 4.7 / 4.8 — same $5 / $25 per MTok. Stated per model rather than shared through a
|
|
1387
1363
|
// fall-through, so neither is ever "whatever was left over".
|
|
1388
|
-
"claude-opus-4-8": {
|
|
1389
|
-
"claude-opus-4-7": {
|
|
1390
|
-
// Sonnet 5.5 — same $2 / $10 as Sonnet 5, but its cache reads are $0.10 / MTok (0.05×, like
|
|
1391
|
-
// Opus 5.5), half of Sonnet 5's $0.20.
|
|
1392
|
-
"claude-sonnet-5-5": {
|
|
1393
|
-
kind: "flat",
|
|
1394
|
-
rate: { promptPerMillion: 2, candidatePerMillion: 10 },
|
|
1395
|
-
cacheReadMultiplier: 0.05
|
|
1396
|
-
},
|
|
1364
|
+
"claude-opus-4-8": { promptPerMillion: 5, candidatePerMillion: 25 },
|
|
1365
|
+
"claude-opus-4-7": { promptPerMillion: 5, candidatePerMillion: 25 },
|
|
1397
1366
|
// Sonnet 5 is $2 / $10 — its OWN tier, and CHEAPER than the older Sonnet 4.6 below.
|
|
1398
1367
|
//
|
|
1399
1368
|
// This launched as an introductory rate through 2026-08-31, and an earlier version of this
|
|
@@ -1402,32 +1371,22 @@ var ANTHROPIC_PRICING = {
|
|
|
1402
1371
|
// standard price and cancelled the scheduled increase, so that reasoning is dead and the old
|
|
1403
1372
|
// figure over-charged every Sonnet 5 request by 50%.
|
|
1404
1373
|
// https://platform.claude.com/docs/en/about-claude/pricing#model-pricing
|
|
1405
|
-
"claude-sonnet-5": {
|
|
1374
|
+
"claude-sonnet-5": { promptPerMillion: 2, candidatePerMillion: 10 },
|
|
1406
1375
|
// Sonnet 4.6 remains on the older $3 / $15 Sonnet tier — the newer model is the cheaper one.
|
|
1407
|
-
"claude-sonnet-4-6": {
|
|
1376
|
+
"claude-sonnet-4-6": { promptPerMillion: 3, candidatePerMillion: 15 }
|
|
1408
1377
|
};
|
|
1409
|
-
function anthropicRatesFor(model
|
|
1410
|
-
|
|
1411
|
-
if (pricing.kind === "flat") {
|
|
1412
|
-
return pricing.rate;
|
|
1413
|
-
}
|
|
1414
|
-
return promptTokens > ANTHROPIC_LONG_CONTEXT_THRESHOLD ? pricing.longContext : pricing.standard;
|
|
1378
|
+
function anthropicRatesFor(model) {
|
|
1379
|
+
return ANTHROPIC_PRICING[model];
|
|
1415
1380
|
}
|
|
1416
1381
|
var ANTHROPIC_CACHE_READ_MULTIPLIER = 0.1;
|
|
1417
|
-
function anthropicCacheReadMultiplierFor(model) {
|
|
1418
|
-
var _a;
|
|
1419
|
-
return (_a = ANTHROPIC_PRICING[model].cacheReadMultiplier) !== null && _a !== void 0 ? _a : ANTHROPIC_CACHE_READ_MULTIPLIER;
|
|
1420
|
-
}
|
|
1421
1382
|
var ANTHROPIC_CACHE_WRITE_5M_MULTIPLIER = 1.25;
|
|
1422
1383
|
var ANTHROPIC_CACHE_WRITE_1H_MULTIPLIER = 2;
|
|
1423
1384
|
function anthropicTokenCost(model, usage) {
|
|
1424
|
-
const
|
|
1425
|
-
const { promptPerMillion, candidatePerMillion } = anthropicRatesFor(model, promptTokens);
|
|
1426
|
-
const cacheReadMultiplier = anthropicCacheReadMultiplierFor(model);
|
|
1385
|
+
const { promptPerMillion, candidatePerMillion } = anthropicRatesFor(model);
|
|
1427
1386
|
const m = TOKENS_PER_MILLION;
|
|
1428
1387
|
const cacheWrite5mTokens = Math.max(0, usage.cacheWriteTokens - usage.cacheWrite1hTokens);
|
|
1429
1388
|
const promptCost = usage.uncachedInputTokens / m * promptPerMillion;
|
|
1430
|
-
const cacheReadCost = usage.cacheReadTokens / m * promptPerMillion *
|
|
1389
|
+
const cacheReadCost = usage.cacheReadTokens / m * promptPerMillion * ANTHROPIC_CACHE_READ_MULTIPLIER;
|
|
1431
1390
|
const cacheWriteCost = cacheWrite5mTokens / m * promptPerMillion * ANTHROPIC_CACHE_WRITE_5M_MULTIPLIER + usage.cacheWrite1hTokens / m * promptPerMillion * ANTHROPIC_CACHE_WRITE_1H_MULTIPLIER;
|
|
1432
1391
|
const candidateCost = usage.outputTokens / m * candidatePerMillion;
|
|
1433
1392
|
const cacheReadFull = usage.cacheReadTokens / m * promptPerMillion;
|
|
@@ -2422,7 +2381,6 @@ var DEFAULT_MODEL = "claude-haiku-4-5-20251001";
|
|
|
2422
2381
|
var DEFAULT_TIMEOUT = 3e5;
|
|
2423
2382
|
var DEFAULT_STALL_TIMEOUT = 3e4;
|
|
2424
2383
|
var DEFAULT_MAX_TOKENS = 4096;
|
|
2425
|
-
var CLAUDE_55_DEFAULT_MAX_TOKENS = 64e3;
|
|
2426
2384
|
var ANTHROPIC_DEFAULT_TEMPERATURE = 1;
|
|
2427
2385
|
var ANTHROPIC_MAX_TEMPERATURE = 1;
|
|
2428
2386
|
function toAnthropicToolChoice(choice) {
|
|
@@ -2436,60 +2394,38 @@ function toAnthropicToolChoice(choice) {
|
|
|
2436
2394
|
}
|
|
2437
2395
|
var ANTHROPIC_CONTEXT_LIMITS = {
|
|
2438
2396
|
"claude-fable-5": 1e6,
|
|
2439
|
-
"claude-opus-5-5": 1e6,
|
|
2440
2397
|
"claude-opus-4-8": 1e6,
|
|
2441
2398
|
"claude-opus-4-7": 1e6,
|
|
2442
|
-
"claude-sonnet-5-5": 1e6,
|
|
2443
2399
|
"claude-sonnet-5": 1e6,
|
|
2444
2400
|
"claude-sonnet-4-6": 1e6,
|
|
2445
|
-
"claude-haiku-5-5": 1e6,
|
|
2446
2401
|
"claude-haiku-4-5-20251001": 2e5
|
|
2447
2402
|
};
|
|
2448
2403
|
var STRUCTURED_OUTPUT_TOOL_NAME = "emit_structured_response";
|
|
2449
2404
|
var SERVER_SIDE_FALLBACK_BETA = "server-side-fallback-2026-06-01";
|
|
2450
|
-
var THINKING_BINDING_CONTROLS_BETA = "thinking-binding-controls-2026-08-01";
|
|
2451
2405
|
function assertSupportedAnthropicModel(model) {
|
|
2452
2406
|
if (!SUPPORTED_ANTHROPIC_MODEL_IDS.includes(model)) {
|
|
2453
2407
|
throw new Error(`AnthropicTransport: unsupported model "${model}". Use one of: ${SUPPORTED_ANTHROPIC_MODEL_IDS.join(", ")}.`);
|
|
2454
2408
|
}
|
|
2455
2409
|
}
|
|
2456
|
-
function isClaude55(model) {
|
|
2457
|
-
return model === "claude-opus-5-5" || model === "claude-sonnet-5-5" || model === "claude-haiku-5-5";
|
|
2458
|
-
}
|
|
2459
2410
|
function rejectsSamplingParams(model) {
|
|
2460
|
-
return model === "claude-fable-5" || model === "claude-opus-4-8" || model === "claude-opus-4-7" || model === "claude-sonnet-5"
|
|
2461
|
-
}
|
|
2462
|
-
function supportsForcedToolChoice(model) {
|
|
2463
|
-
return model !== "claude-opus-5-5" && model !== "claude-sonnet-5-5";
|
|
2411
|
+
return model === "claude-fable-5" || model === "claude-opus-4-8" || model === "claude-opus-4-7" || model === "claude-sonnet-5";
|
|
2464
2412
|
}
|
|
2465
2413
|
function supportsNativeStructuredOutput(model) {
|
|
2466
|
-
return model === "claude-fable-5" || model === "claude-opus-4-8" || model === "claude-sonnet-5" || model === "claude-haiku-4-5-20251001"
|
|
2414
|
+
return model === "claude-fable-5" || model === "claude-opus-4-8" || model === "claude-sonnet-5" || model === "claude-haiku-4-5-20251001";
|
|
2467
2415
|
}
|
|
2468
2416
|
function supportsAdaptiveThinking(model) {
|
|
2469
2417
|
return model !== "claude-haiku-4-5-20251001";
|
|
2470
2418
|
}
|
|
2471
2419
|
function thinkingIsMandatory(model) {
|
|
2472
|
-
return model === "claude-fable-5"
|
|
2473
|
-
}
|
|
2474
|
-
function defaultsToThinking(model) {
|
|
2475
|
-
return model === "claude-sonnet-5" || model === "claude-sonnet-5-5" || model === "claude-haiku-5-5" || thinkingIsMandatory(model);
|
|
2476
|
-
}
|
|
2477
|
-
function thinkingOff(model) {
|
|
2478
|
-
return model === "claude-sonnet-5-5" ? { type: "between_tools" } : { type: "disabled" };
|
|
2479
|
-
}
|
|
2480
|
-
var POLICY_EFFORT = {
|
|
2481
|
-
"claude-opus-5-5": { off: "low" }
|
|
2482
|
-
};
|
|
2483
|
-
function sendsBlockBinding(model) {
|
|
2484
|
-
return isClaude55(model);
|
|
2420
|
+
return model === "claude-fable-5";
|
|
2485
2421
|
}
|
|
2486
2422
|
function anthropicThinking(model, policy) {
|
|
2487
|
-
const
|
|
2423
|
+
const defaultsToThinking = model === "claude-sonnet-5" || thinkingIsMandatory(model);
|
|
2488
2424
|
const adaptive = { type: "adaptive", display: "summarized" };
|
|
2489
2425
|
if (policy === "off") {
|
|
2490
2426
|
if (thinkingIsMandatory(model))
|
|
2491
2427
|
return adaptive;
|
|
2492
|
-
return
|
|
2428
|
+
return defaultsToThinking ? { type: "disabled" } : void 0;
|
|
2493
2429
|
}
|
|
2494
2430
|
if (policy === "auto") {
|
|
2495
2431
|
return supportsAdaptiveThinking(model) ? adaptive : void 0;
|
|
@@ -2497,10 +2433,10 @@ function anthropicThinking(model, policy) {
|
|
|
2497
2433
|
if (policy !== void 0) {
|
|
2498
2434
|
return supportsAdaptiveThinking(model) ? adaptive : void 0;
|
|
2499
2435
|
}
|
|
2500
|
-
return
|
|
2436
|
+
return defaultsToThinking ? adaptive : void 0;
|
|
2501
2437
|
}
|
|
2502
2438
|
function supportsEffort(model) {
|
|
2503
|
-
return model === "claude-fable-5" || model === "claude-opus-4-8" || model === "claude-sonnet-5"
|
|
2439
|
+
return model === "claude-fable-5" || model === "claude-opus-4-8" || model === "claude-sonnet-5";
|
|
2504
2440
|
}
|
|
2505
2441
|
var ANTHROPIC_EFFORT = {
|
|
2506
2442
|
minimal: "low",
|
|
@@ -2510,11 +2446,8 @@ var ANTHROPIC_EFFORT = {
|
|
|
2510
2446
|
max: "max"
|
|
2511
2447
|
};
|
|
2512
2448
|
function anthropicEffort(model, policy) {
|
|
2513
|
-
|
|
2514
|
-
if (policy === void 0)
|
|
2449
|
+
if (policy === void 0 || policy === "auto" || policy === "off")
|
|
2515
2450
|
return void 0;
|
|
2516
|
-
if (policy === "auto" || policy === "off")
|
|
2517
|
-
return (_a = POLICY_EFFORT[model]) === null || _a === void 0 ? void 0 : _a[policy];
|
|
2518
2451
|
if (!supportsEffort(model) || !supportsAdaptiveThinking(model))
|
|
2519
2452
|
return void 0;
|
|
2520
2453
|
return ANTHROPIC_EFFORT[policy];
|
|
@@ -2558,14 +2491,11 @@ var AnthropicTransport = class _AnthropicTransport {
|
|
|
2558
2491
|
* outcome the type's own docs promise callers never happens.
|
|
2559
2492
|
*/
|
|
2560
2493
|
clampWarning(policy) {
|
|
2561
|
-
var _a, _b;
|
|
2562
2494
|
switch (policy) {
|
|
2563
2495
|
case void 0:
|
|
2564
2496
|
return void 0;
|
|
2565
2497
|
case "off":
|
|
2566
|
-
|
|
2567
|
-
return void 0;
|
|
2568
|
-
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.`;
|
|
2498
|
+
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;
|
|
2569
2499
|
case "auto":
|
|
2570
2500
|
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.`;
|
|
2571
2501
|
case "minimal":
|
|
@@ -2574,7 +2504,7 @@ var AnthropicTransport = class _AnthropicTransport {
|
|
|
2574
2504
|
case "high":
|
|
2575
2505
|
case "max":
|
|
2576
2506
|
if (!supportsAdaptiveThinking(this.model) || !supportsEffort(this.model)) {
|
|
2577
|
-
return `AnthropicTransport: thinkingPolicy '${policy}' ignored \u2014 ${this.model} predates output_config.effort, so this turn runs at its default posture. Use Opus 4.8
|
|
2507
|
+
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.`;
|
|
2578
2508
|
}
|
|
2579
2509
|
return void 0;
|
|
2580
2510
|
default: {
|
|
@@ -2584,11 +2514,10 @@ var AnthropicTransport = class _AnthropicTransport {
|
|
|
2584
2514
|
}
|
|
2585
2515
|
}
|
|
2586
2516
|
constructor(config = {}) {
|
|
2587
|
-
var _a, _b, _c, _d
|
|
2517
|
+
var _a, _b, _c, _d;
|
|
2588
2518
|
this.lifetimeCostUsd = 0;
|
|
2589
2519
|
this.lifetimeSavingsUsd = 0;
|
|
2590
2520
|
this.warnedThinkingClamped = false;
|
|
2591
|
-
this.warnedToolChoiceDowngraded = false;
|
|
2592
2521
|
this.warnedUnknownServingModels = /* @__PURE__ */ new Set();
|
|
2593
2522
|
const model = (_a = config.model) !== null && _a !== void 0 ? _a : DEFAULT_MODEL;
|
|
2594
2523
|
assertSupportedAnthropicModel(model);
|
|
@@ -2599,10 +2528,6 @@ var AnthropicTransport = class _AnthropicTransport {
|
|
|
2599
2528
|
logger.warn("AnthropicTransport: using claude-sonnet-4-6 \u2014 higher cost than Haiku; use for stronger reasoning or agent tasks.");
|
|
2600
2529
|
} else if (model === "claude-opus-4-7" || model === "claude-opus-4-8") {
|
|
2601
2530
|
logger.warn(`AnthropicTransport: using ${model} \u2014 significantly higher cost; reserve for tasks where Sonnet reliability is insufficient.`);
|
|
2602
|
-
} else if (model === "claude-opus-5-5") {
|
|
2603
|
-
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.");
|
|
2604
|
-
} else if (model === "claude-sonnet-5-5") {
|
|
2605
|
-
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.");
|
|
2606
2531
|
} else if (model === "claude-fable-5") {
|
|
2607
2532
|
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.`);
|
|
2608
2533
|
}
|
|
@@ -2610,8 +2535,7 @@ var AnthropicTransport = class _AnthropicTransport {
|
|
|
2610
2535
|
this.stallTimeout = (_c = config.stallTimeout) !== null && _c !== void 0 ? _c : DEFAULT_STALL_TIMEOUT;
|
|
2611
2536
|
this.apiKey = config.apiKey;
|
|
2612
2537
|
this.serverEndpoint = config.serverEndpoint;
|
|
2613
|
-
this.maxTokens = (_d = config.maxTokens) !== null && _d !== void 0 ? _d :
|
|
2614
|
-
this.thinkingBlockBinding = (_e = config.thinkingBlockBinding) !== null && _e !== void 0 ? _e : "drop_block";
|
|
2538
|
+
this.maxTokens = (_d = config.maxTokens) !== null && _d !== void 0 ? _d : DEFAULT_MAX_TOKENS;
|
|
2615
2539
|
}
|
|
2616
2540
|
getConfig() {
|
|
2617
2541
|
return {
|
|
@@ -2651,9 +2575,6 @@ var AnthropicTransport = class _AnthropicTransport {
|
|
|
2651
2575
|
if (useNative) {
|
|
2652
2576
|
body.output_config = Object.assign(Object.assign({}, body.output_config), { format: { type: "json_schema", schema: responseSchema } });
|
|
2653
2577
|
} else if (useForcedTool) {
|
|
2654
|
-
if (!supportsForcedToolChoice(this.model)) {
|
|
2655
|
-
throw new Error(`AnthropicTransport: ${this.model} rejects forced tool_choice and must be listed in supportsNativeStructuredOutput.`);
|
|
2656
|
-
}
|
|
2657
2578
|
body.tools = [
|
|
2658
2579
|
{
|
|
2659
2580
|
name: STRUCTURED_OUTPUT_TOOL_NAME,
|
|
@@ -2663,9 +2584,8 @@ var AnthropicTransport = class _AnthropicTransport {
|
|
|
2663
2584
|
];
|
|
2664
2585
|
body.tool_choice = { type: "tool", name: STRUCTURED_OUTPUT_TOOL_NAME };
|
|
2665
2586
|
}
|
|
2666
|
-
if (
|
|
2667
|
-
body.thinking =
|
|
2668
|
-
}
|
|
2587
|
+
if (this.model === "claude-sonnet-5")
|
|
2588
|
+
body.thinking = { type: "disabled" };
|
|
2669
2589
|
const response = yield this.post(body);
|
|
2670
2590
|
if (useForcedTool) {
|
|
2671
2591
|
const toolUse = ((_a = response.content) !== null && _a !== void 0 ? _a : []).find((b) => b.type === "tool_use" && b.name === STRUCTURED_OUTPUT_TOOL_NAME);
|
|
@@ -2694,11 +2614,15 @@ var AnthropicTransport = class _AnthropicTransport {
|
|
|
2694
2614
|
if ((_c = options === null || options === void 0 ? void 0 : options.tools) === null || _c === void 0 ? void 0 : _c.length) {
|
|
2695
2615
|
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 } : {}));
|
|
2696
2616
|
}
|
|
2697
|
-
|
|
2617
|
+
if ((_d = body.tools) === null || _d === void 0 ? void 0 : _d.length) {
|
|
2618
|
+
const toolChoice = toAnthropicToolChoice(options === null || options === void 0 ? void 0 : options.toolChoice);
|
|
2619
|
+
if (toolChoice)
|
|
2620
|
+
body.tool_choice = toolChoice;
|
|
2621
|
+
}
|
|
2698
2622
|
this.warnIfThinkingUnclampable(options === null || options === void 0 ? void 0 : options.thinkingPolicy);
|
|
2699
2623
|
const thinking = anthropicThinking(this.model, options === null || options === void 0 ? void 0 : options.thinkingPolicy);
|
|
2700
2624
|
if (thinking)
|
|
2701
|
-
body.thinking =
|
|
2625
|
+
body.thinking = thinking;
|
|
2702
2626
|
const effort = anthropicEffort(this.model, options === null || options === void 0 ? void 0 : options.thinkingPolicy);
|
|
2703
2627
|
if (effort)
|
|
2704
2628
|
body.output_config = Object.assign(Object.assign({}, body.output_config), { effort });
|
|
@@ -2718,76 +2642,13 @@ var AnthropicTransport = class _AnthropicTransport {
|
|
|
2718
2642
|
if (options === null || options === void 0 ? void 0 : options.cachePolicy) {
|
|
2719
2643
|
this.applyCacheControl(body, options.cachePolicy);
|
|
2720
2644
|
}
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
this.appendTailContext(body, tail);
|
|
2645
|
+
if (options === null || options === void 0 ? void 0 : options.tailContext) {
|
|
2646
|
+
this.appendTailContext(body, options.tailContext);
|
|
2724
2647
|
}
|
|
2725
2648
|
const response = yield this.post(body, options === null || options === void 0 ? void 0 : options.signal);
|
|
2726
|
-
|
|
2727
|
-
if (forcedToolNote && message.responseMeta) {
|
|
2728
|
-
message.responseMeta.toolChoiceDowngraded = true;
|
|
2729
|
-
}
|
|
2730
|
-
return message;
|
|
2649
|
+
return this.fromAnthropicResponse(response, body.max_tokens);
|
|
2731
2650
|
});
|
|
2732
2651
|
}
|
|
2733
|
-
/**
|
|
2734
|
-
* Set `tool_choice` from the caller's {@link ChatToolChoice}. `'required'`/`{ tool }` force a
|
|
2735
|
-
* tool call so a turn can only end via one (e.g. a sub-agent's completion tool); on a model that
|
|
2736
|
-
* rejects forcing they are downgraded (see `downgradeForcedToolChoice`), and the instruction
|
|
2737
|
-
* that replaces them is returned for the tail.
|
|
2738
|
-
*/
|
|
2739
|
-
applyToolChoice(body, choice) {
|
|
2740
|
-
const toolChoice = toAnthropicToolChoice(choice);
|
|
2741
|
-
if (!toolChoice)
|
|
2742
|
-
return void 0;
|
|
2743
|
-
const forced = toolChoice.type === "any" || toolChoice.type === "tool";
|
|
2744
|
-
if (forced && !supportsForcedToolChoice(this.model)) {
|
|
2745
|
-
return this.downgradeForcedToolChoice(toolChoice);
|
|
2746
|
-
}
|
|
2747
|
-
body.tool_choice = toolChoice;
|
|
2748
|
-
return void 0;
|
|
2749
|
-
}
|
|
2750
|
-
/**
|
|
2751
|
-
* Preserved thinking (5.5 family): say what a changed history does to replayed thinking, rather
|
|
2752
|
-
* than inheriting the account default (a 400 on accounts created on or after 2026-08-31).
|
|
2753
|
-
* Adaptive only — `between_tools` and `disabled` reject the field — and a fresh object, so the
|
|
2754
|
-
* shared `adaptive` constant in `anthropicThinking` is never mutated.
|
|
2755
|
-
*/
|
|
2756
|
-
withBlockBinding(thinking) {
|
|
2757
|
-
if (thinking.type !== "adaptive" || !sendsBlockBinding(this.model) || this.thinkingBlockBinding === "omit") {
|
|
2758
|
-
return thinking;
|
|
2759
|
-
}
|
|
2760
|
-
return Object.assign(Object.assign({}, thinking), { block_binding: { prefix_mismatch_behavior: this.thinkingBlockBinding } });
|
|
2761
|
-
}
|
|
2762
|
-
/**
|
|
2763
|
-
* Stand-in for a forced tool call on a model that rejects `tool_choice` `any`/`tool` with a 400
|
|
2764
|
-
* (Opus 5.5, Sonnet 5.5). The request goes out with `tool_choice` omitted (`auto`), and an
|
|
2765
|
-
* instruction naming the tool is returned for the caller to append to the tail.
|
|
2766
|
-
*
|
|
2767
|
-
* **The tools array is left exactly as the caller built it.** It renders first in the prompt, so
|
|
2768
|
-
* it heads both the prompt-cache prefix and the prefix preserved thinking is bound to. Rewriting
|
|
2769
|
-
* a tool only on forced turns (making it `strict`, say) would change those bytes every time an
|
|
2770
|
-
* agent moves between forced and `auto` turns: a cache miss, every replayed thinking block
|
|
2771
|
-
* dropped (or a 400 under `block_binding: 'error'`), and a tool that accepts different arguments
|
|
2772
|
-
* depending on the turn. Whether a tool's arguments are enforced is the caller's decision, made
|
|
2773
|
-
* once per tool with `enforceSchema`, and holds on every turn; a completion tool that is forced
|
|
2774
|
-
* is a good candidate for it.
|
|
2775
|
-
*
|
|
2776
|
-
* `auto` lets the model answer in text instead, so the caller is told: a one-time warning here,
|
|
2777
|
-
* and `responseMeta.toolChoiceDowngraded` on every affected response. In the ChatDriver a
|
|
2778
|
-
* sub-agent that answers in text is held open by the finish-guard completion nudge; a parent
|
|
2779
|
-
* agent that relies on forcing should give itself a `finishGuard` that asks for the call.
|
|
2780
|
-
*/
|
|
2781
|
-
downgradeForcedToolChoice(toolChoice) {
|
|
2782
|
-
if (!this.warnedToolChoiceDowngraded) {
|
|
2783
|
-
this.warnedToolChoiceDowngraded = true;
|
|
2784
|
-
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.`);
|
|
2785
|
-
}
|
|
2786
|
-
if (toolChoice.type === "tool" && toolChoice.name) {
|
|
2787
|
-
return `<system-reminder>Respond to this turn by calling the \`${toolChoice.name}\` tool. Do not reply with text alone.</system-reminder>`;
|
|
2788
|
-
}
|
|
2789
|
-
return "<system-reminder>Respond to this turn by calling one of your tools. Do not reply with text alone.</system-reminder>";
|
|
2790
|
-
}
|
|
2791
2652
|
/**
|
|
2792
2653
|
* Place prompt-cache breakpoints on the outgoing request per the resolved {@link CachePolicy}.
|
|
2793
2654
|
* A breakpoint is `cache_control: {type:'ephemeral'}` on a content block / tool / system block;
|
|
@@ -3087,7 +2948,7 @@ ${att.content}` });
|
|
|
3087
2948
|
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);
|
|
3088
2949
|
}
|
|
3089
2950
|
fromAnthropicResponse(response, effectiveMaxTokens = this.maxTokens) {
|
|
3090
|
-
var _a, _b, _c, _d, _e, _f, _g
|
|
2951
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
3091
2952
|
let inputTokens;
|
|
3092
2953
|
let outputTokens;
|
|
3093
2954
|
let cacheReadTokens;
|
|
@@ -3187,16 +3048,6 @@ ${att.content}` });
|
|
|
3187
3048
|
};
|
|
3188
3049
|
if (response.stop_reason)
|
|
3189
3050
|
responseMeta.finishReason = response.stop_reason;
|
|
3190
|
-
if ((_h = response.input_transformations) === null || _h === void 0 ? void 0 : _h.length) {
|
|
3191
|
-
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 } : {}));
|
|
3192
|
-
const dropped = response.input_transformations.filter((t) => t.type === "thinking_dropped");
|
|
3193
|
-
if (dropped.length) {
|
|
3194
|
-
logger.debug(`AnthropicTransport: ${dropped.length} thinking block(s) dropped by ${(_j = response.model) !== null && _j !== void 0 ? _j : this.model}: ${dropped.map((t) => {
|
|
3195
|
-
var _a2, _b2;
|
|
3196
|
-
return `${(_a2 = t.path) !== null && _a2 !== void 0 ? _a2 : "?"} (${(_b2 = t.reason) !== null && _b2 !== void 0 ? _b2 : "unknown"})`;
|
|
3197
|
-
}).join(", ")}`);
|
|
3198
|
-
}
|
|
3199
|
-
}
|
|
3200
3051
|
base.responseMeta = responseMeta;
|
|
3201
3052
|
return base;
|
|
3202
3053
|
}
|
|
@@ -3228,13 +3079,9 @@ ${att.content}` });
|
|
|
3228
3079
|
}
|
|
3229
3080
|
post(body, signal) {
|
|
3230
3081
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3231
|
-
var _a
|
|
3082
|
+
var _a;
|
|
3232
3083
|
const { url, headers, credentials } = this.buildEndpoint();
|
|
3233
|
-
const
|
|
3234
|
-
((_a = body.fallbacks) === null || _a === void 0 ? void 0 : _a.length) ? SERVER_SIDE_FALLBACK_BETA : void 0,
|
|
3235
|
-
((_b = body.thinking) === null || _b === void 0 ? void 0 : _b.type) === "adaptive" && body.thinking.block_binding ? THINKING_BINDING_CONTROLS_BETA : void 0
|
|
3236
|
-
].filter((b) => Boolean(b));
|
|
3237
|
-
const requestHeaders = betas.length ? Object.assign(Object.assign({}, headers), { "anthropic-beta": [headers["anthropic-beta"], ...betas].filter(Boolean).join(",") }) : headers;
|
|
3084
|
+
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;
|
|
3238
3085
|
return yield postWithRetry({
|
|
3239
3086
|
url,
|
|
3240
3087
|
headers: requestHeaders,
|
|
@@ -14003,7 +13850,6 @@ function collectRows(messages, depth, subAgentOf) {
|
|
|
14003
13850
|
ANTHROPIC_CACHE_READ_MULTIPLIER,
|
|
14004
13851
|
ANTHROPIC_CACHE_WRITE_1H_MULTIPLIER,
|
|
14005
13852
|
ANTHROPIC_CACHE_WRITE_5M_MULTIPLIER,
|
|
14006
|
-
ANTHROPIC_LONG_CONTEXT_THRESHOLD,
|
|
14007
13853
|
AgenticActivityBus,
|
|
14008
13854
|
AnthropicProvider,
|
|
14009
13855
|
AnthropicTransport,
|
|
@@ -14037,7 +13883,6 @@ function collectRows(messages, depth, subAgentOf) {
|
|
|
14037
13883
|
agenticActivityBus,
|
|
14038
13884
|
aiServiceAccessRefusalOf,
|
|
14039
13885
|
aiServiceErrorCodeOf,
|
|
14040
|
-
anthropicCacheReadMultiplierFor,
|
|
14041
13886
|
anthropicRatesFor,
|
|
14042
13887
|
anthropicTokenCost,
|
|
14043
13888
|
assembleDebugLog,
|