@indigoai-us/hq-cli 5.345.223 → 5.345.226

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 (130) hide show
  1. package/CHANGELOG.md +98 -0
  2. package/assets/bot-workers/setup/context/quick-reference.md +2 -2
  3. package/assets/mesh-daemon/README.md +11 -12
  4. package/dist/command-catalog.generated.d.ts +156 -4
  5. package/dist/command-catalog.generated.js +191 -4
  6. package/dist/commands/cloud-provision.d.ts +4 -1
  7. package/dist/commands/cloud-provision.js +7 -3
  8. package/dist/commands/cloud-retire.js +1 -1
  9. package/dist/commands/core-delegate-w1b.js +3 -1
  10. package/dist/commands/core-delegate.d.ts +5 -0
  11. package/dist/commands/core-dm-bind-native.d.ts +5 -1
  12. package/dist/commands/core-dm-bind-native.js +4 -0
  13. package/dist/commands/core-job-notify-native.d.ts +5 -1
  14. package/dist/commands/core-job-notify-native.js +8 -2
  15. package/dist/commands/core-jobs-native.d.ts +27 -1
  16. package/dist/commands/core-jobs-native.js +49 -28
  17. package/dist/commands/core-pipeline-conductor-native.js +7 -7
  18. package/dist/commands/core-pipeline-driver-native.js +5 -5
  19. package/dist/commands/core-refresh-vault-access-native.d.ts +5 -0
  20. package/dist/commands/core-refresh-vault-access-native.js +3 -1
  21. package/dist/commands/core-work-mesh-bind-trusted-native.js +1 -1
  22. package/dist/commands/daemon.d.ts +2 -0
  23. package/dist/commands/daemon.js +68 -2
  24. package/dist/commands/deploy-domains.js +38 -2
  25. package/dist/commands/lanes-accounts.d.ts +14 -0
  26. package/dist/commands/lanes-accounts.js +119 -0
  27. package/dist/commands/lanes-hold.d.ts +2 -27
  28. package/dist/commands/lanes-hold.js +3 -75
  29. package/dist/commands/lanes-loop.js +1 -1
  30. package/dist/commands/lanes-move.js +10 -0
  31. package/dist/commands/lanes-session-start.js +2 -2
  32. package/dist/commands/lanes-shared.js +9 -0
  33. package/dist/commands/lanes.js +137 -12
  34. package/dist/commands/mesh.d.ts +12 -0
  35. package/dist/commands/mesh.js +13 -4
  36. package/dist/commands/monitor.js +1 -1
  37. package/dist/commands/packs.js +1 -1
  38. package/dist/commands/sync-held.d.ts +22 -0
  39. package/dist/commands/sync-held.js +167 -18
  40. package/dist/commands/whoami.d.ts +10 -17
  41. package/dist/commands/whoami.js +7 -79
  42. package/dist/data/command-states.json +13 -0
  43. package/dist/hq-cloud-sync-runner/bin/sync-runner.js +4845 -2524
  44. package/dist/hq-cloud-sync-runner/package.json +1 -1
  45. package/dist/index.js +1 -1
  46. package/dist/lib/capacity/accounts.d.ts +4 -0
  47. package/dist/lib/capacity/accounts.js +4 -0
  48. package/dist/lib/capacity/route.js +14 -0
  49. package/dist/lib/capacity/sign-in.d.ts +18 -0
  50. package/dist/lib/capacity/sign-in.js +34 -1
  51. package/dist/lib/daemon/catalog.d.ts +9 -5
  52. package/dist/lib/daemon/catalog.js +14 -8
  53. package/dist/lib/daemon/config.d.ts +5 -0
  54. package/dist/lib/daemon/config.js +6 -0
  55. package/dist/lib/daemon/hook-requests.d.ts +76 -0
  56. package/dist/lib/daemon/hook-requests.js +481 -0
  57. package/dist/lib/daemon/lanes-monitor-state.d.ts +55 -0
  58. package/dist/lib/daemon/lanes-monitor-state.js +129 -0
  59. package/dist/lib/daemon/lanes-reconcile-loader.d.ts +7 -0
  60. package/dist/lib/daemon/lanes-reconcile-loader.js +13 -0
  61. package/dist/lib/daemon/lanes-reconcile-status.d.ts +35 -0
  62. package/dist/lib/daemon/lanes-reconcile-status.js +86 -0
  63. package/dist/lib/daemon/merge-sections.d.ts +165 -0
  64. package/dist/lib/daemon/merge-sections.js +556 -0
  65. package/dist/lib/daemon/ops/policy.d.ts +2 -2
  66. package/dist/lib/daemon/ops/policy.js +44 -5
  67. package/dist/lib/daemon/protocol.d.ts +1 -1
  68. package/dist/lib/daemon/protocol.js +0 -6
  69. package/dist/lib/daemon/run.js +110 -5
  70. package/dist/lib/daemon/selfcheck.js +2 -2
  71. package/dist/lib/daemon/server.d.ts +2 -4
  72. package/dist/lib/daemon/server.js +11 -49
  73. package/dist/lib/daemon/state-file.d.ts +74 -4
  74. package/dist/lib/daemon/state-file.js +159 -19
  75. package/dist/lib/daemon/supervisor.d.ts +3 -1
  76. package/dist/lib/daemon/updater.d.ts +2 -6
  77. package/dist/lib/daemon/updater.js +4 -11
  78. package/dist/lib/daemon/whoami-cache.d.ts +96 -0
  79. package/dist/lib/daemon/whoami-cache.js +244 -0
  80. package/dist/lib/flag-registry-worker-source.generated.d.ts +1 -1
  81. package/dist/lib/flag-registry-worker-source.generated.js +1 -1
  82. package/dist/lib/hook-engine/coverage.d.ts +2 -0
  83. package/dist/lib/hook-engine/coverage.js +71 -0
  84. package/dist/lib/hook-engine/native-precompact-compatibility.json +449 -0
  85. package/dist/lib/hook-engine/reconcile.js +14 -8
  86. package/dist/lib/install/hook-target.d.ts +13 -3
  87. package/dist/lib/install/hook-target.js +14 -11
  88. package/dist/lib/lanes/account-company.d.ts +7 -1
  89. package/dist/lib/lanes/account-company.js +22 -4
  90. package/dist/lib/lanes/account-ownership.d.ts +65 -0
  91. package/dist/lib/lanes/account-ownership.js +134 -0
  92. package/dist/lib/lanes/accounts.js +9 -2
  93. package/dist/lib/lanes/claude-balance.js +9 -3
  94. package/dist/lib/lanes/config.js +17 -0
  95. package/dist/lib/lanes/envelope-repair-dispatch.js +1 -1
  96. package/dist/lib/lanes/host-capacity.d.ts +19 -0
  97. package/dist/lib/lanes/host-capacity.js +37 -0
  98. package/dist/lib/lanes/monitor.d.ts +2 -0
  99. package/dist/lib/lanes/monitor.js +2 -1
  100. package/dist/lib/lanes/reconcile.js +44 -3
  101. package/dist/lib/lanes/registry-flag.d.ts +6 -0
  102. package/dist/lib/lanes/registry-flag.js +3 -2
  103. package/dist/lib/lanes/repo-merge-hold.d.ts +39 -0
  104. package/dist/lib/lanes/repo-merge-hold.js +90 -0
  105. package/dist/lib/lanes/spawn.d.ts +0 -10
  106. package/dist/lib/lanes/spawn.js +51 -1
  107. package/dist/lib/lanes/types.d.ts +12 -0
  108. package/dist/lib/lanes/watcher-main.js +3 -3
  109. package/dist/lib/mesh/live/daemon/doctor.js +1 -1
  110. package/dist/lib/mesh/live/daemon/install.js +2 -2
  111. package/dist/lib/windows/install-followup.js +1 -1
  112. package/dist/utils/client-health-contract.d.ts +1 -0
  113. package/dist/utils/client-health-contract.js +5 -0
  114. package/dist/utils/client-health.d.ts +2 -0
  115. package/dist/utils/client-health.js +40 -0
  116. package/dist/utils/cognito-session.d.ts +2 -14
  117. package/dist/utils/cognito-session.js +2 -40
  118. package/dist/utils/daemon-cli-version.d.ts +13 -0
  119. package/dist/utils/daemon-cli-version.js +47 -0
  120. package/dist/utils/duplicate-command-usage.js +1 -1
  121. package/dist/utils/machine-token-cache.d.ts +21 -0
  122. package/dist/utils/machine-token-cache.js +49 -0
  123. package/dist/utils/resident-package-preload.js +4 -0
  124. package/dist/utils/whoami-identity.d.ts +54 -0
  125. package/dist/utils/whoami-identity.js +108 -0
  126. package/package.json +8 -8
  127. package/dist/lib/daemon/ops/memory.d.ts +0 -18
  128. package/dist/lib/daemon/ops/memory.js +0 -65
  129. package/dist/lib/daemon/ops/mesh.d.ts +0 -38
  130. package/dist/lib/daemon/ops/mesh.js +0 -70
@@ -1 +1 @@
1
- {"name":"hq-cli-daemon-sync-runner","type":"module","version":"6.18.109","bundleSha256":"f48413f1a1488c5970274fd1dfa973fa6ebd25ba05cc9b486ce9b040fd217a0b","formatVersion":1}
1
+ {"name":"hq-cli-daemon-sync-runner","type":"module","version":"6.18.110","bundleSha256":"f07bdb64deac33e3fd132bfae7452fb8fb207e0b465b0da77b0fcc323a280bf5","formatVersion":1}
package/dist/index.js CHANGED
@@ -216,7 +216,7 @@ export function installFollowupWouldDoWork(argv, env, platform) {
216
216
  const args = argv.slice(2).filter((arg) => arg !== "--verbose");
217
217
  if (args[0] === "mesh" && args[1] === "daemon")
218
218
  return false;
219
- if (args[0] === "daemon" && (args[1] === "run" || args[1] === "install"))
219
+ if (args[0] === "daemon" && (args[1] === "run" || args[1] === "install" || args[1] === "service"))
220
220
  return false;
221
221
  if (platform === "win32")
222
222
  return /[/\\]node_modules[/\\]/i.test(argv[1] ?? "");
@@ -14,6 +14,10 @@ export interface CapacityAccount {
14
14
  source: CapacityAccountSource;
15
15
  /** False for a capacity-only account: read for usage, never used by lanes. */
16
16
  lanes?: boolean;
17
+ /** PS-006: owning business (slug, personal or unknown). Absent on default-home rows. */
18
+ owning_company?: string;
19
+ /** PS-006: owner, another named person, or unknown. Absent on default-home rows. */
20
+ holder?: string;
17
21
  }
18
22
  /**
19
23
  * `disabled_reason` that marks a registry account as capacity-only. Signing in
@@ -9,6 +9,7 @@ import * as fs from "node:fs";
9
9
  import * as os from "node:os";
10
10
  import * as path from "node:path";
11
11
  import { effectiveAccountHome } from "../lanes/account-home.js";
12
+ import { accountOwnership } from "../lanes/account-ownership.js";
12
13
  import { lanesConfigPath, loadLanesConfig } from "../lanes/config.js";
13
14
  import { resolveLanesHqRoot } from "../lanes/hq-root.js";
14
15
  import { LANE_PROVIDERS } from "../lanes/types.js";
@@ -47,12 +48,15 @@ export function listCapacityAccounts(options = {}) {
47
48
  if (!account.enabled && !capacityOnly)
48
49
  continue;
49
50
  const effective = effectiveAccountHome(account, hostname);
51
+ const ownership = accountOwnership(account);
50
52
  accounts.push({
51
53
  provider,
52
54
  label,
53
55
  home: effective.home,
54
56
  source: effective.source === "host" ? "host" : "registry",
55
57
  lanes: account.enabled,
58
+ owning_company: ownership.owning_company,
59
+ holder: ownership.holder,
56
60
  });
57
61
  }
58
62
  }
@@ -14,6 +14,7 @@ import { codexSnapshotStale, hasCodexCreditRoom } from "./codex-availability.js"
14
14
  * { ok, at, request, pick, ranked, skipped, moves, next_reset, capacity,
15
15
  * lanes_error }
16
16
  */
17
+ import { accountHeldByOther } from "../lanes/account-ownership.js";
17
18
  import { canonicalizeHome } from "../lanes/config.js";
18
19
  import { LANE_PROVIDERS } from "../lanes/types.js";
19
20
  import { capacityLoginCommand } from "./ledger.js";
@@ -365,6 +366,19 @@ export function pickAccount(input) {
365
366
  });
366
367
  continue;
367
368
  }
369
+ // PS-006: another person's login is never a pick, so --account auto
370
+ // moves on to the next account instead of failing at lane create.
371
+ const heldConfig = input.lanesConfig.providers?.[providerId]?.accounts?.[laneMatch.id];
372
+ if (accountHeldByOther(heldConfig)) {
373
+ skipped.push({
374
+ ...base,
375
+ reason: "held by another person, not used for lanes",
376
+ fix: "This login is held by " + (heldConfig?.holder ?? "another person") +
377
+ ". Use one of your own logins. Change the holder to owner only if this is really your own login: hq lanes accounts set-owner " +
378
+ providerId + " " + laneMatch.id + " --holder owner",
379
+ });
380
+ continue;
381
+ }
368
382
  const authState = account.authState ?? "unknown";
369
383
  // authState "unknown" means the ledger has no usage reading for the
370
384
  // account, not that its sign-in failed. Do not send the user to log in
@@ -22,6 +22,10 @@ export interface RosterRow {
22
22
  usageOnly?: boolean;
23
23
  /** The default home with no HQ account registered on it. Only the vendor login fixes it. */
24
24
  unregisteredDefault?: boolean;
25
+ /** PS-006: owning business of the login (slug, personal or unknown). */
26
+ owningCompany?: string;
27
+ /** PS-006: owner, another named person, or unknown. */
28
+ holder?: string;
25
29
  }
26
30
  /** Sentence printed for an expired Claude credential. Other commands pass through. */
27
31
  export declare function formatRefreshLine(provider: string, command: string): string;
@@ -63,6 +67,20 @@ export declare function repairSelection(rows: readonly RosterRow[], provider?: s
63
67
  expired: RosterRow[];
64
68
  };
65
69
  export declare function loginJson(rows: readonly RosterRow[], nowMs: number, provider?: string): unknown;
70
+ /**
71
+ * PS-006: the same readings grouped by the business that owns each login,
72
+ * sorted by slug with `unknown` last, so usage can be reported per business.
73
+ */
74
+ export declare function groupByOwningCompany(rows: readonly RosterRow[], nowMs: number): Array<{
75
+ owningCompany: string;
76
+ accounts: Array<{
77
+ provider: string;
78
+ label: string;
79
+ holder: string;
80
+ state: SignInState;
81
+ lastReadingAge: string;
82
+ }>;
83
+ }>;
66
84
  export interface CapacityLoginRequest {
67
85
  provider?: string;
68
86
  account?: string;
@@ -133,10 +133,15 @@ export function rosterFrom(accounts, view, userHome) {
133
133
  defaultHome.set(account.provider, path.resolve(account.home));
134
134
  }
135
135
  const registeredDefault = new Set();
136
+ // The registry account folded into each provider's default row, for its labels.
137
+ const foldedAccount = new Map();
136
138
  for (const account of accounts) {
137
139
  const home = defaultHome.get(account.provider);
138
- if (account.label !== "default" && home && path.resolve(account.home) === home)
140
+ if (account.label !== "default" && home && path.resolve(account.home) === home) {
139
141
  registeredDefault.add(account.provider);
142
+ if (!foldedAccount.has(account.provider))
143
+ foldedAccount.set(account.provider, account);
144
+ }
140
145
  }
141
146
  const rows = [];
142
147
  for (const account of accounts) {
@@ -149,6 +154,7 @@ export function rosterFrom(accounts, view, userHome) {
149
154
  const presented = match
150
155
  ? presentAccount({ ...match, homes: [account.home], labels: [account.label] }, account.provider, userHome)
151
156
  : { state: "unknown", reason: null, command: null };
157
+ const owned = account.label === "default" ? foldedAccount.get(account.provider) : account;
152
158
  rows.push({
153
159
  provider: account.provider,
154
160
  label: account.label,
@@ -164,6 +170,8 @@ export function rosterFrom(accounts, view, userHome) {
164
170
  home: account.home,
165
171
  usageOnly: account.lanes === false,
166
172
  ...(unregisteredDefault ? { unregisteredDefault: true } : {}),
173
+ owningCompany: owned?.owning_company ?? "unknown",
174
+ holder: owned?.holder ?? "unknown",
167
175
  });
168
176
  }
169
177
  return rows;
@@ -261,10 +269,35 @@ export function loginJson(rows, nowMs, provider) {
261
269
  usageOnly: row.usageOnly === true,
262
270
  laneCommand: row.usageOnly ? laneEnableCommand(row.provider, row.label) : null,
263
271
  lastReadingAge: readingAge(row.observedAt, nowMs),
272
+ owningCompany: row.owningCompany ?? "unknown",
273
+ holder: row.holder ?? "unknown",
264
274
  })),
275
+ byOwningCompany: groupByOwningCompany(rows, nowMs),
265
276
  addAccountCommands: addAccountCommands(provider),
266
277
  };
267
278
  }
279
+ /**
280
+ * PS-006: the same readings grouped by the business that owns each login,
281
+ * sorted by slug with `unknown` last, so usage can be reported per business.
282
+ */
283
+ export function groupByOwningCompany(rows, nowMs) {
284
+ const groups = new Map();
285
+ for (const row of rows) {
286
+ const key = row.owningCompany ?? "unknown";
287
+ const list = groups.get(key) ?? [];
288
+ list.push({
289
+ provider: row.provider,
290
+ label: row.label,
291
+ holder: row.holder ?? "unknown",
292
+ state: row.state,
293
+ lastReadingAge: readingAge(row.observedAt, nowMs),
294
+ });
295
+ groups.set(key, list);
296
+ }
297
+ return [...groups.entries()]
298
+ .sort(([a], [b]) => (a === "unknown" ? 1 : 0) - (b === "unknown" ? 1 : 0) || a.localeCompare(b))
299
+ .map(([owningCompany, accounts]) => ({ owningCompany, accounts }));
300
+ }
268
301
  function readingAge(observedAt, nowMs) {
269
302
  if (!observedAt)
270
303
  return "—";
@@ -3,14 +3,14 @@
3
3
  * default list for each machine type, and the concrete unit each service
4
4
  * becomes on this host.
5
5
  *
6
- * Services run today's existing entrypoints (`hq mesh daemon run`,
6
+ * Services run today's existing entrypoints (`hq daemon service mesh`,
7
7
  * `hq bot run <name>`, `hq-sync-runner --watch`, ...) as child processes, so
8
8
  * moving a service under the daemon does not change what it does. Services
9
9
  * with no entrypoint yet stay in the catalog as `unavailable` so status shows
10
10
  * them instead of silently dropping them.
11
11
  */
12
12
  import type { MachineType } from "./machine-type.js";
13
- import type { SyncOwner } from "./config.js";
13
+ import type { SyncOwner, DaemonConfig } from "./config.js";
14
14
  import { type SyncCoreVaultPlan } from "../sync-core/engine-home.js";
15
15
  import type { RemoteControlPoolsConfig } from "./remote-control-pools.js";
16
16
  import { type SyncRunnerProcess } from "./sync-runner.js";
@@ -41,11 +41,13 @@ type UnitCommand = {
41
41
  args: string[];
42
42
  } | {
43
43
  type: "internal";
44
- task: "rotate-logs";
44
+ task: InternalTask;
45
45
  };
46
+ /** Work the daemon does in its own process on a schedule, without starting a child. */
47
+ export type InternalTask = "rotate-logs" | "lanes-reconcile";
46
48
  interface UnitBlock {
47
- /** `waiting` clears on its own once the requirement appears; `unavailable` needs a newer CLI. */
48
- state: "waiting" | "unavailable";
49
+ /** `waiting` clears when requirements appear; `unavailable` needs a newer CLI; `paused` needs an explicit resume. */
50
+ state: "waiting" | "unavailable" | "paused";
49
51
  reason: string;
50
52
  /** A failed availability probe must not stop an already running service. */
51
53
  keepRunning?: true;
@@ -154,6 +156,7 @@ export interface PlanContext {
154
156
  instantSyncEnabled?: boolean;
155
157
  /** Keep the local sync runner stopped until the operator resumes it. */
156
158
  syncPaused: boolean;
159
+ syncCorePause?: DaemonConfig['syncCorePause'];
157
160
  /**
158
161
  * The desktop app's Settings > Sync switches on this computer (US-016).
159
162
  * Off vaults are skipped by the runner; all off keeps the unit stopped.
@@ -229,6 +232,7 @@ export declare function hqCloudUnits(machineType: MachineType, enabled: readonly
229
232
  export declare const CODEX_RUNNER_SCRIPT = "/usr/local/bin/outpost-codex-runner.sh";
230
233
  /** The outpost's Claude runner script, read for the session name it uses. */
231
234
  export declare const CLAUDE_RUNNER_SCRIPT = "/usr/local/bin/outpost-runner.sh";
235
+ export declare const NOT_SIGNED_IN = "not signed in (run `hq login`)";
232
236
  export declare function daemonAloneRunsLegacySync(ctx: PlanContext): boolean;
233
237
  /** Turn enabled services into concrete units for this host. */
234
238
  export declare function planUnits(services: readonly ServiceName[], ctx: PlanContext): UnitPlan[];
@@ -3,7 +3,7 @@
3
3
  * default list for each machine type, and the concrete unit each service
4
4
  * becomes on this host.
5
5
  *
6
- * Services run today's existing entrypoints (`hq mesh daemon run`,
6
+ * Services run today's existing entrypoints (`hq daemon service mesh`,
7
7
  * `hq bot run <name>`, `hq-sync-runner --watch`, ...) as child processes, so
8
8
  * moving a service under the daemon does not change what it does. Services
9
9
  * with no entrypoint yet stay in the catalog as `unavailable` so status shows
@@ -143,7 +143,7 @@ export const CODEX_RUNNER_SCRIPT = "/usr/local/bin/outpost-codex-runner.sh";
143
143
  /** The outpost's Claude runner script, read for the session name it uses. */
144
144
  export const CLAUDE_RUNNER_SCRIPT = "/usr/local/bin/outpost-runner.sh";
145
145
  const NO_HQ_ROOT = "no HQ folder configured (run `hq daemon install --hq-root <path>`)";
146
- const NOT_SIGNED_IN = "not signed in (run `hq login`)";
146
+ export const NOT_SIGNED_IN = "not signed in (run `hq login`)";
147
147
  const KIT_NOT_SET_UP = "the agent kit is not set up on this machine (run `hq agent kit install`)";
148
148
  function syncOwnerBlock(ctx) {
149
149
  if (ctx.machineType === "desktop" && ctx.syncOwner === "desktop-app" && ctx.desktopAppManagesSync) {
@@ -320,7 +320,7 @@ function planService(service, ctx) {
320
320
  return [reconcile, ...engines, manifest, ...selfcheck];
321
321
  }
322
322
  case "mesh": {
323
- const args = ["mesh", "daemon", "run", ...(ctx.hqRoot ? ["--hq-root", ctx.hqRoot] : [])];
323
+ const args = ["daemon", "service", "mesh", ...(ctx.hqRoot ? ["--hq-root", ctx.hqRoot] : [])];
324
324
  return [
325
325
  base(service, {
326
326
  command: { type: "hq", args },
@@ -436,12 +436,15 @@ function planService(service, ctx) {
436
436
  base(service, {
437
437
  kind: "scheduled",
438
438
  // Polls every 15 s so local keep-alive resumes are admitted on time (#1396).
439
- // Each pass is a fresh `hq` node process (~1.8 s CPU, ~200 MB RSS), so
440
- // desktops reconcile in-process on lane-store changes with a bounded
441
- // timer for due keep-alive work, avoiding a fresh CLI process per poll.
439
+ // The daemon's lane-store watcher owns reconcile while it runs (the
440
+ // plan above returns no unit then). This timed unit covers the time
441
+ // before the watcher starts, a watch failure and the watch kill
442
+ // switch. It reconciles in the daemon's own process: it used to start
443
+ // a fresh `hq` node process every 15 s (~1.8 s CPU, ~200 MB RSS),
444
+ // and no longer starts any (hq-core-rust US-036).
442
445
  intervalSec: 15,
443
446
  initialDelaySec: 30,
444
- command: { type: "hq", args: ["runners", "reconcile"] },
447
+ command: { type: "internal", task: "lanes-reconcile" },
445
448
  env: ctx.hqRoot ? { HQ_ROOT: ctx.hqRoot } : {},
446
449
  ...(ctx.machineType === "desktop"
447
450
  ? { runGuard: { name: "lanes-reconcile", idleIntervalSec: 60 } }
@@ -557,8 +560,11 @@ export function planUnits(services, ctx) {
557
560
  const units = [];
558
561
  for (const service of services) {
559
562
  for (const unit of planService(service, ctx)) {
563
+ if (service === "sync-core" && ctx.syncCorePause) {
564
+ unit.blocked = { state: "paused", reason: `paused at ${ctx.syncCorePause.at} by ${ctx.syncCorePause.by}; run hq daemon resume sync-core` };
565
+ }
560
566
  const owner = unit.command ? ctx.legacyOwner(unit.id) : null;
561
- if (owner && unit.blocked?.state !== "unavailable") {
567
+ if (owner && unit.blocked?.state !== "unavailable" && unit.blocked?.state !== "paused") {
562
568
  unit.blocked = {
563
569
  state: "waiting",
564
570
  reason: `already run by ${owner}; \`hq daemon migrate\` will take it over`,
@@ -14,6 +14,11 @@ export interface DaemonConfig {
14
14
  hqCloudVersion?: string;
15
15
  /** Persisted machine-local sync pause. */
16
16
  syncPaused?: boolean;
17
+ /** Separate operator pause for the Rust sync engines only. */
18
+ syncCorePause?: {
19
+ at: string;
20
+ by: string;
21
+ };
17
22
  /** Desktop Instant Sync preference, applied when the sync unit is planned. */
18
23
  instantSyncEnabled?: boolean;
19
24
  /** Explicit desktop handoff; absent values preserve the legacy per-machine owner. */
@@ -47,6 +47,10 @@ export function readDaemonConfig(file) {
47
47
  };
48
48
  if (typeof obj.instantSyncEnabled === "boolean")
49
49
  config.instantSyncEnabled = obj.instantSyncEnabled;
50
+ const pause = obj.syncCorePause;
51
+ if (pause && typeof pause.at === 'string' && Number.isFinite(Date.parse(pause.at)) && typeof pause.by === 'string') {
52
+ config.syncCorePause = { at: pause.at, by: pause.by };
53
+ }
50
54
  if (isMachineType(obj.machineType))
51
55
  config.machineType = obj.machineType;
52
56
  if (obj.syncOwner === "daemon" || obj.syncOwner === "desktop-app")
@@ -69,6 +73,8 @@ export function writeDaemonConfig(file, config) {
69
73
  if (config.hqCloudVersion)
70
74
  ordered.hqCloudVersion = config.hqCloudVersion;
71
75
  ordered.syncPaused = config.syncPaused === true;
76
+ if (config.syncCorePause)
77
+ ordered.syncCorePause = config.syncCorePause;
72
78
  if (typeof config.instantSyncEnabled === "boolean")
73
79
  ordered.instantSyncEnabled = config.instantSyncEnabled;
74
80
  if (config.syncOwner)
@@ -0,0 +1,76 @@
1
+ /** What the daemon is asked to do. A closed list, the same as `Kind` in daemon_req.rs. */
2
+ export type HookOperation = {
3
+ kind: "reindex";
4
+ };
5
+ export interface HookRequest {
6
+ /** The note's file name without `.json`. */
7
+ stem: string;
8
+ id: string;
9
+ /** When the hook left the note (ms since the epoch). */
10
+ at: number;
11
+ /** The HQ root the note names. */
12
+ root: string;
13
+ session: string;
14
+ operation: HookOperation;
15
+ }
16
+ /** The longest note the Rust writer leaves (`NOTE_MAX_BYTES`). */
17
+ export declare const HOOK_REQUEST_MAX_BYTES = 4096;
18
+ /** A note older than this is deleted and never run. */
19
+ export declare const HOOK_REQUEST_MAX_AGE_MS: number;
20
+ /** Tries per note, and the waits before the second and third. */
21
+ export declare const HOOK_REQUEST_MAX_ATTEMPTS = 3;
22
+ export declare const HOOK_REQUEST_RETRY_DELAYS_MS: readonly number[];
23
+ /** The longest a request's program runs before it is killed. */
24
+ export declare const HOOK_REQUEST_KILL_MS = 60000;
25
+ /** Notes handled per pass; the drainer schedules another pass at once when reached. */
26
+ export declare const HOOK_REQUEST_PASS_LIMIT = 64;
27
+ /** The folder name for an HQ root: 32 hex characters of SHA-256 over its real path (`root_key` in daemon_req.rs). */
28
+ export declare function hookRequestRootKey(root: string): string;
29
+ /** The request folder of `root` under `home`. */
30
+ export declare function hookRequestDir(home: string, root: string): string;
31
+ /** Read one note. `stem` is its file name without `.json`. Undefined for anything the writer does not produce. */
32
+ export declare function parseHookRequest(text: string, stem: string): HookRequest | undefined;
33
+ /** The CLI arguments for a validated request. Nothing from the note is passed through as an argument except its checked root. */
34
+ export declare function hookRequestArguments(request: HookRequest): string[];
35
+ export interface HookRequestDrainOptions {
36
+ home: string;
37
+ /** The HQ root this daemon serves, read on every pass. */
38
+ root: () => string | undefined;
39
+ /** Must prove ownership of the canonical per-user daemon lease. */
40
+ ownsQueue: () => boolean;
41
+ /** Runs a validated request. No shell evaluation. */
42
+ execute: (request: HookRequest) => Promise<{
43
+ code: number;
44
+ }>;
45
+ log: (message: string) => void;
46
+ /** Clock (tests). */
47
+ now?: () => number;
48
+ /** Waits before the second and third try (tests). */
49
+ retryDelaysMs?: readonly number[];
50
+ /** The wait between fallback scans (tests). */
51
+ scanIntervalMs?: number;
52
+ }
53
+ /**
54
+ * One pass over the request folder of this daemon's HQ root. Returns the
55
+ * number of notes settled or tried. Notes of another HQ root are in another
56
+ * folder and are not touched.
57
+ */
58
+ export declare function drainHookRequests(options: HookRequestDrainOptions): Promise<number>;
59
+ /** Startup scan plus folder notifications, with a 5 s fallback scan when a
60
+ * watcher is unavailable or an event was missed. Close waits for the request
61
+ * in progress. */
62
+ export declare function startHookRequestDrainer(options: HookRequestDrainOptions): {
63
+ close(): Promise<void>;
64
+ };
65
+ /** Run a validated request through the daemon's own CLI entry point. */
66
+ export declare function executeHookRequest(request: HookRequest, options: {
67
+ nodeBinary: string;
68
+ hqBinary: string;
69
+ allowedRoot: string | undefined;
70
+ env?: NodeJS.ProcessEnv;
71
+ signal?: AbortSignal;
72
+ timeoutMs?: number;
73
+ }): Promise<{
74
+ code: number;
75
+ }>;
76
+ //# sourceMappingURL=hook-requests.d.ts.map