@songsid/agend 2.3.2-beta.4 → 2.3.2-beta.5

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 (156) hide show
  1. package/THIRD_PARTY_NOTICES.md +40 -0
  2. package/dist/antigravity-usage-scan.d.ts +58 -0
  3. package/dist/antigravity-usage-scan.js +257 -0
  4. package/dist/antigravity-usage-scan.js.map +1 -0
  5. package/dist/antigravity-usage-worker.d.ts +1 -0
  6. package/dist/antigravity-usage-worker.js +10 -0
  7. package/dist/antigravity-usage-worker.js.map +1 -0
  8. package/dist/backend/kiro-identity.d.ts +45 -0
  9. package/dist/backend/kiro-identity.js +74 -0
  10. package/dist/backend/kiro-identity.js.map +1 -1
  11. package/dist/backend/kiro.d.ts +15 -0
  12. package/dist/backend/kiro.js +42 -5
  13. package/dist/backend/kiro.js.map +1 -1
  14. package/dist/backend/types.d.ts +6 -0
  15. package/dist/backend/types.js.map +1 -1
  16. package/dist/backend-signin-guide.d.ts +1 -0
  17. package/dist/backend-signin-guide.js +9 -0
  18. package/dist/backend-signin-guide.js.map +1 -0
  19. package/dist/backend-signin-pending.d.ts +10 -0
  20. package/dist/backend-signin-pending.js +44 -0
  21. package/dist/backend-signin-pending.js.map +1 -0
  22. package/dist/browser-backend-signins.d.ts +56 -0
  23. package/dist/browser-backend-signins.js +189 -0
  24. package/dist/browser-backend-signins.js.map +1 -0
  25. package/dist/cache-ledger.d.ts +38 -2
  26. package/dist/cache-ledger.js +133 -8
  27. package/dist/cache-ledger.js.map +1 -1
  28. package/dist/cache-prices.d.ts +2 -1
  29. package/dist/cache-prices.js +5 -2
  30. package/dist/cache-prices.js.map +1 -1
  31. package/dist/cache-service.d.ts +68 -0
  32. package/dist/cache-service.js +355 -13
  33. package/dist/cache-service.js.map +1 -1
  34. package/dist/channel/mcp-tools.js +3 -1
  35. package/dist/channel/mcp-tools.js.map +1 -1
  36. package/dist/cli.js +21 -2
  37. package/dist/cli.js.map +1 -1
  38. package/dist/config.d.ts +19 -0
  39. package/dist/config.js +25 -0
  40. package/dist/config.js.map +1 -1
  41. package/dist/cpu-quota.d.ts +23 -0
  42. package/dist/cpu-quota.js +86 -0
  43. package/dist/cpu-quota.js.map +1 -0
  44. package/dist/daemon.js +6 -3
  45. package/dist/daemon.js.map +1 -1
  46. package/dist/fleet-manager.d.ts +35 -0
  47. package/dist/fleet-manager.js +233 -11
  48. package/dist/fleet-manager.js.map +1 -1
  49. package/dist/general-knowledge/skills/credential-profiles/SKILL.md +5 -2
  50. package/dist/general-knowledge/skills/kiro-engine-migration/SKILL.md +14 -1
  51. package/dist/general-knowledge/skills/web-dashboard/SKILL.canvas-worker-off.md +6 -3
  52. package/dist/general-knowledge/skills/web-dashboard/SKILL.md +6 -3
  53. package/dist/instance-lifecycle.d.ts +9 -0
  54. package/dist/instance-lifecycle.js +27 -1
  55. package/dist/instance-lifecycle.js.map +1 -1
  56. package/dist/kiro-db-reader.d.ts +5 -0
  57. package/dist/kiro-db-reader.js +18 -0
  58. package/dist/kiro-db-reader.js.map +1 -1
  59. package/dist/kiro-engine-status.d.ts +2 -0
  60. package/dist/kiro-engine-status.js +9 -0
  61. package/dist/kiro-engine-status.js.map +1 -1
  62. package/dist/kiro-migrate.d.ts +49 -0
  63. package/dist/kiro-migrate.js +105 -0
  64. package/dist/kiro-migrate.js.map +1 -0
  65. package/dist/kiro-transcript-lane.d.ts +2 -0
  66. package/dist/kiro-transcript-lane.js.map +1 -1
  67. package/dist/kiro-transcript-worker.js +1 -0
  68. package/dist/kiro-transcript-worker.js.map +1 -1
  69. package/dist/kiro-usage-run.d.ts +7 -0
  70. package/dist/kiro-usage-run.js +39 -0
  71. package/dist/kiro-usage-run.js.map +1 -0
  72. package/dist/kiro-usage-scan.d.ts +49 -0
  73. package/dist/kiro-usage-scan.js +223 -0
  74. package/dist/kiro-usage-scan.js.map +1 -0
  75. package/dist/kiro-usage-worker.d.ts +1 -0
  76. package/dist/kiro-usage-worker.js +10 -0
  77. package/dist/kiro-usage-worker.js.map +1 -0
  78. package/dist/kiro-usage.d.ts +58 -0
  79. package/dist/kiro-usage.js +310 -0
  80. package/dist/kiro-usage.js.map +1 -0
  81. package/dist/locale.js +70 -2
  82. package/dist/locale.js.map +1 -1
  83. package/dist/log-service.js +1 -1
  84. package/dist/log-service.js.map +1 -1
  85. package/dist/login-url.d.ts +4 -0
  86. package/dist/login-url.js +22 -0
  87. package/dist/login-url.js.map +1 -0
  88. package/dist/needs-you-hub.d.ts +2 -1
  89. package/dist/needs-you-hub.js +1 -1
  90. package/dist/needs-you-hub.js.map +1 -1
  91. package/dist/needs-you.d.ts +8 -2
  92. package/dist/needs-you.js +6 -0
  93. package/dist/needs-you.js.map +1 -1
  94. package/dist/opencode-usage-scan.d.ts +28 -0
  95. package/dist/opencode-usage-scan.js +92 -0
  96. package/dist/opencode-usage-scan.js.map +1 -0
  97. package/dist/opencode-usage-worker.d.ts +1 -0
  98. package/dist/opencode-usage-worker.js +10 -0
  99. package/dist/opencode-usage-worker.js.map +1 -0
  100. package/dist/outbound-handlers.js +22 -2
  101. package/dist/outbound-handlers.js.map +1 -1
  102. package/dist/outbound-schemas.d.ts +4 -0
  103. package/dist/outbound-schemas.js +4 -0
  104. package/dist/outbound-schemas.js.map +1 -1
  105. package/dist/quickstart-api.js +13 -2
  106. package/dist/quickstart-api.js.map +1 -1
  107. package/dist/quickstart.js +2 -1
  108. package/dist/quickstart.js.map +1 -1
  109. package/dist/setup-form.d.ts +1 -1
  110. package/dist/setup-form.js +7 -1
  111. package/dist/setup-form.js.map +1 -1
  112. package/dist/setup-host.d.ts +9 -0
  113. package/dist/setup-host.js +124 -5
  114. package/dist/setup-host.js.map +1 -1
  115. package/dist/setup-signin-assets.d.ts +2 -0
  116. package/dist/setup-signin-assets.js +6 -0
  117. package/dist/setup-signin-assets.js.map +1 -0
  118. package/dist/setup-wizard.js +2 -0
  119. package/dist/setup-wizard.js.map +1 -1
  120. package/dist/structured-signin-transport.d.ts +8 -0
  121. package/dist/structured-signin-transport.js +79 -0
  122. package/dist/structured-signin-transport.js.map +1 -0
  123. package/dist/structured-signin.d.ts +131 -0
  124. package/dist/structured-signin.js +388 -0
  125. package/dist/structured-signin.js.map +1 -0
  126. package/dist/tool-permissions.js +2 -0
  127. package/dist/tool-permissions.js.map +1 -1
  128. package/dist/topic-commands.js +4 -1
  129. package/dist/topic-commands.js.map +1 -1
  130. package/dist/transcript-sources.d.ts +26 -2
  131. package/dist/transcript-sources.js +87 -40
  132. package/dist/transcript-sources.js.map +1 -1
  133. package/dist/types.d.ts +3 -2
  134. package/dist/ui/backend-signin.js +63 -10
  135. package/dist/ui/fleet-usage.js +19 -15
  136. package/dist/ui/panel-log.js +2 -2
  137. package/dist/ui/panel-needs.js +4 -4
  138. package/dist/ui/shared/app-i18n.js +2 -2
  139. package/dist/ui/shared/app.css +1 -0
  140. package/dist/ui/structured-signin.js +115 -0
  141. package/dist/usage-report.d.ts +20 -0
  142. package/dist/usage-report.js +54 -17
  143. package/dist/usage-report.js.map +1 -1
  144. package/dist/usage-rollup.d.ts +9 -1
  145. package/dist/usage-rollup.js +20 -4
  146. package/dist/usage-rollup.js.map +1 -1
  147. package/dist/web-api.d.ts +1 -0
  148. package/dist/web-api.js +99 -0
  149. package/dist/web-api.js.map +1 -1
  150. package/dist/web-auth.js +1 -1
  151. package/dist/web-auth.js.map +1 -1
  152. package/dist/web-backend-login.d.ts +1 -7
  153. package/dist/web-backend-login.js +2 -24
  154. package/dist/web-backend-login.js.map +1 -1
  155. package/package.json +2 -1
  156. package/templates/windows-shortcuts.ps1 +7 -5
@@ -1 +1 @@
1
- {"version":3,"file":"cache-prices.js","sourceRoot":"","sources":["../src/cache-prices.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,MAAM,CAAC,MAAM,cAAc,GAAG,YAAY,CAAC;AAC3C,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,0DAA0D;IAC1D,gDAAgD;IAChD,8DAA8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AG,EAAE,CAAC,OAAO,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;IACtE,OAAO,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AACrE,CAAC;AAED,qHAAqH;AACrH,MAAM,UAAU,QAAQ,CAAC,KAAgC,EAAE,YAAY,GAAG,CAAC;IACzE,MAAM,GAAG,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC5B,IAAI,CAAC,GAAG;QAAE,OAAO,IAAI,CAAC;IACtB,MAAM,GAAG,GAAG,KAAK,CAAC,GAAG,CAAE,CAAC;IACxB,OAAO,GAAG,CAAC,QAAQ,KAAK,SAAS,IAAI,YAAY,GAAG,GAAG,CAAC,QAAQ,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACjH,CAAC;AAED,sFAAsF;AACtF,MAAM,UAAU,YAAY,CAAC,KAAgC,EAAE,YAAoB;IACjF,MAAM,GAAG,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC5B,MAAM,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACzC,OAAO,CAAC,CAAC,GAAG,IAAI,GAAG,CAAC,QAAQ,KAAK,SAAS,IAAI,YAAY,GAAG,GAAG,CAAC,QAAQ,CAAC;AAC5E,CAAC"}
@@ -1,6 +1,9 @@
1
1
  import { type Ledger } from "./cache-ledger.js";
2
2
  import { type InstanceAnalysis } from "./cache-analysis.js";
3
3
  import { type UsageDays } from "./usage-rollup.js";
4
+ import type { KiroScanInput, KiroScanOutput } from "./kiro-usage-scan.js";
5
+ import type { OpencodeScanInput, OpencodeScanOutput } from "./opencode-usage-scan.js";
6
+ import { type AntigravityScanInput, type AntigravityScanOutput } from "./antigravity-usage-scan.js";
4
7
  /** An instance to analyse: a fleet.yaml instance, or a ClassicBot room (its workspace under the AgEnD home). */
5
8
  export interface CacheInstance {
6
9
  name: string;
@@ -14,12 +17,34 @@ export interface CacheInstance {
14
17
  * without one); "unrecorded" for codex (a rollout does not say which login wrote it).
15
18
  */
16
19
  profile?: string;
20
+ /** #2122: a Kiro instance's classic store — its credential profile's `data.sqlite3`; absent = `kiroDbPath()`. */
21
+ kiroDbPath?: string;
17
22
  }
18
23
  export interface CacheServiceOptions {
19
24
  instances(): CacheInstance[];
20
25
  claudeProjectsDir(): string;
21
26
  claudeKey(workingDirectory: string): string;
22
27
  codexSessionsDir(): string;
28
+ /** #2122 §10 step 3: grok's sessions, `<dir>/<encodeURIComponent(cwd)>/<session>/updates.jsonl`; absent: grok is not read. */
29
+ grokSessionsDir?(): string;
30
+ /**
31
+ * #2122 §10 step 4: muse's sessions, `<dir>/<YYYY>/<MM>/<DD>/<id>/session.jsonl` and its subagents'
32
+ * `<id>/subagent/<sub>/session.jsonl`; absent: muse is not read.
33
+ */
34
+ museSessionsDir?(): string;
35
+ /** #2122 §10 step 5: OpenCode's database (`<XDG_DATA_HOME>/opencode/opencode.db`); absent: OpenCode is not read. */
36
+ opencodeDbPath?(): string;
37
+ /** One OpenCode scan (default: on a worker thread, kiro-usage-run.ts; tests run it in-process). */
38
+ opencodeScan?(input: OpencodeScanInput): Promise<OpencodeScanOutput>;
39
+ /** #2122 §10 step 6: Antigravity's conversation databases' directory; absent: Antigravity is not read. */
40
+ antigravityDir?(): string;
41
+ /**
42
+ * agy's version as AgEnD's cached CLI probe recorded it (never a probe from here); null: not known yet. Only a version
43
+ * the field map is checked on is read (antigravityUsageSupported).
44
+ */
45
+ antigravityVersion?(): string | null;
46
+ /** One Antigravity scan (default: on a worker thread, kiro-usage-run.ts; tests run it in-process). */
47
+ antigravityScan?(input: AntigravityScanInput): Promise<AntigravityScanOutput>;
23
48
  /** Rollout files with their mtimes (the shared rollout index). */
24
49
  listRollouts(root: string): Array<{
25
50
  path: string;
@@ -38,6 +63,11 @@ export interface CacheServiceOptions {
38
63
  monotonic?: () => number;
39
64
  /** #2122: the zone days are folded in (defaults.scheduler.default_timezone, else the host's). */
40
65
  zone?: () => string;
66
+ /** #2122 §10: Kiro's shared classic store and KIRO_HOME; absent: Kiro instances are not read. */
67
+ kiroDbPath?(): string;
68
+ kiroHome?(): string;
69
+ /** One bounded Kiro scan (default: on a worker thread, kiro-usage-run.ts; tests run it in-process). */
70
+ kiroScan?(input: KiroScanInput): Promise<KiroScanOutput>;
41
71
  }
42
72
  export type CacheWindow = "24h" | "7d" | "30d";
43
73
  export declare const WINDOWS: Record<CacheWindow, number>;
@@ -122,6 +152,8 @@ export declare class CacheService {
122
152
  stop(): Promise<void>;
123
153
  scanning(): CacheReport["scanning"];
124
154
  private catchUp;
155
+ /** Whether this service is told where that reader's stores are (Kiro and Grok are optional). */
156
+ private reads;
125
157
  private zone;
126
158
  private daysPath;
127
159
  /** #2122: an instance's rollup, read once. */
@@ -154,10 +186,40 @@ export declare class CacheService {
154
186
  * measured before: its ledger's old hours are still folded into the rollup before they leave, as anyone's.
155
187
  */
156
188
  private keepHistory;
189
+ /** TUI session file → its signature and cwd, as the last Kiro scan saw them (kiro-usage-scan.ts). */
190
+ private kiroTuiIndex;
191
+ /**
192
+ * #2122 §10: one bounded scan of Kiro's stores for these instances (on a worker thread), its estimated turns added to
193
+ * their ledgers. A scan that fails or times out reads nothing and covers no one; the next pass tries again from the
194
+ * same cursors.
195
+ */
196
+ private kiroPass;
197
+ /**
198
+ * #2122 §10 step 5: one OpenCode scan for these instances (on a worker thread), its finished messages added to their
199
+ * ledgers. A failed scan reads nothing and covers no one; the cursor (`opencode:db`) stays where it was.
200
+ */
201
+ private opencodePass;
202
+ /** Antigravity database → its signature and workspace, as the last scan saw them (antigravity-usage-scan.ts). */
203
+ private antigravityIndex;
204
+ /**
205
+ * #2122 §10 step 6: one Antigravity scan for these instances (on a worker thread), its generations added to their
206
+ * ledgers. As the Kiro pass: a failed scan reads nothing and covers no one, and keeps every cursor.
207
+ */
208
+ private antigravityPass;
157
209
  /** A file that is not the one the cursor read (another inode, or shorter): keep the session's end, start at its end. */
158
210
  private followFromEnd;
159
211
  private read;
160
212
  private claudeFiles;
213
+ /** #2122 §10 step 3: a grok instance's sessions' `updates.jsonl` of the last KEEP_DAYS (its directory is its cwd). */
214
+ private grokFiles;
215
+ /** Muse session → the inode its head was read from and the workspace it names (null: none in its head). */
216
+ private readonly museWorkspace;
217
+ /**
218
+ * #2122 §10 step 4: Muse sessions (and their subagents') changed in the last KEEP_DAYS, by the instance whose working
219
+ * directory the session's `workspace_root` names. A main session records it in its first lines (read once per file,
220
+ * at most META_MAX_BYTES); a subagent session is its parent's.
221
+ */
222
+ private museFilesByInstance;
161
223
  /** Codex rollouts of the last KEEP_DAYS, by the instance whose working directory their session_meta names. */
162
224
  private codexFilesByInstance;
163
225
  /** Write what changed; whatever fails to write stays dirty and is written by a later pass. */
@@ -198,3 +260,9 @@ export declare function rolloutMeta(path: string): Promise<{
198
260
  ino: number;
199
261
  cwd: string | null;
200
262
  } | null | "unreadable">;
263
+ /**
264
+ * #2122 §10 step 4: the workspace a Muse session's first lines name (`payload.record.workspace_root`, in its
265
+ * `runtime.session.metadata` record), read with one bounded read; null: none there (yet); "unreadable": there and not
266
+ * readable.
267
+ */
268
+ export declare function museHead(path: string): Promise<string | null | "unreadable">;
@@ -13,20 +13,25 @@
13
13
  * already counted, and counting them twice would be worse than missing a rewrite. The inode is checked on the
14
14
  * descriptor actually read, not only on the listing. Two instances whose transcripts land in the same place (the same
15
15
  * working directory: one Claude project, one Codex cwd) cannot be told apart: neither is analysed, both say so.
16
+ * Kiro (#2122 §10): its stores hold no token counts, so its turns are estimated (kiro-usage.ts) by a scan on a worker
17
+ * thread (kiro-usage-run.ts) — for the usage report only; the cache analysis leaves Kiro out.
16
18
  */
17
19
  import { mkdir, open, readdir, readFile, realpath, rename, stat, writeFile } from "node:fs/promises";
18
20
  import { dirname, join, resolve } from "node:path";
19
21
  import { scanJsonl } from "./cache-scan.js";
20
- import { addTurn, claudeLine, codexLine, emptyLedger, KEEP_DAYS, pruneLedger, reviveLedger } from "./cache-ledger.js";
22
+ import { addTurn, claudeLine, codexLine, emptyLedger, grokLine, museLine, KEEP_DAYS, pruneLedger, reviveLedger } from "./cache-ledger.js";
21
23
  import { analyzeLedger } from "./cache-analysis.js";
22
24
  import { PRICES_CHECKED, PRICE_SOURCES } from "./cache-prices.js";
23
25
  import { addCoverage, foldHours, pruneDays, readDays, writeDays } from "./usage-rollup.js";
26
+ import { antigravityUsageSupported } from "./antigravity-usage-scan.js";
24
27
  export const WINDOWS = { "24h": 86_400_000, "7d": 7 * 86_400_000, "30d": 30 * 86_400_000 };
25
28
  /** A window name as asked (a query string, a tool argument); anything unknown is the default, 7 days. */
26
29
  export const cacheWindow = (w) => (Object.prototype.hasOwnProperty.call(WINDOWS, w) ? w : "7d");
27
30
  const DAY = 86_400_000;
28
31
  const META_MAX_BYTES = 256 * 1024; // session_meta carries the instructions (~22 KB in real rollouts)
29
- const kindOf = (backend) => (backend === "claude-code" ? "claude" : backend === "codex" ? "codex" : null);
32
+ const kindOf = (backend) => (backend === "claude-code" ? "claude" : backend === "codex" ? "codex" : backend === "kiro-cli" ? "kiro" : backend === "grok" ? "grok" : backend === "muse" ? "muse" : backend === "opencode" ? "opencode" : backend === "antigravity" ? "antigravity" : null);
33
+ /** The readers the cache analysis covers; the others are in the usage report only. */
34
+ const analysed = (kind) => kind === "claude" || kind === "codex";
30
35
  const sleep = (ms) => new Promise((r) => { const h = setTimeout(r, ms); h.unref?.(); });
31
36
  const dict = () => Object.create(null);
32
37
  /** An error that means the path is not there (never was, or went): a real absence, not a failure to read it. */
@@ -126,6 +131,11 @@ export class CacheService {
126
131
  await sleep(this.o.pauseMs ?? 25);
127
132
  }
128
133
  }
134
+ /** Whether this service is told where that reader's stores are (Kiro and Grok are optional). */
135
+ reads(kind) {
136
+ return kind === "kiro" ? !!this.o.kiroDbPath : kind === "grok" ? !!this.o.grokSessionsDir : kind === "muse" ? !!this.o.museSessionsDir
137
+ : kind === "opencode" ? !!this.o.opencodeDbPath : kind === "antigravity" ? !!this.o.antigravityDir && antigravityUsageSupported(this.o.antigravityVersion?.() ?? null) : true;
138
+ }
129
139
  zone() { return this.o.zone?.() || Intl.DateTimeFormat().resolvedOptions().timeZone || "UTC"; }
130
140
  daysPath(inst) { return join(dirname(inst.ledgerPath), "usage-days.json"); }
131
141
  /** #2122: an instance's rollup, read once. */
@@ -167,7 +177,8 @@ export class CacheService {
167
177
  const insts = this.o.instances();
168
178
  const shared = await this.shared(insts);
169
179
  for (const inst of insts) {
170
- if (!kindOf(inst.backend) || shared.has(inst.name) || this.unread.has(inst.name))
180
+ const kind = kindOf(inst.backend);
181
+ if (!kind || !this.reads(kind) || shared.has(inst.name) || this.unread.has(inst.name))
171
182
  continue;
172
183
  const next = structuredClone(await this.rollupFor(inst));
173
184
  addCoverage(next, now - KEEP_DAYS * DAY, now);
@@ -202,7 +213,7 @@ export class CacheService {
202
213
  const kind = kindOf(i.backend);
203
214
  if (!kind)
204
215
  continue;
205
- const keys = kind === "claude" ? [`claude|${this.o.claudeKey(i.workingDirectory)}`] : (await cwdKeys(i.workingDirectory)).map((k) => `codex|${k}`);
216
+ const keys = kind === "claude" ? [`claude|${this.o.claudeKey(i.workingDirectory)}`] : (await cwdKeys(i.workingDirectory)).map((k) => `${kind}|${k}`);
206
217
  for (const k of keys)
207
218
  groups.set(k, [...(groups.get(k) ?? []), i.name]);
208
219
  }
@@ -233,6 +244,13 @@ export class CacheService {
233
244
  const insts = this.o.instances();
234
245
  const shared = await this.shared(insts);
235
246
  const codex = await this.codexFilesByInstance(insts.filter((i) => !shared.has(i.name)), cutoff);
247
+ const muse = await this.museFilesByInstance(insts.filter((i) => kindOf(i.backend) === "muse" && !shared.has(i.name)), cutoff);
248
+ const kiro = await this.kiroPass(insts.filter((i) => kindOf(i.backend) === "kiro" && !shared.has(i.name)), cutoff, budget);
249
+ budget -= kiro.read;
250
+ await this.opencodePass(insts.filter((i) => kindOf(i.backend) === "opencode" && !shared.has(i.name)), cutoff);
251
+ await this.antigravityPass(insts.filter((i) => kindOf(i.backend) === "antigravity" && !shared.has(i.name)), cutoff);
252
+ behindBytes += kiro.behindBytes;
253
+ behindFiles += kiro.behindSources;
236
254
  for (const inst of insts) {
237
255
  if (this.stopped)
238
256
  break;
@@ -242,13 +260,22 @@ export class CacheService {
242
260
  continue;
243
261
  }
244
262
  const ledger = await this.ledgerFor(inst);
245
- const files = kind === "claude" ? await this.claudeFiles(inst, cutoff) : codex.get(inst.name) ?? [];
263
+ if (kind === "kiro" || kind === "opencode" || kind === "antigravity") {
264
+ pruneLedger(ledger, cutoff, await this.foldBeforePrune(inst, ledger, cutoff));
265
+ continue;
266
+ }
267
+ const files = kind === "claude" ? await this.claudeFiles(inst, cutoff) : kind === "grok" ? await this.grokFiles(inst, cutoff)
268
+ : kind === "muse" ? muse.get(inst.name) ?? [] : codex.get(inst.name) ?? [];
269
+ // A listing that could not read everything is no inventory: a cursor it missed stays, or the file would be counted
270
+ // again from its start once it is listed (Prism #2605). An instance whose store stays unreadable keeps its cursors
271
+ // until it is readable again — bounded by its own files.
246
272
  const listed = new Set(files.map((f) => f.path));
247
- for (const path of Object.keys(ledger.files))
248
- if (!listed.has(path)) {
249
- delete ledger.files[path];
250
- this.dirty.add(inst.name);
251
- }
273
+ if (!this.unread.has(inst.name))
274
+ for (const path of Object.keys(ledger.files))
275
+ if (!listed.has(path)) {
276
+ delete ledger.files[path];
277
+ this.dirty.add(inst.name);
278
+ }
252
279
  for (const f of files) {
253
280
  let cur = ledger.files[f.path];
254
281
  if (!cur) {
@@ -303,6 +330,171 @@ export class CacheService {
303
330
  if (Object.keys(ledger.hours).length !== before)
304
331
  this.dirty.add(inst.name);
305
332
  }
333
+ /** TUI session file → its signature and cwd, as the last Kiro scan saw them (kiro-usage-scan.ts). */
334
+ kiroTuiIndex = Object.create(null);
335
+ /**
336
+ * #2122 §10: one bounded scan of Kiro's stores for these instances (on a worker thread), its estimated turns added to
337
+ * their ledgers. A scan that fails or times out reads nothing and covers no one; the next pass tries again from the
338
+ * same cursors.
339
+ */
340
+ async kiroPass(insts, cutoff, budget) {
341
+ const none = { read: 0, behindBytes: 0, behindSources: 0 };
342
+ if (!insts.length)
343
+ return none;
344
+ const dbPath = this.o.kiroDbPath?.(), home = this.o.kiroHome?.();
345
+ if (!dbPath || !home)
346
+ return none;
347
+ const ledgers = new Map();
348
+ const input = { kiroHome: home, cutoff, maxBytes: Math.max(budget, 1), tuiIndex: this.kiroTuiIndex, instances: [] };
349
+ for (const inst of insts) {
350
+ const ledger = await this.ledgerFor(inst);
351
+ ledgers.set(inst.name, ledger);
352
+ const cursors = Object.create(null);
353
+ for (const [k, f] of Object.entries(ledger.files))
354
+ if (f.kind === "kiro" && f.sig !== undefined)
355
+ cursors[k] = { sig: f.sig, after: f.after ?? cutoff };
356
+ input.instances.push({ name: inst.name, cwds: await cwdKeys(inst.workingDirectory), dbPath: inst.kiroDbPath ?? dbPath, cursors });
357
+ }
358
+ let out;
359
+ try {
360
+ out = await (this.o.kiroScan ?? (async (i) => (await import("./kiro-usage-run.js")).runKiroUsageScan(i)))(input);
361
+ }
362
+ catch (err) {
363
+ this.o.log?.("warn", "usage: the Kiro scan failed; it is tried again next pass", { err: String(err) });
364
+ for (const i of insts)
365
+ this.unread.add(i.name);
366
+ return none;
367
+ }
368
+ this.kiroTuiIndex = out.tuiIndex;
369
+ const byName = new Map(insts.map((i) => [i.name, i]));
370
+ for (const r of out.instances) {
371
+ const inst = byName.get(r.name), ledger = ledgers.get(r.name);
372
+ if (!inst || !ledger)
373
+ continue;
374
+ // A scan that could not read everything is no inventory: its cursors stay (Prism #2605: dropping them would count a
375
+ // source again from the start once it is readable).
376
+ if (r.failed)
377
+ this.unread.add(r.name);
378
+ else {
379
+ const live = new Set(r.live);
380
+ for (const [k, f] of Object.entries(ledger.files))
381
+ if (f.kind === "kiro" && !live.has(k)) {
382
+ delete ledger.files[k];
383
+ this.dirty.add(r.name);
384
+ }
385
+ }
386
+ for (const u of r.updates) {
387
+ const cur = ledger.files[u.key] ??= { kind: "kiro", ino: 0, offset: 0 };
388
+ for (const t of [...u.turns].sort((a, b) => a.t - b.t))
389
+ addTurn(ledger, cur, t, cutoff, inst.profile ?? "default");
390
+ cur.sig = u.sig;
391
+ cur.after = u.after;
392
+ this.dirty.add(r.name);
393
+ }
394
+ }
395
+ return { read: out.readBytes, behindBytes: out.behindBytes, behindSources: out.behindSources };
396
+ }
397
+ /**
398
+ * #2122 §10 step 5: one OpenCode scan for these instances (on a worker thread), its finished messages added to their
399
+ * ledgers. A failed scan reads nothing and covers no one; the cursor (`opencode:db`) stays where it was.
400
+ */
401
+ async opencodePass(insts, cutoff) {
402
+ const dbPath = this.o.opencodeDbPath?.();
403
+ if (!insts.length || !dbPath)
404
+ return;
405
+ const ledgers = new Map();
406
+ const input = { dbPath, cutoff, instances: [] };
407
+ for (const inst of insts) {
408
+ const ledger = await this.ledgerFor(inst);
409
+ ledgers.set(inst.name, ledger);
410
+ const c = ledger.files["opencode:db"];
411
+ input.instances.push({ name: inst.name, cwds: await cwdKeys(inst.workingDirectory), cursor: c ? { after: c.after ?? cutoff, ids: c.ids ?? [] } : null });
412
+ }
413
+ let out;
414
+ try {
415
+ out = await (this.o.opencodeScan ?? (async (i) => (await import("./kiro-usage-run.js")).runOpencodeUsageScan(i)))(input);
416
+ }
417
+ catch (err) {
418
+ this.o.log?.("warn", "usage: the OpenCode scan failed; it is tried again next pass", { err: String(err) });
419
+ for (const i of insts)
420
+ this.unread.add(i.name);
421
+ return;
422
+ }
423
+ const byName = new Map(insts.map((i) => [i.name, i]));
424
+ for (const r of out.instances) {
425
+ const inst = byName.get(r.name), ledger = ledgers.get(r.name);
426
+ if (!inst || !ledger)
427
+ continue;
428
+ if (r.failed) {
429
+ this.unread.add(r.name);
430
+ continue;
431
+ }
432
+ const cur = ledger.files["opencode:db"] ??= { kind: "opencode", ino: 0, offset: 0 };
433
+ for (const t of [...r.turns].sort((a, b) => a.t - b.t))
434
+ addTurn(ledger, cur, t, cutoff, inst.profile ?? "default");
435
+ if (r.turns.length || cur.after !== r.cursor.after)
436
+ this.dirty.add(r.name);
437
+ cur.after = r.cursor.after;
438
+ cur.ids = r.cursor.ids;
439
+ }
440
+ }
441
+ /** Antigravity database → its signature and workspace, as the last scan saw them (antigravity-usage-scan.ts). */
442
+ antigravityIndex = Object.create(null);
443
+ /**
444
+ * #2122 §10 step 6: one Antigravity scan for these instances (on a worker thread), its generations added to their
445
+ * ledgers. As the Kiro pass: a failed scan reads nothing and covers no one, and keeps every cursor.
446
+ */
447
+ async antigravityPass(insts, cutoff) {
448
+ const dir = this.o.antigravityDir?.();
449
+ if (!insts.length || !dir || !this.reads("antigravity"))
450
+ return;
451
+ const ledgers = new Map();
452
+ const input = { dir, cutoff, index: this.antigravityIndex, instances: [] };
453
+ for (const inst of insts) {
454
+ const ledger = await this.ledgerFor(inst);
455
+ ledgers.set(inst.name, ledger);
456
+ const cursors = Object.create(null);
457
+ for (const [k, f] of Object.entries(ledger.files))
458
+ if (f.kind === "antigravity" && f.sig !== undefined)
459
+ cursors[k] = { sig: f.sig, after: f.after ?? -1 };
460
+ input.instances.push({ name: inst.name, cwds: await cwdKeys(inst.workingDirectory), cursors });
461
+ }
462
+ let out;
463
+ try {
464
+ out = await (this.o.antigravityScan ?? (async (i) => (await import("./kiro-usage-run.js")).runAntigravityUsageScan(i)))(input);
465
+ }
466
+ catch (err) {
467
+ this.o.log?.("warn", "usage: the Antigravity scan failed; it is tried again next pass", { err: String(err) });
468
+ for (const i of insts)
469
+ this.unread.add(i.name);
470
+ return;
471
+ }
472
+ this.antigravityIndex = out.index;
473
+ const byName = new Map(insts.map((i) => [i.name, i]));
474
+ for (const r of out.instances) {
475
+ const inst = byName.get(r.name), ledger = ledgers.get(r.name);
476
+ if (!inst || !ledger)
477
+ continue;
478
+ if (r.failed)
479
+ this.unread.add(r.name);
480
+ else {
481
+ const live = new Set(r.live);
482
+ for (const [k, f] of Object.entries(ledger.files))
483
+ if (f.kind === "antigravity" && !live.has(k)) {
484
+ delete ledger.files[k];
485
+ this.dirty.add(r.name);
486
+ }
487
+ }
488
+ for (const u of r.updates) {
489
+ const cur = ledger.files[u.key] ??= { kind: "antigravity", ino: 0, offset: 0 };
490
+ for (const t of [...u.turns].sort((a, b) => a.t - b.t))
491
+ addTurn(ledger, cur, t, cutoff, inst.profile ?? "default");
492
+ cur.sig = u.sig;
493
+ cur.after = u.after;
494
+ this.dirty.add(r.name);
495
+ }
496
+ }
497
+ }
306
498
  /** A file that is not the one the cursor read (another inode, or shorter): keep the session's end, start at its end. */
307
499
  followFromEnd(ledger, path, cur, ino, size) {
308
500
  const next = { kind: cur.kind, ino, offset: size };
@@ -317,7 +509,12 @@ export class CacheService {
317
509
  async read(ledger, cur, path, budget, cutoff, profile) {
318
510
  try {
319
511
  const res = await scanJsonl(path, cur.offset, { maxBytes: budget, ino: cur.ino }, (line) => {
320
- const turn = cur.kind === "claude" ? claudeLine(line, cur) : codexLine(line, cur);
512
+ if (cur.kind === "grok") {
513
+ for (const t of grokLine(line, cur))
514
+ addTurn(ledger, cur, t, cutoff, profile);
515
+ return;
516
+ }
517
+ const turn = cur.kind === "claude" ? claudeLine(line, cur) : cur.kind === "muse" ? museLine(line, cur) : codexLine(line, cur);
321
518
  if (turn)
322
519
  addTurn(ledger, cur, turn, cutoff, profile);
323
520
  });
@@ -370,6 +567,120 @@ export class CacheService {
370
567
  }
371
568
  return out;
372
569
  }
570
+ /** #2122 §10 step 3: a grok instance's sessions' `updates.jsonl` of the last KEEP_DAYS (its directory is its cwd). */
571
+ async grokFiles(inst, cutoff) {
572
+ const root = this.o.grokSessionsDir?.();
573
+ if (!root)
574
+ return [];
575
+ const out = [];
576
+ for (const cwd of await cwdKeys(inst.workingDirectory)) {
577
+ const dir = join(root, encodeURIComponent(cwd));
578
+ let names;
579
+ // Sessions are directories; grok also keeps plain files there (prompt_history.jsonl), which are not sessions.
580
+ try {
581
+ names = (await readdir(dir, { withFileTypes: true })).filter((e) => e.isDirectory()).map((e) => e.name);
582
+ }
583
+ catch (err) {
584
+ if (!gone(err))
585
+ this.unread.add(inst.name);
586
+ continue;
587
+ }
588
+ for (const n of names) {
589
+ const path = join(dir, n, "updates.jsonl");
590
+ try {
591
+ const st = await stat(path);
592
+ if (st.isFile() && st.mtimeMs >= cutoff)
593
+ out.push({ path, ino: st.ino, size: st.size });
594
+ }
595
+ catch (err) {
596
+ if (!gone(err))
597
+ this.unread.add(inst.name);
598
+ }
599
+ }
600
+ }
601
+ return out;
602
+ }
603
+ /** Muse session → the inode its head was read from and the workspace it names (null: none in its head). */
604
+ museWorkspace = new Map();
605
+ /**
606
+ * #2122 §10 step 4: Muse sessions (and their subagents') changed in the last KEEP_DAYS, by the instance whose working
607
+ * directory the session's `workspace_root` names. A main session records it in its first lines (read once per file,
608
+ * at most META_MAX_BYTES); a subagent session is its parent's.
609
+ */
610
+ async museFilesByInstance(insts, cutoff) {
611
+ const out = new Map();
612
+ const root = this.o.museSessionsDir?.();
613
+ if (!insts.length || !root)
614
+ return out;
615
+ const byCwd = new Map();
616
+ for (const i of insts)
617
+ for (const k of await cwdKeys(i.workingDirectory))
618
+ byCwd.set(k, i.name);
619
+ const unlisted = () => { for (const i of insts)
620
+ this.unread.add(i.name); };
621
+ // Directories only, and never muse's own dot-entries (`.msp-view-v1/`, lock and marker files): a plain file there is no
622
+ // session, and listing through it would fail every pass (Fable #2606).
623
+ const list = async (dir) => {
624
+ try {
625
+ return (await readdir(dir, { withFileTypes: true })).filter((e) => e.isDirectory() && !e.name.startsWith(".")).map((e) => e.name);
626
+ }
627
+ catch (err) {
628
+ if (!gone(err))
629
+ unlisted();
630
+ return [];
631
+ }
632
+ };
633
+ const live = new Set();
634
+ for (const y of await list(root))
635
+ for (const m of await list(join(root, y)))
636
+ for (const d of await list(join(root, y, m))) {
637
+ for (const id of await list(join(root, y, m, d))) {
638
+ const dir = join(root, y, m, d, id), main = join(dir, "session.jsonl");
639
+ const files = [main, ...(await list(join(dir, "subagent"))).map((s) => join(dir, "subagent", s, "session.jsonl"))];
640
+ const stats = [];
641
+ for (const path of files) {
642
+ try {
643
+ const st = await stat(path);
644
+ if (st.isFile() && st.mtimeMs >= cutoff)
645
+ stats.push({ path, ino: st.ino, size: st.size });
646
+ }
647
+ catch (err) {
648
+ if (!gone(err))
649
+ unlisted();
650
+ }
651
+ }
652
+ if (!stats.length)
653
+ continue;
654
+ live.add(main);
655
+ let st;
656
+ try {
657
+ st = await stat(main);
658
+ }
659
+ catch (err) {
660
+ if (!gone(err))
661
+ unlisted();
662
+ continue;
663
+ }
664
+ let meta = this.museWorkspace.get(main);
665
+ if (!meta || meta.ino !== st.ino || meta.ws === null) {
666
+ const head = await museHead(main);
667
+ if (head === "unreadable") {
668
+ unlisted();
669
+ continue;
670
+ }
671
+ meta = { ino: st.ino, ws: head };
672
+ this.museWorkspace.set(main, meta);
673
+ }
674
+ const name = meta.ws ? byCwd.get(resolve(meta.ws)) : undefined;
675
+ if (name)
676
+ out.set(name, [...(out.get(name) ?? []), ...stats]);
677
+ }
678
+ }
679
+ for (const p of this.museWorkspace.keys())
680
+ if (!live.has(p))
681
+ this.museWorkspace.delete(p);
682
+ return out;
683
+ }
373
684
  /** Codex rollouts of the last KEEP_DAYS, by the instance whose working directory their session_meta names. */
374
685
  async codexFilesByInstance(insts, cutoff) {
375
686
  const out = new Map();
@@ -505,7 +816,7 @@ export class CacheService {
505
816
  // `status` is about collecting now; what it measured before (another backend, a directory it did not share yet)
506
817
  // is in `ledger` and `days` either way.
507
818
  const kind = kindOf(inst.backend), others = shared.get(inst.name);
508
- if (!kind)
819
+ if (!kind || !this.reads(kind))
509
820
  out.push({ inst, status: inst.backend.startsWith("kiro") ? "credit_billed" : "unsupported", ledger, days });
510
821
  else if (others)
511
822
  out.push({ inst, status: "shared", with: others, ledger, days });
@@ -525,7 +836,8 @@ export class CacheService {
525
836
  const shared = await this.shared(insts);
526
837
  for (const inst of insts) {
527
838
  const kind = kindOf(inst.backend);
528
- if (!kind) {
839
+ // Kiro is in the usage report (estimated), not in the cache analysis: it records no cache use to analyse.
840
+ if (!analysed(kind)) {
529
841
  instances.push({ name: inst.name, backend: inst.backend, status: inst.backend.startsWith("kiro") ? "credit_billed" : "unsupported" });
530
842
  continue;
531
843
  }
@@ -599,6 +911,36 @@ export async function rolloutMeta(path) {
599
911
  await fh?.close().catch(() => { });
600
912
  }
601
913
  }
914
+ /**
915
+ * #2122 §10 step 4: the workspace a Muse session's first lines name (`payload.record.workspace_root`, in its
916
+ * `runtime.session.metadata` record), read with one bounded read; null: none there (yet); "unreadable": there and not
917
+ * readable.
918
+ */
919
+ export async function museHead(path) {
920
+ let fh;
921
+ try {
922
+ fh = await open(path, "r");
923
+ const buf = Buffer.alloc(META_MAX_BYTES);
924
+ const { bytesRead } = await fh.read(buf, 0, META_MAX_BYTES, 0);
925
+ for (const line of buf.toString("utf8", 0, bytesRead).split("\n")) {
926
+ if (line.indexOf("workspace_root") === -1)
927
+ continue;
928
+ try {
929
+ const ws = JSON.parse(line).payload?.record?.workspace_root;
930
+ if (typeof ws === "string" && ws)
931
+ return ws;
932
+ }
933
+ catch { /* the last, cut line */ }
934
+ }
935
+ return null;
936
+ }
937
+ catch (err) {
938
+ return gone(err) ? null : "unreadable";
939
+ }
940
+ finally {
941
+ await fh?.close().catch(() => { });
942
+ }
943
+ }
602
944
  async function writeAtomic(path, text) {
603
945
  const tmp = `${path}.${process.pid}.tmp`;
604
946
  try {