@agent-inspect/viewer 6.28.0 → 6.29.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -172,6 +172,8 @@ function isPersistedTokenUsage(value) {
172
172
  if (!isOptionalNonNegativeNumber(value.output)) return false;
173
173
  if (!isOptionalNonNegativeNumber(value.total)) return false;
174
174
  if (!isOptionalNonNegativeNumber(value.cached)) return false;
175
+ if (!isOptionalNonNegativeNumber(value.cacheWrite)) return false;
176
+ if (!isOptionalNonNegativeNumber(value.reasoning)) return false;
175
177
  return true;
176
178
  }
177
179
  function isPersistedTraceContext(value) {
@@ -3243,16 +3245,20 @@ function normalizeTokenUsage(value) {
3243
3245
  const output = nonNegativeFinite(value.output);
3244
3246
  const suppliedTotal = nonNegativeFinite(value.total);
3245
3247
  const cached = nonNegativeFinite(value.cached);
3248
+ const cacheWrite = nonNegativeFinite(value.cacheWrite);
3249
+ const reasoning = nonNegativeFinite(value.reasoning);
3246
3250
  const derivedTotal = input !== void 0 && output !== void 0 && Number.isFinite(input + output) ? input + output : void 0;
3247
3251
  const total = suppliedTotal ?? derivedTotal;
3248
- if (input === void 0 && output === void 0 && total === void 0 && cached === void 0) {
3252
+ if (input === void 0 && output === void 0 && total === void 0 && cached === void 0 && cacheWrite === void 0 && reasoning === void 0) {
3249
3253
  return void 0;
3250
3254
  }
3251
3255
  return {
3252
3256
  ...input !== void 0 ? { input } : {},
3253
3257
  ...output !== void 0 ? { output } : {},
3254
3258
  ...total !== void 0 ? { total } : {},
3255
- ...cached !== void 0 ? { cached } : {}
3259
+ ...cached !== void 0 ? { cached } : {},
3260
+ ...cacheWrite !== void 0 ? { cacheWrite } : {},
3261
+ ...reasoning !== void 0 ? { reasoning } : {}
3256
3262
  };
3257
3263
  }
3258
3264
 
@@ -4411,6 +4417,8 @@ function readOpenInferenceTokenUsage(attributes) {
4411
4417
  const completion = attributes["llm.token_count.completion"];
4412
4418
  const total = attributes["llm.token_count.total"];
4413
4419
  const cached = attributes["llm.token_count.prompt_details.cache_read"];
4420
+ const cacheWrite = attributes["llm.token_count.prompt_details.cache_write"] ?? attributes["llm.token_count.prompt_details.cache_creation"];
4421
+ const reasoning = attributes["llm.token_count.completion_details.reasoning"] ?? attributes["llm.token_count.completion_details.reasoning_tokens"];
4414
4422
  const usage = {};
4415
4423
  if (typeof prompt === "number" && Number.isFinite(prompt) && prompt >= 0) {
4416
4424
  usage.input = prompt;
@@ -4424,6 +4432,12 @@ function readOpenInferenceTokenUsage(attributes) {
4424
4432
  if (typeof cached === "number" && Number.isFinite(cached) && cached >= 0) {
4425
4433
  usage.cached = cached;
4426
4434
  }
4435
+ if (typeof cacheWrite === "number" && Number.isFinite(cacheWrite) && cacheWrite >= 0) {
4436
+ usage.cacheWrite = cacheWrite;
4437
+ }
4438
+ if (typeof reasoning === "number" && Number.isFinite(reasoning) && reasoning >= 0) {
4439
+ usage.reasoning = reasoning;
4440
+ }
4427
4441
  if (usage.total === void 0 && usage.input !== void 0 && usage.output !== void 0) {
4428
4442
  usage.total = usage.input + usage.output;
4429
4443
  }