@indigoai-us/hq-cli 5.345.263 → 5.345.264
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +55 -0
- package/contracts/host-canary-release.json +7 -7
- package/dist/command-catalog.generated.d.ts +37 -0
- package/dist/command-catalog.generated.js +46 -0
- 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 +4 -3
- package/dist/commands/sync-held.d.ts +11 -0
- package/dist/commands/sync-held.js +65 -1
- package/dist/commands/sync-telemetry-report.d.ts +5 -0
- package/dist/commands/sync-telemetry-report.js +239 -0
- package/dist/commands/sync-telemetry.d.ts +47 -0
- package/dist/commands/sync-telemetry.js +309 -0
- package/dist/index.js +107 -43
- package/dist/lib/bot/runnable.d.ts +17 -7
- package/dist/lib/bot/runnable.js +17 -10
- package/dist/lib/capacity/available.js +6 -2
- package/dist/lib/capacity/collectors/claude-oauth.d.ts +10 -256
- package/dist/lib/capacity/collectors/claude-oauth.js +19 -1078
- package/dist/lib/capacity/ledger.d.ts +12 -1
- package/dist/lib/capacity/ledger.js +15 -5
- package/dist/lib/capacity/route.d.ts +2 -0
- package/dist/lib/capacity/route.js +21 -4
- package/dist/lib/capacity/scheduler.js +2 -3
- package/dist/lib/capacity/sign-in.js +4 -4
- package/dist/lib/daemon/ops/skill-command.d.ts +2 -0
- package/dist/lib/daemon/ops/skill-command.js +7 -1
- package/dist/lib/doctor/checks/antigravity-wiring.d.ts +2 -1
- package/dist/lib/doctor/checks/antigravity-wiring.js +59 -3
- package/dist/lib/doctor/checks/hook-engine.d.ts +2 -0
- package/dist/lib/doctor/checks/hook-engine.js +100 -1
- package/dist/lib/doctor/checks/host-core.d.ts +1 -1
- package/dist/lib/doctor/checks/host-core.js +11 -4
- package/dist/lib/hook-engine/coverage.d.ts +19 -10
- package/dist/lib/hook-engine/coverage.js +103 -24
- package/dist/lib/hook-engine/native-precompact-compatibility.json +7 -1
- package/dist/lib/hook-engine/native-stop-compatibility.json +8 -4
- package/dist/lib/hook-engine/reconcile.js +49 -1
- package/dist/lib/install/antigravity-targets.d.ts +22 -0
- package/dist/lib/install/antigravity-targets.js +82 -0
- package/dist/main.js +8 -3
- package/dist/sentry-init.d.ts +7 -1
- package/dist/sentry-init.js +6 -2
- package/dist/sentry.d.ts +7 -0
- package/dist/sentry.js +16 -1
- package/dist/started-version.d.ts +13 -0
- package/dist/started-version.js +34 -0
- package/dist/startup-registration.d.ts +9 -9
- package/dist/startup-registration.js +42 -18
- package/dist/utils/client-health.d.ts +1 -0
- package/dist/utils/client-health.js +54 -11
- package/dist/utils/core-next-kill.d.ts +9 -0
- package/dist/utils/core-next-kill.js +22 -0
- package/dist/utils/host-registration.d.ts +4 -2
- package/dist/utils/host-registration.js +55 -7
- package/dist/utils/install-tree-recovery-markers.d.ts +45 -0
- package/dist/utils/install-tree-recovery-markers.js +70 -0
- package/dist/utils/install-tree-torn.d.ts +102 -5
- package/dist/utils/install-tree-torn.js +199 -2
- package/dist/utils/sentry-fingerprint.js +3 -0
- package/package.json +7 -7
|
@@ -389,8 +389,19 @@ export interface LedgerOptions {
|
|
|
389
389
|
}
|
|
390
390
|
export declare function capacityOptionsFromEnv(env?: NodeJS.ProcessEnv): LedgerOptions;
|
|
391
391
|
export declare function capacityRoot(env?: NodeJS.ProcessEnv, home?: string): string;
|
|
392
|
-
/**
|
|
392
|
+
/**
|
|
393
|
+
* Shown for a credential that exists and is past expiry, for providers whose
|
|
394
|
+
* collector renews the token itself (Grok). Never a login.
|
|
395
|
+
*/
|
|
393
396
|
export declare const EXPIRED_REASON = "expired: hq capacity renews it on the next collect";
|
|
397
|
+
/**
|
|
398
|
+
* Shown for an expired Claude credential. hq capacity never refreshes Claude
|
|
399
|
+
* tokens: they are single use, and a refresh here raced Claude Code's own
|
|
400
|
+
* refresh and signed accounts out. Claude Code renews the token on its next run.
|
|
401
|
+
*/
|
|
402
|
+
export declare const CLAUDE_EXPIRED_REASON = "expired: refreshes the next time Claude Code is used with this account";
|
|
403
|
+
/** The expired text for one provider. */
|
|
404
|
+
export declare function expiredReasonFor(provider: string): string;
|
|
394
405
|
/** The token endpoint rejected the stored refresh token. The human must sign in again. */
|
|
395
406
|
export declare const SIGN_IN_REVOKED_REASON = "signed out: sign-in revoked";
|
|
396
407
|
export declare function isExpiredReason(reason: string | null | undefined): boolean;
|
|
@@ -199,17 +199,27 @@ const SIGNED_OUT_PREFIX = "signed out:";
|
|
|
199
199
|
const EXPIRED_PREFIX = "expired:";
|
|
200
200
|
/** Ledger text written before expired and signed-out were different states. */
|
|
201
201
|
const LEGACY_EXPIRED_REASON = "signed out: token expired";
|
|
202
|
-
/**
|
|
203
|
-
|
|
204
|
-
|
|
202
|
+
/**
|
|
203
|
+
* Shown for a credential that exists and is past expiry, for providers whose
|
|
204
|
+
* collector renews the token itself (Grok). Never a login.
|
|
205
|
+
*/
|
|
205
206
|
export const EXPIRED_REASON = "expired: hq capacity renews it on the next collect";
|
|
207
|
+
/**
|
|
208
|
+
* Shown for an expired Claude credential. hq capacity never refreshes Claude
|
|
209
|
+
* tokens: they are single use, and a refresh here raced Claude Code's own
|
|
210
|
+
* refresh and signed accounts out. Claude Code renews the token on its next run.
|
|
211
|
+
*/
|
|
212
|
+
export const CLAUDE_EXPIRED_REASON = "expired: refreshes the next time Claude Code is used with this account";
|
|
213
|
+
/** The expired text for one provider. */
|
|
214
|
+
export function expiredReasonFor(provider) {
|
|
215
|
+
return provider === "claude" ? CLAUDE_EXPIRED_REASON : EXPIRED_REASON;
|
|
216
|
+
}
|
|
206
217
|
/** The token endpoint rejected the stored refresh token. The human must sign in again. */
|
|
207
218
|
export const SIGN_IN_REVOKED_REASON = "signed out: sign-in revoked";
|
|
208
219
|
export function isExpiredReason(reason) {
|
|
209
220
|
if (!reason)
|
|
210
221
|
return false;
|
|
211
222
|
return reason === LEGACY_EXPIRED_REASON
|
|
212
|
-
|| reason === LEGACY_EXPIRED_REASON_V2
|
|
213
223
|
|| reason === "unavailable: token_expired"
|
|
214
224
|
|| reason.startsWith(EXPIRED_PREFIX);
|
|
215
225
|
}
|
|
@@ -1256,7 +1266,7 @@ function clusterAccounts(provider, events, nowMs) {
|
|
|
1256
1266
|
signedOut: isSignedOut,
|
|
1257
1267
|
authState,
|
|
1258
1268
|
observedAt: Number.isFinite(latestAt) ? new Date(latestAt).toISOString() : null,
|
|
1259
|
-
reason: expired ?
|
|
1269
|
+
reason: expired ? expiredReasonFor(provider.provider) : isSignedOut ? problem?.reason ?? null : null,
|
|
1260
1270
|
fixCommand: expired
|
|
1261
1271
|
? (provider.provider === "claude" ? claudeOpenCommand(home) : null)
|
|
1262
1272
|
: isSignedOut
|
|
@@ -28,6 +28,8 @@ export declare const OLD_READING_PENALTY = 10;
|
|
|
28
28
|
* view stale). Sits below any account with fresh known headroom.
|
|
29
29
|
*/
|
|
30
30
|
export declare const UNKNOWN_USAGE_SCORE = -100;
|
|
31
|
+
/** Why line for an expired Claude account ranked as usage-unknown until Claude Code renews it. */
|
|
32
|
+
export declare const CLAUDE_AWAITING_RENEWAL_WHY = "usage unknown until Claude Code renews the expired sign-in";
|
|
31
33
|
/**
|
|
32
34
|
* Score for an account whose plan limit is used up but which still runs on
|
|
33
35
|
* paid extra usage. Ranked only with --allow-extra-usage, below every account
|
|
@@ -50,6 +50,8 @@ export const OLD_READING_PENALTY = 10;
|
|
|
50
50
|
* view stale). Sits below any account with fresh known headroom.
|
|
51
51
|
*/
|
|
52
52
|
export const UNKNOWN_USAGE_SCORE = -100;
|
|
53
|
+
/** Why line for an expired Claude account ranked as usage-unknown until Claude Code renews it. */
|
|
54
|
+
export const CLAUDE_AWAITING_RENEWAL_WHY = "usage unknown until Claude Code renews the expired sign-in";
|
|
53
55
|
/**
|
|
54
56
|
* Score for an account whose plan limit is used up but which still runs on
|
|
55
57
|
* paid extra usage. Ranked only with --allow-extra-usage, below every account
|
|
@@ -317,9 +319,9 @@ export function pickAccount(input) {
|
|
|
317
319
|
const readingsUnreliable = input.collectorEnabled === false
|
|
318
320
|
|| input.collectorEnabled === null
|
|
319
321
|
|| input.capacityStale === true;
|
|
320
|
-
const rankUnknown = (base, accountId, tokenExpired) => {
|
|
322
|
+
const rankUnknown = (base, accountId, tokenExpired, unknownWhy = "usage unknown, capacity readings are stale or the collector is off") => {
|
|
321
323
|
const live = liveLaneCount(lanes, base.provider, accountId);
|
|
322
|
-
const whyParts = [
|
|
324
|
+
const whyParts = [unknownWhy];
|
|
323
325
|
if (live)
|
|
324
326
|
whyParts.push(`${live} live lane${live === 1 ? "" : "s"} already on it`);
|
|
325
327
|
if (tokenExpired)
|
|
@@ -440,10 +442,16 @@ export function pickAccount(input) {
|
|
|
440
442
|
});
|
|
441
443
|
continue;
|
|
442
444
|
}
|
|
445
|
+
// hq capacity never renews a Claude sign-in; only a Claude Code run on
|
|
446
|
+
// the account does. An expired Claude account that is skipped for lack
|
|
447
|
+
// of a fresh reading would never run, never renew, and never be picked,
|
|
448
|
+
// so it is ranked as usage-unknown instead (below every account with
|
|
449
|
+
// known room) unless its last reading shows a limit used up.
|
|
450
|
+
const awaitsClaudeRenewal = providerId === "claude" && tokenExpired;
|
|
443
451
|
// The ledger sets usageStale when the sign-in expired and no reading has
|
|
444
452
|
// landed since the expiry. The limits on file describe the old token, so
|
|
445
453
|
// the account cannot be ranked on them.
|
|
446
|
-
if (account.usageStale === true) {
|
|
454
|
+
if (account.usageStale === true && !awaitsClaudeRenewal) {
|
|
447
455
|
skipped.push({
|
|
448
456
|
...base,
|
|
449
457
|
reason: "no fresh reading (sign-in expired)",
|
|
@@ -477,8 +485,17 @@ export function pickAccount(input) {
|
|
|
477
485
|
.filter((ms) => Number.isFinite(ms));
|
|
478
486
|
const newestReadingMs = readingTimes.length > 0 ? Math.max(...readingTimes) : -Infinity;
|
|
479
487
|
const accountObservedMs = account.observedAt ? Date.parse(account.observedAt) : NaN;
|
|
480
|
-
const noFreshReading =
|
|
488
|
+
const noFreshReading = account.usageStale === true
|
|
489
|
+
|| !Number.isFinite(newestReadingMs)
|
|
481
490
|
|| (Number.isFinite(accountObservedMs) && newestReadingMs < accountObservedMs);
|
|
491
|
+
if (noFreshReading && awaitsClaudeRenewal) {
|
|
492
|
+
const usedUpAtLastReading = viewRows.some((row) => !row.resetPassed
|
|
493
|
+
&& (row.limit.state === "exhausted" || (typeof row.used === "number" && row.used >= 100)));
|
|
494
|
+
if (!usedUpAtLastReading) {
|
|
495
|
+
rankUnknown(base, laneMatch.id, true, CLAUDE_AWAITING_RENEWAL_WHY);
|
|
496
|
+
continue;
|
|
497
|
+
}
|
|
498
|
+
}
|
|
482
499
|
if (noFreshReading) {
|
|
483
500
|
skipped.push({
|
|
484
501
|
...base,
|
|
@@ -26,9 +26,8 @@ export const RUN_TIMEOUT_MS = {
|
|
|
26
26
|
"codex-tail": 15_000,
|
|
27
27
|
"codex-app-server": 30_000,
|
|
28
28
|
"claude-statusline": 10_000,
|
|
29
|
-
//
|
|
30
|
-
//
|
|
31
|
-
// single-use refresh token and get the account marked revoked.
|
|
29
|
+
// Covers a Keychain read and a usage GET per Claude home. The collector no
|
|
30
|
+
// longer refreshes tokens, so a slow run cannot spend a refresh token twice.
|
|
32
31
|
"claude-oauth": 180_000,
|
|
33
32
|
grok: 30_000,
|
|
34
33
|
rebuild: 10_000,
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
import * as fs from "node:fs";
|
|
10
10
|
import * as path from "node:path";
|
|
11
11
|
import { defaultProviderHome } from "./accounts.js";
|
|
12
|
-
import {
|
|
12
|
+
import { expiredReasonFor, capacityLoginCommand, claudeOpenCommand, defaultHomeLoginCommand, isExpiredReason, } from "./ledger.js";
|
|
13
13
|
import { effectiveAccountHome } from "../lanes/account-home.js";
|
|
14
14
|
import { canonicalizeHome, loadLanesConfig, writeLanesConfig } from "../lanes/config.js";
|
|
15
15
|
import { LANE_PROVIDERS, parseLaneProvider } from "../lanes/types.js";
|
|
@@ -94,7 +94,7 @@ export function presentAccount(account, provider, userHome) {
|
|
|
94
94
|
const home = account.homes?.[0] ?? null;
|
|
95
95
|
return {
|
|
96
96
|
state: "expired",
|
|
97
|
-
reason:
|
|
97
|
+
reason: expiredReasonFor(provider),
|
|
98
98
|
command: provider === "claude"
|
|
99
99
|
? claudeOpenCommand(home ?? (label === "default" ? null : home), userHome)
|
|
100
100
|
: account.fixCommand ?? null,
|
|
@@ -250,7 +250,7 @@ function formatRepairPlan(plan) {
|
|
|
250
250
|
lines.push("", "Expired (open the account; login is not repeated):");
|
|
251
251
|
for (const row of plan.expired) {
|
|
252
252
|
lines.push(`${row.provider} ${row.label}`);
|
|
253
|
-
lines.push(row.reason ??
|
|
253
|
+
lines.push(row.reason ?? expiredReasonFor(row.provider));
|
|
254
254
|
if (row.command)
|
|
255
255
|
lines.push(formatRefreshLine(row.provider, row.command));
|
|
256
256
|
}
|
|
@@ -392,7 +392,7 @@ async function runRepair(request, deps) {
|
|
|
392
392
|
skipped.push({
|
|
393
393
|
provider: row.provider,
|
|
394
394
|
label: row.label,
|
|
395
|
-
reason: row.reason ??
|
|
395
|
+
reason: row.reason ?? expiredReasonFor(row.provider),
|
|
396
396
|
fix: row.command ? formatRefreshLine(row.provider, row.command) : null,
|
|
397
397
|
});
|
|
398
398
|
}
|
|
@@ -35,6 +35,8 @@ export declare const SKILL_COMMAND_LIB = "core/scripts/hook-lib.sh";
|
|
|
35
35
|
export declare const SKILL_COMMAND_HOOK_SHA256 = "e6ddbaf1fe8f996fa0ade56cc89c3634782db49ab90becff3380bcb0ef6c5c3c";
|
|
36
36
|
/** sha256 of the pinned `hook-lib.sh` (same value as `skill_command_script::LIB_SHA256`). */
|
|
37
37
|
export declare const SKILL_COMMAND_LIB_SHA256 = "9133295e5ce523bf8355a093bbea5a1c19682ec42b59ab6b626dffbc33544f3f";
|
|
38
|
+
/** All accepted `hook-lib.sh` revisions (same values as `skill_command_script::ACCEPTED_LIB_SHA256`). */
|
|
39
|
+
export declare const SKILL_COMMAND_LIB_ACCEPTED: readonly string[];
|
|
38
40
|
/**
|
|
39
41
|
* The libraries the hook sources only when they are present (ANSWERS-1817
|
|
40
42
|
* Q-SCS8 (b)): absent is the released behaviour; present, they must be the
|
|
@@ -39,6 +39,11 @@ export const SKILL_COMMAND_LIB = "core/scripts/hook-lib.sh";
|
|
|
39
39
|
export const SKILL_COMMAND_HOOK_SHA256 = "e6ddbaf1fe8f996fa0ade56cc89c3634782db49ab90becff3380bcb0ef6c5c3c";
|
|
40
40
|
/** sha256 of the pinned `hook-lib.sh` (same value as `skill_command_script::LIB_SHA256`). */
|
|
41
41
|
export const SKILL_COMMAND_LIB_SHA256 = "9133295e5ce523bf8355a093bbea5a1c19682ec42b59ab6b626dffbc33544f3f";
|
|
42
|
+
/** All accepted `hook-lib.sh` revisions (same values as `skill_command_script::ACCEPTED_LIB_SHA256`). */
|
|
43
|
+
export const SKILL_COMMAND_LIB_ACCEPTED = [
|
|
44
|
+
SKILL_COMMAND_LIB_SHA256,
|
|
45
|
+
"436493e3325fb0cbcad651ae8ef42d89f4adf43fe38abd938ed6a39c0b6d17c1",
|
|
46
|
+
];
|
|
42
47
|
/**
|
|
43
48
|
* The libraries the hook sources only when they are present (ANSWERS-1817
|
|
44
49
|
* Q-SCS8 (b)): absent is the released behaviour; present, they must be the
|
|
@@ -196,7 +201,8 @@ export function runSkillCommand(req, deps) {
|
|
|
196
201
|
return Promise.reject(new SkillCommandOpError("root_mismatch", "skill.command runs only in hqd's own HQ root"));
|
|
197
202
|
}
|
|
198
203
|
const hook = path.join(root, SKILL_COMMAND_HOOK);
|
|
199
|
-
|
|
204
|
+
const libHash = sha256File(path.join(root, SKILL_COMMAND_LIB));
|
|
205
|
+
if (sha256File(hook) !== SKILL_COMMAND_HOOK_SHA256 || !libHash || !SKILL_COMMAND_LIB_ACCEPTED.includes(libHash)) {
|
|
200
206
|
return Promise.reject(new SkillCommandOpError("hook_not_pinned", `${SKILL_COMMAND_HOOK} or ${SKILL_COMMAND_LIB} is not the pinned release (hq-core-staging v16.0.48-beta.124)`));
|
|
201
207
|
}
|
|
202
208
|
for (const lib of SKILL_COMMAND_OPTIONAL_LIBS) {
|
|
@@ -12,10 +12,11 @@
|
|
|
12
12
|
*/
|
|
13
13
|
import type { CheckContext, CheckResult } from "../types.js";
|
|
14
14
|
export declare const ANTIGRAVITY_INSTALL_REMEDIATION = "hq install --global --runtime antigravity";
|
|
15
|
+
export declare const ANTIGRAVITY_HOOKS_REMEDIATION = "hq reindex";
|
|
15
16
|
export interface AntigravityWiringOptions {
|
|
16
17
|
home?: string;
|
|
17
18
|
env?: NodeJS.ProcessEnv;
|
|
18
19
|
appPath?: string;
|
|
19
20
|
}
|
|
20
|
-
export declare function checkAntigravityWiring(
|
|
21
|
+
export declare function checkAntigravityWiring(context: CheckContext, options?: AntigravityWiringOptions): CheckResult[];
|
|
21
22
|
//# sourceMappingURL=antigravity-wiring.d.ts.map
|
|
@@ -12,10 +12,12 @@
|
|
|
12
12
|
*/
|
|
13
13
|
import * as fs from "node:fs";
|
|
14
14
|
import * as os from "node:os";
|
|
15
|
-
import {
|
|
15
|
+
import { ANTIGRAVITY_HOOK_EVENTS, antigravityEventEntries, antigravityTargets, detectAntigravity, isHqAntigravityRule, } from "../../install/antigravity-targets.js";
|
|
16
|
+
import { CORE_NEXT_LINK, isCoreNextEntry } from "../../hook-engine/registration-identity.js";
|
|
16
17
|
import { HQ_MCP_SERVER_NAME } from "../../install/claude-targets.js";
|
|
17
18
|
export const ANTIGRAVITY_INSTALL_REMEDIATION = "hq install --global --runtime antigravity";
|
|
18
|
-
export
|
|
19
|
+
export const ANTIGRAVITY_HOOKS_REMEDIATION = "hq reindex";
|
|
20
|
+
export function checkAntigravityWiring(context, options = {}) {
|
|
19
21
|
const home = options.home ?? os.homedir();
|
|
20
22
|
const detection = detectAntigravity({ home, env: options.env, appPath: options.appPath });
|
|
21
23
|
if (!detection.detected) {
|
|
@@ -30,7 +32,7 @@ export function checkAntigravityWiring(_context, options = {}) {
|
|
|
30
32
|
return [
|
|
31
33
|
checkRule(t.ruleFile),
|
|
32
34
|
checkMcp(t.mcpConfig),
|
|
33
|
-
|
|
35
|
+
checkHooks(t.hooksFile, context.hqRoot),
|
|
34
36
|
];
|
|
35
37
|
}
|
|
36
38
|
function readOrNull(file) {
|
|
@@ -72,4 +74,58 @@ function checkMcp(mcpConfig) {
|
|
|
72
74
|
}
|
|
73
75
|
return { status: "PASS", checkId: "antigravity.mcp", target: mcpConfig, message: `Antigravity MCP server "${HQ_MCP_SERVER_NAME}" is registered.` };
|
|
74
76
|
}
|
|
77
|
+
function checkHooks(hooksFile, hqRoot) {
|
|
78
|
+
const raw = readOrNull(hooksFile);
|
|
79
|
+
if (raw === null) {
|
|
80
|
+
return {
|
|
81
|
+
status: "WARN",
|
|
82
|
+
checkId: "antigravity.hooks",
|
|
83
|
+
target: hooksFile,
|
|
84
|
+
message: "Antigravity hooks.json is missing; HQ hooks are not registered for Antigravity.",
|
|
85
|
+
remediation: ANTIGRAVITY_HOOKS_REMEDIATION,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
let doc;
|
|
89
|
+
try {
|
|
90
|
+
doc = JSON.parse(raw);
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
return {
|
|
94
|
+
status: "FAIL",
|
|
95
|
+
checkId: "antigravity.hooks",
|
|
96
|
+
target: hooksFile,
|
|
97
|
+
message: "Antigravity hooks.json is not valid JSON; Antigravity cannot load hooks from it.",
|
|
98
|
+
remediation: `Fix the JSON, then run ${ANTIGRAVITY_HOOKS_REMEDIATION}`,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
const byEvent = new Map(antigravityEventEntries(doc));
|
|
102
|
+
const isHqNative = (entry) => isCoreNextEntry(entry, hqRoot)
|
|
103
|
+
|| (typeof entry.command === "string" && CORE_NEXT_LINK.test(entry.command));
|
|
104
|
+
const present = ANTIGRAVITY_HOOK_EVENTS.filter((event) => (byEvent.get(event) ?? []).some(isHqNative));
|
|
105
|
+
if (present.length === 0) {
|
|
106
|
+
return {
|
|
107
|
+
status: "WARN",
|
|
108
|
+
checkId: "antigravity.hooks",
|
|
109
|
+
target: hooksFile,
|
|
110
|
+
message: "Antigravity hooks.json has no HQ native hook registrations.",
|
|
111
|
+
remediation: ANTIGRAVITY_HOOKS_REMEDIATION,
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
const missing = ANTIGRAVITY_HOOK_EVENTS.filter((event) => !present.includes(event));
|
|
115
|
+
if (missing.length > 0) {
|
|
116
|
+
return {
|
|
117
|
+
status: "WARN",
|
|
118
|
+
checkId: "antigravity.hooks",
|
|
119
|
+
target: hooksFile,
|
|
120
|
+
message: `Antigravity hooks.json is missing HQ hook registrations for ${missing.join(", ")}.`,
|
|
121
|
+
remediation: ANTIGRAVITY_HOOKS_REMEDIATION,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
return {
|
|
125
|
+
status: "PASS",
|
|
126
|
+
checkId: "antigravity.hooks",
|
|
127
|
+
target: hooksFile,
|
|
128
|
+
message: `Antigravity hooks are registered through the native hook engine (${ANTIGRAVITY_HOOK_EVENTS.join(", ")}).`,
|
|
129
|
+
};
|
|
130
|
+
}
|
|
75
131
|
//# sourceMappingURL=antigravity-wiring.js.map
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { CheckFamily, CheckResult } from '../types.js';
|
|
2
|
+
export declare const STRICT_PORT_FLAG_MAX_AGE_SECONDS: number;
|
|
3
|
+
export declare function checkStrictFlagSnapshot(env?: NodeJS.ProcessEnv, nowMs?: number): CheckResult | null;
|
|
2
4
|
export declare function checkHookEngine(): CheckResult;
|
|
3
5
|
export declare const hookEngineFamily: CheckFamily;
|
|
4
6
|
//# sourceMappingURL=hook-engine.d.ts.map
|
|
@@ -1,5 +1,97 @@
|
|
|
1
|
+
import { lstatSync, readFileSync } from 'node:fs';
|
|
2
|
+
import { homedir } from 'node:os';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { flagSnapshotPath, parseSnapshotTime, personFlagSnapshotPath } from '../../flag-snapshot-file.js';
|
|
1
5
|
import { launcherEnabled } from '../../hook-engine/registration.js';
|
|
2
6
|
import { findHookEngine, hookEngineRequired, pinnedHookEngineMatches, HOOK_ENGINE_REPAIR, HOOK_ENGINE_REPAIR_PIN } from '../../hook-engine/resolve.js';
|
|
7
|
+
export const STRICT_PORT_FLAG_MAX_AGE_SECONDS = 15 * 60;
|
|
8
|
+
function pathPresent(filePath) {
|
|
9
|
+
try {
|
|
10
|
+
lstatSync(filePath);
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function isStrictModeActive(env) {
|
|
18
|
+
const engineEnv = env.HQ_HOOK_ENGINE?.trim().toLowerCase();
|
|
19
|
+
const home = env.HOME || env.USERPROFILE || homedir();
|
|
20
|
+
if (engineEnv === 'off' || pathPresent(join(home, '.hq', 'hook-engine.off')))
|
|
21
|
+
return false;
|
|
22
|
+
if (engineEnv === 'strict')
|
|
23
|
+
return true;
|
|
24
|
+
return pathPresent(join(home, '.hq', 'hook-engine.strict'));
|
|
25
|
+
}
|
|
26
|
+
export function checkStrictFlagSnapshot(env = process.env, nowMs = Date.now()) {
|
|
27
|
+
if (!isStrictModeActive(env))
|
|
28
|
+
return null;
|
|
29
|
+
const companyUid = env.HQ_COMPANY_UID?.trim();
|
|
30
|
+
let snapshotPath;
|
|
31
|
+
if (companyUid) {
|
|
32
|
+
const resolved = flagSnapshotPath(companyUid, env);
|
|
33
|
+
if (!resolved) {
|
|
34
|
+
return {
|
|
35
|
+
checkId: 'hooks.strict-flag-snapshot',
|
|
36
|
+
status: 'WARN',
|
|
37
|
+
message: 'Strict mode is active, but HQ_COMPANY_UID is invalid; hq-hook cannot resolve a company flag snapshot.',
|
|
38
|
+
remediation: 'Check HQ_COMPANY_UID and refresh flags (hq daemon status / hq daemon restart).',
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
snapshotPath = resolved;
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
snapshotPath = personFlagSnapshotPath(env);
|
|
45
|
+
}
|
|
46
|
+
try {
|
|
47
|
+
const raw = JSON.parse(readFileSync(snapshotPath, 'utf8'));
|
|
48
|
+
const fetchedMs = typeof raw.fetched_at === 'string' ? parseSnapshotTime(raw.fetched_at) : Number.NaN;
|
|
49
|
+
if (!Number.isFinite(fetchedMs)) {
|
|
50
|
+
return {
|
|
51
|
+
checkId: 'hooks.strict-flag-snapshot',
|
|
52
|
+
status: 'WARN',
|
|
53
|
+
target: snapshotPath,
|
|
54
|
+
message: 'Strict mode is active, but the flag snapshot timestamp is unreadable.',
|
|
55
|
+
remediation: 'Check hq daemon status and refresh flags (hq daemon status / hq daemon restart).',
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
if (fetchedMs > nowMs) {
|
|
59
|
+
const aheadSeconds = Math.ceil((fetchedMs - nowMs) / 1000);
|
|
60
|
+
return {
|
|
61
|
+
checkId: 'hooks.strict-flag-snapshot',
|
|
62
|
+
status: 'WARN',
|
|
63
|
+
target: snapshotPath,
|
|
64
|
+
message: `Strict mode flag snapshot has a future timestamp (${aheadSeconds}s ahead); hq-hook rejects future snapshots and drops port flags.`,
|
|
65
|
+
remediation: 'Check system clock and refresh flags (hq daemon status / hq daemon restart).',
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
const ageSeconds = Math.floor((nowMs - fetchedMs) / 1000);
|
|
69
|
+
if (ageSeconds > STRICT_PORT_FLAG_MAX_AGE_SECONDS) {
|
|
70
|
+
return {
|
|
71
|
+
checkId: 'hooks.strict-flag-snapshot',
|
|
72
|
+
status: 'WARN',
|
|
73
|
+
target: snapshotPath,
|
|
74
|
+
message: `Strict mode flag snapshot is stale (${ageSeconds}s old > ${STRICT_PORT_FLAG_MAX_AGE_SECONDS}s limit); hq-hook is holding last-known port flags instead of falling back to bash.`,
|
|
75
|
+
remediation: 'Check hq daemon status and refresh flags (hq daemon status / hq daemon restart).',
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
return {
|
|
79
|
+
checkId: 'hooks.strict-flag-snapshot',
|
|
80
|
+
status: 'PASS',
|
|
81
|
+
target: snapshotPath,
|
|
82
|
+
message: `Strict mode flag snapshot is fresh (${ageSeconds}s old).`,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
catch {
|
|
86
|
+
return {
|
|
87
|
+
checkId: 'hooks.strict-flag-snapshot',
|
|
88
|
+
status: 'WARN',
|
|
89
|
+
target: snapshotPath,
|
|
90
|
+
message: 'Strict mode is active, but no readable flag snapshot was found.',
|
|
91
|
+
remediation: 'Check hq daemon status and refresh flags (hq daemon status / hq daemon restart).',
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
}
|
|
3
95
|
export function checkHookEngine() {
|
|
4
96
|
const required = hookEngineRequired();
|
|
5
97
|
const fallback = required ? 'Native engine is required; repair before running hooks.' : 'Existing bash hooks remain active.';
|
|
@@ -13,5 +105,12 @@ export function checkHookEngine() {
|
|
|
13
105
|
return { checkId: 'hooks.native-engine', status: required ? 'FAIL' : 'WARN', message: `Native hook engine unavailable: ${error.message}. ${fallback}`, remediation: HOOK_ENGINE_REPAIR };
|
|
14
106
|
}
|
|
15
107
|
}
|
|
16
|
-
export const hookEngineFamily = {
|
|
108
|
+
export const hookEngineFamily = {
|
|
109
|
+
id: 'hook-engine',
|
|
110
|
+
title: 'Native hook engine',
|
|
111
|
+
run: async () => {
|
|
112
|
+
const strictCheck = checkStrictFlagSnapshot();
|
|
113
|
+
return strictCheck ? [checkHookEngine(), strictCheck] : [checkHookEngine()];
|
|
114
|
+
},
|
|
115
|
+
};
|
|
17
116
|
//# sourceMappingURL=hook-engine.js.map
|
|
@@ -5,7 +5,7 @@ export declare const HOST_CORE_FAMILY_ID = "host-core";
|
|
|
5
5
|
export declare const HOST_CORE_FAMILY_TITLE = "Hook core per host";
|
|
6
6
|
export type CoreKind = 'new-core' | 'launcher' | 'old-dispatcher';
|
|
7
7
|
export interface HostRegistrationFile {
|
|
8
|
-
host: 'claude' | 'codex' | 'grok';
|
|
8
|
+
host: 'claude' | 'codex' | 'grok' | 'antigravity';
|
|
9
9
|
scope: 'project' | 'user';
|
|
10
10
|
file: string;
|
|
11
11
|
/** A file the host merges over `file` (Claude Code's `.claude/settings.local.json`), read with it. */
|
|
@@ -13,6 +13,7 @@ import * as path from 'node:path';
|
|
|
13
13
|
import { jsonFormat } from '../../../commands/mcp-registration.js';
|
|
14
14
|
import { CORE_NEXT_LINK, isCoreNextEntry, isNativeEntry } from '../../hook-engine/registration.js';
|
|
15
15
|
import { isAdapterEntry } from '../../install/codex-targets.js';
|
|
16
|
+
import { antigravityEventEntries, antigravityTargets } from '../../install/antigravity-targets.js';
|
|
16
17
|
import { claudeProjectAdapterHold, uncoveredHooks } from '../../hook-engine/coverage.js';
|
|
17
18
|
import { masterHookPath, shimPath } from '../../install/claude-targets.js';
|
|
18
19
|
import { CORE_NEXT_FLAG, CORE_NEXT_KILL_ENV, CORE_NEXT_KILL_FILE, ENGINE_KILL_ENV, ENGINE_KILL_FILE, REQUIRED_EVALUATORS, STABLE_LINK_NAME, coreNextEnabled, coreNextKillReason, coreNextTargetFor, missingEvaluators, probeEngine, } from '../../../utils/host-registration.js';
|
|
@@ -28,6 +29,7 @@ export function hostRegistrationFiles(root, home, env) {
|
|
|
28
29
|
{ host: 'codex', scope: 'project', file: path.join(root, '.codex', 'hooks.json') },
|
|
29
30
|
{ host: 'codex', scope: 'user', file: path.join(env.CODEX_HOME || path.join(home, '.codex'), 'hooks.json') },
|
|
30
31
|
{ host: 'grok', scope: 'user', file: path.join(home, '.grok', 'hooks', 'hq-hq-bridge.json') },
|
|
32
|
+
{ host: 'antigravity', scope: 'user', file: antigravityTargets(home).hooksFile },
|
|
31
33
|
];
|
|
32
34
|
}
|
|
33
35
|
function hookEntries(doc) {
|
|
@@ -50,6 +52,8 @@ export function classifyEntry(entry, host, root) {
|
|
|
50
52
|
// A stable-path entry for another HQ root still calls the new core.
|
|
51
53
|
if (CORE_NEXT_LINK.test(command))
|
|
52
54
|
return 'new-core';
|
|
55
|
+
if (host === 'antigravity')
|
|
56
|
+
return null;
|
|
53
57
|
if (host === 'grok')
|
|
54
58
|
return command.includes('hq-hq-bridge.sh') ? 'old-dispatcher' : null;
|
|
55
59
|
if (host === 'codex') {
|
|
@@ -63,6 +67,7 @@ const OLD_DISPATCHER = {
|
|
|
63
67
|
claude: 'old dispatcher (master-hook.sh)',
|
|
64
68
|
codex: 'old dispatcher (Codex hook adapter)',
|
|
65
69
|
grok: 'old dispatcher (Grok bash bridge)',
|
|
70
|
+
antigravity: 'none (native engine only)',
|
|
66
71
|
};
|
|
67
72
|
function label(kind, host) {
|
|
68
73
|
if (kind === 'new-core')
|
|
@@ -139,7 +144,7 @@ export function hostCoreResults(root, options = {}) {
|
|
|
139
144
|
return { status: 'PASS', reason: `the new core has ${REQUIRED_EVALUATORS[event].join(', ')}` };
|
|
140
145
|
};
|
|
141
146
|
/** Old-dispatcher hooks for `event` on `host` that the engine's report does not cover. */
|
|
142
|
-
const uncovered = (caps, host, event) => uncoveredHooks(root, host, event, caps.covers, env);
|
|
147
|
+
const uncovered = (caps, host, event) => host === 'antigravity' ? [] : uncoveredHooks(root, host, event, caps.covers, env);
|
|
143
148
|
const listed = (hooks) => (hooks.length > 6 ? `${hooks.slice(0, 6).join(', ')} and ${hooks.length - 6} more` : hooks.join(', '));
|
|
144
149
|
/**
|
|
145
150
|
* Why an event of `<root>/.claude/settings.json` stays on master-hook.sh for
|
|
@@ -217,8 +222,8 @@ export function hostCoreResults(root, options = {}) {
|
|
|
217
222
|
}
|
|
218
223
|
}
|
|
219
224
|
}
|
|
220
|
-
const merged = new Map(eventEntries(doc));
|
|
221
|
-
for (const [event, entries] of eventEntries(overlay))
|
|
225
|
+
const merged = new Map(eventEntries(doc, target.host));
|
|
226
|
+
for (const [event, entries] of eventEntries(overlay, target.host))
|
|
222
227
|
merged.set(event, [...(merged.get(event) ?? []), ...entries]);
|
|
223
228
|
const events = [];
|
|
224
229
|
const mixed = [];
|
|
@@ -298,7 +303,9 @@ export function hostCoreResults(root, options = {}) {
|
|
|
298
303
|
return results;
|
|
299
304
|
}
|
|
300
305
|
/** HQ-relevant entries per event, in file order. */
|
|
301
|
-
function eventEntries(doc) {
|
|
306
|
+
function eventEntries(doc, host) {
|
|
307
|
+
if (host === 'antigravity')
|
|
308
|
+
return antigravityEventEntries(doc);
|
|
302
309
|
const hooks = doc?.hooks;
|
|
303
310
|
if (!hooks || typeof hooks !== 'object' || Array.isArray(hooks))
|
|
304
311
|
return [];
|
|
@@ -184,7 +184,8 @@ export declare const MERGED_WRITE_GUARD_PINS_1649: ReadonlyArray<readonly [strin
|
|
|
184
184
|
export declare function fleetLocalMergedWriteGuardHold(root: string): string | null;
|
|
185
185
|
/**
|
|
186
186
|
* The script revisions the native SessionStart master rebuilds (hq-core v16.0.48 through v16.0.50,
|
|
187
|
-
*
|
|
187
|
+
* the hq-core-staging fd709b39a shim and hq-session.sh, and the hq-core v16.0.53 shim d1d7e7d0
|
|
188
|
+
* from hq-core-staging #2024, whose flag-off error answer `hqd_open.rs` ends quietly as the shim does):
|
|
188
189
|
* `hqd_open.rs` (the daemon shim and its flag-cache library), `session_set/mod.rs` `SCRIPTS`,
|
|
189
190
|
* `ID_LIBS` and `CAPABILITY_LIBS` (hq-session.sh and the two libraries it sources) and
|
|
190
191
|
* `foreign_bind.rs` `RESOLVE_REVISIONS` (resolve-company.sh). The native port
|
|
@@ -220,9 +221,12 @@ export declare function migratePolicyTriggersHold(root: string): string | null;
|
|
|
220
221
|
* and `host::fleet::inherit_scope::RELEASED_LIB_SHA256` (`session-scope-capability.sh`).
|
|
221
222
|
* `FleetLocalPre` matches the shell adapter when either file is absent (`DISPATCHER_UNAVAILABLE`
|
|
222
223
|
* / skip scope inheritance), and refuses any other revision present on disk.
|
|
223
|
-
* `RELEASED_CORE_SHA256`
|
|
224
|
-
*
|
|
225
|
-
*
|
|
224
|
+
* `RELEASED_CORE_SHA256` and this list accept the bd733f7b core (940bb5a0, hq-core v16.0.48 to
|
|
225
|
+
* v16.0.50) and the two classifying cores: hq-core-staging 810d0faa (#2119, 09f5a3e0, v16.0.51)
|
|
226
|
+
* and 7222e9bb (#2129, cf1abd5c, v16.0.52, a comment change). The fleet-local parity tests run
|
|
227
|
+
* against bd733f7b (tests/fleet_local_pre_tool_use_parity.rs) and against cf1abd5c, with the
|
|
228
|
+
* engine's own settings entry it classifies as a master record
|
|
229
|
+
* (tests/fleet_local_pretool_master_parity.rs).
|
|
226
230
|
*/
|
|
227
231
|
export declare const FLEET_LOCAL_PRE_TOOL_USE_PINS: readonly PinnedFile[];
|
|
228
232
|
/**
|
|
@@ -314,7 +318,8 @@ export declare function grokPreToolUseHold(root: string, shadow: boolean): strin
|
|
|
314
318
|
* crates/hq-hook/src/pre_tool_use_master.rs `DISPATCHER_PINS`. master-hook.sh is v16.0.48 (1a2439ae),
|
|
315
319
|
* v16.0.50 (774bca73), v16.0.49 (d5049d5f), v16.0.51 (443272ef) or v16.0.52 (ab46ebdf, and hq-core-staging #2152's f9a32c25, which only scopes the folder hook limit by event; v16.0.51 plus a PostToolUse-only
|
|
316
320
|
* prefilter text for MCP tools), whose session-id alias record the native bind writes too; hook-adapter-core.sh is held per host below; hqd-hook-shim.sh is the released ab289ac0 or the
|
|
317
|
-
* hq-core-staging fd709b39a ee5e9fe7
|
|
321
|
+
* hq-core-staging fd709b39a ee5e9fe7 or the hq-core v16.0.53 d1d7e7d0 (hq-core-staging #2024, whose new
|
|
322
|
+
* branches run only on an error answer from hqd, which the model never asks), and session-id.sh the released 2ebbc508 or the fd709b39a
|
|
318
323
|
* d6a04155; every other file is one revision.
|
|
319
324
|
*/
|
|
320
325
|
export declare const PRE_TOOL_USE_DISPATCHER_PINS: readonly PinnedFile[];
|
|
@@ -326,8 +331,13 @@ export declare const PRE_TOOL_USE_DISPATCHER_PINS: readonly PinnedFile[];
|
|
|
326
331
|
*/
|
|
327
332
|
export declare const PRE_TOOL_USE_CLAUDE_DISPATCHER_PINS: readonly PinnedFile[];
|
|
328
333
|
export declare const PRE_TOOL_USE_CODEX_DISPATCHER_PINS: readonly PinnedFile[];
|
|
334
|
+
export declare const PRE_TOOL_USE_GROK_DISPATCHER_PINS: readonly PinnedFile[];
|
|
335
|
+
export declare const PRE_TOOL_USE_AGENTS_V2_DISPATCHER_PINS: readonly PinnedFile[];
|
|
336
|
+
export declare const PRE_TOOL_USE_FLEET_LOCAL_DISPATCHER_PINS: readonly PinnedFile[];
|
|
329
337
|
/** The Codex adapter the model reproduces on Codex only (pre_tool_use_master.rs `CODEX_ADAPTER_PIN`). */
|
|
330
338
|
export declare const PRE_TOOL_USE_CODEX_ADAPTER_PIN: PinnedFile;
|
|
339
|
+
/** The Grok adapter the model reproduces on Grok only (pre_tool_use_master.rs `GROK_ADAPTER_PIN`). */
|
|
340
|
+
export declare const PRE_TOOL_USE_GROK_ADAPTER_PIN: PinnedFile;
|
|
331
341
|
/**
|
|
332
342
|
* The claimed vault-write guard's script and the companions it reads (crates/hq-hook/src/ports.rs
|
|
333
343
|
* `HOOK_SCRIPT_SHA256` and `HOOK_COMPANION_SHA256` for enforce-vault-write-access). Its arithmetic
|
|
@@ -339,10 +349,9 @@ export declare const PRE_TOOL_USE_VAULT_GUARD_PINS: readonly PinnedFile[];
|
|
|
339
349
|
* Claimed PreToolUse hooks whose native member answers in place of the root's script with no port
|
|
340
350
|
* pin of its own, with the script revisions the member answers for: pre_tool_use_master.rs
|
|
341
351
|
* `CLAIMED_SCRIPT_PINS`, where the native PreToolUse refuses any other present revision. The scope
|
|
342
|
-
* authorizer: hq-core v16.0.45 to v16.0.52
|
|
343
|
-
* 16.0.53-beta.1 (36312275
|
|
344
|
-
*
|
|
345
|
-
* registered safety guard that is missing, as master-hook did.
|
|
352
|
+
* authorizer: hq-core v16.0.45 to v16.0.52, the prereleases core-pins.json lists, and hq-core
|
|
353
|
+
* 16.0.53-beta.1 (36312275, PowerShell check ported in #3993). A missing script is not held: the
|
|
354
|
+
* native PreToolUse refuses a registered safety guard that is missing, as master-hook did.
|
|
346
355
|
*/
|
|
347
356
|
export declare const PRE_TOOL_USE_CLAIMED_SCRIPT_PINS: readonly PinnedFile[];
|
|
348
357
|
/**
|
|
@@ -355,7 +364,7 @@ export declare const PRE_TOOL_USE_CREDENTIAL_GUARD_GENERATIONS: ReadonlyArray<re
|
|
|
355
364
|
/**
|
|
356
365
|
* The native policy-frontmatter check's evaluator scripts, in the order it reads them
|
|
357
366
|
* (crates/hq-hook/src/policy_frontmatter.rs `EVAL_TRIGGER_SHA256`, `FORWARDER_LIB_SHA256`,
|
|
358
|
-
* `
|
|
367
|
+
* `FLOOR_LIB_PINS`). Each is read only once the one before it is on its pin; a missing file
|
|
359
368
|
* gives the same evaluator-unavailable answer bash gave (or skips the floor check), so it is not
|
|
360
369
|
* held.
|
|
361
370
|
*/
|