@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
|
@@ -1482,8 +1482,8 @@ export function generationHold(root) {
|
|
|
1482
1482
|
}
|
|
1483
1483
|
return null;
|
|
1484
1484
|
}
|
|
1485
|
-
/** Folder
|
|
1486
|
-
const RETIRED = new Set(['Stop/70-work-mesh-done.sh']);
|
|
1485
|
+
/** Folder hooks that master-hook.sh never dispatches (retired; `hq rescue` can leave them on disk). */
|
|
1486
|
+
const RETIRED = new Set(['Stop/70-work-mesh-done.sh', 'SessionStart/40-conduct-reap.sh']);
|
|
1487
1487
|
function listDir(dir) {
|
|
1488
1488
|
try {
|
|
1489
1489
|
return fs.readdirSync(dir).sort();
|
|
@@ -1626,7 +1626,7 @@ export function precompactCompatibilityHold(root, env = process.env) {
|
|
|
1626
1626
|
const master = hashes.get('.claude/hooks/master-hook.sh');
|
|
1627
1627
|
if (master && precompactCompatibility.fromBeta104Master.includes(master)) {
|
|
1628
1628
|
const reader = hashes.get('core/scripts/lib/session-id.sh');
|
|
1629
|
-
if (reader &&
|
|
1629
|
+
if (reader && !precompactCompatibility.fromBeta104SessionIds.includes(reader))
|
|
1630
1630
|
return 'mixed PreCompact session reader generation';
|
|
1631
1631
|
if (!reader && env.SESSION_ID_PAYLOAD_JQ)
|
|
1632
1632
|
return 'PreCompact session reader environment override';
|
|
@@ -1810,7 +1810,8 @@ export function fleetLocalMergedWriteGuardHold(root) {
|
|
|
1810
1810
|
return `unreadable merged-write-guard-shadow file ${wrapperRel}`;
|
|
1811
1811
|
}
|
|
1812
1812
|
const wrapperSha = createHash('sha256').update(wrapperBytes).digest('hex');
|
|
1813
|
-
const
|
|
1813
|
+
const isReleased = wrapperSha === MERGED_WRITE_GUARD_PINS_1649[0][1];
|
|
1814
|
+
const pins = isReleased
|
|
1814
1815
|
? MERGED_WRITE_GUARD_PINS_1649
|
|
1815
1816
|
: wrapperSha === MERGED_WRITE_GUARD_PINS_LEGACY[0][1]
|
|
1816
1817
|
? MERGED_WRITE_GUARD_PINS_LEGACY
|
|
@@ -1828,7 +1829,11 @@ export function fleetLocalMergedWriteGuardHold(root) {
|
|
|
1828
1829
|
catch {
|
|
1829
1830
|
return `unreadable merged-write-guard-shadow file ${relative}`;
|
|
1830
1831
|
}
|
|
1831
|
-
|
|
1832
|
+
const actual = createHash('sha256').update(bytes).digest('hex');
|
|
1833
|
+
const accepted = isReleased && relative === HOOK_LIB
|
|
1834
|
+
? MERGED_WRITE_GUARD_SETS.released.hookLibs
|
|
1835
|
+
: [sha];
|
|
1836
|
+
if (!accepted.includes(actual)) {
|
|
1832
1837
|
return `unmodeled merged-write-guard-shadow file ${relative}`;
|
|
1833
1838
|
}
|
|
1834
1839
|
}
|
|
@@ -1836,7 +1841,8 @@ export function fleetLocalMergedWriteGuardHold(root) {
|
|
|
1836
1841
|
}
|
|
1837
1842
|
/**
|
|
1838
1843
|
* The script revisions the native SessionStart master rebuilds (hq-core v16.0.48 through v16.0.50,
|
|
1839
|
-
*
|
|
1844
|
+
* the hq-core-staging fd709b39a shim and hq-session.sh, and the hq-core v16.0.53 shim d1d7e7d0
|
|
1845
|
+
* from hq-core-staging #2024, whose flag-off error answer `hqd_open.rs` ends quietly as the shim does):
|
|
1840
1846
|
* `hqd_open.rs` (the daemon shim and its flag-cache library), `session_set/mod.rs` `SCRIPTS`,
|
|
1841
1847
|
* `ID_LIBS` and `CAPABILITY_LIBS` (hq-session.sh and the two libraries it sources) and
|
|
1842
1848
|
* `foreign_bind.rs` `RESOLVE_REVISIONS` (resolve-company.sh). The native port
|
|
@@ -1844,10 +1850,10 @@ export function fleetLocalMergedWriteGuardHold(root) {
|
|
|
1844
1850
|
* refusal, so the session would start with no SessionStart hook at all.
|
|
1845
1851
|
*/
|
|
1846
1852
|
export const SESSION_START_PINS = [
|
|
1847
|
-
['core/scripts/hqd-hook-shim.sh', ['ab289ac0af680fe3bcacb110302ca8b998bdc33c6f94321d42bd04a344163eed', 'ee5e9fe729eb7e51f87b5f90cdc020be865f5b6b35ac0b5758587546b35715c0']],
|
|
1853
|
+
['core/scripts/hqd-hook-shim.sh', ['ab289ac0af680fe3bcacb110302ca8b998bdc33c6f94321d42bd04a344163eed', 'ee5e9fe729eb7e51f87b5f90cdc020be865f5b6b35ac0b5758587546b35715c0', 'd1d7e7d0231131afc1a49547018207e9bf4df03808aca3fda8f25fedade15b2f']],
|
|
1848
1854
|
['core/scripts/hqd-hook-flag-cache-lib.sh', ['061d264460408e9eaf43fdf0fdde662c906a9a7dacb4e7a591e684bca28c138a']],
|
|
1849
1855
|
['core/scripts/hq-session.sh', ['db701162f71b53fd2188974d2f46c58250593dde1252d65b36e6d02b9a765fe7', '02a37c5dbf4fb5af27cc64d0f271121e990758b757a479f60e9ce099f4d65ded', 'd4d4aef60ff8b095e3abcc817598f376d3c2de8d59758c3ed6dd40d4aa4b11fb']],
|
|
1850
|
-
['core/scripts/lib/session-id.sh', ['2ebbc50893c7c601a111b9e8f9945afeac88f552d7caeec09c4096f4c27a833d']],
|
|
1856
|
+
['core/scripts/lib/session-id.sh', ['2ebbc50893c7c601a111b9e8f9945afeac88f552d7caeec09c4096f4c27a833d', 'd6a04155571ec53edd853878cebaba5a5bab93801a73e356499440c1cd009c71']],
|
|
1851
1857
|
['core/scripts/lib/session-scope-capability.sh', ['388ffef43cfe05810c38ce377245d0d86f415b4009b21a008bca8897be0c9ead']],
|
|
1852
1858
|
['core/scripts/resolve-company.sh', ['00d6fa069f574a86087c77daa44887a2617446d4300d5daebecc9bfb5d81abe7']],
|
|
1853
1859
|
];
|
|
@@ -1933,12 +1939,23 @@ export function migratePolicyTriggersHold(root) {
|
|
|
1933
1939
|
* and `host::fleet::inherit_scope::RELEASED_LIB_SHA256` (`session-scope-capability.sh`).
|
|
1934
1940
|
* `FleetLocalPre` matches the shell adapter when either file is absent (`DISPATCHER_UNAVAILABLE`
|
|
1935
1941
|
* / skip scope inheritance), and refuses any other revision present on disk.
|
|
1936
|
-
* `RELEASED_CORE_SHA256`
|
|
1937
|
-
*
|
|
1938
|
-
*
|
|
1942
|
+
* `RELEASED_CORE_SHA256` and this list accept the bd733f7b core (940bb5a0, hq-core v16.0.48 to
|
|
1943
|
+
* v16.0.50) and the two classifying cores: hq-core-staging 810d0faa (#2119, 09f5a3e0, v16.0.51)
|
|
1944
|
+
* and 7222e9bb (#2129, cf1abd5c, v16.0.52, a comment change). The fleet-local parity tests run
|
|
1945
|
+
* against bd733f7b (tests/fleet_local_pre_tool_use_parity.rs) and against cf1abd5c, with the
|
|
1946
|
+
* engine's own settings entry it classifies as a master record
|
|
1947
|
+
* (tests/fleet_local_pretool_master_parity.rs).
|
|
1939
1948
|
*/
|
|
1940
1949
|
export const FLEET_LOCAL_PRE_TOOL_USE_PINS = [
|
|
1941
|
-
{
|
|
1950
|
+
{
|
|
1951
|
+
relative: 'core/scripts/lib/hook-adapter-core.sh',
|
|
1952
|
+
accepted: [
|
|
1953
|
+
'940bb5a0a268929a4cd3f88b61a0ce619f0fdf64e5d3f25f7f18da35df466ab5',
|
|
1954
|
+
RELEASED_CLASSIFYING_ADAPTER_CORE_SHA256,
|
|
1955
|
+
CLASSIFYING_ADAPTER_CORE_SHA256,
|
|
1956
|
+
],
|
|
1957
|
+
missing: 'allowed',
|
|
1958
|
+
},
|
|
1942
1959
|
{ relative: 'core/scripts/lib/session-scope-capability.sh', accepted: ['388ffef43cfe05810c38ce377245d0d86f415b4009b21a008bca8897be0c9ead'], missing: 'allowed' },
|
|
1943
1960
|
];
|
|
1944
1961
|
/**
|
|
@@ -2095,7 +2112,15 @@ export function grokStopObserveHold(root, event) {
|
|
|
2095
2112
|
*/
|
|
2096
2113
|
export const GROK_PRE_TOOL_USE_ADAPTER_PINS = [
|
|
2097
2114
|
{ relative: '.grok/hooks/hq-grok-hook-adapter.sh', accepted: ['b9075b2f96a6ef8d2ba9675e32ce5881d50522da4eca02b69e6dc8bcd57efddf'], missing: 'allowed' },
|
|
2098
|
-
{
|
|
2115
|
+
{
|
|
2116
|
+
relative: 'core/scripts/lib/hook-adapter-core.sh',
|
|
2117
|
+
accepted: [
|
|
2118
|
+
'940bb5a0a268929a4cd3f88b61a0ce619f0fdf64e5d3f25f7f18da35df466ab5',
|
|
2119
|
+
RELEASED_CLASSIFYING_ADAPTER_CORE_SHA256,
|
|
2120
|
+
CLASSIFYING_ADAPTER_CORE_SHA256,
|
|
2121
|
+
],
|
|
2122
|
+
missing: 'allowed',
|
|
2123
|
+
},
|
|
2099
2124
|
];
|
|
2100
2125
|
/**
|
|
2101
2126
|
* Why Grok PreToolUse must stay on the shell adapter in `root`: the adapter or its library is not the
|
|
@@ -2115,7 +2140,8 @@ export function grokPreToolUseHold(root, shadow) {
|
|
|
2115
2140
|
* crates/hq-hook/src/pre_tool_use_master.rs `DISPATCHER_PINS`. master-hook.sh is v16.0.48 (1a2439ae),
|
|
2116
2141
|
* 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
|
|
2117
2142
|
* 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
|
|
2118
|
-
* hq-core-staging fd709b39a ee5e9fe7
|
|
2143
|
+
* hq-core-staging fd709b39a ee5e9fe7 or the hq-core v16.0.53 d1d7e7d0 (hq-core-staging #2024, whose new
|
|
2144
|
+
* branches run only on an error answer from hqd, which the model never asks), and session-id.sh the released 2ebbc508 or the fd709b39a
|
|
2119
2145
|
* d6a04155; every other file is one revision.
|
|
2120
2146
|
*/
|
|
2121
2147
|
export const PRE_TOOL_USE_DISPATCHER_PINS = [
|
|
@@ -2145,6 +2171,7 @@ export const PRE_TOOL_USE_DISPATCHER_PINS = [
|
|
|
2145
2171
|
'443272ef7642d87b6833bc97b71350502491445cd09b26be9f45140804368b00',
|
|
2146
2172
|
'ab46ebdf0cc84a90dd95a54417817f9f9023b109d5b3710c472a8f5e89061592',
|
|
2147
2173
|
'f9a32c25f5984856a1bb91a7914495577e505c42a8c02831acf8faf049a9a806',
|
|
2174
|
+
'711fb6d2ba7a3b126ddbbcc83e6f14a59178a75f4b856d8a4e64f67b586cabbd',
|
|
2148
2175
|
],
|
|
2149
2176
|
},
|
|
2150
2177
|
{ relative: '.claude/hooks/turn-timing.sh', accepted: ['97c70a3251225ba9e469e41fd3fe2341cfe2936490f54571d2ca16de8e766443'] },
|
|
@@ -2157,7 +2184,14 @@ export const PRE_TOOL_USE_DISPATCHER_PINS = [
|
|
|
2157
2184
|
},
|
|
2158
2185
|
{ relative: 'core/scripts/hq-anywhere-runtime-flag.cjs', accepted: ['8a484cef83d383b440462798ac13e26d132e10bbe509b47e0eb1a3d0db76b2b4'] },
|
|
2159
2186
|
{ relative: 'core/scripts/hqd-hook-flag-cache-lib.sh', accepted: ['061d264460408e9eaf43fdf0fdde662c906a9a7dacb4e7a591e684bca28c138a'] },
|
|
2160
|
-
{
|
|
2187
|
+
{
|
|
2188
|
+
relative: 'core/scripts/hqd-hook-shim.sh',
|
|
2189
|
+
accepted: [
|
|
2190
|
+
'ab289ac0af680fe3bcacb110302ca8b998bdc33c6f94321d42bd04a344163eed',
|
|
2191
|
+
'ee5e9fe729eb7e51f87b5f90cdc020be865f5b6b35ac0b5758587546b35715c0',
|
|
2192
|
+
'd1d7e7d0231131afc1a49547018207e9bf4df03808aca3fda8f25fedade15b2f',
|
|
2193
|
+
],
|
|
2194
|
+
},
|
|
2161
2195
|
{ relative: 'core/scripts/lib/advisory-cap.sh', accepted: ['ab80b2a3f63a5955db392eaff4e54fed88d20130e96ca5c2a0945a3ea146d39b'] },
|
|
2162
2196
|
{ relative: 'core/scripts/lib/epochrealtime.sh', accepted: ['4c9205520dba31533c95eea145f6068ba626885c342c2aa1f232a7237d046cdf'] },
|
|
2163
2197
|
{ relative: 'core/scripts/lib/perl-child-locale.sh', accepted: ['18e6b9d0e22874eea00ecc868b4dcfebbc3bb42434d8d0c81b20baec1194df2e'] },
|
|
@@ -2191,6 +2225,29 @@ export const PRE_TOOL_USE_CODEX_DISPATCHER_PINS = [
|
|
|
2191
2225
|
],
|
|
2192
2226
|
},
|
|
2193
2227
|
];
|
|
2228
|
+
export const PRE_TOOL_USE_GROK_DISPATCHER_PINS = [
|
|
2229
|
+
{
|
|
2230
|
+
relative: 'core/scripts/lib/hook-adapter-core.sh',
|
|
2231
|
+
accepted: [
|
|
2232
|
+
'940bb5a0a268929a4cd3f88b61a0ce619f0fdf64e5d3f25f7f18da35df466ab5',
|
|
2233
|
+
RELEASED_CLASSIFYING_ADAPTER_CORE_SHA256,
|
|
2234
|
+
CLASSIFYING_ADAPTER_CORE_SHA256,
|
|
2235
|
+
],
|
|
2236
|
+
},
|
|
2237
|
+
];
|
|
2238
|
+
export const PRE_TOOL_USE_AGENTS_V2_DISPATCHER_PINS = [
|
|
2239
|
+
{
|
|
2240
|
+
relative: 'core/scripts/lib/hook-adapter-core.sh',
|
|
2241
|
+
accepted: [
|
|
2242
|
+
'940bb5a0a268929a4cd3f88b61a0ce619f0fdf64e5d3f25f7f18da35df466ab5',
|
|
2243
|
+
RELEASED_CLASSIFYING_ADAPTER_CORE_SHA256,
|
|
2244
|
+
CLASSIFYING_ADAPTER_CORE_SHA256,
|
|
2245
|
+
],
|
|
2246
|
+
},
|
|
2247
|
+
];
|
|
2248
|
+
export const PRE_TOOL_USE_FLEET_LOCAL_DISPATCHER_PINS = PRE_TOOL_USE_AGENTS_V2_DISPATCHER_PINS;
|
|
2249
|
+
/** The fleet hosts, whose adapters run master-hook as the Codex adapter does (`HQ_HARNESS=codex`). */
|
|
2250
|
+
const fleetHost = (host) => host === 'agents-v2' || host === 'fleet-local';
|
|
2194
2251
|
/** The Codex adapter the model reproduces on Codex only (pre_tool_use_master.rs `CODEX_ADAPTER_PIN`). */
|
|
2195
2252
|
export const PRE_TOOL_USE_CODEX_ADAPTER_PIN = {
|
|
2196
2253
|
relative: '.codex/hooks/hq-codex-hook-adapter.sh',
|
|
@@ -2200,6 +2257,14 @@ export const PRE_TOOL_USE_CODEX_ADAPTER_PIN = {
|
|
|
2200
2257
|
'a905f51887c497165df1e46e703a504fee7dbc6c879ebcec845d585b13151f52',
|
|
2201
2258
|
],
|
|
2202
2259
|
};
|
|
2260
|
+
/** The Grok adapter the model reproduces on Grok only (pre_tool_use_master.rs `GROK_ADAPTER_PIN`). */
|
|
2261
|
+
export const PRE_TOOL_USE_GROK_ADAPTER_PIN = {
|
|
2262
|
+
relative: '.grok/hooks/hq-grok-hook-adapter.sh',
|
|
2263
|
+
// b9075b2f: v16.0.48 through staging main df7fca97.
|
|
2264
|
+
accepted: [
|
|
2265
|
+
'b9075b2f96a6ef8d2ba9675e32ce5881d50522da4eca02b69e6dc8bcd57efddf',
|
|
2266
|
+
],
|
|
2267
|
+
};
|
|
2203
2268
|
/**
|
|
2204
2269
|
* The claimed vault-write guard's script and the companions it reads (crates/hq-hook/src/ports.rs
|
|
2205
2270
|
* `HOOK_SCRIPT_SHA256` and `HOOK_COMPANION_SHA256` for enforce-vault-write-access). Its arithmetic
|
|
@@ -2223,10 +2288,9 @@ export const PRE_TOOL_USE_VAULT_GUARD_PINS = [
|
|
|
2223
2288
|
* Claimed PreToolUse hooks whose native member answers in place of the root's script with no port
|
|
2224
2289
|
* pin of its own, with the script revisions the member answers for: pre_tool_use_master.rs
|
|
2225
2290
|
* `CLAIMED_SCRIPT_PINS`, where the native PreToolUse refuses any other present revision. The scope
|
|
2226
|
-
* authorizer: hq-core v16.0.45 to v16.0.52
|
|
2227
|
-
* 16.0.53-beta.1 (36312275
|
|
2228
|
-
*
|
|
2229
|
-
* registered safety guard that is missing, as master-hook did.
|
|
2291
|
+
* authorizer: hq-core v16.0.45 to v16.0.52, the prereleases core-pins.json lists, and hq-core
|
|
2292
|
+
* 16.0.53-beta.1 (36312275, PowerShell check ported in #3993). A missing script is not held: the
|
|
2293
|
+
* native PreToolUse refuses a registered safety guard that is missing, as master-hook did.
|
|
2230
2294
|
*/
|
|
2231
2295
|
export const PRE_TOOL_USE_CLAIMED_SCRIPT_PINS = [
|
|
2232
2296
|
{
|
|
@@ -2238,6 +2302,7 @@ export const PRE_TOOL_USE_CLAIMED_SCRIPT_PINS = [
|
|
|
2238
2302
|
'bfe9c24e9aaa6403a83a137326f43ff1eba09acd791ceae232b0b6aed315b6ef',
|
|
2239
2303
|
'1b114e78a6f46a534a3cf4cba96b7d0a9ee33683e0976f9968ee0c956abe6482',
|
|
2240
2304
|
'23e1ce16f323178623faae664697ea5e38e24834884cacfc0978622dad46f74f',
|
|
2305
|
+
'36312275a519af7202ba366fdf4fd22139fb7080d1886eff87c541174e6bdf19',
|
|
2241
2306
|
],
|
|
2242
2307
|
missing: 'allowed',
|
|
2243
2308
|
},
|
|
@@ -2262,14 +2327,21 @@ const CREDENTIAL_ARITH_LIB = '.claude/hooks/bash-arith-subst-guard-lib.sh';
|
|
|
2262
2327
|
/**
|
|
2263
2328
|
* The native policy-frontmatter check's evaluator scripts, in the order it reads them
|
|
2264
2329
|
* (crates/hq-hook/src/policy_frontmatter.rs `EVAL_TRIGGER_SHA256`, `FORWARDER_LIB_SHA256`,
|
|
2265
|
-
* `
|
|
2330
|
+
* `FLOOR_LIB_PINS`). Each is read only once the one before it is on its pin; a missing file
|
|
2266
2331
|
* gives the same evaluator-unavailable answer bash gave (or skips the floor check), so it is not
|
|
2267
2332
|
* held.
|
|
2268
2333
|
*/
|
|
2269
2334
|
export const PRE_TOOL_USE_FRONTMATTER_EVALUATOR_PINS = [
|
|
2270
2335
|
{ relative: 'core/scripts/eval-trigger.sh', accepted: ['0066d89590f96855d800cdce2b883f265eaa6b92ac3fbc6649b82bf768772328'], missing: 'allowed' },
|
|
2271
2336
|
{ relative: 'core/scripts/lib/forwarder.sh', accepted: ['a030068f482cac2ecbfad90394fd7bcd1e24926e9179bcec5c770076ad6e4fc4'], missing: 'allowed' },
|
|
2272
|
-
{
|
|
2337
|
+
{
|
|
2338
|
+
relative: 'core/scripts/lib/hq-cli-floor.sh',
|
|
2339
|
+
accepted: [
|
|
2340
|
+
'd5087c69c33250a71dee35174c259e0a301cee1cd02110a1df5e5ca9d6334fac',
|
|
2341
|
+
'377df32ace180f3825e6de8de5de2fb6237e1132d447331a19fe6fb7efa6defe',
|
|
2342
|
+
],
|
|
2343
|
+
missing: 'allowed',
|
|
2344
|
+
},
|
|
2273
2345
|
];
|
|
2274
2346
|
/** The native image rule's script (ports.rs `HOOK_SCRIPT_SHA256` image-context-guard) and the hook-lib.sh revisions it accepts. */
|
|
2275
2347
|
export const PRE_TOOL_USE_IMAGE_GUARD_PINS = [
|
|
@@ -2499,7 +2571,13 @@ export function stableEngineCommand(command, windows) {
|
|
|
2499
2571
|
export function preToolUseHold(root, host, hooks = []) {
|
|
2500
2572
|
const files = host === 'codex'
|
|
2501
2573
|
? [...PRE_TOOL_USE_DISPATCHER_PINS, ...PRE_TOOL_USE_CODEX_DISPATCHER_PINS, PRE_TOOL_USE_CODEX_ADAPTER_PIN]
|
|
2502
|
-
:
|
|
2574
|
+
: host === 'grok'
|
|
2575
|
+
? [...PRE_TOOL_USE_DISPATCHER_PINS, ...PRE_TOOL_USE_GROK_DISPATCHER_PINS, PRE_TOOL_USE_GROK_ADAPTER_PIN]
|
|
2576
|
+
: host === 'agents-v2'
|
|
2577
|
+
? [...PRE_TOOL_USE_DISPATCHER_PINS, ...PRE_TOOL_USE_AGENTS_V2_DISPATCHER_PINS]
|
|
2578
|
+
: host === 'fleet-local'
|
|
2579
|
+
? [...PRE_TOOL_USE_DISPATCHER_PINS, ...PRE_TOOL_USE_FLEET_LOCAL_DISPATCHER_PINS]
|
|
2580
|
+
: [...PRE_TOOL_USE_DISPATCHER_PINS, ...PRE_TOOL_USE_CLAUDE_DISPATCHER_PINS];
|
|
2503
2581
|
const credential = PRE_TOOL_USE_CREDENTIAL_GUARD_GENERATIONS;
|
|
2504
2582
|
const evaluator = () => {
|
|
2505
2583
|
for (const pin of PRE_TOOL_USE_FRONTMATTER_EVALUATOR_PINS) {
|
|
@@ -2512,7 +2590,7 @@ export function preToolUseHold(root, host, hooks = []) {
|
|
|
2512
2590
|
return null;
|
|
2513
2591
|
};
|
|
2514
2592
|
return pinnedFilesHold(root, 'PreToolUse', files)
|
|
2515
|
-
?? (host === 'codex' ? codexExecFormSettingsHold(root, 'PreToolUse') : null)
|
|
2593
|
+
?? ((host === 'codex' || host === 'grok' || fleetHost(host)) ? codexExecFormSettingsHold(root, 'PreToolUse') : null)
|
|
2516
2594
|
?? pinnedFilesHold(root, 'PreToolUse', PRE_TOOL_USE_VAULT_GUARD_PINS)
|
|
2517
2595
|
?? pinnedFilesHold(root, 'PreToolUse', PRE_TOOL_USE_CLAIMED_SCRIPT_PINS)
|
|
2518
2596
|
?? pinnedFilesHold(root, 'PreToolUse', [
|
|
@@ -2538,7 +2616,7 @@ export const PROMPT_COMPANY_BIND_PINS = [
|
|
|
2538
2616
|
],
|
|
2539
2617
|
},
|
|
2540
2618
|
{ relative: 'core/scripts/hq-session.sh', accepted: ['db701162f71b53fd2188974d2f46c58250593dde1252d65b36e6d02b9a765fe7', '02a37c5dbf4fb5af27cc64d0f271121e990758b757a479f60e9ce099f4d65ded', 'd4d4aef60ff8b095e3abcc817598f376d3c2de8d59758c3ed6dd40d4aa4b11fb'] },
|
|
2541
|
-
{ relative: 'core/scripts/lib/session-id.sh', accepted: ['2ebbc50893c7c601a111b9e8f9945afeac88f552d7caeec09c4096f4c27a833d'] },
|
|
2619
|
+
{ relative: 'core/scripts/lib/session-id.sh', accepted: ['2ebbc50893c7c601a111b9e8f9945afeac88f552d7caeec09c4096f4c27a833d', 'd6a04155571ec53edd853878cebaba5a5bab93801a73e356499440c1cd009c71'] },
|
|
2542
2620
|
{ relative: 'core/scripts/lib/session-scope-capability.sh', accepted: ['388ffef43cfe05810c38ce377245d0d86f415b4009b21a008bca8897be0c9ead'] },
|
|
2543
2621
|
];
|
|
2544
2622
|
/**
|
|
@@ -2598,6 +2676,7 @@ export const CODEX_POST_TOOL_USE_GENERATIONS = [
|
|
|
2598
2676
|
['3c3196254614df7b14dccad507dcee3299fa8cf9c163a6903eac2d86fb2159c5', '98da450068af022eb1eee5420a4eca98867b91690e57316ee565eb7788fb6e7a'],
|
|
2599
2677
|
['a3178b59e633310f3cc39a8c257ff58863169696ffda04dc6ea93a34a5db05ef', '940bb5a0a268929a4cd3f88b61a0ce619f0fdf64e5d3f25f7f18da35df466ab5'],
|
|
2600
2678
|
['a3178b59e633310f3cc39a8c257ff58863169696ffda04dc6ea93a34a5db05ef', CLASSIFYING_ADAPTER_CORE_SHA256],
|
|
2679
|
+
['a905f51887c497165df1e46e703a504fee7dbc6c879ebcec845d585b13151f52', CLASSIFYING_ADAPTER_CORE_SHA256],
|
|
2601
2680
|
];
|
|
2602
2681
|
/** The (Grok adapter, hook-adapter-core.sh) pairs of crates/hq-hook/src/post_hooks/grok.rs `ADAPTER_GENERATIONS`. */
|
|
2603
2682
|
export const GROK_POST_TOOL_USE_GENERATIONS = [
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
"22258fbc7b86d807148fbbb1aad25cce68ae653efc44bed6f2d9f2c445a03144",
|
|
39
39
|
"320d13924e430aaa5fd227f15a502c1c5d7c793351133c2ff5d9611e1bf8847e",
|
|
40
40
|
"368f8944ea69f125c221b5d502028bb3efad4f8ef212d91ff91c64d0ace1e880",
|
|
41
|
+
"436493e3325fb0cbcad651ae8ef42d89f4adf43fe38abd938ed6a39c0b6d17c1",
|
|
41
42
|
"49c337ceccf0a2d7c2a64f6b1de8c3c4d1da507bc5d7afcd01ed292e1f25abf7",
|
|
42
43
|
"4c98cd6f07d4090c062d980b0d85b0084635efdcd4a09afc05cf77287a74b28d",
|
|
43
44
|
"4fe86a1847962a62e203ccba9e20f46f5c2dce050b9d3a5f2aa52b5f95e82d36",
|
|
@@ -68,7 +69,8 @@
|
|
|
68
69
|
"4828d36894273d27a30d1a07a8d8cd649c50ea86ada3505e298a6543a6c84832",
|
|
69
70
|
"5178dfed9387cf5924bb71d5cdded37f445fd7b496e6037e81c43af0e7831d5b",
|
|
70
71
|
"7e615d46df287b8aa9786819cb7e0d49e1d4b0c448bfade59f5fee9d5d169cde",
|
|
71
|
-
"9c5c2ea68f6564e547d8e7f82bed64622c3bc3f78da05b03a2e928db9d1dc0db"
|
|
72
|
+
"9c5c2ea68f6564e547d8e7f82bed64622c3bc3f78da05b03a2e928db9d1dc0db",
|
|
73
|
+
"d6a04155571ec53edd853878cebaba5a5bab93801a73e356499440c1cd009c71"
|
|
72
74
|
],
|
|
73
75
|
".claude/hooks/master-hook.sh": [
|
|
74
76
|
"00ce7c7d805b6300d6a987c340ecf48c5ccbbdf2c6d02265e191975c9cf43424",
|
|
@@ -422,6 +424,10 @@
|
|
|
422
424
|
"1a2439aee50652c5143ccd18561a0aa84a1e94848d02c1aa1c99157f70023f29"
|
|
423
425
|
],
|
|
424
426
|
"fromBeta104SessionId": "2ebbc50893c7c601a111b9e8f9945afeac88f552d7caeec09c4096f4c27a833d",
|
|
427
|
+
"fromBeta104SessionIds": [
|
|
428
|
+
"2ebbc50893c7c601a111b9e8f9945afeac88f552d7caeec09c4096f4c27a833d",
|
|
429
|
+
"d6a04155571ec53edd853878cebaba5a5bab93801a73e356499440c1cd009c71"
|
|
430
|
+
],
|
|
425
431
|
"fileOrder": [
|
|
426
432
|
".claude/hooks/precompact-thrashing-detector.sh",
|
|
427
433
|
".claude/hooks/auto-checkpoint-precompact.sh",
|
|
@@ -137,7 +137,8 @@
|
|
|
137
137
|
"b971dae4a2b82bfa5b31782e54717115abaf052457fb1a546893d04cae43adbb",
|
|
138
138
|
"df3d8ddc15a0c179227c9ba7f855c040973fcee249673156d08b2e2ff2c850b8",
|
|
139
139
|
"49c337ceccf0a2d7c2a64f6b1de8c3c4d1da507bc5d7afcd01ed292e1f25abf7",
|
|
140
|
-
"9133295e5ce523bf8355a093bbea5a1c19682ec42b59ab6b626dffbc33544f3f"
|
|
140
|
+
"9133295e5ce523bf8355a093bbea5a1c19682ec42b59ab6b626dffbc33544f3f",
|
|
141
|
+
"436493e3325fb0cbcad651ae8ef42d89f4adf43fe38abd938ed6a39c0b6d17c1"
|
|
141
142
|
],
|
|
142
143
|
"core/scripts/hook-stop-async-drain.sh": [
|
|
143
144
|
"d7be9aa17c42bd96ba6f9d929240e06d9c057471347374de40ea4be3560da4f5"
|
|
@@ -184,7 +185,8 @@
|
|
|
184
185
|
],
|
|
185
186
|
"core/scripts/lib/session-id.sh": [
|
|
186
187
|
"5178dfed9387cf5924bb71d5cdded37f445fd7b496e6037e81c43af0e7831d5b",
|
|
187
|
-
"2ebbc50893c7c601a111b9e8f9945afeac88f552d7caeec09c4096f4c27a833d"
|
|
188
|
+
"2ebbc50893c7c601a111b9e8f9945afeac88f552d7caeec09c4096f4c27a833d",
|
|
189
|
+
"d6a04155571ec53edd853878cebaba5a5bab93801a73e356499440c1cd009c71"
|
|
188
190
|
],
|
|
189
191
|
"core/scripts/lib/session-scope-capability.sh": [
|
|
190
192
|
"388ffef43cfe05810c38ce377245d0d86f415b4009b21a008bca8897be0c9ead"
|
|
@@ -350,10 +352,12 @@
|
|
|
350
352
|
"b373b582a906b0993a3ce56aa43c1ef0aec6668a6b7e150d59ef3214b7d65b70"
|
|
351
353
|
],
|
|
352
354
|
"core/scripts/hook-lib.sh": [
|
|
353
|
-
"9133295e5ce523bf8355a093bbea5a1c19682ec42b59ab6b626dffbc33544f3f"
|
|
355
|
+
"9133295e5ce523bf8355a093bbea5a1c19682ec42b59ab6b626dffbc33544f3f",
|
|
356
|
+
"436493e3325fb0cbcad651ae8ef42d89f4adf43fe38abd938ed6a39c0b6d17c1"
|
|
354
357
|
],
|
|
355
358
|
"core/scripts/lib/session-id.sh": [
|
|
356
|
-
"2ebbc50893c7c601a111b9e8f9945afeac88f552d7caeec09c4096f4c27a833d"
|
|
359
|
+
"2ebbc50893c7c601a111b9e8f9945afeac88f552d7caeec09c4096f4c27a833d",
|
|
360
|
+
"d6a04155571ec53edd853878cebaba5a5bab93801a73e356499440c1cd009c71"
|
|
357
361
|
],
|
|
358
362
|
"core/scripts/lib/work-mesh-live-hook.sh": [
|
|
359
363
|
"2962e17569d62f5953d41cd516bd7d1b3db9849c3c4fbbd750ae13d7d181bcbe"
|
|
@@ -5,9 +5,10 @@ import { homedir } from 'node:os';
|
|
|
5
5
|
import { addHqHooks, removeHqHooks, shimPath } from '../install/claude-targets.js';
|
|
6
6
|
import { legacyHookTarget } from '../install/hook-target.js';
|
|
7
7
|
import { addCodexHooks, removeCodexHooks, codexHookEntry, codexHookTrustKeys } from '../install/codex-targets.js';
|
|
8
|
+
import { ANTIGRAVITY_HOOK_EVENTS, ANTIGRAVITY_HOOK_NAME, antigravityTargets, buildAntigravityHqHookSpec, detectAntigravity, removeAntigravityHqHooks, } from '../install/antigravity-targets.js';
|
|
8
9
|
import { engineArgs, isCoreNextEntry, isNativeEntry, registrationEngine } from './registration.js';
|
|
9
10
|
import { userHookSettingsFile } from './registration-identity.js';
|
|
10
|
-
import { coreNextArgs, coreNextTargetOrWarn, placeEvent } from '../../utils/host-registration.js';
|
|
11
|
+
import { coreNextArgs, coreNextCommand, coreNextTargetOrWarn, placeEvent } from '../../utils/host-registration.js';
|
|
11
12
|
import { claudeProjectTarget, forHost } from './coverage.js';
|
|
12
13
|
/** The project master-hook command shipped in HQ's .claude/settings.json. */
|
|
13
14
|
function projectClaudeCommand(event) {
|
|
@@ -231,8 +232,55 @@ export function reconcileHookRegistrations(root, home = homedir(), env = process
|
|
|
231
232
|
result.failures.push(`${file}: ${error.message}`);
|
|
232
233
|
}
|
|
233
234
|
}
|
|
235
|
+
try {
|
|
236
|
+
reconcileAntigravity(root, home, env, coreNext);
|
|
237
|
+
}
|
|
238
|
+
catch (error) {
|
|
239
|
+
result.failures.push(`${antigravityTargets(home).hooksFile}: ${error.message}`);
|
|
240
|
+
}
|
|
234
241
|
return result;
|
|
235
242
|
}
|
|
243
|
+
/**
|
|
244
|
+
* Reconcile Antigravity's user-global `~/.gemini/config/hooks.json`.
|
|
245
|
+
*
|
|
246
|
+
* Antigravity has no legacy bash dispatcher, so its hooks run exclusively
|
|
247
|
+
* through the Rust `hq-hook` engine (`core.next`). When `core.next` is on and
|
|
248
|
+
* the installed engine advertises `antigravity` in `registration_hosts`, this
|
|
249
|
+
* writes or updates the `"hq"` named hook spec (preserving all other named
|
|
250
|
+
* hooks in `hooks.json`) whenever Antigravity is detected on the machine or
|
|
251
|
+
* `hooks.json` already exists. When `core.next` is off or killed, it removes
|
|
252
|
+
* the `"hq"` entry (if HQ-owned for this root) without creating the file.
|
|
253
|
+
*/
|
|
254
|
+
function reconcileAntigravity(root, home, env, coreNext) {
|
|
255
|
+
const hooksFile = antigravityTargets(home).hooksFile;
|
|
256
|
+
const fileExists = existsSync(hooksFile);
|
|
257
|
+
const events = coreNext && coreNext.registrationHosts?.includes('antigravity')
|
|
258
|
+
? ANTIGRAVITY_HOOK_EVENTS.filter((event) => coreNext.events.includes(event))
|
|
259
|
+
: [];
|
|
260
|
+
if (events.length > 0 && coreNext) {
|
|
261
|
+
if (!fileExists && !detectAntigravity({ home, env }).detected)
|
|
262
|
+
return;
|
|
263
|
+
const hqSpec = buildAntigravityHqHookSpec(events, (event) => coreNextCommand(coreNext.coreNext, 'antigravity', event, root, 'project'));
|
|
264
|
+
const merge = (doc) => {
|
|
265
|
+
if (JSON.stringify(doc[ANTIGRAVITY_HOOK_NAME]) === JSON.stringify(hqSpec))
|
|
266
|
+
return doc;
|
|
267
|
+
return { ...doc, [ANTIGRAVITY_HOOK_NAME]: hqSpec };
|
|
268
|
+
};
|
|
269
|
+
const current = fileExists ? readJson(hooksFile) : undefined;
|
|
270
|
+
if (current && merge(current) === current)
|
|
271
|
+
return;
|
|
272
|
+
writeMerged(hooksFile, home, merge);
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
if (!fileExists)
|
|
276
|
+
return;
|
|
277
|
+
const current = readJson(hooksFile);
|
|
278
|
+
if (!current)
|
|
279
|
+
return;
|
|
280
|
+
if (removeAntigravityHqHooks(current, root) === current)
|
|
281
|
+
return;
|
|
282
|
+
writeMerged(hooksFile, home, (doc) => removeAntigravityHqHooks(doc, root));
|
|
283
|
+
}
|
|
236
284
|
/**
|
|
237
285
|
* Any master-hook.sh registration for `event`, shipped or wrapped
|
|
238
286
|
* (`... master-hook.sh" Stop 2>>log`, `bash .../master-hook.sh 'Stop'`).
|
|
@@ -2,11 +2,15 @@ export declare const ANTIGRAVITY_BUNDLE_ID = "com.google.antigravity";
|
|
|
2
2
|
export declare const ANTIGRAVITY_CLI_BINARY = "agy";
|
|
3
3
|
export declare const ANTIGRAVITY_RULE_MARKER = "<!-- hq-anywhere:antigravity (managed by `hq install --global`; edits are overwritten) -->";
|
|
4
4
|
export declare const ANTIGRAVITY_HOOKS_ADVISORY = "Antigravity hooks: not wired yet \u2014 HQ policies load through the always-on rule and AGENTS.md; hook guards arrive in a later release";
|
|
5
|
+
export declare const ANTIGRAVITY_HOOK_NAME = "hq";
|
|
6
|
+
export declare const ANTIGRAVITY_HOOK_EVENTS: readonly ["SessionStart", "PreToolUse", "PostToolUse", "Stop"];
|
|
7
|
+
export declare const ANTIGRAVITY_HOOK_TIMEOUT_SEC = 30;
|
|
5
8
|
export interface AntigravityTargets {
|
|
6
9
|
configDir: string;
|
|
7
10
|
rulesDir: string;
|
|
8
11
|
ruleFile: string;
|
|
9
12
|
mcpConfig: string;
|
|
13
|
+
hooksFile: string;
|
|
10
14
|
stateDir: string;
|
|
11
15
|
cliStateDir: string;
|
|
12
16
|
}
|
|
@@ -36,4 +40,22 @@ export type RulePlan = {
|
|
|
36
40
|
/** Decide what to do with the rule file: HQ-owned files are replaced, others are left alone. */
|
|
37
41
|
export declare function planAntigravityRule(current: string | null, hqRoot: string): RulePlan;
|
|
38
42
|
export declare function isHqAntigravityRule(current: string | null): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Extract handler entries per event from an Antigravity `hooks.json` document.
|
|
45
|
+
*
|
|
46
|
+
* Antigravity `hooks.json` maps top-level hook names (e.g. `"hq"`) to event
|
|
47
|
+
* specs. `PreToolUse` and `PostToolUse` use matcher-grouped arrays
|
|
48
|
+
* (`[{ matcher, hooks: [...] }]`), while `SessionStart` and `Stop` use flat
|
|
49
|
+
* arrays of handler objects (`[{ type, command, timeout }]`). Named hooks with
|
|
50
|
+
* `"enabled": false` are skipped because Antigravity does not execute them.
|
|
51
|
+
*/
|
|
52
|
+
export declare function antigravityEventEntries(doc: unknown): Array<[string, Array<Record<string, unknown>>]>;
|
|
53
|
+
/** Build the `"hq"` named hook spec for Antigravity `hooks.json`. */
|
|
54
|
+
export declare function buildAntigravityHqHookSpec(events: readonly string[], commandFor: (event: string) => string): Record<string, unknown>;
|
|
55
|
+
/**
|
|
56
|
+
* Remove HQ's `"hq"` entry from an Antigravity `hooks.json` document when every
|
|
57
|
+
* handler inside it belongs to this HQ root's native hook core. Returns the
|
|
58
|
+
* exact same object reference when nothing changes.
|
|
59
|
+
*/
|
|
60
|
+
export declare function removeAntigravityHqHooks(doc: Record<string, unknown>, root: string): Record<string, unknown>;
|
|
39
61
|
//# sourceMappingURL=antigravity-targets.d.ts.map
|
|
@@ -17,10 +17,15 @@ import * as fs from 'node:fs';
|
|
|
17
17
|
import * as path from 'node:path';
|
|
18
18
|
import { charterPath } from './claude-targets.js';
|
|
19
19
|
import { matchFrontmatter } from '../../utils/frontmatter.js';
|
|
20
|
+
import { isCoreNextEntry } from '../hook-engine/registration-identity.js';
|
|
20
21
|
export const ANTIGRAVITY_BUNDLE_ID = 'com.google.antigravity';
|
|
21
22
|
export const ANTIGRAVITY_CLI_BINARY = 'agy';
|
|
22
23
|
export const ANTIGRAVITY_RULE_MARKER = '<!-- hq-anywhere:antigravity (managed by `hq install --global`; edits are overwritten) -->';
|
|
23
24
|
export const ANTIGRAVITY_HOOKS_ADVISORY = 'Antigravity hooks: not wired yet — HQ policies load through the always-on rule and AGENTS.md; hook guards arrive in a later release';
|
|
25
|
+
export const ANTIGRAVITY_HOOK_NAME = 'hq';
|
|
26
|
+
export const ANTIGRAVITY_HOOK_EVENTS = ['SessionStart', 'PreToolUse', 'PostToolUse', 'Stop'];
|
|
27
|
+
export const ANTIGRAVITY_HOOK_TIMEOUT_SEC = 30;
|
|
28
|
+
const ANTIGRAVITY_GROUPED_EVENTS = new Set(['PreToolUse', 'PostToolUse']);
|
|
24
29
|
export function antigravityTargets(home) {
|
|
25
30
|
const configDir = path.join(home, '.gemini', 'config');
|
|
26
31
|
return {
|
|
@@ -28,6 +33,7 @@ export function antigravityTargets(home) {
|
|
|
28
33
|
rulesDir: path.join(configDir, 'rules'),
|
|
29
34
|
ruleFile: path.join(configDir, 'rules', 'hq.md'),
|
|
30
35
|
mcpConfig: path.join(configDir, 'mcp_config.json'),
|
|
36
|
+
hooksFile: path.join(configDir, 'hooks.json'),
|
|
31
37
|
stateDir: path.join(home, '.gemini', 'antigravity'),
|
|
32
38
|
cliStateDir: path.join(home, '.gemini', 'antigravity-cli'),
|
|
33
39
|
};
|
|
@@ -119,4 +125,80 @@ export function isHqAntigravityRule(current) {
|
|
|
119
125
|
const fence = matchFrontmatter(current);
|
|
120
126
|
return fence !== null && /^trigger:\s*always_on\s*$/m.test(fence[1] ?? '');
|
|
121
127
|
}
|
|
128
|
+
/**
|
|
129
|
+
* Extract handler entries per event from an Antigravity `hooks.json` document.
|
|
130
|
+
*
|
|
131
|
+
* Antigravity `hooks.json` maps top-level hook names (e.g. `"hq"`) to event
|
|
132
|
+
* specs. `PreToolUse` and `PostToolUse` use matcher-grouped arrays
|
|
133
|
+
* (`[{ matcher, hooks: [...] }]`), while `SessionStart` and `Stop` use flat
|
|
134
|
+
* arrays of handler objects (`[{ type, command, timeout }]`). Named hooks with
|
|
135
|
+
* `"enabled": false` are skipped because Antigravity does not execute them.
|
|
136
|
+
*/
|
|
137
|
+
export function antigravityEventEntries(doc) {
|
|
138
|
+
if (!doc || typeof doc !== 'object' || Array.isArray(doc))
|
|
139
|
+
return [];
|
|
140
|
+
const byEvent = new Map();
|
|
141
|
+
for (const spec of Object.values(doc)) {
|
|
142
|
+
if (!spec || typeof spec !== 'object' || Array.isArray(spec))
|
|
143
|
+
continue;
|
|
144
|
+
const obj = spec;
|
|
145
|
+
if (obj.enabled === false)
|
|
146
|
+
continue;
|
|
147
|
+
for (const [event, value] of Object.entries(obj)) {
|
|
148
|
+
if (event === 'enabled' || !Array.isArray(value))
|
|
149
|
+
continue;
|
|
150
|
+
const entries = [];
|
|
151
|
+
for (const item of value) {
|
|
152
|
+
if (!item || typeof item !== 'object' || Array.isArray(item))
|
|
153
|
+
continue;
|
|
154
|
+
const record = item;
|
|
155
|
+
if (Array.isArray(record.hooks)) {
|
|
156
|
+
for (const h of record.hooks) {
|
|
157
|
+
if (h && typeof h === 'object' && !Array.isArray(h)) {
|
|
158
|
+
entries.push(h);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
else if (typeof record.command === 'string') {
|
|
163
|
+
entries.push(record);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
if (entries.length > 0) {
|
|
167
|
+
byEvent.set(event, [...(byEvent.get(event) ?? []), ...entries]);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
return [...byEvent.entries()];
|
|
172
|
+
}
|
|
173
|
+
/** Build the `"hq"` named hook spec for Antigravity `hooks.json`. */
|
|
174
|
+
export function buildAntigravityHqHookSpec(events, commandFor) {
|
|
175
|
+
const spec = {};
|
|
176
|
+
for (const event of events) {
|
|
177
|
+
const handler = {
|
|
178
|
+
type: 'command',
|
|
179
|
+
command: commandFor(event),
|
|
180
|
+
timeout: ANTIGRAVITY_HOOK_TIMEOUT_SEC,
|
|
181
|
+
};
|
|
182
|
+
spec[event] = ANTIGRAVITY_GROUPED_EVENTS.has(event)
|
|
183
|
+
? [{ matcher: '*', hooks: [handler] }]
|
|
184
|
+
: [handler];
|
|
185
|
+
}
|
|
186
|
+
return spec;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Remove HQ's `"hq"` entry from an Antigravity `hooks.json` document when every
|
|
190
|
+
* handler inside it belongs to this HQ root's native hook core. Returns the
|
|
191
|
+
* exact same object reference when nothing changes.
|
|
192
|
+
*/
|
|
193
|
+
export function removeAntigravityHqHooks(doc, root) {
|
|
194
|
+
const existing = doc[ANTIGRAVITY_HOOK_NAME];
|
|
195
|
+
if (!existing || typeof existing !== 'object' || Array.isArray(existing))
|
|
196
|
+
return doc;
|
|
197
|
+
const entries = antigravityEventEntries({ [ANTIGRAVITY_HOOK_NAME]: existing }).flatMap(([, list]) => list);
|
|
198
|
+
if (entries.length === 0 || !entries.every((entry) => isCoreNextEntry(entry, root)))
|
|
199
|
+
return doc;
|
|
200
|
+
const next = { ...doc };
|
|
201
|
+
delete next[ANTIGRAVITY_HOOK_NAME];
|
|
202
|
+
return next;
|
|
203
|
+
}
|
|
122
204
|
//# sourceMappingURL=antigravity-targets.js.map
|
package/dist/main.js
CHANGED
|
@@ -47,6 +47,8 @@ import { printCachedVersionNudge, printVersionAndNudge, refreshVersionCache, sta
|
|
|
47
47
|
import { enforceVersionGate, getVersionGatePhase, isLocalDependencyInstall, resolveRunningInstall, shouldSkipGate, } from "./utils/version-gate.js";
|
|
48
48
|
import { autoUpdateAndReexec } from "./utils/self-update.js";
|
|
49
49
|
import { CLI_VERSION } from "./cli-version.js";
|
|
50
|
+
import { STARTED_CLI_VERSION } from "./started-version.js";
|
|
51
|
+
import { installTreeRecoveryEnv } from "./utils/install-tree-recovery-markers.js";
|
|
50
52
|
import { findLazyCommand, registerCommandCatalog } from "./lazy-commands.js";
|
|
51
53
|
import { argvWithoutHelpOnUnknownCommand } from "./unknown-command.js";
|
|
52
54
|
import { emitCliFirstSyncNextStepOutcome, emitCliFeatureUsed, emitCliLimitNoticeEngagement, emitCliLimitNoticeExposure, emitCliInviteNudgeEvent, emitCliSessionStarted, emitPlanLimitInviteTeammateExposure, isCliLimitResourceKind, queueCliLimitNoticeEngagement, queueCliLimitNoticeExposure, takeFirstSyncStepOutcomes, takeCliFeatureUsages, takeCliLimitNoticeEngagements, takeCliLimitNoticeExposures, takeCliInviteNudgeEvents, takePlanLimitInviteTeammateExposures, maybeShowFirstSyncNextStep, maybeDiscloseLocalCommandUsage, } from "./utils/cli-telemetry.js";
|
|
@@ -330,12 +332,13 @@ export async function runCli() {
|
|
|
330
332
|
}
|
|
331
333
|
},
|
|
332
334
|
argv: process.argv,
|
|
333
|
-
env: process.env,
|
|
335
|
+
env: installTreeRecoveryEnv(process.env),
|
|
334
336
|
entryPath: RUNNING_ENTRY_PATH,
|
|
335
337
|
stderr: process.stderr,
|
|
336
338
|
deps: {
|
|
337
339
|
resolveInstall: resolveRunningInstall,
|
|
338
340
|
versionGatePhase: getVersionGatePhase,
|
|
341
|
+
startedVersion: STARTED_CLI_VERSION ?? CLI_VERSION,
|
|
339
342
|
},
|
|
340
343
|
});
|
|
341
344
|
if (registration.reexecStatus !== undefined) {
|
|
@@ -365,8 +368,10 @@ export async function runCli() {
|
|
|
365
368
|
// process.exitCode — safe to run after exit codes have been set.
|
|
366
369
|
await runGlobalNetworkLifecycle(process.argv, async () => {
|
|
367
370
|
emitPlanLimitNag();
|
|
368
|
-
// Release health: finalize the per-run session before the flush
|
|
369
|
-
|
|
371
|
+
// Release health: finalize the per-run session before the flush, unless
|
|
372
|
+
// this process re-exec'd a replacement child that owns the session.
|
|
373
|
+
if (reexecStatus === null)
|
|
374
|
+
finishSentrySession();
|
|
370
375
|
// Neither task may turn a successful command into Node's
|
|
371
376
|
// `unsettled top-level await` exit. They are observability-only after the
|
|
372
377
|
// command has completed, so a bounded best-effort wait is the terminal
|
package/dist/sentry-init.d.ts
CHANGED
|
@@ -3,8 +3,14 @@ type SentryModule = typeof import("@sentry/node");
|
|
|
3
3
|
type SentryBreadcrumb = Parameters<SentryModule["addBreadcrumb"]>[0];
|
|
4
4
|
/** Shared Sentry SDK setup for the command graph and isolated fast handlers. */
|
|
5
5
|
export declare function createFlaggedBeforeSend(beforeSend: NodeOptions["beforeSend"], skipManualOnlyReportsEnabled?: () => Promise<boolean>): NonNullable<NodeOptions["beforeSend"]>;
|
|
6
|
-
export
|
|
6
|
+
export interface InitSentryRuntimeOptions {
|
|
7
|
+
/** Whether to start a release-health session (default true). */
|
|
8
|
+
startSession?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare function initSentryRuntime(beforeSend: NodeOptions["beforeSend"], overrides?: Partial<Pick<NodeOptions, "transport">>, pendingBreadcrumbs?: readonly SentryBreadcrumb[], options?: InitSentryRuntimeOptions): SentryModule | undefined;
|
|
7
11
|
export declare function finishSentryRuntimeSession(): void;
|
|
12
|
+
/** Discard any un-sent release-health session on the isolation scope (e.g. before a parent re-exec). */
|
|
13
|
+
export declare function discardSentryRuntimeSession(): void;
|
|
8
14
|
/** Close the transport's sockets once the final flush is done. */
|
|
9
15
|
export declare function closeSentryRuntimeTransport(): void;
|
|
10
16
|
export declare function addSentryRuntimeBreadcrumb(breadcrumb: SentryBreadcrumb): void;
|
package/dist/sentry-init.js
CHANGED
|
@@ -115,7 +115,7 @@ async function resolveManualOnlyReportSkip() {
|
|
|
115
115
|
const flagModule = requireRuntime("./lib/doctor/client-health-reason-codes-flag.js");
|
|
116
116
|
return flagModule.clientHealthSkipManualOnlyReportsEnabled();
|
|
117
117
|
}
|
|
118
|
-
export function initSentryRuntime(beforeSend, overrides = {}, pendingBreadcrumbs = []) {
|
|
118
|
+
export function initSentryRuntime(beforeSend, overrides = {}, pendingBreadcrumbs = [], options = {}) {
|
|
119
119
|
// Every startup path (main, fast-route errors, auth refresh, explicit
|
|
120
120
|
// reports) comes through here. A resident process must return before the
|
|
121
121
|
// SDK opens its transport.
|
|
@@ -148,13 +148,17 @@ export function initSentryRuntime(beforeSend, overrides = {}, pendingBreadcrumbs
|
|
|
148
148
|
// A scheduled run (a daemon unit or timer, every 15 s to 6 h) sends only
|
|
149
149
|
// what it captures. Its release-health session was an envelope, and so a
|
|
150
150
|
// new ingest socket, on every clean run.
|
|
151
|
-
if (!isScheduledShortRunCommand(process.argv))
|
|
151
|
+
if (options.startSession !== false && !isScheduledShortRunCommand(process.argv))
|
|
152
152
|
sdk.startSession();
|
|
153
153
|
return sdk;
|
|
154
154
|
}
|
|
155
155
|
export function finishSentryRuntimeSession() {
|
|
156
156
|
sentryModule?.endSession();
|
|
157
157
|
}
|
|
158
|
+
/** Discard any un-sent release-health session on the isolation scope (e.g. before a parent re-exec). */
|
|
159
|
+
export function discardSentryRuntimeSession() {
|
|
160
|
+
sentryModule?.getIsolationScope().setSession();
|
|
161
|
+
}
|
|
158
162
|
/** Close the transport's sockets once the final flush is done. */
|
|
159
163
|
export function closeSentryRuntimeTransport() {
|
|
160
164
|
closeSentryTransportAgents();
|