@tangle-network/agent-app 0.60.275 → 0.60.277

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.
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  ReasoningRow,
3
3
  chatToolCallPart
4
- } from "../chunk-SKI2F3NL.js";
4
+ } from "../chunk-YI2XZCTP.js";
5
5
  import "../chunk-BDEBQ4WO.js";
6
6
  import "../chunk-3HUFJ5LO.js";
7
7
  import "../chunk-FBVLEGEG.js";
@@ -1239,6 +1239,7 @@ function createRouterTurnProducer(options) {
1239
1239
  let wake = null;
1240
1240
  let done = false;
1241
1241
  let outcome = null;
1242
+ let usageReported = false;
1242
1243
  const parts = [];
1243
1244
  const toolParts = /* @__PURE__ */ new Map();
1244
1245
  let textPart = null;
@@ -1300,6 +1301,7 @@ function createRouterTurnProducer(options) {
1300
1301
  reasoningPart = null;
1301
1302
  reasoningClock.settle();
1302
1303
  } else if (event.type === "usage") {
1304
+ usageReported = true;
1303
1305
  push({ type: "usage", usage: {
1304
1306
  promptTokens: event.promptTokens,
1305
1307
  completionTokens: event.completionTokens,
@@ -1343,13 +1345,13 @@ function createRouterTurnProducer(options) {
1343
1345
  await run;
1344
1346
  }
1345
1347
  const snapshot = () => parts.map((part) => part.type === "reasoning" ? { ...part, time: reasoningClock.time(part) } : { ...part });
1346
- const usage = () => ({
1348
+ const usage = () => !outcome || !usageReported ? {} : {
1347
1349
  // The Router's prompt tokens include the cached ones; the sandbox lanes report input and cache reads apart, so
1348
1350
  // the stored row counts them apart here too and `inputTokens + cacheReadTokens` is the prompt on either lane.
1349
- inputTokens: (outcome?.usage.promptTokens ?? 0) - (outcome?.usage.cachedPromptTokens ?? 0),
1350
- outputTokens: outcome?.usage.completionTokens ?? 0,
1351
- ...outcome?.usage.cachedPromptTokens !== void 0 ? { cacheReadTokens: outcome.usage.cachedPromptTokens } : {}
1352
- });
1351
+ inputTokens: outcome.usage.promptTokens - (outcome.usage.cachedPromptTokens ?? 0),
1352
+ outputTokens: outcome.usage.completionTokens,
1353
+ ...outcome.usage.cachedPromptTokens !== void 0 ? { cacheReadTokens: outcome.usage.cachedPromptTokens } : {}
1354
+ };
1353
1355
  return {
1354
1356
  stream: stream(),
1355
1357
  finalText: () => outcome?.text ?? "",