@indigoai-us/hq-cli 5.345.150 → 5.345.152

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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,53 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [5.345.152] — 2026-10-20
6
+ - The bundled sync engine now uses hq-cloud 6.18.91. When a company Outpost
7
+ fails to start and the server has already cleaned it up,
8
+ `hq outposts provision --company <slug>` (and `create --company --name`)
9
+ stops right away and says nothing was left running, you were not charged,
10
+ and it is safe to run the same command again. `hq outposts status --company`
11
+ shows the same line, and `--json` adds `code: "failed_cleaned_up"` and
12
+ `retrySafe: true`. Other blocked reasons keep their existing text.
13
+ - CI: the "changelog entry" check sets up Node before it runs, so it no longer
14
+ fails with "node: command not found" on the self-hosted ARM runners. No change
15
+ to the `hq` command itself.
16
+ - `hq files share --with out_…` and `hq files unshare --with out_…` now accept
17
+ a company Outpost id, with read or write. `hq files acl` shows the grantee as
18
+ `Outpost (out_…)`; `--json` output is unchanged.
19
+ - `hq secrets share --with out_…` now refuses write or admin for a company
20
+ Outpost with "Company Outposts can only be given read access to a secret."
21
+ before anything is sent. Leaving out `--permission` for an Outpost gives it
22
+ read. A server refusal for the same reason shows the same message.
23
+ - `hq rescue` (and so `/update-hq`) now re-trusts HQ's own Codex hooks after a
24
+ successful rescue. Before this, an update that changed a hook command left
25
+ Codex holding the old trusted hash, so Codex skipped that hook until you ran
26
+ `hq reindex`. Rescue trusts a hook only when its entry in the HQ root's
27
+ `.codex/hooks.json` or `.codex/config.toml` matches the copy shipped in the
28
+ installed core release, which it reads from GitHub at the synced commit.
29
+ It reads that copy only from `indigoai-us/hq-core` or
30
+ `indigoai-us/hq-core-staging`; if `core/core.yaml` names any other repo
31
+ (for example after `hq rescue --source <fork>`), rescue trusts nothing.
32
+ Hooks you added to those files by hand, or shipped entries you edited, are
33
+ never trusted. User and managed hooks are left alone, and hooks that are
34
+ already trusted are not rewritten. Rescue does not re-enable a shipped hook
35
+ you disabled; it only refreshes that hook's trust (`hq reindex` still
36
+ re-enables shipped hooks). Nothing happens when Codex is not installed, and
37
+ `--check` never touches hook trust. Rescue prints a warning that points at
38
+ `hq reindex` and keeps its exit status when the shipped files cannot be
39
+ read, when the release does not ship a file an HQ hook comes from, when a
40
+ shipped file does not parse, when the repo is not an HQ core repo, or when
41
+ the trust step fails.
42
+ - `hq secrets exec` run without a session id (no `HQ_SESSION_ID`, `CLAUDE_CODE_SESSION_ID`, `CLAUDE_SESSION_ID`, `CODEX_SESSION_ID`, `CODEX_THREAD_ID` or `GROK_SESSION_ID`), such as a launchd or cron job, no longer borrows the company lock of whichever interactive session last wrote the sessions `.current` pointer. Before this, a job could load the same-named secret from that session's company. Such a job must now pass `--company <slug>` or `--personal`. Otherwise it prints how to fix the call and exits 78 without reading the vault. An `HQ_API_KEY` (`hqk_`) caller is unaffected because its key is bound to one company. A caller with its own session id keeps the existing lock rules: `--company` can only pick a company inside that session's lock.
43
+ - Defines the Windows acceptance bar for the native hook engine and checks it before a release. Hook checks whose stories are not merged yet are reported as pending and do not block other releases. A failed check still blocks the release.
44
+ - A pass requires runner evidence for that commit. Counts written into corpus files, a source-text match, or a signed-off latency number with no report stay pending and do not block a release.
45
+
46
+ ## [5.345.151] — 2026-10-20
47
+ - `hq lanes link _deliver` no longer hands a conductor message to a subagent. Subagent hook events share the root session id, so a subagent tool call used to claim the message and the root session never saw it. Child payloads, including Grok child sessions (`subagent_type`) and Codex child threads, now get nothing and the message stays queued until the root session's next tool call or stop. SubagentStop no longer delivers. A parent session id alone does not mark a child, so resumed, forked, or launcher-spawned Grok roots still receive their messages.
48
+ - If you leave out `--company`, `hq meetings invite <url>` now uses your only active company. If you belong to several companies, it lists them and asks you to pick one. The command used to send the invite as Personal instead. Personal can never record, so you saw the HQ Workforce upgrade prompt even when your company already had meeting recording.
49
+ - `hq sync push`, `pull` and `now` honour the HQ app's Settings > Sync switches on this computer. A command aimed at a vault whose sync is off (the personal vault, one company vault, or every vault with "Turn off all cloud sync") prints `Sync is off for <vault>` with how to turn it back on, and exits 3 without signing in or touching the vault. The target is the `--company` value, else `activeCompany` or `companySlug` in `.hq/config.json`; a `cmp_*` uid is matched through `companies/manifest.yaml`, and an unmatched uid is refused while any company vault is off. `--creds-from-stdin` is checked once stdin is read. With `--json`, the refusal is a `{"type":"skipped","reason":"sync_off"}` line on stderr. `--all` skips the off vaults and syncs the rest. The `hq daemon` background sync skips off vaults the same way and stays stopped while all cloud sync is off; a switch change restarts it once the current sync pass finishes. A settings file that cannot be read prints a warning (and logs one in the daemon) instead of silently syncing everything. `/handoff` still finishes locally and logs a skipped push as skipped.
50
+ - If you already had the HQ app's personal-files switch off (`personalSyncEnabled: false`) or a company's sync off (`workspaceSyncEnabled.<slug>: false`), `hq sync` now refuses those vaults too. That includes the `/handoff` personal publish, the `/startwork` and `/resumework` prefetch, and `/delegate` for those vaults. Turn the vault back on in HQ Settings > Sync to sync it from the command line again.
51
+
5
52
  ## [5.345.150] — 2026-10-19
6
53
  - The bundled sync engine now uses hq-cloud 6.18.90, which brings two fixes.
7
54
  - Owners and admins can now destroy one of a company's Outposts with
@@ -2058,7 +2058,7 @@ export declare const COMMAND_CATALOG: readonly [{
2058
2058
  readonly hidden: false;
2059
2059
  }, {
2060
2060
  readonly flags: "--permission <level>";
2061
- readonly description: "Permission level: read | write | admin";
2061
+ readonly description: "Permission level: read | write | admin (required, except for a company Outpost, which can only be given read and defaults to it)";
2062
2062
  readonly hidden: false;
2063
2063
  }];
2064
2064
  readonly subcommands: readonly [];
@@ -2813,7 +2813,7 @@ export declare const COMMAND_CATALOG: readonly [{
2813
2813
  }];
2814
2814
  readonly options: readonly [{
2815
2815
  readonly flags: "--with <principal>";
2816
- readonly description: "Email address, group id, or '@all' to share with every active company member";
2816
+ readonly description: "Email address, group id, company Outpost id (out_...), or '@all' to share with every active company member";
2817
2817
  readonly hidden: false;
2818
2818
  }, {
2819
2819
  readonly flags: "--permission <level>";
@@ -2859,7 +2859,7 @@ export declare const COMMAND_CATALOG: readonly [{
2859
2859
  }];
2860
2860
  readonly options: readonly [{
2861
2861
  readonly flags: "--with <principal>";
2862
- readonly description: "Person uid, agent uid, email address, group id, or '@all' to remove the grant";
2862
+ readonly description: "Person uid, agent uid, company Outpost id (out_...), email address, group id, or '@all' to remove the grant";
2863
2863
  readonly hidden: false;
2864
2864
  }];
2865
2865
  readonly subcommands: readonly [];
@@ -2469,7 +2469,7 @@ export const COMMAND_CATALOG = [
2469
2469
  },
2470
2470
  {
2471
2471
  "flags": "--permission <level>",
2472
- "description": "Permission level: read | write | admin",
2472
+ "description": "Permission level: read | write | admin (required, except for a company Outpost, which can only be given read and defaults to it)",
2473
2473
  "hidden": false
2474
2474
  }
2475
2475
  ],
@@ -3380,7 +3380,7 @@ export const COMMAND_CATALOG = [
3380
3380
  "options": [
3381
3381
  {
3382
3382
  "flags": "--with <principal>",
3383
- "description": "Email address, group id, or '@all' to share with every active company member",
3383
+ "description": "Email address, group id, company Outpost id (out_...), or '@all' to share with every active company member",
3384
3384
  "hidden": false
3385
3385
  },
3386
3386
  {
@@ -3437,7 +3437,7 @@ export const COMMAND_CATALOG = [
3437
3437
  "options": [
3438
3438
  {
3439
3439
  "flags": "--with <principal>",
3440
- "description": "Person uid, agent uid, email address, group id, or '@all' to remove the grant",
3440
+ "description": "Person uid, agent uid, company Outpost id (out_...), email address, group id, or '@all' to remove the grant",
3441
3441
  "hidden": false
3442
3442
  }
3443
3443
  ],
@@ -0,0 +1,138 @@
1
+ /**
2
+ * Sync switch gate for the manual `hq sync push|pull|now` commands
3
+ * (usage-only-pricing US-016).
4
+ *
5
+ * The desktop app's Settings > Sync section has one switch per vault plus one
6
+ * "Turn off all cloud sync" switch (see `../lib/vault-sync-switches.ts`). The
7
+ * switches affect only this computer. The app gates its own sync paths, but
8
+ * skills and scripts call these CLI commands directly (`/handoff`, the
9
+ * `/startwork` and `/resumework` prefetch, `/delegate`, job remediation). This
10
+ * gate makes those calls honour the same switches: a command aimed at an off
11
+ * vault refuses, and an `--all` run skips the off vaults while the rest sync.
12
+ *
13
+ * How the target vault is found, before any login or network call:
14
+ * - `--personal`, or a `prs_*` uid, is the personal vault;
15
+ * - `--company <ref>`, else the active company in `<hq-root>/.hq/config.json`
16
+ * (`activeCompany ?? companySlug`, the same order hq-cloud's resolver uses);
17
+ * - a `cmp_*` uid is mapped to its slug through `companies/manifest.yaml`
18
+ * (`cloud_uid`). A uid that cannot be mapped while any company vault is off
19
+ * is refused (fail closed): the gate cannot prove it is not an off vault.
20
+ * - `--creds-from-stdin`: the target is the parsed EntityContext, checked
21
+ * after stdin is read (`refusalForEntity`) and still before any transfer.
22
+ *
23
+ * The daemon's own `syncPaused` is not read here: it pauses background sync
24
+ * only (`hq daemon sync pause`, the tray pause), and a manual push while
25
+ * background sync is paused is expected to run.
26
+ */
27
+ import { readVaultSyncSwitches, vaultSkipEnv, type VaultSyncSwitches } from "../lib/vault-sync-switches.js";
28
+ export { readVaultSyncSwitches, vaultSkipEnv, type VaultSyncSwitches };
29
+ /**
30
+ * Exit code for "skipped because sync is off". Distinct from 1 (sync failed)
31
+ * so a caller can tell the two apart; every non-zero exit still means "nothing
32
+ * was synced", which is what `/delegate` and job remediation need to see.
33
+ */
34
+ export declare const CLOUD_OFF_EXIT_CODE = 3;
35
+ export type GatedSyncCommand = "push" | "pull" | "now";
36
+ /** True when "Turn off all cloud sync" is on. Never throws. */
37
+ export declare function isCloudOff(home?: string): boolean;
38
+ /** True when `company` (a slug) is a company vault whose switch is off. */
39
+ export declare function isCompanyVaultOff(switches: VaultSyncSwitches, company: string): boolean;
40
+ /**
41
+ * The refusal text when every vault is off. The first line keeps the phrase
42
+ * "refused immediately": `handoff-sync-prefetch` (shell and native) reports
43
+ * `skipped` rather than `error:<code>` when the pull log contains it, so
44
+ * released HQ versions treat this exit as skipped with no script change.
45
+ */
46
+ export declare function cloudOffMessage(command: GatedSyncCommand): string;
47
+ /** The refusal text when the one vault a command targets is off. */
48
+ export declare function vaultOffMessage(command: GatedSyncCommand, vaultName: string): string;
49
+ /** The refusal text when a company uid cannot be mapped while some vault is off. */
50
+ export declare function unresolvedVaultMessage(command: GatedSyncCommand, ref: string): string;
51
+ /** Which vaults a `push|pull|now` invocation targets. */
52
+ export interface SyncSelection {
53
+ all?: boolean;
54
+ /** `true` for `--personal`; `false` is `--no-personal` (only meaningful with `--all`). */
55
+ personal?: boolean;
56
+ company?: string;
57
+ /** Used to find the active company and the uid-to-slug manifest. */
58
+ hqRoot?: string;
59
+ /** `--creds-from-stdin`: the target is checked after stdin is parsed. */
60
+ credsFromStdin?: boolean;
61
+ }
62
+ /** What an `--all` run must leave out. */
63
+ export interface VaultSkips {
64
+ skipPersonal: boolean;
65
+ skipCompanies: ReadonlySet<string>;
66
+ }
67
+ /** A refusal: the text, and the vault it names (for JSON output). */
68
+ export interface VaultRefusal {
69
+ message: string;
70
+ vault: string;
71
+ }
72
+ /** The vault a company reference or entity uid names. */
73
+ export type ResolvedVault = {
74
+ kind: "personal";
75
+ } | {
76
+ kind: "company";
77
+ slug: string;
78
+ } | {
79
+ kind: "unknown";
80
+ ref: string;
81
+ };
82
+ /**
83
+ * Active company from `<hqRoot>/.hq/config.json`, best effort. Uses
84
+ * `activeCompany ?? companySlug`, the order hq-cloud's `resolveActiveCompany`
85
+ * uses, so a config with only `companySlug` is still gated.
86
+ */
87
+ export declare function readActiveCompanyRef(hqRoot: string | undefined): string | undefined;
88
+ /** Map a slug, `cmp_*` uid or `prs_*` uid to the vault it names. */
89
+ export declare function resolveVaultRef(ref: string, hqRoot: string | undefined): ResolvedVault;
90
+ /**
91
+ * The refusal for `selection`, or null when it may run. `--all` never
92
+ * refuses for one vault: it skips the off vaults (see {@link vaultSkips}).
93
+ * With `--creds-from-stdin` and no `--company`, the target is unknown until
94
+ * stdin is parsed; {@link refusalForEntity} checks it then.
95
+ */
96
+ export declare function refusalFor(command: GatedSyncCommand, selection: SyncSelection, switches: VaultSyncSwitches): VaultRefusal | null;
97
+ /**
98
+ * The refusal for a pre-vended EntityContext read from stdin. A `prs_*` uid
99
+ * is the personal vault; otherwise the slug (or the uid, through the
100
+ * manifest) names the company.
101
+ */
102
+ export declare function refusalForEntity(command: GatedSyncCommand, entity: {
103
+ uid?: unknown;
104
+ slug?: unknown;
105
+ }, hqRoot: string | undefined, switches: VaultSyncSwitches): VaultRefusal | null;
106
+ /** The vaults an `--all` run leaves out. */
107
+ export declare function vaultSkips(selection: SyncSelection, switches: VaultSyncSwitches): VaultSkips;
108
+ /** Thrown after stdin is parsed when its target vault is off. */
109
+ export declare class VaultSyncOffError extends Error {
110
+ readonly refusal: VaultRefusal;
111
+ constructor(refusal: VaultRefusal);
112
+ }
113
+ export interface CloudOffGateDeps {
114
+ home?: string;
115
+ writeErr?: (text: string) => void;
116
+ exit?: (code: number) => never;
117
+ /** `--json`: stderr is a JSON Lines stream, so write events, not prose. */
118
+ json?: boolean;
119
+ }
120
+ /** Write a refusal: plain text, or one JSON Lines event in `--json` mode. */
121
+ export declare function writeVaultRefusal(refusal: VaultRefusal, deps?: Pick<CloudOffGateDeps, "writeErr" | "json">): void;
122
+ /**
123
+ * Print the refusal and exit {@link CLOUD_OFF_EXIT_CODE} when `selection`
124
+ * targets an off vault (or every vault is off); otherwise return what an
125
+ * `--all` run must skip. Runs before any login, lock or network work, and
126
+ * outside the client-health report, so a refusal is not counted as a failed
127
+ * sync. Warns when the settings file is unreadable.
128
+ */
129
+ export declare function refuseSyncForOffVaults(command: GatedSyncCommand, selection: SyncSelection, deps?: CloudOffGateDeps): VaultSkips;
130
+ /**
131
+ * `--creds-from-stdin` check: throw {@link VaultSyncOffError} when the parsed
132
+ * EntityContext targets an off vault. The caller writes it and exits 3.
133
+ */
134
+ export declare function assertEntityVaultSyncAllowed(command: GatedSyncCommand, entity: {
135
+ uid?: unknown;
136
+ slug?: unknown;
137
+ }, hqRoot: string | undefined, home?: string): void;
138
+ //# sourceMappingURL=cloud-off-gate.d.ts.map
@@ -0,0 +1,234 @@
1
+ /**
2
+ * Sync switch gate for the manual `hq sync push|pull|now` commands
3
+ * (usage-only-pricing US-016).
4
+ *
5
+ * The desktop app's Settings > Sync section has one switch per vault plus one
6
+ * "Turn off all cloud sync" switch (see `../lib/vault-sync-switches.ts`). The
7
+ * switches affect only this computer. The app gates its own sync paths, but
8
+ * skills and scripts call these CLI commands directly (`/handoff`, the
9
+ * `/startwork` and `/resumework` prefetch, `/delegate`, job remediation). This
10
+ * gate makes those calls honour the same switches: a command aimed at an off
11
+ * vault refuses, and an `--all` run skips the off vaults while the rest sync.
12
+ *
13
+ * How the target vault is found, before any login or network call:
14
+ * - `--personal`, or a `prs_*` uid, is the personal vault;
15
+ * - `--company <ref>`, else the active company in `<hq-root>/.hq/config.json`
16
+ * (`activeCompany ?? companySlug`, the same order hq-cloud's resolver uses);
17
+ * - a `cmp_*` uid is mapped to its slug through `companies/manifest.yaml`
18
+ * (`cloud_uid`). A uid that cannot be mapped while any company vault is off
19
+ * is refused (fail closed): the gate cannot prove it is not an off vault.
20
+ * - `--creds-from-stdin`: the target is the parsed EntityContext, checked
21
+ * after stdin is read (`refusalForEntity`) and still before any transfer.
22
+ *
23
+ * The daemon's own `syncPaused` is not read here: it pauses background sync
24
+ * only (`hq daemon sync pause`, the tray pause), and a manual push while
25
+ * background sync is paused is expected to run.
26
+ */
27
+ import * as fs from "node:fs";
28
+ import * as path from "node:path";
29
+ import { readCompaniesManifestMap } from "../lib/work-context/repo-remote.js";
30
+ import { readVaultSyncSwitches, unreadableSwitchesWarning, vaultSkipEnv, } from "../lib/vault-sync-switches.js";
31
+ export { readVaultSyncSwitches, vaultSkipEnv };
32
+ /**
33
+ * Exit code for "skipped because sync is off". Distinct from 1 (sync failed)
34
+ * so a caller can tell the two apart; every non-zero exit still means "nothing
35
+ * was synced", which is what `/delegate` and job remediation need to see.
36
+ */
37
+ export const CLOUD_OFF_EXIT_CODE = 3;
38
+ /** True when "Turn off all cloud sync" is on. Never throws. */
39
+ export function isCloudOff(home) {
40
+ return readVaultSyncSwitches(home).allOff;
41
+ }
42
+ /** True when `company` (a slug) is a company vault whose switch is off. */
43
+ export function isCompanyVaultOff(switches, company) {
44
+ return switches.offCompanies.has(company.trim().toLowerCase());
45
+ }
46
+ const HOW_TO_TURN_ON = "To turn it back on, open HQ and go to Settings > Sync.";
47
+ const NOTHING_MOVED = "Nothing was uploaded or downloaded. Your local files are unchanged.";
48
+ /**
49
+ * The refusal text when every vault is off. The first line keeps the phrase
50
+ * "refused immediately": `handoff-sync-prefetch` (shell and native) reports
51
+ * `skipped` rather than `error:<code>` when the pull log contains it, so
52
+ * released HQ versions treat this exit as skipped with no script change.
53
+ */
54
+ export function cloudOffMessage(command) {
55
+ return [
56
+ `Cloud sync is off for every vault on this computer, so \`hq sync ${command}\` was refused immediately.`,
57
+ NOTHING_MOVED,
58
+ HOW_TO_TURN_ON,
59
+ ].join("\n");
60
+ }
61
+ /** The refusal text when the one vault a command targets is off. */
62
+ export function vaultOffMessage(command, vaultName) {
63
+ return [
64
+ `Sync is off for ${vaultName} on this computer, so \`hq sync ${command}\` was refused immediately.`,
65
+ NOTHING_MOVED,
66
+ HOW_TO_TURN_ON,
67
+ ].join("\n");
68
+ }
69
+ /** The refusal text when a company uid cannot be mapped while some vault is off. */
70
+ export function unresolvedVaultMessage(command, ref) {
71
+ return [
72
+ `Sync is off for one or more company vaults on this computer, and \`hq sync ${command}\` could not tell which vault ${ref} is, so it was refused immediately.`,
73
+ NOTHING_MOVED,
74
+ `Run it with --company <slug>, or turn the vaults back on in HQ Settings > Sync.`,
75
+ ].join("\n");
76
+ }
77
+ const COMPANY_UID = /^cmp_/i;
78
+ const PERSON_UID = /^prs_/i;
79
+ /**
80
+ * Active company from `<hqRoot>/.hq/config.json`, best effort. Uses
81
+ * `activeCompany ?? companySlug`, the order hq-cloud's `resolveActiveCompany`
82
+ * uses, so a config with only `companySlug` is still gated.
83
+ */
84
+ export function readActiveCompanyRef(hqRoot) {
85
+ if (!hqRoot)
86
+ return undefined;
87
+ try {
88
+ const cfg = JSON.parse(fs.readFileSync(path.join(hqRoot, ".hq", "config.json"), "utf8"));
89
+ for (const value of [cfg?.activeCompany, cfg?.companySlug]) {
90
+ if (typeof value === "string" && value.trim())
91
+ return value.trim();
92
+ }
93
+ return undefined;
94
+ }
95
+ catch {
96
+ return undefined;
97
+ }
98
+ }
99
+ /** Map a slug, `cmp_*` uid or `prs_*` uid to the vault it names. */
100
+ export function resolveVaultRef(ref, hqRoot) {
101
+ const trimmed = ref.trim();
102
+ if (PERSON_UID.test(trimmed))
103
+ return { kind: "personal" };
104
+ if (!COMPANY_UID.test(trimmed))
105
+ return { kind: "company", slug: trimmed };
106
+ const manifest = hqRoot ? readCompaniesManifestMap(hqRoot) : null;
107
+ for (const [slug, entry] of Object.entries(manifest ?? {})) {
108
+ const uid = entry?.cloud_uid;
109
+ if (typeof uid === "string" && uid.toLowerCase() === trimmed.toLowerCase()) {
110
+ return { kind: "company", slug };
111
+ }
112
+ }
113
+ return { kind: "unknown", ref: trimmed };
114
+ }
115
+ function refusalForVault(command, vault, switches) {
116
+ switch (vault.kind) {
117
+ case "personal":
118
+ return switches.personalOff
119
+ ? { message: vaultOffMessage(command, "your personal vault"), vault: "personal" }
120
+ : null;
121
+ case "company":
122
+ return isCompanyVaultOff(switches, vault.slug)
123
+ ? { message: vaultOffMessage(command, vault.slug), vault: vault.slug }
124
+ : null;
125
+ case "unknown":
126
+ // Fail closed: with any company vault off, an unmapped uid may be it.
127
+ return switches.offCompanies.size > 0
128
+ ? { message: unresolvedVaultMessage(command, vault.ref), vault: vault.ref }
129
+ : null;
130
+ }
131
+ }
132
+ /**
133
+ * The refusal for `selection`, or null when it may run. `--all` never
134
+ * refuses for one vault: it skips the off vaults (see {@link vaultSkips}).
135
+ * With `--creds-from-stdin` and no `--company`, the target is unknown until
136
+ * stdin is parsed; {@link refusalForEntity} checks it then.
137
+ */
138
+ export function refusalFor(command, selection, switches) {
139
+ if (switches.allOff)
140
+ return { message: cloudOffMessage(command), vault: "all" };
141
+ if (selection.all)
142
+ return null;
143
+ if (selection.personal === true) {
144
+ return refusalForVault(command, { kind: "personal" }, switches);
145
+ }
146
+ const ref = selection.company ?? (selection.credsFromStdin ? undefined : readActiveCompanyRef(selection.hqRoot));
147
+ if (!ref)
148
+ return null;
149
+ return refusalForVault(command, resolveVaultRef(ref, selection.hqRoot), switches);
150
+ }
151
+ /**
152
+ * The refusal for a pre-vended EntityContext read from stdin. A `prs_*` uid
153
+ * is the personal vault; otherwise the slug (or the uid, through the
154
+ * manifest) names the company.
155
+ */
156
+ export function refusalForEntity(command, entity, hqRoot, switches) {
157
+ if (switches.allOff)
158
+ return { message: cloudOffMessage(command), vault: "all" };
159
+ const uid = typeof entity.uid === "string" ? entity.uid : "";
160
+ const slug = typeof entity.slug === "string" ? entity.slug : "";
161
+ if (PERSON_UID.test(uid))
162
+ return refusalForVault(command, { kind: "personal" }, switches);
163
+ if (slug.trim())
164
+ return refusalForVault(command, { kind: "company", slug }, switches);
165
+ if (uid.trim())
166
+ return refusalForVault(command, resolveVaultRef(uid, hqRoot), switches);
167
+ return null;
168
+ }
169
+ /** The vaults an `--all` run leaves out. */
170
+ export function vaultSkips(selection, switches) {
171
+ return {
172
+ skipPersonal: selection.personal === false || switches.personalOff,
173
+ skipCompanies: switches.offCompanies,
174
+ };
175
+ }
176
+ /** Thrown after stdin is parsed when its target vault is off. */
177
+ export class VaultSyncOffError extends Error {
178
+ refusal;
179
+ constructor(refusal) {
180
+ super(refusal.message);
181
+ this.refusal = refusal;
182
+ this.name = "VaultSyncOffError";
183
+ }
184
+ }
185
+ /** Write a refusal: plain text, or one JSON Lines event in `--json` mode. */
186
+ export function writeVaultRefusal(refusal, deps = {}) {
187
+ const writeErr = deps.writeErr ?? ((text) => process.stderr.write(text));
188
+ if (deps.json) {
189
+ writeErr(`${JSON.stringify({
190
+ type: "skipped",
191
+ reason: "sync_off",
192
+ vault: refusal.vault,
193
+ exitCode: CLOUD_OFF_EXIT_CODE,
194
+ message: refusal.message,
195
+ })}\n`);
196
+ }
197
+ else {
198
+ writeErr(`${refusal.message}\n`);
199
+ }
200
+ }
201
+ function warnIfUnreadable(switches, deps) {
202
+ if (!switches.unreadable)
203
+ return;
204
+ const writeErr = deps.writeErr ?? ((text) => process.stderr.write(text));
205
+ const message = unreadableSwitchesWarning(switches.unreadable);
206
+ writeErr(deps.json ? `${JSON.stringify({ type: "warning", message })}\n` : `${message}\n`);
207
+ }
208
+ /**
209
+ * Print the refusal and exit {@link CLOUD_OFF_EXIT_CODE} when `selection`
210
+ * targets an off vault (or every vault is off); otherwise return what an
211
+ * `--all` run must skip. Runs before any login, lock or network work, and
212
+ * outside the client-health report, so a refusal is not counted as a failed
213
+ * sync. Warns when the settings file is unreadable.
214
+ */
215
+ export function refuseSyncForOffVaults(command, selection, deps = {}) {
216
+ const switches = readVaultSyncSwitches(deps.home);
217
+ warnIfUnreadable(switches, deps);
218
+ const refusal = refusalFor(command, selection, switches);
219
+ if (refusal) {
220
+ writeVaultRefusal(refusal, deps);
221
+ (deps.exit ?? ((code) => process.exit(code)))(CLOUD_OFF_EXIT_CODE);
222
+ }
223
+ return vaultSkips(selection, switches);
224
+ }
225
+ /**
226
+ * `--creds-from-stdin` check: throw {@link VaultSyncOffError} when the parsed
227
+ * EntityContext targets an off vault. The caller writes it and exits 3.
228
+ */
229
+ export function assertEntityVaultSyncAllowed(command, entity, hqRoot, home) {
230
+ const refusal = refusalForEntity(command, entity, hqRoot, readVaultSyncSwitches(home));
231
+ if (refusal)
232
+ throw new VaultSyncOffError(refusal);
233
+ }
234
+ //# sourceMappingURL=cloud-off-gate.js.map
@@ -196,6 +196,11 @@ export interface PullAllOptions {
196
196
  * personal vault from the run without touching the rest of the plan.
197
197
  */
198
198
  skipPersonal?: boolean;
199
+ /**
200
+ * Lowercased company slugs (or uids) to leave out: vaults whose sync is off
201
+ * on this computer (desktop Settings > Sync, US-016).
202
+ */
203
+ skipCompanies?: ReadonlySet<string>;
199
204
  /**
200
205
  * Forward `--force-scope-shrink` to each company leg: when a scope shrink
201
206
  * would un-track locally-modified files, proceed anyway (dirty files KEPT on
@@ -263,6 +268,8 @@ export interface PushAllOptions {
263
268
  * `hq sync push --all --no-personal`.
264
269
  */
265
270
  skipPersonal?: boolean;
271
+ /** Lowercased company slugs (or uids) to leave out (US-016). */
272
+ skipCompanies?: ReadonlySet<string>;
266
273
  }
267
274
  export interface PushAllRow {
268
275
  slug: string;