@indigoai-us/hq-cli 5.345.230 → 5.345.232

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 (106) hide show
  1. package/CHANGELOG.md +54 -0
  2. package/README.md +3 -2
  3. package/assets/lanes-reconcile/hq-lanes-reconcile.service +1 -1
  4. package/assets/scaffold/core/scripts/pipeline-conductor.sh +14 -14
  5. package/assets/scaffold/core/scripts/pipeline-driver.sh +7 -7
  6. package/assets/scaffold/core/scripts/session-project.sh +19 -4
  7. package/dist/command-catalog.generated.d.ts +213 -177
  8. package/dist/command-catalog.generated.js +263 -212
  9. package/dist/command-registration-plan.d.ts +6 -24
  10. package/dist/command-registration-plan.js +4 -8
  11. package/dist/commands/auth.js +3 -2
  12. package/dist/commands/core-pipeline-conductor-command.js +1 -1
  13. package/dist/commands/core-pipeline-conductor-native.js +5 -5
  14. package/dist/commands/core-pipeline-driver-native.js +5 -5
  15. package/dist/commands/crm.js +2 -1
  16. package/dist/commands/daemon.js +7 -36
  17. package/dist/commands/deploy-access.js +6 -13
  18. package/dist/commands/deploy-comments.js +5 -13
  19. package/dist/commands/deploy-domains.js +6 -13
  20. package/dist/commands/deploy-list.js +25 -11
  21. package/dist/commands/deploy-mutations.d.ts +3 -0
  22. package/dist/commands/deploy-mutations.js +147 -0
  23. package/dist/commands/link.js +29 -0
  24. package/dist/commands/mesh.js +3 -1
  25. package/dist/commands/packs.js +3 -2
  26. package/dist/commands/pkg-remove.js +2 -1
  27. package/dist/commands/report.js +12 -9
  28. package/dist/data/command-states.json +10 -7
  29. package/dist/lib/bot/fleet-bots-update-pass.d.ts +8 -0
  30. package/dist/lib/bot/fleet-bots-update-pass.js +40 -0
  31. package/dist/lib/bot/fleet-bots-update-task.d.ts +12 -0
  32. package/dist/lib/bot/fleet-bots-update-task.js +52 -0
  33. package/dist/lib/bot/fleet-bots-update-worker-v1.d.ts +2 -0
  34. package/dist/lib/bot/fleet-bots-update-worker-v1.js +5 -0
  35. package/dist/lib/daemon/catalog.d.ts +8 -5
  36. package/dist/lib/daemon/catalog.js +15 -8
  37. package/dist/lib/daemon/hook-requests-codex-settings.d.ts +26 -0
  38. package/dist/lib/daemon/hook-requests-codex-settings.js +185 -0
  39. package/dist/lib/daemon/hook-requests-conduct-link.d.ts +1 -0
  40. package/dist/lib/daemon/hook-requests-conduct-link.js +21 -4
  41. package/dist/lib/daemon/hook-requests.d.ts +3 -2
  42. package/dist/lib/daemon/hook-requests.js +16 -3
  43. package/dist/lib/daemon/lock.js +33 -37
  44. package/dist/lib/daemon/ops/skill-command.d.ts +99 -0
  45. package/dist/lib/daemon/ops/skill-command.js +260 -0
  46. package/dist/lib/daemon/protocol.d.ts +1 -1
  47. package/dist/lib/daemon/protocol.js +1 -0
  48. package/dist/lib/daemon/run.js +10 -18
  49. package/dist/lib/daemon/server.js +7 -0
  50. package/dist/lib/daemon/supervisor.d.ts +5 -0
  51. package/dist/lib/daemon/supervisor.js +17 -2
  52. package/dist/lib/db/app-ref.js +10 -15
  53. package/dist/lib/deploy-apps.d.ts +29 -0
  54. package/dist/lib/deploy-apps.js +37 -0
  55. package/dist/lib/doctor/checks/search-index.d.ts +16 -0
  56. package/dist/lib/doctor/checks/search-index.js +61 -0
  57. package/dist/lib/doctor/checks/stranded-lanes.js +1 -1
  58. package/dist/lib/doctor/registry.js +4 -0
  59. package/dist/lib/flag-registry.d.ts +7 -0
  60. package/dist/lib/flag-registry.js +20 -0
  61. package/dist/lib/hook-engine/coverage.d.ts +18 -0
  62. package/dist/lib/hook-engine/coverage.js +42 -1
  63. package/dist/lib/lanes/accounts.js +3 -3
  64. package/dist/lib/lanes/admission-host.js +1 -1
  65. package/dist/lib/lanes/admission.js +4 -4
  66. package/dist/lib/lanes/autopilot.js +2 -2
  67. package/dist/lib/lanes/blocker-freshness.js +1 -1
  68. package/dist/lib/lanes/compaction.js +5 -5
  69. package/dist/lib/lanes/delivery.js +1 -1
  70. package/dist/lib/lanes/depth-cap.js +1 -1
  71. package/dist/lib/lanes/disk-guard.js +1 -1
  72. package/dist/lib/lanes/dropbox.js +1 -1
  73. package/dist/lib/lanes/hooks-install.js +1 -1
  74. package/dist/lib/lanes/imported-question.js +1 -1
  75. package/dist/lib/lanes/keep-alive.d.ts +2 -2
  76. package/dist/lib/lanes/keep-alive.js +3 -3
  77. package/dist/lib/lanes/kr-freshness.js +1 -1
  78. package/dist/lib/lanes/links.js +92 -11
  79. package/dist/lib/lanes/loop.js +2 -2
  80. package/dist/lib/lanes/machine-identity.js +3 -3
  81. package/dist/lib/lanes/models.js +6 -6
  82. package/dist/lib/lanes/quota.js +1 -1
  83. package/dist/lib/lanes/reconcile-install.js +3 -3
  84. package/dist/lib/lanes/reconcile.js +16 -16
  85. package/dist/lib/lanes/remote-control-lane.js +6 -6
  86. package/dist/lib/lanes/reviews.js +2 -2
  87. package/dist/lib/lanes/spawn.js +24 -24
  88. package/dist/lib/lanes/status-fields.js +4 -4
  89. package/dist/lib/lanes/wait.js +4 -4
  90. package/dist/lib/lanes/watch.js +2 -2
  91. package/dist/lib/lanes/watcher-main.js +1 -1
  92. package/dist/lib/lanes/watcher.js +38 -38
  93. package/dist/lib/lanes/worker-process.js +5 -5
  94. package/dist/lib/mesh/live/daemon/pid-lock.d.ts +2 -4
  95. package/dist/lib/mesh/live/daemon/pid-lock.js +38 -55
  96. package/dist/utils/exclusive-lock.d.ts +60 -0
  97. package/dist/utils/exclusive-lock.js +65 -0
  98. package/dist/utils/exit-after-worker.d.ts +7 -0
  99. package/dist/utils/exit-after-worker.js +15 -0
  100. package/package.json +8 -7
  101. package/dist/commands/staff/listings.d.ts +0 -41
  102. package/dist/commands/staff/listings.js +0 -160
  103. package/dist/commands/staff/reset-test-account.d.ts +0 -121
  104. package/dist/commands/staff/reset-test-account.js +0 -285
  105. package/dist/commands/staff/test-account.d.ts +0 -51
  106. package/dist/commands/staff/test-account.js +0 -196
@@ -91,4 +91,11 @@ export declare function resolveProcessFlagGate(flagKey: string, lookup: FlagLook
91
91
  export declare function currentFlagSnapshot(): FlagSnapshot | null;
92
92
  /** Test-only reset for process-global readiness state. */
93
93
  export declare function _resetFlagRegistryForTests(): void;
94
+ /**
95
+ * Stop the background registry worker, if one is still running, and wait for
96
+ * it to end. A command that exits right after its own output calls this first:
97
+ * on Node 20 and 22, process.exit while an eval worker is still starting or
98
+ * fetching can crash the process (SIGSEGV) after the output was written.
99
+ */
100
+ export declare function stopFlagRegistryWorker(): Promise<void>;
94
101
  //# sourceMappingURL=flag-registry.d.ts.map
@@ -469,4 +469,24 @@ export function _resetFlagRegistryForTests() {
469
469
  refreshSentry = undefined;
470
470
  refreshDependencies = {};
471
471
  }
472
+ /**
473
+ * Stop the background registry worker, if one is still running, and wait for
474
+ * it to end. A command that exits right after its own output calls this first:
475
+ * on Node 20 and 22, process.exit while an eval worker is still starting or
476
+ * fetching can crash the process (SIGSEGV) after the output was written.
477
+ */
478
+ export async function stopFlagRegistryWorker() {
479
+ const worker = refreshWorker;
480
+ refreshWorker = null;
481
+ if (!worker || typeof worker.terminate !== "function")
482
+ return;
483
+ try {
484
+ await worker.terminate();
485
+ }
486
+ catch {
487
+ // Already ended or never started: nothing is left running to stop.
488
+ }
489
+ completeRefresh?.();
490
+ completeRefresh = null;
491
+ }
472
492
  //# sourceMappingURL=flag-registry.js.map
@@ -148,6 +148,24 @@ export declare function shellHooks(root: string, host: CoreNextHost, event: stri
148
148
  export declare function claimCovers(pattern: string, hook: string): boolean;
149
149
  /** The same install-level checks as stop/precompact/guard.rs, before reindex switches the event. */
150
150
  export declare function precompactCompatibilityHold(root: string, env?: NodeJS.ProcessEnv): string | null;
151
+ /** The hosts a COVERS host set may name (`Host::ALL` in crates/hq-hook/src/host/mod.rs). */
152
+ export declare const COVERS_HOSTS: readonly CoreNextHost[];
153
+ /**
154
+ * A `covers` key read, as crates/hq-hook/src/covers_hosts.rs `key` reads it:
155
+ * `Stop` claims for every host, `SubagentStop@codex,grok` for those hosts
156
+ * only. Null when the key cannot be read (an empty or unknown host, a second
157
+ * `@`, an event that is not ASCII letters): such a key claims nothing.
158
+ */
159
+ export declare function coversKey(key: string): {
160
+ event: string;
161
+ hosts: string[] | null;
162
+ } | null;
163
+ /**
164
+ * What `covers` claims for `event` on `host`: `covers[event]` (every host),
165
+ * then the ids of each host-set key for `event` that names `host`, in key
166
+ * order, each id once. The same as covers_hosts.rs `claims_on`.
167
+ */
168
+ export declare function coveredOn(covers: Readonly<Record<string, readonly string[]>> | undefined, event: string, host: CoreNextHost): string[];
151
169
  /** The old dispatcher's hooks for `event` on `host` that the engine does not cover. */
152
170
  export declare function uncoveredHooks(root: string, host: CoreNextHost, event: string, covers: Readonly<Record<string, readonly string[]>> | undefined, env?: NodeJS.ProcessEnv): string[];
153
171
  /** Records the environment `target` was resolved under; returns `target`. */
@@ -1624,12 +1624,53 @@ export function precompactCompatibilityHold(root, env = process.env) {
1624
1624
  }
1625
1625
  return null;
1626
1626
  }
1627
+ /** The hosts a COVERS host set may name (`Host::ALL` in crates/hq-hook/src/host/mod.rs). */
1628
+ export const COVERS_HOSTS = ['claude', 'codex', 'grok', 'fleet-local', 'agents-v2'];
1629
+ /**
1630
+ * A `covers` key read, as crates/hq-hook/src/covers_hosts.rs `key` reads it:
1631
+ * `Stop` claims for every host, `SubagentStop@codex,grok` for those hosts
1632
+ * only. Null when the key cannot be read (an empty or unknown host, a second
1633
+ * `@`, an event that is not ASCII letters): such a key claims nothing.
1634
+ */
1635
+ export function coversKey(key) {
1636
+ const at = key.indexOf('@');
1637
+ const event = at < 0 ? key : key.slice(0, at);
1638
+ let hosts = null;
1639
+ if (at >= 0) {
1640
+ const set = key.slice(at + 1);
1641
+ hosts = set.split(',');
1642
+ if (set.includes('@') || !hosts.every((name) => COVERS_HOSTS.includes(name)))
1643
+ return null;
1644
+ }
1645
+ if (!/^[A-Za-z]+$/.test(event))
1646
+ return null;
1647
+ return { event, hosts };
1648
+ }
1649
+ /**
1650
+ * What `covers` claims for `event` on `host`: `covers[event]` (every host),
1651
+ * then the ids of each host-set key for `event` that names `host`, in key
1652
+ * order, each id once. The same as covers_hosts.rs `claims_on`.
1653
+ */
1654
+ export function coveredOn(covers, event, host) {
1655
+ const out = [...(covers?.[event] ?? [])];
1656
+ for (const [key, ids] of Object.entries(covers ?? {})) {
1657
+ if (!key.includes('@'))
1658
+ continue;
1659
+ const read = coversKey(key);
1660
+ if (!read || read.event !== event || !read.hosts?.includes(host))
1661
+ continue;
1662
+ for (const id of ids)
1663
+ if (!out.includes(id))
1664
+ out.push(id);
1665
+ }
1666
+ return out;
1667
+ }
1627
1668
  /** The old dispatcher's hooks for `event` on `host` that the engine does not cover. */
1628
1669
  export function uncoveredHooks(root, host, event, covers, env = process.env) {
1629
1670
  const hooks = shellHooks(root, host, event);
1630
1671
  if (!hooks)
1631
1672
  return [UNREADABLE];
1632
- const covered = covers?.[event] ?? [];
1673
+ const covered = coveredOn(covers, event, host);
1633
1674
  const missing = hooks.filter((hook) => !covered.some((claim) => claimCovers(claim, hook)));
1634
1675
  if (event === 'Stop' && covered.includes('master-hook:Stop')) {
1635
1676
  const hold = stopCompatibilityHold(root, env);
@@ -458,7 +458,7 @@ export function accountStatus(provider, accountId, config, deps = defaultAccount
458
458
  });
459
459
  }
460
460
  catch {
461
- process.stderr.write(`hq lanes: Claude credential expiry check failed for account ${accountId}\n`);
461
+ process.stderr.write(`hq runners: Claude credential expiry check failed for account ${accountId}\n`);
462
462
  }
463
463
  }
464
464
  if (homeExists && !present && provider === "claude" && deps.probe !== undefined) {
@@ -472,7 +472,7 @@ export function accountStatus(provider, accountId, config, deps = defaultAccount
472
472
  identity = claudeIdentityFromProbe(result) ?? undefined;
473
473
  }
474
474
  catch {
475
- process.stderr.write(`hq lanes: Claude auth status probe failed for account ${accountId}\n`);
475
+ process.stderr.write(`hq runners: Claude auth status probe failed for account ${accountId}\n`);
476
476
  }
477
477
  }
478
478
  if (token?.state === "expired") {
@@ -520,7 +520,7 @@ function claudeLoginStatus(result) {
520
520
  }
521
521
  }
522
522
  catch (err) {
523
- process.stderr.write(`hq lanes: Claude auth status returned invalid JSON: ${err instanceof Error ? err.message : String(err)}\n`);
523
+ process.stderr.write(`hq runners: Claude auth status returned invalid JSON: ${err instanceof Error ? err.message : String(err)}\n`);
524
524
  return null;
525
525
  }
526
526
  }
@@ -12,7 +12,7 @@ export function readOutpostIdentity(existsSync = (p) => fs.existsSync(p), readFi
12
12
  text = readFileSync(OUTPOST_ID_PATH);
13
13
  }
14
14
  catch (err) {
15
- process.stderr.write(`hq lanes: failed to read ${OUTPOST_ID_PATH}: ${err instanceof Error ? err.message : String(err)}\n`);
15
+ process.stderr.write(`hq runners: failed to read ${OUTPOST_ID_PATH}: ${err instanceof Error ? err.message : String(err)}\n`);
16
16
  throw err;
17
17
  }
18
18
  const id = text.trim();
@@ -49,7 +49,7 @@ async function withAdmissionLock(lockPath, fn, sleep) {
49
49
  fs.closeSync(fd);
50
50
  }
51
51
  catch (err) {
52
- process.stderr.write(`hq lanes: admission lock close failed for ${lockPath}: ${err instanceof Error ? err.message : String(err)}\n`);
52
+ process.stderr.write(`hq runners: admission lock close failed for ${lockPath}: ${err instanceof Error ? err.message : String(err)}\n`);
53
53
  }
54
54
  try {
55
55
  const currentStat = fs.statSync(lockPath);
@@ -59,7 +59,7 @@ async function withAdmissionLock(lockPath, fn, sleep) {
59
59
  }
60
60
  catch (err) {
61
61
  if (err.code !== "ENOENT") {
62
- process.stderr.write(`hq lanes: admission lock unlink failed for ${lockPath}: ${err instanceof Error ? err.message : String(err)}\n`);
62
+ process.stderr.write(`hq runners: admission lock unlink failed for ${lockPath}: ${err instanceof Error ? err.message : String(err)}\n`);
63
63
  }
64
64
  }
65
65
  }
@@ -74,13 +74,13 @@ async function withAdmissionLock(lockPath, fn, sleep) {
74
74
  if (reclaimStaleLock(lockPath, {
75
75
  staleMs: ADMISSION_LOCK_STALE_MS,
76
76
  liveOwnerMaxMs: liveOwnerMaxMs(),
77
- label: "hq lanes admission",
77
+ label: "hq runners admission",
78
78
  }, { isAlive: admissionLockOwnerAlive }))
79
79
  continue;
80
80
  }
81
81
  catch (probeErr) {
82
82
  if (probeErr.code !== "ENOENT") {
83
- process.stderr.write(`hq lanes: stale admission-lock probe failed for ${lockPath}: ${probeErr instanceof Error ? probeErr.message : String(probeErr)}\n`);
83
+ process.stderr.write(`hq runners: stale admission-lock probe failed for ${lockPath}: ${probeErr instanceof Error ? probeErr.message : String(probeErr)}\n`);
84
84
  }
85
85
  }
86
86
  await sleep(10);
@@ -1290,14 +1290,14 @@ export async function runLeadAutopilotPass(input) {
1290
1290
  fs.closeSync(lockFd);
1291
1291
  }
1292
1292
  catch (error) {
1293
- process.stderr.write(`hq lanes autopilot: lock close failed: ${error instanceof Error ? error.message : String(error)}\n`);
1293
+ process.stderr.write(`hq runners autopilot: lock close failed: ${error instanceof Error ? error.message : String(error)}\n`);
1294
1294
  }
1295
1295
  try {
1296
1296
  fs.unlinkSync(lockPath);
1297
1297
  }
1298
1298
  catch (error) {
1299
1299
  if (error.code !== "ENOENT") {
1300
- process.stderr.write(`hq lanes autopilot: lock removal failed: ${error instanceof Error ? error.message : String(error)}\n`);
1300
+ process.stderr.write(`hq runners autopilot: lock removal failed: ${error instanceof Error ? error.message : String(error)}\n`);
1301
1301
  }
1302
1302
  }
1303
1303
  }
@@ -23,7 +23,7 @@ function errorCode(error) {
23
23
  return error instanceof LanesError ? error.error : "blocker_freshness_unavailable";
24
24
  }
25
25
  function reportError(lane, error) {
26
- process.stderr.write(`hq lanes: blocker freshness disabled for ${lane.lane_id}: ${errorCode(error)}\n`);
26
+ process.stderr.write(`hq runners: blocker freshness disabled for ${lane.lane_id}: ${errorCode(error)}\n`);
27
27
  }
28
28
  function failedResolution(flagEnabled, error, onError) {
29
29
  onError(error);
@@ -167,7 +167,7 @@ function isProviderMarkerLine(line, lineNumber, transcriptPath, provider, oversi
167
167
  record = parsed;
168
168
  }
169
169
  catch (err) {
170
- process.stderr.write(`hq lanes: skipped unparseable provider transcript marker line ${lineNumber} in ${transcriptPath}: ${err instanceof Error ? err.message : String(err)}\n`);
170
+ process.stderr.write(`hq runners: skipped unparseable provider transcript marker line ${lineNumber} in ${transcriptPath}: ${err instanceof Error ? err.message : String(err)}\n`);
171
171
  return false;
172
172
  }
173
173
  return ((provider === "claude" && record.type === "system" && record.subtype === "compact_boundary") ||
@@ -218,7 +218,7 @@ function scanTranscriptLines(transcriptPath, startOffset, includeUnterminatedLas
218
218
  lineNumber += 1;
219
219
  const recognizedMarker = onLine(Buffer.concat(lineParts, lineBytes).toString("utf8"), lineNumber, skipLongLine);
220
220
  if (skipLongLine && recognizedMarker !== true) {
221
- process.stderr.write(`hq lanes: skipped oversized transcript line ${lineNumber} in ${transcriptPath} (over ${maxLineBytes} bytes)\n`);
221
+ process.stderr.write(`hq runners: skipped oversized transcript line ${lineNumber} in ${transcriptPath} (over ${maxLineBytes} bytes)\n`);
222
222
  }
223
223
  lineParts = [];
224
224
  lineBytes = 0;
@@ -349,7 +349,7 @@ export function probeCompactBoundaries(transcriptPath, maxLineBytes = TRANSCRIPT
349
349
  rec = JSON.parse(line);
350
350
  }
351
351
  catch (err) {
352
- process.stderr.write(`hq lanes: skipped an unparseable line in ${transcriptPath}: ${err instanceof Error ? err.message : String(err)}\n`);
352
+ process.stderr.write(`hq runners: skipped an unparseable line in ${transcriptPath}: ${err instanceof Error ? err.message : String(err)}\n`);
353
353
  return false;
354
354
  }
355
355
  if (rec.type !== "system" || rec.subtype !== "compact_boundary")
@@ -391,7 +391,7 @@ export const defaultRunCompaction = (input) => {
391
391
  /** Stderr line printed before a resume-time `/compact` starts. */
392
392
  export function compactionStartNotice(sessionId) {
393
393
  const minutes = Math.round(COMPACTION_TIMEOUT_MS / 60_000);
394
- return `hq lanes: compacting session ${sessionId} before resume; this can take up to ${minutes} minutes. ` +
394
+ return `hq runners: compacting session ${sessionId} before resume; this can take up to ${minutes} minutes. ` +
395
395
  `Re-run with --no-compact to skip it.\n`;
396
396
  }
397
397
  /**
@@ -431,7 +431,7 @@ export function compactLaneSession(input) {
431
431
  reason = "the session transcript gained no compact_boundary record";
432
432
  }
433
433
  if (outcome !== "compacted") {
434
- process.stderr.write(`hq lanes: compaction of session ${input.sessionId} ${outcome}: ${reason ?? ""}\n`);
434
+ process.stderr.write(`hq runners: compaction of session ${input.sessionId} ${outcome}: ${reason ?? ""}\n`);
435
435
  }
436
436
  return {
437
437
  at: started.toISOString(),
@@ -344,7 +344,7 @@ workerOutOffset = 0) {
344
344
  cache_creation_input_tokens: null,
345
345
  };
346
346
  }
347
- process.stderr.write(`hq lanes: failed to read ${outPath}: ${err instanceof Error ? err.message : String(err)}\n`);
347
+ process.stderr.write(`hq runners: failed to read ${outPath}: ${err instanceof Error ? err.message : String(err)}\n`);
348
348
  throw err;
349
349
  }
350
350
  return parseWorkerRunOutput(provider, text);
@@ -33,7 +33,7 @@ export function laneDepthCap(hqRoot, companySlug) {
33
33
  if (value === undefined)
34
34
  return { max: MAX_LANE_DEPTH, source: "default" };
35
35
  if (typeof value !== "number" || !Number.isInteger(value) || value < 1 || value > 8) {
36
- process.stderr.write(`hq lanes: lane_depth_cap_invalid company=${companySlug} maxLaneDepth=${JSON.stringify(value)}; using default ${MAX_LANE_DEPTH}\n`);
36
+ process.stderr.write(`hq runners: lane_depth_cap_invalid company=${companySlug} maxLaneDepth=${JSON.stringify(value)}; using default ${MAX_LANE_DEPTH}\n`);
37
37
  return { max: MAX_LANE_DEPTH, source: "default" };
38
38
  }
39
39
  return { max: value, source: "company" };
@@ -163,7 +163,7 @@ async function gzipRolloutStream(source, temp, target, io) {
163
163
  }
164
164
  catch (cleanupError) {
165
165
  if (cleanupError.code !== "ENOENT") {
166
- process.stderr.write(`hq lanes: rollout compression temp cleanup failed for ${temp}: ${cleanupError instanceof Error ? cleanupError.message : String(cleanupError)}\n`);
166
+ process.stderr.write(`hq runners: rollout compression temp cleanup failed for ${temp}: ${cleanupError instanceof Error ? cleanupError.message : String(cleanupError)}\n`);
167
167
  }
168
168
  }
169
169
  throw error;
@@ -172,7 +172,7 @@ export function readToolActivity(hqRoot, laneId) {
172
172
  return { at: parsed.at, hook_pid: parsed.hook_pid, hook_event: "PreToolUse" };
173
173
  }
174
174
  catch (err) {
175
- process.stderr.write(`hq lanes: tool activity for ${laneId} is unparseable: ${err instanceof Error ? err.message : String(err)}\n`);
175
+ process.stderr.write(`hq runners: tool activity for ${laneId} is unparseable: ${err instanceof Error ? err.message : String(err)}\n`);
176
176
  return null;
177
177
  }
178
178
  }
@@ -698,7 +698,7 @@ export function probeDrainHookRegistration(provider, providerHome) {
698
698
  };
699
699
  }
700
700
  catch (err) {
701
- process.stderr.write(`hq lanes: registration file ${regPath} is unreadable as ${kind}: ${err instanceof Error ? err.message : String(err)}\n`);
701
+ process.stderr.write(`hq runners: registration file ${regPath} is unreadable as ${kind}: ${err instanceof Error ? err.message : String(err)}\n`);
702
702
  return { ...base, registered: false };
703
703
  }
704
704
  }
@@ -8,7 +8,7 @@ export function importedQuestionMarker(root, id) {
8
8
  /** A pending transfer is also read-only: its remote POST may already have succeeded. */
9
9
  export function assertQuestionNotImported(root, id) {
10
10
  if (isQuestionImported(root, id)) {
11
- throw new LanesError("question_imported_read_only", "This question was transferred to hq decide and is read-only in hq lanes. Use hq decide list to find and answer the decision.", { question_id: id });
11
+ throw new LanesError("question_imported_read_only", "This question was transferred to hq decide and is read-only in hq runners. Use hq decide list to find and answer the decision.", { question_id: id });
12
12
  }
13
13
  }
14
14
  export function isQuestionImported(root, id) {
@@ -31,9 +31,9 @@ export declare function queueLaneTerminalResume(current: LaneRecord, at: string,
31
31
  }): LaneTerminalResumeResult;
32
32
  /** Persist a manager status miss and queue its one bounded follow-up turn. */
33
33
  export declare function queueManagerStatusGateResume(hqRoot: string, laneId: string, entry: Omit<ManagerStatusGateHistoryEntry, "event" | "resume_queued" | "resume_skipped_reason">, resumeText: string, skip?: (current: LaneRecord) => boolean): LaneRecord;
34
- export declare const LEAD_LANE_KEEP_ALIVE_RESUME_TEXT = "Automatic keep-alive resume: your last turn ended with decision done and story_complete false. Continue the open work from where you stopped. End with done only when story_complete is true; if you are waiting, use hq lanes ask or stay in the loop.";
34
+ export declare const LEAD_LANE_KEEP_ALIVE_RESUME_TEXT = "Automatic keep-alive resume: your last turn ended with decision done and story_complete false. Continue the open work from where you stopped. End with done only when story_complete is true; if you are waiting, use hq runners ask or stay in the loop.";
35
35
  export declare const LEAD_LANE_KEEP_ALIVE_BLOCKED_RESUME_TEXT = "You ended blocked with no pending question. Record the event you wait on in waiting_on, re-check each blocker, and continue the next unblocked story.";
36
- export declare const LEAD_LANE_KEEP_ALIVE_INTERRUPTED_RESUME_TEXT = "Automatic keep-alive resume: your previous turn was interrupted by a provider process exit. Check your last state before continuing. Continue the open work from where you stopped. End with done only when story_complete is true; if you are waiting, use hq lanes ask or stay in the loop.";
36
+ export declare const LEAD_LANE_KEEP_ALIVE_INTERRUPTED_RESUME_TEXT = "Automatic keep-alive resume: your previous turn was interrupted by a provider process exit. Check your last state before continuing. Continue the open work from where you stopped. End with done only when story_complete is true; if you are waiting, use hq runners ask or stay in the loop.";
37
37
  export type KeepAliveBlockedReason = NonNullable<LaneRecord["keep_alive_blocked_reason"]>;
38
38
  /** The latest terminal envelope fields used by both watch and reconcile. */
39
39
  export interface KeepAliveDoneEnvelope {
@@ -105,9 +105,9 @@ export function queueManagerStatusGateResume(hqRoot, laneId, entry, resumeText,
105
105
  };
106
106
  });
107
107
  }
108
- export const LEAD_LANE_KEEP_ALIVE_RESUME_TEXT = "Automatic keep-alive resume: your last turn ended with decision done and story_complete false. Continue the open work from where you stopped. End with done only when story_complete is true; if you are waiting, use hq lanes ask or stay in the loop.";
108
+ export const LEAD_LANE_KEEP_ALIVE_RESUME_TEXT = "Automatic keep-alive resume: your last turn ended with decision done and story_complete false. Continue the open work from where you stopped. End with done only when story_complete is true; if you are waiting, use hq runners ask or stay in the loop.";
109
109
  export const LEAD_LANE_KEEP_ALIVE_BLOCKED_RESUME_TEXT = "You ended blocked with no pending question. Record the event you wait on in waiting_on, re-check each blocker, and continue the next unblocked story.";
110
- export const LEAD_LANE_KEEP_ALIVE_INTERRUPTED_RESUME_TEXT = "Automatic keep-alive resume: your previous turn was interrupted by a provider process exit. Check your last state before continuing. Continue the open work from where you stopped. End with done only when story_complete is true; if you are waiting, use hq lanes ask or stay in the loop.";
110
+ export const LEAD_LANE_KEEP_ALIVE_INTERRUPTED_RESUME_TEXT = "Automatic keep-alive resume: your previous turn was interrupted by a provider process exit. Check your last state before continuing. Continue the open work from where you stopped. End with done only when story_complete is true; if you are waiting, use hq runners ask or stay in the loop.";
111
111
  export function keepAliveNextCheckAtMs(value, nowMs, anchorMs = nowMs) {
112
112
  if (typeof value !== "string" || !isIsoDateTime(value))
113
113
  return undefined;
@@ -182,7 +182,7 @@ function readKeepAliveQuestionRecords(hqRoot) {
182
182
  questions.push(readQuestion(hqRoot, questionId));
183
183
  }
184
184
  catch (err) {
185
- process.stderr.write(`hq lanes keep-alive: skipped unreadable question ${questionId}: ${err instanceof Error ? err.message : String(err)}\n`);
185
+ process.stderr.write(`hq runners keep-alive: skipped unreadable question ${questionId}: ${err instanceof Error ? err.message : String(err)}\n`);
186
186
  }
187
187
  }
188
188
  return questions;
@@ -308,7 +308,7 @@ function viewsFromLedger(ledger, now, windowHours) {
308
308
  }));
309
309
  }
310
310
  function reportFailure(lane, error) {
311
- process.stderr.write(`hq lanes: KR freshness disabled for ${lane.lane_id}: ${errorCode(error)}\n`);
311
+ process.stderr.write(`hq runners: KR freshness disabled for ${lane.lane_id}: ${errorCode(error)}\n`);
312
312
  }
313
313
  function failedResolution(error, onError) {
314
314
  onError(error);
@@ -136,7 +136,7 @@ function bindSignalLaneSession(root, sid, env) {
136
136
  lane = readLane(root, laneId);
137
137
  }
138
138
  catch {
139
- process.stderr.write("hq lanes signal link: lane record unavailable\n");
139
+ process.stderr.write("hq runners signal link: lane record unavailable\n");
140
140
  return;
141
141
  }
142
142
  if (!lane.signal || !lane.signal_link || lane.signal_link !== env.HQ_LANE_SIGNAL_LINK)
@@ -162,7 +162,7 @@ export function isLinkedSession(root, sid, env = process.env) {
162
162
  bindSignalLaneSession(root, sid, env);
163
163
  }
164
164
  catch {
165
- process.stderr.write("hq lanes signal link: could not bind worker session\n");
165
+ process.stderr.write("hq runners signal link: could not bind worker session\n");
166
166
  return false;
167
167
  }
168
168
  return Boolean(safeId(sid) && readPointer(root, sid));
@@ -351,6 +351,82 @@ function sendQueue(root, link, child, text) {
351
351
  appendDropboxMessageAtPath(pending, { at: new Date().toISOString(), text: cleanText });
352
352
  });
353
353
  }
354
+ /**
355
+ * The daemon's conduct-lanes-link-deliver run (a Codex SubagentStop note) sets
356
+ * HQ_LINK_DELIVER_QUEUED_AT_OR_BEFORE to the event's time, so `_deliver`
357
+ * takes only the messages queued at or before that event; later ones stay
358
+ * pending for the root's next PostToolUse or Stop. Unset: everything is taken,
359
+ * as before. Returns null for a value it cannot read (the caller then takes
360
+ * nothing).
361
+ */
362
+ function deliverCutoff(env) {
363
+ const raw = env.HQ_LINK_DELIVER_QUEUED_AT_OR_BEFORE;
364
+ if (raw === undefined)
365
+ return undefined;
366
+ if (!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{1,9})?Z$/.test(raw))
367
+ return null;
368
+ const at = Date.parse(raw);
369
+ return Number.isFinite(at) ? at : null;
370
+ }
371
+ const HELD_LATER = "held-after-cutoff.jsonl";
372
+ /** Put back rows a cutoff held out of a take that did not finish (crash). Caller holds the queue lock. */
373
+ function restoreHeldRowsUnlocked(inbox) {
374
+ const held = path.join(inbox, HELD_LATER);
375
+ if (!fs.existsSync(held))
376
+ return;
377
+ const pending = path.join(inbox, "pending");
378
+ fs.mkdirSync(pending, { recursive: true });
379
+ const rows = fs.readFileSync(held, "utf8");
380
+ if (rows)
381
+ fs.appendFileSync(path.join(pending, "inbox.jsonl"), rows.endsWith("\n") ? rows : `${rows}\n`, { mode: 0o600 });
382
+ fs.rmSync(held, { force: true });
383
+ }
384
+ /**
385
+ * Before a take with a cutoff: move the pending rows queued after the cutoff,
386
+ * and rows whose time cannot be read, to a held file beside pending, so the
387
+ * take sees only rows at or before it. Caller holds the queue lock and calls
388
+ * restoreHeldRowsUnlocked after the take.
389
+ */
390
+ function holdRowsAfterCutoffUnlocked(inbox, cutoff) {
391
+ const file = path.join(inbox, "pending", "inbox.jsonl");
392
+ if (!fs.existsSync(file))
393
+ return;
394
+ const due = [];
395
+ const later = [];
396
+ for (const line of fs.readFileSync(file, "utf8").split(/\r?\n/)) {
397
+ if (!line)
398
+ continue;
399
+ let at = Number.NaN;
400
+ try {
401
+ const row = JSON.parse(line);
402
+ const value = row && typeof row === "object" ? row.at : undefined;
403
+ if (typeof value === "string")
404
+ at = Date.parse(value);
405
+ }
406
+ catch { /* unreadable rows are not ours to take */ }
407
+ (Number.isFinite(at) && at <= cutoff ? due : later).push(line);
408
+ }
409
+ if (!later.length)
410
+ return;
411
+ fs.writeFileSync(path.join(inbox, HELD_LATER), `${later.join("\n")}\n`, { mode: 0o600 });
412
+ if (due.length)
413
+ fs.writeFileSync(file, `${due.join("\n")}\n`, { mode: 0o600 });
414
+ else
415
+ fs.rmSync(file, { force: true });
416
+ }
417
+ /** Run a take on the queue, limited to rows queued at or before cutoff when one is given. Caller holds the queue lock. */
418
+ function takeUpToUnlocked(inbox, cutoff, take) {
419
+ restoreHeldRowsUnlocked(inbox);
420
+ if (cutoff === undefined)
421
+ return take();
422
+ holdRowsAfterCutoffUnlocked(inbox, cutoff);
423
+ try {
424
+ return take();
425
+ }
426
+ finally {
427
+ restoreHeldRowsUnlocked(inbox);
428
+ }
429
+ }
354
430
  /** Claims pending files by renaming the whole queue, matching conduct-inbox's no-loss drain. */
355
431
  function drainLinkQueueUnlocked(inbox) {
356
432
  const pending = path.join(inbox, "pending");
@@ -543,9 +619,6 @@ function claimLinkQueueUnlocked(inbox) {
543
619
  }
544
620
  return { messages: messages.join("\n"), claims };
545
621
  }
546
- function claimLinkQueue(inbox) {
547
- return withLinkQueueLock(inbox, () => claimLinkQueueUnlocked(inbox));
548
- }
549
622
  function acknowledgeLinkClaims(inbox, claims) {
550
623
  return withLinkQueueLock(inbox, () => acknowledgeLinkClaimsUnlocked(inbox, claims));
551
624
  }
@@ -734,21 +807,29 @@ export async function runLaneLink(subcommand, options) {
734
807
  const target = hookMessage(root, pointer);
735
808
  if (options.ackMode !== undefined && options.ackMode !== "explicit")
736
809
  throw new LaneLinkError("ack_mode_invalid", "Unsupported acknowledgement mode");
810
+ // A cutoff it cannot read: take nothing, everything stays queued.
811
+ const cutoff = deliverCutoff(env);
812
+ if (cutoff === null)
813
+ return {};
737
814
  let claim;
738
815
  let messages;
739
816
  if (pointer.role === "conductor") {
740
817
  await options.beforeConductorQueue?.();
741
- const drained = withConductorQueue(root, pointer.link, sid, (inbox) => options.ackMode === "explicit"
818
+ const drained = withConductorQueue(root, pointer.link, sid, (inbox) => takeUpToUnlocked(inbox, cutoff, () => options.ackMode === "explicit"
742
819
  ? { claim: claimLinkQueueUnlocked(inbox), messages: "" }
743
- : { claim: undefined, messages: drainLinkQueueUnlocked(inbox) });
820
+ : { claim: undefined, messages: drainLinkQueueUnlocked(inbox) }));
744
821
  if (drained === null)
745
822
  return {};
746
823
  claim = drained.claim;
747
824
  messages = claim ? claim.messages : drained.messages;
748
825
  }
749
826
  else {
750
- claim = options.ackMode === "explicit" ? claimLinkQueue(target.inbox) : undefined;
751
- messages = claim ? claim.messages : drainLinkQueue(target.inbox);
827
+ const inbox = target.inbox;
828
+ const taken = withLinkQueueLock(inbox, () => takeUpToUnlocked(inbox, cutoff, () => options.ackMode === "explicit"
829
+ ? { claim: claimLinkQueueUnlocked(inbox), messages: "" }
830
+ : { claim: undefined, messages: drainLinkQueueUnlocked(inbox) }));
831
+ claim = taken.claim;
832
+ messages = claim ? claim.messages : taken.messages;
752
833
  }
753
834
  if (!messages)
754
835
  return {};
@@ -972,8 +1053,8 @@ export async function runLaneLink(subcommand, options) {
972
1053
  // is refused above, so no session can take over a link it was not given.
973
1054
  if (previousHolds && !handoverTokenValid(meta.handover, token, now())) {
974
1055
  throw new LaneLinkError(tokenProvided ? "handover_token_invalid" : "link_owned", tokenProvided
975
- ? `The handover token for ${link} is wrong, used, or expired; ask the conductor of record to run hq lanes link handover again`
976
- : `Link ${link} is held by conductor session ${previous}; that session must run hq lanes link handover and pass you the token`);
1056
+ ? `The handover token for ${link} is wrong, used, or expired; ask the conductor of record to run hq runners link handover again`
1057
+ : `Link ${link} is held by conductor session ${previous}; that session must run hq runners link handover and pass you the token`);
977
1058
  }
978
1059
  const at = now().toISOString();
979
1060
  fs.mkdirSync(path.join(links, "by-session"), { recursive: true });
@@ -450,7 +450,7 @@ function acquireRunnerLease(runDir, identity) {
450
450
  atomicJson(ownerFile, { pid: process.pid, starttime, heartbeat_at: new Date().toISOString() });
451
451
  }
452
452
  catch (error) {
453
- process.stderr.write(`hq lanes: loop lease heartbeat failed: ${error instanceof Error ? error.message : String(error)}\n`);
453
+ process.stderr.write(`hq runners: loop lease heartbeat failed: ${error instanceof Error ? error.message : String(error)}\n`);
454
454
  }
455
455
  }, 15_000);
456
456
  atomicJson(ownerFile, { pid: process.pid, starttime, heartbeat_at: new Date().toISOString() });
@@ -530,7 +530,7 @@ export function enqueueLoopEnvelope(input) {
530
530
  return { file, dir, record: fileEnvelope(file) };
531
531
  }
532
532
  catch (error) {
533
- process.stderr.write(`hq lanes: ignored unreadable loop record ${file}: ${error instanceof Error ? error.message : String(error)}\n`);
533
+ process.stderr.write(`hq runners: ignored unreadable loop record ${file}: ${error instanceof Error ? error.message : String(error)}\n`);
534
534
  return undefined;
535
535
  }
536
536
  })
@@ -33,7 +33,7 @@ function curlImds(method, url, headers) {
33
33
  return body.length > 0 ? body : null;
34
34
  }
35
35
  catch (err) {
36
- process.stderr.write(`hq lanes: IMDS request failed for ${url}: ${err instanceof Error ? err.message : String(err)}\n`);
36
+ process.stderr.write(`hq runners: IMDS request failed for ${url}: ${err instanceof Error ? err.message : String(err)}\n`);
37
37
  return null;
38
38
  }
39
39
  }
@@ -81,7 +81,7 @@ export function resolveMachineIdentity(deps = {}) {
81
81
  imdsId = typeof raw === "string" && raw.trim() !== "" ? raw.trim() : null;
82
82
  }
83
83
  catch (err) {
84
- process.stderr.write(`hq lanes: IMDS identity lookup failed: ${err instanceof Error ? err.message : String(err)}\n`);
84
+ process.stderr.write(`hq runners: IMDS identity lookup failed: ${err instanceof Error ? err.message : String(err)}\n`);
85
85
  }
86
86
  let hostname = null;
87
87
  try {
@@ -90,7 +90,7 @@ export function resolveMachineIdentity(deps = {}) {
90
90
  hostname = typeof host === "string" && host.trim() !== "" ? host.trim() : null;
91
91
  }
92
92
  catch (err) {
93
- process.stderr.write(`hq lanes: hostname identity lookup failed: ${err instanceof Error ? err.message : String(err)}\n`);
93
+ process.stderr.write(`hq runners: hostname identity lookup failed: ${err instanceof Error ? err.message : String(err)}\n`);
94
94
  if (!imdsId) {
95
95
  return {
96
96
  status: "unresolvable",
@@ -54,7 +54,7 @@ export function codexKnownModels(home, readFileSync = (p, enc) => fs.readFileSyn
54
54
  return null;
55
55
  // EACCES, EISDIR, EIO: the list cannot be read, which is the same
56
56
  // contract as a missing or corrupt cache. Reported, never an internal failure.
57
- process.stderr.write(`hq lanes: cannot read ${source} (${err instanceof Error ? err.message : String(err)}); --model is not validated for codex\n`);
57
+ process.stderr.write(`hq runners: cannot read ${source} (${err instanceof Error ? err.message : String(err)}); --model is not validated for codex\n`);
58
58
  return null;
59
59
  }
60
60
  let parsed;
@@ -62,7 +62,7 @@ export function codexKnownModels(home, readFileSync = (p, enc) => fs.readFileSyn
62
62
  parsed = JSON.parse(text);
63
63
  }
64
64
  catch (err) {
65
- process.stderr.write(`hq lanes: ${source} is not JSON (${err instanceof Error ? err.message : String(err)}); --model is not validated for codex\n`);
65
+ process.stderr.write(`hq runners: ${source} is not JSON (${err instanceof Error ? err.message : String(err)}); --model is not validated for codex\n`);
66
66
  return null;
67
67
  }
68
68
  if (!isPlainObject(parsed) || !Array.isArray(parsed.models))
@@ -112,12 +112,12 @@ export function grokKnownModels(home, probe = defaultProbe, env = process.env) {
112
112
  // print a partial list and then fail; an id missing from that output must
113
113
  // not refuse the model, so a failed probe skips validation.
114
114
  if (result.status !== 0) {
115
- process.stderr.write(`hq lanes: \`${source}\` failed (exit ${result.status ?? "spawn error"}${result.stderr.trim() ? `: ${result.stderr.trim().split("\n")[0]}` : ""}); --model is not validated for grok\n`);
115
+ process.stderr.write(`hq runners: \`${source}\` failed (exit ${result.status ?? "spawn error"}${result.stderr.trim() ? `: ${result.stderr.trim().split("\n")[0]}` : ""}); --model is not validated for grok\n`);
116
116
  return null;
117
117
  }
118
118
  const ids = parseGrokModelsOutput(result.stdout);
119
119
  if (ids.length === 0) {
120
- process.stderr.write(`hq lanes: \`${source}\` listed no models (exit ${result.status ?? "spawn error"}${result.stderr.trim() ? `: ${result.stderr.trim().split("\n")[0]}` : ""}); --model is not validated for grok\n`);
120
+ process.stderr.write(`hq runners: \`${source}\` listed no models (exit ${result.status ?? "spawn error"}${result.stderr.trim() ? `: ${result.stderr.trim().split("\n")[0]}` : ""}); --model is not validated for grok\n`);
121
121
  return null;
122
122
  }
123
123
  return { provider: "grok", ids, prefixes: [], source };
@@ -160,12 +160,12 @@ export function claudeKnownModels(probe = defaultProbe, env = process.env) {
160
160
  const source = "claude --help";
161
161
  const result = probe("claude", ["--help"], env);
162
162
  if (result.status !== 0) {
163
- process.stderr.write(`hq lanes: \`${source}\` failed (exit ${result.status ?? "spawn error"}${result.stderr.trim() ? `: ${result.stderr.trim().split("\n")[0]}` : ""}); --model is not validated for claude\n`);
163
+ process.stderr.write(`hq runners: \`${source}\` failed (exit ${result.status ?? "spawn error"}${result.stderr.trim() ? `: ${result.stderr.trim().split("\n")[0]}` : ""}); --model is not validated for claude\n`);
164
164
  return null;
165
165
  }
166
166
  const parsed = parseClaudeHelpModels(result.stdout);
167
167
  if (parsed.aliases.length === 0 && parsed.prefixes.length === 0) {
168
- process.stderr.write(`hq lanes: \`${source}\` named no --model aliases (exit ${result.status ?? "spawn error"}); --model is not validated for claude\n`);
168
+ process.stderr.write(`hq runners: \`${source}\` named no --model aliases (exit ${result.status ?? "spawn error"}); --model is not validated for claude\n`);
169
169
  return null;
170
170
  }
171
171
  // Every Claude model's full name starts with `claude-`. Accept it even when
@@ -644,7 +644,7 @@ export function clearAccountQuotaAfterSuccessfulTurnBestEffort(hqRoot, provider,
644
644
  }
645
645
  catch (err) {
646
646
  const detail = err instanceof Error ? err.message : String(err);
647
- process.stderr.write(`hq lanes: quota cleanup after successful turn failed for provider=${provider} account=${accountId} model=${model}: ${detail}\n`);
647
+ process.stderr.write(`hq runners: quota cleanup after successful turn failed for provider=${provider} account=${accountId} model=${model}: ${detail}\n`);
648
648
  }
649
649
  }
650
650
  function shouldReplaceReset(current, incoming) {