@indigoai-us/hq-cli 5.292.0 → 5.293.0
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 +26 -0
- package/dist/command-catalog.generated.d.ts +3 -0
- package/dist/command-catalog.generated.js +4 -0
- package/dist/commands/lanes-move.js +54 -1
- package/dist/commands/lanes-questions.js +4 -0
- package/dist/commands/lanes.d.ts +2 -0
- package/dist/commands/lanes.js +119 -5
- package/dist/lib/core-utils/sentry-report.js +2 -2
- package/dist/lib/daemon/run.d.ts +11 -0
- package/dist/lib/daemon/run.js +17 -1
- package/dist/lib/lanes/autopilot.d.ts +13 -1
- package/dist/lib/lanes/autopilot.js +271 -28
- package/dist/lib/lanes/grants.d.ts +1 -1
- package/dist/lib/lanes/grants.js +7 -5
- package/dist/lib/lanes/index.d.ts +1 -1
- package/dist/lib/lanes/keep-alive.d.ts +5 -0
- package/dist/lib/lanes/keep-alive.js +9 -4
- package/dist/lib/lanes/questions.d.ts +2 -1
- package/dist/lib/lanes/questions.js +2 -0
- package/dist/lib/lanes/reconcile.js +186 -9
- package/dist/lib/lanes/spawn.js +4 -0
- package/dist/lib/lanes/store.js +21 -1
- package/dist/lib/lanes/types.d.ts +13 -1
- package/dist/lib/lanes/types.js +2 -2
- package/dist/lib/lanes/watcher.js +3 -1
- package/dist/utils/self-update.d.ts +7 -0
- package/dist/utils/self-update.js +5 -1
- package/dist/utils/version-gate.d.ts +15 -0
- package/dist/utils/version-gate.js +46 -2
- package/package.json +1 -1
|
@@ -19,19 +19,19 @@ import { loadWorkerProfile } from "./profile.js";
|
|
|
19
19
|
import { terminalChildResumeHireGrantError, withHireGrantAdmission, } from "./grants.js";
|
|
20
20
|
import { classifySessionLiveness, defaultLivenessDeps, loadLivenessIndex, readDaemonPresenceConnected, unindexedClaudeSessionLiveness, } from "./liveness.js";
|
|
21
21
|
import { ANSWERED_QUESTIONS_FILE, armLaneWatcher, envelopeRepairMode, isPidRecordAlive, laneRunDir, readPidRecord, readProcStarttime, readSpawnManifest, markSpawnFailure, spawnEnvelopeRepair, spawnLaneWorker, retryLaneOnAlternateAccount, } from "./spawn.js";
|
|
22
|
-
import { appendCappedHistory, lanesStoreRoot, parseLaneRecord, parseQuestionRecord, readLane, readQuestion, updateLane, updateQuestion, } from "./store.js";
|
|
22
|
+
import { appendCappedHistory, lanesStoreRoot, parseLaneRecord, parseQuestionRecord, readLane, readQuestion, listQuestionIds, updateLane, updateQuestion, } from "./store.js";
|
|
23
23
|
import { applyThrottleDecision, decideAdmission, defaultThrottleDeps, emptyThrottleState, evaluateThrottle, isCpuCheckEnabled, readAvailableMemMb, readThrottleState, resolveCpuBusyFraction, sampleCpuBusyObservation, recordCpuBusyObservation, throttleStatePath, writeThrottleState, } from "./throttle.js";
|
|
24
24
|
import { readLanesRegistryFlag } from "./registry-flag.js";
|
|
25
25
|
import { resolveLaneCompany } from "./lane-company.js";
|
|
26
26
|
import { appendDropboxMessage } from "./dropbox.js";
|
|
27
27
|
import { DEFAULT_RUNAWAY_SEARCH_GUARD_CONFIG, listHostProcesses, runRunawayToolGuard, RUNAWAY_TOOL_GUARD_FLAG, } from "./runaway-tool-guard.js";
|
|
28
|
-
import { LEAD_LANE_KEEP_ALIVE_FLAG, LEAD_LANE_KEEP_ALIVE_INTERRUPTED_RESUME_TEXT, LEAD_LANE_KEEP_ALIVE_MAX_RESUMES, LEAD_LANE_KEEP_ALIVE_RESUME_TEXT, LANE_SUPERSESSION_LINEAGE_AWARE_FLAG, doneKeepAliveVerdict, hasPendingKeepAliveWork, keepAliveExclusion, loadRetiredLaneIds, leadLaneKeepAliveBackoffMs, undeliveredAnsweredQuestions, } from "./keep-alive.js";
|
|
28
|
+
import { LEAD_LANE_KEEP_ALIVE_FLAG, LEAD_LANE_KEEP_ALIVE_RESUME_BLOCKED_FLAG, LEAD_LANE_KEEP_ALIVE_BLOCKED_GRACE_MS, LEAD_LANE_KEEP_ALIVE_BLOCKED_RESUME_TEXT, queueLaneTerminalResume, LEAD_LANE_KEEP_ALIVE_INTERRUPTED_RESUME_TEXT, LEAD_LANE_KEEP_ALIVE_MAX_RESUMES, LEAD_LANE_KEEP_ALIVE_RESUME_TEXT, LANE_SUPERSESSION_LINEAGE_AWARE_FLAG, doneKeepAliveVerdict, hasPendingKeepAliveWork, keepAliveExclusion, loadRetiredLaneIds, leadLaneKeepAliveBackoffMs, undeliveredAnsweredQuestions, } from "./keep-alive.js";
|
|
29
29
|
import { providerSupportsSessionResume } from "./delivery.js";
|
|
30
30
|
import { applyDefaultQuotaHold, readQuotaSignal, recordAccountQuota } from "./quota.js";
|
|
31
31
|
import { answeredQuestionEntries, questionRecordRefusalCode, raiseEnvelopeQuestions, resolveQuestionCompanyWithFallback, } from "./questions.js";
|
|
32
32
|
import { SILENCE_MS, appendWatcherEvent, classifyLaneExit, isPidAlive, missingExpectedEnvelopeFile, readLatestEnvelopeFile, readLatestEnvelopeRecord, watcherEventsPath, watcherOutLogPath, writeWatcherDecision, } from "./watcher.js";
|
|
33
33
|
import { createLaneMesh, emitLaneDecisionEvents, emitLaneTerminalStateEvent, laneMeshCompany, } from "./mesh-events.js";
|
|
34
|
-
import { laneStories, storyStatusForEnvelope } from "./stories.js";
|
|
34
|
+
import { activeLaneStories, laneStories, storyStatusForEnvelope } from "./stories.js";
|
|
35
35
|
import { resolveManagerStatusGateForLane } from "./manager-status-gate.js";
|
|
36
36
|
import { decideEnvelopeRepair, envelopeQuestionIds, routeProviderFailure } from "./watcher.js";
|
|
37
37
|
import { PROVIDER_REJECTED_REASON, providerRejectionDetails, readProviderRejection, } from "./provider-rejection.js";
|
|
@@ -962,8 +962,9 @@ export async function runPassBody(hqRoot, deps) {
|
|
|
962
962
|
const readRegistryFlag = deps.readRegistryFlag ?? readLanesRegistryFlag;
|
|
963
963
|
const keepAliveFlagCompanies = new Map();
|
|
964
964
|
for (const lane of lanes) {
|
|
965
|
-
if (!(lane.state === "done" || lane.state === "interrupted" || lane.state === "killed" || lane.state === "cancelled" || lane.state === "failed") ||
|
|
965
|
+
if (!(lane.state === "done" || lane.state === "interrupted" || lane.state === "blocked" || lane.state === "killed" || lane.state === "cancelled" || lane.state === "failed") ||
|
|
966
966
|
(lane.keep_alive !== true && lane.worker_profile === undefined) ||
|
|
967
|
+
(lane.state === "blocked" && lane.keep_alive !== true) ||
|
|
967
968
|
!laneRunsHere(lane, deps.host) ||
|
|
968
969
|
(lane.state === "done" && (lane.terminal_reason === PROVIDER_REJECTED_REASON ||
|
|
969
970
|
lane.terminal_reason === "account_not_logged_in" ||
|
|
@@ -985,6 +986,7 @@ export async function runPassBody(hqRoot, deps) {
|
|
|
985
986
|
keepAliveFlagCompanies.set(key, company);
|
|
986
987
|
}
|
|
987
988
|
const keepAliveFlagByCompany = new Map();
|
|
989
|
+
const blockedResumeFlagByCompany = new Map();
|
|
988
990
|
const supersessionLineageAwareByCompany = new Map();
|
|
989
991
|
const env = deps.env ?? process.env;
|
|
990
992
|
await Promise.all([...keepAliveFlagCompanies.entries()].map(async ([key, company]) => {
|
|
@@ -992,11 +994,19 @@ export async function runPassBody(hqRoot, deps) {
|
|
|
992
994
|
company: company ?? undefined,
|
|
993
995
|
env,
|
|
994
996
|
};
|
|
995
|
-
const
|
|
997
|
+
const hasBlockedKeepAliveLane = lanes.some((lane) => lane.state === "blocked" &&
|
|
998
|
+
lane.keep_alive === true &&
|
|
999
|
+
laneRunsHere(lane, startDeps.host) &&
|
|
1000
|
+
keepAliveCompanyKey(resolveLaneCompany(hqRoot, lane).company) === key);
|
|
1001
|
+
const [keepAliveEnabled, lineageAware, blockedResumeEnabled] = await Promise.all([
|
|
996
1002
|
readRegistryFlag(LEAD_LANE_KEEP_ALIVE_FLAG, options),
|
|
997
1003
|
readRegistryFlag(LANE_SUPERSESSION_LINEAGE_AWARE_FLAG, options),
|
|
1004
|
+
hasBlockedKeepAliveLane
|
|
1005
|
+
? readRegistryFlag(LEAD_LANE_KEEP_ALIVE_RESUME_BLOCKED_FLAG, options)
|
|
1006
|
+
: Promise.resolve(false),
|
|
998
1007
|
]);
|
|
999
1008
|
keepAliveFlagByCompany.set(key, keepAliveEnabled);
|
|
1009
|
+
blockedResumeFlagByCompany.set(key, blockedResumeEnabled);
|
|
1000
1010
|
supersessionLineageAwareByCompany.set(key, lineageAware);
|
|
1001
1011
|
}));
|
|
1002
1012
|
const admissionThrottleDeps = startDeps.throttleDeps ?? defaultThrottleDeps(startDeps.env ?? process.env);
|
|
@@ -1016,7 +1026,7 @@ export async function runPassBody(hqRoot, deps) {
|
|
|
1016
1026
|
await withAllLaneAdmissionLocks(hqRoot, async () => {
|
|
1017
1027
|
const freshLanes = loadLaneRecords(hqRoot, summary);
|
|
1018
1028
|
const freshQuestions = loadQuestionRecords(hqRoot, summary);
|
|
1019
|
-
await resumeKeepAlive(hqRoot, freshLanes, freshQuestions, summary, admissionDeps, now, keepAliveFlagByCompany, supersessionLineageAwareByCompany);
|
|
1029
|
+
await resumeKeepAlive(hqRoot, freshLanes, freshQuestions, summary, admissionDeps, now, keepAliveFlagByCompany, supersessionLineageAwareByCompany, blockedResumeFlagByCompany);
|
|
1020
1030
|
const drainLanes = loadLaneRecords(hqRoot, summary);
|
|
1021
1031
|
await admitQueued(hqRoot, drainLanes, summary, admissionDeps, now);
|
|
1022
1032
|
await resumeAwaiting(hqRoot, drainLanes, freshQuestions, summary, admissionDeps);
|
|
@@ -1666,7 +1676,8 @@ function keepAliveProgressResetByHuman(lane) {
|
|
|
1666
1676
|
return true;
|
|
1667
1677
|
const messageMs = Date.parse(lane.last_message_at ?? "");
|
|
1668
1678
|
const resumeMs = lane.last_resume?.text === LEAD_LANE_KEEP_ALIVE_RESUME_TEXT ||
|
|
1669
|
-
lane.last_resume?.text === LEAD_LANE_KEEP_ALIVE_INTERRUPTED_RESUME_TEXT
|
|
1679
|
+
lane.last_resume?.text === LEAD_LANE_KEEP_ALIVE_INTERRUPTED_RESUME_TEXT ||
|
|
1680
|
+
lane.last_resume?.text === LEAD_LANE_KEEP_ALIVE_BLOCKED_RESUME_TEXT
|
|
1670
1681
|
? Number.NaN
|
|
1671
1682
|
: Date.parse(lane.last_resume?.at ?? "");
|
|
1672
1683
|
return Number.isFinite(lastAutoMs) &&
|
|
@@ -1779,7 +1790,169 @@ function latestEnvelopeMtimeMs(hqRoot, lane, ref) {
|
|
|
1779
1790
|
throw new LanesError("keep_alive_envelope_timestamp_unavailable", `Cannot stat latest envelope for lane ${lane.lane_id}: ${err instanceof Error ? err.message : String(err)}`, { lane_id: lane.lane_id, path: filePath });
|
|
1780
1791
|
}
|
|
1781
1792
|
}
|
|
1782
|
-
async function
|
|
1793
|
+
async function resumeBlockedKeepAlive(hqRoot, lane, questions, summary, deps, now, keepAliveFlags, blockedFlags, companyForLane, lanes, retiredLaneIds, lineageAwareByCompany) {
|
|
1794
|
+
const company = companyForLane(lane);
|
|
1795
|
+
if (company === null) {
|
|
1796
|
+
summary.skipped.push({ kind: "lane", id: lane.lane_id, why: "keep_alive_company_unresolved" });
|
|
1797
|
+
return;
|
|
1798
|
+
}
|
|
1799
|
+
const key = keepAliveCompanyKey(company);
|
|
1800
|
+
if (keepAliveFlags.get(key) !== true || blockedFlags.get(key) !== true) {
|
|
1801
|
+
summary.skipped.push({ kind: "lane", id: lane.lane_id, why: "keep_alive_blocked" });
|
|
1802
|
+
return;
|
|
1803
|
+
}
|
|
1804
|
+
if (lane.terminal_reason === "approval_gate_violated" || lane.last_envelope?.blocked_reason === "approval_gate_violated") {
|
|
1805
|
+
summary.skipped.push({ kind: "lane", id: lane.lane_id, why: "keep_alive_approval_gate_violated" });
|
|
1806
|
+
return;
|
|
1807
|
+
}
|
|
1808
|
+
if (lane.last_envelope?.decision !== "blocked") {
|
|
1809
|
+
summary.skipped.push({ kind: "lane", id: lane.lane_id, why: "keep_alive_missing_blocked_envelope" });
|
|
1810
|
+
return;
|
|
1811
|
+
}
|
|
1812
|
+
if (retiredLaneIds === null) {
|
|
1813
|
+
recordKeepAliveSkip(hqRoot, lane, "retired_list_invalid", summary, deps);
|
|
1814
|
+
return;
|
|
1815
|
+
}
|
|
1816
|
+
const exclusion = keepAliveExclusion(lane, lanes, retiredLaneIds, lineageAwareByCompany.get(key) === true, companyForLane);
|
|
1817
|
+
if (exclusion !== undefined) {
|
|
1818
|
+
recordKeepAliveSkip(hqRoot, lane, exclusion, summary, deps);
|
|
1819
|
+
return;
|
|
1820
|
+
}
|
|
1821
|
+
const terminalAt = lane.last_envelope.at;
|
|
1822
|
+
const terminalMs = Date.parse(terminalAt ?? "");
|
|
1823
|
+
if (!Number.isFinite(terminalMs)) {
|
|
1824
|
+
recordKeepAliveSkip(hqRoot, lane, "missing_interruption_time", summary, deps, "blocked terminal time is invalid");
|
|
1825
|
+
return;
|
|
1826
|
+
}
|
|
1827
|
+
if (activeLaneStories(lane).length === 0) {
|
|
1828
|
+
summary.skipped.push({ kind: "lane", id: lane.lane_id, why: "keep_alive_no_open_stories" });
|
|
1829
|
+
return;
|
|
1830
|
+
}
|
|
1831
|
+
let pendingQuestion = questions.some((question) => question.lane_id === lane.lane_id && question.status === "pending");
|
|
1832
|
+
try {
|
|
1833
|
+
for (const id of listQuestionIds(hqRoot)) {
|
|
1834
|
+
const question = readQuestion(hqRoot, id);
|
|
1835
|
+
if (question.lane_id === lane.lane_id && question.status === "pending")
|
|
1836
|
+
pendingQuestion = true;
|
|
1837
|
+
}
|
|
1838
|
+
}
|
|
1839
|
+
catch (error) {
|
|
1840
|
+
markDirty(summary, { kind: "lane", id: lane.lane_id, why: "blocked keep-alive question read failed: " + (error instanceof Error ? error.message : String(error)) });
|
|
1841
|
+
return;
|
|
1842
|
+
}
|
|
1843
|
+
const blockedHistory = lane.status_gate_history ?? [];
|
|
1844
|
+
const priorResumes = lane.keep_alive_blocked_resume_streak ?? 0;
|
|
1845
|
+
const alreadyEscalated = blockedHistory.some((entry) => entry.event === "keep_alive_blocked_escalated" && entry.terminal_at === terminalAt);
|
|
1846
|
+
if (pendingQuestion) {
|
|
1847
|
+
appendBlockedKeepAliveHistory(hqRoot, lane, terminalAt, now.toISOString(), "open_question", deps);
|
|
1848
|
+
return;
|
|
1849
|
+
}
|
|
1850
|
+
if (priorResumes >= 2) {
|
|
1851
|
+
if (!alreadyEscalated) {
|
|
1852
|
+
casLaneIf(hqRoot, lane.lane_id, (current) => current.version === lane.version && current.state === "blocked" && current.last_envelope?.at === terminalAt, (current) => ({
|
|
1853
|
+
...current,
|
|
1854
|
+
status_gate_history: appendCappedHistory(current.status_gate_history ?? [], {
|
|
1855
|
+
event: "keep_alive_blocked_escalated",
|
|
1856
|
+
at: now.toISOString(),
|
|
1857
|
+
terminal_at: terminalAt,
|
|
1858
|
+
}),
|
|
1859
|
+
}), deps.dryRun);
|
|
1860
|
+
}
|
|
1861
|
+
summary.skipped.push({ kind: "lane", id: lane.lane_id, why: "keep_alive_blocked_escalated" });
|
|
1862
|
+
return;
|
|
1863
|
+
}
|
|
1864
|
+
if ((lane.keep_alive_resume_count ?? 0) >= LEAD_LANE_KEEP_ALIVE_MAX_RESUMES || lane.keep_alive_exhausted_at !== undefined) {
|
|
1865
|
+
if (lane.keep_alive_exhausted_at === undefined && !deps.dryRun) {
|
|
1866
|
+
casLaneIf(hqRoot, lane.lane_id, (current) => current.version === lane.version && current.state === "blocked" &&
|
|
1867
|
+
(current.keep_alive_resume_count ?? 0) >= LEAD_LANE_KEEP_ALIVE_MAX_RESUMES, (current) => ({ ...current, keep_alive_exhausted_at: now.toISOString() }), false);
|
|
1868
|
+
}
|
|
1869
|
+
summary.skipped.push({ kind: "lane", id: lane.lane_id, why: "keep_alive_exhausted" });
|
|
1870
|
+
return;
|
|
1871
|
+
}
|
|
1872
|
+
if (now.getTime() - terminalMs < LEAD_LANE_KEEP_ALIVE_BLOCKED_GRACE_MS) {
|
|
1873
|
+
appendBlockedKeepAliveHistory(hqRoot, lane, terminalAt, now.toISOString(), "blocked_grace", deps);
|
|
1874
|
+
return;
|
|
1875
|
+
}
|
|
1876
|
+
const latest = deps.readKeepAliveRecheckLane?.(hqRoot, lane.lane_id) ?? readLane(hqRoot, lane.lane_id);
|
|
1877
|
+
if (latest.version !== lane.version || latest.state !== "blocked" || latest.last_envelope?.decision !== "blocked" || latest.last_envelope.at !== terminalAt)
|
|
1878
|
+
return;
|
|
1879
|
+
let hasOpenQuestion;
|
|
1880
|
+
try {
|
|
1881
|
+
hasOpenQuestion = listQuestionIds(hqRoot).some((id) => {
|
|
1882
|
+
const question = readQuestion(hqRoot, id);
|
|
1883
|
+
return question.lane_id === lane.lane_id && question.status === "pending";
|
|
1884
|
+
});
|
|
1885
|
+
}
|
|
1886
|
+
catch (error) {
|
|
1887
|
+
markDirty(summary, { kind: "lane", id: lane.lane_id, why: "blocked keep-alive question recheck failed: " + (error instanceof Error ? error.message : String(error)) });
|
|
1888
|
+
return;
|
|
1889
|
+
}
|
|
1890
|
+
if (hasOpenQuestion) {
|
|
1891
|
+
appendBlockedKeepAliveHistory(hqRoot, latest, terminalAt, now.toISOString(), "open_question", deps);
|
|
1892
|
+
return;
|
|
1893
|
+
}
|
|
1894
|
+
let current = latest;
|
|
1895
|
+
if (current.provider === "claude" && deps.prepareKeepAliveClaudeResume !== undefined) {
|
|
1896
|
+
try {
|
|
1897
|
+
const prepared = await deps.prepareKeepAliveClaudeResume(current);
|
|
1898
|
+
current = prepared.lane;
|
|
1899
|
+
}
|
|
1900
|
+
catch (error) {
|
|
1901
|
+
markDirty(summary, { kind: "lane", id: lane.lane_id, why: `blocked keep-alive account preparation failed: ${error instanceof Error ? error.message : String(error)}` });
|
|
1902
|
+
return;
|
|
1903
|
+
}
|
|
1904
|
+
const afterPreparation = deps.readKeepAliveRecheckLane?.(hqRoot, lane.lane_id) ?? readLane(hqRoot, lane.lane_id);
|
|
1905
|
+
if (afterPreparation.state !== "blocked" || afterPreparation.last_envelope?.decision !== "blocked" || afterPreparation.last_envelope.at !== terminalAt)
|
|
1906
|
+
return;
|
|
1907
|
+
current = afterPreparation;
|
|
1908
|
+
}
|
|
1909
|
+
const expectedVersion = current.version;
|
|
1910
|
+
const result = queueLaneTerminalResume(current, now.toISOString(), LEAD_LANE_KEEP_ALIVE_BLOCKED_RESUME_TEXT, { allowBlockedResume: true });
|
|
1911
|
+
if (!result.resumeQueued) {
|
|
1912
|
+
if (result.resumeSkippedReason !== undefined) {
|
|
1913
|
+
summary.skipped.push({ kind: "lane", id: lane.lane_id, why: "keep_alive_" + result.resumeSkippedReason });
|
|
1914
|
+
}
|
|
1915
|
+
return;
|
|
1916
|
+
}
|
|
1917
|
+
const queued = casLaneIf(hqRoot, latest.lane_id, (latestRecord) => latestRecord.version === expectedVersion && latestRecord.state === "blocked" && latestRecord.last_envelope?.decision === "blocked" && latestRecord.last_envelope.at === terminalAt, (current) => ({
|
|
1918
|
+
...result.lane,
|
|
1919
|
+
version: current.version,
|
|
1920
|
+
keep_alive_blocked_resume_streak: priorResumes + 1,
|
|
1921
|
+
keep_alive_resume_count: (current.keep_alive_resume_count ?? 0) + 1,
|
|
1922
|
+
keep_alive_last_resume_at: now.toISOString(),
|
|
1923
|
+
status_gate_history: appendCappedHistory(current.status_gate_history ?? [], {
|
|
1924
|
+
event: "keep_alive_blocked_resumed",
|
|
1925
|
+
at: now.toISOString(),
|
|
1926
|
+
terminal_at: terminalAt,
|
|
1927
|
+
resume_queued: true,
|
|
1928
|
+
}),
|
|
1929
|
+
}), deps.dryRun);
|
|
1930
|
+
if (queued.changed) {
|
|
1931
|
+
summary.resumed.push({ id: lane.lane_id, from: "blocked", to: "queued", reason: "keep_alive_blocked" });
|
|
1932
|
+
if (!deps.dryRun) {
|
|
1933
|
+
recordKeepAliveEvent(hqRoot, lane.lane_id, summary, {
|
|
1934
|
+
event: "keep_alive_resume",
|
|
1935
|
+
at: now.toISOString(),
|
|
1936
|
+
attempt: (lane.keep_alive_resume_count ?? 0) + 1,
|
|
1937
|
+
resumed_from: "blocked",
|
|
1938
|
+
});
|
|
1939
|
+
}
|
|
1940
|
+
}
|
|
1941
|
+
}
|
|
1942
|
+
function appendBlockedKeepAliveHistory(hqRoot, lane, terminalAt, at, reason, deps) {
|
|
1943
|
+
if (deps.dryRun || lane.status_gate_history?.some((entry) => entry.event === "keep_alive_blocked_grace" && entry.terminal_at === terminalAt && entry.resume_skipped_reason === reason))
|
|
1944
|
+
return;
|
|
1945
|
+
casLaneIf(hqRoot, lane.lane_id, (current) => current.version === lane.version && current.state === "blocked" && current.last_envelope?.at === terminalAt, (current) => ({
|
|
1946
|
+
...current,
|
|
1947
|
+
status_gate_history: appendCappedHistory(current.status_gate_history ?? [], {
|
|
1948
|
+
event: "keep_alive_blocked_grace",
|
|
1949
|
+
at,
|
|
1950
|
+
terminal_at: terminalAt,
|
|
1951
|
+
resume_skipped_reason: reason,
|
|
1952
|
+
}),
|
|
1953
|
+
}), false);
|
|
1954
|
+
}
|
|
1955
|
+
async function resumeKeepAlive(hqRoot, lanes, questions, summary, deps, now, flagByCompany, supersessionLineageAwareByCompany, blockedResumeFlagByCompany) {
|
|
1783
1956
|
const nowMs = now.getTime();
|
|
1784
1957
|
const nowIso = now.toISOString();
|
|
1785
1958
|
const config = loadLanesConfig(hqRoot);
|
|
@@ -1792,7 +1965,7 @@ async function resumeKeepAlive(hqRoot, lanes, questions, summary, deps, now, fla
|
|
|
1792
1965
|
resolvedCompanyByLaneVersion.set(key, company);
|
|
1793
1966
|
return company;
|
|
1794
1967
|
};
|
|
1795
|
-
const keepAliveEnabled = [...flagByCompany.values()].some((enabled) => enabled);
|
|
1968
|
+
const keepAliveEnabled = [...flagByCompany.values()].some((enabled) => enabled) || [...blockedResumeFlagByCompany.values()].some(Boolean);
|
|
1796
1969
|
let retiredLaneIds = null;
|
|
1797
1970
|
if (keepAliveEnabled) {
|
|
1798
1971
|
try {
|
|
@@ -1813,6 +1986,10 @@ async function resumeKeepAlive(hqRoot, lanes, questions, summary, deps, now, fla
|
|
|
1813
1986
|
recordKeepAliveSkip(hqRoot, originalLane, "terminal_state", summary, deps);
|
|
1814
1987
|
continue;
|
|
1815
1988
|
}
|
|
1989
|
+
if (originalLane.state === "blocked" && originalLane.keep_alive === true) {
|
|
1990
|
+
await resumeBlockedKeepAlive(hqRoot, originalLane, questions, summary, deps, now, flagByCompany, blockedResumeFlagByCompany, companyForLane, lanes, retiredLaneIds, supersessionLineageAwareByCompany);
|
|
1991
|
+
continue;
|
|
1992
|
+
}
|
|
1816
1993
|
if ((originalLane.state !== "done" && originalLane.state !== "interrupted") ||
|
|
1817
1994
|
(originalLane.keep_alive !== true && originalLane.worker_profile === undefined))
|
|
1818
1995
|
continue;
|
package/dist/lib/lanes/spawn.js
CHANGED
|
@@ -28,6 +28,7 @@ import { registryWorkerRecord } from "./registry-persona.js";
|
|
|
28
28
|
import { resolveMachineIdentity, } from "./machine-identity.js";
|
|
29
29
|
import { appendCappedHistory, listLaneIds, readLane, retryUpdateLane } from "./store.js";
|
|
30
30
|
import { managerStatusGateHeartbeat } from "./manager-status-gate.js";
|
|
31
|
+
import { LEAD_LANE_KEEP_ALIVE_BLOCKED_RESUME_TEXT } from "./keep-alive.js";
|
|
31
32
|
import { copySessionFiles, planSessionCopy } from "./move-account.js";
|
|
32
33
|
import { ensureSessionHome } from "./session-relink.js";
|
|
33
34
|
import { MESSAGE_REPLAY_STATE_NAME } from "./message-replay.js";
|
|
@@ -2133,6 +2134,9 @@ export function spawnLaneWorker(hqRoot, lane, deps = {}, launch = {}) {
|
|
|
2133
2134
|
: {}),
|
|
2134
2135
|
};
|
|
2135
2136
|
}
|
|
2137
|
+
if (resume && pendingResume?.text !== LEAD_LANE_KEEP_ALIVE_BLOCKED_RESUME_TEXT) {
|
|
2138
|
+
next.keep_alive_blocked_resume_streak = 0;
|
|
2139
|
+
}
|
|
2136
2140
|
return next;
|
|
2137
2141
|
});
|
|
2138
2142
|
if (!claimed) {
|
package/dist/lib/lanes/store.js
CHANGED
|
@@ -481,6 +481,16 @@ export function parseLaneRecord(raw, filePath) {
|
|
|
481
481
|
value: raw.keep_alive_resume_count,
|
|
482
482
|
});
|
|
483
483
|
}
|
|
484
|
+
if (raw.keep_alive_blocked_resume_streak !== undefined &&
|
|
485
|
+
(typeof raw.keep_alive_blocked_resume_streak !== "number" ||
|
|
486
|
+
!Number.isSafeInteger(raw.keep_alive_blocked_resume_streak) ||
|
|
487
|
+
raw.keep_alive_blocked_resume_streak < 0 || raw.keep_alive_blocked_resume_streak > 2)) {
|
|
488
|
+
throw new LaneSchemaError("keep_alive_blocked_resume_streak must be an integer from 0 through 2", {
|
|
489
|
+
path: filePath,
|
|
490
|
+
field: "keep_alive_blocked_resume_streak",
|
|
491
|
+
value: raw.keep_alive_blocked_resume_streak,
|
|
492
|
+
});
|
|
493
|
+
}
|
|
484
494
|
for (const field of [
|
|
485
495
|
"keep_alive_opted_in_at",
|
|
486
496
|
"keep_alive_last_resume_at",
|
|
@@ -938,6 +948,12 @@ export function parseQuestionRecord(raw, filePath) {
|
|
|
938
948
|
}
|
|
939
949
|
requireString(raw.question_id, "question_id");
|
|
940
950
|
requireString(raw.lane_id, "lane_id");
|
|
951
|
+
if (raw.priority !== undefined && raw.priority !== null && raw.priority !== "P0" && raw.priority !== "P1" && raw.priority !== "P2") {
|
|
952
|
+
throw new LaneSchemaError("priority must be P0, P1, or P2 when present", {
|
|
953
|
+
path: filePath,
|
|
954
|
+
value: raw.priority,
|
|
955
|
+
});
|
|
956
|
+
}
|
|
941
957
|
requireInt(raw.version, "version");
|
|
942
958
|
requireInt(raw.hop, "hop");
|
|
943
959
|
parseOptionalCompanyField(raw, filePath);
|
|
@@ -964,7 +980,11 @@ export function parseQuestionRecord(raw, filePath) {
|
|
|
964
980
|
value: delivered_at,
|
|
965
981
|
});
|
|
966
982
|
}
|
|
967
|
-
return {
|
|
983
|
+
return {
|
|
984
|
+
...raw,
|
|
985
|
+
delivered_at,
|
|
986
|
+
...(raw.priority === null ? { priority: undefined } : {}),
|
|
987
|
+
};
|
|
968
988
|
}
|
|
969
989
|
/**
|
|
970
990
|
* HQ Sync sibling-twin grammar from `@indigoai-us/hq-cloud` `buildConflictPath`:
|
|
@@ -400,6 +400,13 @@ export interface KrFreshnessState {
|
|
|
400
400
|
/** Stable fingerprint of the last stalled KPI set, which is resumed once. */
|
|
401
401
|
stalled_fingerprint?: string;
|
|
402
402
|
}
|
|
403
|
+
export interface KeepAliveBlockedHistoryEntry {
|
|
404
|
+
event: "keep_alive_blocked_grace" | "keep_alive_blocked_resumed" | "keep_alive_blocked_escalated";
|
|
405
|
+
at: string;
|
|
406
|
+
terminal_at: string;
|
|
407
|
+
resume_skipped_reason?: "open_question" | "blocked_grace";
|
|
408
|
+
resume_queued?: boolean;
|
|
409
|
+
}
|
|
403
410
|
export interface KrFreshnessHistoryEntry {
|
|
404
411
|
event: "kr_stalled";
|
|
405
412
|
turn_id: string;
|
|
@@ -411,7 +418,7 @@ export interface KrFreshnessHistoryEntry {
|
|
|
411
418
|
resume_queued?: boolean;
|
|
412
419
|
resume_skipped_reason?: "open_question" | "blocked" | "miss_limit" | "no_provider_session";
|
|
413
420
|
}
|
|
414
|
-
export type LaneGateHistoryEntry = ManagerStatusGateHistoryEntry | BlockerFreshnessHistoryEntry | KrFreshnessHistoryEntry;
|
|
421
|
+
export type LaneGateHistoryEntry = ManagerStatusGateHistoryEntry | BlockerFreshnessHistoryEntry | KrFreshnessHistoryEntry | KeepAliveBlockedHistoryEntry;
|
|
415
422
|
export interface LaneStory {
|
|
416
423
|
project_id: string;
|
|
417
424
|
story_id: string;
|
|
@@ -484,6 +491,8 @@ export interface LaneRecord {
|
|
|
484
491
|
keep_alive_blocked_reason?: "not_opted_in" | "missing_opt_in_time" | "envelope_before_opt_in" | "interruption_before_opt_in" | "missing_interruption_time" | "retired" | "superseded" | "retired_list_invalid" | "terminal_state";
|
|
485
492
|
/** Consecutive automatic keep-alive resumes since the last human reset. */
|
|
486
493
|
keep_alive_resume_count?: number;
|
|
494
|
+
/** Blocked keep-alive resumes in the current blocked episode. */
|
|
495
|
+
keep_alive_blocked_resume_streak?: number;
|
|
487
496
|
/** Time the most recent automatic keep-alive resume was queued. */
|
|
488
497
|
keep_alive_last_resume_at?: string;
|
|
489
498
|
/** Earliest time the next consecutive automatic resume may be queued. */
|
|
@@ -782,12 +791,15 @@ export interface QuestionAnswer {
|
|
|
782
791
|
* question is flagged for the operator; nothing answers it automatically.
|
|
783
792
|
*/
|
|
784
793
|
export type QuestionKind = "continue";
|
|
794
|
+
export type QuestionPriority = "P0" | "P1" | "P2";
|
|
785
795
|
export interface QuestionRecord {
|
|
786
796
|
schema_version: typeof QUESTION_SCHEMA_VERSION | string;
|
|
787
797
|
question_id: string;
|
|
788
798
|
lane_id: string;
|
|
789
799
|
/** Set by the raiser when the options are only continue/stop. */
|
|
790
800
|
question_kind?: QuestionKind;
|
|
801
|
+
/** Urgency selected by the lane author; absent on pre-priority records. */
|
|
802
|
+
priority?: QuestionPriority;
|
|
791
803
|
/** `null` when the originating lane has no company. */
|
|
792
804
|
company: LaneCompanyRef | null;
|
|
793
805
|
project_id: string;
|
package/dist/lib/lanes/types.js
CHANGED
|
@@ -225,11 +225,11 @@ export const LANE_FIELD_WRITERS = {
|
|
|
225
225
|
pickup_validation_pending: ["creator", "command", "spawn", "reconcile"],
|
|
226
226
|
pickup_validation_pending_since: ["creator", "command", "spawn", "reconcile"],
|
|
227
227
|
priority: ["command"], worker: ["creator", "command"], worker_path: ["creator", "command"], worker_pack: ["creator", "command"], worker_profile: ["creator", "command"], worker_profile_hash: ["creator", "command", "spawn"], registry_worker: ["creator", "command", "spawn"], registry_worker_approval_history: ["command", "watcher", "reconcile"], worker_profile_repin_history: ["command"], worker_profile_ignored: ["creator", "command", "spawn"], worker_policy_delivery: ["command", "spawn"],
|
|
228
|
-
keep_alive: ["creator", "command"], keep_alive_standing: ["command"], keep_alive_opted_in_at: ["creator", "command"], keep_alive_blocked_reason: ["command", "reconcile"], keep_alive_resume_count: ["command", "reconcile"], keep_alive_last_resume_at: ["command", "reconcile"], keep_alive_next_eligible_at: ["command", "reconcile"], keep_alive_exhausted_at: ["command", "reconcile"],
|
|
228
|
+
keep_alive: ["creator", "command"], keep_alive_standing: ["command"], keep_alive_opted_in_at: ["creator", "command"], keep_alive_blocked_reason: ["command", "reconcile"], keep_alive_resume_count: ["command", "reconcile"], keep_alive_blocked_resume_streak: ["reconcile", "spawn", "watcher"], keep_alive_last_resume_at: ["command", "reconcile"], keep_alive_next_eligible_at: ["command", "reconcile"], keep_alive_exhausted_at: ["command", "reconcile"],
|
|
229
229
|
provider: ["creator"], account: ["creator", "spawn", "command", "watcher", "reconcile"], account_selection: ["creator", "command"], admission_accounts: ["creator", "command"], account_history: ["command", "spawn", "watcher", "reconcile"], failed_resume_history: ["command"], pending_resume: ["command", "spawn", "watcher", "reconcile"], placement_default: ["creator"], host: ["creator", "command"], origin_host: ["creator"], origin_host_source: ["creator"],
|
|
230
230
|
version: ["creator"], created_at: ["creator"], updated_at: ["creator"], ended_at: ["reconcile"], envelope_summary: ["reconcile"], attribution_history: ["command"],
|
|
231
231
|
last_envelope: ["watcher", "reconcile"], model: ["creator", "spawn", "command"], model_source: ["creator", "spawn", "command"], effort: ["creator", "spawn", "command"], effort_source: ["creator", "spawn", "command"], fast_mode: ["spawn"],
|
|
232
|
-
last_message_at: ["command"], status_gate: ["spawn", "watcher"], status_gate_history: ["watcher"], blocker_freshness_state: ["watcher"], kr_freshness_state: ["watcher"], last_compaction: ["spawn"], story_complete: ["watcher", "reconcile"], story_complete_reason: ["watcher", "reconcile"], story_status: ["watcher", "reconcile"],
|
|
232
|
+
last_message_at: ["command"], status_gate: ["spawn", "watcher"], status_gate_history: ["watcher", "reconcile"], blocker_freshness_state: ["watcher"], kr_freshness_state: ["watcher"], last_compaction: ["spawn"], story_complete: ["watcher", "reconcile"], story_complete_reason: ["watcher", "reconcile"], story_status: ["watcher", "reconcile"],
|
|
233
233
|
overdue: ["reconcile"], overdue_at: ["reconcile"], last_host_report_at: ["watcher", "spawn", "reconcile"], stalled: ["watcher"], stalled_at: ["watcher"], stalled_reason: ["watcher"],
|
|
234
234
|
admitted_reason: ["command", "reconcile"], terminal_reason: ["command", "watcher", "spawn", "reconcile"], stop_history: ["command", "reconcile"], settings_history: ["command"], pending_settings: ["command", "spawn"], interrupted_at: ["command", "watcher", "reconcile"], terminal_details: ["command", "spawn", "watcher", "reconcile"],
|
|
235
235
|
quota_reset_at: ["watcher", "reconcile"], model_quota_marker: ["watcher", "reconcile"], outpost_command_id: ["command"],
|
|
@@ -411,6 +411,8 @@ export function applyTerminalToLaneWithResult(hqRoot, laneId, classification, op
|
|
|
411
411
|
}), current.registry_worker_approval_history ?? []);
|
|
412
412
|
}
|
|
413
413
|
if (envelope) {
|
|
414
|
+
if (envelope.decision !== "blocked")
|
|
415
|
+
next.keep_alive_blocked_resume_streak = 0;
|
|
414
416
|
next.last_envelope = {
|
|
415
417
|
ref: envelopeRef,
|
|
416
418
|
decision: envelope.decision,
|
|
@@ -1536,7 +1538,7 @@ async function runWatcherLoopOwned(hqRoot, laneId, deps) {
|
|
|
1536
1538
|
updated = await settleKrFreshness(hqRoot, updated, manifest.turn_id, tick.emit.at, deps, logDecision);
|
|
1537
1539
|
}
|
|
1538
1540
|
const managerStatusFollowupQueued = manifest.turn_id !== undefined &&
|
|
1539
|
-
updated.status_gate_history?.some((entry) => entry.turn_id === manifest.turn_id &&
|
|
1541
|
+
updated.status_gate_history?.some((entry) => "turn_id" in entry && entry.turn_id === manifest.turn_id &&
|
|
1540
1542
|
((entry.event === "status_missed" && entry.resume_queued === true) ||
|
|
1541
1543
|
(entry.event === "blocker_stale" && entry.resume_queued === true) ||
|
|
1542
1544
|
(entry.event === "kr_stalled" && entry.resume_queued === true))) === true;
|
|
@@ -167,6 +167,13 @@ export interface SelfUpdateDeps {
|
|
|
167
167
|
* aside for the whole install. Read only when an npm global install is due.
|
|
168
168
|
*/
|
|
169
169
|
stagedSelfUpdate?: () => Promise<boolean>;
|
|
170
|
+
/**
|
|
171
|
+
* Runs installs through a copy of the installer's supervisor outside the
|
|
172
|
+
* package until disposed. Defaults to {@link detachUpdateSupervisor}.
|
|
173
|
+
*/
|
|
174
|
+
detachSupervisor?: () => {
|
|
175
|
+
dispose(): void;
|
|
176
|
+
} | null;
|
|
170
177
|
}
|
|
171
178
|
/**
|
|
172
179
|
* Startup path: the running CLI is behind npm `latest`, so update in place and
|
|
@@ -63,7 +63,7 @@ import * as path from "node:path";
|
|
|
63
63
|
import semver from "semver";
|
|
64
64
|
import chalk from "chalk";
|
|
65
65
|
import { CLI_NAME, CLI_VERSION } from "../cli-version.js";
|
|
66
|
-
import { buildBunInstallArgv, buildPnpmInstallArgv, buildPrefixedInstallArgv, buildSpawnPlan, checkUpdateConvergence, derivePnpmHome, isBunManagedPackageDir, isLocalDependencyInstall, isPnpmManagedPackageDir, isPrefixWritable, nonWritablePrefixNote, openInstallOutput, pnpmUpdateEnv, resolveRunningInstall, runUpdateCommand, runSupervisedUpdateCommand, } from "./version-gate.js";
|
|
66
|
+
import { buildBunInstallArgv, buildPnpmInstallArgv, buildPrefixedInstallArgv, buildSpawnPlan, checkUpdateConvergence, derivePnpmHome, detachUpdateSupervisor, isBunManagedPackageDir, isLocalDependencyInstall, isPnpmManagedPackageDir, isPrefixWritable, nonWritablePrefixNote, openInstallOutput, pnpmUpdateEnv, resolveRunningInstall, runUpdateCommand, runSupervisedUpdateCommand, } from "./version-gate.js";
|
|
67
67
|
import { canStageInstall, stagedNpmInstall } from "./staged-install.js";
|
|
68
68
|
import { acquireUpdateLock as acquireSharedUpdateLock } from "./update-lock.js";
|
|
69
69
|
import { markLatestIneffective } from "./version-check.js";
|
|
@@ -420,6 +420,9 @@ async function updateAndReexec(argv, flavor, known, deps) {
|
|
|
420
420
|
if (!releaseLock)
|
|
421
421
|
return { action: "skipped", latest };
|
|
422
422
|
const renamePath = deps.renamePath ?? fs.renameSync;
|
|
423
|
+
// The in-place update moves the package aside, and the installer's
|
|
424
|
+
// supervisor ships inside it, so run the installer through a copy.
|
|
425
|
+
const supervisor = staged ? null : (deps.detachSupervisor ?? detachUpdateSupervisor)();
|
|
423
426
|
// The staged install keeps the running package in place until the swap and
|
|
424
427
|
// restores it itself, so it takes no snapshot.
|
|
425
428
|
const installSnapshot = staged ? null : snapshotInstall(install, renamePath);
|
|
@@ -467,6 +470,7 @@ async function updateAndReexec(argv, flavor, known, deps) {
|
|
|
467
470
|
throw error;
|
|
468
471
|
}
|
|
469
472
|
finally {
|
|
473
|
+
supervisor?.dispose();
|
|
470
474
|
releaseLock();
|
|
471
475
|
}
|
|
472
476
|
if (!result.ok) {
|
|
@@ -284,6 +284,21 @@ export { buildSpawnPlan, quoteForWindowsShell };
|
|
|
284
284
|
*/
|
|
285
285
|
export declare function inOwnProcessGroup<T extends object>(options: T): T;
|
|
286
286
|
declare function updateTimeoutMs(env?: NodeJS.ProcessEnv): number;
|
|
287
|
+
/** The supervisor script the next install runs under. */
|
|
288
|
+
export declare function updateSupervisorPath(): string;
|
|
289
|
+
export interface DetachedUpdateSupervisor {
|
|
290
|
+
path: string;
|
|
291
|
+
dispose(): void;
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Copies the supervisor to a temp dir and runs installs through the copy until
|
|
295
|
+
* disposed. The in-place self-update moves the whole hq-cli package aside
|
|
296
|
+
* before it starts the installer, and the supervisor ships inside that package
|
|
297
|
+
* (5.290.0-5.292.0 failed every npm global self-update with MODULE_NOT_FOUND).
|
|
298
|
+
* The script needs only Node builtins, so the copy runs on its own. Returns
|
|
299
|
+
* null when the copy cannot be made; the caller then keeps the bundled path.
|
|
300
|
+
*/
|
|
301
|
+
export declare function detachUpdateSupervisor(): DetachedUpdateSupervisor | null;
|
|
287
302
|
/**
|
|
288
303
|
* Where an install's output goes — the other half of surviving a killed parent.
|
|
289
304
|
*
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
import { spawnSync } from "node:child_process";
|
|
31
31
|
import { installPathCompatibilityEnabled } from "../lib/install-path-compatibility-flag.js";
|
|
32
32
|
import { buildSpawnPlan, quoteForWindowsShell } from "./windows-spawn.js";
|
|
33
|
-
import { accessSync, closeSync, constants as fsConstants, existsSync, mkdtempSync, openSync, readdirSync, realpathSync, readFileSync, rmSync, } from "node:fs";
|
|
33
|
+
import { accessSync, closeSync, constants as fsConstants, copyFileSync, existsSync, mkdtempSync, openSync, readdirSync, realpathSync, readFileSync, rmSync, } from "node:fs";
|
|
34
34
|
import os from "node:os";
|
|
35
35
|
import path from "node:path";
|
|
36
36
|
import { fileURLToPath } from "node:url";
|
|
@@ -674,6 +674,50 @@ function updateTimeoutMs(env = process.env) {
|
|
|
674
674
|
* compiled module for production and is directly runnable from source tests.
|
|
675
675
|
*/
|
|
676
676
|
const UPDATE_COMMAND_SUPERVISOR = fileURLToPath(new URL("./update-command-supervisor.cjs", import.meta.url));
|
|
677
|
+
/** Set while a self-update runs the installer through a copy of the supervisor. */
|
|
678
|
+
let detachedSupervisor = null;
|
|
679
|
+
/** The supervisor script the next install runs under. */
|
|
680
|
+
export function updateSupervisorPath() {
|
|
681
|
+
return detachedSupervisor ?? UPDATE_COMMAND_SUPERVISOR;
|
|
682
|
+
}
|
|
683
|
+
/**
|
|
684
|
+
* Copies the supervisor to a temp dir and runs installs through the copy until
|
|
685
|
+
* disposed. The in-place self-update moves the whole hq-cli package aside
|
|
686
|
+
* before it starts the installer, and the supervisor ships inside that package
|
|
687
|
+
* (5.290.0-5.292.0 failed every npm global self-update with MODULE_NOT_FOUND).
|
|
688
|
+
* The script needs only Node builtins, so the copy runs on its own. Returns
|
|
689
|
+
* null when the copy cannot be made; the caller then keeps the bundled path.
|
|
690
|
+
*/
|
|
691
|
+
export function detachUpdateSupervisor() {
|
|
692
|
+
if (detachedSupervisor)
|
|
693
|
+
return null;
|
|
694
|
+
let dir;
|
|
695
|
+
try {
|
|
696
|
+
dir = mkdtempSync(path.join(os.tmpdir(), "hq-cli-update-supervisor-"));
|
|
697
|
+
const copy = path.join(dir, "update-command-supervisor.cjs");
|
|
698
|
+
copyFileSync(UPDATE_COMMAND_SUPERVISOR, copy);
|
|
699
|
+
detachedSupervisor = copy;
|
|
700
|
+
const tempDir = dir;
|
|
701
|
+
return {
|
|
702
|
+
path: copy,
|
|
703
|
+
dispose: () => {
|
|
704
|
+
if (detachedSupervisor === copy)
|
|
705
|
+
detachedSupervisor = null;
|
|
706
|
+
try {
|
|
707
|
+
rmSync(tempDir, { recursive: true, force: true });
|
|
708
|
+
}
|
|
709
|
+
catch {
|
|
710
|
+
// Best-effort cleanup of a temp dir.
|
|
711
|
+
}
|
|
712
|
+
},
|
|
713
|
+
};
|
|
714
|
+
}
|
|
715
|
+
catch {
|
|
716
|
+
if (dir)
|
|
717
|
+
rmSync(dir, { recursive: true, force: true });
|
|
718
|
+
return null;
|
|
719
|
+
}
|
|
720
|
+
}
|
|
677
721
|
function readSupervisorSpawnError(errorMarker) {
|
|
678
722
|
try {
|
|
679
723
|
const value = JSON.parse(readFileSync(errorMarker, "utf-8"));
|
|
@@ -754,7 +798,7 @@ export function runSupervisedUpdateCommand(cmd, args, output, env) {
|
|
|
754
798
|
// waits briefly, sends KILL to survivors, and waits for its direct child so
|
|
755
799
|
// the completed result leaves no zombie behind.
|
|
756
800
|
const result = spawnSync(process.execPath, [
|
|
757
|
-
|
|
801
|
+
updateSupervisorPath(),
|
|
758
802
|
JSON.stringify({
|
|
759
803
|
cmd: plan.cmd,
|
|
760
804
|
args: plan.args,
|