@indigoai-us/hq-cli 5.345.217 → 5.345.218
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 +27 -0
- package/README.md +1 -1
- package/assets/bot-workers/setup/skills/add-a-pack.md +3 -3
- package/assets/scaffold/core/scripts/hq-session.sh +4 -0
- package/dist/commands/cloud.d.ts +1 -1
- package/dist/commands/cloud.js +1 -1
- package/dist/commands/core-hq-session-native.js +3 -0
- package/dist/commands/install-global.js +1 -1
- package/dist/commands/members.js +1 -1
- package/dist/commands/pack-start-bot.d.ts +1 -1
- package/dist/commands/pack-start-bot.js +2 -2
- package/dist/commands/pkg-update.js +1 -1
- package/dist/commands/sync-narrow.js +1 -1
- package/dist/commands/team-sync.js +1 -1
- package/dist/data/command-states.json +8 -1
- package/dist/lib/billing/usage-cost.js +5 -2
- package/dist/lib/bot/pack-link.d.ts +2 -2
- package/dist/lib/bot/pack-link.js +2 -2
- package/dist/lib/daemon/hook-env.d.ts +32 -0
- package/dist/lib/daemon/hook-env.js +51 -0
- package/dist/lib/daemon/ops/policy.js +5 -3
- package/dist/lib/daemon/run.js +7 -1
- package/dist/lib/doctor/checks/host-core.d.ts +2 -0
- package/dist/lib/doctor/checks/host-core.js +78 -10
- package/dist/lib/doctor/checks/sync-runtime.js +3 -3
- package/dist/lib/environment/credential-shapes.d.ts +61 -0
- package/dist/lib/environment/credential-shapes.js +333 -0
- package/dist/lib/environment/profile.js +4 -16
- package/dist/lib/hook-engine/coverage.d.ts +13 -0
- package/dist/lib/hook-engine/coverage.js +124 -0
- package/dist/lib/hook-engine/reconcile.js +294 -114
- package/dist/lib/hook-engine/registration.d.ts +10 -3
- package/dist/lib/hook-engine/registration.js +52 -16
- package/dist/lib/install/claude-targets.js +28 -15
- package/dist/lib/install/codex-pack-contributions.js +1 -1
- package/dist/lib/install/codex-targets.js +24 -11
- package/dist/lib/install/hook-target.d.ts +2 -2
- package/dist/lib/install/hook-target.js +7 -5
- package/dist/lib/packages/setup-block.d.ts +2 -2
- package/dist/lib/packages/setup-block.js +2 -2
- package/dist/lib/packages/start-bot.d.ts +1 -1
- package/dist/lib/packages/start-bot.js +1 -1
- package/dist/main.js +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/utils/callback-port-busy.d.ts +1 -1
- package/dist/utils/callback-port-busy.js +4 -4
- package/dist/utils/hook-trust.js +4 -1
- package/dist/utils/host-registration.d.ts +57 -4
- package/dist/utils/host-registration.js +140 -13
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,33 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [5.345.218] — 2026-11-14
|
|
6
|
+
|
|
7
|
+
- `hq-session add company <slug>` with a slug that has no folder now says which folder it looked for (`companies/<slug>/`, with the full path) and what to do next: run `ls companies/` and pass the exact folder name, or create the company with `/newcompany`. It used to say the slug "must use the exact real directory name". Follow-up for feedback ec3775c2, finding 2 (finding 1, demote after retire, was fixed in #2621).
|
|
8
|
+
|
|
9
|
+
- Simplified equivalent policy-selection and session-scope conditions for Clippy 1.95 without changing their behavior or lint settings.
|
|
10
|
+
- `hq env validate` no longer slows down on long text: the check for credential-shaped strings now applies the shared secret patterns to bounded windows of each string (a 320 KB note took 29 s; a 1 MB note now validates in under half a second). It rejects everything those patterns reject, except three kinds of ordinary text that are now accepted: a sentence that names the Slack token prefix, an `Authorization` header followed by a secret's NAME in upper snake case, and a host name that starts with `sk-` and ends in a known suffix (in notes or in aliases). These exemptions fail closed, so some ordinary text is still rejected. A string that holds a private-key header line is always rejected; describe the key type in words instead. A URL with an inline password (`scheme://user:password@host`, including an empty user name) is now rejected.
|
|
11
|
+
- Fixed an intermittent MCP worker test failure by publishing its completed capture file atomically.
|
|
12
|
+
- The seven staff commands are now marked as being retired in the command
|
|
13
|
+
table: `hq staff reset-test-account`, `hq staff test-account add`,
|
|
14
|
+
`hq staff test-account remove`, `hq staff test-account list`,
|
|
15
|
+
`hq staff listings queue`, `hq staff listings approve` and
|
|
16
|
+
`hq staff listings reject`. They only ever worked for an HQ staff sign-in.
|
|
17
|
+
The retiring gate is switched off, so nothing changes: each one runs as
|
|
18
|
+
before, prints no notice, and is still listed by `hq staff --help`. The mark
|
|
19
|
+
names the staff-only hq-staff script outside the public CLI as the
|
|
20
|
+
replacement, for when the gate is switched back on.
|
|
21
|
+
- When the enforcement gate's state folder, or a `workspace/` or `workspace/orchestrator/` above it, can be written by group or other (as a clone under umask 0002 leaves them), the gate still reads its gate facts there, so a call gated on a missing fact is blocked as before, and because a fact can no longer be recorded there it stays blocked until the folder is fixed. The required skills and briefs a prompt sets, and the receipts a tool result records, cannot be kept between events there, so the gate denies outbound calls natively (exit 2), on both `hq-hook run` and the bridged ports.
|
|
22
|
+
- This deny covers every outbound call the gate checks, including when no policy sets a required skill or brief: on such a tree `hq dm`, Slack, `git push` and other outbound calls are refused until the folder is fixed. Each denied call prints one stderr line that names the folder or folders, escaped, and gives the fix (`chmod go-w` on them). The native path also names such folders with the fix in one stderr line per session.
|
|
23
|
+
- This replaces what the earlier `hq-hook run` policy-injection entry says about such folders: the native path still names them with the fix, but it no longer allows every call over them, and the outbound deny above applies.
|
|
24
|
+
- Match the jq on PATH when the native policy gate reports a jq index error: the wording is read from jq's own error instead of its version number, since Ubuntu 26.04's jq 1.8.1 keeps the 1.7 wording.
|
|
25
|
+
- `hq-hook run --host <host> <Event>` now injects policies natively through the `policy-injection` evaluator, the only policy injector on that path; it starts no shell hook, awk or Node program. Context goes out only on events whose context the host passes to the model (Claude Code and Codex: SessionStart, UserPromptSubmit, PreToolUse, PostToolUse; Grok Build: PostToolUse; fleet runtimes: session start and pre-LLM call). On other events the reminder is held and returned with the next delivered event, and a policy is recorded as shown only once its text was returned. Policy text has the chain's first context priority. The enforcement gate runs with its real state on this path and gives the same blocks and context as the bridged port. No host registration calls `hq-hook run` yet.
|
|
26
|
+
- The policy injector's state files (session ledgers and their locks, held reminders, the enforcement list, emit statistics, the scope flag cache) and the enforcement gate's state (`workspace/orchestrator/policy-enforcement`: the session state, policy list, pass stamp and lock; and its gate facts, proofs and override tokens under `workspace/orchestrator/hook-state`) now go through the shared store in `crates/hq-hook/src/host/store.rs`: no link is followed, files must be regular with one link and owned by the account, folders must be owned by the account with no group or other write bit, and deletes and renames run inside the checked folder handle. This also applies to the existing `inject-policy-on-trigger` and `policy-enforcement-gate` ports that `master-hook.sh` can bridge, and closes the write through a link planted at the gate's state folder that those ports could make on main. A gate state path the store refuses (a link, a second name, a FIFO, another account's path) denies the call natively (exit 2) with one stderr line naming it, on every call: the gate never allows because it could not read its state. A state folder or file that group or other can write (for example one made under umask 0002) is never written: nothing is recorded there and reminders may repeat, but the enforcement gate still reads its state and facts there and blocks a missing required fact as before. The native path names such folders, escaped, with the fix in words in one stderr line per session, and never blocks a call over it. On Windows and other non-Unix systems the store is off until US-022: both ports deny every call, before any hand-back case, with one stderr line naming the hook-engine-port flag to turn off and never hand a call back to bash, and the `hq-hook run` policy evaluator refuses UserPromptSubmit and PreToolUse with one line. Windows stays on the shell hooks.
|
|
27
|
+
- Fix `policy.check` denying every company path with "This call has an invalid agent_id" when the daemon's environment held hook fields from another call. The daemon no longer passes any `HQ_HOOK_*` variable to the hook scripts it runs, and `hq daemon run` drops them from its own environment at startup.
|
|
28
|
+
- Require approval before editing replay evidence in hq-cli checkouts, worktrees, or the local recorder store.
|
|
29
|
+
- Fixed: for people with the `core.next` flag on, `hq reindex` replaced the HQ end-of-turn (Stop) hook with the new hook core, although the new core does only part of that event. Several end-of-turn hooks stopped running, among them the lanes monitor gate, linked-session message delivery, pattern capture, the autosave sweep, and the share and after-turn suggestions. Switching back with `~/.hq/state/core-next.off`, `HQ_CORE_NEXT=off`, `HQ_FLAG_CORE_NEXT=false` or the flag turned off did not undo it. Now an event moves to the new core on Claude Code, Codex or Grok Build only when the new core does every hook the old dispatcher runs for that event in your HQ folder. The hook list is read from the folder and compared with what the installed engine reports. Every other event, including Stop today, stays on the old dispatcher with no new-core entry, so no hook runs twice. Switching off removes the new-core entries and restores the registrations exactly as they were, including a Stop entry that an HQ settings update had moved into `.claude/settings.local.json`; the next `hq reindex` repairs a folder that was already switched. `hq reindex` reports a `.claude/settings.local.json` it cannot parse or that is a link instead of changing it. `hq doctor` now fails a new-core entry that runs beside the old one, one whose event has a hook the new core does not do (for example a hook added after the switch), and one still registered while the kill switch is on. It also says that `HQ_CORE_NEXT` set only in an app's environment is read by the hook engine and not by `hq reindex`.
|
|
30
|
+
- Fixed CLI guidance and generated pack-install commands to use the owning sign-in, daemon sync, and content-pack commands. Existing duplicate compatibility and retirement behavior is unchanged.
|
|
31
|
+
|
|
5
32
|
## [5.345.217] — 2026-11-14
|
|
6
33
|
|
|
7
34
|
- Windows Grok ACP bots (Grok 1.0.77) no longer split each reply into one-word messages, fail permission and terminal RPC, drop resumed chats that omit `sessionId`, or die on `--no-subagents` (`feedback_0af4d198`). MCP OAuth crashes, Windows daemon self-restart, and cross-machine bot credential theft are unchanged.
|
package/README.md
CHANGED
|
@@ -213,7 +213,7 @@ it is added to an agent's context.
|
|
|
213
213
|
|
|
214
214
|
### Sign in without opening a browser
|
|
215
215
|
|
|
216
|
-
Run `hq login --no-browser`
|
|
216
|
+
Run `hq login --no-browser` to print a sign-in
|
|
217
217
|
URL and wait for completion. Open the URL in your browser. HQ also uses this
|
|
218
218
|
mode in CI and on Linux without DISPLAY or WAYLAND_DISPLAY. Existing cached
|
|
219
219
|
sessions are reused.
|
|
@@ -6,7 +6,7 @@ description: Recognize a content pack the person pastes or names (a hqforwork.co
|
|
|
6
6
|
# Adding a pack from the chat
|
|
7
7
|
|
|
8
8
|
A pack is a bundle of workers, knowledge and a setup bot that HQ installs with
|
|
9
|
-
`hq
|
|
9
|
+
`hq install`. People arrive with one in three ways: they paste a link
|
|
10
10
|
from a pack page, they type the pack's name, or they drop a folder path. You add
|
|
11
11
|
it without them leaving this conversation, and you end by introducing the bot
|
|
12
12
|
the pack brings. This skill only adds that; nothing else about how you run setup
|
|
@@ -38,7 +38,7 @@ ordinary conversation ("my co-founder is joining" is not a pack).
|
|
|
38
38
|
|
|
39
39
|
### The catalog
|
|
40
40
|
|
|
41
|
-
The catalog is what `hq
|
|
41
|
+
The catalog is what `hq packs list` prints under "Available (curated)": each
|
|
42
42
|
line is an install source like `github:indigoai-us/hq-packages#packages/hq-pack-design-styles`
|
|
43
43
|
with a description. The slug is the last segment without `hq-pack-`; the display
|
|
44
44
|
name is the slug in title case (`design-styles` is "Design Styles") unless the
|
|
@@ -72,7 +72,7 @@ conversation unless they bring it up.
|
|
|
72
72
|
|
|
73
73
|
Run, from the HQ root:
|
|
74
74
|
|
|
75
|
-
hq
|
|
75
|
+
hq install {slug-or-path} --start-bot
|
|
76
76
|
|
|
77
77
|
`{slug-or-path}` is the slug (`sample-kit`), or the local path when the message
|
|
78
78
|
carried one. Quote a path with spaces. Wait for it to finish; it can take a
|
|
@@ -198,6 +198,10 @@ validate_company_slug() {
|
|
|
198
198
|
local slug="${1:-}"
|
|
199
199
|
case "$slug" in ''|*[!a-zA-Z0-9_-]*) echo "hq-session: invalid company_slug: '$slug' (allowed characters: A-Z a-z 0-9 - _)" >&2; return 1 ;; esac
|
|
200
200
|
[ "$slug" != personal ] || { echo "hq-session: personal cannot be combined with a company" >&2; return 1; }
|
|
201
|
+
if [ ! -e "$REPO_ROOT/companies/$slug" ] && [ ! -L "$REPO_ROOT/companies/$slug" ] && ! hq_session_has_case_alias "$REPO_ROOT" "$slug"; then
|
|
202
|
+
echo "hq-session: no company directory at companies/$slug/ (looked for $REPO_ROOT/companies/$slug/). Run ls companies/ and pass the exact directory name, or create the company first with /newcompany." >&2
|
|
203
|
+
return 1
|
|
204
|
+
fi
|
|
201
205
|
if [ -L "$REPO_ROOT/companies/$slug" ] || ! hq_session_has_exact_company_dir "$REPO_ROOT" "$slug" || hq_session_has_case_alias "$REPO_ROOT" "$slug"; then
|
|
202
206
|
echo "hq-session: company_slug must use the exact real directory name: '$slug'" >&2
|
|
203
207
|
return 1
|
package/dist/commands/cloud.d.ts
CHANGED
|
@@ -60,7 +60,7 @@ export declare class SyncSessionExpiredError extends Error {
|
|
|
60
60
|
constructor(kind: "reauth" | "unavailable", reason?: string | undefined);
|
|
61
61
|
}
|
|
62
62
|
/** Shown when the vault rejected the session even after a forced refresh. */
|
|
63
|
-
export declare const SYNC_SESSION_REJECTED_MESSAGE = "The HQ server rejected your session even after it was refreshed, so the saved sign-in is no longer accepted. `hq
|
|
63
|
+
export declare const SYNC_SESSION_REJECTED_MESSAGE = "The HQ server rejected your session even after it was refreshed, so the saved sign-in is no longer accepted. `hq whoami` only checks the saved expiry, not the server. Run `hq login`, then rerun the sync.";
|
|
64
64
|
/** Reason text when token acquisition does not settle within the bound. */
|
|
65
65
|
export declare const SYNC_TOKEN_TIMEOUT_REASON = "timed out waiting for the sign-in service";
|
|
66
66
|
/** Longest a single token acquisition or refresh may take before the sync fails. */
|
package/dist/commands/cloud.js
CHANGED
|
@@ -91,7 +91,7 @@ export class SyncSessionExpiredError extends Error {
|
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
/** Shown when the vault rejected the session even after a forced refresh. */
|
|
94
|
-
export const SYNC_SESSION_REJECTED_MESSAGE = "The HQ server rejected your session even after it was refreshed, so the saved sign-in is no longer accepted. `hq
|
|
94
|
+
export const SYNC_SESSION_REJECTED_MESSAGE = "The HQ server rejected your session even after it was refreshed, so the saved sign-in is no longer accepted. `hq whoami` only checks the saved expiry, not the server. Run `hq login`, then rerun the sync.";
|
|
95
95
|
/** Reason text when token acquisition does not settle within the bound. */
|
|
96
96
|
export const SYNC_TOKEN_TIMEOUT_REASON = "timed out waiting for the sign-in service";
|
|
97
97
|
/** Longest a single token acquisition or refresh may take before the sync fails. */
|
|
@@ -642,6 +642,9 @@ export function executeHqSession(argv, context, overrides = {}) {
|
|
|
642
642
|
return { code: 1, stdout: "", stderr: `hq-session: invalid company_slug: '${slug}' (allowed characters: A-Z a-z 0-9 - _)\n` };
|
|
643
643
|
}
|
|
644
644
|
const dir = path.join(root, "companies", slug);
|
|
645
|
+
if (subcommand === "add" && slug !== "personal" && !deps.exists(dir) && !deps.isSymlink(dir) && !hasCompanyCaseAlias(root, slug, deps)) {
|
|
646
|
+
return { code: 1, stdout: "", stderr: `hq-session: no company directory at companies/${slug}/ (looked for ${dir}/). Run ls companies/ and pass the exact directory name, or create the company first with /newcompany.\n` };
|
|
647
|
+
}
|
|
645
648
|
if (subcommand === "add" && (slug === "personal" || !isRegisteredCompany(root, slug, deps) || deps.isSymlink(dir) || hasCompanyCaseAlias(root, slug, deps) || !exactCompanyDir(root, slug, deps))) {
|
|
646
649
|
return { code: 1, stdout: "", stderr: `hq-session: company_slug must use the exact real directory name: '${slug}'\n` };
|
|
647
650
|
}
|
|
@@ -850,7 +850,7 @@ export function installGlobalCodex(opts) {
|
|
|
850
850
|
const companySkillLinksToRemove = [...new Set(cleanupRoots.flatMap((root) => hqCompanySkillLinksForRoot(t.skillsDir, root)))];
|
|
851
851
|
const hooksOld = readOrNull(t.hooksJson);
|
|
852
852
|
const hooksDoc = readConfigDoc(t.hooksJson, jsonFormat).doc;
|
|
853
|
-
const hookTarget = hookTargetFor(hqRoot, home, opts.daemonInstalled, env);
|
|
853
|
+
const hookTarget = hookTargetFor(hqRoot, home, opts.daemonInstalled, env, 'codex');
|
|
854
854
|
const hooksNext = addCodexHooks(hooksDoc, hqRoot, hookTarget);
|
|
855
855
|
const tomlOld = readOrNull(t.configToml);
|
|
856
856
|
const tomlDoc = readConfigDoc(t.configToml, codexConfigFormat).doc;
|
package/dist/commands/members.js
CHANGED
|
@@ -579,7 +579,7 @@ export function registerMembersCommand(program) {
|
|
|
579
579
|
// grant to give them. What they SEE locally is governed by their sync
|
|
580
580
|
// mode, not by access.
|
|
581
581
|
console.log(chalk.dim(`${role === "owner" ? "Owners" : "Admins"} automatically have full read and write access to all of this company's context — no separate context grant is needed.\n` +
|
|
582
|
-
`What they actually see synced to their machine is governed by their sync mode (\`hq sync mode
|
|
582
|
+
`What they actually see synced to their machine is governed by their sync mode (\`hq daemon sync mode get <company>\`), not by access.`));
|
|
583
583
|
}
|
|
584
584
|
else if (role === "guest") {
|
|
585
585
|
console.log(chalk.dim(GUEST_COMPANY_WIDE_NOTE));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Production wiring for `hq
|
|
2
|
+
* Production wiring for `hq install --start-bot`: the bot lifecycle
|
|
3
3
|
* seams of lib/packages/start-bot.ts bound to the real `hq bot` internals
|
|
4
4
|
* (create, restart, intro) and the bot DM API. Loaded on demand by
|
|
5
5
|
* pkg-install.ts so an ordinary install never imports the bot machinery.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Production wiring for `hq
|
|
2
|
+
* Production wiring for `hq install --start-bot`: the bot lifecycle
|
|
3
3
|
* seams of lib/packages/start-bot.ts bound to the real `hq bot` internals
|
|
4
4
|
* (create, restart, intro) and the bot DM API. Loaded on demand by
|
|
5
5
|
* pkg-install.ts so an ordinary install never imports the bot machinery.
|
|
@@ -26,7 +26,7 @@ async function dmOwner(name, body) {
|
|
|
26
26
|
return;
|
|
27
27
|
}
|
|
28
28
|
const token = await ensureCognitoToken({ tokenSource: "person", interactive: false });
|
|
29
|
-
const owner = await resolveCallerPersonUid(token, undefined, { command: "hq
|
|
29
|
+
const owner = await resolveCallerPersonUid(token, undefined, { command: "hq install --start-bot" });
|
|
30
30
|
if (!owner)
|
|
31
31
|
throw new Error("your HQ login has no person entity yet");
|
|
32
32
|
await new BotApi({ token: async () => token }).sendDm({ toPersonUid: owner, body });
|
|
@@ -37,7 +37,7 @@ async function updatePackages(slug) {
|
|
|
37
37
|
const hqRoot = resolveDefaultHqRoot({ onMissing: 'throw' });
|
|
38
38
|
const entries = readRegistry(hqRoot);
|
|
39
39
|
if (entries.length === 0) {
|
|
40
|
-
console.log('No packages installed. Use "hq
|
|
40
|
+
console.log('No packages installed. Use "hq install <slug>" to install one.');
|
|
41
41
|
return;
|
|
42
42
|
}
|
|
43
43
|
const accessToken = await ensureCognitoToken();
|
|
@@ -94,7 +94,7 @@ export async function resolveNarrowTarget(input) {
|
|
|
94
94
|
throw new Error(`Refusing to narrow: membership for '${companySlug}' is currently ` +
|
|
95
95
|
`syncMode='${syncConfig.syncMode}'. The narrow ritual only runs on ` +
|
|
96
96
|
`syncMode='all' memberships (shared → shared is a no-op; ` +
|
|
97
|
-
`custom requires \`hq sync mode shared\` directly).`);
|
|
97
|
+
`custom requires \`hq daemon sync mode set ${companySlug} shared\` directly).`);
|
|
98
98
|
}
|
|
99
99
|
return {
|
|
100
100
|
membership,
|
|
@@ -361,7 +361,7 @@ export function registerTeamSyncCommand(program) {
|
|
|
361
361
|
.join(', ');
|
|
362
362
|
console.log(chalk.yellow(`Companies ${companyNames} are cloud-synced and do not have team.json. ` +
|
|
363
363
|
'hq team-sync only handles git team repositories with team.json.'));
|
|
364
|
-
console.log(chalk.dim('Use `hq sync pull --all` to sync company vault files and `hq sync status` to check
|
|
364
|
+
console.log(chalk.dim('Use `hq sync pull --all` to sync company vault files and `hq daemon sync status` to check the sync runner state.'));
|
|
365
365
|
}
|
|
366
366
|
if (discovery.nonCloudBackedCompanyNames.length > 0) {
|
|
367
367
|
const companyNames = discovery.nonCloudBackedCompanyNames
|
|
@@ -10,6 +10,13 @@
|
|
|
10
10
|
"report access": { "state": "retiring" },
|
|
11
11
|
"report discard-draft": { "state": "retiring" },
|
|
12
12
|
"report promote": { "state": "retiring" },
|
|
13
|
-
"report templates": { "state": "retiring" }
|
|
13
|
+
"report templates": { "state": "retiring" },
|
|
14
|
+
"staff listings approve": { "state": "retiring", "replacedBy": "the staff-only hq-staff script outside the public CLI" },
|
|
15
|
+
"staff listings queue": { "state": "retiring", "replacedBy": "the staff-only hq-staff script outside the public CLI" },
|
|
16
|
+
"staff listings reject": { "state": "retiring", "replacedBy": "the staff-only hq-staff script outside the public CLI" },
|
|
17
|
+
"staff reset-test-account": { "state": "retiring", "replacedBy": "the staff-only hq-staff script outside the public CLI" },
|
|
18
|
+
"staff test-account add": { "state": "retiring", "replacedBy": "the staff-only hq-staff script outside the public CLI" },
|
|
19
|
+
"staff test-account list": { "state": "retiring", "replacedBy": "the staff-only hq-staff script outside the public CLI" },
|
|
20
|
+
"staff test-account remove": { "state": "retiring", "replacedBy": "the staff-only hq-staff script outside the public CLI" }
|
|
14
21
|
}
|
|
15
22
|
}
|
|
@@ -353,8 +353,11 @@ export function excludeFoldersFix(scope) {
|
|
|
353
353
|
id: "exclude-folders",
|
|
354
354
|
title: "Stop syncing folders you do not need in the cloud",
|
|
355
355
|
detail: "Add the folders to .hqignore in your HQ folder so sync skips them, or limit what this company downloads with " +
|
|
356
|
-
"
|
|
357
|
-
|
|
356
|
+
(scope.kind === "company" ? `\`hq daemon sync mode set ${scope.companySlug} shared\`.` : "the company's sync settings.") +
|
|
357
|
+
" Files already in the cloud stay until you remove them; nothing is deleted.",
|
|
358
|
+
preview: scope.kind === "company"
|
|
359
|
+
? [`hq daemon sync mode get ${scope.companySlug}`, `hq storage status${companyFlag(scope)} --json`]
|
|
360
|
+
: ["hq daemon sync status"],
|
|
358
361
|
apply: ["(edit <HQ folder>/.hqignore: add one line per folder, for example `bigfolder/`)"],
|
|
359
362
|
savesUsdPerMonth: null,
|
|
360
363
|
};
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* "add the {Display Name}" a display name from the catalog
|
|
11
11
|
* ./packs/hq-pack-{slug}, ~/Downloads/hq-pack-{slug} a local pack folder
|
|
12
12
|
*
|
|
13
|
-
* The catalog is the curated list `hq
|
|
13
|
+
* The catalog is the curated list `hq packs list` prints (core.yaml
|
|
14
14
|
* `recommended_packages`, see readRecommendedPackages). A slug or display name
|
|
15
15
|
* that matches none of its entries is `unknown`, with the three closest
|
|
16
16
|
* catalog names to offer. Nothing here knows any particular pack.
|
|
@@ -34,7 +34,7 @@ export type PackReference = {
|
|
|
34
34
|
kind: PackReferenceKind;
|
|
35
35
|
slug: string;
|
|
36
36
|
displayName: string;
|
|
37
|
-
/** What to hand `hq
|
|
37
|
+
/** What to hand `hq install`: the slug, or the local path when the message carried one. */
|
|
38
38
|
installSource: string;
|
|
39
39
|
entry?: PackCatalogEntry;
|
|
40
40
|
} | {
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* "add the {Display Name}" a display name from the catalog
|
|
11
11
|
* ./packs/hq-pack-{slug}, ~/Downloads/hq-pack-{slug} a local pack folder
|
|
12
12
|
*
|
|
13
|
-
* The catalog is the curated list `hq
|
|
13
|
+
* The catalog is the curated list `hq packs list` prints (core.yaml
|
|
14
14
|
* `recommended_packages`, see readRecommendedPackages). A slug or display name
|
|
15
15
|
* that matches none of its entries is `unknown`, with the three closest
|
|
16
16
|
* catalog names to offer. Nothing here knows any particular pack.
|
|
@@ -148,6 +148,6 @@ export function packConfirmSuggestions(displayName) {
|
|
|
148
148
|
/** The exact command the setup bot runs after "Add the ...". */
|
|
149
149
|
export function packInstallCommand(installSource) {
|
|
150
150
|
const arg = /[\s"']/.test(installSource) ? JSON.stringify(installSource) : installSource;
|
|
151
|
-
return `hq
|
|
151
|
+
return `hq install ${arg} --start-bot`;
|
|
152
152
|
}
|
|
153
153
|
//# sourceMappingURL=pack-link.js.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HQ_HOOK_* belongs to one hook dispatch, never to the daemon.
|
|
3
|
+
*
|
|
4
|
+
* master-hook.sh exports the fields it parsed from a hook payload
|
|
5
|
+
* (HQ_HOOK_SESSION_ID, HQ_HOOK_AGENT_ID, HQ_HOOK_AGENT_TYPE, HQ_HOOK_CWD,
|
|
6
|
+
* HQ_HOOK_TOOL_NAME, HQ_HOOK_EVENT, HQ_HOOK_COMMAND, ...) so its child hooks can
|
|
7
|
+
* skip their own parse. A hook script that finds one of them set trusts it over
|
|
8
|
+
* the payload on stdin. The daemon runs hook scripts with a payload it builds
|
|
9
|
+
* itself, so any HQ_HOOK_* it holds describes some other call: a daemon started
|
|
10
|
+
* from inside a hook, or from a shell that exported one, would otherwise answer
|
|
11
|
+
* every check with that call's identity (a stale HQ_HOOK_AGENT_ID turns each
|
|
12
|
+
* main-thread check into "This call has an invalid agent_id").
|
|
13
|
+
*
|
|
14
|
+
* The whole prefix goes, tuning knobs included: the daemon's OS unit never
|
|
15
|
+
* carries any of them (its environment is an allowlist), so a hand-started
|
|
16
|
+
* daemon behaves the same as a managed one.
|
|
17
|
+
*/
|
|
18
|
+
/** The HQ_HOOK_* names set in `env`, sorted. Names only: values may be private. */
|
|
19
|
+
export declare function hookEnvNames(env: NodeJS.ProcessEnv): string[];
|
|
20
|
+
/** `env` without any HQ_HOOK_* name. Returns `env` itself when it has none. */
|
|
21
|
+
export declare function withoutHookEnv(env: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
|
|
22
|
+
/**
|
|
23
|
+
* The environment `hq daemon run` works with. HQ_HOOK_* is deleted from the
|
|
24
|
+
* live process environment, because hqd and the services read it directly, and
|
|
25
|
+
* left out of a caller-supplied one. `removed` names what was dropped, for the
|
|
26
|
+
* daemon log.
|
|
27
|
+
*/
|
|
28
|
+
export declare function daemonStartEnv(given: NodeJS.ProcessEnv | undefined, processEnv?: NodeJS.ProcessEnv): {
|
|
29
|
+
env: NodeJS.ProcessEnv;
|
|
30
|
+
removed: string[];
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=hook-env.d.ts.map
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HQ_HOOK_* belongs to one hook dispatch, never to the daemon.
|
|
3
|
+
*
|
|
4
|
+
* master-hook.sh exports the fields it parsed from a hook payload
|
|
5
|
+
* (HQ_HOOK_SESSION_ID, HQ_HOOK_AGENT_ID, HQ_HOOK_AGENT_TYPE, HQ_HOOK_CWD,
|
|
6
|
+
* HQ_HOOK_TOOL_NAME, HQ_HOOK_EVENT, HQ_HOOK_COMMAND, ...) so its child hooks can
|
|
7
|
+
* skip their own parse. A hook script that finds one of them set trusts it over
|
|
8
|
+
* the payload on stdin. The daemon runs hook scripts with a payload it builds
|
|
9
|
+
* itself, so any HQ_HOOK_* it holds describes some other call: a daemon started
|
|
10
|
+
* from inside a hook, or from a shell that exported one, would otherwise answer
|
|
11
|
+
* every check with that call's identity (a stale HQ_HOOK_AGENT_ID turns each
|
|
12
|
+
* main-thread check into "This call has an invalid agent_id").
|
|
13
|
+
*
|
|
14
|
+
* The whole prefix goes, tuning knobs included: the daemon's OS unit never
|
|
15
|
+
* carries any of them (its environment is an allowlist), so a hand-started
|
|
16
|
+
* daemon behaves the same as a managed one.
|
|
17
|
+
*/
|
|
18
|
+
const HOOK_ENV_NAME = /^HQ_HOOK_/i;
|
|
19
|
+
/** The HQ_HOOK_* names set in `env`, sorted. Names only: values may be private. */
|
|
20
|
+
export function hookEnvNames(env) {
|
|
21
|
+
return Object.keys(env)
|
|
22
|
+
.filter((key) => HOOK_ENV_NAME.test(key))
|
|
23
|
+
.sort();
|
|
24
|
+
}
|
|
25
|
+
/** `env` without any HQ_HOOK_* name. Returns `env` itself when it has none. */
|
|
26
|
+
export function withoutHookEnv(env) {
|
|
27
|
+
const names = hookEnvNames(env);
|
|
28
|
+
if (names.length === 0)
|
|
29
|
+
return env;
|
|
30
|
+
const clean = { ...env };
|
|
31
|
+
for (const name of names)
|
|
32
|
+
delete clean[name];
|
|
33
|
+
return clean;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The environment `hq daemon run` works with. HQ_HOOK_* is deleted from the
|
|
37
|
+
* live process environment, because hqd and the services read it directly, and
|
|
38
|
+
* left out of a caller-supplied one. `removed` names what was dropped, for the
|
|
39
|
+
* daemon log.
|
|
40
|
+
*/
|
|
41
|
+
export function daemonStartEnv(given, processEnv = process.env) {
|
|
42
|
+
const removed = new Set(hookEnvNames(processEnv));
|
|
43
|
+
for (const name of removed)
|
|
44
|
+
delete processEnv[name];
|
|
45
|
+
if (given === undefined || given === processEnv)
|
|
46
|
+
return { env: processEnv, removed: [...removed].sort() };
|
|
47
|
+
for (const name of hookEnvNames(given))
|
|
48
|
+
removed.add(name);
|
|
49
|
+
return { env: withoutHookEnv(given), removed: [...removed].sort() };
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=hook-env.js.map
|
|
@@ -21,6 +21,7 @@ import { spawn } from "node:child_process";
|
|
|
21
21
|
import * as fs from "node:fs";
|
|
22
22
|
import * as path from "node:path";
|
|
23
23
|
import { sessionMetaCompanies } from "../../core-utils/session-company.js";
|
|
24
|
+
import { withoutHookEnv } from "../hook-env.js";
|
|
24
25
|
export const SCOPE_AUTHORIZER = ".claude/hooks/mandatory-scope-authorizer.sh";
|
|
25
26
|
export const POLICY_TRIGGER = ".claude/hooks/inject-policy-on-trigger.sh";
|
|
26
27
|
const SLUG_RE = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
|
|
@@ -328,8 +329,11 @@ export async function policyCheck(args, deps) {
|
|
|
328
329
|
tool_input: args.input ?? {},
|
|
329
330
|
cwd: args.cwd ?? hqRoot,
|
|
330
331
|
});
|
|
332
|
+
// Identity reaches the hook scripts through the payload above and nowhere
|
|
333
|
+
// else. They trust HQ_HOOK_* over the payload, so nothing with that prefix
|
|
334
|
+
// may pass from the daemon's environment (see ../hook-env.ts).
|
|
331
335
|
const env = {
|
|
332
|
-
...(deps.env ?? process.env),
|
|
336
|
+
...withoutHookEnv(deps.env ?? process.env),
|
|
333
337
|
HQ_ROOT: hqRoot,
|
|
334
338
|
CLAUDE_PROJECT_DIR: hqRoot,
|
|
335
339
|
BASH_ENV: "/dev/null",
|
|
@@ -338,8 +342,6 @@ export async function policyCheck(args, deps) {
|
|
|
338
342
|
delete env.HQ_POLICY_COMPANY;
|
|
339
343
|
else
|
|
340
344
|
env.HQ_POLICY_COMPANY = args.company;
|
|
341
|
-
delete env.HQ_HOOK_SESSION_ID;
|
|
342
|
-
delete env.HQ_HOOK_TOOL_NAME;
|
|
343
345
|
const timeoutMs = deps.timeoutMs ?? 15_000;
|
|
344
346
|
const reasons = [];
|
|
345
347
|
let decision = "allow";
|
package/dist/lib/daemon/run.js
CHANGED
|
@@ -52,6 +52,7 @@ import { hqdSocketPath } from "./protocol.js";
|
|
|
52
52
|
import { startHqdServer, syncHqdEnabledMarker } from "./server.js";
|
|
53
53
|
import { startHqdRuntimeListener } from "./anywhere-listener.js";
|
|
54
54
|
import { heartbeatFile, startHeartbeat } from "./heartbeat.js";
|
|
55
|
+
import { daemonStartEnv } from "./hook-env.js";
|
|
55
56
|
import { createProtocolTail, ensureProtocolFifo, openProtocolWriter } from "./protocol-tail.js";
|
|
56
57
|
import { takeControlRequests } from "./requests.js";
|
|
57
58
|
import { currentHqCloud, currentHqCloudAfterLeaseRelease, hqCloudRunners, hqCloudVersionOlder } from "./hq-cloud.js";
|
|
@@ -652,7 +653,9 @@ export function withUserRuntimeDir(env, host) {
|
|
|
652
653
|
return host.exists(dir) ? { ...env, XDG_RUNTIME_DIR: dir } : env;
|
|
653
654
|
}
|
|
654
655
|
export async function runDaemon(opts) {
|
|
655
|
-
|
|
656
|
+
// Before anything reads the environment: hqd and every service inherit it.
|
|
657
|
+
const started = daemonStartEnv(opts.env);
|
|
658
|
+
const env = withUserRuntimeDir(started.env, {
|
|
656
659
|
platform: process.platform,
|
|
657
660
|
uid: process.getuid?.() ?? -1,
|
|
658
661
|
exists: fs.existsSync,
|
|
@@ -747,6 +750,9 @@ export async function runDaemon(opts) {
|
|
|
747
750
|
}
|
|
748
751
|
const hostNote = opts.host ? `, hosted by the ${opts.host} app` : "";
|
|
749
752
|
log("info", `starting hq daemon (pid ${process.pid}) as ${machineType} (${detected.detail})${hostNote}`);
|
|
753
|
+
if (started.removed.length > 0) {
|
|
754
|
+
log("warn", `started with hook fields in the environment; dropped them so policy checks use their own payload: ${started.removed.join(", ")}`);
|
|
755
|
+
}
|
|
750
756
|
try {
|
|
751
757
|
scheduleDaemonPlistRefresh({
|
|
752
758
|
platform,
|
|
@@ -8,6 +8,8 @@ export interface HostRegistrationFile {
|
|
|
8
8
|
host: 'claude' | 'codex' | 'grok';
|
|
9
9
|
scope: 'project' | 'user';
|
|
10
10
|
file: string;
|
|
11
|
+
/** A file the host merges over `file` (Claude Code's `.claude/settings.local.json`), read with it. */
|
|
12
|
+
overlay?: string;
|
|
11
13
|
}
|
|
12
14
|
export interface HostCoreOptions {
|
|
13
15
|
home?: string;
|
|
@@ -13,15 +13,16 @@ import * as path from 'node:path';
|
|
|
13
13
|
import { jsonFormat } from '../../../commands/mcp-registration.js';
|
|
14
14
|
import { CORE_NEXT_LINK, isCoreNextEntry, isNativeEntry } from '../../hook-engine/registration.js';
|
|
15
15
|
import { isAdapterEntry } from '../../install/codex-targets.js';
|
|
16
|
+
import { uncoveredHooks } from '../../hook-engine/coverage.js';
|
|
16
17
|
import { masterHookPath, shimPath } from '../../install/claude-targets.js';
|
|
17
|
-
import { CORE_NEXT_FLAG, CORE_NEXT_KILL_ENV, CORE_NEXT_KILL_FILE, ENGINE_KILL_ENV, ENGINE_KILL_FILE, REQUIRED_EVALUATORS, STABLE_LINK_NAME, coreNextEnabled, missingEvaluators, probeEngine, } from '../../../utils/host-registration.js';
|
|
18
|
+
import { CORE_NEXT_FLAG, CORE_NEXT_KILL_ENV, CORE_NEXT_KILL_FILE, ENGINE_KILL_ENV, ENGINE_KILL_FILE, REQUIRED_EVALUATORS, STABLE_LINK_NAME, coreNextEnabled, coreNextKillReason, missingEvaluators, probeEngine, } from '../../../utils/host-registration.js';
|
|
18
19
|
import { HOOKS_FAMILY_ID } from '../registry.js';
|
|
19
20
|
export const HOST_CORE_FAMILY_ID = 'host-core';
|
|
20
21
|
export const HOST_CORE_FAMILY_TITLE = 'Hook core per host';
|
|
21
22
|
/** The registration files `hq reindex` reconciles, per host. */
|
|
22
23
|
export function hostRegistrationFiles(root, home, env) {
|
|
23
24
|
return [
|
|
24
|
-
{ host: 'claude', scope: 'project', file: path.join(root, '.claude', 'settings.json') },
|
|
25
|
+
{ host: 'claude', scope: 'project', file: path.join(root, '.claude', 'settings.json'), overlay: path.join(root, '.claude', 'settings.local.json') },
|
|
25
26
|
{ host: 'claude', scope: 'user', file: path.join(env.CLAUDE_CONFIG_DIR || path.join(home, '.claude'), 'settings.json') },
|
|
26
27
|
{ host: 'codex', scope: 'project', file: path.join(root, '.codex', 'hooks.json') },
|
|
27
28
|
{ host: 'codex', scope: 'user', file: path.join(env.CODEX_HOME || path.join(home, '.codex'), 'hooks.json') },
|
|
@@ -102,6 +103,7 @@ export function hostCoreResults(root, options = {}) {
|
|
|
102
103
|
const platform = options.platform ?? process.platform;
|
|
103
104
|
const probe = options.probe ?? probeEngine;
|
|
104
105
|
const flagOn = coreNextEnabled(env);
|
|
106
|
+
const killedBy = coreNextKillReason(home, env);
|
|
105
107
|
const probed = new Map();
|
|
106
108
|
const capabilities = (engine) => {
|
|
107
109
|
let found = probed.get(engine);
|
|
@@ -135,9 +137,14 @@ export function hostCoreResults(root, options = {}) {
|
|
|
135
137
|
return { status: 'FAIL', reason: `the new core lacks ${missing.join(', ')}` };
|
|
136
138
|
return { status: 'PASS', reason: `the new core has ${REQUIRED_EVALUATORS[event].join(', ')}` };
|
|
137
139
|
};
|
|
138
|
-
|
|
140
|
+
/** Old-dispatcher hooks for `event` on `host` that the engine's report does not cover. */
|
|
141
|
+
const uncovered = (caps, host, event) => uncoveredHooks(root, host, event, caps.covers);
|
|
142
|
+
const listed = (hooks) => (hooks.length > 6 ? `${hooks.slice(0, 6).join(', ')} and ${hooks.length - 6} more` : hooks.join(', '));
|
|
143
|
+
const oldCore = (event, host) => {
|
|
139
144
|
if (!flagOn)
|
|
140
145
|
return { status: 'PASS', reason: `flag ${CORE_NEXT_FLAG} is off` };
|
|
146
|
+
if (killedBy)
|
|
147
|
+
return { status: 'PASS', reason: `the kill switch is on (${killedBy})` };
|
|
141
148
|
if (platform === 'win32')
|
|
142
149
|
return { status: 'PASS', reason: 'Windows keeps the old registration until US-022' };
|
|
143
150
|
if (!REQUIRED_EVALUATORS[event])
|
|
@@ -148,6 +155,9 @@ export function hostCoreResults(root, options = {}) {
|
|
|
148
155
|
const missing = missingEvaluators(caps, event);
|
|
149
156
|
if (missing.length > 0)
|
|
150
157
|
return { status: 'PASS', reason: `the new core lacks ${missing.join(', ')}` };
|
|
158
|
+
const left = uncovered(caps, host, event);
|
|
159
|
+
if (left.length > 0)
|
|
160
|
+
return { status: 'PASS', reason: `the new core does not cover ${listed(left)}` };
|
|
151
161
|
return { status: 'WARN', reason: 'the new core can take this event; run hq reindex to switch it' };
|
|
152
162
|
};
|
|
153
163
|
const results = [];
|
|
@@ -169,19 +179,72 @@ export function hostCoreResults(root, options = {}) {
|
|
|
169
179
|
results.push({ status: 'WARN', checkId, target: target.file, message: `${target.host} (${target.scope}): registration file is not valid JSON` });
|
|
170
180
|
continue;
|
|
171
181
|
}
|
|
182
|
+
// Claude Code merges settings.local.json over settings.json and runs the
|
|
183
|
+
// entries of both, so an event's registrations are read from both.
|
|
184
|
+
let overlay;
|
|
185
|
+
if (target.overlay) {
|
|
186
|
+
let overlayText;
|
|
187
|
+
try {
|
|
188
|
+
overlayText = fs.readFileSync(target.overlay, 'utf8');
|
|
189
|
+
}
|
|
190
|
+
catch {
|
|
191
|
+
// Absent: nothing merged over.
|
|
192
|
+
overlayText = undefined;
|
|
193
|
+
}
|
|
194
|
+
if (overlayText !== undefined) {
|
|
195
|
+
try {
|
|
196
|
+
overlay = jsonFormat.parse(overlayText);
|
|
197
|
+
}
|
|
198
|
+
catch {
|
|
199
|
+
// Claude Code cannot read it either; say so, since a new-core entry in it cannot be seen.
|
|
200
|
+
results.push({ status: 'WARN', checkId: `${checkId}-local`, target: target.overlay, message: `${target.host} (${target.scope}): ${path.basename(target.overlay)} is not valid JSON, so its hook entries cannot be checked; hq reindex reports it and leaves it as it is` });
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
const merged = new Map(eventEntries(doc));
|
|
205
|
+
for (const [event, entries] of eventEntries(overlay))
|
|
206
|
+
merged.set(event, [...(merged.get(event) ?? []), ...entries]);
|
|
172
207
|
const events = [];
|
|
173
208
|
const mixed = [];
|
|
174
|
-
for (const [event, entries] of
|
|
175
|
-
const
|
|
209
|
+
for (const [event, entries] of merged) {
|
|
210
|
+
const all = entries.map((entry) => classifyEntry(entry, target.host, root)).filter((k) => k !== null);
|
|
211
|
+
const kinds = [...new Set(all)];
|
|
176
212
|
if (kinds.length === 0)
|
|
177
213
|
continue;
|
|
214
|
+
if (kinds.includes('new-core')) {
|
|
215
|
+
// A switched event's new-core entry replaces the shell registration:
|
|
216
|
+
// the engine must do every hook the old dispatcher runs for it here.
|
|
217
|
+
const shell = kinds.filter((k) => k !== 'new-core');
|
|
218
|
+
let verdict;
|
|
219
|
+
if (killedBy) {
|
|
220
|
+
verdict = { status: 'FAIL', reason: `the kill switch is on (${killedBy}) but this event is still registered to the new core; run hq reindex to remove the new-core entry` };
|
|
221
|
+
}
|
|
222
|
+
else if (shell.length > 0) {
|
|
223
|
+
verdict = { status: 'FAIL', reason: `registered to the new core beside the ${shell.map((k) => label(k, target.host)).join(', ')}, so both run and the kill switch would run the old dispatcher twice` };
|
|
224
|
+
}
|
|
225
|
+
else if (all.filter((k) => k === 'new-core').length > 1) {
|
|
226
|
+
verdict = { status: 'WARN', reason: 'registered to the new core more than once, so its checks run twice' };
|
|
227
|
+
}
|
|
228
|
+
else {
|
|
229
|
+
const engine = enginePathOf(entries, target.host, root);
|
|
230
|
+
verdict = newCore(event, engine);
|
|
231
|
+
const caps = verdict.status === 'PASS' && engine ? capabilities(engine) : undefined;
|
|
232
|
+
const left = caps && !(caps instanceof Error) ? uncovered(caps, target.host, event) : [];
|
|
233
|
+
if (left.length > 0)
|
|
234
|
+
verdict = { status: 'FAIL', reason: `the new core does not cover ${listed(left)}, so they do not run; run hq reindex to put this event back on the old dispatcher` };
|
|
235
|
+
}
|
|
236
|
+
if (verdict.status === 'WARN')
|
|
237
|
+
mixed.push(event);
|
|
238
|
+
events.push({ event, core: 'new-core', ...verdict });
|
|
239
|
+
continue;
|
|
240
|
+
}
|
|
178
241
|
if (kinds.length > 1) {
|
|
179
242
|
mixed.push(event);
|
|
180
|
-
events.push({ event, core: kinds
|
|
243
|
+
events.push({ event, core: kinds[0], status: 'WARN', reason: `two HQ registrations: ${kinds.map((k) => label(k, target.host)).join(', ')}` });
|
|
181
244
|
continue;
|
|
182
245
|
}
|
|
183
246
|
const core = kinds[0];
|
|
184
|
-
events.push({ event, core, ...(
|
|
247
|
+
events.push({ event, core, ...oldCore(event, target.host) });
|
|
185
248
|
}
|
|
186
249
|
if (events.length === 0) {
|
|
187
250
|
results.push({ status: 'NA', checkId, target: target.file, message: `${target.host} (${target.scope}): no HQ hook registered` });
|
|
@@ -207,7 +270,7 @@ export function hostCoreResults(root, options = {}) {
|
|
|
207
270
|
message: `${target.host} (${target.scope}): ${summary}`,
|
|
208
271
|
details: { ...(cores.length === 1 ? { core: cores[0] } : {}), cores, events },
|
|
209
272
|
...(failed.length > 0
|
|
210
|
-
? { remediation: `Run hq reindex: it puts ${failed.join(', ')} back on the old dispatcher when the new core cannot take them, or repairs the ${STABLE_LINK_NAME} link. Until then those events run no HQ hook,
|
|
273
|
+
? { remediation: `Run hq reindex: it puts ${failed.join(', ')} back on the old dispatcher when the new core cannot take them, or repairs the ${STABLE_LINK_NAME} link. It also puts an event back on the old dispatcher when the new core no longer covers every hook the old dispatcher runs for it, leaves one registration per event, and removes the new-core entries while the kill switch is on. Until then those events run no HQ hook, a new core without their guards, hooks twice, or none of the hooks the new core does not cover.` }
|
|
211
274
|
: mixed.length > 0
|
|
212
275
|
? { remediation: 'Run hq reindex to leave one HQ registration per event.' }
|
|
213
276
|
: {}),
|
|
@@ -235,9 +298,14 @@ export function coreSwitchResult(options = {}) {
|
|
|
235
298
|
].filter(Boolean);
|
|
236
299
|
const flag = `flag ${CORE_NEXT_FLAG} is ${on ? 'on' : 'off'}`;
|
|
237
300
|
const kill = killedBy.length
|
|
238
|
-
? `; kill switch on (${killedBy.join(', ')}): new-core registrations hand each event to the old dispatcher`
|
|
301
|
+
? `; kill switch on (${killedBy.join(', ')}): new-core registrations hand each event to the old dispatcher, and hq reindex removes them`
|
|
302
|
+
: '';
|
|
303
|
+
// The engine reads the kill switch from each hook's own environment; this
|
|
304
|
+
// check and hq reindex read it from theirs.
|
|
305
|
+
const hostEnv = on || killedBy.length
|
|
306
|
+
? `. ${CORE_NEXT_KILL_ENV} or ${ENGINE_KILL_ENV} set only in a host's environment (for example Claude Code settings env) is honored by the engine at run time only; hq reindex and this check do not see it, so use the file ${path.join('~', CORE_NEXT_KILL_FILE)} to switch the registrations back`
|
|
239
307
|
: '';
|
|
240
|
-
return { status: 'PASS', checkId: 'host-core:switch', message: `${flag}${kill}`, details: { flag: on, killSwitch: killedBy } };
|
|
308
|
+
return { status: 'PASS', checkId: 'host-core:switch', message: `${flag}${kill}${hostEnv}`, details: { flag: on, killSwitch: killedBy } };
|
|
241
309
|
}
|
|
242
310
|
function exists(file) {
|
|
243
311
|
try {
|
|
@@ -85,13 +85,13 @@ function receiverPermissionRemediation(byCall) {
|
|
|
85
85
|
const parts = [];
|
|
86
86
|
if (queueLeg) {
|
|
87
87
|
parts.push("The queue credentials vended by POST /v1/sync/subscribe were refused on the per-device queue leg; " +
|
|
88
|
-
"restart the sync runner so it re-subscribes, then run `hq sync status`. If it repeats, the device roster entry for this machine needs attention (hq-pro device slots).");
|
|
88
|
+
"restart the sync runner so it re-subscribes, then run `hq daemon sync status`. If it repeats, the device roster entry for this machine needs attention (hq-pro device slots).");
|
|
89
89
|
}
|
|
90
90
|
if (pullLeg) {
|
|
91
91
|
parts.push("The object pull after a change event was refused; see sync.runtime.pull-access-denied for the refused keys and the grant to compare.");
|
|
92
92
|
}
|
|
93
93
|
if (parts.length === 0) {
|
|
94
|
-
parts.push("Run `hq sync status` and inspect the selected sync log under ~/.hq/logs/, ~/.hq/daemon/logs/, or the configured HQ_DAEMON_DIR/logs/.");
|
|
94
|
+
parts.push("Run `hq daemon sync status` and inspect the selected sync log under ~/.hq/logs/, ~/.hq/daemon/logs/, or the configured HQ_DAEMON_DIR/logs/.");
|
|
95
95
|
}
|
|
96
96
|
return parts.join(" ");
|
|
97
97
|
}
|
|
@@ -313,7 +313,7 @@ export function analyzeSyncRuntimeLog(lines, options) {
|
|
|
313
313
|
message: check.message ?? `${check.count} ${check.label} in the last hour.`,
|
|
314
314
|
...(check.details ? { details: check.details } : {}),
|
|
315
315
|
remediation: check.remediation ??
|
|
316
|
-
"Run `hq sync status` and inspect the selected sync log under ~/.hq/logs/, ~/.hq/daemon/logs/, or the configured HQ_DAEMON_DIR/logs/.",
|
|
316
|
+
"Run `hq daemon sync status` and inspect the selected sync log under ~/.hq/logs/, ~/.hq/daemon/logs/, or the configured HQ_DAEMON_DIR/logs/.",
|
|
317
317
|
}
|
|
318
318
|
: {
|
|
319
319
|
status: "PASS",
|