@indigoai-us/hq-cli 5.345.219 → 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 (199) hide show
  1. package/CHANGELOG.md +170 -0
  2. package/dist/command-catalog.generated.d.ts +169 -3
  3. package/dist/command-catalog.generated.js +206 -3
  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 +85 -0
  8. package/dist/commands/bot.js +245 -16
  9. package/dist/commands/cloud.d.ts +16 -0
  10. package/dist/commands/cloud.js +112 -102
  11. package/dist/commands/core-checkpoint-native.d.ts +13 -0
  12. package/dist/commands/core-checkpoint-native.js +167 -52
  13. package/dist/commands/core-hook-registration-plan.js +5 -4
  14. package/dist/commands/core-stop-autosave.d.ts +21 -0
  15. package/dist/commands/core-stop-autosave.js +300 -0
  16. package/dist/commands/core.js +2 -0
  17. package/dist/commands/daemon.d.ts +5 -0
  18. package/dist/commands/daemon.js +52 -9
  19. package/dist/commands/doctor-usage.d.ts +5 -0
  20. package/dist/commands/doctor-usage.js +25 -0
  21. package/dist/commands/env.d.ts +49 -4
  22. package/dist/commands/env.js +355 -5
  23. package/dist/commands/integrations.js +84 -3
  24. package/dist/commands/lanes-shared.d.ts +3 -0
  25. package/dist/commands/lanes.d.ts +3 -0
  26. package/dist/commands/lanes.js +87 -3
  27. package/dist/commands/packs.js +23 -0
  28. package/dist/commands/pkg-update.d.ts +6 -0
  29. package/dist/commands/pkg-update.js +15 -7
  30. package/dist/commands/run.js +55 -45
  31. package/dist/commands/sources.js +4 -3
  32. package/dist/commands/sync-core.d.ts +1 -0
  33. package/dist/commands/sync-core.js +77 -3
  34. package/dist/commands/whoami.js +96 -80
  35. package/dist/lib/bot/config.d.ts +17 -0
  36. package/dist/lib/bot/config.js +13 -0
  37. package/dist/lib/bot/fleet-cron.js +29 -4
  38. package/dist/lib/bot/fleet-local.d.ts +30 -2
  39. package/dist/lib/bot/fleet-local.js +60 -1
  40. package/dist/lib/bot/grok-login-scope.d.ts +36 -0
  41. package/dist/lib/bot/grok-login-scope.js +93 -0
  42. package/dist/lib/bot/inflight.d.ts +9 -0
  43. package/dist/lib/bot/jobs/hot-signal-sync.d.ts +51 -0
  44. package/dist/lib/bot/jobs/hot-signal-sync.js +90 -9
  45. package/dist/lib/bot/legacy-provider-login.d.ts +32 -9
  46. package/dist/lib/bot/legacy-provider-login.js +28 -22
  47. package/dist/lib/bot/run.d.ts +29 -5
  48. package/dist/lib/bot/run.js +203 -1
  49. package/dist/lib/bot/runtime-sign-in-check.js +6 -1
  50. package/dist/lib/bot/runtime-sign-in.d.ts +2 -0
  51. package/dist/lib/bot/signals-try-now.d.ts +76 -0
  52. package/dist/lib/bot/signals-try-now.js +111 -0
  53. package/dist/lib/capacity/collectors/claude-oauth.d.ts +22 -3
  54. package/dist/lib/capacity/collectors/claude-oauth.js +78 -22
  55. package/dist/lib/capacity/scheduler.d.ts +8 -0
  56. package/dist/lib/capacity/scheduler.js +5 -2
  57. package/dist/lib/core-utils/sentry-report.js +2 -0
  58. package/dist/lib/daemon/machine-checks.d.ts +22 -1
  59. package/dist/lib/daemon/machine-checks.js +54 -12
  60. package/dist/lib/daemon/run.js +71 -8
  61. package/dist/lib/daemon/runtime-notifications.d.ts +7 -0
  62. package/dist/lib/daemon/runtime-notifications.js +50 -0
  63. package/dist/lib/daemon/stop-autosave-lock.d.ts +19 -0
  64. package/dist/lib/daemon/stop-autosave-lock.js +166 -0
  65. package/dist/lib/daemon/stop-autosave.d.ts +28 -0
  66. package/dist/lib/daemon/stop-autosave.js +111 -0
  67. package/dist/lib/daemon/stop-diagnostics.d.ts +11 -0
  68. package/dist/lib/daemon/stop-diagnostics.js +136 -0
  69. package/dist/lib/daemon/stop-job-executor.d.ts +19 -0
  70. package/dist/lib/daemon/stop-job-executor.js +126 -0
  71. package/dist/lib/daemon/stop-jobs.d.ts +93 -0
  72. package/dist/lib/daemon/stop-jobs.js +599 -0
  73. package/dist/lib/doctor/checks/fleet-hook-core.d.ts +9 -1
  74. package/dist/lib/doctor/checks/fleet-hook-core.js +39 -15
  75. package/dist/lib/doctor/checks/host-core.js +1 -1
  76. package/dist/lib/environment/access-probes.d.ts +234 -0
  77. package/dist/lib/environment/access-probes.js +918 -0
  78. package/dist/lib/environment/profile.d.ts +15 -2
  79. package/dist/lib/environment/profile.js +55 -20
  80. package/dist/lib/environment/rfc3339.d.ts +8 -0
  81. package/dist/lib/environment/rfc3339.js +26 -0
  82. package/dist/lib/environment/work-requirements.d.ts +169 -0
  83. package/dist/lib/environment/work-requirements.js +389 -0
  84. package/dist/lib/hook-engine/coverage.d.ts +137 -7
  85. package/dist/lib/hook-engine/coverage.js +1424 -4
  86. package/dist/lib/hook-engine/fleet-registration.d.ts +17 -5
  87. package/dist/lib/hook-engine/fleet-registration.js +53 -17
  88. package/dist/lib/hook-engine/git-stop-config.json +513 -0
  89. package/dist/lib/hook-engine/native-stop-compatibility.json +311 -0
  90. package/dist/lib/hook-engine/reconcile.js +2 -2
  91. package/dist/lib/hot-channels/alert.d.ts +10 -1
  92. package/dist/lib/hot-channels/alert.js +38 -8
  93. package/dist/lib/hot-channels/signals-claude-login.d.ts +53 -0
  94. package/dist/lib/hot-channels/signals-claude-login.js +96 -0
  95. package/dist/lib/hot-channels/signals-pass.d.ts +143 -17
  96. package/dist/lib/hot-channels/signals-pass.js +324 -17
  97. package/dist/lib/hot-channels/signals-runtime.d.ts +30 -0
  98. package/dist/lib/hot-channels/signals-runtime.js +82 -0
  99. package/dist/lib/install/hook-target.js +1 -1
  100. package/dist/lib/lanes/host-capacity.d.ts +26 -2
  101. package/dist/lib/lanes/host-capacity.js +17 -2
  102. package/dist/lib/lanes/host-compute.d.ts +90 -0
  103. package/dist/lib/lanes/host-compute.js +185 -0
  104. package/dist/lib/lanes/index.d.ts +2 -0
  105. package/dist/lib/lanes/index.js +1 -0
  106. package/dist/lib/lanes/reconcile.js +22 -1
  107. package/dist/lib/lanes/resource-usage.d.ts +155 -0
  108. package/dist/lib/lanes/resource-usage.js +589 -0
  109. package/dist/lib/lanes/run-size.d.ts +46 -0
  110. package/dist/lib/lanes/run-size.js +197 -0
  111. package/dist/lib/lanes/store.js +27 -0
  112. package/dist/lib/lanes/throttle.d.ts +36 -1
  113. package/dist/lib/lanes/throttle.js +47 -10
  114. package/dist/lib/lanes/types.d.ts +40 -0
  115. package/dist/lib/lanes/types.js +2 -2
  116. package/dist/lib/lanes/watcher.js +13 -4
  117. package/dist/lib/lanes/worker-process.d.ts +25 -2
  118. package/dist/lib/lanes/worker-process.js +71 -19
  119. package/dist/lib/placement/match.d.ts +192 -0
  120. package/dist/lib/placement/match.js +667 -0
  121. package/dist/lib/safe-store.d.ts +14 -0
  122. package/dist/lib/safe-store.js +77 -4
  123. package/dist/lib/search-index/index.d.ts +88 -4
  124. package/dist/lib/search-index/index.js +299 -25
  125. package/dist/lib/search-index/max-doc-bytes.d.ts +17 -6
  126. package/dist/lib/search-index/max-doc-bytes.js +48 -23
  127. package/dist/lib/signals/codex-lockdown.d.ts +79 -0
  128. package/dist/lib/signals/codex-lockdown.js +271 -0
  129. package/dist/lib/signals/codex-login.d.ts +37 -0
  130. package/dist/lib/signals/codex-login.js +83 -0
  131. package/dist/lib/signals/engine.d.ts +28 -0
  132. package/dist/lib/signals/engine.js +77 -0
  133. package/dist/lib/signals/reply.d.ts +48 -0
  134. package/dist/lib/signals/reply.js +94 -12
  135. package/dist/lib/signals/run-record.js +6 -1
  136. package/dist/lib/signals/settings.d.ts +5 -0
  137. package/dist/lib/signals/settings.js +2 -0
  138. package/dist/lib/signals/steps/adapters.js +6 -0
  139. package/dist/lib/signals/steps/extract.d.ts +135 -12
  140. package/dist/lib/signals/steps/extract.js +416 -84
  141. package/dist/lib/signals/steps/types.d.ts +21 -0
  142. package/dist/lib/sync-core/engine-home.d.ts +41 -2
  143. package/dist/lib/sync-core/engine-home.js +132 -19
  144. package/dist/lib/sync-core/reconcile.js +1 -1
  145. package/dist/lib/sync-core/release-compare.d.ts +7 -0
  146. package/dist/lib/sync-core/release-compare.js +16 -0
  147. package/dist/lib/sync-core/release.d.ts +2 -1
  148. package/dist/lib/sync-core/release.js +2 -10
  149. package/dist/lib/sync-core/rollout-state.d.ts +2 -1
  150. package/dist/lib/sync-core/rollout-state.js +5 -2
  151. package/dist/lib/sync-core/vault-uid.d.ts +2 -0
  152. package/dist/lib/sync-core/vault-uid.js +4 -0
  153. package/dist/run/schema-env-overrides.d.ts +24 -0
  154. package/dist/run/schema-env-overrides.js +72 -0
  155. package/dist/schemas/hq-work-requirements.v1.schema.json +145 -0
  156. package/dist/utils/auth-session-check.d.ts +16 -0
  157. package/dist/utils/auth-session-check.js +16 -0
  158. package/dist/utils/client-health-contract.d.ts +6 -0
  159. package/dist/utils/client-health-contract.js +13 -0
  160. package/dist/utils/client-health.d.ts +7 -0
  161. package/dist/utils/client-health.js +22 -1
  162. package/dist/utils/command-usage.d.ts +40 -0
  163. package/dist/utils/command-usage.js +61 -0
  164. package/dist/utils/duplicate-command-usage.d.ts +72 -0
  165. package/dist/utils/duplicate-command-usage.js +125 -0
  166. package/dist/utils/host-registration.d.ts +1 -1
  167. package/dist/utils/host-registration.js +6 -1
  168. package/dist/utils/resident-package-preload.js +4 -0
  169. package/dist/utils/sentry-fingerprint.js +9 -0
  170. package/dist/utils/windows-bash.d.ts +2 -0
  171. package/dist/utils/windows-bash.js +2 -1
  172. package/package.json +15 -10
  173. package/scripts/bench-core-compare.mjs +313 -0
  174. package/scripts/bench-core.mjs +399 -12
  175. package/scripts/check-function-manifest.mjs +121 -7
  176. package/dist/commands/__fixtures__/access-vault.d.ts +0 -95
  177. package/dist/commands/__fixtures__/access-vault.js +0 -166
  178. package/dist/commands/__fixtures__/make-tar.d.ts +0 -38
  179. package/dist/commands/__fixtures__/make-tar.js +0 -102
  180. package/dist/commands/secrets-public-types.test-d.d.ts +0 -2
  181. package/dist/commands/secrets-public-types.test-d.js +0 -18
  182. package/dist/lib/decisions/fixtures/us001.d.ts +0 -137
  183. package/dist/lib/decisions/fixtures/us001.js +0 -21
  184. package/dist/lib/doctor/__testing__/fake-hq-tree.d.ts +0 -226
  185. package/dist/lib/doctor/__testing__/fake-hq-tree.js +0 -408
  186. package/dist/lib/doctor/__testing__/run-doctor.d.ts +0 -8
  187. package/dist/lib/doctor/__testing__/run-doctor.js +0 -69
  188. package/dist/lib/fingerprint/fixtures.d.ts +0 -19
  189. package/dist/lib/fingerprint/fixtures.js +0 -61
  190. package/dist/lib/hot-channels/adapters/__fixtures__/dummy.d.ts +0 -33
  191. package/dist/lib/hot-channels/adapters/__fixtures__/dummy.js +0 -53
  192. package/dist/lib/hot-channels/adapters/__fixtures__/meeting-providers.d.ts +0 -38
  193. package/dist/lib/hot-channels/adapters/__fixtures__/meeting-providers.js +0 -64
  194. package/dist/lib/mesh/live/daemon/mqtt-events.test-d.d.ts +0 -2
  195. package/dist/lib/mesh/live/daemon/mqtt-events.test-d.js +0 -10
  196. package/dist/lib/test-utils/isolated-flag-company-context.d.ts +0 -3
  197. package/dist/lib/test-utils/isolated-flag-company-context.js +0 -18
  198. package/scripts/hook-engine-manifest.mjs +0 -22
  199. package/scripts/mesh-daemon-if-stale.mjs +0 -20
@@ -3,9 +3,26 @@ import * as fs from 'node:fs';
3
3
  import * as path from 'node:path';
4
4
  import { load } from 'js-yaml';
5
5
  import { coreNextKillReason, missingEvaluators } from '../../../utils/host-registration.js';
6
- import { FLEET_EVENTS, literalArgv, fallbackProblem, inspectFleetEngine } from '../../hook-engine/fleet-registration.js';
6
+ import { FLEET_ADAPTERS, FLEET_EVENTS, isFleetHost, literalArgv, fallbackProblem, inspectFleetEngine } from '../../hook-engine/fleet-registration.js';
7
7
  import { uncoveredHooks } from '../../hook-engine/coverage.js';
8
- export function fleetHookCoreResults(home, env, inspect = (engine) => inspectFleetEngine(engine, home)) {
8
+ /** The Fleet host whose shell adapter `argv` runs, if any. */
9
+ function shellHost(argv) {
10
+ if (argv[1] === 'run')
11
+ return undefined;
12
+ for (const host of Object.keys(FLEET_ADAPTERS)) {
13
+ if (argv.some(arg => path.basename(arg) === FLEET_ADAPTERS[host]))
14
+ return host;
15
+ }
16
+ return undefined;
17
+ }
18
+ /**
19
+ * One result per hq-fleet profile: per event, which core the bot runtime uses
20
+ * (`native`, `shell`, or `shell fallback` under a kill switch) and on which
21
+ * host (`fleet-local` or `agents-v2`). A native entry passes only when the
22
+ * engine advertises its host and covers every old hook for the event, and its
23
+ * fallback is that host's exact adapter command.
24
+ */
25
+ export function fleetHookCoreResults(home, env, inspect = (engine, host) => inspectFleetEngine(engine, home, undefined, undefined, undefined, host)) {
9
26
  const base = env.HQ_FLEET_HOME?.trim() || path.join(home, '.hq-fleet');
10
27
  let profiles;
11
28
  if (fs.existsSync(path.join(base, 'config.yaml')))
@@ -28,23 +45,29 @@ export function fleetHookCoreResults(home, env, inspect = (engine) => inspectFle
28
45
  continue;
29
46
  const document = load(fs.readFileSync(file, 'utf8'));
30
47
  const cores = {};
48
+ const hosts = {};
31
49
  const problems = [];
32
50
  for (const [event, entries] of Object.entries(document?.hooks ?? {})) {
33
51
  if (!Array.isArray(entries))
34
52
  continue;
35
53
  const commands = entries.map(entry => literalArgv(String(entry?.command ?? ''))).filter((argv) => argv !== null);
36
- const native = commands.filter(argv => path.basename(argv[0] ?? '') === 'hq-hook' && argv[1] === 'run' && argv[2] === '--host' && ['fleet-local', 'agents-v2'].includes(argv[3] ?? ''));
37
- const shell = commands.filter(argv => argv.some(arg => path.basename(arg) === 'hq-fleet-local-hook-adapter.sh') && argv[1] !== 'run');
54
+ const native = commands.filter(argv => path.basename(argv[0] ?? '') === 'hq-hook' && argv[1] === 'run' && argv[2] === '--host' && isFleetHost(argv[3]));
55
+ const shell = commands.filter(argv => shellHost(argv) !== undefined);
38
56
  if (!native.length && !shell.length)
39
57
  continue;
40
58
  cores[event] = native.length ? 'native' : 'shell';
41
- if (native.length && (shell.length || native.length > 1))
59
+ const seen = [...new Set([...native.map(argv => argv[3]), ...shell.map(argv => shellHost(argv))])];
60
+ hosts[event] = seen[0];
61
+ // fleet-local keeps its rule (a native entry alongside any other); any
62
+ // second entry where agents-v2 is involved is a duplicate too, so a
63
+ // toggle that leaves two adapter entries fails.
64
+ const duplicate = native.length ? shell.length > 0 || native.length > 1 : seen.includes('agents-v2') && shell.length > 1;
65
+ if (duplicate)
42
66
  problems.push(`${event}: duplicate hook registrations`);
67
+ if (seen.length > 1)
68
+ problems.push(`${event}: registrations for more than one fleet host (${seen.join(', ')})`);
43
69
  for (const argv of native) {
44
- if (argv[3] === 'agents-v2') {
45
- problems.push(`${event}: agents-v2 native registration is unsupported`);
46
- continue;
47
- }
70
+ const host = argv[3];
48
71
  const value = (flag) => { const index = argv.indexOf(flag); return index < 0 ? undefined : argv[index + 1]; };
49
72
  const killed = coreNextKillReason(home, env);
50
73
  if (killed) {
@@ -58,7 +81,7 @@ export function fleetHookCoreResults(home, env, inspect = (engine) => inspectFle
58
81
  catch {
59
82
  fallback = null;
60
83
  }
61
- const invalid = fallbackProblem(fallback);
84
+ const invalid = fallbackProblem(fallback, host, event);
62
85
  if (invalid)
63
86
  problems.push(`${event}: ${invalid}`);
64
87
  if (argv[4] !== event || !path.isAbsolute(value('--hq-root') ?? '')) {
@@ -66,15 +89,16 @@ export function fleetHookCoreResults(home, env, inspect = (engine) => inspectFle
66
89
  continue;
67
90
  }
68
91
  const engine = argv[0];
69
- let caps = cache.get(engine);
92
+ const key = `${host}\0${engine}`;
93
+ let caps = cache.get(key);
70
94
  if (!caps) {
71
95
  try {
72
- caps = inspect(engine);
96
+ caps = inspect(engine, host);
73
97
  }
74
98
  catch (error) {
75
99
  caps = error;
76
100
  }
77
- cache.set(engine, caps);
101
+ cache.set(key, caps);
78
102
  }
79
103
  if (caps instanceof Error) {
80
104
  problems.push(`${event}: ${caps.message}`);
@@ -85,14 +109,14 @@ export function fleetHookCoreResults(home, env, inspect = (engine) => inspectFle
85
109
  if (missing === null || missing.length)
86
110
  problems.push(`${event}: required evaluators are missing`);
87
111
  if (canonical) {
88
- const left = uncoveredHooks(value('--hq-root'), 'fleet-local', canonical, caps.covers);
112
+ const left = uncoveredHooks(value('--hq-root'), host, canonical, caps.covers, env);
89
113
  if (left.length)
90
114
  problems.push(`${event}: uncovered hooks: ${left.join(', ')}`);
91
115
  }
92
116
  }
93
117
  }
94
118
  results.push({ status: problems.length ? 'FAIL' : 'PASS', checkId: `fleet-hook-core:${name}`, target: file,
95
- message: `Fleet profile ${name}: ${problems.length ? problems.join('; ') : Object.entries(cores).map(([event, core]) => `${event}=${core}`).join(', ') || 'no HQ hook registrations'}.`, details: { cores, problems } });
119
+ message: `Fleet profile ${name}: ${problems.length ? problems.join('; ') : Object.entries(cores).map(([event, core]) => `${event}=${core}${hosts[event] === 'agents-v2' ? ' (agents-v2)' : ''}`).join(', ') || 'no HQ hook registrations'}.`, details: { cores, problems, ...(Object.keys(hosts).length ? { hosts } : {}) } });
96
120
  }
97
121
  catch {
98
122
  results.push({ status: 'WARN', checkId: `fleet-hook-core:${name}`, target: file, message: `Fleet profile ${name} hook configuration could not be read.` });
@@ -139,7 +139,7 @@ export function hostCoreResults(root, options = {}) {
139
139
  return { status: 'PASS', reason: `the new core has ${REQUIRED_EVALUATORS[event].join(', ')}` };
140
140
  };
141
141
  /** Old-dispatcher hooks for `event` on `host` that the engine's report does not cover. */
142
- const uncovered = (caps, host, event) => uncoveredHooks(root, host, event, caps.covers);
142
+ const uncovered = (caps, host, event) => uncoveredHooks(root, host, event, caps.covers, env);
143
143
  const listed = (hooks) => (hooks.length > 6 ? `${hooks.slice(0, 6).join(', ')} and ${hooks.length - 6} more` : hooks.join(', '));
144
144
  const oldCore = (event, host) => {
145
145
  if (!flagOn)
@@ -0,0 +1,234 @@
1
+ /**
2
+ * Access probes for `hq env probe` (PS-009): run each probe by name and
3
+ * record the result as a `readings.access` entry of hq-environment-profile.v1.
4
+ *
5
+ * Probes:
6
+ *
7
+ * vault:<company> a vault listing of companies/<company>/
8
+ * answers under this identity (`hq files browse`)
9
+ * repo:<name> the local checkout's origin answers
10
+ * `git ls-remote` with this machine's git login
11
+ * secret:<NAME>.exists the name exists in the company vault (HEAD,
12
+ * `hq secrets exists`)
13
+ * secret:<NAME>.resolvable this identity can resolve the value: it is
14
+ * injected by `hq secrets exec` into a child
15
+ * that checks only that the variable is non-empty
16
+ * integration:<slug> the app is connected and shared with this
17
+ * identity (`hq integrations list --usable`)
18
+ * data:<path> a path under the HQ root is present and not empty
19
+ * identity:agent/<check>, ... with --agent: the checks of `hq agent probe`
20
+ *
21
+ * The two secret readings carry the suffixes `.exists` and `.resolvable`. The
22
+ * schema's probe-name rule allows `.`, and a secret name cannot contain one,
23
+ * so the suffix never collides with a name.
24
+ *
25
+ * The secret value never reaches this process. `hq secrets exec` fetches it
26
+ * (and keeps its usual encrypted cache) and injects it into a grandchild that
27
+ * exits 0 or UNRESOLVED_EXIT and prints nothing. The exec child's stdout is
28
+ * discarded and its stderr is only matched against known failure phrases,
29
+ * after every occurrence of the secret name is removed; it is never copied
30
+ * into a reason. A reason is one of the fixed sentences in this file plus
31
+ * names the caller gave, and it is withheld if it looks like a credential.
32
+ */
33
+ import type { EnvironmentAccessProbe } from "./profile.js";
34
+ /** The check child exits with this code when the variable is missing or empty. */
35
+ export declare const UNRESOLVED_EXIT = 87;
36
+ /**
37
+ * Runs in the grandchild under `hq secrets exec`. It reads the variable named
38
+ * by its first argument and exits by its length only; it writes nothing.
39
+ */
40
+ export declare const RESOLVE_CHECK_SCRIPT = "const v=process.env[process.argv[1]];process.exit(typeof v===\"string\"&&v.length>0?0:87);";
41
+ /** Same rule as `hq secrets exec --only`. */
42
+ export declare const SECRET_NAME_PATTERN: RegExp;
43
+ export declare const COMPANY_SLUG_PATTERN: RegExp;
44
+ export declare const REPO_NAME_PATTERN: RegExp;
45
+ export declare const INTEGRATION_SLUG_PATTERN: RegExp;
46
+ /** A relative path of plain segments; the schema's probe-name rule allows no more. */
47
+ export declare const DATA_PATH_PATTERN: RegExp;
48
+ export declare const SECRET_EXISTS_SUFFIX = ".exists";
49
+ export declare const SECRET_RESOLVABLE_SUFFIX = ".resolvable";
50
+ export declare const SECRET_TTL_SECONDS = 3600;
51
+ export declare const VAULT_TTL_SECONDS = 3600;
52
+ export declare const INTEGRATION_TTL_SECONDS = 3600;
53
+ export declare const IDENTITY_TTL_SECONDS = 3600;
54
+ export declare const REPO_TTL_SECONDS = 86400;
55
+ export declare const DATA_TTL_SECONDS = 86400;
56
+ export declare const CHILD_TIMEOUT_MS = 60000;
57
+ export declare const GIT_TIMEOUT_MS = 30000;
58
+ export declare const CACHED_RESULT_REASON = "vault unreachable; result came from the local cache";
59
+ export type ProbeTest = "grant" | "reachable" | "exists" | "resolvable" | "usable" | "present" | "agent";
60
+ /** One line of `hq env probe` output. Never has a value field. */
61
+ export interface AccessProbeEntry {
62
+ /** kind:name, the readings.access name. */
63
+ probe: string;
64
+ /** Which question this entry answers; a secret has an exists and a resolvable entry. */
65
+ test: ProbeTest;
66
+ /** What the probe proves, and what it does not. */
67
+ checks: string;
68
+ ok: boolean;
69
+ /** pass when ok; fail when the answer is no; unknown when the probe could not tell. */
70
+ result: "pass" | "fail" | "unknown";
71
+ /** Present when ok is false. A fixed sentence and caller-given names only. */
72
+ reason?: string;
73
+ observed_at: string;
74
+ ttl_seconds: number;
75
+ source: string;
76
+ }
77
+ export interface ChildOutcome {
78
+ code: number;
79
+ /** Bounded. Matched against known phrases only; never printed. */
80
+ stderr: string;
81
+ /** Collected only when asked for. */
82
+ stdout?: string;
83
+ /** true when the child was killed for running past its time limit. */
84
+ timedOut?: boolean;
85
+ }
86
+ export interface ChildRunOptions {
87
+ captureStdout?: boolean;
88
+ /** Merged over the runner's base environment. */
89
+ env?: NodeJS.ProcessEnv;
90
+ }
91
+ export interface AccessProbeDeps {
92
+ /** Run the hq CLI with these args as a child process. */
93
+ runHq: (args: string[], options?: ChildRunOptions) => Promise<ChildOutcome>;
94
+ /** Run git with these args as a child process. */
95
+ runGit: (args: string[], options?: ChildRunOptions) => Promise<ChildOutcome>;
96
+ hqRoot: string;
97
+ /** The node binary the resolvability check runs under. */
98
+ nodeBinary: string;
99
+ /**
100
+ * Installs the interrupt cleanup around the probes that start children and
101
+ * returns its release. Defaults to nothing (tests); the CLI passes
102
+ * installInterruptCleanup.
103
+ */
104
+ installInterrupts?: () => () => void;
105
+ /** The ssh command git would use before this probe adds BatchMode, if any. */
106
+ gitSshCommand?: string;
107
+ /** A bare GIT_SSH program from the caller's environment, if any. */
108
+ gitSshProgram?: string;
109
+ now?: () => Date;
110
+ }
111
+ export interface AccessProbeRequest {
112
+ company: string;
113
+ repos?: string[];
114
+ secrets?: string[];
115
+ integrations?: string[];
116
+ data?: string[];
117
+ /** Also run `hq agent probe` (sends a self-DM and reports to the console). */
118
+ agent?: boolean;
119
+ }
120
+ export interface AccessProbeReport {
121
+ ok: boolean;
122
+ company: string;
123
+ observed_at: string;
124
+ probes: AccessProbeEntry[];
125
+ }
126
+ /** Checks a request before any probe runs; returns a list of problems. */
127
+ export declare function requestProblems(request: AccessProbeRequest): string[];
128
+ /** The readings.access entry for one probe line. */
129
+ export declare function toAccessReading(entry: AccessProbeEntry): EnvironmentAccessProbe;
130
+ /** The base name a reading supersedes: secret:<NAME>.exists also replaces a hand-run secret:<NAME>. */
131
+ export declare function supersededNames(readingName: string): string[];
132
+ type Classified = {
133
+ reason: string;
134
+ result: "fail" | "unknown";
135
+ };
136
+ /**
137
+ * Map an `hq secrets exec` failure to a fixed sentence. The stderr text is
138
+ * matched, never copied: a buggy child could have written anything there.
139
+ * The secret name is removed first, so HQ_SANDBOX/API_KEY does not read as a
140
+ * sandbox refusal.
141
+ */
142
+ export declare function classifyExecFailure(name: string, outcome: ChildOutcome, company?: string): Classified;
143
+ export declare function classifyGitFailure(repo: string, outcome: ChildOutcome): Classified;
144
+ /**
145
+ * The user's ssh command with BatchMode forced on, so ssh cannot prompt.
146
+ *
147
+ * For ssh the FIRST value given for an option wins, command-line -o included
148
+ * (ssh_config(5): "the first obtained value will be used"; checked with
149
+ * `ssh -G -o BatchMode=no -o BatchMode=yes`, which reports batchmode no). So
150
+ * the option goes straight after the program, before the user's own options.
151
+ *
152
+ * Returns null when no word of the command names ssh (plink, a custom
153
+ * wrapper): BatchMode is an ssh option, so nothing is added to it.
154
+ */
155
+ export declare function batchSshCommand(existing: string | undefined): string | null;
156
+ /**
157
+ * Whether an ssh command that does not name ssh is still known not to prompt:
158
+ * plink's `-batch`, or an explicit BatchMode=yes.
159
+ */
160
+ export declare function knownNonInteractiveSsh(command: string): boolean;
161
+ /**
162
+ * The environment the repo probe's git runs under: no terminal prompt, no
163
+ * Git Credential Manager dialog, and no askpass program. Git runs
164
+ * GIT_ASKPASS, core.askPass or SSH_ASKPASS before it looks at
165
+ * GIT_TERMINAL_PROMPT; an empty GIT_ASKPASS skips all three, and git then
166
+ * fails with "terminal prompts disabled". ssh's own askpass is cleared and
167
+ * SSH_ASKPASS_REQUIRE=never stops ssh from using one.
168
+ */
169
+ export declare function gitProbeEnv(env: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
170
+ /**
171
+ * Why a resolved data path may not be read for this company, or null.
172
+ *
173
+ * - The company's own folder must be a real folder, not a symlink (the
174
+ * session-lock reader does not count a symlinked company folder either).
175
+ * - The target may not resolve inside any other company's resolved folder,
176
+ * wherever that folder points: companies/other-co may itself be a symlink
177
+ * to a place outside companies/.
178
+ * - A target inside the resolved companies/ folder must be inside the
179
+ * company's own folder.
180
+ */
181
+ export declare function dataScopeFailure(hqRoot: string, company: string, relative: string, real: string): string | null;
182
+ /**
183
+ * Whether a file path falls inside a company folder other than `company`,
184
+ * judged both by name and after the folder holding it is resolved, so a
185
+ * symlinked folder cannot hide it. Folder names are compared without case on
186
+ * macOS and Windows.
187
+ */
188
+ export declare function pathInOtherCompany(hqRoot: string, company: string, filePath: string): boolean;
189
+ /** Run every requested probe in a fixed order and return one entry per probe. */
190
+ export declare function runAccessProbes(request: AccessProbeRequest, deps: AccessProbeDeps): Promise<AccessProbeReport>;
191
+ /** Kill every process group this module started and has not seen exit. */
192
+ export declare function killLiveGroups(kill?: (pid: number, signal: NodeJS.Signals) => void): number;
193
+ export declare const INTERRUPT_SIGNALS: readonly NodeJS.Signals[];
194
+ export interface SignalHost {
195
+ on: (signal: NodeJS.Signals, handler: (signal: NodeJS.Signals) => void) => unknown;
196
+ off: (signal: NodeJS.Signals, handler: (signal: NodeJS.Signals) => void) => unknown;
197
+ /** Re-raise the signal on this process once the handlers are gone. */
198
+ raise: (signal: NodeJS.Signals) => void;
199
+ kill?: (pid: number, signal: NodeJS.Signals) => void;
200
+ }
201
+ /**
202
+ * While a probe run is in flight, SIGINT, SIGTERM and SIGHUP kill every
203
+ * child process group first (the children are detached, so the terminal's
204
+ * Ctrl-C does not reach them, and one may be an `hq agent probe` about to
205
+ * send its DM), then the handlers are removed and the signal is raised again,
206
+ * so the process ends the way it would have without them. Call the returned
207
+ * function when the run finishes.
208
+ */
209
+ export declare function installInterruptCleanup(host?: SignalHost): () => void;
210
+ /**
211
+ * Spawn a child in its own process group with bounded capture. stdout is
212
+ * discarded unless asked for. On timeout the whole group is killed, so a
213
+ * grandchild (the check under `hq secrets exec`, or an ssh under git) cannot
214
+ * outlive it.
215
+ */
216
+ export declare function runChild(file: string, args: string[], options?: {
217
+ env?: NodeJS.ProcessEnv;
218
+ captureStdout?: boolean;
219
+ timeoutMs?: number;
220
+ }): Promise<ChildOutcome>;
221
+ /** Set together with HQ_ENV_PROBE_TEST_HQ_ENTRY by the built-CLI test; nothing else sets it. */
222
+ export declare const ENV_PROBE_TEST_STUB_ENV = "HQ_ENV_PROBE_TEST_STUB";
223
+ export declare const ENV_PROBE_TEST_HQ_ENTRY_ENV = "HQ_ENV_PROBE_TEST_HQ_ENTRY";
224
+ /**
225
+ * The hq entry the probes run as children. The built-CLI test swaps in a fake
226
+ * hq (a fake vault) with HQ_ENV_PROBE_TEST_HQ_ENTRY, honoured only when
227
+ * HQ_ENV_PROBE_TEST_STUB=1 is set too (the HQ_JOB_TEST_SCHEDULER_STUB pattern).
228
+ */
229
+ export declare function hqEntryFor(env: NodeJS.ProcessEnv, argv1: string | undefined): string;
230
+ export declare function defaultAccessProbeDeps(hqRoot: string, env?: NodeJS.ProcessEnv): AccessProbeDeps;
231
+ /** The company slug of this host's external agent kit, or null when there is none. */
232
+ export declare function agentKitCompany(env?: NodeJS.ProcessEnv): Promise<string | null>;
233
+ export {};
234
+ //# sourceMappingURL=access-probes.d.ts.map