@indigoai-us/hq-cli 5.345.225 → 5.345.226
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 +32 -0
- package/dist/command-catalog.generated.d.ts +78 -0
- package/dist/command-catalog.generated.js +97 -0
- package/dist/commands/daemon.js +1 -1
- package/dist/commands/deploy-domains.js +38 -2
- package/dist/commands/lanes-accounts.d.ts +14 -0
- package/dist/commands/lanes-accounts.js +119 -0
- package/dist/commands/lanes-move.js +10 -0
- package/dist/commands/lanes-shared.js +9 -0
- package/dist/commands/lanes.js +137 -12
- package/dist/commands/sync-held.d.ts +22 -0
- package/dist/commands/sync-held.js +167 -18
- package/dist/hq-cloud-sync-runner/bin/sync-runner.js +4845 -2524
- package/dist/hq-cloud-sync-runner/package.json +1 -1
- package/dist/lib/capacity/accounts.d.ts +4 -0
- package/dist/lib/capacity/accounts.js +4 -0
- package/dist/lib/capacity/route.js +14 -0
- package/dist/lib/capacity/sign-in.d.ts +18 -0
- package/dist/lib/capacity/sign-in.js +34 -1
- package/dist/lib/daemon/catalog.d.ts +1 -0
- package/dist/lib/daemon/catalog.js +1 -1
- package/dist/lib/daemon/hook-requests.d.ts +76 -0
- package/dist/lib/daemon/hook-requests.js +481 -0
- package/dist/lib/daemon/lanes-reconcile-status.d.ts +35 -0
- package/dist/lib/daemon/lanes-reconcile-status.js +86 -0
- package/dist/lib/daemon/ops/policy.d.ts +1 -1
- package/dist/lib/daemon/ops/policy.js +43 -4
- package/dist/lib/daemon/run.js +37 -4
- package/dist/lib/daemon/server.js +6 -1
- package/dist/lib/daemon/supervisor.d.ts +2 -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/lanes/account-company.d.ts +7 -1
- package/dist/lib/lanes/account-company.js +22 -4
- package/dist/lib/lanes/account-ownership.d.ts +65 -0
- package/dist/lib/lanes/account-ownership.js +134 -0
- package/dist/lib/lanes/accounts.js +9 -2
- package/dist/lib/lanes/claude-balance.js +9 -3
- package/dist/lib/lanes/config.js +17 -0
- package/dist/lib/lanes/host-capacity.d.ts +19 -0
- package/dist/lib/lanes/host-capacity.js +37 -0
- package/dist/lib/lanes/reconcile.js +44 -3
- package/dist/lib/lanes/spawn.d.ts +0 -10
- package/dist/lib/lanes/spawn.js +51 -1
- package/dist/lib/lanes/types.d.ts +12 -0
- package/package.json +8 -8
package/dist/lib/daemon/run.js
CHANGED
|
@@ -38,6 +38,7 @@ import { SUPERVISOR_HANDOFF_FLAG, createDaemonFlagSnapshotSource, readDaemonFlag
|
|
|
38
38
|
import { createDaemonKillSwitchMonitors } from "./timed-flag-monitors.js";
|
|
39
39
|
import { MACHINE_CHECKS_RESULT_FILE, readMachineCheckResults, startMachineCheckSchedule } from "./machine-checks.js";
|
|
40
40
|
import { createLanesReconcileWatcher } from "./lanes-reconcile-watcher.js";
|
|
41
|
+
import { createLanesReconcileStatus, withLanesReconcileUnit } from "./lanes-reconcile-status.js";
|
|
41
42
|
import { findLegacyUnits, legacyMeshUnitsToRetire, legacyOwnerLookup, } from "./legacy.js";
|
|
42
43
|
import { readLegacySyncEnv } from "./legacy-sync-env.js";
|
|
43
44
|
import { readVaultSyncSwitches, unreadableSwitchesWarning, writeVaultSyncSwitches } from "../vault-sync-switches.js";
|
|
@@ -77,6 +78,7 @@ import { createTccEpermGuard, TCC_EPERM_SENTRY_FINGERPRINT } from "./tcc-eperm.j
|
|
|
77
78
|
import { daemonRunGuard } from "./lanes-reconcile-guard.js";
|
|
78
79
|
import { startStopJobDrainer } from "./stop-jobs.js";
|
|
79
80
|
import { executeStopJob, pruneStopJobResults, stopJobCompleted } from "./stop-job-executor.js";
|
|
81
|
+
import { executeHookRequest, startHookRequestDrainer } from "./hook-requests.js";
|
|
80
82
|
import { closeStopDiagnosticCursor, drainStopDiagnostics } from "./stop-diagnostics.js";
|
|
81
83
|
export const LOG_ROTATE_BYTES = 5 * 1024 * 1024;
|
|
82
84
|
/** Exit code for "restart me": non-zero so every service manager relaunches (Windows tasks only restart on failure). */
|
|
@@ -1085,6 +1087,17 @@ export async function runDaemon(opts) {
|
|
|
1085
1087
|
let laneReconcileWatcher = null;
|
|
1086
1088
|
let laneReconcileWatcherRoot = null;
|
|
1087
1089
|
let laneReconcileWatchFailedRoot = null;
|
|
1090
|
+
// The watcher's reconcile has no planned unit; its last outcome is added to
|
|
1091
|
+
// the state file so `hq daemon status` has a line for it.
|
|
1092
|
+
let lastPlanSignedIn = false;
|
|
1093
|
+
let lastPlanServices = [];
|
|
1094
|
+
const writeDaemonState = (state) => writeJsonAtomic(paths.statePath, withLanesReconcileUnit(state, laneReconcileWatcher ? laneReconcileStatus.unit(lastPlanSignedIn) : null, lastPlanServices));
|
|
1095
|
+
const laneReconcileStatus = createLanesReconcileStatus({
|
|
1096
|
+
onChange: () => {
|
|
1097
|
+
if (supervisor && laneReconcileWatcher)
|
|
1098
|
+
writeDaemonState(supervisor.state());
|
|
1099
|
+
},
|
|
1100
|
+
});
|
|
1088
1101
|
let laneReconcileHandlerLoadInFlight = false;
|
|
1089
1102
|
let laneReconcileHandlerLoadFailed = false;
|
|
1090
1103
|
const loadLaneReconcileHandler = (initialRoot) => {
|
|
@@ -1144,13 +1157,30 @@ export async function runDaemon(opts) {
|
|
|
1144
1157
|
}),
|
|
1145
1158
|
log: message => log("warn", message),
|
|
1146
1159
|
});
|
|
1147
|
-
|
|
1160
|
+
// Request notes hq-hook leaves on PostToolUse (hook-requests.ts): same lease, same stop signal, this daemon's HQ root only.
|
|
1161
|
+
const hookRequestDrainer = startHookRequestDrainer({
|
|
1162
|
+
home,
|
|
1163
|
+
root: () => readDaemonConfig(paths.configPath).hqRoot ?? env.HQ_ROOT,
|
|
1164
|
+
ownsQueue: ownsStopQueue,
|
|
1165
|
+
execute: request => executeHookRequest(request, {
|
|
1166
|
+
nodeBinary: opts.nodeBinary,
|
|
1167
|
+
hqBinary: opts.hqBinary,
|
|
1168
|
+
allowedRoot: readDaemonConfig(paths.configPath).hqRoot ?? env.HQ_ROOT,
|
|
1169
|
+
env,
|
|
1170
|
+
signal: stopJobAbort.signal,
|
|
1171
|
+
}),
|
|
1172
|
+
log: message => log("warn", message),
|
|
1173
|
+
});
|
|
1174
|
+
/** Closes the watchers; the promise settles once the Stop job or hook request in progress (if any) has finished. */
|
|
1148
1175
|
const closeRuntimeWatchers = () => {
|
|
1149
1176
|
if (stopDiagnosticRoot)
|
|
1150
1177
|
closeStopDiagnosticCursor(stopDiagnosticRoot);
|
|
1151
1178
|
clearInterval(stopDiagnosticTimer);
|
|
1152
1179
|
stopJobAbort.abort();
|
|
1153
|
-
const stopJobsClosed =
|
|
1180
|
+
const stopJobsClosed = Promise.all([
|
|
1181
|
+
stopJobDrainer.close().catch((err) => log("warn", `Stop job drainer did not close cleanly: ${String(err)}`)),
|
|
1182
|
+
hookRequestDrainer.close().catch((err) => log("warn", `Hook request drainer did not close cleanly: ${String(err)}`)),
|
|
1183
|
+
]).then(() => undefined);
|
|
1154
1184
|
laneReconcileWatcher?.close();
|
|
1155
1185
|
laneReconcileWatcher = null;
|
|
1156
1186
|
laneReconcileWatcherRoot = null;
|
|
@@ -1193,9 +1223,10 @@ export async function runDaemon(opts) {
|
|
|
1193
1223
|
try {
|
|
1194
1224
|
for (const directory of laneDirectories)
|
|
1195
1225
|
fs.mkdirSync(directory, { recursive: true, mode: 0o700 });
|
|
1226
|
+
laneReconcileStatus.reset();
|
|
1196
1227
|
laneReconcileWatcher = createLanesReconcileWatcher({
|
|
1197
1228
|
directories: laneDirectories,
|
|
1198
|
-
reconcile: laneReconcileHandler,
|
|
1229
|
+
reconcile: laneReconcileStatus.track(laneReconcileHandler),
|
|
1199
1230
|
intervalMs: 15_000,
|
|
1200
1231
|
onError: (error) => log("error", `in-process lanes reconcile failed: ${error instanceof Error ? error.message : String(error)}`),
|
|
1201
1232
|
onWatchError: (error) => {
|
|
@@ -1337,6 +1368,8 @@ export async function runDaemon(opts) {
|
|
|
1337
1368
|
const runners = { ...packageRunners, syncRunner: syncSource.runnerPath };
|
|
1338
1369
|
const services = enabledServices(machineType, config);
|
|
1339
1370
|
const isSignedIn = signedIn(env, home, log);
|
|
1371
|
+
lastPlanSignedIn = isSignedIn;
|
|
1372
|
+
lastPlanServices = services;
|
|
1340
1373
|
const syncOwner = effectiveSyncOwner(config, machineType);
|
|
1341
1374
|
let syncRunnerProcesses = [];
|
|
1342
1375
|
let syncRunnerOwnerPid = null;
|
|
@@ -1600,7 +1633,7 @@ export async function runDaemon(opts) {
|
|
|
1600
1633
|
},
|
|
1601
1634
|
restartDaemon: () => restartDaemon(),
|
|
1602
1635
|
runGuard: daemonRunGuard,
|
|
1603
|
-
writeState:
|
|
1636
|
+
writeState: writeDaemonState,
|
|
1604
1637
|
holds: {
|
|
1605
1638
|
read: () => readUnitHolds(paths.holdsPath),
|
|
1606
1639
|
write: (holds) => writeUnitHolds(paths.holdsPath, holds),
|
|
@@ -683,7 +683,12 @@ export async function startHqdServer(opts) {
|
|
|
683
683
|
err instanceof MachineLoginError
|
|
684
684
|
? { code: err.code, message: err.message }
|
|
685
685
|
: { code: "internal", message: err instanceof Error ? err.message : String(err) };
|
|
686
|
-
if (error.code === "
|
|
686
|
+
if (error.code === "hq_root_unreadable") {
|
|
687
|
+
// Not a daemon bug (macOS privacy permission), so no error report,
|
|
688
|
+
// but it must stay visible in the daemon log.
|
|
689
|
+
log("warn", `hqd ${req.op} failed: ${error.message}`);
|
|
690
|
+
}
|
|
691
|
+
else if (error.code === "internal") {
|
|
687
692
|
log("error", `hqd ${req.op} failed: ${error.message}`);
|
|
688
693
|
try {
|
|
689
694
|
opts.reportError?.(req.op, err);
|
|
@@ -146,6 +146,8 @@ interface UnitState {
|
|
|
146
146
|
lastRunAt?: number;
|
|
147
147
|
nextRunAt?: number;
|
|
148
148
|
lastResult?: "ok" | "failed";
|
|
149
|
+
/** Why the last run failed: one redacted, truncated line. Set for the in-process lanes reconcile. */
|
|
150
|
+
lastError?: string;
|
|
149
151
|
lastHeartbeatAt?: string;
|
|
150
152
|
lastPassResult?: ReturnType<typeof syncPassResult>;
|
|
151
153
|
/** The pass-request folder the running child was started with; absent when it was not. */
|