@indigoai-us/hq-cli 5.345.269 → 5.345.270
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 +25 -0
- package/contracts/host-canary-release.json +7 -7
- package/dist/lib/hook-engine/native-stop-compatibility.json +2 -1
- package/dist/lib/hook-engine/reconcile.js +8 -0
- package/dist/lib/hook-engine/stable-heal.d.ts +17 -1
- package/dist/lib/hook-engine/stable-heal.js +42 -5
- package/dist/lib/hook-engine/stable-link.d.ts +70 -0
- package/dist/lib/hook-engine/stable-link.js +300 -0
- package/dist/lib/install/hook-target.js +4 -1
- package/dist/lib/signals/steps/extract.d.ts +27 -7
- package/dist/lib/signals/steps/extract.js +88 -87
- package/dist/utils/hook-trust.js +7 -1
- package/dist/utils/host-registration.d.ts +12 -35
- package/dist/utils/host-registration.js +47 -177
- package/package.json +7 -7
|
@@ -411,8 +411,8 @@ export function buildExtractPrompt(input) {
|
|
|
411
411
|
// A fleet turn (hq-fleet-local complete) has no tools, like codex: the host
|
|
412
412
|
// puts the item in the prompt.
|
|
413
413
|
const hostRead = input.runtime === "codex" || input.runtime === "fleet";
|
|
414
|
-
// The no-shell runtimes return
|
|
415
|
-
const
|
|
414
|
+
// The no-shell runtimes return structured candidates as JSON data for the host to write.
|
|
415
|
+
const jsonCandidates = input.runtime === "grok" || hostRead;
|
|
416
416
|
const tool = hostRead ? "terminal or any other tool" : "terminal tool";
|
|
417
417
|
return [
|
|
418
418
|
"You are running the ontology worker's process-source skill unattended for ONE source item.",
|
|
@@ -431,23 +431,29 @@ export function buildExtractPrompt(input) {
|
|
|
431
431
|
: input.runtime === "grok"
|
|
432
432
|
? "- Read the item with the read_file tool. Only files in the item's channel folder are readable."
|
|
433
433
|
: "- Read the item with the Read tool. Only files in the item's channel folder are readable.",
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
434
|
+
...(jsonCandidates
|
|
435
|
+
? [
|
|
436
|
+
`- You have no ${tool}. Return JSON only: {"candidates":[{"kind":"signal"|"entity","type":"<type>","body":"<text>"}]}. HQ writes validated candidates after your turn. At most ${MAX_CANDIDATES_PER_ITEM} candidates; use an empty array for no candidates.`,
|
|
437
|
+
"- Do not return shell commands or flags; put the literal candidate text in \"body\". Company, audience and source ref are fixed by HQ.",
|
|
438
|
+
]
|
|
439
|
+
: [
|
|
440
|
+
`- Write candidates ONLY with: bash ${input.wrapperPath} --kind signal|entity --type <type> --body "<text>"`,
|
|
441
|
+
"- That command already fixes the company, audience and source ref for this item. Do not pass --company, --audience, --source-ref or --body-file; it refuses them.",
|
|
442
|
+
]),
|
|
439
443
|
`- Signal types (exactly these): ${EXTRACT_SIGNAL_TYPES.join(", ")}.`,
|
|
440
444
|
`- Entity types: ${ENTITY_TYPES.join(", ")}.`,
|
|
441
445
|
"- Every signal body must end with a citation: a one-sentence quote from the item or its timestamp, for example: (cite: \"we ship Friday\") or (cite: 00:12:31).",
|
|
442
446
|
"- No other command can run, and no other file can be written.",
|
|
443
|
-
|
|
444
|
-
? '- Return only the JSON
|
|
447
|
+
jsonCandidates
|
|
448
|
+
? '- Return only the JSON candidates object, without markdown fences. This overrides the skill instructions about executing commands.'
|
|
445
449
|
: "- When finished, reply with one line: the number of candidates written.",
|
|
446
450
|
"",
|
|
447
451
|
...(input.priorSignals?.length ? [
|
|
448
452
|
"Already extracted for this source; do not repeat; return `update: <id>` to amend one",
|
|
449
453
|
JSON.stringify(input.priorSignals),
|
|
450
|
-
|
|
454
|
+
jsonCandidates
|
|
455
|
+
? 'For signals only, pass "body" as a JSON string {"title":"short title","body":"text with citation","update":"prior id (omit for new)"}. Entity bodies stay plain text.'
|
|
456
|
+
: 'For signals only, pass --body a JSON object {"title":"short title","body":"text with citation","update":"prior id (omit for new)"}. Entity bodies stay plain text.',
|
|
451
457
|
] : []),
|
|
452
458
|
"--- process-source skill ---",
|
|
453
459
|
input.skillText.trim(),
|
|
@@ -897,57 +903,33 @@ export function grokSandboxProfile(scope, envPath) {
|
|
|
897
903
|
export function grokAllowRules(channelDir) {
|
|
898
904
|
return [`Read(${channelDir}/**)`];
|
|
899
905
|
}
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
const ch = command[i++];
|
|
912
|
-
if (ch === "'" || ch === '"') {
|
|
913
|
-
const quote = ch;
|
|
914
|
-
let closed = false;
|
|
915
|
-
while (i < command.length) {
|
|
916
|
-
const c = command[i++];
|
|
917
|
-
if (c === quote) {
|
|
918
|
-
closed = true;
|
|
919
|
-
break;
|
|
920
|
-
}
|
|
921
|
-
if (quote === '"' && (c === "$" || c === "`"))
|
|
922
|
-
return null;
|
|
923
|
-
if (quote === '"' && c === "\\") {
|
|
924
|
-
const next = command[i++];
|
|
925
|
-
if (next !== '"' && next !== "\\")
|
|
926
|
-
return null;
|
|
927
|
-
word += next;
|
|
928
|
-
}
|
|
929
|
-
else
|
|
930
|
-
word += c;
|
|
931
|
-
}
|
|
932
|
-
if (!closed)
|
|
933
|
-
return null;
|
|
934
|
-
}
|
|
935
|
-
else if (ch === "\\" && command[i] === "'") {
|
|
936
|
-
word += command[i++];
|
|
937
|
-
}
|
|
938
|
-
else if (/^[a-zA-Z0-9_./:-]$/.test(ch))
|
|
939
|
-
word += ch;
|
|
940
|
-
else
|
|
941
|
-
return null;
|
|
942
|
-
}
|
|
943
|
-
words.push(word);
|
|
906
|
+
const SIGNAL_TYPE_SET = new Set(EXTRACT_SIGNAL_TYPES);
|
|
907
|
+
const ENTITY_TYPE_SET = new Set(ENTITY_TYPES);
|
|
908
|
+
const MAX_CANDIDATES_PER_ITEM = 8;
|
|
909
|
+
/**
|
|
910
|
+
* Validate one structured candidate object and build the fixed 7-element argv
|
|
911
|
+
* for the pinned candidate wrapper. No shell ever interprets model output, and
|
|
912
|
+
* the model can never change the executable, wrapper path, or flag shape.
|
|
913
|
+
*/
|
|
914
|
+
export function structuredCandidateArgv(candidate, wrapperPath) {
|
|
915
|
+
if (!candidate || typeof candidate !== "object" || Array.isArray(candidate)) {
|
|
916
|
+
return { ok: false, reason: "candidate must be a JSON object" };
|
|
944
917
|
}
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
918
|
+
const obj = candidate;
|
|
919
|
+
const kind = obj.kind;
|
|
920
|
+
if (kind !== "signal" && kind !== "entity") {
|
|
921
|
+
return { ok: false, reason: 'invalid kind: must be "signal" or "entity"' };
|
|
922
|
+
}
|
|
923
|
+
const type = obj.type;
|
|
924
|
+
const allowedTypes = kind === "signal" ? SIGNAL_TYPE_SET : ENTITY_TYPE_SET;
|
|
925
|
+
if (typeof type !== "string" || !allowedTypes.has(type)) {
|
|
926
|
+
return { ok: false, reason: `invalid ${kind} type` };
|
|
927
|
+
}
|
|
928
|
+
const body = obj.body;
|
|
929
|
+
if (typeof body !== "string" || body.length === 0 || body.includes("\0")) {
|
|
930
|
+
return { ok: false, reason: "body must be a non-empty string without NUL bytes" };
|
|
931
|
+
}
|
|
932
|
+
return { ok: true, argv: [wrapperPath, "--kind", kind, "--type", type, "--body", body] };
|
|
951
933
|
}
|
|
952
934
|
/** True when the writer on disk is still the script this turn generated. */
|
|
953
935
|
function wrapperMatchesGenerated(wrapperPath, expected) {
|
|
@@ -959,10 +941,11 @@ function wrapperMatchesGenerated(wrapperPath, expected) {
|
|
|
959
941
|
}
|
|
960
942
|
}
|
|
961
943
|
/**
|
|
962
|
-
* Validate
|
|
963
|
-
*
|
|
964
|
-
*
|
|
965
|
-
*
|
|
944
|
+
* Validate structured candidates and execute each valid one through the pinned
|
|
945
|
+
* wrapper using a fixed argv array (never a shell command string). A malformed
|
|
946
|
+
* or invalid candidate drops only itself, records why, and keeps the rest of
|
|
947
|
+
* the item's valid candidates. When `expectedWrapper` is set, the file on disk
|
|
948
|
+
* is compared to that text immediately before each exec.
|
|
966
949
|
*/
|
|
967
950
|
export function executeGrokCandidates(text, wrapperPath, spawn, opts, expectedWrapper, runtime = "grok") {
|
|
968
951
|
let data;
|
|
@@ -970,27 +953,33 @@ export function executeGrokCandidates(text, wrapperPath, spawn, opts, expectedWr
|
|
|
970
953
|
data = JSON.parse(text);
|
|
971
954
|
}
|
|
972
955
|
catch {
|
|
973
|
-
return `${runtime} must return a JSON
|
|
956
|
+
return { error: `${runtime} must return a JSON candidates object`, dropped: [] };
|
|
957
|
+
}
|
|
958
|
+
if (!data || typeof data !== "object" || Array.isArray(data) || !("candidates" in data) || !Array.isArray(data.candidates)) {
|
|
959
|
+
return { error: `${runtime} must return a JSON candidates array`, dropped: [] };
|
|
974
960
|
}
|
|
975
|
-
if (
|
|
976
|
-
return `${runtime} must return at most
|
|
961
|
+
if (data.candidates.length > MAX_CANDIDATES_PER_ITEM) {
|
|
962
|
+
return { error: `${runtime} must return at most ${MAX_CANDIDATES_PER_ITEM} candidates`, dropped: [] };
|
|
977
963
|
}
|
|
978
964
|
const batch = [];
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
965
|
+
const dropped = [];
|
|
966
|
+
for (let index = 0; index < data.candidates.length; index++) {
|
|
967
|
+
const parsed = structuredCandidateArgv(data.candidates[index], wrapperPath);
|
|
968
|
+
if (!parsed.ok) {
|
|
969
|
+
dropped.push({ index, reason: parsed.reason });
|
|
970
|
+
continue;
|
|
971
|
+
}
|
|
972
|
+
batch.push(parsed.argv);
|
|
984
973
|
}
|
|
985
974
|
for (const argv of batch) {
|
|
986
975
|
if (expectedWrapper !== undefined && !wrapperMatchesGenerated(wrapperPath, expectedWrapper)) {
|
|
987
|
-
return "pinned candidate writer does not match the generated script";
|
|
976
|
+
return { error: "pinned candidate writer does not match the generated script", dropped };
|
|
988
977
|
}
|
|
989
978
|
const result = spawn("/bin/bash", argv, opts);
|
|
990
979
|
if (result.error || result.status !== 0)
|
|
991
|
-
return "pinned candidate writer failed";
|
|
980
|
+
return { error: "pinned candidate writer failed", dropped };
|
|
992
981
|
}
|
|
993
|
-
return
|
|
982
|
+
return { dropped };
|
|
994
983
|
}
|
|
995
984
|
/**
|
|
996
985
|
* Read denies for the grok login. Grok matches a `~` tool path literally and
|
|
@@ -1395,15 +1384,18 @@ function runTurn(ctx, runtime, prompt, scope, budgetUsd, opts) {
|
|
|
1395
1384
|
const c = classifyFailure(detail, `${runtime} turn failed: ${detail.slice(0, 300) || "error result"}`);
|
|
1396
1385
|
return { ok: false, ...c, turns: parsed.turns, ...failCost };
|
|
1397
1386
|
}
|
|
1387
|
+
let droppedCandidates;
|
|
1398
1388
|
if (runtime === "grok") {
|
|
1399
1389
|
if (scope.wrapperBody === undefined) {
|
|
1400
1390
|
return { ok: false, error: "pinned candidate writer is missing", errorKind: "other", turns: parsed.turns, ...failCost };
|
|
1401
1391
|
}
|
|
1402
|
-
const
|
|
1392
|
+
const exec = executeGrokCandidates(stripFence(String(parsed.result.result ?? "")), scope.wrapperPath, ctx.spawn, {
|
|
1403
1393
|
cwd, env: grokTurnEnv({ ...process.env, HQ_ROOT: ctx.hqRoot }), timeoutMs: SCRIPT_TIMEOUT_MS,
|
|
1404
1394
|
}, scope.wrapperBody);
|
|
1405
|
-
if (
|
|
1406
|
-
|
|
1395
|
+
if (exec.dropped.length)
|
|
1396
|
+
droppedCandidates = exec.dropped;
|
|
1397
|
+
if (exec.error)
|
|
1398
|
+
return { ok: false, error: exec.error, errorKind: "other", turns: parsed.turns, ...(droppedCandidates ? { droppedCandidates } : {}), ...failCost };
|
|
1407
1399
|
}
|
|
1408
1400
|
if (runtime === "codex") {
|
|
1409
1401
|
const used = codexToolItem(res.stdout);
|
|
@@ -1414,13 +1406,15 @@ function runTurn(ctx, runtime, prompt, scope, budgetUsd, opts) {
|
|
|
1414
1406
|
}
|
|
1415
1407
|
if (codexReplyText === null)
|
|
1416
1408
|
return { ok: false, error: "codex printed no reply", errorKind: "other", turns: parsed.turns, ...failCost };
|
|
1417
|
-
const
|
|
1409
|
+
const exec = executeGrokCandidates(stripFence(codexReplyText), scope.wrapperPath, ctx.spawn, {
|
|
1418
1410
|
cwd: scope.turnDir, env: grokTurnEnv({ ...process.env, HQ_ROOT: ctx.hqRoot }), timeoutMs: SCRIPT_TIMEOUT_MS,
|
|
1419
1411
|
}, scope.wrapperBody, "codex");
|
|
1420
|
-
if (
|
|
1421
|
-
|
|
1412
|
+
if (exec.dropped.length)
|
|
1413
|
+
droppedCandidates = exec.dropped;
|
|
1414
|
+
if (exec.error)
|
|
1415
|
+
return { ok: false, error: exec.error, errorKind: "other", turns: parsed.turns, ...(droppedCandidates ? { droppedCandidates } : {}), ...failCost };
|
|
1422
1416
|
}
|
|
1423
|
-
return { ok: true, turns: parsed.turns, ...cost };
|
|
1417
|
+
return { ok: true, turns: parsed.turns, ...(droppedCandidates ? { droppedCandidates } : {}), ...cost };
|
|
1424
1418
|
}
|
|
1425
1419
|
/** Spawn error codes that mean the hq-fleet-local helper never started. */
|
|
1426
1420
|
const FLEET_HELPER_NOT_STARTED = new Set(["ENOENT", "EACCES", "ENOTDIR", "EPERM", "ENOEXEC"]);
|
|
@@ -1492,12 +1486,13 @@ async function runFleetTurn(ctx, target, prompt, scope, opts) {
|
|
|
1492
1486
|
if (scope.wrapperBody === undefined) {
|
|
1493
1487
|
return { ok: false, error: "pinned candidate writer is missing", errorKind: "other", turns: 1, ...charged };
|
|
1494
1488
|
}
|
|
1495
|
-
const
|
|
1489
|
+
const exec = executeGrokCandidates(stripFence(result.text), scope.wrapperPath, ctx.spawn, {
|
|
1496
1490
|
cwd: scope.turnDir, env: grokTurnEnv({ ...process.env, HQ_ROOT: ctx.hqRoot }), timeoutMs: SCRIPT_TIMEOUT_MS,
|
|
1497
1491
|
}, scope.wrapperBody, "claude");
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1492
|
+
const dropped = exec.dropped.length ? { droppedCandidates: exec.dropped } : {};
|
|
1493
|
+
if (exec.error)
|
|
1494
|
+
return { ok: false, error: exec.error, errorKind: "other", turns: 1, ...dropped, ...charged };
|
|
1495
|
+
return { ok: true, turns: 1, ...dropped, ...charged };
|
|
1501
1496
|
}
|
|
1502
1497
|
/**
|
|
1503
1498
|
* The Executive bot's HQ Fleet target (fleetCompleteTarget, the resolution
|
|
@@ -1728,6 +1723,7 @@ export function createExtractStep(options = {}) {
|
|
|
1728
1723
|
/** Signal candidates with no citation marker, and the sources they came from. Counted, not rejected. */
|
|
1729
1724
|
let uncitedCandidates = 0;
|
|
1730
1725
|
const uncitedSources = [];
|
|
1726
|
+
const droppedCandidates = [];
|
|
1731
1727
|
let errorKind;
|
|
1732
1728
|
const failures = [
|
|
1733
1729
|
...unreadable,
|
|
@@ -1903,6 +1899,11 @@ export function createExtractStep(options = {}) {
|
|
|
1903
1899
|
lastCost = turn.costUsd;
|
|
1904
1900
|
if (turn.costEstimated)
|
|
1905
1901
|
unpricedSources += 1;
|
|
1902
|
+
if (turn.droppedCandidates?.length) {
|
|
1903
|
+
for (const d of turn.droppedCandidates) {
|
|
1904
|
+
droppedCandidates.push({ file: item.file, index: d.index, reason: d.reason });
|
|
1905
|
+
}
|
|
1906
|
+
}
|
|
1906
1907
|
sourcesRun += 1;
|
|
1907
1908
|
const created = [...allCandidateFiles(ctx.hqRoot)].filter((f) => !before.has(f));
|
|
1908
1909
|
if (!turn.ok && (priorSignals.length || turn.budgetExceeded)) {
|
|
@@ -1987,7 +1988,7 @@ export function createExtractStep(options = {}) {
|
|
|
1987
1988
|
...(failures.length ? { failures } : {}),
|
|
1988
1989
|
...(skippedItems.length ? { skippedItems } : {}),
|
|
1989
1990
|
...(rejected ? { rejectedCandidates: rejected } : {}),
|
|
1990
|
-
detail: { new: itemsOut, updated, skipped, runtime, ...(runtime === "claude" ? { login: fleet ? "fleet" : "claude-cli", ...(fleet ? { bot: fleet.botName } : {}) } : {}), ...(fleetFallback ? { loginFallback: fleetFallback } : {}), ...(fleetTooLarge.length ? { fleetTooLarge } : {}), ...(choice.fallback ? { fallback: choice.fallback } : {}), ...(budgetStoppedAt ? { budgetStoppedAt } : {}), ...(unpricedSources ? { spendEstimated: true, unpricedSources, unpricedSourceEstimateUsd: turnOpts.unpricedSourceEstimateUsd } : {}), ...(uncitedCandidates ? { uncitedCandidates, uncitedSources } : {}), ...listingDetail },
|
|
1991
|
+
detail: { new: itemsOut, updated, skipped, runtime, ...(runtime === "claude" ? { login: fleet ? "fleet" : "claude-cli", ...(fleet ? { bot: fleet.botName } : {}) } : {}), ...(fleetFallback ? { loginFallback: fleetFallback } : {}), ...(fleetTooLarge.length ? { fleetTooLarge } : {}), ...(choice.fallback ? { fallback: choice.fallback } : {}), ...(budgetStoppedAt ? { budgetStoppedAt } : {}), ...(unpricedSources ? { spendEstimated: true, unpricedSources, unpricedSourceEstimateUsd: turnOpts.unpricedSourceEstimateUsd } : {}), ...(uncitedCandidates ? { uncitedCandidates, uncitedSources } : {}), ...(droppedCandidates.length ? { droppedCandidates } : {}), ...listingDetail },
|
|
1991
1992
|
};
|
|
1992
1993
|
// Between-sources stop. An in-source stop sets budgetStoppedAt and leaves sourcesLeft at 0.
|
|
1993
1994
|
// Main names that next source in budgetStoppedAt; the estimate reason is recorded too.
|
package/dist/utils/hook-trust.js
CHANGED
|
@@ -885,7 +885,10 @@ export function trustGrokProjectHooks(hqRoot, deps = DEFAULT_DEPS) {
|
|
|
885
885
|
let wantJson;
|
|
886
886
|
if (grok && grok.events.length > 0) {
|
|
887
887
|
try {
|
|
888
|
-
candidate?.commitStable
|
|
888
|
+
if (candidate?.commitStable)
|
|
889
|
+
candidate.commitStable(acceptedHosts);
|
|
890
|
+
else
|
|
891
|
+
candidate?.recordAccepted?.(acceptedHosts);
|
|
889
892
|
}
|
|
890
893
|
catch (error) {
|
|
891
894
|
return { runtime: 'grok', status: 'failed', trusted: 0, reason: errorMessage(error) };
|
|
@@ -985,6 +988,9 @@ export function trustGrokProjectHooks(hqRoot, deps = DEFAULT_DEPS) {
|
|
|
985
988
|
const target = (deps.coreNextTarget ?? ((h) => coreNextTargetOrWarn(h)))(home);
|
|
986
989
|
// Only the events the new core covers in full on Grok switch.
|
|
987
990
|
const grok = forHost(target, hqRoot, 'grok');
|
|
991
|
+
if (grok && grok.events.length > 0) {
|
|
992
|
+
getCoreNextCandidate(target)?.recordAccepted?.(['grok']);
|
|
993
|
+
}
|
|
988
994
|
wantJson = grok || platform === 'win32'
|
|
989
995
|
? grokBridgeJson(fs.readFileSync(sourceBridgeJson, 'utf8'), hqRoot, grok, platform, home)
|
|
990
996
|
: undefined;
|
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
import { type EngineOptions } from '../lib/hook-engine/resolve.js';
|
|
2
2
|
import { type NativeTarget } from '../lib/hook-engine/registration.js';
|
|
3
|
+
import { type CanaryHost } from '../lib/hook-engine/canary-gate.js';
|
|
3
4
|
export { CORE_NEXT_FLAG, coreNextEnabled } from './core-next-flag.js';
|
|
4
5
|
export { coreNextStrictReason, ENGINE_STRICT_ENV, ENGINE_STRICT_FILE } from './core-next-kill.js';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
/** Record of canary-accepted hook engines committed to `stable`, under the home folder. */
|
|
8
|
-
export declare const ACCEPTED_HOOK_ENGINE_RECORD: string;
|
|
9
|
-
/** Schema of [`ACCEPTED_HOOK_ENGINE_RECORD`]. */
|
|
10
|
-
export declare const ACCEPTED_HOOK_ENGINE_SCHEMA = "hq.accepted-hook-engine.v1";
|
|
11
|
-
export type CoreNextHost = 'claude' | 'codex' | 'grok' | 'fleet-local' | 'agents-v2' | 'antigravity';
|
|
6
|
+
export { ACCEPTED_HOOK_ENGINE_RECORD, ACCEPTED_HOOK_ENGINE_SCHEMA, STABLE_LINK_NAME, StableDowngradeRefused, linkStableEngine, readAcceptedHookEngineRecord, stableEnginePath, type AcceptedHookEngineEntry, type AcceptedHookEngineRecord, type CoreNextHost, type LinkStableEngineOptions, } from '../lib/hook-engine/stable-link.js';
|
|
7
|
+
import { type CoreNextHost } from '../lib/hook-engine/stable-link.js';
|
|
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
|
|
@@ -44,6 +40,11 @@ export interface CoreNextCandidateMeta {
|
|
|
44
40
|
pinnedEngine: string;
|
|
45
41
|
engineVersion: string;
|
|
46
42
|
commitStable?: (acceptedHosts?: readonly CoreNextHost[]) => string;
|
|
43
|
+
/**
|
|
44
|
+
* Record `acceptedHosts` in `<home>/.hq/bin/hq-hook/accepted-engine.json`
|
|
45
|
+
* after `stable` is linked and a real host canary has passed on this machine.
|
|
46
|
+
*/
|
|
47
|
+
recordAccepted?: (acceptedHosts?: readonly CoreNextHost[]) => void;
|
|
47
48
|
}
|
|
48
49
|
/** Read the candidate engine metadata attached by [`coreNextTarget`], if any. */
|
|
49
50
|
export declare function getCoreNextCandidate(target: CoreNextTarget | null | undefined): CoreNextCandidateMeta | undefined;
|
|
@@ -84,16 +85,6 @@ export declare function probeEngine(engine: string): EngineCapabilities;
|
|
|
84
85
|
* new-core registration with nothing to run.
|
|
85
86
|
*/
|
|
86
87
|
export declare function checkStableEngine(stable: string, pinned: string): void;
|
|
87
|
-
/** The stable path that stands for a pinned engine path. */
|
|
88
|
-
export declare function stableEnginePath(pinned: string, home: string): string;
|
|
89
|
-
/**
|
|
90
|
-
* Point `<home>/.hq/bin/hq-hook/stable` at the pinned engine's version folder
|
|
91
|
-
* and return the stable engine path. The link is replaced by rename, so a
|
|
92
|
-
* planted file at the temporary name or the link itself is never followed. A
|
|
93
|
-
* `stable` that is a real folder (not a link) is someone else's and is left
|
|
94
|
-
* alone: the call fails and the caller keeps the current registrations.
|
|
95
|
-
*/
|
|
96
|
-
export declare function linkStableEngine(pinned: string, home: string, platform?: NodeJS.Platform): string;
|
|
97
88
|
export interface CoreNextOptions {
|
|
98
89
|
platform?: NodeJS.Platform;
|
|
99
90
|
/** Reads the engine's capabilities; `probeEngine` by default. */
|
|
@@ -130,22 +121,6 @@ export interface CoreNextEngine {
|
|
|
130
121
|
* writes. Both fail when the pinned bundle or the stable link is wrong.
|
|
131
122
|
*/
|
|
132
123
|
export declare function resolveCoreNextEngine(home: string, options: CoreNextEngineOptions): CoreNextEngine;
|
|
133
|
-
/** One canary-accepted engine recorded when `commitStable` moved `stable` to it. */
|
|
134
|
-
export interface AcceptedHookEngineEntry {
|
|
135
|
-
engineVersion: string;
|
|
136
|
-
pinnedEngine: string;
|
|
137
|
-
acceptedAt: string;
|
|
138
|
-
hosts: CoreNextHost[];
|
|
139
|
-
}
|
|
140
|
-
export interface AcceptedHookEngineRecord {
|
|
141
|
-
schema: typeof ACCEPTED_HOOK_ENGINE_SCHEMA;
|
|
142
|
-
engines: Record<string, AcceptedHookEngineEntry>;
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* Read `<home>/.hq/bin/hq-hook/accepted-engine.json`; null when absent,
|
|
146
|
-
* unreadable, invalid, or writable by another user.
|
|
147
|
-
*/
|
|
148
|
-
export declare function readAcceptedHookEngineRecord(home: string, platform?: NodeJS.Platform): AcceptedHookEngineRecord | null;
|
|
149
124
|
/**
|
|
150
125
|
* Record `pinned` (`engineVersion`) as canary-accepted for `hosts` after
|
|
151
126
|
* committing `<home>/.hq/bin/hq-hook/stable`. Merges `hosts` when the same
|
|
@@ -183,7 +158,9 @@ export declare function existingAcceptedStableHookEngine(home: string, options:
|
|
|
183
158
|
* Windows), regardless of `core.next`. When the npm engine package is gone,
|
|
184
159
|
* reuses an existing runnable `stable` or relinks `stable` from an already-
|
|
185
160
|
* pinned copy of this CLI's version under `<home>/.hq/bin/hq-hook/<version>`.
|
|
186
|
-
*
|
|
161
|
+
* When `stable` names a newer engine that still runs, it is kept and returned
|
|
162
|
+
* (the link never moves back on its own). Returns null when no usable engine
|
|
163
|
+
* exists on disk.
|
|
187
164
|
*/
|
|
188
165
|
export declare function ensureStableHookEngine(home: string, options?: {
|
|
189
166
|
platform?: NodeJS.Platform;
|
|
@@ -238,7 +215,7 @@ export declare function coreNextTarget(home: string, env?: NodeJS.ProcessEnv, op
|
|
|
238
215
|
* capable event. [`coreNextTarget`] builds its target here, and `hq doctor`
|
|
239
216
|
* uses it to ask the same questions without installing anything.
|
|
240
217
|
*/
|
|
241
|
-
export declare function coreNextTargetFor(home: string, env: NodeJS.ProcessEnv, stable: string, caps: EngineCapabilities, platform?: NodeJS.Platform, warn?: (message: string) => void): CoreNextTarget | null;
|
|
218
|
+
export declare function coreNextTargetFor(home: string, env: NodeJS.ProcessEnv, stable: string, caps: EngineCapabilities, platform?: NodeJS.Platform, warn?: (message: string) => void, onCanaryPassed?: (host: CanaryHost) => void): CoreNextTarget | null;
|
|
242
219
|
/**
|
|
243
220
|
* Set by `hq reindex --from-hook` (a reindex the daemon runs for a hook's
|
|
244
221
|
* request note): the host canary gate then keeps every host on the core it is
|