fleetlens 0.12.0 → 0.12.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.
Files changed (125) hide show
  1. package/app/apps/web/.next/BUILD_ID +1 -1
  2. package/app/apps/web/.next/build-manifest.json +3 -3
  3. package/app/apps/web/.next/prerender-manifest.json +3 -3
  4. package/app/apps/web/.next/server/app/_global-error.html +1 -1
  5. package/app/apps/web/.next/server/app/_global-error.rsc +1 -1
  6. package/app/apps/web/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  7. package/app/apps/web/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  8. package/app/apps/web/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  9. package/app/apps/web/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  10. package/app/apps/web/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  11. package/app/apps/web/.next/server/app/_not-found/page.js +2 -1
  12. package/app/apps/web/.next/server/app/_not-found/page.js.nft.json +1 -1
  13. package/app/apps/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  14. package/app/apps/web/.next/server/app/api/ask/route.js +1 -1
  15. package/app/apps/web/.next/server/app/api/ask/route.js.nft.json +1 -1
  16. package/app/apps/web/.next/server/app/api/digest/day/[date]/route.js +1 -1
  17. package/app/apps/web/.next/server/app/api/digest/day/[date]/route.js.nft.json +1 -1
  18. package/app/apps/web/.next/server/app/api/digest/month/[yearMonth]/route.js +1 -1
  19. package/app/apps/web/.next/server/app/api/digest/month/[yearMonth]/route.js.nft.json +1 -1
  20. package/app/apps/web/.next/server/app/api/digest/month-index/route.js +1 -1
  21. package/app/apps/web/.next/server/app/api/digest/month-index/route.js.nft.json +1 -1
  22. package/app/apps/web/.next/server/app/api/digest/week/[startDate]/route.js +1 -1
  23. package/app/apps/web/.next/server/app/api/digest/week/[startDate]/route.js.nft.json +1 -1
  24. package/app/apps/web/.next/server/app/api/digest/week-index/route.js +1 -1
  25. package/app/apps/web/.next/server/app/api/digest/week-index/route.js.nft.json +1 -1
  26. package/app/apps/web/.next/server/app/api/events/route.js +1 -1
  27. package/app/apps/web/.next/server/app/api/events/route.js.nft.json +1 -1
  28. package/app/apps/web/.next/server/app/api/jobs/route.js +1 -1
  29. package/app/apps/web/.next/server/app/api/jobs/route.js.nft.json +1 -1
  30. package/app/apps/web/.next/server/app/api/pdf/[key]/route.js +1 -1
  31. package/app/apps/web/.next/server/app/api/pdf/[key]/route.js.nft.json +1 -1
  32. package/app/apps/web/.next/server/app/api/runs/[runId]/route.js +1 -1
  33. package/app/apps/web/.next/server/app/api/runs/[runId]/route.js.nft.json +1 -1
  34. package/app/apps/web/.next/server/app/api/runs/[runId]/stream/route.js +1 -1
  35. package/app/apps/web/.next/server/app/api/runs/[runId]/stream/route.js.nft.json +1 -1
  36. package/app/apps/web/.next/server/app/api/runs/route.js +1 -1
  37. package/app/apps/web/.next/server/app/api/runs/route.js.nft.json +1 -1
  38. package/app/apps/web/.next/server/app/api/settings/route.js +1 -1
  39. package/app/apps/web/.next/server/app/api/settings/route.js.nft.json +1 -1
  40. package/app/apps/web/.next/server/app/api/team-config/route.js +1 -1
  41. package/app/apps/web/.next/server/app/api/team-config/route.js.nft.json +1 -1
  42. package/app/apps/web/.next/server/app/api/workflow-agent/route.js +1 -1
  43. package/app/apps/web/.next/server/app/api/workflow-agent/route.js.nft.json +1 -1
  44. package/app/apps/web/.next/server/app/changelog/page.js +2 -1
  45. package/app/apps/web/.next/server/app/changelog/page.js.nft.json +1 -1
  46. package/app/apps/web/.next/server/app/changelog/page_client-reference-manifest.js +1 -1
  47. package/app/apps/web/.next/server/app/day/[date]/page.js +2 -1
  48. package/app/apps/web/.next/server/app/day/[date]/page.js.nft.json +1 -1
  49. package/app/apps/web/.next/server/app/day/[date]/page_client-reference-manifest.js +1 -1
  50. package/app/apps/web/.next/server/app/day/page.js +2 -1
  51. package/app/apps/web/.next/server/app/day/page.js.nft.json +1 -1
  52. package/app/apps/web/.next/server/app/day/page_client-reference-manifest.js +1 -1
  53. package/app/apps/web/.next/server/app/digest/[date]/page.js +2 -1
  54. package/app/apps/web/.next/server/app/digest/[date]/page.js.nft.json +1 -1
  55. package/app/apps/web/.next/server/app/digest/[date]/page_client-reference-manifest.js +1 -1
  56. package/app/apps/web/.next/server/app/digest/page.js +2 -1
  57. package/app/apps/web/.next/server/app/digest/page.js.nft.json +1 -1
  58. package/app/apps/web/.next/server/app/digest/page_client-reference-manifest.js +1 -1
  59. package/app/apps/web/.next/server/app/insights/[key]/page.js +2 -1
  60. package/app/apps/web/.next/server/app/insights/[key]/page.js.nft.json +1 -1
  61. package/app/apps/web/.next/server/app/insights/[key]/page_client-reference-manifest.js +1 -1
  62. package/app/apps/web/.next/server/app/insights/page.js +2 -1
  63. package/app/apps/web/.next/server/app/insights/page.js.nft.json +1 -1
  64. package/app/apps/web/.next/server/app/insights/page_client-reference-manifest.js +1 -1
  65. package/app/apps/web/.next/server/app/page.js +2 -1
  66. package/app/apps/web/.next/server/app/page.js.nft.json +1 -1
  67. package/app/apps/web/.next/server/app/page_client-reference-manifest.js +1 -1
  68. package/app/apps/web/.next/server/app/parallelism/page.js +2 -1
  69. package/app/apps/web/.next/server/app/parallelism/page.js.nft.json +1 -1
  70. package/app/apps/web/.next/server/app/parallelism/page_client-reference-manifest.js +1 -1
  71. package/app/apps/web/.next/server/app/print/[key]/page.js +2 -1
  72. package/app/apps/web/.next/server/app/print/[key]/page.js.nft.json +1 -1
  73. package/app/apps/web/.next/server/app/print/[key]/page_client-reference-manifest.js +1 -1
  74. package/app/apps/web/.next/server/app/projects/[slug]/page.js +2 -1
  75. package/app/apps/web/.next/server/app/projects/[slug]/page.js.nft.json +1 -1
  76. package/app/apps/web/.next/server/app/projects/[slug]/page_client-reference-manifest.js +1 -1
  77. package/app/apps/web/.next/server/app/projects/page.js +2 -1
  78. package/app/apps/web/.next/server/app/projects/page.js.nft.json +1 -1
  79. package/app/apps/web/.next/server/app/projects/page_client-reference-manifest.js +1 -1
  80. package/app/apps/web/.next/server/app/runs/page.js +2 -1
  81. package/app/apps/web/.next/server/app/runs/page.js.nft.json +1 -1
  82. package/app/apps/web/.next/server/app/runs/page_client-reference-manifest.js +1 -1
  83. package/app/apps/web/.next/server/app/sessions/[id]/page.js +2 -1
  84. package/app/apps/web/.next/server/app/sessions/[id]/page.js.nft.json +1 -1
  85. package/app/apps/web/.next/server/app/sessions/[id]/page_client-reference-manifest.js +1 -1
  86. package/app/apps/web/.next/server/app/sessions/page.js +2 -1
  87. package/app/apps/web/.next/server/app/sessions/page.js.nft.json +1 -1
  88. package/app/apps/web/.next/server/app/sessions/page_client-reference-manifest.js +1 -1
  89. package/app/apps/web/.next/server/app/settings/page.js +2 -1
  90. package/app/apps/web/.next/server/app/settings/page.js.nft.json +1 -1
  91. package/app/apps/web/.next/server/app/settings/page_client-reference-manifest.js +1 -1
  92. package/app/apps/web/.next/server/app/team/page.js +2 -1
  93. package/app/apps/web/.next/server/app/team/page.js.nft.json +1 -1
  94. package/app/apps/web/.next/server/app/team/page_client-reference-manifest.js +1 -1
  95. package/app/apps/web/.next/server/app/usage/page.js +2 -1
  96. package/app/apps/web/.next/server/app/usage/page.js.nft.json +1 -1
  97. package/app/apps/web/.next/server/app/usage/page_client-reference-manifest.js +1 -1
  98. package/app/apps/web/.next/server/chunks/packages_parser_dist_06d9se1._.js +3 -0
  99. package/app/apps/web/.next/server/chunks/packages_parser_dist_10ihc3~._.js +3 -0
  100. package/app/apps/web/.next/server/chunks/ssr/[root-of-the-server]__0n-ax-5._.js +3 -0
  101. package/app/apps/web/.next/server/chunks/ssr/_0xu2pvc._.js +1 -1
  102. package/app/apps/web/.next/server/chunks/ssr/apps_web_lib_0k0tl52._.js +3 -0
  103. package/app/apps/web/.next/server/chunks/ssr/apps_web_lib_changelog_ts_0n7_p1d._.js +3 -0
  104. package/app/apps/web/.next/server/chunks/ssr/apps_web_lib_changelog_ts_0nb5_-s._.js +3 -0
  105. package/app/apps/web/.next/server/chunks/ssr/packages_parser_dist_12.endt._.js +1 -1
  106. package/app/apps/web/.next/server/middleware-build-manifest.js +3 -3
  107. package/app/apps/web/.next/server/middleware-manifest.json +5 -5
  108. package/app/apps/web/.next/server/pages/500.html +1 -1
  109. package/app/apps/web/.next/server/server-reference-manifest.js +1 -1
  110. package/app/apps/web/.next/server/server-reference-manifest.json +1 -1
  111. package/app/apps/web/.next/static/chunks/03_7wmpodz36t.js +1 -0
  112. package/app/apps/web/lib/changelog-data.generated.ts +1 -1
  113. package/app/apps/web/package.json +1 -1
  114. package/app/apps/web/tsconfig.tsbuildinfo +1 -1
  115. package/dist/daemon-worker.js +127 -32
  116. package/dist/index.js +131 -36
  117. package/package.json +1 -1
  118. package/app/apps/web/.next/server/chunks/packages_parser_dist_04rh1zd._.js +0 -3
  119. package/app/apps/web/.next/server/chunks/packages_parser_dist_0ndsxe6._.js +0 -3
  120. package/app/apps/web/.next/server/chunks/ssr/[root-of-the-server]__03y~03u._.js +0 -3
  121. package/app/apps/web/.next/server/chunks/ssr/apps_web_lib_0af94gl._.js +0 -3
  122. package/app/apps/web/.next/static/chunks/0ck03i0l4zeun.js +0 -1
  123. /package/app/apps/web/.next/static/{WH20Ct_NdpZTKsqI_yquG → rrY-ephAArv8tjJOXD622}/_buildManifest.js +0 -0
  124. /package/app/apps/web/.next/static/{WH20Ct_NdpZTKsqI_yquG → rrY-ephAArv8tjJOXD622}/_clientMiddlewareManifest.js +0 -0
  125. /package/app/apps/web/.next/static/{WH20Ct_NdpZTKsqI_yquG → rrY-ephAArv8tjJOXD622}/_ssgManifest.js +0 -0
@@ -159,7 +159,19 @@ function dailyActivity(sessions) {
159
159
  };
160
160
  for (const s of sessions) {
161
161
  const startDay = sessionDay(s);
162
- if (startDay) {
162
+ if (s.dailyBreakdown && s.dailyBreakdown.length > 0) {
163
+ for (const d of s.dailyBreakdown) {
164
+ const bucket = touchBucket(d.day);
165
+ bucket.toolCalls += d.toolCalls;
166
+ bucket.turns += d.turns;
167
+ bucket.tokens.input += d.tokens.input;
168
+ bucket.tokens.output += d.tokens.output;
169
+ bucket.tokens.cacheRead += d.tokens.cacheRead;
170
+ bucket.tokens.cacheWrite += d.tokens.cacheWrite;
171
+ }
172
+ if (startDay)
173
+ touchBucket(startDay).durationMs += s.durationMs ?? 0;
174
+ } else if (startDay) {
163
175
  const bucket = touchBucket(startDay);
164
176
  bucket.toolCalls += s.toolCallCount ?? 0;
165
177
  bucket.turns += s.turnCount ?? 0;
@@ -169,31 +181,30 @@ function dailyActivity(sessions) {
169
181
  bucket.tokens.cacheWrite += s.totalUsage.cacheWrite;
170
182
  bucket.durationMs += s.durationMs ?? 0;
171
183
  }
184
+ const presenceDays = /* @__PURE__ */ new Set();
172
185
  const segments = s.activeSegments;
173
186
  if (segments && segments.length > 0) {
174
- const touchedDays = /* @__PURE__ */ new Set();
175
187
  for (const seg of segments) {
176
188
  let cur = seg.startMs;
177
189
  while (cur < seg.endMs) {
178
190
  const day = toLocalDay(cur);
179
- touchedDays.add(day);
191
+ presenceDays.add(day);
180
192
  const d = new Date(cur);
181
193
  d.setHours(24, 0, 0, 0);
182
194
  const dayEndMs = Math.min(d.getTime(), seg.endMs);
183
- const bucket = touchBucket(day);
184
- bucket.airTimeMs += dayEndMs - cur;
195
+ touchBucket(day).airTimeMs += dayEndMs - cur;
185
196
  cur = dayEndMs;
186
197
  }
187
198
  }
188
- for (const day of touchedDays) {
189
- const bucket = touchBucket(day);
190
- bucket.sessions++;
191
- }
192
199
  } else if (startDay) {
193
- const bucket = touchBucket(startDay);
194
- bucket.sessions++;
195
- bucket.airTimeMs += s.airTimeMs ?? 0;
200
+ presenceDays.add(startDay);
201
+ touchBucket(startDay).airTimeMs += s.airTimeMs ?? 0;
196
202
  }
203
+ if (s.dailyBreakdown)
204
+ for (const d of s.dailyBreakdown)
205
+ presenceDays.add(d.day);
206
+ for (const day of presenceDays)
207
+ touchBucket(day).sessions++;
197
208
  }
198
209
  const range = minDay && maxDay ? daysBetween(minDay, maxDay) : [];
199
210
  const out = [];
@@ -1238,9 +1249,31 @@ function parseTranscript(rawLines) {
1238
1249
  let linesAdded = 0;
1239
1250
  let linesRemoved = 0;
1240
1251
  const filesEdited = /* @__PURE__ */ new Set();
1252
+ const perDay = /* @__PURE__ */ new Map();
1253
+ const fallbackDay = startMs !== void 0 ? toLocalDay(startMs) : void 0;
1254
+ const dayBucket = (ts) => {
1255
+ let day;
1256
+ if (ts) {
1257
+ const ms = Date.parse(ts);
1258
+ if (!Number.isNaN(ms))
1259
+ day = toLocalDay(ms);
1260
+ }
1261
+ day = day ?? fallbackDay;
1262
+ if (!day)
1263
+ return void 0;
1264
+ let b = perDay.get(day);
1265
+ if (!b) {
1266
+ b = { toolCalls: 0, turns: 0, tokens: { ...BLANK_USAGE2 } };
1267
+ perDay.set(day, b);
1268
+ }
1269
+ return b;
1270
+ };
1241
1271
  for (const e of events) {
1242
1272
  if (e.role === "tool-call") {
1243
1273
  toolCallCount++;
1274
+ const tcDay = dayBucket(e.timestamp);
1275
+ if (tcDay)
1276
+ tcDay.toolCalls++;
1244
1277
  const toolBlock = e.blocks.find((b) => b && b.type === "tool_use");
1245
1278
  if (toolBlock) {
1246
1279
  const input = toolBlock.input ?? {};
@@ -1277,6 +1310,9 @@ function parseTranscript(rawLines) {
1277
1310
  firstUserPreview = e.teammateMessage ? e.teammateMessage.body : e.preview;
1278
1311
  }
1279
1312
  turnCount++;
1313
+ const turnDay = dayBucket(e.timestamp);
1314
+ if (turnDay)
1315
+ turnDay.turns++;
1280
1316
  lastUserPreview = e.preview;
1281
1317
  }
1282
1318
  }
@@ -1318,6 +1354,14 @@ function parseTranscript(rawLines) {
1318
1354
  totalUsage.output += u.output;
1319
1355
  totalUsage.cacheRead += u.cacheRead;
1320
1356
  totalUsage.cacheWrite += u.cacheWrite;
1357
+ const ts = typeof o.timestamp === "string" ? o.timestamp : void 0;
1358
+ const b = dayBucket(ts);
1359
+ if (b) {
1360
+ b.tokens.input += u.input;
1361
+ b.tokens.output += u.output;
1362
+ b.tokens.cacheRead += u.cacheRead;
1363
+ b.tokens.cacheWrite += u.cacheWrite;
1364
+ }
1321
1365
  }
1322
1366
  }
1323
1367
  }
@@ -1341,6 +1385,7 @@ function parseTranscript(rawLines) {
1341
1385
  lastAgentPreview,
1342
1386
  toolCallCount,
1343
1387
  turnCount,
1388
+ dailyBreakdown: Array.from(perDay.entries()).map(([day, v]) => ({ day, toolCalls: v.toolCalls, turns: v.turns, tokens: v.tokens })).sort((a, b) => a.day.localeCompare(b.day)),
1344
1389
  airTimeMs,
1345
1390
  activeSegments,
1346
1391
  linesAdded,
@@ -1359,6 +1404,7 @@ var init_parser = __esm({
1359
1404
  "../parser/dist/parser.js"() {
1360
1405
  "use strict";
1361
1406
  init_user_input();
1407
+ init_analytics();
1362
1408
  BLANK_USAGE2 = { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 };
1363
1409
  TEAMMATE_MSG_RE = /^\s*<teammate-message\s+teammate_id="([^"]+)"[^>]*>([\s\S]*?)<\/teammate-message>/;
1364
1410
  }
@@ -1632,7 +1678,7 @@ async function loadCalibrationEvents(root = DEFAULT_ROOT) {
1632
1678
  out.sort((a, b) => a.ts.localeCompare(b.ts));
1633
1679
  return out;
1634
1680
  }
1635
- function aggregateUsageFromLines(lines, seenKeys, usage) {
1681
+ function aggregateUsageFromLines(lines, seenKeys, usage, perDay, fallbackDay) {
1636
1682
  for (const raw of lines) {
1637
1683
  if (!raw || typeof raw !== "object")
1638
1684
  continue;
@@ -1652,35 +1698,85 @@ function aggregateUsageFromLines(lines, seenKeys, usage) {
1652
1698
  const u = m.usage;
1653
1699
  if (u) {
1654
1700
  const toNum = (v) => typeof v === "number" ? v : 0;
1655
- usage.input += toNum(u.input_tokens);
1656
- usage.output += toNum(u.output_tokens);
1657
- usage.cacheRead += toNum(u.cache_read_input_tokens);
1658
- usage.cacheWrite += toNum(u.cache_creation_input_tokens);
1701
+ const inp = toNum(u.input_tokens);
1702
+ const out = toNum(u.output_tokens);
1703
+ const cr = toNum(u.cache_read_input_tokens);
1704
+ const cw = toNum(u.cache_creation_input_tokens);
1705
+ usage.input += inp;
1706
+ usage.output += out;
1707
+ usage.cacheRead += cr;
1708
+ usage.cacheWrite += cw;
1709
+ if (perDay) {
1710
+ let day;
1711
+ const ts = typeof r.timestamp === "string" ? r.timestamp : void 0;
1712
+ if (ts) {
1713
+ const ms = Date.parse(ts);
1714
+ if (!Number.isNaN(ms))
1715
+ day = toLocalDay(ms);
1716
+ }
1717
+ day = day ?? fallbackDay;
1718
+ if (day) {
1719
+ let d = perDay.get(day);
1720
+ if (!d) {
1721
+ d = { ...BLANK_USAGE3 };
1722
+ perDay.set(day, d);
1723
+ }
1724
+ d.input += inp;
1725
+ d.output += out;
1726
+ d.cacheRead += cr;
1727
+ d.cacheWrite += cw;
1728
+ }
1729
+ }
1659
1730
  }
1660
1731
  }
1661
1732
  }
1662
- async function computeSessionUsageWithSubagents(parentLines, projectDirPath, sessionId) {
1733
+ async function computeSessionUsageWithSubagents(parentLines, projectDirPath, sessionId, fallbackDay) {
1663
1734
  const usage = { ...BLANK_USAGE3 };
1664
1735
  const seenKeys = /* @__PURE__ */ new Set();
1665
- aggregateUsageFromLines(parentLines, seenKeys, usage);
1736
+ const perDay = /* @__PURE__ */ new Map();
1737
+ aggregateUsageFromLines(parentLines, seenKeys, usage, perDay, fallbackDay);
1666
1738
  const subagentsDir = path.join(projectDirPath, sessionId, "subagents");
1667
1739
  let entries;
1668
1740
  try {
1669
1741
  entries = await fs.readdir(subagentsDir);
1670
1742
  } catch {
1671
- return usage;
1743
+ return { usage, perDay };
1672
1744
  }
1673
1745
  const jsonlFiles = entries.filter((f) => f.endsWith(".jsonl"));
1674
1746
  if (jsonlFiles.length === 0)
1675
- return usage;
1747
+ return { usage, perDay };
1676
1748
  await Promise.all(jsonlFiles.map(async (f) => {
1677
1749
  try {
1678
1750
  const lines = await readJsonlFile(path.join(subagentsDir, f));
1679
- aggregateUsageFromLines(lines, seenKeys, usage);
1751
+ aggregateUsageFromLines(lines, seenKeys, usage, perDay, fallbackDay);
1680
1752
  } catch {
1681
1753
  }
1682
1754
  }));
1683
- return usage;
1755
+ return { usage, perDay };
1756
+ }
1757
+ function mergeDailyTokens(base, perDayTokens, totalUsage) {
1758
+ const counts = new Map((base ?? []).map((d) => [d.day, d]));
1759
+ const days = /* @__PURE__ */ new Set([...counts.keys(), ...perDayTokens.keys()]);
1760
+ const out = [...days].sort((a, b) => a.localeCompare(b)).map((day) => ({
1761
+ day,
1762
+ toolCalls: counts.get(day)?.toolCalls ?? 0,
1763
+ turns: counts.get(day)?.turns ?? 0,
1764
+ tokens: { ...perDayTokens.get(day) ?? BLANK_USAGE3 }
1765
+ }));
1766
+ if (out.length > 0) {
1767
+ const summed = out.reduce((a, r) => ({
1768
+ input: a.input + r.tokens.input,
1769
+ output: a.output + r.tokens.output,
1770
+ cacheRead: a.cacheRead + r.tokens.cacheRead,
1771
+ cacheWrite: a.cacheWrite + r.tokens.cacheWrite
1772
+ }), { ...BLANK_USAGE3 });
1773
+ const first = out[0].tokens;
1774
+ first.input += totalUsage.input - summed.input;
1775
+ first.output += totalUsage.output - summed.output;
1776
+ first.cacheRead += totalUsage.cacheRead - summed.cacheRead;
1777
+ first.cacheWrite += totalUsage.cacheWrite - summed.cacheWrite;
1778
+ }
1779
+ return out;
1684
1780
  }
1685
1781
  async function scanWorkflowAggregate(projectDirPath, sessionId) {
1686
1782
  const dir = path.join(projectDirPath, sessionId, "workflows");
@@ -1738,7 +1834,10 @@ async function getCachedMeta(f) {
1738
1834
  const { meta } = parseTranscript(rawLines);
1739
1835
  const sessionId = sessionIdFromFileName(f.fileName);
1740
1836
  const projectDirPath = path.dirname(f.fullPath);
1741
- meta.totalUsage = await computeSessionUsageWithSubagents(rawLines, projectDirPath, sessionId);
1837
+ const fallbackDay = meta.firstTimestamp ? toLocalDay(Date.parse(meta.firstTimestamp)) : void 0;
1838
+ const { usage, perDay: perDayTokens } = await computeSessionUsageWithSubagents(rawLines, projectDirPath, sessionId, fallbackDay);
1839
+ meta.totalUsage = usage;
1840
+ meta.dailyBreakdown = mergeDailyTokens(meta.dailyBreakdown, perDayTokens, usage);
1742
1841
  const wf = await scanWorkflowAggregate(projectDirPath, sessionId);
1743
1842
  const full = {
1744
1843
  ...meta,
@@ -5471,16 +5570,12 @@ function bucketToRollup(b) {
5471
5570
  };
5472
5571
  }
5473
5572
  function buildRollupsForRange(sessions, sinceDay) {
5474
- const buckets = dailyActivity(sessions);
5475
5573
  const startCounts = /* @__PURE__ */ new Map();
5476
5574
  for (const s of sessions) {
5477
5575
  const d = sessionDay(s);
5478
5576
  if (d) startCounts.set(d, (startCounts.get(d) ?? 0) + 1);
5479
5577
  }
5480
- return buckets.filter((b) => !sinceDay || b.date >= sinceDay).map((b) => ({
5481
- ...bucketToRollup(b),
5482
- sessions: startCounts.get(b.date) ?? 0
5483
- }));
5578
+ return dailyActivity(sessions).filter((b) => !sinceDay || b.date >= sinceDay).map((b) => ({ ...bucketToRollup(b), uniqueSessions: startCounts.get(b.date) ?? 0 }));
5484
5579
  }
5485
5580
  function dayBoundsMs(day) {
5486
5581
  const [y, m, d] = day.split("-").map(Number);
@@ -15051,14 +15146,14 @@ async function getUpdateAvailability() {
15051
15146
  if (isDevMode()) return null;
15052
15147
  const latest = await fetchLatestVersion();
15053
15148
  if (latest === null) return {
15054
- current: "0.12.0",
15149
+ current: "0.12.1",
15055
15150
  latest: null,
15056
15151
  updateAvailable: false
15057
15152
  };
15058
15153
  return {
15059
- current: "0.12.0",
15154
+ current: "0.12.1",
15060
15155
  latest,
15061
- updateAvailable: shouldUpdate("0.12.0", latest)
15156
+ updateAvailable: shouldUpdate("0.12.1", latest)
15062
15157
  };
15063
15158
  }
15064
15159
 
package/dist/index.js CHANGED
@@ -176,7 +176,19 @@ function dailyActivity(sessions) {
176
176
  };
177
177
  for (const s of sessions) {
178
178
  const startDay = sessionDay(s);
179
- if (startDay) {
179
+ if (s.dailyBreakdown && s.dailyBreakdown.length > 0) {
180
+ for (const d of s.dailyBreakdown) {
181
+ const bucket = touchBucket(d.day);
182
+ bucket.toolCalls += d.toolCalls;
183
+ bucket.turns += d.turns;
184
+ bucket.tokens.input += d.tokens.input;
185
+ bucket.tokens.output += d.tokens.output;
186
+ bucket.tokens.cacheRead += d.tokens.cacheRead;
187
+ bucket.tokens.cacheWrite += d.tokens.cacheWrite;
188
+ }
189
+ if (startDay)
190
+ touchBucket(startDay).durationMs += s.durationMs ?? 0;
191
+ } else if (startDay) {
180
192
  const bucket = touchBucket(startDay);
181
193
  bucket.toolCalls += s.toolCallCount ?? 0;
182
194
  bucket.turns += s.turnCount ?? 0;
@@ -186,31 +198,30 @@ function dailyActivity(sessions) {
186
198
  bucket.tokens.cacheWrite += s.totalUsage.cacheWrite;
187
199
  bucket.durationMs += s.durationMs ?? 0;
188
200
  }
201
+ const presenceDays = /* @__PURE__ */ new Set();
189
202
  const segments = s.activeSegments;
190
203
  if (segments && segments.length > 0) {
191
- const touchedDays = /* @__PURE__ */ new Set();
192
204
  for (const seg of segments) {
193
205
  let cur = seg.startMs;
194
206
  while (cur < seg.endMs) {
195
207
  const day2 = toLocalDay(cur);
196
- touchedDays.add(day2);
208
+ presenceDays.add(day2);
197
209
  const d = new Date(cur);
198
210
  d.setHours(24, 0, 0, 0);
199
211
  const dayEndMs = Math.min(d.getTime(), seg.endMs);
200
- const bucket = touchBucket(day2);
201
- bucket.airTimeMs += dayEndMs - cur;
212
+ touchBucket(day2).airTimeMs += dayEndMs - cur;
202
213
  cur = dayEndMs;
203
214
  }
204
215
  }
205
- for (const day2 of touchedDays) {
206
- const bucket = touchBucket(day2);
207
- bucket.sessions++;
208
- }
209
216
  } else if (startDay) {
210
- const bucket = touchBucket(startDay);
211
- bucket.sessions++;
212
- bucket.airTimeMs += s.airTimeMs ?? 0;
217
+ presenceDays.add(startDay);
218
+ touchBucket(startDay).airTimeMs += s.airTimeMs ?? 0;
213
219
  }
220
+ if (s.dailyBreakdown)
221
+ for (const d of s.dailyBreakdown)
222
+ presenceDays.add(d.day);
223
+ for (const day2 of presenceDays)
224
+ touchBucket(day2).sessions++;
214
225
  }
215
226
  const range = minDay && maxDay ? daysBetween(minDay, maxDay) : [];
216
227
  const out = [];
@@ -1255,9 +1266,31 @@ function parseTranscript(rawLines) {
1255
1266
  let linesAdded = 0;
1256
1267
  let linesRemoved = 0;
1257
1268
  const filesEdited = /* @__PURE__ */ new Set();
1269
+ const perDay = /* @__PURE__ */ new Map();
1270
+ const fallbackDay = startMs !== void 0 ? toLocalDay(startMs) : void 0;
1271
+ const dayBucket = (ts) => {
1272
+ let day2;
1273
+ if (ts) {
1274
+ const ms = Date.parse(ts);
1275
+ if (!Number.isNaN(ms))
1276
+ day2 = toLocalDay(ms);
1277
+ }
1278
+ day2 = day2 ?? fallbackDay;
1279
+ if (!day2)
1280
+ return void 0;
1281
+ let b = perDay.get(day2);
1282
+ if (!b) {
1283
+ b = { toolCalls: 0, turns: 0, tokens: { ...BLANK_USAGE2 } };
1284
+ perDay.set(day2, b);
1285
+ }
1286
+ return b;
1287
+ };
1258
1288
  for (const e of events) {
1259
1289
  if (e.role === "tool-call") {
1260
1290
  toolCallCount++;
1291
+ const tcDay = dayBucket(e.timestamp);
1292
+ if (tcDay)
1293
+ tcDay.toolCalls++;
1261
1294
  const toolBlock = e.blocks.find((b) => b && b.type === "tool_use");
1262
1295
  if (toolBlock) {
1263
1296
  const input = toolBlock.input ?? {};
@@ -1294,6 +1327,9 @@ function parseTranscript(rawLines) {
1294
1327
  firstUserPreview = e.teammateMessage ? e.teammateMessage.body : e.preview;
1295
1328
  }
1296
1329
  turnCount++;
1330
+ const turnDay = dayBucket(e.timestamp);
1331
+ if (turnDay)
1332
+ turnDay.turns++;
1297
1333
  lastUserPreview = e.preview;
1298
1334
  }
1299
1335
  }
@@ -1335,6 +1371,14 @@ function parseTranscript(rawLines) {
1335
1371
  totalUsage.output += u.output;
1336
1372
  totalUsage.cacheRead += u.cacheRead;
1337
1373
  totalUsage.cacheWrite += u.cacheWrite;
1374
+ const ts = typeof o.timestamp === "string" ? o.timestamp : void 0;
1375
+ const b = dayBucket(ts);
1376
+ if (b) {
1377
+ b.tokens.input += u.input;
1378
+ b.tokens.output += u.output;
1379
+ b.tokens.cacheRead += u.cacheRead;
1380
+ b.tokens.cacheWrite += u.cacheWrite;
1381
+ }
1338
1382
  }
1339
1383
  }
1340
1384
  }
@@ -1358,6 +1402,7 @@ function parseTranscript(rawLines) {
1358
1402
  lastAgentPreview,
1359
1403
  toolCallCount,
1360
1404
  turnCount,
1405
+ dailyBreakdown: Array.from(perDay.entries()).map(([day2, v]) => ({ day: day2, toolCalls: v.toolCalls, turns: v.turns, tokens: v.tokens })).sort((a, b) => a.day.localeCompare(b.day)),
1361
1406
  airTimeMs,
1362
1407
  activeSegments,
1363
1408
  linesAdded,
@@ -1376,6 +1421,7 @@ var init_parser = __esm({
1376
1421
  "../parser/dist/parser.js"() {
1377
1422
  "use strict";
1378
1423
  init_user_input();
1424
+ init_analytics();
1379
1425
  BLANK_USAGE2 = { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 };
1380
1426
  TEAMMATE_MSG_RE = /^\s*<teammate-message\s+teammate_id="([^"]+)"[^>]*>([\s\S]*?)<\/teammate-message>/;
1381
1427
  }
@@ -1649,7 +1695,7 @@ async function loadCalibrationEvents(root = DEFAULT_ROOT) {
1649
1695
  out.sort((a, b) => a.ts.localeCompare(b.ts));
1650
1696
  return out;
1651
1697
  }
1652
- function aggregateUsageFromLines(lines, seenKeys, usage2) {
1698
+ function aggregateUsageFromLines(lines, seenKeys, usage2, perDay, fallbackDay) {
1653
1699
  for (const raw of lines) {
1654
1700
  if (!raw || typeof raw !== "object")
1655
1701
  continue;
@@ -1669,35 +1715,85 @@ function aggregateUsageFromLines(lines, seenKeys, usage2) {
1669
1715
  const u = m.usage;
1670
1716
  if (u) {
1671
1717
  const toNum = (v) => typeof v === "number" ? v : 0;
1672
- usage2.input += toNum(u.input_tokens);
1673
- usage2.output += toNum(u.output_tokens);
1674
- usage2.cacheRead += toNum(u.cache_read_input_tokens);
1675
- usage2.cacheWrite += toNum(u.cache_creation_input_tokens);
1718
+ const inp = toNum(u.input_tokens);
1719
+ const out = toNum(u.output_tokens);
1720
+ const cr = toNum(u.cache_read_input_tokens);
1721
+ const cw = toNum(u.cache_creation_input_tokens);
1722
+ usage2.input += inp;
1723
+ usage2.output += out;
1724
+ usage2.cacheRead += cr;
1725
+ usage2.cacheWrite += cw;
1726
+ if (perDay) {
1727
+ let day2;
1728
+ const ts = typeof r.timestamp === "string" ? r.timestamp : void 0;
1729
+ if (ts) {
1730
+ const ms = Date.parse(ts);
1731
+ if (!Number.isNaN(ms))
1732
+ day2 = toLocalDay(ms);
1733
+ }
1734
+ day2 = day2 ?? fallbackDay;
1735
+ if (day2) {
1736
+ let d = perDay.get(day2);
1737
+ if (!d) {
1738
+ d = { ...BLANK_USAGE3 };
1739
+ perDay.set(day2, d);
1740
+ }
1741
+ d.input += inp;
1742
+ d.output += out;
1743
+ d.cacheRead += cr;
1744
+ d.cacheWrite += cw;
1745
+ }
1746
+ }
1676
1747
  }
1677
1748
  }
1678
1749
  }
1679
- async function computeSessionUsageWithSubagents(parentLines, projectDirPath, sessionId) {
1750
+ async function computeSessionUsageWithSubagents(parentLines, projectDirPath, sessionId, fallbackDay) {
1680
1751
  const usage2 = { ...BLANK_USAGE3 };
1681
1752
  const seenKeys = /* @__PURE__ */ new Set();
1682
- aggregateUsageFromLines(parentLines, seenKeys, usage2);
1753
+ const perDay = /* @__PURE__ */ new Map();
1754
+ aggregateUsageFromLines(parentLines, seenKeys, usage2, perDay, fallbackDay);
1683
1755
  const subagentsDir = path.join(projectDirPath, sessionId, "subagents");
1684
1756
  let entries2;
1685
1757
  try {
1686
1758
  entries2 = await fs.readdir(subagentsDir);
1687
1759
  } catch {
1688
- return usage2;
1760
+ return { usage: usage2, perDay };
1689
1761
  }
1690
1762
  const jsonlFiles = entries2.filter((f) => f.endsWith(".jsonl"));
1691
1763
  if (jsonlFiles.length === 0)
1692
- return usage2;
1764
+ return { usage: usage2, perDay };
1693
1765
  await Promise.all(jsonlFiles.map(async (f) => {
1694
1766
  try {
1695
1767
  const lines = await readJsonlFile(path.join(subagentsDir, f));
1696
- aggregateUsageFromLines(lines, seenKeys, usage2);
1768
+ aggregateUsageFromLines(lines, seenKeys, usage2, perDay, fallbackDay);
1697
1769
  } catch {
1698
1770
  }
1699
1771
  }));
1700
- return usage2;
1772
+ return { usage: usage2, perDay };
1773
+ }
1774
+ function mergeDailyTokens(base, perDayTokens, totalUsage) {
1775
+ const counts = new Map((base ?? []).map((d) => [d.day, d]));
1776
+ const days = /* @__PURE__ */ new Set([...counts.keys(), ...perDayTokens.keys()]);
1777
+ const out = [...days].sort((a, b) => a.localeCompare(b)).map((day2) => ({
1778
+ day: day2,
1779
+ toolCalls: counts.get(day2)?.toolCalls ?? 0,
1780
+ turns: counts.get(day2)?.turns ?? 0,
1781
+ tokens: { ...perDayTokens.get(day2) ?? BLANK_USAGE3 }
1782
+ }));
1783
+ if (out.length > 0) {
1784
+ const summed = out.reduce((a, r) => ({
1785
+ input: a.input + r.tokens.input,
1786
+ output: a.output + r.tokens.output,
1787
+ cacheRead: a.cacheRead + r.tokens.cacheRead,
1788
+ cacheWrite: a.cacheWrite + r.tokens.cacheWrite
1789
+ }), { ...BLANK_USAGE3 });
1790
+ const first = out[0].tokens;
1791
+ first.input += totalUsage.input - summed.input;
1792
+ first.output += totalUsage.output - summed.output;
1793
+ first.cacheRead += totalUsage.cacheRead - summed.cacheRead;
1794
+ first.cacheWrite += totalUsage.cacheWrite - summed.cacheWrite;
1795
+ }
1796
+ return out;
1701
1797
  }
1702
1798
  async function scanWorkflowAggregate(projectDirPath, sessionId) {
1703
1799
  const dir = path.join(projectDirPath, sessionId, "workflows");
@@ -1755,7 +1851,10 @@ async function getCachedMeta(f) {
1755
1851
  const { meta } = parseTranscript(rawLines);
1756
1852
  const sessionId = sessionIdFromFileName(f.fileName);
1757
1853
  const projectDirPath = path.dirname(f.fullPath);
1758
- meta.totalUsage = await computeSessionUsageWithSubagents(rawLines, projectDirPath, sessionId);
1854
+ const fallbackDay = meta.firstTimestamp ? toLocalDay(Date.parse(meta.firstTimestamp)) : void 0;
1855
+ const { usage: usage2, perDay: perDayTokens } = await computeSessionUsageWithSubagents(rawLines, projectDirPath, sessionId, fallbackDay);
1856
+ meta.totalUsage = usage2;
1857
+ meta.dailyBreakdown = mergeDailyTokens(meta.dailyBreakdown, perDayTokens, usage2);
1759
1858
  const wf = await scanWorkflowAggregate(projectDirPath, sessionId);
1760
1859
  const full = {
1761
1860
  ...meta,
@@ -4769,9 +4868,9 @@ Installed: ${PACKAGE_NAME}@${verify.installedVersion} at ${verify.installedPath
4769
4868
  console.warn(
4770
4869
  ` \u2022 reinstall in the correct Node env: 'npm install -g ${PACKAGE_NAME}@latest'`
4771
4870
  );
4772
- } else if (verify.installedVersion !== "0.12.0") {
4871
+ } else if (verify.installedVersion !== "0.12.1") {
4773
4872
  console.log(
4774
- ` \u2192 This process is still running ${"0.12.0"}. Next invocation will use ${verify.installedVersion}.`
4873
+ ` \u2192 This process is still running ${"0.12.1"}. Next invocation will use ${verify.installedVersion}.`
4775
4874
  );
4776
4875
  }
4777
4876
  }
@@ -4806,14 +4905,14 @@ async function getUpdateAvailability() {
4806
4905
  if (isDevMode()) return null;
4807
4906
  const latest = await fetchLatestVersion();
4808
4907
  if (latest === null) return {
4809
- current: "0.12.0",
4908
+ current: "0.12.1",
4810
4909
  latest: null,
4811
4910
  updateAvailable: false
4812
4911
  };
4813
4912
  return {
4814
- current: "0.12.0",
4913
+ current: "0.12.1",
4815
4914
  latest,
4816
- updateAvailable: shouldUpdate("0.12.0", latest)
4915
+ updateAvailable: shouldUpdate("0.12.1", latest)
4817
4916
  };
4818
4917
  }
4819
4918
  async function checkForUpdate() {
@@ -4903,7 +5002,7 @@ async function restartServices(state) {
4903
5002
  }
4904
5003
  async function forceUpdate() {
4905
5004
  const latest = await fetchLatestVersion();
4906
- const current = "0.12.0";
5005
+ const current = "0.12.1";
4907
5006
  if (latest === null) {
4908
5007
  console.error("Could not reach npm registry. Check your network.");
4909
5008
  process.exit(1);
@@ -15719,16 +15818,12 @@ function bucketToRollup(b) {
15719
15818
  };
15720
15819
  }
15721
15820
  function buildRollupsForRange(sessions, sinceDay) {
15722
- const buckets = dailyActivity(sessions);
15723
15821
  const startCounts = /* @__PURE__ */ new Map();
15724
15822
  for (const s of sessions) {
15725
15823
  const d = sessionDay(s);
15726
15824
  if (d) startCounts.set(d, (startCounts.get(d) ?? 0) + 1);
15727
15825
  }
15728
- return buckets.filter((b) => !sinceDay || b.date >= sinceDay).map((b) => ({
15729
- ...bucketToRollup(b),
15730
- sessions: startCounts.get(b.date) ?? 0
15731
- }));
15826
+ return dailyActivity(sessions).filter((b) => !sinceDay || b.date >= sinceDay).map((b) => ({ ...bucketToRollup(b), uniqueSessions: startCounts.get(b.date) ?? 0 }));
15732
15827
  }
15733
15828
  function dayBoundsMs(day2) {
15734
15829
  const [y, m, d] = day2.split("-").map(Number);
@@ -17531,7 +17626,7 @@ async function main() {
17531
17626
  case "version":
17532
17627
  case "--version":
17533
17628
  case "-v":
17534
- console.log(`fleetlens ${"0.12.0"}`);
17629
+ console.log(`fleetlens ${"0.12.1"}`);
17535
17630
  break;
17536
17631
  case "help":
17537
17632
  case "--help":
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fleetlens",
3
- "version": "0.12.0",
3
+ "version": "0.12.1",
4
4
  "description": "fleetlens — local-only dashboard and usage tracker for Claude Code sessions and agent fleets",
5
5
  "license": "MIT",
6
6
  "repository": {