@indigoai-us/hq-cli 5.345.218 → 5.345.220
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 +130 -0
- package/dist/command-catalog.generated.d.ts +94 -1
- package/dist/command-catalog.generated.js +114 -1
- package/dist/commands/agents.d.ts +22 -0
- package/dist/commands/agents.js +92 -1
- package/dist/commands/bot.d.ts +48 -0
- package/dist/commands/bot.js +108 -8
- package/dist/commands/cloud.d.ts +16 -0
- package/dist/commands/cloud.js +112 -102
- package/dist/commands/core-checkpoint-native.d.ts +13 -0
- package/dist/commands/core-checkpoint-native.js +167 -52
- package/dist/commands/core-hook-registration-plan.d.ts +8 -0
- package/dist/commands/core-hook-registration-plan.js +22 -0
- package/dist/commands/core.js +9 -0
- package/dist/commands/daemon.js +21 -2
- package/dist/commands/doctor.js +4 -0
- package/dist/commands/integrations.js +84 -3
- package/dist/commands/lanes-shared.d.ts +2 -0
- package/dist/commands/lanes-watch.js +28 -1
- package/dist/commands/lanes.d.ts +2 -0
- package/dist/commands/lanes.js +99 -9
- package/dist/commands/packs.js +23 -0
- package/dist/commands/pkg-update.d.ts +6 -0
- package/dist/commands/pkg-update.js +15 -7
- package/dist/commands/reindex.js +6 -0
- package/dist/commands/run.js +55 -45
- package/dist/commands/sources.js +3 -2
- package/dist/index.js +8 -0
- package/dist/lib/anywhere-person-setting.d.ts +2 -2
- package/dist/lib/anywhere-person-setting.js +2 -2
- package/dist/lib/bot/fleet-cron.js +5 -2
- package/dist/lib/bot/inflight.d.ts +9 -0
- package/dist/lib/bot/jobs/hot-signal-sync.d.ts +51 -0
- package/dist/lib/bot/jobs/hot-signal-sync.js +90 -9
- package/dist/lib/bot/run.d.ts +29 -5
- package/dist/lib/bot/run.js +203 -1
- package/dist/lib/bot/signals-try-now.d.ts +76 -0
- package/dist/lib/bot/signals-try-now.js +111 -0
- package/dist/lib/capacity/collectors/claude-oauth.d.ts +22 -3
- package/dist/lib/capacity/collectors/claude-oauth.js +78 -22
- package/dist/lib/capacity/scheduler.d.ts +8 -0
- package/dist/lib/capacity/scheduler.js +5 -2
- package/dist/lib/daemon/anywhere-listener.d.ts +33 -1
- package/dist/lib/daemon/anywhere-listener.js +86 -4
- package/dist/lib/daemon/machine-check-owner.d.ts +21 -0
- package/dist/lib/daemon/machine-check-owner.js +95 -0
- package/dist/lib/daemon/machine-check-registration.d.ts +4 -0
- package/dist/lib/daemon/machine-check-registration.js +64 -0
- package/dist/lib/daemon/machine-checks.d.ts +144 -0
- package/dist/lib/daemon/machine-checks.js +412 -0
- package/dist/lib/daemon/run.js +35 -4
- package/dist/lib/daemon/runtime-notifications.d.ts +7 -0
- package/dist/lib/daemon/runtime-notifications.js +50 -0
- package/dist/lib/daemon/server.d.ts +2 -0
- package/dist/lib/daemon/server.js +6 -0
- package/dist/lib/daemon/state-file.d.ts +12 -1
- package/dist/lib/daemon/state-file.js +23 -1
- package/dist/lib/doctor/checks/fleet-hook-core.d.ts +12 -0
- package/dist/lib/doctor/checks/fleet-hook-core.js +127 -0
- package/dist/lib/doctor/checks/host-core.js +3 -1
- package/dist/lib/doctor/checks/machine-checks.d.ts +16 -0
- package/dist/lib/doctor/checks/machine-checks.js +103 -0
- package/dist/lib/doctor/registry.js +4 -0
- package/dist/lib/doctor/types.d.ts +4 -0
- package/dist/lib/hook-engine/canary-gate.d.ts +64 -0
- package/dist/lib/hook-engine/canary-gate.js +147 -0
- package/dist/lib/hook-engine/coverage.d.ts +3 -1
- package/dist/lib/hook-engine/coverage.js +8 -2
- package/dist/lib/hook-engine/fleet-registration.d.ts +42 -0
- package/dist/lib/hook-engine/fleet-registration.js +168 -0
- package/dist/lib/hook-engine/reconcile.js +3 -2
- package/dist/lib/hook-engine/registration-identity.d.ts +33 -0
- package/dist/lib/hook-engine/registration-identity.js +97 -0
- package/dist/lib/hook-engine/registration.d.ts +1 -30
- package/dist/lib/hook-engine/registration.js +1 -88
- package/dist/lib/hook-engine/resolve.d.ts +2 -0
- package/dist/lib/hook-engine/resolve.js +7 -3
- package/dist/lib/hot-channels/alert.d.ts +10 -1
- package/dist/lib/hot-channels/alert.js +34 -7
- package/dist/lib/hot-channels/signals-claude-login.d.ts +53 -0
- package/dist/lib/hot-channels/signals-claude-login.js +96 -0
- package/dist/lib/hot-channels/signals-pass.d.ts +17 -0
- package/dist/lib/hot-channels/signals-pass.js +31 -3
- package/dist/lib/lanes/canonical-host.d.ts +8 -1
- package/dist/lib/lanes/canonical-host.js +9 -3
- package/dist/lib/lanes/machine-identity.d.ts +15 -0
- package/dist/lib/lanes/machine-identity.js +26 -0
- package/dist/lib/lanes/spawn.js +17 -3
- package/dist/lib/search-index/index.js +11 -1
- package/dist/lib/signals/engine.d.ts +1 -0
- package/dist/lib/signals/engine.js +7 -0
- package/dist/lib/signals/reply.d.ts +48 -0
- package/dist/lib/signals/reply.js +72 -11
- package/dist/lib/signals/steps/adapters.js +6 -0
- package/dist/lib/signals/steps/extract.d.ts +50 -3
- package/dist/lib/signals/steps/extract.js +100 -17
- package/dist/lib/signals/steps/types.d.ts +19 -0
- package/dist/lib/sync-core/engine-home.d.ts +6 -1
- package/dist/lib/sync-core/engine-home.js +13 -3
- package/dist/lib/sync-core/reconcile.js +1 -1
- package/dist/lib/sync-core/release-compare.d.ts +7 -0
- package/dist/lib/sync-core/release-compare.js +16 -0
- package/dist/lib/sync-core/release.d.ts +2 -1
- package/dist/lib/sync-core/release.js +2 -10
- package/dist/run/schema-env-overrides.d.ts +24 -0
- package/dist/run/schema-env-overrides.js +72 -0
- package/dist/utils/core-next-flag.d.ts +4 -0
- package/dist/utils/core-next-flag.js +22 -0
- package/dist/utils/core-next-kill.d.ts +16 -0
- package/dist/utils/core-next-kill.js +35 -0
- package/dist/utils/host-registration.d.ts +33 -23
- package/dist/utils/host-registration.js +90 -66
- package/package.json +14 -10
- package/scripts/check-function-manifest.mjs +5 -4
- package/dist/commands/__fixtures__/access-vault.d.ts +0 -95
- package/dist/commands/__fixtures__/access-vault.js +0 -166
- package/dist/commands/__fixtures__/make-tar.d.ts +0 -38
- package/dist/commands/__fixtures__/make-tar.js +0 -102
- package/dist/commands/secrets-public-types.test-d.d.ts +0 -2
- package/dist/commands/secrets-public-types.test-d.js +0 -18
- package/dist/lib/decisions/fixtures/us001.d.ts +0 -137
- package/dist/lib/decisions/fixtures/us001.js +0 -21
- package/dist/lib/doctor/__testing__/fake-hq-tree.d.ts +0 -226
- package/dist/lib/doctor/__testing__/fake-hq-tree.js +0 -408
- package/dist/lib/doctor/__testing__/run-doctor.d.ts +0 -8
- package/dist/lib/doctor/__testing__/run-doctor.js +0 -69
- package/dist/lib/fingerprint/fixtures.d.ts +0 -19
- package/dist/lib/fingerprint/fixtures.js +0 -61
- package/dist/lib/hot-channels/adapters/__fixtures__/dummy.d.ts +0 -33
- package/dist/lib/hot-channels/adapters/__fixtures__/dummy.js +0 -53
- package/dist/lib/hot-channels/adapters/__fixtures__/meeting-providers.d.ts +0 -38
- package/dist/lib/hot-channels/adapters/__fixtures__/meeting-providers.js +0 -64
- package/dist/lib/mesh/live/daemon/mqtt-events.test-d.d.ts +0 -2
- package/dist/lib/mesh/live/daemon/mqtt-events.test-d.js +0 -10
- package/dist/lib/test-utils/isolated-flag-company-context.d.ts +0 -3
- package/dist/lib/test-utils/isolated-flag-company-context.js +0 -18
- package/scripts/hook-engine-manifest.mjs +0 -22
- package/scripts/mesh-daemon-if-stale.mjs +0 -20
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import * as fs from "node:fs";
|
|
2
2
|
import * as path from "node:path";
|
|
3
3
|
import { parse as parseToml } from "smol-toml";
|
|
4
|
+
import { compareSyncCoreReleases } from "./release-compare.js";
|
|
4
5
|
export const SYNC_CORE_REQUESTS_PER_DAY = 20_000;
|
|
6
|
+
// The first engine release with no daily request count; it ignores `requests_per_day`.
|
|
7
|
+
export const SYNC_CORE_REQUEST_COUNT_REMOVED_IN = "v0.1.29";
|
|
5
8
|
export function syncCoreEngineHome(home, vaultUid) {
|
|
6
9
|
return path.join(home, ".hq", "sync-core", "engines", vaultUid);
|
|
7
10
|
}
|
|
@@ -11,7 +14,14 @@ export function syncCoreUnitId(vaultUid) {
|
|
|
11
14
|
export function isSyncCoreVaultUid(value) {
|
|
12
15
|
return typeof value === "string" && /^(prs|cmp)_[A-Za-z0-9][A-Za-z0-9_-]*$/.test(value);
|
|
13
16
|
}
|
|
14
|
-
export function engineConfigToml(vault, hqRoot, phase, tokenPath
|
|
17
|
+
export function engineConfigToml(vault, hqRoot, phase, tokenPath,
|
|
18
|
+
/** The engine release this vault runs. Not given: treated as an engine that still counts requests. */
|
|
19
|
+
release) {
|
|
20
|
+
// Engines before the removal fall back to 10,000 a day when the line is missing.
|
|
21
|
+
// A release that is not a plain vX.Y.Z (a pre-release, a mislabelled marker) keeps the line too.
|
|
22
|
+
const countsRequests = release === undefined ||
|
|
23
|
+
!/^v?\d+\.\d+\.\d+$/.test(release) ||
|
|
24
|
+
compareSyncCoreReleases(release, SYNC_CORE_REQUEST_COUNT_REMOVED_IN) < 0;
|
|
15
25
|
const lines = [
|
|
16
26
|
"[sync]",
|
|
17
27
|
'engine = "rust-test"',
|
|
@@ -19,7 +29,7 @@ export function engineConfigToml(vault, hqRoot, phase, tokenPath) {
|
|
|
19
29
|
...(phase === "full" ? ["full_vault = true"] : []),
|
|
20
30
|
`vaults = [${JSON.stringify(vault.uid)}]`,
|
|
21
31
|
`hq_root = ${JSON.stringify(hqRoot)}`,
|
|
22
|
-
`requests_per_day = ${SYNC_CORE_REQUESTS_PER_DAY}
|
|
32
|
+
...(countsRequests ? [`requests_per_day = ${SYNC_CORE_REQUESTS_PER_DAY}`] : []),
|
|
23
33
|
...(tokenPath ? [`token_path = ${JSON.stringify(tokenPath)}`] : []),
|
|
24
34
|
];
|
|
25
35
|
if (vault.kind === "company") {
|
|
@@ -70,7 +80,7 @@ export function writeEngineHome(opts) {
|
|
|
70
80
|
replaceSymlink(path.join(hq, "work-mesh"), path.join(opts.home, ".hq", "work-mesh"));
|
|
71
81
|
replaceSymlink(path.join(hq, "cognito-tokens.json"), opts.tokenFile);
|
|
72
82
|
}
|
|
73
|
-
const configChanged = writeIfChanged(path.join(root, "config.toml"), engineConfigToml(opts.vault, opts.hqRoot, opts.phase, windows ? opts.tokenFile : undefined));
|
|
83
|
+
const configChanged = writeIfChanged(path.join(root, "config.toml"), engineConfigToml(opts.vault, opts.hqRoot, opts.phase, windows ? opts.tokenFile : undefined, opts.release));
|
|
74
84
|
const ownedPath = path.join(root, "owned", `${opts.vault.uid}.json`);
|
|
75
85
|
let ownedChanged = false;
|
|
76
86
|
if (opts.phase === "full") {
|
|
@@ -179,7 +179,7 @@ export async function reconcileSyncCore(deps) {
|
|
|
179
179
|
const engineHome = syncCoreEngineHome(deps.home, vault.uid);
|
|
180
180
|
if (!before)
|
|
181
181
|
clearEngineStatus(deps.home, vault.uid);
|
|
182
|
-
writeEngineHome({ home: deps.home, hqRoot: deps.hqRoot, vault, phase: "full", tokenFile: deps.tokenFile, platform });
|
|
182
|
+
writeEngineHome({ home: deps.home, hqRoot: deps.hqRoot, vault, phase: "full", tokenFile: deps.tokenFile, platform, release: engineRelease });
|
|
183
183
|
const wasFull = before?.phase === "full";
|
|
184
184
|
const alreadyOff = vault.kind === "personal"
|
|
185
185
|
? switchesBefore.personalOff
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compares two engine releases ("v0.1.28", "0.1.29"). Negative when `a` is older.
|
|
3
|
+
* Kept apart from release.ts, which downloads, so callers that only compare
|
|
4
|
+
* versions do not pull networking into their import closure.
|
|
5
|
+
*/
|
|
6
|
+
export declare function compareSyncCoreReleases(a: string, b: string): number;
|
|
7
|
+
//# sourceMappingURL=release-compare.d.ts.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compares two engine releases ("v0.1.28", "0.1.29"). Negative when `a` is older.
|
|
3
|
+
* Kept apart from release.ts, which downloads, so callers that only compare
|
|
4
|
+
* versions do not pull networking into their import closure.
|
|
5
|
+
*/
|
|
6
|
+
export function compareSyncCoreReleases(a, b) {
|
|
7
|
+
const parse = (release) => release.replace(/^v/, "").split(".").map((part) => Number.parseInt(part, 10) || 0);
|
|
8
|
+
const [x, y] = [parse(a), parse(b)];
|
|
9
|
+
for (let i = 0; i < Math.max(x.length, y.length); i += 1) {
|
|
10
|
+
const diff = (x[i] ?? 0) - (y[i] ?? 0);
|
|
11
|
+
if (diff !== 0)
|
|
12
|
+
return diff;
|
|
13
|
+
}
|
|
14
|
+
return 0;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=release-compare.js.map
|
|
@@ -7,7 +7,8 @@ export declare const SYNC_CORE_FULL_RELEASE: string | null;
|
|
|
7
7
|
*/
|
|
8
8
|
export declare const SYNC_CORE_WINDOWS_FULL_RELEASE: string | null;
|
|
9
9
|
export declare const SYNC_CORE_WINDOWS_FULL_RELEASE_ENV = "HQ_SYNC_CORE_WINDOWS_FULL_RELEASE";
|
|
10
|
-
|
|
10
|
+
import { compareSyncCoreReleases } from "./release-compare.js";
|
|
11
|
+
export { compareSyncCoreReleases };
|
|
11
12
|
export declare function windowsFullRelease(env?: NodeJS.ProcessEnv): string | null;
|
|
12
13
|
export declare function fullModeAllowed(release: string, platform?: NodeJS.Platform, env?: NodeJS.ProcessEnv): boolean;
|
|
13
14
|
export declare const SYNC_CORE_DOWNLOAD_BASE = "https://indigoai-public.s3.amazonaws.com/hq-sync-core";
|
|
@@ -12,16 +12,8 @@ export const SYNC_CORE_FULL_RELEASE = "v0.1.23";
|
|
|
12
12
|
*/
|
|
13
13
|
export const SYNC_CORE_WINDOWS_FULL_RELEASE = null;
|
|
14
14
|
export const SYNC_CORE_WINDOWS_FULL_RELEASE_ENV = "HQ_SYNC_CORE_WINDOWS_FULL_RELEASE";
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const [x, y] = [parse(a), parse(b)];
|
|
18
|
-
for (let i = 0; i < Math.max(x.length, y.length); i += 1) {
|
|
19
|
-
const diff = (x[i] ?? 0) - (y[i] ?? 0);
|
|
20
|
-
if (diff !== 0)
|
|
21
|
-
return diff;
|
|
22
|
-
}
|
|
23
|
-
return 0;
|
|
24
|
-
}
|
|
15
|
+
import { compareSyncCoreReleases } from "./release-compare.js";
|
|
16
|
+
export { compareSyncCoreReleases };
|
|
25
17
|
export function windowsFullRelease(env = process.env) {
|
|
26
18
|
const override = env[SYNC_CORE_WINDOWS_FULL_RELEASE_ENV]?.trim();
|
|
27
19
|
return override && /^v?\d+\.\d+\.\d+$/.test(override) ? override : SYNC_CORE_WINDOWS_FULL_RELEASE;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `hq run` must not let inherited process.env values replace .env.schema
|
|
3
|
+
* (feedback_d5698e57). Varlock treats process.env as overrides: an item whose
|
|
4
|
+
* key is already in the environment is marked overridden and the hq() resolver
|
|
5
|
+
* is never called. `hq secrets exec` injects last, so the vault value wins.
|
|
6
|
+
* These helpers make `hq run` match that: schema and .env.local files win,
|
|
7
|
+
* inherited env does not.
|
|
8
|
+
*/
|
|
9
|
+
/** Env keys declared in schema / .env.local files (KEY=... lines). */
|
|
10
|
+
export declare function schemaDeclaredKeys(paths: string[]): string[];
|
|
11
|
+
export interface EnvOverrideGraph {
|
|
12
|
+
overrideValues?: Record<string, string | undefined>;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Drop inherited process.env overrides for schema-declared keys so varlock
|
|
16
|
+
* resolves the file (and hq()) instead of the caller's shell.
|
|
17
|
+
*/
|
|
18
|
+
export declare function clearInheritedSchemaOverrides(graph: EnvOverrideGraph, keys: string[]): void;
|
|
19
|
+
/**
|
|
20
|
+
* Run `fn` with schema-declared keys removed from process.env, then restore.
|
|
21
|
+
* Covers a varlock that re-reads process.env at load/resolve time.
|
|
22
|
+
*/
|
|
23
|
+
export declare function withoutInheritedSchemaEnv<T>(keys: string[], fn: () => Promise<T>): Promise<T>;
|
|
24
|
+
//# sourceMappingURL=schema-env-overrides.d.ts.map
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `hq run` must not let inherited process.env values replace .env.schema
|
|
3
|
+
* (feedback_d5698e57). Varlock treats process.env as overrides: an item whose
|
|
4
|
+
* key is already in the environment is marked overridden and the hq() resolver
|
|
5
|
+
* is never called. `hq secrets exec` injects last, so the vault value wins.
|
|
6
|
+
* These helpers make `hq run` match that: schema and .env.local files win,
|
|
7
|
+
* inherited env does not.
|
|
8
|
+
*/
|
|
9
|
+
import * as fs from "node:fs";
|
|
10
|
+
const KEY = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
11
|
+
/** Env keys declared in schema / .env.local files (KEY=... lines). */
|
|
12
|
+
export function schemaDeclaredKeys(paths) {
|
|
13
|
+
const keys = new Set();
|
|
14
|
+
for (const file of paths) {
|
|
15
|
+
let text;
|
|
16
|
+
try {
|
|
17
|
+
text = fs.readFileSync(file, "utf8");
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
for (const raw of text.split(/\r?\n/)) {
|
|
23
|
+
const line = raw.trim();
|
|
24
|
+
if (line === "" || line.startsWith("#"))
|
|
25
|
+
continue;
|
|
26
|
+
const eq = line.indexOf("=");
|
|
27
|
+
if (eq < 1)
|
|
28
|
+
continue;
|
|
29
|
+
const key = line.slice(0, eq).trim();
|
|
30
|
+
if (KEY.test(key))
|
|
31
|
+
keys.add(key);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return [...keys];
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Drop inherited process.env overrides for schema-declared keys so varlock
|
|
38
|
+
* resolves the file (and hq()) instead of the caller's shell.
|
|
39
|
+
*/
|
|
40
|
+
export function clearInheritedSchemaOverrides(graph, keys) {
|
|
41
|
+
const ov = graph.overrideValues;
|
|
42
|
+
if (!ov)
|
|
43
|
+
return;
|
|
44
|
+
for (const key of keys) {
|
|
45
|
+
delete ov[key];
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Run `fn` with schema-declared keys removed from process.env, then restore.
|
|
50
|
+
* Covers a varlock that re-reads process.env at load/resolve time.
|
|
51
|
+
*/
|
|
52
|
+
export async function withoutInheritedSchemaEnv(keys, fn) {
|
|
53
|
+
const saved = [];
|
|
54
|
+
for (const key of keys) {
|
|
55
|
+
if (!Object.prototype.hasOwnProperty.call(process.env, key))
|
|
56
|
+
continue;
|
|
57
|
+
saved.push([key, process.env[key]]);
|
|
58
|
+
delete process.env[key];
|
|
59
|
+
}
|
|
60
|
+
try {
|
|
61
|
+
return await fn();
|
|
62
|
+
}
|
|
63
|
+
finally {
|
|
64
|
+
for (const [key, value] of saved) {
|
|
65
|
+
if (value === undefined)
|
|
66
|
+
delete process.env[key];
|
|
67
|
+
else
|
|
68
|
+
process.env[key] = value;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=schema-env-overrides.js.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The offline `core.next` decision, kept free of the hook-engine modules so
|
|
3
|
+
* daemon code can read it without loading them (they read the CLI's
|
|
4
|
+
* package.json at import, which breaks bundled daemon children).
|
|
5
|
+
*/
|
|
6
|
+
import { readLocalOverride } from '@indigoai-us/hq-flags-client';
|
|
7
|
+
import { readFlagSnapshotFile, readPersonFlagSnapshotFile } from '../lib/flag-snapshot-file.js';
|
|
8
|
+
import { resolveProcessFlagCompanyContext } from '../lib/process-flag-company-context.js';
|
|
9
|
+
export const CORE_NEXT_FLAG = 'core.next';
|
|
10
|
+
/** `core.next` for this machine, person or company, offline. */
|
|
11
|
+
export function coreNextEnabled(env = process.env) {
|
|
12
|
+
const override = readLocalOverride(CORE_NEXT_FLAG, env);
|
|
13
|
+
if (override !== null)
|
|
14
|
+
return override;
|
|
15
|
+
const { companyUid: uid, companySlug } = resolveProcessFlagCompanyContext(env);
|
|
16
|
+
// An explicit company slug that does not resolve stays off, as for the launcher flag.
|
|
17
|
+
if (!uid && companySlug)
|
|
18
|
+
return false;
|
|
19
|
+
const snapshot = uid ? readFlagSnapshotFile(uid, { env }) : readPersonFlagSnapshotFile({ env });
|
|
20
|
+
return snapshot?.flags[CORE_NEXT_FLAG] === true;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=core-next-flag.js.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** Engine-side kill switch: environment variable and file under the home folder. */
|
|
2
|
+
export declare const CORE_NEXT_KILL_ENV = "HQ_CORE_NEXT";
|
|
3
|
+
export declare const CORE_NEXT_KILL_FILE: string;
|
|
4
|
+
/** The engine-wide kill switch the bridge already honors; the engine checks it too. */
|
|
5
|
+
export declare const ENGINE_KILL_ENV = "HQ_HOOK_ENGINE";
|
|
6
|
+
export declare const ENGINE_KILL_FILE: string;
|
|
7
|
+
/**
|
|
8
|
+
* Why the new core is switched off on this machine, or null. The same four
|
|
9
|
+
* switches the engine reads (`crates/hq-hook/src/core_next.rs` `kill_reason`):
|
|
10
|
+
* `HQ_CORE_NEXT=off|0|false|no`, `HQ_HOOK_ENGINE=off`, and the files
|
|
11
|
+
* `~/.hq/state/core-next.off` and `~/.hq/hook-engine.off` (a link counts, as
|
|
12
|
+
* for the engine). With any of them on, `hq reindex` removes the new-core
|
|
13
|
+
* entries it added, so the registrations are what they were before the switch.
|
|
14
|
+
*/
|
|
15
|
+
export declare function coreNextKillReason(home: string, env?: NodeJS.ProcessEnv): string | null;
|
|
16
|
+
//# sourceMappingURL=core-next-kill.d.ts.map
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/** Shared offline kill switches without installer imports. */
|
|
2
|
+
import * as fs from 'node:fs';
|
|
3
|
+
import * as path from 'node:path';
|
|
4
|
+
/** Engine-side kill switch: environment variable and file under the home folder. */
|
|
5
|
+
export const CORE_NEXT_KILL_ENV = 'HQ_CORE_NEXT';
|
|
6
|
+
export const CORE_NEXT_KILL_FILE = path.join('.hq', 'state', 'core-next.off');
|
|
7
|
+
/** The engine-wide kill switch the bridge already honors; the engine checks it too. */
|
|
8
|
+
export const ENGINE_KILL_ENV = 'HQ_HOOK_ENGINE';
|
|
9
|
+
export const ENGINE_KILL_FILE = path.join('.hq', 'hook-engine.off');
|
|
10
|
+
/**
|
|
11
|
+
* Why the new core is switched off on this machine, or null. The same four
|
|
12
|
+
* switches the engine reads (`crates/hq-hook/src/core_next.rs` `kill_reason`):
|
|
13
|
+
* `HQ_CORE_NEXT=off|0|false|no`, `HQ_HOOK_ENGINE=off`, and the files
|
|
14
|
+
* `~/.hq/state/core-next.off` and `~/.hq/hook-engine.off` (a link counts, as
|
|
15
|
+
* for the engine). With any of them on, `hq reindex` removes the new-core
|
|
16
|
+
* entries it added, so the registrations are what they were before the switch.
|
|
17
|
+
*/
|
|
18
|
+
export function coreNextKillReason(home, env = process.env) {
|
|
19
|
+
const coreNextEnv = (env[CORE_NEXT_KILL_ENV] ?? '').trim();
|
|
20
|
+
if (/^(off|0|false|no)$/i.test(coreNextEnv))
|
|
21
|
+
return `${CORE_NEXT_KILL_ENV}=${env[CORE_NEXT_KILL_ENV]}`;
|
|
22
|
+
if (/^off$/i.test((env[ENGINE_KILL_ENV] ?? '').trim()))
|
|
23
|
+
return `${ENGINE_KILL_ENV}=${env[ENGINE_KILL_ENV]}`;
|
|
24
|
+
for (const file of [path.join(home, CORE_NEXT_KILL_FILE), path.join(home, ENGINE_KILL_FILE)]) {
|
|
25
|
+
try {
|
|
26
|
+
fs.lstatSync(file);
|
|
27
|
+
return file;
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
// Absent: this switch is off.
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=core-next-kill.js.map
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
+
import { type EngineOptions } from '../lib/hook-engine/resolve.js';
|
|
1
2
|
import { type NativeTarget } from '../lib/hook-engine/registration.js';
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
export declare const CORE_NEXT_KILL_ENV = "HQ_CORE_NEXT";
|
|
5
|
-
export declare const CORE_NEXT_KILL_FILE: string;
|
|
6
|
-
/** The engine-wide kill switch the bridge already honors; the engine checks it too. */
|
|
7
|
-
export declare const ENGINE_KILL_ENV = "HQ_HOOK_ENGINE";
|
|
8
|
-
export declare const ENGINE_KILL_FILE: string;
|
|
3
|
+
export { CORE_NEXT_FLAG, coreNextEnabled } from './core-next-flag.js';
|
|
4
|
+
export { coreNextKillReason, CORE_NEXT_KILL_ENV, CORE_NEXT_KILL_FILE, ENGINE_KILL_ENV, ENGINE_KILL_FILE } from './core-next-kill.js';
|
|
9
5
|
/** Name of the release-stable link next to the pinned engine versions. */
|
|
10
6
|
export declare const STABLE_LINK_NAME = "stable";
|
|
11
|
-
export type CoreNextHost = 'claude' | 'codex' | 'grok';
|
|
7
|
+
export type CoreNextHost = 'claude' | 'codex' | 'grok' | 'fleet-local' | 'agents-v2';
|
|
12
8
|
/**
|
|
13
9
|
* `project`: the HQ root's own registration, always answers.
|
|
14
10
|
* `global`: the user-scope Claude Code entry; answers nothing inside an HQ
|
|
@@ -30,6 +26,12 @@ export interface CoreNextTarget {
|
|
|
30
26
|
fallback?: FallbackTarget;
|
|
31
27
|
/** The old dispatcher's hooks the engine does in full, per event (`capabilities --json` `covers`). */
|
|
32
28
|
covers?: Readonly<Record<string, readonly string[]>>;
|
|
29
|
+
/**
|
|
30
|
+
* The host canary gate (US-019 criterion 4): true when `host` may switch
|
|
31
|
+
* events in `root` to this engine. Set by [`coreNextTarget`]; checked by
|
|
32
|
+
* `forHost` (`hook-engine/coverage.ts`) before any event switches.
|
|
33
|
+
*/
|
|
34
|
+
canary?: (root: string, host: CoreNextHost) => boolean;
|
|
33
35
|
}
|
|
34
36
|
/** The target one event is registered to: the new core only for an event it can take. */
|
|
35
37
|
export declare function targetForEvent(target: FallbackTarget | CoreNextTarget, event: string): FallbackTarget | CoreNextTarget;
|
|
@@ -45,6 +47,7 @@ export declare const CAPABILITIES_SCHEMA = "hq-hook.capabilities.v1";
|
|
|
45
47
|
/** What an engine reported: its version and the evaluators it runs per event. */
|
|
46
48
|
export interface EngineCapabilities {
|
|
47
49
|
version: string;
|
|
50
|
+
registrationHosts?: string[];
|
|
48
51
|
events: Record<string, string[]>;
|
|
49
52
|
/** The old dispatcher's hooks the engine does in full, per event; empty for an engine that does not say. */
|
|
50
53
|
covers?: Record<string, string[]>;
|
|
@@ -66,17 +69,6 @@ export declare function probeEngine(engine: string): EngineCapabilities;
|
|
|
66
69
|
* new-core registration with nothing to run.
|
|
67
70
|
*/
|
|
68
71
|
export declare function checkStableEngine(stable: string, pinned: string): void;
|
|
69
|
-
/**
|
|
70
|
-
* Why the new core is switched off on this machine, or null. The same four
|
|
71
|
-
* switches the engine reads (`crates/hq-hook/src/core_next.rs` `kill_reason`):
|
|
72
|
-
* `HQ_CORE_NEXT=off|0|false|no`, `HQ_HOOK_ENGINE=off`, and the files
|
|
73
|
-
* `~/.hq/state/core-next.off` and `~/.hq/hook-engine.off` (a link counts, as
|
|
74
|
-
* for the engine). With any of them on, `hq reindex` removes the new-core
|
|
75
|
-
* entries it added, so the registrations are what they were before the switch.
|
|
76
|
-
*/
|
|
77
|
-
export declare function coreNextKillReason(home: string, env?: NodeJS.ProcessEnv): string | null;
|
|
78
|
-
/** `core.next` for this machine, person or company, offline. */
|
|
79
|
-
export declare function coreNextEnabled(env?: NodeJS.ProcessEnv): boolean;
|
|
80
72
|
/** The stable path that stands for a pinned engine path. */
|
|
81
73
|
export declare function stableEnginePath(pinned: string, home: string): string;
|
|
82
74
|
/**
|
|
@@ -91,7 +83,28 @@ export interface CoreNextOptions {
|
|
|
91
83
|
platform?: NodeJS.Platform;
|
|
92
84
|
/** Reads the engine's capabilities; `probeEngine` by default. */
|
|
93
85
|
probe?: (engine: string) => EngineCapabilities;
|
|
86
|
+
/** Where gate warnings go (once each); standard error by default. */
|
|
87
|
+
warn?: (message: string) => void;
|
|
88
|
+
}
|
|
89
|
+
/** Why this home stays on shell registrations, or null when engine selection may run. */
|
|
90
|
+
export declare function coreNextOffReason(home: string, env: NodeJS.ProcessEnv, platform: NodeJS.Platform): string | null;
|
|
91
|
+
export type CoreNextEngineLookup = Pick<EngineOptions, 'platform' | 'arch' | 'version' | 'resolvePackage'>;
|
|
92
|
+
export interface CoreNextEngineOptions {
|
|
93
|
+
mode: 'install' | 'read-only';
|
|
94
|
+
platform?: NodeJS.Platform;
|
|
95
|
+
probe?: (engine: string) => EngineCapabilities;
|
|
96
|
+
lookup?: CoreNextEngineLookup;
|
|
97
|
+
}
|
|
98
|
+
export interface CoreNextEngine {
|
|
99
|
+
stable: string;
|
|
100
|
+
pinned: string;
|
|
101
|
+
caps: EngineCapabilities;
|
|
94
102
|
}
|
|
103
|
+
/**
|
|
104
|
+
* The one engine selection. Install links the stable path. Read-only never
|
|
105
|
+
* writes. Both fail when the pinned bundle or the stable link is wrong.
|
|
106
|
+
*/
|
|
107
|
+
export declare function resolveCoreNextEngine(home: string, options: CoreNextEngineOptions): CoreNextEngine;
|
|
95
108
|
/**
|
|
96
109
|
* The new-core target when `core.next` is on, the engine for this CLI is
|
|
97
110
|
* installed, the stable link resolves to it, it runs, and it has every
|
|
@@ -108,9 +121,7 @@ export declare function coreNextTarget(home: string, env?: NodeJS.ProcessEnv, op
|
|
|
108
121
|
* [`coreNextTarget`], with any failure turned into one warning and null, so
|
|
109
122
|
* `hq install` and `hq reindex` go on with the old registrations.
|
|
110
123
|
*/
|
|
111
|
-
export declare function coreNextTargetOrWarn(home: string, env?: NodeJS.ProcessEnv, options?: CoreNextOptions
|
|
112
|
-
warn?: (message: string) => void;
|
|
113
|
-
}): CoreNextTarget | null;
|
|
124
|
+
export declare function coreNextTargetOrWarn(home: string, env?: NodeJS.ProcessEnv, options?: CoreNextOptions): CoreNextTarget | null;
|
|
114
125
|
/** Test hook: forget which warnings were printed. */
|
|
115
126
|
export declare function _resetCoreNextWarningsForTests(): void;
|
|
116
127
|
/** Arguments after the engine path for one host, event and scope. */
|
|
@@ -175,5 +186,4 @@ export declare function grokBridgeJson(source: string, root: string, target: Cor
|
|
|
175
186
|
* Throws on any refusal; the caller keeps the current file.
|
|
176
187
|
*/
|
|
177
188
|
export declare function replaceFileNoFollow(file: string, content: string, home?: string): void;
|
|
178
|
-
export {};
|
|
179
189
|
//# sourceMappingURL=host-registration.d.ts.map
|
|
@@ -21,6 +21,11 @@
|
|
|
21
21
|
* which carries the server's person, company and machine targeting. No network
|
|
22
22
|
* call: reindex runs from lifecycle hooks.
|
|
23
23
|
*
|
|
24
|
+
* The switch is gated by the host canary (US-019 criterion 4,
|
|
25
|
+
* `hook-engine/canary-gate.ts`): Claude Code, Codex and Grok Build move an
|
|
26
|
+
* event to the new core only with a current passing canary for the engine's
|
|
27
|
+
* version and the root's hq-core gate, unless `HQ_SKIP_HOST_CANARY_GATE=1`.
|
|
28
|
+
*
|
|
24
29
|
* The switch is per event. Before an event is pointed at the new core, the
|
|
25
30
|
* engine behind the stable path is started (`--version`, then `capabilities
|
|
26
31
|
* --json`), and the event switches only when every evaluator it needs
|
|
@@ -37,19 +42,16 @@
|
|
|
37
42
|
import { execFileSync } from 'node:child_process';
|
|
38
43
|
import * as fs from 'node:fs';
|
|
39
44
|
import * as path from 'node:path';
|
|
40
|
-
import { readLocalOverride } from '@indigoai-us/hq-flags-client';
|
|
41
|
-
import { readFlagSnapshotFile, readPersonFlagSnapshotFile } from '../lib/flag-snapshot-file.js';
|
|
42
|
-
import { resolveProcessFlagCompanyContext } from '../lib/process-flag-company-context.js';
|
|
43
45
|
import { installHookEngine } from '../lib/hook-engine/resolve.js';
|
|
46
|
+
// Read-only names stay on this namespace. host-registration.test.ts mocks a module that exports only installHookEngine.
|
|
47
|
+
import * as hookEngineResolve from '../lib/hook-engine/resolve.js';
|
|
44
48
|
import { launcherRoot, quotePosix, quoteWindows } from '../lib/hook-engine/registration.js';
|
|
45
49
|
import { openStoreDir } from '../lib/safe-store.js';
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
export
|
|
50
|
-
|
|
51
|
-
export const ENGINE_KILL_ENV = 'HQ_HOOK_ENGINE';
|
|
52
|
-
export const ENGINE_KILL_FILE = path.join('.hq', 'hook-engine.off');
|
|
50
|
+
import { SKIP_CANARY_GATE_ENV, checkHostCanary } from '../lib/hook-engine/canary-gate.js';
|
|
51
|
+
export { CORE_NEXT_FLAG, coreNextEnabled } from './core-next-flag.js';
|
|
52
|
+
import { CORE_NEXT_FLAG, coreNextEnabled } from './core-next-flag.js';
|
|
53
|
+
export { coreNextKillReason, CORE_NEXT_KILL_ENV, CORE_NEXT_KILL_FILE, ENGINE_KILL_ENV, ENGINE_KILL_FILE } from './core-next-kill.js';
|
|
54
|
+
import { coreNextKillReason } from './core-next-kill.js';
|
|
53
55
|
/** Name of the release-stable link next to the pinned engine versions. */
|
|
54
56
|
export const STABLE_LINK_NAME = 'stable';
|
|
55
57
|
/** The target one event is registered to: the new core only for an event it can take. */
|
|
@@ -130,7 +132,7 @@ export function probeEngine(engine) {
|
|
|
130
132
|
covers[event] = Array.isArray(ids) ? ids.filter((id) => typeof id === 'string') : [];
|
|
131
133
|
}
|
|
132
134
|
}
|
|
133
|
-
return { version: version.slice('hq-hook '.length), events, covers };
|
|
135
|
+
return { version: version.slice('hq-hook '.length), events, covers, registrationHosts: doc.registration_hosts };
|
|
134
136
|
}
|
|
135
137
|
/**
|
|
136
138
|
* Check that the stable path resolves to the pinned engine before a
|
|
@@ -150,43 +152,6 @@ export function checkStableEngine(stable, pinned) {
|
|
|
150
152
|
if (!fs.statSync(resolved).isFile())
|
|
151
153
|
throw new Error(`${resolved} is not a file`);
|
|
152
154
|
}
|
|
153
|
-
/**
|
|
154
|
-
* Why the new core is switched off on this machine, or null. The same four
|
|
155
|
-
* switches the engine reads (`crates/hq-hook/src/core_next.rs` `kill_reason`):
|
|
156
|
-
* `HQ_CORE_NEXT=off|0|false|no`, `HQ_HOOK_ENGINE=off`, and the files
|
|
157
|
-
* `~/.hq/state/core-next.off` and `~/.hq/hook-engine.off` (a link counts, as
|
|
158
|
-
* for the engine). With any of them on, `hq reindex` removes the new-core
|
|
159
|
-
* entries it added, so the registrations are what they were before the switch.
|
|
160
|
-
*/
|
|
161
|
-
export function coreNextKillReason(home, env = process.env) {
|
|
162
|
-
const coreNextEnv = (env[CORE_NEXT_KILL_ENV] ?? '').trim();
|
|
163
|
-
if (/^(off|0|false|no)$/i.test(coreNextEnv))
|
|
164
|
-
return `${CORE_NEXT_KILL_ENV}=${env[CORE_NEXT_KILL_ENV]}`;
|
|
165
|
-
if (/^off$/i.test((env[ENGINE_KILL_ENV] ?? '').trim()))
|
|
166
|
-
return `${ENGINE_KILL_ENV}=${env[ENGINE_KILL_ENV]}`;
|
|
167
|
-
for (const file of [path.join(home, CORE_NEXT_KILL_FILE), path.join(home, ENGINE_KILL_FILE)]) {
|
|
168
|
-
try {
|
|
169
|
-
fs.lstatSync(file);
|
|
170
|
-
return file;
|
|
171
|
-
}
|
|
172
|
-
catch {
|
|
173
|
-
// Absent: this switch is off.
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
return null;
|
|
177
|
-
}
|
|
178
|
-
/** `core.next` for this machine, person or company, offline. */
|
|
179
|
-
export function coreNextEnabled(env = process.env) {
|
|
180
|
-
const override = readLocalOverride(CORE_NEXT_FLAG, env);
|
|
181
|
-
if (override !== null)
|
|
182
|
-
return override;
|
|
183
|
-
const { companyUid: uid, companySlug } = resolveProcessFlagCompanyContext(env);
|
|
184
|
-
// An explicit company slug that does not resolve stays off, as for the launcher flag.
|
|
185
|
-
if (!uid && companySlug)
|
|
186
|
-
return false;
|
|
187
|
-
const snapshot = uid ? readFlagSnapshotFile(uid, { env }) : readPersonFlagSnapshotFile({ env });
|
|
188
|
-
return snapshot?.flags[CORE_NEXT_FLAG] === true;
|
|
189
|
-
}
|
|
190
155
|
function hookEngineDir(home) {
|
|
191
156
|
return path.join(home, '.hq', 'bin', 'hq-hook');
|
|
192
157
|
}
|
|
@@ -294,6 +259,44 @@ function pointsAt(link, folder) {
|
|
|
294
259
|
return false;
|
|
295
260
|
}
|
|
296
261
|
}
|
|
262
|
+
/** Why this home stays on shell registrations, or null when engine selection may run. */
|
|
263
|
+
export function coreNextOffReason(home, env, platform) {
|
|
264
|
+
const killed = coreNextKillReason(home, env);
|
|
265
|
+
if (killed)
|
|
266
|
+
return killed;
|
|
267
|
+
if (platform === 'win32')
|
|
268
|
+
return 'Windows keeps shell registration';
|
|
269
|
+
if (!coreNextEnabled({ ...env, HOME: home, USERPROFILE: home }))
|
|
270
|
+
return 'core.next is off';
|
|
271
|
+
return null;
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* The one engine selection. Install links the stable path. Read-only never
|
|
275
|
+
* writes. Both fail when the pinned bundle or the stable link is wrong.
|
|
276
|
+
*/
|
|
277
|
+
export function resolveCoreNextEngine(home, options) {
|
|
278
|
+
const platform = options.platform ?? process.platform;
|
|
279
|
+
let pinned;
|
|
280
|
+
let stable;
|
|
281
|
+
if (options.mode === 'install') {
|
|
282
|
+
const installed = installHookEngine(options.lookup ? { ...options.lookup, home } : { home });
|
|
283
|
+
if (!installed)
|
|
284
|
+
throw new Error('the hook engine for this CLI is not installed');
|
|
285
|
+
pinned = installed;
|
|
286
|
+
stable = linkStableEngine(pinned, home, platform);
|
|
287
|
+
}
|
|
288
|
+
else {
|
|
289
|
+
const found = hookEngineResolve.findHookEngine({ ...options.lookup, home });
|
|
290
|
+
if (!found)
|
|
291
|
+
throw new Error('the pinned hook engine is unavailable');
|
|
292
|
+
hookEngineResolve.assertPinnedHookEngineMatches(found);
|
|
293
|
+
pinned = found.pinned;
|
|
294
|
+
stable = stableEnginePath(found.pinned, home);
|
|
295
|
+
}
|
|
296
|
+
checkStableEngine(stable, pinned);
|
|
297
|
+
const caps = (options.probe ?? probeEngine)(stable);
|
|
298
|
+
return { stable, pinned, caps };
|
|
299
|
+
}
|
|
297
300
|
/**
|
|
298
301
|
* The new-core target when `core.next` is on, the engine for this CLI is
|
|
299
302
|
* installed, the stable link resolves to it, it runs, and it has every
|
|
@@ -307,23 +310,48 @@ function pointsAt(link, folder) {
|
|
|
307
310
|
*/
|
|
308
311
|
export function coreNextTarget(home, env = process.env, options = {}) {
|
|
309
312
|
const platform = options.platform ?? process.platform;
|
|
310
|
-
if (
|
|
311
|
-
return null;
|
|
312
|
-
// The kill switch rolls the registrations back as well as the next event.
|
|
313
|
-
if (coreNextKillReason(home, env))
|
|
313
|
+
if (coreNextOffReason(home, env, platform))
|
|
314
314
|
return null;
|
|
315
|
-
|
|
316
|
-
return null;
|
|
317
|
-
const pinned = installHookEngine({ home });
|
|
318
|
-
if (!pinned)
|
|
319
|
-
throw new Error('the hook engine for this CLI is not installed');
|
|
320
|
-
const stable = linkStableEngine(pinned, home, platform);
|
|
321
|
-
checkStableEngine(stable, pinned);
|
|
322
|
-
const caps = (options.probe ?? probeEngine)(stable);
|
|
315
|
+
const { stable, caps } = resolveCoreNextEngine(home, { mode: 'install', platform, probe: options.probe });
|
|
323
316
|
const events = capableEvents(caps);
|
|
324
|
-
|
|
317
|
+
if (!events.length)
|
|
318
|
+
return null;
|
|
319
|
+
return { coreNext: stable, events, covers: caps.covers ?? {}, canary: hostCanaryGate(home, env, caps.version, platform, options.warn) };
|
|
325
320
|
}
|
|
326
321
|
const warned = new Set();
|
|
322
|
+
function warnOnce(message, warn) {
|
|
323
|
+
if (warned.has(message))
|
|
324
|
+
return;
|
|
325
|
+
warned.add(message);
|
|
326
|
+
(warn ?? ((text) => process.stderr.write(`${text}\n`)))(message);
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* The host canary gate for an engine at `version` (hq-core-rust US-019
|
|
330
|
+
* criterion 4, `hook-engine/canary-gate.ts`): Claude Code, Codex and Grok
|
|
331
|
+
* Build switch an event only with a current passing canary for this engine
|
|
332
|
+
* version and the root's hq-core gate. A refusal is one warning and the old
|
|
333
|
+
* registrations on that host. `HQ_SKIP_HOST_CANARY_GATE=1` lets the switch go
|
|
334
|
+
* on, with a warning that names what it bypassed. `fleet-local` is not a host
|
|
335
|
+
* the canary runs and is not gated here.
|
|
336
|
+
*/
|
|
337
|
+
function hostCanaryGate(home, env, version, platform, warn) {
|
|
338
|
+
return (root, host) => {
|
|
339
|
+
if (host === 'fleet-local')
|
|
340
|
+
return true;
|
|
341
|
+
// agents-v2 is planned by `hq core hook-registration-plan`, which gates on
|
|
342
|
+
// coverage and never asks this gate; any other caller keeps the shell plan.
|
|
343
|
+
if (host === 'agents-v2')
|
|
344
|
+
return false;
|
|
345
|
+
const gate = checkHostCanary({ home, root, host, engineVersion: version, env, platform });
|
|
346
|
+
if (gate.skipped) {
|
|
347
|
+
warnOnce(`hq: warning: ${SKIP_CANARY_GATE_ENV} is set: bypassing the host canary gate and switching ${host} hook events to the new core (hq-hook ${version}) without a passing host canary (${gate.reason})`, warn);
|
|
348
|
+
}
|
|
349
|
+
else if (!gate.allowed) {
|
|
350
|
+
warnOnce(`hq: warning: flag ${CORE_NEXT_FLAG} is on, but ${host} has no passing host canary for hq-hook ${version} and this HQ root (${gate.reason}); keeping the old hook registrations on ${host}. Run scripts/host-canary.mjs --host ${host}, or bypass the gate with hq reindex --skip-host-canary-gate`, warn);
|
|
351
|
+
}
|
|
352
|
+
return gate.allowed;
|
|
353
|
+
};
|
|
354
|
+
}
|
|
327
355
|
/**
|
|
328
356
|
* [`coreNextTarget`], with any failure turned into one warning and null, so
|
|
329
357
|
* `hq install` and `hq reindex` go on with the old registrations.
|
|
@@ -333,11 +361,7 @@ export function coreNextTargetOrWarn(home, env = process.env, options = {}) {
|
|
|
333
361
|
return coreNextTarget(home, env, options);
|
|
334
362
|
}
|
|
335
363
|
catch (error) {
|
|
336
|
-
|
|
337
|
-
if (!warned.has(message)) {
|
|
338
|
-
warned.add(message);
|
|
339
|
-
(options.warn ?? ((text) => process.stderr.write(`${text}\n`)))(message);
|
|
340
|
-
}
|
|
364
|
+
warnOnce(`hq: warning: flag ${CORE_NEXT_FLAG} is on, but the new hook core cannot be used (${error.message}); keeping the old hook registrations`, options.warn);
|
|
341
365
|
return null;
|
|
342
366
|
}
|
|
343
367
|
}
|