@indigoai-us/hq-cli 5.345.223 → 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 +98 -0
- package/assets/bot-workers/setup/context/quick-reference.md +2 -2
- package/assets/mesh-daemon/README.md +11 -12
- package/dist/command-catalog.generated.d.ts +156 -4
- package/dist/command-catalog.generated.js +191 -4
- package/dist/commands/cloud-provision.d.ts +4 -1
- package/dist/commands/cloud-provision.js +7 -3
- package/dist/commands/cloud-retire.js +1 -1
- package/dist/commands/core-delegate-w1b.js +3 -1
- package/dist/commands/core-delegate.d.ts +5 -0
- package/dist/commands/core-dm-bind-native.d.ts +5 -1
- package/dist/commands/core-dm-bind-native.js +4 -0
- package/dist/commands/core-job-notify-native.d.ts +5 -1
- package/dist/commands/core-job-notify-native.js +8 -2
- package/dist/commands/core-jobs-native.d.ts +27 -1
- package/dist/commands/core-jobs-native.js +49 -28
- package/dist/commands/core-pipeline-conductor-native.js +7 -7
- package/dist/commands/core-pipeline-driver-native.js +5 -5
- package/dist/commands/core-refresh-vault-access-native.d.ts +5 -0
- package/dist/commands/core-refresh-vault-access-native.js +3 -1
- package/dist/commands/core-work-mesh-bind-trusted-native.js +1 -1
- package/dist/commands/daemon.d.ts +2 -0
- package/dist/commands/daemon.js +68 -2
- 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-hold.d.ts +2 -27
- package/dist/commands/lanes-hold.js +3 -75
- package/dist/commands/lanes-loop.js +1 -1
- package/dist/commands/lanes-move.js +10 -0
- package/dist/commands/lanes-session-start.js +2 -2
- package/dist/commands/lanes-shared.js +9 -0
- package/dist/commands/lanes.js +137 -12
- package/dist/commands/mesh.d.ts +12 -0
- package/dist/commands/mesh.js +13 -4
- package/dist/commands/monitor.js +1 -1
- package/dist/commands/packs.js +1 -1
- package/dist/commands/sync-held.d.ts +22 -0
- package/dist/commands/sync-held.js +167 -18
- package/dist/commands/whoami.d.ts +10 -17
- package/dist/commands/whoami.js +7 -79
- package/dist/data/command-states.json +13 -0
- package/dist/hq-cloud-sync-runner/bin/sync-runner.js +4845 -2524
- package/dist/hq-cloud-sync-runner/package.json +1 -1
- package/dist/index.js +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 +9 -5
- package/dist/lib/daemon/catalog.js +14 -8
- package/dist/lib/daemon/config.d.ts +5 -0
- package/dist/lib/daemon/config.js +6 -0
- package/dist/lib/daemon/hook-requests.d.ts +76 -0
- package/dist/lib/daemon/hook-requests.js +481 -0
- package/dist/lib/daemon/lanes-monitor-state.d.ts +55 -0
- package/dist/lib/daemon/lanes-monitor-state.js +129 -0
- package/dist/lib/daemon/lanes-reconcile-loader.d.ts +7 -0
- package/dist/lib/daemon/lanes-reconcile-loader.js +13 -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/merge-sections.d.ts +165 -0
- package/dist/lib/daemon/merge-sections.js +556 -0
- package/dist/lib/daemon/ops/policy.d.ts +2 -2
- package/dist/lib/daemon/ops/policy.js +44 -5
- package/dist/lib/daemon/protocol.d.ts +1 -1
- package/dist/lib/daemon/protocol.js +0 -6
- package/dist/lib/daemon/run.js +110 -5
- package/dist/lib/daemon/selfcheck.js +2 -2
- package/dist/lib/daemon/server.d.ts +2 -4
- package/dist/lib/daemon/server.js +11 -49
- package/dist/lib/daemon/state-file.d.ts +74 -4
- package/dist/lib/daemon/state-file.js +159 -19
- package/dist/lib/daemon/supervisor.d.ts +3 -1
- package/dist/lib/daemon/updater.d.ts +2 -6
- package/dist/lib/daemon/updater.js +4 -11
- package/dist/lib/daemon/whoami-cache.d.ts +96 -0
- package/dist/lib/daemon/whoami-cache.js +244 -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/hook-engine/coverage.d.ts +2 -0
- package/dist/lib/hook-engine/coverage.js +71 -0
- package/dist/lib/hook-engine/native-precompact-compatibility.json +449 -0
- package/dist/lib/hook-engine/reconcile.js +14 -8
- package/dist/lib/install/hook-target.d.ts +13 -3
- package/dist/lib/install/hook-target.js +14 -11
- 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/envelope-repair-dispatch.js +1 -1
- package/dist/lib/lanes/host-capacity.d.ts +19 -0
- package/dist/lib/lanes/host-capacity.js +37 -0
- package/dist/lib/lanes/monitor.d.ts +2 -0
- package/dist/lib/lanes/monitor.js +2 -1
- package/dist/lib/lanes/reconcile.js +44 -3
- package/dist/lib/lanes/registry-flag.d.ts +6 -0
- package/dist/lib/lanes/registry-flag.js +3 -2
- package/dist/lib/lanes/repo-merge-hold.d.ts +39 -0
- package/dist/lib/lanes/repo-merge-hold.js +90 -0
- 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/dist/lib/lanes/watcher-main.js +3 -3
- package/dist/lib/mesh/live/daemon/doctor.js +1 -1
- package/dist/lib/mesh/live/daemon/install.js +2 -2
- package/dist/lib/windows/install-followup.js +1 -1
- package/dist/utils/client-health-contract.d.ts +1 -0
- package/dist/utils/client-health-contract.js +5 -0
- package/dist/utils/client-health.d.ts +2 -0
- package/dist/utils/client-health.js +40 -0
- package/dist/utils/cognito-session.d.ts +2 -14
- package/dist/utils/cognito-session.js +2 -40
- package/dist/utils/daemon-cli-version.d.ts +13 -0
- package/dist/utils/daemon-cli-version.js +47 -0
- package/dist/utils/duplicate-command-usage.js +1 -1
- package/dist/utils/machine-token-cache.d.ts +21 -0
- package/dist/utils/machine-token-cache.js +49 -0
- package/dist/utils/resident-package-preload.js +4 -0
- package/dist/utils/whoami-identity.d.ts +54 -0
- package/dist/utils/whoami-identity.js +108 -0
- package/package.json +8 -8
- package/dist/lib/daemon/ops/memory.d.ts +0 -18
- package/dist/lib/daemon/ops/memory.js +0 -65
- package/dist/lib/daemon/ops/mesh.d.ts +0 -38
- package/dist/lib/daemon/ops/mesh.js +0 -70
|
@@ -9,20 +9,13 @@ import { readLanesFlagLocalOverride, readLanesRegistryFlag } from "../lib/lanes/
|
|
|
9
9
|
import { sessionIdFromEnv } from "../lib/mesh/live/session-identity.js";
|
|
10
10
|
import { readLaneReview } from "../lib/lanes/reviews.js";
|
|
11
11
|
import { resolveLaneCompany } from "../lib/lanes/lane-company.js";
|
|
12
|
-
|
|
13
|
-
export
|
|
14
|
-
export const REPO_MERGE_HOLDS_REL = path.join("workspace", "lanes", "holds");
|
|
15
|
-
const HOLD_SCHEMA_VERSION = "hq-lanes-repo-merge-hold.v1";
|
|
16
|
-
const HISTORY_CAP = 50;
|
|
12
|
+
import { HOLD_HISTORY_CAP, HOLD_SCHEMA_VERSION, LANES_REPO_MERGE_HOLD_FLAG, LANES_REVIEW_BEFORE_MERGE_FLAG, REPO_MERGE_HOLDS_REL, holdFilePath, parseHold, } from "../lib/lanes/repo-merge-hold.js";
|
|
13
|
+
export { LANES_REPO_MERGE_HOLD_FLAG, LANES_REVIEW_BEFORE_MERGE_FLAG, REPO_MERGE_HOLDS_REL };
|
|
17
14
|
const HOLD_LOCK_WAIT_MS = 5_000;
|
|
18
15
|
const HOLD_LOCK_STALE_MS = 5 * 60_000;
|
|
19
16
|
function fail(error, message, details = {}) {
|
|
20
17
|
throw new LanesError(error, message, details);
|
|
21
18
|
}
|
|
22
|
-
function holdFilePath(hqRoot, repo) {
|
|
23
|
-
const [owner, repository] = canonicalRepo(repo).split("/");
|
|
24
|
-
return path.join(hqRoot, REPO_MERGE_HOLDS_REL, `${owner}__${repository}.json`);
|
|
25
|
-
}
|
|
26
19
|
function nonEmptyText(field, raw) {
|
|
27
20
|
const value = raw.trim();
|
|
28
21
|
if (!value)
|
|
@@ -66,71 +59,6 @@ function parseUntil(raw, now) {
|
|
|
66
59
|
}
|
|
67
60
|
return new Date(timestamp).toISOString();
|
|
68
61
|
}
|
|
69
|
-
function isObject(value) {
|
|
70
|
-
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
71
|
-
}
|
|
72
|
-
function isCanonicalTimestamp(value) {
|
|
73
|
-
if (typeof value !== "string")
|
|
74
|
-
return false;
|
|
75
|
-
const timestamp = Date.parse(value);
|
|
76
|
-
return Number.isFinite(timestamp) && new Date(timestamp).toISOString() === value;
|
|
77
|
-
}
|
|
78
|
-
function parseHold(raw, file) {
|
|
79
|
-
if (!isObject(raw))
|
|
80
|
-
return fail("repo_hold_invalid", "Merge hold record must be an object", { path: file });
|
|
81
|
-
const company = raw.company;
|
|
82
|
-
const history = raw.history;
|
|
83
|
-
if (raw.schema_version !== HOLD_SCHEMA_VERSION || typeof raw.repo !== "string" ||
|
|
84
|
-
!isObject(company) || typeof company.slug !== "string" || !company.slug.trim() ||
|
|
85
|
-
typeof company.uid !== "string" || !company.uid.trim() ||
|
|
86
|
-
typeof raw.reason !== "string" || !raw.reason.trim() ||
|
|
87
|
-
!isCanonicalTimestamp(raw.set_at) || !isCanonicalTimestamp(raw.until) ||
|
|
88
|
-
!(raw.set_by_lane === null || typeof raw.set_by_lane === "string") ||
|
|
89
|
-
!(raw.set_by_session === null || typeof raw.set_by_session === "string") ||
|
|
90
|
-
!Array.isArray(history) || history.length > HISTORY_CAP ||
|
|
91
|
-
(raw.released_at !== undefined && !isCanonicalTimestamp(raw.released_at)) ||
|
|
92
|
-
(raw.released_reason !== undefined && typeof raw.released_reason !== "string")) {
|
|
93
|
-
return fail("repo_hold_invalid", "Merge hold record has invalid fields", { path: file });
|
|
94
|
-
}
|
|
95
|
-
let repo;
|
|
96
|
-
try {
|
|
97
|
-
repo = canonicalRepo(raw.repo);
|
|
98
|
-
}
|
|
99
|
-
catch {
|
|
100
|
-
return fail("repo_hold_invalid", "Merge hold record has an invalid repository", { path: file });
|
|
101
|
-
}
|
|
102
|
-
if (repo !== raw.repo)
|
|
103
|
-
return fail("repo_hold_invalid", "Merge hold repository is not canonical", { path: file });
|
|
104
|
-
if ((raw.released_at === undefined) !== (raw.released_reason === undefined)) {
|
|
105
|
-
return fail("repo_hold_invalid", "Released merge hold must include both release fields", { path: file });
|
|
106
|
-
}
|
|
107
|
-
if (raw.released_at !== undefined && (!raw.released_reason || !raw.released_reason.trim())) {
|
|
108
|
-
return fail("repo_hold_invalid", "Released merge hold is missing its reason", { path: file });
|
|
109
|
-
}
|
|
110
|
-
assertNoSecretText("hold.reason", raw.reason);
|
|
111
|
-
if (typeof raw.released_reason === "string")
|
|
112
|
-
assertNoSecretText("hold.released_reason", raw.released_reason);
|
|
113
|
-
for (const entry of history) {
|
|
114
|
-
if (!isObject(entry) || !isCanonicalTimestamp(entry.set_at) || !isCanonicalTimestamp(entry.until) ||
|
|
115
|
-
typeof entry.reason !== "string" || !entry.reason.trim() ||
|
|
116
|
-
!(entry.set_by_lane === null || typeof entry.set_by_lane === "string") ||
|
|
117
|
-
!(entry.set_by_session === null || typeof entry.set_by_session === "string") ||
|
|
118
|
-
(entry.released_at !== undefined && !isCanonicalTimestamp(entry.released_at)) ||
|
|
119
|
-
(entry.released_reason !== undefined && typeof entry.released_reason !== "string")) {
|
|
120
|
-
return fail("repo_hold_invalid", "Merge hold history has invalid entries", { path: file });
|
|
121
|
-
}
|
|
122
|
-
if ((entry.released_at === undefined) !== (entry.released_reason === undefined)) {
|
|
123
|
-
return fail("repo_hold_invalid", "Merge hold history release fields are incomplete", { path: file });
|
|
124
|
-
}
|
|
125
|
-
if (entry.released_reason !== undefined && !entry.released_reason.trim()) {
|
|
126
|
-
return fail("repo_hold_invalid", "Merge hold history release reason is empty", { path: file });
|
|
127
|
-
}
|
|
128
|
-
assertNoSecretText("hold.history.reason", entry.reason);
|
|
129
|
-
if (typeof entry.released_reason === "string")
|
|
130
|
-
assertNoSecretText("hold.history.released_reason", entry.released_reason);
|
|
131
|
-
}
|
|
132
|
-
return raw;
|
|
133
|
-
}
|
|
134
62
|
function readHold(hqRoot, repo) {
|
|
135
63
|
const file = holdFilePath(hqRoot, repo);
|
|
136
64
|
let contents;
|
|
@@ -474,7 +402,7 @@ export function registerLaneRepoMergeHoldCommand(lanes, deps, wrap) {
|
|
|
474
402
|
until,
|
|
475
403
|
set_by_lane: env.HQ_LANE_ID?.trim() || null,
|
|
476
404
|
set_by_session: sessionIdFromEnv(env) ?? null,
|
|
477
|
-
history: [...(previous?.history ?? []), ...(previous ? [historyEntry(previous)] : [])].slice(-
|
|
405
|
+
history: [...(previous?.history ?? []), ...(previous ? [historyEntry(previous)] : [])].slice(-HOLD_HISTORY_CAP),
|
|
478
406
|
};
|
|
479
407
|
writeHold(hqRoot, next);
|
|
480
408
|
return next;
|
|
@@ -122,7 +122,7 @@ export function startLaneLoopControllerWithAdmissionLockHeld(ctx, laneId, initia
|
|
|
122
122
|
const entry = process.argv[1];
|
|
123
123
|
if (!entry)
|
|
124
124
|
throw new LanesError("loop_controller_entry_missing", "Cannot resolve the hq CLI entry point for the loop controller", { lane_id: laneId });
|
|
125
|
-
const args = [entry, "
|
|
125
|
+
const args = [entry, "runners", "_loop-worker", laneId];
|
|
126
126
|
const env = { ...ctx.env, HQ_LANE_LOOP_CONTROLLER: "1", ...(initialAdmission ? { HQ_LANE_LOOP_INITIAL: "1" } : {}) };
|
|
127
127
|
const child = ctx.spawnProcess
|
|
128
128
|
? ctx.spawnProcess(liveNodeBinary(), args, { cwd: ctx.hqRoot(), detached: true, windowsHide: true, stdio: ["ignore", 1, 2], env })
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { accountHeldByOther } from "../lib/lanes/account-ownership.js";
|
|
1
2
|
import * as path from "node:path";
|
|
2
3
|
import { chooseHostForLane } from "../lib/lanes/host-capacity.js";
|
|
3
4
|
import { laneRunsHere, loadLanesConfig, loadWorkerProfile, readLane, updateLane, withLaneAdmissionLock, } from "../lib/lanes/index.js";
|
|
@@ -167,6 +168,15 @@ export function createLaneMoveHandlers(deps) {
|
|
|
167
168
|
assertKnownOutpost(target.id, known);
|
|
168
169
|
}
|
|
169
170
|
const accountConfig = loadLanesConfig(hqRoot).providers[before.provider].accounts[account];
|
|
171
|
+
if (accountHeldByOther(accountConfig)) {
|
|
172
|
+
const holder = accountConfig?.holder ?? null;
|
|
173
|
+
throw new LanesError("account_held_by_other", `Account ${account} is held by ${holder}, not the owner, and is not used for lanes`, {
|
|
174
|
+
lane_id: laneId,
|
|
175
|
+
provider: before.provider,
|
|
176
|
+
account,
|
|
177
|
+
holder,
|
|
178
|
+
});
|
|
179
|
+
}
|
|
170
180
|
if (accountConfig === undefined || !accountConfig.enabled) {
|
|
171
181
|
throw new LanesError("lane_move_account_invalid", `Account ${account} is unavailable for ${before.provider}`, {
|
|
172
182
|
lane_id: laneId,
|
|
@@ -489,7 +489,7 @@ export function startSessionStartOrphanSweep(root, env = process.env, spawnDetac
|
|
|
489
489
|
"const start=()=>{let lease;try{lease=JSON.parse(fs.readFileSync(lock,'utf8'))}catch{}if(lease?.owner_token!==token){if(Date.now()<Number(lease?.started_at||0)+1000)return setTimeout(start,10);process.exit(0)}",
|
|
490
490
|
"try{fs.writeFileSync(lock,JSON.stringify({...lease,pid:process.pid}))}catch{}",
|
|
491
491
|
"const tmp=report+'.tmp';let output;try{output=fs.createWriteStream(tmp,{flags:'wx',mode:0o600})}catch{cleanup();process.exit(0)}",
|
|
492
|
-
"const child=cp.spawn(process.execPath,[cli,'
|
|
492
|
+
"const child=cp.spawn(process.execPath,[cli,'runners','_reap','--json','--legacy'],{stdio:['ignore','pipe','ignore'],env:{...process.env,HQ_ROOT:root,HQ_NO_UPDATE_CHECK:'1'}});",
|
|
493
493
|
"child.stdout.pipe(output);child.on('error',()=>{output.destroy();try{fs.rmSync(tmp,{force:true})}catch{}cleanup()});",
|
|
494
494
|
"child.on('exit',(code)=>output.end(()=>{try{if(code===0)fs.renameSync(tmp,report);else fs.rmSync(tmp,{force:true})}catch{}cleanup()}));};start();",
|
|
495
495
|
].join("");
|
|
@@ -554,7 +554,7 @@ export function startSessionStartFlagRefresh(env, spawnDetached = spawn, now = D
|
|
|
554
554
|
catch {
|
|
555
555
|
return false;
|
|
556
556
|
}
|
|
557
|
-
const child = spawnDetached(process.execPath, [cli, "
|
|
557
|
+
const child = spawnDetached(process.execPath, [cli, "runners", "session-start", "--refresh-flags"], {
|
|
558
558
|
detached: true,
|
|
559
559
|
stdio: "ignore",
|
|
560
560
|
env: { ...env, HQ_NO_UPDATE_CHECK: "1" },
|
|
@@ -3,6 +3,7 @@ import { readLanesRegistryFlag } from "../lib/lanes/registry-flag.js";
|
|
|
3
3
|
import { LANE_OUTPOST_LOAD_BALANCING_FLAG } from "../lib/lanes/flag-keys.js";
|
|
4
4
|
import { resolveLaneEffort } from "../lib/lanes/effort.js";
|
|
5
5
|
import { LanesError } from "../lib/lanes/errors.js";
|
|
6
|
+
import { accountHeldByOther } from "../lib/lanes/account-ownership.js";
|
|
6
7
|
import { AccountResolutionError, accountStatus, loadLanesConfig } from "../lib/lanes/index.js";
|
|
7
8
|
import { resolveLaneModel } from "../lib/lanes/spawn.js";
|
|
8
9
|
import { sessionIdFromEnv } from "../lib/mesh/live/session-identity.js";
|
|
@@ -25,6 +26,14 @@ export function assertCurrentResumeAccountAvailable(ctx, lane) {
|
|
|
25
26
|
? `Lane ${lane.lane_id} records account ${JSON.stringify(lane.account)} which is not configured for ${lane.provider}`
|
|
26
27
|
: `Account ${JSON.stringify(lane.account)} is disabled${account.disabled_reason ? `: ${account.disabled_reason}` : ""}`, { provider: lane.provider, account: lane.account ?? "", ...(account?.disabled_reason !== undefined ? { reason: account.disabled_reason } : {}) });
|
|
27
28
|
}
|
|
29
|
+
// PS-006: keeping a lane on a login held by another person is refused
|
|
30
|
+
// before anything probes that login's home.
|
|
31
|
+
if (accountHeldByOther(account)) {
|
|
32
|
+
const holder = account.holder ?? null;
|
|
33
|
+
throw new LanesError("account_held_by_other", `Account ${lane.account} is held by ${holder}, not the owner, and is not used for lanes`, {
|
|
34
|
+
provider: lane.provider, account: lane.account ?? "", holder,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
28
37
|
const status = accountStatus(lane.provider, lane.account, config, {
|
|
29
38
|
existsSync: ctx.existsSync,
|
|
30
39
|
hostname: ctx.hostname(),
|
package/dist/commands/lanes.js
CHANGED
|
@@ -85,6 +85,7 @@ import { sessionIdFromEnv } from "../lib/mesh/live/session-identity.js";
|
|
|
85
85
|
import { applyLoopDisposition, loopDispositionSnapshot } from "../lib/lanes/loop-disposition.js";
|
|
86
86
|
import { listLaneReviews } from "../lib/lanes/reviews.js";
|
|
87
87
|
import { effectiveAccountHome } from "../lib/lanes/account-home.js";
|
|
88
|
+
import { accountHeldByOther } from "../lib/lanes/account-ownership.js";
|
|
88
89
|
import { remoteControlSelectionConfig, remoteControlSessionHome } from "../lib/lanes/remote-control-lane.js";
|
|
89
90
|
import { AccountResolutionError, compareLaneQueueOrder, LANE_PROVIDERS, LANE_STATES, QUESTION_STATUSES, SENIOR_KINDS, accountStatus, appendCappedHistory, canonicalizeHome, createLane, mintLaneId, decideAdmission, defaultLivenessDeps, defaultSystemdUserDir, defaultThrottleDeps, installReconcileTimer, providerPathEnv, probeDrainHookRegistration, isLanesError, isLaneVersionConflict, isTerminalLaneState, isFinishedResumableHireChild, childrenHoldingHireGrantCarve, laneHoldsHireGrantCarve, assignedChildHireGrants, hireGrantCapacityError, planHireGrantBackfill, terminalChildResumeHireGrantError, withHireGrantAdmission, laneStoryLedgerEnabled, syncLaneToProjectStoryLedger, removeLaneFromProjectStoryLedger, validateProjectStories, buildLaneStatusSnapshot, formatLaneStatusHuman, expandLocalLaneIdPrefix, listLaneIds, listQuestionIds, loadLanesConfig, laneRunsHere, MAX_LANE_DEPTH, MONITOR_ERROR_EXIT_CODE, readLiveMonitorEvidence, resolveMachineIdentity as lookupMachineIdentity, loadLivenessIndex, parseLaneProvider, isLaneProvider, parseLaneRecord, parseLaneState, parseQuestionRecord, parseSeniorKind, readAllLanes, readLane, sanitizeHostComponent, retryUpdateLane, syncLaneRecordFromOwner, readQuestion, resolveAccount, resolveLaneWorker, ignoredWorkerProfileFields, loadWorkerProfile, loadWorkerProfileWithRegistry, registryWorkerRecord, runReconcilePass, DEAD_HOST_MS, sessionLiveness, tryReadLane, uninstallReconcileTimer, updateLane, updateQuestion, dropboxDir, laneDeliveryMechanism, hasActiveAdmissionReservation, hasActivePendingResume, hasRecordedSessionId, hasEarlierEligibleQueuedLane, laneAdmissionCapReason, providerSupportsSessionResume, providerSessionPortable, isFailedQuotaKeepAliveLane, sessionNotPortableMessage, withLaneAdmissionLock, withAllLaneAdmissionLocks, readWorkerRunResult, resumeCommandRefusal, withLaneHireLocks, raiseLaneQuestion, sha256Text, } from "../lib/lanes/index.js";
|
|
90
91
|
import { admitQueuedNow } from "../lib/lanes/reconcile.js";
|
|
@@ -3559,14 +3560,58 @@ function markPickupFailure(hqRoot, laneId, reasonRaw, details) {
|
|
|
3559
3560
|
export function applyOutpostAccountPickup(hqRoot, laneId, modelDeps = {}) {
|
|
3560
3561
|
const lane = readLane(hqRoot, laneId);
|
|
3561
3562
|
const config = loadLanesConfig(hqRoot);
|
|
3563
|
+
// PS-006: a recorded login held by another person is never resolved or
|
|
3564
|
+
// probed here. When balancing or the router chose it (account_source
|
|
3565
|
+
// "balanced" or "auto"), pick again among the usable logins; the balanced
|
|
3566
|
+
// pick never returns a held login. When it was pinned (--account, a worker
|
|
3567
|
+
// profile, or a record from before account_source), fail the pickup. The
|
|
3568
|
+
// pickup terminal reasons are a fixed schema list, so that reuses
|
|
3569
|
+
// account_disabled and names the cause in the details.
|
|
3570
|
+
const recordedConfig = lane.account === undefined ? undefined : config.providers[lane.provider].accounts[lane.account];
|
|
3571
|
+
const recordedHeld = lane.account !== undefined && accountHeldByOther(recordedConfig);
|
|
3572
|
+
const recordedPinned = lane.account_source !== "balanced" && lane.account_source !== "auto";
|
|
3573
|
+
if (recordedHeld && recordedPinned) {
|
|
3574
|
+
return markPickupFailure(hqRoot, laneId, "account_disabled", {
|
|
3575
|
+
error: "account_held_by_other",
|
|
3576
|
+
provider: lane.provider,
|
|
3577
|
+
account: lane.account,
|
|
3578
|
+
holder: recordedConfig?.holder ?? null,
|
|
3579
|
+
});
|
|
3580
|
+
}
|
|
3581
|
+
// A pick at pickup (no recorded account, or a balanced login now held by
|
|
3582
|
+
// another person) stays inside the lane's company and its admission list,
|
|
3583
|
+
// the same scope a local first assignment uses. Nothing left in scope fails
|
|
3584
|
+
// the pickup instead of borrowing another company's or a personal login.
|
|
3585
|
+
const repick = lane.account === undefined || recordedHeld;
|
|
3586
|
+
let allowedAccounts;
|
|
3587
|
+
if (repick) {
|
|
3588
|
+
const providerAccounts = config.providers[lane.provider].accounts;
|
|
3589
|
+
const company = resolveLaneCompany(hqRoot, lane).company;
|
|
3590
|
+
allowedAccounts = Object.keys(providerAccounts).filter((id) => accountMatchesCompany(providerAccounts[id], company, providerAccounts) &&
|
|
3591
|
+
(lane.admission_accounts === undefined || lane.admission_accounts.includes(id)));
|
|
3592
|
+
if (!allowedAccounts.some((id) => providerAccounts[id]?.enabled === true && !accountHeldByOther(providerAccounts[id]))) {
|
|
3593
|
+
return markPickupFailure(hqRoot, laneId, "account_disabled", {
|
|
3594
|
+
error: recordedHeld ? "account_held_by_other" : "no_account_in_lane_scope",
|
|
3595
|
+
provider: lane.provider,
|
|
3596
|
+
account: lane.account ?? null,
|
|
3597
|
+
...(recordedHeld ? { holder: recordedConfig?.holder ?? null } : {}),
|
|
3598
|
+
company: company?.slug ?? null,
|
|
3599
|
+
admission_accounts: lane.admission_accounts ?? null,
|
|
3600
|
+
message: "No enabled login in the lane's company" +
|
|
3601
|
+
(lane.admission_accounts !== undefined ? " and admission accounts" : "") +
|
|
3602
|
+
" is usable by lanes on this host",
|
|
3603
|
+
});
|
|
3604
|
+
}
|
|
3605
|
+
}
|
|
3562
3606
|
try {
|
|
3563
|
-
const resolved = resolveAccount(lane.provider, lane.account, config, {
|
|
3607
|
+
const resolved = resolveAccount(lane.provider, repick ? undefined : lane.account, config, {
|
|
3564
3608
|
hqRoot,
|
|
3565
3609
|
hostname: os.hostname(),
|
|
3566
3610
|
accountDeps: {
|
|
3567
3611
|
probe: modelDeps.probe,
|
|
3568
3612
|
env: modelDeps.env,
|
|
3569
3613
|
},
|
|
3614
|
+
...(allowedAccounts !== undefined ? { allowedAccounts } : {}),
|
|
3570
3615
|
});
|
|
3571
3616
|
const status = accountStatus(lane.provider, resolved.id, config, {
|
|
3572
3617
|
existsSync: (p) => fs.existsSync(p),
|
|
@@ -3622,19 +3667,42 @@ export function applyOutpostAccountPickup(hqRoot, laneId, modelDeps = {}) {
|
|
|
3622
3667
|
// writer. `account` stays closed to `command`: an operator command never
|
|
3623
3668
|
// re-pins the account of a lane it does not execute. The bind also
|
|
3624
3669
|
// clears the pickup marker: from here the reconcile pass may admit it.
|
|
3625
|
-
|
|
3670
|
+
const bound = retryUpdateLane(hqRoot, laneId, "spawn", (current) => {
|
|
3626
3671
|
if (isTerminalLaneState(current.state) || current.state === "running")
|
|
3627
3672
|
return current;
|
|
3628
3673
|
if (current.account === resolved.id && current.pickup_validation_pending === undefined) {
|
|
3629
3674
|
return current;
|
|
3630
3675
|
}
|
|
3676
|
+
const leavingHeld = recordedHeld && current.account === lane.account && current.account !== resolved.id;
|
|
3631
3677
|
return {
|
|
3632
3678
|
...current,
|
|
3633
3679
|
account: resolved.id,
|
|
3634
3680
|
pickup_validation_pending: undefined,
|
|
3635
3681
|
pickup_validation_pending_since: undefined,
|
|
3682
|
+
...(leavingHeld
|
|
3683
|
+
? {
|
|
3684
|
+
account_history: appendCappedHistory(current.account_history ?? [], {
|
|
3685
|
+
from: current.account ?? null,
|
|
3686
|
+
to: resolved.id,
|
|
3687
|
+
at: new Date().toISOString(),
|
|
3688
|
+
reason: "account_unavailable",
|
|
3689
|
+
}),
|
|
3690
|
+
}
|
|
3691
|
+
: {}),
|
|
3636
3692
|
};
|
|
3637
3693
|
});
|
|
3694
|
+
// PS-006: after leaving a held login, the source and any Claude balance
|
|
3695
|
+
// selection that pointed at it describe an account the lane no longer
|
|
3696
|
+
// uses. Those fields are command-written, so this is a second write.
|
|
3697
|
+
if (recordedHeld && bound.account === resolved.id && bound.account !== lane.account &&
|
|
3698
|
+
(bound.account_source !== "balanced" || bound.account_selection !== undefined)) {
|
|
3699
|
+
return retryUpdateLane(hqRoot, laneId, "command", (current) => {
|
|
3700
|
+
if (isTerminalLaneState(current.state) || current.account !== resolved.id)
|
|
3701
|
+
return current;
|
|
3702
|
+
return { ...current, account_source: "balanced", account_selection: undefined };
|
|
3703
|
+
});
|
|
3704
|
+
}
|
|
3705
|
+
return bound;
|
|
3638
3706
|
}
|
|
3639
3707
|
catch (err) {
|
|
3640
3708
|
if (err instanceof AccountResolutionError) {
|
|
@@ -3692,6 +3760,14 @@ export async function createLaneFromSignal(input, deps = {}) {
|
|
|
3692
3760
|
}
|
|
3693
3761
|
/** Project label for lanes created with --no-story and no --project. */
|
|
3694
3762
|
export const NO_STORY_DEFAULT_PROJECT = "standing";
|
|
3763
|
+
/** PS-006: a pinned login held by another person is refused before anything touches its home. */
|
|
3764
|
+
function refuseHeldPinnedAccount(provider, account, config) {
|
|
3765
|
+
const accountConfig = config.providers[provider].accounts[account];
|
|
3766
|
+
if (!accountHeldByOther(accountConfig))
|
|
3767
|
+
return;
|
|
3768
|
+
const holder = accountConfig?.holder ?? null;
|
|
3769
|
+
throw new LanesError("account_held_by_other", `Account ${account} is held by ${holder}, not the owner, and is not used for lanes`, { provider, account, holder });
|
|
3770
|
+
}
|
|
3695
3771
|
async function runCreate(ctx, opts) {
|
|
3696
3772
|
if (opts.signal !== undefined) {
|
|
3697
3773
|
if (!opts.company?.trim())
|
|
@@ -4234,6 +4310,7 @@ async function runCreate(ctx, opts) {
|
|
|
4234
4310
|
if (!requested) {
|
|
4235
4311
|
throw new AccountResolutionError("unknown_account", `Unknown account ${JSON.stringify(opts.account)} for ${provider}`, { provider, account: opts.account, enabled: [] });
|
|
4236
4312
|
}
|
|
4313
|
+
refuseHeldPinnedAccount(provider, requested, config);
|
|
4237
4314
|
const resolved = resolveAccount(provider, requested, config, {
|
|
4238
4315
|
hqRoot,
|
|
4239
4316
|
hostname: ctx.hostname(),
|
|
@@ -4243,6 +4320,7 @@ async function runCreate(ctx, opts) {
|
|
|
4243
4320
|
pinnedAccount = resolved.id;
|
|
4244
4321
|
}
|
|
4245
4322
|
else if (profileAccount !== undefined && profileAccounts === undefined) {
|
|
4323
|
+
refuseHeldPinnedAccount(provider, profileAccount, config);
|
|
4246
4324
|
const resolved = resolveAccount(provider, profileAccount, config, {
|
|
4247
4325
|
hqRoot,
|
|
4248
4326
|
hostname: ctx.hostname(),
|
|
@@ -4251,6 +4329,10 @@ async function runCreate(ctx, opts) {
|
|
|
4251
4329
|
});
|
|
4252
4330
|
pinnedAccount = resolved.id;
|
|
4253
4331
|
}
|
|
4332
|
+
// PS-006: refuse a pinned login held by another person before any model
|
|
4333
|
+
// check reads its home.
|
|
4334
|
+
if (pinnedAccount !== undefined)
|
|
4335
|
+
refuseHeldPinnedAccount(provider, pinnedAccount, config);
|
|
4254
4336
|
if (outpostId !== undefined &&
|
|
4255
4337
|
profile !== undefined &&
|
|
4256
4338
|
!(await placementEnabled())) {
|
|
@@ -4316,6 +4398,9 @@ async function runCreate(ctx, opts) {
|
|
|
4316
4398
|
...Object.keys(accounts)
|
|
4317
4399
|
.filter((id) => id !== candidate &&
|
|
4318
4400
|
accounts[id]?.enabled &&
|
|
4401
|
+
// PS-006: never probe, list models or read the catalog in
|
|
4402
|
+
// another person's login home.
|
|
4403
|
+
!accountHeldByOther(accounts[id]) &&
|
|
4319
4404
|
(profileAccounts === undefined || profileAccounts.includes(id)) &&
|
|
4320
4405
|
accountStatus(provider, id, config, {
|
|
4321
4406
|
existsSync: ctx.existsSync,
|
|
@@ -4397,6 +4482,8 @@ async function runCreate(ctx, opts) {
|
|
|
4397
4482
|
const accountCompany = resolveLaneCompany(hqRoot, { lane_id: "pending-create", company, mesh_company: meshCompany ?? undefined, project_id: project }).company;
|
|
4398
4483
|
const allowedAccounts = Object.keys(config.providers[provider].accounts).filter((id) => (candidateAccounts === undefined || candidateAccounts.includes(id)) &&
|
|
4399
4484
|
accountMatchesCompany(config.providers[provider].accounts[id], accountCompany, config.providers[provider].accounts));
|
|
4485
|
+
if (pinnedAccount !== undefined)
|
|
4486
|
+
refuseHeldPinnedAccount(provider, pinnedAccount, config);
|
|
4400
4487
|
if (pinnedAccount !== undefined && !accountMatchesCompany(config.providers[provider].accounts[pinnedAccount], accountCompany, config.providers[provider].accounts)) {
|
|
4401
4488
|
throw new LanesError("account_company_mismatch", `Account ${pinnedAccount} does not belong to the lane company`, { provider, account: pinnedAccount });
|
|
4402
4489
|
}
|
|
@@ -7302,11 +7389,16 @@ function applyLaneSettings(ctx, laneId, request, options) {
|
|
|
7302
7389
|
if (account === undefined) {
|
|
7303
7390
|
throw new AccountResolutionError("unknown_account", `Lane ${laneId} records account ${JSON.stringify(lane.account)} which is not configured for ${lane.provider}`, { provider: lane.provider, account: lane.account ?? "", enabled: [] });
|
|
7304
7391
|
}
|
|
7305
|
-
|
|
7306
|
-
|
|
7307
|
-
|
|
7308
|
-
|
|
7309
|
-
|
|
7392
|
+
// PS-006: never list models or read the catalog in another person's
|
|
7393
|
+
// login. The next spawn moves the lane off it (or refuses) and checks the
|
|
7394
|
+
// model against the account it really runs on.
|
|
7395
|
+
if (!accountHeldByOther(account)) {
|
|
7396
|
+
validateLaneModel(lane.provider, model, effectiveAccountHome(account, ctx.hostname()).home, {
|
|
7397
|
+
readFileSync: ctx.readFileSync,
|
|
7398
|
+
probe: ctx.probeProvider,
|
|
7399
|
+
env: ctx.env,
|
|
7400
|
+
});
|
|
7401
|
+
}
|
|
7310
7402
|
}
|
|
7311
7403
|
const effort = parseCliEffort(lane.provider, request.effort);
|
|
7312
7404
|
const at = ctx.now().toISOString();
|
|
@@ -7858,6 +7950,10 @@ function validateResumeProfileModel(ctx, lane, profile) {
|
|
|
7858
7950
|
}
|
|
7859
7951
|
const hqRoot = ctx.hqRoot();
|
|
7860
7952
|
const config = loadLanesConfig(hqRoot);
|
|
7953
|
+
// PS-006: never read models in another person's login. The resume moves the
|
|
7954
|
+
// lane off that login at spawn, where the new account's models are checked.
|
|
7955
|
+
if (lane.account !== undefined && accountHeldByOther(config.providers[lane.provider].accounts[lane.account]))
|
|
7956
|
+
return;
|
|
7861
7957
|
const account = resolveAccount(lane.provider, lane.account, config, {
|
|
7862
7958
|
hqRoot,
|
|
7863
7959
|
existsSync: ctx.existsSync,
|
|
@@ -7927,6 +8023,15 @@ export function applyResumeProfileAndEffort(hqRoot, current, next, input) {
|
|
|
7927
8023
|
next.provider = targetProvider;
|
|
7928
8024
|
next.provider_source = providerPinned ? current.provider_source : "profile";
|
|
7929
8025
|
if (!accountPinned && profileMatchesProvider) {
|
|
8026
|
+
const profileAccountConfig = profileAccount === undefined
|
|
8027
|
+
? undefined
|
|
8028
|
+
: loadLanesConfig(hqRoot).providers[targetProvider].accounts[profileAccount];
|
|
8029
|
+
if (profileAccount !== undefined && accountHeldByOther(profileAccountConfig)) {
|
|
8030
|
+
const holder = profileAccountConfig?.holder ?? null;
|
|
8031
|
+
throw new LanesError("account_held_by_other", `Worker profile account ${profileAccount} is held by ${holder}, not the owner, and is not used for lanes`, {
|
|
8032
|
+
lane_id: current.lane_id, account: profileAccount, holder,
|
|
8033
|
+
});
|
|
8034
|
+
}
|
|
7930
8035
|
if (profileAccount !== undefined && profileAccount !== current.account &&
|
|
7931
8036
|
!accountMatchesCompany(loadLanesConfig(hqRoot).providers[targetProvider].accounts[profileAccount], resolveLaneCompany(hqRoot, current).company, loadLanesConfig(hqRoot).providers[targetProvider].accounts)) {
|
|
7932
8037
|
throw new LanesError("account_company_mismatch", "Worker profile account does not belong to the lane company", {
|
|
@@ -8001,11 +8106,15 @@ function recordResumeSetup(ctx, lane, input) {
|
|
|
8001
8106
|
if (account === undefined) {
|
|
8002
8107
|
throw new AccountResolutionError("unknown_account", `Lane ${lane.lane_id} records account ${JSON.stringify(lane.account)} which is not configured for ${lane.provider}`, { provider: lane.provider, account: lane.account ?? "", enabled: [] });
|
|
8003
8108
|
}
|
|
8004
|
-
|
|
8005
|
-
|
|
8006
|
-
|
|
8007
|
-
|
|
8008
|
-
|
|
8109
|
+
// PS-006: as in applyLaneSettings, a held recorded login is not probed;
|
|
8110
|
+
// spawn moves the lane off it or refuses.
|
|
8111
|
+
if (!accountHeldByOther(account)) {
|
|
8112
|
+
validateLaneModel(lane.provider, model, effectiveAccountHome(account, ctx.hostname()).home, {
|
|
8113
|
+
readFileSync: ctx.readFileSync,
|
|
8114
|
+
probe: ctx.probeProvider,
|
|
8115
|
+
env: ctx.env,
|
|
8116
|
+
});
|
|
8117
|
+
}
|
|
8009
8118
|
}
|
|
8010
8119
|
if (input.profile === undefined &&
|
|
8011
8120
|
input.effort === undefined &&
|
|
@@ -8122,6 +8231,11 @@ async function prepareAccountMove(ctx, lane, input) {
|
|
|
8122
8231
|
if (targetCfg === undefined) {
|
|
8123
8232
|
throw new AccountResolutionError("unknown_account", `Unknown account ${JSON.stringify(target)} for ${lane.provider}. Configured: ${Object.keys(providerCfg.accounts).join(", ") || "(none)"}`, { provider: lane.provider, account: target, enabled: Object.keys(providerCfg.accounts).filter((id) => providerCfg.accounts[id]?.enabled) });
|
|
8124
8233
|
}
|
|
8234
|
+
if (accountHeldByOther(targetCfg)) {
|
|
8235
|
+
throw new LanesError("account_held_by_other", `Account ${target} is held by ${targetCfg.holder}, not the owner, and is not used for lanes`, {
|
|
8236
|
+
provider: lane.provider, account: target, holder: targetCfg.holder ?? null,
|
|
8237
|
+
});
|
|
8238
|
+
}
|
|
8125
8239
|
if (!accountMatchesCompany(targetCfg, resolveLaneCompany(hqRoot, lane).company, providerCfg.accounts)) {
|
|
8126
8240
|
throw new LanesError("account_company_mismatch", "Lane moves require an account assigned to the lane's company", {
|
|
8127
8241
|
provider: lane.provider, account: target, company: lane.company,
|
|
@@ -11599,6 +11713,17 @@ export function registerRunnersCommand(parent, deps = {}) {
|
|
|
11599
11713
|
.action(wrap(async (provider, accountId, home, opts) => {
|
|
11600
11714
|
await accountHandlers.runAccountsSetHome(ctx, provider, accountId, home, opts);
|
|
11601
11715
|
}));
|
|
11716
|
+
accounts
|
|
11717
|
+
.command("set-owner")
|
|
11718
|
+
.description("Record which business owns a login and who holds it (labels only; no credential moves)")
|
|
11719
|
+
.argument("<provider>", "claude | codex | grok")
|
|
11720
|
+
.argument("<account-id>", "Existing account id")
|
|
11721
|
+
.option("--owning-company <slug>", "Company slug, personal, or unknown")
|
|
11722
|
+
.option("--holder <name>", "owner, or the name of the person who holds the login")
|
|
11723
|
+
.option("--json", "JSON on stdout (always)")
|
|
11724
|
+
.action(wrap(async (provider, accountId, opts) => {
|
|
11725
|
+
await accountHandlers.runAccountsSetOwner(ctx, provider, accountId, opts);
|
|
11726
|
+
}));
|
|
11602
11727
|
accounts
|
|
11603
11728
|
.command("login")
|
|
11604
11729
|
.description("Create a home, run the vendor login, and register the account")
|
package/dist/commands/mesh.d.ts
CHANGED
|
@@ -64,6 +64,14 @@ export declare function runContextCorrect(opts: {
|
|
|
64
64
|
export declare function registerMeshCommand(program: Command, deps?: {
|
|
65
65
|
defaultCompanyPrompt?: DefaultCompanyPromptDeps;
|
|
66
66
|
}): void;
|
|
67
|
+
/**
|
|
68
|
+
* The resident Work Mesh loop. `hq daemon` runs it as its `mesh` service
|
|
69
|
+
* (`hq daemon service mesh`); `hq mesh daemon run`, which older standalone
|
|
70
|
+
* units still start, is retiring and runs the same loop.
|
|
71
|
+
*/
|
|
72
|
+
export declare function runMeshDaemonService(opts?: {
|
|
73
|
+
hqRoot?: string;
|
|
74
|
+
}): Promise<void>;
|
|
67
75
|
export declare function runDaemonStatus(opts: {
|
|
68
76
|
json?: boolean;
|
|
69
77
|
}, deps?: {
|
|
@@ -73,5 +81,9 @@ export declare function runDaemonStatus(opts: {
|
|
|
73
81
|
run?: RunCommand;
|
|
74
82
|
uid?: number;
|
|
75
83
|
}): Promise<void>;
|
|
84
|
+
/** Work Mesh health report: `hq daemon doctor` (and the retiring `hq mesh daemon doctor`). */
|
|
85
|
+
export declare function runMeshDaemonDoctor(opts: {
|
|
86
|
+
json?: boolean;
|
|
87
|
+
}): Promise<void>;
|
|
76
88
|
export {};
|
|
77
89
|
//# sourceMappingURL=mesh.d.ts.map
|
package/dist/commands/mesh.js
CHANGED
|
@@ -2604,7 +2604,7 @@ async function runMeshMode(action, opts) {
|
|
|
2604
2604
|
(mode !== act
|
|
2605
2605
|
? ` (note: HQ_MESH_MODE=${process.env.HQ_MESH_MODE} overrides → ${mode})`
|
|
2606
2606
|
: "") +
|
|
2607
|
-
`. Restart the daemon (hq
|
|
2607
|
+
`. Restart the daemon (hq daemon restart mesh) to apply.`);
|
|
2608
2608
|
return;
|
|
2609
2609
|
}
|
|
2610
2610
|
if (act === "check") {
|
|
@@ -3081,7 +3081,7 @@ export function registerMeshCommand(program, deps = {}) {
|
|
|
3081
3081
|
.command("run")
|
|
3082
3082
|
.description("Start the single-instance daemon (pid lock, spool watch, presence)")
|
|
3083
3083
|
.option("--hq-root <path>", "HQ tree root (else HQ_ROOT / persisted trusted roots); the Windows task passes this explicitly")
|
|
3084
|
-
.action((opts) => wrap(() =>
|
|
3084
|
+
.action((opts) => wrap(() => runMeshDaemonService(opts))());
|
|
3085
3085
|
daemon
|
|
3086
3086
|
.command("install")
|
|
3087
3087
|
.description("Install LaunchAgent (macOS), systemd user unit (Linux), or Scheduled Task (Windows)")
|
|
@@ -3104,7 +3104,7 @@ export function registerMeshCommand(program, deps = {}) {
|
|
|
3104
3104
|
.command("doctor")
|
|
3105
3105
|
.description("Report daemon running/MQTT/spool/held/dead-letter/outbox/flush health")
|
|
3106
3106
|
.option("--json", "Print machine-readable JSON")
|
|
3107
|
-
.action((opts) => wrap(() =>
|
|
3107
|
+
.action((opts) => wrap(() => runMeshDaemonDoctor(opts))());
|
|
3108
3108
|
mesh
|
|
3109
3109
|
.command("push-status")
|
|
3110
3110
|
.description("Report whether the owner DM push signal is live or stale, with the last event time")
|
|
@@ -3125,6 +3125,14 @@ async function runMeshPushStatus(opts) {
|
|
|
3125
3125
|
if (status.status === "stale")
|
|
3126
3126
|
process.exitCode = 1;
|
|
3127
3127
|
}
|
|
3128
|
+
/**
|
|
3129
|
+
* The resident Work Mesh loop. `hq daemon` runs it as its `mesh` service
|
|
3130
|
+
* (`hq daemon service mesh`); `hq mesh daemon run`, which older standalone
|
|
3131
|
+
* units still start, is retiring and runs the same loop.
|
|
3132
|
+
*/
|
|
3133
|
+
export async function runMeshDaemonService(opts = {}) {
|
|
3134
|
+
await runResidentCommandWithPackageLease("mesh-daemon", () => runDaemonRun(opts));
|
|
3135
|
+
}
|
|
3128
3136
|
async function runDaemonRun(opts = {}) {
|
|
3129
3137
|
const { runMeshDaemon } = await import("../lib/mesh/live/daemon/run.js");
|
|
3130
3138
|
const hqRoot = opts.hqRoot?.trim() || undefined;
|
|
@@ -3277,7 +3285,8 @@ export async function runDaemonStatus(opts, deps = {}) {
|
|
|
3277
3285
|
console.log(`mqtt: ${state.mqttState}`);
|
|
3278
3286
|
}
|
|
3279
3287
|
}
|
|
3280
|
-
|
|
3288
|
+
/** Work Mesh health report: `hq daemon doctor` (and the retiring `hq mesh daemon doctor`). */
|
|
3289
|
+
export async function runMeshDaemonDoctor(opts) {
|
|
3281
3290
|
// Same predicate as install: a repo's .claude/ is not an HQ root. Doctor
|
|
3282
3291
|
// only reads, so an unresolvable root is reported as absent, not fatal.
|
|
3283
3292
|
const report = collectDaemonDoctor({
|
package/dist/commands/monitor.js
CHANGED
|
@@ -465,7 +465,7 @@ export function invokeLaneMonitorMessage(hqRoot, meta, sequence, text, inProcess
|
|
|
465
465
|
const cliEntrypoint = process.argv[1];
|
|
466
466
|
if (!cliEntrypoint)
|
|
467
467
|
throw new LanesError("monitor_cli_path_missing", "Could not locate the hq CLI entry point for lane delivery.");
|
|
468
|
-
const result = spawnSync(process.execPath, [cliEntrypoint, "
|
|
468
|
+
const result = spawnSync(process.execPath, [cliEntrypoint, "runners", "_monitor-message", meta.target.laneId], {
|
|
469
469
|
cwd: meta.cwd,
|
|
470
470
|
env: { ...process.env, HQ_ROOT: hqRoot },
|
|
471
471
|
input: JSON.stringify({ text, monitor_id: meta.monitor_id, description: meta.description, sequence }),
|
package/dist/commands/packs.js
CHANGED
|
@@ -482,7 +482,7 @@ export function registerPacksCommand(parent) {
|
|
|
482
482
|
.option('--allow-hooks', 'Install pack hooks without prompting')
|
|
483
483
|
.option('--allow-mcp', 'Register pack MCP servers without prompting')
|
|
484
484
|
.option('--branch', 'Follow the source branch instead of SHA-pinning')
|
|
485
|
-
.addOption(new Option('--registry', 'Update installed registry packages instead
|
|
485
|
+
.addOption(new Option('--registry', 'Update installed registry packages instead of content packs ([name] is the package slug)').conflicts([...CONTENT_PACK_UPDATE_OPTIONS]))
|
|
486
486
|
.action(async (name, opts) => {
|
|
487
487
|
if (opts.registry) {
|
|
488
488
|
// Exactly the `hq packages update [slug]` path: same function, lease,
|
|
@@ -23,9 +23,27 @@ export interface HeldScope {
|
|
|
23
23
|
at: string;
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
|
+
export interface CorruptIdentityRecovery {
|
|
27
|
+
recovered: boolean;
|
|
28
|
+
reason?: "none" | "unproven" | "different-person" | "several-people";
|
|
29
|
+
clearedMarker: boolean;
|
|
30
|
+
clearedScopeFiles: number;
|
|
31
|
+
/** Corrupt scope records restored with an upload hold. Absent on older hq-cloud. */
|
|
32
|
+
heldScopeFiles?: number;
|
|
33
|
+
/** True when recovery replaced the file with a hold and cleared nothing. */
|
|
34
|
+
uploadsStayHeld?: boolean;
|
|
35
|
+
}
|
|
26
36
|
interface FenceExports {
|
|
27
37
|
listPushIdentityFences: (stateDir: string) => HeldScope[];
|
|
28
38
|
releasePushIdentityFences: (stateDir: string, identities: readonly string[], slugs?: readonly string[]) => string[];
|
|
39
|
+
corruptPushIdentityHold?: (stateDir: string, journalSlug?: string) => boolean;
|
|
40
|
+
recoverCorruptPushIdentity?: (stateDir: string, identities: readonly string[], options?: {
|
|
41
|
+
personalOwnerUid?: string | null;
|
|
42
|
+
slugs?: readonly string[];
|
|
43
|
+
limitToSlugs?: boolean;
|
|
44
|
+
confirmUnproven?: boolean;
|
|
45
|
+
}) => CorruptIdentityRecovery;
|
|
46
|
+
readPersonalVaultOwnerUid?: () => string | null;
|
|
29
47
|
}
|
|
30
48
|
export declare const HELD_UNAVAILABLE_MESSAGE = "this HQ build cannot list or release held uploads yet; update HQ and try again";
|
|
31
49
|
export declare function fenceExports(mod?: Record<string, unknown>): FenceExports | undefined;
|
|
@@ -61,7 +79,11 @@ export interface ReleaseHeldOptions {
|
|
|
61
79
|
personal?: boolean;
|
|
62
80
|
yes?: boolean;
|
|
63
81
|
json?: boolean;
|
|
82
|
+
/** Restore an unreadable identity file and keep every upload held until the person confirms the files. */
|
|
83
|
+
confirmUnproven?: boolean;
|
|
64
84
|
}
|
|
85
|
+
/** Next step on this computer when saved history names nobody or more than one person. */
|
|
86
|
+
export declare const CONFIRM_UNPROVEN_COMMAND = "hq sync release-held --confirm-unproven";
|
|
65
87
|
export declare function runReleaseHeld(deps: SyncHeldDeps, options: ReleaseHeldOptions): Promise<number>;
|
|
66
88
|
/**
|
|
67
89
|
* The signed-in identity from the session token `ensureCognitoToken` selects
|