@indigoai-us/hq-cli 5.345.238 → 5.345.242
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 +74 -0
- package/assets/scaffold/core/scripts/hq-delegate-grant.sh +170 -8
- package/assets/scaffold/core/scripts/hq-delegate-publish.sh +21 -1
- package/assets/scaffold/core/scripts/hq-delegate-repo.sh +7 -1
- package/assets/scaffold/core/scripts/hq-delegate-secrets.sh +95 -20
- package/assets/scaffold/core/scripts/hq-delegate-transfer.sh +57 -9
- package/assets/scaffold/core/scripts/lib/delegate-engine.sh +77 -0
- package/dist/command-catalog.generated.d.ts +212 -10
- package/dist/command-catalog.generated.js +260 -10
- package/dist/command-registration-plan.d.ts +6 -0
- package/dist/command-registration-plan.js +1 -0
- package/dist/commands/cloud-off-gate.d.ts +9 -8
- package/dist/commands/cloud-off-gate.js +41 -40
- package/dist/commands/cloud.d.ts +17 -2
- package/dist/commands/cloud.js +126 -24
- package/dist/commands/core-delegate-w1b.js +333 -27
- package/dist/commands/core-delegate.d.ts +2 -1
- package/dist/commands/core-delegate.js +209 -48
- package/dist/commands/core-handoff.js +1 -1
- package/dist/commands/core-job-model-auth.d.ts +95 -0
- package/dist/commands/core-job-model-auth.js +247 -0
- package/dist/commands/core-job-run-native.js +280 -12
- package/dist/commands/core.js +1 -0
- package/dist/commands/deploy-comments.js +8 -2
- package/dist/commands/deploy-events.d.ts +40 -0
- package/dist/commands/deploy-events.js +300 -0
- package/dist/commands/doctor.d.ts +4 -4
- package/dist/commands/doctor.js +2 -2
- package/dist/commands/feedback.js +2 -3
- package/dist/commands/files-browse.js +2 -0
- package/dist/commands/files.js +4 -0
- package/dist/commands/integrations-core.d.ts +11 -0
- package/dist/commands/integrations-core.js +15 -1
- package/dist/commands/keyed-sync-pull.d.ts +12 -0
- package/dist/commands/keyed-sync-pull.js +151 -0
- package/dist/commands/lanes-link.js +2 -2
- package/dist/commands/lanes-loop.d.ts +2 -2
- package/dist/commands/lanes-loop.js +5 -5
- package/dist/commands/lanes-questions.js +1 -1
- package/dist/commands/lanes-stories.js +1 -1
- package/dist/commands/lanes.js +80 -14
- package/dist/commands/library-add.d.ts +5 -2
- package/dist/commands/library-add.js +22 -9
- package/dist/commands/mcp-registration.d.ts +4 -18
- package/dist/commands/mcp-registration.js +9 -29
- package/dist/commands/mesh.d.ts +4 -0
- package/dist/commands/mesh.js +25 -5
- package/dist/commands/pack-install.d.ts +2 -3
- package/dist/commands/pack-install.js +6 -8
- package/dist/commands/rescue.d.ts +3 -2
- package/dist/commands/rescue.js +48 -34
- package/dist/commands/search.d.ts +6 -0
- package/dist/commands/search.js +24 -4
- package/dist/commands/secrets.d.ts +3 -4
- package/dist/commands/secrets.js +3 -20
- package/dist/commands/sources.js +6 -2
- package/dist/commands/sync-core.d.ts +8 -0
- package/dist/commands/sync-core.js +43 -0
- package/dist/hq-cloud-sync-runner/bin/sync-runner.js +1830 -1468
- package/dist/hq-cloud-sync-runner/package.json +1 -1
- package/dist/lib/bot/api.d.ts +2 -1
- package/dist/lib/bot/api.js +2 -15
- package/dist/lib/capacity/accounts.d.ts +1 -1
- package/dist/lib/capacity/accounts.js +1 -1
- package/dist/lib/capacity/collectors/claude-oauth.d.ts +0 -2
- package/dist/lib/capacity/collectors/claude-oauth.js +0 -5
- package/dist/lib/capacity/freshness.d.ts +1 -1
- package/dist/lib/capacity/freshness.js +1 -1
- package/dist/lib/capacity/route.js +1 -1
- package/dist/lib/core-utils/delegate-helper-paths.d.ts +26 -0
- package/dist/lib/core-utils/delegate-helper-paths.js +33 -0
- package/dist/lib/daemon/catalog.d.ts +3 -0
- package/dist/lib/daemon/hook-requests.d.ts +1 -1
- package/dist/lib/daemon/hook-requests.js +4 -2
- package/dist/lib/daemon/jq-provision.d.ts +63 -0
- package/dist/lib/daemon/jq-provision.js +155 -0
- package/dist/lib/daemon/lanes-reconcile-guard.d.ts +4 -3
- package/dist/lib/daemon/lanes-reconcile-guard.js +4 -4
- package/dist/lib/daemon/mesh-owner.d.ts +4 -0
- package/dist/lib/daemon/mesh-owner.js +20 -0
- package/dist/lib/daemon/ops/policy.d.ts +3 -0
- package/dist/lib/daemon/ops/policy.js +32 -4
- package/dist/lib/daemon/run.js +17 -22
- package/dist/lib/daemon/server.d.ts +6 -0
- package/dist/lib/daemon/server.js +5 -0
- package/dist/lib/daemon/verified-jq.d.ts +96 -0
- package/dist/lib/daemon/verified-jq.js +337 -0
- package/dist/lib/doctor/checks/jq.js +16 -0
- package/dist/lib/doctor/deep/executor.d.ts +7 -0
- package/dist/lib/doctor/deep/executor.js +1 -1
- package/dist/lib/doctor/deep/parity.js +1 -27
- package/dist/lib/doctor/deep/sandbox.d.ts +2 -2
- package/dist/lib/doctor/deep/sandbox.js +3 -19
- package/dist/lib/doctor/fix/refresh-sync-handoff.js +52 -21
- package/dist/lib/doctor/fixtures/discover.d.ts +2 -0
- package/dist/lib/doctor/fixtures/discover.js +1 -1
- package/dist/lib/doctor/json-output.d.ts +1 -1
- package/dist/lib/doctor/registry.d.ts +6 -7
- package/dist/lib/doctor/registry.js +6 -7
- package/dist/lib/doctor/report.d.ts +9 -10
- package/dist/lib/doctor/report.js +4 -4
- package/dist/lib/environment/work-requirements.d.ts +1 -1
- package/dist/lib/environment/work-requirements.js +1 -1
- 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.js +11 -3
- package/dist/lib/hook-engine/git-stop-config.json +510 -510
- package/dist/lib/hook-engine/native-precompact-compatibility.json +443 -443
- package/dist/lib/hook-engine/native-stop-compatibility.json +359 -359
- package/dist/lib/hot-channels/adapters/meetings.d.ts +1 -16
- package/dist/lib/hot-channels/adapters/meetings.js +3 -28
- package/dist/lib/hot-channels/adapters/slack.d.ts +3 -1
- package/dist/lib/hot-channels/adapters/slack.js +4 -1
- package/dist/lib/hot-channels/contract.d.ts +14 -0
- package/dist/lib/hot-channels/fleet-complete.d.ts +18 -2
- package/dist/lib/hot-channels/fleet-complete.js +29 -4
- package/dist/lib/hot-channels/meeting-source-ref.d.ts +17 -0
- package/dist/lib/hot-channels/meeting-source-ref.js +32 -0
- package/dist/lib/hot-channels/prompts/signals-pass.md +6 -1
- package/dist/lib/hot-channels/run.d.ts +10 -0
- package/dist/lib/hot-channels/run.js +34 -0
- package/dist/lib/hot-channels/signals-pass.d.ts +27 -0
- package/dist/lib/hot-channels/signals-pass.js +57 -2
- package/dist/lib/hot-channels/signals-runtime.js +3 -2
- package/dist/lib/jq/install.d.ts +27 -0
- package/dist/lib/jq/install.js +156 -0
- package/dist/lib/lanes/accounts.js +2 -2
- package/dist/lib/lanes/claude-balance.d.ts +6 -0
- package/dist/lib/lanes/claude-balance.js +124 -0
- package/dist/lib/lanes/grants.js +15 -2
- package/dist/lib/lanes/hq-root.d.ts +1 -1
- package/dist/lib/lanes/hq-root.js +1 -1
- package/dist/lib/lanes/links.d.ts +1 -1
- package/dist/lib/lanes/liveness.d.ts +3 -0
- package/dist/lib/lanes/liveness.js +61 -7
- package/dist/lib/lanes/models.d.ts +1 -1
- package/dist/lib/lanes/models.js +1 -1
- package/dist/lib/lanes/outpost-dispatch.d.ts +1 -1
- package/dist/lib/lanes/outpost-dispatch.js +13 -13
- package/dist/lib/lanes/outpost-pruner-install.js +1 -1
- package/dist/lib/lanes/questions.d.ts +1 -1
- package/dist/lib/lanes/questions.js +2 -2
- package/dist/lib/lanes/spawn.js +4 -6
- package/dist/lib/lanes/store.d.ts +13 -2
- package/dist/lib/lanes/store.js +13 -5
- package/dist/lib/lanes/types.d.ts +7 -7
- package/dist/lib/lanes/types.js +1 -1
- package/dist/lib/lanes/watcher-main.js +1 -1
- package/dist/lib/lanes/watcher.d.ts +1 -1
- package/dist/lib/lanes/watcher.js +1 -1
- package/dist/lib/mesh/live/daemon/doctor.js +7 -1
- package/dist/lib/mesh/live/daemon/install.d.ts +4 -0
- package/dist/lib/mesh/live/daemon/install.js +10 -0
- package/dist/lib/mesh/live/daemon/run.js +17 -0
- package/dist/lib/mesh/live/emit-retry.d.ts +20 -2
- package/dist/lib/mesh/live/emit-retry.js +57 -4
- package/dist/lib/mesh/live/emit.js +25 -4
- package/dist/lib/mesh/live/flush.d.ts +2 -0
- package/dist/lib/mesh/live/flush.js +21 -8
- package/dist/lib/mesh/live/spool.d.ts +9 -1
- package/dist/lib/mesh/live/spool.js +41 -29
- package/dist/lib/onboarding/cli/onboard.js +5 -0
- package/dist/lib/signals/sanitize.d.ts +19 -0
- package/dist/lib/signals/sanitize.js +103 -7
- package/dist/lib/signals/steps/upload.d.ts +40 -1
- package/dist/lib/signals/steps/upload.js +122 -6
- package/dist/lib/sync-core/access-refresh.d.ts +29 -0
- package/dist/lib/sync-core/access-refresh.js +97 -0
- package/dist/lib/sync-core/company-adoption.d.ts +33 -0
- package/dist/lib/sync-core/company-adoption.js +223 -0
- package/dist/lib/sync-core/engine-home.d.ts +1 -0
- package/dist/lib/sync-core/engine-owned.d.ts +13 -0
- package/dist/lib/sync-core/engine-owned.js +38 -0
- package/dist/lib/sync-core/hand-back.d.ts +17 -0
- package/dist/lib/sync-core/hand-back.js +23 -0
- package/dist/lib/sync-core/post-apply-reindex.d.ts +33 -0
- package/dist/lib/sync-core/post-apply-reindex.js +149 -0
- package/dist/lib/sync-core/reconcile.d.ts +10 -0
- package/dist/lib/sync-core/reconcile.js +117 -12
- package/dist/lib/sync-core/rollout-state.d.ts +11 -1
- package/dist/lib/sync-core/rollout-state.js +40 -4
- package/dist/lib/vault-sync-switches.d.ts +14 -0
- package/dist/lib/vault-sync-switches.js +22 -0
- package/dist/lib/windows/jq.d.ts +4 -0
- package/dist/lib/windows/jq.js +10 -39
- package/dist/lib/workers-registry/index.d.ts +1 -1
- package/dist/lib/workers-registry/index.js +8 -12
- package/dist/utils/callback-port-busy.d.ts +2 -2
- package/dist/utils/callback-port-busy.js +2 -2
- package/dist/utils/cli-network-lifecycle.js +1 -0
- package/dist/utils/client-health-contract.d.ts +2 -0
- package/dist/utils/client-health-contract.js +1 -1
- package/dist/utils/client-health.js +1 -9
- package/dist/utils/cognito-config.js +5 -0
- package/dist/utils/cognito-session.d.ts +4 -6
- package/dist/utils/cognito-session.js +4 -24
- package/dist/utils/github-tag-fallback.d.ts +16 -0
- package/dist/utils/github-tag-fallback.js +126 -0
- package/dist/utils/incomplete-install-error.js +1 -11
- package/dist/utils/install-tree-torn.d.ts +11 -0
- package/dist/utils/install-tree-torn.js +1 -1
- package/dist/utils/resident-package-preload.js +2 -1
- package/dist/utils/version-report.d.ts +2 -1
- package/dist/utils/version-report.js +40 -27
- package/docs/anywhere-runtime.md +8 -0
- package/package.json +9 -9
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/** Shared, pinned jq installer for daemon provisioning and Windows hook setup. */
|
|
2
|
+
import { createHash } from "node:crypto";
|
|
3
|
+
import * as fs from "node:fs";
|
|
4
|
+
import * as path from "node:path";
|
|
5
|
+
const MAX_DOWNLOAD_BYTES = 16 * 1024 * 1024;
|
|
6
|
+
function missing(error) {
|
|
7
|
+
return error.code === "ENOENT";
|
|
8
|
+
}
|
|
9
|
+
/** Carries the refused component so callers can exclude its entire subtree. */
|
|
10
|
+
export class UnsafeJqPathError extends Error {
|
|
11
|
+
path;
|
|
12
|
+
constructor(path, message) {
|
|
13
|
+
super(message);
|
|
14
|
+
this.path = path;
|
|
15
|
+
this.name = "UnsafeJqPathError";
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function checkOwned(file, directory, allowRootOwner = false) {
|
|
19
|
+
let stat;
|
|
20
|
+
try {
|
|
21
|
+
stat = fs.lstatSync(file);
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
if (missing(error))
|
|
25
|
+
return false;
|
|
26
|
+
throw new UnsafeJqPathError(file, `Could not inspect jq path ${file}: ${error.message}`);
|
|
27
|
+
}
|
|
28
|
+
if (stat.isSymbolicLink() || (directory ? !stat.isDirectory() : !stat.isFile())) {
|
|
29
|
+
throw new UnsafeJqPathError(file, `Refusing unsafe jq path: ${file}`);
|
|
30
|
+
}
|
|
31
|
+
// Windows permission bits do not describe ACLs; the user's profile is the
|
|
32
|
+
// trust boundary there. POSIX additionally requires ownership and no writers.
|
|
33
|
+
if (process.platform !== "win32" &&
|
|
34
|
+
((stat.uid !== process.getuid?.() && !(allowRootOwner && stat.uid === 0)) || (stat.mode & 0o022) !== 0)) {
|
|
35
|
+
throw new UnsafeJqPathError(file, `Refusing jq path not exclusively writable by its owner: ${file}`);
|
|
36
|
+
}
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
/** Reject links at every component below the owned home, including the file. */
|
|
40
|
+
function checkPath(home, target, create = false, directory = false, allowRootOwner = false) {
|
|
41
|
+
if (!path.isAbsolute(home) || !path.isAbsolute(target))
|
|
42
|
+
throw new Error("jq needs an absolute home and target");
|
|
43
|
+
const relative = path.relative(home, target);
|
|
44
|
+
if ((!relative && !directory) || relative === ".." || relative.startsWith(`..${path.sep}`) || path.isAbsolute(relative)) {
|
|
45
|
+
throw new Error("jq target must be inside its home");
|
|
46
|
+
}
|
|
47
|
+
if (!checkOwned(home, true, allowRootOwner))
|
|
48
|
+
throw new UnsafeJqPathError(home, `jq home does not exist: ${home}`);
|
|
49
|
+
let dir = home;
|
|
50
|
+
const parts = relative ? relative.split(path.sep) : [];
|
|
51
|
+
for (const part of directory ? parts : parts.slice(0, -1)) {
|
|
52
|
+
dir = path.join(dir, part);
|
|
53
|
+
if (!checkOwned(dir, true, allowRootOwner) && create) {
|
|
54
|
+
try {
|
|
55
|
+
fs.mkdirSync(dir, { mode: 0o700 });
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
if (error.code !== "EEXIST")
|
|
59
|
+
throw error;
|
|
60
|
+
}
|
|
61
|
+
checkOwned(dir, true, allowRootOwner);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
if (!directory)
|
|
65
|
+
checkOwned(target, false, allowRootOwner);
|
|
66
|
+
}
|
|
67
|
+
/** Validate/create a private directory without following links or shared parents. */
|
|
68
|
+
export function checkJqDirectory(home, directory, create = false) {
|
|
69
|
+
checkPath(home, directory, create, true);
|
|
70
|
+
}
|
|
71
|
+
/** Read-only check for an existing system PATH directory, which may be root-owned. */
|
|
72
|
+
export function checkSystemJqDirectory(directory) {
|
|
73
|
+
checkPath(directory, directory, false, true, true);
|
|
74
|
+
}
|
|
75
|
+
function digest(bytes) {
|
|
76
|
+
return createHash("sha256").update(bytes).digest("hex");
|
|
77
|
+
}
|
|
78
|
+
/** Never run an existing managed binary until its pinned digest is checked. */
|
|
79
|
+
export function matchesPinnedJq(home, target, asset) {
|
|
80
|
+
checkPath(home, target);
|
|
81
|
+
let fd;
|
|
82
|
+
try {
|
|
83
|
+
fd = fs.openSync(target, fs.constants.O_RDONLY | (fs.constants.O_NOFOLLOW ?? 0));
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
if (missing(error))
|
|
87
|
+
return false;
|
|
88
|
+
throw error;
|
|
89
|
+
}
|
|
90
|
+
try {
|
|
91
|
+
const stat = fs.fstatSync(fd);
|
|
92
|
+
if (!stat.isFile() || stat.size > MAX_DOWNLOAD_BYTES)
|
|
93
|
+
return false;
|
|
94
|
+
return digest(fs.readFileSync(fd)) === asset.sha256;
|
|
95
|
+
}
|
|
96
|
+
finally {
|
|
97
|
+
fs.closeSync(fd);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
export async function installPinnedJq(options) {
|
|
101
|
+
const { home, target, asset } = options;
|
|
102
|
+
if (matchesPinnedJq(home, target, asset) &&
|
|
103
|
+
(process.platform === "win32" || (fs.statSync(target).mode & 0o111) !== 0))
|
|
104
|
+
return target;
|
|
105
|
+
const response = await (options.fetch ?? fetch)(asset.url, {
|
|
106
|
+
signal: AbortSignal.timeout(20_000), redirect: "follow",
|
|
107
|
+
});
|
|
108
|
+
if (!response.ok)
|
|
109
|
+
throw new Error(`jq download failed: HTTP ${response.status}`);
|
|
110
|
+
if (Number(response.headers.get("content-length") ?? 0) > MAX_DOWNLOAD_BYTES) {
|
|
111
|
+
await response.body?.cancel();
|
|
112
|
+
throw new Error("jq download is larger than any jq release");
|
|
113
|
+
}
|
|
114
|
+
const chunks = [];
|
|
115
|
+
let total = 0;
|
|
116
|
+
if (response.body) {
|
|
117
|
+
const reader = response.body.getReader();
|
|
118
|
+
try {
|
|
119
|
+
for (;;) {
|
|
120
|
+
const { done, value } = await reader.read();
|
|
121
|
+
if (done)
|
|
122
|
+
break;
|
|
123
|
+
total += value.byteLength;
|
|
124
|
+
if (total > MAX_DOWNLOAD_BYTES) {
|
|
125
|
+
await reader.cancel();
|
|
126
|
+
throw new Error("jq download is larger than any jq release");
|
|
127
|
+
}
|
|
128
|
+
chunks.push(Buffer.from(value));
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
finally {
|
|
132
|
+
reader.releaseLock();
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
const bytes = Buffer.concat(chunks);
|
|
136
|
+
if (digest(bytes) !== asset.sha256) {
|
|
137
|
+
throw new Error("jq download did not match the pinned release checksum");
|
|
138
|
+
}
|
|
139
|
+
checkPath(home, target, true);
|
|
140
|
+
const staged = fs.mkdtempSync(path.join(path.dirname(target), ".hq-jq-"));
|
|
141
|
+
try {
|
|
142
|
+
// Private staging and exclusive creation prevent pre-planted links.
|
|
143
|
+
// Verification precedes executable permission and the optional probe.
|
|
144
|
+
const file = path.join(staged, path.basename(target));
|
|
145
|
+
fs.writeFileSync(file, bytes, { flag: "wx", mode: 0o600 });
|
|
146
|
+
fs.chmodSync(file, 0o755);
|
|
147
|
+
await options.verify?.(file);
|
|
148
|
+
checkPath(home, target);
|
|
149
|
+
fs.renameSync(file, target);
|
|
150
|
+
}
|
|
151
|
+
finally {
|
|
152
|
+
fs.rmSync(staged, { recursive: true, force: true });
|
|
153
|
+
}
|
|
154
|
+
return target;
|
|
155
|
+
}
|
|
156
|
+
//# sourceMappingURL=install.js.map
|
|
@@ -17,7 +17,7 @@ import * as path from "node:path";
|
|
|
17
17
|
import { AccountResolutionError } from "./errors.js";
|
|
18
18
|
import { isTerminalLaneState } from "./types.js";
|
|
19
19
|
import { accountMaxRunning } from "./config.js";
|
|
20
|
-
import {
|
|
20
|
+
import { readAllLanes } from "./store.js";
|
|
21
21
|
import { loadQuotaState, quotaBlockFor } from "./quota.js";
|
|
22
22
|
// Provider home helpers live in a leaf module so bot code can use them
|
|
23
23
|
// without importing the lane store; re-exported for existing callers.
|
|
@@ -204,7 +204,7 @@ export function lastStartedAt(lanes, provider, accountId) {
|
|
|
204
204
|
return latest;
|
|
205
205
|
}
|
|
206
206
|
function defaultLoadLanes(hqRoot) {
|
|
207
|
-
return
|
|
207
|
+
return readAllLanes(hqRoot);
|
|
208
208
|
}
|
|
209
209
|
function compareEligible(a, b) {
|
|
210
210
|
if (a.occupying !== b.occupying)
|
|
@@ -90,6 +90,12 @@ export declare function selectClaudeAccount(input: {
|
|
|
90
90
|
actualTargetHost?: LaneHost;
|
|
91
91
|
unavailableHosts?: readonly BalanceHostGap[];
|
|
92
92
|
}): ClaudeAccountSelection;
|
|
93
|
+
export declare function selectCompanyOutpostClaudeAccount(input: {
|
|
94
|
+
target: BalanceHostSnapshot;
|
|
95
|
+
company?: LaneCompanyRef;
|
|
96
|
+
explicitAccount?: string;
|
|
97
|
+
requestedPlacement?: LanePlacementPolicy | null;
|
|
98
|
+
}): ClaudeAccountSelection;
|
|
93
99
|
export declare function accountLoadsForReport(input: {
|
|
94
100
|
hosts: readonly BalanceHostSnapshot[];
|
|
95
101
|
config: LanesConfig;
|
|
@@ -263,6 +263,130 @@ export function selectClaudeAccount(input) {
|
|
|
263
263
|
unavailable_hosts: [...(input.unavailableHosts ?? [])],
|
|
264
264
|
};
|
|
265
265
|
}
|
|
266
|
+
function companyOutpostIneligibility(status) {
|
|
267
|
+
if (!status.enabled)
|
|
268
|
+
return "disabled";
|
|
269
|
+
if (status.auth_state === "home_missing")
|
|
270
|
+
return "home_missing";
|
|
271
|
+
if (status.logged_in === false)
|
|
272
|
+
return "not_logged_in";
|
|
273
|
+
if (status.logged_in === null)
|
|
274
|
+
return "login_status_unknown";
|
|
275
|
+
if (status.quota_held === true)
|
|
276
|
+
return "quota_held";
|
|
277
|
+
return undefined;
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Picks the Claude login for a lane on a company Outpost. The box runs the
|
|
281
|
+
* lane with its own company sign-in, so the candidates are the accounts the
|
|
282
|
+
* box reports, not this machine's lanes config, and loads on personal hosts
|
|
283
|
+
* do not count.
|
|
284
|
+
*/
|
|
285
|
+
function companyOutpostSignInSteps(slug, outpostId) {
|
|
286
|
+
const company = slug ?? "<slug>";
|
|
287
|
+
const owner = slug ? `An owner or admin of ${slug}` : "An owner or admin of the company";
|
|
288
|
+
return `${owner} runs: hq outposts login --company ${company} --outpost ${outpostId}, opens the link, then runs: hq outposts login-code --company ${company} --outpost ${outpostId} <code>`;
|
|
289
|
+
}
|
|
290
|
+
export function selectCompanyOutpostClaudeAccount(input) {
|
|
291
|
+
const targetHost = input.target.capacity.host;
|
|
292
|
+
const placementDetails = {
|
|
293
|
+
requested_placement: input.requestedPlacement ?? null,
|
|
294
|
+
target_host: targetHost,
|
|
295
|
+
};
|
|
296
|
+
const reported = input.target.capacity.providers.claude.accounts;
|
|
297
|
+
const skipped = [];
|
|
298
|
+
const loads = Object.keys(reported).sort().map((account) => {
|
|
299
|
+
const status = reported[account];
|
|
300
|
+
const load = accountHostLoad(input.target, account);
|
|
301
|
+
const ineligible = companyOutpostIneligibility(status);
|
|
302
|
+
if (ineligible !== undefined)
|
|
303
|
+
skipped.push({ account, host: targetHost, reason: ineligible });
|
|
304
|
+
return {
|
|
305
|
+
account,
|
|
306
|
+
target_enabled: status.enabled,
|
|
307
|
+
target_logged_in: status.logged_in,
|
|
308
|
+
eligible: ineligible === undefined,
|
|
309
|
+
...(ineligible !== undefined ? { ineligible_reason: ineligible } : {}),
|
|
310
|
+
...(status.quota_held === true && status.quota_reset_at !== undefined ? { quota_reset_at: status.quota_reset_at } : {}),
|
|
311
|
+
live_lanes: load.live_lanes ?? 0,
|
|
312
|
+
counts_complete: load.live_lanes !== null && load.count_source !== "capacity_partial",
|
|
313
|
+
usage: status.usage ?? null,
|
|
314
|
+
recent_usage_at: null,
|
|
315
|
+
hosts: [load],
|
|
316
|
+
};
|
|
317
|
+
});
|
|
318
|
+
const outpostLabel = `company Outpost ${targetHost.id}`;
|
|
319
|
+
const signIn = companyOutpostSignInSteps(input.company?.slug, targetHost.id);
|
|
320
|
+
if (input.explicitAccount !== undefined) {
|
|
321
|
+
const selected = loads.find((load) => load.account === input.explicitAccount);
|
|
322
|
+
if (!selected || !selected.eligible) {
|
|
323
|
+
const reason = selected?.ineligible_reason ?? "unknown_account";
|
|
324
|
+
const name = `Claude account ${JSON.stringify(input.explicitAccount)}`;
|
|
325
|
+
const known = `Accounts on that Outpost: ${loads.map((load) => load.account).join(", ") || "(none)"}`;
|
|
326
|
+
const message = reason === "quota_held"
|
|
327
|
+
? `${name} on ${outpostLabel} is out of quota${selected?.quota_reset_at ? ` until ${selected.quota_reset_at}` : ""}. ${known}`
|
|
328
|
+
: reason === "unknown_account"
|
|
329
|
+
? `${outpostLabel} has no ${name}. ${known}`
|
|
330
|
+
: reason === "disabled"
|
|
331
|
+
? `${name} is disabled on ${outpostLabel}. ${known}`
|
|
332
|
+
: `${name} is not signed in on ${outpostLabel}. ${signIn}`;
|
|
333
|
+
throw new LanesError("claude_account_balance_account_unavailable", message, {
|
|
334
|
+
account: input.explicitAccount,
|
|
335
|
+
reason,
|
|
336
|
+
...(selected?.quota_reset_at !== undefined ? { quota_reset_at: selected.quota_reset_at } : {}),
|
|
337
|
+
...placementDetails,
|
|
338
|
+
account_reasons: skipped,
|
|
339
|
+
unavailable_hosts: [],
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
return {
|
|
343
|
+
account: input.explicitAccount,
|
|
344
|
+
signal: "explicit",
|
|
345
|
+
reason: "explicit",
|
|
346
|
+
target_host: targetHost,
|
|
347
|
+
considered: loads,
|
|
348
|
+
skipped_accounts: skipped,
|
|
349
|
+
unavailable_hosts: [],
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
const eligible = loads.filter((load) => load.eligible);
|
|
353
|
+
if (eligible.length === 0) {
|
|
354
|
+
const quotaHeld = loads.length > 0 && loads.every((load) => load.ineligible_reason === "quota_held");
|
|
355
|
+
const resets = loads.flatMap((load) => load.quota_reset_at !== undefined ? [load.quota_reset_at] : []).sort();
|
|
356
|
+
const message = quotaHeld
|
|
357
|
+
? `Every Claude account on ${outpostLabel} is out of quota${resets.length > 0 ? `; the first resets at ${resets[0]}` : ""}.`
|
|
358
|
+
: `No signed-in Claude account is available on ${outpostLabel}. ${signIn}`;
|
|
359
|
+
throw new LanesError("claude_account_balance_no_eligible_account", message, {
|
|
360
|
+
provider: "claude",
|
|
361
|
+
...placementDetails,
|
|
362
|
+
...(quotaHeld && resets.length > 0 ? { quota_reset_at: resets[0] } : {}),
|
|
363
|
+
account_reasons: loads.map((load) => ({
|
|
364
|
+
account: load.account,
|
|
365
|
+
reason: load.ineligible_reason ?? "unavailable",
|
|
366
|
+
...(load.quota_reset_at !== undefined ? { quota_reset_at: load.quota_reset_at } : {}),
|
|
367
|
+
})),
|
|
368
|
+
unavailable_hosts: [],
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
const signal = eligible.every((load) => usageScore(load.usage) !== null) ? "usage" : "lane_count";
|
|
372
|
+
eligible.sort((a, b) => {
|
|
373
|
+
if (signal === "usage") {
|
|
374
|
+
const byUsage = usageScore(a.usage) - usageScore(b.usage);
|
|
375
|
+
if (byUsage !== 0)
|
|
376
|
+
return byUsage;
|
|
377
|
+
}
|
|
378
|
+
return a.live_lanes - b.live_lanes || a.account.localeCompare(b.account);
|
|
379
|
+
});
|
|
380
|
+
return {
|
|
381
|
+
account: eligible[0].account,
|
|
382
|
+
signal,
|
|
383
|
+
reason: "least_loaded",
|
|
384
|
+
target_host: targetHost,
|
|
385
|
+
considered: loads,
|
|
386
|
+
skipped_accounts: skipped,
|
|
387
|
+
unavailable_hosts: [],
|
|
388
|
+
};
|
|
389
|
+
}
|
|
266
390
|
export function accountLoadsForReport(input) {
|
|
267
391
|
const first = input.hosts[0];
|
|
268
392
|
if (!first)
|
package/dist/lib/lanes/grants.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isTerminalLaneState } from "./types.js";
|
|
2
|
-
import {
|
|
2
|
+
import { readAllLanes, readLane, withLaneHireLocks } from "./store.js";
|
|
3
3
|
import { LanesError } from "./errors.js";
|
|
4
4
|
export function isFinishedResumableHireChild(state) {
|
|
5
5
|
return state === "awaiting_input" || state === "blocked" || state === "done";
|
|
@@ -83,7 +83,10 @@ export function hireGrantCapacityError(parent, children) {
|
|
|
83
83
|
/** Keep the occupancy snapshot and the resulting lane write in one parent-lock scope. */
|
|
84
84
|
export function withHireGrantAdmission(hqRoot, parentLaneId, fn, suppliedHierarchy, preferSuppliedLaneIds = new Set(), finishedChildrenDoNotCount = false) {
|
|
85
85
|
return withLaneHireLocks(hqRoot, [parentLaneId], () => {
|
|
86
|
-
|
|
86
|
+
// readAllLanes skips (with a warning) a record this CLI cannot parse, such as
|
|
87
|
+
// a host kind it does not know, so an unrelated lane cannot block a hire.
|
|
88
|
+
const skipped = [];
|
|
89
|
+
const ownerLanes = readAllLanes(hqRoot, undefined, (row) => skipped.push(row));
|
|
87
90
|
let allLanes;
|
|
88
91
|
let parent;
|
|
89
92
|
if (suppliedHierarchy === undefined) {
|
|
@@ -105,6 +108,16 @@ export function withHireGrantAdmission(hqRoot, parentLaneId, fn, suppliedHierarc
|
|
|
105
108
|
}
|
|
106
109
|
parent = suppliedParent;
|
|
107
110
|
}
|
|
111
|
+
// A skipped child of this parent may still hold part of its grant. Counting
|
|
112
|
+
// without it would let the parent hire past the grant, so fail closed unless
|
|
113
|
+
// the raw record says the child is finished or a readable copy is known.
|
|
114
|
+
const knownIds = new Set(allLanes.map((lane) => lane.lane_id));
|
|
115
|
+
const unreadableChild = skipped.find((row) => row.senior_id === parentLaneId &&
|
|
116
|
+
!knownIds.has(row.lane_id) &&
|
|
117
|
+
!isTerminalLaneState(row.state));
|
|
118
|
+
if (unreadableChild) {
|
|
119
|
+
throw new LanesError("hire_grant_context_invalid", `Lane ${unreadableChild.lane_id} under senior lane ${parentLaneId} could not be read, so its hire grant use is unknown. Repair or remove that lane record before hiring.`, { senior_lane_id: parentLaneId, unreadable_lane_id: unreadableChild.lane_id });
|
|
120
|
+
}
|
|
108
121
|
const children = childrenHoldingHireGrantCarve(allLanes, parentLaneId, finishedChildrenDoNotCount);
|
|
109
122
|
const parentGrant = parent.hire_grant ?? 0;
|
|
110
123
|
const availableChildGrant = Math.max(0, parentGrant - assignedChildHireGrants(children));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* HQ-root resolution for `hq
|
|
2
|
+
* HQ-root resolution for `hq runners` only (not a global findHqRoot change).
|
|
3
3
|
*
|
|
4
4
|
* `findHqRoot` walks for `.claude` or `workers` and ignores `$HQ_ROOT`. Every
|
|
5
5
|
* git worktree under `workspace/worktrees/` has its own `.claude`, so a
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* HQ-root resolution for `hq
|
|
2
|
+
* HQ-root resolution for `hq runners` only (not a global findHqRoot change).
|
|
3
3
|
*
|
|
4
4
|
* `findHqRoot` walks for `.claude` or `workers` and ignores `$HQ_ROOT`. Every
|
|
5
5
|
* git worktree under `workspace/worktrees/` has its own `.claude`, so a
|
|
@@ -22,7 +22,7 @@ export interface LinkOptions {
|
|
|
22
22
|
input?: string;
|
|
23
23
|
ackMode?: string;
|
|
24
24
|
claims?: string;
|
|
25
|
-
/** One-time handover token from `hq
|
|
25
|
+
/** One-time handover token from `hq runners link handover`, consumed by `adopt`. */
|
|
26
26
|
token?: string;
|
|
27
27
|
/** File holding the handover token; keeps it out of argv. */
|
|
28
28
|
tokenFile?: string;
|
|
@@ -50,6 +50,9 @@ export interface LivenessDeps {
|
|
|
50
50
|
readdirSync: (dir: string, options: {
|
|
51
51
|
withFileTypes: true;
|
|
52
52
|
}) => fs.Dirent[];
|
|
53
|
+
openSync?: typeof fs.openSync;
|
|
54
|
+
readSync?: typeof fs.readSync;
|
|
55
|
+
closeSync?: typeof fs.closeSync;
|
|
53
56
|
hostname?: () => string;
|
|
54
57
|
}
|
|
55
58
|
export declare function defaultLivenessDeps(): LivenessDeps;
|
|
@@ -41,6 +41,9 @@ export function defaultLivenessDeps() {
|
|
|
41
41
|
statSync: (file) => fs.statSync(file),
|
|
42
42
|
lstatSync: (file) => fs.lstatSync(file),
|
|
43
43
|
readdirSync: fs.readdirSync.bind(fs),
|
|
44
|
+
openSync: fs.openSync.bind(fs),
|
|
45
|
+
readSync: fs.readSync.bind(fs),
|
|
46
|
+
closeSync: fs.closeSync.bind(fs),
|
|
44
47
|
hostname: () => os.hostname(),
|
|
45
48
|
};
|
|
46
49
|
}
|
|
@@ -186,6 +189,55 @@ export function ingestSpoolLine(line, sessions, lineNo) {
|
|
|
186
189
|
entry.lastSeq = seq;
|
|
187
190
|
sessions[sessionId] = entry;
|
|
188
191
|
}
|
|
192
|
+
/** 64 KiB. Keeps leftover bounded to one jsonl line, never the whole spool. */
|
|
193
|
+
const SPOOL_READ_CHUNK = 64 * 1024;
|
|
194
|
+
/** Drop a truncated leftover bigger than this; liveness events are small JSON. */
|
|
195
|
+
const SPOOL_MAX_LINE = 1_048_576;
|
|
196
|
+
function ingestSpoolFile(spoolPath, sessions, deps) {
|
|
197
|
+
const openSync = deps.openSync ?? fs.openSync;
|
|
198
|
+
const readSync = deps.readSync ?? fs.readSync;
|
|
199
|
+
const closeSync = deps.closeSync ?? fs.closeSync;
|
|
200
|
+
const fd = openSync(spoolPath, "r");
|
|
201
|
+
try {
|
|
202
|
+
const buf = Buffer.alloc(SPOOL_READ_CHUNK);
|
|
203
|
+
let leftover = "";
|
|
204
|
+
let lineNo = 0;
|
|
205
|
+
for (;;) {
|
|
206
|
+
const n = readSync(fd, buf, 0, buf.length, null);
|
|
207
|
+
if (n === 0)
|
|
208
|
+
break;
|
|
209
|
+
leftover += buf.toString("utf8", 0, n);
|
|
210
|
+
let nl = leftover.indexOf("\n");
|
|
211
|
+
while (nl !== -1) {
|
|
212
|
+
lineNo += 1;
|
|
213
|
+
ingestSpoolLine(leftover.slice(0, nl), sessions, lineNo);
|
|
214
|
+
leftover = leftover.slice(nl + 1);
|
|
215
|
+
nl = leftover.indexOf("\n");
|
|
216
|
+
}
|
|
217
|
+
if (leftover.length > SPOOL_MAX_LINE)
|
|
218
|
+
leftover = "";
|
|
219
|
+
}
|
|
220
|
+
if (leftover) {
|
|
221
|
+
lineNo += 1;
|
|
222
|
+
ingestSpoolLine(leftover, sessions, lineNo);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
finally {
|
|
226
|
+
closeSync(fd);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
function buildLivenessIndexFromSpoolFile(spoolPath, meta, deps) {
|
|
230
|
+
const sessions = {};
|
|
231
|
+
ingestSpoolFile(spoolPath, sessions, deps);
|
|
232
|
+
return {
|
|
233
|
+
schema_version: "hq-lane-liveness-index.v1",
|
|
234
|
+
built_at: meta.built_at,
|
|
235
|
+
spool_path: meta.spool_path,
|
|
236
|
+
spool_bytes: meta.spool_bytes,
|
|
237
|
+
spool_mtime_ms: meta.spool_mtime_ms,
|
|
238
|
+
sessions,
|
|
239
|
+
};
|
|
240
|
+
}
|
|
189
241
|
export function buildLivenessIndexFromSpool(spoolContents, meta) {
|
|
190
242
|
const sessions = {};
|
|
191
243
|
const lines = spoolContents.split("\n");
|
|
@@ -256,11 +308,9 @@ function mergeLivenessCarry(index, carry) {
|
|
|
256
308
|
}
|
|
257
309
|
export function rebuildLivenessIndex(hqRoot, spoolPath, deps = defaultLivenessDeps()) {
|
|
258
310
|
const carry = readLivenessCarryFor(spoolPath, deps);
|
|
259
|
-
let contents;
|
|
260
311
|
let st;
|
|
261
312
|
try {
|
|
262
313
|
st = deps.statSync(spoolPath);
|
|
263
|
-
contents = deps.readFileSync(spoolPath, "utf8");
|
|
264
314
|
}
|
|
265
315
|
catch (err) {
|
|
266
316
|
const code = err.code;
|
|
@@ -278,12 +328,12 @@ export function rebuildLivenessIndex(hqRoot, spoolPath, deps = defaultLivenessDe
|
|
|
278
328
|
}
|
|
279
329
|
throw err;
|
|
280
330
|
}
|
|
281
|
-
const index = mergeLivenessCarry(
|
|
331
|
+
const index = mergeLivenessCarry(buildLivenessIndexFromSpoolFile(spoolPath, {
|
|
282
332
|
spool_path: spoolPath,
|
|
283
333
|
spool_bytes: st.size,
|
|
284
334
|
spool_mtime_ms: Math.floor(st.mtimeMs),
|
|
285
335
|
built_at: new Date(deps.now()).toISOString(),
|
|
286
|
-
}), carry);
|
|
336
|
+
}, deps), carry);
|
|
287
337
|
atomicWriteJson(livenessIndexPath(hqRoot), index, deps);
|
|
288
338
|
return index;
|
|
289
339
|
}
|
|
@@ -354,21 +404,25 @@ export function loadLivenessIndex(hqRoot, spoolPath, deps = defaultLivenessDeps(
|
|
|
354
404
|
}
|
|
355
405
|
}
|
|
356
406
|
if (!persist) {
|
|
357
|
-
let contents = "";
|
|
358
407
|
let stSize = 0;
|
|
359
408
|
let stMtime = 0;
|
|
360
409
|
try {
|
|
361
410
|
const st = deps.statSync(spool);
|
|
362
411
|
stSize = st.size;
|
|
363
412
|
stMtime = Math.floor(st.mtimeMs);
|
|
364
|
-
|
|
413
|
+
return mergeLivenessCarry(buildLivenessIndexFromSpoolFile(spool, {
|
|
414
|
+
spool_path: spool,
|
|
415
|
+
spool_bytes: stSize,
|
|
416
|
+
spool_mtime_ms: stMtime,
|
|
417
|
+
built_at: new Date(deps.now()).toISOString(),
|
|
418
|
+
}, deps), carry);
|
|
365
419
|
}
|
|
366
420
|
catch (err) {
|
|
367
421
|
const code = err.code;
|
|
368
422
|
if (code !== "ENOENT")
|
|
369
423
|
throw err;
|
|
370
424
|
}
|
|
371
|
-
return mergeLivenessCarry(buildLivenessIndexFromSpool(
|
|
425
|
+
return mergeLivenessCarry(buildLivenessIndexFromSpool("", {
|
|
372
426
|
spool_path: spool,
|
|
373
427
|
spool_bytes: stSize,
|
|
374
428
|
spool_mtime_ms: stMtime,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Per-provider known model ids, for validating `hq
|
|
2
|
+
* Per-provider known model ids, for validating `hq runners create --model`.
|
|
3
3
|
*
|
|
4
4
|
* No provider adapter in this package carries a model list, so each id set
|
|
5
5
|
* is read from where the provider itself keeps it, the way the accounts
|
package/dist/lib/lanes/models.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Per-provider known model ids, for validating `hq
|
|
2
|
+
* Per-provider known model ids, for validating `hq runners create --model`.
|
|
3
3
|
*
|
|
4
4
|
* No provider adapter in this package carries a model list, so each id set
|
|
5
5
|
* is read from where the provider itself keeps it, the way the accounts
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* The transport is the existing OutpostsClient submit/wait pair — the same
|
|
5
5
|
* path as `hq outposts exec --async`. Create stages a payload, then runs
|
|
6
|
-
* `hq
|
|
6
|
+
* `hq runners pickup --payload-url` on the box. A submit or wait failure is
|
|
7
7
|
* `outpost_dispatch_failed`, never a queued lane nobody will pick up.
|
|
8
8
|
*/
|
|
9
9
|
import { OutpostsClient } from "@indigoai-us/hq-cloud/outposts";
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* The transport is the existing OutpostsClient submit/wait pair — the same
|
|
5
5
|
* path as `hq outposts exec --async`. Create stages a payload, then runs
|
|
6
|
-
* `hq
|
|
6
|
+
* `hq runners pickup --payload-url` on the box. A submit or wait failure is
|
|
7
7
|
* `outpost_dispatch_failed`, never a queued lane nobody will pick up.
|
|
8
8
|
*/
|
|
9
9
|
import { OutpostsClient, joinCommandParts, withRemoteHqDir } from "@indigoai-us/hq-cloud/outposts";
|
|
@@ -13,7 +13,7 @@ export const PICKUP_WAIT_MS = PICKUP_EXEC_TIMEOUT_SECONDS * 1000;
|
|
|
13
13
|
export function buildOutpostQuestionAnswerCommand(input) {
|
|
14
14
|
const args = [
|
|
15
15
|
input.hqBinary?.trim() || "hq",
|
|
16
|
-
"
|
|
16
|
+
"runners",
|
|
17
17
|
"questions",
|
|
18
18
|
"answer",
|
|
19
19
|
input.questionId,
|
|
@@ -59,11 +59,11 @@ export function parseOutpostPickupPayload(raw) {
|
|
|
59
59
|
}
|
|
60
60
|
/** Same wrapping `hq outposts exec` applies: run from the box's HQ folder. */
|
|
61
61
|
export function buildOutpostPickupCommand(payloadUrl) {
|
|
62
|
-
return withRemoteHqDir(joinCommandParts(["hq", "
|
|
62
|
+
return withRemoteHqDir(joinCommandParts(["hq", "runners", "pickup", "--payload-url", payloadUrl]));
|
|
63
63
|
}
|
|
64
64
|
/** Bounded, read-only capacity query executed by the target Outpost CLI. */
|
|
65
65
|
export function buildOutpostCapacityCommand() {
|
|
66
|
-
return withRemoteHqDir(joinCommandParts(["hq", "
|
|
66
|
+
return withRemoteHqDir(joinCommandParts(["hq", "runners", "capacity", "--json"]));
|
|
67
67
|
}
|
|
68
68
|
/**
|
|
69
69
|
* Marks a lane list that runs on an Outpost for another host. Such a list
|
|
@@ -79,7 +79,7 @@ export function buildOutpostLaneListCommand(input = {}) {
|
|
|
79
79
|
"env",
|
|
80
80
|
`${REMOTE_LANE_READ_ENV}=1`,
|
|
81
81
|
input.hqBinary?.trim() || "hq",
|
|
82
|
-
"
|
|
82
|
+
"runners",
|
|
83
83
|
"list",
|
|
84
84
|
"--json",
|
|
85
85
|
];
|
|
@@ -107,7 +107,7 @@ export function buildOutpostLegacyLaneUlidListCommand(input) {
|
|
|
107
107
|
const hqBinary = input.hqBinary?.trim() || "hq";
|
|
108
108
|
const script = [
|
|
109
109
|
"const { spawnSync } = require('node:child_process');",
|
|
110
|
-
`const result = spawnSync(${JSON.stringify(hqBinary)}, ['
|
|
110
|
+
`const result = spawnSync(${JSON.stringify(hqBinary)}, ['runners', 'list', '--json'], { encoding: 'utf8', maxBuffer: 16 * 1024 * 1024, env: { ...process.env, ${REMOTE_LANE_READ_ENV}: '1' } });`,
|
|
111
111
|
"if (result.error || result.status !== 0) { console.error(JSON.stringify({ error: result.error?.message || 'legacy Outpost lane list failed', status: result.status, signal: result.signal, stderr_tail: String(result.stderr || '').slice(-4096), stdout_tail: String(result.stdout || '').slice(-4096) })); process.exit(result.status || 1); }",
|
|
112
112
|
"try {",
|
|
113
113
|
"const payload = JSON.parse(result.stdout);",
|
|
@@ -123,7 +123,7 @@ export function buildOutpostLegacyLaneUlidListCommand(input) {
|
|
|
123
123
|
export function buildOutpostQuestionListCommand(input = {}) {
|
|
124
124
|
const args = [
|
|
125
125
|
...(input.sessionId?.trim() ? ["env", `HQ_SESSION_ID=${input.sessionId.trim()}`] : []),
|
|
126
|
-
"hq", "
|
|
126
|
+
"hq", "runners", "questions", "list",
|
|
127
127
|
];
|
|
128
128
|
const company = input.company?.trim();
|
|
129
129
|
if (company)
|
|
@@ -144,7 +144,7 @@ export function buildOutpostQuestionListCommand(input = {}) {
|
|
|
144
144
|
export function buildOutpostQuestionShowCommand(questionId) {
|
|
145
145
|
return withRemoteHqDir(joinCommandParts([
|
|
146
146
|
"hq",
|
|
147
|
-
"
|
|
147
|
+
"runners",
|
|
148
148
|
"questions",
|
|
149
149
|
"show",
|
|
150
150
|
questionId,
|
|
@@ -154,7 +154,7 @@ export function buildOutpostQuestionShowCommand(questionId) {
|
|
|
154
154
|
export function buildOutpostQuestionCancelCommand(input) {
|
|
155
155
|
return withRemoteHqDir(joinCommandParts([
|
|
156
156
|
"hq",
|
|
157
|
-
"
|
|
157
|
+
"runners",
|
|
158
158
|
"questions",
|
|
159
159
|
"cancel",
|
|
160
160
|
input.questionId,
|
|
@@ -166,7 +166,7 @@ export function buildOutpostQuestionCancelCommand(input) {
|
|
|
166
166
|
export function buildOutpostMoveTargetCommand(input) {
|
|
167
167
|
return withRemoteHqDir(joinCommandParts([
|
|
168
168
|
"hq",
|
|
169
|
-
"
|
|
169
|
+
"runners",
|
|
170
170
|
"move-target",
|
|
171
171
|
input.laneId,
|
|
172
172
|
"--host-kind",
|
|
@@ -181,7 +181,7 @@ export function buildOutpostMoveTargetCommand(input) {
|
|
|
181
181
|
export function buildOutpostBalanceMoveCommand(input) {
|
|
182
182
|
return withRemoteHqDir(joinCommandParts([
|
|
183
183
|
"hq",
|
|
184
|
-
"
|
|
184
|
+
"runners",
|
|
185
185
|
"balance-move-target",
|
|
186
186
|
input.laneId,
|
|
187
187
|
"--account",
|
|
@@ -196,7 +196,7 @@ export function buildOutpostBalanceMoveCommand(input) {
|
|
|
196
196
|
export function buildOutpostIdentityBackfillCommand(expectedId) {
|
|
197
197
|
return withRemoteHqDir(joinCommandParts([
|
|
198
198
|
"hq",
|
|
199
|
-
"
|
|
199
|
+
"runners",
|
|
200
200
|
"outpost-identity-backfill-target",
|
|
201
201
|
"--expected-id",
|
|
202
202
|
expectedId,
|
|
@@ -205,7 +205,7 @@ export function buildOutpostIdentityBackfillCommand(expectedId) {
|
|
|
205
205
|
/** Build the same `hq outposts exec` remote command used by lane pickup. */
|
|
206
206
|
export function buildOutpostLaneCommand(input) {
|
|
207
207
|
const action = input.action === "blocked-escalation-target" ? "_enqueue-blocked-escalation" : input.action;
|
|
208
|
-
const args = [input.hqBinary?.trim() || "hq", "
|
|
208
|
+
const args = [input.hqBinary?.trim() || "hq", "runners", action];
|
|
209
209
|
if (input.action === "blocked-escalation-target")
|
|
210
210
|
args.push(input.recipientKind ?? "lane", input.laneId);
|
|
211
211
|
else
|