@agentistics/mcp 2.132.1 → 2.132.3

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.
@@ -161,6 +161,8 @@ function getModelPrice(modelId) {
161
161
  }
162
162
  var isUnpricedModel = (modelId) => getModelPrice(modelId) === UNPRICED_PRICE;
163
163
  function sessionModelUsage(s, fallbackModel) {
164
+ if (s.tokens_unavailable)
165
+ return [];
164
166
  const breakdown = s.model_usage;
165
167
  if (breakdown && typeof breakdown === "object") {
166
168
  const entries = Object.entries(breakdown).filter(([m, u]) => m && u);
@@ -877,10 +879,10 @@ var CAPABILITY_REFINEMENTS = {
877
879
  cost: { source: REPLAY("codex"), state: { state: "partial", exactness: "estimated", limit: "priced from the table over three of four counters; the unread cache-write counter is not priced." } }
878
880
  },
879
881
  gemini: {
880
- tokens: { source: `${P2}; ${REPLAY("gemini")}`, state: { state: "partial", exactness: "exact", limit: "rich-JSON chat shape only; the append-journal shape carries per-record tokens that are deliberately not read until the owner decides (it changes money on every cost surface)." } },
881
- cost: { source: `${P2}; ${REPLAY("gemini")}`, state: { state: "partial", exactness: "estimated", limit: "rich-JSON chat shape only, priced from the table; see tokens." } },
882
- model: { source: `${P2}; ${REPLAY("gemini")}`, state: { state: "partial", exactness: "exact", limit: "rich-JSON chat shape only; the append-journal shape is not read for its model." } },
883
- tools: { source: `${P2}; ${REPLAY("gemini")}`, state: { state: "partial", exactness: "exact", limit: "rich-JSON chat shape only; the append-journal shape is not read for tool calls." } }
882
+ tokens: { source: `${P2}; ${REPLAY("gemini")}`, state: { state: "partial", exactness: "exact", limit: "both chat shapes (rich-JSON and the append-journal) are summed per response since 1.1.0 (owner D8); `input` is the uncached part (the API's prompt count includes the cache); thoughts, tool and total are not read; a record with no `tokens`, or with null counters, adds nothing (absent, never 0)." } },
883
+ cost: { source: `${P2}; ${REPLAY("gemini")}`, state: { state: "partial", exactness: "estimated", limit: "priced from the table over the summed tokens of both chat shapes; see tokens." } },
884
+ model: { source: `${P2}; ${REPLAY("gemini")}`, state: { state: "partial", exactness: "exact", limit: "the last model named by a response record wins, in both chat shapes; a session whose records name none has no model." } },
885
+ tools: { source: `${P2}; ${REPLAY("gemini")}`, state: { state: "partial", exactness: "exact", limit: "counted from the `toolCalls` of response records in both chat shapes." } }
884
886
  },
885
887
  copilot: {
886
888
  tokens: { source: `${P2}; ${REPLAY("copilot")}`, state: { state: "partial", exactness: "exact", limit: "only at session.shutdown, one cumulative report per model; a crashed session has none (absent, never zero)." } },
@@ -1097,6 +1099,7 @@ function filterSessions(sessions, harness) {
1097
1099
  return sessions.filter((s) => sessionHarness(s) === harness);
1098
1100
  }
1099
1101
  function sessionTokens2(s) {
1102
+ const tokensUnavailable = s.tokens_unavailable === true;
1100
1103
  const input = s.input_tokens ?? 0;
1101
1104
  const output = s.output_tokens ?? 0;
1102
1105
  const cacheRead = s.cache_read_input_tokens ?? 0;
@@ -1113,7 +1116,7 @@ function sessionTokens2(s) {
1113
1116
  };
1114
1117
  const cost = sessionCostUSD(priced) ?? 0;
1115
1118
  const unpriced = unpricedTokens(priced);
1116
- return { input, output, cacheRead, cacheWrite, cost, unpriced };
1119
+ return { input, output, cacheRead, cacheWrite, cost, unpriced, tokensUnavailable };
1117
1120
  }
1118
1121
  function sessionMessages(s) {
1119
1122
  return (s.user_message_count ?? 0) + (s.assistant_message_count ?? 0);
@@ -1500,15 +1503,17 @@ function legacySummary(data, harness) {
1500
1503
  const projectSessions = {};
1501
1504
  const activeDates = new Set;
1502
1505
  for (const s of allSessions) {
1503
- const { input, output, cacheRead, cacheWrite, cost, unpriced } = sessionTokens2(s);
1506
+ const { input, output, cacheRead, cacheWrite, cost, unpriced, tokensUnavailable } = sessionTokens2(s);
1504
1507
  totalUnpriced += unpriced;
1505
- totalInput += input;
1506
- totalOutput += output;
1507
- totalCacheRead += cacheRead;
1508
- totalCacheWrite += cacheWrite;
1509
- totalCostUSD += cost;
1510
- if (s.model)
1511
- modelTokens[s.model] = (modelTokens[s.model] ?? 0) + input + output;
1508
+ if (!tokensUnavailable) {
1509
+ totalInput += input;
1510
+ totalOutput += output;
1511
+ totalCacheRead += cacheRead;
1512
+ totalCacheWrite += cacheWrite;
1513
+ totalCostUSD += cost;
1514
+ if (s.model)
1515
+ modelTokens[s.model] = (modelTokens[s.model] ?? 0) + input + output;
1516
+ }
1512
1517
  if (s.project_path) {
1513
1518
  const root = canonicalProjectPath(s.project_path);
1514
1519
  projectSessions[root] = (projectSessions[root] ?? 0) + 1;
@@ -1542,11 +1547,13 @@ function legacyHarnesses(data) {
1542
1547
  let input = 0, output = 0, cacheRead = 0, cacheWrite = 0, cost = 0, messages = 0, lastActive = "";
1543
1548
  for (const s of hs) {
1544
1549
  const t = sessionTokens2(s);
1545
- input += t.input;
1546
- output += t.output;
1547
- cacheRead += t.cacheRead;
1548
- cacheWrite += t.cacheWrite;
1549
- cost += t.cost;
1550
+ if (!t.tokensUnavailable) {
1551
+ input += t.input;
1552
+ output += t.output;
1553
+ cacheRead += t.cacheRead;
1554
+ cacheWrite += t.cacheWrite;
1555
+ cost += t.cost;
1556
+ }
1550
1557
  messages += sessionMessages(s);
1551
1558
  if (s.start_time && String(s.start_time) > lastActive)
1552
1559
  lastActive = String(s.start_time);
@@ -1576,13 +1583,15 @@ function legacyProjects(data, harness) {
1576
1583
  if (!byPath[key])
1577
1584
  byPath[key] = { sessions: 0, inputTokens: 0, outputTokens: 0, cacheRead: 0, cacheWrite: 0, costUSD: 0, messages: 0, lastActive: "", languages: [] };
1578
1585
  const agg = byPath[key];
1579
- const { input, output, cacheRead, cacheWrite, cost } = sessionTokens2(s);
1586
+ const { input, output, cacheRead, cacheWrite, cost, tokensUnavailable } = sessionTokens2(s);
1580
1587
  agg.sessions += 1;
1581
- agg.inputTokens += input;
1582
- agg.outputTokens += output;
1583
- agg.cacheRead += cacheRead;
1584
- agg.cacheWrite += cacheWrite;
1585
- agg.costUSD += cost;
1588
+ if (!tokensUnavailable) {
1589
+ agg.inputTokens += input;
1590
+ agg.outputTokens += output;
1591
+ agg.cacheRead += cacheRead;
1592
+ agg.cacheWrite += cacheWrite;
1593
+ agg.costUSD += cost;
1594
+ }
1586
1595
  agg.messages += sessionMessages(s);
1587
1596
  if (!agg.lastActive || (s.start_time ?? "") > agg.lastActive)
1588
1597
  agg.lastActive = s.start_time ?? "";
@@ -1637,12 +1646,14 @@ function legacyCosts(data, harness) {
1637
1646
  if (!byModel[model])
1638
1647
  byModel[model] = { inputTokens: 0, outputTokens: 0, cacheReadTokens: 0, cacheWriteTokens: 0, estimatedCostUSD: 0 };
1639
1648
  const agg = byModel[model];
1640
- const { input, output, cacheRead, cacheWrite, cost } = sessionTokens2(s);
1641
- agg.inputTokens += input;
1642
- agg.outputTokens += output;
1643
- agg.cacheReadTokens += cacheRead;
1644
- agg.cacheWriteTokens += cacheWrite;
1645
- agg.estimatedCostUSD += cost;
1649
+ const { input, output, cacheRead, cacheWrite, cost, tokensUnavailable } = sessionTokens2(s);
1650
+ if (!tokensUnavailable) {
1651
+ agg.inputTokens += input;
1652
+ agg.outputTokens += output;
1653
+ agg.cacheReadTokens += cacheRead;
1654
+ agg.cacheWriteTokens += cacheWrite;
1655
+ agg.estimatedCostUSD += cost;
1656
+ }
1646
1657
  }
1647
1658
  const breakdown = Object.entries(byModel).map(([model, u]) => ({
1648
1659
  model,
@@ -1663,14 +1674,16 @@ function legacyRepos(data, harness) {
1663
1674
  if (!byRemote[key])
1664
1675
  byRemote[key] = { sessions: 0, messages: 0, inputTokens: 0, outputTokens: 0, cacheRead: 0, cacheWrite: 0, costUSD: 0, lastActive: "" };
1665
1676
  const agg = byRemote[key];
1666
- const { input, output, cacheRead, cacheWrite, cost } = sessionTokens2(s);
1677
+ const { input, output, cacheRead, cacheWrite, cost, tokensUnavailable } = sessionTokens2(s);
1667
1678
  agg.sessions += 1;
1668
1679
  agg.messages += sessionMessages(s);
1669
- agg.inputTokens += input;
1670
- agg.outputTokens += output;
1671
- agg.cacheRead += cacheRead;
1672
- agg.cacheWrite += cacheWrite;
1673
- agg.costUSD += cost;
1680
+ if (!tokensUnavailable) {
1681
+ agg.inputTokens += input;
1682
+ agg.outputTokens += output;
1683
+ agg.cacheRead += cacheRead;
1684
+ agg.cacheWrite += cacheWrite;
1685
+ agg.costUSD += cost;
1686
+ }
1674
1687
  if (s.start_time && String(s.start_time) > agg.lastActive)
1675
1688
  agg.lastActive = String(s.start_time);
1676
1689
  }
@@ -2782,12 +2795,14 @@ async function callTool(req) {
2782
2795
  startedAt: s.start_time,
2783
2796
  durationMinutes: s.duration_minutes,
2784
2797
  messages: sessionMessages(s),
2785
- inputTokens: input,
2786
- outputTokens: output,
2787
- cacheReadTokens: cacheRead,
2788
- cacheWriteTokens: cacheWrite,
2789
- totalTokens: input + output + cacheRead + cacheWrite,
2790
- estimatedCostUSD: unpriced > 0 && unpriced === input + output + cacheRead + cacheWrite ? null : Math.round(cost * 1e4) / 1e4,
2798
+ ...s.tokens_unavailable ? {} : {
2799
+ inputTokens: input,
2800
+ outputTokens: output,
2801
+ cacheReadTokens: cacheRead,
2802
+ cacheWriteTokens: cacheWrite,
2803
+ totalTokens: input + output + cacheRead + cacheWrite
2804
+ },
2805
+ ...s.tokens_unavailable ? {} : { estimatedCostUSD: unpriced > 0 && unpriced === input + output + cacheRead + cacheWrite ? null : Math.round(cost * 1e4) / 1e4 },
2791
2806
  ...unpriced > 0 ? { unpricedTokens: unpriced } : {},
2792
2807
  model: s.model ?? null,
2793
2808
  ...startedBy.get(s.session_id) ? { startedBy: startedBy.get(s.session_id) } : {}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentistics/mcp",
3
- "version": "2.132.1",
3
+ "version": "2.132.3",
4
4
  "description": "Agentistics MCP server — Claude Code analytics for Claude Desktop and Claude Code",
5
5
  "type": "module",
6
6
  "main": "./dist/agentistics-mcp.js",