@genesislcap/ai-assistant 15.92.0-GENC-1665.1 → 15.92.0-HT-305.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 +39 -212
- package/dist/chat-driver.cjs.map +3 -3
- package/dist/chat-driver.mjs +39 -210
- package/dist/chat-driver.mjs.map +3 -3
- package/dist/custom-elements.json +114 -147
- package/dist/dts/chat-driver-node.d.ts +1 -1
- package/dist/dts/chat-driver-node.d.ts.map +1 -1
- package/dist/dts/components/chat-driver/chat-driver.constants.d.ts +0 -10
- package/dist/dts/components/chat-driver/chat-driver.constants.d.ts.map +1 -1
- package/dist/dts/components/chat-driver/chat-driver.d.ts.map +1 -1
- package/dist/dts/react.d.ts +9 -9
- package/dist/esm/chat-driver-node.js +1 -1
- package/dist/esm/components/chat-driver/chat-driver.constants.js +0 -10
- package/dist/esm/components/chat-driver/chat-driver.js +6 -39
- package/dist/esm/state/debug-event-log.js +1 -1
- package/dist/react.cjs +6 -6
- package/dist/react.mjs +5 -5
- 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,35 +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, NOT the 0.1× every older model reads at: the global multiplier would bill its
|
|
1380
|
-
// 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, cache reads $0.20 (0.1×).
|
|
1391
|
-
"claude-sonnet-5-5": { kind: "flat", rate: { promptPerMillion: 2, candidatePerMillion: 10 } },
|
|
1364
|
+
"claude-opus-4-8": { promptPerMillion: 5, candidatePerMillion: 25 },
|
|
1365
|
+
"claude-opus-4-7": { promptPerMillion: 5, candidatePerMillion: 25 },
|
|
1392
1366
|
// Sonnet 5 is $2 / $10 — its OWN tier, and CHEAPER than the older Sonnet 4.6 below.
|
|
1393
1367
|
//
|
|
1394
1368
|
// This launched as an introductory rate through 2026-08-31, and an earlier version of this
|
|
@@ -1397,32 +1371,22 @@ var ANTHROPIC_PRICING = {
|
|
|
1397
1371
|
// standard price and cancelled the scheduled increase, so that reasoning is dead and the old
|
|
1398
1372
|
// figure over-charged every Sonnet 5 request by 50%.
|
|
1399
1373
|
// https://platform.claude.com/docs/en/about-claude/pricing#model-pricing
|
|
1400
|
-
"claude-sonnet-5": {
|
|
1374
|
+
"claude-sonnet-5": { promptPerMillion: 2, candidatePerMillion: 10 },
|
|
1401
1375
|
// Sonnet 4.6 remains on the older $3 / $15 Sonnet tier — the newer model is the cheaper one.
|
|
1402
|
-
"claude-sonnet-4-6": {
|
|
1376
|
+
"claude-sonnet-4-6": { promptPerMillion: 3, candidatePerMillion: 15 }
|
|
1403
1377
|
};
|
|
1404
|
-
function anthropicRatesFor(model
|
|
1405
|
-
|
|
1406
|
-
if (pricing.kind === "flat") {
|
|
1407
|
-
return pricing.rate;
|
|
1408
|
-
}
|
|
1409
|
-
return promptTokens > ANTHROPIC_LONG_CONTEXT_THRESHOLD ? pricing.longContext : pricing.standard;
|
|
1378
|
+
function anthropicRatesFor(model) {
|
|
1379
|
+
return ANTHROPIC_PRICING[model];
|
|
1410
1380
|
}
|
|
1411
1381
|
var ANTHROPIC_CACHE_READ_MULTIPLIER = 0.1;
|
|
1412
|
-
function anthropicCacheReadMultiplierFor(model) {
|
|
1413
|
-
var _a;
|
|
1414
|
-
return (_a = ANTHROPIC_PRICING[model].cacheReadMultiplier) !== null && _a !== void 0 ? _a : ANTHROPIC_CACHE_READ_MULTIPLIER;
|
|
1415
|
-
}
|
|
1416
1382
|
var ANTHROPIC_CACHE_WRITE_5M_MULTIPLIER = 1.25;
|
|
1417
1383
|
var ANTHROPIC_CACHE_WRITE_1H_MULTIPLIER = 2;
|
|
1418
1384
|
function anthropicTokenCost(model, usage) {
|
|
1419
|
-
const
|
|
1420
|
-
const { promptPerMillion, candidatePerMillion } = anthropicRatesFor(model, promptTokens);
|
|
1421
|
-
const cacheReadMultiplier = anthropicCacheReadMultiplierFor(model);
|
|
1385
|
+
const { promptPerMillion, candidatePerMillion } = anthropicRatesFor(model);
|
|
1422
1386
|
const m = TOKENS_PER_MILLION;
|
|
1423
1387
|
const cacheWrite5mTokens = Math.max(0, usage.cacheWriteTokens - usage.cacheWrite1hTokens);
|
|
1424
1388
|
const promptCost = usage.uncachedInputTokens / m * promptPerMillion;
|
|
1425
|
-
const cacheReadCost = usage.cacheReadTokens / m * promptPerMillion *
|
|
1389
|
+
const cacheReadCost = usage.cacheReadTokens / m * promptPerMillion * ANTHROPIC_CACHE_READ_MULTIPLIER;
|
|
1426
1390
|
const cacheWriteCost = cacheWrite5mTokens / m * promptPerMillion * ANTHROPIC_CACHE_WRITE_5M_MULTIPLIER + usage.cacheWrite1hTokens / m * promptPerMillion * ANTHROPIC_CACHE_WRITE_1H_MULTIPLIER;
|
|
1427
1391
|
const candidateCost = usage.outputTokens / m * candidatePerMillion;
|
|
1428
1392
|
const cacheReadFull = usage.cacheReadTokens / m * promptPerMillion;
|
|
@@ -2430,60 +2394,38 @@ function toAnthropicToolChoice(choice) {
|
|
|
2430
2394
|
}
|
|
2431
2395
|
var ANTHROPIC_CONTEXT_LIMITS = {
|
|
2432
2396
|
"claude-fable-5": 1e6,
|
|
2433
|
-
"claude-opus-5-5": 1e6,
|
|
2434
2397
|
"claude-opus-4-8": 1e6,
|
|
2435
2398
|
"claude-opus-4-7": 1e6,
|
|
2436
|
-
"claude-sonnet-5-5": 1e6,
|
|
2437
2399
|
"claude-sonnet-5": 1e6,
|
|
2438
2400
|
"claude-sonnet-4-6": 1e6,
|
|
2439
|
-
"claude-haiku-5-5": 1e6,
|
|
2440
2401
|
"claude-haiku-4-5-20251001": 2e5
|
|
2441
2402
|
};
|
|
2442
2403
|
var STRUCTURED_OUTPUT_TOOL_NAME = "emit_structured_response";
|
|
2443
2404
|
var SERVER_SIDE_FALLBACK_BETA = "server-side-fallback-2026-06-01";
|
|
2444
|
-
var THINKING_BINDING_CONTROLS_BETA = "thinking-binding-controls-2026-08-01";
|
|
2445
2405
|
function assertSupportedAnthropicModel(model) {
|
|
2446
2406
|
if (!SUPPORTED_ANTHROPIC_MODEL_IDS.includes(model)) {
|
|
2447
2407
|
throw new Error(`AnthropicTransport: unsupported model "${model}". Use one of: ${SUPPORTED_ANTHROPIC_MODEL_IDS.join(", ")}.`);
|
|
2448
2408
|
}
|
|
2449
2409
|
}
|
|
2450
|
-
function isClaude55(model) {
|
|
2451
|
-
return model === "claude-opus-5-5" || model === "claude-sonnet-5-5" || model === "claude-haiku-5-5";
|
|
2452
|
-
}
|
|
2453
2410
|
function rejectsSamplingParams(model) {
|
|
2454
|
-
return model === "claude-fable-5" || model === "claude-opus-4-8" || model === "claude-opus-4-7" || model === "claude-sonnet-5"
|
|
2455
|
-
}
|
|
2456
|
-
function supportsForcedToolChoice(model) {
|
|
2457
|
-
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";
|
|
2458
2412
|
}
|
|
2459
2413
|
function supportsNativeStructuredOutput(model) {
|
|
2460
|
-
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";
|
|
2461
2415
|
}
|
|
2462
2416
|
function supportsAdaptiveThinking(model) {
|
|
2463
2417
|
return model !== "claude-haiku-4-5-20251001";
|
|
2464
2418
|
}
|
|
2465
2419
|
function thinkingIsMandatory(model) {
|
|
2466
|
-
return model === "claude-fable-5"
|
|
2467
|
-
}
|
|
2468
|
-
function defaultsToThinking(model) {
|
|
2469
|
-
return model === "claude-sonnet-5" || model === "claude-sonnet-5-5" || model === "claude-haiku-5-5" || thinkingIsMandatory(model);
|
|
2470
|
-
}
|
|
2471
|
-
function thinkingOff(model) {
|
|
2472
|
-
return model === "claude-sonnet-5-5" ? { type: "between_tools" } : { type: "disabled" };
|
|
2473
|
-
}
|
|
2474
|
-
var POLICY_EFFORT = {
|
|
2475
|
-
"claude-opus-5-5": { auto: "high", off: "low" }
|
|
2476
|
-
};
|
|
2477
|
-
function sendsBlockBinding(model) {
|
|
2478
|
-
return isClaude55(model);
|
|
2420
|
+
return model === "claude-fable-5";
|
|
2479
2421
|
}
|
|
2480
2422
|
function anthropicThinking(model, policy) {
|
|
2481
|
-
const
|
|
2423
|
+
const defaultsToThinking = model === "claude-sonnet-5" || thinkingIsMandatory(model);
|
|
2482
2424
|
const adaptive = { type: "adaptive", display: "summarized" };
|
|
2483
2425
|
if (policy === "off") {
|
|
2484
2426
|
if (thinkingIsMandatory(model))
|
|
2485
2427
|
return adaptive;
|
|
2486
|
-
return
|
|
2428
|
+
return defaultsToThinking ? { type: "disabled" } : void 0;
|
|
2487
2429
|
}
|
|
2488
2430
|
if (policy === "auto") {
|
|
2489
2431
|
return supportsAdaptiveThinking(model) ? adaptive : void 0;
|
|
@@ -2491,10 +2433,10 @@ function anthropicThinking(model, policy) {
|
|
|
2491
2433
|
if (policy !== void 0) {
|
|
2492
2434
|
return supportsAdaptiveThinking(model) ? adaptive : void 0;
|
|
2493
2435
|
}
|
|
2494
|
-
return
|
|
2436
|
+
return defaultsToThinking ? adaptive : void 0;
|
|
2495
2437
|
}
|
|
2496
2438
|
function supportsEffort(model) {
|
|
2497
|
-
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";
|
|
2498
2440
|
}
|
|
2499
2441
|
var ANTHROPIC_EFFORT = {
|
|
2500
2442
|
minimal: "low",
|
|
@@ -2504,11 +2446,8 @@ var ANTHROPIC_EFFORT = {
|
|
|
2504
2446
|
max: "max"
|
|
2505
2447
|
};
|
|
2506
2448
|
function anthropicEffort(model, policy) {
|
|
2507
|
-
|
|
2508
|
-
if (policy === void 0)
|
|
2449
|
+
if (policy === void 0 || policy === "auto" || policy === "off")
|
|
2509
2450
|
return void 0;
|
|
2510
|
-
if (policy === "auto" || policy === "off")
|
|
2511
|
-
return (_a = POLICY_EFFORT[model]) === null || _a === void 0 ? void 0 : _a[policy];
|
|
2512
2451
|
if (!supportsEffort(model) || !supportsAdaptiveThinking(model))
|
|
2513
2452
|
return void 0;
|
|
2514
2453
|
return ANTHROPIC_EFFORT[policy];
|
|
@@ -2552,14 +2491,11 @@ var AnthropicTransport = class _AnthropicTransport {
|
|
|
2552
2491
|
* outcome the type's own docs promise callers never happens.
|
|
2553
2492
|
*/
|
|
2554
2493
|
clampWarning(policy) {
|
|
2555
|
-
var _a, _b;
|
|
2556
2494
|
switch (policy) {
|
|
2557
2495
|
case void 0:
|
|
2558
2496
|
return void 0;
|
|
2559
2497
|
case "off":
|
|
2560
|
-
|
|
2561
|
-
return void 0;
|
|
2562
|
-
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;
|
|
2563
2499
|
case "auto":
|
|
2564
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.`;
|
|
2565
2501
|
case "minimal":
|
|
@@ -2568,7 +2504,7 @@ var AnthropicTransport = class _AnthropicTransport {
|
|
|
2568
2504
|
case "high":
|
|
2569
2505
|
case "max":
|
|
2570
2506
|
if (!supportsAdaptiveThinking(this.model) || !supportsEffort(this.model)) {
|
|
2571
|
-
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.`;
|
|
2572
2508
|
}
|
|
2573
2509
|
return void 0;
|
|
2574
2510
|
default: {
|
|
@@ -2578,11 +2514,10 @@ var AnthropicTransport = class _AnthropicTransport {
|
|
|
2578
2514
|
}
|
|
2579
2515
|
}
|
|
2580
2516
|
constructor(config = {}) {
|
|
2581
|
-
var _a, _b, _c, _d
|
|
2517
|
+
var _a, _b, _c, _d;
|
|
2582
2518
|
this.lifetimeCostUsd = 0;
|
|
2583
2519
|
this.lifetimeSavingsUsd = 0;
|
|
2584
2520
|
this.warnedThinkingClamped = false;
|
|
2585
|
-
this.warnedToolChoiceDowngraded = false;
|
|
2586
2521
|
this.warnedUnknownServingModels = /* @__PURE__ */ new Set();
|
|
2587
2522
|
const model = (_a = config.model) !== null && _a !== void 0 ? _a : DEFAULT_MODEL;
|
|
2588
2523
|
assertSupportedAnthropicModel(model);
|
|
@@ -2593,10 +2528,6 @@ var AnthropicTransport = class _AnthropicTransport {
|
|
|
2593
2528
|
logger.warn("AnthropicTransport: using claude-sonnet-4-6 \u2014 higher cost than Haiku; use for stronger reasoning or agent tasks.");
|
|
2594
2529
|
} else if (model === "claude-opus-4-7" || model === "claude-opus-4-8") {
|
|
2595
2530
|
logger.warn(`AnthropicTransport: using ${model} \u2014 significantly higher cost; reserve for tasks where Sonnet reliability is insufficient.`);
|
|
2596
|
-
} else if (model === "claude-opus-5-5") {
|
|
2597
|
-
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.");
|
|
2598
|
-
} else if (model === "claude-sonnet-5-5") {
|
|
2599
|
-
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.");
|
|
2600
2531
|
} else if (model === "claude-fable-5") {
|
|
2601
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.`);
|
|
2602
2533
|
}
|
|
@@ -2605,7 +2536,6 @@ var AnthropicTransport = class _AnthropicTransport {
|
|
|
2605
2536
|
this.apiKey = config.apiKey;
|
|
2606
2537
|
this.serverEndpoint = config.serverEndpoint;
|
|
2607
2538
|
this.maxTokens = (_d = config.maxTokens) !== null && _d !== void 0 ? _d : DEFAULT_MAX_TOKENS;
|
|
2608
|
-
this.thinkingBlockBinding = (_e = config.thinkingBlockBinding) !== null && _e !== void 0 ? _e : "drop_block";
|
|
2609
2539
|
}
|
|
2610
2540
|
getConfig() {
|
|
2611
2541
|
return {
|
|
@@ -2645,9 +2575,6 @@ var AnthropicTransport = class _AnthropicTransport {
|
|
|
2645
2575
|
if (useNative) {
|
|
2646
2576
|
body.output_config = Object.assign(Object.assign({}, body.output_config), { format: { type: "json_schema", schema: responseSchema } });
|
|
2647
2577
|
} else if (useForcedTool) {
|
|
2648
|
-
if (!supportsForcedToolChoice(this.model)) {
|
|
2649
|
-
throw new Error(`AnthropicTransport: ${this.model} rejects forced tool_choice and must be listed in supportsNativeStructuredOutput.`);
|
|
2650
|
-
}
|
|
2651
2578
|
body.tools = [
|
|
2652
2579
|
{
|
|
2653
2580
|
name: STRUCTURED_OUTPUT_TOOL_NAME,
|
|
@@ -2657,9 +2584,8 @@ var AnthropicTransport = class _AnthropicTransport {
|
|
|
2657
2584
|
];
|
|
2658
2585
|
body.tool_choice = { type: "tool", name: STRUCTURED_OUTPUT_TOOL_NAME };
|
|
2659
2586
|
}
|
|
2660
|
-
if (
|
|
2661
|
-
body.thinking =
|
|
2662
|
-
}
|
|
2587
|
+
if (this.model === "claude-sonnet-5")
|
|
2588
|
+
body.thinking = { type: "disabled" };
|
|
2663
2589
|
const response = yield this.post(body);
|
|
2664
2590
|
if (useForcedTool) {
|
|
2665
2591
|
const toolUse = ((_a = response.content) !== null && _a !== void 0 ? _a : []).find((b) => b.type === "tool_use" && b.name === STRUCTURED_OUTPUT_TOOL_NAME);
|
|
@@ -2671,7 +2597,7 @@ var AnthropicTransport = class _AnthropicTransport {
|
|
|
2671
2597
|
// ── ChatTransport (multi-turn chat) ────────────────────────────────────
|
|
2672
2598
|
sendChatMessage(history, userMessage, options) {
|
|
2673
2599
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2674
|
-
var _a, _b, _c, _d, _e
|
|
2600
|
+
var _a, _b, _c, _d, _e;
|
|
2675
2601
|
const reachableModels = /* @__PURE__ */ new Set([
|
|
2676
2602
|
this.model,
|
|
2677
2603
|
...((_a = options === null || options === void 0 ? void 0 : options.fallbacks) !== null && _a !== void 0 ? _a : []).map((f) => f.model)
|
|
@@ -2688,11 +2614,15 @@ var AnthropicTransport = class _AnthropicTransport {
|
|
|
2688
2614
|
if ((_c = options === null || options === void 0 ? void 0 : options.tools) === null || _c === void 0 ? void 0 : _c.length) {
|
|
2689
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 } : {}));
|
|
2690
2616
|
}
|
|
2691
|
-
|
|
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
|
+
}
|
|
2692
2622
|
this.warnIfThinkingUnclampable(options === null || options === void 0 ? void 0 : options.thinkingPolicy);
|
|
2693
2623
|
const thinking = anthropicThinking(this.model, options === null || options === void 0 ? void 0 : options.thinkingPolicy);
|
|
2694
2624
|
if (thinking)
|
|
2695
|
-
body.thinking =
|
|
2625
|
+
body.thinking = thinking;
|
|
2696
2626
|
const effort = anthropicEffort(this.model, options === null || options === void 0 ? void 0 : options.thinkingPolicy);
|
|
2697
2627
|
if (effort)
|
|
2698
2628
|
body.output_config = Object.assign(Object.assign({}, body.output_config), { effort });
|
|
@@ -2706,83 +2636,19 @@ var AnthropicTransport = class _AnthropicTransport {
|
|
|
2706
2636
|
if ((options === null || options === void 0 ? void 0 : options.responseSchema) && supportsNativeStructuredOutput(this.model)) {
|
|
2707
2637
|
body.output_config = Object.assign(Object.assign({}, body.output_config), { format: { type: "json_schema", schema: options.responseSchema } });
|
|
2708
2638
|
}
|
|
2709
|
-
if ((
|
|
2639
|
+
if ((_e = options === null || options === void 0 ? void 0 : options.fallbacks) === null || _e === void 0 ? void 0 : _e.length) {
|
|
2710
2640
|
body.fallbacks = options.fallbacks.map((f) => f.maxTokens != null ? { model: f.model, max_tokens: f.maxTokens } : { model: f.model });
|
|
2711
2641
|
}
|
|
2712
2642
|
if (options === null || options === void 0 ? void 0 : options.cachePolicy) {
|
|
2713
2643
|
this.applyCacheControl(body, options.cachePolicy);
|
|
2714
2644
|
}
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
this.appendTailContext(body, tail);
|
|
2645
|
+
if (options === null || options === void 0 ? void 0 : options.tailContext) {
|
|
2646
|
+
this.appendTailContext(body, options.tailContext);
|
|
2718
2647
|
}
|
|
2719
2648
|
const response = yield this.post(body, options === null || options === void 0 ? void 0 : options.signal);
|
|
2720
|
-
|
|
2721
|
-
if (forcedToolNote && message.responseMeta) {
|
|
2722
|
-
message.responseMeta.toolChoiceDowngraded = true;
|
|
2723
|
-
}
|
|
2724
|
-
return message;
|
|
2649
|
+
return this.fromAnthropicResponse(response, body.max_tokens);
|
|
2725
2650
|
});
|
|
2726
2651
|
}
|
|
2727
|
-
/**
|
|
2728
|
-
* Set `tool_choice` from the caller's {@link ChatToolChoice}. `'required'`/`{ tool }` force a
|
|
2729
|
-
* tool call so a turn can only end via one (e.g. a sub-agent's completion tool); on a model that
|
|
2730
|
-
* rejects forcing they are downgraded (see `downgradeForcedToolChoice`), and the instruction
|
|
2731
|
-
* that replaces them is returned for the tail.
|
|
2732
|
-
*/
|
|
2733
|
-
applyToolChoice(body, choice, tools) {
|
|
2734
|
-
const toolChoice = toAnthropicToolChoice(choice);
|
|
2735
|
-
if (!toolChoice)
|
|
2736
|
-
return void 0;
|
|
2737
|
-
const forced = toolChoice.type === "any" || toolChoice.type === "tool";
|
|
2738
|
-
if (forced && !supportsForcedToolChoice(this.model)) {
|
|
2739
|
-
return this.downgradeForcedToolChoice(body, toolChoice, tools);
|
|
2740
|
-
}
|
|
2741
|
-
body.tool_choice = toolChoice;
|
|
2742
|
-
return void 0;
|
|
2743
|
-
}
|
|
2744
|
-
/**
|
|
2745
|
-
* Preserved thinking (5.5 family): say what a changed history does to replayed thinking, rather
|
|
2746
|
-
* than inheriting the account default (a 400 on accounts created on or after 2026-08-31).
|
|
2747
|
-
* Adaptive only — `between_tools` and `disabled` reject the field — and a fresh object, so the
|
|
2748
|
-
* shared `adaptive` constant in `anthropicThinking` is never mutated.
|
|
2749
|
-
*/
|
|
2750
|
-
withBlockBinding(thinking) {
|
|
2751
|
-
if (thinking.type !== "adaptive" || !sendsBlockBinding(this.model) || this.thinkingBlockBinding === "omit") {
|
|
2752
|
-
return thinking;
|
|
2753
|
-
}
|
|
2754
|
-
return Object.assign(Object.assign({}, thinking), { block_binding: { prefix_mismatch_behavior: this.thinkingBlockBinding } });
|
|
2755
|
-
}
|
|
2756
|
-
/**
|
|
2757
|
-
* Stand-in for a forced tool call on a model that rejects `tool_choice` `any`/`tool` with a 400
|
|
2758
|
-
* (Opus 5.5, Sonnet 5.5). The request goes out with `tool_choice` omitted (`auto`), and:
|
|
2759
|
-
*
|
|
2760
|
-
* - for a NAMED tool, that tool's schema is enforced (`strict: true`), so a call that does
|
|
2761
|
-
* happen has valid arguments — the half of forcing that `auto` can still guarantee. Not done
|
|
2762
|
-
* for `'required'`: enforcing every tool in a large surface can exceed the provider's
|
|
2763
|
-
* per-request compilation limits, and a tool the caller enforced already carries it;
|
|
2764
|
-
* - an instruction naming the tool is returned for the caller to append to the tail.
|
|
2765
|
-
*
|
|
2766
|
-
* `auto` lets the model answer in text instead, so the caller is told: a one-time warning here,
|
|
2767
|
-
* and `responseMeta.toolChoiceDowngraded` on every affected response, which a driver uses to
|
|
2768
|
-
* nudge and retry once when no tool was called.
|
|
2769
|
-
*/
|
|
2770
|
-
downgradeForcedToolChoice(body, toolChoice, tools) {
|
|
2771
|
-
var _a, _b;
|
|
2772
|
-
if (!this.warnedToolChoiceDowngraded) {
|
|
2773
|
-
this.warnedToolChoiceDowngraded = true;
|
|
2774
|
-
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.`);
|
|
2775
|
-
}
|
|
2776
|
-
if (toolChoice.type === "tool" && toolChoice.name) {
|
|
2777
|
-
const index = (_b = (_a = body.tools) === null || _a === void 0 ? void 0 : _a.findIndex((t) => t.name === toolChoice.name)) !== null && _b !== void 0 ? _b : -1;
|
|
2778
|
-
const source = tools.find((t) => t.name === toolChoice.name);
|
|
2779
|
-
if (index >= 0 && source && body.tools && !body.tools[index].strict) {
|
|
2780
|
-
body.tools[index] = Object.assign(Object.assign({}, body.tools[index]), { input_schema: enforceAnthropicToolSchema(source.parameters, source.name), strict: true });
|
|
2781
|
-
}
|
|
2782
|
-
return `<system-reminder>Respond to this turn by calling the \`${toolChoice.name}\` tool. Do not reply with text alone.</system-reminder>`;
|
|
2783
|
-
}
|
|
2784
|
-
return "<system-reminder>Respond to this turn by calling one of your tools. Do not reply with text alone.</system-reminder>";
|
|
2785
|
-
}
|
|
2786
2652
|
/**
|
|
2787
2653
|
* Place prompt-cache breakpoints on the outgoing request per the resolved {@link CachePolicy}.
|
|
2788
2654
|
* A breakpoint is `cache_control: {type:'ephemeral'}` on a content block / tool / system block;
|
|
@@ -3082,7 +2948,7 @@ ${att.content}` });
|
|
|
3082
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);
|
|
3083
2949
|
}
|
|
3084
2950
|
fromAnthropicResponse(response, effectiveMaxTokens = this.maxTokens) {
|
|
3085
|
-
var _a, _b, _c, _d, _e, _f, _g
|
|
2951
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
3086
2952
|
let inputTokens;
|
|
3087
2953
|
let outputTokens;
|
|
3088
2954
|
let cacheReadTokens;
|
|
@@ -3182,16 +3048,6 @@ ${att.content}` });
|
|
|
3182
3048
|
};
|
|
3183
3049
|
if (response.stop_reason)
|
|
3184
3050
|
responseMeta.finishReason = response.stop_reason;
|
|
3185
|
-
if ((_h = response.input_transformations) === null || _h === void 0 ? void 0 : _h.length) {
|
|
3186
|
-
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 } : {}));
|
|
3187
|
-
const dropped = response.input_transformations.filter((t) => t.type === "thinking_dropped");
|
|
3188
|
-
if (dropped.length) {
|
|
3189
|
-
logger.debug(`AnthropicTransport: ${dropped.length} thinking block(s) dropped by ${(_j = response.model) !== null && _j !== void 0 ? _j : this.model}: ${dropped.map((t) => {
|
|
3190
|
-
var _a2, _b2;
|
|
3191
|
-
return `${(_a2 = t.path) !== null && _a2 !== void 0 ? _a2 : "?"} (${(_b2 = t.reason) !== null && _b2 !== void 0 ? _b2 : "unknown"})`;
|
|
3192
|
-
}).join(", ")}`);
|
|
3193
|
-
}
|
|
3194
|
-
}
|
|
3195
3051
|
base.responseMeta = responseMeta;
|
|
3196
3052
|
return base;
|
|
3197
3053
|
}
|
|
@@ -3223,13 +3079,9 @@ ${att.content}` });
|
|
|
3223
3079
|
}
|
|
3224
3080
|
post(body, signal) {
|
|
3225
3081
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3226
|
-
var _a
|
|
3082
|
+
var _a;
|
|
3227
3083
|
const { url, headers, credentials } = this.buildEndpoint();
|
|
3228
|
-
const
|
|
3229
|
-
((_a = body.fallbacks) === null || _a === void 0 ? void 0 : _a.length) ? SERVER_SIDE_FALLBACK_BETA : void 0,
|
|
3230
|
-
((_b = body.thinking) === null || _b === void 0 ? void 0 : _b.type) === "adaptive" && body.thinking.block_binding ? THINKING_BINDING_CONTROLS_BETA : void 0
|
|
3231
|
-
].filter((b) => Boolean(b));
|
|
3232
|
-
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;
|
|
3233
3085
|
return yield postWithRetry({
|
|
3234
3086
|
url,
|
|
3235
3087
|
headers: requestHeaders,
|
|
@@ -5206,7 +5058,7 @@ var DEBUG_LOG_README = [
|
|
|
5206
5058
|
"kind:'turn'.`agentSnapshot` \u2014 the active agent's own view of its internal state, captured at that turn. An agent opts into this by exposing a `getDebugSnapshot()` that returns JSON-serializable per-state info; stateful/flow agents wire it automatically, so you can watch a flow advance turn-by-turn (e.g. current step, cursor, collected fields, pending changes). Absent for agents that don't expose one.",
|
|
5207
5059
|
"kind:'event' \u2014 a meta/lifecycle event. `type` names it (see below); `detail` carries structured data. `detail.placement` is the emitting UI instance: 'bubble' (collapsed), 'panel' (popped-out), or 'standalone'.",
|
|
5208
5060
|
"Each 'event' also has an `importance`: 'high' (failures/limits \u2014 turn.error, tool.failed, subagent.failed, file.read-failed, suggestions.failed, context.threshold-crossed), 'normal' (session flow \u2014 connects, turns, retries, handoffs, agent/provider changes, interactions, sub-agent start/complete), or 'low' (skippable UI/bookkeeping noise \u2014 panel.toggled, attachment.added, driver.wired/unwired, context.updated, context.condensed). To skim, ignore importance:'low'; to triage a failure, filter to importance:'high' then read the nearby messages and turns. A 'high' turn.error is often preceded by one or more 'normal' turn.retry events for the same reason \u2014 read them together to see how many attempts were made before bailing. 'message' and 'turn' entries carry no importance \u2014 they are the substance, always read them.",
|
|
5209
|
-
"Event types: assistant.connected/disconnected (mount + placement + whether the session was created or restored), assistant.popout/popin (window placement), driver.created/wired/unwired (which driver is live and why it stops/starts responding across a popout), state.changed (idle\u2194loading), turn.start/turn.end (turn boundary; turn.end carries durationMs), turn.retry (a recoverable in-turn retry \u2014 detail.reason plus attempt/maxAttempts; for malformed calls also finishMessage; for empty responses also the provider finishReason + thoughtsTokens + parts breakdown; reason no-tool-call is a sub-agent on a model that rejects forced tool use (Opus 5.5 / Sonnet 5.5) answering its forced turn in text, retried once with a nudge), turn.error (a turn failed or hit a guardrail \u2014 detail.reason is one of exception/malformed-function-call/empty-response/unknown-tool-limit/max-iterations/response-truncated/refusal/budget-exhausted/provider-refused/context-exhausted/ai-service-error, plus reason-specific diagnostics: attempts (for empty-response also finishReason + thoughtsTokens + a parts breakdown, distinguishing a thinking-only STOP from a truly empty turn), finishMessage, for response-truncated the model + maxTokens + outputTokens + tools, unknownTools (split into staleTools \u2014 real earlier this activation but retired by the current state or hidden behind an open exclusive fold \u2014 and hallucinatedTools \u2014 never advertised) + availableTools, iterations + limit, for budget-exhausted the budgetUsd + spentUsd figures reported by the proxy plus the resolved vendor, for provider-refused the kind (spend|auth) plus the upstream status and error type \u2014 the vendor refusing the ACCOUNT rather than us refusing to spend, so the remedy is a top-up or a key rotation rather than a raised cap, and the kind is the only place that distinction survives because the user-facing copy is deliberately cause-free, for context-exhausted the estimated contextTokens against the guard that stopped the turn plus the iterations reached \u2014 the driver ending a runaway tool loop at the edge of the context window rather than issuing a request the provider would reject, so the transcript survives intact and can still be compacted, for ai-service-error the code (one of AI_SERVICE_ERROR_CODES, e.g. NO_API_KEY) and the status the AI service answered with \u2014 its own text goes to the browser console only, or name + message for exceptions), tool.failed (a tool threw), tool.unresolved (the model called a tool that could not be dispatched \u2014 detail.kind is folded/fold-hidden/stale/unknown, plus tool + agent and, for the counted kinds, the consecutive streak; the recurring lead-up to an unknown-tool-limit turn.error), subagent.started/completed/failed (the lifecycle of a `requestSubAgent` delegation \u2014 detail.agent names the sub-agent; these bracket the sub-agent turns that appear as kind:turn entries with an N-M `turnIndex`; subagent.failed also carries detail.reason, one of max_iterations/malformed_tool_call/empty_response/unknown_tool_limit/timeout/response_truncated/refusal/budget_exhausted/provider_refused/context_exhausted/ai_service_error; budget_exhausted and provider_refused are terminal for the PARENT turn too, and so is ai_service_error when the refusal is about the service rather than the request and came from the vendor the parent calls \u2014 the parent stops rather than calling the model again into the same wall; after context_exhausted the parent goes on, but its own next call is likely to stop on the same guard), agent.handoff (routing; from=null is the initial activation), agent.pinned/unpinned (forced routing), routing.decided (ONE PER ROUTING DECISION \u2014 see its own paragraph below), provider.selected (the resolved provider for the upcoming turns \u2014 detail.provider is the registry SLOT/tier name, detail.model the concrete model behind it and detail.vendor its vendor; emitted only when the slot CHANGES, so read the per-turn `model` for the model of any given call rather than assuming the nearest event still applies), interaction.requested/resolved (blocking user widgets \u2014 explain quiet gaps; note that when a sub-agent opens a widget, detail.agent \u2014 and the agentName on the interaction message \u2014 is the HOST agent that owns the widget, NOT the sub-agent that asked, because widgets render and resolve on the host driver; detail.ownerPath names the agents that actually asked, outermost first, the last being the one whose tool requested it, and detail.heldBy says who held it when it opened: user, or the id of the interceptor that claimed it, such as autopilot; on interaction.resolved, detail.answeredBy is who answered \u2014 the claimant id when it settled through its own hold, user for any other answer (a click counts as the person even on a widget a claimant held) \u2014 absent when it closed unanswered (a timeout or a stop), and absent too when it settled by itself other than through the hold of a claimant \u2014 a widget registered resolvesItself (one that does its work and settles on its own, asking the person nothing, such as a generation run), or one outcome its controller said settled itself (ctx.resolve with resolvedItself, such as a generation phase that failed outright before its review gate ever asked anything) \u2014 which then carries detail.resolvedItself: true instead, as the interaction message does \u2014 nobody answered it, and the platform cannot tell it finishing from the person interrupting it (a Skip), so only the result of the widget itself can say which; the same value is stamped on the interaction message as answeredBy and on the result the asking tool handler receives (absent there in the same cases), and when it is not user the tool result that interaction returned carries a decidedOnUsersBehalf record, so the model was told the choice was not made by the person; detail.edits, present only when non-zero, counts the editing actions a claimant ran on the widget before it was settled, whoever settled it, and those edits are stamped on the interaction message as edits, each with by, action, choice and args when it had some, in the order they ran, while a decidedOnUsersBehalf record carries their choice texts as edits, and when the person settled it after such edits the tool result carries an editedOnUsersBehalf record instead \u2014 the framing and those choice texts \u2014 so the model knows the widget was changed on the user behalf before the user answered, and that the user then confirmed it by finishing it), interaction.held (a claimant moved a pending interaction to the person or back to itself \u2014 detail.heldBy is the new holder, detail.claimant the interceptor; detail.late: true is an interceptor that declined it when it opened claiming it afterwards, such as the autopilot resumed while it was open; a widget held by anything but user was not answered by the person), interaction.claim-refused (a claim on a userOnly interaction, which stays with the person \u2014 detail.claimant + reason), autopilot.* (the autopilot, a decorator that answers interactions on behalf of the user \u2014 autopilot.claimed / autopilot.declined say whether it took each interaction and, for a decline, detail.reason: paused, other-flow, no-autopilot, unavailable, userOnly, policy or no-controller; one declined as paused that is still open when the person resumes the autopilot is looked at again, and the autopilot.claimed or autopilot.declined recorded for it then carries detail.onResume: true (a decline then can also be claimed-elsewhere, another interceptor having claimed it first); a restored mode looks at nothing; autopilot.decision-sent is what it was sent (detail.chars; detail.nothingEnabled: true when every action on the widget was unavailable \u2014 a gate whose controller said it was asking, such as a failed build the autopilot may not cancel \u2014 so it could only hand it back, which it may then do even after the person asked it to decide it itself; a widget whose controller says it is working (ctx.setWorking) is never sent a decision until it says it is asking, even when an action is enabled or the person resumes the autopilot); autopilot.acted is what it did (detail.action, detail.note, detail.finished); autopilot.handed-back is a decision it gave to the person (detail.reason and detail.trigger: model, no-decision or error); autopilot.paused / autopilot.resumed are mode changes (detail.scope, detail.trigger, detail.decideYourself when the person resumed during a hand-back; detail.trigger is restored when the mode came back with the session after a reload, applied once its flow re-activated, which starts nothing by itself); autopilot.carried is the mode, running or paused, going with the task to the agent that took it over, rather than ending with the flow as on any other change of flow owner: to the target of a hand-off, or back to its caller on the hand-back (detail.from, detail.to, detail.mode); a pause the person chose goes with it, and Stop and Clear still end it; a mode restored for the target of a hand-off applies to its caller when the reload hands back; autopilot.error is the wrapper itself failing; autopilot.refinement counts a refining action against its step \u2014 a written answer (reply) or a widget action declared refines, such as a regenerate with instructions, counted together (detail.action, detail.stepKey, detail.count, detail.limitReached, after which every refining action is withdrawn for that step: not listed, and refused; the decision and every relisting of its actions say how many are left at the step, as a line Refinements left at this step: N, wherever the widget has a refining action); autopilot.handback-presented is the turn-level hand-back, shown when a working turn ended needing the person with no widget to hand over (detail.why: max-iterations, context-exhausted, failure or question; detail.options; detail.choice once answered); autopilot.catch-up is the autopilot being given the whole visible transcript at once (detail.why: first, for its first decision in a flow or after a reload; size, when its own history passed its budget and was rebuilt short \u2014 detail.ownChars; or compacted, when a compaction removed the last message it had seen, so it reads the summary and everything since, short; in each, what it had sent on the user behalf is included and labelled as its own, since its own history does not hold it); autopilot.cost-dropped is autopilot spend that no message carries, so it is NOT in the session total (detail.costUsd and detail.why: handed-back, aborted or stale for a written question it answered that no reply was sent for \u2014 stale when a pause, a resume, a new turn or the end of its flow came before the answer landed, which then went nowhere \u2014 or no-recorder when the driver had no way to book a decision to its interaction); a hand-back trigger can also be budget (the decision passed its spend cap), watchdog (its work went quiet: no ready surface and no heartbeat, or its own decision stalled with no model call landing, which stops that decision) or detached (the autopilot was removed while it held the interaction, which went to the person with no reason shown). To debug one autopilot decision, follow its interactionId: interaction.requested (heldBy), autopilot.claimed, autopilot.decision-sent, autopilot.acted or autopilot.handed-back, interaction.invoked, interaction.resolved (answeredBy), then the next turn of the working agent), interaction.invoked (a claimant ran one of the actions the widget itself exposes, through its hold, the same code the button runs \u2014 detail.claimant, detail.action (an option id, select or reply) and detail.finished, whether that settled the interaction, and when it did not, the run is recorded as an edit; the choice and narration it recorded reach the result of the tool that asked as decidedOnUsersBehalf; the person's own programmatic action, from a host with no DOM to click, carries detail.by: user in place of detail.claimant, and is not recorded as an edit nor as a decision on their behalf, so what it settles is answered by user), interaction.step (a long action run as named steps through runSteps, which survive a reload \u2014 detail.step and detail.outcome: started, done, skipped when the step was already done before a reload, or resumed when it started before a reload and runs again with what it saved part-way, such as a job id it re-attaches to), interaction.checkpoint (the checkpoints a conversation keeps for its long actions: the one in flight, and each one a reload cut, held apart until a request of its own widget type takes it over, so a resumed flow that opens other long widgets first, which save their own, loses nothing \u2014 detail.action: resumed when a reload cut the work and a request of the same widget type that the registration sameWork agrees is the same work took it over, refused when sameWork said a new request is different work (detail.saved is the identity it kept; detail.kept: true, since it stays for a later request of that type, and is offered to every one until one agrees) or when runSteps found the handed-over checkpoint malformed and started fresh (detail.reason, detail.saved), or cleared when its flow ended, once per checkpoint, with detail.cut: true for one a reload cut that nothing took over), context.updated/threshold-crossed (token + cost), headless.attached (a HeadlessSession attached, for a host that drives the assistant with no screen \u2014 detail.label, what the host called itself, when it gave one) and headless.raw-resolved (that host settled an interaction raw, bypassing the widget's own actions: detail.interactionId and detail.component; the result went to the tool as given, so check what the widget would have enforced), context.condensed (a stale tool payload was collapsed out of the model-bound history by a `condenseWhen` declaration on the tool \u2014 detail.tool + toolCallId, target args|response, trigger (superseded:<key> or age:<n>), stubLen, and an estimated tokensSaved; stored history and this log keep the FULL payload, so the model-visible slice at any point is the full history minus the condensations recorded up to then), panel.toggled, attachment.added, file.read-failed, suggestions.failed.",
|
|
5061
|
+
"Event types: assistant.connected/disconnected (mount + placement + whether the session was created or restored), assistant.popout/popin (window placement), driver.created/wired/unwired (which driver is live and why it stops/starts responding across a popout), state.changed (idle\u2194loading), turn.start/turn.end (turn boundary; turn.end carries durationMs), turn.retry (a recoverable in-turn retry \u2014 detail.reason plus attempt/maxAttempts; for malformed calls also finishMessage; for empty responses also the provider finishReason + thoughtsTokens + parts breakdown), turn.error (a turn failed or hit a guardrail \u2014 detail.reason is one of exception/malformed-function-call/empty-response/unknown-tool-limit/max-iterations/response-truncated/refusal/budget-exhausted/provider-refused/context-exhausted/ai-service-error, plus reason-specific diagnostics: attempts (for empty-response also finishReason + thoughtsTokens + a parts breakdown, distinguishing a thinking-only STOP from a truly empty turn), finishMessage, for response-truncated the model + maxTokens + outputTokens + tools, unknownTools (split into staleTools \u2014 real earlier this activation but retired by the current state or hidden behind an open exclusive fold \u2014 and hallucinatedTools \u2014 never advertised) + availableTools, iterations + limit, for budget-exhausted the budgetUsd + spentUsd figures reported by the proxy plus the resolved vendor, for provider-refused the kind (spend|auth) plus the upstream status and error type \u2014 the vendor refusing the ACCOUNT rather than us refusing to spend, so the remedy is a top-up or a key rotation rather than a raised cap, and the kind is the only place that distinction survives because the user-facing copy is deliberately cause-free, for context-exhausted the estimated contextTokens against the guard that stopped the turn plus the iterations reached \u2014 the driver ending a runaway tool loop at the edge of the context window rather than issuing a request the provider would reject, so the transcript survives intact and can still be compacted, for ai-service-error the code (one of AI_SERVICE_ERROR_CODES, e.g. NO_API_KEY) and the status the AI service answered with \u2014 its own text goes to the browser console only, or name + message for exceptions), tool.failed (a tool threw), tool.unresolved (the model called a tool that could not be dispatched \u2014 detail.kind is folded/fold-hidden/stale/unknown, plus tool + agent and, for the counted kinds, the consecutive streak; the recurring lead-up to an unknown-tool-limit turn.error), subagent.started/completed/failed (the lifecycle of a `requestSubAgent` delegation \u2014 detail.agent names the sub-agent; these bracket the sub-agent turns that appear as kind:turn entries with an N-M `turnIndex`; subagent.failed also carries detail.reason, one of max_iterations/malformed_tool_call/empty_response/unknown_tool_limit/timeout/response_truncated/refusal/budget_exhausted/provider_refused/context_exhausted/ai_service_error; budget_exhausted and provider_refused are terminal for the PARENT turn too, and so is ai_service_error when the refusal is about the service rather than the request and came from the vendor the parent calls \u2014 the parent stops rather than calling the model again into the same wall; after context_exhausted the parent goes on, but its own next call is likely to stop on the same guard), agent.handoff (routing; from=null is the initial activation), agent.pinned/unpinned (forced routing), routing.decided (ONE PER ROUTING DECISION \u2014 see its own paragraph below), provider.selected (the resolved provider for the upcoming turns \u2014 detail.provider is the registry SLOT/tier name, detail.model the concrete model behind it and detail.vendor its vendor; emitted only when the slot CHANGES, so read the per-turn `model` for the model of any given call rather than assuming the nearest event still applies), interaction.requested/resolved (blocking user widgets \u2014 explain quiet gaps; note that when a sub-agent opens a widget, detail.agent \u2014 and the agentName on the interaction message \u2014 is the HOST agent that owns the widget, NOT the sub-agent that asked, because widgets render and resolve on the host driver; detail.ownerPath names the agents that actually asked, outermost first, the last being the one whose tool requested it, and detail.heldBy says who held it when it opened: user, or the id of the interceptor that claimed it, such as autopilot; on interaction.resolved, detail.answeredBy is who answered \u2014 the claimant id when it settled through its own hold, user for any other answer (a click counts as the person even on a widget a claimant held) \u2014 absent when it closed unanswered (a timeout or a stop), and absent too when it settled by itself other than through the hold of a claimant \u2014 a widget registered resolvesItself (one that does its work and settles on its own, asking the person nothing, such as a generation run), or one outcome its controller said settled itself (ctx.resolve with resolvedItself, such as a generation phase that failed outright before its review gate ever asked anything) \u2014 which then carries detail.resolvedItself: true instead, as the interaction message does \u2014 nobody answered it, and the platform cannot tell it finishing from the person interrupting it (a Skip), so only the result of the widget itself can say which; the same value is stamped on the interaction message as answeredBy and on the result the asking tool handler receives (absent there in the same cases), and when it is not user the tool result that interaction returned carries a decidedOnUsersBehalf record, so the model was told the choice was not made by the person; detail.edits, present only when non-zero, counts the editing actions a claimant ran on the widget before it was settled, whoever settled it, and those edits are stamped on the interaction message as edits, each with by, action, choice and args when it had some, in the order they ran, while a decidedOnUsersBehalf record carries their choice texts as edits, and when the person settled it after such edits the tool result carries an editedOnUsersBehalf record instead \u2014 the framing and those choice texts \u2014 so the model knows the widget was changed on the user behalf before the user answered, and that the user then confirmed it by finishing it), interaction.held (a claimant moved a pending interaction to the person or back to itself \u2014 detail.heldBy is the new holder, detail.claimant the interceptor; detail.late: true is an interceptor that declined it when it opened claiming it afterwards, such as the autopilot resumed while it was open; a widget held by anything but user was not answered by the person), interaction.claim-refused (a claim on a userOnly interaction, which stays with the person \u2014 detail.claimant + reason), autopilot.* (the autopilot, a decorator that answers interactions on behalf of the user \u2014 autopilot.claimed / autopilot.declined say whether it took each interaction and, for a decline, detail.reason: paused, other-flow, no-autopilot, unavailable, userOnly, policy or no-controller; one declined as paused that is still open when the person resumes the autopilot is looked at again, and the autopilot.claimed or autopilot.declined recorded for it then carries detail.onResume: true (a decline then can also be claimed-elsewhere, another interceptor having claimed it first); a restored mode looks at nothing; autopilot.decision-sent is what it was sent (detail.chars; detail.nothingEnabled: true when every action on the widget was unavailable \u2014 a gate whose controller said it was asking, such as a failed build the autopilot may not cancel \u2014 so it could only hand it back, which it may then do even after the person asked it to decide it itself; a widget whose controller says it is working (ctx.setWorking) is never sent a decision until it says it is asking, even when an action is enabled or the person resumes the autopilot); autopilot.acted is what it did (detail.action, detail.note, detail.finished); autopilot.handed-back is a decision it gave to the person (detail.reason and detail.trigger: model, no-decision or error); autopilot.paused / autopilot.resumed are mode changes (detail.scope, detail.trigger, detail.decideYourself when the person resumed during a hand-back; detail.trigger is restored when the mode came back with the session after a reload, applied once its flow re-activated, which starts nothing by itself); autopilot.carried is the mode, running or paused, going with the task to the agent that took it over, rather than ending with the flow as on any other change of flow owner: to the target of a hand-off, or back to its caller on the hand-back (detail.from, detail.to, detail.mode); a pause the person chose goes with it, and Stop and Clear still end it; a mode restored for the target of a hand-off applies to its caller when the reload hands back; autopilot.error is the wrapper itself failing; autopilot.refinement counts a refining action against its step \u2014 a written answer (reply) or a widget action declared refines, such as a regenerate with instructions, counted together (detail.action, detail.stepKey, detail.count, detail.limitReached, after which every refining action is withdrawn for that step: not listed, and refused; the decision and every relisting of its actions say how many are left at the step, as a line Refinements left at this step: N, wherever the widget has a refining action); autopilot.handback-presented is the turn-level hand-back, shown when a working turn ended needing the person with no widget to hand over (detail.why: max-iterations, context-exhausted, failure or question; detail.options; detail.choice once answered); autopilot.catch-up is the autopilot being given the whole visible transcript at once (detail.why: first, for its first decision in a flow or after a reload; size, when its own history passed its budget and was rebuilt short \u2014 detail.ownChars; or compacted, when a compaction removed the last message it had seen, so it reads the summary and everything since, short; in each, what it had sent on the user behalf is included and labelled as its own, since its own history does not hold it); autopilot.cost-dropped is autopilot spend that no message carries, so it is NOT in the session total (detail.costUsd and detail.why: handed-back, aborted or stale for a written question it answered that no reply was sent for \u2014 stale when a pause, a resume, a new turn or the end of its flow came before the answer landed, which then went nowhere \u2014 or no-recorder when the driver had no way to book a decision to its interaction); a hand-back trigger can also be budget (the decision passed its spend cap), watchdog (its work went quiet: no ready surface and no heartbeat, or its own decision stalled with no model call landing, which stops that decision) or detached (the autopilot was removed while it held the interaction, which went to the person with no reason shown). To debug one autopilot decision, follow its interactionId: interaction.requested (heldBy), autopilot.claimed, autopilot.decision-sent, autopilot.acted or autopilot.handed-back, interaction.invoked, interaction.resolved (answeredBy), then the next turn of the working agent), interaction.invoked (a claimant ran one of the actions the widget itself exposes, through its hold, the same code the button runs \u2014 detail.claimant, detail.action (an option id, select or reply) and detail.finished, whether that settled the interaction, and when it did not, the run is recorded as an edit; the choice and narration it recorded reach the result of the tool that asked as decidedOnUsersBehalf; the person's own programmatic action, from a host with no DOM to click, carries detail.by: user in place of detail.claimant, and is not recorded as an edit nor as a decision on their behalf, so what it settles is answered by user), interaction.step (a long action run as named steps through runSteps, which survive a reload \u2014 detail.step and detail.outcome: started, done, skipped when the step was already done before a reload, or resumed when it started before a reload and runs again with what it saved part-way, such as a job id it re-attaches to), interaction.checkpoint (the checkpoints a conversation keeps for its long actions: the one in flight, and each one a reload cut, held apart until a request of its own widget type takes it over, so a resumed flow that opens other long widgets first, which save their own, loses nothing \u2014 detail.action: resumed when a reload cut the work and a request of the same widget type that the registration sameWork agrees is the same work took it over, refused when sameWork said a new request is different work (detail.saved is the identity it kept; detail.kept: true, since it stays for a later request of that type, and is offered to every one until one agrees) or when runSteps found the handed-over checkpoint malformed and started fresh (detail.reason, detail.saved), or cleared when its flow ended, once per checkpoint, with detail.cut: true for one a reload cut that nothing took over), context.updated/threshold-crossed (token + cost), headless.attached (a HeadlessSession attached, for a host that drives the assistant with no screen \u2014 detail.label, what the host called itself, when it gave one) and headless.raw-resolved (that host settled an interaction raw, bypassing the widget's own actions: detail.interactionId and detail.component; the result went to the tool as given, so check what the widget would have enforced), context.condensed (a stale tool payload was collapsed out of the model-bound history by a `condenseWhen` declaration on the tool \u2014 detail.tool + toolCallId, target args|response, trigger (superseded:<key> or age:<n>), stubLen, and an estimated tokensSaved; stored history and this log keep the FULL payload, so the model-visible slice at any point is the full history minus the condensations recorded up to then), panel.toggled, attachment.added, file.read-failed, suggestions.failed.",
|
|
5210
5062
|
"Sub-agent meta events: a sub-agent's own turn.retry/turn.error/tool.failed/tool.unresolved events are merged into this same timeline, tagged with `detail.subAgent` \u2014 a `\"<parent> \u203A <sub-agent>\"` breadcrumb that composes when nested (e.g. `\"UI Builder \u203A Planner \u203A Grounding\"`) \u2014 and interleaved by their original timestamps within the subagent.started\u2192completed/failed bracket. These are the per-attempt/per-failure signals that do NOT appear among the sub-agent's (hoisted) messages: a malformed/empty attempt that gets retried produces no message, and the stale-vs-hallucinated split and streak counts live only on the event. A sub-agent's high-volume, message-derivable events (turn.start/turn.end, provider.selected, context.updated) are intentionally NOT merged \u2014 read its hoisted messages for model/tokens/cost and turn-by-turn activity, and the bracketing subagent.* events for the run's span.",
|
|
5211
5063
|
"`meta` holds context captured at export time: agentSummary (full agent configs), context (active model, contextTokens/contextLimit/contextUsagePercent for the last call, and the session totals \u2014 sessionCostUsd, sessionTokensConsumed, and the four-bucket sessionUsage lifted to the top of this log), activeDebugSnapshot (the active agent's `getDebugSnapshot()` taken fresh at export \u2014 reflects state NOW, which may have advanced beyond the last turn's agentSnapshot), debug (optional host-supplied debug state), host, and the export timestamp.",
|
|
5212
5064
|
"Note the two different scopes in `meta.context`: `contextTokens` is the prompt size of the LAST call (against `contextLimit`, the model context window), while `sessionUsage`/`sessionTokensConsumed` are cumulative BILLED throughput. Every turn resends the conversation, so the cumulative figure counts each turn\u2019s prompt again in the next turn\u2019s and is expected to dwarf the context size \u2014 that is not double-counting.",
|
|
@@ -6300,7 +6152,6 @@ var HARVESTED_SUBAGENT_EVENTS = /* @__PURE__ */ new Set([
|
|
|
6300
6152
|
"tool.failed",
|
|
6301
6153
|
"tool.unresolved"
|
|
6302
6154
|
]);
|
|
6303
|
-
var NO_TOOL_CALL_NUDGE = "IMPORTANT: Your previous reply ended without calling a tool, but this task can only be finished by calling one. Call the tool now; do not reply with text alone.";
|
|
6304
6155
|
|
|
6305
6156
|
// src/utils/tool-fold.ts
|
|
6306
6157
|
var TOOL_FOLD_SYMBOL = Symbol("toolFold");
|
|
@@ -10238,8 +10089,6 @@ var ChatDriver = class _ChatDriver extends EventTarget {
|
|
|
10238
10089
|
let iterations = 0;
|
|
10239
10090
|
let malformedAttempts = 0;
|
|
10240
10091
|
let emptyResponseAttempts = 0;
|
|
10241
|
-
let noToolCallRetried = false;
|
|
10242
|
-
let noToolCallNudgePending = false;
|
|
10243
10092
|
let setupTransportAttempts = 0;
|
|
10244
10093
|
let firstLlmCall = !!currentInput;
|
|
10245
10094
|
let pinnedThinkingPolicy;
|
|
@@ -10292,9 +10141,7 @@ var ChatDriver = class _ChatDriver extends EventTarget {
|
|
|
10292
10141
|
|
|
10293
10142
|
${MALFORMED_CALL_NUDGE}` : emptyResponseAttempts > 0 ? `
|
|
10294
10143
|
|
|
10295
|
-
${EMPTY_RESPONSE_NUDGE}` :
|
|
10296
|
-
|
|
10297
|
-
${NO_TOOL_CALL_NUDGE}` : "";
|
|
10144
|
+
${EMPTY_RESPONSE_NUDGE}` : "";
|
|
10298
10145
|
const firstCallNote = tailNote && iterations === 1 ? `
|
|
10299
10146
|
|
|
10300
10147
|
${tailNote}` : "";
|
|
@@ -10651,28 +10498,10 @@ ${tailBody}
|
|
|
10651
10498
|
emptyResponseAttempts = 0;
|
|
10652
10499
|
malformedAttempts = 0;
|
|
10653
10500
|
setupTransportAttempts = 0;
|
|
10654
|
-
noToolCallNudgePending = false;
|
|
10655
10501
|
if (closing) return turnDone();
|
|
10656
10502
|
if (!response.toolCalls?.length) {
|
|
10657
|
-
if (this.isSubAgent && !this.subAgentCompletion && response.responseMeta?.toolChoiceDowngraded && !noToolCallRetried) {
|
|
10658
|
-
noToolCallRetried = true;
|
|
10659
|
-
noToolCallNudgePending = true;
|
|
10660
|
-
logger2.warn(
|
|
10661
|
-
"ChatDriver: sub-agent replied without the tool call its forced turn needed, retrying once"
|
|
10662
|
-
);
|
|
10663
|
-
recordMetaEvent(this.sessionKey, "turn.retry", {
|
|
10664
|
-
reason: "no-tool-call",
|
|
10665
|
-
agent: this.activeAgentName,
|
|
10666
|
-
provider: this.lastResolvedProviderName,
|
|
10667
|
-
attempt: 1,
|
|
10668
|
-
maxAttempts: 1
|
|
10669
|
-
});
|
|
10670
|
-
iterations -= 1;
|
|
10671
|
-
continue;
|
|
10672
|
-
}
|
|
10673
10503
|
break;
|
|
10674
10504
|
}
|
|
10675
|
-
noToolCallRetried = false;
|
|
10676
10505
|
const toolCalls = response.toolCalls;
|
|
10677
10506
|
const executedById = /* @__PURE__ */ new Map();
|
|
10678
10507
|
const unknownToolIds = /* @__PURE__ */ new Set();
|
|
@@ -13812,7 +13641,6 @@ function collectRows(messages, depth, subAgentOf) {
|
|
|
13812
13641
|
ANTHROPIC_CACHE_READ_MULTIPLIER,
|
|
13813
13642
|
ANTHROPIC_CACHE_WRITE_1H_MULTIPLIER,
|
|
13814
13643
|
ANTHROPIC_CACHE_WRITE_5M_MULTIPLIER,
|
|
13815
|
-
ANTHROPIC_LONG_CONTEXT_THRESHOLD,
|
|
13816
13644
|
AgenticActivityBus,
|
|
13817
13645
|
AnthropicProvider,
|
|
13818
13646
|
AnthropicTransport,
|
|
@@ -13846,7 +13674,6 @@ function collectRows(messages, depth, subAgentOf) {
|
|
|
13846
13674
|
agenticActivityBus,
|
|
13847
13675
|
aiServiceAccessRefusalOf,
|
|
13848
13676
|
aiServiceErrorCodeOf,
|
|
13849
|
-
anthropicCacheReadMultiplierFor,
|
|
13850
13677
|
anthropicRatesFor,
|
|
13851
13678
|
anthropicTokenCost,
|
|
13852
13679
|
assembleDebugLog,
|