@indigoai-us/hq-cli 5.345.251 → 5.345.252

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 (160) hide show
  1. package/CHANGELOG.md +112 -0
  2. package/assets/scaffold/core/scripts/hq-session.sh +9 -0
  3. package/contracts/host-canary-release.json +9 -3
  4. package/dist/command-catalog.generated.d.ts +121 -1
  5. package/dist/command-catalog.generated.js +148 -1
  6. package/dist/commands/bot.js +7 -2
  7. package/dist/commands/core-bucket-c-work-mesh-offer-native.js +1 -1
  8. package/dist/commands/core-hq-session-binding.d.ts +140 -0
  9. package/dist/commands/core-hq-session-binding.js +363 -0
  10. package/dist/commands/core-hq-session-native.d.ts +23 -0
  11. package/dist/commands/core-hq-session-native.js +59 -9
  12. package/dist/commands/core-stop-autosave.js +1 -1
  13. package/dist/commands/core.js +10 -0
  14. package/dist/commands/doctor.d.ts +5 -1
  15. package/dist/commands/doctor.js +42 -5
  16. package/dist/commands/files.js +1 -1
  17. package/dist/commands/install-global.js +4 -2
  18. package/dist/commands/logout.js +4 -0
  19. package/dist/commands/ontology-graph.d.ts +2 -0
  20. package/dist/commands/ontology-graph.js +33 -0
  21. package/dist/commands/report.js +35 -2
  22. package/dist/commands/storage-gate.js +1 -1
  23. package/dist/commands/vault-retention-flag.js +2 -1
  24. package/dist/commands/whoami.js +1 -1
  25. package/dist/hq-cloud-sync-runner/bin/sync-runner.js +238 -221
  26. package/dist/hq-cloud-sync-runner/package.json +1 -1
  27. package/dist/index.js +3 -1
  28. package/dist/lib/agent-kit/inbox-poll-backoff-flag.js +1 -1
  29. package/dist/lib/agent-kit/mcp/tools.js +48 -0
  30. package/dist/lib/bot/fleet-bots-update-pass.js +1 -1
  31. package/dist/lib/bot/fleet-cron.d.ts +35 -0
  32. package/dist/lib/bot/fleet-cron.js +54 -12
  33. package/dist/lib/bot/fleet-local.d.ts +18 -0
  34. package/dist/lib/bot/fleet-local.js +51 -5
  35. package/dist/lib/bot/inbox-poll-backoff-flag.js +1 -1
  36. package/dist/lib/bot/signals-engine-flag.d.ts +1 -1
  37. package/dist/lib/bot/signals-engine-flag.js +1 -1
  38. package/dist/lib/cli-invite-nudge.js +1 -1
  39. package/dist/lib/client-version.d.ts +2 -0
  40. package/dist/lib/client-version.js +24 -0
  41. package/dist/lib/company-flag-gate.d.ts +30 -0
  42. package/dist/lib/company-flag-gate.js +104 -0
  43. package/dist/lib/core-utils/hook-timeout-debug-context-flag.js +1 -1
  44. package/dist/lib/daemon/flag.js +2 -1
  45. package/dist/lib/daemon/legacy-journal-gate.js +3 -1
  46. package/dist/lib/daemon/shared-flag-reads.js +1 -1
  47. package/dist/lib/doctor/checks/host-core.js +22 -4
  48. package/dist/lib/doctor/checks/jq.d.ts +27 -6
  49. package/dist/lib/doctor/checks/jq.js +46 -8
  50. package/dist/lib/doctor/client-health-reason-codes-flag.js +1 -1
  51. package/dist/lib/doctor/fix/refresh-sync-handoff.d.ts +1 -1
  52. package/dist/lib/doctor/fix/refresh-sync-handoff.js +1 -1
  53. package/dist/lib/flag-client-gate-headers.d.ts +38 -0
  54. package/dist/lib/flag-client-gate-headers.js +62 -0
  55. package/dist/lib/flag-client-headers.d.ts +15 -0
  56. package/dist/lib/flag-client-headers.js +25 -0
  57. package/dist/lib/flag-registry-worker-source.generated.d.ts +1 -1
  58. package/dist/lib/flag-registry-worker-source.generated.js +1 -1
  59. package/dist/lib/flag-registry-worker.js +35 -0
  60. package/dist/lib/flag-registry.d.ts +1 -20
  61. package/dist/lib/flag-registry.js +5 -81
  62. package/dist/lib/hook-engine/adapter-core-pin.d.ts +29 -0
  63. package/dist/lib/hook-engine/adapter-core-pin.js +29 -0
  64. package/dist/lib/hook-engine/coverage.d.ts +50 -1
  65. package/dist/lib/hook-engine/coverage.js +111 -7
  66. package/dist/lib/hook-engine/reconcile.js +3 -2
  67. package/dist/lib/hot-channels/prompts/signals-pass.md +20 -0
  68. package/dist/lib/hot-channels/signal-changes.d.ts +228 -0
  69. package/dist/lib/hot-channels/signal-changes.js +683 -0
  70. package/dist/lib/hot-channels/signals-pass.d.ts +24 -0
  71. package/dist/lib/hot-channels/signals-pass.js +232 -12
  72. package/dist/lib/lanes/outpost-worktree-pruner-flag.d.ts +1 -1
  73. package/dist/lib/lanes/outpost-worktree-pruner-flag.js +1 -1
  74. package/dist/lib/lanes/registry-flag.js +2 -1
  75. package/dist/lib/lanes/spawn.js +11 -1
  76. package/dist/lib/mesh/live/binding-intent.d.ts +61 -0
  77. package/dist/lib/mesh/live/binding-intent.js +201 -0
  78. package/dist/lib/mesh/live/binding-receipt.d.ts +157 -0
  79. package/dist/lib/mesh/live/binding-receipt.js +365 -0
  80. package/dist/lib/mesh/live/company-flag-refresh.js +1 -1
  81. package/dist/lib/mesh/live/daemon/doctor-telemetry.d.ts +39 -0
  82. package/dist/lib/mesh/live/daemon/doctor-telemetry.js +58 -0
  83. package/dist/lib/mesh/live/daemon/install.js +2 -1
  84. package/dist/lib/mesh/live/daemon/presence.js +9 -0
  85. package/dist/lib/mesh/live/daemon/run.d.ts +3 -0
  86. package/dist/lib/mesh/live/daemon/run.js +33 -1
  87. package/dist/lib/ontology-graph/lineage/index.d.ts +401 -0
  88. package/dist/lib/ontology-graph/lineage/index.js +1027 -0
  89. package/dist/lib/ontology-graph/model/index.d.ts +54 -0
  90. package/dist/lib/ontology-graph/model/index.js +112 -0
  91. package/dist/lib/ontology-graph/model/pass-tasks.d.ts +75 -0
  92. package/dist/lib/ontology-graph/model/pass-tasks.js +166 -0
  93. package/dist/lib/ontology-graph/model/pass.d.ts +6 -0
  94. package/dist/lib/ontology-graph/model/pass.js +9 -2
  95. package/dist/lib/ontology-graph/model/pending-items.d.ts +8 -0
  96. package/dist/lib/ontology-graph/model/pending-items.js +24 -1
  97. package/dist/lib/ontology-graph/model/step.d.ts +1 -1
  98. package/dist/lib/ontology-graph/model/tasks.d.ts +11 -3
  99. package/dist/lib/ontology-graph/model/tasks.js +20 -7
  100. package/dist/lib/ontology-graph/read/brief.js +41 -6
  101. package/dist/lib/ontology-graph/read/index.d.ts +4 -0
  102. package/dist/lib/ontology-graph/read/index.js +173 -29
  103. package/dist/lib/ontology-graph/read/lineage.d.ts +101 -0
  104. package/dist/lib/ontology-graph/read/lineage.js +262 -0
  105. package/dist/lib/ontology-graph/replay/buffered-store.js +17 -0
  106. package/dist/lib/ontology-graph/replay/engine.d.ts +32 -1
  107. package/dist/lib/ontology-graph/replay/engine.js +213 -8
  108. package/dist/lib/ontology-graph/replay/extractors.d.ts +26 -0
  109. package/dist/lib/ontology-graph/replay/extractors.js +25 -1
  110. package/dist/lib/ontology-graph/replay/index.d.ts +2 -0
  111. package/dist/lib/ontology-graph/replay/index.js +9 -3
  112. package/dist/lib/ontology-graph/replay/signal-changes.d.ts +118 -0
  113. package/dist/lib/ontology-graph/replay/signal-changes.js +687 -0
  114. package/dist/lib/ontology-graph/schema/decision-status.d.ts +18 -0
  115. package/dist/lib/ontology-graph/schema/decision-status.js +20 -0
  116. package/dist/lib/ontology-graph/schema/index.d.ts +1 -0
  117. package/dist/lib/ontology-graph/schema/index.js +1 -0
  118. package/dist/lib/ontology-graph/setup/index.js +13 -3
  119. package/dist/lib/search-index/index.d.ts +33 -1
  120. package/dist/lib/search-index/index.js +180 -25
  121. package/dist/lib/search-index/qmd-exit-diagnostics.d.ts +7 -0
  122. package/dist/lib/search-index/qmd-exit-diagnostics.js +25 -1
  123. package/dist/lib/signals/adapters-catalog.js +1 -1
  124. package/dist/lib/sync-core/engine-holds.d.ts +1 -0
  125. package/dist/lib/sync-core/engine-holds.js +26 -0
  126. package/dist/lib/sync-core/engine-home.d.ts +3 -0
  127. package/dist/lib/sync-core/engine-home.js +41 -1
  128. package/dist/lib/sync-core/flag.js +2 -1
  129. package/dist/lib/sync-core/legacy-journal-export-child.js +5 -3
  130. package/dist/lib/sync-core/legacy-journal-export.d.ts +23 -4
  131. package/dist/lib/sync-core/legacy-journal-export.js +120 -55
  132. package/dist/lib/sync-core/reconcile.d.ts +2 -1
  133. package/dist/lib/sync-core/reconcile.js +30 -5
  134. package/dist/lib/sync-invalid-entity-warning.js +2 -1
  135. package/dist/lib/windows/install-followup.d.ts +41 -0
  136. package/dist/lib/windows/install-followup.js +87 -0
  137. package/dist/lib/windows/jq.d.ts +59 -0
  138. package/dist/lib/windows/jq.js +154 -3
  139. package/dist/lib/windows/user-path.d.ts +5 -0
  140. package/dist/lib/windows/user-path.js +1 -1
  141. package/dist/lib/work-context/auto-bind.d.ts +12 -0
  142. package/dist/lib/work-context/auto-bind.js +49 -3
  143. package/dist/lib/work-context/organize.d.ts +4 -2
  144. package/dist/lib/work-context/organize.js +18 -8
  145. package/dist/lib/work-context/reconcile.js +16 -1
  146. package/dist/main.js +12 -1
  147. package/dist/utils/client-health-contract.d.ts +30 -0
  148. package/dist/utils/client-health-contract.js +111 -0
  149. package/dist/utils/client-health.d.ts +5 -2
  150. package/dist/utils/client-health.js +74 -5
  151. package/dist/utils/exclusive-lock.d.ts +5 -1
  152. package/dist/utils/exclusive-lock.js +9 -2
  153. package/dist/utils/host-registration.d.ts +7 -0
  154. package/dist/utils/host-registration.js +10 -1
  155. package/dist/utils/pid.d.ts +31 -0
  156. package/dist/utils/pid.js +65 -0
  157. package/dist/utils/resident-package-preload.js +12 -4
  158. package/dist/utils/sentry-fingerprint.js +3 -0
  159. package/package.json +8 -8
  160. package/scripts/install-hook-engine.mjs +5 -3
@@ -13,9 +13,9 @@ import * as path from 'node:path';
13
13
  import { jsonFormat } from '../../../commands/mcp-registration.js';
14
14
  import { CORE_NEXT_LINK, isCoreNextEntry, isNativeEntry } from '../../hook-engine/registration.js';
15
15
  import { isAdapterEntry } from '../../install/codex-targets.js';
16
- import { uncoveredHooks } from '../../hook-engine/coverage.js';
16
+ import { claudeProjectAdapterHold, uncoveredHooks } from '../../hook-engine/coverage.js';
17
17
  import { masterHookPath, shimPath } from '../../install/claude-targets.js';
18
- import { CORE_NEXT_FLAG, CORE_NEXT_KILL_ENV, CORE_NEXT_KILL_FILE, ENGINE_KILL_ENV, ENGINE_KILL_FILE, REQUIRED_EVALUATORS, STABLE_LINK_NAME, coreNextEnabled, coreNextKillReason, missingEvaluators, probeEngine, } from '../../../utils/host-registration.js';
18
+ import { CORE_NEXT_FLAG, CORE_NEXT_KILL_ENV, CORE_NEXT_KILL_FILE, ENGINE_KILL_ENV, ENGINE_KILL_FILE, REQUIRED_EVALUATORS, STABLE_LINK_NAME, coreNextEnabled, coreNextKillReason, coreNextTargetFor, missingEvaluators, probeEngine, } from '../../../utils/host-registration.js';
19
19
  import { fleetHookCoreResults } from './fleet-hook-core.js';
20
20
  import { HOOKS_FAMILY_ID } from '../registry.js';
21
21
  export const HOST_CORE_FAMILY_ID = 'host-core';
@@ -141,7 +141,17 @@ export function hostCoreResults(root, options = {}) {
141
141
  /** Old-dispatcher hooks for `event` on `host` that the engine's report does not cover. */
142
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
- const oldCore = (event, host) => {
144
+ /**
145
+ * Why an event of `<root>/.claude/settings.json` stays on master-hook.sh for
146
+ * the Codex and Grok Build shell adapters, or null: the answer `hq reindex`
147
+ * acts on (coverage.ts `claudeProjectAdapterHold`), asked of the same target
148
+ * reindex builds for an engine with `caps`, without installing anything.
149
+ */
150
+ const adapterHold = (caps, event) => {
151
+ const target = coreNextTargetFor(home, env, defaultStableEngine(home, platform), caps, platform, () => { });
152
+ return claudeProjectAdapterHold(root, event, target, env);
153
+ };
154
+ const oldCore = (event, host, scope) => {
145
155
  if (!flagOn)
146
156
  return { status: 'PASS', reason: `flag ${CORE_NEXT_FLAG} is off` };
147
157
  if (killedBy)
@@ -159,6 +169,11 @@ export function hostCoreResults(root, options = {}) {
159
169
  const left = uncovered(caps, host, event);
160
170
  if (left.length > 0)
161
171
  return { status: 'PASS', reason: `the new core does not cover ${listed(left)}` };
172
+ if (host === 'claude' && scope === 'project') {
173
+ const held = adapterHold(caps, event);
174
+ if (held)
175
+ return { status: 'PASS', reason: `held on the old dispatcher while ${held}` };
176
+ }
162
177
  return { status: 'WARN', reason: 'the new core can take this event; run hq reindex to switch it' };
163
178
  };
164
179
  const results = [];
@@ -233,6 +248,9 @@ export function hostCoreResults(root, options = {}) {
233
248
  const left = caps && !(caps instanceof Error) ? uncovered(caps, target.host, event) : [];
234
249
  if (left.length > 0)
235
250
  verdict = { status: 'FAIL', reason: `the new core does not cover ${listed(left)}, so they do not run; run hq reindex to put this event back on the old dispatcher` };
251
+ const held = verdict.status === 'PASS' && caps && !(caps instanceof Error) && target.host === 'claude' && target.scope === 'project' ? adapterHold(caps, event) : null;
252
+ if (held)
253
+ verdict = { status: 'FAIL', reason: `registered to the new core while ${held}, so that adapter finds no master record for it; run hq reindex to put this event back on master-hook.sh` };
236
254
  }
237
255
  if (verdict.status === 'WARN')
238
256
  mixed.push(event);
@@ -245,7 +263,7 @@ export function hostCoreResults(root, options = {}) {
245
263
  continue;
246
264
  }
247
265
  const core = kinds[0];
248
- events.push({ event, core, ...oldCore(event, target.host) });
266
+ events.push({ event, core, ...oldCore(event, target.host, target.scope) });
249
267
  }
250
268
  if (events.length === 0) {
251
269
  results.push({ status: 'NA', checkId, target: target.file, message: `${target.host} (${target.scope}): no HQ hook registered` });
@@ -1,12 +1,16 @@
1
+ import type { PowerShellRun } from "../../windows/user-path.js";
1
2
  import type { CheckContext, CheckFamily, CheckResult } from "../types.js";
2
3
  export declare const JQ_FAMILY_ID = "jq";
3
4
  export declare const JQ_CHECK_ID = "jq.on-path";
4
5
  /**
5
- * Windows install hint for a missing jq. hq-core-staging PR 1882 makes
6
- * master-hook block every tool call without jq. The npm postinstall
7
- * (scripts/install-hook-engine.mjs) prints the same line; a test keeps them equal.
6
+ * Windows repair hint for a missing jq. hq-core-staging PR 1882 makes
7
+ * master-hook block every tool call without jq. HQ's own repair comes first
8
+ * and no package manager is named (hq-cli #3716): the repair installs a
9
+ * checksum-verified jq and puts its folder on the user PATH.
8
10
  */
9
- export declare const JQ_WINDOWS_INSTALL_HINT = "Install jq (Windows: winget install jqlang.jq) and open a new terminal; HQ hooks block tool calls until jq is on PATH.";
11
+ export declare const JQ_WINDOWS_INSTALL_HINT = "Run `hq doctor --fix-jq` (it installs the verified jq and adds it to your PATH), then open a new terminal and restart Claude Code; HQ hooks block tool calls until jq is on PATH.";
12
+ /** What to do when jq is on the stored PATH but this process started before it was added. */
13
+ export declare const JQ_RESTART_HINT = "Open a new terminal and restart Claude Code. A session that was already open keeps its old PATH, and its hooks may keep blocking tool calls until it restarts.";
10
14
  /** Per-platform install guidance for a missing jq. */
11
15
  export declare function jqInstallHint(platform: NodeJS.Platform): string;
12
16
  export interface JqCheckDeps {
@@ -15,11 +19,28 @@ export interface JqCheckDeps {
15
19
  findJq: () => string | undefined;
16
20
  /** `jq --version` output for the binary at `file`; throws when it cannot run. */
17
21
  readVersion: (file: string) => string;
22
+ /**
23
+ * Windows only: the jq on the stored machine and user Path, which is what a
24
+ * new terminal gets. Asked only when `findJq` finds nothing.
25
+ */
26
+ findPersistedJq?: () => string | undefined;
18
27
  }
28
+ /**
29
+ * The closing check of `hq doctor --fix-jq`: the jq.on-path check, asked about
30
+ * the stored Windows PATH instead of this process's PATH. The stored value is
31
+ * what the next terminal and the next Claude Code session start with, and the
32
+ * terminal running the repair may be the one that still has the old PATH.
33
+ */
34
+ export declare function verifyJqForNewSessions(options?: {
35
+ powerShell?: PowerShellRun;
36
+ env?: NodeJS.ProcessEnv;
37
+ readVersion?: JqCheckDeps["readVersion"];
38
+ }): CheckResult[];
19
39
  /**
20
40
  * HQ's master-hook needs jq to parse every hook payload. Since hq-core-staging
21
- * PR 1882 it blocks every PreToolUse call when jq is missing, and no installer
22
- * puts jq on PATH on Windows. This check only reads: it never installs jq.
41
+ * PR 1882 it blocks every PreToolUse call when jq is missing. On Windows the
42
+ * CLI installs jq itself (ensureWindowsJq). This check only reads: it never
43
+ * installs jq.
23
44
  */
24
45
  export declare function createJqFamily(deps?: JqCheckDeps): CheckFamily;
25
46
  export declare const jqFamily: CheckFamily;
@@ -1,14 +1,18 @@
1
1
  import { execFileSync } from "node:child_process";
2
2
  import { findExecutableOnPath } from "../../../utils/resolve-executable.js";
3
3
  import { JQ_VERSION_RE } from "../../daemon/verified-jq.js";
4
+ import { WINDOWS_JQ_REPAIR, findJqOnPersistedPath } from "../../windows/jq.js";
4
5
  export const JQ_FAMILY_ID = "jq";
5
6
  export const JQ_CHECK_ID = "jq.on-path";
6
7
  /**
7
- * Windows install hint for a missing jq. hq-core-staging PR 1882 makes
8
- * master-hook block every tool call without jq. The npm postinstall
9
- * (scripts/install-hook-engine.mjs) prints the same line; a test keeps them equal.
8
+ * Windows repair hint for a missing jq. hq-core-staging PR 1882 makes
9
+ * master-hook block every tool call without jq. HQ's own repair comes first
10
+ * and no package manager is named (hq-cli #3716): the repair installs a
11
+ * checksum-verified jq and puts its folder on the user PATH.
10
12
  */
11
- export const JQ_WINDOWS_INSTALL_HINT = "Install jq (Windows: winget install jqlang.jq) and open a new terminal; HQ hooks block tool calls until jq is on PATH.";
13
+ export const JQ_WINDOWS_INSTALL_HINT = `Run \`${WINDOWS_JQ_REPAIR}\` (it installs the verified jq and adds it to your PATH), then open a new terminal and restart Claude Code; HQ hooks block tool calls until jq is on PATH.`;
14
+ /** What to do when jq is on the stored PATH but this process started before it was added. */
15
+ export const JQ_RESTART_HINT = "Open a new terminal and restart Claude Code. A session that was already open keeps its old PATH, and its hooks may keep blocking tool calls until it restarts.";
12
16
  /** Per-platform install guidance for a missing jq. */
13
17
  export function jqInstallHint(platform) {
14
18
  if (platform === "win32")
@@ -28,11 +32,26 @@ const defaultDeps = {
28
32
  stdio: ["ignore", "pipe", "pipe"],
29
33
  windowsHide: true,
30
34
  }),
35
+ findPersistedJq: () => findJqOnPersistedPath(),
31
36
  };
37
+ /**
38
+ * The closing check of `hq doctor --fix-jq`: the jq.on-path check, asked about
39
+ * the stored Windows PATH instead of this process's PATH. The stored value is
40
+ * what the next terminal and the next Claude Code session start with, and the
41
+ * terminal running the repair may be the one that still has the old PATH.
42
+ */
43
+ export function verifyJqForNewSessions(options = {}) {
44
+ return checkJq({ hqRoot: "" }, {
45
+ platform: "win32",
46
+ findJq: () => findJqOnPersistedPath(options.powerShell, options.env),
47
+ readVersion: options.readVersion ?? defaultDeps.readVersion,
48
+ });
49
+ }
32
50
  /**
33
51
  * HQ's master-hook needs jq to parse every hook payload. Since hq-core-staging
34
- * PR 1882 it blocks every PreToolUse call when jq is missing, and no installer
35
- * puts jq on PATH on Windows. This check only reads: it never installs jq.
52
+ * PR 1882 it blocks every PreToolUse call when jq is missing. On Windows the
53
+ * CLI installs jq itself (ensureWindowsJq). This check only reads: it never
54
+ * installs jq.
36
55
  */
37
56
  export function createJqFamily(deps = defaultDeps) {
38
57
  return {
@@ -44,7 +63,12 @@ export function createJqFamily(deps = defaultDeps) {
44
63
  export const jqFamily = createJqFamily();
45
64
  export function checkJq(_context, deps = defaultDeps) {
46
65
  const hint = jqInstallHint(deps.platform);
47
- const file = deps.findJq();
66
+ let file = deps.findJq();
67
+ let storedPathOnly = false;
68
+ if (!file && deps.platform === "win32" && deps.findPersistedJq) {
69
+ file = deps.findPersistedJq();
70
+ storedPathOnly = file !== undefined;
71
+ }
48
72
  if (!file) {
49
73
  return [
50
74
  {
@@ -81,7 +105,21 @@ export function checkJq(_context, deps = defaultDeps) {
81
105
  checkId: JQ_CHECK_ID,
82
106
  target: file,
83
107
  message: `The jq on PATH at ${file} is not jq: \`jq --version\` printed "${shown}" instead of jq-1.x. HQ hooks cannot read tool calls with it.`,
84
- remediation: `${jqInstallHint(deps.platform)} The HQ desktop app replaces a jq that is not jq when it next checks its tools.`,
108
+ remediation: deps.platform === "win32"
109
+ ? `Remove or rename ${file}, then run \`${WINDOWS_JQ_REPAIR}\`. The HQ desktop app replaces a jq that is not jq when it next checks its tools.`
110
+ : `${hint} The HQ desktop app replaces a jq that is not jq when it next checks its tools.`,
111
+ },
112
+ ];
113
+ }
114
+ if (storedPathOnly) {
115
+ return [
116
+ {
117
+ status: "WARN",
118
+ checkId: JQ_CHECK_ID,
119
+ target: file,
120
+ message: `${version || "jq"} is on your Windows PATH at ${file}, but this terminal started before it was added.`,
121
+ remediation: JQ_RESTART_HINT,
122
+ details: { version },
85
123
  },
86
124
  ];
87
125
  }
@@ -1,4 +1,4 @@
1
- import { createFlagClient, } from "@indigoai-us/hq-flags-client";
1
+ import { createHqFlagClient as createFlagClient } from "../flag-client-headers.js";
2
2
  import { resolveFlagRegistryEndpoint } from "../flag-registry-endpoint.js";
3
3
  import { getClientHealthFlagToken } from "./client-health-flag-token.js";
4
4
  export const CLIENT_HEALTH_REASON_CODES_FLAG = "client-health-sync-reason-codes";
@@ -197,5 +197,5 @@ export declare const REFRESH_PREEMPT_POLL_MS = 500;
197
197
  * cooperative one; the same staged writes and atomic journal keep completed
198
198
  * work.
199
199
  */
200
- export declare const REFRESH_SUPERVISOR_SOURCE = "\nconst fs = require(\"node:fs\");\nconst path = require(\"node:path\");\nconst { spawn, spawnSync } = require(\"node:child_process\");\nconst [logPath, exitPath, hbPath, pidPath, cancelPath, locksDir, maxMs, cmd, ...args] = process.argv.slice(1);\nconst isWin = process.platform === \"win32\";\nconst beat = () => { try { fs.writeFileSync(hbPath, String(Date.now())); } catch {} };\nbeat();\nconst hb = setInterval(beat, 10000);\nlet fd;\ntry { fd = fs.openSync(logPath, \"a\", 0o600); } catch { fd = \"ignore\"; }\nlet finished = false;\nlet preempted = false;\nlet capped = false;\nlet stopAt = 0;\nlet watch;\n// Its own process group on POSIX, so a stop reaches every process the pull started.\nconst child = spawn(cmd, args, { stdio: [\"ignore\", fd, fd], windowsHide: true, detached: !isWin });\ntry { fs.writeFileSync(pidPath, String(child.pid)); } catch {}\nif (!isWin && child.pid) {\n try {\n const r = spawnSync(\"ps\", [\"-o\", \"lstart=\", \"-p\", String(child.pid)], { encoding: \"utf8\" });\n const started = (r.stdout || \"\").trim();\n if (started) fs.writeFileSync(path.join(path.dirname(pidPath), path.basename(pidPath, \".pid\") + \".start\"), started);\n } catch {}\n}\nconst killTree = (sig) => {\n if (isWin) {\n try { spawnSync(\"taskkill\", [\"/PID\", String(child.pid), \"/T\", \"/F\"], { stdio: \"ignore\", windowsHide: true }); } catch {}\n return;\n }\n try { process.kill(-child.pid, sig); } catch {}\n};\nconst stop = () => {\n if (stopAt) return;\n stopAt = Date.now();\n killTree(\"SIGTERM\");\n setTimeout(() => killTree(\"SIGKILL\"), 5000);\n};\nconst exitNow = (status) => process.exit(typeof status === \"number\" ? status : 1);\nconst done = (status, signal) => {\n if (finished) return;\n finished = true;\n clearInterval(hb);\n clearInterval(watch);\n clearTimeout(stopper);\n try {\n fs.writeFileSync(exitPath + \".tmp\", JSON.stringify({ status, signal, preempted, capped }));\n fs.renameSync(exitPath + \".tmp\", exitPath);\n } catch {}\n if (!stopAt) return exitNow(status);\n // A stopped pull's group is always SIGKILLed after the grace period, even\n // when the pull itself exited on SIGTERM, so no grandchild survives.\n const left = Math.max(0, stopAt + 5000 - Date.now());\n setTimeout(() => { killTree(\"SIGKILL\"); exitNow(status); }, left);\n};\nconst stopper = setTimeout(() => {\n capped = true;\n // At the cap the pull is no longer live: stop heartbeating so nothing reads it as in progress.\n clearInterval(hb);\n try { fs.writeFileSync(hbPath, \"capped:\" + Date.now()); } catch {}\n stop();\n}, Number(maxMs));\nconst alive = (pid) => { try { process.kill(pid, 0); return true; } catch (e) { return Boolean(e && e.code === \"EPERM\"); } };\nlet lockName = null;\nconst findLock = () => {\n let names;\n try { names = fs.readdirSync(locksDir); } catch { return null; }\n for (const name of names) {\n // A sync holds shared membership: <lock>.shared-<pid>-<hex>.\n const shared = /^(.+\\.lock)\\.shared-(\\d+)-/.exec(name);\n if (shared && Number(shared[2]) === child.pid) return shared[1];\n if (!name.endsWith(\".lock\")) continue;\n // An exclusive holder writes its record into the lock file itself.\n try {\n const info = JSON.parse(fs.readFileSync(path.join(locksDir, name), \"utf8\"));\n if (info && info.pid === child.pid) return name;\n } catch {}\n }\n return null;\n};\nconst someoneWaiting = () => {\n if (fs.existsSync(cancelPath)) return true;\n if (!lockName) lockName = findLock();\n if (!lockName) return false;\n let names;\n try { names = fs.readdirSync(locksDir); } catch { return false; }\n const prefix = lockName + \".wait-\";\n for (const name of names) {\n if (!name.startsWith(prefix)) continue;\n const waiter = Number(name.slice(prefix.length).split(\"-\")[0]);\n if (Number.isInteger(waiter) && waiter > 0 && waiter !== child.pid && waiter !== process.pid && alive(waiter)) return true;\n }\n return false;\n};\nwatch = setInterval(() => {\n if (finished || stopAt) return;\n if (someoneWaiting()) {\n preempted = true;\n stop();\n }\n}, 500);\nchild.on(\"error\", (error) => {\n try { fs.appendFileSync(logPath, String((error && error.code) || error) + \"\\n\"); } catch {}\n done(null, null);\n});\nchild.on(\"exit\", (status, signal) => done(status, signal));\n";
200
+ export declare const REFRESH_SUPERVISOR_SOURCE = "\nconst fs = require(\"node:fs\");\nconst path = require(\"node:path\");\nconst { spawn, spawnSync } = require(\"node:child_process\");\nconst [logPath, exitPath, hbPath, pidPath, cancelPath, locksDir, maxMs, cmd, ...args] = process.argv.slice(1);\nconst isWin = process.platform === \"win32\";\nconst beat = () => { try { fs.writeFileSync(hbPath, String(Date.now())); } catch {} };\nbeat();\nconst hb = setInterval(beat, 10000);\nlet fd;\ntry { fd = fs.openSync(logPath, \"a\", 0o600); } catch { fd = \"ignore\"; }\nlet finished = false;\nlet preempted = false;\nlet capped = false;\nlet stopAt = 0;\nlet watch;\n// Its own process group on POSIX, so a stop reaches every process the pull started.\nconst child = spawn(cmd, args, { stdio: [\"ignore\", fd, fd], windowsHide: true, detached: !isWin });\ntry { fs.writeFileSync(pidPath + \".tmp\", String(child.pid)); fs.renameSync(pidPath + \".tmp\", pidPath); } catch {}\nif (!isWin && child.pid) {\n try {\n const r = spawnSync(\"ps\", [\"-o\", \"lstart=\", \"-p\", String(child.pid)], { encoding: \"utf8\" });\n const started = (r.stdout || \"\").trim();\n if (started) fs.writeFileSync(path.join(path.dirname(pidPath), path.basename(pidPath, \".pid\") + \".start\"), started);\n } catch {}\n}\nconst killTree = (sig) => {\n if (isWin) {\n try { spawnSync(\"taskkill\", [\"/PID\", String(child.pid), \"/T\", \"/F\"], { stdio: \"ignore\", windowsHide: true }); } catch {}\n return;\n }\n try { process.kill(-child.pid, sig); } catch {}\n};\nconst stop = () => {\n if (stopAt) return;\n stopAt = Date.now();\n killTree(\"SIGTERM\");\n setTimeout(() => killTree(\"SIGKILL\"), 5000);\n};\nconst exitNow = (status) => process.exit(typeof status === \"number\" ? status : 1);\nconst done = (status, signal) => {\n if (finished) return;\n finished = true;\n clearInterval(hb);\n clearInterval(watch);\n clearTimeout(stopper);\n try {\n fs.writeFileSync(exitPath + \".tmp\", JSON.stringify({ status, signal, preempted, capped }));\n fs.renameSync(exitPath + \".tmp\", exitPath);\n } catch {}\n if (!stopAt) return exitNow(status);\n // A stopped pull's group is always SIGKILLed after the grace period, even\n // when the pull itself exited on SIGTERM, so no grandchild survives.\n const left = Math.max(0, stopAt + 5000 - Date.now());\n setTimeout(() => { killTree(\"SIGKILL\"); exitNow(status); }, left);\n};\nconst stopper = setTimeout(() => {\n capped = true;\n // At the cap the pull is no longer live: stop heartbeating so nothing reads it as in progress.\n clearInterval(hb);\n try { fs.writeFileSync(hbPath, \"capped:\" + Date.now()); } catch {}\n stop();\n}, Number(maxMs));\nconst alive = (pid) => { try { process.kill(pid, 0); return true; } catch (e) { return Boolean(e && e.code === \"EPERM\"); } };\nlet lockName = null;\nconst findLock = () => {\n let names;\n try { names = fs.readdirSync(locksDir); } catch { return null; }\n for (const name of names) {\n // A sync holds shared membership: <lock>.shared-<pid>-<hex>.\n const shared = /^(.+\\.lock)\\.shared-(\\d+)-/.exec(name);\n if (shared && Number(shared[2]) === child.pid) return shared[1];\n if (!name.endsWith(\".lock\")) continue;\n // An exclusive holder writes its record into the lock file itself.\n try {\n const info = JSON.parse(fs.readFileSync(path.join(locksDir, name), \"utf8\"));\n if (info && info.pid === child.pid) return name;\n } catch {}\n }\n return null;\n};\nconst someoneWaiting = () => {\n if (fs.existsSync(cancelPath)) return true;\n if (!lockName) lockName = findLock();\n if (!lockName) return false;\n let names;\n try { names = fs.readdirSync(locksDir); } catch { return false; }\n const prefix = lockName + \".wait-\";\n for (const name of names) {\n if (!name.startsWith(prefix)) continue;\n const waiter = Number(name.slice(prefix.length).split(\"-\")[0]);\n if (Number.isInteger(waiter) && waiter > 0 && waiter !== child.pid && waiter !== process.pid && alive(waiter)) return true;\n }\n return false;\n};\nwatch = setInterval(() => {\n if (finished || stopAt) return;\n if (someoneWaiting()) {\n preempted = true;\n stop();\n }\n}, 500);\nchild.on(\"error\", (error) => {\n try { fs.appendFileSync(logPath, String((error && error.code) || error) + \"\\n\"); } catch {}\n done(null, null);\n});\nchild.on(\"exit\", (status, signal) => done(status, signal));\n";
201
201
  //# sourceMappingURL=refresh-sync-handoff.d.ts.map
@@ -690,7 +690,7 @@ let stopAt = 0;
690
690
  let watch;
691
691
  // Its own process group on POSIX, so a stop reaches every process the pull started.
692
692
  const child = spawn(cmd, args, { stdio: ["ignore", fd, fd], windowsHide: true, detached: !isWin });
693
- try { fs.writeFileSync(pidPath, String(child.pid)); } catch {}
693
+ try { fs.writeFileSync(pidPath + ".tmp", String(child.pid)); fs.renameSync(pidPath + ".tmp", pidPath); } catch {}
694
694
  if (!isWin && child.pid) {
695
695
  try {
696
696
  const r = spawnSync("ps", ["-o", "lstart=", "-p", String(child.pid)], { encoding: "utf8" });
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Client-gate headers sent on every `/v1/flags/resolve` request, matching
3
+ * `hq-pro` `src/flags/client-gates.ts` (`x-hq-client-version` and
4
+ * `x-hq-client-platform`).
5
+ *
6
+ * This module has no file-system reads and no global `fetch` reference. The
7
+ * embedded flag-registry worker bundles it and runs as
8
+ * `new Worker(source, { eval: true })`, with no module URL, so the CLI version
9
+ * is passed in by the caller (workerData for the worker, `CLI_VERSION` in
10
+ * `flag-client-headers.ts` for the main thread). Nothing here may resolve a
11
+ * path relative to its own file.
12
+ */
13
+ import type { FlagClientOptions } from "@indigoai-us/hq-flags-client";
14
+ export declare const CLIENT_VERSION_HEADER = "x-hq-client-version";
15
+ export declare const CLIENT_PLATFORM_HEADER = "x-hq-client-platform";
16
+ /** The `fetch` shape `@indigoai-us/hq-flags-client` calls. */
17
+ export type FlagFetch = NonNullable<FlagClientOptions["fetch"]>;
18
+ /**
19
+ * Map Node's `process.platform` onto the header value expected by
20
+ * `hq-pro` `src/flags/client-gates.ts` (`darwin`, `linux`, `windows`).
21
+ */
22
+ export declare function clientGatePlatform(platform?: NodeJS.Platform): string;
23
+ /**
24
+ * The version header value, or undefined when the version could not be read.
25
+ * A missing header is stored as null by the server, and only rows that carry a
26
+ * gate deny on it, so an unreadable version is sent as no header at all
27
+ * rather than as a placeholder.
28
+ */
29
+ export declare function clientGateVersion(version: unknown): string | undefined;
30
+ /** Client-gate headers for `/v1/flags/resolve`. The version header is omitted when unreadable. */
31
+ export declare function clientGateHeaders(version: unknown, platform?: NodeJS.Platform): Record<string, string>;
32
+ /**
33
+ * Wrap a flag-client `fetch` so every request carries the client-gate headers.
34
+ * Headers stay a plain object, so a caller-supplied fetch that reads
35
+ * `init.headers.authorization` sees the same shape the flag client built.
36
+ */
37
+ export declare function withClientGateHeaders(baseFetch: FlagFetch, version: unknown, platform?: NodeJS.Platform): FlagFetch;
38
+ //# sourceMappingURL=flag-client-gate-headers.d.ts.map
@@ -0,0 +1,62 @@
1
+ export const CLIENT_VERSION_HEADER = "x-hq-client-version";
2
+ export const CLIENT_PLATFORM_HEADER = "x-hq-client-platform";
3
+ /** Longest version string `hq-pro` accepts in `x-hq-client-version`. */
4
+ const MAX_CLIENT_VERSION_LENGTH = 64;
5
+ /**
6
+ * Map Node's `process.platform` onto the header value expected by
7
+ * `hq-pro` `src/flags/client-gates.ts` (`darwin`, `linux`, `windows`).
8
+ */
9
+ export function clientGatePlatform(platform = process.platform) {
10
+ return platform === "win32" ? "windows" : platform;
11
+ }
12
+ /**
13
+ * The version header value, or undefined when the version could not be read.
14
+ * A missing header is stored as null by the server, and only rows that carry a
15
+ * gate deny on it, so an unreadable version is sent as no header at all
16
+ * rather than as a placeholder.
17
+ */
18
+ export function clientGateVersion(version) {
19
+ if (typeof version !== "string")
20
+ return undefined;
21
+ const trimmed = version.trim();
22
+ if (trimmed.length === 0 || trimmed.length > MAX_CLIENT_VERSION_LENGTH)
23
+ return undefined;
24
+ return trimmed;
25
+ }
26
+ /** Client-gate headers for `/v1/flags/resolve`. The version header is omitted when unreadable. */
27
+ export function clientGateHeaders(version, platform = process.platform) {
28
+ const headers = {};
29
+ const clientVersion = clientGateVersion(version);
30
+ if (clientVersion !== undefined)
31
+ headers[CLIENT_VERSION_HEADER] = clientVersion;
32
+ headers[CLIENT_PLATFORM_HEADER] = clientGatePlatform(platform);
33
+ return headers;
34
+ }
35
+ /** Copy request headers of any `HeadersInit` shape into a plain record. */
36
+ function plainHeaders(headers) {
37
+ if (headers === undefined || headers === null)
38
+ return {};
39
+ if (Array.isArray(headers))
40
+ return Object.fromEntries(headers.map(([key, value]) => [key, value]));
41
+ if (typeof headers.forEach === "function" &&
42
+ typeof headers.get === "function") {
43
+ const record = {};
44
+ headers
45
+ .forEach((value, key) => { record[key] = value; });
46
+ return record;
47
+ }
48
+ return { ...headers };
49
+ }
50
+ /**
51
+ * Wrap a flag-client `fetch` so every request carries the client-gate headers.
52
+ * Headers stay a plain object, so a caller-supplied fetch that reads
53
+ * `init.headers.authorization` sees the same shape the flag client built.
54
+ */
55
+ export function withClientGateHeaders(baseFetch, version, platform = process.platform) {
56
+ const gateHeaders = clientGateHeaders(version, platform);
57
+ return ((input, init) => baseFetch(input, {
58
+ ...init,
59
+ headers: { ...plainHeaders(init?.headers), ...gateHeaders },
60
+ }));
61
+ }
62
+ //# sourceMappingURL=flag-client-gate-headers.js.map
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Main-thread flag clients that send the client-gate headers
3
+ * (`x-hq-client-version`, `x-hq-client-platform`) on every
4
+ * `/v1/flags/resolve` request, matching `hq-pro` `src/flags/client-gates.ts`.
5
+ *
6
+ * The header logic lives in `flag-client-gate-headers.ts`; the embedded
7
+ * flag-registry worker keeps its own copy and gets the version through
8
+ * workerData. The version comes from `client-version.ts`, which never throws:
9
+ * an unreadable version sends the request without the version header.
10
+ */
11
+ import { type FlagClient, type FlagClientOptions } from "@indigoai-us/hq-flags-client";
12
+ export { CLIENT_PLATFORM_HEADER, CLIENT_VERSION_HEADER, clientGateHeaders, clientGatePlatform, clientGateVersion, withClientGateHeaders, type FlagFetch, } from "./flag-client-gate-headers.js";
13
+ /** Drop-in `createFlagClient` wrapper that injects client-gate headers on every request. */
14
+ export declare function createHqFlagClient(options: FlagClientOptions): FlagClient;
15
+ //# sourceMappingURL=flag-client-headers.d.ts.map
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Main-thread flag clients that send the client-gate headers
3
+ * (`x-hq-client-version`, `x-hq-client-platform`) on every
4
+ * `/v1/flags/resolve` request, matching `hq-pro` `src/flags/client-gates.ts`.
5
+ *
6
+ * The header logic lives in `flag-client-gate-headers.ts`; the embedded
7
+ * flag-registry worker keeps its own copy and gets the version through
8
+ * workerData. The version comes from `client-version.ts`, which never throws:
9
+ * an unreadable version sends the request without the version header.
10
+ */
11
+ import { createFlagClient as createRawFlagClient, } from "@indigoai-us/hq-flags-client";
12
+ import { readClientVersion } from "./client-version.js";
13
+ import { withClientGateHeaders } from "./flag-client-gate-headers.js";
14
+ export { CLIENT_PLATFORM_HEADER, CLIENT_VERSION_HEADER, clientGateHeaders, clientGatePlatform, clientGateVersion, withClientGateHeaders, } from "./flag-client-gate-headers.js";
15
+ /** Drop-in `createFlagClient` wrapper that injects client-gate headers on every request. */
16
+ export function createHqFlagClient(options) {
17
+ const baseFetch = options.fetch ?? globalThis.fetch;
18
+ return createRawFlagClient({
19
+ ...options,
20
+ ...(typeof baseFetch === "function"
21
+ ? { fetch: withClientGateHeaders(baseFetch, readClientVersion()) }
22
+ : {}),
23
+ });
24
+ }
25
+ //# sourceMappingURL=flag-client-headers.js.map