@indigoai-us/hq-cli 5.345.237 → 5.345.241
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.
- package/CHANGELOG.md +33 -0
- package/assets/scaffold/core/scripts/hq-delegate-repo.sh +7 -1
- package/assets/scaffold/core/scripts/hq-delegate-secrets.sh +95 -20
- package/assets/scaffold/core/scripts/hq-delegate-transfer.sh +57 -9
- package/dist/command-catalog.generated.d.ts +185 -3
- package/dist/command-catalog.generated.js +228 -3
- package/dist/command-registration-plan.d.ts +6 -0
- package/dist/command-registration-plan.js +1 -0
- package/dist/commands/bot.d.ts +2 -0
- package/dist/commands/bot.js +23 -0
- package/dist/commands/cloud-off-gate.d.ts +2 -1
- package/dist/commands/cloud-off-gate.js +17 -4
- package/dist/commands/cloud.d.ts +17 -2
- package/dist/commands/cloud.js +126 -24
- package/dist/commands/core-delegate-w1b.js +35 -10
- package/dist/commands/core-delegate.d.ts +2 -1
- package/dist/commands/core-delegate.js +207 -48
- package/dist/commands/deploy-comments.js +8 -2
- package/dist/commands/deploy-events.d.ts +40 -0
- package/dist/commands/deploy-events.js +300 -0
- package/dist/commands/doctor.d.ts +4 -4
- package/dist/commands/doctor.js +2 -2
- package/dist/commands/feedback.js +2 -3
- package/dist/commands/keyed-sync-pull.d.ts +12 -0
- package/dist/commands/keyed-sync-pull.js +151 -0
- package/dist/commands/library-add.d.ts +5 -2
- package/dist/commands/library-add.js +22 -9
- package/dist/commands/mcp-registration.d.ts +4 -18
- package/dist/commands/mcp-registration.js +9 -29
- package/dist/commands/mesh.d.ts +4 -0
- package/dist/commands/mesh.js +25 -5
- package/dist/commands/pack-install.d.ts +2 -3
- package/dist/commands/pack-install.js +6 -8
- package/dist/commands/secrets.d.ts +3 -4
- package/dist/commands/secrets.js +3 -20
- package/dist/hq-cloud-sync-runner/bin/sync-runner.js +307 -232
- package/dist/hq-cloud-sync-runner/package.json +1 -1
- package/dist/lib/agent-kit/inbox-state.d.ts +2 -1
- package/dist/lib/agent-kit/inbox-state.js +27 -3
- package/dist/lib/bot/api.d.ts +2 -1
- package/dist/lib/bot/api.js +2 -15
- package/dist/lib/bot/promote.d.ts +23 -0
- package/dist/lib/bot/promote.js +73 -0
- package/dist/lib/bot/promotion-hold-reconcile.d.ts +56 -0
- package/dist/lib/bot/promotion-hold-reconcile.js +155 -0
- package/dist/lib/capacity/collectors/claude-oauth.d.ts +0 -2
- package/dist/lib/capacity/collectors/claude-oauth.js +0 -5
- package/dist/lib/core-utils/delegate-helper-paths.d.ts +26 -0
- package/dist/lib/core-utils/delegate-helper-paths.js +33 -0
- package/dist/lib/daemon/jq-provision.d.ts +63 -0
- package/dist/lib/daemon/jq-provision.js +155 -0
- package/dist/lib/daemon/lanes-reconcile-guard.d.ts +4 -3
- package/dist/lib/daemon/lanes-reconcile-guard.js +4 -4
- package/dist/lib/daemon/mesh-owner.d.ts +4 -0
- package/dist/lib/daemon/mesh-owner.js +20 -0
- package/dist/lib/daemon/ops/policy.d.ts +3 -0
- package/dist/lib/daemon/ops/policy.js +32 -4
- package/dist/lib/daemon/run.d.ts +17 -1
- package/dist/lib/daemon/run.js +24 -3
- package/dist/lib/daemon/server.d.ts +6 -0
- package/dist/lib/daemon/server.js +5 -0
- package/dist/lib/daemon/verified-jq.d.ts +96 -0
- package/dist/lib/daemon/verified-jq.js +337 -0
- package/dist/lib/doctor/checks/jq.js +16 -0
- package/dist/lib/doctor/deep/executor.d.ts +7 -0
- package/dist/lib/doctor/deep/executor.js +1 -1
- package/dist/lib/doctor/deep/parity.js +1 -27
- package/dist/lib/doctor/deep/sandbox.d.ts +2 -2
- package/dist/lib/doctor/deep/sandbox.js +3 -19
- package/dist/lib/doctor/fix/refresh-sync-handoff.js +52 -21
- package/dist/lib/doctor/fixtures/discover.d.ts +2 -0
- package/dist/lib/doctor/fixtures/discover.js +1 -1
- package/dist/lib/doctor/json-output.d.ts +1 -1
- package/dist/lib/doctor/registry.d.ts +6 -7
- package/dist/lib/doctor/registry.js +6 -7
- package/dist/lib/doctor/report.d.ts +9 -10
- package/dist/lib/doctor/report.js +4 -4
- package/dist/lib/flag-registry-worker-source.generated.d.ts +1 -1
- package/dist/lib/flag-registry-worker-source.generated.js +1 -1
- package/dist/lib/jq/install.d.ts +27 -0
- package/dist/lib/jq/install.js +156 -0
- package/dist/lib/lanes/outpost-dispatch.d.ts +1 -1
- package/dist/lib/lanes/outpost-dispatch.js +13 -13
- package/dist/lib/lanes/outpost-pruner-install.js +1 -1
- package/dist/lib/mesh/live/daemon/doctor.js +7 -1
- package/dist/lib/mesh/live/daemon/install.d.ts +4 -0
- package/dist/lib/mesh/live/daemon/install.js +10 -0
- package/dist/lib/mesh/live/daemon/run.js +17 -0
- package/dist/lib/mesh/live/emit-retry.d.ts +20 -2
- package/dist/lib/mesh/live/emit-retry.js +57 -4
- package/dist/lib/mesh/live/emit.js +25 -4
- package/dist/lib/mesh/live/flush.d.ts +2 -0
- package/dist/lib/mesh/live/flush.js +21 -8
- package/dist/lib/mesh/live/spool.d.ts +9 -1
- package/dist/lib/mesh/live/spool.js +41 -29
- package/dist/lib/sync-core/rollout-state.d.ts +9 -1
- package/dist/lib/sync-core/rollout-state.js +34 -4
- package/dist/lib/windows/jq.d.ts +4 -0
- package/dist/lib/windows/jq.js +10 -39
- package/dist/lib/workers-registry/index.js +7 -11
- package/dist/utils/callback-port-busy.d.ts +2 -2
- package/dist/utils/callback-port-busy.js +2 -2
- package/dist/utils/cli-network-lifecycle.js +1 -0
- package/dist/utils/client-health-contract.d.ts +2 -0
- package/dist/utils/client-health-contract.js +1 -1
- package/dist/utils/client-health.js +1 -9
- package/dist/utils/cognito-config.js +5 -0
- package/dist/utils/cognito-session.d.ts +4 -6
- package/dist/utils/cognito-session.js +4 -24
- package/dist/utils/incomplete-install-error.js +1 -11
- package/dist/utils/install-tree-torn.d.ts +11 -0
- package/dist/utils/install-tree-torn.js +1 -1
- package/dist/utils/resident-package-preload.js +2 -1
- package/docs/anywhere-runtime.md +8 -0
- package/package.json +9 -9
|
@@ -175,8 +175,8 @@ async function postBatchWithRetries(poster, body, deps) {
|
|
|
175
175
|
*/
|
|
176
176
|
export async function flushSessionEvents(inputDeps) {
|
|
177
177
|
const env = inputDeps.env ?? process.env;
|
|
178
|
-
const nothingDone = () => ({ claimed: 0, posted: 0, held: 0, dropped: 0, deadLettered: 0,
|
|
179
|
-
restored: 0, batches: 0, heldClaimed: false, heldOverflow: 0 });
|
|
178
|
+
const nothingDone = (noClaimReason) => ({ claimed: 0, posted: 0, held: 0, dropped: 0, deadLettered: 0,
|
|
179
|
+
restored: 0, batches: 0, heldClaimed: false, heldOverflow: 0, ...(noClaimReason ? { noClaimReason } : {}) });
|
|
180
180
|
// Idle machine: with nothing spooled, held or orphaned there is nothing to
|
|
181
181
|
// report, so do not ask whether reporting is allowed. The gate still runs
|
|
182
182
|
// before anything is claimed or sent whenever there is something.
|
|
@@ -190,7 +190,7 @@ export async function flushSessionEvents(inputDeps) {
|
|
|
190
190
|
let boundOnly = false;
|
|
191
191
|
if (hqAnywhereRuntimeLocallyDisabled(env) || (inputDeps.reportingAllowed && !(await inputDeps.reportingAllowed()))) {
|
|
192
192
|
if (!operatorAllowsHqAnywhere(env))
|
|
193
|
-
return nothingDone();
|
|
193
|
+
return nothingDone("operator_switch_off");
|
|
194
194
|
boundOnly = true;
|
|
195
195
|
}
|
|
196
196
|
// Events stored before this machine first saw HQ Anywhere off were held
|
|
@@ -239,7 +239,7 @@ export async function flushSessionEvents(inputDeps) {
|
|
|
239
239
|
forEachJsonlLine(claim, look);
|
|
240
240
|
}
|
|
241
241
|
if (!any)
|
|
242
|
-
return nothingDone();
|
|
242
|
+
return nothingDone("anywhere_off_no_company_session_event");
|
|
243
243
|
}
|
|
244
244
|
// One resolver per flush: git lookups are cached per cwd for this flush only.
|
|
245
245
|
const deps = {
|
|
@@ -260,6 +260,9 @@ export async function flushSessionEvents(inputDeps) {
|
|
|
260
260
|
const orphans = boundOnly
|
|
261
261
|
? recoverOrphanSpoolClaims(deps.workMeshRoot)
|
|
262
262
|
: recoverOrphanClaims(deps.workMeshRoot);
|
|
263
|
+
for (const claim of orphans.unreadable) {
|
|
264
|
+
deps.log?.(`work-mesh: kept unreadable claim ${path.basename(claim.claimPath)} for the next flush: ${claim.error.slice(0, 120)}`);
|
|
265
|
+
}
|
|
263
266
|
const spoolClaim = claimSpool(deps.workMeshRoot, ts);
|
|
264
267
|
// Throttle held re-attempts; spool (fresh) events still flush every cycle.
|
|
265
268
|
const lastHeldRetryAtMs = deps.lastHeldRetryAtMs ?? 0;
|
|
@@ -580,23 +583,33 @@ export async function flushSessionEvents(inputDeps) {
|
|
|
580
583
|
}
|
|
581
584
|
finally {
|
|
582
585
|
// Crash / throw mid-flush: put unprocessed events back on the spool.
|
|
586
|
+
let restoreFailed = 0;
|
|
587
|
+
let restoreError = "";
|
|
583
588
|
for (const event of pendingRestore) {
|
|
584
589
|
try {
|
|
585
590
|
appendSpoolLine(JSON.stringify(canonicalizeForRestore(event)), deps.workMeshRoot);
|
|
586
591
|
summary.restored += 1;
|
|
587
592
|
}
|
|
588
|
-
catch {
|
|
589
|
-
|
|
593
|
+
catch (err) {
|
|
594
|
+
// The claim files still hold this event; they are kept below so the
|
|
595
|
+
// orphan claim scan retries it next flush.
|
|
596
|
+
restoreFailed += 1;
|
|
597
|
+
if (!restoreError)
|
|
598
|
+
restoreError = err instanceof Error ? err.message : String(err);
|
|
590
599
|
}
|
|
591
600
|
}
|
|
592
601
|
pendingRestore.clear();
|
|
593
|
-
let gaveBack =
|
|
602
|
+
let gaveBack = restoreFailed === 0;
|
|
603
|
+
if (restoreFailed > 0) {
|
|
604
|
+
deps.log?.(`work-mesh: could not put ${restoreFailed} events back on the spool; kept claim files for the next flush: ${restoreError.slice(0, 120)}`);
|
|
605
|
+
}
|
|
594
606
|
try {
|
|
595
607
|
appendRawSpoolLines(giveBack, deps.workMeshRoot);
|
|
596
608
|
}
|
|
597
|
-
catch {
|
|
609
|
+
catch (err) {
|
|
598
610
|
// The claim files still hold these lines; the next flush recovers them.
|
|
599
611
|
gaveBack = false;
|
|
612
|
+
deps.log?.(`work-mesh: could not give ${giveBack.length} lines back to the spool; kept claim files for the next flush: ${(err instanceof Error ? err.message : String(err)).slice(0, 120)}`);
|
|
600
613
|
}
|
|
601
614
|
if (gaveBack) {
|
|
602
615
|
for (const p of claimPaths) {
|
|
@@ -68,13 +68,20 @@ export declare function hasPendingFlushWork(root: string): boolean;
|
|
|
68
68
|
* file alone does not start a flush on every cycle.
|
|
69
69
|
*/
|
|
70
70
|
export declare function hasPendingSpoolWork(root: string): boolean;
|
|
71
|
+
/** A claim file this flush could not read. It is left on disk for the next flush. */
|
|
72
|
+
export interface UnreadableClaim {
|
|
73
|
+
claimPath: string;
|
|
74
|
+
error: string;
|
|
75
|
+
}
|
|
71
76
|
/**
|
|
72
77
|
* Recover orphaned claim files: read their lines and return paths to unlink
|
|
73
|
-
* after the flush dispositions them.
|
|
78
|
+
* after the flush dispositions them. A claim that cannot be read is listed in
|
|
79
|
+
* `unreadable` and left out of `claimPaths`, so it stays for the next flush.
|
|
74
80
|
*/
|
|
75
81
|
export declare function recoverOrphanClaims(root: string): {
|
|
76
82
|
lines: string[];
|
|
77
83
|
claimPaths: string[];
|
|
84
|
+
unreadable: UnreadableClaim[];
|
|
78
85
|
};
|
|
79
86
|
/** Orphaned claim files of the spool only (never held claims). */
|
|
80
87
|
export declare function listOrphanSpoolClaims(root: string): string[];
|
|
@@ -85,6 +92,7 @@ export declare function listOrphanSpoolClaims(root: string): string[];
|
|
|
85
92
|
export declare function recoverOrphanSpoolClaims(root: string): {
|
|
86
93
|
lines: string[];
|
|
87
94
|
claimPaths: string[];
|
|
95
|
+
unreadable: UnreadableClaim[];
|
|
88
96
|
};
|
|
89
97
|
export declare function removeClaimFile(claimPath: string | null): void;
|
|
90
98
|
export declare function deadLetterNonEmpty(root?: string): boolean;
|
|
@@ -447,39 +447,57 @@ export function hasPendingSpoolWork(root) {
|
|
|
447
447
|
}
|
|
448
448
|
return jsonlHasBytes(workMeshSpoolPath(root));
|
|
449
449
|
}
|
|
450
|
+
/**
|
|
451
|
+
* Read a claim file's non-empty lines with the streaming reader, so a claim
|
|
452
|
+
* larger than V8's string limit still reads. A claim that vanished reads as
|
|
453
|
+
* empty. Any other failure returns an error, and the caller must keep the file:
|
|
454
|
+
* removing it would delete the events it still holds.
|
|
455
|
+
*/
|
|
450
456
|
function readClaimFileLines(claimPath) {
|
|
451
457
|
if (!fs.existsSync(claimPath))
|
|
452
|
-
return [];
|
|
458
|
+
return { lines: [] };
|
|
459
|
+
const lines = [];
|
|
453
460
|
try {
|
|
454
|
-
const
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
lines
|
|
460
|
-
|
|
461
|
-
|
|
461
|
+
const opened = forEachJsonlLine(claimPath, (line) => {
|
|
462
|
+
if (line.trim())
|
|
463
|
+
lines.push(line);
|
|
464
|
+
});
|
|
465
|
+
if (opened)
|
|
466
|
+
return { lines };
|
|
467
|
+
if (!fs.existsSync(claimPath))
|
|
468
|
+
return { lines: [] };
|
|
469
|
+
return { error: "could not open claim file" };
|
|
462
470
|
}
|
|
463
|
-
catch {
|
|
464
|
-
return
|
|
471
|
+
catch (err) {
|
|
472
|
+
return { error: (err instanceof Error ? err.message : String(err)).slice(0, 200) };
|
|
465
473
|
}
|
|
466
474
|
}
|
|
467
|
-
|
|
468
|
-
* Recover orphaned claim files: read their lines and return paths to unlink
|
|
469
|
-
* after the flush dispositions them.
|
|
470
|
-
*/
|
|
471
|
-
export function recoverOrphanClaims(root) {
|
|
472
|
-
const claimPaths = listOrphanClaimFiles(root);
|
|
475
|
+
function recoverClaims(claimFiles) {
|
|
473
476
|
const lines = [];
|
|
474
|
-
|
|
477
|
+
const claimPaths = [];
|
|
478
|
+
const unreadable = [];
|
|
479
|
+
for (const p of claimFiles) {
|
|
480
|
+
const read = readClaimFileLines(p);
|
|
481
|
+
if ("error" in read) {
|
|
482
|
+
// Not in claimPaths: the flush removes only claims it has read.
|
|
483
|
+
unreadable.push({ claimPath: p, error: read.error });
|
|
484
|
+
continue;
|
|
485
|
+
}
|
|
475
486
|
// Plain loop: Array#push(...huge) exceeds V8's argument limit (~65k–128k)
|
|
476
487
|
// and throws RangeError ("Maximum call stack size exceeded").
|
|
477
|
-
const
|
|
478
|
-
for (const line of orphanLines) {
|
|
488
|
+
for (const line of read.lines)
|
|
479
489
|
lines.push(line);
|
|
480
|
-
|
|
490
|
+
claimPaths.push(p);
|
|
481
491
|
}
|
|
482
|
-
return { lines, claimPaths };
|
|
492
|
+
return { lines, claimPaths, unreadable };
|
|
493
|
+
}
|
|
494
|
+
/**
|
|
495
|
+
* Recover orphaned claim files: read their lines and return paths to unlink
|
|
496
|
+
* after the flush dispositions them. A claim that cannot be read is listed in
|
|
497
|
+
* `unreadable` and left out of `claimPaths`, so it stays for the next flush.
|
|
498
|
+
*/
|
|
499
|
+
export function recoverOrphanClaims(root) {
|
|
500
|
+
return recoverClaims(listOrphanClaimFiles(root));
|
|
483
501
|
}
|
|
484
502
|
/** Orphaned claim files of the spool only (never held claims). */
|
|
485
503
|
export function listOrphanSpoolClaims(root) {
|
|
@@ -495,13 +513,7 @@ export function listOrphanSpoolClaims(root) {
|
|
|
495
513
|
* HQ Anywhere switched off: held lines and held claims are left where they are.
|
|
496
514
|
*/
|
|
497
515
|
export function recoverOrphanSpoolClaims(root) {
|
|
498
|
-
|
|
499
|
-
const lines = [];
|
|
500
|
-
for (const p of claimPaths) {
|
|
501
|
-
for (const line of readClaimFileLines(p))
|
|
502
|
-
lines.push(line);
|
|
503
|
-
}
|
|
504
|
-
return { lines, claimPaths };
|
|
516
|
+
return recoverClaims(listOrphanSpoolClaims(root));
|
|
505
517
|
}
|
|
506
518
|
export function removeClaimFile(claimPath) {
|
|
507
519
|
if (!claimPath)
|
|
@@ -29,8 +29,16 @@ export interface SyncCoreRolloutState {
|
|
|
29
29
|
error?: string;
|
|
30
30
|
}
|
|
31
31
|
export declare function syncCoreRolloutStatePath(home: string): string;
|
|
32
|
-
|
|
32
|
+
type RolloutStateFailure = "is unreadable" | "contains invalid JSON" | "has an invalid format" | "has an unsupported version";
|
|
33
|
+
export declare class SyncCoreRolloutStateError extends Error {
|
|
34
|
+
constructor(reason: RolloutStateFailure);
|
|
35
|
+
}
|
|
36
|
+
/** Manual sync needs to distinguish an absent state from one it cannot trust. */
|
|
37
|
+
export declare function readSyncCoreRolloutState(home: string, { strict }?: {
|
|
38
|
+
strict?: boolean;
|
|
39
|
+
}): SyncCoreRolloutState | null;
|
|
33
40
|
export declare function engineVaultCount(home: string): number;
|
|
34
41
|
export declare function readSyncCoreRolloutStateFile(file: string): SyncCoreRolloutState | null;
|
|
35
42
|
export declare function writeSyncCoreRolloutState(home: string, state: SyncCoreRolloutState): void;
|
|
43
|
+
export {};
|
|
36
44
|
//# sourceMappingURL=rollout-state.d.ts.map
|
|
@@ -81,20 +81,50 @@ function vault(value) {
|
|
|
81
81
|
...(streams !== undefined ? { downloadStreams: streams } : {}),
|
|
82
82
|
};
|
|
83
83
|
}
|
|
84
|
-
export
|
|
85
|
-
|
|
84
|
+
export class SyncCoreRolloutStateError extends Error {
|
|
85
|
+
constructor(reason) {
|
|
86
|
+
super(`Manual sync stopped: sync rollout.json ${reason}. Restore a valid rollout state before retrying.`);
|
|
87
|
+
this.name = "SyncCoreRolloutStateError";
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
/** Manual sync needs to distinguish an absent state from one it cannot trust. */
|
|
91
|
+
export function readSyncCoreRolloutState(home, { strict = false } = {}) {
|
|
92
|
+
return readRolloutStateFile(syncCoreRolloutStatePath(home), strict);
|
|
86
93
|
}
|
|
87
94
|
export function engineVaultCount(home) {
|
|
88
95
|
return readSyncCoreRolloutState(home)?.vaults.filter((vault) => vault.phase === "full").length ?? 0;
|
|
89
96
|
}
|
|
90
97
|
export function readSyncCoreRolloutStateFile(file) {
|
|
98
|
+
return readRolloutStateFile(file, false);
|
|
99
|
+
}
|
|
100
|
+
function readRolloutStateFile(file, strict) {
|
|
101
|
+
function fail(reason) {
|
|
102
|
+
if (strict)
|
|
103
|
+
throw new SyncCoreRolloutStateError(reason);
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
let contents;
|
|
107
|
+
try {
|
|
108
|
+
contents = fs.readFileSync(file, "utf8");
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
if (error.code === "ENOENT")
|
|
112
|
+
return null;
|
|
113
|
+
return fail("is unreadable");
|
|
114
|
+
}
|
|
91
115
|
let raw;
|
|
92
116
|
try {
|
|
93
|
-
raw = JSON.parse(
|
|
117
|
+
raw = JSON.parse(contents);
|
|
94
118
|
}
|
|
95
119
|
catch {
|
|
96
|
-
return
|
|
120
|
+
return fail("contains invalid JSON");
|
|
121
|
+
}
|
|
122
|
+
if (raw && typeof raw === "object" && "version" in raw && raw.version !== 1) {
|
|
123
|
+
return fail("has an unsupported version");
|
|
97
124
|
}
|
|
125
|
+
return parseRolloutState(raw) ?? fail("has an invalid format");
|
|
126
|
+
}
|
|
127
|
+
function parseRolloutState(raw) {
|
|
98
128
|
if (!raw || typeof raw !== "object" || Array.isArray(raw))
|
|
99
129
|
return null;
|
|
100
130
|
const obj = raw;
|
package/dist/lib/windows/jq.d.ts
CHANGED
|
@@ -3,6 +3,10 @@ interface JqAsset {
|
|
|
3
3
|
name: string;
|
|
4
4
|
sha256: string;
|
|
5
5
|
}
|
|
6
|
+
export declare function windowsJqAsset(arch: string): {
|
|
7
|
+
url: string;
|
|
8
|
+
sha256: string;
|
|
9
|
+
} | null;
|
|
6
10
|
export declare function windowsJqPath(home?: string): string;
|
|
7
11
|
interface InstallOptions {
|
|
8
12
|
platform?: NodeJS.Platform;
|
package/dist/lib/windows/jq.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { createHash } from "node:crypto";
|
|
2
|
-
import { readFileSync } from "node:fs";
|
|
3
|
-
import { mkdir, mkdtemp, rename, rm, writeFile } from "node:fs/promises";
|
|
4
1
|
import { homedir } from "node:os";
|
|
5
|
-
import {
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { installPinnedJq } from "../jq/install.js";
|
|
6
4
|
const version = "1.8.2";
|
|
7
5
|
const release = `https://github.com/jqlang/jq/releases/download/jq-${version}`;
|
|
8
6
|
export const WINDOWS_JQ_REPAIR = "hq doctor --fix-jq";
|
|
@@ -21,23 +19,14 @@ const assets = {
|
|
|
21
19
|
sha256: "a99cb668f95bdd788d9ee20529613b115e5d2a0d7f9127ee6976607e878558ba",
|
|
22
20
|
},
|
|
23
21
|
};
|
|
22
|
+
export function windowsJqAsset(arch) {
|
|
23
|
+
const asset = assets[arch];
|
|
24
|
+
return asset ? { url: `${release}/${asset.name}`, sha256: asset.sha256 } : null;
|
|
25
|
+
}
|
|
24
26
|
export function windowsJqPath(home = homedir()) {
|
|
25
27
|
// hq-core-staging #2047 adds this directory to hook PATH when it holds jq.exe.
|
|
26
28
|
return join(home, ".local", "bin", "jq.exe");
|
|
27
29
|
}
|
|
28
|
-
function digest(bytes) {
|
|
29
|
-
return createHash("sha256").update(bytes).digest("hex");
|
|
30
|
-
}
|
|
31
|
-
function matchesAsset(file, asset) {
|
|
32
|
-
try {
|
|
33
|
-
return digest(readFileSync(file)) === asset.sha256;
|
|
34
|
-
}
|
|
35
|
-
catch (error) {
|
|
36
|
-
if (error.code === "ENOENT")
|
|
37
|
-
return false;
|
|
38
|
-
throw error;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
30
|
/** The npm lifecycle, global hook setup and doctor use the same Windows installer. */
|
|
42
31
|
export async function installWindowsJq({ platform = process.platform, arch = process.arch, home, fetch: download = fetch, asset = assets[arch], } = {}) {
|
|
43
32
|
if (platform !== "win32")
|
|
@@ -45,28 +34,10 @@ export async function installWindowsJq({ platform = process.platform, arch = pro
|
|
|
45
34
|
if (!asset)
|
|
46
35
|
throw new Error(`jq has no official Windows build for ${arch}.`);
|
|
47
36
|
const target = windowsJqPath(home);
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
37
|
+
return installPinnedJq({
|
|
38
|
+
home: home ?? homedir(), target,
|
|
39
|
+
asset: { url: `${release}/${asset.name}`, sha256: asset.sha256 },
|
|
40
|
+
fetch: download,
|
|
52
41
|
});
|
|
53
|
-
if (!response.ok)
|
|
54
|
-
throw new Error(`jq download failed (HTTP ${response.status}).`);
|
|
55
|
-
const bytes = new Uint8Array(await response.arrayBuffer());
|
|
56
|
-
if (digest(bytes) !== asset.sha256) {
|
|
57
|
-
throw new Error(`The SHA-256 of ${asset.name} did not match the pinned release checksum.`);
|
|
58
|
-
}
|
|
59
|
-
const dir = dirname(target);
|
|
60
|
-
await mkdir(dir, { recursive: true });
|
|
61
|
-
const staged = await mkdtemp(join(dir, ".hq-jq-"));
|
|
62
|
-
try {
|
|
63
|
-
const file = join(staged, "jq.exe");
|
|
64
|
-
await writeFile(file, bytes, { flag: "wx", mode: 0o755 });
|
|
65
|
-
await rename(file, target);
|
|
66
|
-
}
|
|
67
|
-
finally {
|
|
68
|
-
await rm(staged, { recursive: true, force: true });
|
|
69
|
-
}
|
|
70
|
-
return target;
|
|
71
42
|
}
|
|
72
43
|
//# sourceMappingURL=jq.js.map
|
|
@@ -117,10 +117,6 @@ function packAttribution(root, relativeDirectory) {
|
|
|
117
117
|
return '';
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
|
-
function quote(value) {
|
|
121
|
-
// Deliberately mirrors `${value//\"/\\\"}` in the source shell script.
|
|
122
|
-
return value.replace(/"/g, '\\"');
|
|
123
|
-
}
|
|
124
120
|
function isoSeconds(now) {
|
|
125
121
|
return now.toISOString().replace(/\.\d{3}Z$/, 'Z');
|
|
126
122
|
}
|
|
@@ -133,16 +129,16 @@ function registryText(now, entries) {
|
|
|
133
129
|
'', 'version: "5.0"', `generated_at: "${isoSeconds(now)}"`, '', 'workers:',
|
|
134
130
|
];
|
|
135
131
|
for (const entry of entries) {
|
|
136
|
-
lines.push(` - id:
|
|
137
|
-
lines.push(` path:
|
|
138
|
-
lines.push(` type:
|
|
132
|
+
lines.push(` - id: ${JSON.stringify(entry.id)}`);
|
|
133
|
+
lines.push(` path: ${JSON.stringify(entry.path)}`);
|
|
134
|
+
lines.push(` type: ${JSON.stringify(entry.type)}`);
|
|
139
135
|
lines.push(` visibility: "${entry.visibility}"`);
|
|
140
136
|
if (entry.team)
|
|
141
|
-
lines.push(` team:
|
|
137
|
+
lines.push(` team: ${JSON.stringify(entry.team)}`);
|
|
142
138
|
if (entry.company)
|
|
143
|
-
lines.push(` company:
|
|
144
|
-
lines.push(` status:
|
|
145
|
-
lines.push(` description:
|
|
139
|
+
lines.push(` company: ${JSON.stringify(entry.company)}`);
|
|
140
|
+
lines.push(` status: ${JSON.stringify(entry.status)}`);
|
|
141
|
+
lines.push(` description: ${JSON.stringify(entry.description)}`);
|
|
146
142
|
}
|
|
147
143
|
return `${lines.join('\n')}\n`;
|
|
148
144
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/** Fixed callback port for the loopback OAuth server when unset
|
|
2
|
-
export
|
|
1
|
+
/** Fixed callback port for the loopback OAuth server when unset. */
|
|
2
|
+
export { DEFAULT_COGNITO_CALLBACK_PORT as DEFAULT_CALLBACK_PORT } from "./cognito-callback-port.js";
|
|
3
3
|
/**
|
|
4
4
|
* The fixed, actionable remedy. Interpolates ONLY the numeric callback port (a
|
|
5
5
|
* bounded value drawn from config, never caller input or upstream error text),
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
// ONLY when err.code === 'EADDRINUSE' AND err.port equals the configured
|
|
37
37
|
// callback port, so an EADDRINUSE raised by any OTHER listener stays
|
|
38
38
|
// reportable (the boundary must never swallow a genuine listener defect).
|
|
39
|
-
/** Fixed callback port for the loopback OAuth server when unset
|
|
40
|
-
export
|
|
39
|
+
/** Fixed callback port for the loopback OAuth server when unset. */
|
|
40
|
+
export { DEFAULT_COGNITO_CALLBACK_PORT as DEFAULT_CALLBACK_PORT } from "./cognito-callback-port.js";
|
|
41
41
|
/** Node's errno code for a `listen()` against an address already in use. */
|
|
42
42
|
const EADDRINUSE = "EADDRINUSE";
|
|
43
43
|
/**
|
|
@@ -52,6 +52,7 @@ const SCHEDULED_SHORT_RUN_COMMANDS = [
|
|
|
52
52
|
["daemon", "service", "sync-core-manifest"],
|
|
53
53
|
["runners", "reconcile"],
|
|
54
54
|
["lanes", "reconcile"],
|
|
55
|
+
["runners", "outpost-pruner", "run"],
|
|
55
56
|
["lanes", "outpost-pruner", "run"],
|
|
56
57
|
["index", "sync"],
|
|
57
58
|
["core", "jobs", "reconcile"],
|
|
@@ -189,6 +189,8 @@ export declare class ClientHealthContractError extends Error {
|
|
|
189
189
|
readonly field: string;
|
|
190
190
|
constructor(code: ClientHealthContractErrorCode, field: string, detail?: string);
|
|
191
191
|
}
|
|
192
|
+
/** Same shape sync-auth-middleware.ts enforces on x-hq-*-version headers. */
|
|
193
|
+
export declare const SEMVER: RegExp;
|
|
192
194
|
/**
|
|
193
195
|
* Parse + validate one heartbeat. Unknown extra fields are ignored (additive
|
|
194
196
|
* tolerance); every consumed value fails closed on unsafe content.
|
|
@@ -166,7 +166,7 @@ export class ClientHealthContractError extends Error {
|
|
|
166
166
|
const INSTALLATION_ID = /^[A-Za-z0-9][A-Za-z0-9_-]{7,63}$/;
|
|
167
167
|
const COMMAND_ID = /^[A-Za-z0-9][A-Za-z0-9_-]{7,63}$/;
|
|
168
168
|
/** Same shape sync-auth-middleware.ts enforces on x-hq-*-version headers. */
|
|
169
|
-
const SEMVER = /^(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-(?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*)(?:\.(?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*))*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/;
|
|
169
|
+
export const SEMVER = /^(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-(?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*)(?:\.(?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*))*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/;
|
|
170
170
|
const ISO_UTC = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?Z$/;
|
|
171
171
|
/**
|
|
172
172
|
* Secret-shaped prefixes rejected outright even when the charset is otherwise
|
|
@@ -42,7 +42,7 @@ import { vaultApiFetch } from "./vault-api.js";
|
|
|
42
42
|
import { collectVersions } from "./feedback-versions.js";
|
|
43
43
|
import { resolveDaemonCliVersion } from "./daemon-cli-version.js";
|
|
44
44
|
import { isAuthError } from "./auth-error.js";
|
|
45
|
-
import { CLIENT_HEALTH_CONTRACT_VERSION, CLIENT_HEALTH_MAX_SYNC_ENGINE_VAULTS, parseClientHealthHeartbeat, } from "./client-health-contract.js";
|
|
45
|
+
import { CLIENT_HEALTH_CONTRACT_VERSION, CLIENT_HEALTH_MAX_SYNC_ENGINE_VAULTS, parseClientHealthHeartbeat, SEMVER, } from "./client-health-contract.js";
|
|
46
46
|
import { collectLocalFilesOverview } from "./local-files-overview.js";
|
|
47
47
|
import { readSyncCoreRolloutStateFile } from "../lib/sync-core/rollout-state.js";
|
|
48
48
|
/** Same bound as CLI telemetry: a heartbeat may never stall a command. */
|
|
@@ -91,14 +91,6 @@ export const JOURNAL_OBSERVER_HEAP_MB = 512;
|
|
|
91
91
|
export const JOURNAL_OBSERVER_TIMEOUT_MS = 20_000;
|
|
92
92
|
/** An observation lock older than this is treated as abandoned. */
|
|
93
93
|
const JOURNAL_OBSERVATION_LOCK_STALE_MS = 5 * 60_000;
|
|
94
|
-
/**
|
|
95
|
-
* Pre-filter mirror of the contract's SemVer shape (the contract keeps its
|
|
96
|
-
* validators private). A version failing this is DROPPED individually so one
|
|
97
|
-
* malformed component version (e.g. a hand-edited core.yaml) never suppresses
|
|
98
|
-
* the whole heartbeat; `parseClientHealthHeartbeat` remains the final
|
|
99
|
-
* fail-closed gate before anything crosses the wire.
|
|
100
|
-
*/
|
|
101
|
-
const SEMVER = /^(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-(?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*)(?:\.(?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*))*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/;
|
|
102
94
|
const INSTALLATION_ID = /^[A-Za-z0-9][A-Za-z0-9_-]{7,63}$/;
|
|
103
95
|
export function newInstallationId() {
|
|
104
96
|
// 32 lowercase hex chars: always starts alphanumeric, always in-charset,
|
|
@@ -10,6 +10,11 @@ export const DEFAULT_COGNITO = {
|
|
|
10
10
|
get port() {
|
|
11
11
|
return resolveCognitoCallbackPort(process.env.HQ_COGNITO_CALLBACK_PORT);
|
|
12
12
|
},
|
|
13
|
+
// Skip Cognito's Hosted UI — go straight to Google OAuth. The Cognito
|
|
14
|
+
// /oauth2/authorize endpoint honors `identity_provider` and performs an
|
|
15
|
+
// internal redirect, so the user never sees the (un-styleable) Hosted UI.
|
|
16
|
+
// Set HQ_COGNITO_IDENTITY_PROVIDER="" to fall back to the IdP picker for
|
|
17
|
+
// accounts that use email+password (admin-created users without Google).
|
|
13
18
|
identityProvider: process.env.HQ_COGNITO_IDENTITY_PROVIDER !== undefined
|
|
14
19
|
? process.env.HQ_COGNITO_IDENTITY_PROVIDER || undefined
|
|
15
20
|
: "Google",
|
|
@@ -8,9 +8,7 @@
|
|
|
8
8
|
*
|
|
9
9
|
* Defaults point at the shared vault-indigo-hq-prod Cognito pool (canonical
|
|
10
10
|
* post-2026-04-25 cutover; hq-dev remains the staging fallback via env
|
|
11
|
-
* overrides)
|
|
12
|
-
* CLI and the in-tree demo script stay drift-free. Override any of them via
|
|
13
|
-
* env:
|
|
11
|
+
* overrides), defined in cognito-config.ts. Override any of them via env:
|
|
14
12
|
*
|
|
15
13
|
* AWS_REGION — e.g. us-east-1
|
|
16
14
|
* HQ_COGNITO_DOMAIN — Cognito User Pool domain prefix
|
|
@@ -18,11 +16,12 @@
|
|
|
18
16
|
* HQ_COGNITO_CALLBACK_PORT — Loopback OAuth callback port
|
|
19
17
|
* HQ_VAULT_API_URL — vault-service API Gateway URL
|
|
20
18
|
*/
|
|
21
|
-
import { isExpiring, isMachineIdentity, type
|
|
19
|
+
import { isExpiring, isMachineIdentity, type CognitoTokens, type ClientInfo, type VaultServiceConfig } from "@indigoai-us/hq-cloud";
|
|
22
20
|
import { hasPersonCachedSession, isMachineCredsFileEnvSet, wantsMachineCognitoTokens, type CognitoTokenSource } from "./machine-principal-state.js";
|
|
23
21
|
import { HQ_MACHINE_TOKEN_STATE_DIR_ENV, loadMachineCachedTokens, machineTokenCacheFile, machineTokenStateDir } from "./machine-token-cache.js";
|
|
24
22
|
export { HQ_MACHINE_TOKEN_STATE_DIR_ENV, loadMachineCachedTokens, machineTokenCacheFile, machineTokenStateDir };
|
|
25
23
|
import { resolveDefaultHqRoot } from "./hq-root-resolver.js";
|
|
24
|
+
import { DEFAULT_COGNITO, DEFAULT_VAULT_API_URL } from "./cognito-config.js";
|
|
26
25
|
import { HQ_NO_BROWSER_LOGIN_ENV, type InteractiveCallerInput } from "./interactive-caller.js";
|
|
27
26
|
import { loadCachedTokens, personTokenCacheFile, readPersonTokenFile } from "./person-token-cache.js";
|
|
28
27
|
export { loadCachedTokens, personTokenCacheFile, readPersonTokenFile };
|
|
@@ -36,8 +35,7 @@ export type CognitoActorKind = "human" | "agent" | "unknown";
|
|
|
36
35
|
* Default: the work-mesh daemon state dir (`~/.hq/work-mesh/daemon`), so a
|
|
37
36
|
* machine mint never overwrites a person's `~/.hq/cognito-tokens.json`.
|
|
38
37
|
*/
|
|
39
|
-
export
|
|
40
|
-
export declare const DEFAULT_VAULT_API_URL: string;
|
|
38
|
+
export { DEFAULT_COGNITO, DEFAULT_VAULT_API_URL };
|
|
41
39
|
export { resolveDefaultHqRoot };
|
|
42
40
|
export declare const DEFAULT_HQ_ROOT: string;
|
|
43
41
|
/** Default machine-creds path hq-cloud also checks when the env is unset. */
|
|
@@ -8,9 +8,7 @@
|
|
|
8
8
|
*
|
|
9
9
|
* Defaults point at the shared vault-indigo-hq-prod Cognito pool (canonical
|
|
10
10
|
* post-2026-04-25 cutover; hq-dev remains the staging fallback via env
|
|
11
|
-
* overrides)
|
|
12
|
-
* CLI and the in-tree demo script stay drift-free. Override any of them via
|
|
13
|
-
* env:
|
|
11
|
+
* overrides), defined in cognito-config.ts. Override any of them via env:
|
|
14
12
|
*
|
|
15
13
|
* AWS_REGION — e.g. us-east-1
|
|
16
14
|
* HQ_COGNITO_DOMAIN — Cognito User Pool domain prefix
|
|
@@ -31,7 +29,8 @@ import { HQ_MACHINE_TOKEN_STATE_DIR_ENV, loadMachineCachedTokens, machineTokenCa
|
|
|
31
29
|
export { HQ_MACHINE_TOKEN_STATE_DIR_ENV, loadMachineCachedTokens, machineTokenCacheFile, machineTokenStateDir };
|
|
32
30
|
import { resolveDefaultHqRoot } from "./hq-root-resolver.js";
|
|
33
31
|
import { acquireLockFileExclusively } from "./exclusive-lock.js";
|
|
34
|
-
import { interactiveLoginConfig
|
|
32
|
+
import { interactiveLoginConfig } from "./cognito-callback-port.js";
|
|
33
|
+
import { DEFAULT_COGNITO, DEFAULT_VAULT_API_URL } from "./cognito-config.js";
|
|
35
34
|
import { HQ_NO_BROWSER_LOGIN_ENV, NON_INTERACTIVE_LOGIN_MESSAGE, isInteractiveCaller, } from "./interactive-caller.js";
|
|
36
35
|
import { reportNoninteractivePersonRefreshRejection } from "./cognito-refresh-sentry.js";
|
|
37
36
|
import { decodeJwtPayload, loadCachedTokens, personTokenCacheFile, readPersonTokenFile, readTokenFile, } from "./person-token-cache.js";
|
|
@@ -45,26 +44,7 @@ export { hasPersonCachedSession, isMachineCredsFileEnvSet, wantsMachineCognitoTo
|
|
|
45
44
|
* Default: the work-mesh daemon state dir (`~/.hq/work-mesh/daemon`), so a
|
|
46
45
|
* machine mint never overwrites a person's `~/.hq/cognito-tokens.json`.
|
|
47
46
|
*/
|
|
48
|
-
export
|
|
49
|
-
region: process.env.AWS_REGION ?? "us-east-1",
|
|
50
|
-
userPoolDomain: process.env.HQ_COGNITO_DOMAIN ?? "vault-indigo-hq-prod",
|
|
51
|
-
clientId: process.env.HQ_COGNITO_CLIENT_ID ?? "7acei2c8v870enheptb1j5foln",
|
|
52
|
-
// Resolved on read, not at module load: main.ts imports this for every
|
|
53
|
-
// command, and a stray HQ_COGNITO_CALLBACK_PORT should warn only when a
|
|
54
|
-
// sign-in actually reads the port.
|
|
55
|
-
get port() {
|
|
56
|
-
return resolveCognitoCallbackPort(process.env.HQ_COGNITO_CALLBACK_PORT);
|
|
57
|
-
},
|
|
58
|
-
// Skip Cognito's Hosted UI — go straight to Google OAuth. The Cognito
|
|
59
|
-
// /oauth2/authorize endpoint honors `identity_provider` and performs an
|
|
60
|
-
// internal redirect, so the user never sees the (un-styleable) Hosted UI.
|
|
61
|
-
// Set HQ_COGNITO_IDENTITY_PROVIDER="" to fall back to the IdP picker for
|
|
62
|
-
// accounts that use email+password (admin-created users without Google).
|
|
63
|
-
identityProvider: process.env.HQ_COGNITO_IDENTITY_PROVIDER !== undefined
|
|
64
|
-
? process.env.HQ_COGNITO_IDENTITY_PROVIDER || undefined
|
|
65
|
-
: "Google",
|
|
66
|
-
};
|
|
67
|
-
export const DEFAULT_VAULT_API_URL = process.env.HQ_VAULT_API_URL ?? "https://hqapi.hq.computer";
|
|
47
|
+
export { DEFAULT_COGNITO, DEFAULT_VAULT_API_URL };
|
|
68
48
|
// HQ-root resolution (HQ_ROOT, cwd walk with the core.yaml + companies/
|
|
69
49
|
// check, installer records, known locations, then ~/hq or a throw) has one
|
|
70
50
|
// implementation, in hq-root-resolver.ts (US-030 c2). Re-exported here for
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
import * as fs from "fs";
|
|
76
76
|
import * as path from "path";
|
|
77
77
|
import { packageRoot, stringDerivedPackageRoot } from "./hq-roots.js";
|
|
78
|
-
import { evalThrowShape, hasCjsLoaderSourceReadFrame, packageNameOf } from "./install-tree-torn.js";
|
|
78
|
+
import { evalThrowShape, hasCjsLoaderSourceReadFrame, packageNameOf, RESOLVER_FRAME, } from "./install-tree-torn.js";
|
|
79
79
|
import { boundedDiagnosticValue } from "./package-root-diagnostics.js";
|
|
80
80
|
/**
|
|
81
81
|
* The actionable remedy shown to the operator. Input-free — nothing from the
|
|
@@ -106,16 +106,6 @@ const RELATIVE_SPECIFIER = /^\.\.?[\\/]/;
|
|
|
106
106
|
* `esm/loader` module.
|
|
107
107
|
*/
|
|
108
108
|
const ESM_LOADER_FRAME = /node:internal[\\/]modules[\\/]esm[\\/]load\b/;
|
|
109
|
-
/**
|
|
110
|
-
* The Node module RESOLVER frame — `finalizeResolution` in
|
|
111
|
-
* `node:internal/modules/esm/resolve`, or the CJS `Module._findPath → toRealPath`
|
|
112
|
-
* route in `node:internal/modules/cjs/loader`. Alongside `syscall === 'lstat'`
|
|
113
|
-
* this proves a resolve-time ENOENT (HQ-CLI-1S) — a path component that vanished
|
|
114
|
-
* between the resolver's stat and its realpathSync lstat — so an ordinary
|
|
115
|
-
* `fs.lstatSync` ENOENT from hq's own code stays captured. Mirrors the frame
|
|
116
|
-
* matcher in install-tree-torn.ts (duplicated exactly as ESM_LOADER_FRAME is).
|
|
117
|
-
*/
|
|
118
|
-
const RESOLVER_FRAME = /node:internal[\\/]modules[\\/](?:esm[\\/]resolve|cjs[\\/]loader)\b/;
|
|
119
109
|
const ROOT_DIAGNOSTIC_BYTES = 256;
|
|
120
110
|
const CODE_DIAGNOSTIC_BYTES = 32;
|
|
121
111
|
// Package names live inside hq-cli's own dependency graph, so their universe is
|
|
@@ -132,6 +132,17 @@ export interface ClassifiedModuleError {
|
|
|
132
132
|
/** The thrown error's `name` for the eval-throw dialect (HQ-CLI-1T), else absent. */
|
|
133
133
|
errorName?: string;
|
|
134
134
|
}
|
|
135
|
+
/**
|
|
136
|
+
* The Node module RESOLVER frame — `finalizeResolution` in
|
|
137
|
+
* `node:internal/modules/esm/resolve` (the observed HQ-CLI-1S route, where
|
|
138
|
+
* realpathSync lstat's a component that vanished after the earlier stat), or the
|
|
139
|
+
* CJS `Module._findPath → toRealPath` route in `node:internal/modules/cjs/loader`
|
|
140
|
+
* (the same stat-then-lstat TOCTOU, accepted for symmetry). Requiring a resolver
|
|
141
|
+
* frame — alongside `syscall === 'lstat'` — is what proves the ENOENT came from
|
|
142
|
+
* the resolver's realpath step, so an ordinary `fs.lstatSync` ENOENT written by
|
|
143
|
+
* hq's own code (no resolver frame) is NOT misclassified as a torn install.
|
|
144
|
+
*/
|
|
145
|
+
export declare const RESOLVER_FRAME: RegExp;
|
|
135
146
|
export declare function hasCjsLoaderSourceReadFrame(stack: string): boolean;
|
|
136
147
|
/**
|
|
137
148
|
* Reduce a bare specifier to its PACKAGE name: `@scope/name/sub` → `@scope/name`,
|
|
@@ -87,7 +87,7 @@ function hasEsmLoaderSourceReadFrame(stack) {
|
|
|
87
87
|
* the resolver's realpath step, so an ordinary `fs.lstatSync` ENOENT written by
|
|
88
88
|
* hq's own code (no resolver frame) is NOT misclassified as a torn install.
|
|
89
89
|
*/
|
|
90
|
-
const RESOLVER_FRAME = /node:internal[\\/]modules[\\/](?:esm[\\/]resolve|cjs[\\/]loader)\b/;
|
|
90
|
+
export const RESOLVER_FRAME = /node:internal[\\/]modules[\\/](?:esm[\\/]resolve|cjs[\\/]loader)\b/;
|
|
91
91
|
/** The closed set of error `name`s the eval-throw dialect accepts (HQ-CLI-1T). */
|
|
92
92
|
const EVAL_THROW_NAMES = new Set(["TypeError", "ReferenceError", "SyntaxError"]);
|
|
93
93
|
/**
|