@indigoai-us/hq-cli 5.345.245 → 5.345.247
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 +91 -0
- package/dist/command-catalog.generated.d.ts +96 -9
- package/dist/command-catalog.generated.js +117 -9
- package/dist/commands/bot.js +1 -1
- package/dist/commands/core-checkpoint-native.d.ts +5 -1
- package/dist/commands/core-checkpoint-native.js +13 -5
- package/dist/commands/deploy-comments.js +139 -0
- package/dist/commands/deploy-list.d.ts +5 -0
- package/dist/commands/deploy-list.js +8 -0
- package/dist/commands/dm.d.ts +4 -1
- package/dist/commands/dm.js +11 -2
- package/dist/commands/files.d.ts +11 -2
- package/dist/commands/files.js +48 -3
- package/dist/commands/install-global.d.ts +15 -0
- package/dist/commands/install-global.js +98 -4
- package/dist/commands/lanes-loop.js +4 -1
- package/dist/commands/lanes.js +16 -5
- package/dist/commands/mcp-registration.d.ts +17 -0
- package/dist/commands/mcp-registration.js +119 -0
- package/dist/commands/mesh.d.ts +2 -0
- package/dist/commands/mesh.js +26 -6
- package/dist/commands/pkg-install.js +1 -1
- package/dist/commands/reindex.js +3 -2
- package/dist/commands/rescue.d.ts +22 -1
- package/dist/commands/rescue.js +56 -9
- package/dist/commands/sources.d.ts +1 -1
- package/dist/commands/sources.js +1 -1
- package/dist/commands/storage.d.ts +15 -2
- package/dist/commands/storage.js +74 -7
- package/dist/hq-cloud-sync-runner/bin/sync-runner.js +232 -225
- package/dist/hq-cloud-sync-runner/package.json +1 -1
- package/dist/lib/agent-kit/mcp/tools.js +22 -0
- package/dist/lib/bot/jobs/hot-signal-sync.js +4 -1
- package/dist/lib/daemon/fleet-members-cache.d.ts +55 -0
- package/dist/lib/daemon/fleet-members-cache.js +266 -0
- package/dist/lib/daemon/handoff.d.ts +4 -0
- package/dist/lib/daemon/handoff.js +2 -1
- package/dist/lib/daemon/hook-requests.d.ts +2 -1
- package/dist/lib/daemon/hook-requests.js +19 -2
- package/dist/lib/daemon/install.d.ts +9 -1
- package/dist/lib/daemon/install.js +11 -2
- package/dist/lib/daemon/ops/policy.d.ts +23 -3
- package/dist/lib/daemon/ops/policy.js +62 -15
- package/dist/lib/daemon/run.js +12 -0
- package/dist/lib/daemon/server.d.ts +5 -0
- package/dist/lib/daemon/server.js +1 -1
- package/dist/lib/daemon/supervisor.d.ts +6 -0
- package/dist/lib/daemon/supervisor.js +31 -2
- package/dist/lib/doctor/checks/antigravity-wiring.d.ts +21 -0
- package/dist/lib/doctor/checks/antigravity-wiring.js +75 -0
- package/dist/lib/doctor/checks/anywhere.js +30 -0
- package/dist/lib/doctor/checks/runtime-probe.js +13 -0
- package/dist/lib/doctor/checks/sync-runtime.js +8 -1
- package/dist/lib/doctor/platform.d.ts +1 -1
- package/dist/lib/doctor/platform.js +5 -0
- package/dist/lib/doctor/registry.js +3 -0
- 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/hook-engine/coverage.d.ts +159 -0
- package/dist/lib/hook-engine/coverage.js +347 -0
- package/dist/lib/hook-engine/native-precompact-compatibility.json +1 -0
- package/dist/lib/hot-channels/signals-pass.d.ts +52 -2
- package/dist/lib/hot-channels/signals-pass.js +65 -3
- package/dist/lib/install/antigravity-targets.d.ts +39 -0
- package/dist/lib/install/antigravity-targets.js +122 -0
- package/dist/lib/install/claude-targets.d.ts +6 -0
- package/dist/lib/install/claude-targets.js +9 -1
- package/dist/lib/lanes/reconcile-result.d.ts +1 -1
- package/dist/lib/lanes/reconcile.js +19 -4
- package/dist/lib/lanes/remote-control-lane.d.ts +6 -0
- package/dist/lib/lanes/remote-control-lane.js +10 -1
- package/dist/lib/lanes/spawn.d.ts +2 -0
- package/dist/lib/lanes/spawn.js +19 -3
- package/dist/lib/lanes/worker-env-scrub.d.ts +48 -0
- package/dist/lib/lanes/worker-env-scrub.js +146 -0
- package/dist/lib/lanes/worker-process.js +4 -1
- package/dist/lib/mesh/client.js +5 -1
- package/dist/lib/mesh/live/daemon/doctor.d.ts +9 -0
- package/dist/lib/mesh/live/daemon/doctor.js +51 -6
- package/dist/lib/mesh/live/daemon/install.d.ts +39 -0
- package/dist/lib/mesh/live/daemon/install.js +70 -0
- package/dist/lib/mesh/live/daemon/outbox-company.d.ts +47 -0
- package/dist/lib/mesh/live/daemon/outbox-company.js +77 -0
- package/dist/lib/mesh/live/daemon/run.d.ts +2 -0
- package/dist/lib/mesh/live/daemon/run.js +48 -3
- package/dist/lib/mesh/live/daemon/state.d.ts +5 -0
- package/dist/lib/mesh/live/daemon/system-unit.d.ts +21 -0
- package/dist/lib/mesh/live/daemon/system-unit.js +80 -0
- package/dist/lib/mesh/live/daemon/transcript-watch.d.ts +4 -1
- package/dist/lib/mesh/live/daemon/transcript-watch.js +42 -38
- package/dist/lib/mesh/live/direct-drain.js +3 -1
- package/dist/lib/mesh/live/emit.js +4 -2
- package/dist/lib/mesh/live/flush.d.ts +61 -0
- package/dist/lib/mesh/live/flush.js +434 -114
- package/dist/lib/mesh/live/paths.d.ts +10 -0
- package/dist/lib/mesh/live/paths.js +14 -0
- package/dist/lib/mesh/live/reporting-privacy.d.ts +41 -1
- package/dist/lib/mesh/live/reporting-privacy.js +81 -7
- package/dist/lib/mesh/live/spool.d.ts +171 -17
- package/dist/lib/mesh/live/spool.js +777 -62
- package/dist/lib/signals/engine.d.ts +82 -2
- package/dist/lib/signals/engine.js +389 -53
- package/dist/lib/signals/steps/extract.js +5 -0
- package/dist/lib/work-context/organize.d.ts +22 -4
- package/dist/lib/work-context/organize.js +50 -21
- package/dist/lib/work-context/paths.d.ts +6 -0
- package/dist/lib/work-context/paths.js +9 -0
- package/dist/lib/work-context/reconcile.d.ts +1 -1
- package/dist/lib/work-context/reconcile.js +1 -1
- package/dist/startup-registration.d.ts +14 -0
- package/dist/startup-registration.js +26 -0
- package/dist/utils/cli-telemetry.d.ts +6 -0
- package/dist/utils/cli-telemetry.js +154 -9
- package/dist/utils/github-tag-fallback.d.ts +7 -2
- package/dist/utils/github-tag-fallback.js +17 -8
- package/dist/utils/hq-core-source.d.ts +31 -0
- package/dist/utils/hq-core-source.js +144 -0
- package/dist/utils/interactive-caller.d.ts +6 -0
- package/dist/utils/interactive-caller.js +8 -0
- package/dist/utils/shipped-codex-hooks.d.ts +6 -4
- package/dist/utils/shipped-codex-hooks.js +22 -10
- package/dist/utils/vault-api.js +1 -0
- package/dist/utils/version-report.d.ts +3 -1
- package/dist/utils/version-report.js +13 -5
- package/docs/anywhere-runtime.md +2 -2
- package/package.json +8 -8
- package/scripts/check-function-manifest.mjs +99 -18
|
@@ -16,6 +16,14 @@
|
|
|
16
16
|
* a watcher can miss a change: on macOS fs.watch is backed by an FSEvents
|
|
17
17
|
* stream that starts asynchronously, so a change made right after a rebuild
|
|
18
18
|
* re-arms the watchers is never reported.
|
|
19
|
+
*
|
|
20
|
+
* A stamp alone can also miss a change. Linux sets a directory's mtime from
|
|
21
|
+
* the coarse kernel clock (one tick, about 1-10 ms), so a change made in the
|
|
22
|
+
* same tick as the rebuild's stat leaves dev:ino:mtime unchanged. This is git's
|
|
23
|
+
* "racy index" problem and gets git's answer: a directory whose mtime is within
|
|
24
|
+
* RACY_WINDOW_MS of the rebuild is racy, its names are kept, and list()
|
|
25
|
+
* re-reads it and compares names until its mtime is older than the window.
|
|
26
|
+
* Directories outside the window cost one stat per list(), as before.
|
|
19
27
|
*/
|
|
20
28
|
import { spawn } from "node:child_process";
|
|
21
29
|
import * as fs from "node:fs";
|
|
@@ -36,20 +44,32 @@ export class PolicyOpError extends Error {
|
|
|
36
44
|
this.name = "PolicyOpError";
|
|
37
45
|
}
|
|
38
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* How close to a rebuild a directory's mtime may be before a later change could
|
|
49
|
+
* leave it unchanged. It must exceed the filesystem's mtime granularity: one
|
|
50
|
+
* kernel tick on Linux (up to 10 ms), nanoseconds on APFS, and 2 s on FAT and
|
|
51
|
+
* exFAT volumes, which set the bound. A wider window only means a recently
|
|
52
|
+
* changed directory is re-read (one readdir) on each list() for that long.
|
|
53
|
+
*/
|
|
54
|
+
export const RACY_WINDOW_MS = 2_000;
|
|
39
55
|
/** Cached list of policy files under HQ_ROOT, invalidated by fs.watch. */
|
|
40
56
|
export class PolicyIndex {
|
|
41
57
|
hqRoot;
|
|
42
58
|
log;
|
|
59
|
+
now;
|
|
43
60
|
entries = null;
|
|
44
|
-
/** Directory
|
|
45
|
-
|
|
61
|
+
/** Directory state taken while building `entries` (dir -> stamp, plus names while racy). */
|
|
62
|
+
dirStates = new Map();
|
|
46
63
|
watchers = [];
|
|
47
64
|
closed = false;
|
|
48
65
|
/** Bumped on every invalidation; lets callers see that the cache was rebuilt. */
|
|
49
66
|
version = 0;
|
|
50
|
-
constructor(hqRoot, log = () => { }
|
|
67
|
+
constructor(hqRoot, log = () => { },
|
|
68
|
+
/** Wall clock in ms, compared with directory mtimes. Injectable for tests. */
|
|
69
|
+
now = Date.now) {
|
|
51
70
|
this.hqRoot = hqRoot;
|
|
52
71
|
this.log = log;
|
|
72
|
+
this.now = now;
|
|
53
73
|
}
|
|
54
74
|
/** Policies visible to `company`: core, personal, and that company only. */
|
|
55
75
|
list(company) {
|
|
@@ -73,15 +93,36 @@ export class PolicyIndex {
|
|
|
73
93
|
}
|
|
74
94
|
/** True when any directory scanned by the last rebuild changed since. */
|
|
75
95
|
isStale() {
|
|
76
|
-
|
|
77
|
-
|
|
96
|
+
// Read the clock before any readdir: a change after that readdir lands more
|
|
97
|
+
// than RACY_WINDOW_MS after a settled directory's mtime, so it moves the
|
|
98
|
+
// mtime and the stamp check alone sees it from then on.
|
|
99
|
+
const now = this.now();
|
|
100
|
+
for (const [dir, state] of this.dirStates) {
|
|
101
|
+
if (dirStat(dir).stamp !== state.stamp)
|
|
102
|
+
return true;
|
|
103
|
+
if (state.names === undefined)
|
|
104
|
+
continue;
|
|
105
|
+
if (!sameNames(sortedDirNames(dir), state.names))
|
|
78
106
|
return true;
|
|
107
|
+
if (now - state.mtimeMs > RACY_WINDOW_MS)
|
|
108
|
+
state.names = undefined;
|
|
109
|
+
}
|
|
79
110
|
return false;
|
|
80
111
|
}
|
|
81
112
|
rebuild() {
|
|
82
113
|
// Stamp each directory before reading it, so a change racing the read
|
|
83
114
|
// either shows up in the read or leaves a stale stamp for the next list().
|
|
84
|
-
|
|
115
|
+
// A racy directory's names are read right after its stamp, before the
|
|
116
|
+
// reads below, so a change in between at worst costs one extra rebuild.
|
|
117
|
+
const start = this.now();
|
|
118
|
+
const dirStates = new Map();
|
|
119
|
+
const record = (dir) => {
|
|
120
|
+
const st = dirStat(dir);
|
|
121
|
+
const state = { stamp: st.stamp, mtimeMs: st.mtimeMs };
|
|
122
|
+
if (st.stamp !== "missing" && st.mtimeMs >= start - RACY_WINDOW_MS)
|
|
123
|
+
state.names = sortedDirNames(dir);
|
|
124
|
+
dirStates.set(dir, state);
|
|
125
|
+
};
|
|
85
126
|
const dirs = [
|
|
86
127
|
{ dir: path.join(this.hqRoot, "core", "policies"), scope: "core" },
|
|
87
128
|
{ dir: path.join(this.hqRoot, "personal", "policies"), scope: "personal" },
|
|
@@ -89,18 +130,18 @@ export class PolicyIndex {
|
|
|
89
130
|
const companiesDir = path.join(this.hqRoot, "companies");
|
|
90
131
|
const companyDirs = [];
|
|
91
132
|
for (const d of dirs)
|
|
92
|
-
|
|
93
|
-
|
|
133
|
+
record(d.dir);
|
|
134
|
+
record(companiesDir);
|
|
94
135
|
for (const co of readDirNames(companiesDir)) {
|
|
95
136
|
if (!SLUG_RE.test(co))
|
|
96
137
|
continue;
|
|
97
138
|
const companyDir = path.join(companiesDir, co);
|
|
98
|
-
|
|
139
|
+
record(companyDir);
|
|
99
140
|
if (isDir(companyDir))
|
|
100
141
|
companyDirs.push(companyDir);
|
|
101
142
|
const dir = path.join(companiesDir, co, "policies");
|
|
102
143
|
if (isDir(dir)) {
|
|
103
|
-
|
|
144
|
+
record(dir);
|
|
104
145
|
dirs.push({ dir, scope: "company", company: co });
|
|
105
146
|
}
|
|
106
147
|
}
|
|
@@ -113,7 +154,7 @@ export class PolicyIndex {
|
|
|
113
154
|
}
|
|
114
155
|
}
|
|
115
156
|
this.entries = entries;
|
|
116
|
-
this.
|
|
157
|
+
this.dirStates = dirStates;
|
|
117
158
|
this.rewatch([...dirs.map((d) => d.dir), ...companyDirs, companiesDir]);
|
|
118
159
|
}
|
|
119
160
|
rewatch(dirs) {
|
|
@@ -149,14 +190,20 @@ function readDirNames(dir) {
|
|
|
149
190
|
throw err;
|
|
150
191
|
}
|
|
151
192
|
}
|
|
152
|
-
|
|
153
|
-
|
|
193
|
+
function sortedDirNames(dir) {
|
|
194
|
+
return readDirNames(dir).sort();
|
|
195
|
+
}
|
|
196
|
+
function sameNames(a, b) {
|
|
197
|
+
return a.length === b.length && a.every((name, i) => name === b[i]);
|
|
198
|
+
}
|
|
199
|
+
/** Identity plus modification time of a directory ("missing" if absent), and that mtime in ms. */
|
|
200
|
+
function dirStat(dir) {
|
|
154
201
|
try {
|
|
155
202
|
const st = fs.statSync(dir, { bigint: true });
|
|
156
|
-
return `${st.dev}:${st.ino}:${st.mtimeNs}
|
|
203
|
+
return { stamp: `${st.dev}:${st.ino}:${st.mtimeNs}`, mtimeMs: Number(st.mtimeNs) / 1e6 };
|
|
157
204
|
}
|
|
158
205
|
catch {
|
|
159
|
-
return "missing";
|
|
206
|
+
return { stamp: "missing", mtimeMs: 0 };
|
|
160
207
|
}
|
|
161
208
|
}
|
|
162
209
|
function isDir(dir) {
|
package/dist/lib/daemon/run.js
CHANGED
|
@@ -41,6 +41,7 @@ import { daemonLanesReconcileHandler } from "../lanes/daemon-reconcile.js";
|
|
|
41
41
|
import { computeLanesMonitorSection } from "./lanes-monitor-state.js";
|
|
42
42
|
import { ensureDaemonLanesReconcileHandler, runDaemonLanesReconcileInProcess } from "./lanes-reconcile-loader.js";
|
|
43
43
|
import { startWhoamiCacheWriter } from "./whoami-cache.js";
|
|
44
|
+
import { hqMembersList, startFleetMembersWarmer } from "./fleet-members-cache.js";
|
|
44
45
|
import { SUPERVISOR_HANDOFF_FLAG, readDaemonFlag } from "./flag.js";
|
|
45
46
|
import { createDaemonSharedFlagReads, hqdListenerFlagGate } from "./shared-flag-reads.js";
|
|
46
47
|
import { createDaemonKillSwitchMonitors } from "./timed-flag-monitors.js";
|
|
@@ -1226,6 +1227,16 @@ export async function runDaemon(opts) {
|
|
|
1226
1227
|
lookupPersonUid: async (token) => (await import("../../commands/whoami.js")).readPersonUid(token),
|
|
1227
1228
|
})
|
|
1228
1229
|
: null;
|
|
1230
|
+
const fleetMembersAbort = new AbortController();
|
|
1231
|
+
const fleetMembers = path.resolve(home) === path.resolve(os.homedir())
|
|
1232
|
+
? startFleetMembersWarmer({
|
|
1233
|
+
home,
|
|
1234
|
+
env,
|
|
1235
|
+
log,
|
|
1236
|
+
abort: fleetMembersAbort,
|
|
1237
|
+
list: hqMembersList({ nodeBinary: opts.nodeBinary, hqBinary: opts.hqBinary, env, signal: fleetMembersAbort.signal }),
|
|
1238
|
+
})
|
|
1239
|
+
: null;
|
|
1229
1240
|
// The hqd listener checks again when a shared read's HQ Anywhere answer
|
|
1230
1241
|
// changes, or the running server's runtime gate changes; it has no timer of
|
|
1231
1242
|
// its own beyond a rare fallback (anywhere-listener.ts).
|
|
@@ -1369,6 +1380,7 @@ export async function runDaemon(opts) {
|
|
|
1369
1380
|
mergeSections.close();
|
|
1370
1381
|
stateWriter.close();
|
|
1371
1382
|
whoamiCache?.close();
|
|
1383
|
+
fleetMembers?.close();
|
|
1372
1384
|
return stopJobsClosed;
|
|
1373
1385
|
};
|
|
1374
1386
|
const plan = () => {
|
|
@@ -45,6 +45,11 @@ export interface HqdServerOptions {
|
|
|
45
45
|
env?: NodeJS.ProcessEnv;
|
|
46
46
|
/** Test seam for the hq-anywhere-runtime fail-safe gate. */
|
|
47
47
|
mcpEnabled?: () => boolean | Promise<boolean>;
|
|
48
|
+
/**
|
|
49
|
+
* Time a skill.command request may run, from when hqd received it. Defaults
|
|
50
|
+
* to HQD_DEFAULT_REQUEST_TIMEOUT_MS; tests set it shorter.
|
|
51
|
+
*/
|
|
52
|
+
skillCommandTimeoutMs?: number;
|
|
48
53
|
/** Test seam for the live hq-flags read used by the daemon's bounded runtime monitor. */
|
|
49
54
|
runtimeFlagReader?: (options: ReadDaemonFlagOptions) => Promise<boolean>;
|
|
50
55
|
/** Test seam for the human opt-in setting; production reads hq-pro. */
|
|
@@ -564,7 +564,7 @@ export async function startHqdServer(opts) {
|
|
|
564
564
|
case "skill.command":
|
|
565
565
|
return runSkillCommand(parseSkillCommandArgs(args), {
|
|
566
566
|
daemonRoot: requireRoot(),
|
|
567
|
-
deadlineMs: requestStartedAt + HQD_DEFAULT_REQUEST_TIMEOUT_MS,
|
|
567
|
+
deadlineMs: requestStartedAt + (opts.skillCommandTimeoutMs ?? HQD_DEFAULT_REQUEST_TIMEOUT_MS),
|
|
568
568
|
});
|
|
569
569
|
case "mcp.call": {
|
|
570
570
|
const name = stringArg(args, "name");
|
|
@@ -244,6 +244,12 @@ export interface Supervisor {
|
|
|
244
244
|
* `keepAcrossCliUpdates` running.
|
|
245
245
|
*/
|
|
246
246
|
export declare function planKey(plan: UnitPlan, cliVersion?: string): string;
|
|
247
|
+
/**
|
|
248
|
+
* The line of a unit's output that names why it stopped: V8's FATAL ERROR
|
|
249
|
+
* line, else the last line that looks like a thrown error. Stack frames and
|
|
250
|
+
* plain log lines are not causes. Bounded to 200 characters.
|
|
251
|
+
*/
|
|
252
|
+
export declare function exitCauseLine(outputTail: string | undefined): string | undefined;
|
|
247
253
|
export declare const DAEMON_REQUEST_POLL_MS = 250;
|
|
248
254
|
export declare function createSupervisor(deps: SupervisorDeps): Supervisor;
|
|
249
255
|
export {};
|
|
@@ -187,6 +187,20 @@ export function planKey(plan, cliVersion) {
|
|
|
187
187
|
fields.push(cliVersion);
|
|
188
188
|
return JSON.stringify(fields);
|
|
189
189
|
}
|
|
190
|
+
/**
|
|
191
|
+
* The line of a unit's output that names why it stopped: V8's FATAL ERROR
|
|
192
|
+
* line, else the last line that looks like a thrown error. Stack frames and
|
|
193
|
+
* plain log lines are not causes. Bounded to 200 characters.
|
|
194
|
+
*/
|
|
195
|
+
export function exitCauseLine(outputTail) {
|
|
196
|
+
if (!outputTail)
|
|
197
|
+
return undefined;
|
|
198
|
+
const lines = outputTail.split(/\r?\n/).map((line) => line.trim()).filter(Boolean);
|
|
199
|
+
const fatal = [...lines].reverse().find((line) => line.startsWith("FATAL ERROR:"));
|
|
200
|
+
const thrown = [...lines].reverse().find((line) => /^(Uncaught )?([A-Z][A-Za-z]*Error|Error)(\s*\[[A-Z_]+\])?:/.test(line));
|
|
201
|
+
const cause = fatal ?? thrown;
|
|
202
|
+
return cause ? cause.slice(0, 200) : undefined;
|
|
203
|
+
}
|
|
190
204
|
function errorMessage(err) {
|
|
191
205
|
return err instanceof Error ? err.message : String(err);
|
|
192
206
|
}
|
|
@@ -936,7 +950,22 @@ export function createSupervisor(deps) {
|
|
|
936
950
|
emit();
|
|
937
951
|
return;
|
|
938
952
|
}
|
|
939
|
-
|
|
953
|
+
// An abnormal exit names its cause from the unit's own output (for
|
|
954
|
+
// example V8's "JavaScript heap out of memory" before a SIGABRT), so
|
|
955
|
+
// the daemon log says why without opening the unit log.
|
|
956
|
+
// The output is read at most once per exit.
|
|
957
|
+
let tailRead = false;
|
|
958
|
+
let tail;
|
|
959
|
+
const exitTail = () => {
|
|
960
|
+
if (!tailRead) {
|
|
961
|
+
tailRead = true;
|
|
962
|
+
tail = readExitOutputTail(slot);
|
|
963
|
+
}
|
|
964
|
+
return tail;
|
|
965
|
+
};
|
|
966
|
+
const abnormal = code !== 0 && signal !== "SIGTERM" && signal !== "SIGINT";
|
|
967
|
+
const cause = abnormal && slot.lastSpawnError === undefined ? exitCauseLine(exitTail()) : undefined;
|
|
968
|
+
deps.log("warn", `${slot.plan.id} exited (code=${code ?? "null"} signal=${signal ?? "none"})${cause ? `: ${cause}` : ""}`);
|
|
940
969
|
if (ranFor >= HEALTHY_RUN_MS)
|
|
941
970
|
slot.attempts = 0;
|
|
942
971
|
if (ranFor >= EPISODE_HEALTHY_RESET_MS) {
|
|
@@ -954,7 +983,7 @@ export function createSupervisor(deps) {
|
|
|
954
983
|
else {
|
|
955
984
|
const spawnError = slot.lastSpawnError;
|
|
956
985
|
delete slot.lastSpawnError;
|
|
957
|
-
const outputTail = spawnError === undefined ?
|
|
986
|
+
const outputTail = spawnError === undefined ? exitTail() : undefined;
|
|
958
987
|
delete slot.lastLockHolderPid;
|
|
959
988
|
if (slot.plan.service === "sync-core" && code === SYNC_CORE_LOCK_HELD_EXIT) {
|
|
960
989
|
const holder = lockHolderPidFromOutput(outputTail);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Google Antigravity wiring checks.
|
|
3
|
+
*
|
|
4
|
+
* HQ wires Antigravity through two user-scope files under `~/.gemini/config/`:
|
|
5
|
+
* the always-on global rule `rules/hq.md` and the `hq` entry in
|
|
6
|
+
* `mcp_config.json` (both written by `hq install --global`). This tier reports
|
|
7
|
+
* whether each is present. Antigravity hooks are not wired by HQ yet; that is
|
|
8
|
+
* reported as an advisory NA line, never a failure.
|
|
9
|
+
*
|
|
10
|
+
* When Antigravity is not detected the tier reports a single NA line. Home and
|
|
11
|
+
* the app path are injectable so tests never read the developer's real home.
|
|
12
|
+
*/
|
|
13
|
+
import type { CheckContext, CheckResult } from "../types.js";
|
|
14
|
+
export declare const ANTIGRAVITY_INSTALL_REMEDIATION = "hq install --global --runtime antigravity";
|
|
15
|
+
export interface AntigravityWiringOptions {
|
|
16
|
+
home?: string;
|
|
17
|
+
env?: NodeJS.ProcessEnv;
|
|
18
|
+
appPath?: string;
|
|
19
|
+
}
|
|
20
|
+
export declare function checkAntigravityWiring(_context: CheckContext, options?: AntigravityWiringOptions): CheckResult[];
|
|
21
|
+
//# sourceMappingURL=antigravity-wiring.d.ts.map
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Google Antigravity wiring checks.
|
|
3
|
+
*
|
|
4
|
+
* HQ wires Antigravity through two user-scope files under `~/.gemini/config/`:
|
|
5
|
+
* the always-on global rule `rules/hq.md` and the `hq` entry in
|
|
6
|
+
* `mcp_config.json` (both written by `hq install --global`). This tier reports
|
|
7
|
+
* whether each is present. Antigravity hooks are not wired by HQ yet; that is
|
|
8
|
+
* reported as an advisory NA line, never a failure.
|
|
9
|
+
*
|
|
10
|
+
* When Antigravity is not detected the tier reports a single NA line. Home and
|
|
11
|
+
* the app path are injectable so tests never read the developer's real home.
|
|
12
|
+
*/
|
|
13
|
+
import * as fs from "node:fs";
|
|
14
|
+
import * as os from "node:os";
|
|
15
|
+
import { ANTIGRAVITY_HOOKS_ADVISORY, antigravityTargets, detectAntigravity, isHqAntigravityRule, } from "../../install/antigravity-targets.js";
|
|
16
|
+
import { HQ_MCP_SERVER_NAME } from "../../install/claude-targets.js";
|
|
17
|
+
export const ANTIGRAVITY_INSTALL_REMEDIATION = "hq install --global --runtime antigravity";
|
|
18
|
+
export function checkAntigravityWiring(_context, options = {}) {
|
|
19
|
+
const home = options.home ?? os.homedir();
|
|
20
|
+
const detection = detectAntigravity({ home, env: options.env, appPath: options.appPath });
|
|
21
|
+
if (!detection.detected) {
|
|
22
|
+
return [{
|
|
23
|
+
status: "NA",
|
|
24
|
+
checkId: "antigravity.detected",
|
|
25
|
+
target: "antigravity",
|
|
26
|
+
message: "Google Antigravity not detected (no app, ~/.gemini/config, ~/.gemini/antigravity, or agy on PATH).",
|
|
27
|
+
}];
|
|
28
|
+
}
|
|
29
|
+
const t = antigravityTargets(home);
|
|
30
|
+
return [
|
|
31
|
+
checkRule(t.ruleFile),
|
|
32
|
+
checkMcp(t.mcpConfig),
|
|
33
|
+
{ status: "NA", checkId: "antigravity.hooks", target: "antigravity", message: ANTIGRAVITY_HOOKS_ADVISORY },
|
|
34
|
+
];
|
|
35
|
+
}
|
|
36
|
+
function readOrNull(file) {
|
|
37
|
+
try {
|
|
38
|
+
return fs.readFileSync(file, "utf8");
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function checkRule(ruleFile) {
|
|
45
|
+
const raw = readOrNull(ruleFile);
|
|
46
|
+
if (raw === null) {
|
|
47
|
+
return { status: "WARN", checkId: "antigravity.rule", target: ruleFile, message: "Antigravity HQ rule is missing; Antigravity sessions will not load the HQ charter.", remediation: ANTIGRAVITY_INSTALL_REMEDIATION };
|
|
48
|
+
}
|
|
49
|
+
if (!isHqAntigravityRule(raw)) {
|
|
50
|
+
return { status: "WARN", checkId: "antigravity.rule", target: ruleFile, message: "Antigravity rules/hq.md exists but is not the HQ-managed always-on rule.", remediation: ANTIGRAVITY_INSTALL_REMEDIATION };
|
|
51
|
+
}
|
|
52
|
+
return { status: "PASS", checkId: "antigravity.rule", target: ruleFile, message: "Antigravity always-on HQ rule is present." };
|
|
53
|
+
}
|
|
54
|
+
function checkMcp(mcpConfig) {
|
|
55
|
+
const raw = readOrNull(mcpConfig);
|
|
56
|
+
if (raw === null) {
|
|
57
|
+
return { status: "WARN", checkId: "antigravity.mcp", target: mcpConfig, message: `Antigravity mcp_config.json is missing; the "${HQ_MCP_SERVER_NAME}" MCP server is not registered.`, remediation: ANTIGRAVITY_INSTALL_REMEDIATION };
|
|
58
|
+
}
|
|
59
|
+
let doc;
|
|
60
|
+
try {
|
|
61
|
+
doc = JSON.parse(raw);
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
return { status: "FAIL", checkId: "antigravity.mcp", target: mcpConfig, message: "Antigravity mcp_config.json is not valid JSON; Antigravity cannot load any MCP server from it.", remediation: "Fix the JSON, then run hq install --global --runtime antigravity" };
|
|
65
|
+
}
|
|
66
|
+
const servers = doc?.mcpServers;
|
|
67
|
+
const entry = servers && typeof servers === "object" && !Array.isArray(servers)
|
|
68
|
+
? servers[HQ_MCP_SERVER_NAME]
|
|
69
|
+
: undefined;
|
|
70
|
+
if (!entry || typeof entry !== "object") {
|
|
71
|
+
return { status: "WARN", checkId: "antigravity.mcp", target: mcpConfig, message: `Antigravity mcp_config.json has no "${HQ_MCP_SERVER_NAME}" MCP server.`, remediation: ANTIGRAVITY_INSTALL_REMEDIATION };
|
|
72
|
+
}
|
|
73
|
+
return { status: "PASS", checkId: "antigravity.mcp", target: mcpConfig, message: `Antigravity MCP server "${HQ_MCP_SERVER_NAME}" is registered.` };
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=antigravity-wiring.js.map
|
|
@@ -18,6 +18,7 @@ import { HQ_MCP_SERVER_NAME, SKILL_LINK_PREFIX, claudeTargets } from "../../inst
|
|
|
18
18
|
import { codexTargets } from "../../install/codex-targets.js";
|
|
19
19
|
import { CHATGPT_MODE } from "../../install/chatgpt-targets.js";
|
|
20
20
|
import { GROK_MODE } from "../../install/grok-targets.js";
|
|
21
|
+
import { antigravityTargets, isHqAntigravityRule } from "../../install/antigravity-targets.js";
|
|
21
22
|
import { HqdClientError, hqdRequest } from "../../daemon/protocol.js";
|
|
22
23
|
import { daemonPresenceLabel, heartbeatFile, readHeartbeat } from "../../daemon/heartbeat.js";
|
|
23
24
|
import { DAEMON_LAUNCHD_LABEL, DAEMON_SYSTEMD_UNIT, LEGACY_DAEMON_WINDOWS_TASK, currentWindowsIdentity, legacyWindowsTask, windowsTaskName, } from "../../daemon/install.js";
|
|
@@ -53,6 +54,32 @@ export function createAnywhereFamily(deps = {}) {
|
|
|
53
54
|
return { id: ANYWHERE_FAMILY_ID, title: "HQ anywhere runtime", run: (context) => runAnywhereChecks(context, deps) };
|
|
54
55
|
}
|
|
55
56
|
export const anywhereFamily = createAnywhereFamily();
|
|
57
|
+
/** One line for Google Antigravity, only when its config root (~/.gemini/config) exists. */
|
|
58
|
+
function antigravityAnywhereCheck(home) {
|
|
59
|
+
const t = antigravityTargets(home);
|
|
60
|
+
if (!fs.existsSync(t.configDir))
|
|
61
|
+
return null;
|
|
62
|
+
let rule = null;
|
|
63
|
+
try {
|
|
64
|
+
rule = fs.readFileSync(t.ruleFile, "utf8");
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
rule = null;
|
|
68
|
+
}
|
|
69
|
+
let mcp = false;
|
|
70
|
+
try {
|
|
71
|
+
const doc = JSON.parse(fs.readFileSync(t.mcpConfig, "utf8"));
|
|
72
|
+
mcp = Boolean(doc.mcpServers && typeof doc.mcpServers === "object" && doc.mcpServers[HQ_MCP_SERVER_NAME]);
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
mcp = false;
|
|
76
|
+
}
|
|
77
|
+
const ruleOk = isHqAntigravityRule(rule);
|
|
78
|
+
if (ruleOk && mcp)
|
|
79
|
+
return result("PASS", "antigravity", "Antigravity: always-on HQ rule and hq MCP server are installed (hooks not wired yet)");
|
|
80
|
+
const missing = [ruleOk ? null : "always-on HQ rule", mcp ? null : "hq MCP server"].filter(Boolean).join(" and ");
|
|
81
|
+
return result("WARN", "antigravity", `Antigravity: ${missing} missing`, "hq install --global --runtime antigravity");
|
|
82
|
+
}
|
|
56
83
|
function result(status, checkId, message, remediation, target) {
|
|
57
84
|
return { status, checkId: `anywhere.${checkId}`, message, ...(remediation ? { remediation } : {}), ...(target ? { target } : {}) };
|
|
58
85
|
}
|
|
@@ -146,6 +173,9 @@ async function runAnywhereChecks(context, deps = {}) {
|
|
|
146
173
|
result("WARN", "grok-mode", `Grok integration mode: ${GROK_MODE}; host connector setup is managed in Grok`, "hq install --global --runtime grok"),
|
|
147
174
|
];
|
|
148
175
|
const out = [healthCheck, settingCheck, ...remoteModes];
|
|
176
|
+
const antigravity = antigravityAnywhereCheck(home);
|
|
177
|
+
if (antigravity)
|
|
178
|
+
out.push(antigravity);
|
|
149
179
|
if (!installed) {
|
|
150
180
|
return [...out, result("NA", "installed", "HQ local anywhere runtime is not installed on this machine", REMEDIATION.installClaude)];
|
|
151
181
|
}
|
|
@@ -324,6 +324,19 @@ export function checkRuntimeProbe(context) {
|
|
|
324
324
|
},
|
|
325
325
|
];
|
|
326
326
|
}
|
|
327
|
+
// Google Antigravity: HQ does not register hooks there yet, so an empty or
|
|
328
|
+
// present ledger says nothing about this host. Report it as not applicable.
|
|
329
|
+
if (platformId === "antigravity") {
|
|
330
|
+
return [
|
|
331
|
+
{
|
|
332
|
+
status: "NA",
|
|
333
|
+
checkId,
|
|
334
|
+
target,
|
|
335
|
+
message: `Host platform is Google Antigravity. HQ hooks are not wired for Antigravity yet; HQ policies ` +
|
|
336
|
+
`load through the always-on rule and AGENTS.md. The policy-trigger ledger is ${repro.ledgerState}${scope}.`,
|
|
337
|
+
},
|
|
338
|
+
];
|
|
339
|
+
}
|
|
327
340
|
// Ledger present ⇒ a hook demonstrably fired this session ⇒ enforcement is live.
|
|
328
341
|
if (repro.ledgerState === "present") {
|
|
329
342
|
return [
|
|
@@ -324,7 +324,14 @@ export function analyzeSyncRuntimeLog(lines, options) {
|
|
|
324
324
|
function readLogTail(file) {
|
|
325
325
|
const fd = fs.openSync(file, "r");
|
|
326
326
|
try {
|
|
327
|
-
const
|
|
327
|
+
const stat = fs.fstatSync(fd);
|
|
328
|
+
// Opening a directory read-only succeeds on Linux, and where a directory's
|
|
329
|
+
// size reads as 0 (btrfs, overlayfs on btrfs) the zero-length read below
|
|
330
|
+
// succeeds too. Refuse anything that is not a regular file so a directory
|
|
331
|
+
// at the log path reads as unreadable on every filesystem.
|
|
332
|
+
if (!stat.isFile())
|
|
333
|
+
throw new Error(`sync log is not a regular file: ${file}`);
|
|
334
|
+
const size = stat.size;
|
|
328
335
|
const length = Math.min(size, LOG_TAIL_BYTES);
|
|
329
336
|
const buffer = Buffer.alloc(length);
|
|
330
337
|
fs.readSync(fd, buffer, 0, length, size - length);
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
*/
|
|
52
52
|
import type { DoctorStatus } from "./types.js";
|
|
53
53
|
/** Every platform the doctor can report, including the `unknown` fallback. */
|
|
54
|
-
export declare const PLATFORMS: readonly ["claude-code-cli", "claude-code-app", "claude-code-sdk", "codex", "grok", "unknown"];
|
|
54
|
+
export declare const PLATFORMS: readonly ["claude-code-cli", "claude-code-app", "claude-code-sdk", "codex", "grok", "antigravity", "unknown"];
|
|
55
55
|
/** A detected host platform. Closed union derived from {@link PLATFORMS}. */
|
|
56
56
|
export type Platform = (typeof PLATFORMS)[number];
|
|
57
57
|
/**
|
|
@@ -57,6 +57,7 @@ export const PLATFORMS = [
|
|
|
57
57
|
"claude-code-sdk",
|
|
58
58
|
"codex",
|
|
59
59
|
"grok",
|
|
60
|
+
"antigravity",
|
|
60
61
|
"unknown",
|
|
61
62
|
];
|
|
62
63
|
// --- environment signal collectors --------------------------------------------
|
|
@@ -124,6 +125,9 @@ export function bundleIdEvidence(env) {
|
|
|
124
125
|
if (id === "com.openai.codex") {
|
|
125
126
|
return { key, detail, points: "codex", strength: "strong" };
|
|
126
127
|
}
|
|
128
|
+
if (id === "com.google.antigravity") {
|
|
129
|
+
return { key, detail, points: "antigravity", strength: "strong" };
|
|
130
|
+
}
|
|
127
131
|
if (/grok|(?:^|\.)x\.ai(?:\.|$)|com\.xai/i.test(id)) {
|
|
128
132
|
return { key, detail, points: "grok", strength: "strong" };
|
|
129
133
|
}
|
|
@@ -437,6 +441,7 @@ const PLATFORM_LABELS = {
|
|
|
437
441
|
"claude-code-sdk": "Claude Code (SDK)",
|
|
438
442
|
codex: "Codex",
|
|
439
443
|
grok: "Grok",
|
|
444
|
+
antigravity: "Google Antigravity",
|
|
440
445
|
unknown: "unknown",
|
|
441
446
|
};
|
|
442
447
|
/** A human-readable label for a platform, for text and report output. */
|
|
@@ -18,6 +18,7 @@ import { jqFamily } from './checks/jq.js';
|
|
|
18
18
|
import * as path from "node:path";
|
|
19
19
|
import { checkCodexWiring } from "./checks/codex-wiring.js";
|
|
20
20
|
import { checkGrokWiring } from "./checks/grok-wiring.js";
|
|
21
|
+
import { checkAntigravityWiring } from "./checks/antigravity-wiring.js";
|
|
21
22
|
import { checkRuntimeProbe } from "./checks/runtime-probe.js";
|
|
22
23
|
import { runtimeHealthFamily } from "./checks/runtime-health.js";
|
|
23
24
|
import { integrationsFamily } from "./checks/integrations.js";
|
|
@@ -110,6 +111,8 @@ function runHooksFamily(context) {
|
|
|
110
111
|
// doctor run — a thrown tier degrades to an UNKNOWN result instead.
|
|
111
112
|
results.push(...safeTier("hooks.codex", () => checkCodexWiring(context)));
|
|
112
113
|
results.push(...safeTier("hooks.grok", () => checkGrokWiring(context)));
|
|
114
|
+
// Antigravity: rule + MCP wiring and a hooks-pending advisory (NA when not detected).
|
|
115
|
+
results.push(...safeTier("antigravity", () => checkAntigravityWiring(context)));
|
|
113
116
|
// The runtime probe (US-006) is the live tier: it reads the policy-trigger
|
|
114
117
|
// ledger to report whether hooks actually FIRED on the detected host, catching
|
|
115
118
|
// an app/SDK runtime that loads hook config correctly and then never dispatches
|