@indigoai-us/hq-cli 5.345.212 → 5.345.215-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (161) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/dist/bin/hq-auth-refresh.js +2 -1
  3. package/dist/command-catalog.generated.d.ts +442 -50
  4. package/dist/command-catalog.generated.js +541 -50
  5. package/dist/commands/agent-inbox.d.ts +11 -1
  6. package/dist/commands/agent-inbox.js +128 -38
  7. package/dist/commands/agent-kit.js +2 -2
  8. package/dist/commands/agents.d.ts +51 -1
  9. package/dist/commands/agents.js +154 -2
  10. package/dist/commands/bot-jobs.d.ts +2 -15
  11. package/dist/commands/bot-jobs.js +2 -94
  12. package/dist/commands/bot-runtime.d.ts +46 -5
  13. package/dist/commands/bot-runtime.js +228 -18
  14. package/dist/commands/bot.d.ts +16 -9
  15. package/dist/commands/bot.js +169 -51
  16. package/dist/commands/cloud.d.ts +66 -13
  17. package/dist/commands/cloud.js +120 -39
  18. package/dist/commands/company-restore.d.ts +23 -0
  19. package/dist/commands/company-restore.js +128 -0
  20. package/dist/commands/company.js +2 -0
  21. package/dist/commands/core-handoff.js +1 -0
  22. package/dist/commands/core-hq-session-native.js +2 -2
  23. package/dist/commands/core-pin-native.js +1 -1
  24. package/dist/commands/core-policy.js +1 -1
  25. package/dist/commands/core-resolve-company-native.js +1 -1
  26. package/dist/commands/core-sentry-report-fast.d.ts +2 -0
  27. package/dist/commands/core-sentry-report-fast.js +3 -1
  28. package/dist/commands/daemon.js +11 -1
  29. package/dist/commands/integrations-connect.d.ts +17 -4
  30. package/dist/commands/integrations-connect.js +224 -26
  31. package/dist/commands/lanes-link.js +10 -5
  32. package/dist/commands/lanes.js +26 -9
  33. package/dist/commands/rescue.js +13 -0
  34. package/dist/commands/secrets.d.ts +11 -0
  35. package/dist/commands/secrets.js +41 -7
  36. package/dist/commands/sources.js +6 -0
  37. package/dist/commands/storage-offload.d.ts +12 -0
  38. package/dist/commands/storage-offload.js +41 -3
  39. package/dist/commands/sync-mode.js +5 -0
  40. package/dist/commands/whoami.js +4 -0
  41. package/dist/index.js +2 -0
  42. package/dist/lazy-commands.js +2 -0
  43. package/dist/lib/agent-kit/inbox-fetch.d.ts +122 -1
  44. package/dist/lib/agent-kit/inbox-fetch.js +215 -3
  45. package/dist/lib/agent-kit/inbox-redact.js +1 -1
  46. package/dist/lib/agent-kit/inbox-state.d.ts +98 -1
  47. package/dist/lib/agent-kit/inbox-state.js +261 -4
  48. package/dist/lib/agent-kit/mcp/tools.d.ts +3 -3
  49. package/dist/lib/agent-kit/mcp/tools.js +68 -25
  50. package/dist/lib/agent-kit/run/inbox.js +4 -2
  51. package/dist/lib/agent-kit/skills.js +4 -1
  52. package/dist/lib/agent-kit/wake.d.ts +9 -1
  53. package/dist/lib/agent-kit/wake.js +10 -3
  54. package/dist/lib/bot/config.d.ts +1 -0
  55. package/dist/lib/bot/config.js +10 -0
  56. package/dist/lib/bot/eventbridge-cron.d.ts +22 -0
  57. package/dist/lib/bot/eventbridge-cron.js +104 -0
  58. package/dist/lib/bot/fleet-cron.js +193 -14
  59. package/dist/lib/bot/fleet-download.d.ts +2 -0
  60. package/dist/lib/bot/fleet-download.js +23 -0
  61. package/dist/lib/bot/fleet-local.d.ts +34 -1
  62. package/dist/lib/bot/fleet-local.js +254 -37
  63. package/dist/lib/bot/fleet-python.d.ts +3 -0
  64. package/dist/lib/bot/fleet-python.js +34 -4
  65. package/dist/lib/bot/fleet-runtime-sources.d.ts +15 -0
  66. package/dist/lib/bot/fleet-runtime-sources.js +30 -0
  67. package/dist/lib/bot/legacy-provider-login.d.ts +8 -0
  68. package/dist/lib/bot/legacy-provider-login.js +19 -2
  69. package/dist/lib/bot/prompt.js +1 -1
  70. package/dist/lib/bot/readiness.d.ts +8 -0
  71. package/dist/lib/bot/readiness.js +17 -3
  72. package/dist/lib/bot/runtime-auth.d.ts +30 -0
  73. package/dist/lib/bot/runtime-auth.js +94 -3
  74. package/dist/lib/bot/status.d.ts +2 -0
  75. package/dist/lib/capacity/collectors/grok-refresh.d.ts +80 -0
  76. package/dist/lib/capacity/collectors/grok-refresh.js +189 -0
  77. package/dist/lib/capacity/collectors/grok.d.ts +5 -0
  78. package/dist/lib/capacity/collectors/grok.js +56 -5
  79. package/dist/lib/core-utils/session-id.d.ts +1 -1
  80. package/dist/lib/core-utils/session-id.js +4 -0
  81. package/dist/lib/daemon/catalog.js +11 -1
  82. package/dist/lib/daemon/run.js +9 -1
  83. package/dist/lib/daemon/updater.d.ts +34 -2
  84. package/dist/lib/daemon/updater.js +51 -2
  85. package/dist/lib/db/sqlite-binding.d.ts +1 -0
  86. package/dist/lib/db/sqlite-binding.js +1 -1
  87. package/dist/lib/delivery/artifacts.d.ts +99 -0
  88. package/dist/lib/delivery/artifacts.js +548 -0
  89. package/dist/lib/delivery/backup.d.ts +78 -0
  90. package/dist/lib/delivery/backup.js +343 -0
  91. package/dist/lib/delivery/cache.d.ts +29 -0
  92. package/dist/lib/delivery/cache.js +33 -0
  93. package/dist/lib/delivery/contracts.d.ts +142 -0
  94. package/dist/lib/delivery/contracts.js +289 -0
  95. package/dist/lib/delivery/credentials.d.ts +54 -0
  96. package/dist/lib/delivery/credentials.js +119 -0
  97. package/dist/lib/delivery/enrollment.d.ts +142 -0
  98. package/dist/lib/delivery/enrollment.js +382 -0
  99. package/dist/lib/delivery/identity.d.ts +25 -0
  100. package/dist/lib/delivery/identity.js +82 -0
  101. package/dist/lib/delivery/inbox.d.ts +116 -0
  102. package/dist/lib/delivery/inbox.js +260 -0
  103. package/dist/lib/delivery/migrations.d.ts +139 -0
  104. package/dist/lib/delivery/migrations.js +623 -0
  105. package/dist/lib/delivery/mqtt-adapter.d.ts +50 -0
  106. package/dist/lib/delivery/mqtt-adapter.js +242 -0
  107. package/dist/lib/delivery/mqtt.d.ts +61 -0
  108. package/dist/lib/delivery/mqtt.js +112 -0
  109. package/dist/lib/delivery/outbox.d.ts +95 -0
  110. package/dist/lib/delivery/outbox.js +187 -0
  111. package/dist/lib/delivery/provenance.d.ts +129 -0
  112. package/dist/lib/delivery/provenance.js +93 -0
  113. package/dist/lib/delivery/reconciler.d.ts +151 -0
  114. package/dist/lib/delivery/reconciler.js +492 -0
  115. package/dist/lib/delivery/restore.d.ts +35 -0
  116. package/dist/lib/delivery/restore.js +134 -0
  117. package/dist/lib/delivery/store.d.ts +161 -0
  118. package/dist/lib/delivery/store.js +940 -0
  119. package/dist/lib/delivery/workers/macos-job-helper.d.ts +103 -0
  120. package/dist/lib/delivery/workers/macos-job-helper.js +927 -0
  121. package/dist/lib/delivery/workers/macos.d.ts +176 -0
  122. package/dist/lib/delivery/workers/macos.js +901 -0
  123. package/dist/lib/delivery/workers/windows-boundary.d.ts +453 -0
  124. package/dist/lib/delivery/workers/windows-boundary.js +693 -0
  125. package/dist/lib/delivery/workers/windows-job-helper.d.ts +35 -0
  126. package/dist/lib/delivery/workers/windows-job-helper.js +264 -0
  127. package/dist/lib/delivery/workers/windows.d.ts +241 -0
  128. package/dist/lib/delivery/workers/windows.js +608 -0
  129. package/dist/lib/doctor/checks/release-links.d.ts +50 -8
  130. package/dist/lib/doctor/checks/release-links.js +260 -24
  131. package/dist/lib/doctor/fix/apply.js +24 -8
  132. package/dist/lib/doctor/fix/remediation.js +15 -5
  133. package/dist/lib/install/provider-wrappers.d.ts +2 -0
  134. package/dist/lib/install/provider-wrappers.js +68 -3
  135. package/dist/lib/lanes/autopilot-registry.d.ts +14 -0
  136. package/dist/lib/lanes/autopilot-registry.js +59 -7
  137. package/dist/lib/lanes/links.d.ts +14 -0
  138. package/dist/lib/lanes/links.js +320 -25
  139. package/dist/lib/lanes/outpost-pruner-install.d.ts +10 -0
  140. package/dist/lib/lanes/outpost-pruner-install.js +4 -3
  141. package/dist/main.js +3 -1
  142. package/dist/sentry-init.d.ts +2 -0
  143. package/dist/sentry-init.js +13 -2
  144. package/dist/sentry.d.ts +2 -0
  145. package/dist/sentry.js +5 -1
  146. package/dist/utils/cli-network-lifecycle.d.ts +9 -0
  147. package/dist/utils/cli-network-lifecycle.js +52 -0
  148. package/dist/utils/cognito-callback-port.d.ts +14 -0
  149. package/dist/utils/cognito-callback-port.js +24 -0
  150. package/dist/utils/cognito-session.js +3 -3
  151. package/dist/utils/deleted-company-notice.d.ts +59 -0
  152. package/dist/utils/deleted-company-notice.js +156 -0
  153. package/dist/utils/login-browser.d.ts +1 -1
  154. package/dist/utils/login-browser.js +7 -5
  155. package/dist/utils/resident-package-preload.js +30 -15
  156. package/dist/utils/safe-link.d.ts +63 -0
  157. package/dist/utils/safe-link.js +246 -0
  158. package/dist/utils/sentry-keepalive-transport.d.ts +28 -0
  159. package/dist/utils/sentry-keepalive-transport.js +70 -0
  160. package/dist/utils/vault-api.js +7 -0
  161. package/package.json +7 -7
@@ -14,4 +14,18 @@ export declare function resetStrayPortWarningForTests(): void;
14
14
  export declare function resolveCognitoCallbackPort(raw: string | number | undefined, warn?: PortWarn): number;
15
15
  /** Return `config` with its callback port forced into the registered set. */
16
16
  export declare function withRegisteredCallbackPort<T extends CognitoAuthConfig>(config: T, warn?: PortWarn): T;
17
+ /** Default OIDC prompt for a browser sign-in: the provider shows its account chooser. */
18
+ export declare const DEFAULT_COGNITO_LOGIN_PROMPT = "select_account";
19
+ /** HQ_COGNITO_PROMPT overrides the sign-in prompt; an empty value sends no prompt. */
20
+ export declare function resolveCognitoLoginPrompt(env?: NodeJS.ProcessEnv): string | undefined;
21
+ /**
22
+ * Config for an interactive browser sign-in: a registered callback port plus
23
+ * the account-chooser prompt. Cognito forwards `prompt` to the identity
24
+ * provider, so a person with several Google accounts picks one instead of
25
+ * being signed in silently with whichever the browser used last.
26
+ *
27
+ * Use this only for a sign-in a person completes in a browser. Token refresh
28
+ * keeps passing DEFAULT_COGNITO itself, which never carries a prompt.
29
+ */
30
+ export declare function interactiveLoginConfig<T extends CognitoAuthConfig>(config: T, warn?: PortWarn): T;
17
31
  //# sourceMappingURL=cognito-callback-port.d.ts.map
@@ -53,4 +53,28 @@ export function withRegisteredCallbackPort(config, warn = defaultWarn) {
53
53
  const port = resolveCognitoCallbackPort(config.port, warn);
54
54
  return port === config.port ? config : { ...config, port };
55
55
  }
56
+ /** Default OIDC prompt for a browser sign-in: the provider shows its account chooser. */
57
+ export const DEFAULT_COGNITO_LOGIN_PROMPT = "select_account";
58
+ /** HQ_COGNITO_PROMPT overrides the sign-in prompt; an empty value sends no prompt. */
59
+ export function resolveCognitoLoginPrompt(env = process.env) {
60
+ const raw = env.HQ_COGNITO_PROMPT;
61
+ if (raw === undefined)
62
+ return DEFAULT_COGNITO_LOGIN_PROMPT;
63
+ return raw.trim() || undefined;
64
+ }
65
+ /**
66
+ * Config for an interactive browser sign-in: a registered callback port plus
67
+ * the account-chooser prompt. Cognito forwards `prompt` to the identity
68
+ * provider, so a person with several Google accounts picks one instead of
69
+ * being signed in silently with whichever the browser used last.
70
+ *
71
+ * Use this only for a sign-in a person completes in a browser. Token refresh
72
+ * keeps passing DEFAULT_COGNITO itself, which never carries a prompt.
73
+ */
74
+ export function interactiveLoginConfig(config, warn = defaultWarn) {
75
+ const registered = withRegisteredCallbackPort(config, warn);
76
+ const { prompt: _configured, ...rest } = registered;
77
+ const prompt = resolveCognitoLoginPrompt();
78
+ return (prompt ? { ...rest, prompt } : rest);
79
+ }
56
80
  //# sourceMappingURL=cognito-callback-port.js.map
@@ -32,7 +32,7 @@ import { daemonDir } from "../lib/mesh/live/daemon/paths.js";
32
32
  import { workMeshRoot } from "../lib/mesh/live/paths.js";
33
33
  import { defaultHqRootFallback, hqDiscoveryCandidates, pathForPlatform, } from "./hq-root-resolver.js";
34
34
  import { acquireLockFileExclusively } from "./exclusive-lock.js";
35
- import { resolveCognitoCallbackPort, withRegisteredCallbackPort } from "./cognito-callback-port.js";
35
+ import { interactiveLoginConfig, resolveCognitoCallbackPort } from "./cognito-callback-port.js";
36
36
  import { HQ_NO_BROWSER_LOGIN_ENV, NON_INTERACTIVE_LOGIN_MESSAGE, isInteractiveCaller, } from "./interactive-caller.js";
37
37
  import { reportNoninteractivePersonRefreshRejection } from "./cognito-refresh-sentry.js";
38
38
  import { decodeJwtPayload, loadCachedTokens, personTokenCacheFile, readPersonTokenFile, readTokenFile, } from "./person-token-cache.js";
@@ -956,7 +956,7 @@ async function ensureCognitoTokenUnserialized(options) {
956
956
  "(or HQ_MACHINE_CREDS_FILE to its machine-creds.json). Otherwise run `hq login` on a computer with a browser.");
957
957
  }
958
958
  console.error(chalk.cyan(" No cached HQ session — launching browser sign-in..."));
959
- const tokens = await browserLogin(withRegisteredCallbackPort(DEFAULT_COGNITO));
959
+ const tokens = await browserLogin(interactiveLoginConfig(DEFAULT_COGNITO));
960
960
  return tokens.accessToken;
961
961
  }
962
962
  /**
@@ -1037,7 +1037,7 @@ async function ensureCognitoIdTokenUnserialized(options) {
1037
1037
  "(or HQ_MACHINE_CREDS_FILE to its machine-creds.json). Otherwise run `hq login` on a computer with a browser.");
1038
1038
  }
1039
1039
  console.error(chalk.cyan(" No cached HQ session — launching browser sign-in..."));
1040
- const tokens = await browserLogin(withRegisteredCallbackPort(DEFAULT_COGNITO));
1040
+ const tokens = await browserLogin(interactiveLoginConfig(DEFAULT_COGNITO));
1041
1041
  return tokens.idToken;
1042
1042
  }
1043
1043
  /**
@@ -0,0 +1,59 @@
1
+ /** One entry of `deletedCompanies` on `GET /membership/me`. */
2
+ export interface DeletedCompanyEntry {
3
+ companyUid: string;
4
+ companyName?: string;
5
+ companySlug?: string;
6
+ role?: string;
7
+ deletedAt: string | null;
8
+ deletedByYou: boolean;
9
+ restorable: boolean;
10
+ restoreUntil: string | null;
11
+ }
12
+ /** Where a person goes when they cannot restore a company themselves. */
13
+ export declare const DELETED_COMPANY_SUPPORT_POINTER = "Run `hq feedback bug` to ask HQ support about recovery.";
14
+ /** The same pointer, for the end of a sentence that starts with "..., or". */
15
+ export declare const DELETED_COMPANY_SUPPORT_POINTER_INLINE = "run `hq feedback bug` to ask HQ support about recovery.";
16
+ /** Default bound on the notice's own `/membership/me` read. */
17
+ export declare const DELETED_COMPANY_NOTICE_TIMEOUT_MS = 3000;
18
+ /** Name shown for a deleted company: its name, then its slug, then "A company". */
19
+ export declare function deletedCompanyDisplayName(entry: DeletedCompanyEntry): string;
20
+ /** Narrow an untrusted `deletedCompanies` value. Malformed entries are dropped. */
21
+ export declare function parseDeletedCompanies(raw: unknown): DeletedCompanyEntry[];
22
+ /**
23
+ * Plain lines describing one deleted company and the person's next step.
24
+ * `now` closes the restore offer once `restoreUntil` has passed, even if the
25
+ * entry still says `restorable`.
26
+ */
27
+ export declare function formatDeletedCompanyNotice(entry: DeletedCompanyEntry, now?: Date): string[];
28
+ /**
29
+ * Read `deletedCompanies` from `GET /membership/me`. Throws on a transport
30
+ * failure or a non-2xx answer; `printDeletedCompanyNotices` swallows that,
31
+ * `hq company restore` reports it.
32
+ */
33
+ export declare function fetchDeletedCompanies(opts: {
34
+ token: string;
35
+ signal?: AbortSignal;
36
+ }): Promise<DeletedCompanyEntry[]>;
37
+ /** Test hook: allow the notice to print again in this process. */
38
+ export declare function resetDeletedCompanyNoticeForTests(): void;
39
+ export interface PrintDeletedCompanyNoticesOptions {
40
+ /** Bearer token to read with. Defaults to the cached session, never a sign-in. */
41
+ token?: string;
42
+ /**
43
+ * `deletedCompanies` from a `/membership/me` response the caller already
44
+ * has. When the key is present (even as `undefined`) no request is made.
45
+ */
46
+ entries?: unknown;
47
+ /** Bound on the read. */
48
+ timeoutMs?: number;
49
+ /** Where the lines go. Defaults to stderr. */
50
+ write?: (line: string) => void;
51
+ now?: Date;
52
+ }
53
+ /**
54
+ * Tell a signed-in person about companies that were deleted, on stderr, at
55
+ * most once per process. Never throws and never touches the exit code: every
56
+ * failure is silent. Machine and agent identities are skipped.
57
+ */
58
+ export declare function printDeletedCompanyNotices(opts?: PrintDeletedCompanyNoticesOptions): Promise<void>;
59
+ //# sourceMappingURL=deleted-company-notice.d.ts.map
@@ -0,0 +1,156 @@
1
+ // src/utils/deleted-company-notice.ts
2
+ //
3
+ // A deleted company disappears from `/membership/me` memberships, so a person
4
+ // whose only company was deleted sees "no memberships" with no explanation.
5
+ // hq-pro now lists those companies under `deletedCompanies`; this module turns
6
+ // them into a plain notice on stderr and feeds `hq company restore`.
7
+ //
8
+ // The pinned hq-cloud client drops unknown keys from `/membership/me`, so the
9
+ // field is read here with a direct `vaultApiFetch` call.
10
+ //
11
+ // vault-api.ts loads this module on use (a dynamic import in its
12
+ // no-memberships branch), so the static imports below do not form a cycle.
13
+ import { ensureCognitoToken, resolveCognitoTokenSource } from "./cognito-session.js";
14
+ import { vaultApiFetch } from "./vault-api.js";
15
+ /** Where a person goes when they cannot restore a company themselves. */
16
+ export const DELETED_COMPANY_SUPPORT_POINTER = "Run `hq feedback bug` to ask HQ support about recovery.";
17
+ /** The same pointer, for the end of a sentence that starts with "..., or". */
18
+ export const DELETED_COMPANY_SUPPORT_POINTER_INLINE = "run `hq feedback bug` to ask HQ support about recovery.";
19
+ /** Default bound on the notice's own `/membership/me` read. */
20
+ export const DELETED_COMPANY_NOTICE_TIMEOUT_MS = 3_000;
21
+ const LONG_DATE = new Intl.DateTimeFormat("en-US", {
22
+ dateStyle: "long",
23
+ timeZone: "UTC",
24
+ });
25
+ function formatDate(iso) {
26
+ if (typeof iso !== "string" || !iso)
27
+ return null;
28
+ const time = Date.parse(iso);
29
+ if (!Number.isFinite(time))
30
+ return null;
31
+ return LONG_DATE.format(new Date(time));
32
+ }
33
+ /** Server-supplied text is printed to a terminal: drop control characters. */
34
+ function clean(value) {
35
+ if (typeof value !== "string")
36
+ return undefined;
37
+ // eslint-disable-next-line no-control-regex
38
+ const text = value.replace(/[\u0000-\u001f\u007f-\u009f]/g, "").trim();
39
+ return text || undefined;
40
+ }
41
+ /** Name shown for a deleted company: its name, then its slug, then "A company". */
42
+ export function deletedCompanyDisplayName(entry) {
43
+ return clean(entry.companyName) ?? clean(entry.companySlug) ?? "A company";
44
+ }
45
+ /** Narrow an untrusted `deletedCompanies` value. Malformed entries are dropped. */
46
+ export function parseDeletedCompanies(raw) {
47
+ if (!Array.isArray(raw))
48
+ return [];
49
+ const entries = [];
50
+ for (const item of raw) {
51
+ if (!item || typeof item !== "object")
52
+ continue;
53
+ const record = item;
54
+ const companyUid = clean(record.companyUid);
55
+ if (!companyUid)
56
+ continue;
57
+ entries.push({
58
+ companyUid,
59
+ companyName: clean(record.companyName),
60
+ companySlug: clean(record.companySlug),
61
+ role: clean(record.role),
62
+ deletedAt: typeof record.deletedAt === "string" ? record.deletedAt : null,
63
+ deletedByYou: record.deletedByYou === true,
64
+ restorable: record.restorable === true,
65
+ restoreUntil: typeof record.restoreUntil === "string" ? record.restoreUntil : null,
66
+ });
67
+ }
68
+ return entries;
69
+ }
70
+ /**
71
+ * Plain lines describing one deleted company and the person's next step.
72
+ * `now` closes the restore offer once `restoreUntil` has passed, even if the
73
+ * entry still says `restorable`.
74
+ */
75
+ export function formatDeletedCompanyNotice(entry, now = new Date()) {
76
+ const name = deletedCompanyDisplayName(entry);
77
+ const deletedOn = formatDate(entry.deletedAt);
78
+ const lead = `${name} was deleted${deletedOn ? ` on ${deletedOn}` : ""}.`;
79
+ const untilTime = entry.restoreUntil ? Date.parse(entry.restoreUntil) : NaN;
80
+ const windowPassed = Number.isFinite(untilTime) && untilTime <= now.getTime();
81
+ if (entry.restorable && !windowPassed) {
82
+ const until = formatDate(entry.restoreUntil);
83
+ const target = clean(entry.companySlug) ?? entry.companyUid;
84
+ return [
85
+ `${lead} You can restore it${until ? ` until ${until}` : ""}: ` +
86
+ `run \`hq company restore ${target}\` or open the HQ desktop app.`,
87
+ ];
88
+ }
89
+ if (entry.deletedByYou) {
90
+ return [
91
+ `${lead} The 30-day restore window has closed. ${DELETED_COMPANY_SUPPORT_POINTER}`,
92
+ ];
93
+ }
94
+ return [
95
+ `${lead} Ask the company owner to restore it, or ${DELETED_COMPANY_SUPPORT_POINTER_INLINE}`,
96
+ ];
97
+ }
98
+ /**
99
+ * Read `deletedCompanies` from `GET /membership/me`. Throws on a transport
100
+ * failure or a non-2xx answer; `printDeletedCompanyNotices` swallows that,
101
+ * `hq company restore` reports it.
102
+ */
103
+ export async function fetchDeletedCompanies(opts) {
104
+ const res = await vaultApiFetch({
105
+ token: opts.token,
106
+ path: "/membership/me",
107
+ signal: opts.signal,
108
+ });
109
+ if (!res.ok)
110
+ throw new Error(`membership read failed (${res.status})`);
111
+ const data = (await res.json());
112
+ return parseDeletedCompanies(data?.deletedCompanies);
113
+ }
114
+ let noticeAttempted = false;
115
+ /** Test hook: allow the notice to print again in this process. */
116
+ export function resetDeletedCompanyNoticeForTests() {
117
+ noticeAttempted = false;
118
+ }
119
+ /**
120
+ * Tell a signed-in person about companies that were deleted, on stderr, at
121
+ * most once per process. Never throws and never touches the exit code: every
122
+ * failure is silent. Machine and agent identities are skipped.
123
+ */
124
+ export async function printDeletedCompanyNotices(opts = {}) {
125
+ if (noticeAttempted)
126
+ return;
127
+ noticeAttempted = true;
128
+ try {
129
+ if (resolveCognitoTokenSource() === "machine")
130
+ return;
131
+ let entries;
132
+ if ("entries" in opts) {
133
+ entries = parseDeletedCompanies(opts.entries);
134
+ }
135
+ else {
136
+ const token = opts.token ?? (await ensureCognitoToken({ interactive: false }));
137
+ if (!token)
138
+ return;
139
+ entries = await fetchDeletedCompanies({
140
+ token,
141
+ signal: AbortSignal.timeout(opts.timeoutMs ?? DELETED_COMPANY_NOTICE_TIMEOUT_MS),
142
+ });
143
+ }
144
+ if (entries.length === 0)
145
+ return;
146
+ const write = opts.write ?? ((line) => process.stderr.write(`${line}\n`));
147
+ for (const entry of entries) {
148
+ for (const line of formatDeletedCompanyNotice(entry, opts.now))
149
+ write(line);
150
+ }
151
+ }
152
+ catch {
153
+ // A notice is decoration on another command. It must never fail it.
154
+ }
155
+ }
156
+ //# sourceMappingURL=deleted-company-notice.js.map
@@ -1,4 +1,4 @@
1
1
  import type { CognitoAuthConfig, CognitoTokens } from "@indigoai-us/hq-cloud";
2
2
  /** Keep desktop login unchanged; manual login uses the same PKCE loopback flow. */
3
- export declare function loginWithBrowserPreference(config: CognitoAuthConfig, browser?: boolean): Promise<CognitoTokens>;
3
+ export declare function loginWithBrowserPreference(requested: CognitoAuthConfig, browser?: boolean): Promise<CognitoTokens>;
4
4
  //# sourceMappingURL=login-browser.d.ts.map
@@ -2,7 +2,7 @@ import { createHash, randomBytes, timingSafeEqual } from "node:crypto";
2
2
  import { createServer } from "node:http";
3
3
  import { browserLogin, saveCachedTokens, CognitoAuthError } from "@indigoai-us/hq-cloud";
4
4
  import { isHeadless } from "./headless.js";
5
- import { withRegisteredCallbackPort } from "./cognito-callback-port.js";
5
+ import { interactiveLoginConfig } from "./cognito-callback-port.js";
6
6
  function assertHumanLoginAllowed() {
7
7
  // Preserve hq-cloud's company-machine boundary on the manual URL path.
8
8
  if (["1", "true", "yes"].includes(process.env.HQ_MACHINE_AUTH_REQUIRED?.trim().toLowerCase() ?? "")) {
@@ -10,13 +10,15 @@ function assertHumanLoginAllowed() {
10
10
  }
11
11
  }
12
12
  /** Keep desktop login unchanged; manual login uses the same PKCE loopback flow. */
13
- export async function loginWithBrowserPreference(config, browser = true) {
13
+ export async function loginWithBrowserPreference(requested, browser = true) {
14
14
  // A callback port outside the registered set opens a redirect_mismatch tab.
15
+ // The manual URL path builds the same redirect_uri and authorize URL, so
16
+ // both paths share one config: registered port plus the account chooser.
17
+ const config = interactiveLoginConfig(requested);
15
18
  if (browser && !isHeadless())
16
- return browserLogin(withRegisteredCallbackPort(config));
19
+ return browserLogin(config);
17
20
  assertHumanLoginAllowed();
18
- // The manual URL path builds the same redirect_uri, so it needs the same guard.
19
- const port = withRegisteredCallbackPort(config).port ?? 3000;
21
+ const port = config.port ?? 3000;
20
22
  const redirectUri = `http://localhost:${port}/callback`;
21
23
  const base = `https://${config.userPoolDomain}.auth.${config.region}.amazoncognito.com`;
22
24
  const verifier = randomBytes(32).toString("base64url");
@@ -1,15 +1,15 @@
1
1
  import { releaseCurrentPackageUseLease, releasePackageUseLeaseAfterResidentPreload, } from "./package-use-lease.js";
2
2
  /** Runtime modules that resident commands may need after a wait starts. */
3
3
  export const RESIDENT_PACKAGE_MODULES = {
4
- "agent-kit": ["../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"],
5
- "agent-mcp": ["../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", "../commands/access.js", "open", "../utils/cognito-session.js", "../lib/first-sync-next-step.js", "../utils/local-files-overview.js", "@indigoai-us/hq-cloud"],
4
+ "agent-kit": ["../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", "../utils/deleted-company-notice.js", "open", "../utils/cognito-session.js", "../lib/first-sync-next-step.js", "@indigoai-us/hq-cloud"],
5
+ "agent-mcp": ["../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", "../utils/deleted-company-notice.js", "../commands/access.js", "open", "../utils/cognito-session.js", "../lib/first-sync-next-step.js", "../utils/local-files-overview.js", "@indigoai-us/hq-cloud"],
6
6
  login: [
7
7
  "../lib/mesh/api.js",
8
8
  "../lib/work-context/config.js",
9
9
  "../lib/work-context/default-company.js",
10
10
  "../lib/work-context/paths.js",
11
11
  "../lib/plan-limit-nag.js",
12
- "../utils/plan-gate-error.js",
12
+ "../utils/plan-gate-error.js", "../utils/deleted-company-notice.js",
13
13
  "../sentry.js", "../lib/doctor/client-health-reason-codes-flag.js", "@indigoai-us/hq-flags-client",
14
14
  "open",
15
15
  "../utils/cognito-session.js",
@@ -20,13 +20,13 @@ export const RESIDENT_PACKAGE_MODULES = {
20
20
  "../lib/auth-login-provider-state.js",
21
21
  "../lib/daemon/mcp-oauth.js",
22
22
  "../lib/plan-limit-nag.js",
23
- "../utils/plan-gate-error.js",
23
+ "../utils/plan-gate-error.js", "../utils/deleted-company-notice.js",
24
24
  "../sentry.js", "../lib/doctor/client-health-reason-codes-flag.js", "@indigoai-us/hq-flags-client",
25
25
  "open",
26
26
  "../utils/cognito-session.js",
27
27
  "@indigoai-us/hq-cloud",
28
28
  ],
29
- "agents-terminal": ["../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"],
29
+ "agents-terminal": ["../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", "../utils/deleted-company-notice.js", "open", "../utils/cognito-session.js", "../lib/first-sync-next-step.js", "@indigoai-us/hq-cloud"],
30
30
  bot: [
31
31
  "../commands/lanes.js",
32
32
  "../lib/lanes/reconcile.js",
@@ -39,7 +39,7 @@ export const RESIDENT_PACKAGE_MODULES = {
39
39
  "@aws-sdk/client-s3",
40
40
  "../sentry.js", "../lib/doctor/client-health-reason-codes-flag.js", "@indigoai-us/hq-flags-client",
41
41
  "../lib/plan-limit-nag.js",
42
- "../utils/plan-gate-error.js",
42
+ "../utils/plan-gate-error.js", "../utils/deleted-company-notice.js",
43
43
  "open",
44
44
  "../utils/cognito-session.js",
45
45
  "../lib/first-sync-next-step.js",
@@ -60,7 +60,7 @@ export const RESIDENT_PACKAGE_MODULES = {
60
60
  "../lib/flag-registry.js",
61
61
  "../utils/cognito-session.js",
62
62
  "../lib/plan-limit-nag.js",
63
- "../utils/plan-gate-error.js",
63
+ "../utils/plan-gate-error.js", "../utils/deleted-company-notice.js",
64
64
  "../lib/daemon/mcp-oauth.js",
65
65
  "../commands/lanes.js",
66
66
  "commander",
@@ -82,19 +82,19 @@ export const RESIDENT_PACKAGE_MODULES = {
82
82
  "../lib/capacity/accounts.js",
83
83
  ],
84
84
  "daemon-logs-follow": [],
85
- "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"],
86
- "lanes-watch": ["../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", "../lib/lanes/reconcile.js", "../utils/local-files-overview.js", "../lib/flag-registry.js", "../utils/vault-api.js", "../commands/files-browse.js", "@aws-sdk/client-s3", "../commands/access.js", "../commands/sources.js", "../lib/hot-channels/adapters/index.js", "../commands/lanes.js", "../lib/capacity/collect.js", "../lib/capacity/accounts.js"],
87
- "monitor-wait": ["../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", "../lib/lanes/reconcile.js", "../utils/local-files-overview.js", "../lib/flag-registry.js", "../utils/vault-api.js", "../commands/files-browse.js", "@aws-sdk/client-s3", "../commands/access.js", "../commands/sources.js", "../lib/hot-channels/adapters/index.js", "../commands/lanes.js", "../lib/capacity/collect.js", "../lib/capacity/accounts.js"],
88
- "monitor-run": ["../commands/lanes.js", "../lib/plan-limit-nag.js", "../utils/plan-gate-error.js", "../sentry.js", "../lib/doctor/client-health-reason-codes-flag.js", "@indigoai-us/hq-flags-client", "open", "../utils/cognito-session.js", "../lib/first-sync-next-step.js", "@indigoai-us/hq-cloud", "../lib/lanes/reconcile.js", "../utils/local-files-overview.js", "../lib/flag-registry.js", "../utils/vault-api.js", "../commands/files-browse.js", "@aws-sdk/client-s3", "../commands/access.js", "../commands/sources.js", "../lib/hot-channels/adapters/index.js", "../lib/capacity/collect.js", "../lib/capacity/accounts.js"],
89
- "agents-message-wait": ["../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"],
90
- "integrations-oauth-wait": ["../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"],
91
- "outpost-wait": ["../commands/lanes.js", "../lib/plan-limit-nag.js", "../utils/plan-gate-error.js", "../sentry.js", "../lib/doctor/client-health-reason-codes-flag.js", "@indigoai-us/hq-flags-client", "open", "../utils/cognito-session.js", "../lib/first-sync-next-step.js", "@indigoai-us/hq-cloud", "../lib/lanes/reconcile.js", "../utils/local-files-overview.js", "../lib/flag-registry.js", "../utils/vault-api.js", "../commands/files-browse.js", "@aws-sdk/client-s3", "../commands/access.js", "../commands/sources.js", "../lib/hot-channels/adapters/index.js", "../lib/capacity/collect.js", "../lib/capacity/accounts.js"],
85
+ "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", "../utils/deleted-company-notice.js", "open", "../utils/cognito-session.js", "../lib/first-sync-next-step.js", "@indigoai-us/hq-cloud"],
86
+ "lanes-watch": ["../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", "../utils/deleted-company-notice.js", "open", "../utils/cognito-session.js", "../lib/first-sync-next-step.js", "@indigoai-us/hq-cloud", "../lib/lanes/reconcile.js", "../utils/local-files-overview.js", "../lib/flag-registry.js", "../utils/vault-api.js", "../commands/files-browse.js", "@aws-sdk/client-s3", "../commands/access.js", "../commands/sources.js", "../lib/hot-channels/adapters/index.js", "../commands/lanes.js", "../lib/capacity/collect.js", "../lib/capacity/accounts.js"],
87
+ "monitor-wait": ["../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", "../utils/deleted-company-notice.js", "open", "../utils/cognito-session.js", "../lib/first-sync-next-step.js", "@indigoai-us/hq-cloud", "../lib/lanes/reconcile.js", "../utils/local-files-overview.js", "../lib/flag-registry.js", "../utils/vault-api.js", "../commands/files-browse.js", "@aws-sdk/client-s3", "../commands/access.js", "../commands/sources.js", "../lib/hot-channels/adapters/index.js", "../commands/lanes.js", "../lib/capacity/collect.js", "../lib/capacity/accounts.js"],
88
+ "monitor-run": ["../commands/lanes.js", "../lib/plan-limit-nag.js", "../utils/plan-gate-error.js", "../utils/deleted-company-notice.js", "../sentry.js", "../lib/doctor/client-health-reason-codes-flag.js", "@indigoai-us/hq-flags-client", "open", "../utils/cognito-session.js", "../lib/first-sync-next-step.js", "@indigoai-us/hq-cloud", "../lib/lanes/reconcile.js", "../utils/local-files-overview.js", "../lib/flag-registry.js", "../utils/vault-api.js", "../commands/files-browse.js", "@aws-sdk/client-s3", "../commands/access.js", "../commands/sources.js", "../lib/hot-channels/adapters/index.js", "../lib/capacity/collect.js", "../lib/capacity/accounts.js"],
89
+ "agents-message-wait": ["../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", "../utils/deleted-company-notice.js", "open", "../utils/cognito-session.js", "../lib/first-sync-next-step.js", "@indigoai-us/hq-cloud"],
90
+ "integrations-oauth-wait": ["../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", "../utils/deleted-company-notice.js", "open", "../utils/cognito-session.js", "../lib/first-sync-next-step.js", "@indigoai-us/hq-cloud"],
91
+ "outpost-wait": ["../commands/lanes.js", "../lib/plan-limit-nag.js", "../utils/plan-gate-error.js", "../utils/deleted-company-notice.js", "../sentry.js", "../lib/doctor/client-health-reason-codes-flag.js", "@indigoai-us/hq-flags-client", "open", "../utils/cognito-session.js", "../lib/first-sync-next-step.js", "@indigoai-us/hq-cloud", "../lib/lanes/reconcile.js", "../utils/local-files-overview.js", "../lib/flag-registry.js", "../utils/vault-api.js", "../commands/files-browse.js", "@aws-sdk/client-s3", "../commands/access.js", "../commands/sources.js", "../lib/hot-channels/adapters/index.js", "../lib/capacity/collect.js", "../lib/capacity/accounts.js"],
92
92
  "secrets-sandbox": [],
93
93
  "pkg-update": ["../sentry.js", "../lib/doctor/client-health-reason-codes-flag.js", "@indigoai-us/hq-flags-client", "../utils/cognito-session.js", "@indigoai-us/hq-cloud"],
94
94
  "pack-install": [
95
95
  "../sentry.js", "../lib/doctor/client-health-reason-codes-flag.js", "@indigoai-us/hq-flags-client",
96
96
  "../lib/plan-limit-nag.js",
97
- "../utils/plan-gate-error.js",
97
+ "../utils/plan-gate-error.js", "../utils/deleted-company-notice.js",
98
98
  "open",
99
99
  "../commands/mcp-serve.js",
100
100
  "../lib/anywhere-person-setting.js",
@@ -121,6 +121,7 @@ const LOADERS = {
121
121
  },
122
122
  () => import("../lib/plan-limit-nag.js"),
123
123
  () => import("../utils/plan-gate-error.js"),
124
+ () => import("../utils/deleted-company-notice.js"),
124
125
  () => import("open"),
125
126
  () => import("../utils/cognito-session.js"),
126
127
  () => import("../lib/first-sync-next-step.js"),
@@ -135,6 +136,7 @@ const LOADERS = {
135
136
  },
136
137
  () => import("../lib/plan-limit-nag.js"),
137
138
  () => import("../utils/plan-gate-error.js"),
139
+ () => import("../utils/deleted-company-notice.js"),
138
140
  () => import("../commands/access.js"),
139
141
  () => import("open"),
140
142
  () => import("../utils/cognito-session.js"),
@@ -149,6 +151,7 @@ const LOADERS = {
149
151
  () => import("../lib/work-context/paths.js"),
150
152
  () => import("../lib/plan-limit-nag.js"),
151
153
  () => import("../utils/plan-gate-error.js"),
154
+ () => import("../utils/deleted-company-notice.js"),
152
155
  async () => {
153
156
  const { preloadSentrySdk } = await import("../sentry.js");
154
157
  await import("../lib/doctor/client-health-reason-codes-flag.js");
@@ -165,6 +168,7 @@ const LOADERS = {
165
168
  () => import("../lib/daemon/mcp-oauth.js"),
166
169
  () => import("../lib/plan-limit-nag.js"),
167
170
  () => import("../utils/plan-gate-error.js"),
171
+ () => import("../utils/deleted-company-notice.js"),
168
172
  async () => {
169
173
  const { preloadSentrySdk } = await import("../sentry.js");
170
174
  await import("../lib/doctor/client-health-reason-codes-flag.js");
@@ -184,6 +188,7 @@ const LOADERS = {
184
188
  },
185
189
  () => import("../lib/plan-limit-nag.js"),
186
190
  () => import("../utils/plan-gate-error.js"),
191
+ () => import("../utils/deleted-company-notice.js"),
187
192
  () => import("open"),
188
193
  () => import("../utils/cognito-session.js"),
189
194
  () => import("../lib/first-sync-next-step.js"),
@@ -213,6 +218,7 @@ const LOADERS = {
213
218
  },
214
219
  () => import("../lib/plan-limit-nag.js"),
215
220
  () => import("../utils/plan-gate-error.js"),
221
+ () => import("../utils/deleted-company-notice.js"),
216
222
  () => import("open"),
217
223
  () => import("../utils/cognito-session.js"),
218
224
  () => import("../lib/first-sync-next-step.js"),
@@ -259,6 +265,7 @@ const LOADERS = {
259
265
  () => import("../utils/cognito-session.js"),
260
266
  () => import("../lib/plan-limit-nag.js"),
261
267
  () => import("../utils/plan-gate-error.js"),
268
+ () => import("../utils/deleted-company-notice.js"),
262
269
  () => import("../lib/daemon/mcp-oauth.js"),
263
270
  () => import("../commands/lanes.js"),
264
271
  () => import("commander"),
@@ -292,6 +299,7 @@ const LOADERS = {
292
299
  },
293
300
  () => import("../lib/plan-limit-nag.js"),
294
301
  () => import("../utils/plan-gate-error.js"),
302
+ () => import("../utils/deleted-company-notice.js"),
295
303
  () => import("open"),
296
304
  () => import("../utils/cognito-session.js"),
297
305
  () => import("../lib/first-sync-next-step.js"),
@@ -306,6 +314,7 @@ const LOADERS = {
306
314
  },
307
315
  () => import("../lib/plan-limit-nag.js"),
308
316
  () => import("../utils/plan-gate-error.js"),
317
+ () => import("../utils/deleted-company-notice.js"),
309
318
  () => import("open"),
310
319
  () => import("../utils/cognito-session.js"),
311
320
  () => import("../lib/first-sync-next-step.js"),
@@ -336,6 +345,7 @@ const LOADERS = {
336
345
  },
337
346
  () => import("../lib/plan-limit-nag.js"),
338
347
  () => import("../utils/plan-gate-error.js"),
348
+ () => import("../utils/deleted-company-notice.js"),
339
349
  () => import("open"),
340
350
  () => import("../utils/cognito-session.js"),
341
351
  () => import("../lib/first-sync-next-step.js"),
@@ -361,6 +371,7 @@ const LOADERS = {
361
371
  () => import("../commands/lanes.js"),
362
372
  () => import("../lib/plan-limit-nag.js"),
363
373
  () => import("../utils/plan-gate-error.js"),
374
+ () => import("../utils/deleted-company-notice.js"),
364
375
  async () => {
365
376
  const { preloadSentrySdk } = await import("../sentry.js");
366
377
  await import("../lib/doctor/client-health-reason-codes-flag.js");
@@ -396,6 +407,7 @@ const LOADERS = {
396
407
  },
397
408
  () => import("../lib/plan-limit-nag.js"),
398
409
  () => import("../utils/plan-gate-error.js"),
410
+ () => import("../utils/deleted-company-notice.js"),
399
411
  () => import("open"),
400
412
  () => import("../utils/cognito-session.js"),
401
413
  () => import("../lib/first-sync-next-step.js"),
@@ -410,6 +422,7 @@ const LOADERS = {
410
422
  },
411
423
  () => import("../lib/plan-limit-nag.js"),
412
424
  () => import("../utils/plan-gate-error.js"),
425
+ () => import("../utils/deleted-company-notice.js"),
413
426
  () => import("open"),
414
427
  () => import("../utils/cognito-session.js"),
415
428
  () => import("../lib/first-sync-next-step.js"),
@@ -419,6 +432,7 @@ const LOADERS = {
419
432
  () => import("../commands/lanes.js"),
420
433
  () => import("../lib/plan-limit-nag.js"),
421
434
  () => import("../utils/plan-gate-error.js"),
435
+ () => import("../utils/deleted-company-notice.js"),
422
436
  async () => {
423
437
  const { preloadSentrySdk } = await import("../sentry.js");
424
438
  await import("../lib/doctor/client-health-reason-codes-flag.js");
@@ -465,6 +479,7 @@ const LOADERS = {
465
479
  },
466
480
  () => import("../lib/plan-limit-nag.js"),
467
481
  () => import("../utils/plan-gate-error.js"),
482
+ () => import("../utils/deleted-company-notice.js"),
468
483
  () => import("open"),
469
484
  () => import("../commands/mcp-serve.js"),
470
485
  () => import("../lib/anywhere-person-setting.js"),
@@ -47,4 +47,67 @@ export declare function removeEntryNoFollow(p: string, opts?: {
47
47
  * Returns false when nothing exists at `linkPath`.
48
48
  */
49
49
  export declare function removeLinkOnly(linkPath: string): boolean;
50
+ /** Marker file written into a folder HQ copied in place of a release link. */
51
+ export declare const LINK_COPY_MARKER = ".hq-link-copy";
52
+ /** What a link copy's marker records. */
53
+ export interface LinkCopyMarker {
54
+ /** The absolute folder the copy was made from (the link's target). */
55
+ source: string;
56
+ /** The entry name HQ gave the copy. */
57
+ name: string;
58
+ /** {@link linkCopyTreeHash} of the copy when HQ wrote it. */
59
+ hash: string;
60
+ /** Why HQ copied instead of linking. */
61
+ reason?: string;
62
+ }
63
+ export interface LinkCopyResult {
64
+ /** Hash recorded in the marker. */
65
+ hash: string;
66
+ /** Paths (relative to the source) of links that resolve outside `within`; not copied. */
67
+ skippedOutside: string[];
68
+ }
69
+ export interface LinkCopyOptions {
70
+ /** Real path of the HQ root. A link inside the source is followed only when it resolves under it. */
71
+ within: string;
72
+ /** Why HQ copied instead of linking; stored in the marker. */
73
+ reason?: string;
74
+ }
75
+ /**
76
+ * A sha256 over the names and contents of what a link copy of `dir` holds,
77
+ * read with the same rules as the copy (see {@link walkLinkCopyTree}). Hashing
78
+ * the copy and hashing its source give the same value while they match.
79
+ */
80
+ export declare function linkCopyTreeHash(dir: string, within: string): string;
81
+ /**
82
+ * The hash of an HQ link copy as it sits on disk. HQ copies never contain
83
+ * links (links in the source are copied as real files and folders, or left
84
+ * out), so any link inside the copy is something the user added: it is hashed
85
+ * by its text and never followed. For a copy without links this equals
86
+ * {@link linkCopyTreeHash} of the copy.
87
+ */
88
+ export declare function linkCopyContentHash(dir: string, within: string): string;
89
+ /**
90
+ * The marker of a folder HQ copied in place of a release link, or null when
91
+ * `p` is not a real folder carrying a valid marker.
92
+ */
93
+ export declare function readLinkCopyMarker(p: string): LinkCopyMarker | null;
94
+ /**
95
+ * Copy the folder `source` to the new path `dest` and mark it as a link copy.
96
+ * `source` must resolve under `opts.within` (the HQ root). A link inside the
97
+ * source is followed only when it resolves under `opts.within`; one that
98
+ * resolves outside is left out and listed in `skippedOutside`. A partial copy
99
+ * is removed when the copy fails.
100
+ */
101
+ export declare function copyFolderForLink(source: string, dest: string, opts: LinkCopyOptions): LinkCopyResult;
102
+ /**
103
+ * Replace the marked link copy at `dest` with a fresh copy of `source`. The
104
+ * new copy is made beside it first, so a failed copy leaves the old copy in
105
+ * place. The old copy is then renamed aside, the new one renamed into place,
106
+ * and only then is the old one deleted; if the second rename fails the old
107
+ * copy is renamed back. A failure at any step leaves a complete, marked copy
108
+ * at `dest`. Refuses a folder without a link-copy marker. The caller decides
109
+ * whether the old copy holds user changes (compare
110
+ * {@link linkCopyContentHash} with the marker's hash) before calling this.
111
+ */
112
+ export declare function refreshLinkCopy(source: string, dest: string, opts: LinkCopyOptions): LinkCopyResult;
50
113
  //# sourceMappingURL=safe-link.d.ts.map