@indigoai-us/hq-cli 5.311.4 → 5.312.0

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 (34) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/command-catalog.generated.d.ts +95 -0
  3. package/dist/command-catalog.generated.js +120 -0
  4. package/dist/command-registration-plan.d.ts +6 -0
  5. package/dist/command-registration-plan.js +1 -0
  6. package/dist/commands/daemon.js +22 -0
  7. package/dist/commands/dm.js +22 -6
  8. package/dist/commands/files-browse.js +16 -4
  9. package/dist/commands/lanes-message.js +17 -2
  10. package/dist/commands/lanes-shared.d.ts +1 -0
  11. package/dist/commands/lanes.js +96 -20
  12. package/dist/commands/vault-retention-flag.d.ts +3 -0
  13. package/dist/commands/vault-retention-flag.js +9 -0
  14. package/dist/commands/vault-retention.d.ts +11 -0
  15. package/dist/commands/vault-retention.js +69 -0
  16. package/dist/lib/core-utils/sentry-report.js +21 -4
  17. package/dist/lib/daemon/catalog.d.ts +2 -0
  18. package/dist/lib/daemon/catalog.js +13 -1
  19. package/dist/lib/daemon/config.d.ts +2 -0
  20. package/dist/lib/daemon/config.js +4 -0
  21. package/dist/lib/daemon/run.d.ts +2 -0
  22. package/dist/lib/daemon/run.js +5 -0
  23. package/dist/lib/lanes/autopilot.d.ts +38 -1
  24. package/dist/lib/lanes/autopilot.js +353 -5
  25. package/dist/lib/lanes/flag-keys.d.ts +9 -1
  26. package/dist/lib/lanes/flag-keys.js +9 -1
  27. package/dist/lib/lanes/keep-alive.d.ts +2 -0
  28. package/dist/lib/lanes/keep-alive.js +2 -0
  29. package/dist/lib/lanes/reconcile.d.ts +5 -0
  30. package/dist/lib/lanes/reconcile.js +57 -4
  31. package/dist/lib/lanes/watcher-main.js +20 -1
  32. package/dist/lib/lanes/watcher.d.ts +9 -0
  33. package/dist/lib/lanes/watcher.js +47 -1
  34. package/package.json +1 -1
@@ -5,7 +5,7 @@
5
5
  * Usage: node watcher-main.js <lane-id>
6
6
  * Requires HQ_ROOT in the environment.
7
7
  */
8
- import { spawnSync } from "node:child_process";
8
+ import { spawn, spawnSync } from "node:child_process";
9
9
  import { existsSync, realpathSync } from "node:fs";
10
10
  import * as path from "node:path";
11
11
  import { fileURLToPath } from "node:url";
@@ -32,6 +32,25 @@ export function watcherMainDeps(hqRoot, laneId, env = process.env, repairDispatc
32
32
  throw new Error(`recovery command exited ${result.status ?? result.signal ?? "without status"}: ${(result.stderr ?? "").trim()}`);
33
33
  }
34
34
  },
35
+ scheduleTerminalKeepAlive: async ({ laneId: scheduledLaneId, version, dueAt }) => {
36
+ await new Promise((resolve, reject) => {
37
+ const child = spawn(process.execPath, [
38
+ cliEntry,
39
+ "lanes",
40
+ "_keep-alive-terminal-trigger",
41
+ scheduledLaneId,
42
+ String(version),
43
+ dueAt,
44
+ ], {
45
+ env,
46
+ detached: true,
47
+ stdio: "ignore",
48
+ });
49
+ child.once("error", reject);
50
+ child.once("spawn", resolve);
51
+ child.unref();
52
+ });
53
+ },
35
54
  };
36
55
  }
37
56
  function deliverLaneSeniorMessage(cliEntry, laneId, text) {
@@ -238,6 +238,15 @@ export interface WatcherLoopDeps {
238
238
  readKrFreshnessFlag?: typeof readLanesRegistryFlag;
239
239
  /** Test seam; production reads the company-scoped hq-flags row. */
240
240
  readEnvelopeRepairContinueFlag?: typeof readLanesRegistryFlag;
241
+ /** Test seam; production reads the company-scoped hq-flags row. */
242
+ readTerminalKeepAliveFlag?: typeof readLanesRegistryFlag;
243
+ /** Schedule an immediate reconcile check for the terminal lane version. */
244
+ scheduleTerminalKeepAlive?: (input: {
245
+ laneId: string;
246
+ version: number;
247
+ terminalAt: string;
248
+ dueAt: string;
249
+ }) => Promise<void>;
241
250
  }
242
251
  /**
243
252
  * Wrap one mesh call. A failed emit is logged as `mesh_event_failed` with
@@ -53,7 +53,7 @@ import { laneCompanyUidSource, resolveLaneCompany } from "./lane-company.js";
53
53
  import { blockerFreshnessFingerprint, resolveBlockerFreshnessForLane, } from "./blocker-freshness.js";
54
54
  import { krFreshnessFingerprint, resolveKrFreshnessForLane, } from "./kr-freshness.js";
55
55
  import { managerStatusWasWritten, readStatusSnapshot, resolveManagerStatusTarget, } from "./manager-status-gate.js";
56
- import { queueLaneTerminalResume, queueManagerStatusGateResume } from "./keep-alive.js";
56
+ import { LEAD_LANE_KEEP_ALIVE_FIRST_RESUME_SETTLE_MS, LEAD_LANE_KEEP_ALIVE_FLAG, LEAD_LANE_KEEP_ALIVE_IMMEDIATE_FIRST_RESUME_FLAG, LEAD_LANE_KEEP_ALIVE_TERMINAL_TRIGGER_FLAG, queueLaneTerminalResume, queueManagerStatusGateResume, } from "./keep-alive.js";
57
57
  import { LANE_ENVELOPE_REPAIR_CONTINUE_FLAG } from "./flag-keys.js";
58
58
  import { monitorSessionDir } from "../monitor.js";
59
59
  import { laneRunDir, missingPidProbe, probePidRecord, readPidRecord, readProcStarttime, readSpawnManifest, envelopeRepairMode, spawnEnvelopeRepair, writePidRecord, retryLaneOnAlternateAccount, } from "./spawn.js";
@@ -1780,6 +1780,52 @@ async function runWatcherLoopOwned(hqRoot, laneId, deps) {
1780
1780
  });
1781
1781
  }
1782
1782
  }
1783
+ const terminalEnvelopeNextCheckMs = effectiveEnvelope?.next_check_at === undefined
1784
+ ? undefined
1785
+ : Date.parse(effectiveEnvelope.next_check_at);
1786
+ const hasFutureTerminalNextCheck = terminalEnvelopeNextCheckMs !== undefined &&
1787
+ Number.isFinite(terminalEnvelopeNextCheckMs) &&
1788
+ terminalEnvelopeNextCheckMs > Date.parse(tick.emit.at);
1789
+ if (terminalWrite.changed &&
1790
+ updated.keep_alive === true &&
1791
+ effectiveEnvelope?.decision === "done" &&
1792
+ effectiveEnvelope.story_complete === false &&
1793
+ !hasFutureTerminalNextCheck &&
1794
+ updated.state === "done" &&
1795
+ deps.scheduleTerminalKeepAlive) {
1796
+ try {
1797
+ const current = readLane(hqRoot, laneId);
1798
+ if (current.state === "done" && current.version === updated.version && current.keep_alive === true) {
1799
+ const resolution = resolveLaneCompany(hqRoot, current);
1800
+ const company = resolution.company;
1801
+ if (company) {
1802
+ const readFlag = deps.readTerminalKeepAliveFlag ?? readLanesRegistryFlag;
1803
+ const flagOptions = { company, companyUidSource: laneCompanyUidSource(resolution.source) };
1804
+ const [triggerEnabled, keepAliveEnabled, immediateFirstResumeEnabled] = await Promise.all([
1805
+ readFlag(LEAD_LANE_KEEP_ALIVE_TERMINAL_TRIGGER_FLAG, flagOptions),
1806
+ readFlag(LEAD_LANE_KEEP_ALIVE_FLAG, flagOptions),
1807
+ readFlag(LEAD_LANE_KEEP_ALIVE_IMMEDIATE_FIRST_RESUME_FLAG, flagOptions),
1808
+ ]);
1809
+ if (triggerEnabled && keepAliveEnabled && immediateFirstResumeEnabled) {
1810
+ const terminalAtMs = Date.parse(tick.emit.at);
1811
+ const dueAt = new Date(terminalAtMs + LEAD_LANE_KEEP_ALIVE_FIRST_RESUME_SETTLE_MS).toISOString();
1812
+ logDecision({ event: "keep_alive_terminal_trigger_scheduled", at: tick.emit.at, due_at: dueAt, version: current.version });
1813
+ await deps.scheduleTerminalKeepAlive({
1814
+ laneId,
1815
+ version: current.version,
1816
+ terminalAt: tick.emit.at,
1817
+ dueAt,
1818
+ });
1819
+ }
1820
+ }
1821
+ }
1822
+ }
1823
+ catch (err) {
1824
+ const message = err instanceof Error ? err.message : String(err);
1825
+ process.stderr.write(`hq lanes watcher: terminal keep-alive trigger failed for ${laneId}: ${message}\n`);
1826
+ logDecision({ event: "keep_alive_terminal_trigger_failed", at: tick.emit.at, error: message });
1827
+ }
1828
+ }
1783
1829
  }
1784
1830
  }
1785
1831
  lastSignalMs = tick.nextLastSignalMs;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@indigoai-us/hq-cli",
3
- "version": "5.311.4",
3
+ "version": "5.312.0",
4
4
  "description": "HQ by Indigo management CLI — modules and cloud sync",
5
5
  "main": "dist/index.js",
6
6
  "bin": {