fleetlens 1.0.18 → 1.0.19

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 (199) 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 +1 -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/agent/page.js +1 -1
  15. package/app/apps/web/.next/server/app/agent/page.js.nft.json +1 -1
  16. package/app/apps/web/.next/server/app/agent/page_client-reference-manifest.js +1 -1
  17. package/app/apps/web/.next/server/app/api/agent/chats/[id]/events/route.js +3 -3
  18. package/app/apps/web/.next/server/app/api/agent/chats/[id]/events/route.js.nft.json +1 -1
  19. package/app/apps/web/.next/server/app/api/agent/chats/[id]/messages/route.js +2 -2
  20. package/app/apps/web/.next/server/app/api/agent/chats/[id]/messages/route.js.nft.json +1 -1
  21. package/app/apps/web/.next/server/app/api/agent/chats/[id]/route.js +3 -3
  22. package/app/apps/web/.next/server/app/api/agent/chats/[id]/route.js.nft.json +1 -1
  23. package/app/apps/web/.next/server/app/api/agent/chats/[id]/stop/route.js +2 -2
  24. package/app/apps/web/.next/server/app/api/agent/chats/[id]/stop/route.js.nft.json +1 -1
  25. package/app/apps/web/.next/server/app/api/agent/chats/route.js +3 -3
  26. package/app/apps/web/.next/server/app/api/agent/chats/route.js.nft.json +1 -1
  27. package/app/apps/web/.next/server/app/api/agent/index/route.js +1 -1
  28. package/app/apps/web/.next/server/app/api/agent/index/route.js.nft.json +1 -1
  29. package/app/apps/web/.next/server/app/api/agent/mcp/route.js +1 -1
  30. package/app/apps/web/.next/server/app/api/agent/mcp/route.js.nft.json +1 -1
  31. package/app/apps/web/.next/server/app/api/agent/suggestions/route.js +2 -2
  32. package/app/apps/web/.next/server/app/api/agent/suggestions/route.js.nft.json +1 -1
  33. package/app/apps/web/.next/server/app/api/ask/route.js +2 -2
  34. package/app/apps/web/.next/server/app/api/ask/route.js.nft.json +1 -1
  35. package/app/apps/web/.next/server/app/api/digest/day/[date]/route.js +3 -3
  36. package/app/apps/web/.next/server/app/api/digest/day/[date]/route.js.nft.json +1 -1
  37. package/app/apps/web/.next/server/app/api/digest/month/[yearMonth]/route.js +3 -3
  38. package/app/apps/web/.next/server/app/api/digest/month/[yearMonth]/route.js.nft.json +1 -1
  39. package/app/apps/web/.next/server/app/api/digest/month-index/route.js +2 -2
  40. package/app/apps/web/.next/server/app/api/digest/month-index/route.js.nft.json +1 -1
  41. package/app/apps/web/.next/server/app/api/digest/week/[startDate]/route.js +3 -3
  42. package/app/apps/web/.next/server/app/api/digest/week/[startDate]/route.js.nft.json +1 -1
  43. package/app/apps/web/.next/server/app/api/digest/week-index/route.js +2 -2
  44. package/app/apps/web/.next/server/app/api/digest/week-index/route.js.nft.json +1 -1
  45. package/app/apps/web/.next/server/app/api/events/route.js +1 -1
  46. package/app/apps/web/.next/server/app/api/events/route.js.nft.json +1 -1
  47. package/app/apps/web/.next/server/app/api/jobs/route.js +1 -1
  48. package/app/apps/web/.next/server/app/api/jobs/route.js.nft.json +1 -1
  49. package/app/apps/web/.next/server/app/api/pdf/[key]/route.js +2 -2
  50. package/app/apps/web/.next/server/app/api/pdf/[key]/route.js.nft.json +1 -1
  51. package/app/apps/web/.next/server/app/api/projects/open-folder/route.js +1 -1
  52. package/app/apps/web/.next/server/app/api/projects/open-folder/route.js.nft.json +1 -1
  53. package/app/apps/web/.next/server/app/api/runs/[runId]/route.js +1 -1
  54. package/app/apps/web/.next/server/app/api/runs/[runId]/route.js.nft.json +1 -1
  55. package/app/apps/web/.next/server/app/api/runs/[runId]/stream/route.js +1 -1
  56. package/app/apps/web/.next/server/app/api/runs/[runId]/stream/route.js.nft.json +1 -1
  57. package/app/apps/web/.next/server/app/api/runs/route.js +1 -1
  58. package/app/apps/web/.next/server/app/api/runs/route.js.nft.json +1 -1
  59. package/app/apps/web/.next/server/app/api/settings/credentials/route.js +1 -1
  60. package/app/apps/web/.next/server/app/api/settings/credentials/route.js.nft.json +1 -1
  61. package/app/apps/web/.next/server/app/api/settings/route.js +3 -3
  62. package/app/apps/web/.next/server/app/api/settings/route.js.nft.json +1 -1
  63. package/app/apps/web/.next/server/app/api/team/autostart/route.js +1 -1
  64. package/app/apps/web/.next/server/app/api/team/autostart/route.js.nft.json +1 -1
  65. package/app/apps/web/.next/server/app/api/team/onboarding/start/route.js +2 -2
  66. package/app/apps/web/.next/server/app/api/team/onboarding/start/route.js.nft.json +1 -1
  67. package/app/apps/web/.next/server/app/api/team/sync-projects/route.js +1 -1
  68. package/app/apps/web/.next/server/app/api/team/sync-projects/route.js.nft.json +1 -1
  69. package/app/apps/web/.next/server/app/api/workflow-agent/route.js +1 -1
  70. package/app/apps/web/.next/server/app/api/workflow-agent/route.js.nft.json +1 -1
  71. package/app/apps/web/.next/server/app/changelog/page.js +1 -1
  72. package/app/apps/web/.next/server/app/changelog/page.js.nft.json +1 -1
  73. package/app/apps/web/.next/server/app/changelog/page_client-reference-manifest.js +1 -1
  74. package/app/apps/web/.next/server/app/day/[date]/page.js +1 -1
  75. package/app/apps/web/.next/server/app/day/[date]/page.js.nft.json +1 -1
  76. package/app/apps/web/.next/server/app/day/[date]/page_client-reference-manifest.js +1 -1
  77. package/app/apps/web/.next/server/app/day/page.js +1 -1
  78. package/app/apps/web/.next/server/app/day/page.js.nft.json +1 -1
  79. package/app/apps/web/.next/server/app/day/page_client-reference-manifest.js +1 -1
  80. package/app/apps/web/.next/server/app/digest/[date]/page.js +1 -1
  81. package/app/apps/web/.next/server/app/digest/[date]/page.js.nft.json +1 -1
  82. package/app/apps/web/.next/server/app/digest/[date]/page_client-reference-manifest.js +1 -1
  83. package/app/apps/web/.next/server/app/digest/page.js +1 -1
  84. package/app/apps/web/.next/server/app/digest/page.js.nft.json +1 -1
  85. package/app/apps/web/.next/server/app/digest/page_client-reference-manifest.js +1 -1
  86. package/app/apps/web/.next/server/app/insights/[key]/page.js +1 -1
  87. package/app/apps/web/.next/server/app/insights/[key]/page.js.nft.json +1 -1
  88. package/app/apps/web/.next/server/app/insights/[key]/page_client-reference-manifest.js +1 -1
  89. package/app/apps/web/.next/server/app/insights/page.js +1 -1
  90. package/app/apps/web/.next/server/app/insights/page.js.nft.json +1 -1
  91. package/app/apps/web/.next/server/app/insights/page_client-reference-manifest.js +1 -1
  92. package/app/apps/web/.next/server/app/page.js +1 -1
  93. package/app/apps/web/.next/server/app/page.js.nft.json +1 -1
  94. package/app/apps/web/.next/server/app/page_client-reference-manifest.js +1 -1
  95. package/app/apps/web/.next/server/app/parallelism/page.js +1 -1
  96. package/app/apps/web/.next/server/app/parallelism/page.js.nft.json +1 -1
  97. package/app/apps/web/.next/server/app/parallelism/page_client-reference-manifest.js +1 -1
  98. package/app/apps/web/.next/server/app/print/[key]/page.js +1 -1
  99. package/app/apps/web/.next/server/app/print/[key]/page.js.nft.json +1 -1
  100. package/app/apps/web/.next/server/app/print/[key]/page_client-reference-manifest.js +1 -1
  101. package/app/apps/web/.next/server/app/projects/[slug]/page.js +1 -1
  102. package/app/apps/web/.next/server/app/projects/[slug]/page.js.nft.json +1 -1
  103. package/app/apps/web/.next/server/app/projects/[slug]/page_client-reference-manifest.js +1 -1
  104. package/app/apps/web/.next/server/app/projects/page.js +1 -1
  105. package/app/apps/web/.next/server/app/projects/page.js.nft.json +1 -1
  106. package/app/apps/web/.next/server/app/projects/page_client-reference-manifest.js +1 -1
  107. package/app/apps/web/.next/server/app/runs/page.js +1 -1
  108. package/app/apps/web/.next/server/app/runs/page.js.nft.json +1 -1
  109. package/app/apps/web/.next/server/app/runs/page_client-reference-manifest.js +1 -1
  110. package/app/apps/web/.next/server/app/sessions/[id]/page.js +1 -1
  111. package/app/apps/web/.next/server/app/sessions/[id]/page.js.nft.json +1 -1
  112. package/app/apps/web/.next/server/app/sessions/[id]/page_client-reference-manifest.js +1 -1
  113. package/app/apps/web/.next/server/app/sessions/page.js +1 -1
  114. package/app/apps/web/.next/server/app/sessions/page.js.nft.json +1 -1
  115. package/app/apps/web/.next/server/app/sessions/page_client-reference-manifest.js +1 -1
  116. package/app/apps/web/.next/server/app/settings/page.js +1 -1
  117. package/app/apps/web/.next/server/app/settings/page.js.nft.json +1 -1
  118. package/app/apps/web/.next/server/app/settings/page_client-reference-manifest.js +1 -1
  119. package/app/apps/web/.next/server/app/team/onboarding/page.js +1 -1
  120. package/app/apps/web/.next/server/app/team/onboarding/page.js.nft.json +1 -1
  121. package/app/apps/web/.next/server/app/team/onboarding/page_client-reference-manifest.js +1 -1
  122. package/app/apps/web/.next/server/app/team/page.js +1 -1
  123. package/app/apps/web/.next/server/app/team/page.js.nft.json +1 -1
  124. package/app/apps/web/.next/server/app/team/page_client-reference-manifest.js +1 -1
  125. package/app/apps/web/.next/server/app/usage/page.js +1 -1
  126. package/app/apps/web/.next/server/app/usage/page.js.nft.json +1 -1
  127. package/app/apps/web/.next/server/app/usage/page_client-reference-manifest.js +1 -1
  128. package/app/apps/web/.next/server/chunks/{[externals]__0vj7dsg._.js → [externals]__009b9dp._.js} +2 -2
  129. package/app/apps/web/.next/server/chunks/{[root-of-the-server]__0uiom2m._.js → [root-of-the-server]__0-m_ww1._.js} +4 -4
  130. package/app/apps/web/.next/server/chunks/[root-of-the-server]__02.51sr._.js +1 -1
  131. package/app/apps/web/.next/server/chunks/[root-of-the-server]__04kgta3._.js +3 -0
  132. package/app/apps/web/.next/server/chunks/{[root-of-the-server]__0-09rjv._.js → [root-of-the-server]__04v_wzy._.js} +3 -3
  133. package/app/apps/web/.next/server/chunks/[root-of-the-server]__04zf.rz._.js +3 -0
  134. package/app/apps/web/.next/server/chunks/{[root-of-the-server]__0mcer3z._.js → [root-of-the-server]__05qjsez._.js} +3 -3
  135. package/app/apps/web/.next/server/chunks/{[root-of-the-server]__07b5796._.js → [root-of-the-server]__06r8ow3._.js} +3 -3
  136. package/app/apps/web/.next/server/chunks/[root-of-the-server]__0b6-z85._.js +3 -0
  137. package/app/apps/web/.next/server/chunks/[root-of-the-server]__0c2ff1o._.js +3 -0
  138. package/app/apps/web/.next/server/chunks/[root-of-the-server]__0dk36uf._.js +3 -0
  139. package/app/apps/web/.next/server/chunks/{[root-of-the-server]__057w7kr._.js → [root-of-the-server]__0e.u3kk._.js} +4 -4
  140. package/app/apps/web/.next/server/chunks/[root-of-the-server]__0err1au._.js +3 -0
  141. package/app/apps/web/.next/server/chunks/[root-of-the-server]__0gf69vt._.js +3 -0
  142. package/app/apps/web/.next/server/chunks/{[root-of-the-server]__0uf_ch4._.js → [root-of-the-server]__0grbvrx._.js} +4 -4
  143. package/app/apps/web/.next/server/chunks/{[root-of-the-server]__0o9lsie._.js → [root-of-the-server]__0hltqxa._.js} +5 -5
  144. package/app/apps/web/.next/server/chunks/{[root-of-the-server]__067~im1._.js → [root-of-the-server]__0hmu6os._.js} +3 -3
  145. package/app/apps/web/.next/server/chunks/{[root-of-the-server]__08c24et._.js → [root-of-the-server]__0i0tt-w._.js} +3 -3
  146. package/app/apps/web/.next/server/chunks/[root-of-the-server]__0k_9_ug._.js +3 -0
  147. package/app/apps/web/.next/server/chunks/[root-of-the-server]__0loi1z7._.js +3 -0
  148. package/app/apps/web/.next/server/chunks/[root-of-the-server]__0nqkqln._.js +3 -0
  149. package/app/apps/web/.next/server/chunks/{[root-of-the-server]__0c7ght_._.js → [root-of-the-server]__0osa5o6._.js} +3 -3
  150. package/app/apps/web/.next/server/chunks/[root-of-the-server]__0ouoylv._.js +3 -0
  151. package/app/apps/web/.next/server/chunks/[root-of-the-server]__0y4-1qc._.js +3 -0
  152. package/app/apps/web/.next/server/chunks/[root-of-the-server]__0y99mwp._.js +3 -0
  153. package/app/apps/web/.next/server/chunks/[root-of-the-server]__0zab5mf._.js +21 -0
  154. package/app/apps/web/.next/server/chunks/[root-of-the-server]__0~s0tk_._.js +3 -0
  155. package/app/apps/web/.next/server/chunks/{[root-of-the-server]__12vjv4c._.js → [root-of-the-server]__125bt0f._.js} +2 -2
  156. package/app/apps/web/.next/server/chunks/node_modules_next_dist_esm_build_templates_app-route_02bw8.n.js +1 -1
  157. package/app/apps/web/.next/server/chunks/packages_entries_dist_node_0bckr7-.js +1 -1
  158. package/app/apps/web/.next/server/chunks/packages_parser_dist_06d9se1._.js +1 -1
  159. package/app/apps/web/.next/server/chunks/packages_parser_dist_10ihc3~._.js +1 -1
  160. package/app/apps/web/.next/server/chunks/ssr/[root-of-the-server]__060v2ui._.js +3 -0
  161. package/app/apps/web/.next/server/chunks/ssr/[root-of-the-server]__12s3gv9._.js +1 -1
  162. package/app/apps/web/.next/server/chunks/ssr/_0k8yioi._.js +1 -1
  163. package/app/apps/web/.next/server/chunks/ssr/apps_web_lib_changelog_ts_0n7_p1d._.js +1 -1
  164. package/app/apps/web/.next/server/chunks/ssr/apps_web_lib_changelog_ts_0nb5_-s._.js +1 -1
  165. package/app/apps/web/.next/server/chunks/ssr/packages_parser_dist_0mx_509._.js +1 -1
  166. package/app/apps/web/.next/server/middleware-build-manifest.js +3 -3
  167. package/app/apps/web/.next/server/middleware-manifest.json +5 -5
  168. package/app/apps/web/.next/server/pages/500.html +1 -1
  169. package/app/apps/web/.next/server/server-reference-manifest.js +1 -1
  170. package/app/apps/web/.next/server/server-reference-manifest.json +1 -1
  171. package/app/apps/web/.next/static/chunks/16j2bz7n9vbpl.js +1 -0
  172. package/app/apps/web/lib/changelog-data.generated.ts +1 -1
  173. package/app/apps/web/package.json +1 -1
  174. package/app/apps/web/tsconfig.tsbuildinfo +1 -1
  175. package/dist/daemon-worker.js +483 -314
  176. package/dist/index.js +338 -235
  177. package/menubar/Fleetlens.app/Contents/Info.plist +2 -2
  178. package/menubar/Fleetlens.app/Contents/MacOS/FleetlensMenubar +0 -0
  179. package/package.json +1 -1
  180. package/app/apps/web/.next/server/chunks/[root-of-the-server]__00n3f9y._.js +0 -3
  181. package/app/apps/web/.next/server/chunks/[root-of-the-server]__01oercw._.js +0 -21
  182. package/app/apps/web/.next/server/chunks/[root-of-the-server]__02zukjw._.js +0 -3
  183. package/app/apps/web/.next/server/chunks/[root-of-the-server]__06b4cj-._.js +0 -3
  184. package/app/apps/web/.next/server/chunks/[root-of-the-server]__07xaqv3._.js +0 -3
  185. package/app/apps/web/.next/server/chunks/[root-of-the-server]__08m2h38._.js +0 -3
  186. package/app/apps/web/.next/server/chunks/[root-of-the-server]__0kc9e1n._.js +0 -3
  187. package/app/apps/web/.next/server/chunks/[root-of-the-server]__0l5i8nk._.js +0 -3
  188. package/app/apps/web/.next/server/chunks/[root-of-the-server]__0mq0or2._.js +0 -3
  189. package/app/apps/web/.next/server/chunks/[root-of-the-server]__0ozooam._.js +0 -3
  190. package/app/apps/web/.next/server/chunks/[root-of-the-server]__0usaajs._.js +0 -3
  191. package/app/apps/web/.next/server/chunks/[root-of-the-server]__0zyh554._.js +0 -3
  192. package/app/apps/web/.next/server/chunks/[root-of-the-server]__0~4wgaf._.js +0 -3
  193. package/app/apps/web/.next/server/chunks/[root-of-the-server]__0~~bpcw._.js +0 -3
  194. package/app/apps/web/.next/server/chunks/[root-of-the-server]__10.g-w1._.js +0 -3
  195. package/app/apps/web/.next/server/chunks/ssr/[root-of-the-server]__0~.gwld._.js +0 -3
  196. package/app/apps/web/.next/static/chunks/17t_lnxxkqqrf.js +0 -1
  197. /package/app/apps/web/.next/static/{sxV6Ch245PGzvI7UkiFL0 → Z3xWgPPXC-h-hpfO9GTfl}/_buildManifest.js +0 -0
  198. /package/app/apps/web/.next/static/{sxV6Ch245PGzvI7UkiFL0 → Z3xWgPPXC-h-hpfO9GTfl}/_clientMiddlewareManifest.js +0 -0
  199. /package/app/apps/web/.next/static/{sxV6Ch245PGzvI7UkiFL0 → Z3xWgPPXC-h-hpfO9GTfl}/_ssgManifest.js +0 -0
@@ -1726,8 +1726,132 @@ var init_team = __esm({
1726
1726
  }
1727
1727
  });
1728
1728
 
1729
- // ../parser/dist/claude-code.js
1729
+ // ../parser/dist/jsonl-read.js
1730
+ import { closeSync, createReadStream, openSync, readSync, statSync as statSync3 } from "node:fs";
1730
1731
  import { promises as fs } from "node:fs";
1732
+ import { createInterface } from "node:readline";
1733
+ function jsonlFileTooLarge(sizeBytes) {
1734
+ return sizeBytes > MAX_JSONL_FILE_BYTES;
1735
+ }
1736
+ function pushLine(line, out) {
1737
+ const trimmed = line.trim();
1738
+ if (!trimmed)
1739
+ return;
1740
+ if (Buffer.byteLength(trimmed) > MAX_JSONL_LINE_BYTES)
1741
+ return;
1742
+ try {
1743
+ out.push(JSON.parse(trimmed));
1744
+ } catch {
1745
+ }
1746
+ }
1747
+ async function readJsonlFile(filePath) {
1748
+ const st = await fs.stat(filePath);
1749
+ if (jsonlFileTooLarge(st.size))
1750
+ throw new JsonlTooLargeError(filePath, st.size);
1751
+ const out = [];
1752
+ const rl = createInterface({
1753
+ input: createReadStream(filePath, { encoding: "utf8" }),
1754
+ crlfDelay: Infinity
1755
+ });
1756
+ let n = 0;
1757
+ for await (const line of rl) {
1758
+ pushLine(line, out);
1759
+ if (++n % 1e3 === 0)
1760
+ await Promise.resolve();
1761
+ }
1762
+ return out;
1763
+ }
1764
+ function readJsonlFileSync(filePath) {
1765
+ const st = statSync3(filePath);
1766
+ if (jsonlFileTooLarge(st.size))
1767
+ throw new JsonlTooLargeError(filePath, st.size);
1768
+ const fd = openSync(filePath, "r");
1769
+ const buf = Buffer.allocUnsafe(64 * 1024);
1770
+ let carry = Buffer.alloc(0);
1771
+ const out = [];
1772
+ try {
1773
+ for (; ; ) {
1774
+ const n = readSync(fd, buf, 0, buf.length, null);
1775
+ if (n === 0)
1776
+ break;
1777
+ const incoming = buf.subarray(0, n);
1778
+ const data = carry.length === 0 ? incoming : Buffer.concat([carry, incoming]);
1779
+ let start = 0;
1780
+ for (let i = 0; i < data.length; i++) {
1781
+ if (data[i] === 10) {
1782
+ pushLine(data.subarray(start, i).toString("utf8"), out);
1783
+ start = i + 1;
1784
+ }
1785
+ }
1786
+ carry = start === 0 ? Buffer.from(data) : Buffer.from(data.subarray(start));
1787
+ }
1788
+ if (carry.length > 0)
1789
+ pushLine(carry.toString("utf8"), out);
1790
+ } finally {
1791
+ closeSync(fd);
1792
+ }
1793
+ return out;
1794
+ }
1795
+ async function mapPool(items, limit, fn) {
1796
+ const out = new Array(items.length);
1797
+ let next = 0;
1798
+ async function worker() {
1799
+ for (; ; ) {
1800
+ const i = next++;
1801
+ if (i >= items.length)
1802
+ return;
1803
+ out[i] = await fn(items[i], i);
1804
+ }
1805
+ }
1806
+ const n = Math.min(Math.max(1, limit), items.length);
1807
+ if (items.length === 0)
1808
+ return out;
1809
+ await Promise.all(Array.from({ length: n }, () => worker()));
1810
+ return out;
1811
+ }
1812
+ function lruSet(map, key, value, max = DETAIL_CACHE_LIMIT) {
1813
+ if (map.has(key))
1814
+ map.delete(key);
1815
+ map.set(key, value);
1816
+ while (map.size > max) {
1817
+ const oldest = map.keys().next().value;
1818
+ if (oldest === void 0)
1819
+ break;
1820
+ map.delete(oldest);
1821
+ }
1822
+ }
1823
+ function lruGet(map, key) {
1824
+ const v = map.get(key);
1825
+ if (v === void 0)
1826
+ return void 0;
1827
+ map.delete(key);
1828
+ map.set(key, v);
1829
+ return v;
1830
+ }
1831
+ var MAX_JSONL_FILE_BYTES, MAX_JSONL_LINE_BYTES, LIST_PARSE_CONCURRENCY, DETAIL_CACHE_LIMIT, JsonlTooLargeError;
1832
+ var init_jsonl_read = __esm({
1833
+ "../parser/dist/jsonl-read.js"() {
1834
+ "use strict";
1835
+ MAX_JSONL_FILE_BYTES = 64 * 1024 * 1024;
1836
+ MAX_JSONL_LINE_BYTES = 2 * 1024 * 1024;
1837
+ LIST_PARSE_CONCURRENCY = 4;
1838
+ DETAIL_CACHE_LIMIT = 4;
1839
+ JsonlTooLargeError = class extends Error {
1840
+ filePath;
1841
+ sizeBytes;
1842
+ code = "JSONL_TOO_LARGE";
1843
+ constructor(filePath, sizeBytes) {
1844
+ super(`transcript too large to parse (${sizeBytes} bytes): ${filePath}`);
1845
+ this.filePath = filePath;
1846
+ this.sizeBytes = sizeBytes;
1847
+ this.name = "JsonlTooLargeError";
1848
+ }
1849
+ };
1850
+ }
1851
+ });
1852
+
1853
+ // ../parser/dist/claude-code.js
1854
+ import { promises as fs2 } from "node:fs";
1731
1855
  import os from "node:os";
1732
1856
  import path from "node:path";
1733
1857
  function decodeProjectName(dir) {
@@ -1741,20 +1865,6 @@ function encodeProjectDir(cwd) {
1741
1865
  function isFleetlensRuntimeDir(projectDir) {
1742
1866
  return projectDir === FLEETLENS_RUNTIME_PROJECT_DIR;
1743
1867
  }
1744
- async function readJsonlFile(filePath) {
1745
- const raw = await fs.readFile(filePath, "utf8");
1746
- const out = [];
1747
- for (const line of raw.split("\n")) {
1748
- const trimmed = line.trim();
1749
- if (!trimmed)
1750
- continue;
1751
- try {
1752
- out.push(JSON.parse(trimmed));
1753
- } catch {
1754
- }
1755
- }
1756
- return out;
1757
- }
1758
1868
  function sessionIdFromFileName(fileName) {
1759
1869
  return fileName.replace(/\.jsonl$/i, "");
1760
1870
  }
@@ -1783,7 +1893,7 @@ async function walkJsonlFiles(root = DEFAULT_ROOT) {
1783
1893
  }
1784
1894
  let topEntries;
1785
1895
  try {
1786
- topEntries = await fs.readdir(root, { withFileTypes: true });
1896
+ topEntries = await fs2.readdir(root, { withFileTypes: true });
1787
1897
  } catch {
1788
1898
  return [];
1789
1899
  }
@@ -1792,7 +1902,7 @@ async function walkJsonlFiles(root = DEFAULT_ROOT) {
1792
1902
  const projectPath = path.join(root, projectDir);
1793
1903
  let files;
1794
1904
  try {
1795
- files = await fs.readdir(projectPath);
1905
+ files = await fs2.readdir(projectPath);
1796
1906
  } catch {
1797
1907
  return [];
1798
1908
  }
@@ -1800,7 +1910,7 @@ async function walkJsonlFiles(root = DEFAULT_ROOT) {
1800
1910
  const refs = await Promise.all(jsonlFiles.map(async (f) => {
1801
1911
  const fullPath = path.join(projectPath, f);
1802
1912
  try {
1803
- const stat = await fs.stat(fullPath);
1913
+ const stat = await fs2.stat(fullPath);
1804
1914
  return {
1805
1915
  projectDir,
1806
1916
  fileName: f,
@@ -1820,11 +1930,13 @@ async function walkJsonlFiles(root = DEFAULT_ROOT) {
1820
1930
  }
1821
1931
  async function loadCalibrationEvents(root = DEFAULT_ROOT) {
1822
1932
  const files = await walkJsonlFiles(root);
1823
- const perFile = await Promise.all(files.map(async (f) => {
1933
+ const perFile = await mapPool(files, LIST_PARSE_CONCURRENCY, async (f) => {
1824
1934
  const cached = calibrationEventsCache.get(f.fullPath);
1825
1935
  if (cached && cached.mtimeMs === f.mtimeMs && cached.sizeBytes === f.sizeBytes) {
1826
1936
  return cached.events;
1827
1937
  }
1938
+ if (jsonlFileTooLarge(f.sizeBytes))
1939
+ return [];
1828
1940
  let lines;
1829
1941
  try {
1830
1942
  lines = await readJsonlFile(f.fullPath);
@@ -1870,7 +1982,7 @@ async function loadCalibrationEvents(root = DEFAULT_ROOT) {
1870
1982
  sizeBytes: f.sizeBytes
1871
1983
  });
1872
1984
  return events;
1873
- }));
1985
+ });
1874
1986
  const out = perFile.flat();
1875
1987
  out.sort((a, b) => a.ts.localeCompare(b.ts));
1876
1988
  return out;
@@ -1935,7 +2047,7 @@ async function computeSessionUsageWithSubagents(parentLines, projectDirPath, ses
1935
2047
  const subagentsDir = path.join(projectDirPath, sessionId, "subagents");
1936
2048
  let entries;
1937
2049
  try {
1938
- entries = await fs.readdir(subagentsDir);
2050
+ entries = await fs2.readdir(subagentsDir);
1939
2051
  } catch {
1940
2052
  return { usage, perDay };
1941
2053
  }
@@ -1979,7 +2091,7 @@ async function scanWorkflowAggregate(projectDirPath, sessionId) {
1979
2091
  const dir = path.join(projectDirPath, sessionId, "workflows");
1980
2092
  let entries;
1981
2093
  try {
1982
- entries = await fs.readdir(dir);
2094
+ entries = await fs2.readdir(dir);
1983
2095
  } catch {
1984
2096
  return { workflowCount: 0, spawnedAgentCount: 0, spans: [] };
1985
2097
  }
@@ -1990,7 +2102,7 @@ async function scanWorkflowAggregate(projectDirPath, sessionId) {
1990
2102
  const spans = [];
1991
2103
  const parsed = await Promise.all(jsonFiles.map(async (f) => {
1992
2104
  try {
1993
- const j = JSON.parse(await fs.readFile(path.join(dir, f), "utf8"));
2105
+ const j = JSON.parse(await fs2.readFile(path.join(dir, f), "utf8"));
1994
2106
  if (typeof j.agentCount === "number")
1995
2107
  spawnedAgentCount += j.agentCount;
1996
2108
  if (typeof j.startTime === "number" && typeof j.durationMs === "number" && j.durationMs > 0) {
@@ -2006,7 +2118,7 @@ async function scanWorkflowAggregate(projectDirPath, sessionId) {
2006
2118
  async function dirNewestMtimeMs(dir, depth) {
2007
2119
  let entries;
2008
2120
  try {
2009
- entries = await fs.readdir(dir, { withFileTypes: true });
2121
+ entries = await fs2.readdir(dir, { withFileTypes: true });
2010
2122
  } catch {
2011
2123
  return 0;
2012
2124
  }
@@ -2015,7 +2127,7 @@ async function dirNewestMtimeMs(dir, depth) {
2015
2127
  try {
2016
2128
  if (e.isDirectory())
2017
2129
  return depth > 0 ? await dirNewestMtimeMs(p, depth - 1) : 0;
2018
- return (await fs.stat(p)).mtimeMs;
2130
+ return (await fs2.stat(p)).mtimeMs;
2019
2131
  } catch {
2020
2132
  return 0;
2021
2133
  }
@@ -2068,6 +2180,8 @@ async function getCachedMeta(f) {
2068
2180
  if (cached && cached.mtimeMs === f.mtimeMs && cached.sizeBytes === f.sizeBytes) {
2069
2181
  return cached.meta;
2070
2182
  }
2183
+ if (jsonlFileTooLarge(f.sizeBytes))
2184
+ return null;
2071
2185
  try {
2072
2186
  const rawLines = await readJsonlFile(f.fullPath);
2073
2187
  const { meta } = parseTranscript(rawLines);
@@ -2095,10 +2209,12 @@ async function getCachedMeta(f) {
2095
2209
  }
2096
2210
  }
2097
2211
  async function getCachedDetail(f) {
2098
- const cached = detailCache.get(f.fullPath);
2212
+ const cached = lruGet(detailCache, f.fullPath);
2099
2213
  if (cached && cached.mtimeMs === f.mtimeMs && cached.sizeBytes === f.sizeBytes) {
2100
2214
  return cached.detail;
2101
2215
  }
2216
+ if (jsonlFileTooLarge(f.sizeBytes))
2217
+ return null;
2102
2218
  try {
2103
2219
  const rawLines = await readJsonlFile(f.fullPath);
2104
2220
  const { meta, events } = parseTranscript(rawLines);
@@ -2119,7 +2235,7 @@ async function getCachedDetail(f) {
2119
2235
  ...wf.workflowCount > 0 ? { workflowCount: wf.workflowCount, spawnedAgentCount: wf.spawnedAgentCount } : {},
2120
2236
  ...foldWorkflowAgentTime(meta.activeSegments, wf.spans)
2121
2237
  };
2122
- detailCache.set(f.fullPath, { detail, mtimeMs: f.mtimeMs, sizeBytes: f.sizeBytes });
2238
+ lruSet(detailCache, f.fullPath, { detail, mtimeMs: f.mtimeMs, sizeBytes: f.sizeBytes });
2123
2239
  const metaOnly = { ...detail };
2124
2240
  delete metaOnly.events;
2125
2241
  metaCache.set(f.fullPath, { meta: metaOnly, mtimeMs: f.mtimeMs, sizeBytes: f.sizeBytes });
@@ -2135,10 +2251,10 @@ async function listSessions(opts = {}) {
2135
2251
  files = files.filter((f) => f.projectDir === projectDir);
2136
2252
  files.sort((a, b) => b.mtimeMs - a.mtimeMs);
2137
2253
  const sliced = files.slice(0, limit);
2138
- const metas = await Promise.all(sliced.map(async (f) => {
2254
+ const metas = await mapPool(sliced, LIST_PARSE_CONCURRENCY, async (f) => {
2139
2255
  const m = await getCachedMeta(f);
2140
2256
  return m ? withLastActivity(m, f) : null;
2141
- }));
2257
+ });
2142
2258
  return metas.filter((m) => m !== null);
2143
2259
  }
2144
2260
  async function getSession(id, opts = {}) {
@@ -2258,7 +2374,7 @@ function summarizeSubagentLines(lines) {
2258
2374
  async function loadSubagents(dir, sessionStartMs, parentEvents) {
2259
2375
  let entries;
2260
2376
  try {
2261
- entries = await fs.readdir(dir);
2377
+ entries = await fs2.readdir(dir);
2262
2378
  } catch {
2263
2379
  return [];
2264
2380
  }
@@ -2311,7 +2427,7 @@ async function loadSubagents(dir, sessionStartMs, parentEvents) {
2311
2427
  const metaPath = path.join(dir, `agent-${agentId}.meta.json`);
2312
2428
  let meta = {};
2313
2429
  try {
2314
- const raw = await fs.readFile(metaPath, "utf8");
2430
+ const raw = await fs2.readFile(metaPath, "utf8");
2315
2431
  meta = JSON.parse(raw);
2316
2432
  } catch {
2317
2433
  }
@@ -2357,7 +2473,7 @@ async function loadSubagents(dir, sessionStartMs, parentEvents) {
2357
2473
  async function loadWorkflows(dir, sessionStartMs, parentEvents) {
2358
2474
  let entries;
2359
2475
  try {
2360
- entries = await fs.readdir(dir);
2476
+ entries = await fs2.readdir(dir);
2361
2477
  } catch {
2362
2478
  return [];
2363
2479
  }
@@ -2406,7 +2522,7 @@ async function loadWorkflows(dir, sessionStartMs, parentEvents) {
2406
2522
  const runs = await Promise.all(jsonFiles.map(async (f) => {
2407
2523
  let j;
2408
2524
  try {
2409
- j = JSON.parse(await fs.readFile(path.join(dir, f), "utf8"));
2525
+ j = JSON.parse(await fs2.readFile(path.join(dir, f), "utf8"));
2410
2526
  } catch {
2411
2527
  return null;
2412
2528
  }
@@ -2694,6 +2810,8 @@ var init_claude_code = __esm({
2694
2810
  init_team();
2695
2811
  init_agent_metadata();
2696
2812
  init_calibration();
2813
+ init_jsonl_read();
2814
+ init_jsonl_read();
2697
2815
  DEFAULT_ROOT = path.join(os.homedir(), ".claude", "projects");
2698
2816
  FLEETLENS_RUNTIME_PROJECT_DIR = encodeProjectDir(path.join(os.homedir(), ".cclens", "runtime"));
2699
2817
  metaCache = /* @__PURE__ */ new Map();
@@ -2725,11 +2843,11 @@ var init_claude_code = __esm({
2725
2843
  });
2726
2844
 
2727
2845
  // ../parser/dist/codex.js
2728
- import { promises as fs2 } from "node:fs";
2846
+ import { promises as fs3 } from "node:fs";
2729
2847
  import os2 from "node:os";
2730
2848
  import path2 from "node:path";
2731
2849
  async function safeReaddir(p) {
2732
- return fs2.readdir(p).catch(() => []);
2850
+ return fs3.readdir(p).catch(() => []);
2733
2851
  }
2734
2852
  async function listRolloutFiles(root) {
2735
2853
  const out = [];
@@ -2754,7 +2872,7 @@ async function listRolloutFiles(root) {
2754
2872
  if (!m)
2755
2873
  continue;
2756
2874
  const full = path2.join(dayDir, entry);
2757
- const stat = await fs2.stat(full).catch(() => null);
2875
+ const stat = await fs3.stat(full).catch(() => null);
2758
2876
  if (!stat)
2759
2877
  continue;
2760
2878
  out.push({
@@ -2769,20 +2887,6 @@ async function listRolloutFiles(root) {
2769
2887
  }
2770
2888
  return out;
2771
2889
  }
2772
- async function readJsonl(filePath) {
2773
- const raw = await fs2.readFile(filePath, "utf8");
2774
- const out = [];
2775
- for (const line of raw.split("\n")) {
2776
- const trimmed = line.trim();
2777
- if (!trimmed)
2778
- continue;
2779
- try {
2780
- out.push(JSON.parse(trimmed));
2781
- } catch {
2782
- }
2783
- }
2784
- return out;
2785
- }
2786
2890
  function emptyUsage() {
2787
2891
  return { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 };
2788
2892
  }
@@ -3150,8 +3254,10 @@ async function scanAllCodex(root) {
3150
3254
  });
3151
3255
  continue;
3152
3256
  }
3257
+ if (jsonlFileTooLarge(file.sizeBytes))
3258
+ continue;
3153
3259
  try {
3154
- const lines = await readJsonl(file.filePath);
3260
+ const lines = await readJsonlFile(file.filePath);
3155
3261
  const parsed = parseRollout(file, lines);
3156
3262
  metaCache2.set(file.filePath, {
3157
3263
  meta: parsed.meta,
@@ -3252,14 +3358,16 @@ async function getCodexSession(id, opts = {}) {
3252
3358
  const direct = all.find((a) => a.meta.id === id);
3253
3359
  if (!direct)
3254
3360
  return null;
3255
- const cached2 = detailCache2.get(direct.file.filePath);
3361
+ const cached2 = lruGet(detailCache2, direct.file.filePath);
3256
3362
  if (cached2 && cached2.mtimeMs === direct.file.mtimeMs && cached2.sizeBytes === direct.file.sizeBytes) {
3257
3363
  return cached2.detail;
3258
3364
  }
3259
- const lines2 = await readJsonl(direct.file.filePath);
3365
+ if (jsonlFileTooLarge(direct.file.sizeBytes))
3366
+ return null;
3367
+ const lines2 = await readJsonlFile(direct.file.filePath);
3260
3368
  const { meta: meta2, events: events2 } = parseRollout(direct.file, lines2);
3261
3369
  const detail2 = { ...meta2, events: events2 };
3262
- detailCache2.set(direct.file.filePath, {
3370
+ lruSet(detailCache2, direct.file.filePath, {
3263
3371
  detail: detail2,
3264
3372
  mtimeMs: direct.file.mtimeMs,
3265
3373
  sizeBytes: direct.file.sizeBytes
@@ -3267,11 +3375,13 @@ async function getCodexSession(id, opts = {}) {
3267
3375
  return detail2;
3268
3376
  }
3269
3377
  const file = rootEntry.file;
3270
- const cached = detailCache2.get(file.filePath);
3378
+ const cached = lruGet(detailCache2, file.filePath);
3271
3379
  if (cached && cached.mtimeMs === file.mtimeMs && cached.sizeBytes === file.sizeBytes) {
3272
3380
  return cached.detail;
3273
3381
  }
3274
- const lines = await readJsonl(file.filePath);
3382
+ if (jsonlFileTooLarge(file.sizeBytes))
3383
+ return null;
3384
+ const lines = await readJsonlFile(file.filePath);
3275
3385
  const { meta, events } = parseRollout(file, lines);
3276
3386
  const children = all.filter((a) => a.threadSource === "subagent" && a.rootSessionId === id);
3277
3387
  const parentStartMs = meta.firstTimestamp ? Date.parse(meta.firstTimestamp) : void 0;
@@ -3281,7 +3391,7 @@ async function getCodexSession(id, opts = {}) {
3281
3391
  events,
3282
3392
  ...subagents.length > 0 ? { subagents, spawnedAgentCount: subagents.length } : {}
3283
3393
  };
3284
- detailCache2.set(file.filePath, {
3394
+ lruSet(detailCache2, file.filePath, {
3285
3395
  detail,
3286
3396
  mtimeMs: file.mtimeMs,
3287
3397
  sizeBytes: file.sizeBytes
@@ -3307,7 +3417,9 @@ async function getLatestCodexUsage(opts = {}) {
3307
3417
  return null;
3308
3418
  files.sort((a, b) => b.mtimeMs - a.mtimeMs);
3309
3419
  for (const file of files) {
3310
- const lines = await readJsonl(file.filePath);
3420
+ if (jsonlFileTooLarge(file.sizeBytes))
3421
+ continue;
3422
+ const lines = await readJsonlFile(file.filePath);
3311
3423
  for (let i = lines.length - 1; i >= 0; i--) {
3312
3424
  const line = lines[i];
3313
3425
  if (typeof line !== "object" || line === null)
@@ -3373,6 +3485,7 @@ var init_codex = __esm({
3373
3485
  init_analytics();
3374
3486
  init_git_project();
3375
3487
  init_user_input();
3488
+ init_jsonl_read();
3376
3489
  DEFAULT_CODEX_ROOT = path2.join(os2.homedir(), ".codex", "sessions");
3377
3490
  ROLLOUT_RE = /^rollout-(\d{4}-\d{2}-\d{2}T\d{2}-\d{2}-\d{2})-([0-9a-f-]+)\.jsonl$/;
3378
3491
  IDLE_GAP_MS = 3 * 60 * 1e3;
@@ -3384,7 +3497,7 @@ var init_codex = __esm({
3384
3497
  });
3385
3498
 
3386
3499
  // ../parser/dist/copilot.js
3387
- import { promises as fs3 } from "node:fs";
3500
+ import { promises as fs4 } from "node:fs";
3388
3501
  import os3 from "node:os";
3389
3502
  import path3 from "node:path";
3390
3503
  function recordOf(value) {
@@ -3410,13 +3523,13 @@ function syntheticProjectDir(cwd) {
3410
3523
  return cwd ? cwd.replace(/^\//, "-").replace(/\//g, "-") : "(unknown)";
3411
3524
  }
3412
3525
  async function listSessionFiles(root) {
3413
- const entries = await fs3.readdir(root, { withFileTypes: true }).catch(() => []);
3526
+ const entries = await fs4.readdir(root, { withFileTypes: true }).catch(() => []);
3414
3527
  const out = [];
3415
3528
  for (const entry of entries) {
3416
3529
  if (!entry.isDirectory())
3417
3530
  continue;
3418
3531
  const filePath = path3.join(root, entry.name, "events.jsonl");
3419
- const stat = await fs3.stat(filePath).catch(() => null);
3532
+ const stat = await fs4.stat(filePath).catch(() => null);
3420
3533
  if (!stat?.isFile())
3421
3534
  continue;
3422
3535
  out.push({
@@ -3428,20 +3541,6 @@ async function listSessionFiles(root) {
3428
3541
  }
3429
3542
  return out;
3430
3543
  }
3431
- async function readJsonl2(filePath) {
3432
- const raw = await fs3.readFile(filePath, "utf8");
3433
- const out = [];
3434
- for (const line of raw.split("\n")) {
3435
- const trimmed = line.trim();
3436
- if (!trimmed)
3437
- continue;
3438
- try {
3439
- out.push(JSON.parse(trimmed));
3440
- } catch {
3441
- }
3442
- }
3443
- return out;
3444
- }
3445
3544
  function computeActiveSegments3(timestamps) {
3446
3545
  const sorted = [...new Set(timestamps)].sort((a, b) => a - b);
3447
3546
  if (sorted.length === 0)
@@ -3746,8 +3845,10 @@ async function scanCopilot(root) {
3746
3845
  out.push({ file, meta: cached.meta });
3747
3846
  continue;
3748
3847
  }
3848
+ if (jsonlFileTooLarge(file.sizeBytes))
3849
+ continue;
3749
3850
  try {
3750
- const lines = await readJsonl2(file.filePath);
3851
+ const lines = await readJsonlFile(file.filePath);
3751
3852
  const { meta } = parseSession(file, lines);
3752
3853
  metaCache3.set(file.filePath, { meta, mtimeMs: file.mtimeMs, sizeBytes: file.sizeBytes });
3753
3854
  out.push({ file, meta });
@@ -3767,14 +3868,16 @@ async function getCopilotSession(id, opts = {}) {
3767
3868
  const entry = (await scanCopilot(root)).find((candidate) => candidate.meta.id === id);
3768
3869
  if (!entry)
3769
3870
  return null;
3770
- const cached = detailCache3.get(entry.file.filePath);
3871
+ const cached = lruGet(detailCache3, entry.file.filePath);
3771
3872
  if (cached && cached.mtimeMs === entry.file.mtimeMs && cached.sizeBytes === entry.file.sizeBytes) {
3772
3873
  return cached.detail;
3773
3874
  }
3774
- const lines = await readJsonl2(entry.file.filePath);
3875
+ if (jsonlFileTooLarge(entry.file.sizeBytes))
3876
+ return null;
3877
+ const lines = await readJsonlFile(entry.file.filePath);
3775
3878
  const { meta, events } = parseSession(entry.file, lines);
3776
3879
  const detail = { ...meta, events };
3777
- detailCache3.set(entry.file.filePath, {
3880
+ lruSet(detailCache3, entry.file.filePath, {
3778
3881
  detail,
3779
3882
  mtimeMs: entry.file.mtimeMs,
3780
3883
  sizeBytes: entry.file.sizeBytes
@@ -3794,6 +3897,7 @@ var init_copilot = __esm({
3794
3897
  init_analytics();
3795
3898
  init_git_project();
3796
3899
  init_user_input();
3900
+ init_jsonl_read();
3797
3901
  DEFAULT_COPILOT_ROOT = path3.join(os3.homedir(), ".copilot", "session-state");
3798
3902
  IDLE_GAP_MS2 = 3 * 60 * 1e3;
3799
3903
  metaCache3 = /* @__PURE__ */ new Map();
@@ -3802,11 +3906,11 @@ var init_copilot = __esm({
3802
3906
  });
3803
3907
 
3804
3908
  // ../parser/dist/gemini.js
3805
- import { promises as fs4 } from "node:fs";
3909
+ import { promises as fs5 } from "node:fs";
3806
3910
  import os4 from "node:os";
3807
3911
  import path4 from "node:path";
3808
3912
  async function safeReaddir2(p) {
3809
- return fs4.readdir(p).catch(() => []);
3913
+ return fs5.readdir(p).catch(() => []);
3810
3914
  }
3811
3915
  async function listSessionFiles2(root) {
3812
3916
  const out = [];
@@ -3818,7 +3922,7 @@ async function listSessionFiles2(root) {
3818
3922
  if (!SESSION_FILE_RE.test(entry))
3819
3923
  continue;
3820
3924
  const full = path4.join(chatsDir, entry);
3821
- const stat = await fs4.stat(full).catch(() => null);
3925
+ const stat = await fs5.stat(full).catch(() => null);
3822
3926
  if (!stat || !stat.isFile())
3823
3927
  continue;
3824
3928
  const filenameId = entry.replace(/\.(jsonl|json)$/, "").split("-").pop() ?? entry;
@@ -3835,13 +3939,13 @@ async function listSessionFiles2(root) {
3835
3939
  return out;
3836
3940
  }
3837
3941
  async function loadSlugToCwd() {
3838
- const stat = await fs4.stat(GEMINI_PROJECTS_FILE).catch(() => null);
3942
+ const stat = await fs5.stat(GEMINI_PROJECTS_FILE).catch(() => null);
3839
3943
  if (!stat)
3840
3944
  return /* @__PURE__ */ new Map();
3841
3945
  if (projectsCache && projectsCache.mtimeMs === stat.mtimeMs) {
3842
3946
  return projectsCache.slugToCwd;
3843
3947
  }
3844
- const raw = await fs4.readFile(GEMINI_PROJECTS_FILE, "utf8").catch(() => "");
3948
+ const raw = await fs5.readFile(GEMINI_PROJECTS_FILE, "utf8").catch(() => "");
3845
3949
  let parsed;
3846
3950
  try {
3847
3951
  parsed = JSON.parse(raw);
@@ -3866,8 +3970,11 @@ function isMessageRecord(o) {
3866
3970
  return !!o && typeof o === "object" && typeof o.id === "string" && typeof o.type === "string";
3867
3971
  }
3868
3972
  async function readAndReplay(file) {
3869
- const raw = await fs4.readFile(file.filePath, "utf8");
3973
+ if (jsonlFileTooLarge(file.sizeBytes)) {
3974
+ return { meta: {}, messages: [] };
3975
+ }
3870
3976
  if (file.format === "legacy-json") {
3977
+ const raw = await fs5.readFile(file.filePath, "utf8");
3871
3978
  let blob;
3872
3979
  try {
3873
3980
  blob = JSON.parse(raw);
@@ -3888,16 +3995,8 @@ async function readAndReplay(file) {
3888
3995
  const meta = {};
3889
3996
  const byId = /* @__PURE__ */ new Map();
3890
3997
  const order = [];
3891
- for (const line of raw.split("\n")) {
3892
- const trimmed = line.trim();
3893
- if (!trimmed)
3894
- continue;
3895
- let obj;
3896
- try {
3897
- obj = JSON.parse(trimmed);
3898
- } catch {
3899
- continue;
3900
- }
3998
+ const parsedLines = await readJsonlFile(file.filePath);
3999
+ for (const obj of parsedLines) {
3901
4000
  if (isRewindMarker(obj)) {
3902
4001
  const target = obj.$rewindTo;
3903
4002
  const idx = order.indexOf(target);
@@ -4233,6 +4332,8 @@ async function listGeminiSessions(opts = {}) {
4233
4332
  out.push(cached.meta);
4234
4333
  continue;
4235
4334
  }
4335
+ if (jsonlFileTooLarge(file.sizeBytes))
4336
+ continue;
4236
4337
  try {
4237
4338
  const { meta } = await parseSession2(file);
4238
4339
  metaCache4.set(file.filePath, {
@@ -4270,13 +4371,13 @@ async function getGeminiSession(id, opts = {}) {
4270
4371
  }
4271
4372
  if (!chosen)
4272
4373
  return null;
4273
- const cached = detailCache4.get(chosen.filePath);
4374
+ const cached = lruGet(detailCache4, chosen.filePath);
4274
4375
  if (cached && cached.mtimeMs === chosen.mtimeMs && cached.sizeBytes === chosen.sizeBytes) {
4275
4376
  return cached.detail;
4276
4377
  }
4277
4378
  const { meta, events } = await parseSession2(chosen);
4278
4379
  const detail = { ...meta, events };
4279
- detailCache4.set(chosen.filePath, {
4380
+ lruSet(detailCache4, chosen.filePath, {
4280
4381
  detail,
4281
4382
  mtimeMs: chosen.mtimeMs,
4282
4383
  sizeBytes: chosen.sizeBytes
@@ -4296,6 +4397,7 @@ var init_gemini = __esm({
4296
4397
  init_analytics();
4297
4398
  init_git_project();
4298
4399
  init_user_input();
4400
+ init_jsonl_read();
4299
4401
  DEFAULT_GEMINI_ROOT = path4.join(os4.homedir(), ".gemini", "tmp");
4300
4402
  GEMINI_PROJECTS_FILE = path4.join(os4.homedir(), ".gemini", "projects.json");
4301
4403
  SESSION_FILE_RE = /^session-.+\.(jsonl|json)$/;
@@ -4307,21 +4409,21 @@ var init_gemini = __esm({
4307
4409
  });
4308
4410
 
4309
4411
  // ../parser/dist/antigravity.js
4310
- import { promises as fs5 } from "node:fs";
4412
+ import { promises as fs6 } from "node:fs";
4311
4413
  import os5 from "node:os";
4312
4414
  import path5 from "node:path";
4313
4415
  async function safeReaddir3(p) {
4314
- return fs5.readdir(p).catch(() => []);
4416
+ return fs6.readdir(p).catch(() => []);
4315
4417
  }
4316
4418
  async function loadSlugToCwd2(root) {
4317
4419
  const historyFile = path5.join(root, "history.jsonl");
4318
- const stat = await fs5.stat(historyFile).catch(() => null);
4420
+ const stat = await fs6.stat(historyFile).catch(() => null);
4319
4421
  if (!stat)
4320
4422
  return /* @__PURE__ */ new Map();
4321
4423
  if (historyCache && historyCache.mtimeMs === stat.mtimeMs) {
4322
4424
  return historyCache.slugToCwd;
4323
4425
  }
4324
- const raw = await fs5.readFile(historyFile, "utf8").catch(() => "");
4426
+ const raw = await fs6.readFile(historyFile, "utf8").catch(() => "");
4325
4427
  const slugToCwd = /* @__PURE__ */ new Map();
4326
4428
  for (const line of raw.split("\n")) {
4327
4429
  const trimmed = line.trim();
@@ -4345,7 +4447,7 @@ async function listSessionFiles3(root) {
4345
4447
  const entries = await safeReaddir3(brainDir);
4346
4448
  for (const entry of entries) {
4347
4449
  const transcriptPath = path5.join(brainDir, entry, ".system_generated", "logs", "transcript.jsonl");
4348
- const stat = await fs5.stat(transcriptPath).catch(() => null);
4450
+ const stat = await fs6.stat(transcriptPath).catch(() => null);
4349
4451
  if (stat && stat.isFile()) {
4350
4452
  out.push({
4351
4453
  filePath: transcriptPath,
@@ -4368,7 +4470,9 @@ function truncate4(s, n) {
4368
4470
  return s.length <= n ? s : s.slice(0, n - 1) + "\u2026";
4369
4471
  }
4370
4472
  async function parseSession3(file) {
4371
- const raw = await fs5.readFile(file.filePath, "utf8");
4473
+ if (jsonlFileTooLarge(file.sizeBytes)) {
4474
+ throw new Error(`transcript too large to parse (${file.sizeBytes} bytes)`);
4475
+ }
4372
4476
  const events = [];
4373
4477
  const totalUsage = emptyUsage4();
4374
4478
  let firstTimestamp;
@@ -4395,24 +4499,19 @@ async function parseSession3(file) {
4395
4499
  const pendingToolCalls = [];
4396
4500
  const parsedObjects = [];
4397
4501
  const indexMap = /* @__PURE__ */ new Map();
4398
- for (const line of raw.split("\n")) {
4399
- const trimmed = line.trim();
4400
- if (!trimmed)
4401
- continue;
4402
- try {
4403
- const obj = JSON.parse(trimmed);
4404
- const stepIdx = obj.step_index;
4405
- if (typeof stepIdx === "number") {
4406
- if (indexMap.has(stepIdx)) {
4407
- parsedObjects[indexMap.get(stepIdx)] = obj;
4408
- } else {
4409
- indexMap.set(stepIdx, parsedObjects.length);
4410
- parsedObjects.push(obj);
4411
- }
4502
+ const lines = await readJsonlFile(file.filePath);
4503
+ for (const rawLine of lines) {
4504
+ const obj = rawLine;
4505
+ const stepIdx = obj.step_index;
4506
+ if (typeof stepIdx === "number") {
4507
+ if (indexMap.has(stepIdx)) {
4508
+ parsedObjects[indexMap.get(stepIdx)] = obj;
4412
4509
  } else {
4510
+ indexMap.set(stepIdx, parsedObjects.length);
4413
4511
  parsedObjects.push(obj);
4414
4512
  }
4415
- } catch {
4513
+ } else {
4514
+ parsedObjects.push(obj);
4416
4515
  }
4417
4516
  }
4418
4517
  for (const rawObj of parsedObjects) {
@@ -4630,6 +4729,8 @@ async function listAntigravitySessions(opts = {}) {
4630
4729
  out.push(cached.meta);
4631
4730
  continue;
4632
4731
  }
4732
+ if (jsonlFileTooLarge(file.sizeBytes))
4733
+ continue;
4633
4734
  try {
4634
4735
  const { meta } = await parseSession3(file);
4635
4736
  metaCache5.set(file.filePath, {
@@ -4659,13 +4760,13 @@ async function getAntigravitySession(id, opts = {}) {
4659
4760
  }
4660
4761
  if (!chosen)
4661
4762
  return null;
4662
- const cached = detailCache5.get(chosen.filePath);
4763
+ const cached = lruGet(detailCache5, chosen.filePath);
4663
4764
  if (cached && cached.mtimeMs === chosen.mtimeMs && cached.sizeBytes === chosen.sizeBytes && cached.cwd === chosen.cwd) {
4664
4765
  return cached.detail;
4665
4766
  }
4666
4767
  const { meta, events } = await parseSession3(chosen);
4667
4768
  const detail = { ...meta, events };
4668
- detailCache5.set(chosen.filePath, {
4769
+ lruSet(detailCache5, chosen.filePath, {
4669
4770
  detail,
4670
4771
  mtimeMs: chosen.mtimeMs,
4671
4772
  sizeBytes: chosen.sizeBytes,
@@ -4686,6 +4787,7 @@ var init_antigravity = __esm({
4686
4787
  init_analytics();
4687
4788
  init_git_project();
4688
4789
  init_user_input();
4790
+ init_jsonl_read();
4689
4791
  DEFAULT_ANTIGRAVITY_ROOT = path5.join(os5.homedir(), ".gemini", "antigravity-cli");
4690
4792
  IDLE_GAP_MS4 = 3 * 60 * 1e3;
4691
4793
  historyCache = null;
@@ -4695,7 +4797,7 @@ var init_antigravity = __esm({
4695
4797
  });
4696
4798
 
4697
4799
  // ../parser/dist/cowork.js
4698
- import { promises as fs6 } from "node:fs";
4800
+ import { promises as fs7 } from "node:fs";
4699
4801
  import os6 from "node:os";
4700
4802
  import path6 from "node:path";
4701
4803
  function defaultCoworkRoot() {
@@ -4710,10 +4812,10 @@ function defaultCoworkRoot() {
4710
4812
  return path6.join(home, ".config", "Claude", "local-agent-mode-sessions");
4711
4813
  }
4712
4814
  async function safeReaddir4(p) {
4713
- return fs6.readdir(p).catch(() => []);
4815
+ return fs7.readdir(p).catch(() => []);
4714
4816
  }
4715
4817
  async function statMs(p) {
4716
- const s = await fs6.stat(p).catch(() => null);
4818
+ const s = await fs7.stat(p).catch(() => null);
4717
4819
  return s ? s.mtimeMs : 0;
4718
4820
  }
4719
4821
  async function listSessionFiles4(root) {
@@ -4730,7 +4832,7 @@ async function listSessionFiles4(root) {
4730
4832
  if (!SESSION_ID_RE.test(entry))
4731
4833
  continue;
4732
4834
  const auditPath = path6.join(workspaceDir, entry, "audit.jsonl");
4733
- const auditStat = await fs6.stat(auditPath).catch(() => null);
4835
+ const auditStat = await fs7.stat(auditPath).catch(() => null);
4734
4836
  if (!auditStat || !auditStat.isFile() || auditStat.size === 0)
4735
4837
  continue;
4736
4838
  const metaPath = path6.join(workspaceDir, `${entry}.json`);
@@ -4752,13 +4854,13 @@ async function listSessionFiles4(root) {
4752
4854
  }
4753
4855
  async function loadSpacesForWorkspace(workspaceDir) {
4754
4856
  const spacesPath = path6.join(workspaceDir, "spaces.json");
4755
- const stat = await fs6.stat(spacesPath).catch(() => null);
4857
+ const stat = await fs7.stat(spacesPath).catch(() => null);
4756
4858
  if (!stat)
4757
4859
  return /* @__PURE__ */ new Map();
4758
4860
  const cached = spacesCache.get(workspaceDir);
4759
4861
  if (cached && cached.mtimeMs === stat.mtimeMs)
4760
4862
  return cached.spaceIdToPath;
4761
- const raw = await fs6.readFile(spacesPath, "utf8").catch(() => "");
4863
+ const raw = await fs7.readFile(spacesPath, "utf8").catch(() => "");
4762
4864
  const out = /* @__PURE__ */ new Map();
4763
4865
  try {
4764
4866
  const parsed = JSON.parse(raw);
@@ -4776,7 +4878,7 @@ async function loadSpacesForWorkspace(workspaceDir) {
4776
4878
  return out;
4777
4879
  }
4778
4880
  async function readCoworkMeta(metaPath) {
4779
- const raw = await fs6.readFile(metaPath, "utf8").catch(() => "");
4881
+ const raw = await fs7.readFile(metaPath, "utf8").catch(() => "");
4780
4882
  if (!raw)
4781
4883
  return {};
4782
4884
  try {
@@ -4812,20 +4914,6 @@ function resolveProject(meta, spaceIdToPath) {
4812
4914
  cwd: projectPath
4813
4915
  };
4814
4916
  }
4815
- async function readJsonl3(filePath) {
4816
- const raw = await fs6.readFile(filePath, "utf8");
4817
- const out = [];
4818
- for (const line of raw.split("\n")) {
4819
- const trimmed = line.trim();
4820
- if (!trimmed)
4821
- continue;
4822
- try {
4823
- out.push(JSON.parse(trimmed));
4824
- } catch {
4825
- }
4826
- }
4827
- return out;
4828
- }
4829
4917
  function dedupeReplayedLines(lines) {
4830
4918
  const keepAt = /* @__PURE__ */ new Map();
4831
4919
  lines.forEach((line, i) => {
@@ -4948,8 +5036,11 @@ function buildCoworkSubagents(subagentGroups, allLines, sessionStartMs) {
4948
5036
  return runs;
4949
5037
  }
4950
5038
  async function parseCoworkSession(file) {
5039
+ if (jsonlFileTooLarge(file.auditSize)) {
5040
+ throw new Error(`transcript too large to parse (${file.auditSize} bytes)`);
5041
+ }
4951
5042
  const [lines, coworkMeta, spaceIdToPath] = await Promise.all([
4952
- readJsonl3(file.auditPath),
5043
+ readJsonlFile(file.auditPath),
4953
5044
  readCoworkMeta(file.metaPath),
4954
5045
  loadSpacesForWorkspace(file.workspaceDir)
4955
5046
  ]);
@@ -5018,7 +5109,7 @@ async function getCoworkSession(id, opts = {}) {
5018
5109
  if (!file)
5019
5110
  return null;
5020
5111
  const key = cacheKeyFor(file);
5021
- const cached = detailCache6.get(file.auditPath);
5112
+ const cached = lruGet(detailCache6, file.auditPath);
5022
5113
  if (cached && cacheKeyMatches(cached.key, key))
5023
5114
  return cached.detail;
5024
5115
  const { meta, events, subagents } = await parseCoworkSession(file);
@@ -5027,7 +5118,7 @@ async function getCoworkSession(id, opts = {}) {
5027
5118
  events,
5028
5119
  ...subagents.length ? { subagents } : {}
5029
5120
  };
5030
- detailCache6.set(file.auditPath, { detail, key });
5121
+ lruSet(detailCache6, file.auditPath, { detail, key });
5031
5122
  return detail;
5032
5123
  }
5033
5124
  var DEFAULT_COWORK_ROOT, SESSION_ID_RE, spacesCache, metaCache6, detailCache6;
@@ -5037,6 +5128,7 @@ var init_cowork = __esm({
5037
5128
  init_claude_code();
5038
5129
  init_git_project();
5039
5130
  init_parser();
5131
+ init_jsonl_read();
5040
5132
  DEFAULT_COWORK_ROOT = defaultCoworkRoot();
5041
5133
  SESSION_ID_RE = /^local_[0-9a-f-]+$/;
5042
5134
  spacesCache = /* @__PURE__ */ new Map();
@@ -5046,7 +5138,7 @@ var init_cowork = __esm({
5046
5138
  });
5047
5139
 
5048
5140
  // ../parser/dist/grok.js
5049
- import { promises as fs7 } from "node:fs";
5141
+ import { promises as fs8 } from "node:fs";
5050
5142
  import os7 from "node:os";
5051
5143
  import path7 from "node:path";
5052
5144
  function resolveDefaultGrokRoot() {
@@ -5054,10 +5146,10 @@ function resolveDefaultGrokRoot() {
5054
5146
  return path7.join(home, "sessions");
5055
5147
  }
5056
5148
  async function safeReaddir5(p) {
5057
- return fs7.readdir(p).catch(() => []);
5149
+ return fs8.readdir(p).catch(() => []);
5058
5150
  }
5059
5151
  async function safeReadJson(p) {
5060
- const raw = await fs7.readFile(p, "utf8").catch(() => null);
5152
+ const raw = await fs8.readFile(p, "utf8").catch(() => null);
5061
5153
  if (raw == null)
5062
5154
  return null;
5063
5155
  try {
@@ -5068,7 +5160,7 @@ async function safeReadJson(p) {
5068
5160
  }
5069
5161
  async function resolveEncodedCwd(groupDir, encoded) {
5070
5162
  const cwdFile = path7.join(groupDir, ".cwd");
5071
- const fromFile = await fs7.readFile(cwdFile, "utf8").catch(() => null);
5163
+ const fromFile = await fs8.readFile(cwdFile, "utf8").catch(() => null);
5072
5164
  if (fromFile && fromFile.trim())
5073
5165
  return fromFile.trim();
5074
5166
  try {
@@ -5084,7 +5176,7 @@ async function listSessionDirs(root) {
5084
5176
  if (group === "session_search.sqlite" || group.startsWith("."))
5085
5177
  continue;
5086
5178
  const groupDir = path7.join(root, group);
5087
- const groupStat = await fs7.stat(groupDir).catch(() => null);
5179
+ const groupStat = await fs8.stat(groupDir).catch(() => null);
5088
5180
  if (!groupStat?.isDirectory())
5089
5181
  continue;
5090
5182
  const decodedCwd = await resolveEncodedCwd(groupDir, group);
@@ -5097,9 +5189,9 @@ async function listSessionDirs(root) {
5097
5189
  const updatesPath = path7.join(dirPath, "updates.jsonl");
5098
5190
  const signalsCandidate = path7.join(dirPath, "signals.json");
5099
5191
  const [summaryStat, updatesStat, signalsStat] = await Promise.all([
5100
- fs7.stat(summaryPath).catch(() => null),
5101
- fs7.stat(updatesPath).catch(() => null),
5102
- fs7.stat(signalsCandidate).catch(() => null)
5192
+ fs8.stat(summaryPath).catch(() => null),
5193
+ fs8.stat(updatesPath).catch(() => null),
5194
+ fs8.stat(signalsCandidate).catch(() => null)
5103
5195
  ]);
5104
5196
  if (!summaryStat?.isFile())
5105
5197
  continue;
@@ -5256,10 +5348,13 @@ function computeActiveSegments6(tsMs) {
5256
5348
  return out;
5257
5349
  }
5258
5350
  async function parseSession4(dir) {
5259
- const [summary, signals, updatesRaw] = await Promise.all([
5351
+ if (jsonlFileTooLarge(dir.sizeBytes)) {
5352
+ throw new Error(`transcript too large to parse (${dir.sizeBytes} bytes)`);
5353
+ }
5354
+ const [summary, signals, updateLines] = await Promise.all([
5260
5355
  safeReadJson(dir.summaryPath),
5261
5356
  dir.signalsPath ? safeReadJson(dir.signalsPath) : Promise.resolve(null),
5262
- fs7.readFile(dir.updatesPath, "utf8").catch(() => "")
5357
+ readJsonlFile(dir.updatesPath).catch(() => [])
5263
5358
  ]);
5264
5359
  const sessionId = summary?.info?.id ?? dir.sessionId;
5265
5360
  const cwd = summary?.info?.cwd ?? dir.decodedCwd;
@@ -5378,17 +5473,8 @@ async function parseSession4(dir) {
5378
5473
  buf.promptId = promptId;
5379
5474
  buf.raw.push(raw);
5380
5475
  }
5381
- const lines = updatesRaw.split("\n");
5382
- for (const line of lines) {
5383
- const trimmed = line.trim();
5384
- if (!trimmed)
5385
- continue;
5386
- let obj;
5387
- try {
5388
- obj = JSON.parse(trimmed);
5389
- } catch {
5390
- continue;
5391
- }
5476
+ for (const rawLine of updateLines) {
5477
+ const obj = rawLine;
5392
5478
  const update = obj.params?.update;
5393
5479
  if (!update || typeof update !== "object")
5394
5480
  continue;
@@ -5558,7 +5644,7 @@ async function countSubagentChildren(dirPath) {
5558
5644
  const entries = await safeReaddir5(subRoot);
5559
5645
  let n = 0;
5560
5646
  for (const e of entries) {
5561
- const st = await fs7.stat(path7.join(subRoot, e)).catch(() => null);
5647
+ const st = await fs8.stat(path7.join(subRoot, e)).catch(() => null);
5562
5648
  if (st?.isDirectory())
5563
5649
  n += 1;
5564
5650
  }
@@ -5624,6 +5710,8 @@ async function listGrokSessions(opts = {}) {
5624
5710
  out.push(cached.meta);
5625
5711
  continue;
5626
5712
  }
5713
+ if (jsonlFileTooLarge(dir.sizeBytes))
5714
+ continue;
5627
5715
  try {
5628
5716
  const { meta, sessionKind } = await parseSession4(dir);
5629
5717
  if (sessionKind === "subagent")
@@ -5652,7 +5740,7 @@ async function getGrokSession(id, opts = {}) {
5652
5740
  const { meta: meta2, events: events2 } = await parseSession4(dir);
5653
5741
  if (meta2.id === id) {
5654
5742
  const detail2 = { ...meta2, events: events2 };
5655
- detailCache7.set(dir.dirPath, {
5743
+ lruSet(detailCache7, dir.dirPath, {
5656
5744
  detail: detail2,
5657
5745
  mtimeMs: dir.mtimeMs,
5658
5746
  sizeBytes: dir.sizeBytes
@@ -5664,7 +5752,7 @@ async function getGrokSession(id, opts = {}) {
5664
5752
  }
5665
5753
  return null;
5666
5754
  }
5667
- const cached = detailCache7.get(chosen.dirPath);
5755
+ const cached = lruGet(detailCache7, chosen.dirPath);
5668
5756
  if (cached && cached.mtimeMs === chosen.mtimeMs && cached.sizeBytes === chosen.sizeBytes) {
5669
5757
  return cached.detail;
5670
5758
  }
@@ -5676,7 +5764,7 @@ async function getGrokSession(id, opts = {}) {
5676
5764
  events,
5677
5765
  ...subagents.length > 0 ? { subagents, spawnedAgentCount: subagents.length } : {}
5678
5766
  };
5679
- detailCache7.set(chosen.dirPath, {
5767
+ lruSet(detailCache7, chosen.dirPath, {
5680
5768
  detail,
5681
5769
  mtimeMs: chosen.mtimeMs,
5682
5770
  sizeBytes: chosen.sizeBytes
@@ -5704,6 +5792,7 @@ var init_grok = __esm({
5704
5792
  init_analytics();
5705
5793
  init_git_project();
5706
5794
  init_user_input();
5795
+ init_jsonl_read();
5707
5796
  DEFAULT_GROK_ROOT = path7.join(os7.homedir(), ".grok", "sessions");
5708
5797
  IDLE_GAP_MS5 = 3 * 60 * 1e3;
5709
5798
  metaCache7 = /* @__PURE__ */ new Map();
@@ -5773,6 +5862,9 @@ __export(fs_exports, {
5773
5862
  DEFAULT_GEMINI_ROOT: () => DEFAULT_GEMINI_ROOT,
5774
5863
  DEFAULT_GROK_ROOT: () => DEFAULT_GROK_ROOT,
5775
5864
  DEFAULT_ROOT: () => DEFAULT_ROOT,
5865
+ JsonlTooLargeError: () => JsonlTooLargeError,
5866
+ MAX_JSONL_FILE_BYTES: () => MAX_JSONL_FILE_BYTES,
5867
+ MAX_JSONL_LINE_BYTES: () => MAX_JSONL_LINE_BYTES,
5776
5868
  RICH_ROLLUP_SCHEMA_VERSION: () => RICH_ROLLUP_SCHEMA_VERSION,
5777
5869
  agentSources: () => agentSources,
5778
5870
  antigravitySessionLocalDay: () => antigravitySessionLocalDay,
@@ -5802,6 +5894,7 @@ __export(fs_exports, {
5802
5894
  grokSessionLocalDay: () => grokSessionLocalDay,
5803
5895
  invalidateFile: () => invalidateFile,
5804
5896
  isFleetlensRuntimeDir: () => isFleetlensRuntimeDir,
5897
+ jsonlFileTooLarge: () => jsonlFileTooLarge,
5805
5898
  listAllSessions: () => listAllSessions,
5806
5899
  listAntigravitySessions: () => listAntigravitySessions,
5807
5900
  listCodexSessions: () => listCodexSessions,
@@ -5820,6 +5913,7 @@ __export(fs_exports, {
5820
5913
  pruneUsageAgent: () => pruneUsageAgent,
5821
5914
  readGitFolder: () => readGitFolder,
5822
5915
  readJsonlFile: () => readJsonlFile,
5916
+ readJsonlFileSync: () => readJsonlFileSync,
5823
5917
  readTeamConfig: () => readTeamConfig,
5824
5918
  resolveDefaultGrokRoot: () => resolveDefaultGrokRoot,
5825
5919
  resolveProjectIdentity: () => resolveProjectIdentity,
@@ -5828,7 +5922,7 @@ __export(fs_exports, {
5828
5922
  walkJsonlFiles: () => walkJsonlFiles,
5829
5923
  writeTeamConfig: () => writeTeamConfig
5830
5924
  });
5831
- import { promises as fs8, existsSync as existsSync3, readFileSync as readFileSync5, writeFileSync as writeFileSync2, appendFileSync, mkdirSync as mkdirSync2 } from "node:fs";
5925
+ import { promises as fs9, existsSync as existsSync3, readFileSync as readFileSync5, writeFileSync as writeFileSync2, appendFileSync, mkdirSync as mkdirSync2 } from "node:fs";
5832
5926
  import os8 from "node:os";
5833
5927
  import path8 from "node:path";
5834
5928
  function cclensHome() {
@@ -5900,7 +5994,7 @@ function pruneUsageAgent(agent) {
5900
5994
  async function loadUsageByDay(start, end) {
5901
5995
  let raw;
5902
5996
  try {
5903
- raw = await fs8.readFile(usageLogPath(), "utf8");
5997
+ raw = await fs9.readFile(usageLogPath(), "utf8");
5904
5998
  } catch {
5905
5999
  return { by_day: [] };
5906
6000
  }
@@ -5945,7 +6039,7 @@ async function loadUsageByDay(start, end) {
5945
6039
  async function loadCalibrationSnapshots() {
5946
6040
  let raw;
5947
6041
  try {
5948
- raw = await fs8.readFile(usageLogPath(), "utf8");
6042
+ raw = await fs9.readFile(usageLogPath(), "utf8");
5949
6043
  } catch {
5950
6044
  return [];
5951
6045
  }
@@ -6124,6 +6218,7 @@ var init_fs = __esm({
6124
6218
  init_cowork();
6125
6219
  init_grok();
6126
6220
  init_claude_code();
6221
+ init_jsonl_read();
6127
6222
  init_git_project();
6128
6223
  init_codex();
6129
6224
  init_copilot();
@@ -6213,10 +6308,10 @@ import {
6213
6308
  readFileSync as readFileSync11,
6214
6309
  writeFileSync as writeFileSync4,
6215
6310
  existsSync as existsSync10,
6216
- openSync,
6217
- readSync,
6311
+ openSync as openSync2,
6312
+ readSync as readSync2,
6218
6313
  fstatSync,
6219
- closeSync
6314
+ closeSync as closeSync2
6220
6315
  } from "node:fs";
6221
6316
  import { dirname as dirname3 } from "node:path";
6222
6317
  function appendSnapshot(filePath, snapshot) {
@@ -6278,13 +6373,13 @@ function latestSnapshotsByAgent(filePath, opts = {}) {
6278
6373
  function readTail(filePath, maxBytes) {
6279
6374
  let fd;
6280
6375
  try {
6281
- fd = openSync(filePath, "r");
6376
+ fd = openSync2(filePath, "r");
6282
6377
  const size = fstatSync(fd).size;
6283
6378
  if (size <= 0) return "";
6284
6379
  const start = Math.max(0, size - maxBytes);
6285
6380
  const len = size - start;
6286
6381
  const buf = Buffer.alloc(len);
6287
- readSync(fd, buf, 0, len, start);
6382
+ readSync2(fd, buf, 0, len, start);
6288
6383
  let text = buf.toString("utf8");
6289
6384
  if (start > 0) {
6290
6385
  const nl = text.indexOf("\n");
@@ -6298,7 +6393,7 @@ function readTail(filePath, maxBytes) {
6298
6393
  return "";
6299
6394
  }
6300
6395
  } finally {
6301
- if (fd !== void 0) closeSync(fd);
6396
+ if (fd !== void 0) closeSync2(fd);
6302
6397
  }
6303
6398
  }
6304
6399
  var init_storage = __esm({
@@ -6796,7 +6891,7 @@ __export(file_probe_exports, {
6796
6891
  probeArtifactSignals: () => probeArtifactSignals
6797
6892
  });
6798
6893
  import { createHash as createHash2 } from "node:crypto";
6799
- import { existsSync as existsSync15, readdirSync as readdirSync4, statSync as statSync6 } from "node:fs";
6894
+ import { existsSync as existsSync15, readdirSync as readdirSync4, statSync as statSync7 } from "node:fs";
6800
6895
  import { homedir as homedir5 } from "node:os";
6801
6896
  import { join as join11, relative, resolve as resolve4, sep } from "node:path";
6802
6897
  import { execFileSync as execFileSync2 } from "node:child_process";
@@ -6827,7 +6922,7 @@ function listMarkdownFiles(dir) {
6827
6922
  const full = join11(dir, name);
6828
6923
  let stat;
6829
6924
  try {
6830
- stat = statSync6(full);
6925
+ stat = statSync7(full);
6831
6926
  } catch {
6832
6927
  continue;
6833
6928
  }
@@ -6850,7 +6945,7 @@ function firstSeenDateOf(file) {
6850
6945
  } catch {
6851
6946
  }
6852
6947
  try {
6853
- const s = statSync6(file);
6948
+ const s = statSync7(file);
6854
6949
  return localDay(s.birthtime || s.mtime);
6855
6950
  } catch {
6856
6951
  return todayLocal();
@@ -6904,7 +6999,7 @@ function scanEdited(roots, day) {
6904
6999
  if (firstSeen === day) continue;
6905
7000
  let stat;
6906
7001
  try {
6907
- stat = statSync6(f);
7002
+ stat = statSync7(f);
6908
7003
  } catch {
6909
7004
  continue;
6910
7005
  }
@@ -6980,7 +7075,7 @@ var init_file_probe = __esm({
6980
7075
  });
6981
7076
 
6982
7077
  // src/pid.ts
6983
- import { readFileSync as readFileSync24, writeFileSync as writeFileSync15, mkdirSync as mkdirSync14, unlinkSync as unlinkSync5 } from "node:fs";
7078
+ import { readFileSync as readFileSync23, writeFileSync as writeFileSync15, mkdirSync as mkdirSync14, unlinkSync as unlinkSync5 } from "node:fs";
6984
7079
  import { execFileSync as execFileSync3 } from "node:child_process";
6985
7080
  import { dirname as dirname13 } from "node:path";
6986
7081
  function writePid(filePath, pid, port, version) {
@@ -6994,7 +7089,7 @@ function writePid(filePath, pid, port, version) {
6994
7089
  }
6995
7090
  function readPid(filePath) {
6996
7091
  try {
6997
- const content = readFileSync24(filePath, "utf8").trim();
7092
+ const content = readFileSync23(filePath, "utf8").trim();
6998
7093
  const [pidStr, portStr, versionStr] = content.split(":");
6999
7094
  const pid = parseInt(pidStr, 10);
7000
7095
  if (Number.isNaN(pid)) return null;
@@ -7050,7 +7145,7 @@ var init_pid = __esm({
7050
7145
  import { spawn as spawn3 } from "node:child_process";
7051
7146
  import { join as join16, dirname as dirname14 } from "node:path";
7052
7147
  import { fileURLToPath } from "node:url";
7053
- import { existsSync as existsSync23, realpathSync as realpathSync3, readFileSync as readFileSync25 } from "node:fs";
7148
+ import { existsSync as existsSync23, realpathSync as realpathSync3, readFileSync as readFileSync24 } from "node:fs";
7054
7149
  import { homedir as homedir9 } from "node:os";
7055
7150
  function appDir() {
7056
7151
  const here = dirname14(fileURLToPath(import.meta.url));
@@ -7067,10 +7162,10 @@ function cliBinRealPath() {
7067
7162
  function onDiskVersion() {
7068
7163
  try {
7069
7164
  const here = dirname14(fileURLToPath(import.meta.url));
7070
- const pkg = JSON.parse(readFileSync25(join16(here, "..", "package.json"), "utf8"));
7071
- return pkg.version ?? "1.0.18";
7165
+ const pkg = JSON.parse(readFileSync24(join16(here, "..", "package.json"), "utf8"));
7166
+ return pkg.version ?? "1.0.19";
7072
7167
  } catch {
7073
- return "1.0.18";
7168
+ return "1.0.19";
7074
7169
  }
7075
7170
  }
7076
7171
  function getServerStatus() {
@@ -7174,7 +7269,7 @@ var init_server = __esm({
7174
7269
 
7175
7270
  // src/daemon-worker.ts
7176
7271
  import { spawn as spawn4 } from "node:child_process";
7177
- import { closeSync as closeSync2, existsSync as existsSync24, mkdirSync as mkdirSync15, openSync as openSync2, readFileSync as readFileSync26, writeFileSync as writeFileSync16 } from "node:fs";
7272
+ import { closeSync as closeSync3, existsSync as existsSync24, mkdirSync as mkdirSync15, openSync as openSync3, readFileSync as readFileSync25, writeFileSync as writeFileSync16 } from "node:fs";
7178
7273
  import { dirname as dirname15, join as join17 } from "node:path";
7179
7274
  import { fileURLToPath as fileURLToPath2 } from "node:url";
7180
7275
 
@@ -8927,7 +9022,8 @@ function listEntriesForDay(localDay2) {
8927
9022
 
8928
9023
  // src/perception/build-entries.ts
8929
9024
  init_dist();
8930
- import { statSync as statSync3, readFileSync as readFileSync14 } from "node:fs";
9025
+ init_fs();
9026
+ import { statSync as statSync4 } from "node:fs";
8931
9027
  import { basename as basename3, dirname as dirname5 } from "node:path";
8932
9028
 
8933
9029
  // ../entries/dist/signals.js
@@ -9668,15 +9764,16 @@ function decodeProjectDirName(projectDir) {
9668
9764
  return projectDir.replace(/-/g, "/");
9669
9765
  }
9670
9766
  function buildEntriesForFile(filePath) {
9671
- const stat = statSync3(filePath);
9672
- const raw = readFileSync14(filePath, "utf8");
9673
- const rawLines = raw.split("\n").filter(Boolean).map((l) => {
9674
- try {
9675
- return JSON.parse(l);
9676
- } catch {
9677
- return null;
9678
- }
9679
- }).filter((x) => x !== null);
9767
+ const stat = statSync4(filePath);
9768
+ if (jsonlFileTooLarge(stat.size)) return [];
9769
+ return entriesFromLines(filePath, stat.size, readJsonlFileSync(filePath));
9770
+ }
9771
+ async function buildEntriesForFileAsync(filePath) {
9772
+ const stat = statSync4(filePath);
9773
+ if (jsonlFileTooLarge(stat.size)) return [];
9774
+ return entriesFromLines(filePath, stat.size, await readJsonlFile(filePath));
9775
+ }
9776
+ function entriesFromLines(filePath, sizeBytes, rawLines) {
9680
9777
  if (rawLines.length === 0) return null;
9681
9778
  const { meta, events } = parseTranscript(rawLines);
9682
9779
  const fileName = basename3(filePath);
@@ -9692,7 +9789,7 @@ function buildEntriesForFile(filePath) {
9692
9789
  };
9693
9790
  const built = buildEntries(sd);
9694
9791
  for (const e of built) {
9695
- e.source_checkpoint.byte_offset = stat.size;
9792
+ e.source_checkpoint.byte_offset = sizeBytes;
9696
9793
  }
9697
9794
  return built;
9698
9795
  }
@@ -9935,7 +10032,7 @@ function buildIngestPayload(inputs) {
9935
10032
  return {
9936
10033
  ingestId: randomUUID(),
9937
10034
  observedAt: (/* @__PURE__ */ new Date()).toISOString(),
9938
- cliVersion: "1.0.18",
10035
+ cliVersion: "1.0.19",
9939
10036
  ...richRollup || inputs.enrichedExtras || inputs.artifactSignals ? { schemaVersion: RICH_ROLLUP_SCHEMA_VERSION } : {},
9940
10037
  ...inputs.rollup ? { dailyRollup: inputs.rollup } : {},
9941
10038
  ...richRollup ? { richRollup } : {},
@@ -9962,7 +10059,7 @@ async function pushToTeamServer(config, payload) {
9962
10059
  }
9963
10060
 
9964
10061
  // src/team/git-remote.ts
9965
- import { existsSync as existsSync13, readFileSync as readFileSync15, statSync as statSync4 } from "node:fs";
10062
+ import { existsSync as existsSync13, readFileSync as readFileSync14, statSync as statSync5 } from "node:fs";
9966
10063
  import { dirname as dirname6, isAbsolute as isAbsolute2, join as join9, resolve as resolve3 } from "node:path";
9967
10064
  var GITHUB_URL_RE = /github\.com[:/]([A-Za-z0-9_.-]+)\/([A-Za-z0-9_.-]+?)(?:\.git)?$/;
9968
10065
  function parseGithubRemote(url) {
@@ -9985,15 +10082,15 @@ function originUrl2(configText) {
9985
10082
  }
9986
10083
  function gitConfigPathFor(dir) {
9987
10084
  const dotGit = join9(dir, ".git");
9988
- const st = statSync4(dotGit, { throwIfNoEntry: false });
10085
+ const st = statSync5(dotGit, { throwIfNoEntry: false });
9989
10086
  if (!st) return null;
9990
10087
  if (st.isDirectory()) return join9(dotGit, "config");
9991
- const m = readFileSync15(dotGit, "utf8").match(/^gitdir:\s*(.+)\s*$/m);
10088
+ const m = readFileSync14(dotGit, "utf8").match(/^gitdir:\s*(.+)\s*$/m);
9992
10089
  if (!m) return null;
9993
10090
  const gd = isAbsolute2(m[1]) ? m[1] : resolve3(dir, m[1]);
9994
10091
  const commondirFile = join9(gd, "commondir");
9995
10092
  if (existsSync13(commondirFile)) {
9996
- const common = readFileSync15(commondirFile, "utf8").trim();
10093
+ const common = readFileSync14(commondirFile, "utf8").trim();
9997
10094
  return join9(isAbsolute2(common) ? common : resolve3(gd, common), "config");
9998
10095
  }
9999
10096
  return join9(gd, "config");
@@ -10009,7 +10106,7 @@ function createRepoResolver() {
10009
10106
  for (let d = dir; ; d = dirname6(d)) {
10010
10107
  const config = gitConfigPathFor(d);
10011
10108
  if (config && existsSync13(config)) {
10012
- const url = originUrl2(readFileSync15(config, "utf8"));
10109
+ const url = originUrl2(readFileSync14(config, "utf8"));
10013
10110
  repo = url ? parseGithubRemote(url) : null;
10014
10111
  break;
10015
10112
  }
@@ -10025,7 +10122,7 @@ function createRepoResolver() {
10025
10122
 
10026
10123
  // src/team/queue.ts
10027
10124
  init_fs();
10028
- import { readFileSync as readFileSync16, writeFileSync as writeFileSync7, appendFileSync as appendFileSync4, statSync as statSync5, mkdirSync as mkdirSync6 } from "node:fs";
10125
+ import { readFileSync as readFileSync15, writeFileSync as writeFileSync7, appendFileSync as appendFileSync4, statSync as statSync6, mkdirSync as mkdirSync6 } from "node:fs";
10029
10126
  import { dirname as dirname7 } from "node:path";
10030
10127
  var QUEUE_PATH = cclensPath("ingest-queue.jsonl");
10031
10128
  var MAX_SIZE_BYTES = 10 * 1024 * 1024;
@@ -10035,7 +10132,7 @@ function enqueuePayload(payload, queuePath = QUEUE_PATH) {
10035
10132
  const entry = { payload, enqueuedAt: (/* @__PURE__ */ new Date()).toISOString() };
10036
10133
  appendFileSync4(queuePath, JSON.stringify(entry) + "\n", "utf8");
10037
10134
  try {
10038
- const { size } = statSync5(queuePath);
10135
+ const { size } = statSync6(queuePath);
10039
10136
  if (size > MAX_SIZE_BYTES) {
10040
10137
  pruneOldest(queuePath);
10041
10138
  }
@@ -10045,7 +10142,7 @@ function enqueuePayload(payload, queuePath = QUEUE_PATH) {
10045
10142
  function dequeuePayloads(queuePath = QUEUE_PATH) {
10046
10143
  let lines;
10047
10144
  try {
10048
- lines = readFileSync16(queuePath, "utf8").trim().split("\n").filter(Boolean);
10145
+ lines = readFileSync15(queuePath, "utf8").trim().split("\n").filter(Boolean);
10049
10146
  } catch {
10050
10147
  return [];
10051
10148
  }
@@ -10066,7 +10163,7 @@ function dequeuePayloads(queuePath = QUEUE_PATH) {
10066
10163
  function pruneOldest(queuePath) {
10067
10164
  let lines;
10068
10165
  try {
10069
- lines = readFileSync16(queuePath, "utf8").trim().split("\n").filter(Boolean);
10166
+ lines = readFileSync15(queuePath, "utf8").trim().split("\n").filter(Boolean);
10070
10167
  } catch {
10071
10168
  return;
10072
10169
  }
@@ -10079,7 +10176,7 @@ init_storage();
10079
10176
  import { randomUUID as randomUUID2 } from "node:crypto";
10080
10177
 
10081
10178
  // src/usage/profile.ts
10082
- import { existsSync as existsSync14, mkdirSync as mkdirSync7, readFileSync as readFileSync17, writeFileSync as writeFileSync8 } from "node:fs";
10179
+ import { existsSync as existsSync14, mkdirSync as mkdirSync7, readFileSync as readFileSync16, writeFileSync as writeFileSync8 } from "node:fs";
10083
10180
  import { dirname as dirname8 } from "node:path";
10084
10181
  var PROFILE_ENDPOINT = "https://api.anthropic.com/api/oauth/profile";
10085
10182
  var BETA_HEADER2 = "oauth-2025-04-20";
@@ -10125,7 +10222,7 @@ async function fetchProfile(nowMs = Date.now()) {
10125
10222
  function readCachedProfile(cachePath) {
10126
10223
  if (!existsSync14(cachePath)) return null;
10127
10224
  try {
10128
- const raw = JSON.parse(readFileSync17(cachePath, "utf8"));
10225
+ const raw = JSON.parse(readFileSync16(cachePath, "utf8"));
10129
10226
  if (typeof raw.fetchedAtMs !== "number" || !raw.profile) return null;
10130
10227
  return raw;
10131
10228
  } catch {
@@ -10294,13 +10391,13 @@ async function runTeamBackfill(log3 = noopLog, filePath = USAGE_LOG, configOverr
10294
10391
 
10295
10392
  // src/team/sync-log.ts
10296
10393
  init_fs();
10297
- import { readFileSync as readFileSync18 } from "node:fs";
10394
+ import { readFileSync as readFileSync17 } from "node:fs";
10298
10395
  var MAX_LINES = 300;
10299
10396
  var MAX_MSG_CHARS = 1900;
10300
10397
  function readPendingSyncLog(watermark) {
10301
10398
  let raw;
10302
10399
  try {
10303
- raw = readFileSync18(cclensPath("daemon.log"), "utf8");
10400
+ raw = readFileSync17(cclensPath("daemon.log"), "utf8");
10304
10401
  } catch {
10305
10402
  return { lines: [] };
10306
10403
  }
@@ -10921,12 +11018,12 @@ async function buildCyclePeaksForPush(planTier, loadCurve) {
10921
11018
  }
10922
11019
 
10923
11020
  // src/perception/worker.ts
10924
- import { statSync as statSync7 } from "node:fs";
11021
+ import { statSync as statSync8 } from "node:fs";
10925
11022
  init_fs();
10926
11023
 
10927
11024
  // src/perception/state.ts
10928
11025
  init_fs();
10929
- import { existsSync as existsSync16, readFileSync as readFileSync19, writeFileSync as writeFileSync10, mkdirSync as mkdirSync9, renameSync as renameSync4 } from "node:fs";
11026
+ import { existsSync as existsSync16, readFileSync as readFileSync18, writeFileSync as writeFileSync10, mkdirSync as mkdirSync9, renameSync as renameSync4 } from "node:fs";
10930
11027
  import { dirname as dirname10 } from "node:path";
10931
11028
  var STALE_MS = 15 * 60 * 1e3;
10932
11029
  var pathCached = null;
@@ -10945,7 +11042,7 @@ function readState() {
10945
11042
  file_checkpoints: {}
10946
11043
  };
10947
11044
  }
10948
- const raw = readFileSync19(p, "utf8");
11045
+ const raw = readFileSync18(p, "utf8");
10949
11046
  return JSON.parse(raw);
10950
11047
  }
10951
11048
  function writeState(s) {
@@ -11006,73 +11103,125 @@ async function listAllSessionJsonls(root) {
11006
11103
  function log(msg) {
11007
11104
  console.error(`[perception] ${msg}`);
11008
11105
  }
11106
+ function checkpoint(path12, statSize, extra) {
11107
+ updateCheckpoint(path12, {
11108
+ byte_offset: statSize,
11109
+ last_event_ts: extra?.last_event_ts ?? null,
11110
+ affects_days: extra?.affects_days ?? []
11111
+ });
11112
+ }
11009
11113
  async function runPerceptionSweep(opts = {}) {
11010
11114
  const state = readState();
11011
11115
  if (state.sweep_in_progress && !isSweepStale()) {
11012
- return { sessionsProcessed: 0, entriesWritten: 0, errors: 0 };
11116
+ return { sessionsProcessed: 0, entriesWritten: 0, errors: 0, skippedOversized: 0 };
11013
11117
  }
11014
11118
  markSweepStart();
11119
+ const maxFileBytes = opts.maxFileBytes ?? MAX_JSONL_FILE_BYTES;
11015
11120
  let sessions = 0;
11016
11121
  let entries = 0;
11017
11122
  let errors = 0;
11123
+ let skippedOversized = 0;
11018
11124
  try {
11019
11125
  const files = await listAllSessionJsonls(opts.projectsRoot);
11020
11126
  for (const f of files) {
11021
11127
  try {
11022
- const stat = statSync7(f);
11128
+ const stat = statSync8(f);
11023
11129
  const prev = state.file_checkpoints[f];
11024
11130
  if (prev && prev.byte_offset >= stat.size) continue;
11025
- const built = buildEntriesForFile(f);
11131
+ if (stat.size > maxFileBytes) {
11132
+ checkpoint(f, stat.size);
11133
+ state.file_checkpoints[f] = { byte_offset: stat.size, last_event_ts: null, affects_days: [] };
11134
+ skippedOversized++;
11135
+ log(`skipped oversized ${f} (${stat.size} bytes)`);
11136
+ continue;
11137
+ }
11138
+ const built = await buildEntriesForFileAsync(f);
11026
11139
  if (built === null) continue;
11027
11140
  for (const e of built) {
11028
11141
  writeEntryPreservingEnrichment(e);
11029
11142
  entries++;
11030
11143
  }
11031
- updateCheckpoint(f, {
11032
- byte_offset: stat.size,
11144
+ checkpoint(f, stat.size, {
11033
11145
  last_event_ts: built.at(-1)?.end_iso ?? null,
11034
11146
  affects_days: built.map((e) => e.local_day)
11035
11147
  });
11148
+ state.file_checkpoints[f] = {
11149
+ byte_offset: stat.size,
11150
+ last_event_ts: built.at(-1)?.end_iso ?? null,
11151
+ affects_days: built.map((e) => e.local_day)
11152
+ };
11036
11153
  sessions++;
11037
11154
  } catch (err) {
11038
11155
  errors++;
11039
11156
  log(`skipped ${f}: ${err.message}`);
11040
11157
  }
11041
11158
  }
11042
- if (opts.projectsRoot === void 0) {
11043
- for (const source of agentSources) {
11044
- if (source.kind === "claude-code") continue;
11045
- try {
11046
- const metas = await source.listSessions();
11047
- for (const meta of metas) {
11159
+ const extraSources = opts.extraSources ?? (opts.projectsRoot === void 0 ? agentSources.filter((s) => s.kind !== "claude-code") : []);
11160
+ for (const source of extraSources) {
11161
+ if (source.kind === "claude-code") continue;
11162
+ try {
11163
+ const metas = await source.listSessions();
11164
+ for (const meta of metas) {
11165
+ try {
11166
+ if (!meta.filePath) continue;
11167
+ let stat;
11048
11168
  try {
11049
- const detail = await source.getSession(meta.id);
11050
- if (!detail) continue;
11051
- const built = buildEntries(detail);
11052
- for (const e of built) {
11053
- try {
11054
- const stat = statSync7(meta.filePath);
11055
- e.source_checkpoint.byte_offset = stat.size;
11056
- } catch {
11057
- }
11058
- writeEntryPreservingEnrichment(e);
11059
- entries++;
11060
- }
11061
- sessions++;
11062
- } catch (err) {
11063
- errors++;
11064
- log(`${source.kind} skipped ${meta.id}: ${err.message}`);
11169
+ stat = statSync8(meta.filePath);
11170
+ } catch {
11171
+ continue;
11065
11172
  }
11173
+ const prev = state.file_checkpoints[meta.filePath];
11174
+ if (prev && prev.byte_offset >= stat.size) continue;
11175
+ if (stat.size > maxFileBytes) {
11176
+ checkpoint(meta.filePath, stat.size);
11177
+ state.file_checkpoints[meta.filePath] = {
11178
+ byte_offset: stat.size,
11179
+ last_event_ts: null,
11180
+ affects_days: []
11181
+ };
11182
+ skippedOversized++;
11183
+ log(`skipped oversized ${source.kind} ${meta.filePath} (${stat.size} bytes)`);
11184
+ continue;
11185
+ }
11186
+ const detail = await source.getSession(meta.id);
11187
+ if (!detail) {
11188
+ checkpoint(meta.filePath, stat.size);
11189
+ state.file_checkpoints[meta.filePath] = {
11190
+ byte_offset: stat.size,
11191
+ last_event_ts: null,
11192
+ affects_days: []
11193
+ };
11194
+ continue;
11195
+ }
11196
+ const built = buildEntries(detail);
11197
+ for (const e of built) {
11198
+ e.source_checkpoint.byte_offset = stat.size;
11199
+ writeEntryPreservingEnrichment(e);
11200
+ entries++;
11201
+ }
11202
+ checkpoint(meta.filePath, stat.size, {
11203
+ last_event_ts: built.at(-1)?.end_iso ?? null,
11204
+ affects_days: built.map((e) => e.local_day)
11205
+ });
11206
+ state.file_checkpoints[meta.filePath] = {
11207
+ byte_offset: stat.size,
11208
+ last_event_ts: built.at(-1)?.end_iso ?? null,
11209
+ affects_days: built.map((e) => e.local_day)
11210
+ };
11211
+ sessions++;
11212
+ } catch (err) {
11213
+ errors++;
11214
+ log(`${source.kind} skipped ${meta.id}: ${err.message}`);
11066
11215
  }
11067
- } catch (err) {
11068
- log(`${source.kind} pass failed: ${err.message}`);
11069
11216
  }
11217
+ } catch (err) {
11218
+ log(`${source.kind} pass failed: ${err.message}`);
11070
11219
  }
11071
11220
  }
11072
11221
  } finally {
11073
11222
  markSweepEnd();
11074
11223
  }
11075
- return { sessionsProcessed: sessions, entriesWritten: entries, errors };
11224
+ return { sessionsProcessed: sessions, entriesWritten: entries, errors, skippedOversized };
11076
11225
  }
11077
11226
 
11078
11227
  // ../../node_modules/zod/v3/external.js
@@ -15255,7 +15404,7 @@ var ClaudeBinNotFoundError = class extends Error {
15255
15404
  };
15256
15405
 
15257
15406
  // ../entries/dist/tmux-runner.js
15258
- import { mkdirSync as mkdirSync10, writeFileSync as writeFileSync11, existsSync as existsSync18, readdirSync as readdirSync6, realpathSync as realpathSync2, readFileSync as readFileSync20, unlinkSync as unlinkSync3, renameSync as renameSync5 } from "node:fs";
15407
+ import { mkdirSync as mkdirSync10, writeFileSync as writeFileSync11, existsSync as existsSync18, readdirSync as readdirSync6, realpathSync as realpathSync2, readFileSync as readFileSync19, unlinkSync as unlinkSync3, renameSync as renameSync5 } from "node:fs";
15259
15408
  import { join as join14 } from "node:path";
15260
15409
  import { homedir as homedir8 } from "node:os";
15261
15410
  import { spawnSync } from "node:child_process";
@@ -15294,7 +15443,7 @@ function ensureRuntimeCwdTrusted(cwd) {
15294
15443
  const cfgPath = join14(homedir8(), ".claude.json");
15295
15444
  let cfg;
15296
15445
  try {
15297
- cfg = JSON.parse(readFileSync20(cfgPath, "utf8"));
15446
+ cfg = JSON.parse(readFileSync19(cfgPath, "utf8"));
15298
15447
  } catch {
15299
15448
  return;
15300
15449
  }
@@ -15446,7 +15595,7 @@ function snapshotAllTranscripts() {
15446
15595
  function readJsonlCwd(path12, maxLines = 8) {
15447
15596
  let raw;
15448
15597
  try {
15449
- raw = readFileSync20(path12, "utf8");
15598
+ raw = readFileSync19(path12, "utf8");
15450
15599
  } catch {
15451
15600
  return void 0;
15452
15601
  }
@@ -15503,7 +15652,7 @@ async function discoverTranscript(targetCwd, existingBefore, startMs, timeoutMs,
15503
15652
  function parseTranscript2(path12, defaultModel) {
15504
15653
  let raw;
15505
15654
  try {
15506
- raw = readFileSync20(path12, "utf8");
15655
+ raw = readFileSync19(path12, "utf8");
15507
15656
  } catch {
15508
15657
  return { assembled: "", inputTokens: 0, outputTokens: 0, modelUsed: defaultModel, done: false };
15509
15658
  }
@@ -16013,7 +16162,7 @@ function applyEnrichmentError(entry, errorMessage, model, costUsd, generatedAt,
16013
16162
 
16014
16163
  // ../entries/dist/budget.js
16015
16164
  init_fs();
16016
- import { appendFileSync as appendFileSync6, readFileSync as readFileSync21, existsSync as existsSync20, mkdirSync as mkdirSync12 } from "node:fs";
16165
+ import { appendFileSync as appendFileSync6, readFileSync as readFileSync20, existsSync as existsSync20, mkdirSync as mkdirSync12 } from "node:fs";
16017
16166
  import { dirname as dirname12 } from "node:path";
16018
16167
  var spendPathCached = null;
16019
16168
  function spendPath() {
@@ -16034,7 +16183,7 @@ function monthToDateSpend(now = /* @__PURE__ */ new Date()) {
16034
16183
  const year = now.getUTCFullYear();
16035
16184
  const month = now.getUTCMonth();
16036
16185
  let total = 0;
16037
- const raw = readFileSync21(p, "utf8");
16186
+ const raw = readFileSync20(p, "utf8");
16038
16187
  for (const line of raw.split("\n")) {
16039
16188
  if (!line)
16040
16189
  continue;
@@ -16056,7 +16205,7 @@ function monthToDateSpend(now = /* @__PURE__ */ new Date()) {
16056
16205
 
16057
16206
  // ../entries/dist/pipeline-lock.js
16058
16207
  init_fs();
16059
- import { writeFileSync as writeFileSync13, unlinkSync as unlinkSync4, existsSync as existsSync21, readFileSync as readFileSync22, statSync as statSync8 } from "node:fs";
16208
+ import { writeFileSync as writeFileSync13, unlinkSync as unlinkSync4, existsSync as existsSync21, readFileSync as readFileSync21, statSync as statSync9 } from "node:fs";
16060
16209
  var STALE_MS2 = 60 * 1e3;
16061
16210
  var HEARTBEAT_MS = 30 * 1e3;
16062
16211
  var lockPathCached = null;
@@ -16105,10 +16254,10 @@ function interactiveLockFresh(nowMs) {
16105
16254
  if (!existsSync21(p))
16106
16255
  return false;
16107
16256
  try {
16108
- const mtime = statSync8(p).mtimeMs;
16257
+ const mtime = statSync9(p).mtimeMs;
16109
16258
  if (nowMs - mtime > STALE_MS2)
16110
16259
  return false;
16111
- const pid = Number(readFileSync22(p, "utf8").trim());
16260
+ const pid = Number(readFileSync21(p, "utf8").trim());
16112
16261
  if (!Number.isFinite(pid) || pid <= 0)
16113
16262
  return false;
16114
16263
  if (!pidAlive(pid))
@@ -16123,7 +16272,7 @@ function interactiveLockFresh(nowMs) {
16123
16272
  var THIRTY_MIN_MS = 30 * 60 * 1e3;
16124
16273
 
16125
16274
  // ../entries/dist/settings.js
16126
- import { readFileSync as readFileSync23, writeFileSync as writeFileSync14, renameSync as renameSync6, chmodSync as chmodSync2, mkdirSync as mkdirSync13, existsSync as existsSync22 } from "node:fs";
16275
+ import { readFileSync as readFileSync22, writeFileSync as writeFileSync14, renameSync as renameSync6, chmodSync as chmodSync2, mkdirSync as mkdirSync13, existsSync as existsSync22 } from "node:fs";
16127
16276
  init_fs();
16128
16277
  var DEFAULT_SETTINGS = {
16129
16278
  ai_features: {
@@ -16158,7 +16307,7 @@ function readSettings() {
16158
16307
  if (!existsSync22(p))
16159
16308
  return DEFAULT_SETTINGS;
16160
16309
  try {
16161
- const raw = readFileSync23(p, "utf8");
16310
+ const raw = readFileSync22(p, "utf8");
16162
16311
  return fromDisk(JSON.parse(raw));
16163
16312
  } catch {
16164
16313
  return DEFAULT_SETTINGS;
@@ -18918,14 +19067,14 @@ async function getUpdateAvailability() {
18918
19067
  if (isDevMode()) return null;
18919
19068
  const latest = await fetchLatestVersion();
18920
19069
  if (latest === null) return {
18921
- current: "1.0.18",
19070
+ current: "1.0.19",
18922
19071
  latest: null,
18923
19072
  updateAvailable: false
18924
19073
  };
18925
19074
  return {
18926
- current: "1.0.18",
19075
+ current: "1.0.19",
18927
19076
  latest,
18928
- updateAvailable: shouldUpdate("1.0.18", latest)
19077
+ updateAvailable: shouldUpdate("1.0.19", latest)
18929
19078
  };
18930
19079
  }
18931
19080
 
@@ -18990,15 +19139,21 @@ var currentIntervalMs = BASE_INTERVAL_MS;
18990
19139
  var waitingForRefresh = false;
18991
19140
  var updateCheckInFlight = false;
18992
19141
  var PERCEPTION_INTERVAL_MS = 5 * 60 * 1e3;
19142
+ var nextPerceptionAtMs = Date.now() + PERCEPTION_INTERVAL_MS;
18993
19143
  var perceptionInFlight = false;
18994
19144
  var backfillAttempted = false;
18995
- var perceptionHandle = setInterval(async () => {
19145
+ async function runPerceptionTick() {
18996
19146
  if (perceptionInFlight) return;
18997
19147
  perceptionInFlight = true;
18998
19148
  try {
18999
- const { sessionsProcessed, entriesWritten, errors } = await runPerceptionSweep();
19000
- if (sessionsProcessed > 0 || errors > 0) {
19001
- log2("info", `perception sweep: ${sessionsProcessed} sessions, ${entriesWritten} entries, ${errors} errors`);
19149
+ const { sessionsProcessed, entriesWritten, errors, skippedOversized } = await runPerceptionSweep();
19150
+ if (sessionsProcessed > 0 || errors > 0 || skippedOversized > 0) {
19151
+ const mem = process.memoryUsage();
19152
+ const mb = (n) => Math.round(n / 1048576);
19153
+ log2(
19154
+ "info",
19155
+ `perception sweep: ${sessionsProcessed} sessions, ${entriesWritten} entries, ${errors} errors, ${skippedOversized} oversized skipped \xB7 heap ${mb(mem.heapUsed)}MB rss ${mb(mem.rss)}MB`
19156
+ );
19002
19157
  }
19003
19158
  if (!backfillAttempted) {
19004
19159
  backfillAttempted = true;
@@ -19013,11 +19168,12 @@ var perceptionHandle = setInterval(async () => {
19013
19168
  log2("error", `perception sweep failed: ${err.message}`);
19014
19169
  } finally {
19015
19170
  perceptionInFlight = false;
19171
+ nextPerceptionAtMs = Date.now() + PERCEPTION_INTERVAL_MS;
19016
19172
  }
19017
- }, PERCEPTION_INTERVAL_MS);
19173
+ }
19018
19174
  function readUpdateState() {
19019
19175
  try {
19020
- return JSON.parse(readFileSync26(UPDATE_STATE, "utf8"));
19176
+ return JSON.parse(readFileSync25(UPDATE_STATE, "utf8"));
19021
19177
  } catch {
19022
19178
  return null;
19023
19179
  }
@@ -19075,7 +19231,7 @@ async function runDaemonUpdateCheck() {
19075
19231
  }
19076
19232
  let logFd = "ignore";
19077
19233
  try {
19078
- logFd = openSync2(DAEMON_LOG, "a");
19234
+ logFd = openSync3(DAEMON_LOG, "a");
19079
19235
  } catch {
19080
19236
  }
19081
19237
  const child = spawn4(process.execPath, [entry, "update"], {
@@ -19086,7 +19242,7 @@ async function runDaemonUpdateCheck() {
19086
19242
  if (typeof logFd === "number") {
19087
19243
  child.on("exit", () => {
19088
19244
  try {
19089
- closeSync2(logFd);
19245
+ closeSync3(logFd);
19090
19246
  } catch {
19091
19247
  }
19092
19248
  });
@@ -19309,66 +19465,79 @@ function sleep2(ms) {
19309
19465
  }
19310
19466
  async function runLoop() {
19311
19467
  while (true) {
19312
- const now = Date.now();
19313
- if (now >= nextAuxPollAtMs) {
19314
- await pollAuxiliaryUsage();
19315
- nextAuxPollAtMs = Date.now() + BASE_INTERVAL_MS;
19316
- }
19317
- if (now >= nextPollAtMs) {
19318
- if (nextPollAtMs > 0 && now - nextPollAtMs > currentIntervalMs) {
19319
- log2(
19320
- "info",
19321
- `wake-from-sleep catch-up: ${Math.round((now - nextPollAtMs + currentIntervalMs) / 1e3)}s since last poll`
19322
- );
19468
+ try {
19469
+ const now = Date.now();
19470
+ if (now >= nextAuxPollAtMs) {
19471
+ await pollAuxiliaryUsage();
19472
+ nextAuxPollAtMs = Date.now() + BASE_INTERVAL_MS;
19323
19473
  }
19324
- const accounts = discoverClaudeAccounts({ nowMs: now });
19325
- if (accounts.length === 0) {
19326
- const expired = discoverClaudeAccounts({ nowMs: now, usableOnly: false });
19327
- if (expired.length > 0) {
19328
- if (!waitingForRefresh) {
19329
- log2("info", "token expired; waiting for Claude Code to refresh it");
19474
+ if (now >= nextPollAtMs) {
19475
+ if (nextPollAtMs > 0 && now - nextPollAtMs > currentIntervalMs) {
19476
+ log2(
19477
+ "info",
19478
+ `wake-from-sleep catch-up: ${Math.round((now - nextPollAtMs + currentIntervalMs) / 1e3)}s since last poll`
19479
+ );
19480
+ }
19481
+ const accounts = discoverClaudeAccounts({ nowMs: now });
19482
+ if (accounts.length === 0) {
19483
+ const expired = discoverClaudeAccounts({ nowMs: now, usableOnly: false });
19484
+ if (expired.length > 0) {
19485
+ if (!waitingForRefresh) {
19486
+ log2("info", "token expired; waiting for Claude Code to refresh it");
19487
+ waitingForRefresh = true;
19488
+ }
19489
+ } else {
19490
+ log2("warn", "no Claude Code OAuth token found; waiting");
19330
19491
  waitingForRefresh = true;
19492
+ nextPollAtMs = now + BASE_INTERVAL_MS;
19331
19493
  }
19332
19494
  } else {
19333
- log2("warn", "no Claude Code OAuth token found; waiting");
19334
- waitingForRefresh = true;
19335
- nextPollAtMs = now + BASE_INTERVAL_MS;
19336
- }
19337
- } else {
19338
- if (waitingForRefresh) {
19339
- log2("info", "token refreshed; resuming polls");
19340
- waitingForRefresh = false;
19495
+ if (waitingForRefresh) {
19496
+ log2("info", "token refreshed; resuming polls");
19497
+ waitingForRefresh = false;
19498
+ }
19499
+ const outcome = await pollClaudeUsage();
19500
+ scheduleAfter(Date.now(), outcome);
19341
19501
  }
19342
- const outcome = await pollClaudeUsage();
19343
- scheduleAfter(Date.now(), outcome);
19344
19502
  }
19345
- }
19346
- const teamNow = Date.now();
19347
- if (teamNow >= nextTeamSyncAtMs) {
19348
- await runTeamSync(log2, void 0, {
19349
- trigger: firstTeamSync ? "boot" : "auto",
19350
- nextSyncMs: BASE_INTERVAL_MS
19351
- });
19352
- firstTeamSync = false;
19353
- nextTeamSyncAtMs = Date.now() + BASE_INTERVAL_MS;
19354
- }
19355
- if (Date.now() >= nextUpdateCheckAtMs) {
19356
- await runDaemonUpdateCheck();
19357
- }
19358
- if (Date.now() >= nextServerHealthAtMs) {
19359
- await runServerHealthCheck();
19360
- nextServerHealthAtMs = Date.now() + SERVER_HEALTH_INTERVAL_MS;
19503
+ const teamNow = Date.now();
19504
+ if (teamNow >= nextTeamSyncAtMs) {
19505
+ await runTeamSync(log2, void 0, {
19506
+ trigger: firstTeamSync ? "boot" : "auto",
19507
+ nextSyncMs: BASE_INTERVAL_MS
19508
+ });
19509
+ firstTeamSync = false;
19510
+ nextTeamSyncAtMs = Date.now() + BASE_INTERVAL_MS;
19511
+ }
19512
+ if (Date.now() >= nextUpdateCheckAtMs) {
19513
+ await runDaemonUpdateCheck();
19514
+ }
19515
+ if (Date.now() >= nextServerHealthAtMs) {
19516
+ await runServerHealthCheck();
19517
+ nextServerHealthAtMs = Date.now() + SERVER_HEALTH_INTERVAL_MS;
19518
+ }
19519
+ if (Date.now() >= nextPerceptionAtMs) {
19520
+ await runPerceptionTick();
19521
+ }
19522
+ } catch (err) {
19523
+ log2("error", `daemon tick failed: ${err.stack ?? err}`);
19361
19524
  }
19362
19525
  await sleep2(WATCHDOG_INTERVAL_MS);
19363
19526
  }
19364
19527
  }
19365
19528
  log2(
19366
19529
  "info",
19367
- `daemon started (pid=${process.pid}, interval=${BASE_INTERVAL_MS / 1e3}s, watchdog=${WATCHDOG_INTERVAL_MS / 1e3}s)`
19530
+ `daemon started (pid=${process.pid}, version=${"1.0.19"}, interval=${BASE_INTERVAL_MS / 1e3}s, watchdog=${WATCHDOG_INTERVAL_MS / 1e3}s, script=${process.argv[1] ?? "?"})`
19368
19531
  );
19369
19532
  void runLoop();
19533
+ process.on("unhandledRejection", (reason) => {
19534
+ log2("error", `unhandledRejection: ${reason instanceof Error ? reason.stack : String(reason)}`);
19535
+ });
19536
+ process.on("uncaughtException", (err) => {
19537
+ log2("error", `uncaughtException: ${err.stack ?? String(err)}`);
19538
+ process.exit(1);
19539
+ });
19370
19540
  process.on("SIGTERM", () => {
19371
- clearInterval(perceptionHandle);
19372
19541
  log2("info", `daemon stopping (pid=${process.pid})`);
19373
19542
  process.exit(0);
19374
19543
  });