@indigoai-us/hq-cli 5.108.16 → 5.108.18

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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,44 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [5.108.18] — 2026-09-07
6
+
7
+ ### Fixed
8
+
9
+ - A global `hq` reinstall running underneath a starting command no longer
10
+ crashes it (Sentry HQ-CLI-1G/1H/1J/1K — 7713386011, 7713482655, 7713783135,
11
+ 7714501738). `hq` resolves most of its command graph lazily as its first real
12
+ step, so when an external updater — the outpost `hq-cli-update` timer, an
13
+ agent box's self-update, or the desktop app — renames the installed package
14
+ aside and re-extracts it file by file (~16s every 6h on every box), a command
15
+ that started a moment earlier resolved a deferred import against a directory
16
+ that no longer held it and died with `ERR_MODULE_NOT_FOUND` /
17
+ `MODULE_NOT_FOUND`, filing a separate high-priority crash for each missing
18
+ path. hq-cli cannot stop the foreign updater, but the registration phase is
19
+ provably side-effect free (it runs before any command action), so a
20
+ resolution failure there is now caught: the CLI prints one informational line,
21
+ waits — bounded, default 90s, `HQ_INSTALL_SETTLE_TIMEOUT_MS` to override — for
22
+ the install to settle (shared update lock released, the missing target back,
23
+ the retired `.hq-cli-*` sibling gone, a healthy manifest), and then re-runs
24
+ the command once on the settled tree. A genuinely broken or incomplete install
25
+ still reports exactly once, with a reinstall remedy naming the missing module
26
+ and bounded diagnostics, so real packaging faults stay visible. The recovery
27
+ re-execs at most once per invocation and never runs a command twice.
28
+
29
+ ## [5.108.17] — 2026-09-07
30
+
31
+ ### Fixed
32
+
33
+ - The Work Mesh Live daemon's transcript watcher no longer rescans every file
34
+ under `~/.claude/projects` and `~/.codex/sessions` every 15 seconds. It keeps a
35
+ per-directory mtime cache and only relists directories that changed, re-stats
36
+ recently active files, revalidates every cached directory at least every five
37
+ minutes (content appends do not change a directory's mtime, so a session that
38
+ resumes after idling is still picked up), backs the interval off from 30 s to
39
+ 120 s on busy machines, caps the entries examined per tick with per-root
40
+ budgets, never runs two ticks at once, and bounds its cache. Capped ticks skip
41
+ disappearance reconciliation so an unvisited session is never ended falsely.
42
+
5
43
  ## [5.108.16] — 2026-09-07
6
44
 
7
45
  ### Fixed
@@ -231,7 +269,6 @@
231
269
  and `hq reindex` now prunes local session-log copies 7 days after the vault
232
270
  confirms them (`HQ_SESSION_LOG_LOCAL_RETENTION_DAYS`, `off` to disable).
233
271
 
234
-
235
272
  ## [5.108.5] — 2026-09-04
236
273
 
237
274
  ### Added
@@ -1672,7 +1709,6 @@ All self-update behavior honors the existing `HQ_NO_UPDATE_CHECK=1` opt-out.
1672
1709
 
1673
1710
  - **`hq db provision` / `hq db status --remote` use Cognito + vault API** to call the live control plane (`POST /v1/db/provision`, `GET /v1/db/status`). Team plan required for provision; local `status|sql|migrate` unchanged.
1674
1711
 
1675
-
1676
1712
  ## [5.55.1]
1677
1713
 
1678
1714
  ### Fixed
@@ -19,6 +19,6 @@ export type { DaemonDoctorDeps, DaemonDoctorReport } from "./doctor.js";
19
19
  export { scopeBundleToAgentIdentity, } from "./credentials.js";
20
20
  export { FLUSH_INTERVAL_MS, SPOOL_DEBOUNCE_MS, runMeshDaemon, } from "./run.js";
21
21
  export type { DaemonHandle, DaemonRunDeps } from "./run.js";
22
- export { TRANSCRIPT_ADAPTER_VERSION, TRANSCRIPT_EVENT_SOURCE, TRANSCRIPT_FRESH_MS, TRANSCRIPT_HOOK_COVER_MS, TRANSCRIPT_MARKER, TRANSCRIPT_SESSION_END_MS, TRANSCRIPT_TURN_QUIET_MS, TRANSCRIPT_WATCH_INTERVAL_MS, TranscriptWatcher, decodeClaudeProjectDirName, defaultTranscriptFs, discoverTranscripts, isTranscriptHookCovered, noteHookSessionsFromSpoolFile, resolveTranscriptRegistration, sessionIdFromClaudeTranscriptPath, sessionIdFromCodexTranscriptPath, } from "./transcript-watch.js";
23
- export type { DiscoveredTranscript, TranscriptFs, TranscriptKind, TranscriptWatchDeps, TranscriptWatchTickResult, } from "./transcript-watch.js";
22
+ export { TRANSCRIPT_ADAPTER_VERSION, TRANSCRIPT_EVENT_SOURCE, TRANSCRIPT_FRESH_MS, TRANSCRIPT_HOOK_COVER_MS, TRANSCRIPT_MARKER, TRANSCRIPT_SESSION_END_MS, TRANSCRIPT_TURN_QUIET_MS, TRANSCRIPT_WATCH_BACKOFF_DURATION_MS, TRANSCRIPT_WATCH_BACKOFF_ENTRIES, TRANSCRIPT_WATCH_ENTRY_CAP, TRANSCRIPT_WATCH_INTERVAL_MAX_MS, TRANSCRIPT_WATCH_INTERVAL_MS, TRANSCRIPT_WATCH_REVALIDATE_MS, TranscriptWatcher, createTranscriptDiscoverCache, decodeClaudeProjectDirName, defaultTranscriptFs, discoverTranscripts, discoverTranscriptsWithMeta, isTranscriptHookCovered, nextTranscriptWatchIntervalMs, noteHookSessionsFromSpoolFile, resolveTranscriptRegistration, sessionIdFromClaudeTranscriptPath, sessionIdFromCodexTranscriptPath, sortDiscoveries, } from "./transcript-watch.js";
23
+ export type { DiscoveredTranscript, DiscoverScanMeta, DiscoverTranscriptsResult, TranscriptDiscoverCache, TranscriptFs, TranscriptKind, TranscriptWatchDeps, TranscriptWatchTickResult, } from "./transcript-watch.js";
24
24
  //# sourceMappingURL=index.d.ts.map
@@ -10,5 +10,5 @@ export { buildInstallPaths, daemonServiceStatus, detectPlatform, installDaemonSe
10
10
  export { UNHEALTHY_SPOOL_AGE_MS, collectDaemonDoctor, formatDaemonDoctor, } from "./doctor.js";
11
11
  export { scopeBundleToAgentIdentity, } from "./credentials.js";
12
12
  export { FLUSH_INTERVAL_MS, SPOOL_DEBOUNCE_MS, runMeshDaemon, } from "./run.js";
13
- export { TRANSCRIPT_ADAPTER_VERSION, TRANSCRIPT_EVENT_SOURCE, TRANSCRIPT_FRESH_MS, TRANSCRIPT_HOOK_COVER_MS, TRANSCRIPT_MARKER, TRANSCRIPT_SESSION_END_MS, TRANSCRIPT_TURN_QUIET_MS, TRANSCRIPT_WATCH_INTERVAL_MS, TranscriptWatcher, decodeClaudeProjectDirName, defaultTranscriptFs, discoverTranscripts, isTranscriptHookCovered, noteHookSessionsFromSpoolFile, resolveTranscriptRegistration, sessionIdFromClaudeTranscriptPath, sessionIdFromCodexTranscriptPath, } from "./transcript-watch.js";
13
+ export { TRANSCRIPT_ADAPTER_VERSION, TRANSCRIPT_EVENT_SOURCE, TRANSCRIPT_FRESH_MS, TRANSCRIPT_HOOK_COVER_MS, TRANSCRIPT_MARKER, TRANSCRIPT_SESSION_END_MS, TRANSCRIPT_TURN_QUIET_MS, TRANSCRIPT_WATCH_BACKOFF_DURATION_MS, TRANSCRIPT_WATCH_BACKOFF_ENTRIES, TRANSCRIPT_WATCH_ENTRY_CAP, TRANSCRIPT_WATCH_INTERVAL_MAX_MS, TRANSCRIPT_WATCH_INTERVAL_MS, TRANSCRIPT_WATCH_REVALIDATE_MS, TranscriptWatcher, createTranscriptDiscoverCache, decodeClaudeProjectDirName, defaultTranscriptFs, discoverTranscripts, discoverTranscriptsWithMeta, isTranscriptHookCovered, nextTranscriptWatchIntervalMs, noteHookSessionsFromSpoolFile, resolveTranscriptRegistration, sessionIdFromClaudeTranscriptPath, sessionIdFromCodexTranscriptPath, sortDiscoveries, } from "./transcript-watch.js";
14
14
  //# sourceMappingURL=index.js.map
@@ -358,6 +358,17 @@ export async function runMeshDaemon(deps = {}) {
358
358
  return;
359
359
  try {
360
360
  const summary = await transcriptWatcher.tick();
361
+ if (summary.skippedConcurrent)
362
+ return;
363
+ if (summary.intervalChanged) {
364
+ log(dir, `transcript-watch interval ${summary.previousIntervalMs}ms -> ${summary.intervalMs}ms`);
365
+ }
366
+ if (summary.capEpisodeStart) {
367
+ log(dir, `transcript-watch entry cap hit (examined=${summary.entriesExamined})`);
368
+ }
369
+ if (summary.cacheOverflowCleared) {
370
+ log(dir, "transcript-watch cache overflow; cleared for full rescan");
371
+ }
361
372
  if (summary.started > 0 ||
362
373
  summary.turns > 0 ||
363
374
  summary.ended > 0) {
@@ -377,7 +388,8 @@ export async function runMeshDaemon(deps = {}) {
377
388
  void runTranscriptTick().finally(() => {
378
389
  if (stopped)
379
390
  return;
380
- transcriptIntervalHandle = timers.setTimeout(transcriptTick, TRANSCRIPT_WATCH_INTERVAL_MS);
391
+ const delay = transcriptWatcher?.getIntervalMs() ?? TRANSCRIPT_WATCH_INTERVAL_MS;
392
+ transcriptIntervalHandle = timers.setTimeout(transcriptTick, delay);
381
393
  });
382
394
  }, TRANSCRIPT_WATCH_INTERVAL_MS);
383
395
  }
@@ -2,7 +2,16 @@
2
2
  * Transcript-watch fallback for hookless hosts (US-018 / AMEND-001).
3
3
  *
4
4
  * Enumerates ~/.claude/projects/ (recursive *.jsonl) and ~/.codex/sessions/
5
- * every 15s using only readdir + stat (mtime). Never opens or reads transcript bytes.
5
+ * on an adaptive interval (default 30s, backoff to 120s) using only readdir +
6
+ * stat (mtime). Never opens or reads transcript bytes.
7
+ *
8
+ * Scans are incremental: directory mtime is cached so unchanged directories are
9
+ * not re-listed; only files in changed directories (plus files still inside the
10
+ * active mtime window) are re-statted. Every TRANSCRIPT_WATCH_REVALIDATE_MS a
11
+ * cached directory is force-relisted so idle appends and coarse mtimes cannot
12
+ * hide changes forever. A per-tick entry cap (split across Claude/Codex roots)
13
+ * bounds pathological trees; capped ticks skip disappearance reconciliation.
14
+ * Ticks never overlap (a concurrent call is skipped).
6
15
  *
7
16
  * Session identity (deterministic):
8
17
  * - Claude: ~/.claude/projects/<encoded-cwd>/<sessionId>.jsonl
@@ -22,7 +31,21 @@ import { reconcileObservation, type ReconcileDeps } from "../../../work-context/
22
31
  import { readSessionState, writeSessionState, type SessionStateFile } from "../../../work-context/state.js";
23
32
  import { enqueueSessionEvent } from "../enqueue.js";
24
33
  import type { SessionEventHarness } from "../format-spool-line.js";
25
- export declare const TRANSCRIPT_WATCH_INTERVAL_MS = 15000;
34
+ export declare const TRANSCRIPT_WATCH_INTERVAL_MS = 30000;
35
+ /** Ceiling for adaptive backoff after heavy ticks. */
36
+ export declare const TRANSCRIPT_WATCH_INTERVAL_MAX_MS = 120000;
37
+ /** Double the interval when a tick examines more than this many entries. */
38
+ export declare const TRANSCRIPT_WATCH_BACKOFF_ENTRIES = 2000;
39
+ /** Double the interval when a tick takes longer than this many ms. */
40
+ export declare const TRANSCRIPT_WATCH_BACKOFF_DURATION_MS = 500;
41
+ /** Hard cap on entries examined (dir stats, readdir children, file stats) per tick. */
42
+ export declare const TRANSCRIPT_WATCH_ENTRY_CAP = 20000;
43
+ /**
44
+ * Even when a directory mtime matches the cache, force a full relist (readdir +
45
+ * re-stat) after this many ms so content appends and coarse mtime granularity
46
+ * cannot hide membership or mtime changes indefinitely.
47
+ */
48
+ export declare const TRANSCRIPT_WATCH_REVALIDATE_MS: number;
26
49
  export declare const TRANSCRIPT_TURN_QUIET_MS = 5000;
27
50
  export declare const TRANSCRIPT_SESSION_END_MS: number;
28
51
  export declare const TRANSCRIPT_HOOK_COVER_MS = 60000;
@@ -86,6 +109,8 @@ export interface TranscriptWatchDeps {
86
109
  reconcile?: typeof reconcileObservation;
87
110
  claudeProjectsDir?: string;
88
111
  codexSessionsDir?: string;
112
+ /** Override entry cap (tests). Defaults to TRANSCRIPT_WATCH_ENTRY_CAP. */
113
+ entryCap?: number;
89
114
  }
90
115
  export interface TranscriptWatchTickResult {
91
116
  discovered: number;
@@ -94,7 +119,43 @@ export interface TranscriptWatchTickResult {
94
119
  ended: number;
95
120
  skippedHookCovered: number;
96
121
  skippedStale: number;
122
+ /** Dir stats + readdir children + file stats examined this tick. */
123
+ entriesExamined: number;
124
+ durationMs: number;
125
+ /** True when TRANSCRIPT_WATCH_ENTRY_CAP stopped the walk early. */
126
+ capped: boolean;
127
+ /** True on the first capped tick of a contiguous capped episode (for logging). */
128
+ capEpisodeStart: boolean;
129
+ /** True when the discover cache was cleared due to exceeding the file cap. */
130
+ cacheOverflowCleared: boolean;
131
+ /** Interval after this tick's adaptive backoff adjustment. */
132
+ intervalMs: number;
133
+ previousIntervalMs: number;
134
+ intervalChanged: boolean;
135
+ /** True when a previous tick was still running (this call was a no-op). */
136
+ skippedConcurrent: boolean;
137
+ }
138
+ /** Per-directory mtime + child cache for incremental discovery. */
139
+ export interface TranscriptDirCacheEntry {
140
+ mtimeMs: number;
141
+ files: DiscoveredTranscript[];
142
+ subdirs: string[];
143
+ /** Wall time of the last complete listing of this directory. */
144
+ lastFullStatAtMs: number;
145
+ }
146
+ export interface TranscriptDiscoverCache {
147
+ dirs: Map<string, TranscriptDirCacheEntry>;
97
148
  }
149
+ export interface DiscoverScanMeta {
150
+ entriesExamined: number;
151
+ dirsListed: number;
152
+ dirsSkipped: number;
153
+ filesStatted: number;
154
+ capped: boolean;
155
+ /** True when cache file count exceeded the entry cap and the cache was cleared. */
156
+ cacheOverflowCleared: boolean;
157
+ }
158
+ export declare function createTranscriptDiscoverCache(): TranscriptDiscoverCache;
98
159
  /**
99
160
  * Claude Code encodes an absolute cwd as a directory name by replacing every
100
161
  * "/" with "-". Decoding is best-effort (hyphenated path segments are ambiguous).
@@ -110,15 +171,41 @@ export declare function sessionIdFromClaudeTranscriptPath(filePath: string): str
110
171
  * Rule: trailing UUID in basename, else basename without extension.
111
172
  */
112
173
  export declare function sessionIdFromCodexTranscriptPath(filePath: string): string | null;
113
- /**
114
- * Enumerate transcript files with mtime only (no content read).
115
- */
116
- export declare function discoverTranscripts(opts: {
174
+ export interface DiscoverTranscriptsOptions {
117
175
  home?: string;
118
176
  fs?: TranscriptFs;
119
177
  claudeProjectsDir?: string;
120
178
  codexSessionsDir?: string;
121
- }): DiscoveredTranscript[];
179
+ /** When set, reuse/update this cache for incremental scans. */
180
+ cache?: TranscriptDiscoverCache;
181
+ /** Clock for active-window re-stat decisions. Defaults to Date.now(). */
182
+ nowMs?: number;
183
+ /** Override entry cap (tests). Defaults to TRANSCRIPT_WATCH_ENTRY_CAP. */
184
+ entryCap?: number;
185
+ /** Active mtime window for re-stat in unchanged dirs. */
186
+ activeWindowMs?: number;
187
+ }
188
+ export interface DiscoverTranscriptsResult {
189
+ transcripts: DiscoveredTranscript[];
190
+ meta: DiscoverScanMeta;
191
+ }
192
+ /**
193
+ * Enumerate transcript files with mtime only (no content read).
194
+ * Pass `cache` to skip readdir on directories whose mtime is unchanged
195
+ * (until TRANSCRIPT_WATCH_REVALIDATE_MS forces a relist).
196
+ *
197
+ * Each root gets half of `entryCap`; unused budget from the first root is
198
+ * available to the second so a huge Claude tree cannot starve Codex.
199
+ */
200
+ export declare function discoverTranscriptsWithMeta(opts?: DiscoverTranscriptsOptions): DiscoverTranscriptsResult;
201
+ /**
202
+ * Enumerate transcript files with mtime only (no content read).
203
+ * Without a cache this is a full walk; with `cache` it is incremental.
204
+ */
205
+ export declare function discoverTranscripts(opts?: DiscoverTranscriptsOptions): DiscoveredTranscript[];
206
+ /** Sort key for comparing discovery results independent of walk order. */
207
+ export declare function discoveryFingerprint(d: DiscoveredTranscript): string;
208
+ export declare function sortDiscoveries(items: DiscoveredTranscript[]): DiscoveredTranscript[];
122
209
  /**
123
210
  * Whether hooks already cover this session: durable hook-written state, or a
124
211
  * hook event observed within the last TRANSCRIPT_HOOK_COVER_MS.
@@ -156,10 +243,23 @@ export declare class TranscriptWatcher {
156
243
  private readonly readState;
157
244
  private readonly writeState;
158
245
  private readonly reconcileFn;
246
+ private readonly discoverCache;
247
+ private intervalMs;
248
+ private tickInFlight;
249
+ /** Tracks contiguous capped ticks so we log once per cap episode. */
250
+ private inCapEpisode;
159
251
  constructor(deps: TranscriptWatchDeps);
252
+ /** Current adaptive poll interval (after the last tick's backoff). */
253
+ getIntervalMs(): number;
254
+ /** Expose discovery cache for tests. */
255
+ getDiscoverCache(): TranscriptDiscoverCache;
160
256
  /** Record that a hook path emitted an event for sessionId (daemon flush). */
161
257
  noteHookEvent(sessionId: string, atMs?: number): void;
162
258
  tick(): Promise<TranscriptWatchTickResult>;
259
+ /**
260
+ * Heavy ticks double the poll interval up to MAX; a quiet tick resets to base.
261
+ */
262
+ private applyIntervalBackoff;
163
263
  /**
164
264
  * Register via reconcileObservation (membership-validated slug→uid), then
165
265
  * enqueue session_start. Never overwrites a hook-written state.
@@ -167,4 +267,11 @@ export declare class TranscriptWatcher {
167
267
  private emitStart;
168
268
  private emitKind;
169
269
  }
270
+ /**
271
+ * Adaptive interval: busy ticks double up to MAX; quiet ticks return to base.
272
+ */
273
+ export declare function nextTranscriptWatchIntervalMs(currentMs: number, opts: {
274
+ entriesExamined: number;
275
+ durationMs: number;
276
+ }): number;
170
277
  //# sourceMappingURL=transcript-watch.d.ts.map