@indigoai-us/hq-cli 5.345.128 → 5.345.129

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 (43) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/commands/core-bucket-c-work-mesh-offer-native.js +8 -2
  3. package/dist/commands/daemon.js +2 -0
  4. package/dist/commands/lanes.js +26 -14
  5. package/dist/commands/mesh.js +32 -19
  6. package/dist/lib/bot/inbox-poll-backoff-flag.d.ts +3 -5
  7. package/dist/lib/bot/inbox-poll-backoff-flag.js +20 -12
  8. package/dist/lib/bot/inbox-wake.d.ts +18 -0
  9. package/dist/lib/bot/inbox-wake.js +125 -0
  10. package/dist/lib/bot/run.d.ts +8 -0
  11. package/dist/lib/bot/run.js +51 -7
  12. package/dist/lib/bot/runtime/messages-stream.js +31 -3
  13. package/dist/lib/daemon/catalog.d.ts +4 -0
  14. package/dist/lib/daemon/catalog.js +6 -3
  15. package/dist/lib/daemon/flag-monitor.d.ts +4 -1
  16. package/dist/lib/daemon/flag-monitor.js +12 -6
  17. package/dist/lib/daemon/flag.d.ts +2 -0
  18. package/dist/lib/daemon/flag.js +11 -5
  19. package/dist/lib/daemon/hq-child-bootstrap.mjs +47 -7
  20. package/dist/lib/daemon/kill-switch-flags.d.ts +5 -0
  21. package/dist/lib/daemon/kill-switch-flags.js +5 -0
  22. package/dist/lib/daemon/lanes-reconcile-loader.d.ts +7 -0
  23. package/dist/lib/daemon/lanes-reconcile-loader.js +24 -0
  24. package/dist/lib/daemon/lanes-reconcile-watcher.d.ts +17 -0
  25. package/dist/lib/daemon/lanes-reconcile-watcher.js +80 -0
  26. package/dist/lib/daemon/remote-control.d.ts +8 -5
  27. package/dist/lib/daemon/remote-control.js +8 -7
  28. package/dist/lib/daemon/run.d.ts +4 -1
  29. package/dist/lib/daemon/run.js +133 -20
  30. package/dist/lib/doctor/json-output.d.ts +15 -3
  31. package/dist/lib/doctor/json-output.js +13 -1
  32. package/dist/lib/lanes/daemon-reconcile.d.ts +3 -0
  33. package/dist/lib/lanes/daemon-reconcile.js +8 -0
  34. package/dist/lib/lanes/reconcile-result.d.ts +10 -0
  35. package/dist/lib/lanes/reconcile-result.js +11 -0
  36. package/dist/lib/mesh/live/daemon/work-subscribe.d.ts +1 -1
  37. package/dist/lib/mesh/live/daemon/work-subscribe.js +8 -1
  38. package/dist/lib/mesh/live/paths.d.ts +2 -0
  39. package/dist/lib/mesh/live/paths.js +2 -0
  40. package/dist/lib/mesh/story-status.d.ts +2 -2
  41. package/dist/lib/mesh/story-status.js +2 -1
  42. package/dist/utils/resident-package-preload.js +6 -0
  43. package/package.json +1 -1
@@ -24,7 +24,12 @@ import { CLAUDE_RUNNER_SCRIPT, CODEX_RUNNER_SCRIPT, enabledServices, planUnits }
24
24
  import { effectiveSyncOwner, readDaemonConfig } from "./config.js";
25
25
  import { assertPersonalServiceSessionCapability, readRemoteControlPoolsConfig, remoteControlPoolSecretsEnv, } from "./remote-control-pools.js";
26
26
  import { loadLanesConfig } from "../lanes/config.js";
27
+ import { daemonLanesReconcileHandler } from "../lanes/daemon-reconcile.js";
28
+ import { ensureDaemonLanesReconcileHandler } from "./lanes-reconcile-loader.js";
27
29
  import { SUPERVISOR_HANDOFF_FLAG, readDaemonFlag } from "./flag.js";
30
+ import { createBoundedDaemonFlagMonitor } from "./flag-monitor.js";
31
+ import { DAEMON_CHILD_BOOTSTRAP_HANDOFF_WATCH_FLAG, DAEMON_LANES_RECONCILE_FILE_WATCH_FLAG, DAEMON_SEARCH_INDEX_RUNNER_OWNS_INDEX_FLAG, DAEMON_SYNC_PROCESS_SCAN_ON_MISSING_FLAG, } from "./kill-switch-flags.js";
32
+ import { createLanesReconcileWatcher } from "./lanes-reconcile-watcher.js";
28
33
  import { findLegacyUnits, legacyMeshUnitsToRetire, legacyOwnerLookup } from "./legacy.js";
29
34
  import { readLegacySyncEnv } from "./legacy-sync-env.js";
30
35
  import { acquireDaemonLock, isProcessAlive, processCommandLine, releaseDaemonLock } from "./lock.js";
@@ -216,11 +221,14 @@ export function backgroundQosCommand(command, backgroundQos, platform = process.
216
221
  return command;
217
222
  return [DARWIN_TASKPOLICY, ["-b", command[0], ...command[1]]];
218
223
  }
219
- export function daemonHqChildCommand(nodeBinary, hqBinary, args, bootstrapPath, packagePrefix) {
224
+ export function daemonHqChildCommand(nodeBinary, hqBinary, args, bootstrapPath, packagePrefix, handoffWatchEnabled = true) {
220
225
  return bootstrapPath && packagePrefix
221
- ? [nodeBinary, [bootstrapPath, packagePrefix, CLI_VERSION, ...args]]
226
+ ? [nodeBinary, [bootstrapPath, packagePrefix, CLI_VERSION, ...(handoffWatchEnabled ? [] : ["--handoff-watch=off"]), ...args]]
222
227
  : [nodeBinary, [hqBinary, ...args]];
223
228
  }
229
+ export function daemonSyncUnitIsPresent(units) {
230
+ return units.some((unit) => unit.id === "sync");
231
+ }
224
232
  export function resolveSyncRunnerPath() {
225
233
  try {
226
234
  const require = createRequire(import.meta.url);
@@ -674,11 +682,104 @@ export async function runDaemon(opts) {
674
682
  };
675
683
  const daemonSyncRunnerPids = new Set();
676
684
  let supervisor = null;
685
+ const killSwitchMonitor = (flagKey) => createBoundedDaemonFlagMonitor({
686
+ fallback: true,
687
+ read: () => readDaemonFlag(flagKey, {
688
+ env,
689
+ fallback: true,
690
+ localOverrideMode: "ignore",
691
+ throwOnError: true,
692
+ }),
693
+ onReadError: (error) => log("warn", `could not read ${flagKey}; keeping its default-on behavior (${error instanceof Error ? error.name : "UnknownError"})`),
694
+ });
695
+ const childBootstrapHandoffWatchFlag = killSwitchMonitor(DAEMON_CHILD_BOOTSTRAP_HANDOFF_WATCH_FLAG);
696
+ const lanesReconcileFileWatchFlag = killSwitchMonitor(DAEMON_LANES_RECONCILE_FILE_WATCH_FLAG);
697
+ const searchIndexRunnerOwnsIndexFlag = killSwitchMonitor(DAEMON_SEARCH_INDEX_RUNNER_OWNS_INDEX_FLAG);
698
+ const syncProcessScanOnMissingFlag = killSwitchMonitor(DAEMON_SYNC_PROCESS_SCAN_ON_MISSING_FLAG);
699
+ let laneReconcileWatcher = null;
700
+ let laneReconcileWatcherRoot = null;
701
+ let laneReconcileWatchFailedRoot = null;
702
+ let laneReconcileHandlerLoadInFlight = false;
703
+ let laneReconcileHandlerLoadFailed = false;
704
+ const loadLaneReconcileHandler = (initialRoot) => {
705
+ if (daemonLanesReconcileHandler() || laneReconcileHandlerLoadInFlight || laneReconcileHandlerLoadFailed)
706
+ return;
707
+ laneReconcileHandlerLoadInFlight = true;
708
+ const resolveRoot = () => {
709
+ const configured = readDaemonConfig(paths.configPath).hqRoot ?? (env.HQ_ROOT?.trim() || undefined);
710
+ return configured && fs.existsSync(configured) ? configured : initialRoot;
711
+ };
712
+ void ensureDaemonLanesReconcileHandler({ hqRoot: resolveRoot, env }).then(() => {
713
+ supervisor?.reconcile();
714
+ }).catch((error) => {
715
+ laneReconcileHandlerLoadFailed = true;
716
+ log("error", `could not load the in-process lanes reconciler; retaining the scheduled unit (${error instanceof Error ? error.message : String(error)})`);
717
+ }).finally(() => {
718
+ laneReconcileHandlerLoadInFlight = false;
719
+ });
720
+ };
721
+ const closeRuntimeWatchers = () => {
722
+ laneReconcileWatcher?.close();
723
+ laneReconcileWatcher = null;
724
+ laneReconcileWatcherRoot = null;
725
+ childBootstrapHandoffWatchFlag.close();
726
+ lanesReconcileFileWatchFlag.close();
727
+ searchIndexRunnerOwnsIndexFlag.close();
728
+ syncProcessScanOnMissingFlag.close();
729
+ };
677
730
  const plan = () => {
678
731
  const config = readDaemonConfig(paths.configPath);
679
732
  const legacy = legacyUnits();
680
733
  const configured = config.hqRoot ?? (env.HQ_ROOT?.trim() || undefined);
681
734
  const hqRoot = configured && fs.existsSync(configured) ? configured : undefined;
735
+ if (laneReconcileWatcherRoot && laneReconcileWatcherRoot !== hqRoot) {
736
+ laneReconcileWatcher?.close();
737
+ laneReconcileWatcher = null;
738
+ laneReconcileWatcherRoot = null;
739
+ laneReconcileWatchFailedRoot = null;
740
+ }
741
+ const lanesReconcileEnabled = lanesReconcileFileWatchFlag.status().enabled;
742
+ if (!lanesReconcileEnabled) {
743
+ laneReconcileWatcher?.close();
744
+ laneReconcileWatcher = null;
745
+ laneReconcileWatcherRoot = null;
746
+ laneReconcileWatchFailedRoot = null;
747
+ }
748
+ else if (hqRoot) {
749
+ if (!daemonLanesReconcileHandler())
750
+ loadLaneReconcileHandler(hqRoot);
751
+ const laneReconcileHandler = daemonLanesReconcileHandler();
752
+ if (laneReconcileHandler && laneReconcileWatcherRoot !== hqRoot && laneReconcileWatchFailedRoot !== hqRoot) {
753
+ laneReconcileWatcher?.close();
754
+ laneReconcileWatcher = null;
755
+ laneReconcileWatcherRoot = null;
756
+ const laneStore = path.join(hqRoot, "workspace", "lanes");
757
+ const laneDirectories = [path.join(laneStore, "lanes"), path.join(laneStore, "questions")];
758
+ try {
759
+ for (const directory of laneDirectories)
760
+ fs.mkdirSync(directory, { recursive: true, mode: 0o700 });
761
+ laneReconcileWatcher = createLanesReconcileWatcher({
762
+ directories: laneDirectories,
763
+ reconcile: laneReconcileHandler,
764
+ intervalMs: 15_000,
765
+ onError: (error) => log("error", `in-process lanes reconcile failed: ${error instanceof Error ? error.message : String(error)}`),
766
+ onWatchError: (error) => {
767
+ laneReconcileWatcher = null;
768
+ laneReconcileWatcherRoot = null;
769
+ laneReconcileWatchFailedRoot = hqRoot;
770
+ log("error", `lane-store watch failed; restoring the scheduled reconcile unit (${error instanceof Error ? error.message : String(error)})`);
771
+ supervisor?.reconcile();
772
+ },
773
+ });
774
+ laneReconcileWatcherRoot = hqRoot;
775
+ laneReconcileWatchFailedRoot = null;
776
+ }
777
+ catch (error) {
778
+ laneReconcileWatchFailedRoot = hqRoot;
779
+ log("error", `could not watch the lane store; retaining the scheduled reconcile unit (${error instanceof Error ? error.message : String(error)})`);
780
+ }
781
+ }
782
+ }
682
783
  let remoteControlPools = { version: 1, pools: [] };
683
784
  let remoteControlPoolsError;
684
785
  try {
@@ -810,21 +911,30 @@ export async function runDaemon(opts) {
810
911
  !config.syncPaused &&
811
912
  hqRoot &&
812
913
  isSignedIn) {
813
- const processList = listSyncRunnerProcesses(platform);
814
- if (!processList.ok) {
815
- syncRunnerProcesses = null;
816
- log("warn", `${processList.error}; sync will wait before taking ownership`);
817
- }
818
- else {
819
- syncRunnerProcesses = processList.processes;
820
- try {
821
- syncRunnerOwnerPid = readWatchRunnerOwnerStatus(watchRunnerOwnerStatusPath(hqRoot, home, env))?.pid ?? null;
914
+ const syncUnitPresent = daemonSyncUnitIsPresent(supervisor?.state().units ?? []);
915
+ if (!syncProcessScanOnMissingFlag.status().enabled || !syncUnitPresent) {
916
+ const processList = listSyncRunnerProcesses(platform);
917
+ if (!processList.ok) {
918
+ syncRunnerProcesses = null;
919
+ log("warn", `${processList.error}; sync will wait before taking ownership`);
822
920
  }
823
- catch (error) {
824
- log("warn", `could not verify the sync watch-owner status: ${error instanceof Error ? error.message : String(error)}`);
921
+ else {
922
+ syncRunnerProcesses = processList.processes;
923
+ try {
924
+ syncRunnerOwnerPid = readWatchRunnerOwnerStatus(watchRunnerOwnerStatusPath(hqRoot, home, env))?.pid ?? null;
925
+ }
926
+ catch (error) {
927
+ log("warn", `could not verify the sync watch-owner status: ${error instanceof Error ? error.message : String(error)}`);
928
+ }
825
929
  }
826
930
  }
827
931
  }
932
+ const appManagesSync = desktopAppManagesSync({
933
+ machineType,
934
+ host: opts.host,
935
+ legacy,
936
+ appRunning: () => desktopAppRunning(platform),
937
+ });
828
938
  const plans = planUnits(services, {
829
939
  machineType,
830
940
  platform,
@@ -840,15 +950,15 @@ export async function runDaemon(opts) {
840
950
  kitConfigured: fs.existsSync(agentKitPaths(home, env).kitConfigPath),
841
951
  syncPaused: config.syncPaused === true,
842
952
  syncOwner,
843
- desktopAppManagesSync: desktopAppManagesSync({
844
- machineType,
845
- host: opts.host,
846
- legacy,
847
- appRunning: () => desktopAppRunning(platform),
848
- }),
953
+ desktopAppManagesSync: appManagesSync,
849
954
  syncRunnerProcesses,
850
955
  syncRunnerOwnerPid,
851
956
  daemonSyncRunnerPids,
957
+ lanesReconcileInProcess: Boolean(laneReconcileWatcher && laneReconcileWatcherRoot === hqRoot),
958
+ searchIndexOwnedBySyncRunner: searchIndexRunnerOwnsIndexFlag.status().enabled &&
959
+ hqCloud !== null && !hqCloudVersionOlder(hqCloud.version, "6.18.75") &&
960
+ syncOwner === "daemon" && services.includes("sync") && !config.syncPaused &&
961
+ !appManagesSync && Boolean(hqRoot && isSignedIn && runners.syncRunner),
852
962
  syncHeartbeatTimeoutMs: syncHeartbeatTimeoutMs(env),
853
963
  bots: listLocalBots(),
854
964
  legacyOwner: legacyOwnerLookup(legacy),
@@ -884,7 +994,7 @@ export async function runDaemon(opts) {
884
994
  if (!command || command.type === "internal")
885
995
  throw new Error(`${unit.id} has no process to start`);
886
996
  let [file, args] = command.type === "hq"
887
- ? daemonHqChildCommand(opts.nodeBinary, opts.hqBinary, command.args, stagedHqChildBootstrap?.bootstrapPath ?? null, cliPackagePrefix)
997
+ ? daemonHqChildCommand(opts.nodeBinary, opts.hqBinary, command.args, stagedHqChildBootstrap?.bootstrapPath ?? null, cliPackagePrefix, childBootstrapHandoffWatchFlag.status().enabled)
888
998
  : command.type === "node"
889
999
  ? [opts.nodeBinary, [command.script, ...command.args]]
890
1000
  : [command.file, command.args];
@@ -1112,6 +1222,7 @@ export async function runDaemon(opts) {
1112
1222
  stopping = true;
1113
1223
  log("info", `${why}; stopping services`);
1114
1224
  closeHqd();
1225
+ closeRuntimeWatchers();
1115
1226
  // Keep shutdown bounded, but let a stopping sync runner reach its persist deadline.
1116
1227
  const cap = createShutdownCap();
1117
1228
  extendSyncShutdownCap = cap.extendForSyncRunnerPersist;
@@ -1139,6 +1250,7 @@ export async function runDaemon(opts) {
1139
1250
  return;
1140
1251
  stopping = true;
1141
1252
  closeHqd();
1253
+ closeRuntimeWatchers();
1142
1254
  const released = supervisor.release();
1143
1255
  // What these readers have not read stays in the FIFO for the next daemon.
1144
1256
  for (const tail of protocolTails)
@@ -1207,6 +1319,7 @@ export async function runDaemon(opts) {
1207
1319
  catch (err) {
1208
1320
  log("error", `supervisor failed to start: ${err.message}`);
1209
1321
  closeHqd();
1322
+ closeRuntimeWatchers();
1210
1323
  releaseDaemonLock(paths.lockPath);
1211
1324
  resolve(1);
1212
1325
  }
@@ -106,9 +106,10 @@ export interface BuildDoctorJsonInput {
106
106
  clientHealthCheckStatusEnabledCheckIds?: ReadonlySet<string>;
107
107
  /**
108
108
  * JSON consumed by the SessionStart health hook (`--client-health-report`).
109
- * Ordinary hq-core upgrade WARNs and leftover `sync.journal.personal` WARNs
110
- * are omitted from every JSON document (`--json` and `--client-health-report`),
111
- * including `summary` tallies: `--fix` cannot apply a release, and the leftover
109
+ * Ordinary hq-core upgrade WARNs, leftover `sync.journal.personal` WARNs, and
110
+ * leftover `sync.manifest.personal` WARNs are omitted from every JSON document
111
+ * (`--json` and `--client-health-report`), including `summary` tallies: `--fix`
112
+ * cannot apply a release or upload personal manifests, and the leftover
112
113
  * personal shard is not a live sync target. Company journals this `--fix`
113
114
  * pass did not try to refresh are omitted the same way: the repair cap leaves
114
115
  * them for a later session, and older hooks that only call `hq doctor --json`
@@ -141,6 +142,17 @@ export declare function isLeftoverPersonalJournalWarn(result: {
141
142
  checkId: string;
142
143
  status: DoctorStatus;
143
144
  }): boolean;
145
+ /**
146
+ * True when doctor still WARNs on a stale personal sync manifest.
147
+ * `--fix` does not upload manifests (network, auth, vault write), so the row
148
+ * stays WARN after a repair pass. JSON omits the WARN so `--json` health hooks
149
+ * do not file it as a failed repair. FAIL stays visible, and human
150
+ * `hq doctor` still prints the WARN.
151
+ */
152
+ export declare function isLeftoverPersonalManifestWarn(result: {
153
+ checkId: string;
154
+ status: DoctorStatus;
155
+ }): boolean;
144
156
  /** Assemble the machine-readable document from a completed run. */
145
157
  export declare function buildDoctorJson(input: BuildDoctorJsonInput): DoctorJsonDocument;
146
158
  /** Serialise the document as pretty-printed JSON with a trailing newline. */
@@ -50,8 +50,20 @@ export function isOrdinaryCoreUpdateWarn(result) {
50
50
  export function isLeftoverPersonalJournalWarn(result) {
51
51
  return result.checkId === "sync.journal.personal" && result.status === "WARN";
52
52
  }
53
+ /**
54
+ * True when doctor still WARNs on a stale personal sync manifest.
55
+ * `--fix` does not upload manifests (network, auth, vault write), so the row
56
+ * stays WARN after a repair pass. JSON omits the WARN so `--json` health hooks
57
+ * do not file it as a failed repair. FAIL stays visible, and human
58
+ * `hq doctor` still prints the WARN.
59
+ */
60
+ export function isLeftoverPersonalManifestWarn(result) {
61
+ return result.checkId === "sync.manifest.personal" && result.status === "WARN";
62
+ }
53
63
  function omitFromDoctorJson(result) {
54
- return isOrdinaryCoreUpdateWarn(result) || isLeftoverPersonalJournalWarn(result);
64
+ return (isOrdinaryCoreUpdateWarn(result) ||
65
+ isLeftoverPersonalJournalWarn(result) ||
66
+ isLeftoverPersonalManifestWarn(result));
55
67
  }
56
68
  /** Tally the results that actually ship in the JSON document. */
57
69
  function summarizeJsonResults(results) {
@@ -0,0 +1,3 @@
1
+ export declare function registerDaemonLanesReconcileHandler(handler: () => Promise<void>): void;
2
+ export declare function daemonLanesReconcileHandler(): (() => Promise<void>) | null;
3
+ //# sourceMappingURL=daemon-reconcile.d.ts.map
@@ -0,0 +1,8 @@
1
+ let daemonReconcileHandler = null;
2
+ export function registerDaemonLanesReconcileHandler(handler) {
3
+ daemonReconcileHandler = handler;
4
+ }
5
+ export function daemonLanesReconcileHandler() {
6
+ return daemonReconcileHandler;
7
+ }
8
+ //# sourceMappingURL=daemon-reconcile.js.map
@@ -0,0 +1,10 @@
1
+ export interface ReconcilePassResult {
2
+ ok: boolean;
3
+ errors?: readonly {
4
+ code?: string;
5
+ message: string;
6
+ }[];
7
+ }
8
+ /** Preserve CLI exit semantics while letting the daemon report failures to its watcher. */
9
+ export declare function finishReconcilePass(summary: ReconcilePassResult, mode: "cli" | "daemon", exit?: (code: number) => void): void;
10
+ //# sourceMappingURL=reconcile-result.d.ts.map
@@ -0,0 +1,11 @@
1
+ /** Preserve CLI exit semantics while letting the daemon report failures to its watcher. */
2
+ export function finishReconcilePass(summary, mode, exit = (code) => process.exit(code)) {
3
+ if (summary.ok)
4
+ return;
5
+ if (mode === "daemon") {
6
+ const detail = summary.errors?.map((error) => `${error.code ?? "unknown"}: ${error.message}`).join("; ") ?? "unknown reconcile error";
7
+ throw new Error(`In-process lanes reconcile failed: ${detail}`);
8
+ }
9
+ exit(1);
10
+ }
11
+ //# sourceMappingURL=reconcile-result.js.map
@@ -14,7 +14,7 @@ export interface WorkCacheMqtt extends MeshMqttEventClient {
14
14
  export interface WorkCacheSubscriber {
15
15
  stop: () => Promise<void>;
16
16
  }
17
- export declare const AGENT_INBOX_PUSH_STATE_BASENAME = "agent-inbox-push.json";
17
+ export { AGENT_INBOX_PUSH_STATE_BASENAME } from "../paths.js";
18
18
  export declare function startWorkCacheSubscriber(opts: {
19
19
  meshRoot: string;
20
20
  fetchCredentials?: PersonalCredentialsFetcher;
@@ -8,7 +8,8 @@ import { createPersonalRealtimeFetcher, } from "./credentials.js";
8
8
  import { presignIotWssUrl } from "./presign.js";
9
9
  import { applyProjectViewPush, parseProjectViewPush } from "./live-cache.js";
10
10
  import { backoffDelayMs, RECONNECT_MIN_DELAY_MS } from "./presence.js";
11
- export const AGENT_INBOX_PUSH_STATE_BASENAME = "agent-inbox-push.json";
11
+ import { AGENT_INBOX_PUSH_STATE_BASENAME } from "../paths.js";
12
+ export { AGENT_INBOX_PUSH_STATE_BASENAME } from "../paths.js";
12
13
  const INBOX_PUSH_HEARTBEAT_MS = 5_000;
13
14
  function readInboxWakeSequence(meshRoot, onInfo) {
14
15
  const target = path.join(meshRoot, AGENT_INBOX_PUSH_STATE_BASENAME);
@@ -78,6 +79,7 @@ export async function startWorkCacheSubscriber(opts) {
78
79
  let heartbeatTimer = null;
79
80
  let generation = 0;
80
81
  let inboxSubscribed = false;
82
+ let inboxAgentUid;
81
83
  // Carry the sequence forward from the last state marker so a daemon restart
82
84
  // cannot reuse a value the watcher has already consumed.
83
85
  let wakeSequence = readInboxWakeSequence(opts.meshRoot, opts.onInfo);
@@ -92,6 +94,7 @@ export async function startWorkCacheSubscriber(opts) {
92
94
  connected,
93
95
  heartbeatAtMs: now().getTime(),
94
96
  wakeSequence,
97
+ ...(connected && inboxAgentUid ? { agentUid: inboxAgentUid } : {}),
95
98
  });
96
99
  }
97
100
  catch (error) {
@@ -115,6 +118,7 @@ export async function startWorkCacheSubscriber(opts) {
115
118
  if (stopped)
116
119
  return;
117
120
  inboxSubscribed = false;
121
+ inboxAgentUid = undefined;
118
122
  clearInboxHeartbeat();
119
123
  persistInboxState(false);
120
124
  const gen = ++generation;
@@ -133,6 +137,7 @@ export async function startWorkCacheSubscriber(opts) {
133
137
  bundle.topics.inbox === `hq/${bundle.actorUid}/inbox`
134
138
  ? bundle.topics.inbox
135
139
  : undefined;
140
+ inboxAgentUid = inboxTopic ? bundle.actorUid : undefined;
136
141
  if (!topic && !inboxTopic) {
137
142
  opts.onInfo?.("work cache subscribe skipped: credentials have no supported topic");
138
143
  return;
@@ -175,6 +180,7 @@ export async function startWorkCacheSubscriber(opts) {
175
180
  return;
176
181
  if (err) {
177
182
  inboxSubscribed = false;
183
+ inboxAgentUid = undefined;
178
184
  clearInboxHeartbeat();
179
185
  persistInboxState(false);
180
186
  opts.onInfo?.("agent inbox push subscribe failed");
@@ -212,6 +218,7 @@ export async function startWorkCacheSubscriber(opts) {
212
218
  if (stopped || gen !== generation)
213
219
  return;
214
220
  inboxSubscribed = false;
221
+ inboxAgentUid = undefined;
215
222
  clearInboxHeartbeat();
216
223
  persistInboxState(false);
217
224
  schedule();
@@ -2,6 +2,8 @@
2
2
  * Local Work Mesh Live paths under ~/.hq/work-mesh/.
3
3
  * Injectable root for tests (never touch the real HOME in unit tests).
4
4
  */
5
+ /** Content-free sequence file written by the mesh MQTT inbox subscriber. */
6
+ export declare const AGENT_INBOX_PUSH_STATE_BASENAME = "agent-inbox-push.json";
5
7
  export declare function workMeshRoot(home?: string, env?: NodeJS.ProcessEnv): string;
6
8
  export declare function workMeshSpoolPath(root?: string): string;
7
9
  export declare function workMeshHeldPath(root?: string): string;
@@ -5,6 +5,8 @@
5
5
  import * as os from "node:os";
6
6
  import * as path from "node:path";
7
7
  const WORK_MESH_DIRNAME = "work-mesh";
8
+ /** Content-free sequence file written by the mesh MQTT inbox subscriber. */
9
+ export const AGENT_INBOX_PUSH_STATE_BASENAME = "agent-inbox-push.json";
8
10
  export function workMeshRoot(home = os.homedir(), env = process.env) {
9
11
  const override = env.HQ_WORK_MESH_ROOT?.trim();
10
12
  if (override)
@@ -5,8 +5,8 @@ export type BoardStoryStatus = (typeof BOARD_STORY_STATUSES)[number];
5
5
  * need attention, while `dropped` is terminal; the Board has only one terminal
6
6
  * column (`done`).
7
7
  */
8
- export declare const LEDGER_STATES: readonly ["todo", "in_progress", "review", "waiting", "blocked", "done", "dropped"];
9
- export declare const ACCEPTED_LEDGER_STATES: readonly ["todo", "in_progress", "review", "waiting", "blocked", "done", "dropped", "in_review", "verification"];
8
+ export declare const LEDGER_STATES: readonly ["todo", "queued", "in_progress", "review", "waiting", "blocked", "done", "dropped"];
9
+ export declare const ACCEPTED_LEDGER_STATES: readonly ["todo", "queued", "in_progress", "review", "waiting", "blocked", "done", "dropped", "in_review", "verification"];
10
10
  export declare class UnknownProjectStoryStateError extends Error {
11
11
  readonly source: string;
12
12
  readonly storyId: string;
@@ -6,10 +6,11 @@ const boardStoryStatusSet = new Set(BOARD_STORY_STATUSES);
6
6
  * column (`done`).
7
7
  */
8
8
  export const LEDGER_STATES = [
9
- "todo", "in_progress", "review", "waiting", "blocked", "done", "dropped",
9
+ "todo", "queued", "in_progress", "review", "waiting", "blocked", "done", "dropped",
10
10
  ];
11
11
  const LEDGER_STATE_TO_BOARD_STATUS = {
12
12
  todo: "queued",
13
+ queued: "queued",
13
14
  in_progress: "in_progress",
14
15
  review: "review",
15
16
  // The four-column Board cannot represent waiting separately. Preserve the
@@ -53,12 +53,15 @@ export const RESIDENT_PACKAGE_MODULES = {
53
53
  "../lib/plan-limit-nag.js",
54
54
  "../utils/plan-gate-error.js",
55
55
  "../lib/daemon/mcp-oauth.js",
56
+ "../commands/lanes.js",
57
+ "commander",
56
58
  "@modelcontextprotocol/sdk/client/index.js",
57
59
  "@modelcontextprotocol/sdk/client/streamableHttp.js",
58
60
  "../utils/staged-npm-install.js",
59
61
  "open",
60
62
  "../lib/first-sync-next-step.js",
61
63
  "@indigoai-us/hq-cloud",
64
+ "../lib/lanes/reconcile.js",
62
65
  ],
63
66
  "daemon-logs-follow": [],
64
67
  "mesh-daemon": ["../sentry.js", "../lib/doctor/client-health-reason-codes-flag.js", "@indigoai-us/hq-flags-client", "../lib/plan-limit-nag.js", "../utils/plan-gate-error.js", "open", "../utils/cognito-session.js", "../lib/first-sync-next-step.js", "@indigoai-us/hq-cloud"],
@@ -220,12 +223,15 @@ const LOADERS = {
220
223
  () => import("../lib/plan-limit-nag.js"),
221
224
  () => import("../utils/plan-gate-error.js"),
222
225
  () => import("../lib/daemon/mcp-oauth.js"),
226
+ () => import("../commands/lanes.js"),
227
+ () => import("commander"),
223
228
  () => import("@modelcontextprotocol/sdk/client/index.js"),
224
229
  () => import("@modelcontextprotocol/sdk/client/streamableHttp.js"),
225
230
  () => import("../utils/staged-npm-install.js"),
226
231
  () => import("open"),
227
232
  () => import("../lib/first-sync-next-step.js"),
228
233
  () => import("@indigoai-us/hq-cloud"),
234
+ () => import("../lib/lanes/reconcile.js"),
229
235
  ],
230
236
  "daemon-logs-follow": [],
231
237
  "mesh-daemon": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@indigoai-us/hq-cli",
3
- "version": "5.345.128",
3
+ "version": "5.345.129",
4
4
  "description": "HQ by Indigo management CLI — modules and cloud sync",
5
5
  "main": "dist/index.js",
6
6
  "bin": {