@indigoai-us/hq-cli 5.345.220 → 5.345.222
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 +164 -0
- package/dist/command-catalog.generated.d.ts +175 -2
- package/dist/command-catalog.generated.js +213 -2
- package/dist/commands/auth.js +6 -2
- 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-delegate-w1b.js +9 -3
- 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 +6 -0
- package/dist/commands/daemon.js +46 -8
- 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/link.d.ts +2 -0
- package/dist/commands/link.js +14 -2
- package/dist/commands/mesh.js +23 -3
- package/dist/commands/sources.js +3 -3
- package/dist/commands/sync-core.d.ts +7 -0
- package/dist/commands/sync-core.js +132 -3
- package/dist/commands/whoami.js +96 -80
- package/dist/data/command-states.json +3 -0
- 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/catalog.js +2 -0
- package/dist/lib/daemon/install.d.ts +2 -1
- package/dist/lib/daemon/install.js +9 -0
- package/dist/lib/daemon/legacy.d.ts +1 -0
- package/dist/lib/daemon/legacy.js +5 -2
- package/dist/lib/daemon/machine-check-owner.d.ts +2 -0
- package/dist/lib/daemon/machine-check-owner.js +6 -1
- package/dist/lib/daemon/machine-checks.d.ts +29 -2
- package/dist/lib/daemon/machine-checks.js +64 -13
- package/dist/lib/daemon/mesh-owner.d.ts +45 -0
- package/dist/lib/daemon/mesh-owner.js +166 -0
- package/dist/lib/daemon/native-notice-ledger.d.ts +27 -0
- package/dist/lib/daemon/native-notice-ledger.js +113 -0
- package/dist/lib/daemon/run.d.ts +15 -0
- package/dist/lib/daemon/run.js +137 -11
- package/dist/lib/daemon/selfcheck.d.ts +35 -2
- package/dist/lib/daemon/selfcheck.js +118 -9
- 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 +146 -7
- package/dist/lib/hook-engine/coverage.js +1480 -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 +362 -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/mesh/live/daemon/config.d.ts +8 -1
- package/dist/lib/mesh/live/daemon/config.js +16 -0
- package/dist/lib/mesh/live/daemon/install.d.ts +31 -2
- package/dist/lib/mesh/live/daemon/install.js +142 -1
- package/dist/lib/mesh/live/daemon/login-home.d.ts +5 -0
- package/dist/lib/mesh/live/daemon/login-home.js +27 -0
- package/dist/lib/mesh/live/daemon/unit-home.d.ts +49 -0
- package/dist/lib/mesh/live/daemon/unit-home.js +134 -0
- package/dist/lib/placement/match.d.ts +192 -0
- package/dist/lib/placement/match.js +667 -0
- package/dist/lib/registry/registry.d.ts +35 -7
- package/dist/lib/registry/registry.js +88 -13
- package/dist/lib/safe-store.d.ts +14 -0
- package/dist/lib/safe-store.js +77 -4
- package/dist/lib/scan-packages/index.js +24 -2
- 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 +49 -23
- package/dist/lib/service-manager/startup-migration.d.ts +1 -0
- package/dist/lib/service-manager/startup-migration.js +3 -0
- 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-holds.d.ts +14 -0
- package/dist/lib/sync-core/engine-holds.js +60 -0
- package/dist/lib/sync-core/engine-home.d.ts +37 -1
- package/dist/lib/sync-core/engine-home.js +119 -16
- package/dist/lib/sync-core/reconcile.js +8 -0
- 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-settings.d.ts +21 -0
- package/dist/lib/sync-core/vault-settings.js +131 -0
- package/dist/lib/sync-core/vault-uid.d.ts +2 -0
- package/dist/lib/sync-core/vault-uid.js +4 -0
- package/dist/lib/windows/install-followup.d.ts +2 -0
- package/dist/lib/windows/install-followup.js +4 -1
- 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 +5 -2
- package/dist/utils/pack-contributions.d.ts +3 -0
- package/dist/utils/pack-contributions.js +110 -23
- package/dist/utils/resident-package-preload.js +4 -0
- package/dist/utils/self-update.d.ts +3 -1
- package/dist/utils/self-update.js +56 -11
- package/dist/utils/sentry-fingerprint.js +9 -0
- package/dist/utils/update-lock.d.ts +151 -14
- package/dist/utils/update-lock.js +782 -46
- package/dist/utils/version-gate.js +12 -2
- 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
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { prepareSignalPublication, flushSignalPublications } from "../bot/jobs/signal-to-lane.js";
|
|
2
2
|
import { isRuntimeUsageLimit } from "../bot/runtime-failure.js";
|
|
3
|
+
import { createCodexRuntime, defaultSpawn, runRuntimeTurn, RuntimeError } from "../bot/runtime/index.js";
|
|
4
|
+
import { CODEX_LOCKDOWN_DISABLED_FEATURES, CODEX_LOCKDOWN_ENV_ALLOWLIST, codexLockdownEnv, codexLockdownFilesystem, codexLockdownFlags, lockdownHomes, resolveCodexLockdownTarget, } from "../signals/codex-lockdown.js";
|
|
5
|
+
import { checkRuntimeSignIn } from "../bot/runtime-sign-in-check.js";
|
|
6
|
+
import { isRuntimeSignInFailure } from "../bot/runtime-sign-in.js";
|
|
3
7
|
import { redactErrorText } from "../../utils/redact-error-text.js";
|
|
4
8
|
import { acquireSyncLock } from "./sync-lock.js";
|
|
5
9
|
import { spawn } from "node:child_process";
|
|
@@ -27,6 +31,10 @@ export class SignalsPassError extends Error {
|
|
|
27
31
|
this.name = "SignalsPassError";
|
|
28
32
|
this.code = code;
|
|
29
33
|
}
|
|
34
|
+
/** The failure class without the tool: `bad-output` for both `claude-bad-output` and `codex-bad-output`. */
|
|
35
|
+
get failure() {
|
|
36
|
+
return this.code === "claude-logged-out-codex-bot" ? "logged-out" : this.code.replace(/^(?:claude|codex)-/, "");
|
|
37
|
+
}
|
|
30
38
|
}
|
|
31
39
|
/**
|
|
32
40
|
* How to sign Claude Code in for signals. The desktop app comes first: its
|
|
@@ -37,18 +45,35 @@ export class SignalsPassError extends Error {
|
|
|
37
45
|
*/
|
|
38
46
|
export const CLAUDE_SIGN_IN_STEPS = "Open HQ, go to Settings → AI tools, and use the Claude Code button there (Connect Claude, or Install Claude if it is not installed yet). " +
|
|
39
47
|
"Or run `claude auth login` in a terminal on this computer.";
|
|
48
|
+
/** The same steps for Codex: the pane's Codex row has "Connect Codex" / "Install Codex". */
|
|
49
|
+
export const CODEX_SIGN_IN_STEPS = "Open HQ, go to Settings → AI tools, and use the Codex button there (Connect Codex, or Install Codex if it is not installed yet). " +
|
|
50
|
+
"Or run `codex login` in a terminal on this computer.";
|
|
51
|
+
/** The sign-in steps for the tool the pass runs on. */
|
|
52
|
+
export function signalsSignInSteps(runtime) {
|
|
53
|
+
return runtime === "codex" ? CODEX_SIGN_IN_STEPS : CLAUDE_SIGN_IN_STEPS;
|
|
54
|
+
}
|
|
40
55
|
/** Documents the pass could not run stay queued; said in every signed-out message. */
|
|
41
56
|
const QUEUED_DOCS_TEXT = "The documents waiting for signals stay queued and run once Claude Code is signed in.";
|
|
57
|
+
/** The command that switches one bot's signals to its own Codex. */
|
|
58
|
+
export function codexBotSignalsOptInCommand(botName) {
|
|
59
|
+
return `hq bot set ${botName} --signals-runtime bot`;
|
|
60
|
+
}
|
|
42
61
|
/**
|
|
43
|
-
* What the owner of a Codex main bot is told when this pass
|
|
44
|
-
* missing or signed out
|
|
45
|
-
*
|
|
62
|
+
* What the owner of a Codex main bot is told when this pass, on Claude Code,
|
|
63
|
+
* finds claude missing or signed out: sign Claude Code in. The DM does not
|
|
64
|
+
* offer moving signals to Codex, because whether that is possible depends on
|
|
65
|
+
* the bot (an HQ Fleet Runtime bot cannot, and a bot needs its own Codex
|
|
66
|
+
* login); `hq bot status` offers it where the bot qualifies.
|
|
46
67
|
*/
|
|
47
|
-
export const CODEX_BOT_NEEDS_CLAUDE_TEXT = "Your main bot runs on Codex, but signals from hot-channel sync
|
|
48
|
-
|
|
68
|
+
export const CODEX_BOT_NEEDS_CLAUDE_TEXT = "Your main bot runs on Codex, but signals from hot-channel sync on this computer run on Claude Code, which is not installed or not signed in here. " +
|
|
69
|
+
`To run them, sign Claude Code in: ${CLAUDE_SIGN_IN_STEPS} ` +
|
|
70
|
+
"The documents waiting for signals stay queued and run once Claude Code is signed in.";
|
|
49
71
|
/** What the owner is told when this pass finds claude signed out on any other bot. */
|
|
50
72
|
export const CLAUDE_SIGNED_OUT_TEXT = "Signals from hot-channel sync need Claude Code, which is not signed in on this computer. " +
|
|
51
73
|
`${CLAUDE_SIGN_IN_STEPS} ${QUEUED_DOCS_TEXT}`;
|
|
74
|
+
/** What the owner of a Codex bot that runs signals on Codex is told when Codex is missing or signed out. */
|
|
75
|
+
export const CODEX_SIGNED_OUT_TEXT = "Signals from hot-channel sync run on your bot's Codex, which is not installed or not signed in on this computer. " +
|
|
76
|
+
`${CODEX_SIGN_IN_STEPS} The documents waiting for signals stay queued and run once Codex is signed in.`;
|
|
52
77
|
/** Signal types the pass accepts; the same type folders existing signals use. */
|
|
53
78
|
export const SIGNAL_TYPES = [
|
|
54
79
|
"action_item",
|
|
@@ -414,6 +439,38 @@ function classifyClaudeExit(run) {
|
|
|
414
439
|
const reason = `${envelopeText}\n${run.stderr}`.trim();
|
|
415
440
|
return classifyClaudeError(`${plainStdout}\n${reason}`.trim(), `claude exited with code ${String(run.code)}`, reason);
|
|
416
441
|
}
|
|
442
|
+
/** The line the bot's spawn appends to stderr when it stopped a call for running past its budget. */
|
|
443
|
+
const TURN_TIMEOUT_MARK = /runtime turn exceeded \d+ ?ms/;
|
|
444
|
+
/**
|
|
445
|
+
* Sort a failed Codex turn (a RuntimeError from runRuntimeTurn) into a failure
|
|
446
|
+
* class. Only the error Codex reported, or stderr, is quoted; a RuntimeError
|
|
447
|
+
* whose excerpt is a tail of ordinary output never decides the class and is
|
|
448
|
+
* never quoted, because that output is built from the document.
|
|
449
|
+
*/
|
|
450
|
+
export function classifyCodexFailure(err, item, timeoutMs, elapsedMs) {
|
|
451
|
+
if (!(err instanceof RuntimeError)) {
|
|
452
|
+
return new SignalsPassError("codex-provider-error", `codex call failed${providerReason(err instanceof Error ? err.message : String(err))}`);
|
|
453
|
+
}
|
|
454
|
+
if (!err.started)
|
|
455
|
+
return new SignalsPassError("codex-logged-out", `codex could not start${providerReason(err.message)}`);
|
|
456
|
+
if (TURN_TIMEOUT_MARK.test(err.stderrFull ?? "") || (err.exitCode === null && elapsedMs >= timeoutMs)) {
|
|
457
|
+
return new SignalsPassError("codex-timeout", `codex timed out after ${timeoutMs}ms on ${item.file}`);
|
|
458
|
+
}
|
|
459
|
+
// Exit 0 with no agent message (parseOutput): nothing to parse, and the same document would do the same again.
|
|
460
|
+
if (err.exitCode === null && /^codex produced no reply/.test(err.message)) {
|
|
461
|
+
const bad = new SignalsPassError("codex-bad-output", "codex finished with no reply");
|
|
462
|
+
bad.noRetry = true;
|
|
463
|
+
return bad;
|
|
464
|
+
}
|
|
465
|
+
const reported = err.excerptIsOutputTail ? "" : err.stderrExcerpt;
|
|
466
|
+
const text = `${err.message}\n${reported}`;
|
|
467
|
+
if (isRuntimeUsageLimit(text))
|
|
468
|
+
return new SignalsPassError("codex-usage-limit", `codex is out of usage${providerReason(reported)}`);
|
|
469
|
+
if (isRuntimeSignInFailure(text) || CLAUDE_LOGGED_OUT_RE.test(reported)) {
|
|
470
|
+
return new SignalsPassError("codex-logged-out", `codex reported it is not logged in${providerReason(reported)}`);
|
|
471
|
+
}
|
|
472
|
+
return new SignalsPassError("codex-provider-error", `codex exited with code ${String(err.exitCode)}${providerReason(reported)}`);
|
|
473
|
+
}
|
|
417
474
|
/**
|
|
418
475
|
* Parse `claude -p --output-format json` output into signals. The envelope's
|
|
419
476
|
* `result` must itself be one JSON object, optionally inside a single code
|
|
@@ -437,7 +494,16 @@ export function parseClaudeSignals(stdout) {
|
|
|
437
494
|
if (typeof env.result !== "string") {
|
|
438
495
|
throw new SignalsPassError("claude-bad-output", "claude envelope has no result text");
|
|
439
496
|
}
|
|
440
|
-
|
|
497
|
+
return parseSignalsReply(env.result, "claude");
|
|
498
|
+
}
|
|
499
|
+
/**
|
|
500
|
+
* Parse the model's final reply text into signals, for either tool: one JSON
|
|
501
|
+
* object, optionally inside a single code fence; nothing is scraped out of
|
|
502
|
+
* prose. Claude's reply is its envelope's `result`; Codex's is its last agent
|
|
503
|
+
* message (`codex exec -o`). Same schema and the same per-document cap.
|
|
504
|
+
*/
|
|
505
|
+
export function parseSignalsReply(reply, runtime) {
|
|
506
|
+
let text = reply.trim();
|
|
441
507
|
const fence = /^```(?:json)?\n([\s\S]*)\n```$/.exec(text);
|
|
442
508
|
if (fence)
|
|
443
509
|
text = fence[1].trim();
|
|
@@ -450,13 +516,13 @@ export function parseClaudeSignals(stdout) {
|
|
|
450
516
|
// must be that sentence, so prose about a limit stays bad output, and the
|
|
451
517
|
// reply is not quoted because it is stdout.
|
|
452
518
|
if (text.length <= MAX_LIMIT_SENTENCE_CHARS && LIMIT_SENTENCE_REPLY.test(text) && isRuntimeUsageLimit(text)) {
|
|
453
|
-
throw new SignalsPassError(
|
|
519
|
+
throw new SignalsPassError(`${runtime}-usage-limit`, `${runtime} is out of usage: its whole reply was a limit sentence`);
|
|
454
520
|
}
|
|
455
|
-
throw new SignalsPassError(
|
|
521
|
+
throw new SignalsPassError(`${runtime}-bad-output`, `${runtime} result is not JSON`);
|
|
456
522
|
}
|
|
457
523
|
const signals = body?.signals;
|
|
458
524
|
if (!Array.isArray(signals)) {
|
|
459
|
-
throw new SignalsPassError(
|
|
525
|
+
throw new SignalsPassError(`${runtime}-bad-output`, `${runtime} result has no signals list`);
|
|
460
526
|
}
|
|
461
527
|
return signals.slice(0, MAX_SIGNALS_PER_DOC).map((raw, i) => {
|
|
462
528
|
const s = raw;
|
|
@@ -466,14 +532,59 @@ export function parseClaudeSignals(stdout) {
|
|
|
466
532
|
typeof s.title !== "string" ||
|
|
467
533
|
s.title.trim().length === 0 ||
|
|
468
534
|
typeof s.body !== "string") {
|
|
469
|
-
throw new SignalsPassError(
|
|
535
|
+
throw new SignalsPassError(`${runtime}-bad-output`, `${runtime} signal ${i} has the wrong shape`);
|
|
470
536
|
}
|
|
471
537
|
if (s.update !== undefined && (typeof s.update !== "string" || !/^[a-f0-9]{64}$/.test(s.update))) {
|
|
472
|
-
throw new SignalsPassError(
|
|
538
|
+
throw new SignalsPassError(`${runtime}-bad-output`, `${runtime} signal ${i} has an invalid update id`);
|
|
473
539
|
}
|
|
474
540
|
return { type: s.type, title: s.title.trim(), body: s.body.trim(), ...(s.update ? { update: s.update } : {}) };
|
|
475
541
|
});
|
|
476
542
|
}
|
|
543
|
+
/** The Codex permission profile a signals turn runs under. */
|
|
544
|
+
export const CODEX_SIGNALS_PROFILE = "hq_signals_pass";
|
|
545
|
+
/**
|
|
546
|
+
* The lockdown is the signals engine's shared one (signals/codex-lockdown.ts):
|
|
547
|
+
* the same disabled features and config, environment allowlist, real-binary
|
|
548
|
+
* lookup past HQ's wrappers, and install-dir grant checks as the extract step.
|
|
549
|
+
*/
|
|
550
|
+
export const CODEX_SIGNALS_DISABLED_FEATURES = CODEX_LOCKDOWN_DISABLED_FEATURES;
|
|
551
|
+
export const CODEX_SIGNALS_ENV_ALLOWLIST = CODEX_LOCKDOWN_ENV_ALLOWLIST;
|
|
552
|
+
/**
|
|
553
|
+
* argv for one Codex signals turn. The prompt and document go on stdin (`-`),
|
|
554
|
+
* which keeps a 200 KB payload off argv. `--ignore-user-config` drops
|
|
555
|
+
* config.toml (MCP servers, settings), `--ignore-rules` drops execpolicy allow
|
|
556
|
+
* rules, `--ephemeral` keeps no session, `-a never` asks no one,
|
|
557
|
+
* codexLockdownFlags turns every tool feature, web search and bundled skills
|
|
558
|
+
* off, and the permission profile (codexLockdownFilesystem) reads only the
|
|
559
|
+
* platform minimum, the codex install and the empty turn dir, writes
|
|
560
|
+
* nothing, and has no network. The reply comes back in the `-o` file.
|
|
561
|
+
*/
|
|
562
|
+
export function codexSignalsArgs(input) {
|
|
563
|
+
const profile = CODEX_SIGNALS_PROFILE;
|
|
564
|
+
return [
|
|
565
|
+
"-a",
|
|
566
|
+
"never",
|
|
567
|
+
"exec",
|
|
568
|
+
"--json",
|
|
569
|
+
"--skip-git-repo-check",
|
|
570
|
+
"--ephemeral",
|
|
571
|
+
"--ignore-user-config",
|
|
572
|
+
"--ignore-rules",
|
|
573
|
+
...codexLockdownFlags(),
|
|
574
|
+
"-C",
|
|
575
|
+
input.turnDir,
|
|
576
|
+
"-o",
|
|
577
|
+
input.outputFile,
|
|
578
|
+
"-c",
|
|
579
|
+
`default_permissions=${JSON.stringify(profile)}`,
|
|
580
|
+
"-c",
|
|
581
|
+
`permissions.${profile}.filesystem=${codexLockdownFilesystem(input.installDir, input.turnDir)}`,
|
|
582
|
+
"-c",
|
|
583
|
+
`permissions.${profile}.network.enabled=false`,
|
|
584
|
+
...(input.model ? ["-m", input.model] : []),
|
|
585
|
+
"-",
|
|
586
|
+
];
|
|
587
|
+
}
|
|
477
588
|
/** `sha256(source_ref \n type \n title)`: the same signal from the same source keeps its id. */
|
|
478
589
|
export function signalId(sourceRef, type, title) {
|
|
479
590
|
return createHash("sha256").update(`${sourceRef}\n${type}\n${title}`).digest("hex");
|
|
@@ -579,6 +690,7 @@ export function createClaudeSignalsPass(options) {
|
|
|
579
690
|
let preflight;
|
|
580
691
|
let prompt;
|
|
581
692
|
let docsSent = 0;
|
|
693
|
+
const runtimeSpawn = options.runtimeSpawn ?? defaultSpawn;
|
|
582
694
|
const codexBot = () => {
|
|
583
695
|
try {
|
|
584
696
|
return options.botRuntime?.() === "codex";
|
|
@@ -588,7 +700,94 @@ export function createClaudeSignalsPass(options) {
|
|
|
588
700
|
return false;
|
|
589
701
|
}
|
|
590
702
|
};
|
|
703
|
+
/** The tool this pass runs on, decided once per pass (see the file header). */
|
|
704
|
+
let runtimeChoice;
|
|
705
|
+
const signalsRuntime = () => {
|
|
706
|
+
if (runtimeChoice === undefined) {
|
|
707
|
+
let optedIn = false;
|
|
708
|
+
try {
|
|
709
|
+
optedIn = options.useBotRuntime?.() === true;
|
|
710
|
+
}
|
|
711
|
+
catch {
|
|
712
|
+
// An unreadable opt-in keeps today's behaviour.
|
|
713
|
+
}
|
|
714
|
+
runtimeChoice = optedIn && codexBot() ? "codex" : "claude";
|
|
715
|
+
}
|
|
716
|
+
return runtimeChoice;
|
|
717
|
+
};
|
|
718
|
+
let codexSession;
|
|
719
|
+
const codexSetup = async () => {
|
|
720
|
+
if (codexSession)
|
|
721
|
+
return codexSession;
|
|
722
|
+
let base;
|
|
723
|
+
try {
|
|
724
|
+
base = options.botRuntimeEnv?.() ?? env;
|
|
725
|
+
}
|
|
726
|
+
catch (err) {
|
|
727
|
+
throw new SignalsPassError("codex-logged-out", `codex login is not usable: ${providerReason(err instanceof Error ? err.message : String(err)).replace(/^: /, "")}`);
|
|
728
|
+
}
|
|
729
|
+
// botRuntimeEnv is signalsCodexLogin's environment (signals-runtime.ts),
|
|
730
|
+
// the one gate for which login may be used; it always sets CODEX_HOME.
|
|
731
|
+
const codexHome = base.CODEX_HOME?.trim();
|
|
732
|
+
if (!codexHome)
|
|
733
|
+
throw new SignalsPassError("codex-logged-out", "codex login is not usable: no Codex login dir was given for the bot");
|
|
734
|
+
const target = resolveCodexLockdownTarget(options.codexBin ?? "codex", {
|
|
735
|
+
envPath: base.PATH,
|
|
736
|
+
homes: lockdownHomes(base),
|
|
737
|
+
hqRoot: options.hqRoot,
|
|
738
|
+
loginDir: codexHome,
|
|
739
|
+
});
|
|
740
|
+
if (!target.ok)
|
|
741
|
+
throw new SignalsPassError("codex-logged-out", `codex could not start: ${target.error}`);
|
|
742
|
+
const tempRoot = await fs.mkdtemp(path.join(os.tmpdir(), "hq-signals-codex-home-"));
|
|
743
|
+
const home = path.join(tempRoot, "home");
|
|
744
|
+
await fs.mkdir(home, { mode: 0o700 });
|
|
745
|
+
codexSession = {
|
|
746
|
+
binary: target.binary,
|
|
747
|
+
installDir: target.installDir,
|
|
748
|
+
env: codexLockdownEnv(base, { home, codexHome }),
|
|
749
|
+
tempRoot,
|
|
750
|
+
};
|
|
751
|
+
return codexSession;
|
|
752
|
+
};
|
|
753
|
+
/** End of pass: the temp HOME goes. Never throws; the login is never touched. */
|
|
754
|
+
const codexTeardown = async () => {
|
|
755
|
+
const session = codexSession;
|
|
756
|
+
codexSession = undefined;
|
|
757
|
+
if (!session)
|
|
758
|
+
return;
|
|
759
|
+
await fs.rm(session.tempRoot, { recursive: true, force: true }).catch(() => undefined);
|
|
760
|
+
};
|
|
761
|
+
/**
|
|
762
|
+
* The bot's Codex runtime with the real binary, minus the model fallback:
|
|
763
|
+
* on a "model requires a newer version" refusal, runRuntimeTurn would run
|
|
764
|
+
* `codex --version` and `codex debug models` outside the lockdown argv and
|
|
765
|
+
* then send the turn again on other models. The exception allows one
|
|
766
|
+
* bounded turn, so a refusal is a failed call (`codex-provider-error`).
|
|
767
|
+
*/
|
|
768
|
+
const codexRuntimeFor = (session) => ({
|
|
769
|
+
...createCodexRuntime(),
|
|
770
|
+
binary: session.binary,
|
|
771
|
+
resolveBinary: undefined,
|
|
772
|
+
fallbackModelsAfterVersionMismatch: undefined,
|
|
773
|
+
});
|
|
774
|
+
/**
|
|
775
|
+
* Every codex process this pass starts gets the allowlist and nothing else:
|
|
776
|
+
* the turn runner and the sign-in check add keys of their own
|
|
777
|
+
* (HQ_NO_ENSURE_HQ_DESKTOP, TMPDIR), which are dropped here.
|
|
778
|
+
*/
|
|
779
|
+
const codexSpawn = (command, args, spawnOptions) => {
|
|
780
|
+
const allowed = {};
|
|
781
|
+
for (const key of CODEX_SIGNALS_ENV_ALLOWLIST) {
|
|
782
|
+
if (spawnOptions.env[key] !== undefined)
|
|
783
|
+
allowed[key] = spawnOptions.env[key];
|
|
784
|
+
}
|
|
785
|
+
return runtimeSpawn(command, args, { ...spawnOptions, env: allowed });
|
|
786
|
+
};
|
|
591
787
|
const tellLogin = (signedIn) => {
|
|
788
|
+
// The record is Claude Code's login; a pass on Codex has nothing to add to it.
|
|
789
|
+
if (signalsRuntime() !== "claude")
|
|
790
|
+
return;
|
|
592
791
|
try {
|
|
593
792
|
options.onClaudeLogin?.(signedIn);
|
|
594
793
|
}
|
|
@@ -597,10 +796,16 @@ export function createClaudeSignalsPass(options) {
|
|
|
597
796
|
}
|
|
598
797
|
};
|
|
599
798
|
const checkLogin = async () => {
|
|
600
|
-
await
|
|
799
|
+
await (signalsRuntime() === "codex" ? checkCodexLogin() : checkClaudeLogin());
|
|
601
800
|
tellLogin(true);
|
|
602
801
|
};
|
|
603
|
-
|
|
802
|
+
/**
|
|
803
|
+
* The Claude preflight, unchanged from before the Codex option: a hung
|
|
804
|
+
* `claude auth status` is claude-timeout at once, a CLI that cannot start or
|
|
805
|
+
* exits non-zero is signed out, `loggedIn: false` is signed out, any other
|
|
806
|
+
* exit 0 is signed in.
|
|
807
|
+
*/
|
|
808
|
+
const checkClaudeLogin = async () => {
|
|
604
809
|
const run = await runBounded(claude, ["auth", "status"], { timeoutMs: authTimeoutMs, cwd: claudeCwd, env });
|
|
605
810
|
if (run.timedOut)
|
|
606
811
|
throw new SignalsPassError("claude-timeout", "claude auth status timed out");
|
|
@@ -618,6 +823,26 @@ export function createClaudeSignalsPass(options) {
|
|
|
618
823
|
// A plain-text status with exit 0 means logged in.
|
|
619
824
|
}
|
|
620
825
|
};
|
|
826
|
+
/**
|
|
827
|
+
* The Codex preflight: the bot's own runtime sign-in check
|
|
828
|
+
* (runtime-sign-in-check.ts, `codex login status`) in the turn's own
|
|
829
|
+
* environment. Signed out, or a CLI that cannot start, stops the pass
|
|
830
|
+
* before any document is sent.
|
|
831
|
+
*/
|
|
832
|
+
const checkCodexLogin = async () => {
|
|
833
|
+
const session = await codexSetup();
|
|
834
|
+
const check = await checkRuntimeSignIn({
|
|
835
|
+
runtime: codexRuntimeFor(session),
|
|
836
|
+
env: session.env,
|
|
837
|
+
cwd: session.env.HOME ?? claudeCwd,
|
|
838
|
+
spawn: codexSpawn,
|
|
839
|
+
timeoutMs: authTimeoutMs,
|
|
840
|
+
now,
|
|
841
|
+
});
|
|
842
|
+
if (check.signedIn === false || check.couldNotStart) {
|
|
843
|
+
throw new SignalsPassError("codex-logged-out", "codex is not logged in (codex login status failed)");
|
|
844
|
+
}
|
|
845
|
+
};
|
|
621
846
|
const runWorklist = async (args) => runBounded("bash", [worklist, ...args], {
|
|
622
847
|
timeoutMs: WORKLIST_TIMEOUT_MS,
|
|
623
848
|
cwd: options.hqRoot,
|
|
@@ -708,7 +933,7 @@ export function createClaudeSignalsPass(options) {
|
|
|
708
933
|
return await extractOnce(item, input);
|
|
709
934
|
}
|
|
710
935
|
catch (err) {
|
|
711
|
-
if (!(err instanceof SignalsPassError) || err.
|
|
936
|
+
if (!(err instanceof SignalsPassError) || err.failure !== "bad-output")
|
|
712
937
|
throw err;
|
|
713
938
|
if (err.noRetry || attempt >= BAD_OUTPUT_ATTEMPTS)
|
|
714
939
|
throw err;
|
|
@@ -716,7 +941,57 @@ export function createClaudeSignalsPass(options) {
|
|
|
716
941
|
}
|
|
717
942
|
}
|
|
718
943
|
};
|
|
719
|
-
const extractOnce =
|
|
944
|
+
const extractOnce = (item, input) => signalsRuntime() === "codex" ? extractOnceCodex(item, input) : extractOnceClaude(item, input);
|
|
945
|
+
/**
|
|
946
|
+
* One Codex call through the bot runtime's turn runner, the one a Daily
|
|
947
|
+
* Brief job goes through (runRuntimeTurn), with the isolated argv of
|
|
948
|
+
* codexSignalsArgs. The reply is the last agent message.
|
|
949
|
+
*/
|
|
950
|
+
const extractOnceCodex = async (item, input) => {
|
|
951
|
+
prompt ??= fs.readFile(promptFile, "utf8");
|
|
952
|
+
const instructions = await prompt;
|
|
953
|
+
const session = await codexSetup();
|
|
954
|
+
const base = codexRuntimeFor(session);
|
|
955
|
+
const turnEnv = session.env;
|
|
956
|
+
const turnDir = await fs.mkdtemp(path.join(os.tmpdir(), "hq-signals-codex-"));
|
|
957
|
+
const stdin = `${instructions.trimEnd()}\n\n--- document ---\n${input.text}`;
|
|
958
|
+
const runtime = {
|
|
959
|
+
...base,
|
|
960
|
+
buildArgs: (turn, scratch) => codexSignalsArgs({
|
|
961
|
+
turnDir,
|
|
962
|
+
outputFile: scratch.outputFile,
|
|
963
|
+
installDir: session.installDir,
|
|
964
|
+
...(turn.model ? { model: turn.model } : {}),
|
|
965
|
+
}),
|
|
966
|
+
stdinInput: () => stdin,
|
|
967
|
+
spawnProtocol: undefined,
|
|
968
|
+
parseStreamLine: undefined,
|
|
969
|
+
};
|
|
970
|
+
const startedAt = Date.now();
|
|
971
|
+
let reply;
|
|
972
|
+
try {
|
|
973
|
+
reply = (await runRuntimeTurn(runtime, { prompt: input.text, systemPrompt: instructions, systemPromptFile: "", cwd: turnDir, autoApprove: false, env: turnEnv }, { spawnImpl: codexSpawn, timeoutMs })).text;
|
|
974
|
+
}
|
|
975
|
+
catch (err) {
|
|
976
|
+
throw classifyCodexFailure(err, item, timeoutMs, Date.now() - startedAt);
|
|
977
|
+
}
|
|
978
|
+
finally {
|
|
979
|
+
await fs.rm(turnDir, { recursive: true, force: true }).catch(() => undefined);
|
|
980
|
+
}
|
|
981
|
+
try {
|
|
982
|
+
return parseSignalsReply(reply, "codex");
|
|
983
|
+
}
|
|
984
|
+
catch (err) {
|
|
985
|
+
if (err instanceof SignalsPassError && err.failure === "bad-output") {
|
|
986
|
+
// Only sizes: the reply is model output built from the document.
|
|
987
|
+
const bad = new SignalsPassError("codex-bad-output", `${err.message} (reply ${Buffer.byteLength(reply)} bytes)`);
|
|
988
|
+
bad.noRetry = reply.trim().length === 0;
|
|
989
|
+
throw bad;
|
|
990
|
+
}
|
|
991
|
+
throw err;
|
|
992
|
+
}
|
|
993
|
+
};
|
|
994
|
+
const extractOnceClaude = async (item, input) => {
|
|
720
995
|
prompt ??= fs.readFile(promptFile, "utf8");
|
|
721
996
|
const run = await runBounded(claude, ["-p", await prompt, ...CLAUDE_ISOLATION_ARGS, "--output-format", "json", "--max-turns", "1"], {
|
|
722
997
|
timeoutMs,
|
|
@@ -805,7 +1080,7 @@ export function createClaudeSignalsPass(options) {
|
|
|
805
1080
|
let badInARow = 0;
|
|
806
1081
|
const badOutputFailure = () => badDocs === 1 && badOutput !== undefined
|
|
807
1082
|
? badOutput
|
|
808
|
-
: new SignalsPassError(
|
|
1083
|
+
: new SignalsPassError(`${signalsRuntime()}-bad-output`, `${badDocs} documents had unusable ${signalsRuntime()} replies; first: ${badOutput?.message ?? ""}`);
|
|
809
1084
|
const byChannel = new Map();
|
|
810
1085
|
// The adapter's own channel is listed even when this run landed nothing
|
|
811
1086
|
// there, so items an earlier run left over the cap still get processed.
|
|
@@ -855,7 +1130,7 @@ export function createClaudeSignalsPass(options) {
|
|
|
855
1130
|
signals = await extract(item, input);
|
|
856
1131
|
}
|
|
857
1132
|
catch (err) {
|
|
858
|
-
if (!(err instanceof SignalsPassError) || err.
|
|
1133
|
+
if (!(err instanceof SignalsPassError) || err.failure !== "bad-output")
|
|
859
1134
|
throw err;
|
|
860
1135
|
// One document's unusable reply must not hold back the documents
|
|
861
1136
|
// behind it. It stays unmarked (or pending) for a later run, and the
|
|
@@ -894,6 +1169,7 @@ export function createClaudeSignalsPass(options) {
|
|
|
894
1169
|
let err = caught;
|
|
895
1170
|
if (err instanceof SignalsPassError && err.code === "claude-logged-out") {
|
|
896
1171
|
tellLogin(false);
|
|
1172
|
+
// Still on Claude Code because the Codex bot has not opted in.
|
|
897
1173
|
if (codexBot())
|
|
898
1174
|
err = new SignalsPassError("claude-logged-out-codex-bot", CODEX_BOT_NEEDS_CLAUDE_TEXT);
|
|
899
1175
|
}
|
|
@@ -903,6 +1179,9 @@ export function createClaudeSignalsPass(options) {
|
|
|
903
1179
|
}
|
|
904
1180
|
throw err;
|
|
905
1181
|
}
|
|
1182
|
+
finally {
|
|
1183
|
+
await codexTeardown();
|
|
1184
|
+
}
|
|
906
1185
|
return progress.written;
|
|
907
1186
|
};
|
|
908
1187
|
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which bot the hot-channel signals pass takes its runtime from, and which
|
|
3
|
+
* Codex login it uses.
|
|
4
|
+
*
|
|
5
|
+
* The pass runs on Claude Code unless the Executive bot is a Codex bot whose
|
|
6
|
+
* bot.json has `signalsRuntime: "bot"` (signalsPassRuntime in bot/config.ts).
|
|
7
|
+
* Both `hq bot run` (the hot-signal-sync job) and `hq sources sync` use the
|
|
8
|
+
* Executive bot, the bot whose runtime the pass already read for its wording
|
|
9
|
+
* (defaultResolveBotRuntime) and the one the signals engine's extract step
|
|
10
|
+
* reads, so a Claude bot behaves exactly as before. bot.json is read when the
|
|
11
|
+
* pass asks, so `hq bot set <name> --signals-runtime ...` applies from the
|
|
12
|
+
* next pass without a restart.
|
|
13
|
+
*/
|
|
14
|
+
import { signalsCodexLogin, type SignalsCodexLogin } from "../signals/codex-login.js";
|
|
15
|
+
import type { ClaudeSignalsPassOptions } from "./signals-pass.js";
|
|
16
|
+
export { signalsCodexLogin, type SignalsCodexLogin } from "../signals/codex-login.js";
|
|
17
|
+
export type SignalsRuntimeOptions = Required<Pick<ClaudeSignalsPassOptions, "botRuntime" | "useBotRuntime" | "botRuntimeEnv">>;
|
|
18
|
+
/**
|
|
19
|
+
* signalsCodexLogin, plus the extract step's refusal of a login folder that
|
|
20
|
+
* holds files Codex would load as instructions (AGENTS.md,
|
|
21
|
+
* AGENTS.override.md, user skills). The one gate the pass, `hq bot status`
|
|
22
|
+
* and `hq bot set --signals-runtime` all read, including the HQ Fleet
|
|
23
|
+
* Runtime refusal.
|
|
24
|
+
*/
|
|
25
|
+
export declare function signalsPassCodexLogin(dir: string, config: Parameters<typeof signalsCodexLogin>[1], base?: NodeJS.ProcessEnv): SignalsCodexLogin;
|
|
26
|
+
/** The options for a pass that runs on the bot in `dir`. */
|
|
27
|
+
export declare function botSignalsRuntimeOptions(dir: string, base?: NodeJS.ProcessEnv): SignalsRuntimeOptions;
|
|
28
|
+
/** The options for a pass run outside a bot (`hq sources sync`): the Executive bot's. */
|
|
29
|
+
export declare function executiveSignalsRuntimeOptions(root?: string, base?: NodeJS.ProcessEnv): SignalsRuntimeOptions;
|
|
30
|
+
//# sourceMappingURL=signals-runtime.d.ts.map
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which bot the hot-channel signals pass takes its runtime from, and which
|
|
3
|
+
* Codex login it uses.
|
|
4
|
+
*
|
|
5
|
+
* The pass runs on Claude Code unless the Executive bot is a Codex bot whose
|
|
6
|
+
* bot.json has `signalsRuntime: "bot"` (signalsPassRuntime in bot/config.ts).
|
|
7
|
+
* Both `hq bot run` (the hot-signal-sync job) and `hq sources sync` use the
|
|
8
|
+
* Executive bot, the bot whose runtime the pass already read for its wording
|
|
9
|
+
* (defaultResolveBotRuntime) and the one the signals engine's extract step
|
|
10
|
+
* reads, so a Claude bot behaves exactly as before. bot.json is read when the
|
|
11
|
+
* pass asks, so `hq bot set <name> --signals-runtime ...` applies from the
|
|
12
|
+
* next pass without a restart.
|
|
13
|
+
*/
|
|
14
|
+
import { readBotConfig, signalsPassRuntime, isBotRuntimeId } from "../bot/config.js";
|
|
15
|
+
import { resolveExecutiveBot } from "../bot/executive.js";
|
|
16
|
+
import { botsRoot } from "../bot/paths.js";
|
|
17
|
+
import { signalsCodexLogin } from "../signals/codex-login.js";
|
|
18
|
+
import { codexHomeInstructions } from "../signals/steps/extract.js";
|
|
19
|
+
// The shared login rule lives in signals/codex-login.ts; re-exported for callers here.
|
|
20
|
+
export { signalsCodexLogin } from "../signals/codex-login.js";
|
|
21
|
+
/**
|
|
22
|
+
* signalsCodexLogin, plus the extract step's refusal of a login folder that
|
|
23
|
+
* holds files Codex would load as instructions (AGENTS.md,
|
|
24
|
+
* AGENTS.override.md, user skills). The one gate the pass, `hq bot status`
|
|
25
|
+
* and `hq bot set --signals-runtime` all read, including the HQ Fleet
|
|
26
|
+
* Runtime refusal.
|
|
27
|
+
*/
|
|
28
|
+
export function signalsPassCodexLogin(dir, config, base = process.env) {
|
|
29
|
+
const login = signalsCodexLogin(dir, config, base);
|
|
30
|
+
if (!login.ok)
|
|
31
|
+
return login;
|
|
32
|
+
const instructions = codexHomeInstructions(login.codexHome);
|
|
33
|
+
if (instructions.length > 0) {
|
|
34
|
+
return {
|
|
35
|
+
ok: false,
|
|
36
|
+
reason: `${config.name}'s Codex login folder holds ${instructions.join(", ")}, which Codex would load as instructions. Remove ${instructions.length === 1 ? "it" : "them"} from ${login.codexHome}`,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
return login;
|
|
40
|
+
}
|
|
41
|
+
/** The options for a pass that runs on the bot in `dir`. */
|
|
42
|
+
export function botSignalsRuntimeOptions(dir, base = process.env) {
|
|
43
|
+
return {
|
|
44
|
+
botRuntime: () => {
|
|
45
|
+
const config = readBotConfig(dir);
|
|
46
|
+
return config && isBotRuntimeId(config.runtime) ? config.runtime : null;
|
|
47
|
+
},
|
|
48
|
+
useBotRuntime: () => signalsPassRuntime(readBotConfig(dir)) === "codex",
|
|
49
|
+
// signalsCodexLogin: the bot's own Codex login, or a throw, which fails
|
|
50
|
+
// the pass signed out instead of using another login.
|
|
51
|
+
botRuntimeEnv: () => {
|
|
52
|
+
const config = readBotConfig(dir);
|
|
53
|
+
if (!config)
|
|
54
|
+
throw new Error("the bot's config is not readable");
|
|
55
|
+
const login = signalsPassCodexLogin(dir, config, base);
|
|
56
|
+
if (!login.ok)
|
|
57
|
+
throw new Error(login.reason);
|
|
58
|
+
// Only the ok variant is a login dir this pass can point CODEX_HOME at.
|
|
59
|
+
if (!("codexHome" in login))
|
|
60
|
+
throw new Error(`${config.name}'s Codex login cannot be lent to a signals turn`);
|
|
61
|
+
return login.env;
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
/** The options for a pass run outside a bot (`hq sources sync`): the Executive bot's. */
|
|
66
|
+
export function executiveSignalsRuntimeOptions(root = botsRoot(), base = process.env) {
|
|
67
|
+
const executive = () => {
|
|
68
|
+
const bot = resolveExecutiveBot({ root });
|
|
69
|
+
return bot ? botSignalsRuntimeOptions(bot.dir, base) : null;
|
|
70
|
+
};
|
|
71
|
+
return {
|
|
72
|
+
botRuntime: () => executive()?.botRuntime() ?? null,
|
|
73
|
+
useBotRuntime: () => executive()?.useBotRuntime() ?? false,
|
|
74
|
+
botRuntimeEnv: () => {
|
|
75
|
+
const options = executive();
|
|
76
|
+
if (!options)
|
|
77
|
+
throw new Error("there is no Executive bot on this computer");
|
|
78
|
+
return options.botRuntimeEnv();
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=signals-runtime.js.map
|
|
@@ -40,7 +40,7 @@ export function hookTargetFor(hqRoot, home, daemonInstalled, env = process.env,
|
|
|
40
40
|
// other event keeps the flag-off target. A failure to set up the new core
|
|
41
41
|
// is one warning, and install goes on with the flag-off target for every
|
|
42
42
|
// event.
|
|
43
|
-
const coreNext = forHost(coreNextTargetOrWarn(home, env), hqRoot, host);
|
|
43
|
+
const coreNext = forHost(coreNextTargetOrWarn(home, env), hqRoot, host, env);
|
|
44
44
|
const fallback = legacyHookTarget(hqRoot, home, daemonInstalled, env);
|
|
45
45
|
return coreNext ? { ...coreNext, fallback } : fallback;
|
|
46
46
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type AuthState } from "./accounts.js";
|
|
2
2
|
import type { ClaudeCredentialReader } from "./claude-credential.js";
|
|
3
|
+
import { type HostComputeReading } from "./host-compute.js";
|
|
3
4
|
import type { LocalHostMatch } from "./local-host-identity.js";
|
|
4
5
|
import { type QuotaState } from "./quota.js";
|
|
5
6
|
import type { LaneHost, LaneProvider, LaneRecord, LanesConfig } from "./types.js";
|
|
@@ -51,6 +52,20 @@ export interface HostCapacitySnapshot {
|
|
|
51
52
|
host_aliases?: string[];
|
|
52
53
|
sampled_at: string;
|
|
53
54
|
providers: Record<LaneProvider, HostCapacityProvider>;
|
|
55
|
+
/**
|
|
56
|
+
* CPU, memory and disk on this host (PS-004), in the shape of
|
|
57
|
+
* hq-environment-profile.v1 `readings.compute`. Absent when the producer did
|
|
58
|
+
* not sample it (older CLIs, snapshots built for placement only) or a
|
|
59
|
+
* required value could not be read. Informational: placement does not use
|
|
60
|
+
* it yet, and a stale reading is never room (see `computeHeadroom`).
|
|
61
|
+
*/
|
|
62
|
+
compute?: HostComputeReading;
|
|
63
|
+
/**
|
|
64
|
+
* Present with `compute`. true when the reading is past its ttl_seconds:
|
|
65
|
+
* false where it was sampled, re-checked against the reader's clock when a
|
|
66
|
+
* snapshot from another host is parsed.
|
|
67
|
+
*/
|
|
68
|
+
compute_stale?: boolean;
|
|
54
69
|
}
|
|
55
70
|
/** The printed form: `hq runners capacity --json` and the remote capacity probe. */
|
|
56
71
|
export type HostCapacitySnapshotWire = Omit<HostCapacitySnapshot, "host" | "host_aliases"> & {
|
|
@@ -95,9 +110,18 @@ export declare function buildHostCapacitySnapshot(input: {
|
|
|
95
110
|
now: Date;
|
|
96
111
|
quotaState?: QuotaState;
|
|
97
112
|
readClaudeCredential?: ClaudeCredentialReader;
|
|
113
|
+
/** This host's compute reading, from `readHostCompute`. */
|
|
114
|
+
compute?: HostComputeReading | null;
|
|
98
115
|
}): HostCapacitySnapshot;
|
|
99
|
-
/**
|
|
100
|
-
|
|
116
|
+
/**
|
|
117
|
+
* Reject malformed remote snapshots before they can influence host selection.
|
|
118
|
+
*
|
|
119
|
+
* A compute block that breaks the schema's rules is dropped rather than
|
|
120
|
+
* failing the snapshot: placement does not read it, so it must not make a host
|
|
121
|
+
* unavailable. A kept block is marked stale when the producer said so or when
|
|
122
|
+
* it is past its ttl at `now`.
|
|
123
|
+
*/
|
|
124
|
+
export declare function parseHostCapacitySnapshot(raw: unknown, now?: Date): HostCapacitySnapshot;
|
|
101
125
|
/**
|
|
102
126
|
* Choose the least-loaded eligible host/account from advisory snapshots. The
|
|
103
127
|
* selected host still runs the shared admission check under its own lock.
|