@indigoai-us/hq-cli 5.345.262 → 5.345.264

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 (64) hide show
  1. package/CHANGELOG.md +69 -0
  2. package/contracts/host-canary-release.json +7 -7
  3. package/dist/command-catalog.generated.d.ts +37 -0
  4. package/dist/command-catalog.generated.js +46 -0
  5. package/dist/command-registration-plan.d.ts +6 -0
  6. package/dist/command-registration-plan.js +1 -0
  7. package/dist/commands/bot.d.ts +2 -0
  8. package/dist/commands/bot.js +4 -3
  9. package/dist/commands/core-handoff.js +273 -115
  10. package/dist/commands/sync-held.d.ts +11 -0
  11. package/dist/commands/sync-held.js +65 -1
  12. package/dist/commands/sync-telemetry-report.d.ts +5 -0
  13. package/dist/commands/sync-telemetry-report.js +239 -0
  14. package/dist/commands/sync-telemetry.d.ts +47 -0
  15. package/dist/commands/sync-telemetry.js +309 -0
  16. package/dist/index.js +107 -43
  17. package/dist/lib/bot/runnable.d.ts +17 -7
  18. package/dist/lib/bot/runnable.js +17 -10
  19. package/dist/lib/capacity/available.js +6 -2
  20. package/dist/lib/capacity/collectors/claude-oauth.d.ts +10 -256
  21. package/dist/lib/capacity/collectors/claude-oauth.js +19 -1078
  22. package/dist/lib/capacity/ledger.d.ts +12 -1
  23. package/dist/lib/capacity/ledger.js +15 -5
  24. package/dist/lib/capacity/route.d.ts +2 -0
  25. package/dist/lib/capacity/route.js +21 -4
  26. package/dist/lib/capacity/scheduler.js +2 -3
  27. package/dist/lib/capacity/sign-in.js +4 -4
  28. package/dist/lib/daemon/ops/skill-command.d.ts +2 -0
  29. package/dist/lib/daemon/ops/skill-command.js +7 -1
  30. package/dist/lib/doctor/checks/antigravity-wiring.d.ts +2 -1
  31. package/dist/lib/doctor/checks/antigravity-wiring.js +59 -3
  32. package/dist/lib/doctor/checks/hook-engine.d.ts +2 -0
  33. package/dist/lib/doctor/checks/hook-engine.js +100 -1
  34. package/dist/lib/doctor/checks/host-core.d.ts +1 -1
  35. package/dist/lib/doctor/checks/host-core.js +11 -4
  36. package/dist/lib/hook-engine/coverage.d.ts +19 -10
  37. package/dist/lib/hook-engine/coverage.js +103 -24
  38. package/dist/lib/hook-engine/native-precompact-compatibility.json +7 -1
  39. package/dist/lib/hook-engine/native-stop-compatibility.json +8 -4
  40. package/dist/lib/hook-engine/reconcile.js +49 -1
  41. package/dist/lib/install/antigravity-targets.d.ts +22 -0
  42. package/dist/lib/install/antigravity-targets.js +82 -0
  43. package/dist/main.js +8 -3
  44. package/dist/sentry-init.d.ts +7 -1
  45. package/dist/sentry-init.js +6 -2
  46. package/dist/sentry.d.ts +7 -0
  47. package/dist/sentry.js +16 -1
  48. package/dist/started-version.d.ts +13 -0
  49. package/dist/started-version.js +34 -0
  50. package/dist/startup-registration.d.ts +9 -9
  51. package/dist/startup-registration.js +42 -18
  52. package/dist/utils/client-health.d.ts +1 -0
  53. package/dist/utils/client-health.js +54 -11
  54. package/dist/utils/core-next-kill.d.ts +9 -0
  55. package/dist/utils/core-next-kill.js +22 -0
  56. package/dist/utils/delegate-lock.js +19 -1
  57. package/dist/utils/host-registration.d.ts +4 -2
  58. package/dist/utils/host-registration.js +55 -7
  59. package/dist/utils/install-tree-recovery-markers.d.ts +45 -0
  60. package/dist/utils/install-tree-recovery-markers.js +70 -0
  61. package/dist/utils/install-tree-torn.d.ts +102 -5
  62. package/dist/utils/install-tree-torn.js +199 -2
  63. package/dist/utils/sentry-fingerprint.js +3 -0
  64. package/package.json +7 -7
@@ -0,0 +1,70 @@
1
+ /**
2
+ * One-shot recovery markers for a process restarted by torn-install recovery.
3
+ *
4
+ * The parent passes `HQ_INSTALL_TREE_RECOVERED=1` and
5
+ * `HQ_INSTALL_TREE_RECOVERY_TREE_STATE` in the re-exec environment so the
6
+ * restarted child can never loop. Consuming those markers into process memory
7
+ * and removing them from `process.env` guarantees two things at once:
8
+ *
9
+ * 1. Every recovery seam inside THIS process (`index.ts`, fast routes, and
10
+ * `main.ts`) still sees the one-shot guard through `installTreeRecoveryEnv`
11
+ * and fails closed (`outcome: "guarded"`, `attempt: 2`) instead of looping.
12
+ * 2. Descendant `hq` processes spawned by the restarted command (hooks,
13
+ * runners, `hq daemon`, MCP children) do not inherit the markers and can
14
+ * recover from a later torn install on their own.
15
+ *
16
+ * Kept dependency-free so `index.ts` can load it at entry without growing any
17
+ * fast-path module closure.
18
+ */
19
+ /**
20
+ * Set on the re-exec'd child so it can NEVER wait or re-exec again — distinct
21
+ * from self-update's HQ_RESCUE_SELF_UPDATED so the two recovery paths cannot
22
+ * shadow each other.
23
+ */
24
+ export const INSTALL_TREE_RECOVERY_GUARD_ENV = "HQ_INSTALL_TREE_RECOVERED";
25
+ /** Carries the writer-state observed by the parent into the guarded re-exec. */
26
+ export const INSTALL_TREE_RECOVERY_TREE_STATE_ENV = "HQ_INSTALL_TREE_RECOVERY_TREE_STATE";
27
+ const ONE_SHOT_RECOVERY_KEYS = [
28
+ INSTALL_TREE_RECOVERY_GUARD_ENV,
29
+ INSTALL_TREE_RECOVERY_TREE_STATE_ENV,
30
+ ];
31
+ let consumedRecoveryMarkers;
32
+ /**
33
+ * Consume the one-shot torn-install recovery markers from `env` and remove them
34
+ * so spawned child processes cannot inherit them. When called on `process.env`,
35
+ * retains them in process memory for this process's own recovery seams.
36
+ */
37
+ export function consumeInstallTreeRecoveryMarkers(env = process.env) {
38
+ const markers = {};
39
+ for (const key of ONE_SHOT_RECOVERY_KEYS) {
40
+ const value = env[key];
41
+ if (typeof value === "string" && value !== "")
42
+ markers[key] = value;
43
+ delete env[key];
44
+ }
45
+ const hasMarkers = Object.keys(markers).length > 0;
46
+ if (env === process.env) {
47
+ consumedRecoveryMarkers = hasMarkers ? markers : undefined;
48
+ }
49
+ return hasMarkers ? markers : undefined;
50
+ }
51
+ /**
52
+ * Remove the one-shot recovery markers from `env` without recording them.
53
+ * Called once startup registration succeeds so direct callers that did not go
54
+ * through `index.ts` also avoid leaking markers to descendants.
55
+ */
56
+ export function clearInstallTreeRecoveryEnv(env = process.env) {
57
+ delete env[INSTALL_TREE_RECOVERY_GUARD_ENV];
58
+ delete env[INSTALL_TREE_RECOVERY_TREE_STATE_ENV];
59
+ }
60
+ /**
61
+ * Re-attach this process's consumed one-shot recovery markers to an env view
62
+ * passed into `registerCommandsWithRecovery`, so multi-stage startup seams in
63
+ * the same restarted process still enforce the single-restart loop guard.
64
+ */
65
+ export function installTreeRecoveryEnv(base) {
66
+ if (!consumedRecoveryMarkers)
67
+ return base;
68
+ return { ...consumedRecoveryMarkers, ...base };
69
+ }
70
+ //# sourceMappingURL=install-tree-recovery-markers.js.map
@@ -29,7 +29,15 @@
29
29
  * ../startup-registration.ts; version-gate.ts / self-update.ts / update-lock.ts
30
30
  * are only READ (their exported symbols), never modified.
31
31
  */
32
+ import { INSTALL_TREE_RECOVERY_GUARD_ENV } from "./install-tree-recovery-markers.js";
32
33
  import { MISSING_REGISTRATION_PLAN_CODE } from "./registration-plan-error.js";
34
+ export { INSTALL_TREE_RECOVERY_GUARD_ENV };
35
+ /** Fixed message for the counted, non-error Sentry event emitted on a mixed-install restart. */
36
+ export declare const MIXED_INSTALL_RESTART_EVENT_MESSAGE = "hq-cli detected a mixed install (on-disk version changed) and restarted once";
37
+ /** Metric name for counting mixed-install restarts alongside the info event. */
38
+ export declare const MIXED_INSTALL_RESTART_METRIC = "hq_cli.install_tree.mixed_install_restart";
39
+ /** Bounded explicit fingerprint so all mixed-install restarts count into one non-error group. */
40
+ export declare const MIXED_INSTALL_RESTART_FINGERPRINT: readonly ["install-tree-torn", "mixed-install-restart"];
33
41
  /**
34
42
  * The loader-error `code`s recovery classifies. The first two mean "a module
35
43
  * could not be resolved"; `ENOENT` is the loader/resolver dialect where a module
@@ -39,7 +47,7 @@ import { MISSING_REGISTRATION_PLAN_CODE } from "./registration-plan-error.js";
39
47
  * {@link ModuleErrorDialect}. `ERR_HQ_NO_REGISTRATION_PLAN` is hq-cli's own code
40
48
  * for a catalog root the registration plan does not know (HQ-CLI-GM).
41
49
  */
42
- type ModuleNotFoundCode = "ERR_MODULE_NOT_FOUND" | "MODULE_NOT_FOUND" | "ENOENT" | "EVAL_THROW" | typeof MISSING_REGISTRATION_PLAN_CODE;
50
+ type ModuleNotFoundCode = "ERR_MODULE_NOT_FOUND" | "MODULE_NOT_FOUND" | "ENOENT" | "EVAL_THROW" | typeof MISSING_REGISTRATION_PLAN_CODE | "VERSION_SKEW";
43
51
  /**
44
52
  * The closed set of resolution-failure dialects, verified on Node v22.23.1 and
45
53
  * the observed Node 24 synchronous ESM loader shape (the @sentry/node
@@ -86,7 +94,7 @@ type ModuleNotFoundCode = "ERR_MODULE_NOT_FOUND" | "MODULE_NOT_FOUND" | "ENOENT"
86
94
  * - `unknown`: a module-not-found whose message did not parse; recovery
87
95
  * still waits on the lock / retired-dir / quiet signals.
88
96
  */
89
- type ModuleErrorDialect = "esm-path" | "esm-package" | "cjs-path" | "cjs-package" | "cjs-relative" | "esm-enoent" | "cjs-enoent" | "resolve-enoent" | "eval-throw" | "missing-plan" | "unknown";
97
+ type ModuleErrorDialect = "esm-path" | "esm-package" | "cjs-path" | "cjs-package" | "cjs-relative" | "esm-enoent" | "cjs-enoent" | "resolve-enoent" | "eval-throw" | "missing-plan" | "version-skew" | "unknown";
90
98
  /**
91
99
  * The missing thing, re-resolvable by the readiness probe:
92
100
  * - `path`: an absolute filesystem path (a `.js` file, or a package dir).
@@ -129,8 +137,12 @@ export interface ClassifiedModuleError {
129
137
  /** The importer the message named (from-clause or requireStack[0]), or "". */
130
138
  importer: string;
131
139
  target: ModuleErrorTarget;
132
- /** The thrown error's `name` for the eval-throw dialect (HQ-CLI-1T), else absent. */
140
+ /** The thrown error's `name` for the eval-throw or version-skew dialect, else absent. */
133
141
  errorName?: string;
142
+ /** Version this process started with when `dialect === "version-skew"`. */
143
+ startedVersion?: string;
144
+ /** Version currently on disk in `<packageRoot>/package.json` when `dialect === "version-skew"`. */
145
+ onDiskVersion?: string;
134
146
  }
135
147
  /**
136
148
  * The Node module RESOLVER frame — `finalizeResolution` in
@@ -204,6 +216,51 @@ export declare function evalThrowShape(err: unknown): EvalThrowShape | null;
204
216
  * missing file, so recovery keys entirely on the writer signal + quiet window.
205
217
  */
206
218
  export declare function classifyEvalThrow(err: unknown, packageRoot: string | null): ClassifiedModuleError | null;
219
+ /** Observed mismatch between the running process's startup version and the install on disk. */
220
+ export interface InstallVersionSkew {
221
+ startedVersion: string;
222
+ onDiskVersion: string;
223
+ }
224
+ export interface DetectInstallVersionSkewArgs {
225
+ /** The running install's package dir (from resolveRunningInstall or derived root), or null. */
226
+ packageRoot: string | null;
227
+ /** CLI version this process started with (defaults to CLI_VERSION). */
228
+ startedVersion?: string;
229
+ fs?: InstallTreeFs;
230
+ }
231
+ /**
232
+ * Read the installed `@indigoai-us/hq-cli` version currently on disk at
233
+ * `<packageRoot>/package.json`, or return `null` when the manifest is absent,
234
+ * unreadable, malformed, or belongs to a different package. Never throws.
235
+ */
236
+ export declare function readInstalledPackageVersion(packageRoot: string | null, fs?: InstallTreeFs): string | null;
237
+ /**
238
+ * Return the version pair when the installed `package.json` on disk holds a
239
+ * DIFFERENT version than the version this process started with (HQ-CLI-HD), or
240
+ * `null` when the version is unchanged or cannot be verified on disk.
241
+ */
242
+ export declare function detectInstallVersionSkew(args: DetectInstallVersionSkewArgs): InstallVersionSkew | null;
243
+ /**
244
+ * Classify a startup error as a mixed-install failure (HQ-CLI-HD) whenever the
245
+ * installed `package.json` on disk now reports a DIFFERENT CLI version than the
246
+ * one this process started with.
247
+ *
248
+ * When an updater (such as the desktop app) swaps the CLI install folder while a
249
+ * process is starting, newly imported modules from the new release sit beside old
250
+ * modules already in memory and can throw export-mismatch SyntaxErrors, TypeErrors
251
+ * inside `dist/`, or ERR_MODULE_NOT_FOUND for files renamed between releases —
252
+ * none of which match the same-version torn-install classifiers or recover if the
253
+ * wait polls for a deleted old filename. Using `target: { kind: "unknown" }` lets
254
+ * the settle wait check lock/manifest/retired-sibling health and restart the
255
+ * process cleanly on the new release once.
256
+ *
257
+ * Returns `null` whenever the version on disk matches `startedVersion` or cannot
258
+ * be read, so ordinary defects keep their normal error reporting unchanged.
259
+ */
260
+ export declare function classifyInstallVersionSkew(err: unknown, packageRoot: string | null, options?: {
261
+ startedVersion?: string;
262
+ fs?: InstallTreeFs;
263
+ }): ClassifiedModuleError | null;
207
264
  /** The filesystem surface the probe and wait use, injectable for hermetic tests. */
208
265
  export interface InstallTreeFs {
209
266
  existsSync(p: string): boolean;
@@ -389,8 +446,12 @@ export type InstallTreeTornDiagnostics = {
389
446
  node: string;
390
447
  /** Presence on the final poll when the scope directory could be observed. */
391
448
  retiredSiblingPresent?: boolean;
392
- /** The thrown error's `name` for the eval-throw dialect (HQ-CLI-1T), else "". */
449
+ /** The thrown error's `name` for the eval-throw or version-skew dialect, else "". */
393
450
  errorName: string;
451
+ /** Version this process started with when `dialect === "version-skew"`. */
452
+ startedVersion?: string;
453
+ /** Version on disk when `dialect === "version-skew"`. */
454
+ onDiskVersion?: string;
394
455
  retiredSiblingKind: RetiredSiblingKind;
395
456
  installTargetState: InstallTargetState;
396
457
  versionGatePhase: VersionGatePhase;
@@ -468,5 +529,41 @@ export declare const INSTALL_TREE_LOCK_HELD_REMEDY: string;
468
529
  * {@link INSTALL_TREE_TORN_REMEDY} byte-for-byte.
469
530
  */
470
531
  export declare function installTreeTornStderrLine(err: InstallTreeTornError): string;
471
- export {};
532
+ /** Bounded payload recorded when a mixed install recovers by restarting once (HQ-CLI-HD). */
533
+ export interface MixedInstallRestartEvent {
534
+ startedVersion: string;
535
+ onDiskVersion: string;
536
+ errorName: string;
537
+ waitedMs: number;
538
+ sawLock: boolean;
539
+ sawRetired: boolean;
540
+ }
541
+ /** Minimal Sentry surface required to record a counted, non-error mixed-install restart. */
542
+ export interface MixedInstallRestartReporterSentry {
543
+ captureMessage: (message: string, context?: {
544
+ level?: "info" | "warning" | "error" | "log" | "debug" | "fatal";
545
+ fingerprint?: string[];
546
+ tags?: Record<string, string>;
547
+ contexts?: Record<string, Record<string, unknown>>;
548
+ }) => unknown;
549
+ metrics?: {
550
+ count?: (name: string, value?: number, options?: {
551
+ attributes?: Record<string, string>;
552
+ }) => unknown;
553
+ };
554
+ flush?: (timeout?: number) => PromiseLike<boolean>;
555
+ }
556
+ export interface RecordMixedInstallRestartDeps {
557
+ sentry?: MixedInstallRestartReporterSentry;
558
+ argv?: readonly string[];
559
+ env?: NodeJS.ProcessEnv;
560
+ flushTimeoutMs?: number;
561
+ }
562
+ /**
563
+ * Record a mixed-install recovery restart as a counted, non-error Sentry event
564
+ * (info-level message + counter metric, never an unhandled exception) so the
565
+ * incident remains measurable after the user-side restart fixes the failure.
566
+ * Never throws and never blocks recovery on telemetry failure.
567
+ */
568
+ export declare function recordMixedInstallRestart(event: MixedInstallRestartEvent, deps?: RecordMixedInstallRestartDeps): Promise<void>;
472
569
  //# sourceMappingURL=install-tree-torn.d.ts.map
@@ -33,11 +33,23 @@ import * as nodeFs from "node:fs";
33
33
  import { homedir } from "node:os";
34
34
  import * as path from "node:path";
35
35
  import { fileURLToPath } from "node:url";
36
- import { CLI_NAME } from "../cli-version.js";
36
+ import { CLI_NAME, CLI_VERSION } from "../cli-version.js";
37
+ import { runSentryInitialization } from "./cli-network-lifecycle.js";
38
+ import { INSTALL_TREE_RECOVERY_GUARD_ENV } from "./install-tree-recovery-markers.js";
37
39
  import { boundedDiagnosticValue } from "./package-root-diagnostics.js";
38
40
  import { isLockStale, UPDATE_LOCK_STALE_MS } from "./update-lock.js";
39
41
  import { HQ_CLI_NPM_UPDATE_COMMAND } from "./npm-install-flags.js";
40
42
  import { MISSING_REGISTRATION_PLAN_CODE } from "./registration-plan-error.js";
43
+ export { INSTALL_TREE_RECOVERY_GUARD_ENV };
44
+ /** Fixed message for the counted, non-error Sentry event emitted on a mixed-install restart. */
45
+ export const MIXED_INSTALL_RESTART_EVENT_MESSAGE = "hq-cli detected a mixed install (on-disk version changed) and restarted once";
46
+ /** Metric name for counting mixed-install restarts alongside the info event. */
47
+ export const MIXED_INSTALL_RESTART_METRIC = "hq_cli.install_tree.mixed_install_restart";
48
+ /** Bounded explicit fingerprint so all mixed-install restarts count into one non-error group. */
49
+ export const MIXED_INSTALL_RESTART_FINGERPRINT = [
50
+ "install-tree-torn",
51
+ "mixed-install-restart",
52
+ ];
41
53
  /** Byte caps for the (hq-derived, path-shaped) diagnostic strings. */
42
54
  const SPECIFIER_BYTES = 256;
43
55
  const IMPORTER_BYTES = 256;
@@ -46,6 +58,8 @@ const PACKAGE_ROOT_BYTES = 256;
46
58
  const LOCK_TOOL_BYTES = 64;
47
59
  /** The eval-throw error name is a short closed-set token; the cap is only a belt. */
48
60
  const ERRORNAME_BYTES = 64;
61
+ /** Byte cap for CLI version strings recorded in version-skew diagnostics/tags. */
62
+ const VERSION_BYTES = 64;
49
63
  const ESM_PACKAGE_RE = /^Cannot find package '([^']+)' imported from (.+)$/s;
50
64
  const CJS_MODULE_RE = /^Cannot find module '([^']+)'/s;
51
65
  const ESM_MODULE_IMPORTED_RE = /^Cannot find module '([^']+)' imported from (.+)$/s;
@@ -489,6 +503,88 @@ export function classifyEvalThrow(err, packageRoot) {
489
503
  errorName: shape.errorName,
490
504
  };
491
505
  }
506
+ /**
507
+ * Read the installed `@indigoai-us/hq-cli` version currently on disk at
508
+ * `<packageRoot>/package.json`, or return `null` when the manifest is absent,
509
+ * unreadable, malformed, or belongs to a different package. Never throws.
510
+ */
511
+ export function readInstalledPackageVersion(packageRoot, fs = nodeInstallTreeFs) {
512
+ if (!packageRoot)
513
+ return null;
514
+ try {
515
+ const raw = fs.readFileSync(path.join(packageRoot, "package.json"), "utf-8");
516
+ const parsed = JSON.parse(raw);
517
+ if (parsed === null || typeof parsed !== "object")
518
+ return null;
519
+ if (parsed.name !== CLI_NAME)
520
+ return null;
521
+ if (typeof parsed.version !== "string")
522
+ return null;
523
+ const trimmed = parsed.version.trim();
524
+ return trimmed.length > 0 ? trimmed : null;
525
+ }
526
+ catch {
527
+ return null;
528
+ }
529
+ }
530
+ /**
531
+ * Return the version pair when the installed `package.json` on disk holds a
532
+ * DIFFERENT version than the version this process started with (HQ-CLI-HD), or
533
+ * `null` when the version is unchanged or cannot be verified on disk.
534
+ */
535
+ export function detectInstallVersionSkew(args) {
536
+ const startedVersion = (args.startedVersion ?? CLI_VERSION).trim();
537
+ if (!startedVersion)
538
+ return null;
539
+ const onDiskVersion = readInstalledPackageVersion(args.packageRoot, args.fs);
540
+ if (onDiskVersion === null || onDiskVersion === startedVersion)
541
+ return null;
542
+ return { startedVersion, onDiskVersion };
543
+ }
544
+ /**
545
+ * Classify a startup error as a mixed-install failure (HQ-CLI-HD) whenever the
546
+ * installed `package.json` on disk now reports a DIFFERENT CLI version than the
547
+ * one this process started with.
548
+ *
549
+ * When an updater (such as the desktop app) swaps the CLI install folder while a
550
+ * process is starting, newly imported modules from the new release sit beside old
551
+ * modules already in memory and can throw export-mismatch SyntaxErrors, TypeErrors
552
+ * inside `dist/`, or ERR_MODULE_NOT_FOUND for files renamed between releases —
553
+ * none of which match the same-version torn-install classifiers or recover if the
554
+ * wait polls for a deleted old filename. Using `target: { kind: "unknown" }` lets
555
+ * the settle wait check lock/manifest/retired-sibling health and restart the
556
+ * process cleanly on the new release once.
557
+ *
558
+ * Returns `null` whenever the version on disk matches `startedVersion` or cannot
559
+ * be read, so ordinary defects keep their normal error reporting unchanged.
560
+ */
561
+ export function classifyInstallVersionSkew(err, packageRoot, options) {
562
+ if (err === null || typeof err !== "object")
563
+ return null;
564
+ if (isInstallTreeTornError(err))
565
+ return null;
566
+ const skew = detectInstallVersionSkew({
567
+ packageRoot,
568
+ startedVersion: options?.startedVersion,
569
+ fs: options?.fs,
570
+ });
571
+ if (!skew)
572
+ return null;
573
+ const record = err;
574
+ const errorName = typeof record.name === "string" && record.name.trim().length > 0
575
+ ? boundedDiagnosticValue(record.name.trim(), ERRORNAME_BYTES)
576
+ : undefined;
577
+ return {
578
+ code: "VERSION_SKEW",
579
+ dialect: "version-skew",
580
+ specifier: `${skew.startedVersion}->${skew.onDiskVersion}`,
581
+ importer: "",
582
+ target: { kind: "unknown" },
583
+ ...(errorName ? { errorName } : {}),
584
+ startedVersion: skew.startedVersion,
585
+ onDiskVersion: skew.onDiskVersion,
586
+ };
587
+ }
492
588
  const nodeInstallTreeFs = {
493
589
  existsSync: (p) => nodeFs.existsSync(p),
494
590
  statSync: (p) => nodeFs.statSync(p),
@@ -1268,6 +1364,12 @@ export class InstallTreeTornError extends Error {
1268
1364
  if (typeof init.retiredSiblingPresent === "boolean") {
1269
1365
  diagnostics.retiredSiblingPresent = init.retiredSiblingPresent;
1270
1366
  }
1367
+ if (init.classified.startedVersion) {
1368
+ diagnostics.startedVersion = boundedDiagnosticValue(init.classified.startedVersion, VERSION_BYTES);
1369
+ }
1370
+ if (init.classified.onDiskVersion) {
1371
+ diagnostics.onDiskVersion = boundedDiagnosticValue(init.classified.onDiskVersion, VERSION_BYTES);
1372
+ }
1271
1373
  this.diagnostics = diagnostics;
1272
1374
  Object.setPrototypeOf(this, new.target.prototype);
1273
1375
  }
@@ -1362,6 +1464,101 @@ export function installTreeTornStderrLine(err) {
1362
1464
  ? INSTALL_TREE_RETIRED_UNVERIFIED_REMEDY
1363
1465
  : INSTALL_TREE_TORN_REMEDY;
1364
1466
  const specifier = err.diagnostics.specifier;
1365
- return specifier ? `${remedy} (missing: ${specifier})` : remedy;
1467
+ if (!specifier)
1468
+ return remedy;
1469
+ if (err.diagnostics.dialect === "version-skew") {
1470
+ return `${remedy} (version changed: ${specifier})`;
1471
+ }
1472
+ return `${remedy} (missing: ${specifier})`;
1473
+ }
1474
+ function mixedInstallOsTag(platform) {
1475
+ if (platform === "win32")
1476
+ return "windows";
1477
+ if (platform === "darwin")
1478
+ return "macos";
1479
+ if (platform === "linux")
1480
+ return "linux";
1481
+ return "other";
1482
+ }
1483
+ /**
1484
+ * Record a mixed-install recovery restart as a counted, non-error Sentry event
1485
+ * (info-level message + counter metric, never an unhandled exception) so the
1486
+ * incident remains measurable after the user-side restart fixes the failure.
1487
+ * Never throws and never blocks recovery on telemetry failure.
1488
+ */
1489
+ export async function recordMixedInstallRestart(event, deps) {
1490
+ const fromVersion = boundedDiagnosticValue(event.startedVersion || "unknown", VERSION_BYTES);
1491
+ const toVersion = boundedDiagnosticValue(event.onDiskVersion || "unknown", VERSION_BYTES);
1492
+ const errorName = boundedDiagnosticValue(event.errorName || "unknown", ERRORNAME_BYTES);
1493
+ const osTag = mixedInstallOsTag(process.platform);
1494
+ const tags = {
1495
+ install_tree_phase: "version_skew",
1496
+ recovery_outcome: "restarted",
1497
+ from_version: fromVersion,
1498
+ to_version: toVersion,
1499
+ error_name: errorName,
1500
+ os: osTag,
1501
+ };
1502
+ const contexts = {
1503
+ install_tree_torn: {
1504
+ dialect: "version-skew",
1505
+ code: "VERSION_SKEW",
1506
+ outcome: "restarted",
1507
+ startedVersion: fromVersion,
1508
+ onDiskVersion: toVersion,
1509
+ errorName,
1510
+ waitedMs: event.waitedMs,
1511
+ sawLock: event.sawLock,
1512
+ sawRetired: event.sawRetired,
1513
+ node: process.version,
1514
+ },
1515
+ };
1516
+ try {
1517
+ let sentry = deps?.sentry;
1518
+ let initializedHere = false;
1519
+ let sentryMod;
1520
+ if (!sentry) {
1521
+ const loadedSentry = await import("../sentry.js");
1522
+ sentryMod = loadedSentry;
1523
+ initializedHere = Boolean(runSentryInitialization(deps?.argv ?? process.argv,
1524
+ // Do not start a release-health session in the restarting parent; the
1525
+ // replacement child starts and finishes the invocation's real session.
1526
+ () => loadedSentry.ensureSentryInitialized({ startSession: false }), deps?.env ?? process.env));
1527
+ // If main.ts already started a session before registration failed, drop it
1528
+ // before captureMessage so the restarting parent does not count a session
1529
+ // alongside the replacement child.
1530
+ loadedSentry.discardSentrySession();
1531
+ sentry = loadedSentry.Sentry;
1532
+ }
1533
+ try {
1534
+ sentry.metrics?.count?.(MIXED_INSTALL_RESTART_METRIC, 1, {
1535
+ attributes: {
1536
+ from_version: fromVersion,
1537
+ to_version: toVersion,
1538
+ error_name: errorName,
1539
+ os: osTag,
1540
+ },
1541
+ });
1542
+ }
1543
+ catch {
1544
+ // Counter emission is best-effort; still emit the info message event.
1545
+ }
1546
+ sentry.captureMessage(MIXED_INSTALL_RESTART_EVENT_MESSAGE, {
1547
+ level: "info",
1548
+ fingerprint: [...MIXED_INSTALL_RESTART_FINGERPRINT],
1549
+ tags,
1550
+ contexts,
1551
+ });
1552
+ const flushTimeoutMs = deps?.flushTimeoutMs ?? 500;
1553
+ if (flushTimeoutMs > 0 && sentry.flush) {
1554
+ await sentry.flush(flushTimeoutMs);
1555
+ }
1556
+ if (initializedHere && sentryMod) {
1557
+ sentryMod.closeSentryTransport();
1558
+ }
1559
+ }
1560
+ catch {
1561
+ // Telemetry must never prevent or fail the user-side restart.
1562
+ }
1366
1563
  }
1367
1564
  //# sourceMappingURL=install-tree-torn.js.map
@@ -188,6 +188,7 @@ const INSTALL_TREE_PHASES = new Set([
188
188
  "eval-throw",
189
189
  "missing-plan",
190
190
  "resolve-enoent",
191
+ "version-skew",
191
192
  "unknown",
192
193
  ]);
193
194
  const KNOWN_INSTALL_TREE_UPDATERS = new Map([
@@ -222,6 +223,8 @@ function installTreePhaseTag(value) {
222
223
  return "module_evaluation";
223
224
  if (value === "missing-plan")
224
225
  return "registration_plan";
226
+ if (value === "version-skew")
227
+ return "version_skew";
225
228
  if (value === "esm-package" || value === "cjs-package")
226
229
  return "package_resolution";
227
230
  if (value === "unknown")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@indigoai-us/hq-cli",
3
- "version": "5.345.262",
3
+ "version": "5.345.264",
4
4
  "description": "HQ by Indigo management CLI — modules and cloud sync",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -128,11 +128,11 @@
128
128
  "*.{ts,tsx,mts,cts,js,jsx,mjs,cjs}": "eslint --cache --no-error-on-unmatched-pattern"
129
129
  },
130
130
  "optionalDependencies": {
131
- "@indigoai-us/hq-hook-win32-x64": "5.345.262",
132
- "@indigoai-us/hq-hook-win32-arm64": "5.345.262",
133
- "@indigoai-us/hq-hook-darwin-x64": "5.345.262",
134
- "@indigoai-us/hq-hook-darwin-arm64": "5.345.262",
135
- "@indigoai-us/hq-hook-linux-x64": "5.345.262",
136
- "@indigoai-us/hq-hook-linux-arm64": "5.345.262"
131
+ "@indigoai-us/hq-hook-win32-x64": "5.345.264",
132
+ "@indigoai-us/hq-hook-win32-arm64": "5.345.264",
133
+ "@indigoai-us/hq-hook-darwin-x64": "5.345.264",
134
+ "@indigoai-us/hq-hook-darwin-arm64": "5.345.264",
135
+ "@indigoai-us/hq-hook-linux-x64": "5.345.264",
136
+ "@indigoai-us/hq-hook-linux-arm64": "5.345.264"
137
137
  }
138
138
  }