@indigoai-us/hq-cli 5.345.221 → 5.345.222
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 +47 -1
- package/dist/command-catalog.generated.d.ts +31 -0
- package/dist/command-catalog.generated.js +38 -0
- package/dist/commands/auth.js +2 -1
- package/dist/commands/core-delegate-w1b.js +9 -3
- package/dist/commands/daemon.d.ts +1 -0
- package/dist/commands/daemon.js +15 -1
- package/dist/commands/link.d.ts +2 -0
- package/dist/commands/link.js +14 -2
- package/dist/commands/mesh.js +23 -3
- package/dist/commands/sync-core.d.ts +6 -0
- package/dist/commands/sync-core.js +55 -0
- package/dist/data/command-states.json +3 -0
- package/dist/lib/daemon/catalog.js +2 -0
- package/dist/lib/daemon/install.d.ts +2 -1
- package/dist/lib/daemon/install.js +9 -0
- package/dist/lib/daemon/legacy.d.ts +1 -0
- package/dist/lib/daemon/legacy.js +5 -2
- package/dist/lib/daemon/machine-check-owner.d.ts +2 -0
- package/dist/lib/daemon/machine-check-owner.js +6 -1
- package/dist/lib/daemon/machine-checks.d.ts +7 -1
- package/dist/lib/daemon/machine-checks.js +10 -1
- package/dist/lib/daemon/mesh-owner.d.ts +45 -0
- package/dist/lib/daemon/mesh-owner.js +166 -0
- package/dist/lib/daemon/native-notice-ledger.d.ts +27 -0
- package/dist/lib/daemon/native-notice-ledger.js +113 -0
- package/dist/lib/daemon/run.d.ts +15 -0
- package/dist/lib/daemon/run.js +71 -3
- package/dist/lib/daemon/selfcheck.d.ts +35 -2
- package/dist/lib/daemon/selfcheck.js +118 -9
- package/dist/lib/hook-engine/coverage.d.ts +9 -0
- package/dist/lib/hook-engine/coverage.js +56 -0
- package/dist/lib/hook-engine/native-stop-compatibility.json +56 -5
- package/dist/lib/mesh/live/daemon/config.d.ts +8 -1
- package/dist/lib/mesh/live/daemon/config.js +16 -0
- package/dist/lib/mesh/live/daemon/install.d.ts +31 -2
- package/dist/lib/mesh/live/daemon/install.js +142 -1
- package/dist/lib/mesh/live/daemon/login-home.d.ts +5 -0
- package/dist/lib/mesh/live/daemon/login-home.js +27 -0
- package/dist/lib/mesh/live/daemon/unit-home.d.ts +49 -0
- package/dist/lib/mesh/live/daemon/unit-home.js +134 -0
- package/dist/lib/registry/registry.d.ts +35 -7
- package/dist/lib/registry/registry.js +88 -13
- package/dist/lib/scan-packages/index.js +24 -2
- package/dist/lib/search-index/max-doc-bytes.js +2 -1
- package/dist/lib/service-manager/startup-migration.d.ts +1 -0
- package/dist/lib/service-manager/startup-migration.js +3 -0
- package/dist/lib/sync-core/engine-holds.d.ts +14 -0
- package/dist/lib/sync-core/engine-holds.js +60 -0
- package/dist/lib/sync-core/engine-home.d.ts +2 -0
- package/dist/lib/sync-core/reconcile.js +8 -0
- package/dist/lib/sync-core/vault-settings.d.ts +21 -0
- package/dist/lib/sync-core/vault-settings.js +131 -0
- package/dist/lib/windows/install-followup.d.ts +2 -0
- package/dist/lib/windows/install-followup.js +4 -1
- package/dist/utils/host-registration.js +3 -1
- package/dist/utils/pack-contributions.d.ts +3 -0
- package/dist/utils/pack-contributions.js +110 -23
- package/dist/utils/self-update.d.ts +3 -1
- package/dist/utils/self-update.js +56 -11
- package/dist/utils/update-lock.d.ts +151 -14
- package/dist/utils/update-lock.js +782 -46
- package/dist/utils/version-gate.js +12 -2
- package/package.json +7 -7
|
@@ -25,6 +25,34 @@ export interface EngineUnitProblem {
|
|
|
25
25
|
export declare function engineUnitsNeedingAttention(state: DaemonState | null, holds: PersistedHolds, now: number,
|
|
26
26
|
/** False for a vault that is skipped on this machine or not on the rollout. */
|
|
27
27
|
wanted?: (vaultUid: string) => boolean): EngineUnitProblem[];
|
|
28
|
+
export declare const WAKE_LIVE_WITHIN_MS = 60000;
|
|
29
|
+
export interface WakeMarker {
|
|
30
|
+
connected: boolean;
|
|
31
|
+
heartbeatAtMs: number;
|
|
32
|
+
}
|
|
33
|
+
export declare function readWakeMarker(file: string): WakeMarker | null;
|
|
34
|
+
export interface WakeProblem {
|
|
35
|
+
since: number;
|
|
36
|
+
what: string;
|
|
37
|
+
}
|
|
38
|
+
export interface WakeWatch {
|
|
39
|
+
notLiveSince: number;
|
|
40
|
+
checkedAt: number;
|
|
41
|
+
}
|
|
42
|
+
export declare const WAKE_WATCH_GAP_MS: number;
|
|
43
|
+
export declare function readWakeWatch(file: string): WakeWatch | null;
|
|
44
|
+
export declare function engineIsRunning(state: DaemonState | null, wanted?: (vaultUid: string) => boolean): boolean;
|
|
45
|
+
export interface WakeAssessment {
|
|
46
|
+
live: boolean;
|
|
47
|
+
notLiveSince?: number;
|
|
48
|
+
problem: WakeProblem | null;
|
|
49
|
+
}
|
|
50
|
+
export declare function assessWake(input: {
|
|
51
|
+
engineRunning: boolean;
|
|
52
|
+
marker: WakeMarker | null;
|
|
53
|
+
watch: WakeWatch | null;
|
|
54
|
+
now: number;
|
|
55
|
+
}): WakeAssessment;
|
|
28
56
|
export interface SelfCheckRecord {
|
|
29
57
|
lastSentAt: number;
|
|
30
58
|
/** Sorted unit ids last reported (for the log; the rate limit ignores them). */
|
|
@@ -56,11 +84,11 @@ export declare function writeSelfCheckResult(file: string, result: SelfCheckResu
|
|
|
56
84
|
* in the last day. Which units are affected does not matter, so units that
|
|
57
85
|
* take turns failing cannot send a DM on every change.
|
|
58
86
|
*/
|
|
59
|
-
export declare function shouldReport(problems: EngineUnitProblem[], last: SelfCheckRecord | null, now: number): boolean;
|
|
87
|
+
export declare function shouldReport(problems: EngineUnitProblem[], last: SelfCheckRecord | null, now: number, wake?: WakeProblem | null): boolean;
|
|
60
88
|
/** The DM text for the owner. Plain, with the commands that fix each case. */
|
|
61
89
|
export declare function selfCheckMessage(problems: EngineUnitProblem[], machine: string,
|
|
62
90
|
/** A name for a vault (company slug, "personal"), when known. */
|
|
63
|
-
vaultName?: (vaultUid: string) => string | undefined): {
|
|
91
|
+
vaultName?: (vaultUid: string) => string | undefined, wake?: WakeProblem | null): {
|
|
64
92
|
body: string;
|
|
65
93
|
details: string;
|
|
66
94
|
};
|
|
@@ -87,6 +115,11 @@ export interface SelfCheckDeps {
|
|
|
87
115
|
details: string;
|
|
88
116
|
}) => Promise<string | null>;
|
|
89
117
|
log: (line: string) => void;
|
|
118
|
+
wake?: {
|
|
119
|
+
markerPath: string;
|
|
120
|
+
watchPath: string;
|
|
121
|
+
meshWanted: () => boolean;
|
|
122
|
+
};
|
|
90
123
|
}
|
|
91
124
|
export type SelfCheckOutcome = "healthy" | "reported" | "already-reported" | "no-owner";
|
|
92
125
|
export declare function runSelfCheck(deps: SelfCheckDeps): Promise<SelfCheckOutcome>;
|
|
@@ -76,6 +76,80 @@ function unitProblem(unit, hold, state, now) {
|
|
|
76
76
|
what: `${unit.status === "running" ? "restarting" : "failing"} with no heartbeat since ${iso(since)}, restarted ${unit.restarts} times${exit}`,
|
|
77
77
|
};
|
|
78
78
|
}
|
|
79
|
+
export const WAKE_LIVE_WITHIN_MS = 60_000;
|
|
80
|
+
export function readWakeMarker(file) {
|
|
81
|
+
let text;
|
|
82
|
+
try {
|
|
83
|
+
text = fs.readFileSync(file, "utf8");
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
if (error.code === "ENOENT")
|
|
87
|
+
return null;
|
|
88
|
+
throw error;
|
|
89
|
+
}
|
|
90
|
+
let parsed;
|
|
91
|
+
try {
|
|
92
|
+
parsed = JSON.parse(text);
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
if (error instanceof SyntaxError)
|
|
96
|
+
return null;
|
|
97
|
+
throw error;
|
|
98
|
+
}
|
|
99
|
+
if (!parsed || typeof parsed !== "object")
|
|
100
|
+
return null;
|
|
101
|
+
if (typeof parsed.heartbeatAtMs !== "number" || !Number.isFinite(parsed.heartbeatAtMs))
|
|
102
|
+
return null;
|
|
103
|
+
return { connected: parsed.connected === true, heartbeatAtMs: parsed.heartbeatAtMs };
|
|
104
|
+
}
|
|
105
|
+
export const WAKE_WATCH_GAP_MS = 150 * 60_000;
|
|
106
|
+
export function readWakeWatch(file) {
|
|
107
|
+
let text;
|
|
108
|
+
try {
|
|
109
|
+
text = fs.readFileSync(file, "utf8");
|
|
110
|
+
}
|
|
111
|
+
catch (error) {
|
|
112
|
+
if (error.code === "ENOENT")
|
|
113
|
+
return null;
|
|
114
|
+
throw error;
|
|
115
|
+
}
|
|
116
|
+
try {
|
|
117
|
+
const parsed = JSON.parse(text);
|
|
118
|
+
const ok = (v) => typeof v === "number" && Number.isFinite(v);
|
|
119
|
+
return ok(parsed?.notLiveSince) && ok(parsed.checkedAt)
|
|
120
|
+
? { notLiveSince: parsed.notLiveSince, checkedAt: parsed.checkedAt }
|
|
121
|
+
: null;
|
|
122
|
+
}
|
|
123
|
+
catch (error) {
|
|
124
|
+
if (error instanceof SyntaxError)
|
|
125
|
+
return null;
|
|
126
|
+
throw error;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
export function engineIsRunning(state, wanted = () => true) {
|
|
130
|
+
return (state?.units ?? []).some((unit) => unit.id.startsWith(ENGINE_UNIT_PREFIX) &&
|
|
131
|
+
unit.status === "running" &&
|
|
132
|
+
wanted(unit.id.slice(ENGINE_UNIT_PREFIX.length)));
|
|
133
|
+
}
|
|
134
|
+
export function assessWake(input) {
|
|
135
|
+
const { marker, now } = input;
|
|
136
|
+
const fresh = marker !== null && now - marker.heartbeatAtMs <= WAKE_LIVE_WITHIN_MS;
|
|
137
|
+
if (!input.engineRunning || (fresh && marker.connected))
|
|
138
|
+
return { live: true, problem: null };
|
|
139
|
+
const watch = input.watch && now - input.watch.checkedAt <= WAKE_WATCH_GAP_MS ? input.watch : null;
|
|
140
|
+
const firstSeen = watch?.notLiveSince ?? now;
|
|
141
|
+
const since = firstSeen;
|
|
142
|
+
const what = marker === null
|
|
143
|
+
? `Work Mesh has written no change-notification marker since at least ${iso(since)}`
|
|
144
|
+
: fresh
|
|
145
|
+
? `Work Mesh has not been connected for change notifications since at least ${iso(since)}`
|
|
146
|
+
: `Work Mesh last updated its change-notification marker at ${iso(marker.heartbeatAtMs)}, and it was still stale at every check since ${iso(since)}`;
|
|
147
|
+
return {
|
|
148
|
+
live: false,
|
|
149
|
+
notLiveSince: firstSeen,
|
|
150
|
+
problem: now - since > ATTENTION_AFTER_MS ? { since, what } : null,
|
|
151
|
+
};
|
|
152
|
+
}
|
|
79
153
|
function iso(ms) {
|
|
80
154
|
return new Date(ms).toISOString().replace(/\.\d{3}Z$/, "Z");
|
|
81
155
|
}
|
|
@@ -91,6 +165,9 @@ export function readSelfCheckRecord(file) {
|
|
|
91
165
|
}
|
|
92
166
|
}
|
|
93
167
|
export function writeSelfCheckRecord(file, record) {
|
|
168
|
+
writeSelfCheckRecordFile(file, record);
|
|
169
|
+
}
|
|
170
|
+
function writeSelfCheckRecordFile(file, record) {
|
|
94
171
|
ensurePrivateDir(path.dirname(file));
|
|
95
172
|
const tmp = `${file}.${process.pid}.tmp`;
|
|
96
173
|
fs.writeFileSync(tmp, `${JSON.stringify(record, null, 2)}\n`, { mode: 0o600 });
|
|
@@ -132,32 +209,62 @@ export function writeSelfCheckResult(file, result, options = {}) {
|
|
|
132
209
|
* in the last day. Which units are affected does not matter, so units that
|
|
133
210
|
* take turns failing cannot send a DM on every change.
|
|
134
211
|
*/
|
|
135
|
-
export function shouldReport(problems, last, now) {
|
|
136
|
-
if (problems.length === 0)
|
|
212
|
+
export function shouldReport(problems, last, now, wake = null) {
|
|
213
|
+
if (problems.length === 0 && !wake)
|
|
137
214
|
return false;
|
|
138
215
|
if (!last)
|
|
139
216
|
return true;
|
|
217
|
+
if (problems.length > 0 && last.units.length === 0)
|
|
218
|
+
return true;
|
|
140
219
|
return now - last.lastSentAt >= REPORT_INTERVAL_MS;
|
|
141
220
|
}
|
|
142
221
|
/** The DM text for the owner. Plain, with the commands that fix each case. */
|
|
143
222
|
export function selfCheckMessage(problems, machine,
|
|
144
223
|
/** A name for a vault (company slug, "personal"), when known. */
|
|
145
|
-
vaultName = () => undefined) {
|
|
224
|
+
vaultName = () => undefined, wake = null) {
|
|
146
225
|
const named = (p) => {
|
|
147
226
|
const uid = p.unitId.slice(ENGINE_UNIT_PREFIX.length);
|
|
148
227
|
const name = vaultName(uid);
|
|
149
228
|
return name ? `${name} (${uid})` : uid;
|
|
150
229
|
};
|
|
151
230
|
const names = problems.map(named).join(", ");
|
|
152
|
-
const body =
|
|
153
|
-
|
|
231
|
+
const body = problems.length > 0
|
|
232
|
+
? `HQ sync on ${machine}: the sync engine for ${names} has not synced for over ${ATTENTION_AFTER_MS / 60_000} minutes. ` +
|
|
233
|
+
"Run `hq daemon status` on that machine."
|
|
234
|
+
: `HQ sync on ${machine}: the sync engine is running without change notifications, so it only polls and other machines' changes can arrive up to 30 minutes late. ` +
|
|
235
|
+
"Run `hq mesh daemon status` and `hq daemon status` on that machine.";
|
|
154
236
|
const lines = problems.map((p) => `- ${named(p)}: ${p.what}. Retry with: hq daemon restart ${p.unitId}`);
|
|
237
|
+
if (wake)
|
|
238
|
+
lines.push(`- change notifications: ${wake.what}. Check with: hq mesh daemon status and hq daemon status`);
|
|
155
239
|
lines.push("", "Logs: hq daemon logs <unit>. This check runs in hq daemon and sends at most one DM a day from this machine.");
|
|
156
240
|
return { body, details: lines.join("\n") };
|
|
157
241
|
}
|
|
242
|
+
function checkWake(deps, state, now) {
|
|
243
|
+
if (!deps.wake)
|
|
244
|
+
return null;
|
|
245
|
+
try {
|
|
246
|
+
const assessment = assessWake({
|
|
247
|
+
engineRunning: deps.wake.meshWanted() && engineIsRunning(state, deps.wanted),
|
|
248
|
+
marker: readWakeMarker(deps.wake.markerPath),
|
|
249
|
+
watch: readWakeWatch(deps.wake.watchPath),
|
|
250
|
+
now,
|
|
251
|
+
});
|
|
252
|
+
if (assessment.live)
|
|
253
|
+
fs.rmSync(deps.wake.watchPath, { force: true });
|
|
254
|
+
else
|
|
255
|
+
writeSelfCheckRecordFile(deps.wake.watchPath, { notLiveSince: assessment.notLiveSince ?? now, checkedAt: now });
|
|
256
|
+
return assessment.problem;
|
|
257
|
+
}
|
|
258
|
+
catch (error) {
|
|
259
|
+
deps.log(`sync engine self-check: could not check change notifications (${error.code ?? error.message})`);
|
|
260
|
+
return null;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
158
263
|
export async function runSelfCheck(deps) {
|
|
159
264
|
const now = deps.now();
|
|
160
|
-
const
|
|
265
|
+
const state = deps.readState();
|
|
266
|
+
const problems = engineUnitsNeedingAttention(state, deps.readHolds(), now, deps.wanted);
|
|
267
|
+
const wake = checkWake(deps, state, now);
|
|
161
268
|
if (deps.resultPath) {
|
|
162
269
|
try {
|
|
163
270
|
writeSelfCheckResult(deps.resultPath, { checkedAt: now, problems: problems.length });
|
|
@@ -166,18 +273,20 @@ export async function runSelfCheck(deps) {
|
|
|
166
273
|
deps.log(`sync engine self-check: could not record this run's result (${error.code ?? "error"})`);
|
|
167
274
|
}
|
|
168
275
|
}
|
|
169
|
-
if (problems.length === 0) {
|
|
276
|
+
if (problems.length === 0 && !wake) {
|
|
170
277
|
deps.log("sync engine self-check: every engine unit is healthy");
|
|
171
278
|
return "healthy";
|
|
172
279
|
}
|
|
173
280
|
for (const p of problems)
|
|
174
281
|
deps.log(`sync engine self-check: ${p.unitId} ${p.what}`);
|
|
282
|
+
if (wake)
|
|
283
|
+
deps.log(`sync engine self-check: ${wake.what} while a sync engine is running`);
|
|
175
284
|
const last = readSelfCheckRecord(deps.recordPath);
|
|
176
|
-
if (!shouldReport(problems, last, now)) {
|
|
285
|
+
if (!shouldReport(problems, last, now, wake)) {
|
|
177
286
|
deps.log(`sync engine self-check: already reported at ${iso(last.lastSentAt)}; next report after ${iso(last.lastSentAt + REPORT_INTERVAL_MS)}`);
|
|
178
287
|
return "already-reported";
|
|
179
288
|
}
|
|
180
|
-
const to = await deps.sendToOwner(selfCheckMessage(problems, deps.machine, deps.vaultName));
|
|
289
|
+
const to = await deps.sendToOwner(selfCheckMessage(problems, deps.machine, deps.vaultName, wake));
|
|
181
290
|
if (to === null) {
|
|
182
291
|
deps.log("sync engine self-check: this machine is signed in as an agent, so there is no owner to DM; nothing was sent");
|
|
183
292
|
return "no-owner";
|
|
@@ -129,6 +129,15 @@ export declare function joinRaw(base: string, rest: string, platform?: NodeJS.Pl
|
|
|
129
129
|
* sticky are not x bits. Both sides check it on the `modeBits` table in the shared cases.json.
|
|
130
130
|
*/
|
|
131
131
|
export declare function modeBitsExecutable(mode: number, root: boolean, owner: boolean, member: boolean): boolean;
|
|
132
|
+
/**
|
|
133
|
+
* As `stop::compat::generation`: the Stop files (and master-hook.sh, which only votes) of hq-core
|
|
134
|
+
* v16.0.48-beta.104 and later are one side, every earlier release the other (`generations` in the
|
|
135
|
+
* shared policy). A file present at a released version of one side votes for it; another version,
|
|
136
|
+
* or a missing or unreadable file, casts no vote. Votes for both sides hold: no released core ships
|
|
137
|
+
* that mix, so the Stop master-hook would run cannot be told. On the later side, a master-hook.sh
|
|
138
|
+
* that is present and not a released later version holds too. Exported for tests.
|
|
139
|
+
*/
|
|
140
|
+
export declare function generationHold(root: string): string | null;
|
|
132
141
|
/** The hooks the old dispatcher runs for `event` on `host` in this HQ root; null when they cannot be read exactly. */
|
|
133
142
|
export declare function shellHooks(root: string, host: CoreNextHost, event: string): string[] | null;
|
|
134
143
|
/**
|
|
@@ -404,6 +404,9 @@ export function stopCompatibilityHold(root, env = process.env, fixed = (p) => p)
|
|
|
404
404
|
const script = unreleasedScript(root, (id) => listed !== null && runs(id));
|
|
405
405
|
if (script)
|
|
406
406
|
return script;
|
|
407
|
+
const mixed = generationHold(root);
|
|
408
|
+
if (mixed)
|
|
409
|
+
return mixed;
|
|
407
410
|
// Any GIT_* name outside the allowlist counts when present, even empty: git dies on an empty GIT_DIR,
|
|
408
411
|
// GIT_WORK_TREE, GIT_COMMON_DIR or GIT_OBJECT_DIRECTORY, where the native readers ignore the
|
|
409
412
|
// environment (#2790 r4 C1), and on many others (review r17 C3, C5).
|
|
@@ -1416,6 +1419,59 @@ function unreleasedScript(root, runs) {
|
|
|
1416
1419
|
}
|
|
1417
1420
|
return missing;
|
|
1418
1421
|
}
|
|
1422
|
+
/**
|
|
1423
|
+
* As `stop::compat::generation`: the Stop files (and master-hook.sh, which only votes) of hq-core
|
|
1424
|
+
* v16.0.48-beta.104 and later are one side, every earlier release the other (`generations` in the
|
|
1425
|
+
* shared policy). A file present at a released version of one side votes for it; another version,
|
|
1426
|
+
* or a missing or unreadable file, casts no vote. Votes for both sides hold: no released core ships
|
|
1427
|
+
* that mix, so the Stop master-hook would run cannot be told. On the later side, a master-hook.sh
|
|
1428
|
+
* that is present and not a released later version holds too. Exported for tests.
|
|
1429
|
+
*/
|
|
1430
|
+
export function generationHold(root) {
|
|
1431
|
+
const sides = stopCompatibility.generations ?? {};
|
|
1432
|
+
const files = [];
|
|
1433
|
+
for (const side of ['before104', 'from104'])
|
|
1434
|
+
for (const file of Object.keys(sides[side] ?? {}))
|
|
1435
|
+
if (!files.includes(file))
|
|
1436
|
+
files.push(file);
|
|
1437
|
+
const before = [];
|
|
1438
|
+
const from = [];
|
|
1439
|
+
for (const file of files) {
|
|
1440
|
+
let bytes;
|
|
1441
|
+
try {
|
|
1442
|
+
const full = path.join(root, file);
|
|
1443
|
+
if (!fs.statSync(full).isFile())
|
|
1444
|
+
continue;
|
|
1445
|
+
bytes = fs.readFileSync(full);
|
|
1446
|
+
}
|
|
1447
|
+
catch {
|
|
1448
|
+
continue;
|
|
1449
|
+
}
|
|
1450
|
+
const hex = createHash('sha256').update(bytes).digest('hex');
|
|
1451
|
+
if ((sides.from104?.[file] ?? []).includes(hex))
|
|
1452
|
+
from.push(file);
|
|
1453
|
+
else if ((sides.before104?.[file] ?? []).includes(hex))
|
|
1454
|
+
before.push(file);
|
|
1455
|
+
}
|
|
1456
|
+
if (before.length && from.length)
|
|
1457
|
+
return `mixed hq-core Stop files from both sides of v16.0.48-beta.104 (${from.join(', ')} from beta.104 or later; ${before.join(', ')} from before)`;
|
|
1458
|
+
// Review rv-2836: on the later side, a master-hook.sh that is present and not a released beta.104-or-later
|
|
1459
|
+
// version may be an earlier release that is not listed (beta.82 to beta.84 shipped edbac513), which runs the
|
|
1460
|
+
// Claude-only Stop gates on a Cursor payload: held, as Rust does.
|
|
1461
|
+
const master = '.claude/hooks/master-hook.sh';
|
|
1462
|
+
if (from.length && !from.includes(master) && !before.includes(master)) {
|
|
1463
|
+
let present = true;
|
|
1464
|
+
try {
|
|
1465
|
+
fs.lstatSync(path.join(root, master));
|
|
1466
|
+
}
|
|
1467
|
+
catch {
|
|
1468
|
+
present = false;
|
|
1469
|
+
}
|
|
1470
|
+
if (present)
|
|
1471
|
+
return `hq-core Stop files from v16.0.48-beta.104 or later (${from.join(', ')}) with a ${master} that is not a released beta.104 or later version`;
|
|
1472
|
+
}
|
|
1473
|
+
return null;
|
|
1474
|
+
}
|
|
1419
1475
|
/** Folder hook that master-hook.sh never dispatches (retired; `hq rescue` can leave it on disk). */
|
|
1420
1476
|
const RETIRED = new Set(['Stop/70-work-mesh-done.sh']);
|
|
1421
1477
|
function listDir(dir) {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"dispatcher": [
|
|
3
|
-
"HQ_MASTER_CHILD_TIMEOUT"
|
|
3
|
+
"HQ_MASTER_CHILD_TIMEOUT",
|
|
4
|
+
"HQ_MASTER_STOP_BUDGET",
|
|
5
|
+
"HQ_MASTER_STOP_CHILD_TIMEOUT"
|
|
4
6
|
],
|
|
5
7
|
"gitEnvironmentAllowlist": [
|
|
6
8
|
"GIT_EDITOR",
|
|
@@ -92,7 +94,8 @@
|
|
|
92
94
|
"e9398ea6abc5ed2c8ad010f5135ea3e37d7f244f9d506d8e0f426d29358c6773"
|
|
93
95
|
],
|
|
94
96
|
"core/hooks/Stop/70-work-mesh-turn-end.sh": [
|
|
95
|
-
"1b37183a94a46152c9592d6821f323203438e09ed59956d6239880bb73f896db"
|
|
97
|
+
"1b37183a94a46152c9592d6821f323203438e09ed59956d6239880bb73f896db",
|
|
98
|
+
"b373b582a906b0993a3ce56aa43c1ef0aec6668a6b7e150d59ef3214b7d65b70"
|
|
96
99
|
],
|
|
97
100
|
".claude/hooks/hq-autocommit-bash-flag.cjs": [
|
|
98
101
|
"419c65157c0167473ace808bacc7cb5902afa4336f8281f7e7f9c228d74a77a4"
|
|
@@ -129,7 +132,8 @@
|
|
|
129
132
|
"be7ca74b2524afba56fefd530bf46cbd1dd39a4c181b6a64c87e124b29bdebe7",
|
|
130
133
|
"b971dae4a2b82bfa5b31782e54717115abaf052457fb1a546893d04cae43adbb",
|
|
131
134
|
"df3d8ddc15a0c179227c9ba7f855c040973fcee249673156d08b2e2ff2c850b8",
|
|
132
|
-
"49c337ceccf0a2d7c2a64f6b1de8c3c4d1da507bc5d7afcd01ed292e1f25abf7"
|
|
135
|
+
"49c337ceccf0a2d7c2a64f6b1de8c3c4d1da507bc5d7afcd01ed292e1f25abf7",
|
|
136
|
+
"9133295e5ce523bf8355a093bbea5a1c19682ec42b59ab6b626dffbc33544f3f"
|
|
133
137
|
],
|
|
134
138
|
"core/scripts/hook-stop-async-drain.sh": [
|
|
135
139
|
"d7be9aa17c42bd96ba6f9d929240e06d9c057471347374de40ea4be3560da4f5"
|
|
@@ -175,7 +179,8 @@
|
|
|
175
179
|
"89c0273ad7bac4bda2b114ca5f02c38229343a5418bad92f641e400c2883b4e0"
|
|
176
180
|
],
|
|
177
181
|
"core/scripts/lib/session-id.sh": [
|
|
178
|
-
"5178dfed9387cf5924bb71d5cdded37f445fd7b496e6037e81c43af0e7831d5b"
|
|
182
|
+
"5178dfed9387cf5924bb71d5cdded37f445fd7b496e6037e81c43af0e7831d5b",
|
|
183
|
+
"2ebbc50893c7c601a111b9e8f9945afeac88f552d7caeec09c4096f4c27a833d"
|
|
179
184
|
],
|
|
180
185
|
"core/scripts/lib/session-scope-capability.sh": [
|
|
181
186
|
"388ffef43cfe05810c38ce377245d0d86f415b4009b21a008bca8897be0c9ead"
|
|
@@ -188,7 +193,8 @@
|
|
|
188
193
|
"db440318b8933b7c436c7b7172adffc9e8fd00c92f0e1745ed5da76871accbe7"
|
|
189
194
|
],
|
|
190
195
|
"core/scripts/lib/work-mesh-live-hook.sh": [
|
|
191
|
-
"25dc6d35877366ae91532a28a64d380aee054a8c571df88ed0b741aef29cf34e"
|
|
196
|
+
"25dc6d35877366ae91532a28a64d380aee054a8c571df88ed0b741aef29cf34e",
|
|
197
|
+
"2962e17569d62f5953d41cd516bd7d1b3db9849c3c4fbbd750ae13d7d181bcbe"
|
|
192
198
|
],
|
|
193
199
|
"core/scripts/lib/work-mesh-live-rebind.sh": [
|
|
194
200
|
"d351bf68103b7f8514d96a945bdeb6c371d9d7ba289347c368a34fea36fd4ad9"
|
|
@@ -244,6 +250,7 @@
|
|
|
244
250
|
],
|
|
245
251
|
"core/hooks/Stop/70-work-mesh-turn-end.sh": [
|
|
246
252
|
"core/scripts/lib/hook-stop-async.sh",
|
|
253
|
+
"core/scripts/lib/session-id.sh",
|
|
247
254
|
"core/scripts/lib/work-mesh-enqueue.sh"
|
|
248
255
|
],
|
|
249
256
|
".claude/hooks/hq-autocommit.sh": [
|
|
@@ -307,5 +314,49 @@
|
|
|
307
314
|
"core/scripts/board-project-id.sh",
|
|
308
315
|
"core/scripts/hq-session.sh"
|
|
309
316
|
]
|
|
317
|
+
},
|
|
318
|
+
"generations": {
|
|
319
|
+
"before104": {
|
|
320
|
+
"core/hooks/Stop/70-work-mesh-turn-end.sh": [
|
|
321
|
+
"1b37183a94a46152c9592d6821f323203438e09ed59956d6239880bb73f896db"
|
|
322
|
+
],
|
|
323
|
+
"core/scripts/hook-lib.sh": [
|
|
324
|
+
"89899ae7720f0bdde5cd8e014c614a6aa1796f4b79f23194e397d33b9c7e0bf2",
|
|
325
|
+
"4c98cd6f07d4090c062d980b0d85b0084635efdcd4a09afc05cf77287a74b28d",
|
|
326
|
+
"be7ca74b2524afba56fefd530bf46cbd1dd39a4c181b6a64c87e124b29bdebe7",
|
|
327
|
+
"b971dae4a2b82bfa5b31782e54717115abaf052457fb1a546893d04cae43adbb",
|
|
328
|
+
"df3d8ddc15a0c179227c9ba7f855c040973fcee249673156d08b2e2ff2c850b8",
|
|
329
|
+
"49c337ceccf0a2d7c2a64f6b1de8c3c4d1da507bc5d7afcd01ed292e1f25abf7"
|
|
330
|
+
],
|
|
331
|
+
"core/scripts/lib/session-id.sh": [
|
|
332
|
+
"5178dfed9387cf5924bb71d5cdded37f445fd7b496e6037e81c43af0e7831d5b"
|
|
333
|
+
],
|
|
334
|
+
"core/scripts/lib/work-mesh-live-hook.sh": [
|
|
335
|
+
"25dc6d35877366ae91532a28a64d380aee054a8c571df88ed0b741aef29cf34e"
|
|
336
|
+
],
|
|
337
|
+
".claude/hooks/master-hook.sh": [
|
|
338
|
+
"fe01ffc7d0380d3c9c391bc4d12f445ed4e82662d92111de442f795f210765ec",
|
|
339
|
+
"7c4ecd88d8790fe152e2cbcff9b452e2d91f391f24c1ba2dce46815a52ced021",
|
|
340
|
+
"f25c7720f24cc160fc149e56a5695aed52515a7425e3cdca87b7b021a0d0573b",
|
|
341
|
+
"e16b0ff06978f85feaa3cb45056c4355a5b8c094e94b36a9cdca2af214ee86b5"
|
|
342
|
+
]
|
|
343
|
+
},
|
|
344
|
+
"from104": {
|
|
345
|
+
"core/hooks/Stop/70-work-mesh-turn-end.sh": [
|
|
346
|
+
"b373b582a906b0993a3ce56aa43c1ef0aec6668a6b7e150d59ef3214b7d65b70"
|
|
347
|
+
],
|
|
348
|
+
"core/scripts/hook-lib.sh": [
|
|
349
|
+
"9133295e5ce523bf8355a093bbea5a1c19682ec42b59ab6b626dffbc33544f3f"
|
|
350
|
+
],
|
|
351
|
+
"core/scripts/lib/session-id.sh": [
|
|
352
|
+
"2ebbc50893c7c601a111b9e8f9945afeac88f552d7caeec09c4096f4c27a833d"
|
|
353
|
+
],
|
|
354
|
+
"core/scripts/lib/work-mesh-live-hook.sh": [
|
|
355
|
+
"2962e17569d62f5953d41cd516bd7d1b3db9849c3c4fbbd750ae13d7d181bcbe"
|
|
356
|
+
],
|
|
357
|
+
".claude/hooks/master-hook.sh": [
|
|
358
|
+
"1a2439aee50652c5143ccd18561a0aa84a1e94848d02c1aa1c99157f70023f29"
|
|
359
|
+
]
|
|
360
|
+
}
|
|
310
361
|
}
|
|
311
362
|
}
|
|
@@ -15,7 +15,7 @@ export declare function isInstallableHqRoot(dir: string): boolean;
|
|
|
15
15
|
export declare function findAncestorHqRoot(startDir: string): string | null;
|
|
16
16
|
export interface InstallHqRootResolution {
|
|
17
17
|
root: string;
|
|
18
|
-
source: "flag" | "env" | "ancestor";
|
|
18
|
+
source: "flag" | "env" | "ancestor" | "trusted";
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
21
|
* Resolve the HQ root `hq mesh daemon install` records and passes to the
|
|
@@ -33,4 +33,11 @@ export declare function resolveInstallHqRoot(opts?: {
|
|
|
33
33
|
export declare function readDaemonConfig(daemonDirectory: string): DaemonConfig;
|
|
34
34
|
/** Record a verified local HQ checkout without trusting a caller-supplied path at runtime. */
|
|
35
35
|
export declare function registerTrustedHqRoot(daemonDirectory: string, candidate: string | undefined): DaemonConfig;
|
|
36
|
+
export declare function resolveIfStaleHqRoot(opts: {
|
|
37
|
+
explicit?: string;
|
|
38
|
+
env?: NodeJS.ProcessEnv;
|
|
39
|
+
cwd?: string;
|
|
40
|
+
daemonDirectory: string;
|
|
41
|
+
installedUnitRoot?: string | null;
|
|
42
|
+
}): InstallHqRootResolution;
|
|
36
43
|
//# sourceMappingURL=config.d.ts.map
|
|
@@ -117,4 +117,20 @@ export function registerTrustedHqRoot(daemonDirectory, candidate) {
|
|
|
117
117
|
fs.writeFileSync(daemonConfigPath(daemonDirectory), `${JSON.stringify(next, null, 2)}\n`, { mode: 0o600 });
|
|
118
118
|
return next;
|
|
119
119
|
}
|
|
120
|
+
export function resolveIfStaleHqRoot(opts) {
|
|
121
|
+
try {
|
|
122
|
+
return resolveInstallHqRoot(opts);
|
|
123
|
+
}
|
|
124
|
+
catch (error) {
|
|
125
|
+
if (opts.explicit?.trim() || (opts.env ?? process.env).HQ_ROOT?.trim())
|
|
126
|
+
throw error;
|
|
127
|
+
const fromUnit = verifyHqRoot(opts.installedUnitRoot ?? undefined);
|
|
128
|
+
if (fromUnit)
|
|
129
|
+
return { root: fromUnit, source: "trusted" };
|
|
130
|
+
const trusted = readDaemonConfig(opts.daemonDirectory).trustedHqRoots.at(-1);
|
|
131
|
+
if (!trusted)
|
|
132
|
+
throw error;
|
|
133
|
+
return { root: trusted, source: "trusted" };
|
|
134
|
+
}
|
|
135
|
+
}
|
|
120
136
|
//# sourceMappingURL=config.js.map
|
|
@@ -67,7 +67,7 @@ export interface InstallPaths {
|
|
|
67
67
|
/** Verified HQ root to persist and pass to the installed service. */
|
|
68
68
|
hqRoot?: string;
|
|
69
69
|
/** How hqRoot was chosen (shown in the Windows install confirmation). */
|
|
70
|
-
hqRootSource?: "flag" | "env" | "ancestor";
|
|
70
|
+
hqRootSource?: "flag" | "env" | "ancestor" | "trusted";
|
|
71
71
|
}
|
|
72
72
|
export interface InstallResult {
|
|
73
73
|
platform: DaemonInstallPlatform;
|
|
@@ -94,6 +94,7 @@ export interface InstallResult {
|
|
|
94
94
|
/** Windows status: whether recordedHqRoot still passes isInstallableHqRoot. */
|
|
95
95
|
rootValid?: boolean;
|
|
96
96
|
}
|
|
97
|
+
export declare function installedUnitHqRoot(home: string, platform?: DaemonInstallPlatform, env?: NodeJS.ProcessEnv): string | null;
|
|
97
98
|
/** Best-effort restart result used after an in-place CLI upgrade. */
|
|
98
99
|
export interface RestartDaemonResult {
|
|
99
100
|
attempted: boolean;
|
|
@@ -117,7 +118,32 @@ export declare function restartDaemonServiceIfInstalled(opts?: {
|
|
|
117
118
|
sleep?: SleepFn;
|
|
118
119
|
/** Windows: terminate the recorded daemon pid after `schtasks /End` (tests inject). */
|
|
119
120
|
kill?: (pid: number) => void;
|
|
121
|
+
loginHome?: string;
|
|
122
|
+
meshOwner?: () => MeshOwner;
|
|
120
123
|
}): RestartDaemonResult;
|
|
124
|
+
export type MeshOwner = "hq-daemon" | "hq-daemon-mesh-off" | null;
|
|
125
|
+
export interface MeshUnitRepairResult {
|
|
126
|
+
repaired: boolean;
|
|
127
|
+
action?: "replaced" | "removed";
|
|
128
|
+
from?: string;
|
|
129
|
+
message?: string;
|
|
130
|
+
}
|
|
131
|
+
export declare function repairMeshUnitFromOtherHome(opts?: {
|
|
132
|
+
platform?: DaemonInstallPlatform;
|
|
133
|
+
home?: string;
|
|
134
|
+
loginHome?: string;
|
|
135
|
+
uid?: number;
|
|
136
|
+
hqRoot?: string;
|
|
137
|
+
env?: NodeJS.ProcessEnv;
|
|
138
|
+
existsSync?: typeof fs.existsSync;
|
|
139
|
+
run?: (command: string, args: string[]) => {
|
|
140
|
+
status: number | null;
|
|
141
|
+
stdout?: string;
|
|
142
|
+
stderr?: string;
|
|
143
|
+
};
|
|
144
|
+
sleep?: SleepFn;
|
|
145
|
+
meshOwner?: () => MeshOwner;
|
|
146
|
+
}): MeshUnitRepairResult;
|
|
121
147
|
export declare function detectPlatform(platform?: NodeJS.Platform): DaemonInstallPlatform;
|
|
122
148
|
/**
|
|
123
149
|
* HQ updates moved the CLI from toolchain/node/bin/hq to
|
|
@@ -187,6 +213,7 @@ export declare function installDaemonIfStale(opts: {
|
|
|
187
213
|
readUnit?: (file: string) => string | null;
|
|
188
214
|
/** Checks the installed unit's node path (tests); defaults to the real filesystem. */
|
|
189
215
|
nodeProblem?: (nodePath: string) => "missing" | "versioned" | null;
|
|
216
|
+
loginHome?: string;
|
|
190
217
|
}): InstallIfStaleResult;
|
|
191
218
|
/**
|
|
192
219
|
* The node binary baked into the installed daemon unit (darwin plist or linux
|
|
@@ -205,7 +232,7 @@ export declare function buildInstallPaths(opts: {
|
|
|
205
232
|
argv?: string[];
|
|
206
233
|
execPath?: string;
|
|
207
234
|
hqRoot?: string;
|
|
208
|
-
hqRootSource?: "flag" | "env" | "ancestor";
|
|
235
|
+
hqRootSource?: "flag" | "env" | "ancestor" | "trusted";
|
|
209
236
|
/** Windows account (`DOMAIN\user`) the task runs as; defaults to the current user. */
|
|
210
237
|
windowsUser?: string;
|
|
211
238
|
/** Windows headless launcher override (tests); defaults to %SystemRoot%\System32\conhost.exe when present. */
|
|
@@ -337,6 +364,7 @@ export declare function installDaemonService(opts: {
|
|
|
337
364
|
run?: RunCommand;
|
|
338
365
|
uid?: number;
|
|
339
366
|
sleep?: SleepFn;
|
|
367
|
+
loginHome?: string;
|
|
340
368
|
}): InstallResult;
|
|
341
369
|
export declare function uninstallDaemonService(opts: {
|
|
342
370
|
platform?: DaemonInstallPlatform;
|
|
@@ -351,6 +379,7 @@ export declare function uninstallDaemonService(opts: {
|
|
|
351
379
|
schtasks?: SchtasksRunner;
|
|
352
380
|
/** Windows: terminate the recorded daemon pid after `schtasks /End` (tests inject). */
|
|
353
381
|
kill?: (pid: number) => void;
|
|
382
|
+
loginHome?: string;
|
|
354
383
|
}): InstallResult;
|
|
355
384
|
/**
|
|
356
385
|
* Live service-manager probe for `daemonServiceStatus`: `launchctl print
|