@indigoai-us/hq-cli 5.345.220 → 5.345.221
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 +118 -0
- package/dist/command-catalog.generated.d.ts +144 -2
- package/dist/command-catalog.generated.js +175 -2
- package/dist/commands/auth.js +4 -1
- package/dist/commands/bot-runtime.d.ts +18 -5
- package/dist/commands/bot-runtime.js +29 -12
- package/dist/commands/bot.d.ts +39 -2
- package/dist/commands/bot.js +140 -11
- package/dist/commands/core-stop-autosave.d.ts +21 -0
- package/dist/commands/core-stop-autosave.js +300 -0
- package/dist/commands/core.js +2 -0
- package/dist/commands/daemon.d.ts +5 -0
- package/dist/commands/daemon.js +31 -7
- package/dist/commands/doctor-usage.d.ts +5 -0
- package/dist/commands/doctor-usage.js +25 -0
- package/dist/commands/env.d.ts +49 -4
- package/dist/commands/env.js +355 -5
- package/dist/commands/lanes-shared.d.ts +3 -0
- package/dist/commands/lanes.d.ts +3 -0
- package/dist/commands/lanes.js +87 -3
- package/dist/commands/sources.js +3 -3
- package/dist/commands/sync-core.d.ts +1 -0
- package/dist/commands/sync-core.js +77 -3
- package/dist/commands/whoami.js +96 -80
- package/dist/lib/bot/config.d.ts +17 -0
- package/dist/lib/bot/config.js +13 -0
- package/dist/lib/bot/fleet-cron.js +24 -2
- package/dist/lib/bot/fleet-local.d.ts +30 -2
- package/dist/lib/bot/fleet-local.js +60 -1
- package/dist/lib/bot/grok-login-scope.d.ts +36 -0
- package/dist/lib/bot/grok-login-scope.js +93 -0
- package/dist/lib/bot/legacy-provider-login.d.ts +32 -9
- package/dist/lib/bot/legacy-provider-login.js +28 -22
- package/dist/lib/bot/runtime-sign-in-check.js +6 -1
- package/dist/lib/bot/runtime-sign-in.d.ts +2 -0
- package/dist/lib/core-utils/sentry-report.js +2 -0
- package/dist/lib/daemon/machine-checks.d.ts +22 -1
- package/dist/lib/daemon/machine-checks.js +54 -12
- package/dist/lib/daemon/run.js +66 -8
- package/dist/lib/daemon/stop-autosave-lock.d.ts +19 -0
- package/dist/lib/daemon/stop-autosave-lock.js +166 -0
- package/dist/lib/daemon/stop-autosave.d.ts +28 -0
- package/dist/lib/daemon/stop-autosave.js +111 -0
- package/dist/lib/daemon/stop-diagnostics.d.ts +11 -0
- package/dist/lib/daemon/stop-diagnostics.js +136 -0
- package/dist/lib/daemon/stop-job-executor.d.ts +19 -0
- package/dist/lib/daemon/stop-job-executor.js +126 -0
- package/dist/lib/daemon/stop-jobs.d.ts +93 -0
- package/dist/lib/daemon/stop-jobs.js +599 -0
- package/dist/lib/doctor/checks/fleet-hook-core.js +1 -1
- package/dist/lib/doctor/checks/host-core.js +1 -1
- package/dist/lib/environment/access-probes.d.ts +234 -0
- package/dist/lib/environment/access-probes.js +918 -0
- package/dist/lib/environment/profile.d.ts +15 -2
- package/dist/lib/environment/profile.js +55 -20
- package/dist/lib/environment/rfc3339.d.ts +8 -0
- package/dist/lib/environment/rfc3339.js +26 -0
- package/dist/lib/environment/work-requirements.d.ts +169 -0
- package/dist/lib/environment/work-requirements.js +389 -0
- package/dist/lib/hook-engine/coverage.d.ts +137 -7
- package/dist/lib/hook-engine/coverage.js +1424 -4
- package/dist/lib/hook-engine/fleet-registration.js +2 -2
- package/dist/lib/hook-engine/git-stop-config.json +513 -0
- package/dist/lib/hook-engine/native-stop-compatibility.json +311 -0
- package/dist/lib/hook-engine/reconcile.js +2 -2
- package/dist/lib/hot-channels/alert.d.ts +2 -2
- package/dist/lib/hot-channels/alert.js +8 -5
- package/dist/lib/hot-channels/signals-pass.d.ts +126 -17
- package/dist/lib/hot-channels/signals-pass.js +296 -17
- package/dist/lib/hot-channels/signals-runtime.d.ts +30 -0
- package/dist/lib/hot-channels/signals-runtime.js +82 -0
- package/dist/lib/install/hook-target.js +1 -1
- package/dist/lib/lanes/host-capacity.d.ts +26 -2
- package/dist/lib/lanes/host-capacity.js +17 -2
- package/dist/lib/lanes/host-compute.d.ts +90 -0
- package/dist/lib/lanes/host-compute.js +185 -0
- package/dist/lib/lanes/index.d.ts +2 -0
- package/dist/lib/lanes/index.js +1 -0
- package/dist/lib/lanes/reconcile.js +22 -1
- package/dist/lib/lanes/resource-usage.d.ts +155 -0
- package/dist/lib/lanes/resource-usage.js +589 -0
- package/dist/lib/lanes/run-size.d.ts +46 -0
- package/dist/lib/lanes/run-size.js +197 -0
- package/dist/lib/lanes/store.js +27 -0
- package/dist/lib/lanes/throttle.d.ts +36 -1
- package/dist/lib/lanes/throttle.js +47 -10
- package/dist/lib/lanes/types.d.ts +40 -0
- package/dist/lib/lanes/types.js +2 -2
- package/dist/lib/lanes/watcher.js +13 -4
- package/dist/lib/lanes/worker-process.d.ts +25 -2
- package/dist/lib/lanes/worker-process.js +71 -19
- package/dist/lib/placement/match.d.ts +192 -0
- package/dist/lib/placement/match.js +667 -0
- package/dist/lib/safe-store.d.ts +14 -0
- package/dist/lib/safe-store.js +77 -4
- package/dist/lib/search-index/index.d.ts +88 -4
- package/dist/lib/search-index/index.js +288 -24
- package/dist/lib/search-index/max-doc-bytes.d.ts +17 -6
- package/dist/lib/search-index/max-doc-bytes.js +48 -23
- package/dist/lib/signals/codex-lockdown.d.ts +79 -0
- package/dist/lib/signals/codex-lockdown.js +271 -0
- package/dist/lib/signals/codex-login.d.ts +37 -0
- package/dist/lib/signals/codex-login.js +83 -0
- package/dist/lib/signals/engine.d.ts +27 -0
- package/dist/lib/signals/engine.js +70 -0
- package/dist/lib/signals/reply.js +22 -1
- package/dist/lib/signals/run-record.js +6 -1
- package/dist/lib/signals/settings.d.ts +5 -0
- package/dist/lib/signals/settings.js +2 -0
- package/dist/lib/signals/steps/extract.d.ts +85 -9
- package/dist/lib/signals/steps/extract.js +317 -68
- package/dist/lib/signals/steps/types.d.ts +2 -0
- package/dist/lib/sync-core/engine-home.d.ts +35 -1
- package/dist/lib/sync-core/engine-home.js +119 -16
- package/dist/lib/sync-core/rollout-state.d.ts +2 -1
- package/dist/lib/sync-core/rollout-state.js +5 -2
- package/dist/lib/sync-core/vault-uid.d.ts +2 -0
- package/dist/lib/sync-core/vault-uid.js +4 -0
- package/dist/schemas/hq-work-requirements.v1.schema.json +145 -0
- package/dist/utils/auth-session-check.d.ts +16 -0
- package/dist/utils/auth-session-check.js +16 -0
- package/dist/utils/client-health-contract.d.ts +6 -0
- package/dist/utils/client-health-contract.js +13 -0
- package/dist/utils/client-health.d.ts +7 -0
- package/dist/utils/client-health.js +22 -1
- package/dist/utils/command-usage.d.ts +40 -0
- package/dist/utils/command-usage.js +61 -0
- package/dist/utils/duplicate-command-usage.d.ts +72 -0
- package/dist/utils/duplicate-command-usage.js +125 -0
- package/dist/utils/host-registration.js +2 -1
- package/dist/utils/resident-package-preload.js +4 -0
- package/dist/utils/sentry-fingerprint.js +9 -0
- package/dist/utils/windows-bash.d.ts +2 -0
- package/dist/utils/windows-bash.js +2 -1
- package/package.json +9 -8
- package/scripts/bench-core-compare.mjs +313 -0
- package/scripts/bench-core.mjs +399 -12
- package/scripts/check-function-manifest.mjs +116 -3
package/dist/commands/core.js
CHANGED
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
import { Option } from "commander";
|
|
32
32
|
import { registerCoreHookRegistrationPlan } from "./core-hook-registration-plan.js";
|
|
33
33
|
import { registerCoreCheckpointCommand } from "./core-checkpoint.js";
|
|
34
|
+
import { registerCoreStopAutosave } from "./core-stop-autosave.js";
|
|
34
35
|
import { runHookEnginePath } from '../hook-engine-path.js';
|
|
35
36
|
import { registerCoreDelegateCommand } from "./core-delegate.js";
|
|
36
37
|
import { registerCoreDelegateW1b } from "./core-delegate-w1b.js";
|
|
@@ -451,6 +452,7 @@ export function registerCoreCommands(program) {
|
|
|
451
452
|
});
|
|
452
453
|
describeCoreCommand(machineCheckOwnerCommand, { execution: "native", root: "cwd" });
|
|
453
454
|
registerCoreCheckpointCommand(core);
|
|
455
|
+
registerCoreStopAutosave(core);
|
|
454
456
|
registerCoreHookRegistrationPlan(core);
|
|
455
457
|
const hookEnginePath = core.command('hook-engine-path')
|
|
456
458
|
.description('Print the offline, version-pinned native hook engine path')
|
|
@@ -57,6 +57,11 @@ export interface DaemonCommandDeps {
|
|
|
57
57
|
runtimeAllowed?: () => boolean | Promise<boolean>;
|
|
58
58
|
/** Test seam for the company sync-mode commands. */
|
|
59
59
|
syncModeClient?: () => Promise<SyncModeVaultClient>;
|
|
60
|
+
/**
|
|
61
|
+
* Test seam for the deleted-company notice `hq daemon sync mode list`
|
|
62
|
+
* prints to stderr when there are no memberships (as `hq sync mode --show` does).
|
|
63
|
+
*/
|
|
64
|
+
deletedCompanyNotices?: () => Promise<void>;
|
|
60
65
|
/** Reads stdin for the one-shot daemon machine login; never reads env or argv credentials. */
|
|
61
66
|
readStdin?: () => Promise<string>;
|
|
62
67
|
windowsUser?: string;
|
package/dist/commands/daemon.js
CHANGED
|
@@ -41,7 +41,7 @@ import { runDaemonCall } from "../lib/daemon/command-call.js";
|
|
|
41
41
|
import { acknowledgeConflictNotice, conflictNoticeStateDir } from "../lib/daemon/conflict-notices.js";
|
|
42
42
|
import { isSyncRunnerCommandLine, readWatchRunnerOwnerStatus, syncRunnerPathFromCommandLine, watchRunnerOwnerStatusPath } from "../lib/daemon/sync-runner.js";
|
|
43
43
|
import { stagedSyncRunnerVersion, syncRunnerBundleStageRoot } from "../lib/daemon/sync-runner-bundle.js";
|
|
44
|
-
import { getSyncModeForCompany, setSyncMode } from "./sync-mode.js";
|
|
44
|
+
import { formatShowTable, getSyncModeForCompany, parseCustomPaths, setSyncMode, showSyncModes, validateMode, } from "./sync-mode.js";
|
|
45
45
|
import { assertSafeCompanySlug } from "../utils/people.js";
|
|
46
46
|
import { anywhereRuntimeAllowed } from "../lib/anywhere-person-setting.js";
|
|
47
47
|
import { hqdRequest, hqdSocketPath, HqdClientError } from "../lib/daemon/protocol.js";
|
|
@@ -919,13 +919,28 @@ async function runDaemonSyncModeGet(d, companySlug, opts) {
|
|
|
919
919
|
};
|
|
920
920
|
d.out(opts.json ? JSON.stringify(value, null, 2) : `${value.companySlug}: ${value.mode}${value.isDefault ? " (default)" : ""}`);
|
|
921
921
|
}
|
|
922
|
-
async function
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
922
|
+
async function runDaemonSyncModeList(d, opts) {
|
|
923
|
+
// Same rows, columns and order as `hq sync mode --show`.
|
|
924
|
+
const rows = await showSyncModes({ vaultClient: await daemonSyncModeClient(d) });
|
|
925
|
+
d.out(opts.json ? JSON.stringify(rows, null, 2) : formatShowTable(rows));
|
|
926
|
+
// No memberships may mean the person's company was deleted (stderr only).
|
|
927
|
+
if (rows.length === 0)
|
|
928
|
+
await daemonDeletedCompanyNotices(d);
|
|
929
|
+
}
|
|
930
|
+
async function daemonDeletedCompanyNotices(d) {
|
|
931
|
+
if (d.deletedCompanyNotices)
|
|
932
|
+
return d.deletedCompanyNotices();
|
|
933
|
+
const { printDeletedCompanyNotices } = await import("../utils/deleted-company-notice.js");
|
|
934
|
+
await printDeletedCompanyNotices({ write: (line) => d.err(line) });
|
|
935
|
+
}
|
|
936
|
+
async function runDaemonSyncModeSet(d, companySlug, modeArg, opts) {
|
|
937
|
+
// Same validation and write as `hq sync mode <mode> --company <slug> [--paths <csv>]`.
|
|
938
|
+
const mode = validateMode(modeArg);
|
|
939
|
+
const customPaths = parseCustomPaths(opts.paths);
|
|
926
940
|
const result = await setSyncMode({
|
|
927
941
|
mode,
|
|
928
942
|
companySlug,
|
|
943
|
+
customPaths,
|
|
929
944
|
vaultClient: await daemonSyncModeClient(d),
|
|
930
945
|
});
|
|
931
946
|
const value = {
|
|
@@ -934,6 +949,9 @@ async function runDaemonSyncModeSet(d, companySlug, mode, opts) {
|
|
|
934
949
|
previousMode: result.previousMode,
|
|
935
950
|
mode: result.newMode,
|
|
936
951
|
isDefault: result.newConfig.isDefault,
|
|
952
|
+
...(result.newConfig.customPaths && result.newConfig.customPaths.length > 0
|
|
953
|
+
? { customPaths: result.newConfig.customPaths }
|
|
954
|
+
: {}),
|
|
937
955
|
...(result.newConfig.updatedAt ? { updatedAt: result.newConfig.updatedAt } : {}),
|
|
938
956
|
};
|
|
939
957
|
d.out(opts.json ? JSON.stringify(value, null, 2) : `${value.companySlug}: ${value.previousMode} → ${value.mode}`);
|
|
@@ -1757,14 +1775,20 @@ export function registerDaemonCommand(program, over = {}) {
|
|
|
1757
1775
|
.option("--json", "Print machine-readable JSON")
|
|
1758
1776
|
.action(wrap((d, opts) => runDaemonSyncTakeOwnership(d, opts)));
|
|
1759
1777
|
const mode = sync.command("mode").description("Read or change a company's sync footprint");
|
|
1778
|
+
mode
|
|
1779
|
+
.command("list")
|
|
1780
|
+
.description("List every membership's company and current sync mode (same table as `hq sync mode --show`)")
|
|
1781
|
+
.option("--json", "Print machine-readable JSON")
|
|
1782
|
+
.action(wrap((d, opts) => runDaemonSyncModeList(d, opts)));
|
|
1760
1783
|
mode
|
|
1761
1784
|
.command("get <company>")
|
|
1762
|
-
.description("Read a company's current
|
|
1785
|
+
.description("Read a company's current sync mode")
|
|
1763
1786
|
.option("--json", "Print machine-readable JSON")
|
|
1764
1787
|
.action(wrap((d, company, opts) => runDaemonSyncModeGet(d, company, opts)));
|
|
1765
1788
|
mode
|
|
1766
1789
|
.command("set <company> <mode>")
|
|
1767
|
-
.description("Set a company's sync mode to all or
|
|
1790
|
+
.description("Set a company's sync mode to shared, all or custom")
|
|
1791
|
+
.option("--paths <csv>", "Comma-separated allowed prefixes (required when mode is 'custom')")
|
|
1768
1792
|
.option("--json", "Print machine-readable JSON")
|
|
1769
1793
|
.action(wrap((d, company, mode, opts) => runDaemonSyncModeSet(d, company, mode, opts)));
|
|
1770
1794
|
daemon
|
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
* `hq doctor usage` — counts per command for the last 30 days, read from the
|
|
3
3
|
* local usage file (utils/command-usage.ts). It reads one small folder under
|
|
4
4
|
* `~/.hq` and sends nothing.
|
|
5
|
+
*
|
|
6
|
+
* `hq doctor usage --duplicates [--since <window>]` lists the duplicate
|
|
7
|
+
* command paths (utils/duplicate-command-usage.ts) with their runs in the
|
|
8
|
+
* window. It exits 0 when none ran, 1 when one did, and 2 when the count
|
|
9
|
+
* cannot be read or the window is not valid.
|
|
5
10
|
*/
|
|
6
11
|
import type { Command } from "commander";
|
|
7
12
|
export declare function registerDoctorUsageCommand(doctor: Command): void;
|
|
@@ -2,17 +2,42 @@
|
|
|
2
2
|
* `hq doctor usage` — counts per command for the last 30 days, read from the
|
|
3
3
|
* local usage file (utils/command-usage.ts). It reads one small folder under
|
|
4
4
|
* `~/.hq` and sends nothing.
|
|
5
|
+
*
|
|
6
|
+
* `hq doctor usage --duplicates [--since <window>]` lists the duplicate
|
|
7
|
+
* command paths (utils/duplicate-command-usage.ts) with their runs in the
|
|
8
|
+
* window. It exits 0 when none ran, 1 when one did, and 2 when the count
|
|
9
|
+
* cannot be read or the window is not valid.
|
|
5
10
|
*/
|
|
6
11
|
import { COMMAND_USAGE_WINDOW_DAYS, readCommandUsage, renderCommandUsageText, } from "../utils/command-usage.js";
|
|
12
|
+
import { DEFAULT_SINCE, duplicateUsageExitCode, MAX_SINCE_HOURS, parseSince, readDuplicateUsage, renderDuplicateUsageText, } from "../utils/duplicate-command-usage.js";
|
|
7
13
|
export function registerDoctorUsageCommand(doctor) {
|
|
8
14
|
doctor
|
|
9
15
|
.command("usage")
|
|
10
16
|
.description(`Show how many times each command ran on this computer in the last ${COMMAND_USAGE_WINDOW_DAYS} days (a local file that is never sent).`)
|
|
11
17
|
.option("--json", "Emit the counts as JSON.")
|
|
18
|
+
.option("--duplicates", "List only the duplicate commands and their runs in the window; exit 0 when none ran, 1 when one did, 2 when the count cannot be read.")
|
|
19
|
+
.option("--since <window>", `Window for --duplicates: Nh or Nd, at most ${MAX_SINCE_HOURS / 24}d (default ${DEFAULT_SINCE}). Counts are per UTC date, so whole dates are counted.`)
|
|
12
20
|
.action((opts, command) => {
|
|
13
21
|
// `hq doctor` declares --json too, and Commander stores the flag on
|
|
14
22
|
// whichever of the two commands it reaches first. Read the merged set.
|
|
15
23
|
const json = opts.json === true || command.optsWithGlobals().json === true;
|
|
24
|
+
if (opts.since !== undefined && opts.duplicates !== true) {
|
|
25
|
+
process.stderr.write("hq doctor usage: --since needs --duplicates\n");
|
|
26
|
+
process.exitCode = 2;
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
if (opts.duplicates === true) {
|
|
30
|
+
const since = opts.since ?? DEFAULT_SINCE;
|
|
31
|
+
if (parseSince(since) === null) {
|
|
32
|
+
process.stderr.write(`hq doctor usage: --since must be Nh or Nd (N from 1), at most ${MAX_SINCE_HOURS / 24}d; got "${since}"\n`);
|
|
33
|
+
process.exitCode = 2;
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const report = readDuplicateUsage({ since });
|
|
37
|
+
process.stdout.write(json ? `${JSON.stringify(report, null, 2)}\n` : renderDuplicateUsageText(report));
|
|
38
|
+
process.exitCode = duplicateUsageExitCode(report);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
16
41
|
const report = readCommandUsage();
|
|
17
42
|
process.stdout.write(json ? `${JSON.stringify(report, null, 2)}\n` : renderCommandUsageText(report));
|
|
18
43
|
});
|
package/dist/commands/env.d.ts
CHANGED
|
@@ -1,18 +1,63 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `hq env`: environment profiles (hq-environment-profile.v1).
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* `hq env validate <file>` reads one file and checks it against the schema.
|
|
5
|
+
* It writes nothing, calls no service and needs no sign-in; the CLI's usual
|
|
6
|
+
* start-up state files are still written, as for every hq command.
|
|
7
|
+
*
|
|
8
|
+
* `hq env probe` runs access probes by name (vault grant, repo, secret,
|
|
9
|
+
* integration, local data, and optionally `hq agent probe`) and prints them
|
|
10
|
+
* as readings.access entries. A secret is resolved only inside a child of
|
|
11
|
+
* `hq secrets exec`, which checks its length and prints nothing; no value
|
|
12
|
+
* reaches this process. `--write-profile <file>` stores the readings in an
|
|
13
|
+
* existing profile after validating the result.
|
|
14
|
+
*
|
|
15
|
+
* `hq env match --requirements <file> --profiles <dir>` runs the matcher
|
|
16
|
+
* (src/lib/placement/match.ts): it filters the profiles for one piece of work
|
|
17
|
+
* and prints a first ranking, which the conductor engine reads. It is not a
|
|
18
|
+
* placement; the conductor makes and records the choice. It writes nothing,
|
|
19
|
+
* calls no service and needs no sign-in.
|
|
8
20
|
*/
|
|
9
21
|
import type { Command } from "commander";
|
|
22
|
+
import type { AccessProbeDeps } from "../lib/environment/access-probes.js";
|
|
10
23
|
/** A profile is a few kilobytes; nothing larger than this is read. */
|
|
11
24
|
export declare const ENV_VALIDATE_MAX_BYTES: number;
|
|
12
25
|
export interface EnvCommandDeps {
|
|
13
26
|
print: (line: string) => void;
|
|
14
27
|
printError: (line: string) => void;
|
|
15
28
|
setExitCode: (code: number) => void;
|
|
29
|
+
/** Test seam for `hq env probe`; defaults to real child processes. */
|
|
30
|
+
probeDeps?: (hqRoot: string) => AccessProbeDeps;
|
|
31
|
+
/** Test seam for the HQ root `hq env probe` reads repos and data under. */
|
|
32
|
+
hqRoot?: () => string;
|
|
33
|
+
/** Test seam: the environment the session lock and agent kit are read from. */
|
|
34
|
+
env?: NodeJS.ProcessEnv;
|
|
35
|
+
/** Test seam: the company of this host's external agent kit, or null. */
|
|
36
|
+
agentCompany?: () => Promise<string | null>;
|
|
16
37
|
}
|
|
17
38
|
export declare function registerEnvCommand(program: Command, overrides?: Partial<EnvCommandDeps>): Command;
|
|
39
|
+
type EnvMatchFailureCode = "unreadable" | "too_large" | "invalid_requirements" | "invalid_profile" | "invalid_now";
|
|
40
|
+
export type EnvMatchRun = {
|
|
41
|
+
ok: true;
|
|
42
|
+
match: import("../lib/placement/match.js").MatchResult;
|
|
43
|
+
profilesRead: number;
|
|
44
|
+
} | {
|
|
45
|
+
ok: false;
|
|
46
|
+
code: EnvMatchFailureCode;
|
|
47
|
+
message: string;
|
|
48
|
+
issues: string[];
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Load the requirements and every profile in the directory, then call the
|
|
52
|
+
* matcher library. All I/O for `hq env match` is here; match() itself reads
|
|
53
|
+
* nothing.
|
|
54
|
+
*/
|
|
55
|
+
export declare function runEnvMatch(opts: {
|
|
56
|
+
requirements: string;
|
|
57
|
+
profiles: string;
|
|
58
|
+
now?: string;
|
|
59
|
+
}): Promise<EnvMatchRun>;
|
|
60
|
+
/** A profile file: *.json, not a dotfile (which covers AppleDouble "._*" files). */
|
|
61
|
+
export declare function isProfileFileName(name: string): boolean;
|
|
62
|
+
export {};
|
|
18
63
|
//# sourceMappingURL=env.d.ts.map
|
package/dist/commands/env.js
CHANGED
|
@@ -1,14 +1,31 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `hq env`: environment profiles (hq-environment-profile.v1).
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* `hq env validate <file>` reads one file and checks it against the schema.
|
|
5
|
+
* It writes nothing, calls no service and needs no sign-in; the CLI's usual
|
|
6
|
+
* start-up state files are still written, as for every hq command.
|
|
7
|
+
*
|
|
8
|
+
* `hq env probe` runs access probes by name (vault grant, repo, secret,
|
|
9
|
+
* integration, local data, and optionally `hq agent probe`) and prints them
|
|
10
|
+
* as readings.access entries. A secret is resolved only inside a child of
|
|
11
|
+
* `hq secrets exec`, which checks its length and prints nothing; no value
|
|
12
|
+
* reaches this process. `--write-profile <file>` stores the readings in an
|
|
13
|
+
* existing profile after validating the result.
|
|
14
|
+
*
|
|
15
|
+
* `hq env match --requirements <file> --profiles <dir>` runs the matcher
|
|
16
|
+
* (src/lib/placement/match.ts): it filters the profiles for one piece of work
|
|
17
|
+
* and prints a first ranking, which the conductor engine reads. It is not a
|
|
18
|
+
* placement; the conductor makes and records the choice. It writes nothing,
|
|
19
|
+
* calls no service and needs no sign-in.
|
|
8
20
|
*/
|
|
9
|
-
import {
|
|
21
|
+
import { randomBytes } from "node:crypto";
|
|
22
|
+
import { chmodSync, lstatSync, readFileSync, readdirSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
23
|
+
import * as path from "node:path";
|
|
10
24
|
/** A profile is a few kilobytes; nothing larger than this is read. */
|
|
11
25
|
export const ENV_VALIDATE_MAX_BYTES = 5 * 1024 * 1024;
|
|
26
|
+
function collect(value, previous = []) {
|
|
27
|
+
return [...previous, ...value.split(",").map((part) => part.trim()).filter(Boolean)];
|
|
28
|
+
}
|
|
12
29
|
export function registerEnvCommand(program, overrides = {}) {
|
|
13
30
|
const deps = {
|
|
14
31
|
print: (line) => console.log(line),
|
|
@@ -77,6 +94,339 @@ export function registerEnvCommand(program, overrides = {}) {
|
|
|
77
94
|
}
|
|
78
95
|
deps.setExitCode(1);
|
|
79
96
|
});
|
|
97
|
+
env
|
|
98
|
+
.command("probe")
|
|
99
|
+
.description("Run access probes by name and print them as hq-environment-profile.v1 readings.access entries: " +
|
|
100
|
+
"company vault grant, repos, secrets (exists by HEAD, and resolvable inside hq secrets exec; the value is never printed or stored), " +
|
|
101
|
+
"integrations and local data (exit 1 when a probe does not pass)")
|
|
102
|
+
.option("--company <slug>", "Company whose vault, secrets and integrations are probed (required)")
|
|
103
|
+
.option("--repo <name>", "Checkout name under repos/private or repos/public; its origin must answer git ls-remote (repeatable, comma-separated)", collect)
|
|
104
|
+
.option("--secret <NAME>", "Secret name to probe: exists, then resolvable by this identity (repeatable, comma-separated)", collect)
|
|
105
|
+
.option("--integration <slug>", "App that must be connected and shared with this identity (repeatable, comma-separated)", collect)
|
|
106
|
+
.option("--data <path>", "Path relative to the HQ root that must be present and not empty (repeatable, comma-separated)", collect)
|
|
107
|
+
.option("--agent", "Also run hq agent probe (identity, vault, presence, DMs); it sends a self-DM and reports to the console")
|
|
108
|
+
.option("--write-profile <file>", "Store the readings in this profile's readings.access, replacing entries with the same names; the profile must validate afterwards")
|
|
109
|
+
.option("--json", "Print the result as JSON")
|
|
110
|
+
.action(async (opts) => {
|
|
111
|
+
const probes = await import("../lib/environment/access-probes.js");
|
|
112
|
+
const { validateEnvironmentAccessProbe, parseEnvironmentProfile } = await import("../lib/environment/profile.js");
|
|
113
|
+
const environment = deps.env ?? process.env;
|
|
114
|
+
const refuse = (code, message, exit = 2) => {
|
|
115
|
+
if (opts.json)
|
|
116
|
+
deps.print(JSON.stringify({ ok: false, code, message, probes: [] }, null, 2));
|
|
117
|
+
else
|
|
118
|
+
deps.printError(message);
|
|
119
|
+
deps.setExitCode(exit);
|
|
120
|
+
};
|
|
121
|
+
if (!opts.company) {
|
|
122
|
+
refuse("invalid_request", "--company <slug> is required");
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
const company = opts.company;
|
|
126
|
+
const request = {
|
|
127
|
+
company,
|
|
128
|
+
repos: opts.repo ?? [],
|
|
129
|
+
secrets: opts.secret ?? [],
|
|
130
|
+
integrations: opts.integration ?? [],
|
|
131
|
+
data: opts.data ?? [],
|
|
132
|
+
agent: Boolean(opts.agent),
|
|
133
|
+
};
|
|
134
|
+
const problems = probes.requestProblems(request);
|
|
135
|
+
if (problems.length > 0) {
|
|
136
|
+
refuse("invalid_request", problems.join("; "));
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
// A session locked to a company set may not probe a company outside it.
|
|
140
|
+
// The session id comes from the caller's environment only, never from
|
|
141
|
+
// the global workspace/sessions/.current fallback. No lock: no check.
|
|
142
|
+
const { sessionIdFromEnv } = await import("../lib/core-utils/session-id.js");
|
|
143
|
+
if (sessionIdFromEnv(environment)) {
|
|
144
|
+
const { readSessionCompanyLock } = await import("../lib/session-company-lock.js");
|
|
145
|
+
let lock;
|
|
146
|
+
try {
|
|
147
|
+
lock = readSessionCompanyLock(environment);
|
|
148
|
+
}
|
|
149
|
+
catch (error) {
|
|
150
|
+
refuse("session_lock_unreadable", error instanceof Error ? error.message : String(error));
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
// Fail closed: a session id with no readable lock (missing or invalid
|
|
154
|
+
// metadata, a missing or symlinked primary folder) is refused, not
|
|
155
|
+
// treated as unlocked. The shared reader is unchanged, so hq secrets
|
|
156
|
+
// exec keeps its own behaviour.
|
|
157
|
+
if (!lock || lock.companies.length === 0) {
|
|
158
|
+
refuse("session_lock_empty", "An HQ session with no company lock cannot run hq env probe. This session has an id but no readable company lock. " +
|
|
159
|
+
`Bind it with core/scripts/hq-session.sh add company ${company}, then run the probe again.`);
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
if (!lock.companies.includes(company)) {
|
|
163
|
+
refuse("outside_session_lock", `Company '${company}' is outside this session's locked company set.`);
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
// hq agent probe runs on this host's agent kit credentials, whatever
|
|
168
|
+
// --company says. A kit enrolled for another company would act as that
|
|
169
|
+
// company (token, vault listing, secret list, DM, console report), so
|
|
170
|
+
// --agent runs only when the kit belongs to the probed company. The
|
|
171
|
+
// other company's name is not printed.
|
|
172
|
+
if (opts.agent) {
|
|
173
|
+
const agentCompany = await (deps.agentCompany ?? (() => probes.agentKitCompany(environment)))();
|
|
174
|
+
if (agentCompany !== company) {
|
|
175
|
+
refuse("agent_company_mismatch", agentCompany
|
|
176
|
+
? `this host's agent kit is enrolled for a different company, so hq agent probe was not run for ${company}; nothing was probed`
|
|
177
|
+
: `this host has no external agent kit enrolled for ${company}, so --agent cannot run; nothing was probed`);
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
let hqRoot;
|
|
182
|
+
try {
|
|
183
|
+
hqRoot = deps.hqRoot
|
|
184
|
+
? deps.hqRoot()
|
|
185
|
+
: (await import("../utils/hq-root-resolver.js")).resolveDefaultHqRoot({ env: environment, onMissing: "fallback" });
|
|
186
|
+
}
|
|
187
|
+
catch (error) {
|
|
188
|
+
refuse("no_hq_root", error instanceof Error ? error.message : String(error));
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
// Read the profile before probing, so a bad --write-profile costs no probe.
|
|
192
|
+
// It is read again just before the write (readProfile below).
|
|
193
|
+
const readProfile = (stage) => {
|
|
194
|
+
const file = opts.writeProfile;
|
|
195
|
+
if (probes.pathInOtherCompany(hqRoot, company, file)) {
|
|
196
|
+
refuse("profile_outside_company", `${file} is inside another company's folder; probes for ${company} are not stored there`);
|
|
197
|
+
return null;
|
|
198
|
+
}
|
|
199
|
+
let text;
|
|
200
|
+
let mode;
|
|
201
|
+
try {
|
|
202
|
+
const link = lstatSync(file);
|
|
203
|
+
if (link.isSymbolicLink()) {
|
|
204
|
+
refuse("profile_is_symlink", `${file} is a symlink; hq env probe writes only to a regular profile file`);
|
|
205
|
+
return null;
|
|
206
|
+
}
|
|
207
|
+
if (link.size > ENV_VALIDATE_MAX_BYTES) {
|
|
208
|
+
refuse("too_large", `${file} is too large: ${link.size} bytes`);
|
|
209
|
+
return null;
|
|
210
|
+
}
|
|
211
|
+
mode = link.mode & 0o777;
|
|
212
|
+
text = readFileSync(file, "utf8");
|
|
213
|
+
}
|
|
214
|
+
catch (error) {
|
|
215
|
+
refuse(stage === "before" ? "unreadable" : "write_failed", `cannot read ${file} (${error.code ?? "error"})${stage === "write" ? "; it was not changed" : ""}`);
|
|
216
|
+
return null;
|
|
217
|
+
}
|
|
218
|
+
const parsed = parseEnvironmentProfile(text);
|
|
219
|
+
if (!parsed.ok) {
|
|
220
|
+
refuse("profile_invalid", `${file} is not a valid profile${stage === "before" ? " before probing" : " now; it was not changed"}: ${parsed.message}`, stage === "before" ? 2 : 1);
|
|
221
|
+
return null;
|
|
222
|
+
}
|
|
223
|
+
if (parsed.profile.view.company !== company) {
|
|
224
|
+
refuse("company_mismatch", `${file} is a profile for a different company; probes for ${company} are not stored in it`);
|
|
225
|
+
return null;
|
|
226
|
+
}
|
|
227
|
+
if (parsed.profile.declared.state === "template") {
|
|
228
|
+
refuse("profile_is_template", `${file} is a template profile, which carries no access readings; nothing was ${stage === "before" ? "probed" : "written"}`);
|
|
229
|
+
return null;
|
|
230
|
+
}
|
|
231
|
+
return { text, mode };
|
|
232
|
+
};
|
|
233
|
+
if (opts.writeProfile && !readProfile("before"))
|
|
234
|
+
return;
|
|
235
|
+
const probeDeps = deps.probeDeps ? deps.probeDeps(hqRoot) : probes.defaultAccessProbeDeps(hqRoot, environment);
|
|
236
|
+
// The runner installs the interrupt cleanup around the probes that start children only.
|
|
237
|
+
const report = await probes.runAccessProbes(request, probeDeps);
|
|
238
|
+
const access = report.probes.map(probes.toAccessReading);
|
|
239
|
+
// Every reading is checked against $defs/probe before it is printed or stored.
|
|
240
|
+
const invalid = access.flatMap((reading, index) => validateEnvironmentAccessProbe(reading).map((issue) => `probe ${index}${issue.path}: ${issue.message}`));
|
|
241
|
+
if (invalid.length > 0) {
|
|
242
|
+
refuse("reading_invalid", `a probe reading does not match readings.access: ${invalid.slice(0, 5).join("; ")}`, 1);
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
let written;
|
|
246
|
+
if (opts.writeProfile) {
|
|
247
|
+
// Merge onto the profile as it is now, not as it was before probing.
|
|
248
|
+
const fresh = readProfile("write");
|
|
249
|
+
if (!fresh)
|
|
250
|
+
return;
|
|
251
|
+
const profileText = fresh.text;
|
|
252
|
+
const profileMode = fresh.mode;
|
|
253
|
+
const document = JSON.parse(profileText.charCodeAt(0) === 0xfeff ? profileText.slice(1) : profileText);
|
|
254
|
+
const replaced = new Set(access.flatMap((reading) => probes.supersededNames(reading.name)));
|
|
255
|
+
document.readings.access = [
|
|
256
|
+
...document.readings.access.filter((reading) => !replaced.has(reading.name)),
|
|
257
|
+
...access,
|
|
258
|
+
];
|
|
259
|
+
const text = `${JSON.stringify(document, null, 2)}\n`;
|
|
260
|
+
const after = parseEnvironmentProfile(text);
|
|
261
|
+
if (!after.ok) {
|
|
262
|
+
refuse("profile_invalid", `${opts.writeProfile} would not validate with these readings, so it was not changed: ${after.message}`, 1);
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
// An unpredictable name, created exclusively: a planted file or
|
|
266
|
+
// symlink at the temp path makes the write fail instead of being followed.
|
|
267
|
+
const temporary = path.join(path.dirname(opts.writeProfile), `.${path.basename(opts.writeProfile)}.probe-${randomBytes(12).toString("hex")}.tmp`);
|
|
268
|
+
try {
|
|
269
|
+
writeFileSync(temporary, text, { mode: profileMode, flag: "wx" });
|
|
270
|
+
// The mode given to writeFileSync is narrowed by the umask; set it exactly.
|
|
271
|
+
chmodSync(temporary, profileMode);
|
|
272
|
+
renameSync(temporary, opts.writeProfile);
|
|
273
|
+
}
|
|
274
|
+
catch (error) {
|
|
275
|
+
try {
|
|
276
|
+
rmSync(temporary, { force: true });
|
|
277
|
+
}
|
|
278
|
+
catch { /* nothing to clean */ }
|
|
279
|
+
refuse("write_failed", `could not write ${opts.writeProfile} (${error.code ?? "error"}); it was not changed`);
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
written = opts.writeProfile;
|
|
283
|
+
}
|
|
284
|
+
if (opts.json) {
|
|
285
|
+
deps.print(JSON.stringify({
|
|
286
|
+
ok: report.ok,
|
|
287
|
+
company: report.company,
|
|
288
|
+
observed_at: report.observed_at,
|
|
289
|
+
probes: report.probes,
|
|
290
|
+
readings: { access },
|
|
291
|
+
...(written ? { written } : {}),
|
|
292
|
+
}, null, 2));
|
|
293
|
+
}
|
|
294
|
+
else {
|
|
295
|
+
for (const entry of report.probes) {
|
|
296
|
+
const tag = entry.ok ? "PASS" : entry.result === "unknown" ? "UNKNOWN" : "FAIL";
|
|
297
|
+
deps.print(`${tag} ${entry.probe} ${entry.test} ${entry.ok ? entry.checks : entry.reason ?? entry.checks}`);
|
|
298
|
+
}
|
|
299
|
+
if (written)
|
|
300
|
+
deps.print(`stored ${access.length} readings in ${written}`);
|
|
301
|
+
}
|
|
302
|
+
deps.setExitCode(report.ok ? 0 : 1);
|
|
303
|
+
});
|
|
304
|
+
env
|
|
305
|
+
.command("match")
|
|
306
|
+
.description("First ranking of environments for one piece of work: rules R1-R9 with one reason per rejection, then scores (read-only; not a placement, the conductor engine chooses)")
|
|
307
|
+
.requiredOption("--requirements <file>", "hq-work-requirements.v1 JSON file")
|
|
308
|
+
.requiredOption("--profiles <dir>", "Directory of hq-environment-profile.v1 JSON files (every *.json in it, not recursive)")
|
|
309
|
+
.option("--now <date-time>", "Match time every reading is aged against (RFC 3339; default: the current time)")
|
|
310
|
+
.option("--json", "Print the result as JSON")
|
|
311
|
+
.action(async (opts) => {
|
|
312
|
+
const result = await runEnvMatch(opts);
|
|
313
|
+
if (!result.ok) {
|
|
314
|
+
if (opts.json)
|
|
315
|
+
deps.print(JSON.stringify({ ok: false, code: result.code, message: result.message, issues: result.issues }, null, 2));
|
|
316
|
+
else {
|
|
317
|
+
deps.printError(result.message);
|
|
318
|
+
for (const issue of result.issues)
|
|
319
|
+
deps.printError(` ${issue}`);
|
|
320
|
+
}
|
|
321
|
+
deps.setExitCode(1);
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
const read = result.profilesRead === 0
|
|
325
|
+
? `no profiles read from ${opts.profiles}`
|
|
326
|
+
: `${result.profilesRead} profile${result.profilesRead === 1 ? "" : "s"} read from ${opts.profiles}`;
|
|
327
|
+
if (opts.json) {
|
|
328
|
+
// stdout carries the library result unchanged; the count goes to stderr.
|
|
329
|
+
deps.printError(`hq env match: ${read}`);
|
|
330
|
+
deps.print(JSON.stringify(result.match, null, 2));
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
for (const line of formatMatch(result.match, read))
|
|
334
|
+
deps.print(line);
|
|
335
|
+
});
|
|
80
336
|
return env;
|
|
81
337
|
}
|
|
338
|
+
function readBounded(file) {
|
|
339
|
+
try {
|
|
340
|
+
const { size } = statSync(file);
|
|
341
|
+
if (size > ENV_VALIDATE_MAX_BYTES) {
|
|
342
|
+
return { ok: false, code: "too_large", message: `${file} is too large: ${size} bytes; hq env match reads files up to ${ENV_VALIDATE_MAX_BYTES} bytes` };
|
|
343
|
+
}
|
|
344
|
+
return { ok: true, text: readFileSync(file, "utf8") };
|
|
345
|
+
}
|
|
346
|
+
catch (error) {
|
|
347
|
+
return { ok: false, code: "unreadable", message: `cannot read ${file} (${error.code ?? "error"})` };
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* Load the requirements and every profile in the directory, then call the
|
|
352
|
+
* matcher library. All I/O for `hq env match` is here; match() itself reads
|
|
353
|
+
* nothing.
|
|
354
|
+
*/
|
|
355
|
+
export async function runEnvMatch(opts) {
|
|
356
|
+
const { parseWorkRequirements } = await import("../lib/environment/work-requirements.js");
|
|
357
|
+
const { parseEnvironmentProfile } = await import("../lib/environment/profile.js");
|
|
358
|
+
const { isRfc3339DateTime } = await import("../lib/environment/rfc3339.js");
|
|
359
|
+
const { match } = await import("../lib/placement/match.js");
|
|
360
|
+
let now = new Date();
|
|
361
|
+
if (opts.now !== undefined) {
|
|
362
|
+
if (!isRfc3339DateTime(opts.now))
|
|
363
|
+
return { ok: false, code: "invalid_now", message: "--now must be an RFC 3339 date-time", issues: [] };
|
|
364
|
+
now = new Date(opts.now);
|
|
365
|
+
}
|
|
366
|
+
const requirementsText = readBounded(opts.requirements);
|
|
367
|
+
if (!requirementsText.ok)
|
|
368
|
+
return { ...requirementsText, issues: [] };
|
|
369
|
+
const requirements = parseWorkRequirements(requirementsText.text);
|
|
370
|
+
if (!requirements.ok) {
|
|
371
|
+
return {
|
|
372
|
+
ok: false,
|
|
373
|
+
code: "invalid_requirements",
|
|
374
|
+
message: `${opts.requirements}: ${requirements.message}`,
|
|
375
|
+
issues: requirements.issues.map((issue) => `${issue.path || "/"}: ${issue.message}`),
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
let names;
|
|
379
|
+
try {
|
|
380
|
+
// Dotfiles, including macOS AppleDouble "._name.json" files, are not profiles.
|
|
381
|
+
names = readdirSync(opts.profiles).filter(isProfileFileName).sort();
|
|
382
|
+
}
|
|
383
|
+
catch (error) {
|
|
384
|
+
return { ok: false, code: "unreadable", message: `cannot read ${opts.profiles} (${error.code ?? "error"})`, issues: [] };
|
|
385
|
+
}
|
|
386
|
+
const profiles = [];
|
|
387
|
+
for (const name of names) {
|
|
388
|
+
const file = path.join(opts.profiles, name);
|
|
389
|
+
const text = readBounded(file);
|
|
390
|
+
if (!text.ok)
|
|
391
|
+
return { ...text, issues: [] };
|
|
392
|
+
const parsed = parseEnvironmentProfile(text.text);
|
|
393
|
+
if (!parsed.ok) {
|
|
394
|
+
return {
|
|
395
|
+
ok: false,
|
|
396
|
+
code: "invalid_profile",
|
|
397
|
+
message: `${file}: ${parsed.message}`,
|
|
398
|
+
issues: parsed.issues.map((issue) => `${issue.path || "/"}: ${issue.message}`),
|
|
399
|
+
};
|
|
400
|
+
}
|
|
401
|
+
profiles.push(parsed.profile);
|
|
402
|
+
}
|
|
403
|
+
return { ok: true, match: match(requirements.requirements, profiles, { now }), profilesRead: profiles.length };
|
|
404
|
+
}
|
|
405
|
+
/** A profile file: *.json, not a dotfile (which covers AppleDouble "._*" files). */
|
|
406
|
+
export function isProfileFileName(name) {
|
|
407
|
+
return name.endsWith(".json") && !name.startsWith(".");
|
|
408
|
+
}
|
|
409
|
+
function formatMatch(result, read) {
|
|
410
|
+
const lines = [
|
|
411
|
+
`${result.notice}`,
|
|
412
|
+
`work ${result.work_id} (company ${result.company}), readings aged at ${result.now}; ${read}`,
|
|
413
|
+
"",
|
|
414
|
+
result.ranked.length === 0 ? "No feasible pair." : "Ranked pairs:",
|
|
415
|
+
];
|
|
416
|
+
for (const pair of result.ranked) {
|
|
417
|
+
const login = pair.account_id === null ? `${pair.engine} (template, login injected at start)` : `${pair.engine} ${pair.account_id}`;
|
|
418
|
+
const owner = pair.owning_company === null ? "" : `, owning company ${pair.owning_company}`;
|
|
419
|
+
lines.push(` ${pair.rank}. ${pair.score.toFixed(2)} ${pair.environment_id} ${login}${owner}, room ${pair.room.basis}`);
|
|
420
|
+
}
|
|
421
|
+
if (result.rejected.length > 0) {
|
|
422
|
+
lines.push("", "Rejected:");
|
|
423
|
+
for (const entry of result.rejected) {
|
|
424
|
+
const subject = entry.subject === "environment"
|
|
425
|
+
? entry.environment_id
|
|
426
|
+
: `${entry.environment_id} ${entry.engine} ${entry.account_id ?? `(held by ${entry.holder})`}`;
|
|
427
|
+
lines.push(` ${subject}: ${entry.reason.rule} ${entry.reason.field}: ${entry.reason.detail}`);
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
return lines;
|
|
431
|
+
}
|
|
82
432
|
//# sourceMappingURL=env.js.map
|
|
@@ -20,6 +20,7 @@ import type { SessionCopyResult } from "../lib/lanes/move-account.js";
|
|
|
20
20
|
import type { WorkerProfile } from "../lib/lanes/profile.js";
|
|
21
21
|
import type { OutpostHireGrantContext } from "../lib/lanes/hire-grant-dispatch.js";
|
|
22
22
|
import { LanesError } from "../lib/lanes/errors.js";
|
|
23
|
+
import type { deriveWorkRequirements } from "../lib/environment/work-requirements.js";
|
|
23
24
|
export type { LaneCompanyRef, LaneRecord } from "../lib/lanes/index.js";
|
|
24
25
|
export interface LaneAccountMove {
|
|
25
26
|
lane: LaneRecord;
|
|
@@ -343,6 +344,8 @@ export interface Ctx {
|
|
|
343
344
|
}) => Promise<boolean>;
|
|
344
345
|
/** Test seam for the default-off project focus guard flag. */
|
|
345
346
|
focusGuardEnabled?: (company?: LaneCompanyRef) => Promise<boolean>;
|
|
347
|
+
/** Test seam for the hq-work-requirements.v1 derivation run by lane create. */
|
|
348
|
+
deriveWorkRequirements?: typeof deriveWorkRequirements;
|
|
346
349
|
storyLedgerEnabled: () => boolean;
|
|
347
350
|
isSsmOwnerDispatch: () => boolean;
|
|
348
351
|
withGrantHireLocks: typeof withLaneHireLocks;
|
package/dist/commands/lanes.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export type { OutpostIdentity } from "../lib/lanes/admission-host.js";
|
|
|
12
12
|
import { type OutpostDispatchResult } from "../lib/lanes/outpost-dispatch.js";
|
|
13
13
|
import { emitLaneDecisionEvents } from "../lib/lanes/mesh-events.js";
|
|
14
14
|
import { MAX_LANE_DEPTH, withLaneAdmissionLock, withLaneHireLocks, type LaneCompanyRef, type QuestionBody, type LaneRecord, type QuestionRecord, type ResolvedLaneWorker, type SeniorRef, type LivenessDeps, type MachineIdentity, type MonitorEvidenceReader, type RunCommand, type ThrottleDeps } from "../lib/lanes/index.js";
|
|
15
|
+
import { deriveWorkRequirements } from "../lib/environment/work-requirements.js";
|
|
15
16
|
import { questionBodyAbsPath } from "../lib/lanes/questions.js";
|
|
16
17
|
import { type RunCompactionFn } from "../lib/lanes/compaction.js";
|
|
17
18
|
import { type ResolvedEffort } from "../lib/lanes/effort.js";
|
|
@@ -116,6 +117,8 @@ export interface LanesCommandDeps {
|
|
|
116
117
|
storyLedgerEnabled?: () => boolean;
|
|
117
118
|
/** Test seam for the default-off focus guard flag. */
|
|
118
119
|
focusGuardEnabled?: (company?: LaneCompanyRef) => Promise<boolean>;
|
|
120
|
+
/** Test seam for the hq-work-requirements.v1 derivation run by lane create. */
|
|
121
|
+
deriveWorkRequirements?: typeof deriveWorkRequirements;
|
|
119
122
|
/** Test seam for the SSM-only Outpost owner grant path. */
|
|
120
123
|
isSsmOwnerDispatch?: () => boolean;
|
|
121
124
|
/** Test seam for changing a lane between pre-lock and locked grant reads. */
|