@indigoai-us/hq-cli 5.345.250 → 5.345.252
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 +214 -0
- package/assets/scaffold/core/scripts/hq-session.sh +9 -0
- package/contracts/host-canary-release.json +9 -3
- package/dist/command-catalog.generated.d.ts +316 -2
- package/dist/command-catalog.generated.js +389 -2
- package/dist/commands/bot.js +12 -3
- package/dist/commands/core-bucket-c-work-mesh-offer-native.js +1 -1
- package/dist/commands/core-hq-session-binding.d.ts +140 -0
- package/dist/commands/core-hq-session-binding.js +363 -0
- package/dist/commands/core-hq-session-native.d.ts +23 -0
- package/dist/commands/core-hq-session-native.js +59 -9
- package/dist/commands/core-stop-autosave.js +1 -1
- package/dist/commands/core.js +10 -0
- package/dist/commands/doctor.d.ts +5 -1
- package/dist/commands/doctor.js +42 -5
- package/dist/commands/files.js +1 -1
- package/dist/commands/install-global.js +4 -2
- package/dist/commands/lanes.d.ts +2 -0
- package/dist/commands/lanes.js +9 -4
- package/dist/commands/logout.js +4 -0
- package/dist/commands/ontology-graph.d.ts +11 -2
- package/dist/commands/ontology-graph.js +130 -4
- package/dist/commands/report.js +35 -2
- package/dist/commands/sources.js +26 -8
- package/dist/commands/storage-gate.js +1 -1
- package/dist/commands/vault-retention-flag.js +2 -1
- package/dist/commands/whoami.js +1 -1
- package/dist/hq-cloud-sync-runner/bin/sync-runner.js +238 -221
- package/dist/hq-cloud-sync-runner/package.json +1 -1
- package/dist/index.js +3 -1
- package/dist/lib/agent-kit/inbox-poll-backoff-flag.js +1 -1
- package/dist/lib/agent-kit/mcp/tools.js +48 -0
- package/dist/lib/bot/fleet-bots-update-pass.js +1 -1
- package/dist/lib/bot/fleet-cron.d.ts +37 -0
- package/dist/lib/bot/fleet-cron.js +59 -12
- package/dist/lib/bot/fleet-local.d.ts +18 -0
- package/dist/lib/bot/fleet-local.js +51 -5
- package/dist/lib/bot/inbox-poll-backoff-flag.js +1 -1
- package/dist/lib/bot/signals-engine-flag.d.ts +1 -1
- package/dist/lib/bot/signals-engine-flag.js +1 -1
- package/dist/lib/cli-invite-nudge.js +1 -1
- package/dist/lib/client-version.d.ts +2 -0
- package/dist/lib/client-version.js +24 -0
- package/dist/lib/company-flag-gate.d.ts +30 -0
- package/dist/lib/company-flag-gate.js +104 -0
- package/dist/lib/core-utils/hook-timeout-debug-context-flag.js +1 -1
- package/dist/lib/daemon/flag.js +2 -1
- package/dist/lib/daemon/legacy-journal-gate.js +3 -1
- package/dist/lib/daemon/shared-flag-reads.js +1 -1
- package/dist/lib/doctor/checks/host-core.js +22 -4
- package/dist/lib/doctor/checks/jq.d.ts +27 -6
- package/dist/lib/doctor/checks/jq.js +46 -8
- package/dist/lib/doctor/client-health-reason-codes-flag.js +1 -1
- package/dist/lib/doctor/fix/refresh-sync-handoff.d.ts +1 -1
- package/dist/lib/doctor/fix/refresh-sync-handoff.js +1 -1
- package/dist/lib/flag-client-gate-headers.d.ts +38 -0
- package/dist/lib/flag-client-gate-headers.js +62 -0
- package/dist/lib/flag-client-headers.d.ts +15 -0
- package/dist/lib/flag-client-headers.js +25 -0
- package/dist/lib/flag-registry-worker-source.generated.d.ts +1 -1
- package/dist/lib/flag-registry-worker-source.generated.js +1 -1
- package/dist/lib/flag-registry-worker.js +35 -0
- package/dist/lib/flag-registry.d.ts +1 -20
- package/dist/lib/flag-registry.js +5 -81
- package/dist/lib/hook-engine/adapter-core-pin.d.ts +29 -0
- package/dist/lib/hook-engine/adapter-core-pin.js +29 -0
- package/dist/lib/hook-engine/coverage.d.ts +68 -8
- package/dist/lib/hook-engine/coverage.js +167 -25
- package/dist/lib/hook-engine/native-stop-compatibility.json +9 -4
- package/dist/lib/hook-engine/reconcile.js +3 -2
- package/dist/lib/hot-channels/graph-context.d.ts +26 -1
- package/dist/lib/hot-channels/graph-context.js +76 -9
- package/dist/lib/hot-channels/prompts/signals-pass.md +20 -0
- package/dist/lib/hot-channels/run.d.ts +1 -0
- package/dist/lib/hot-channels/signal-changes.d.ts +228 -0
- package/dist/lib/hot-channels/signal-changes.js +683 -0
- package/dist/lib/hot-channels/signals-pass.d.ts +24 -0
- package/dist/lib/hot-channels/signals-pass.js +240 -15
- package/dist/lib/lanes/outpost-worktree-pruner-flag.d.ts +1 -1
- package/dist/lib/lanes/outpost-worktree-pruner-flag.js +1 -1
- package/dist/lib/lanes/registry-flag.js +2 -1
- package/dist/lib/lanes/spawn.js +11 -1
- package/dist/lib/mesh/live/binding-intent.d.ts +61 -0
- package/dist/lib/mesh/live/binding-intent.js +201 -0
- package/dist/lib/mesh/live/binding-receipt.d.ts +157 -0
- package/dist/lib/mesh/live/binding-receipt.js +365 -0
- package/dist/lib/mesh/live/company-flag-refresh.js +1 -1
- package/dist/lib/mesh/live/daemon/doctor-telemetry.d.ts +39 -0
- package/dist/lib/mesh/live/daemon/doctor-telemetry.js +58 -0
- package/dist/lib/mesh/live/daemon/install.js +2 -1
- package/dist/lib/mesh/live/daemon/presence.js +9 -0
- package/dist/lib/mesh/live/daemon/run.d.ts +3 -0
- package/dist/lib/mesh/live/daemon/run.js +33 -1
- package/dist/lib/ontology-graph/lineage/index.d.ts +401 -0
- package/dist/lib/ontology-graph/lineage/index.js +1027 -0
- package/dist/lib/ontology-graph/model/files.d.ts +4 -0
- package/dist/lib/ontology-graph/model/files.js +23 -0
- package/dist/lib/ontology-graph/model/index.d.ts +65 -1
- package/dist/lib/ontology-graph/model/index.js +154 -18
- package/dist/lib/ontology-graph/model/pass-tasks.d.ts +84 -1
- package/dist/lib/ontology-graph/model/pass-tasks.js +173 -4
- package/dist/lib/ontology-graph/model/pass.d.ts +11 -0
- package/dist/lib/ontology-graph/model/pass.js +17 -10
- package/dist/lib/ontology-graph/model/pending-items.d.ts +39 -0
- package/dist/lib/ontology-graph/model/pending-items.js +136 -0
- package/dist/lib/ontology-graph/model/step.d.ts +47 -2
- package/dist/lib/ontology-graph/model/step.js +202 -36
- package/dist/lib/ontology-graph/model/tasks.d.ts +28 -4
- package/dist/lib/ontology-graph/model/tasks.js +48 -15
- package/dist/lib/ontology-graph/pages/render.d.ts +1 -1
- package/dist/lib/ontology-graph/pages/render.js +4 -3
- package/dist/lib/ontology-graph/read/brief.d.ts +13 -3
- package/dist/lib/ontology-graph/read/brief.js +349 -67
- package/dist/lib/ontology-graph/read/index.d.ts +5 -1
- package/dist/lib/ontology-graph/read/index.js +174 -30
- package/dist/lib/ontology-graph/read/lineage.d.ts +101 -0
- package/dist/lib/ontology-graph/read/lineage.js +262 -0
- package/dist/lib/ontology-graph/read/reader-setting.d.ts +2 -0
- package/dist/lib/ontology-graph/read/reader-setting.js +4 -1
- package/dist/lib/ontology-graph/remodel/index.d.ts +174 -0
- package/dist/lib/ontology-graph/remodel/index.js +450 -0
- package/dist/lib/ontology-graph/replay/buffered-store.js +17 -0
- package/dist/lib/ontology-graph/replay/engine.d.ts +32 -1
- package/dist/lib/ontology-graph/replay/engine.js +213 -8
- package/dist/lib/ontology-graph/replay/extractors.d.ts +26 -0
- package/dist/lib/ontology-graph/replay/extractors.js +25 -1
- package/dist/lib/ontology-graph/replay/index.d.ts +2 -0
- package/dist/lib/ontology-graph/replay/index.js +120 -8
- package/dist/lib/ontology-graph/replay/signal-changes.d.ts +118 -0
- package/dist/lib/ontology-graph/replay/signal-changes.js +687 -0
- package/dist/lib/ontology-graph/schema/authority.d.ts +14 -5
- package/dist/lib/ontology-graph/schema/authority.js +13 -3
- package/dist/lib/ontology-graph/schema/decision-status.d.ts +18 -0
- package/dist/lib/ontology-graph/schema/decision-status.js +20 -0
- package/dist/lib/ontology-graph/schema/index.d.ts +2 -1
- package/dist/lib/ontology-graph/schema/index.js +2 -1
- package/dist/lib/ontology-graph/setup/index.d.ts +88 -0
- package/dist/lib/ontology-graph/setup/index.js +499 -0
- package/dist/lib/ontology-graph/types.d.ts +21 -0
- package/dist/lib/ontology-graph/types.js +5 -0
- package/dist/lib/search-index/index.d.ts +33 -1
- package/dist/lib/search-index/index.js +180 -25
- package/dist/lib/search-index/qmd-exit-diagnostics.d.ts +7 -0
- package/dist/lib/search-index/qmd-exit-diagnostics.js +25 -1
- package/dist/lib/signals/adapters-catalog.js +1 -1
- package/dist/lib/signals/failure-alert.js +4 -5
- package/dist/lib/signals/steps/adapters.js +3 -0
- package/dist/lib/sync-core/engine-holds.d.ts +1 -0
- package/dist/lib/sync-core/engine-holds.js +26 -0
- package/dist/lib/sync-core/engine-home.d.ts +3 -0
- package/dist/lib/sync-core/engine-home.js +41 -1
- package/dist/lib/sync-core/flag.js +2 -1
- package/dist/lib/sync-core/legacy-journal-export-child.js +5 -3
- package/dist/lib/sync-core/legacy-journal-export.d.ts +23 -4
- package/dist/lib/sync-core/legacy-journal-export.js +120 -55
- package/dist/lib/sync-core/reconcile.d.ts +2 -1
- package/dist/lib/sync-core/reconcile.js +30 -5
- package/dist/lib/sync-invalid-entity-warning.js +2 -1
- package/dist/lib/windows/install-followup.d.ts +41 -0
- package/dist/lib/windows/install-followup.js +87 -0
- package/dist/lib/windows/jq.d.ts +59 -0
- package/dist/lib/windows/jq.js +154 -3
- package/dist/lib/windows/user-path.d.ts +5 -0
- package/dist/lib/windows/user-path.js +1 -1
- package/dist/lib/work-context/auto-bind.d.ts +12 -0
- package/dist/lib/work-context/auto-bind.js +49 -3
- package/dist/lib/work-context/organize.d.ts +4 -2
- package/dist/lib/work-context/organize.js +18 -8
- package/dist/lib/work-context/reconcile.js +16 -1
- package/dist/main.js +12 -1
- package/dist/utils/client-health-contract.d.ts +30 -0
- package/dist/utils/client-health-contract.js +111 -0
- package/dist/utils/client-health.d.ts +5 -2
- package/dist/utils/client-health.js +74 -5
- package/dist/utils/exclusive-lock.d.ts +5 -1
- package/dist/utils/exclusive-lock.js +9 -2
- package/dist/utils/host-registration.d.ts +7 -0
- package/dist/utils/host-registration.js +10 -1
- package/dist/utils/pid.d.ts +31 -0
- package/dist/utils/pid.js +65 -0
- package/dist/utils/resident-package-preload.js +12 -4
- package/dist/utils/sentry-fingerprint.js +3 -0
- package/dist/utils/sync-person.d.ts +15 -0
- package/dist/utils/sync-person.js +74 -0
- package/package.json +8 -8
- package/scripts/install-hook-engine.mjs +5 -3
|
@@ -5,6 +5,39 @@ import { createFlagClient } from "@indigoai-us/hq-flags-client";
|
|
|
5
5
|
import { decodeJwtClaims } from "./daemon/machine-token-identity.js";
|
|
6
6
|
const data = workerData;
|
|
7
7
|
const endpoint = data.endpoint;
|
|
8
|
+
/**
|
|
9
|
+
* Client-gate headers for hq-pro `src/flags/client-gates.ts`. This worker runs
|
|
10
|
+
* as `new Worker(source, { eval: true })` with no module URL, so it must not
|
|
11
|
+
* import cli-version.ts (which reads package.json relative to its own file) and
|
|
12
|
+
* keeps its imports to the ones above. The parent passes the version in
|
|
13
|
+
* workerData. `flag-client-gate-headers.ts` is the main-thread copy of this
|
|
14
|
+
* logic; flag-registry-worker-client-gate-headers.test.ts runs this one.
|
|
15
|
+
* A missing or unusable version sends no x-hq-client-version header (the
|
|
16
|
+
* server stores null and fails gated rows closed); the request still goes out.
|
|
17
|
+
*/
|
|
18
|
+
function clientGateFetch() {
|
|
19
|
+
const base = globalThis.fetch;
|
|
20
|
+
if (typeof base !== "function")
|
|
21
|
+
return undefined;
|
|
22
|
+
const gate = {};
|
|
23
|
+
const version = typeof data.clientVersion === "string" ? data.clientVersion.trim() : "";
|
|
24
|
+
if (version.length > 0 && version.length <= 64)
|
|
25
|
+
gate["x-hq-client-version"] = version;
|
|
26
|
+
gate["x-hq-client-platform"] = process.platform === "win32" ? "windows" : process.platform;
|
|
27
|
+
return ((input, init) => {
|
|
28
|
+
const headers = {};
|
|
29
|
+
const given = init?.headers;
|
|
30
|
+
if (Array.isArray(given))
|
|
31
|
+
for (const [key, value] of given)
|
|
32
|
+
headers[key] = value;
|
|
33
|
+
else if (given instanceof Headers)
|
|
34
|
+
given.forEach((value, key) => { headers[key] = value; });
|
|
35
|
+
else if (given)
|
|
36
|
+
Object.assign(headers, given);
|
|
37
|
+
return base(input, { ...init, headers: { ...headers, ...gate } });
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
const gatedFetch = clientGateFetch();
|
|
8
41
|
const COMPANY_UID_RE = /^cmp_[A-Za-z0-9]{3,128}$/;
|
|
9
42
|
const COMPANY_SLUG_RE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;
|
|
10
43
|
async function refresh() {
|
|
@@ -26,6 +59,7 @@ async function refresh() {
|
|
|
26
59
|
getToken: () => idToken,
|
|
27
60
|
refreshIntervalMs: 0,
|
|
28
61
|
onError: () => { },
|
|
62
|
+
...(gatedFetch ? { fetch: gatedFetch } : {}),
|
|
29
63
|
});
|
|
30
64
|
await client.ready();
|
|
31
65
|
const snapshot = client.snapshot();
|
|
@@ -41,6 +75,7 @@ async function refresh() {
|
|
|
41
75
|
getToken: () => idToken,
|
|
42
76
|
refreshIntervalMs: 0,
|
|
43
77
|
onError: () => { },
|
|
78
|
+
...(gatedFetch ? { fetch: gatedFetch } : {}),
|
|
44
79
|
});
|
|
45
80
|
try {
|
|
46
81
|
await personClient.ready();
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* keep a short-lived, offline CLI alive until the client's network deadline.
|
|
7
7
|
*/
|
|
8
8
|
import { type WorkerOptions } from "node:worker_threads";
|
|
9
|
-
import {
|
|
9
|
+
import { type FlagClient, type FlagLookupOptions, type FlagSnapshot } from "@indigoai-us/hq-flags-client";
|
|
10
10
|
type FlagRegistrySentry = Pick<typeof import("@sentry/node"), "captureException" | "withScope">;
|
|
11
11
|
export { resolveProcessFlagCompanyContext } from "./process-flag-company-context.js";
|
|
12
12
|
export type { ProcessFlagCompanyContext } from "./process-flag-company-context.js";
|
|
@@ -35,11 +35,6 @@ export interface FlagRegistryDependencies {
|
|
|
35
35
|
forceRefresh?: boolean;
|
|
36
36
|
captureWorkerFailure?: (error: Error, tags: Record<string, string>) => void;
|
|
37
37
|
}
|
|
38
|
-
export interface CompanyFlagGateDependencies {
|
|
39
|
-
endpoint?: string;
|
|
40
|
-
requestTimeoutMs?: number;
|
|
41
|
-
createClient?: typeof createFlagClient;
|
|
42
|
-
}
|
|
43
38
|
/** Extract only a CLI-level --company option; values after `--` belong to child commands. */
|
|
44
39
|
export declare function explicitCompanyScopeFromArgv(argv: readonly string[]): string | undefined;
|
|
45
40
|
/** Wait briefly for the current company refresh to persist or report completion. */
|
|
@@ -64,20 +59,6 @@ export declare function refreshFlagRegistrySnapshot(timeoutMs?: number): Promise
|
|
|
64
59
|
* falls through to the exact legacy predicate owned by the caller.
|
|
65
60
|
*/
|
|
66
61
|
export declare function resolveFlagGate(reader: FlagReader | null | undefined, flagKey: string, lookup: FlagLookupOptions, legacyFallback: () => boolean, env?: NodeJS.ProcessEnv): boolean;
|
|
67
|
-
/** Resolve one explicit company's flag without relying on process-wide binding. */
|
|
68
|
-
export declare function resolveCompanyFlagGate(companyUid: string, idToken: string, flagKey: string, lookup: FlagLookupOptions, legacyFallback: () => boolean, dependencies?: CompanyFlagGateDependencies): Promise<boolean>;
|
|
69
|
-
/**
|
|
70
|
-
* Read one explicit company's flag and say whether the registry answered.
|
|
71
|
-
*
|
|
72
|
-
* Returns the evaluator's resolution when the registry snapshot loaded (an
|
|
73
|
-
* absent row resolves to `lookup.fallback`, source "fallback"), a
|
|
74
|
-
* "local-override" resolution when the process sets one, and null when the
|
|
75
|
-
* registry could not be read: no company uid or token, a client error, a
|
|
76
|
-
* timeout, or a failed load. Callers that keep a last-known value (ingest
|
|
77
|
-
* kill switches) use the null to tell an unreadable registry from an answer.
|
|
78
|
-
* Bounded by the client's request timeout, like `resolveCompanyFlagGate`.
|
|
79
|
-
*/
|
|
80
|
-
export declare function readCompanyFlag(companyUid: string, idToken: string, flagKey: string, lookup: FlagLookupOptions, dependencies?: CompanyFlagGateDependencies): Promise<FlagResolution | null>;
|
|
81
62
|
/** Resolve a process gate against the shared snapshot reader, when configured. */
|
|
82
63
|
export declare function resolveProcessFlagGate(flagKey: string, lookup: FlagLookupOptions, legacyFallback: () => boolean, companyUid?: string, options?: {
|
|
83
64
|
acceptStaleSnapshot?: boolean;
|
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
* keep a short-lived, offline CLI alive until the client's network deadline.
|
|
7
7
|
*/
|
|
8
8
|
import { Worker } from "node:worker_threads";
|
|
9
|
-
import {
|
|
9
|
+
import { isFlagSnapshot, readLocalOverride, resolveFlag, } from "@indigoai-us/hq-flags-client";
|
|
10
|
+
import { readClientVersion } from "./client-version.js";
|
|
10
11
|
import { resolveFlagRegistryEndpoint, } from "./flag-registry-endpoint.js";
|
|
11
12
|
import { FLAG_REGISTRY_WORKER_SOURCE } from "./flag-registry-worker-source.generated.js";
|
|
12
13
|
import { resolveFlagSnapshotCompanyUid, resolveProcessFlagCompanyContext } from "./process-flag-company-context.js";
|
|
@@ -214,6 +215,9 @@ export function kickFlagRegistryReadiness(dependencies = {}) {
|
|
|
214
215
|
...((companyUid || company.companySlug) && dependencies.idToken
|
|
215
216
|
? { idToken: dependencies.idToken }
|
|
216
217
|
: {}),
|
|
218
|
+
// The eval'd worker has no module URL and cannot read package.json
|
|
219
|
+
// itself; it sends this as x-hq-client-version (none when unreadable).
|
|
220
|
+
clientVersion: readClientVersion(),
|
|
217
221
|
},
|
|
218
222
|
eval: true,
|
|
219
223
|
};
|
|
@@ -333,86 +337,6 @@ export function resolveFlagGate(reader, flagKey, lookup, legacyFallback, env = p
|
|
|
333
337
|
return localOverrideOrFallback(flagKey, legacyFallback, env);
|
|
334
338
|
}
|
|
335
339
|
}
|
|
336
|
-
/** Resolve one explicit company's flag without relying on process-wide binding. */
|
|
337
|
-
export async function resolveCompanyFlagGate(companyUid, idToken, flagKey, lookup, legacyFallback, dependencies = {}) {
|
|
338
|
-
const localOverride = processLocalOverride(flagKey);
|
|
339
|
-
if (localOverride !== null)
|
|
340
|
-
return localOverride;
|
|
341
|
-
const targetCompanyUid = normalizedCompanyUid(companyUid);
|
|
342
|
-
if (!targetCompanyUid || idToken.trim() === "") {
|
|
343
|
-
return localOverrideOrFallback(flagKey, legacyFallback);
|
|
344
|
-
}
|
|
345
|
-
let client;
|
|
346
|
-
try {
|
|
347
|
-
client = (dependencies.createClient ?? createFlagClient)({
|
|
348
|
-
endpoint: resolveFlagRegistryEndpoint(dependencies.endpoint, process.env),
|
|
349
|
-
getToken: () => idToken,
|
|
350
|
-
companyUid: targetCompanyUid,
|
|
351
|
-
refreshIntervalMs: 0,
|
|
352
|
-
requestTimeoutMs: dependencies.requestTimeoutMs ?? 1_200,
|
|
353
|
-
onError: (error) => {
|
|
354
|
-
const errorClass = error instanceof Error ? error.name : "unknown";
|
|
355
|
-
console.error(`hq: Could not resolve a company flag (${errorClass}); using its fallback.`);
|
|
356
|
-
},
|
|
357
|
-
});
|
|
358
|
-
await client.ready();
|
|
359
|
-
return resolveFlagGate(client, flagKey, lookup, legacyFallback);
|
|
360
|
-
}
|
|
361
|
-
catch (error) {
|
|
362
|
-
const errorClass = error instanceof Error ? error.name : "unknown";
|
|
363
|
-
console.error(`hq: Could not resolve a company flag (${errorClass}); using its fallback.`);
|
|
364
|
-
return localOverrideOrFallback(flagKey, legacyFallback);
|
|
365
|
-
}
|
|
366
|
-
finally {
|
|
367
|
-
client?.close();
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
/**
|
|
371
|
-
* Read one explicit company's flag and say whether the registry answered.
|
|
372
|
-
*
|
|
373
|
-
* Returns the evaluator's resolution when the registry snapshot loaded (an
|
|
374
|
-
* absent row resolves to `lookup.fallback`, source "fallback"), a
|
|
375
|
-
* "local-override" resolution when the process sets one, and null when the
|
|
376
|
-
* registry could not be read: no company uid or token, a client error, a
|
|
377
|
-
* timeout, or a failed load. Callers that keep a last-known value (ingest
|
|
378
|
-
* kill switches) use the null to tell an unreadable registry from an answer.
|
|
379
|
-
* Bounded by the client's request timeout, like `resolveCompanyFlagGate`.
|
|
380
|
-
*/
|
|
381
|
-
export async function readCompanyFlag(companyUid, idToken, flagKey, lookup, dependencies = {}) {
|
|
382
|
-
const localOverride = processLocalOverride(flagKey);
|
|
383
|
-
if (localOverride !== null)
|
|
384
|
-
return { value: localOverride, source: "local-override" };
|
|
385
|
-
const targetCompanyUid = normalizedCompanyUid(companyUid);
|
|
386
|
-
if (!targetCompanyUid || idToken.trim() === "")
|
|
387
|
-
return null;
|
|
388
|
-
let client;
|
|
389
|
-
try {
|
|
390
|
-
client = (dependencies.createClient ?? createFlagClient)({
|
|
391
|
-
endpoint: resolveFlagRegistryEndpoint(dependencies.endpoint, process.env),
|
|
392
|
-
getToken: () => idToken,
|
|
393
|
-
companyUid: targetCompanyUid,
|
|
394
|
-
refreshIntervalMs: 0,
|
|
395
|
-
requestTimeoutMs: dependencies.requestTimeoutMs ?? 1_200,
|
|
396
|
-
onError: (error) => {
|
|
397
|
-
const errorClass = error instanceof Error ? error.name : "unknown";
|
|
398
|
-
console.error(`hq: Could not read a company flag (${errorClass}).`);
|
|
399
|
-
},
|
|
400
|
-
});
|
|
401
|
-
await client.ready();
|
|
402
|
-
// ready() resolves after a failed load too; no snapshot means no answer.
|
|
403
|
-
if (client.snapshot() === null)
|
|
404
|
-
return null;
|
|
405
|
-
return client.explain(flagKey, lookup);
|
|
406
|
-
}
|
|
407
|
-
catch (error) {
|
|
408
|
-
const errorClass = error instanceof Error ? error.name : "unknown";
|
|
409
|
-
console.error(`hq: Could not read a company flag (${errorClass}).`);
|
|
410
|
-
return null;
|
|
411
|
-
}
|
|
412
|
-
finally {
|
|
413
|
-
client?.close();
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
340
|
/** Resolve a process gate against the shared snapshot reader, when configured. */
|
|
417
341
|
export function resolveProcessFlagGate(flagKey, lookup, legacyFallback, companyUid, options = {}) {
|
|
418
342
|
const defaultOnKillSwitch = options.killSwitchWithoutCompany === true;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one place the classifying `core/scripts/lib/hook-adapter-core.sh`
|
|
3
|
+
* revision is pinned (hq-core-staging #2119, ITEM 502 / 502b): the revision
|
|
4
|
+
* whose `hqad_classify_exec` reads both `run --host claude <Event> --hq-root
|
|
5
|
+
* <root> [--global]` and the `stable` symlink alias in `.claude/settings.json`
|
|
6
|
+
* as `master\t<Event>`.
|
|
7
|
+
*
|
|
8
|
+
* Every list that names this revision reads it from here:
|
|
9
|
+
* - TypeScript: `CODEX_POST_TOOL_USE_GENERATIONS`, `GROK_POST_TOOL_USE_GENERATIONS`,
|
|
10
|
+
* `FLEET_LOCAL_ADAPTER_CORE` and `CLASSIFYING_ADAPTER_CORE_HASHES` (coverage.ts);
|
|
11
|
+
* - Rust: `crates/hq-hook/src/adapter_core_pin.rs` reads this file at build
|
|
12
|
+
* time (`include_str!`), and `post_hooks/codex.rs` `POST_TOOL_USE_GENERATIONS`,
|
|
13
|
+
* `post_hooks/grok.rs` `ADAPTER_GENERATIONS` and `host/fleet/local_pre.rs`
|
|
14
|
+
* `RELEASED_CORE_SHA256` use that constant.
|
|
15
|
+
* `coverage-adapter-core-pin.test.ts` and the Rust `adapter_core_pin` tests
|
|
16
|
+
* fail when any of them carries the hash as a literal or the fixture bytes
|
|
17
|
+
* stop hashing to it.
|
|
18
|
+
*
|
|
19
|
+
* To re-pin (after hq-core-staging #2119 merges): set the hash on the export
|
|
20
|
+
* line below (keep it on one line, single-quoted: the Rust build parses it),
|
|
21
|
+
* replace the bytes at `CLASSIFYING_ADAPTER_CORE_FIXTURE` with the merged
|
|
22
|
+
* file, and update that file's record in test/fixtures/PROVENANCE.md.
|
|
23
|
+
*/
|
|
24
|
+
export declare const CLASSIFYING_ADAPTER_CORE_SHA256 = "cf1abd5c832722d26a46ced0694e8a3cd0d70ff30194a03fb2ce989289a8621c";
|
|
25
|
+
/** Released v16.0.51 revision still supported by the Claude project adapter hold. */
|
|
26
|
+
export declare const RELEASED_CLASSIFYING_ADAPTER_CORE_SHA256 = "09f5a3e05db016257f4515cf7e0101a9a34368a04c975337a5ce22f8dfe3dfb0";
|
|
27
|
+
/** The fixture copy of the pinned revision, under crates/hq-hook/tests/fixtures. */
|
|
28
|
+
export declare const CLASSIFYING_ADAPTER_CORE_FIXTURE = "adapter-stable-alias/core/scripts/lib/hook-adapter-core.sh";
|
|
29
|
+
//# sourceMappingURL=adapter-core-pin.d.ts.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one place the classifying `core/scripts/lib/hook-adapter-core.sh`
|
|
3
|
+
* revision is pinned (hq-core-staging #2119, ITEM 502 / 502b): the revision
|
|
4
|
+
* whose `hqad_classify_exec` reads both `run --host claude <Event> --hq-root
|
|
5
|
+
* <root> [--global]` and the `stable` symlink alias in `.claude/settings.json`
|
|
6
|
+
* as `master\t<Event>`.
|
|
7
|
+
*
|
|
8
|
+
* Every list that names this revision reads it from here:
|
|
9
|
+
* - TypeScript: `CODEX_POST_TOOL_USE_GENERATIONS`, `GROK_POST_TOOL_USE_GENERATIONS`,
|
|
10
|
+
* `FLEET_LOCAL_ADAPTER_CORE` and `CLASSIFYING_ADAPTER_CORE_HASHES` (coverage.ts);
|
|
11
|
+
* - Rust: `crates/hq-hook/src/adapter_core_pin.rs` reads this file at build
|
|
12
|
+
* time (`include_str!`), and `post_hooks/codex.rs` `POST_TOOL_USE_GENERATIONS`,
|
|
13
|
+
* `post_hooks/grok.rs` `ADAPTER_GENERATIONS` and `host/fleet/local_pre.rs`
|
|
14
|
+
* `RELEASED_CORE_SHA256` use that constant.
|
|
15
|
+
* `coverage-adapter-core-pin.test.ts` and the Rust `adapter_core_pin` tests
|
|
16
|
+
* fail when any of them carries the hash as a literal or the fixture bytes
|
|
17
|
+
* stop hashing to it.
|
|
18
|
+
*
|
|
19
|
+
* To re-pin (after hq-core-staging #2119 merges): set the hash on the export
|
|
20
|
+
* line below (keep it on one line, single-quoted: the Rust build parses it),
|
|
21
|
+
* replace the bytes at `CLASSIFYING_ADAPTER_CORE_FIXTURE` with the merged
|
|
22
|
+
* file, and update that file's record in test/fixtures/PROVENANCE.md.
|
|
23
|
+
*/
|
|
24
|
+
export const CLASSIFYING_ADAPTER_CORE_SHA256 = 'cf1abd5c832722d26a46ced0694e8a3cd0d70ff30194a03fb2ce989289a8621c';
|
|
25
|
+
/** Released v16.0.51 revision still supported by the Claude project adapter hold. */
|
|
26
|
+
export const RELEASED_CLASSIFYING_ADAPTER_CORE_SHA256 = '09f5a3e05db016257f4515cf7e0101a9a34368a04c975337a5ce22f8dfe3dfb0';
|
|
27
|
+
/** The fixture copy of the pinned revision, under crates/hq-hook/tests/fixtures. */
|
|
28
|
+
export const CLASSIFYING_ADAPTER_CORE_FIXTURE = 'adapter-stable-alias/core/scripts/lib/hook-adapter-core.sh';
|
|
29
|
+
//# sourceMappingURL=adapter-core-pin.js.map
|
|
@@ -169,14 +169,15 @@ export declare function coveredOn(covers: Readonly<Record<string, readonly strin
|
|
|
169
169
|
/** The old dispatcher's hooks for `event` on `host` that the engine does not cover. */
|
|
170
170
|
export declare function uncoveredHooks(root: string, host: CoreNextHost, event: string, covers: Readonly<Record<string, readonly string[]>> | undefined, env?: NodeJS.ProcessEnv): string[];
|
|
171
171
|
/**
|
|
172
|
-
* The script revisions the native SessionStart master rebuilds (hq-core v16.0.48 through v16.0.50
|
|
172
|
+
* The script revisions the native SessionStart master rebuilds (hq-core v16.0.48 through v16.0.50,
|
|
173
|
+
* and the hq-core-staging fd709b39a shim and hq-session.sh):
|
|
173
174
|
* `hqd_open.rs` (the daemon shim and its flag-cache library), `session_set/mod.rs` `SCRIPTS`,
|
|
174
175
|
* `ID_LIBS` and `CAPABILITY_LIBS` (hq-session.sh and the two libraries it sources) and
|
|
175
176
|
* `foreign_bind.rs` `RESOLVE_REVISIONS` (resolve-company.sh). The native port
|
|
176
177
|
* refuses a SessionStart that reaches any other revision, and Claude Code drops a SessionStart
|
|
177
178
|
* refusal, so the session would start with no SessionStart hook at all.
|
|
178
179
|
*/
|
|
179
|
-
export declare const SESSION_START_PINS: ReadonlyArray<readonly [string, string]>;
|
|
180
|
+
export declare const SESSION_START_PINS: ReadonlyArray<readonly [string, readonly string[]]>;
|
|
180
181
|
/**
|
|
181
182
|
* Why SessionStart must stay on the shell registration in `root`: one of [`SESSION_START_PINS`] is
|
|
182
183
|
* missing, cannot be read, or is not the pinned revision. A registration-time hold, as for Codex
|
|
@@ -226,12 +227,20 @@ export declare function pinnedFilesHold(root: string, event: string, files: read
|
|
|
226
227
|
* order it reads them. Each is skipped there when it is not a file.
|
|
227
228
|
*/
|
|
228
229
|
export declare const GROK_STOP_OBSERVE_PINS: readonly PinnedFile[];
|
|
230
|
+
/** The turn-end leaf revision (b373b582, hq-core v16.0.48 to v16.0.50) that sources `session-id.sh`. */
|
|
231
|
+
export declare const GROK_STOP_OBSERVE_SESSION_ID_LEAF = "b373b582a906b0993a3ce56aa43c1ef0aec6668a6b7e150d59ef3214b7d65b70";
|
|
232
|
+
/**
|
|
233
|
+
* The session library the b373b582 leaf sources (grok_stop_observe.rs `SESSION_ID_LIB_SHA256`).
|
|
234
|
+
* The native member reads it only beside that leaf, and only when no variable names the session;
|
|
235
|
+
* the hold checks it whenever the leaf is b373b582, which can only keep more roots on the shell.
|
|
236
|
+
*/
|
|
237
|
+
export declare const GROK_STOP_OBSERVE_SESSION_ID_PIN: PinnedFile;
|
|
229
238
|
/**
|
|
230
239
|
* Why a Grok StopCancelled or StopFailure (`event`) must stay on the shell adapter in `root`: the
|
|
231
|
-
* turn-end leaf or one of its two libraries is a revision the native member refuses
|
|
232
|
-
* (grok_stop_observe.rs `plan`). As there, nothing
|
|
233
|
-
* `.claude/hooks/hook-gate.sh` or no leaf: the member writes nothing and
|
|
234
|
-
* when the member accepts the root's files.
|
|
240
|
+
* turn-end leaf or one of its two libraries is a revision the native member refuses, or the leaf is
|
|
241
|
+
* b373b582 and `core/scripts/lib/session-id.sh` is (grok_stop_observe.rs `plan`). As there, nothing
|
|
242
|
+
* is read in a root with no `.claude/hooks/hook-gate.sh` or no leaf: the member writes nothing and
|
|
243
|
+
* refuses no file. Null when the member accepts the root's files.
|
|
235
244
|
*/
|
|
236
245
|
export declare function grokStopObserveHold(root: string, event: string): string | null;
|
|
237
246
|
/**
|
|
@@ -257,7 +266,9 @@ export declare function grokPreToolUseHold(root: string, shadow: boolean): strin
|
|
|
257
266
|
/**
|
|
258
267
|
* The dispatcher files the native PreToolUse master model reproduces, in its check order:
|
|
259
268
|
* crates/hq-hook/src/pre_tool_use_master.rs `DISPATCHER_PINS`. master-hook.sh is v16.0.48 (1a2439ae),
|
|
260
|
-
* v16.0.50 (774bca73) or v16.0.49 (d5049d5f);
|
|
269
|
+
* v16.0.50 (774bca73) or v16.0.49 (d5049d5f); hqd-hook-shim.sh is the released ab289ac0 or the
|
|
270
|
+
* hq-core-staging fd709b39a ee5e9fe7, and session-id.sh the released 2ebbc508 or the fd709b39a
|
|
271
|
+
* d6a04155; every other file is one revision.
|
|
261
272
|
*/
|
|
262
273
|
export declare const PRE_TOOL_USE_DISPATCHER_PINS: readonly PinnedFile[];
|
|
263
274
|
/** The Codex adapter the model reproduces on Codex only (pre_tool_use_master.rs `CODEX_ADAPTER_PIN`). */
|
|
@@ -331,7 +342,7 @@ export declare function mergedWriteGuardHold(root: string, event: string): strin
|
|
|
331
342
|
*/
|
|
332
343
|
export declare function preToolUseHold(root: string, host: CoreNextHost, hooks?: readonly string[]): string | null;
|
|
333
344
|
/**
|
|
334
|
-
* The scripts the native first-prompt company bind rebuilds
|
|
345
|
+
* The scripts the native first-prompt company bind rebuilds:
|
|
335
346
|
* `MENTION_LIBS` in crates/hq-hook/src/prompt_company_mention/bind.rs, then `SCRIPTS`, `ID_LIBS` and
|
|
336
347
|
* `CAPABILITY_LIBS` in crates/hq-hook/src/session_set/mod.rs.
|
|
337
348
|
*/
|
|
@@ -399,4 +410,53 @@ export declare function subagentScopeLibraryHold(root: string, event: string): s
|
|
|
399
410
|
/** Records the environment `target` was resolved under; returns `target`. */
|
|
400
411
|
export declare function resolvedUnder<T extends CoreNextTarget | null>(target: T, env: NodeJS.ProcessEnv): T;
|
|
401
412
|
export declare function forHost(target: CoreNextTarget | null, root: string, host: CoreNextHost, env?: NodeJS.ProcessEnv): CoreNextTarget | null;
|
|
413
|
+
/**
|
|
414
|
+
* Revisions of `core/scripts/lib/hook-adapter-core.sh` whose `hqad_classify_exec`
|
|
415
|
+
* classifies both `run --host claude <Event> --hq-root <root> [--global]` and the
|
|
416
|
+
* `stable` symlink alias as `master\t<Event>` (hq-core-staging #2119, ITEM 502/502b).
|
|
417
|
+
* Both the released revision and the current pin are recorded in `adapter-core-pin.ts`.
|
|
418
|
+
*/
|
|
419
|
+
export declare const CLASSIFYING_ADAPTER_CORE_HASHES: readonly string[];
|
|
420
|
+
/**
|
|
421
|
+
* Returns whether the HQ root's `core/scripts/lib/hook-adapter-core.sh` is a
|
|
422
|
+
* pinned revision known to classify new-core `run --host claude` and `stable`
|
|
423
|
+
* entries in `.claude/settings.json`.
|
|
424
|
+
*/
|
|
425
|
+
export declare function adapterCoreClassifiesNewCore(root: string): boolean;
|
|
426
|
+
/** The Codex and Grok Build shell adapters present in `root`; each reads `<root>/.claude/settings.json`. */
|
|
427
|
+
export declare function presentAdapterHosts(root: string): Array<'codex' | 'grok'>;
|
|
428
|
+
/**
|
|
429
|
+
* Why `event` must stay on `master-hook.sh` in `<root>/.claude/settings.json`
|
|
430
|
+
* (which adapter hosts hold it there), or null when it may switch (ITEM 502 /
|
|
431
|
+
* 502b). The Codex and Grok Build shell
|
|
432
|
+
* adapters find their master record in that file through
|
|
433
|
+
* `core/scripts/lib/hook-adapter-core.sh`, and an unpatched revision sees only
|
|
434
|
+
* `master-hook.sh` entries. So while a present adapter host keeps any event
|
|
435
|
+
* that reads those entries on its shell adapter, the Claude Code project entry
|
|
436
|
+
* stays on master-hook.sh, whatever holds the host there: its canary (failed,
|
|
437
|
+
* missing, stale, or a hook-started reindex keeping the host's current core),
|
|
438
|
+
* a coverage hold for that one event (SubagentStop on Codex), or no new core
|
|
439
|
+
* at all (flag off, kill switch). `--skip-host-canary-gate` passes every
|
|
440
|
+
* canary but leaves the coverage holds, so it cannot switch such an event
|
|
441
|
+
* either.
|
|
442
|
+
*
|
|
443
|
+
* Grok Build StopCancelled and StopFailure, which its adapter runs as the
|
|
444
|
+
* settings.json `Stop` entries, are not tied to Claude Code `Stop` here: their
|
|
445
|
+
* own switch already reads whether master-hook is among those entries
|
|
446
|
+
* ([`grokStopObserveUncovered`]), so they follow the Claude Code entry rather
|
|
447
|
+
* than hold it (tying them both ways would hold both forever).
|
|
448
|
+
*
|
|
449
|
+
* `hq reindex` ([`claudeProjectTarget`]) and `hq doctor`
|
|
450
|
+
* (`host-core:claude-project`) both answer from here: each asks what the
|
|
451
|
+
* adapter hosts' own reindex registers, through [`forHost`] on the same target.
|
|
452
|
+
*
|
|
453
|
+
* User-level `~/.claude/settings.json` is never read by the Codex or Grok
|
|
454
|
+
* adapters and is unaffected.
|
|
455
|
+
*/
|
|
456
|
+
export declare function claudeProjectAdapterHold(root: string, event: string, coreNext: CoreNextTarget | null, env?: NodeJS.ProcessEnv): string | null;
|
|
457
|
+
/**
|
|
458
|
+
* `claudeNext` narrowed for `<root>/.claude/settings.json` to the events
|
|
459
|
+
* [`claudeProjectAdapterHold`] lets switch; null when none does.
|
|
460
|
+
*/
|
|
461
|
+
export declare function claudeProjectTarget(coreNext: CoreNextTarget | null, claudeNext: CoreNextTarget | null, root: string, env?: NodeJS.ProcessEnv): CoreNextTarget | null;
|
|
402
462
|
//# sourceMappingURL=coverage.d.ts.map
|