@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
|
@@ -168,6 +168,165 @@ export declare function coversKey(key: string): {
|
|
|
168
168
|
export declare function coveredOn(covers: Readonly<Record<string, readonly string[]>> | undefined, event: string, host: CoreNextHost): string[];
|
|
169
169
|
/** The old dispatcher's hooks for `event` on `host` that the engine does not cover. */
|
|
170
170
|
export declare function uncoveredHooks(root: string, host: CoreNextHost, event: string, covers: Readonly<Record<string, readonly string[]>> | undefined, env?: NodeJS.ProcessEnv): string[];
|
|
171
|
+
/**
|
|
172
|
+
* The script revisions the native SessionStart master rebuilds (hq-core v16.0.48 through v16.0.50):
|
|
173
|
+
* `hqd_open.rs` (the daemon shim and its flag-cache library), `session_set/mod.rs` `SCRIPTS`,
|
|
174
|
+
* `ID_LIBS` and `CAPABILITY_LIBS` (hq-session.sh and the two libraries it sources) and
|
|
175
|
+
* `foreign_bind.rs` `RESOLVE_REVISIONS` (resolve-company.sh). The native port
|
|
176
|
+
* refuses a SessionStart that reaches any other revision, and Claude Code drops a SessionStart
|
|
177
|
+
* refusal, so the session would start with no SessionStart hook at all.
|
|
178
|
+
*/
|
|
179
|
+
export declare const SESSION_START_PINS: ReadonlyArray<readonly [string, string]>;
|
|
180
|
+
/**
|
|
181
|
+
* Why SessionStart must stay on the shell registration in `root`: one of [`SESSION_START_PINS`] is
|
|
182
|
+
* missing, cannot be read, or is not the pinned revision. A registration-time hold, as for Codex
|
|
183
|
+
* SubagentStop: `hq reindex` keeps master-hook for SessionStart, and the native port still refuses
|
|
184
|
+
* any revision it does not rebuild. Null when every file matches.
|
|
185
|
+
*/
|
|
186
|
+
export declare function sessionStartHold(root: string): string | null;
|
|
187
|
+
/**
|
|
188
|
+
* The one Codex adapter pair the native Codex SubagentStop is modelled on (hq-core v16.0.47):
|
|
189
|
+
* `ADAPTER_RELEASES` and `ADAPTER_CORE_RELEASES` in crates/hq-hook/src/post_hooks/codex.rs.
|
|
190
|
+
* crates/hq-hook/src/lifecycle_dispatch.rs has a test that these values match those.
|
|
191
|
+
*/
|
|
192
|
+
export declare const CODEX_SUBAGENT_STOP_PAIR: ReadonlyArray<readonly [string, string]>;
|
|
193
|
+
/**
|
|
194
|
+
* Why Codex SubagentStop must stay on the shell adapter in `root`: the root's Codex adapter or its
|
|
195
|
+
* library is not the pair the native port models, or cannot be read. The native first member,
|
|
196
|
+
* `lifecycle-dispatch`, refuses every Codex SubagentStop on such a root, so without this hold
|
|
197
|
+
* `hq reindex` would switch the event onto a refusal (hq-cli #3404 R12). Null when the pair matches.
|
|
198
|
+
*/
|
|
199
|
+
export declare function codexSubagentStopHold(root: string): string | null;
|
|
200
|
+
/**
|
|
201
|
+
* [`codexSubagentStopHold`] for the sha256 of the root's adapter and its library, in
|
|
202
|
+
* `CODEX_SUBAGENT_STOP_PAIR` order (null for a file that cannot be read).
|
|
203
|
+
*/
|
|
204
|
+
export declare function codexSubagentStopPairHold(hashes: ReadonlyArray<string | null>): string | null;
|
|
205
|
+
/** One script a native port reads by sha256 before it does an event's work. */
|
|
206
|
+
export interface PinnedFile {
|
|
207
|
+
/** The file, relative to the HQ root. */
|
|
208
|
+
relative: string;
|
|
209
|
+
/** The sha256 of each revision the native port accepts. */
|
|
210
|
+
accepted: readonly string[];
|
|
211
|
+
/** `allowed` where the native port goes on without the file: a root that lacks it is not held. */
|
|
212
|
+
missing?: 'allowed';
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* The shared pin check of the registration holds: why `event` must stay on the shell registration
|
|
216
|
+
* in `root`, or null when the native port accepts every file. A file that is not a regular file is
|
|
217
|
+
* skipped when its entry says `missing: 'allowed'` and held otherwise; one that cannot be read, or
|
|
218
|
+
* whose sha256 is not in its `accepted` list, is held. `generations` lists the revisions that
|
|
219
|
+
* belong together, one sha256 per file in `files` order: the files found must all come from one
|
|
220
|
+
* listed generation (a file skipped as missing matches any).
|
|
221
|
+
*/
|
|
222
|
+
export declare function pinnedFilesHold(root: string, event: string, files: readonly PinnedFile[], generations?: ReadonlyArray<readonly string[]>): string | null;
|
|
223
|
+
/**
|
|
224
|
+
* The three scripts the native Grok StopCancelled and StopFailure member reads by sha256
|
|
225
|
+
* (crates/hq-hook/src/grok_stop_observe.rs `LEAF_SHA256`, `ASYNC_SHA256`, `ENQUEUE_SHA256`), in the
|
|
226
|
+
* order it reads them. Each is skipped there when it is not a file.
|
|
227
|
+
*/
|
|
228
|
+
export declare const GROK_STOP_OBSERVE_PINS: readonly PinnedFile[];
|
|
229
|
+
/**
|
|
230
|
+
* Why a Grok StopCancelled or StopFailure (`event`) must stay on the shell adapter in `root`: the
|
|
231
|
+
* turn-end leaf or one of its two libraries is a revision the native member refuses
|
|
232
|
+
* (grok_stop_observe.rs `plan`). As there, nothing is read in a root with no
|
|
233
|
+
* `.claude/hooks/hook-gate.sh` or no leaf: the member writes nothing and refuses no file. Null
|
|
234
|
+
* when the member accepts the root's files.
|
|
235
|
+
*/
|
|
236
|
+
export declare function grokStopObserveHold(root: string, event: string): string | null;
|
|
237
|
+
/**
|
|
238
|
+
* The Grok adapter and its library the native Grok PreToolUse work is modelled on, as one pair:
|
|
239
|
+
* `.grok/hooks/hq-grok-hook-adapter.sh` b9075b2f with `core/scripts/lib/hook-adapter-core.sh`
|
|
240
|
+
* 940bb5a0 (hq-core v16.0.48 to v16.0.50; crates/hq-hook/src/grok_adapter.rs and grok_pretool.rs).
|
|
241
|
+
* The native side rebuilds the payload this adapter hands its registry hooks and its own checks
|
|
242
|
+
* of the call; it does not read the adapter's sha256 at run time, so another revision would be
|
|
243
|
+
* answered with this model. A root without one of the two files has no other revision to answer
|
|
244
|
+
* for, so a missing file is not held; every hq-core release ships both.
|
|
245
|
+
*/
|
|
246
|
+
export declare const GROK_PRE_TOOL_USE_ADAPTER_PINS: readonly PinnedFile[];
|
|
247
|
+
/**
|
|
248
|
+
* The merged-write-guard-shadow wrapper and its .cjs the native Grok member models
|
|
249
|
+
* (crates/hq-hook/src/merged_write_guard.rs `SCRIPT_SHA256` 63ddff4a and `CJS_SHA256` 225e5c89; the
|
|
250
|
+
* released 742870a2 and 6f65f2b9, which pretool_merged_write_guard.rs models by the wrapper's
|
|
251
|
+
* sha256). A root without them runs no shadow row, so a missing file is not held.
|
|
252
|
+
*/
|
|
253
|
+
export declare const GROK_SHADOW_GUARD_PINS: readonly PinnedFile[];
|
|
254
|
+
/**
|
|
255
|
+
* Why Grok PreToolUse must stay on the shell adapter in `root`: the adapter or its library is not the
|
|
256
|
+
* pair the native work is modelled on, or (when `shadow`, the registry lists the claimed
|
|
257
|
+
* merged-write-guard-shadow row) the wrapper or its .cjs is not a revision the native member
|
|
258
|
+
* models. Unlike the other holds there is no run-time refusal to mirror: on another adapter the
|
|
259
|
+
* native side would answer with the v16.0.50 model, so the hold is the only guard. A missing file is
|
|
260
|
+
* not held: the hold guards against another revision. The merge-hold shim is not pinned:
|
|
261
|
+
* the claimed merge-gates-ready member reads hold records, never the shim.
|
|
262
|
+
*/
|
|
263
|
+
export declare function grokPreToolUseHold(root: string, shadow: boolean): string | null;
|
|
264
|
+
/**
|
|
265
|
+
* The scripts the native first-prompt company bind rebuilds, each at one revision:
|
|
266
|
+
* `MENTION_LIBS` in crates/hq-hook/src/prompt_company_mention/bind.rs, then `SCRIPTS`, `ID_LIBS` and
|
|
267
|
+
* `CAPABILITY_LIBS` in crates/hq-hook/src/session_set/mod.rs.
|
|
268
|
+
*/
|
|
269
|
+
export declare const PROMPT_COMPANY_BIND_PINS: readonly PinnedFile[];
|
|
270
|
+
/**
|
|
271
|
+
* Why UserPromptSubmit must stay on the shell registration in `root`: the native
|
|
272
|
+
* natural-language-router (crates/hq-hook/src/prompt_up7/nl_router.rs) would refuse the first prompt
|
|
273
|
+
* of a session whose company it rebinds, because a script of that bind is not the revision it
|
|
274
|
+
* rebuilds. As there, the bind is skipped (no hold) without the router script, without
|
|
275
|
+
* core/scripts/hook-lib.sh, or without prompt-company-mention.sh or hq-session.sh; with both of
|
|
276
|
+
* those on disk a missing session-id.sh or session-scope-capability.sh is refused, so it holds.
|
|
277
|
+
* Whether a prompt reaches the bind is decided per prompt, so the hold does not wait for one.
|
|
278
|
+
*/
|
|
279
|
+
export declare function promptCompanyBindHold(root: string): string | null;
|
|
280
|
+
/**
|
|
281
|
+
* The policy-enforcement-gate.sh revisions the native gate answers, by the name of
|
|
282
|
+
* `gate::Revision` (crates/hq-hook/src/gate/mod.rs `script_sha256`), each with the
|
|
283
|
+
* core/scripts/hook-lib.sh revisions it accepts beside that gate
|
|
284
|
+
* (crates/hq-hook/src/gate/facts.rs `accepted_hook_lib_sha256`).
|
|
285
|
+
*/
|
|
286
|
+
export declare const POLICY_GATE_REVISIONS: ReadonlyArray<{
|
|
287
|
+
revision: string;
|
|
288
|
+
gate: string;
|
|
289
|
+
hookLibs: readonly string[];
|
|
290
|
+
}>;
|
|
291
|
+
/**
|
|
292
|
+
* Why PostToolUse must stay on the shell registration in `root`: the native policy gate
|
|
293
|
+
* (crates/hq-hook/src/post_hooks/mod.rs `run_gate`, reached from the Claude Code, Codex, Grok Build
|
|
294
|
+
* and fleet-local PostToolUse paths) blocks every call it answers beside a gate script that is not
|
|
295
|
+
* a listed revision, or a hook-lib.sh that revision does not accept. As there, a root with no gate
|
|
296
|
+
* script runs no gate (no hold) and a root with no hook-lib.sh is not refused for it.
|
|
297
|
+
*/
|
|
298
|
+
export declare function policyGateHold(root: string): string | null;
|
|
299
|
+
/** The (Codex adapter, hook-adapter-core.sh) pairs of crates/hq-hook/src/post_hooks/codex.rs `POST_TOOL_USE_GENERATIONS`. */
|
|
300
|
+
export declare const CODEX_POST_TOOL_USE_GENERATIONS: ReadonlyArray<readonly [string, string]>;
|
|
301
|
+
/** The (Grok adapter, hook-adapter-core.sh) pairs of crates/hq-hook/src/post_hooks/grok.rs `ADAPTER_GENERATIONS`. */
|
|
302
|
+
export declare const GROK_POST_TOOL_USE_GENERATIONS: ReadonlyArray<readonly [string, string]>;
|
|
303
|
+
/** The hook-adapter-core.sh revisions of crates/hq-hook/src/host/fleet/local_pre.rs `RELEASED_CORE_SHA256`. */
|
|
304
|
+
export declare const FLEET_LOCAL_ADAPTER_CORE: readonly string[];
|
|
305
|
+
/**
|
|
306
|
+
* Why PostToolUse must stay on the shell adapter of `host` in `root`: the native adapter work
|
|
307
|
+
* refuses the root's adapter scripts. Null for a host with no adapter pin, and where the native
|
|
308
|
+
* port reads no pin:
|
|
309
|
+
* - Codex (post_hooks/codex.rs `answer`, `pin_generation`): nothing is read without
|
|
310
|
+
* `.claude/hooks/hook-gate.sh`. With it, the adapter and its library must be one listed pair; a
|
|
311
|
+
* missing one is refused.
|
|
312
|
+
* - Grok Build (post_hooks/grok.rs `answer`, `held_flush_modelled`, `pin`): nothing is read with
|
|
313
|
+
* neither hook-gate.sh nor `.claude/hooks/inject-policy-on-trigger.sh` on disk. Otherwise as Codex.
|
|
314
|
+
* - fleet-local (post_hooks/fleet.rs `answer`): nothing is read without hook-gate.sh or without
|
|
315
|
+
* hook-adapter-core.sh; with both, the library must be a listed revision.
|
|
316
|
+
* Which calls reach the check is decided per call (a registry row for the tool, a Bash call, a held
|
|
317
|
+
* reminder), so the hold does not wait for one.
|
|
318
|
+
*/
|
|
319
|
+
export declare function postToolUseAdapterHold(root: string, host: CoreNextHost): string | null;
|
|
320
|
+
/** The session-scope-capability.sh master-hook's Task-agent pin is modelled on (crates/hq-hook/src/scope/session.rs `SUBAGENT_PIN_LIB_SHA256`). */
|
|
321
|
+
export declare const SUBAGENT_SCOPE_LIBRARY: PinnedFile;
|
|
322
|
+
/**
|
|
323
|
+
* Why SubagentStart or SubagentStop (`event`) must stay on the shell registration in `root`: the
|
|
324
|
+
* native master work (crates/hq-hook/src/lifecycle_master.rs `begin`) refuses every such event that
|
|
325
|
+
* names a Task agent when the scope library is another revision or not a readable file
|
|
326
|
+
* (scope/session.rs `subagent_pin_library`). As there, a root with nothing at that path is not
|
|
327
|
+
* refused (master-hook bound nothing), so it is not held.
|
|
328
|
+
*/
|
|
329
|
+
export declare function subagentScopeLibraryHold(root: string, event: string): string | null;
|
|
171
330
|
/** Records the environment `target` was resolved under; returns `target`. */
|
|
172
331
|
export declare function resolvedUnder<T extends CoreNextTarget | null>(target: T, env: NodeJS.ProcessEnv): T;
|
|
173
332
|
export declare function forHost(target: CoreNextTarget | null, root: string, host: CoreNextHost, env?: NodeJS.ProcessEnv): CoreNextTarget | null;
|
|
@@ -1695,8 +1695,355 @@ export function uncoveredHooks(root, host, event, covers, env = process.env) {
|
|
|
1695
1695
|
if (!missing.includes(hook))
|
|
1696
1696
|
missing.push(hook);
|
|
1697
1697
|
}
|
|
1698
|
+
if (host === 'codex' && event === 'SubagentStop' && covered.includes('codex-adapter:SubagentStop')) {
|
|
1699
|
+
const hold = codexSubagentStopHold(root);
|
|
1700
|
+
if (hold)
|
|
1701
|
+
missing.push(`(native SubagentStop compatibility: ${hold})`);
|
|
1702
|
+
}
|
|
1703
|
+
if (event === 'SessionStart' && covered.includes('master-hook:SessionStart')) {
|
|
1704
|
+
const hold = sessionStartHold(root);
|
|
1705
|
+
if (hold)
|
|
1706
|
+
missing.push(`(native SessionStart compatibility: ${hold})`);
|
|
1707
|
+
}
|
|
1708
|
+
if (host === 'grok' && GROK_STOP_OBSERVE.has(event) && covered.includes(`grok-adapter:${event}`)) {
|
|
1709
|
+
const hold = grokStopObserveHold(root, event);
|
|
1710
|
+
if (hold)
|
|
1711
|
+
missing.push(`(native ${event} compatibility: ${hold})`);
|
|
1712
|
+
}
|
|
1713
|
+
if (host === 'grok' && event === 'PreToolUse' && covered.includes('grok-adapter:PreToolUse')) {
|
|
1714
|
+
const shadow = covered.includes('merged-write-guard-shadow') && hooks.includes('merged-write-guard-shadow');
|
|
1715
|
+
const hold = grokPreToolUseHold(root, shadow);
|
|
1716
|
+
if (hold)
|
|
1717
|
+
missing.push(`(native PreToolUse compatibility: ${hold})`);
|
|
1718
|
+
}
|
|
1719
|
+
// The native natural-language-router runs where the registry lists it; its claim and master-hook's switch the event.
|
|
1720
|
+
if (event === 'UserPromptSubmit' && covered.includes('master-hook:UserPromptSubmit') && covered.includes('natural-language-router') && hooks.includes('natural-language-router')) {
|
|
1721
|
+
const hold = promptCompanyBindHold(root);
|
|
1722
|
+
if (hold)
|
|
1723
|
+
missing.push(`(native UserPromptSubmit compatibility: ${hold})`);
|
|
1724
|
+
}
|
|
1725
|
+
if (event === 'PostToolUse' && covered.includes('master-hook:PostToolUse')) {
|
|
1726
|
+
// The native policy gate runs where the registry lists it, on every host master-hook's PostToolUse is claimed for.
|
|
1727
|
+
const gate = covered.includes('policy-enforcement-gate') && hooks.includes('policy-enforcement-gate') ? policyGateHold(root) : null;
|
|
1728
|
+
if (gate)
|
|
1729
|
+
missing.push(`(native PostToolUse compatibility: ${gate})`);
|
|
1730
|
+
const adapter = covered.includes(`${host}-adapter:PostToolUse`) ? postToolUseAdapterHold(root, host) : null;
|
|
1731
|
+
if (adapter)
|
|
1732
|
+
missing.push(`(native PostToolUse compatibility: ${adapter})`);
|
|
1733
|
+
}
|
|
1734
|
+
if (SUBAGENT_SCOPE_HOSTS[event]?.includes(host) && covered.includes(`master-hook:${event}`)) {
|
|
1735
|
+
const hold = subagentScopeLibraryHold(root, event);
|
|
1736
|
+
if (hold)
|
|
1737
|
+
missing.push(`(native ${event} compatibility: ${hold})`);
|
|
1738
|
+
}
|
|
1698
1739
|
return missing;
|
|
1699
1740
|
}
|
|
1741
|
+
/**
|
|
1742
|
+
* The script revisions the native SessionStart master rebuilds (hq-core v16.0.48 through v16.0.50):
|
|
1743
|
+
* `hqd_open.rs` (the daemon shim and its flag-cache library), `session_set/mod.rs` `SCRIPTS`,
|
|
1744
|
+
* `ID_LIBS` and `CAPABILITY_LIBS` (hq-session.sh and the two libraries it sources) and
|
|
1745
|
+
* `foreign_bind.rs` `RESOLVE_REVISIONS` (resolve-company.sh). The native port
|
|
1746
|
+
* refuses a SessionStart that reaches any other revision, and Claude Code drops a SessionStart
|
|
1747
|
+
* refusal, so the session would start with no SessionStart hook at all.
|
|
1748
|
+
*/
|
|
1749
|
+
export const SESSION_START_PINS = [
|
|
1750
|
+
['core/scripts/hqd-hook-shim.sh', 'ab289ac0af680fe3bcacb110302ca8b998bdc33c6f94321d42bd04a344163eed'],
|
|
1751
|
+
['core/scripts/hqd-hook-flag-cache-lib.sh', '061d264460408e9eaf43fdf0fdde662c906a9a7dacb4e7a591e684bca28c138a'],
|
|
1752
|
+
['core/scripts/hq-session.sh', 'db701162f71b53fd2188974d2f46c58250593dde1252d65b36e6d02b9a765fe7'],
|
|
1753
|
+
['core/scripts/lib/session-id.sh', '2ebbc50893c7c601a111b9e8f9945afeac88f552d7caeec09c4096f4c27a833d'],
|
|
1754
|
+
['core/scripts/lib/session-scope-capability.sh', '388ffef43cfe05810c38ce377245d0d86f415b4009b21a008bca8897be0c9ead'],
|
|
1755
|
+
['core/scripts/resolve-company.sh', '00d6fa069f574a86087c77daa44887a2617446d4300d5daebecc9bfb5d81abe7'],
|
|
1756
|
+
];
|
|
1757
|
+
/**
|
|
1758
|
+
* Why SessionStart must stay on the shell registration in `root`: one of [`SESSION_START_PINS`] is
|
|
1759
|
+
* missing, cannot be read, or is not the pinned revision. A registration-time hold, as for Codex
|
|
1760
|
+
* SubagentStop: `hq reindex` keeps master-hook for SessionStart, and the native port still refuses
|
|
1761
|
+
* any revision it does not rebuild. Null when every file matches.
|
|
1762
|
+
*/
|
|
1763
|
+
export function sessionStartHold(root) {
|
|
1764
|
+
for (const [relative, sha] of SESSION_START_PINS) {
|
|
1765
|
+
let bytes;
|
|
1766
|
+
try {
|
|
1767
|
+
const file = path.join(root, relative);
|
|
1768
|
+
if (!fs.statSync(file).isFile())
|
|
1769
|
+
return `unreadable SessionStart file ${relative}`;
|
|
1770
|
+
bytes = fs.readFileSync(file);
|
|
1771
|
+
}
|
|
1772
|
+
catch {
|
|
1773
|
+
return `unreadable SessionStart file ${relative}`;
|
|
1774
|
+
}
|
|
1775
|
+
if (createHash('sha256').update(bytes).digest('hex') !== sha)
|
|
1776
|
+
return `unmodeled SessionStart file ${relative}`;
|
|
1777
|
+
}
|
|
1778
|
+
return null;
|
|
1779
|
+
}
|
|
1780
|
+
/**
|
|
1781
|
+
* The one Codex adapter pair the native Codex SubagentStop is modelled on (hq-core v16.0.47):
|
|
1782
|
+
* `ADAPTER_RELEASES` and `ADAPTER_CORE_RELEASES` in crates/hq-hook/src/post_hooks/codex.rs.
|
|
1783
|
+
* crates/hq-hook/src/lifecycle_dispatch.rs has a test that these values match those.
|
|
1784
|
+
*/
|
|
1785
|
+
export const CODEX_SUBAGENT_STOP_PAIR = [
|
|
1786
|
+
['.codex/hooks/hq-codex-hook-adapter.sh', '3c3196254614df7b14dccad507dcee3299fa8cf9c163a6903eac2d86fb2159c5'],
|
|
1787
|
+
['core/scripts/lib/hook-adapter-core.sh', '98da450068af022eb1eee5420a4eca98867b91690e57316ee565eb7788fb6e7a'],
|
|
1788
|
+
];
|
|
1789
|
+
/**
|
|
1790
|
+
* Why Codex SubagentStop must stay on the shell adapter in `root`: the root's Codex adapter or its
|
|
1791
|
+
* library is not the pair the native port models, or cannot be read. The native first member,
|
|
1792
|
+
* `lifecycle-dispatch`, refuses every Codex SubagentStop on such a root, so without this hold
|
|
1793
|
+
* `hq reindex` would switch the event onto a refusal (hq-cli #3404 R12). Null when the pair matches.
|
|
1794
|
+
*/
|
|
1795
|
+
export function codexSubagentStopHold(root) {
|
|
1796
|
+
return codexSubagentStopPairHold(CODEX_SUBAGENT_STOP_PAIR.map(([relative]) => {
|
|
1797
|
+
try {
|
|
1798
|
+
return createHash('sha256').update(fs.readFileSync(path.join(root, relative))).digest('hex');
|
|
1799
|
+
}
|
|
1800
|
+
catch {
|
|
1801
|
+
return null;
|
|
1802
|
+
}
|
|
1803
|
+
}));
|
|
1804
|
+
}
|
|
1805
|
+
/**
|
|
1806
|
+
* [`codexSubagentStopHold`] for the sha256 of the root's adapter and its library, in
|
|
1807
|
+
* `CODEX_SUBAGENT_STOP_PAIR` order (null for a file that cannot be read).
|
|
1808
|
+
*/
|
|
1809
|
+
export function codexSubagentStopPairHold(hashes) {
|
|
1810
|
+
for (const [index, [relative, sha]] of CODEX_SUBAGENT_STOP_PAIR.entries()) {
|
|
1811
|
+
const found = hashes[index];
|
|
1812
|
+
if (found == null)
|
|
1813
|
+
return `unreadable Codex SubagentStop file ${relative}`;
|
|
1814
|
+
if (found !== sha)
|
|
1815
|
+
return `unmodeled Codex SubagentStop file ${relative}`;
|
|
1816
|
+
}
|
|
1817
|
+
return null;
|
|
1818
|
+
}
|
|
1819
|
+
/** Rust's `Path::is_file`: a regular file, symlinks followed; false for anything that cannot be read. */
|
|
1820
|
+
const regularFile = (file) => { try {
|
|
1821
|
+
return fs.statSync(file).isFile();
|
|
1822
|
+
}
|
|
1823
|
+
catch {
|
|
1824
|
+
return false;
|
|
1825
|
+
} };
|
|
1826
|
+
/**
|
|
1827
|
+
* The shared pin check of the registration holds: why `event` must stay on the shell registration
|
|
1828
|
+
* in `root`, or null when the native port accepts every file. A file that is not a regular file is
|
|
1829
|
+
* skipped when its entry says `missing: 'allowed'` and held otherwise; one that cannot be read, or
|
|
1830
|
+
* whose sha256 is not in its `accepted` list, is held. `generations` lists the revisions that
|
|
1831
|
+
* belong together, one sha256 per file in `files` order: the files found must all come from one
|
|
1832
|
+
* listed generation (a file skipped as missing matches any).
|
|
1833
|
+
*/
|
|
1834
|
+
export function pinnedFilesHold(root, event, files, generations = []) {
|
|
1835
|
+
const found = [];
|
|
1836
|
+
for (const { relative, accepted, missing } of files) {
|
|
1837
|
+
const file = path.join(root, relative);
|
|
1838
|
+
if (!regularFile(file)) {
|
|
1839
|
+
if (missing !== 'allowed')
|
|
1840
|
+
return `unreadable ${event} file ${relative}`;
|
|
1841
|
+
found.push(null);
|
|
1842
|
+
continue;
|
|
1843
|
+
}
|
|
1844
|
+
let bytes;
|
|
1845
|
+
try {
|
|
1846
|
+
bytes = fs.readFileSync(file);
|
|
1847
|
+
}
|
|
1848
|
+
catch {
|
|
1849
|
+
return `unreadable ${event} file ${relative}`;
|
|
1850
|
+
}
|
|
1851
|
+
const hash = createHash('sha256').update(bytes).digest('hex');
|
|
1852
|
+
if (!accepted.includes(hash))
|
|
1853
|
+
return `unmodeled ${event} file ${relative}`;
|
|
1854
|
+
found.push(hash);
|
|
1855
|
+
}
|
|
1856
|
+
if (generations.length && !generations.some((generation) => found.every((hash, index) => hash === null || hash === generation[index]))) {
|
|
1857
|
+
return `mixed ${event} file generation ${files.filter((_, index) => found[index] !== null).map(({ relative }) => relative).join(' and ')}`;
|
|
1858
|
+
}
|
|
1859
|
+
return null;
|
|
1860
|
+
}
|
|
1861
|
+
/**
|
|
1862
|
+
* The three scripts the native Grok StopCancelled and StopFailure member reads by sha256
|
|
1863
|
+
* (crates/hq-hook/src/grok_stop_observe.rs `LEAF_SHA256`, `ASYNC_SHA256`, `ENQUEUE_SHA256`), in the
|
|
1864
|
+
* order it reads them. Each is skipped there when it is not a file.
|
|
1865
|
+
*/
|
|
1866
|
+
export const GROK_STOP_OBSERVE_PINS = [
|
|
1867
|
+
{ relative: 'core/hooks/Stop/70-work-mesh-turn-end.sh', accepted: ['1b37183a94a46152c9592d6821f323203438e09ed59956d6239880bb73f896db'], missing: 'allowed' },
|
|
1868
|
+
{ relative: 'core/scripts/lib/hook-stop-async.sh', accepted: ['730b008b81b360923f82785467f3a3b6592be6610ee3b909e446b242543ab3bc', 'fe89218c3f92413cff36e82a937eed5e548e712644d8228b34d59c7f459917ad'], missing: 'allowed' },
|
|
1869
|
+
{ relative: 'core/scripts/lib/work-mesh-enqueue.sh', accepted: ['db440318b8933b7c436c7b7172adffc9e8fd00c92f0e1745ed5da76871accbe7', 'ac44fc8f68dbe7311811e0e97bba2b1e53b3aa856856db566635a135c6319451'], missing: 'allowed' },
|
|
1870
|
+
];
|
|
1871
|
+
/**
|
|
1872
|
+
* Why a Grok StopCancelled or StopFailure (`event`) must stay on the shell adapter in `root`: the
|
|
1873
|
+
* turn-end leaf or one of its two libraries is a revision the native member refuses
|
|
1874
|
+
* (grok_stop_observe.rs `plan`). As there, nothing is read in a root with no
|
|
1875
|
+
* `.claude/hooks/hook-gate.sh` or no leaf: the member writes nothing and refuses no file. Null
|
|
1876
|
+
* when the member accepts the root's files.
|
|
1877
|
+
*/
|
|
1878
|
+
export function grokStopObserveHold(root, event) {
|
|
1879
|
+
if (!regularFile(path.join(root, '.claude', 'hooks', 'hook-gate.sh')))
|
|
1880
|
+
return null;
|
|
1881
|
+
if (!regularFile(path.join(root, GROK_STOP_OBSERVE_PINS[0].relative)))
|
|
1882
|
+
return null;
|
|
1883
|
+
return pinnedFilesHold(root, event, GROK_STOP_OBSERVE_PINS);
|
|
1884
|
+
}
|
|
1885
|
+
/**
|
|
1886
|
+
* The Grok adapter and its library the native Grok PreToolUse work is modelled on, as one pair:
|
|
1887
|
+
* `.grok/hooks/hq-grok-hook-adapter.sh` b9075b2f with `core/scripts/lib/hook-adapter-core.sh`
|
|
1888
|
+
* 940bb5a0 (hq-core v16.0.48 to v16.0.50; crates/hq-hook/src/grok_adapter.rs and grok_pretool.rs).
|
|
1889
|
+
* The native side rebuilds the payload this adapter hands its registry hooks and its own checks
|
|
1890
|
+
* of the call; it does not read the adapter's sha256 at run time, so another revision would be
|
|
1891
|
+
* answered with this model. A root without one of the two files has no other revision to answer
|
|
1892
|
+
* for, so a missing file is not held; every hq-core release ships both.
|
|
1893
|
+
*/
|
|
1894
|
+
export const GROK_PRE_TOOL_USE_ADAPTER_PINS = [
|
|
1895
|
+
{ relative: '.grok/hooks/hq-grok-hook-adapter.sh', accepted: ['b9075b2f96a6ef8d2ba9675e32ce5881d50522da4eca02b69e6dc8bcd57efddf'], missing: 'allowed' },
|
|
1896
|
+
{ relative: 'core/scripts/lib/hook-adapter-core.sh', accepted: ['940bb5a0a268929a4cd3f88b61a0ce619f0fdf64e5d3f25f7f18da35df466ab5'], missing: 'allowed' },
|
|
1897
|
+
];
|
|
1898
|
+
/**
|
|
1899
|
+
* The merged-write-guard-shadow wrapper and its .cjs the native Grok member models
|
|
1900
|
+
* (crates/hq-hook/src/merged_write_guard.rs `SCRIPT_SHA256` 63ddff4a and `CJS_SHA256` 225e5c89; the
|
|
1901
|
+
* released 742870a2 and 6f65f2b9, which pretool_merged_write_guard.rs models by the wrapper's
|
|
1902
|
+
* sha256). A root without them runs no shadow row, so a missing file is not held.
|
|
1903
|
+
*/
|
|
1904
|
+
export const GROK_SHADOW_GUARD_PINS = [
|
|
1905
|
+
{ relative: '.claude/hooks/merged-write-guard-shadow.sh', accepted: ['63ddff4a40e861d8d922b0701863259a3cedbffaf6d44a94d837865e62cca6ac', '742870a2ada4f9357320f7708fca7363be6d81fde374948b59873c327a7d7206'], missing: 'allowed' },
|
|
1906
|
+
{ relative: '.claude/hooks/merged-write-guard-shadow.cjs', accepted: ['225e5c89501ab87965db46e6520c0fd8d08ec5e9745068a2e7324e64f7360884', '6f65f2b9425612f9b2ec2590dace82585230210dcd69a124a9cdeb0116ea7f30'], missing: 'allowed' },
|
|
1907
|
+
];
|
|
1908
|
+
/**
|
|
1909
|
+
* Why Grok PreToolUse must stay on the shell adapter in `root`: the adapter or its library is not the
|
|
1910
|
+
* pair the native work is modelled on, or (when `shadow`, the registry lists the claimed
|
|
1911
|
+
* merged-write-guard-shadow row) the wrapper or its .cjs is not a revision the native member
|
|
1912
|
+
* models. Unlike the other holds there is no run-time refusal to mirror: on another adapter the
|
|
1913
|
+
* native side would answer with the v16.0.50 model, so the hold is the only guard. A missing file is
|
|
1914
|
+
* not held: the hold guards against another revision. The merge-hold shim is not pinned:
|
|
1915
|
+
* the claimed merge-gates-ready member reads hold records, never the shim.
|
|
1916
|
+
*/
|
|
1917
|
+
export function grokPreToolUseHold(root, shadow) {
|
|
1918
|
+
return pinnedFilesHold(root, 'PreToolUse', GROK_PRE_TOOL_USE_ADAPTER_PINS)
|
|
1919
|
+
?? (shadow ? pinnedFilesHold(root, 'PreToolUse', GROK_SHADOW_GUARD_PINS) : null);
|
|
1920
|
+
}
|
|
1921
|
+
/**
|
|
1922
|
+
* The scripts the native first-prompt company bind rebuilds, each at one revision:
|
|
1923
|
+
* `MENTION_LIBS` in crates/hq-hook/src/prompt_company_mention/bind.rs, then `SCRIPTS`, `ID_LIBS` and
|
|
1924
|
+
* `CAPABILITY_LIBS` in crates/hq-hook/src/session_set/mod.rs.
|
|
1925
|
+
*/
|
|
1926
|
+
export const PROMPT_COMPANY_BIND_PINS = [
|
|
1927
|
+
{ relative: 'core/scripts/lib/prompt-company-mention.sh', accepted: ['6c68e31d0605db272a6b922e361d1e7659ab77e96faaf613c62afa192aef4ee0'] },
|
|
1928
|
+
{ relative: 'core/scripts/hq-session.sh', accepted: ['db701162f71b53fd2188974d2f46c58250593dde1252d65b36e6d02b9a765fe7'] },
|
|
1929
|
+
{ relative: 'core/scripts/lib/session-id.sh', accepted: ['2ebbc50893c7c601a111b9e8f9945afeac88f552d7caeec09c4096f4c27a833d'] },
|
|
1930
|
+
{ relative: 'core/scripts/lib/session-scope-capability.sh', accepted: ['388ffef43cfe05810c38ce377245d0d86f415b4009b21a008bca8897be0c9ead'] },
|
|
1931
|
+
];
|
|
1932
|
+
/**
|
|
1933
|
+
* Why UserPromptSubmit must stay on the shell registration in `root`: the native
|
|
1934
|
+
* natural-language-router (crates/hq-hook/src/prompt_up7/nl_router.rs) would refuse the first prompt
|
|
1935
|
+
* of a session whose company it rebinds, because a script of that bind is not the revision it
|
|
1936
|
+
* rebuilds. As there, the bind is skipped (no hold) without the router script, without
|
|
1937
|
+
* core/scripts/hook-lib.sh, or without prompt-company-mention.sh or hq-session.sh; with both of
|
|
1938
|
+
* those on disk a missing session-id.sh or session-scope-capability.sh is refused, so it holds.
|
|
1939
|
+
* Whether a prompt reaches the bind is decided per prompt, so the hold does not wait for one.
|
|
1940
|
+
*/
|
|
1941
|
+
export function promptCompanyBindHold(root) {
|
|
1942
|
+
for (const needed of ['.claude/hooks/natural-language-router.sh', 'core/scripts/hook-lib.sh', PROMPT_COMPANY_BIND_PINS[0].relative, PROMPT_COMPANY_BIND_PINS[1].relative]) {
|
|
1943
|
+
if (!regularFile(path.join(root, needed)))
|
|
1944
|
+
return null;
|
|
1945
|
+
}
|
|
1946
|
+
return pinnedFilesHold(root, 'UserPromptSubmit', PROMPT_COMPANY_BIND_PINS);
|
|
1947
|
+
}
|
|
1948
|
+
/**
|
|
1949
|
+
* The policy-enforcement-gate.sh revisions the native gate answers, by the name of
|
|
1950
|
+
* `gate::Revision` (crates/hq-hook/src/gate/mod.rs `script_sha256`), each with the
|
|
1951
|
+
* core/scripts/hook-lib.sh revisions it accepts beside that gate
|
|
1952
|
+
* (crates/hq-hook/src/gate/facts.rs `accepted_hook_lib_sha256`).
|
|
1953
|
+
*/
|
|
1954
|
+
export const POLICY_GATE_REVISIONS = [
|
|
1955
|
+
{ revision: 'Staging2018', gate: '1bc4df8eaabded175804d2effba704c93b439df05c0867f85bb27f5dcfbc7914', hookLibs: ['9133295e5ce523bf8355a093bbea5a1c19682ec42b59ab6b626dffbc33544f3f'] },
|
|
1956
|
+
{ revision: 'Core16_0_48Beta90', gate: 'a2879dfe692233f5953bac86672947bbd82f3c5247292f3efcb80f16c3d2c6b1', hookLibs: ['9133295e5ce523bf8355a093bbea5a1c19682ec42b59ab6b626dffbc33544f3f', '49c337ceccf0a2d7c2a64f6b1de8c3c4d1da507bc5d7afcd01ed292e1f25abf7', 'be7ca74b2524afba56fefd530bf46cbd1dd39a4c181b6a64c87e124b29bdebe7'] },
|
|
1957
|
+
{ revision: 'Core16_0_48Beta68', gate: '6005f2315210c31daf0c870b768303bfd15f58f3416c52b6e02da9bcb430e9bb', hookLibs: ['c3eb950f80aea21d3f8ad2bc0f76656e6c5a39a5197b4d985aa03d13144fc8a7'] },
|
|
1958
|
+
{ revision: 'Staging1804', gate: 'b3156dc1173cfc3954da0910d05d7c3fa608ba2a75f80407a3e305c9a5949d26', hookLibs: ['df3d8ddc15a0c179227c9ba7f855c040973fcee249673156d08b2e2ff2c850b8', 'b971dae4a2b82bfa5b31782e54717115abaf052457fb1a546893d04cae43adbb'] },
|
|
1959
|
+
{ revision: 'Core16_0_45', gate: 'f692078ab91b20fd6889de57656c08b5572398af3cce044d0c61d06c462a853f', hookLibs: ['c5c8153f1e6cead7a2cbfc9085788f26970efc79752660ff2c308112622a5c8e'] },
|
|
1960
|
+
];
|
|
1961
|
+
const POLICY_GATE = '.claude/hooks/policy-enforcement-gate.sh';
|
|
1962
|
+
const HOOK_LIB = 'core/scripts/hook-lib.sh';
|
|
1963
|
+
/**
|
|
1964
|
+
* Why PostToolUse must stay on the shell registration in `root`: the native policy gate
|
|
1965
|
+
* (crates/hq-hook/src/post_hooks/mod.rs `run_gate`, reached from the Claude Code, Codex, Grok Build
|
|
1966
|
+
* and fleet-local PostToolUse paths) blocks every call it answers beside a gate script that is not
|
|
1967
|
+
* a listed revision, or a hook-lib.sh that revision does not accept. As there, a root with no gate
|
|
1968
|
+
* script runs no gate (no hold) and a root with no hook-lib.sh is not refused for it.
|
|
1969
|
+
*/
|
|
1970
|
+
export function policyGateHold(root) {
|
|
1971
|
+
if (!regularFile(path.join(root, POLICY_GATE)))
|
|
1972
|
+
return null;
|
|
1973
|
+
const files = [
|
|
1974
|
+
{ relative: POLICY_GATE, accepted: POLICY_GATE_REVISIONS.map(({ gate }) => gate) },
|
|
1975
|
+
{ relative: HOOK_LIB, accepted: POLICY_GATE_REVISIONS.flatMap(({ hookLibs }) => hookLibs), missing: 'allowed' },
|
|
1976
|
+
];
|
|
1977
|
+
return pinnedFilesHold(root, 'PostToolUse', files, POLICY_GATE_REVISIONS.flatMap(({ gate, hookLibs }) => hookLibs.map((lib) => [gate, lib])));
|
|
1978
|
+
}
|
|
1979
|
+
const CODEX_ADAPTER = '.codex/hooks/hq-codex-hook-adapter.sh';
|
|
1980
|
+
const GROK_ADAPTER = '.grok/hooks/hq-grok-hook-adapter.sh';
|
|
1981
|
+
const ADAPTER_CORE = 'core/scripts/lib/hook-adapter-core.sh';
|
|
1982
|
+
/** The (Codex adapter, hook-adapter-core.sh) pairs of crates/hq-hook/src/post_hooks/codex.rs `POST_TOOL_USE_GENERATIONS`. */
|
|
1983
|
+
export const CODEX_POST_TOOL_USE_GENERATIONS = [
|
|
1984
|
+
['3c3196254614df7b14dccad507dcee3299fa8cf9c163a6903eac2d86fb2159c5', '98da450068af022eb1eee5420a4eca98867b91690e57316ee565eb7788fb6e7a'],
|
|
1985
|
+
['a3178b59e633310f3cc39a8c257ff58863169696ffda04dc6ea93a34a5db05ef', '940bb5a0a268929a4cd3f88b61a0ce619f0fdf64e5d3f25f7f18da35df466ab5'],
|
|
1986
|
+
];
|
|
1987
|
+
/** The (Grok adapter, hook-adapter-core.sh) pairs of crates/hq-hook/src/post_hooks/grok.rs `ADAPTER_GENERATIONS`. */
|
|
1988
|
+
export const GROK_POST_TOOL_USE_GENERATIONS = [
|
|
1989
|
+
['56d5ce126646589e4ca5b2a2a29f9e11900891d1c791310d23fef757aae02904', '98da450068af022eb1eee5420a4eca98867b91690e57316ee565eb7788fb6e7a'],
|
|
1990
|
+
['f9664658ba328e2d8107c1e0b58ef797d892811130a21ba7d6fd6f83d17a4a9d', 'e750ab8b96cefcac007088f1fb583ff56af8a1169666656518b862296a149f0c'],
|
|
1991
|
+
['b9075b2f96a6ef8d2ba9675e32ce5881d50522da4eca02b69e6dc8bcd57efddf', '940bb5a0a268929a4cd3f88b61a0ce619f0fdf64e5d3f25f7f18da35df466ab5'],
|
|
1992
|
+
];
|
|
1993
|
+
/** The hook-adapter-core.sh revisions of crates/hq-hook/src/host/fleet/local_pre.rs `RELEASED_CORE_SHA256`. */
|
|
1994
|
+
export const FLEET_LOCAL_ADAPTER_CORE = ['940bb5a0a268929a4cd3f88b61a0ce619f0fdf64e5d3f25f7f18da35df466ab5'];
|
|
1995
|
+
/**
|
|
1996
|
+
* Why PostToolUse must stay on the shell adapter of `host` in `root`: the native adapter work
|
|
1997
|
+
* refuses the root's adapter scripts. Null for a host with no adapter pin, and where the native
|
|
1998
|
+
* port reads no pin:
|
|
1999
|
+
* - Codex (post_hooks/codex.rs `answer`, `pin_generation`): nothing is read without
|
|
2000
|
+
* `.claude/hooks/hook-gate.sh`. With it, the adapter and its library must be one listed pair; a
|
|
2001
|
+
* missing one is refused.
|
|
2002
|
+
* - Grok Build (post_hooks/grok.rs `answer`, `held_flush_modelled`, `pin`): nothing is read with
|
|
2003
|
+
* neither hook-gate.sh nor `.claude/hooks/inject-policy-on-trigger.sh` on disk. Otherwise as Codex.
|
|
2004
|
+
* - fleet-local (post_hooks/fleet.rs `answer`): nothing is read without hook-gate.sh or without
|
|
2005
|
+
* hook-adapter-core.sh; with both, the library must be a listed revision.
|
|
2006
|
+
* Which calls reach the check is decided per call (a registry row for the tool, a Bash call, a held
|
|
2007
|
+
* reminder), so the hold does not wait for one.
|
|
2008
|
+
*/
|
|
2009
|
+
export function postToolUseAdapterHold(root, host) {
|
|
2010
|
+
const gate = regularFile(path.join(root, '.claude', 'hooks', 'hook-gate.sh'));
|
|
2011
|
+
const pair = (adapter, generations) => pinnedFilesHold(root, 'PostToolUse', [
|
|
2012
|
+
{ relative: adapter, accepted: generations.map(([own]) => own) },
|
|
2013
|
+
{ relative: ADAPTER_CORE, accepted: generations.map(([, core]) => core) },
|
|
2014
|
+
], generations);
|
|
2015
|
+
if (host === 'codex')
|
|
2016
|
+
return gate ? pair(CODEX_ADAPTER, CODEX_POST_TOOL_USE_GENERATIONS) : null;
|
|
2017
|
+
if (host === 'grok')
|
|
2018
|
+
return gate || regularFile(path.join(root, '.claude', 'hooks', 'inject-policy-on-trigger.sh')) ? pair(GROK_ADAPTER, GROK_POST_TOOL_USE_GENERATIONS) : null;
|
|
2019
|
+
if (host === 'fleet-local')
|
|
2020
|
+
return gate && regularFile(path.join(root, ADAPTER_CORE)) ? pinnedFilesHold(root, 'PostToolUse', [{ relative: ADAPTER_CORE, accepted: FLEET_LOCAL_ADAPTER_CORE }]) : null;
|
|
2021
|
+
return null;
|
|
2022
|
+
}
|
|
2023
|
+
/** The session-scope-capability.sh master-hook's Task-agent pin is modelled on (crates/hq-hook/src/scope/session.rs `SUBAGENT_PIN_LIB_SHA256`). */
|
|
2024
|
+
export const SUBAGENT_SCOPE_LIBRARY = { relative: 'core/scripts/lib/session-scope-capability.sh', accepted: ['388ffef43cfe05810c38ce377245d0d86f415b4009b21a008bca8897be0c9ead'] };
|
|
2025
|
+
/**
|
|
2026
|
+
* Why SubagentStart or SubagentStop (`event`) must stay on the shell registration in `root`: the
|
|
2027
|
+
* native master work (crates/hq-hook/src/lifecycle_master.rs `begin`) refuses every such event that
|
|
2028
|
+
* names a Task agent when the scope library is another revision or not a readable file
|
|
2029
|
+
* (scope/session.rs `subagent_pin_library`). As there, a root with nothing at that path is not
|
|
2030
|
+
* refused (master-hook bound nothing), so it is not held.
|
|
2031
|
+
*/
|
|
2032
|
+
export function subagentScopeLibraryHold(root, event) {
|
|
2033
|
+
try {
|
|
2034
|
+
fs.lstatSync(path.join(root, SUBAGENT_SCOPE_LIBRARY.relative));
|
|
2035
|
+
}
|
|
2036
|
+
catch {
|
|
2037
|
+
return null;
|
|
2038
|
+
}
|
|
2039
|
+
return pinnedFilesHold(root, event, [SUBAGENT_SCOPE_LIBRARY]);
|
|
2040
|
+
}
|
|
2041
|
+
/**
|
|
2042
|
+
* The hosts whose native master work reads the scope library on `event`: SubagentStart on Claude
|
|
2043
|
+
* Code and Grok Build, SubagentStop on Claude Code and Codex (lifecycle_master.rs `begin`,
|
|
2044
|
+
* `task_agent` and `stop_agent`).
|
|
2045
|
+
*/
|
|
2046
|
+
const SUBAGENT_SCOPE_HOSTS = { SubagentStart: ['claude', 'grok'], SubagentStop: ['claude', 'codex'] };
|
|
1700
2047
|
/** Grok events the adapter dispatched as its settings.json `Stop` entries (lifecycle_master.rs `dispatched`). */
|
|
1701
2048
|
const GROK_STOP_OBSERVE = new Set(['StopCancelled', 'StopFailure']);
|
|
1702
2049
|
/**
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"17247cbd11597181dbe374579ac5c3ab65cbd04d546c4cd416d65d70cc9c71ae",
|
|
21
21
|
"1b082635f2166ca668fe8f8ad180e1c8dc6e3517f5657beece68056200219350",
|
|
22
22
|
"5a74d090475b7112f1013f1f11b777dd9cff9032608030d3ab004e56567b5b3d",
|
|
23
|
+
"7ac8365fa95474b2003caa1ff8bed07c88e18abc4d4cbae041f0249dd826a70c",
|
|
23
24
|
"afdc525b83ad443ca3cbafd650746599f702748b9d01e1e6c34f747fb5e098ae",
|
|
24
25
|
"bc8ddf7a648832db6314a989a7c26355f59909cbbcb001c553c6150f072623e8",
|
|
25
26
|
"ca4f0c5cf4c1de34e90f8e3e3114a025958fa78905c569b3a780cca0506e71f8",
|
|
@@ -109,8 +109,40 @@ export declare const DEFAULT_SIGNALS_TIMEOUT_MS = 120000;
|
|
|
109
109
|
export declare const AUTH_PREFLIGHT_TIMEOUT_MS = 10000;
|
|
110
110
|
/** Budget for one worklist script call. */
|
|
111
111
|
export declare const WORKLIST_TIMEOUT_MS = 60000;
|
|
112
|
-
/**
|
|
113
|
-
|
|
112
|
+
/**
|
|
113
|
+
* Documents one pass sends to claude across all adapters of a run.
|
|
114
|
+
*
|
|
115
|
+
* 40, raised from 20 on 2026-11-22 (owner decision: raise the limit rather
|
|
116
|
+
* than reword the warning). The 2026-11-21 06:30 PT indigo job had 31
|
|
117
|
+
* documents waiting after four days of signed-out runs: 20 were read in about
|
|
118
|
+
* 2m45s for the whole job (about 8s a document) and 11 were left for the next
|
|
119
|
+
* day, so a run with nothing wrong was reported as partial. 40 covers that
|
|
120
|
+
* backlog, and a 24-meeting re-run, in one pass.
|
|
121
|
+
*
|
|
122
|
+
* The cap still bounds the run. Calls stay subscription-only (an API-key or
|
|
123
|
+
* third-party login is refused before the first document), a usage-limit reply
|
|
124
|
+
* stops the pass at once, and BAD_OUTPUT_STOP_AFTER stops a run of unusable
|
|
125
|
+
* replies, so raising the cap adds no per-token spend. At the observed rate 40
|
|
126
|
+
* documents take about 5-6 minutes; each call keeps its own
|
|
127
|
+
* DEFAULT_SIGNALS_TIMEOUT_MS budget, and the sync lock is heartbeated, so a
|
|
128
|
+
* longer pass is not taken over as stale.
|
|
129
|
+
*
|
|
130
|
+
* Worst-case duration (not expected; it needs nearly every call to run to its
|
|
131
|
+
* full 120 s budget without BAD_OUTPUT_STOP_AFTER documents failing in a row):
|
|
132
|
+
* - Unusable replies: 40 documents x BAD_OUTPUT_ATTEMPTS (3) calls x 120 s =
|
|
133
|
+
* 4 hours (2 hours at the old cap of 20). That is longer than the 3 hours
|
|
134
|
+
* after which the engine's company run lock can be taken over (LOCK_STALE_MS
|
|
135
|
+
* in src/lib/signals/run-lock.ts, counted from the lock's start, with no
|
|
136
|
+
* heartbeat).
|
|
137
|
+
* - Once a timed-out document is skipped instead of sent again (PR 3438, not
|
|
138
|
+
* merged when this was written): 40 x 120 s = 80 minutes (40 minutes at the
|
|
139
|
+
* old cap). That is longer than the 60 minutes after which the bot releases
|
|
140
|
+
* an in-flight job (IN_FLIGHT_RELEASE_MS in src/lib/bot/local-jobs.ts).
|
|
141
|
+
* The worklist listing keeps its fixed WORKLIST_TIMEOUT_MS (60 s) at
|
|
142
|
+
* `--limit 40`; it does not grow with the limit the way the extract step's
|
|
143
|
+
* listing budget does (src/lib/signals/steps/extract.ts).
|
|
144
|
+
*/
|
|
145
|
+
export declare const DEFAULT_MAX_SIGNAL_DOCS = 40;
|
|
114
146
|
/**
|
|
115
147
|
* Claude calls per document when the reply is unusable (`claude-bad-output`).
|
|
116
148
|
* The reply differs from call to call, so a document whose first reply has a
|
|
@@ -262,6 +294,24 @@ export declare function signalCitation(at: string | undefined, segments: Readonl
|
|
|
262
294
|
start_ms: number;
|
|
263
295
|
end_ms: number;
|
|
264
296
|
} | undefined;
|
|
297
|
+
/**
|
|
298
|
+
* A meeting recap cites the span of the segments it is given: the earliest
|
|
299
|
+
* segment start and the latest segment end, whatever order the markers come
|
|
300
|
+
* in, so an out-of-order or overlapping marker cannot give a start after the
|
|
301
|
+
* end or a span shorter than one segment. `segments` comes from the payload
|
|
302
|
+
* text the pass read, which is capped at MAX_PAYLOAD_BYTES, so a longer
|
|
303
|
+
* transcript is cited up to the last marker inside that cap, not to its end.
|
|
304
|
+
* Undefined when there are no segments. Nothing is inferred beyond the
|
|
305
|
+
* markers already in `segments`.
|
|
306
|
+
*/
|
|
307
|
+
export declare function summaryTranscriptCitation(segments: ReadonlyMap<number, {
|
|
308
|
+
startMs: number;
|
|
309
|
+
endMs: number;
|
|
310
|
+
}>, sourceRef: string): {
|
|
311
|
+
source_ref: string;
|
|
312
|
+
start_ms: number;
|
|
313
|
+
end_ms: number;
|
|
314
|
+
} | undefined;
|
|
265
315
|
export interface IndexRow {
|
|
266
316
|
signal_id: string;
|
|
267
317
|
type: string;
|