@indigoai-us/hq-cli 5.345.237 → 5.345.241

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 (115) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/assets/scaffold/core/scripts/hq-delegate-repo.sh +7 -1
  3. package/assets/scaffold/core/scripts/hq-delegate-secrets.sh +95 -20
  4. package/assets/scaffold/core/scripts/hq-delegate-transfer.sh +57 -9
  5. package/dist/command-catalog.generated.d.ts +185 -3
  6. package/dist/command-catalog.generated.js +228 -3
  7. package/dist/command-registration-plan.d.ts +6 -0
  8. package/dist/command-registration-plan.js +1 -0
  9. package/dist/commands/bot.d.ts +2 -0
  10. package/dist/commands/bot.js +23 -0
  11. package/dist/commands/cloud-off-gate.d.ts +2 -1
  12. package/dist/commands/cloud-off-gate.js +17 -4
  13. package/dist/commands/cloud.d.ts +17 -2
  14. package/dist/commands/cloud.js +126 -24
  15. package/dist/commands/core-delegate-w1b.js +35 -10
  16. package/dist/commands/core-delegate.d.ts +2 -1
  17. package/dist/commands/core-delegate.js +207 -48
  18. package/dist/commands/deploy-comments.js +8 -2
  19. package/dist/commands/deploy-events.d.ts +40 -0
  20. package/dist/commands/deploy-events.js +300 -0
  21. package/dist/commands/doctor.d.ts +4 -4
  22. package/dist/commands/doctor.js +2 -2
  23. package/dist/commands/feedback.js +2 -3
  24. package/dist/commands/keyed-sync-pull.d.ts +12 -0
  25. package/dist/commands/keyed-sync-pull.js +151 -0
  26. package/dist/commands/library-add.d.ts +5 -2
  27. package/dist/commands/library-add.js +22 -9
  28. package/dist/commands/mcp-registration.d.ts +4 -18
  29. package/dist/commands/mcp-registration.js +9 -29
  30. package/dist/commands/mesh.d.ts +4 -0
  31. package/dist/commands/mesh.js +25 -5
  32. package/dist/commands/pack-install.d.ts +2 -3
  33. package/dist/commands/pack-install.js +6 -8
  34. package/dist/commands/secrets.d.ts +3 -4
  35. package/dist/commands/secrets.js +3 -20
  36. package/dist/hq-cloud-sync-runner/bin/sync-runner.js +307 -232
  37. package/dist/hq-cloud-sync-runner/package.json +1 -1
  38. package/dist/lib/agent-kit/inbox-state.d.ts +2 -1
  39. package/dist/lib/agent-kit/inbox-state.js +27 -3
  40. package/dist/lib/bot/api.d.ts +2 -1
  41. package/dist/lib/bot/api.js +2 -15
  42. package/dist/lib/bot/promote.d.ts +23 -0
  43. package/dist/lib/bot/promote.js +73 -0
  44. package/dist/lib/bot/promotion-hold-reconcile.d.ts +56 -0
  45. package/dist/lib/bot/promotion-hold-reconcile.js +155 -0
  46. package/dist/lib/capacity/collectors/claude-oauth.d.ts +0 -2
  47. package/dist/lib/capacity/collectors/claude-oauth.js +0 -5
  48. package/dist/lib/core-utils/delegate-helper-paths.d.ts +26 -0
  49. package/dist/lib/core-utils/delegate-helper-paths.js +33 -0
  50. package/dist/lib/daemon/jq-provision.d.ts +63 -0
  51. package/dist/lib/daemon/jq-provision.js +155 -0
  52. package/dist/lib/daemon/lanes-reconcile-guard.d.ts +4 -3
  53. package/dist/lib/daemon/lanes-reconcile-guard.js +4 -4
  54. package/dist/lib/daemon/mesh-owner.d.ts +4 -0
  55. package/dist/lib/daemon/mesh-owner.js +20 -0
  56. package/dist/lib/daemon/ops/policy.d.ts +3 -0
  57. package/dist/lib/daemon/ops/policy.js +32 -4
  58. package/dist/lib/daemon/run.d.ts +17 -1
  59. package/dist/lib/daemon/run.js +24 -3
  60. package/dist/lib/daemon/server.d.ts +6 -0
  61. package/dist/lib/daemon/server.js +5 -0
  62. package/dist/lib/daemon/verified-jq.d.ts +96 -0
  63. package/dist/lib/daemon/verified-jq.js +337 -0
  64. package/dist/lib/doctor/checks/jq.js +16 -0
  65. package/dist/lib/doctor/deep/executor.d.ts +7 -0
  66. package/dist/lib/doctor/deep/executor.js +1 -1
  67. package/dist/lib/doctor/deep/parity.js +1 -27
  68. package/dist/lib/doctor/deep/sandbox.d.ts +2 -2
  69. package/dist/lib/doctor/deep/sandbox.js +3 -19
  70. package/dist/lib/doctor/fix/refresh-sync-handoff.js +52 -21
  71. package/dist/lib/doctor/fixtures/discover.d.ts +2 -0
  72. package/dist/lib/doctor/fixtures/discover.js +1 -1
  73. package/dist/lib/doctor/json-output.d.ts +1 -1
  74. package/dist/lib/doctor/registry.d.ts +6 -7
  75. package/dist/lib/doctor/registry.js +6 -7
  76. package/dist/lib/doctor/report.d.ts +9 -10
  77. package/dist/lib/doctor/report.js +4 -4
  78. package/dist/lib/flag-registry-worker-source.generated.d.ts +1 -1
  79. package/dist/lib/flag-registry-worker-source.generated.js +1 -1
  80. package/dist/lib/jq/install.d.ts +27 -0
  81. package/dist/lib/jq/install.js +156 -0
  82. package/dist/lib/lanes/outpost-dispatch.d.ts +1 -1
  83. package/dist/lib/lanes/outpost-dispatch.js +13 -13
  84. package/dist/lib/lanes/outpost-pruner-install.js +1 -1
  85. package/dist/lib/mesh/live/daemon/doctor.js +7 -1
  86. package/dist/lib/mesh/live/daemon/install.d.ts +4 -0
  87. package/dist/lib/mesh/live/daemon/install.js +10 -0
  88. package/dist/lib/mesh/live/daemon/run.js +17 -0
  89. package/dist/lib/mesh/live/emit-retry.d.ts +20 -2
  90. package/dist/lib/mesh/live/emit-retry.js +57 -4
  91. package/dist/lib/mesh/live/emit.js +25 -4
  92. package/dist/lib/mesh/live/flush.d.ts +2 -0
  93. package/dist/lib/mesh/live/flush.js +21 -8
  94. package/dist/lib/mesh/live/spool.d.ts +9 -1
  95. package/dist/lib/mesh/live/spool.js +41 -29
  96. package/dist/lib/sync-core/rollout-state.d.ts +9 -1
  97. package/dist/lib/sync-core/rollout-state.js +34 -4
  98. package/dist/lib/windows/jq.d.ts +4 -0
  99. package/dist/lib/windows/jq.js +10 -39
  100. package/dist/lib/workers-registry/index.js +7 -11
  101. package/dist/utils/callback-port-busy.d.ts +2 -2
  102. package/dist/utils/callback-port-busy.js +2 -2
  103. package/dist/utils/cli-network-lifecycle.js +1 -0
  104. package/dist/utils/client-health-contract.d.ts +2 -0
  105. package/dist/utils/client-health-contract.js +1 -1
  106. package/dist/utils/client-health.js +1 -9
  107. package/dist/utils/cognito-config.js +5 -0
  108. package/dist/utils/cognito-session.d.ts +4 -6
  109. package/dist/utils/cognito-session.js +4 -24
  110. package/dist/utils/incomplete-install-error.js +1 -11
  111. package/dist/utils/install-tree-torn.d.ts +11 -0
  112. package/dist/utils/install-tree-torn.js +1 -1
  113. package/dist/utils/resident-package-preload.js +2 -1
  114. package/docs/anywhere-runtime.md +8 -0
  115. package/package.json +9 -9
@@ -1127,6 +1127,11 @@ export const COMMAND_CATALOG = [
1127
1127
  "helpText": [],
1128
1128
  "arguments": [],
1129
1129
  "options": [
1130
+ {
1131
+ "flags": "--company-slug <slug>",
1132
+ "description": "Trusted local layout slug; required with HQ_API_KEY and --company cmp_…",
1133
+ "hidden": false
1134
+ },
1130
1135
  {
1131
1136
  "flags": "--hq-root <path>",
1132
1137
  "description": "Local HQ tree root (default: <runtime-path>)",
@@ -10534,7 +10539,7 @@ export const COMMAND_CATALOG = [
10534
10539
  "options": [
10535
10540
  {
10536
10541
  "flags": "--size <size>",
10537
- "description": "Outpost size: small | medium | large | xlarge. Without it, a terminal shows a menu with prices and medium preselected; a script gets the default, $100/month",
10542
+ "description": "Outpost size: small | medium | large | xlarge. Without it, a terminal shows a menu with prices and small ($100/month) preselected; a script sends no size and is billed the small price",
10538
10543
  "hidden": false
10539
10544
  },
10540
10545
  {
@@ -10627,7 +10632,7 @@ export const COMMAND_CATALOG = [
10627
10632
  },
10628
10633
  {
10629
10634
  "flags": "--size <size>",
10630
- "description": "small, medium, large or xlarge (the server default is medium)",
10635
+ "description": "small, medium, large or xlarge (without it, the Outpost is billed the small price, $100/month)",
10631
10636
  "hidden": false
10632
10637
  },
10633
10638
  {
@@ -26384,7 +26389,7 @@ export const COMMAND_CATALOG = [
26384
26389
  "subcommands": [
26385
26390
  {
26386
26391
  "name": "list",
26387
- "description": "List comments on an app in your org",
26392
+ "description": "List comments on an app in your org, or on a personal app with --personal",
26388
26393
  "aliases": [],
26389
26394
  "hidden": false,
26390
26395
  "helpOption": true,
@@ -26405,6 +26410,11 @@ export const COMMAND_CATALOG = [
26405
26410
  "description": "use this company instead of the active company",
26406
26411
  "hidden": false
26407
26412
  },
26413
+ {
26414
+ "flags": "--personal",
26415
+ "description": "read a personal app (personal deploy scope) instead of a company app",
26416
+ "hidden": false
26417
+ },
26408
26418
  {
26409
26419
  "flags": "--json",
26410
26420
  "description": "print the API comment array as JSON",
@@ -26495,6 +26505,221 @@ export const COMMAND_CATALOG = [
26495
26505
  }
26496
26506
  ]
26497
26507
  },
26508
+ {
26509
+ "name": "events",
26510
+ "description": "Read and answer site events that visitors send from your deployed apps",
26511
+ "aliases": [],
26512
+ "hidden": false,
26513
+ "helpOption": true,
26514
+ "helpCommand": true,
26515
+ "usage": "[options] [command]",
26516
+ "helpText": [],
26517
+ "arguments": [],
26518
+ "options": [],
26519
+ "subcommands": [
26520
+ {
26521
+ "name": "enable",
26522
+ "description": "Turn site events on (or off with --off) for an app",
26523
+ "aliases": [],
26524
+ "hidden": false,
26525
+ "helpOption": true,
26526
+ "helpCommand": false,
26527
+ "usage": "[options] <app-id>",
26528
+ "helpText": [],
26529
+ "arguments": [
26530
+ {
26531
+ "name": "app-id",
26532
+ "required": true,
26533
+ "variadic": false,
26534
+ "description": ""
26535
+ }
26536
+ ],
26537
+ "options": [
26538
+ {
26539
+ "flags": "--company <slug>",
26540
+ "description": "company owning the app",
26541
+ "hidden": false
26542
+ },
26543
+ {
26544
+ "flags": "--personal",
26545
+ "description": "use personal scope",
26546
+ "hidden": false
26547
+ },
26548
+ {
26549
+ "flags": "--off",
26550
+ "description": "turn site events off; stored events are kept",
26551
+ "hidden": false
26552
+ },
26553
+ {
26554
+ "flags": "--json",
26555
+ "description": "print {ok, appId, eventsEnabled} as JSON",
26556
+ "hidden": false
26557
+ }
26558
+ ],
26559
+ "subcommands": []
26560
+ },
26561
+ {
26562
+ "name": "list",
26563
+ "description": "List site events on an app",
26564
+ "aliases": [],
26565
+ "hidden": false,
26566
+ "helpOption": true,
26567
+ "helpCommand": false,
26568
+ "usage": "[options] <app-id>",
26569
+ "helpText": [],
26570
+ "arguments": [
26571
+ {
26572
+ "name": "app-id",
26573
+ "required": true,
26574
+ "variadic": false,
26575
+ "description": ""
26576
+ }
26577
+ ],
26578
+ "options": [
26579
+ {
26580
+ "flags": "--company <slug>",
26581
+ "description": "company owning the app",
26582
+ "hidden": false
26583
+ },
26584
+ {
26585
+ "flags": "--personal",
26586
+ "description": "use personal scope",
26587
+ "hidden": false
26588
+ },
26589
+ {
26590
+ "flags": "--after <event-id>",
26591
+ "description": "only events after this event id",
26592
+ "hidden": false
26593
+ },
26594
+ {
26595
+ "flags": "--status <status>",
26596
+ "description": "new or handled",
26597
+ "hidden": false
26598
+ },
26599
+ {
26600
+ "flags": "--limit <n>",
26601
+ "description": "maximum number of events",
26602
+ "hidden": false
26603
+ },
26604
+ {
26605
+ "flags": "--json",
26606
+ "description": "print the API response ({events, nextAfter}) as JSON",
26607
+ "hidden": false
26608
+ }
26609
+ ],
26610
+ "subcommands": []
26611
+ },
26612
+ {
26613
+ "name": "reply",
26614
+ "description": "Reply to a site event and/or set its status",
26615
+ "aliases": [],
26616
+ "hidden": false,
26617
+ "helpOption": true,
26618
+ "helpCommand": false,
26619
+ "usage": "[options] <app-id> <event-id>",
26620
+ "helpText": [],
26621
+ "arguments": [
26622
+ {
26623
+ "name": "app-id",
26624
+ "required": true,
26625
+ "variadic": false,
26626
+ "description": ""
26627
+ },
26628
+ {
26629
+ "name": "event-id",
26630
+ "required": true,
26631
+ "variadic": false,
26632
+ "description": ""
26633
+ }
26634
+ ],
26635
+ "options": [
26636
+ {
26637
+ "flags": "--company <slug>",
26638
+ "description": "company owning the app",
26639
+ "hidden": false
26640
+ },
26641
+ {
26642
+ "flags": "--personal",
26643
+ "description": "use personal scope",
26644
+ "hidden": false
26645
+ },
26646
+ {
26647
+ "flags": "--text <reply>",
26648
+ "description": "reply text the page shows",
26649
+ "hidden": false
26650
+ },
26651
+ {
26652
+ "flags": "--status <status>",
26653
+ "description": "new or handled",
26654
+ "hidden": false
26655
+ },
26656
+ {
26657
+ "flags": "--json",
26658
+ "description": "print {ok, id, status, reply} as JSON",
26659
+ "hidden": false
26660
+ }
26661
+ ],
26662
+ "subcommands": []
26663
+ },
26664
+ {
26665
+ "name": "watch",
26666
+ "description": "Poll for new site events and print one JSON line per event",
26667
+ "aliases": [],
26668
+ "hidden": false,
26669
+ "helpOption": true,
26670
+ "helpCommand": false,
26671
+ "usage": "[options] <app-id>",
26672
+ "helpText": [],
26673
+ "arguments": [
26674
+ {
26675
+ "name": "app-id",
26676
+ "required": true,
26677
+ "variadic": false,
26678
+ "description": ""
26679
+ }
26680
+ ],
26681
+ "options": [
26682
+ {
26683
+ "flags": "--company <slug>",
26684
+ "description": "company owning the app",
26685
+ "hidden": false
26686
+ },
26687
+ {
26688
+ "flags": "--personal",
26689
+ "description": "use personal scope",
26690
+ "hidden": false
26691
+ },
26692
+ {
26693
+ "flags": "--cursor-file <path>",
26694
+ "description": "file that stores the last reported event id",
26695
+ "hidden": false
26696
+ },
26697
+ {
26698
+ "flags": "--label <name>",
26699
+ "description": "name used in the output lines (default: the app id)",
26700
+ "hidden": false
26701
+ },
26702
+ {
26703
+ "flags": "--interval <seconds>",
26704
+ "description": "seconds between polls, at least 30",
26705
+ "hidden": false,
26706
+ "defaultValue": "30"
26707
+ },
26708
+ {
26709
+ "flags": "--status <status>",
26710
+ "description": "new or handled (default: new)",
26711
+ "hidden": false
26712
+ },
26713
+ {
26714
+ "flags": "--once",
26715
+ "description": "poll once and exit",
26716
+ "hidden": false
26717
+ }
26718
+ ],
26719
+ "subcommands": []
26720
+ }
26721
+ ]
26722
+ },
26498
26723
  {
26499
26724
  "name": "list",
26500
26725
  "description": "List deploy apps in your company, optionally filtered by name or subdomain",
@@ -558,6 +558,12 @@ export declare const REGISTRATION_PLAN: readonly [{
558
558
  readonly parent: "deploy";
559
559
  readonly module: "./commands/deploy-comments.js";
560
560
  readonly exportName: "registerDeployCommentsCommand";
561
+ }, {
562
+ readonly type: "registrar";
563
+ readonly root: "deploy";
564
+ readonly parent: "deploy";
565
+ readonly module: "./commands/deploy-events.js";
566
+ readonly exportName: "registerDeployEventsCommand";
561
567
  }, {
562
568
  readonly type: "registrar";
563
569
  readonly root: "deploy";
@@ -95,6 +95,7 @@ export const REGISTRATION_PLAN = [
95
95
  { type: "registrar", root: "report", parent: "program", module: "./commands/report.js", exportName: "registerReportCommand" },
96
96
  { type: "group", root: "deploy", id: "deploy", name: "deploy", description: "Manage deployments in hq-deploy" },
97
97
  { type: "registrar", root: "deploy", parent: "deploy", module: "./commands/deploy-comments.js", exportName: "registerDeployCommentsCommand" },
98
+ { type: "registrar", root: "deploy", parent: "deploy", module: "./commands/deploy-events.js", exportName: "registerDeployEventsCommand" },
98
99
  { type: "registrar", root: "deploy", parent: "deploy", module: "./commands/deploy-list.js", exportName: "registerDeployListCommand" },
99
100
  { type: "registrar", root: "deploy", parent: "deploy", module: "./commands/deploy-mutations.js", exportName: "registerDeployMutationsCommand" },
100
101
  { type: "registrar", root: "deploy", parent: "deploy", module: "./commands/deploy-access.js", exportName: "registerDeployAccessCommand" },
@@ -662,6 +662,8 @@ export declare const botPromoteSeams: {
662
662
  running: boolean;
663
663
  how: string;
664
664
  }>;
665
+ /** `hq bot start` asks HQ every time; `hq bot run` shares the daemon's per-bot interval, so a restart loop does not hammer HQ. */
666
+ reconcileHold: (name: string, dir: string, config: BotConfig, command: "hq bot start" | "hq bot run") => Promise<import("../lib/bot/promote.js").PromotionHoldReconcile>;
665
667
  };
666
668
  export declare function registerBotCommand(program: Command): void;
667
669
  /**
@@ -18,6 +18,7 @@ import { OwnerContextCache, lookupOwnerContext } from "../lib/bot/owner-context.
18
18
  import { hasActivePromotion, localPromotionState } from "../lib/bot/promotion-receipt.js";
19
19
  import { botBusyState, readInflightTurns } from "../lib/bot/inflight.js";
20
20
  import { hasPromotionHold, promotionHoldSummary } from "../lib/bot/promotion-hold.js";
21
+ import { heldBotThrottleDir, reconcileHeldBot } from "../lib/bot/promotion-hold-reconcile.js";
21
22
  /**
22
23
  * `hq bot` — personal local bots (local-bots US-003/US-004/US-005).
23
24
  *
@@ -2254,6 +2255,7 @@ async function runBotResident(nameArg) {
2254
2255
  console.log(orphanBotRunMessage(name, outcome));
2255
2256
  return;
2256
2257
  }
2258
+ await releaseCancelledMove(name, dir, config, "text", "hq bot run");
2257
2259
  if ((await convertLegacyBotToFleet(name, dir, config, "run")).fleet)
2258
2260
  return;
2259
2261
  if (healNodePathFromJob(name, dir, config))
@@ -4230,7 +4232,27 @@ async function runBotListRemote(opts) {
4230
4232
  /** The bot's lifecycle seams for `hq bot promote`; tests replace them. */
4231
4233
  export const botPromoteSeams = {
4232
4234
  start: (name, dir, config) => startBot(name, dir, config, "silent"),
4235
+ /** `hq bot start` asks HQ every time; `hq bot run` shares the daemon's per-bot interval, so a restart loop does not hammer HQ. */
4236
+ reconcileHold: (name, dir, config, command) => reconcileHeldBot(name, dir, config, command === "hq bot run"
4237
+ ? { command, lockWaitMs: 0, throttle: { dir: heldBotThrottleDir(daemonPaths().root) } }
4238
+ : { command, lockWaitMs: 15_000, onWait: () => console.error(chalk.dim(`${name}: waiting for another hq command working on this bot...`)) }),
4233
4239
  };
4240
+ /** Before a start refuses a held bot: free it when HQ shows its move cancelled. */
4241
+ async function releaseCancelledMove(name, dir, config, output, command) {
4242
+ try {
4243
+ if (!hasPromotionHold(dir))
4244
+ return;
4245
+ }
4246
+ catch {
4247
+ return;
4248
+ }
4249
+ const result = await botPromoteSeams.reconcileHold(name, dir, config, command);
4250
+ if (result.outcome !== "released" || output !== "text")
4251
+ return;
4252
+ console.log(result.reason === "cancelled"
4253
+ ? `${name}: its move to the cloud was cancelled in HQ, so it is no longer held on this computer. Starting it.`
4254
+ : `${name}: HQ has no move to the cloud for it, so it is no longer held on this computer. Starting it.`);
4255
+ }
4234
4256
  /** `hq bot promote <name> --company <uid> --cancel`. */
4235
4257
  async function runBotPromoteCancel(name, dir, config, api, opts) {
4236
4258
  const result = await cancelLocalBotPromotion({
@@ -4422,6 +4444,7 @@ export function registerBotCommand(program) {
4422
4444
  .option("--json", "Print machine-readable JSON")
4423
4445
  .action((name, opts) => wrap(async () => {
4424
4446
  const b = requireBot(name);
4447
+ await releaseCancelledMove(b.name, b.dir, b.config, opts.json ? "json" : "text", "hq bot start");
4425
4448
  if (isFleetRuntimeBot(b.config)) {
4426
4449
  refuseHeldFleetBot(b.dir);
4427
4450
  const adopted = await adoptFleetRuntimeProfile(b.name, b.dir, b.config, { progress: fleetInstallProgressReporter(opts.json ? "silent" : "text") });
@@ -131,7 +131,8 @@ export declare function writeVaultRefusal(refusal: VaultRefusal, deps?: Pick<Clo
131
131
  * targets an off vault (or every vault is off); otherwise return what an
132
132
  * `--all` run must skip. Runs before any login, lock or network work, and
133
133
  * outside the client-health report, so a refusal is not counted as a failed
134
- * sync. Warns when the settings file is unreadable.
134
+ * sync. Warns about unreadable switch settings and exits 1 if the rollout
135
+ * state cannot establish which engine owns the vaults.
135
136
  */
136
137
  export declare function refuseSyncForOffVaults(command: GatedSyncCommand, selection: SyncSelection, deps?: CloudOffGateDeps): VaultSkips;
137
138
  /**
@@ -28,7 +28,7 @@ import * as fs from "node:fs";
28
28
  import * as os from "node:os";
29
29
  import * as path from "node:path";
30
30
  import { readCompaniesManifestMap } from "../lib/work-context/repo-remote.js";
31
- import { readSyncCoreRolloutState } from "../lib/sync-core/rollout-state.js";
31
+ import { readSyncCoreRolloutState, SyncCoreRolloutStateError } from "../lib/sync-core/rollout-state.js";
32
32
  import { readVaultSyncSwitches, unreadableSwitchesWarning, vaultSkipEnv, } from "../lib/vault-sync-switches.js";
33
33
  export { readVaultSyncSwitches, vaultSkipEnv };
34
34
  /**
@@ -51,7 +51,7 @@ export const NO_ENGINE_VAULTS = {
51
51
  uidSlugs: new Map(),
52
52
  };
53
53
  export function readEngineOwnedVaults(home = os.homedir()) {
54
- const state = readSyncCoreRolloutState(home);
54
+ const state = readSyncCoreRolloutState(home, { strict: true });
55
55
  if (!state)
56
56
  return NO_ENGINE_VAULTS;
57
57
  const held = new Set((state.held ?? []).map((h) => h.uid.toLowerCase()));
@@ -246,12 +246,25 @@ function warnIfUnreadable(switches, deps) {
246
246
  * targets an off vault (or every vault is off); otherwise return what an
247
247
  * `--all` run must skip. Runs before any login, lock or network work, and
248
248
  * outside the client-health report, so a refusal is not counted as a failed
249
- * sync. Warns when the settings file is unreadable.
249
+ * sync. Warns about unreadable switch settings and exits 1 if the rollout
250
+ * state cannot establish which engine owns the vaults.
250
251
  */
251
252
  export function refuseSyncForOffVaults(command, selection, deps = {}) {
252
253
  const switches = readVaultSyncSwitches(deps.home);
253
254
  warnIfUnreadable(switches, deps);
254
- const refusal = refusalFor(command, selection, switches, readEngineOwnedVaults(deps.home));
255
+ let engine;
256
+ try {
257
+ engine = readEngineOwnedVaults(deps.home);
258
+ }
259
+ catch (error) {
260
+ if (!(error instanceof SyncCoreRolloutStateError))
261
+ throw error;
262
+ const writeErr = deps.writeErr ?? ((text) => process.stderr.write(text));
263
+ const message = error.message;
264
+ writeErr(deps.json ? `${JSON.stringify({ type: "fatal", message })}\n` : `${message}\n`);
265
+ return (deps.exit ?? ((code) => process.exit(code)))(1);
266
+ }
267
+ const refusal = refusalFor(command, selection, switches, engine);
255
268
  if (refusal) {
256
269
  writeVaultRefusal(refusal, deps);
257
270
  (deps.exit ?? ((code) => process.exit(code)))(CLOUD_OFF_EXIT_CODE);
@@ -14,7 +14,7 @@
14
14
  * (also `hq daemon sync status --local`)
15
15
  */
16
16
  import { Command } from "commander";
17
- import { type ConflictStrategy, type EntityContext, type MembershipSyncConfig, type SyncMode, type PullScope, type ExplicitGrant, type ShareOptions, type VaultServiceConfig } from "@indigoai-us/hq-cloud";
17
+ import { VaultClient, scopeLookupSkipMessage, SyncScopeLookupError, type ConflictStrategy, type EntityContext, type MembershipSyncConfig, type SyncMode, type PullScope, type ExplicitGrant, type ShareOptions, type VaultServiceConfig } from "@indigoai-us/hq-cloud";
18
18
  import { withSyncWatchdog, type SyncWatchdogLimits } from "../utils/sync-watchdog.js";
19
19
  import { type BannerLevel } from "../lib/narrow-hint-banner.js";
20
20
  import { type PlanLimitRefusalSummary } from "../lib/billing/plan-limit-refusals.js";
@@ -576,6 +576,7 @@ export interface PullAllResult {
576
576
  }>;
577
577
  perCompany: PullAllRow[];
578
578
  }
579
+ export { scopeLookupSkipMessage, SyncScopeLookupError };
579
580
  export declare function pullAll(options: PullAllOptions, deps: PullAllDeps): Promise<PullAllResult>;
580
581
  /**
581
582
  * Drives `hq sync push --all`: same membership + canonical-person fanout as
@@ -661,6 +662,21 @@ export interface PerCompanyPullResolveResult {
661
662
  resolvedMode: MembershipSyncConfig["syncMode"] | undefined;
662
663
  }
663
664
  export declare function resolvePerCompanyPullPlan(client: PerCompanyPullResolveClient, targetCompany: string | undefined): Promise<PerCompanyPullResolveResult>;
665
+ /**
666
+ * Resolve the effective PULL scope (DEV-1768) for a single foreground pull
667
+ * (`hq sync pull` / `hq sync now`), so the membership's REAL syncMode +
668
+ * prefixSet are threaded into `sync()`. Without this the CLI ran `syncMode:
669
+ * "all"` and stamped an all-mode PullRecord that wedged the next menubar sync.
670
+ *
671
+ * Delegates to the shared `resolvePullScope` (same resolver the runner uses),
672
+ * which fails closed since hq-cloud 6.18.117. Returns `undefined` only when no
673
+ * company is named or active (then `sync()` resolves the active company itself
674
+ * and pulls `all`, as before). When the lookup fails it throws (audit item 4):
675
+ * an auth refusal is rethrown as-is so the sign-in message survives, and any
676
+ * other failure is a bounded {@link SyncScopeLookupError}. The command then
677
+ * stops for this company rather than syncing unscoped. Exported for tests.
678
+ */
679
+ export declare function resolveCliPullScope(client: VaultClient, companyRef: string | undefined, hqRoot: string, onResolvedCompanyUid?: (companyUid: string) => void): Promise<PullScope | undefined>;
664
680
  export declare function registerCloudCommands(program: Command): void;
665
681
  /**
666
682
  * `hq sync doctor --reconcile-conflicts [--yes]`.
@@ -825,5 +841,4 @@ export declare function describePushSkips(result: {
825
841
  text: string;
826
842
  warn: boolean;
827
843
  };
828
- export {};
829
844
  //# sourceMappingURL=cloud.d.ts.map