@phnx-labs/agents-cli 1.22.42 → 1.22.44

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 (256) hide show
  1. package/CHANGELOG.md +149 -0
  2. package/README.md +15 -13
  3. package/dist/bootstrap.js +33 -13
  4. package/dist/cli/command-registry.d.ts +0 -8
  5. package/dist/cli/command-registry.js +1 -25
  6. package/dist/commands/alias.d.ts +7 -4
  7. package/dist/commands/alias.js +33 -8
  8. package/dist/commands/apply.d.ts +7 -10
  9. package/dist/commands/apply.js +15 -35
  10. package/dist/commands/artifacts.js +4 -5
  11. package/dist/commands/audit.d.ts +6 -6
  12. package/dist/commands/audit.js +12 -12
  13. package/dist/commands/auth.js +14 -6
  14. package/dist/commands/beta.d.ts +7 -1
  15. package/dist/commands/beta.js +16 -9
  16. package/dist/commands/commands.js +1 -1
  17. package/dist/commands/computer.js +20 -6
  18. package/dist/commands/daemon.js +1 -1
  19. package/dist/commands/doctor.d.ts +4 -2
  20. package/dist/commands/doctor.js +21 -9
  21. package/dist/commands/events.d.ts +2 -2
  22. package/dist/commands/events.js +6 -5
  23. package/dist/commands/exec.d.ts +1 -1
  24. package/dist/commands/exec.js +11 -6
  25. package/dist/commands/factory.d.ts +1 -1
  26. package/dist/commands/feed.js +1 -30
  27. package/dist/commands/fleet-capture.d.ts +1 -1
  28. package/dist/commands/fleet-capture.js +4 -5
  29. package/dist/commands/harness.js +4 -52
  30. package/dist/commands/hooks.js +1 -1
  31. package/dist/commands/insights.d.ts +1 -1
  32. package/dist/commands/insights.js +3 -2
  33. package/dist/commands/menubar.js +58 -1
  34. package/dist/commands/monitors.js +1 -1
  35. package/dist/commands/org.d.ts +5 -0
  36. package/dist/commands/org.js +83 -29
  37. package/dist/commands/output.js +2 -2
  38. package/dist/commands/profiles.js +2 -2
  39. package/dist/commands/prune.js +5 -4
  40. package/dist/commands/routines.js +43 -25
  41. package/dist/commands/routines.test-fixture.d.ts +86 -0
  42. package/dist/commands/routines.test-fixture.js +345 -0
  43. package/dist/commands/sessions-picker.js +124 -122
  44. package/dist/commands/sessions.test-fixture.d.ts +24 -0
  45. package/dist/commands/sessions.test-fixture.js +224 -0
  46. package/dist/commands/setup.js +9 -1
  47. package/dist/commands/share.d.ts +9 -10
  48. package/dist/commands/share.js +68 -50
  49. package/dist/commands/skills.js +1 -1
  50. package/dist/commands/snapshot.d.ts +1 -1
  51. package/dist/commands/snapshot.js +4 -4
  52. package/dist/commands/ssh.js +15 -62
  53. package/dist/commands/status.d.ts +4 -2
  54. package/dist/commands/status.js +10 -7
  55. package/dist/commands/subagents.js +1 -1
  56. package/dist/commands/sync.d.ts +1 -0
  57. package/dist/commands/sync.js +29 -2
  58. package/dist/commands/view.js +11 -2
  59. package/dist/commands/webhook.js +1 -1
  60. package/dist/lib/accounting/rotate.d.ts +5 -3
  61. package/dist/lib/accounting/rotate.js +36 -7
  62. package/dist/lib/accounting/usage.d.ts +18 -4
  63. package/dist/lib/accounting/usage.js +138 -27
  64. package/dist/lib/agent-spec/agents.d.ts +7 -7
  65. package/dist/lib/agent-spec/agents.js +15 -15
  66. package/dist/lib/analytics/mix-commands.d.ts +6 -28
  67. package/dist/lib/analytics/mix-commands.js +14 -40
  68. package/dist/lib/audit/log.d.ts +2 -2
  69. package/dist/lib/audit/log.js +2 -2
  70. package/dist/lib/beta.js +1 -1
  71. package/dist/lib/browser/domain-skills.d.ts +26 -6
  72. package/dist/lib/browser/domain-skills.js +81 -43
  73. package/dist/lib/cloud/rush.d.ts +0 -15
  74. package/dist/lib/cloud/rush.js +0 -35
  75. package/dist/lib/crabbox/runtimes.d.ts +6 -2
  76. package/dist/lib/crabbox/runtimes.js +21 -5
  77. package/dist/lib/daemon/daemon.js +97 -58
  78. package/dist/lib/daemon/daemon.test-fixture.d.ts +24 -0
  79. package/dist/lib/daemon/daemon.test-fixture.js +71 -0
  80. package/dist/lib/daemon/runner.d.ts +18 -1
  81. package/dist/lib/daemon/runner.js +105 -11
  82. package/dist/lib/daemon-ticks.d.ts +38 -1
  83. package/dist/lib/daemon-ticks.js +52 -5
  84. package/dist/lib/device-config.js +1 -2
  85. package/dist/lib/devices/discovery-policy.d.ts +3 -3
  86. package/dist/lib/devices/discovery-policy.js +3 -3
  87. package/dist/lib/devices/doctor-findings.js +1 -1
  88. package/dist/lib/devices/fleet.d.ts +4 -8
  89. package/dist/lib/devices/fleet.js +3 -15
  90. package/dist/lib/devices/health-report.js +4 -4
  91. package/dist/lib/devices/pool.d.ts +0 -6
  92. package/dist/lib/devices/pool.js +0 -6
  93. package/dist/lib/devices/registry.d.ts +0 -15
  94. package/dist/lib/devices/registry.js +0 -9
  95. package/dist/lib/devices/stats-cache.d.ts +12 -0
  96. package/dist/lib/devices/stats-cache.js +24 -5
  97. package/dist/lib/drift-sync.d.ts +1 -1
  98. package/dist/lib/drift-sync.js +2 -2
  99. package/dist/lib/drift.d.ts +1 -1
  100. package/dist/lib/exec.js +13 -3
  101. package/dist/lib/fleet/capture.d.ts +1 -1
  102. package/dist/lib/fleet/manifest.js +1 -1
  103. package/dist/lib/fleet/remote-login.d.ts +2 -2
  104. package/dist/lib/fleet/remote-login.js +3 -4
  105. package/dist/lib/format.d.ts +9 -0
  106. package/dist/lib/format.js +16 -0
  107. package/dist/lib/github/pr-mergeable.d.ts +49 -0
  108. package/dist/lib/github/pr-mergeable.js +157 -0
  109. package/dist/lib/github/pr-verdict.d.ts +67 -0
  110. package/dist/lib/github/pr-verdict.js +72 -0
  111. package/dist/lib/harness/adapter.d.ts +6 -5
  112. package/dist/lib/hosts/dispatch.d.ts +2 -0
  113. package/dist/lib/hosts/dispatch.js +8 -1
  114. package/dist/lib/hosts/passthrough.d.ts +10 -0
  115. package/dist/lib/hosts/passthrough.js +28 -7
  116. package/dist/lib/hosts/providers/devices.js +1 -13
  117. package/dist/lib/hosts/ready.d.ts +12 -3
  118. package/dist/lib/hosts/ready.js +27 -12
  119. package/dist/lib/hosts/registry.d.ts +4 -5
  120. package/dist/lib/hosts/registry.js +3 -7
  121. package/dist/lib/hosts/session-index.js +1 -1
  122. package/dist/lib/installations/shims.js +1 -1
  123. package/dist/lib/installations/versions.d.ts +40 -0
  124. package/dist/lib/installations/versions.js +78 -4
  125. package/dist/lib/menubar/MenubarHelper.app/Contents/Info.plist +1 -5
  126. package/dist/lib/menubar/MenubarHelper.app/Contents/MacOS/MenubarHelper +0 -0
  127. package/dist/lib/menubar/MenubarHelper.app/Contents/_CodeSignature/CodeResources +2 -15
  128. package/dist/lib/menubar/install-menubar.d.ts +109 -0
  129. package/dist/lib/menubar/install-menubar.js +218 -12
  130. package/dist/lib/monitors/config.d.ts +2 -2
  131. package/dist/lib/monitors/config.js +3 -2
  132. package/dist/lib/origin-machine.d.ts +18 -0
  133. package/dist/lib/origin-machine.js +34 -0
  134. package/dist/lib/perf/db.js +1 -1
  135. package/dist/lib/perf/spool.js +1 -1
  136. package/dist/lib/prix-account.d.ts +2 -1
  137. package/dist/lib/prix-account.js +2 -1
  138. package/dist/lib/profiles.d.ts +7 -0
  139. package/dist/lib/profiles.js +26 -1
  140. package/dist/lib/remote-agents-json.js +1 -7
  141. package/dist/lib/routines-placement.d.ts +1 -1
  142. package/dist/lib/routines-placement.js +1 -1
  143. package/dist/lib/sandbox.d.ts +24 -0
  144. package/dist/lib/sandbox.js +101 -0
  145. package/dist/lib/scheduling/routines.d.ts +18 -9
  146. package/dist/lib/scheduling/routines.js +16 -8
  147. package/dist/lib/secrets/Agents CLI.app/Contents/CodeResources +0 -0
  148. package/dist/lib/secrets/Agents CLI.app/Contents/Info.plist +0 -2
  149. package/dist/lib/secrets/Agents CLI.app/Contents/MacOS/Agents CLI +0 -0
  150. package/dist/lib/secrets/Agents CLI.app/Contents/_CodeSignature/CodeResources +1 -13
  151. package/dist/lib/secrets/agent.js +9 -1
  152. package/dist/lib/secrets/index.js +1 -1
  153. package/dist/lib/secrets/list-filter.js +1 -1
  154. package/dist/lib/service-manifest.d.ts +20 -0
  155. package/dist/lib/service-manifest.js +34 -0
  156. package/dist/lib/session/active.d.ts +4 -16
  157. package/dist/lib/session/active.js +2 -6
  158. package/dist/lib/session/cloud.js +1 -1
  159. package/dist/lib/session/db.d.ts +13 -98
  160. package/dist/lib/session/db.js +5 -12
  161. package/dist/lib/session/discover.d.ts +5 -81
  162. package/dist/lib/session/discover.js +5 -5
  163. package/dist/lib/session/fork.js +1 -1
  164. package/dist/lib/session/live-metadata.js +1 -1
  165. package/dist/lib/session/origin-machine.d.ts +1 -18
  166. package/dist/lib/session/origin-machine.js +4 -34
  167. package/dist/lib/session/relative-time.d.ts +1 -44
  168. package/dist/lib/session/relative-time.js +4 -120
  169. package/dist/lib/session/remote/remote-bundle.d.ts +12 -0
  170. package/dist/lib/session/remote/remote-bundle.js +61 -0
  171. package/dist/lib/session/remote/remote-list.d.ts +148 -0
  172. package/dist/lib/session/remote/remote-list.js +607 -0
  173. package/dist/lib/session/remote/remote.d.ts +132 -0
  174. package/dist/lib/session/remote/remote.js +314 -0
  175. package/dist/lib/session/remote/watch.d.ts +101 -0
  176. package/dist/lib/session/remote/watch.js +241 -0
  177. package/dist/lib/session/remote-bundle.d.ts +1 -12
  178. package/dist/lib/session/remote-bundle.js +3 -61
  179. package/dist/lib/session/remote-list.d.ts +1 -148
  180. package/dist/lib/session/remote-list.js +3 -607
  181. package/dist/lib/session/remote.d.ts +1 -132
  182. package/dist/lib/session/remote.js +3 -314
  183. package/dist/lib/session/short-id.d.ts +1 -17
  184. package/dist/lib/session/short-id.js +4 -20
  185. package/dist/lib/session/watch.d.ts +1 -101
  186. package/dist/lib/session/watch.js +3 -242
  187. package/dist/lib/session/width.d.ts +1 -29
  188. package/dist/lib/session/width.js +4 -101
  189. package/dist/lib/share/config.d.ts +12 -2
  190. package/dist/lib/share/config.js +47 -11
  191. package/dist/lib/share/delete.js +1 -1
  192. package/dist/lib/share/publish.js +1 -1
  193. package/dist/lib/share/worker-template.js +2 -2
  194. package/dist/lib/smart-launch.d.ts +4 -4
  195. package/dist/lib/smart-launch.js +8 -18
  196. package/dist/lib/snapshot.d.ts +2 -2
  197. package/dist/lib/snapshot.js +1 -1
  198. package/dist/lib/staleness/index.d.ts +3 -1
  199. package/dist/lib/staleness/index.js +21 -1
  200. package/dist/lib/staleness/types.d.ts +11 -0
  201. package/dist/lib/staleness/writers/commands.js +13 -4
  202. package/dist/lib/staleness/writers/hooks.js +3 -1
  203. package/dist/lib/staleness/writers/mcp.d.ts +0 -7
  204. package/dist/lib/staleness/writers/mcp.js +16 -1
  205. package/dist/lib/staleness/writers/rules.js +1 -1
  206. package/dist/lib/staleness/writers/skills.js +3 -1
  207. package/dist/lib/staleness/writers/subagents.d.ts +0 -9
  208. package/dist/lib/staleness/writers/subagents.js +18 -1
  209. package/dist/lib/staleness/writers/types.d.ts +10 -0
  210. package/dist/lib/startup/command-registry.d.ts +10 -1
  211. package/dist/lib/startup/command-registry.js +26 -7
  212. package/dist/lib/startup/root-command.d.ts +18 -1
  213. package/dist/lib/startup/root-command.js +18 -1
  214. package/dist/lib/state.js +7 -0
  215. package/dist/lib/teams/placement-probe.js +28 -13
  216. package/dist/lib/teams/scheduler.d.ts +3 -1
  217. package/dist/lib/teams/scheduler.js +1 -1
  218. package/dist/lib/text/relative-time.d.ts +44 -0
  219. package/dist/lib/text/relative-time.js +120 -0
  220. package/dist/lib/text/short-id.d.ts +17 -0
  221. package/dist/lib/text/short-id.js +20 -0
  222. package/dist/lib/text/width.d.ts +29 -0
  223. package/dist/lib/text/width.js +101 -0
  224. package/dist/lib/triggers/handlers.d.ts +7 -0
  225. package/dist/lib/triggers/handlers.js +8 -0
  226. package/dist/lib/triggers/webhook.d.ts +1 -0
  227. package/dist/lib/triggers/webhook.js +2 -1
  228. package/dist/lib/types.d.ts +1 -1
  229. package/dist/lib/view-types.d.ts +7 -0
  230. package/package.json +2 -3
  231. package/dist/bin/agents +0 -0
  232. package/dist/commands/serve.d.ts +0 -10
  233. package/dist/commands/serve.js +0 -68
  234. package/dist/commands/tickets.d.ts +0 -2
  235. package/dist/commands/tickets.js +0 -43
  236. package/dist/commands/trends.d.ts +0 -10
  237. package/dist/commands/trends.js +0 -12
  238. package/dist/lib/menubar/MenubarHelper.app/Contents/CodeResources +0 -0
  239. package/dist/lib/menubar/MenubarHelper.app/Contents/Resources/AppIcon.icns +0 -0
  240. package/dist/lib/observe-aliases.d.ts +0 -30
  241. package/dist/lib/observe-aliases.js +0 -38
  242. package/dist/lib/secrets/Agents CLI.app/Contents/Resources/AppIcon.icns +0 -0
  243. package/dist/lib/serve/control.d.ts +0 -95
  244. package/dist/lib/serve/control.js +0 -260
  245. package/dist/lib/serve/data.d.ts +0 -81
  246. package/dist/lib/serve/data.js +0 -91
  247. package/dist/lib/serve/page.d.ts +0 -7
  248. package/dist/lib/serve/page.js +0 -140
  249. package/dist/lib/serve/server.d.ts +0 -80
  250. package/dist/lib/serve/server.js +0 -145
  251. package/dist/lib/serve/stream.d.ts +0 -43
  252. package/dist/lib/serve/stream.js +0 -116
  253. package/dist/lib/serve/token.d.ts +0 -35
  254. package/dist/lib/serve/token.js +0 -85
  255. package/dist/lib/tickets/list.d.ts +0 -53
  256. package/dist/lib/tickets/list.js +0 -153
@@ -13,13 +13,6 @@ import { type IndexedToolCall } from './tool-calls.js';
13
13
  * assert against the constant instead of hardcoding a number that every bump
14
14
  * then has to chase (docs/sessions.md calls the constant the source of truth). */
15
15
  export declare const SCHEMA_VERSION = 39;
16
- /**
17
- * Bump to force `agents sessions backfill resources` to re-derive every
18
- * session's skill/slash-command tallies on its next run (resource_scan_ledger
19
- * rows with a lower version are treated as stale — the same mechanism
20
- * TOOL_INDEX_VERSION gives the tool backfill).
21
- */
22
- export declare const RESOURCE_INDEX_VERSION = 1;
23
16
  /**
24
17
  * Bumping this invalidates every cached facet row without touching the schema
25
18
  * version, so a change to the extraction logic (a new metric, a corrected bucket)
@@ -28,67 +21,6 @@ export declare const RESOURCE_INDEX_VERSION = 1;
28
21
  */
29
22
  /** Bump when facet extraction changes so cached rows recompute (stalls-by-model v6). */
30
23
  export declare const INSIGHTS_EXTRACTOR_VERSION = 6;
31
- export declare const PREVIEW_EXTRACTOR_VERSION = 1;
32
- /** Raw row shape returned from the sessions table. */
33
- export interface SessionRow {
34
- id: string;
35
- short_id: string;
36
- agent: string;
37
- origin: string | null;
38
- routine_name: string | null;
39
- routine_run_id: string | null;
40
- version: string | null;
41
- account: string | null;
42
- account_key: string | null;
43
- account_org: string | null;
44
- mode: string | null;
45
- timestamp: string;
46
- last_activity: string | null;
47
- project: string | null;
48
- cwd: string | null;
49
- git_branch: string | null;
50
- topic: string | null;
51
- label: string | null;
52
- message_count: number | null;
53
- token_count: number | null;
54
- output_tokens: number | null;
55
- input_tokens: number | null;
56
- cache_read_tokens: number | null;
57
- cache_write_tokens: number | null;
58
- cost_usd: number | null;
59
- cost_usd_nocache: number | null;
60
- duration_ms: number | null;
61
- model: string | null;
62
- tool_call_count: number | null;
63
- file_path: string;
64
- file_mtime_ms: number | null;
65
- file_size: number | null;
66
- scanned_at: number | null;
67
- is_team_origin: number;
68
- pr_url: string | null;
69
- pr_number: number | null;
70
- worktree_slug: string | null;
71
- ticket_id: string | null;
72
- spawned_team: string | null;
73
- plan: string | null;
74
- machine: string | null;
75
- todos: string | null;
76
- recent_directories_touched: string | null;
77
- linear_project: string | null;
78
- linear_project_url: string | null;
79
- actor: string | null;
80
- initiated_by: string | null;
81
- /** NULL means "not yet computed" (a row scanned before this field existed) — see rowToMeta. */
82
- used_browser: number | null;
83
- used_computer: number | null;
84
- /**
85
- * Epoch ms the transcript file was first confirmed gone while content survived
86
- * (RUSH-2436); NULL = live/never archived. Optional because the scanner upsert
87
- * write-payload never sets it — the INSERT column list omits it, so a rescan
88
- * preserves the sticky stamp; it is written only by querySessions.
89
- */
90
- archived_at?: number | null;
91
- }
92
24
  /** File stat snapshot used to detect changes between scan runs. */
93
25
  export interface ScanStamp {
94
26
  fileMtimeMs: number;
@@ -143,7 +75,7 @@ export interface QueryOptions {
143
75
  export declare function getDB(): Database.Database;
144
76
  /** Close the cached database connection. */
145
77
  export declare function closeDB(): void;
146
- export interface FtsOptimizeResult {
78
+ interface FtsOptimizeResult {
147
79
  table: string;
148
80
  segmentsBefore: number;
149
81
  segmentsAfter: number;
@@ -224,7 +156,7 @@ export declare function getScanStampsForPaths(filePaths: string[]): Map<string,
224
156
  * written by the Claude scan (B-2) and consumed on the next scan to decide
225
157
  * full-vs-incremental and to hydrate the resume.
226
158
  */
227
- export interface ParserStateRow {
159
+ interface ParserStateRow {
228
160
  parserState: string | null;
229
161
  contentText: string | null;
230
162
  fileMtimeMs: number;
@@ -348,7 +280,7 @@ export declare function querySessions(options?: QueryOptions): SessionMeta[];
348
280
  /** Count sessions matching the given filter options. */
349
281
  export declare function countSessions(options?: QueryOptions): number;
350
282
  /** One grouped row in a cost/duration rollup. */
351
- export interface UsageRollupRow {
283
+ interface UsageRollupRow {
352
284
  /**
353
285
  * Grouping key value: the agent id, project name, ISO date (YYYY-MM-DD), or
354
286
  * account identity (`claude:org=<uuid>` / `unattributed:<reason>`).
@@ -454,7 +386,7 @@ export type UsageRollupGroup = 'agent' | 'project' | 'day' | 'account';
454
386
  * Account rotation is NOT done here — that stays on live rate-limit windows
455
387
  * via `--strategy balanced` / rotate.ts.
456
388
  */
457
- export type AffinityGroup = 'machine' | 'agent' | 'machine_agent';
389
+ type AffinityGroup = 'machine' | 'agent' | 'machine_agent';
458
390
  export interface AffinityRow {
459
391
  /** Group key: machine name, agent id, or "machine\\tagent". */
460
392
  key: string;
@@ -540,7 +472,7 @@ export declare function resourceUsageCoverage(): {
540
472
  total: number;
541
473
  };
542
474
  /** Outcome of a resource-usage backfill run. */
543
- export interface ResourceBackfillResult {
475
+ interface ResourceBackfillResult {
544
476
  /** Sessions considered (matched the filter, had a real transcript). */
545
477
  scanned: number;
546
478
  /** Sessions (re)parsed and written this run. */
@@ -585,7 +517,7 @@ export interface TeamSpawner {
585
517
  */
586
518
  export declare function teamSpawners(): Map<string, TeamSpawner>;
587
519
  /** A session with its cost, for the top-N-by-cost listing. */
588
- export interface TopCostSession {
520
+ interface TopCostSession {
589
521
  meta: SessionMeta;
590
522
  costUsd: number;
591
523
  durationMs: number;
@@ -638,7 +570,7 @@ export declare function findSessionsById(idQuery: string, scope?: Pick<QueryOpti
638
570
  */
639
571
  export declare function findSessionsByShortIds(shortIds: string[]): Map<string, SessionMeta>;
640
572
  /** A single full-text search result with ranking score. */
641
- export interface FtsHit {
573
+ interface FtsHit {
642
574
  sessionId: string;
643
575
  score: number;
644
576
  matchedTerms: string[];
@@ -667,11 +599,6 @@ export declare function buildFtsQuery(input: string): {
667
599
  * so "higher = better" is consistent across all tiers.
668
600
  */
669
601
  export declare function ftsSearch(input: string, limit?: number): FtsHit[];
670
- /** Return the total row counts for the sessions and FTS5 tables (diagnostic). */
671
- export declare function getRowCount(): {
672
- sessions: number;
673
- textRows: number;
674
- };
675
602
  /**
676
603
  * Rewrite file_path for all sessions whose path starts with oldPrefix, replacing
677
604
  * it with newPrefix + the unchanged suffix. Also clears the matching scan_ledger
@@ -683,14 +610,14 @@ export declare function getRowCount(): {
683
610
  */
684
611
  export declare function updateSessionFilePaths(oldPrefix: string, newPrefix: string): number;
685
612
  /** Per-kind capture tallies for a browser task. Counts only -- never the bytes. */
686
- export interface BrowserCaptureCounts {
613
+ interface BrowserCaptureCounts {
687
614
  screenshot: number;
688
615
  pdf: number;
689
616
  recording: number;
690
617
  download: number;
691
618
  }
692
619
  /** One durable browser-task row. `machine` defaults to this device. */
693
- export interface BrowserSessionRecord {
620
+ interface BrowserSessionRecord {
694
621
  task: string;
695
622
  profile: string;
696
623
  sessionId?: string;
@@ -704,7 +631,7 @@ export interface BrowserSessionRecord {
704
631
  capturesRemote?: string;
705
632
  }
706
633
  /** One durable computer-use invocation row. `machine` defaults to this device. */
707
- export interface ComputerSessionRecord {
634
+ interface ComputerSessionRecord {
708
635
  invocationId: string;
709
636
  sessionId?: string;
710
637
  launchId?: string;
@@ -743,7 +670,7 @@ export declare function recordBrowserSession(record: BrowserSessionRecord): void
743
670
  */
744
671
  export declare function recordComputerSession(record: ComputerSessionRecord): void;
745
672
  /** A stored browser row as read back, with counts rehydrated. */
746
- export interface StoredBrowserSession extends Required<Pick<BrowserSessionRecord, 'task' | 'profile'>> {
673
+ interface StoredBrowserSession extends Required<Pick<BrowserSessionRecord, 'task' | 'profile'>> {
747
674
  sessionId?: string;
748
675
  launchId?: string;
749
676
  actor?: string;
@@ -771,7 +698,7 @@ export declare function listBrowserSessionRecords(profile?: string, opts?: {
771
698
  /** One stored browser task by its (profile, task) key, or null. */
772
699
  export declare function getBrowserSessionRecord(profile: string, task: string): StoredBrowserSession | null;
773
700
  /** A stored computer-use invocation as read back. */
774
- export interface StoredComputerSession {
701
+ interface StoredComputerSession {
775
702
  invocationId: string;
776
703
  sessionId?: string;
777
704
  launchId?: string;
@@ -782,19 +709,6 @@ export interface StoredComputerSession {
782
709
  actionCount: number;
783
710
  taskPreview?: string;
784
711
  }
785
- /**
786
- * Retention for the tool-session tables.
787
- *
788
- * These are the durable answer to a ledger that prunes at 7 days, so they are
789
- * deliberately long-lived — but "durable" is not "unbounded". `computer_sessions`
790
- * takes one row per `agents computer` CLI PROCESS (`COMPUTER_INVOCATION_ID` is
791
- * minted per process), and an agent driving a desktop invokes that hundreds of
792
- * times a day, so an unbounded table would grow without limit and be read in
793
- * full on every listing.
794
- */
795
- export declare const TOOL_SESSION_MAX_AGE_DAYS = 365;
796
- /** Default ceiling on rows one listing will read. */
797
- export declare const TOOL_SESSION_LIST_LIMIT = 2000;
798
712
  /**
799
713
  * Drop tool-session rows past {@link TOOL_SESSION_MAX_AGE_DAYS}.
800
714
  *
@@ -813,3 +727,4 @@ export declare function listComputerSessionRecords(opts?: {
813
727
  limit?: number;
814
728
  startedBeforeMs?: number;
815
729
  }): StoredComputerSession[];
730
+ export {};
@@ -13,7 +13,7 @@ import { parseSession, sessionFilePathContainer } from './parse.js';
13
13
  import { extractRecentDirectoriesTouched, extractTodoProgressFromEvents } from './state.js';
14
14
  import { getSessionsDir, getSessionsDbPath } from '../state.js';
15
15
  import { query as queryEvents, queryToolUsageForSessions } from '../feed/events.js';
16
- import { machineForSessionFile } from './origin-machine.js';
16
+ import { machineForSessionFile } from '../origin-machine.js';
17
17
  import { loadSessionActorIndex, readSessionActorRecord } from './actor-sidecar.js';
18
18
  import { toolCallsFromEvents } from './tool-calls.js';
19
19
  import { persistToolCalls, toolEvidenceSourcePath } from './tool-store.js';
@@ -34,7 +34,7 @@ export const SCHEMA_VERSION = 39;
34
34
  * rows with a lower version are treated as stale — the same mechanism
35
35
  * TOOL_INDEX_VERSION gives the tool backfill).
36
36
  */
37
- export const RESOURCE_INDEX_VERSION = 1;
37
+ const RESOURCE_INDEX_VERSION = 1;
38
38
  /**
39
39
  * Canonicalize a file path for use as a scan_ledger key. The same physical
40
40
  * session file is reachable via multiple aliases — `~/.claude/projects/x.jsonl`
@@ -397,7 +397,7 @@ CREATE INDEX IF NOT EXISTS idx_computer_sessions_started ON computer_sessions(st
397
397
  */
398
398
  /** Bump when facet extraction changes so cached rows recompute (stalls-by-model v6). */
399
399
  export const INSIGHTS_EXTRACTOR_VERSION = 6;
400
- export const PREVIEW_EXTRACTOR_VERSION = 1;
400
+ const PREVIEW_EXTRACTOR_VERSION = 1;
401
401
  let dbInstance = null;
402
402
  /**
403
403
  * Apply schema migrations from `fromVersion` → SCHEMA_VERSION. The new
@@ -3365,13 +3365,6 @@ export function ftsSearch(input, limit = 200) {
3365
3365
  hits.sort((a, b) => b.score - a.score);
3366
3366
  return hits.slice(0, limit);
3367
3367
  }
3368
- /** Return the total row counts for the sessions and FTS5 tables (diagnostic). */
3369
- export function getRowCount() {
3370
- const db = getDB();
3371
- const sessions = db.prepare(`SELECT COUNT(*) AS c FROM sessions`).get().c;
3372
- const textRows = db.prepare(`SELECT COUNT(*) AS c FROM session_text`).get().c;
3373
- return { sessions, textRows };
3374
- }
3375
3368
  /**
3376
3369
  * Rewrite file_path for all sessions whose path starts with oldPrefix, replacing
3377
3370
  * it with newPrefix + the unchanged suffix. Also clears the matching scan_ledger
@@ -3520,9 +3513,9 @@ export function getBrowserSessionRecord(profile, task) {
3520
3513
  * times a day, so an unbounded table would grow without limit and be read in
3521
3514
  * full on every listing.
3522
3515
  */
3523
- export const TOOL_SESSION_MAX_AGE_DAYS = 365;
3516
+ const TOOL_SESSION_MAX_AGE_DAYS = 365;
3524
3517
  /** Default ceiling on rows one listing will read. */
3525
- export const TOOL_SESSION_LIST_LIMIT = 2000;
3518
+ const TOOL_SESSION_LIST_LIMIT = 2000;
3526
3519
  /**
3527
3520
  * Drop tool-session rows past {@link TOOL_SESSION_MAX_AGE_DAYS}.
3528
3521
  *
@@ -10,8 +10,6 @@ import type { SessionAgentId, SessionEvent, SessionMeta, TodoProgress } from './
10
10
  export { machineForSessionFile } from './origin-machine.js';
11
11
  import { type ScanStamp } from './db.js';
12
12
  import { ToolCallCollector, type IndexedToolCall, type ToolCallCollectorSnapshot } from './tool-calls.js';
13
- /** One JSONL record may not force an unbounded string allocation. */
14
- export declare const SESSION_JSONL_LINE_MAX_BYTES: number;
15
13
  /** Options controlling which sessions to discover and how to report progress. */
16
14
  export interface DiscoverOptions {
17
15
  agent?: SessionAgentId;
@@ -172,7 +170,7 @@ interface CodexSessionScan {
172
170
  */
173
171
  export declare function discoverSessions(options?: DiscoverOptions): Promise<SessionMeta[]>;
174
172
  /** What one incremental scan actually did. */
175
- export interface IncrementalScanResult {
173
+ interface IncrementalScanResult {
176
174
  /** True when this process won the single-flight claim and ran the scan. */
177
175
  claimed: boolean;
178
176
  /**
@@ -362,7 +360,7 @@ export declare function filterChangedFiles(filePaths: string[]): Array<{
362
360
  scan: ScanStamp;
363
361
  }>;
364
362
  /** A path already stat'd by the walk — mtime is the raw (unfloored) fs value. */
365
- export interface PreStatEntry {
363
+ interface PreStatEntry {
366
364
  filePath: string;
367
365
  fileMtimeMs: number;
368
366
  fileSize: number;
@@ -378,64 +376,13 @@ export declare function filterChangedEntries(entries: PreStatEntry[]): Array<{
378
376
  scan: ScanStamp;
379
377
  }>;
380
378
  export declare function shouldDeferRecentAppend(prev: ScanStamp, current: ScanStamp, nowMs: number, debounceMs?: number): boolean;
381
- /** One leaf directory of transcripts to change-detect, plus its live-root flag. */
382
- export interface LeafDir {
383
- /** Absolute path to the directory that directly holds transcript files. */
384
- dirPath: string;
385
- /**
386
- * True if this dir is under the agent's LIVE `~/.<agent>` root — the only tree
387
- * an agent process appends to live. Every file in such a dir is treated as
388
- * hot (always re-stat'd), so an in-place append is never missed there.
389
- */
390
- isLiveRoot: boolean;
391
- }
392
- /** The changed files a leaf-dir walk surfaced, ready to parse + upsert. */
393
- export interface LeafDirScan {
394
- /** Files whose (mtime, size) changed vs the ledger — the parse set. */
395
- changed: Array<{
396
- filePath: string;
397
- scan: ScanStamp;
398
- }>;
399
- /**
400
- * Every transcript file seen across all leaf dirs (changed or not), in
401
- * live-root-first order, each tagged with whether its dir is a live root.
402
- * Lets a caller restore cross-root, session-id precedence (prefer the live
403
- * copy of a session over a frozen backup copy) independent of which copy
404
- * happened to be flagged "changed" this run.
405
- */
406
- allFiles: Array<{
407
- filePath: string;
408
- isLiveRoot: boolean;
409
- }>;
410
- }
411
- /**
412
- * Walk a set of leaf transcript directories and return the files that changed,
413
- * skipping the per-file `stat` of directories whose (mtime, entry_count) matches
414
- * the dir_ledger.
415
- *
416
- * Per leaf dir:
417
- * - `stat` the dir once and `readdir` it (one cheap syscall) to get the entry
418
- * count and the file list.
419
- * - If the dir matches the dir_ledger (floored mtime AND entry_count), no file
420
- * was created / deleted / renamed since we last walked it. We then stat ONLY
421
- * the hot files (live-root files, or files scanned within HOT_FILE_WINDOW_MS)
422
- * and run just those through the ledger compare — so an in-place append to a
423
- * still-live session is still caught, while immutable backup/version dirs
424
- * collapse to a single dir stat and zero per-file stats.
425
- * - Else (changed dir, or no ledger row) we stat every file (today's full
426
- * walk) and record the fresh dir stamp so the next run can short-circuit.
427
- *
428
- * The kill-switch (`AGENTS_SESSIONS_NO_DIR_LEDGER=1`) forces the full-walk branch
429
- * for every dir and never consults or records the dir_ledger.
430
- */
431
- export declare function collectChangedFilesInLeafDirs(leafDirs: LeafDir[], ext: string): LeafDirScan;
432
379
  /**
433
380
  * Collect all directories to scan for an agent's sessions. Deduplicates by
434
381
  * realpath to avoid double-counting symlinked version homes.
435
382
  */
436
383
  export declare function getAgentSessionDirs(agent: string, subdir: string): string[];
437
384
  /** A session-agent's on-disk watch roots (every version home + backup mirror). */
438
- export interface SessionRoots {
385
+ interface SessionRoots {
439
386
  agent: SessionAgentId;
440
387
  /** Absolute directories that hold this agent's transcripts, existing right now. */
441
388
  dirs: string[];
@@ -492,7 +439,7 @@ export declare function readCodexMeta(filePath: string, resolveAccount?: () => s
492
439
  * both a full parse and a resumable incremental parse (see
493
440
  * {@link scanClaudeSessionIncremental}).
494
441
  */
495
- export interface ClaudeParseState {
442
+ interface ClaudeParseState {
496
443
  timestamp?: string;
497
444
  cwd?: string;
498
445
  gitBranch?: string;
@@ -680,7 +627,7 @@ export declare function __resetClaudeScanBranchCountsForTest(): void;
680
627
  * fold ({@link applyCodexLine}) runs for both a full parse and an incremental
681
628
  * resume. Mirrors {@link ClaudeParseState}.
682
629
  */
683
- export interface CodexParseState {
630
+ interface CodexParseState {
684
631
  sessionId?: string;
685
632
  timestamp?: string;
686
633
  cwd?: string;
@@ -712,18 +659,6 @@ export interface CodexParseState {
712
659
  }
713
660
  /** Zero-value accumulator for a fresh (from-byte-0) Codex parse. */
714
661
  export declare function initCodexParseState(): CodexParseState;
715
- /**
716
- * Fold one parsed Codex line into the accumulator — the exact loop body
717
- * {@link scanCodexSession} used to run inline, extracted verbatim and mutating
718
- * `state.*` in place. `parsed` is the already-`JSON.parse`d line (the
719
- * malformed-line skip happens in the caller, as before).
720
- */
721
- export declare function applyCodexLine(state: CodexParseState, parsed: any): void;
722
- /**
723
- * Build the {@link CodexSessionScan} return object from an accumulator — the
724
- * exact return-building {@link scanCodexSession} used to run inline.
725
- */
726
- export declare function finalizeCodexScan(state: CodexParseState): CodexSessionScan;
727
662
  /**
728
663
  * SERIALIZED continuation blob persisted in `scan_ledger.parser_state` for a
729
664
  * Codex rollout. Carries everything {@link hydrateCodexParseState} needs to
@@ -769,17 +704,6 @@ export interface CodexParserState {
769
704
  * incremental replay equals a full parse.
770
705
  */
771
706
  export declare function serializeCodexParserState(state: CodexParseState, offset: number, jsonlDroppingOversizedLine?: boolean): CodexParserState;
772
- /**
773
- * Rebuild a live {@link CodexParseState} from a persisted continuation so that
774
- * applying the appended lines yields the same accumulator a full parse would.
775
- *
776
- * `userTexts` is rehydrated as a single joined blob from `contentText`: only
777
- * `userTexts.join('\n')` (detectTicket + contentText) and `userTexts.length > 0`
778
- * are ever read downstream, and both are preserved by a one-element array
779
- * holding the joined content. Topic is first-wins and already persisted, so a
780
- * collapsed userTexts never changes it.
781
- */
782
- export declare function hydrateCodexParseState(prior: CodexParserState): CodexParseState;
783
707
  /**
784
708
  * Resume a Codex parse from `fromOffset` bytes into the file, folding only the
785
709
  * newly-appended lines into `prior`. Returns the finalized scan, the next
@@ -55,7 +55,7 @@ const MUSE_SESSIONS_DIR = path.join(HOME, '.local', 'share', 'muse', 'sessions')
55
55
  const OPENCLAW_TTL_MS = 60_000;
56
56
  const ACTIVE_APPEND_RESCAN_DEBOUNCE_MS = 5_000;
57
57
  /** One JSONL record may not force an unbounded string allocation. */
58
- export const SESSION_JSONL_LINE_MAX_BYTES = 1024 * 1024;
58
+ const SESSION_JSONL_LINE_MAX_BYTES = 1024 * 1024;
59
59
  /**
60
60
  * Stream one appended JSONL range, applying only newline-terminated records.
61
61
  * Memory is bounded to one record. An ordinary unterminated tail remains for the
@@ -728,7 +728,7 @@ export function shouldDeferRecentAppend(prev, current, nowMs, debounceMs = ACTIV
728
728
  * The kill-switch (`AGENTS_SESSIONS_NO_DIR_LEDGER=1`) forces the full-walk branch
729
729
  * for every dir and never consults or records the dir_ledger.
730
730
  */
731
- export function collectChangedFilesInLeafDirs(leafDirs, ext) {
731
+ function collectChangedFilesInLeafDirs(leafDirs, ext) {
732
732
  const disabled = dirLedgerDisabled();
733
733
  const dirStamps = disabled ? new Map() : getDirLedgerForPaths(leafDirs.map(d => d.dirPath));
734
734
  const now = Date.now();
@@ -3619,7 +3619,7 @@ export function initCodexParseState() {
3619
3619
  * `state.*` in place. `parsed` is the already-`JSON.parse`d line (the
3620
3620
  * malformed-line skip happens in the caller, as before).
3621
3621
  */
3622
- export function applyCodexLine(state, parsed) {
3622
+ function applyCodexLine(state, parsed) {
3623
3623
  collectCodexToolCalls(state.toolCollector, parsed);
3624
3624
  // PR signal, structurally: a Codex `function_call` whose command is
3625
3625
  // `gh pr create`, then the pull URL from a `function_call_output`.
@@ -3730,7 +3730,7 @@ export function applyCodexLine(state, parsed) {
3730
3730
  * Build the {@link CodexSessionScan} return object from an accumulator — the
3731
3731
  * exact return-building {@link scanCodexSession} used to run inline.
3732
3732
  */
3733
- export function finalizeCodexScan(state) {
3733
+ function finalizeCodexScan(state) {
3734
3734
  // Codex reports one cumulative snapshot: uncached input, cached (cache-read)
3735
3735
  // input, and output+reasoning. It has no cache-write bucket. Derive the burn
3736
3736
  // split and both costs (actual + no-cache) from that final snapshot (RUSH-2287).
@@ -3869,7 +3869,7 @@ export function serializeCodexParserState(state, offset, jsonlDroppingOversizedL
3869
3869
  * holding the joined content. Topic is first-wins and already persisted, so a
3870
3870
  * collapsed userTexts never changes it.
3871
3871
  */
3872
- export function hydrateCodexParseState(prior) {
3872
+ function hydrateCodexParseState(prior) {
3873
3873
  return {
3874
3874
  sessionId: prior.sessionId,
3875
3875
  timestamp: prior.timestamp,
@@ -19,7 +19,7 @@ import * as fs from 'fs';
19
19
  import * as path from 'path';
20
20
  import { upsertSession } from './db.js';
21
21
  import { recordRunName } from './run-names.js';
22
- import { deriveShortId } from './short-id.js';
22
+ import { deriveShortId } from '../text/short-id.js';
23
23
  /** Agents that `fork` can branch today (see the module doc for why). */
24
24
  export const FORKABLE_AGENTS = ['claude'];
25
25
  /** Whether a session's agent can be forked by {@link forkSession}. */
@@ -16,7 +16,7 @@
16
16
  // state the live registry already computed. When the transcript IS on disk, the
17
17
  // synthesized row carries its path, so the downstream `buildPreview` renders the
18
18
  // real digest; otherwise it renders the header + a "not indexed here" note.
19
- import { deriveShortId } from './short-id.js';
19
+ import { deriveShortId } from '../text/short-id.js';
20
20
  import { isSessionTrackedAgent } from './types.js';
21
21
  /**
22
22
  * Reshape one live `ActiveSession` into a `SessionMeta` candidate for the id
@@ -1,18 +1 @@
1
- /**
2
- * Resolve which machine a session transcript originated on.
3
- *
4
- * Cross-machine sync mirrors a remote transcript to
5
- * `backups/<agent>/<machine>/<subdir>/…`. Every other transcript is a live-home
6
- * file on this box, so the origin is the local machine id.
7
- *
8
- * Kept in a leaf module (no session/db imports) so both discovery and the
9
- * sessions DB upsert path can stamp `machine` without circular deps.
10
- */
11
- /** Local machine id, cached for the process lifetime. */
12
- export declare function localMachineId(): string;
13
- /**
14
- * The machine a discovered session originated on.
15
- * When the path sits under the agent's backups root, the first segment below it
16
- * is the origin machine id; otherwise it's the local machine.
17
- */
18
- export declare function machineForSessionFile(filePath: string, agent: string): string;
1
+ export * from '../origin-machine.js';
@@ -1,34 +1,4 @@
1
- /**
2
- * Resolve which machine a session transcript originated on.
3
- *
4
- * Cross-machine sync mirrors a remote transcript to
5
- * `backups/<agent>/<machine>/<subdir>/…`. Every other transcript is a live-home
6
- * file on this box, so the origin is the local machine id.
7
- *
8
- * Kept in a leaf module (no session/db imports) so both discovery and the
9
- * sessions DB upsert path can stamp `machine` without circular deps.
10
- */
11
- import * as path from 'path';
12
- import { getHistoryDir } from '../state.js';
13
- import { machineId } from '../machine-id.js';
14
- let _localMachineId;
15
- /** Local machine id, cached for the process lifetime. */
16
- export function localMachineId() {
17
- return (_localMachineId ??= machineId());
18
- }
19
- /**
20
- * The machine a discovered session originated on.
21
- * When the path sits under the agent's backups root, the first segment below it
22
- * is the origin machine id; otherwise it's the local machine.
23
- */
24
- export function machineForSessionFile(filePath, agent) {
25
- if (!filePath)
26
- return localMachineId();
27
- const base = path.join(getHistoryDir(), 'backups', agent) + path.sep;
28
- if (filePath.startsWith(base)) {
29
- const seg = filePath.slice(base.length).split(path.sep)[0];
30
- if (seg)
31
- return seg;
32
- }
33
- return localMachineId();
34
- }
1
+ // Moved to ../origin-machine.ts (move 1 of the core-module refactor — see
2
+ // .agents/artifacts/2026-08-20/plan-*.md). Kept as a re-export shim so
3
+ // existing importers don't break.
4
+ export * from '../origin-machine.js';
@@ -1,44 +1 @@
1
- /**
2
- * Human-readable "time since" formatting for session timestamps. Lives here (not
3
- * inline in `sessions.ts`) so both the session list renderer and the remote
4
- * offline-cache banner (`remote.ts`) share one formatter — `sessions.ts` imports
5
- * `remote.ts`, so a back-import would cycle.
6
- */
7
- export declare function formatRelativeTime(isoTimestamp: string): string;
8
- /**
9
- * Compact age — `now`, `45m`, `3h`, `2d`, then the calendar date. This is the
10
- * *creation* half of a session's time cell: it renders right next to the long
11
- * last-activity label, and one row can afford one long form, not two.
12
- */
13
- export declare function formatCompactAge(isoTimestamp: string): string;
14
- /** The two time fields a session listing shows for one row. */
15
- export interface SessionAgeParts {
16
- /**
17
- * Compact age of the session's creation, set only when the session ran long
18
- * enough (>= a minute) for it to say something `last` does not.
19
- */
20
- created?: string;
21
- /** Last-activity label — the long relative form the listing sorts by. */
22
- last: string;
23
- }
24
- /**
25
- * Split a session's timestamps into the two fields a listing renders: when it
26
- * was created and when it was last active. One last-activity label answers
27
- * neither "is this the old session I'm looking for" nor "how long did it run" —
28
- * a session touched an hour ago may have started last week.
29
- */
30
- export declare function sessionAgeParts(createdIso: string, lastActivityIso?: string): SessionAgeParts;
31
- /**
32
- * Parse a time filter string (relative like '7d' or an ISO timestamp) into epoch
33
- * milliseconds. Backs `--since` on `sessions`, `cost`, `teams`, and `output`, and
34
- * `--unused` on `secrets list`.
35
- *
36
- * It lives here, in a module with no imports, rather than in `discover.ts` where
37
- * it started: `discover.ts` loads `../sqlite.js`, so importing this one function
38
- * from there pulls `node:sqlite` into the caller's module graph and Node prints
39
- * `ExperimentalWarning: SQLite …` on stderr. That is invisible in a command that
40
- * already touches the session DB, and a broken contract in one that doesn't —
41
- * `monitors --json` asserts a clean stderr. `discover.ts` re-exports it, so
42
- * existing importers are unaffected.
43
- */
44
- export declare function parseTimeFilter(input: string): number;
1
+ export * from '../text/relative-time.js';