@indigoai-us/hq-cli 5.345.267 → 5.345.269
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 +29 -0
- package/README.md +12 -0
- package/contracts/host-canary-release.json +7 -7
- package/dist/commands/core-job-notify-native.d.ts +6 -0
- package/dist/commands/core-job-notify-native.js +64 -4
- package/dist/commands/core-jobs-native.js +3 -16
- package/dist/commands/install-global.js +54 -17
- package/dist/lib/daemon/machine-check-owner.js +1 -1
- package/dist/lib/daemon/machine-checks.d.ts +3 -11
- package/dist/lib/daemon/machine-checks.js +4 -15
- package/dist/lib/daemon/run.js +12 -0
- package/dist/lib/doctor/checks/codex-wiring.d.ts +4 -2
- package/dist/lib/doctor/checks/codex-wiring.js +70 -13
- package/dist/lib/doctor/checks/fleet-hook-core.d.ts +4 -4
- package/dist/lib/doctor/checks/fleet-hook-core.js +5 -10
- package/dist/lib/doctor/checks/grok-wiring.js +38 -0
- package/dist/lib/doctor/checks/hook-engine.js +0 -2
- package/dist/lib/doctor/checks/host-core.d.ts +1 -1
- package/dist/lib/doctor/checks/host-core.js +8 -38
- package/dist/lib/hook-engine/coverage.d.ts +10 -1
- package/dist/lib/hook-engine/coverage.js +63 -8
- package/dist/lib/hook-engine/fleet-registration.js +7 -4
- package/dist/lib/hook-engine/native-precompact-compatibility.json +7 -1
- package/dist/lib/hook-engine/native-stop-compatibility.json +30 -11
- package/dist/lib/hook-engine/reconcile.d.ts +10 -1
- package/dist/lib/hook-engine/reconcile.js +339 -42
- package/dist/lib/hook-engine/stable-gate.d.ts +43 -0
- package/dist/lib/hook-engine/stable-gate.js +276 -0
- package/dist/lib/hot-channels/fleet-complete.js +2 -2
- package/dist/lib/install/antigravity-targets.js +2 -1
- package/dist/lib/install/claude-targets.d.ts +6 -6
- package/dist/lib/install/claude-targets.js +13 -9
- package/dist/lib/install/codex-targets.d.ts +4 -4
- package/dist/lib/install/codex-targets.js +26 -16
- package/dist/lib/install/hook-target.d.ts +23 -2
- package/dist/lib/install/hook-target.js +89 -16
- package/dist/lib/outpost-identity-env.d.ts +18 -0
- package/dist/lib/outpost-identity-env.js +29 -0
- package/dist/lib/signals/steps/extract.js +46 -12
- package/dist/utils/core-next-kill.d.ts +2 -15
- package/dist/utils/core-next-kill.js +5 -36
- package/dist/utils/hook-engine-crash.d.ts +86 -0
- package/dist/utils/hook-engine-crash.js +325 -0
- package/dist/utils/hook-engine-rollup.d.ts +8 -3
- package/dist/utils/hook-engine-rollup.js +0 -1
- package/dist/utils/hook-trust.d.ts +2 -0
- package/dist/utils/hook-trust.js +156 -13
- package/dist/utils/host-registration.d.ts +158 -4
- package/dist/utils/host-registration.js +500 -17
- package/dist/utils/version-gate.d.ts +42 -4
- package/dist/utils/version-gate.js +84 -25
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,35 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [5.345.269] — 2026-11-29
|
|
6
|
+
- Shard `.github/workflows/hq-hook.yml` self-hosted Windows (`matrix.beaker`) `Unit and pipe tests` across 6 parallel `hq-windows` runners using a prebuilt `cargo nextest` archive (`windows-build-archive` + `windows-test-shard`), cutting release-tag Windows test wall time while preserving full target parity and all `build` job release duties.
|
|
7
|
+
- Run the hq-hook Windows baseline shard and join jobs on the AWS Windows runners: they no longer ask for the `beaker` label, so they use the same `self-hosted, Windows, X64, hq-windows` label set as the PR and train Windows jobs they are compared with.
|
|
8
|
+
- Fixed: Allow Antigravity's `schedule` timer/cron tool in `hq-hook` PreToolUse with exact argument key validation (`DurationSeconds`, `CronExpression`, `Prompt`, `TimerCondition`, `IsDaemon`, `ExactTiming`, `MaxIterations`) so Antigravity sessions can run polling loops without being refused fail-closed.
|
|
9
|
+
- Read permission-fallback flag snapshot directories via the caller's environment lookup (`TMPDIR` / `LOCALAPPDATA`) so scoped readers and unit tests do not inherit host temporary snapshot files.
|
|
10
|
+
- Fixed: `hq-hook` command rules now scan here-document bodies when a here-document is piped into another command such as `cat <<'EOF' | python3`, matching the shell hook's handling of piped here-documents.
|
|
11
|
+
- Native UserPromptSubmit `/skill` handling now has tests that run every accepted `hook-lib.sh` revision, including the released hq-core 16.0.52 library, against the shell hook. When the native check cannot decide, the refusal now gives the check's reason and the matching remedy (update the HQ CLI, or `/hq-bug`) instead of asking you to start hqd.
|
|
12
|
+
- Internal: Wait up to 10 s for WMI `Win32_ProcessStartTrace` ETW delivery in `crates/hq-hook/tests/windows/GuiProbe.cs` across positive controls and phase completions, and include `SessionId` and non-baseline Toolhelp snapshots in failure diagnostics.
|
|
13
|
+
- The hook engine now records a panic as one fixed-format line in `~/.hq/logs/hook-engine.jsonl` (location, a message class and versions; no payload or argument values), and the daemon sends each new line within minutes as a `hook_engine_crash` event under the existing telemetry consent and `HQ_TELEMETRY=0` opt-out. Hook answers and exit codes are unchanged.
|
|
14
|
+
- The version gate accepts two optional server fields: `blockedVersions`, which forces an update off a withdrawn release, and `targetVersion`, the exact release that update installs. Servers that do not send them behave as before.
|
|
15
|
+
- Changed: the host canary record shipped with the CLI is refreshed for the 5.345.269 release build.
|
|
16
|
+
- Cap concurrent child-hook spawns in `agents_v2_company_folder_hooks` tests and use bash builtins in 1-second timeout fixtures so parallel runs do not contend on macOS process startup.
|
|
17
|
+
|
|
18
|
+
## [5.345.268] — 2026-11-29
|
|
19
|
+
- Isolate `SCCACHE_SERVER_PORT` and local `SCCACHE_DIR` per runner (`beaker` -> port `4226` / `hq-sccache/beaker`, `beaker-2` -> port `4227` / `hq-sccache/beaker-2`) in all Beaker `Configure sccache (Beaker)` workflow steps so concurrent `beaker` and `beaker-2` jobs on the same Windows host do not collide on `127.0.0.1:4226` or share a local cache directory.
|
|
20
|
+
- Speed up hq-hook builds on the Beaker Windows runners: the release-tag Windows job builds in the workspace target folder again instead of a per-runner folder outside the checkout, and the release-tag, train build-archive and train Clippy jobs on Beaker use the machine-local compiler cache instead of the shared S3 cache, which those jobs could only read and which held no Beaker builds.
|
|
21
|
+
- Rebalance hq-hook Windows Beaker test shards from measured per-binary durations with exact-cover checks, schedule the main Windows baseline behind an immediate-exit freshness and train-priority gate aligned with `beaker-baseline.mjs`, and ignore gate-skipped baseline runs in baseline readers.
|
|
22
|
+
- Declare scalar `test:` fields on the `auto-checkpoint-git-submodule` and `auto-checkpoint-git-gitlink-fails` rows in `US-049-auto-checkpoint/conditional-differences.yaml` and drop the stale `ledger-reference-baseline.tsv` entry left behind by #4226.
|
|
23
|
+
- Native auto-checkpoint now reads repositories that hold nested repositories (gitlinks, with or without `.gitmodules`) as `git status` does, so PostToolUse calls in an HQ root with nested repos no longer stop with "the repository has submodules".
|
|
24
|
+
- On Windows, the native `block-hq-worktree-session` port finds `node.exe` on Git Bash's tool folders again (a #4111 regression used a `:`-separated, exact-name lookup), so it refuses with the flag-service reason when the legacy flag reader would ask the service. Four Windows-only hq-hook tests no longer depend on the runner: the command-guard reference bash gets Git Bash's hook `PATH`, the custom-hook job test drives `--custom-hooks` instead of the removed launcher, and the scope breaker test expects the Windows credential-guard refusal where that guard runs first.
|
|
25
|
+
- `hq core job notify` now delivers scheduled-job alerts on Outposts where the job owner is the box's own user id (`OUTPOST_USER_ID`) and `hq whoami` cannot map it to an email, which includes every company Outpost. It reads the owner email from `OUTPOST_OWNER_EMAIL` or `OWNER_EMAIL` in the process env or in `/etc/outpost/codex-identity.env`. When no email is found, the result reports `"reason":"unresolved_owner_id"`.
|
|
26
|
+
- Native scope check now matches the hq-core 16.0.53 script for Windows interpreter path arguments, directory-changing shell commands, env/genv options, command substitutions inside text, path-led message values, remote positions, and unquoted or piped arguments.
|
|
27
|
+
- Changed: the host canary record shipped with the CLI is rebuilt on the final 5.345.268 engine.
|
|
28
|
+
- Changed: the host canary record shipped with the CLI is refreshed for the 5.345.268 release build.
|
|
29
|
+
- Signals: when the extract step runs on a bot's own login, a helper that started and then errored now fails only that item instead of moving the rest of the run to the Claude command-line login. An item too large for the bot's helper runs alone on the command-line path, and later items stay on the bot's login; if the command-line login is signed out, only that item fails and the run continues. The bot sign-in message now names the provider (`hq bot auth <bot> --provider <provider>`).
|
|
30
|
+
- Speed up the batch-train script tests: the test driver caches each workflow file's js-yaml parse by content, so the 264 scenarios run 4 js-yaml parses instead of about 480. Same scenarios and assertions.
|
|
31
|
+
- Removed: Remove the engine bridge CLI, shadow mode, hash-pin manifest, and `block-hq-grep` hook port from `hq-hook` (US-027) while keeping `block-hq-grep` in `COVERS` for older core compatibility and registering native `hq-hook` entries across Claude, Codex, Grok, and fleet roots without legacy shell scripts.
|
|
32
|
+
- Removed: Remove the hook-engine and `core.next` kill switches (`HQ_CORE_NEXT=off|0|false|no`, `~/.hq/state/core-next.off`, `HQ_HOOK_ENGINE=off`, `~/.hq/hook-engine.off`) and legacy `master-hook.sh` hand-off paths so registered hooks always run natively through `hq-hook`.
|
|
33
|
+
|
|
5
34
|
## [5.345.267] — 2026-11-29
|
|
6
35
|
- Speed up `scope_bash` tests on Windows by reusing the test binary when already outside an HQ tree and evaluating large spelling matrices in-process.
|
|
7
36
|
- Update the legacy journal gate test fixture to use the current sync-core release.
|
package/README.md
CHANGED
|
@@ -159,6 +159,18 @@ is about to send its fields prints this line once instead, and records it under
|
|
|
159
159
|
HQ sends a usage event when you run a signed-in command (CLI version and a timestamp; when enabled, first-sync guidance shown or followed and the flag key cli.first-sync-next-step; never command names, file contents, or secrets) to improve the CLI. Set HQ_TELEMETRY=0 to turn this off.
|
|
160
160
|
```
|
|
161
161
|
|
|
162
|
+
The `hq daemon` also sends `hook_engine_crash` when the native hook engine
|
|
163
|
+
panics. The engine writes one line per panic to `~/.hq/logs/hook-engine.jsonl`;
|
|
164
|
+
the daemon checks for new lines every five minutes and sends each once, at most
|
|
165
|
+
12 per hour (the number held back rides on the next event as
|
|
166
|
+
`properties.suppressed`). Each event carries `properties.crashId`, `signature`
|
|
167
|
+
(a hash of location and class), `location` (`file:line` in the engine source),
|
|
168
|
+
`messageClass` (a fixed set such as `unwrap-none`), `appVersion`, `engine`,
|
|
169
|
+
`release`, `os` and `arch`. It never carries the panic message, payloads,
|
|
170
|
+
arguments or paths outside the engine source. It is sent only when you have
|
|
171
|
+
opted in to telemetry (agents always collect), and never while `HQ_TELEMETRY=0`
|
|
172
|
+
is set; crashes from those periods are not sent later.
|
|
173
|
+
|
|
162
174
|
Turn telemetry off:
|
|
163
175
|
|
|
164
176
|
```bash
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schema": "hq.host-canary-release.v1",
|
|
3
|
-
"cliVersion": "5.345.
|
|
3
|
+
"cliVersion": "5.345.269",
|
|
4
4
|
"hosts": {
|
|
5
5
|
"claude": [
|
|
6
6
|
{
|
|
7
7
|
"passed": true,
|
|
8
|
-
"at": "2026-11-
|
|
9
|
-
"engineVersion": "0.3.1+hq.5.345.
|
|
8
|
+
"at": "2026-11-29T18:12:55.433Z",
|
|
9
|
+
"engineVersion": "0.3.1+hq.5.345.269.src.59ee74f3c4e4594944cf3944b26360e7060f2c54a18817cb87fa3cfddc33163d",
|
|
10
10
|
"gateSha256": "a2879dfe692233f5953bac86672947bbd82f3c5247292f3efcb80f16c3d2c6b1"
|
|
11
11
|
},
|
|
12
12
|
{
|
|
13
13
|
"passed": true,
|
|
14
|
-
"at": "2026-11-
|
|
15
|
-
"engineVersion": "0.3.1+hq.5.345.
|
|
14
|
+
"at": "2026-11-29T18:13:15.465Z",
|
|
15
|
+
"engineVersion": "0.3.1+hq.5.345.269.src.59ee74f3c4e4594944cf3944b26360e7060f2c54a18817cb87fa3cfddc33163d",
|
|
16
16
|
"gateSha256": "ca58a94859eae0a345c11c8d9c59303eb76350dc1cf223391037d21979c28718"
|
|
17
17
|
},
|
|
18
18
|
{
|
|
19
19
|
"passed": true,
|
|
20
|
-
"at": "2026-11-
|
|
21
|
-
"engineVersion": "0.3.1+hq.5.345.
|
|
20
|
+
"at": "2026-11-29T18:13:51.865Z",
|
|
21
|
+
"engineVersion": "0.3.1+hq.5.345.269.src.59ee74f3c4e4594944cf3944b26360e7060f2c54a18817cb87fa3cfddc33163d",
|
|
22
22
|
"gateSha256": "ecdbab7c2e0a1d94eb9c98f15e760390f215bc7115a217ded24b4275322722d2"
|
|
23
23
|
}
|
|
24
24
|
]
|
|
@@ -16,6 +16,12 @@ export type JobNotifyDependencies = {
|
|
|
16
16
|
* `hq whoami` (hq-core-rust US-036). Default: src/lib/daemon/whoami-cache.ts.
|
|
17
17
|
*/
|
|
18
18
|
daemonWhoami?: (json: boolean) => string | null;
|
|
19
|
+
/**
|
|
20
|
+
* The Outpost identity env file read for the box's user id and owner email
|
|
21
|
+
* (default /etc/outpost/codex-identity.env). Skipped when
|
|
22
|
+
* HQ_JOB_SKIP_SYSTEM_IDENTITY=1.
|
|
23
|
+
*/
|
|
24
|
+
identityFile?: string;
|
|
19
25
|
env: Environment;
|
|
20
26
|
cwd: string;
|
|
21
27
|
now: () => Date;
|
|
@@ -7,6 +7,7 @@ import { spawnSync } from "node:child_process";
|
|
|
7
7
|
import { load } from "js-yaml";
|
|
8
8
|
import { serializeJqJson } from "../lib/core-utils/jq-json-serializer.js";
|
|
9
9
|
import { registerCoreJobLeaf } from "./core-job-native-utils.js";
|
|
10
|
+
import { OUTPOST_IDENTITY_ENV_FILE, parseOutpostIdentityAssignments } from "../lib/outpost-identity-env.js";
|
|
10
11
|
const USAGE = [
|
|
11
12
|
"hq-job-notify.sh — dm-only remediation alerts for Outpost scheduled jobs (US-006).",
|
|
12
13
|
"",
|
|
@@ -210,7 +211,7 @@ const COGNITO_SUB = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{1
|
|
|
210
211
|
function cachedWhoami(deps, json) {
|
|
211
212
|
return (deps.daemonWhoami ?? ((asJson) => daemonWhoamiOutput(asJson, deps.env)))(json);
|
|
212
213
|
}
|
|
213
|
-
function
|
|
214
|
+
function whoamiOwnerEmail(owner, deps) {
|
|
214
215
|
if (!deps.commandExists("hq"))
|
|
215
216
|
return "";
|
|
216
217
|
let parsed;
|
|
@@ -235,6 +236,63 @@ function resolveCognitoOwner(owner, deps) {
|
|
|
235
236
|
}
|
|
236
237
|
return "";
|
|
237
238
|
}
|
|
239
|
+
function identityValue(value) {
|
|
240
|
+
const trimmed = (value ?? "").trim();
|
|
241
|
+
return trimmed === "null" ? "" : trimmed;
|
|
242
|
+
}
|
|
243
|
+
function identityFileSource(deps) {
|
|
244
|
+
const empty = { userId: "", emails: [] };
|
|
245
|
+
if (deps.env.HQ_JOB_SKIP_SYSTEM_IDENTITY === "1")
|
|
246
|
+
return empty;
|
|
247
|
+
let contents;
|
|
248
|
+
try {
|
|
249
|
+
contents = deps.readFile(deps.identityFile ?? OUTPOST_IDENTITY_ENV_FILE);
|
|
250
|
+
}
|
|
251
|
+
catch {
|
|
252
|
+
return empty;
|
|
253
|
+
}
|
|
254
|
+
const last = {};
|
|
255
|
+
// Later assignments win, as when the file is sourced by a shell.
|
|
256
|
+
for (const { key, value } of parseOutpostIdentityAssignments(contents))
|
|
257
|
+
last[key] = value;
|
|
258
|
+
return {
|
|
259
|
+
userId: identityValue(last.OUTPOST_USER_ID),
|
|
260
|
+
emails: [identityValue(last.OUTPOST_OWNER_EMAIL), identityValue(last.OWNER_EMAIL)],
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* The box's own owner email when `owner` is this Outpost's user id
|
|
265
|
+
* (OUTPOST_USER_ID), from the process env or the Outpost identity env file.
|
|
266
|
+
* Company Outposts and machine sessions whose cached token carries no
|
|
267
|
+
* delegated owner resolve here. An email is used only from a source whose own
|
|
268
|
+
* OUTPOST_USER_ID equals the owner, and nothing resolves when the env and the
|
|
269
|
+
* file name different user ids.
|
|
270
|
+
*/
|
|
271
|
+
function outpostIdentityOwnerEmail(owner, deps) {
|
|
272
|
+
const target = owner.toLowerCase();
|
|
273
|
+
const envSource = {
|
|
274
|
+
userId: identityValue(deps.env.OUTPOST_USER_ID),
|
|
275
|
+
emails: [identityValue(deps.env.OUTPOST_OWNER_EMAIL), identityValue(deps.env.OWNER_EMAIL)],
|
|
276
|
+
};
|
|
277
|
+
const named = [envSource, identityFileSource(deps)].filter((source) => source.userId);
|
|
278
|
+
if (named.length === 0 || named.some((source) => source.userId.toLowerCase() !== target))
|
|
279
|
+
return "";
|
|
280
|
+
for (const source of named) {
|
|
281
|
+
const email = source.emails.find((candidate) => EMAIL_RECIPIENT.test(candidate));
|
|
282
|
+
if (email)
|
|
283
|
+
return email;
|
|
284
|
+
}
|
|
285
|
+
return "";
|
|
286
|
+
}
|
|
287
|
+
function resolveCognitoOwner(owner, deps) {
|
|
288
|
+
const fromWhoami = whoamiOwnerEmail(owner, deps);
|
|
289
|
+
if (fromWhoami)
|
|
290
|
+
return { recipient: fromWhoami, via: "hq whoami" };
|
|
291
|
+
const fromIdentity = outpostIdentityOwnerEmail(owner, deps);
|
|
292
|
+
if (fromIdentity)
|
|
293
|
+
return { recipient: fromIdentity, via: "the Outpost identity env" };
|
|
294
|
+
return { recipient: "", via: "" };
|
|
295
|
+
}
|
|
238
296
|
function normalizedEpoch(value) {
|
|
239
297
|
if (!/^-?\d+$/.test(value))
|
|
240
298
|
throw new Error(`invalid HQ_JOB_NOTIFY_NOW_EPOCH: ${value}`);
|
|
@@ -303,11 +361,12 @@ export function runJobNotify(argv, options = {}) {
|
|
|
303
361
|
let recipient = owner;
|
|
304
362
|
const cognitoOwner = Boolean(owner) && COGNITO_SUB.test(owner);
|
|
305
363
|
if (cognitoOwner) {
|
|
306
|
-
|
|
364
|
+
const resolved = resolveCognitoOwner(owner, deps);
|
|
365
|
+
recipient = resolved.recipient;
|
|
307
366
|
if (recipient)
|
|
308
|
-
log(`owner ${owner} is a Cognito user id — delivering to ${recipient}`);
|
|
367
|
+
log(`owner ${owner} is a Cognito user id — delivering to ${recipient} (from ${resolved.via})`);
|
|
309
368
|
else {
|
|
310
|
-
log(`owner ${owner} is a Cognito user id that hq dm cannot address and hq whoami
|
|
369
|
+
log(`owner ${owner} is a Cognito user id that hq dm cannot address, and neither hq whoami nor the Outpost identity env maps it to an email — set the job owner to an email or prs_ uid (logged only); never fails the job`);
|
|
311
370
|
deps.appendFile(deliveryLog, '{"delivered":false,"reason":"unresolved_owner_id"}\n');
|
|
312
371
|
}
|
|
313
372
|
}
|
|
@@ -400,6 +459,7 @@ export function runJobNotify(argv, options = {}) {
|
|
|
400
459
|
kind,
|
|
401
460
|
owner,
|
|
402
461
|
...(cognitoOwner ? { recipient: recipient || null } : {}),
|
|
462
|
+
...(cognitoOwner && !recipient ? { reason: "unresolved_owner_id" } : {}),
|
|
403
463
|
channel_unimplemented: channelUnimplemented === 1,
|
|
404
464
|
deliver_rc: deliverRc,
|
|
405
465
|
}, "compact"));
|
|
@@ -9,6 +9,7 @@ import { serializeJqJson } from "../lib/core-utils/jq-json-serializer.js";
|
|
|
9
9
|
import { resolveLiveRoot } from "../utils/hq-roots.js";
|
|
10
10
|
import { describeCoreCommand } from "./core-command-catalog.js";
|
|
11
11
|
import { runScheduleParse } from "./core-jobs-schedule.js";
|
|
12
|
+
import { OUTPOST_IDENTITY_ENV_FILE, parseOutpostIdentityAssignments } from "../lib/outpost-identity-env.js";
|
|
12
13
|
export { detectHostTimezone, runScheduleParse } from "./core-jobs-schedule.js";
|
|
13
14
|
const VALIDATE_USAGE = "usage: jobs-validate.sh <file-or-dir> [file-or-dir...]\n";
|
|
14
15
|
function isValidCronField(value, minimum, maximum) {
|
|
@@ -451,26 +452,12 @@ function shellText(value) {
|
|
|
451
452
|
return String(value);
|
|
452
453
|
}
|
|
453
454
|
function parseIdentityAssignments(contents) {
|
|
454
|
-
|
|
455
|
-
for (const line of contents.split(/\r?\n/)) {
|
|
456
|
-
const assignment = /^\s*(?:export\s+)?(OUTPOST_USER_ID|OUTPOST_OWNER_EMAIL|OWNER_EMAIL)\s*=\s*(.*?)\s*$/.exec(line);
|
|
457
|
-
if (!assignment)
|
|
458
|
-
continue;
|
|
459
|
-
let value = assignment[2] ?? "";
|
|
460
|
-
if ((value.startsWith("'") && value.endsWith("'")) || (value.startsWith('"') && value.endsWith('"'))) {
|
|
461
|
-
value = value.slice(1, -1);
|
|
462
|
-
}
|
|
463
|
-
else {
|
|
464
|
-
value = value.replace(/\s+#.*$/, "");
|
|
465
|
-
}
|
|
466
|
-
values.push(value);
|
|
467
|
-
}
|
|
468
|
-
return values;
|
|
455
|
+
return parseOutpostIdentityAssignments(contents).map((assignment) => assignment.value);
|
|
469
456
|
}
|
|
470
457
|
function identityFileTokens(options) {
|
|
471
458
|
if (process.env.HQ_JOB_SKIP_SYSTEM_IDENTITY === "1")
|
|
472
459
|
return [];
|
|
473
|
-
const filename =
|
|
460
|
+
const filename = OUTPOST_IDENTITY_ENV_FILE;
|
|
474
461
|
try {
|
|
475
462
|
const contents = options.identityFileReader
|
|
476
463
|
? options.identityFileReader(filename)
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { resolveInstallHookTarget } from '../lib/install/hook-target.js';
|
|
2
|
+
import { isNativeOnlyCoreRoot } from '../lib/hook-engine/coverage.js';
|
|
3
|
+
import { HQ_CLI_NPM_REPAIR_COMMAND } from '../utils/npm-install-flags.js';
|
|
4
|
+
import { resolvePortableEngineForNativeOnly } from '../utils/host-registration.js';
|
|
2
5
|
/**
|
|
3
6
|
* `hq install --global --runtime claude` / `hq uninstall --global --runtime claude`
|
|
4
7
|
* (hq-anywhere-runtime US-005).
|
|
@@ -138,16 +141,39 @@ function canonical(v) {
|
|
|
138
141
|
: val);
|
|
139
142
|
}
|
|
140
143
|
/** JSON settings format whose verify step checks every HQ hook is registered. */
|
|
141
|
-
function settingsInstallFormat(hqRoot, target) {
|
|
144
|
+
function settingsInstallFormat(hqRoot, target, platform = process.platform) {
|
|
142
145
|
return {
|
|
143
146
|
...jsonFormat,
|
|
144
147
|
emptyDoc: () => ({}),
|
|
145
148
|
assertEntry(doc) {
|
|
146
|
-
if (!hasAllHqHooks(doc, hqRoot, target))
|
|
149
|
+
if (!hasAllHqHooks(doc, hqRoot, target, platform))
|
|
147
150
|
throw new Error('HQ hooks not present after write');
|
|
148
151
|
},
|
|
149
152
|
};
|
|
150
153
|
}
|
|
154
|
+
/**
|
|
155
|
+
* When writing a portable native wrapper for a native-only HQ root, ensure
|
|
156
|
+
* `<home>/.hq/bin/hq-hook/stable` exists and points to an accepted engine
|
|
157
|
+
* before writing any host settings. When `core.next` is on and the host canary
|
|
158
|
+
* gate refused the new engine (M-2), falls back only to a previously accepted
|
|
159
|
+
* engine already linked at `stable` and never links the refused engine.
|
|
160
|
+
* Refuses clearly when no accepted engine is available so global install never
|
|
161
|
+
* writes a wrapper that blocks every session or runs a canary-refused engine.
|
|
162
|
+
*/
|
|
163
|
+
function ensurePortableEngineOrThrow(hqRoot, home, target, env, host, platform, refusedCandidate) {
|
|
164
|
+
if (target !== 'portable')
|
|
165
|
+
return;
|
|
166
|
+
const resolution = resolvePortableEngineForNativeOnly(home, {
|
|
167
|
+
platform,
|
|
168
|
+
env,
|
|
169
|
+
host,
|
|
170
|
+
root: hqRoot,
|
|
171
|
+
candidate: refusedCandidate ?? null,
|
|
172
|
+
});
|
|
173
|
+
if (!resolution.stable) {
|
|
174
|
+
throw Object.assign(new Error(`Cannot install HQ global hooks for native-only HQ root ${hqRoot}: ${resolution.refusalReason ?? `repair with: ${HQ_CLI_NPM_REPAIR_COMMAND}`}`), { expected: true });
|
|
175
|
+
}
|
|
176
|
+
}
|
|
151
177
|
/**
|
|
152
178
|
* Removal format: verifies no HQ hook remains, and serializes a doc that equals
|
|
153
179
|
* the pre-install document back to the ORIGINAL bytes (byte-identical uninstall).
|
|
@@ -347,7 +373,10 @@ function readState(t) {
|
|
|
347
373
|
function assertHqRoot(hqRoot) {
|
|
348
374
|
if (!path.isAbsolute(hqRoot))
|
|
349
375
|
throw new Error(`HQ root must be absolute: ${hqRoot}`);
|
|
350
|
-
|
|
376
|
+
const required = isNativeOnlyCoreRoot(hqRoot)
|
|
377
|
+
? [charterPath(hqRoot)]
|
|
378
|
+
: [charterPath(hqRoot), masterHookPath(hqRoot)];
|
|
379
|
+
for (const p of required) {
|
|
351
380
|
if (!fs.existsSync(p))
|
|
352
381
|
throw new Error(`${hqRoot} is not an HQ checkout (missing ${p})`);
|
|
353
382
|
}
|
|
@@ -419,10 +448,11 @@ export function installGlobalClaude(opts) {
|
|
|
419
448
|
const marketplaceNeedsAdd = !!pluginSource && existingMarketplace === undefined;
|
|
420
449
|
const pluginAdded = !!pluginSource && (prior?.plugin?.pluginAdded === true || pluginNeedsInstall);
|
|
421
450
|
const marketplaceAdded = !!pluginSource && (prior?.plugin?.marketplaceAdded === true || marketplaceNeedsAdd);
|
|
422
|
-
const
|
|
451
|
+
const platform = opts.platform ?? process.platform;
|
|
452
|
+
const { target: hookTarget, refusedCandidate } = resolveInstallHookTarget(hqRoot, home, opts.daemonInstalled, env, 'claude', platform);
|
|
423
453
|
const settingsNext = pluginSource
|
|
424
454
|
? cleanupRoots.reduce((doc, root) => removeHqHooks(doc, root), settingsDoc)
|
|
425
|
-
: addHqHooks(settingsDoc, hqRoot, hookTarget);
|
|
455
|
+
: addHqHooks(settingsDoc, hqRoot, hookTarget, platform);
|
|
426
456
|
const skillLinksToRemove = [...new Set(pluginSource
|
|
427
457
|
? cleanupRoots.flatMap((root) => hqSkillLinksForRoot(t.skillsDir, root))
|
|
428
458
|
: cleanupRoots.flatMap((root) => hqCompanySkillLinksForRoot(t.skillsDir, root)))];
|
|
@@ -468,6 +498,8 @@ export function installGlobalClaude(opts) {
|
|
|
468
498
|
log(`Would run: claude plugin marketplace add --scope user ${pluginSource.sourceDir}; claude plugin install --scope user -y ${pluginSource.pluginId}`);
|
|
469
499
|
return touched;
|
|
470
500
|
}
|
|
501
|
+
if (!pluginSource)
|
|
502
|
+
ensurePortableEngineOrThrow(hqRoot, home, hookTarget, env, 'claude', platform, refusedCandidate);
|
|
471
503
|
if (pluginSource && (marketplaceNeedsAdd || pluginNeedsInstall)) {
|
|
472
504
|
let marketplaceMayNeedRollback = false;
|
|
473
505
|
try {
|
|
@@ -555,8 +587,8 @@ export function installGlobalClaude(opts) {
|
|
|
555
587
|
writeConfigAtomic({
|
|
556
588
|
target: t.settingsJson,
|
|
557
589
|
pack: HQ_ANYWHERE_PACK,
|
|
558
|
-
format: settingsInstallFormat(hqRoot, hookTarget),
|
|
559
|
-
merge: (doc) => addHqHooks(doc, hqRoot, hookTarget),
|
|
590
|
+
format: settingsInstallFormat(hqRoot, hookTarget, platform),
|
|
591
|
+
merge: (doc) => addHqHooks(doc, hqRoot, hookTarget, platform),
|
|
560
592
|
assertName: 'hooks',
|
|
561
593
|
env: { home },
|
|
562
594
|
});
|
|
@@ -607,7 +639,7 @@ export function installGlobalClaude(opts) {
|
|
|
607
639
|
if (pluginSource)
|
|
608
640
|
log(` plugin: ${pluginSource.pluginId} installed from ${pluginSource.sourceDir}; direct hooks and MCP entries removed`);
|
|
609
641
|
else {
|
|
610
|
-
log(` hooks: ${typeof hookTarget === 'object' ? ('coreNext' in hookTarget ? hookTarget.coreNext : hookTarget.engine) : hookTarget === 'shim' ? 'hqd-hook-shim.sh' : 'master-hook.sh'} registered in ${t.settingsJson}`);
|
|
642
|
+
log(` hooks: ${typeof hookTarget === 'object' ? ('coreNext' in hookTarget ? hookTarget.coreNext : hookTarget.engine) : hookTarget === 'portable' ? 'hq-hook (portable)' : hookTarget === 'shim' ? 'hqd-hook-shim.sh' : 'master-hook.sh'} registered in ${t.settingsJson}`);
|
|
611
643
|
log(` MCP: "${HQ_MCP_SERVER_NAME}" registered in ${t.claudeJson}`);
|
|
612
644
|
}
|
|
613
645
|
log(` registry: ${seeded.length} manifest entr${seeded.length === 1 ? 'y' : 'ies'} seeded`);
|
|
@@ -792,17 +824,20 @@ function readCodexState(t) {
|
|
|
792
824
|
function assertCodexHqRoot(hqRoot) {
|
|
793
825
|
if (!path.isAbsolute(hqRoot))
|
|
794
826
|
throw new Error(`HQ root must be absolute: ${hqRoot}`);
|
|
795
|
-
|
|
827
|
+
const required = isNativeOnlyCoreRoot(hqRoot)
|
|
828
|
+
? [codexCharterSource(hqRoot)]
|
|
829
|
+
: [codexCharterSource(hqRoot), codexAdapterPath(hqRoot)];
|
|
830
|
+
for (const p of required) {
|
|
796
831
|
if (!fs.existsSync(p))
|
|
797
832
|
throw new Error(`${hqRoot} is not an HQ checkout (missing ${p})`);
|
|
798
833
|
}
|
|
799
834
|
}
|
|
800
|
-
function hooksInstallFormat(hqRoot, target) {
|
|
835
|
+
function hooksInstallFormat(hqRoot, target, platform = process.platform) {
|
|
801
836
|
return {
|
|
802
837
|
...jsonFormat,
|
|
803
838
|
emptyDoc: () => ({}),
|
|
804
839
|
assertEntry(doc) {
|
|
805
|
-
if (!hasAllCodexHooks(doc, hqRoot, target))
|
|
840
|
+
if (!hasAllCodexHooks(doc, hqRoot, target, platform))
|
|
806
841
|
throw new Error('HQ Codex hooks not present after write');
|
|
807
842
|
},
|
|
808
843
|
};
|
|
@@ -850,10 +885,11 @@ export function installGlobalCodex(opts) {
|
|
|
850
885
|
}
|
|
851
886
|
const skills = planSkills(hqRoot, t);
|
|
852
887
|
const companySkillLinksToRemove = [...new Set(cleanupRoots.flatMap((root) => hqCompanySkillLinksForRoot(t.skillsDir, root)))];
|
|
888
|
+
const platform = opts.platform ?? process.platform;
|
|
853
889
|
const hooksOld = readOrNull(t.hooksJson);
|
|
854
890
|
const hooksDoc = readConfigDoc(t.hooksJson, jsonFormat).doc;
|
|
855
|
-
const hookTarget =
|
|
856
|
-
const hooksNext = addCodexHooks(hooksDoc, hqRoot, hookTarget);
|
|
891
|
+
const { target: hookTarget, refusedCandidate } = resolveInstallHookTarget(hqRoot, home, opts.daemonInstalled, env, 'codex', platform);
|
|
892
|
+
const hooksNext = addCodexHooks(hooksDoc, hqRoot, hookTarget, platform);
|
|
857
893
|
const tomlOld = readOrNull(t.configToml);
|
|
858
894
|
const tomlDoc = readConfigDoc(t.configToml, codexConfigFormat).doc;
|
|
859
895
|
const codexServers = tomlDoc.value.mcp_servers;
|
|
@@ -903,6 +939,7 @@ export function installGlobalCodex(opts) {
|
|
|
903
939
|
log(lineDiff(codexConfigFormat.serialize(tomlDoc), codexConfigFormat.serialize(tomlNext)));
|
|
904
940
|
return touched;
|
|
905
941
|
}
|
|
942
|
+
ensurePortableEngineOrThrow(hqRoot, home, hookTarget, env, 'codex', platform, refusedCandidate);
|
|
906
943
|
// Skill links go first so a link failure leaves no pointer or AGENTS.md
|
|
907
944
|
// block behind (see installGlobalClaude).
|
|
908
945
|
const skillsDirExisted = fs.existsSync(t.skillsDir);
|
|
@@ -945,8 +982,8 @@ export function installGlobalCodex(opts) {
|
|
|
945
982
|
writeConfigAtomic({
|
|
946
983
|
target: t.hooksJson,
|
|
947
984
|
pack: HQ_ANYWHERE_PACK,
|
|
948
|
-
format: hooksInstallFormat(hqRoot, hookTarget),
|
|
949
|
-
merge: (doc) => addCodexHooks(doc, hqRoot, hookTarget),
|
|
985
|
+
format: hooksInstallFormat(hqRoot, hookTarget, platform),
|
|
986
|
+
merge: (doc) => addCodexHooks(doc, hqRoot, hookTarget, platform),
|
|
950
987
|
assertName: 'hooks',
|
|
951
988
|
env: { home },
|
|
952
989
|
});
|
|
@@ -986,7 +1023,7 @@ export function installGlobalCodex(opts) {
|
|
|
986
1023
|
log(` skills linked: ${skills.link.length} new, ${skills.already.length} already present, ${skills.skipped.length} skipped`);
|
|
987
1024
|
reportSkillCopies(linkKinds, log);
|
|
988
1025
|
reportSkippedSkills(skills, log, false);
|
|
989
|
-
log(` hooks: ${typeof hookTarget === 'object' ? ('coreNext' in hookTarget ? hookTarget.coreNext : hookTarget.engine) : hookTarget === 'shim' ? shimPath(hqRoot) : codexAdapterPath(hqRoot)} registered in ${t.hooksJson}`);
|
|
1026
|
+
log(` hooks: ${typeof hookTarget === 'object' ? ('coreNext' in hookTarget ? hookTarget.coreNext : hookTarget.engine) : hookTarget === 'portable' ? 'hq-hook (portable)' : hookTarget === 'shim' ? shimPath(hqRoot) : codexAdapterPath(hqRoot)} registered in ${t.hooksJson}`);
|
|
990
1027
|
log(` MCP: "${HQ_MCP_SERVER_NAME}" registered in ${t.configToml}`);
|
|
991
1028
|
return touched;
|
|
992
1029
|
}
|
|
@@ -46,7 +46,7 @@ function decideOwner(env, home, now, platform) {
|
|
|
46
46
|
if (platform === "win32")
|
|
47
47
|
return { owner: "legacy", reason: "windows: machine checks need /bin/bash" };
|
|
48
48
|
if (!machineChecksScheduleOn(env, home))
|
|
49
|
-
return { owner: "legacy", reason: "core.next is off
|
|
49
|
+
return { owner: "legacy", reason: "core.next is off" };
|
|
50
50
|
const sessionRoot = env.HQ_ROOT?.trim();
|
|
51
51
|
let daemonRoot;
|
|
52
52
|
try {
|
|
@@ -155,20 +155,12 @@ export declare const MACHINE_CHECKS_INTERVAL_MS: number;
|
|
|
155
155
|
export declare const MACHINE_CHECKS_MIN_INTERVAL_MS: number;
|
|
156
156
|
/** Use the same offline flag decision as hook registration. */
|
|
157
157
|
export declare const machineChecksCoreNextOn: typeof coreNextEnabled;
|
|
158
|
-
/**
|
|
159
|
-
* A switch that sends this machine back to the old hook core is set:
|
|
160
|
-
* HQ_CORE_NEXT is off, 0, false or no; HQ_HOOK_ENGINE is off (both trimmed,
|
|
161
|
-
* any ASCII case); or `<home>/.hq/state/core-next.off` or
|
|
162
|
-
* `<home>/.hq/hook-engine.off` exists (any file type, a link counts). These
|
|
163
|
-
* are the switches the hook engine checks.
|
|
164
|
-
*/
|
|
165
|
-
export declare function machineChecksKillSwitchSet(env: NodeJS.ProcessEnv, home: string): boolean;
|
|
166
158
|
/**
|
|
167
159
|
* The daemon's schedule runs when the new hook core (`core.next`) is on for
|
|
168
|
-
* this machine
|
|
169
|
-
*
|
|
160
|
+
* this machine, so the checks leave the hook path when the machine moves to
|
|
161
|
+
* the new core and nothing runs twice.
|
|
170
162
|
*/
|
|
171
|
-
export declare function machineChecksScheduleOn(env: NodeJS.ProcessEnv,
|
|
163
|
+
export declare function machineChecksScheduleOn(env: NodeJS.ProcessEnv, _home: string): boolean;
|
|
172
164
|
export interface MachineCheckScheduleOptions {
|
|
173
165
|
env: NodeJS.ProcessEnv;
|
|
174
166
|
/** The home folder that holds the kill-switch files. */
|
|
@@ -37,7 +37,6 @@ import { createHash } from "node:crypto";
|
|
|
37
37
|
import * as fs from "node:fs";
|
|
38
38
|
import * as path from "node:path";
|
|
39
39
|
import { coreNextEnabled } from "../../utils/core-next-flag.js";
|
|
40
|
-
import { coreNextKillReason } from "../../utils/core-next-kill.js";
|
|
41
40
|
import { isExcludedWindowsBash, resolveWindowsBash } from "../../utils/windows-bash.js";
|
|
42
41
|
import { anyNativeSessionStartRegistered } from "./machine-check-registration.js";
|
|
43
42
|
import { nativeNoticeLedgerUsable, nativeNoticeShownFingerprints } from "./native-notice-ledger.js";
|
|
@@ -428,23 +427,13 @@ export const MACHINE_CHECKS_INTERVAL_MS = 60 * 60_000;
|
|
|
428
427
|
export const MACHINE_CHECKS_MIN_INTERVAL_MS = 15 * 60_000;
|
|
429
428
|
/** Use the same offline flag decision as hook registration. */
|
|
430
429
|
export const machineChecksCoreNextOn = coreNextEnabled;
|
|
431
|
-
/**
|
|
432
|
-
* A switch that sends this machine back to the old hook core is set:
|
|
433
|
-
* HQ_CORE_NEXT is off, 0, false or no; HQ_HOOK_ENGINE is off (both trimmed,
|
|
434
|
-
* any ASCII case); or `<home>/.hq/state/core-next.off` or
|
|
435
|
-
* `<home>/.hq/hook-engine.off` exists (any file type, a link counts). These
|
|
436
|
-
* are the switches the hook engine checks.
|
|
437
|
-
*/
|
|
438
|
-
export function machineChecksKillSwitchSet(env, home) {
|
|
439
|
-
return coreNextKillReason(home, env) !== null;
|
|
440
|
-
}
|
|
441
430
|
/**
|
|
442
431
|
* The daemon's schedule runs when the new hook core (`core.next`) is on for
|
|
443
|
-
* this machine
|
|
444
|
-
*
|
|
432
|
+
* this machine, so the checks leave the hook path when the machine moves to
|
|
433
|
+
* the new core and nothing runs twice.
|
|
445
434
|
*/
|
|
446
|
-
export function machineChecksScheduleOn(env,
|
|
447
|
-
return
|
|
435
|
+
export function machineChecksScheduleOn(env, _home) {
|
|
436
|
+
return machineChecksCoreNextOn(env);
|
|
448
437
|
}
|
|
449
438
|
/**
|
|
450
439
|
* The checks to commit in this batch: each whose last result (the results
|
package/dist/lib/daemon/run.js
CHANGED
|
@@ -48,6 +48,7 @@ import { createDaemonSharedFlagReads, hqdListenerFlagGate } from "./shared-flag-
|
|
|
48
48
|
import { createDaemonKillSwitchMonitors } from "./timed-flag-monitors.js";
|
|
49
49
|
import { MACHINE_CHECKS_INTERVAL_MS, MACHINE_CHECKS_MIN_INTERVAL_MS, MACHINE_CHECKS_RESULT_FILE, readMachineCheckResults, startMachineCheckSchedule, } from "./machine-checks.js";
|
|
50
50
|
import { HOOK_ENGINE_ROLLUP_STATE_FILE, hookEngineRollupLogLine, runHookEngineRollup, } from "../../utils/hook-engine-rollup.js";
|
|
51
|
+
import { HOOK_ENGINE_CRASH_STATE_FILE, runHookEngineCrashUpload, startHookEngineCrashSchedule, } from "../../utils/hook-engine-crash.js";
|
|
51
52
|
import { createLanesReconcileWatcher } from "./lanes-reconcile-watcher.js";
|
|
52
53
|
import { createLanesReconcileStatus, withLanesReconcileUnit } from "./lanes-reconcile-status.js";
|
|
53
54
|
import { findLegacyUnits, legacyMeshUnitsToRetire, legacyOwnerLookup, } from "./legacy.js";
|
|
@@ -1310,6 +1311,16 @@ export async function runDaemon(opts) {
|
|
|
1310
1311
|
log(line.level, line.message);
|
|
1311
1312
|
},
|
|
1312
1313
|
});
|
|
1314
|
+
// hq-hook crash lines go out within minutes, not with the daily rollup
|
|
1315
|
+
// (decision 3.1); same client, consent and HQ_TELEMETRY opt-out.
|
|
1316
|
+
const hookEngineCrashes = startHookEngineCrashSchedule({
|
|
1317
|
+
log,
|
|
1318
|
+
run: () => runHookEngineCrashUpload({
|
|
1319
|
+
home,
|
|
1320
|
+
env,
|
|
1321
|
+
stateFile: path.join(paths.root, HOOK_ENGINE_CRASH_STATE_FILE),
|
|
1322
|
+
}),
|
|
1323
|
+
});
|
|
1313
1324
|
let laneReconcileWatcher = null;
|
|
1314
1325
|
let laneReconcileWatcherRoot = null;
|
|
1315
1326
|
let laneReconcileWatchFailedRoot = null;
|
|
@@ -1425,6 +1436,7 @@ export async function runDaemon(opts) {
|
|
|
1425
1436
|
laneReconcileWatcherRoot = null;
|
|
1426
1437
|
killSwitches.close();
|
|
1427
1438
|
machineChecks.close();
|
|
1439
|
+
hookEngineCrashes.close();
|
|
1428
1440
|
flagSnapshots.close();
|
|
1429
1441
|
mergeSections.close();
|
|
1430
1442
|
stateWriter.close();
|
|
@@ -55,13 +55,15 @@ export interface CodexWiringOptions {
|
|
|
55
55
|
}
|
|
56
56
|
/** What {@link detectCodexAdapter} learned about `.codex/config.toml`. */
|
|
57
57
|
export interface CodexAdapterDetection {
|
|
58
|
-
/** True when at least one config.toml hook command routes to the adapter. */
|
|
58
|
+
/** True when at least one config.toml hook command routes to the adapter or native hq-hook. */
|
|
59
59
|
detected: boolean;
|
|
60
|
+
/** Whether `.codex/config.toml` routes via the legacy bash adapter or native `hq-hook`. */
|
|
61
|
+
mode?: "adapter" | "native";
|
|
60
62
|
/** Whether `.codex/config.toml` exists and was readable. */
|
|
61
63
|
configPresent: boolean;
|
|
62
64
|
/** TOML parse failure, when the file exists but could not be parsed. */
|
|
63
65
|
configParseError: string | null;
|
|
64
|
-
/** Events whose config.toml command references the adapter script. */
|
|
66
|
+
/** Events whose config.toml command references the adapter script or native hq-hook. */
|
|
65
67
|
wiredEvents: string[];
|
|
66
68
|
}
|
|
67
69
|
/**
|