@indigoai-us/hq-cli 5.345.220 → 5.345.221

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 (138) hide show
  1. package/CHANGELOG.md +118 -0
  2. package/dist/command-catalog.generated.d.ts +144 -2
  3. package/dist/command-catalog.generated.js +175 -2
  4. package/dist/commands/auth.js +4 -1
  5. package/dist/commands/bot-runtime.d.ts +18 -5
  6. package/dist/commands/bot-runtime.js +29 -12
  7. package/dist/commands/bot.d.ts +39 -2
  8. package/dist/commands/bot.js +140 -11
  9. package/dist/commands/core-stop-autosave.d.ts +21 -0
  10. package/dist/commands/core-stop-autosave.js +300 -0
  11. package/dist/commands/core.js +2 -0
  12. package/dist/commands/daemon.d.ts +5 -0
  13. package/dist/commands/daemon.js +31 -7
  14. package/dist/commands/doctor-usage.d.ts +5 -0
  15. package/dist/commands/doctor-usage.js +25 -0
  16. package/dist/commands/env.d.ts +49 -4
  17. package/dist/commands/env.js +355 -5
  18. package/dist/commands/lanes-shared.d.ts +3 -0
  19. package/dist/commands/lanes.d.ts +3 -0
  20. package/dist/commands/lanes.js +87 -3
  21. package/dist/commands/sources.js +3 -3
  22. package/dist/commands/sync-core.d.ts +1 -0
  23. package/dist/commands/sync-core.js +77 -3
  24. package/dist/commands/whoami.js +96 -80
  25. package/dist/lib/bot/config.d.ts +17 -0
  26. package/dist/lib/bot/config.js +13 -0
  27. package/dist/lib/bot/fleet-cron.js +24 -2
  28. package/dist/lib/bot/fleet-local.d.ts +30 -2
  29. package/dist/lib/bot/fleet-local.js +60 -1
  30. package/dist/lib/bot/grok-login-scope.d.ts +36 -0
  31. package/dist/lib/bot/grok-login-scope.js +93 -0
  32. package/dist/lib/bot/legacy-provider-login.d.ts +32 -9
  33. package/dist/lib/bot/legacy-provider-login.js +28 -22
  34. package/dist/lib/bot/runtime-sign-in-check.js +6 -1
  35. package/dist/lib/bot/runtime-sign-in.d.ts +2 -0
  36. package/dist/lib/core-utils/sentry-report.js +2 -0
  37. package/dist/lib/daemon/machine-checks.d.ts +22 -1
  38. package/dist/lib/daemon/machine-checks.js +54 -12
  39. package/dist/lib/daemon/run.js +66 -8
  40. package/dist/lib/daemon/stop-autosave-lock.d.ts +19 -0
  41. package/dist/lib/daemon/stop-autosave-lock.js +166 -0
  42. package/dist/lib/daemon/stop-autosave.d.ts +28 -0
  43. package/dist/lib/daemon/stop-autosave.js +111 -0
  44. package/dist/lib/daemon/stop-diagnostics.d.ts +11 -0
  45. package/dist/lib/daemon/stop-diagnostics.js +136 -0
  46. package/dist/lib/daemon/stop-job-executor.d.ts +19 -0
  47. package/dist/lib/daemon/stop-job-executor.js +126 -0
  48. package/dist/lib/daemon/stop-jobs.d.ts +93 -0
  49. package/dist/lib/daemon/stop-jobs.js +599 -0
  50. package/dist/lib/doctor/checks/fleet-hook-core.js +1 -1
  51. package/dist/lib/doctor/checks/host-core.js +1 -1
  52. package/dist/lib/environment/access-probes.d.ts +234 -0
  53. package/dist/lib/environment/access-probes.js +918 -0
  54. package/dist/lib/environment/profile.d.ts +15 -2
  55. package/dist/lib/environment/profile.js +55 -20
  56. package/dist/lib/environment/rfc3339.d.ts +8 -0
  57. package/dist/lib/environment/rfc3339.js +26 -0
  58. package/dist/lib/environment/work-requirements.d.ts +169 -0
  59. package/dist/lib/environment/work-requirements.js +389 -0
  60. package/dist/lib/hook-engine/coverage.d.ts +137 -7
  61. package/dist/lib/hook-engine/coverage.js +1424 -4
  62. package/dist/lib/hook-engine/fleet-registration.js +2 -2
  63. package/dist/lib/hook-engine/git-stop-config.json +513 -0
  64. package/dist/lib/hook-engine/native-stop-compatibility.json +311 -0
  65. package/dist/lib/hook-engine/reconcile.js +2 -2
  66. package/dist/lib/hot-channels/alert.d.ts +2 -2
  67. package/dist/lib/hot-channels/alert.js +8 -5
  68. package/dist/lib/hot-channels/signals-pass.d.ts +126 -17
  69. package/dist/lib/hot-channels/signals-pass.js +296 -17
  70. package/dist/lib/hot-channels/signals-runtime.d.ts +30 -0
  71. package/dist/lib/hot-channels/signals-runtime.js +82 -0
  72. package/dist/lib/install/hook-target.js +1 -1
  73. package/dist/lib/lanes/host-capacity.d.ts +26 -2
  74. package/dist/lib/lanes/host-capacity.js +17 -2
  75. package/dist/lib/lanes/host-compute.d.ts +90 -0
  76. package/dist/lib/lanes/host-compute.js +185 -0
  77. package/dist/lib/lanes/index.d.ts +2 -0
  78. package/dist/lib/lanes/index.js +1 -0
  79. package/dist/lib/lanes/reconcile.js +22 -1
  80. package/dist/lib/lanes/resource-usage.d.ts +155 -0
  81. package/dist/lib/lanes/resource-usage.js +589 -0
  82. package/dist/lib/lanes/run-size.d.ts +46 -0
  83. package/dist/lib/lanes/run-size.js +197 -0
  84. package/dist/lib/lanes/store.js +27 -0
  85. package/dist/lib/lanes/throttle.d.ts +36 -1
  86. package/dist/lib/lanes/throttle.js +47 -10
  87. package/dist/lib/lanes/types.d.ts +40 -0
  88. package/dist/lib/lanes/types.js +2 -2
  89. package/dist/lib/lanes/watcher.js +13 -4
  90. package/dist/lib/lanes/worker-process.d.ts +25 -2
  91. package/dist/lib/lanes/worker-process.js +71 -19
  92. package/dist/lib/placement/match.d.ts +192 -0
  93. package/dist/lib/placement/match.js +667 -0
  94. package/dist/lib/safe-store.d.ts +14 -0
  95. package/dist/lib/safe-store.js +77 -4
  96. package/dist/lib/search-index/index.d.ts +88 -4
  97. package/dist/lib/search-index/index.js +288 -24
  98. package/dist/lib/search-index/max-doc-bytes.d.ts +17 -6
  99. package/dist/lib/search-index/max-doc-bytes.js +48 -23
  100. package/dist/lib/signals/codex-lockdown.d.ts +79 -0
  101. package/dist/lib/signals/codex-lockdown.js +271 -0
  102. package/dist/lib/signals/codex-login.d.ts +37 -0
  103. package/dist/lib/signals/codex-login.js +83 -0
  104. package/dist/lib/signals/engine.d.ts +27 -0
  105. package/dist/lib/signals/engine.js +70 -0
  106. package/dist/lib/signals/reply.js +22 -1
  107. package/dist/lib/signals/run-record.js +6 -1
  108. package/dist/lib/signals/settings.d.ts +5 -0
  109. package/dist/lib/signals/settings.js +2 -0
  110. package/dist/lib/signals/steps/extract.d.ts +85 -9
  111. package/dist/lib/signals/steps/extract.js +317 -68
  112. package/dist/lib/signals/steps/types.d.ts +2 -0
  113. package/dist/lib/sync-core/engine-home.d.ts +35 -1
  114. package/dist/lib/sync-core/engine-home.js +119 -16
  115. package/dist/lib/sync-core/rollout-state.d.ts +2 -1
  116. package/dist/lib/sync-core/rollout-state.js +5 -2
  117. package/dist/lib/sync-core/vault-uid.d.ts +2 -0
  118. package/dist/lib/sync-core/vault-uid.js +4 -0
  119. package/dist/schemas/hq-work-requirements.v1.schema.json +145 -0
  120. package/dist/utils/auth-session-check.d.ts +16 -0
  121. package/dist/utils/auth-session-check.js +16 -0
  122. package/dist/utils/client-health-contract.d.ts +6 -0
  123. package/dist/utils/client-health-contract.js +13 -0
  124. package/dist/utils/client-health.d.ts +7 -0
  125. package/dist/utils/client-health.js +22 -1
  126. package/dist/utils/command-usage.d.ts +40 -0
  127. package/dist/utils/command-usage.js +61 -0
  128. package/dist/utils/duplicate-command-usage.d.ts +72 -0
  129. package/dist/utils/duplicate-command-usage.js +125 -0
  130. package/dist/utils/host-registration.js +2 -1
  131. package/dist/utils/resident-package-preload.js +4 -0
  132. package/dist/utils/sentry-fingerprint.js +9 -0
  133. package/dist/utils/windows-bash.d.ts +2 -0
  134. package/dist/utils/windows-bash.js +2 -1
  135. package/package.json +9 -8
  136. package/scripts/bench-core-compare.mjs +313 -0
  137. package/scripts/bench-core.mjs +399 -12
  138. package/scripts/check-function-manifest.mjs +116 -3
@@ -1769,6 +1769,11 @@ export const COMMAND_CATALOG = [
1769
1769
  "flags": "--company <slug>",
1770
1770
  "description": "Also report this company's billing and usage notice",
1771
1771
  "hidden": false
1772
+ },
1773
+ {
1774
+ "flags": "--check",
1775
+ "description": "Exit 1 when there is no usable session, like `hq auth status`",
1776
+ "hidden": false
1772
1777
  }
1773
1778
  ],
1774
1779
  "subcommands": []
@@ -11995,6 +12000,25 @@ export const COMMAND_CATALOG = [
11995
12000
  ],
11996
12001
  "subcommands": []
11997
12002
  },
12003
+ {
12004
+ "name": "stop-autosave",
12005
+ "description": "Drain the typed Stop autosave job",
12006
+ "aliases": [],
12007
+ "hidden": false,
12008
+ "helpOption": true,
12009
+ "helpCommand": false,
12010
+ "usage": "[options]",
12011
+ "helpText": [],
12012
+ "arguments": [],
12013
+ "options": [
12014
+ {
12015
+ "flags": "--session-id <id>",
12016
+ "description": "",
12017
+ "hidden": false
12018
+ }
12019
+ ],
12020
+ "subcommands": []
12021
+ },
11998
12022
  {
11999
12023
  "name": "hook-registration-plan",
12000
12024
  "description": "Print the offline fleet hook registration plan without changing the installation",
@@ -15089,6 +15113,94 @@ export const COMMAND_CATALOG = [
15089
15113
  }
15090
15114
  ],
15091
15115
  "subcommands": []
15116
+ },
15117
+ {
15118
+ "name": "probe",
15119
+ "description": "Run access probes by name and print them as hq-environment-profile.v1 readings.access entries: company vault grant, repos, secrets (exists by HEAD, and resolvable inside hq secrets exec; the value is never printed or stored), integrations and local data (exit 1 when a probe does not pass)",
15120
+ "aliases": [],
15121
+ "hidden": false,
15122
+ "helpOption": true,
15123
+ "helpCommand": false,
15124
+ "usage": "[options]",
15125
+ "helpText": [],
15126
+ "arguments": [],
15127
+ "options": [
15128
+ {
15129
+ "flags": "--company <slug>",
15130
+ "description": "Company whose vault, secrets and integrations are probed (required)",
15131
+ "hidden": false
15132
+ },
15133
+ {
15134
+ "flags": "--repo <name>",
15135
+ "description": "Checkout name under repos/private or repos/public; its origin must answer git ls-remote (repeatable, comma-separated)",
15136
+ "hidden": false
15137
+ },
15138
+ {
15139
+ "flags": "--secret <NAME>",
15140
+ "description": "Secret name to probe: exists, then resolvable by this identity (repeatable, comma-separated)",
15141
+ "hidden": false
15142
+ },
15143
+ {
15144
+ "flags": "--integration <slug>",
15145
+ "description": "App that must be connected and shared with this identity (repeatable, comma-separated)",
15146
+ "hidden": false
15147
+ },
15148
+ {
15149
+ "flags": "--data <path>",
15150
+ "description": "Path relative to the HQ root that must be present and not empty (repeatable, comma-separated)",
15151
+ "hidden": false
15152
+ },
15153
+ {
15154
+ "flags": "--agent",
15155
+ "description": "Also run hq agent probe (identity, vault, presence, DMs); it sends a self-DM and reports to the console",
15156
+ "hidden": false
15157
+ },
15158
+ {
15159
+ "flags": "--write-profile <file>",
15160
+ "description": "Store the readings in this profile's readings.access, replacing entries with the same names; the profile must validate afterwards",
15161
+ "hidden": false
15162
+ },
15163
+ {
15164
+ "flags": "--json",
15165
+ "description": "Print the result as JSON",
15166
+ "hidden": false
15167
+ }
15168
+ ],
15169
+ "subcommands": []
15170
+ },
15171
+ {
15172
+ "name": "match",
15173
+ "description": "First ranking of environments for one piece of work: rules R1-R9 with one reason per rejection, then scores (read-only; not a placement, the conductor engine chooses)",
15174
+ "aliases": [],
15175
+ "hidden": false,
15176
+ "helpOption": true,
15177
+ "helpCommand": false,
15178
+ "usage": "[options]",
15179
+ "helpText": [],
15180
+ "arguments": [],
15181
+ "options": [
15182
+ {
15183
+ "flags": "--requirements <file>",
15184
+ "description": "hq-work-requirements.v1 JSON file",
15185
+ "hidden": false
15186
+ },
15187
+ {
15188
+ "flags": "--profiles <dir>",
15189
+ "description": "Directory of hq-environment-profile.v1 JSON files (every *.json in it, not recursive)",
15190
+ "hidden": false
15191
+ },
15192
+ {
15193
+ "flags": "--now <date-time>",
15194
+ "description": "Match time every reading is aged against (RFC 3339; default: the current time)",
15195
+ "hidden": false
15196
+ },
15197
+ {
15198
+ "flags": "--json",
15199
+ "description": "Print the result as JSON",
15200
+ "hidden": false
15201
+ }
15202
+ ],
15203
+ "subcommands": []
15092
15204
  }
15093
15205
  ]
15094
15206
  },
@@ -15190,6 +15302,16 @@ export const COMMAND_CATALOG = [
15190
15302
  "flags": "--json",
15191
15303
  "description": "Emit the counts as JSON.",
15192
15304
  "hidden": false
15305
+ },
15306
+ {
15307
+ "flags": "--duplicates",
15308
+ "description": "List only the duplicate commands and their runs in the window; exit 0 when none ran, 1 when one did, 2 when the count cannot be read.",
15309
+ "hidden": false
15310
+ },
15311
+ {
15312
+ "flags": "--since <window>",
15313
+ "description": "Window for --duplicates: Nh or Nd, at most 29d (default 1d). Counts are per UTC date, so whole dates are counted.",
15314
+ "hidden": false
15193
15315
  }
15194
15316
  ],
15195
15317
  "subcommands": []
@@ -23333,9 +23455,28 @@ export const COMMAND_CATALOG = [
23333
23455
  "arguments": [],
23334
23456
  "options": [],
23335
23457
  "subcommands": [
23458
+ {
23459
+ "name": "list",
23460
+ "description": "List every membership's company and current sync mode (same table as `hq sync mode --show`)",
23461
+ "aliases": [],
23462
+ "hidden": false,
23463
+ "helpOption": true,
23464
+ "helpCommand": false,
23465
+ "usage": "[options]",
23466
+ "helpText": [],
23467
+ "arguments": [],
23468
+ "options": [
23469
+ {
23470
+ "flags": "--json",
23471
+ "description": "Print machine-readable JSON",
23472
+ "hidden": false
23473
+ }
23474
+ ],
23475
+ "subcommands": []
23476
+ },
23336
23477
  {
23337
23478
  "name": "get",
23338
- "description": "Read a company's current all/shared sync mode",
23479
+ "description": "Read a company's current sync mode",
23339
23480
  "aliases": [],
23340
23481
  "hidden": false,
23341
23482
  "helpOption": true,
@@ -23361,7 +23502,7 @@ export const COMMAND_CATALOG = [
23361
23502
  },
23362
23503
  {
23363
23504
  "name": "set",
23364
- "description": "Set a company's sync mode to all or shared",
23505
+ "description": "Set a company's sync mode to shared, all or custom",
23365
23506
  "aliases": [],
23366
23507
  "hidden": false,
23367
23508
  "helpOption": true,
@@ -23383,6 +23524,11 @@ export const COMMAND_CATALOG = [
23383
23524
  }
23384
23525
  ],
23385
23526
  "options": [
23527
+ {
23528
+ "flags": "--paths <csv>",
23529
+ "description": "Comma-separated allowed prefixes (required when mode is 'custom')",
23530
+ "hidden": false
23531
+ },
23386
23532
  {
23387
23533
  "flags": "--json",
23388
23534
  "description": "Print machine-readable JSON",
@@ -24647,6 +24793,17 @@ export const COMMAND_CATALOG = [
24647
24793
  "description": "Brain: claude, codex (or chatgpt) or grok",
24648
24794
  "hidden": false
24649
24795
  },
24796
+ {
24797
+ "flags": "--kind <kind>",
24798
+ "description": "The bot the answer is for: personal (default) or company",
24799
+ "hidden": false
24800
+ },
24801
+ {
24802
+ "flags": "--company <slug>",
24803
+ "description": "The company of a company bot (repeatable); a Grok login is reused only within one company",
24804
+ "hidden": false,
24805
+ "defaultValue": []
24806
+ },
24650
24807
  {
24651
24808
  "flags": "--json",
24652
24809
  "description": "Print machine-readable JSON: { provider, signedIn, source }",
@@ -24671,6 +24828,17 @@ export const COMMAND_CATALOG = [
24671
24828
  "description": "Brain: codex (or chatgpt) or grok",
24672
24829
  "hidden": false
24673
24830
  },
24831
+ {
24832
+ "flags": "--kind <kind>",
24833
+ "description": "The bot the sign-in is for: personal (default) or company",
24834
+ "hidden": false
24835
+ },
24836
+ {
24837
+ "flags": "--company <slug>",
24838
+ "description": "The company of a company bot (repeatable)",
24839
+ "hidden": false,
24840
+ "defaultValue": []
24841
+ },
24674
24842
  {
24675
24843
  "flags": "--json",
24676
24844
  "description": "Print one JSON line per event (device code, messages) and a final result",
@@ -24815,6 +24983,11 @@ export const COMMAND_CATALOG = [
24815
24983
  "description": "Thinking level (claude low|medium|high|xhigh|max; codex minimal|low|medium|high|xhigh; grok low|medium|high|xhigh), or default (medium)",
24816
24984
  "hidden": false
24817
24985
  },
24986
+ {
24987
+ "flags": "--signals-runtime <bot|claude>",
24988
+ "description": "Where hot-channel signals run: bot (the Executive Codex bot's own Codex) or claude (Claude Code, the default). Set on the Executive bot; local to this computer, from the next sync",
24989
+ "hidden": false
24990
+ },
24818
24991
  {
24819
24992
  "flags": "--json",
24820
24993
  "description": "Print machine-readable JSON",
@@ -18,6 +18,7 @@
18
18
  */
19
19
  import { loginWithBrowserPreference } from "../utils/login-browser.js";
20
20
  import { formatAuthExpiry } from "../utils/auth-expiry.js";
21
+ import { authStatusExitCode } from "../utils/auth-session-check.js";
21
22
  import { releaseCurrentPackageUseLease, releasePackageUseLeaseAfterResidentPreload } from "../utils/package-use-lease.js";
22
23
  import { preloadResidentPackageModules, reportResidentPackagePreloadFailure } from "../utils/resident-package-preload.js";
23
24
  import * as fs from "node:fs";
@@ -414,6 +415,8 @@ export function registerAuthCommands(program) {
414
415
  // machine cache was valid, and could show a stale person session as the
415
416
  // machine one.
416
417
  const cached = machine ? loadMachineCachedTokens() : loadCachedTokens();
418
+ // Shared with `hq whoami --check`, so both give the same exit status.
419
+ const exitCode = authStatusExitCode({ tokenSource, cached });
417
420
  if (!cached) {
418
421
  if (machine) {
419
422
  // No cached session yet, but machine creds mint one on demand —
@@ -424,7 +427,7 @@ export function registerAuthCommands(program) {
424
427
  }
425
428
  console.log(chalk.yellow("No cached HQ session — run `hq login`"));
426
429
  console.log(chalk.dim(`token source: ${tokenSource}`));
427
- process.exit(1);
430
+ process.exit(exitCode);
428
431
  }
429
432
  const claims = peekIdToken(cached.idToken);
430
433
  const who = machine
@@ -1,8 +1,7 @@
1
1
  import { type ClaudeLoginCheck } from "../lib/bot/claude-login.js";
2
2
  import { fleetRuntimeReady, type FleetInstallProgress, type FleetInstallProgressListener, type FleetLocalTargetRelease } from "../lib/bot/fleet-local.js";
3
3
  import { installedFleetPython } from "../lib/bot/fleet-python.js";
4
- import { type FleetSignInHereDeps, type FleetSignInProvider } from "../lib/bot/legacy-provider-login.js";
5
- import type { LegacyProviderLogin } from "../lib/bot/legacy-convert.js";
4
+ import { type BotLoginScope, type FleetSignInHereDeps, type FleetSignInProvider, type GrokLoginProbeAsyncDeps, type GrokSiblingLogin } from "../lib/bot/legacy-provider-login.js";
6
5
  export type FleetProgressMode = "text" | "json" | "silent";
7
6
  interface ProgressOutput {
8
7
  write(text: string): void;
@@ -48,19 +47,33 @@ export interface BrainSignInStatus {
48
47
  provider: BrainProvider;
49
48
  signedIn: boolean;
50
49
  source: BrainLoginSource | null;
50
+ /**
51
+ * Grok only: another bot on this computer holds, or may hold, a Grok
52
+ * sign-in of a different or unknown company, so none is reused. The text
53
+ * says which.
54
+ */
55
+ blocked?: string;
51
56
  }
52
57
  export interface BrainSignInDeps extends FleetSignInHereDeps {
53
58
  target?: () => Promise<FleetLocalTargetRelease>;
54
59
  claudeLogin?: () => ClaudeLoginCheck;
55
- grokSiblings?: () => Promise<LegacyProviderLogin>;
60
+ grokSiblings?: () => Promise<GrokSiblingLogin>;
61
+ /** Seams for the scan of the other Fleet bots' Grok sign-ins. */
62
+ grokProbe?: GrokLoginProbeAsyncDeps;
56
63
  }
57
64
  export declare function parseBrainProvider(value: string): BrainProvider;
58
65
  export declare function parseFleetSignInProvider(value: string): FleetSignInProvider;
59
66
  export declare function brainSignInStatus(provider: BrainProvider, deps?: BrainSignInDeps): Promise<BrainSignInStatus>;
67
+ /** Which bot auth-status and sign-in answer for: a company bot of --company, else a personal bot, as create defaults. */
68
+ export interface BrainScopeOptions {
69
+ kind?: string;
70
+ company?: string[];
71
+ }
72
+ export declare function brainLoginScope(opts: BrainScopeOptions): BotLoginScope;
60
73
  export declare function runBotAuthStatus(opts: {
61
74
  provider: string;
62
75
  json?: boolean;
63
- }, deps?: BrainSignInDeps): Promise<(BrainSignInStatus & {
76
+ } & BrainScopeOptions, deps?: BrainSignInDeps): Promise<(BrainSignInStatus & {
64
77
  ok: true;
65
78
  }) | {
66
79
  ok: false;
@@ -87,7 +100,7 @@ export declare function runBotSignIn(opts: {
87
100
  provider: string;
88
101
  json?: boolean;
89
102
  browser?: boolean;
90
- }, deps?: BotSignInDeps): Promise<BrainSignInStatus & {
103
+ } & BrainScopeOptions, rawDeps?: BotSignInDeps): Promise<BrainSignInStatus & {
91
104
  ok: boolean;
92
105
  reason?: string;
93
106
  }>;
@@ -1,6 +1,5 @@
1
1
  import { spawn } from "node:child_process";
2
2
  import * as fs from "node:fs";
3
- import * as os from "node:os";
4
3
  import * as path from "node:path";
5
4
  import { stripVTControlCharacters } from "node:util";
6
5
  import chalk from "chalk";
@@ -11,7 +10,8 @@ import { cachedFleetLocalTargetRelease, ensureFleetRuntimeInstalled, fleetLocalD
11
10
  import { installedFleetPython } from "../lib/bot/fleet-python.js";
12
11
  import { createInstallProgressTracker } from "../lib/bot/install-progress.js";
13
12
  import { botCreateEstimate } from "../lib/bot/readiness.js";
14
- import { fleetSignInReusableHere, grokCliLoginReadable, grokLoginReadableHereAsync, } from "../lib/bot/legacy-provider-login.js";
13
+ import { fleetSignInReusableHere, grokLoginReadableHereAsync, newBotLoginScope, } from "../lib/bot/legacy-provider-login.js";
14
+ import { normalizeBotCompanies } from "../lib/bot/config.js";
15
15
  function megabytes(bytes) {
16
16
  return `${(bytes / 1_048_576).toFixed(1)} MB`;
17
17
  }
@@ -182,20 +182,29 @@ export async function brainSignInStatus(provider, deps = {}) {
182
182
  }
183
183
  let grok = deps.grok;
184
184
  if (provider === "grok" && !grok) {
185
- const cli = (deps.grokCli ?? (() => grokCliLoginReadable(deps.homedir ?? os.homedir(), deps.env ?? process.env)))();
186
- if (!(grokCliImport && cli.readable)) {
187
- const siblings = await (deps.grokSiblings ?? (() => grokLoginReadableHereAsync("")))();
188
- grok = () => siblings;
189
- }
185
+ // Always asked, even with a Grok CLI login: the helper copies another bot's login before it reads the Grok CLI's.
186
+ const siblings = await (deps.grokSiblings ?? (() => grokLoginReadableHereAsync("", { ...deps.grokProbe, scope: deps.scope ?? null })))();
187
+ grok = () => siblings;
190
188
  }
191
- const { target: _target, claudeLogin: _claudeLogin, grokSiblings: _grokSiblings, ...hereDeps } = deps;
189
+ const { target: _target, claudeLogin: _claudeLogin, grokSiblings: _grokSiblings, grokProbe: _grokProbe, ...hereDeps } = deps;
192
190
  const login = fleetSignInReusableHere(provider, { ...hereDeps, ...(grok ? { grok } : {}), ...(grokCliImport !== undefined ? { grokCliImport } : {}) });
193
191
  if (!login.readable)
194
- return { provider, signedIn: false, source: null };
192
+ return { provider, signedIn: false, source: null, ...(login.blocked ? { blocked: login.detail } : {}) };
195
193
  const source = provider === "chatgpt" ? "codex-cli" : login.detail.startsWith("Grok CLI login") ? "grok-cli" : "fleet-bot";
196
194
  return { provider, signedIn: true, source };
197
195
  }
198
196
  const BRAIN_NAMES = { claude: "Claude", chatgpt: "ChatGPT", grok: "Grok" };
197
+ export function brainLoginScope(opts) {
198
+ const kind = opts.kind?.trim().toLowerCase();
199
+ if (kind !== undefined && kind !== "personal" && kind !== "company") {
200
+ throw Object.assign(new Error(`--kind must be personal or company, not ${opts.kind}.`), { expected: true });
201
+ }
202
+ const companies = normalizeBotCompanies(opts.company);
203
+ if (kind === "personal" && companies.length) {
204
+ throw Object.assign(new Error("--company only applies to a company bot; drop it or use --kind company."), { expected: true });
205
+ }
206
+ return newBotLoginScope(kind === "company" || companies.length ? "company" : "personal", companies);
207
+ }
199
208
  export async function runBotAuthStatus(opts, deps = {}) {
200
209
  let provider;
201
210
  try {
@@ -209,7 +218,7 @@ export async function runBotAuthStatus(opts, deps = {}) {
209
218
  process.exitCode = 1;
210
219
  return failure;
211
220
  }
212
- const status = { ...(await brainSignInStatus(provider, deps)), ok: true };
221
+ const status = { ...(await brainSignInStatus(provider, { scope: brainLoginScope(opts), ...deps })), ok: true };
213
222
  if (opts.json) {
214
223
  console.log(JSON.stringify(status));
215
224
  return status;
@@ -217,7 +226,9 @@ export async function runBotAuthStatus(opts, deps = {}) {
217
226
  const name = BRAIN_NAMES[status.provider];
218
227
  console.log(status.signedIn
219
228
  ? `A new ${name} bot signs in with the ${name} login already on this computer.`
220
- : `A new ${name} bot needs a ${name} sign-in first (hq bot sign-in --provider ${status.provider}).`);
229
+ : status.blocked
230
+ ? `A new ${name} bot cannot reuse a ${name} login on this computer: ${status.blocked}.`
231
+ : `A new ${name} bot needs a ${name} sign-in first (hq bot sign-in --provider ${status.provider}).`);
221
232
  return status;
222
233
  }
223
234
  function onTerminate(cancel) {
@@ -302,8 +313,9 @@ function forEachLine(stream, onLine) {
302
313
  stream.on("error", () => resolve());
303
314
  });
304
315
  }
305
- export async function runBotSignIn(opts, deps = {}) {
316
+ export async function runBotSignIn(opts, rawDeps = {}) {
306
317
  const brain = parseBrainProvider(opts.provider);
318
+ const deps = { scope: brainLoginScope(opts), ...rawDeps };
307
319
  const emit = deps.emit ?? ((line) => { process.stdout.write(`${line}\n`); });
308
320
  const write = deps.write ?? ((text) => { process.stderr.write(text); });
309
321
  const finish = (result) => {
@@ -321,6 +333,11 @@ export async function runBotSignIn(opts, deps = {}) {
321
333
  const before = await brainSignInStatus(brain, deps);
322
334
  if (before.signedIn)
323
335
  return finish({ ...before, ok: true });
336
+ if (before.blocked) {
337
+ // A Grok CLI login would not help: the helper copies the other bot's login first.
338
+ process.exitCode = 1;
339
+ return finish({ ...before, ok: false, reason: "grok-login-held-back" });
340
+ }
324
341
  const { cli, browser, device } = BRAIN_SIGN_IN_CLI[brain];
325
342
  const args = opts.browser === false ? device : browser;
326
343
  const executable = (deps.findCli ?? ((name) => findCliOnPath(name)))(cli);
@@ -1,4 +1,6 @@
1
1
  import { type LegacyMoveState, type LegacyProviderLoginProbe } from "../lib/bot/legacy-convert.js";
2
+ import { type GrokSiblingLogin } from "../lib/bot/legacy-provider-login.js";
3
+ import { type BotSignalsRuntimeSetting } from "../lib/bot/config.js";
2
4
  import { type ClaudeLoginNow, type SignalsClaudeLogin } from "../lib/hot-channels/signals-claude-login.js";
3
5
  import { Command } from "commander";
4
6
  import { type ExecutiveBot } from "../lib/bot/executive.js";
@@ -73,10 +75,24 @@ export interface BotRow {
73
75
  signInCommand: string;
74
76
  /**
75
77
  * The Claude Code login the hot-channel signals pass needs, which can differ
76
- * from the bot's own runtime login (a Codex bot still runs signals on
77
- * Claude Code). Only for a bot with the hot-signal-sync job; null otherwise.
78
+ * from the bot's own runtime login (a Codex bot runs signals on Claude Code
79
+ * until it opts in with `hq bot set <name> --signals-runtime bot`). Only for
80
+ * a bot with the hot-signal-sync job whose signals run on Claude Code; null
81
+ * otherwise, including a Codex bot whose signals run on Codex.
78
82
  */
79
83
  signalsClaudeSignIn: SignalsClaudeSignIn | null;
84
+ /**
85
+ * The tool the hot-channel signals pass runs on for this bot: "claude", or
86
+ * "codex" for a Codex bot that opted in (its sign-in is `runtimeSignedIn`).
87
+ * Null for a bot without the hot-signal-sync job.
88
+ */
89
+ signalsRuntime: "claude" | "codex" | null;
90
+ /**
91
+ * When `signalsRuntime` is "codex": the CODEX_HOME the pass uses, from the
92
+ * same function the pass reads (signalsCodexLogin), so status and pass name
93
+ * one login. Null otherwise, or when that login is not usable.
94
+ */
95
+ signalsCodexHome: string | null;
80
96
  /**
81
97
  * Set when the bot cannot run until its model provider is signed in, on any
82
98
  * engine: a Fleet bot never signed in or whose last turn failed on auth, a
@@ -209,6 +225,17 @@ export declare const signalsClaudeSeams: {
209
225
  export declare function signalsClaudeSignInFor(dir: string, fleet: boolean, record?: SignalsClaudeLogin | null, live?: ClaudeLoginNow | null): SignalsClaudeSignIn | null;
210
226
  /** The status lines for the Claude Code login signals needs: the answer first, the last signals pass as context. */
211
227
  export declare function signalsClaudeSignInLines(s: SignalsClaudeSignIn): string[];
228
+ /**
229
+ * The tool the signals pass runs on for a bot with the hot-signal-sync job
230
+ * (null without the job): the Executive bot's choice, as in the pass.
231
+ */
232
+ export declare function signalsRuntimeFor(dir: string, fleet: boolean): "claude" | "codex" | null;
233
+ /** The Codex login the pass uses when signals run on Codex (signalsCodexLogin), else null. */
234
+ export declare function signalsCodexHomeFor(dir: string, fleet: boolean): string | null;
235
+ /** Why the Executive bot's Codex login cannot run signals, when signals are set to run on it; else null. */
236
+ export declare function signalsCodexRefusalFor(dir: string, fleet: boolean): string | null;
237
+ /** The status line for a bot whose signals run on its own Codex: the bot's own sign-in answer. */
238
+ export declare function signalsCodexRuntimeLine(companies: readonly string[], runtimeSignedIn: boolean | null): string;
212
239
  export interface BrainSignIn {
213
240
  provider: BotRuntimeId;
214
241
  needed: true;
@@ -256,6 +283,8 @@ export declare const botCreateSeams: {
256
283
  claudeLogin: () => ClaudeLoginCheck;
257
284
  brainSignIn: typeof brainSignInStatus;
258
285
  importBrainLogin: (agentUid: string, runtime: "codex" | "grok") => void;
286
+ /** The same question the helper call asks itself: would a Grok account sign-in for this bot copy a login it may not share? */
287
+ grokSiblingLogin: (config: BotConfig) => GrokSiblingLogin;
259
288
  runtimeStatus: typeof fleetRuntimeStatus;
260
289
  installRuntime: typeof ensureFleetRuntimeInstalled;
261
290
  waitForReady: typeof waitForGatewayReady;
@@ -359,6 +388,8 @@ export interface BotSetOptions {
359
388
  model?: string;
360
389
  effort?: string;
361
390
  displayName?: string;
391
+ /** "bot": a Codex bot runs hot-channel signals on its own Codex; "claude" (the default): on Claude Code. */
392
+ signalsRuntime?: string;
362
393
  json?: boolean;
363
394
  }
364
395
  export interface BotSetDeps {
@@ -382,6 +413,12 @@ export interface BotSetDeps {
382
413
  };
383
414
  }
384
415
  export declare function runBotSet(nameArg: string, opts: BotSetOptions, deps?: BotSetDeps): Promise<void>;
416
+ /**
417
+ * `--signals-runtime`: "bot" only for a Codex bot (a Claude bot already runs
418
+ * signals on Claude Code, and Grok has no isolated signals call yet);
419
+ * "claude" for any bot.
420
+ */
421
+ export declare function validateSignalsRuntimeSetting(runtime: BotRuntimeId, value: string): BotSignalsRuntimeSetting;
385
422
  /** switch-account's test turn: short, so probe, stop, start and a rollback fit the desktop's 5-minute budget. */
386
423
  export declare const SWITCH_ACCOUNT_PROBE_TIMEOUT_MS = 60000;
387
424
  export interface BotSwitchAccountOptions {