@indigoai-us/hq-cli 5.345.219 → 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 +170 -0
- package/dist/command-catalog.generated.d.ts +169 -3
- package/dist/command-catalog.generated.js +206 -3
- 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 +85 -0
- package/dist/commands/bot.js +245 -16
- package/dist/commands/cloud.d.ts +16 -0
- package/dist/commands/cloud.js +112 -102
- package/dist/commands/core-checkpoint-native.d.ts +13 -0
- package/dist/commands/core-checkpoint-native.js +167 -52
- package/dist/commands/core-hook-registration-plan.js +5 -4
- 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 +52 -9
- 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/integrations.js +84 -3
- 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/packs.js +23 -0
- package/dist/commands/pkg-update.d.ts +6 -0
- package/dist/commands/pkg-update.js +15 -7
- package/dist/commands/run.js +55 -45
- package/dist/commands/sources.js +4 -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 +29 -4
- 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/inflight.d.ts +9 -0
- package/dist/lib/bot/jobs/hot-signal-sync.d.ts +51 -0
- package/dist/lib/bot/jobs/hot-signal-sync.js +90 -9
- 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/run.d.ts +29 -5
- package/dist/lib/bot/run.js +203 -1
- 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/bot/signals-try-now.d.ts +76 -0
- package/dist/lib/bot/signals-try-now.js +111 -0
- package/dist/lib/capacity/collectors/claude-oauth.d.ts +22 -3
- package/dist/lib/capacity/collectors/claude-oauth.js +78 -22
- package/dist/lib/capacity/scheduler.d.ts +8 -0
- package/dist/lib/capacity/scheduler.js +5 -2
- 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 +71 -8
- package/dist/lib/daemon/runtime-notifications.d.ts +7 -0
- package/dist/lib/daemon/runtime-notifications.js +50 -0
- 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.d.ts +9 -1
- package/dist/lib/doctor/checks/fleet-hook-core.js +39 -15
- 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.d.ts +17 -5
- package/dist/lib/hook-engine/fleet-registration.js +53 -17
- 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 +10 -1
- package/dist/lib/hot-channels/alert.js +38 -8
- package/dist/lib/hot-channels/signals-claude-login.d.ts +53 -0
- package/dist/lib/hot-channels/signals-claude-login.js +96 -0
- package/dist/lib/hot-channels/signals-pass.d.ts +143 -17
- package/dist/lib/hot-channels/signals-pass.js +324 -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 +299 -25
- 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 +28 -0
- package/dist/lib/signals/engine.js +77 -0
- package/dist/lib/signals/reply.d.ts +48 -0
- package/dist/lib/signals/reply.js +94 -12
- 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/adapters.js +6 -0
- package/dist/lib/signals/steps/extract.d.ts +135 -12
- package/dist/lib/signals/steps/extract.js +416 -84
- package/dist/lib/signals/steps/types.d.ts +21 -0
- package/dist/lib/sync-core/engine-home.d.ts +41 -2
- package/dist/lib/sync-core/engine-home.js +132 -19
- package/dist/lib/sync-core/reconcile.js +1 -1
- package/dist/lib/sync-core/release-compare.d.ts +7 -0
- package/dist/lib/sync-core/release-compare.js +16 -0
- package/dist/lib/sync-core/release.d.ts +2 -1
- package/dist/lib/sync-core/release.js +2 -10
- 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/run/schema-env-overrides.d.ts +24 -0
- package/dist/run/schema-env-overrides.js +72 -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.d.ts +1 -1
- package/dist/utils/host-registration.js +6 -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 +15 -10
- package/scripts/bench-core-compare.mjs +313 -0
- package/scripts/bench-core.mjs +399 -12
- package/scripts/check-function-manifest.mjs +121 -7
- package/dist/commands/__fixtures__/access-vault.d.ts +0 -95
- package/dist/commands/__fixtures__/access-vault.js +0 -166
- package/dist/commands/__fixtures__/make-tar.d.ts +0 -38
- package/dist/commands/__fixtures__/make-tar.js +0 -102
- package/dist/commands/secrets-public-types.test-d.d.ts +0 -2
- package/dist/commands/secrets-public-types.test-d.js +0 -18
- package/dist/lib/decisions/fixtures/us001.d.ts +0 -137
- package/dist/lib/decisions/fixtures/us001.js +0 -21
- package/dist/lib/doctor/__testing__/fake-hq-tree.d.ts +0 -226
- package/dist/lib/doctor/__testing__/fake-hq-tree.js +0 -408
- package/dist/lib/doctor/__testing__/run-doctor.d.ts +0 -8
- package/dist/lib/doctor/__testing__/run-doctor.js +0 -69
- package/dist/lib/fingerprint/fixtures.d.ts +0 -19
- package/dist/lib/fingerprint/fixtures.js +0 -61
- package/dist/lib/hot-channels/adapters/__fixtures__/dummy.d.ts +0 -33
- package/dist/lib/hot-channels/adapters/__fixtures__/dummy.js +0 -53
- package/dist/lib/hot-channels/adapters/__fixtures__/meeting-providers.d.ts +0 -38
- package/dist/lib/hot-channels/adapters/__fixtures__/meeting-providers.js +0 -64
- package/dist/lib/mesh/live/daemon/mqtt-events.test-d.d.ts +0 -2
- package/dist/lib/mesh/live/daemon/mqtt-events.test-d.js +0 -10
- package/dist/lib/test-utils/isolated-flag-company-context.d.ts +0 -3
- package/dist/lib/test-utils/isolated-flag-company-context.js +0 -18
- package/scripts/hook-engine-manifest.mjs +0 -22
- package/scripts/mesh-daemon-if-stale.mjs +0 -20
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lockdown for a Codex turn that reads untrusted text (a meeting transcript,
|
|
3
|
+
* a Slack message) and must not run anything: the signals extract step, and
|
|
4
|
+
* the hot-channel signals pass once it rebases onto this module.
|
|
5
|
+
*
|
|
6
|
+
* The turn's sandbox reads only codex's platform minimum (:minimal: system
|
|
7
|
+
* paths such as /usr, /System, /etc, /Library/Preferences), the codex
|
|
8
|
+
* install and an empty temp dir, writes nothing and has no network. It
|
|
9
|
+
* inherits only PATH and LANG from the parent; HOME is an empty temp dir and
|
|
10
|
+
* CODEX_HOME is the bot's own login dir (./codex-login.ts), which the codex
|
|
11
|
+
* process itself reads and refreshes outside the sandbox. The real codex
|
|
12
|
+
* binary is found by walking PATH past HQ's provider wrappers
|
|
13
|
+
* (~/.hq/bin/codex), so the read grant can never become ~/.hq.
|
|
14
|
+
*
|
|
15
|
+
* Feature names come from `codex features list` on codex-cli 0.169.0 (the
|
|
16
|
+
* HQ desktop toolchain's codex) and were checked against 0.167.1. Both
|
|
17
|
+
* versions accept every name here; an unknown name is a hard error
|
|
18
|
+
* ("Unknown feature flag"), so a codex that dropped one refuses to start
|
|
19
|
+
* instead of running with the feature on. `codex debug prompt-input` on
|
|
20
|
+
* 0.169.0, run with these flags from an empty dir, lists no shell, file,
|
|
21
|
+
* image, browser, app, plugin, MCP, skill or web tool; codex still lists
|
|
22
|
+
* its own code-mode `exec` wrapper, `wait`, `request_user_input` and the
|
|
23
|
+
* `collaboration` sub-agent tools, which no flag or config key of that
|
|
24
|
+
* version removes. The sandbox grant below is what bounds those.
|
|
25
|
+
*/
|
|
26
|
+
import * as fs from "node:fs";
|
|
27
|
+
import * as os from "node:os";
|
|
28
|
+
import * as path from "node:path";
|
|
29
|
+
/** Every Codex feature that gives the model a tool or reaches outside the turn. */
|
|
30
|
+
export const CODEX_LOCKDOWN_DISABLED_FEATURES = [
|
|
31
|
+
"shell_tool",
|
|
32
|
+
"unified_exec",
|
|
33
|
+
"shell_snapshot",
|
|
34
|
+
"apps",
|
|
35
|
+
"plugins",
|
|
36
|
+
"remote_plugin",
|
|
37
|
+
"plugin_sharing",
|
|
38
|
+
"hooks",
|
|
39
|
+
"multi_agent",
|
|
40
|
+
"multi_agent_v2",
|
|
41
|
+
"browser_use",
|
|
42
|
+
"browser_use_external",
|
|
43
|
+
"browser_use_full_cdp_access",
|
|
44
|
+
"browser_annotation_api",
|
|
45
|
+
"in_app_browser",
|
|
46
|
+
"in_app_local_automation",
|
|
47
|
+
"computer_use",
|
|
48
|
+
"image_generation",
|
|
49
|
+
"view_image",
|
|
50
|
+
"skill_search",
|
|
51
|
+
"skill_mcp_dependency_install",
|
|
52
|
+
"tool_suggest",
|
|
53
|
+
"tool_call_mcp_elicitation",
|
|
54
|
+
"memories",
|
|
55
|
+
"sleep_tool",
|
|
56
|
+
"goals",
|
|
57
|
+
"code_mode_host",
|
|
58
|
+
"workspace_dependencies",
|
|
59
|
+
];
|
|
60
|
+
/**
|
|
61
|
+
* Config overrides (`-c`) that are not features: web search off (the value is
|
|
62
|
+
* checked; a wrong one fails config load), and codex's bundled skills off.
|
|
63
|
+
*/
|
|
64
|
+
export const CODEX_LOCKDOWN_CONFIG = ['web_search="disabled"', "skills.bundled.enabled=false"];
|
|
65
|
+
/** `--disable <feature>` for every locked feature, then the `-c` overrides. */
|
|
66
|
+
export function codexLockdownFlags() {
|
|
67
|
+
return [
|
|
68
|
+
...CODEX_LOCKDOWN_DISABLED_FEATURES.flatMap((feature) => ["--disable", feature]),
|
|
69
|
+
...CODEX_LOCKDOWN_CONFIG.flatMap((value) => ["-c", value]),
|
|
70
|
+
];
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* The only variables a locked Codex turn has. HOME is the turn's own empty
|
|
74
|
+
* temp dir; CODEX_HOME is the bot's own Codex login dir (./codex-login.ts),
|
|
75
|
+
* used in place and never copied.
|
|
76
|
+
*/
|
|
77
|
+
export const CODEX_LOCKDOWN_ENV_ALLOWLIST = ["PATH", "HOME", "CODEX_HOME", "LANG"];
|
|
78
|
+
/** The environment of a locked Codex turn: PATH and LANG from `base`, HOME and CODEX_HOME from `dirs`. */
|
|
79
|
+
export function codexLockdownEnv(base, dirs) {
|
|
80
|
+
return {
|
|
81
|
+
...(base.PATH !== undefined ? { PATH: base.PATH } : {}),
|
|
82
|
+
HOME: dirs.home,
|
|
83
|
+
CODEX_HOME: dirs.codexHome,
|
|
84
|
+
...(base.LANG !== undefined ? { LANG: base.LANG } : {}),
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
/** The account's home from the password database, which $HOME (and so os.homedir()) can hide. Undefined when it cannot be read. */
|
|
88
|
+
export function passwdHome() {
|
|
89
|
+
try {
|
|
90
|
+
const home = os.userInfo().homedir;
|
|
91
|
+
return home && home.trim() ? home : undefined;
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
return undefined;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
/** Every home a grant must stay out of: os.homedir(), $HOME and the passwd home, without duplicates. */
|
|
98
|
+
export function lockdownHomes(env = process.env, passwd = passwdHome()) {
|
|
99
|
+
return [...new Set([os.homedir(), env.HOME, passwd].filter((h) => typeof h === "string" && h.trim() !== ""))];
|
|
100
|
+
}
|
|
101
|
+
/** First line of HQ's provider wrapper scripts (src/lib/install/provider-wrappers.ts). */
|
|
102
|
+
export const HQ_PROVIDER_WRAPPER_MARKER = "# hq-anywhere provider sign-in wrapper";
|
|
103
|
+
function realpathOrNull(p) {
|
|
104
|
+
try {
|
|
105
|
+
return fs.realpathSync(p);
|
|
106
|
+
}
|
|
107
|
+
catch {
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
function isUnder(child, parent) {
|
|
112
|
+
return child === parent || child.startsWith(parent.endsWith(path.sep) ? parent : parent + path.sep);
|
|
113
|
+
}
|
|
114
|
+
/** True when the file is one of HQ's provider wrapper scripts (it names the marker in its first 256 bytes). */
|
|
115
|
+
export function isHqProviderWrapper(file) {
|
|
116
|
+
let fd;
|
|
117
|
+
try {
|
|
118
|
+
fd = fs.openSync(file, "r");
|
|
119
|
+
const buf = Buffer.alloc(256);
|
|
120
|
+
const n = fs.readSync(fd, buf, 0, buf.length, 0);
|
|
121
|
+
return buf.subarray(0, n).toString("utf8").includes(HQ_PROVIDER_WRAPPER_MARKER);
|
|
122
|
+
}
|
|
123
|
+
catch {
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
finally {
|
|
127
|
+
if (fd !== undefined)
|
|
128
|
+
fs.closeSync(fd);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
/** Every real form of each home: as given and through links. */
|
|
132
|
+
function homeForms(homes) {
|
|
133
|
+
const out = new Set();
|
|
134
|
+
for (const h of homes) {
|
|
135
|
+
if (!h)
|
|
136
|
+
continue;
|
|
137
|
+
out.add(path.resolve(h));
|
|
138
|
+
const real = realpathOrNull(h);
|
|
139
|
+
if (real)
|
|
140
|
+
out.add(real);
|
|
141
|
+
}
|
|
142
|
+
return [...out];
|
|
143
|
+
}
|
|
144
|
+
/** The real path of an executable, or null when it is HQ's wrapper, lives under ~/.hq, or is not executable. */
|
|
145
|
+
function realExecutable(candidate, homes) {
|
|
146
|
+
try {
|
|
147
|
+
fs.accessSync(candidate, fs.constants.X_OK);
|
|
148
|
+
}
|
|
149
|
+
catch {
|
|
150
|
+
return null;
|
|
151
|
+
}
|
|
152
|
+
const real = realpathOrNull(candidate);
|
|
153
|
+
if (!real)
|
|
154
|
+
return null;
|
|
155
|
+
for (const h of homeForms(homes))
|
|
156
|
+
if (isUnder(real, path.join(h, ".hq")))
|
|
157
|
+
return null;
|
|
158
|
+
if (isHqProviderWrapper(candidate) || isHqProviderWrapper(real))
|
|
159
|
+
return null;
|
|
160
|
+
return real;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* The real codex executable, as a realpath. A name is looked up on PATH and
|
|
164
|
+
* every entry that is HQ's provider wrapper, or resolves under ~/.hq, is
|
|
165
|
+
* walked past. A path is used as given, and refused when it is such a
|
|
166
|
+
* wrapper. Null when no real codex is found.
|
|
167
|
+
*/
|
|
168
|
+
export function resolveRealCodexBinary(bin, envPath, homes) {
|
|
169
|
+
if (bin.includes("/"))
|
|
170
|
+
return realExecutable(path.resolve(bin), homes);
|
|
171
|
+
for (const dir of (envPath ?? "").split(path.delimiter)) {
|
|
172
|
+
if (!dir || !path.isAbsolute(dir))
|
|
173
|
+
continue;
|
|
174
|
+
const real = realExecutable(path.join(dir, bin), homes);
|
|
175
|
+
if (real)
|
|
176
|
+
return real;
|
|
177
|
+
}
|
|
178
|
+
return null;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Why a read grant is unsafe, or null when it is safe. Unsafe: the filesystem
|
|
182
|
+
* root; a home or any parent of one; ~/.hq, anything under it or any parent
|
|
183
|
+
* of it; a home's dot dir (~/.codex, ~/.claude, ...) or anything under one,
|
|
184
|
+
* except codex's own standalone release tree (~/.codex/packages/), which
|
|
185
|
+
* holds no login; any other folder inside a home that is not an npm
|
|
186
|
+
* `@openai/codex` package root (its package.json names it), so a codex
|
|
187
|
+
* dropped into ~/Downloads never grants ~/Downloads; the codex login dir,
|
|
188
|
+
* anything inside it, or any parent of it; anything that overlaps the HQ
|
|
189
|
+
* root.
|
|
190
|
+
*/
|
|
191
|
+
export function unsafeCodexGrantReason(grant, input) {
|
|
192
|
+
const g = realpathOrNull(grant) ?? path.resolve(grant);
|
|
193
|
+
if (g === path.parse(g).root)
|
|
194
|
+
return "it is the filesystem root";
|
|
195
|
+
const hq = realpathOrNull(input.hqRoot) ?? path.resolve(input.hqRoot);
|
|
196
|
+
if (isUnder(g, hq) || isUnder(hq, g))
|
|
197
|
+
return "it overlaps the HQ root";
|
|
198
|
+
for (const h of homeForms(input.homes)) {
|
|
199
|
+
if (isUnder(h, g))
|
|
200
|
+
return "it is a home folder or contains one";
|
|
201
|
+
const hqDir = path.join(h, ".hq");
|
|
202
|
+
if (isUnder(g, hqDir) || isUnder(hqDir, g))
|
|
203
|
+
return "it is ~/.hq, inside it, or contains it";
|
|
204
|
+
if (isUnder(g, h)) {
|
|
205
|
+
const parts = path.relative(h, g).split(path.sep);
|
|
206
|
+
const standalone = parts[0] === ".codex" && parts[1] === "packages" && parts.length > 2;
|
|
207
|
+
if ((parts[0] ?? "").startsWith(".") && !standalone)
|
|
208
|
+
return `it is inside ${path.join("~", parts[0] ?? "")}`;
|
|
209
|
+
// A first-level folder (~/Downloads, ~/tools) is never a grant, package.json or not.
|
|
210
|
+
if (parts.length === 1)
|
|
211
|
+
return "it is a folder directly in a home";
|
|
212
|
+
if (!standalone && !isCodexPackageRoot(g))
|
|
213
|
+
return "it is a plain folder in a home, not a codex package";
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
if (input.loginDir) {
|
|
217
|
+
for (const d of [path.resolve(input.loginDir), realpathOrNull(input.loginDir)]) {
|
|
218
|
+
if (d && (isUnder(d, g) || isUnder(g, d)))
|
|
219
|
+
return "it is the codex login folder, inside it, or contains it";
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
return null;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* True when the folder is an npm `@openai/codex` package root: its
|
|
226
|
+
* package.json names `@openai/codex`, and it holds the native build codex
|
|
227
|
+
* ships with, `node_modules/@openai/codex-<platform>/vendor/`.
|
|
228
|
+
*/
|
|
229
|
+
function isCodexPackageRoot(dir) {
|
|
230
|
+
try {
|
|
231
|
+
const pkg = JSON.parse(fs.readFileSync(path.join(dir, "package.json"), "utf8"));
|
|
232
|
+
if (pkg.name !== "@openai/codex")
|
|
233
|
+
return false;
|
|
234
|
+
const scope = path.join(dir, "node_modules", "@openai");
|
|
235
|
+
return fs.readdirSync(scope).some((e) => e.startsWith("codex-") && fs.statSync(path.join(scope, e, "vendor"), { throwIfNoEntry: false })?.isDirectory() === true);
|
|
236
|
+
}
|
|
237
|
+
catch {
|
|
238
|
+
return false;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* The codex binary's own install dir from its realpath: the package root for
|
|
243
|
+
* an npm install (`.../@openai/codex` for `.../@openai/codex/bin/codex.js`,
|
|
244
|
+
* which holds the native binary under node_modules), else the binary's own
|
|
245
|
+
* folder, or that folder's parent when it is named `bin`.
|
|
246
|
+
*/
|
|
247
|
+
export function codexInstallDir(realBin) {
|
|
248
|
+
const own = path.dirname(realBin);
|
|
249
|
+
return path.basename(own) === "bin" ? path.dirname(own) : own;
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Resolve the real codex and its install dir, failing closed: no real codex,
|
|
253
|
+
* or an install dir that is not a safe grant, is an error and no turn runs.
|
|
254
|
+
*/
|
|
255
|
+
export function resolveCodexLockdownTarget(bin, input) {
|
|
256
|
+
const binary = resolveRealCodexBinary(bin, input.envPath, input.homes);
|
|
257
|
+
if (!binary) {
|
|
258
|
+
return { ok: false, error: `codex install could not be resolved safely: no real codex binary found for '${bin}' outside ~/.hq and HQ's provider wrappers` };
|
|
259
|
+
}
|
|
260
|
+
const installDir = codexInstallDir(binary);
|
|
261
|
+
const unsafe = unsafeCodexGrantReason(installDir, input);
|
|
262
|
+
if (unsafe)
|
|
263
|
+
return { ok: false, error: `codex install could not be resolved safely: ${installDir} cannot be granted (${unsafe})` };
|
|
264
|
+
return { ok: true, binary, installDir };
|
|
265
|
+
}
|
|
266
|
+
/** TOML inline table for a locked turn's permission profile: read the platform minimum, the install dir and the empty work dir; write nothing. */
|
|
267
|
+
export function codexLockdownFilesystem(installDir, workDir) {
|
|
268
|
+
const entries = [[":minimal", "read"], [installDir, "read"], [workDir, "read"]];
|
|
269
|
+
return `{${entries.map(([k, v]) => `${JSON.stringify(k)}=${JSON.stringify(v)}`).join(",")}}`;
|
|
270
|
+
}
|
|
271
|
+
//# sourceMappingURL=codex-lockdown.js.map
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which Codex login a signals Codex turn may use for a bot, and the
|
|
3
|
+
* environment that points Codex at it. Self-contained (no signals-pass or
|
|
4
|
+
* hot-channel imports) so every signals Codex path can share it.
|
|
5
|
+
*
|
|
6
|
+
* Policy: the turn runs with CODEX_HOME set to the bot's own Codex login
|
|
7
|
+
* dir, in place. Nothing copies the login, so nothing writes it back: Codex
|
|
8
|
+
* refreshes it under its own lock, as it does for the bot's own turns, and a
|
|
9
|
+
* refresh-token rotation can never leave a stale copy behind or race a
|
|
10
|
+
* write-back.
|
|
11
|
+
*
|
|
12
|
+
* Refused:
|
|
13
|
+
* - an HQ Fleet Runtime bot: its Codex login lives in the Fleet runtime's
|
|
14
|
+
* profile, and the Fleet helper offers only login, status and logout, with
|
|
15
|
+
* no lock-respecting way to lend it to a separate codex process;
|
|
16
|
+
* - a bot on the owner's personal login (no CODEX_HOME, or the owner's
|
|
17
|
+
* ~/.codex), which other Codex processes on this computer refresh too;
|
|
18
|
+
* - a bot with no Codex login setting, whose CODEX_HOME would come from the
|
|
19
|
+
* caller's environment rather than from the bot.
|
|
20
|
+
*/
|
|
21
|
+
import type { BotConfig } from "../bot/config.js";
|
|
22
|
+
/** The login a signals Codex turn uses for a bot, or why it has none it may use. */
|
|
23
|
+
export type SignalsCodexLogin = {
|
|
24
|
+
ok: true;
|
|
25
|
+
codexHome: string;
|
|
26
|
+
env: NodeJS.ProcessEnv;
|
|
27
|
+
} | {
|
|
28
|
+
ok: false;
|
|
29
|
+
reason: string;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* The bot's own Codex login dir (botAuthEnv: `hq bot login <name> --runtime
|
|
33
|
+
* codex`, or a capacity account), with the environment that points Codex at
|
|
34
|
+
* it, or the reason it may not be used.
|
|
35
|
+
*/
|
|
36
|
+
export declare function signalsCodexLogin(dir: string, config: Pick<BotConfig, "name" | "runtime" | "runtimeAuth" | "hqRoot" | "engine">, base?: NodeJS.ProcessEnv, ownerHome?: string): SignalsCodexLogin;
|
|
37
|
+
//# sourceMappingURL=codex-login.d.ts.map
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which Codex login a signals Codex turn may use for a bot, and the
|
|
3
|
+
* environment that points Codex at it. Self-contained (no signals-pass or
|
|
4
|
+
* hot-channel imports) so every signals Codex path can share it.
|
|
5
|
+
*
|
|
6
|
+
* Policy: the turn runs with CODEX_HOME set to the bot's own Codex login
|
|
7
|
+
* dir, in place. Nothing copies the login, so nothing writes it back: Codex
|
|
8
|
+
* refreshes it under its own lock, as it does for the bot's own turns, and a
|
|
9
|
+
* refresh-token rotation can never leave a stale copy behind or race a
|
|
10
|
+
* write-back.
|
|
11
|
+
*
|
|
12
|
+
* Refused:
|
|
13
|
+
* - an HQ Fleet Runtime bot: its Codex login lives in the Fleet runtime's
|
|
14
|
+
* profile, and the Fleet helper offers only login, status and logout, with
|
|
15
|
+
* no lock-respecting way to lend it to a separate codex process;
|
|
16
|
+
* - a bot on the owner's personal login (no CODEX_HOME, or the owner's
|
|
17
|
+
* ~/.codex), which other Codex processes on this computer refresh too;
|
|
18
|
+
* - a bot with no Codex login setting, whose CODEX_HOME would come from the
|
|
19
|
+
* caller's environment rather than from the bot.
|
|
20
|
+
*/
|
|
21
|
+
import * as fs from "node:fs";
|
|
22
|
+
import * as os from "node:os";
|
|
23
|
+
import * as path from "node:path";
|
|
24
|
+
import { botAuthEnv, botRuntimeAuth } from "../bot/runtime-auth.js";
|
|
25
|
+
import { diagnosticsEnabled } from "../diagnostics.js";
|
|
26
|
+
function realpathOr(p) {
|
|
27
|
+
try {
|
|
28
|
+
return fs.realpathSync(p);
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
return path.resolve(p);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The bot's own Codex login dir (botAuthEnv: `hq bot login <name> --runtime
|
|
36
|
+
* codex`, or a capacity account), with the environment that points Codex at
|
|
37
|
+
* it, or the reason it may not be used.
|
|
38
|
+
*/
|
|
39
|
+
export function signalsCodexLogin(dir, config, base = process.env, ownerHome = os.homedir()) {
|
|
40
|
+
if (config.runtime !== "codex")
|
|
41
|
+
return { ok: false, reason: `${config.name} does not run on Codex` };
|
|
42
|
+
if (config.engine !== undefined) {
|
|
43
|
+
return {
|
|
44
|
+
ok: false,
|
|
45
|
+
reason: `${config.name} runs on the HQ Fleet Runtime, which keeps its Codex login to itself, so signals cannot use it yet`,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
let env;
|
|
49
|
+
try {
|
|
50
|
+
env = botAuthEnv(dir, config, base);
|
|
51
|
+
}
|
|
52
|
+
catch (err) {
|
|
53
|
+
// botAuthEnv's own refusals are plain sentences that name the fix; any
|
|
54
|
+
// other error (a file or parse error) is shown as a fixed sentence, with
|
|
55
|
+
// the detail only under --verbose or HQ_DEBUG.
|
|
56
|
+
if (err instanceof Error && err.expected === true)
|
|
57
|
+
return { ok: false, reason: err.message };
|
|
58
|
+
if (diagnosticsEnabled(base))
|
|
59
|
+
process.stderr.write(`[hq signals] codex login lookup for ${config.name} failed: ${err instanceof Error ? err.message : String(err)}\n`);
|
|
60
|
+
return {
|
|
61
|
+
ok: false,
|
|
62
|
+
reason: `${config.name}'s Codex login could not be read. Sign it in again with: \`hq bot login ${config.name} --runtime codex\``,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
// A bot with no Codex login setting gets the caller's environment back,
|
|
66
|
+
// so its CODEX_HOME would be whatever the caller had, not the bot's own.
|
|
67
|
+
if (!botRuntimeAuth(config, "codex")) {
|
|
68
|
+
return {
|
|
69
|
+
ok: false,
|
|
70
|
+
reason: `${config.name} has no Codex login of its own. Give it one first: \`hq bot login ${config.name} --runtime codex\``,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
const codexHome = env.CODEX_HOME?.trim();
|
|
74
|
+
const personal = [ownerHome, base.HOME].filter((h) => !!h?.trim()).map((h) => realpathOr(path.join(h, ".codex")));
|
|
75
|
+
if (!codexHome || personal.includes(realpathOr(codexHome))) {
|
|
76
|
+
return {
|
|
77
|
+
ok: false,
|
|
78
|
+
reason: `${config.name} uses your personal Codex login. Give it its own first: \`hq bot login ${config.name} --runtime codex\``,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
return { ok: true, codexHome, env };
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=codex-login.js.map
|
|
@@ -30,6 +30,7 @@ export interface StepRecord {
|
|
|
30
30
|
itemsInByAdapter?: Record<string, number>;
|
|
31
31
|
tokenLevels?: Record<string, string>;
|
|
32
32
|
adapterSkips?: Record<string, string>;
|
|
33
|
+
adapterOutcomes?: Record<string, string>;
|
|
33
34
|
uploaded?: {
|
|
34
35
|
count: number;
|
|
35
36
|
bytes: number;
|
|
@@ -88,6 +89,21 @@ export interface RunRecord {
|
|
|
88
89
|
signalsOut: number;
|
|
89
90
|
};
|
|
90
91
|
lockTakeover?: LockTakeover;
|
|
92
|
+
/**
|
|
93
|
+
* PS-011 placement facts, set on every finished record this CLI writes.
|
|
94
|
+
* Absent on records written before PS-011. host_id is the machine's
|
|
95
|
+
* canonical host id (the id lane placement uses); engine is the runtime the
|
|
96
|
+
* extract step ran (claude, codex, grok), null when no model turn ran;
|
|
97
|
+
* account is the login that runtime used ("default" for the user's own
|
|
98
|
+
* Claude or Grok login, the CLAUDE_CONFIG_DIR folder name when set, or
|
|
99
|
+
* "custom" when that name holds @, / or a backslash,
|
|
100
|
+
* "bot:<name>" for the Executive bot's Codex login); duration_seconds is
|
|
101
|
+
* finishedAt minus startedAt.
|
|
102
|
+
*/
|
|
103
|
+
host_id?: string | null;
|
|
104
|
+
engine?: string | null;
|
|
105
|
+
account?: string | null;
|
|
106
|
+
duration_seconds?: number | null;
|
|
91
107
|
}
|
|
92
108
|
/** A company another run is holding the lock for. Nothing was started for it. */
|
|
93
109
|
export interface LockedCompany {
|
|
@@ -175,7 +191,19 @@ export interface RunSignalsOptions {
|
|
|
175
191
|
* channel. Needs `company`.
|
|
176
192
|
*/
|
|
177
193
|
redo?: readonly string[];
|
|
194
|
+
/** PS-011 placement facts. Defaults: this machine's canonical host id and the engine's login. */
|
|
195
|
+
placement?: SignalsPlacementDeps;
|
|
196
|
+
}
|
|
197
|
+
export interface SignalsPlacementDeps {
|
|
198
|
+
hostId?: () => string | null;
|
|
199
|
+
account?: (engine: string) => string | null;
|
|
178
200
|
}
|
|
201
|
+
/** The runtime the record's extract step ran, or null when no extract turn ran. */
|
|
202
|
+
export declare function signalsRunEngine(record: Pick<RunRecord, "steps">, incremental: boolean): string | null;
|
|
203
|
+
/** The login an engine's extract turn uses, named without paths or e-mail addresses. */
|
|
204
|
+
export declare function defaultSignalsAccount(engine: string, env?: NodeJS.ProcessEnv, resolveBotName?: () => string | null): string | null;
|
|
205
|
+
/** Sets host_id, engine, account and duration_seconds on a finished record (PS-011). */
|
|
206
|
+
export declare function stampRunPlacement(record: RunRecord, deps: SignalsPlacementDeps, incremental: boolean): void;
|
|
179
207
|
/** Bad input from the caller (company slug, missing company): exit 2. */
|
|
180
208
|
export declare class SignalsUsageError extends Error {
|
|
181
209
|
constructor(message: string);
|
|
@@ -23,12 +23,77 @@ import { extractStep, redoItemChannel } from "./steps/extract.js";
|
|
|
23
23
|
import { uploadStep } from "./steps/upload.js";
|
|
24
24
|
import { SIGNALS_RUN_ALERT_ADAPTER, raiseSignalsRunAlerts, resolveSignedInAlertPerson, } from "./failure-alert.js";
|
|
25
25
|
import { signalsAlertKey, signalsAlertStatePath } from "../hot-channels/alert.js";
|
|
26
|
+
import { canonicalHostIdHere } from "../lanes/run-size.js";
|
|
27
|
+
import { resolveExecutiveBot } from "../bot/executive.js";
|
|
28
|
+
import { botsRoot } from "../bot/paths.js";
|
|
26
29
|
export const SIGNALS_TRIGGERS = ["job", "chat", "manual", "brief"];
|
|
27
30
|
export const SIGNALS_STEP_CHOICES = ["garden", "extract", "adapters", "upload", "all"];
|
|
28
31
|
export const STEP_ORDER = ["garden", "adapters", "extract", "garden", "upload"];
|
|
29
32
|
export const RUN_RECORD_SCHEMA_VERSION = 2;
|
|
30
33
|
/** A failed run with a transient error is due for a retry this long after it finished. */
|
|
31
34
|
export const RETRY_DELAY_MS = 15 * 60 * 1000;
|
|
35
|
+
/** The runtime the record's extract step ran, or null when no extract turn ran. */
|
|
36
|
+
export function signalsRunEngine(record, incremental) {
|
|
37
|
+
const extract = [...record.steps].reverse().find((s) => s.name === "extract" && s.status !== "skipped");
|
|
38
|
+
if (!extract)
|
|
39
|
+
return null;
|
|
40
|
+
const runtime = extract.detail?.runtime;
|
|
41
|
+
if (typeof runtime === "string" && runtime.trim() !== "")
|
|
42
|
+
return runtime;
|
|
43
|
+
// The incremental (single growing source) extract always runs claude.
|
|
44
|
+
return incremental ? "claude" : null;
|
|
45
|
+
}
|
|
46
|
+
/** The login an engine's extract turn uses, named without paths or e-mail addresses. */
|
|
47
|
+
export function defaultSignalsAccount(engine, env = process.env, resolveBotName = () => resolveExecutiveBot({ root: botsRoot() })?.name ?? null) {
|
|
48
|
+
if (engine === "claude") {
|
|
49
|
+
const dir = env.CLAUDE_CONFIG_DIR?.trim();
|
|
50
|
+
if (!dir)
|
|
51
|
+
return "default";
|
|
52
|
+
const name = path.basename(dir);
|
|
53
|
+
// A folder named after an e-mail address, or one path.basename cannot
|
|
54
|
+
// split (a backslash path), is not a safe label to store.
|
|
55
|
+
return !name || /[@/\\]/.test(name) ? "custom" : name;
|
|
56
|
+
}
|
|
57
|
+
if (engine === "codex") {
|
|
58
|
+
try {
|
|
59
|
+
const name = resolveBotName();
|
|
60
|
+
return name ? "bot:" + name : null;
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (engine === "grok")
|
|
67
|
+
return "default";
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
/** Sets host_id, engine, account and duration_seconds on a finished record (PS-011). */
|
|
71
|
+
export function stampRunPlacement(record, deps, incremental) {
|
|
72
|
+
let hostId;
|
|
73
|
+
try {
|
|
74
|
+
hostId = (deps.hostId ?? (() => canonicalHostIdHere()))();
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
hostId = null;
|
|
78
|
+
}
|
|
79
|
+
const engine = signalsRunEngine(record, incremental);
|
|
80
|
+
let account = null;
|
|
81
|
+
if (engine) {
|
|
82
|
+
try {
|
|
83
|
+
account = (deps.account ?? ((e) => defaultSignalsAccount(e)))(engine);
|
|
84
|
+
}
|
|
85
|
+
catch {
|
|
86
|
+
account = null;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
const started = Date.parse(record.startedAt);
|
|
90
|
+
const finished = record.finishedAt === null ? NaN : Date.parse(record.finishedAt);
|
|
91
|
+
record.host_id = hostId;
|
|
92
|
+
record.engine = engine;
|
|
93
|
+
record.account = account;
|
|
94
|
+
record.duration_seconds =
|
|
95
|
+
Number.isFinite(started) && Number.isFinite(finished) ? Math.round(Math.max(0, finished - started) / 100) / 10 : null;
|
|
96
|
+
}
|
|
32
97
|
/** Bad input from the caller (company slug, missing company): exit 2. */
|
|
33
98
|
export class SignalsUsageError extends Error {
|
|
34
99
|
constructor(message) {
|
|
@@ -354,6 +419,7 @@ export async function runSignals(opts) {
|
|
|
354
419
|
}
|
|
355
420
|
return;
|
|
356
421
|
}
|
|
422
|
+
stampRunPlacement(record, opts.placement ?? {}, opts.incremental === true);
|
|
357
423
|
persist();
|
|
358
424
|
updateSummaryFile(hqRoot, date, record, record.finishedAt ?? now().toISOString());
|
|
359
425
|
};
|
|
@@ -402,6 +468,7 @@ export async function runSignals(opts) {
|
|
|
402
468
|
record.failureReason = sentence(err.message.charAt(0).toUpperCase() + err.message.slice(1));
|
|
403
469
|
record.nextRetryAt = null;
|
|
404
470
|
if (!dryRun) {
|
|
471
|
+
stampRunPlacement(record, opts.placement ?? {}, opts.incremental === true);
|
|
405
472
|
persist();
|
|
406
473
|
updateSummaryFile(hqRoot, date, record, record.finishedAt ?? now().toISOString());
|
|
407
474
|
}
|
|
@@ -433,6 +500,7 @@ export async function runSignals(opts) {
|
|
|
433
500
|
catchUp: record.catchUp,
|
|
434
501
|
maxTurns,
|
|
435
502
|
maxBudgetUsd,
|
|
503
|
+
unpricedSourceEstimateUsd: settings.unpricedSourceEstimateUsd,
|
|
436
504
|
now,
|
|
437
505
|
spawn,
|
|
438
506
|
write,
|
|
@@ -441,6 +509,13 @@ export async function runSignals(opts) {
|
|
|
441
509
|
...(opts.isFlagOn ? { isFlagOn: opts.isFlagOn } : {}),
|
|
442
510
|
...(opts.registeredAdapterIds ? { registeredAdapterIds: opts.registeredAdapterIds } : {}),
|
|
443
511
|
...(redo.length > 0 ? { redo } : {}),
|
|
512
|
+
priorSteps: record.steps.map((s) => ({
|
|
513
|
+
name: s.name,
|
|
514
|
+
status: s.status,
|
|
515
|
+
...(s.skippedReason !== undefined ? { skippedReason: s.skippedReason } : {}),
|
|
516
|
+
...(s.adapterSkips ? { adapterSkips: { ...s.adapterSkips } } : {}),
|
|
517
|
+
...(s.adapterOutcomes ? { adapterOutcomes: { ...s.adapterOutcomes } } : {}),
|
|
518
|
+
})),
|
|
444
519
|
};
|
|
445
520
|
let stepRec;
|
|
446
521
|
const planner = stepImpls[name].dryRun;
|
|
@@ -504,6 +579,8 @@ export async function runSignals(opts) {
|
|
|
504
579
|
record.nextRetryAt =
|
|
505
580
|
record.errorKind === "transient" ? new Date(new Date(record.finishedAt).getTime() + RETRY_DELAY_MS).toISOString() : null;
|
|
506
581
|
try {
|
|
582
|
+
if (!dryRun)
|
|
583
|
+
stampRunPlacement(record, opts.placement ?? {}, opts.incremental === true);
|
|
507
584
|
persist();
|
|
508
585
|
}
|
|
509
586
|
catch {
|
|
@@ -69,7 +69,55 @@ export interface RunReplyOptions {
|
|
|
69
69
|
retryScheduled?: boolean;
|
|
70
70
|
/** This run was the automatic retry; a failure says no further retry follows. */
|
|
71
71
|
wasRetry?: boolean;
|
|
72
|
+
/**
|
|
73
|
+
* The reply goes to the HQ desktop app (a local bot's owner DM), which opens
|
|
74
|
+
* `hq-desktop://brief` in place (hot-signal-sync US-023). The reply then
|
|
75
|
+
* links to today's brief instead of offering the "Create today's brief"
|
|
76
|
+
* decision. Unset (Fleet DMs, Slack, the terminal) keeps the decision and
|
|
77
|
+
* never writes an hq-desktop:// link.
|
|
78
|
+
*/
|
|
79
|
+
desktopLinks?: boolean;
|
|
80
|
+
/**
|
|
81
|
+
* This bot has a scheduled brief job (a jobs.json entry that runs
|
|
82
|
+
* /daily-brief on a schedule). hq-cli never starts the brief itself, so only
|
|
83
|
+
* then does a desktop reply say the brief builds next; otherwise it says to
|
|
84
|
+
* open the page to create it.
|
|
85
|
+
*/
|
|
86
|
+
briefJobScheduled?: boolean;
|
|
72
87
|
}
|
|
88
|
+
/** The in-app deep link the desktop app opens as the Daily Brief page (US-023). */
|
|
89
|
+
export declare const BRIEF_DEEP_LINK = "hq-desktop://brief";
|
|
90
|
+
/**
|
|
91
|
+
* The brief link line for desktop replies when a brief job is scheduled. The
|
|
92
|
+
* words after the link are the plain-text fallback for a client that shows
|
|
93
|
+
* the label without opening it.
|
|
94
|
+
*/
|
|
95
|
+
export declare const OPEN_BRIEF_LINK_LINE = "[Open today's brief](hq-desktop://brief), or find it on the Daily Brief page.";
|
|
96
|
+
/** The same line when no brief job is scheduled: the member creates the brief on that page. */
|
|
97
|
+
export declare const CREATE_BRIEF_LINK_LINE = "[Open today's brief](hq-desktop://brief) to create it, or find it on the Daily Brief page.";
|
|
98
|
+
/** Said before the link on a finished run, only when a brief job is scheduled. */
|
|
99
|
+
export declare const BRIEF_BUILDS_NEXT_LINE = "Your brief builds next.";
|
|
100
|
+
/** The retry decision's option id, and its label (the text a click sends back). */
|
|
101
|
+
export declare const TRY_NOW_OPTION_ID = "try-now";
|
|
102
|
+
export declare const TRY_NOW_LABEL = "Try now";
|
|
103
|
+
/**
|
|
104
|
+
* What a failed run means for today's brief, true on every channel: a failed
|
|
105
|
+
* signals run never blocks the Daily Brief. It does not promise that a brief
|
|
106
|
+
* runs (hq-cli never starts one, and many bots have no brief job), nor the
|
|
107
|
+
* brief's stale-signals notice (hq-core #1987, only in v16.0.48 betas so far).
|
|
108
|
+
*/
|
|
109
|
+
export declare const FAILED_RUN_BRIEF_LINE = "This does not stop your brief from building.";
|
|
110
|
+
/** The same for a finished-with-problems run, whose new signals the brief can use. */
|
|
111
|
+
export declare const PARTIAL_RUN_BRIEF_LINE = "This does not stop your brief from building with what came in.";
|
|
112
|
+
/** The open-brief decision's question when no brief job is known to be scheduled. */
|
|
113
|
+
export declare const CREATE_BRIEF_QUESTION = "Create today's brief now?";
|
|
114
|
+
/** The line a finished-with-problems reply ends with. */
|
|
115
|
+
export declare const SAY_TRY_NOW_LINE = "Say \"Try now\" to run signals again.";
|
|
116
|
+
/**
|
|
117
|
+
* True when the reply asks the member for "Try now": a decision with the
|
|
118
|
+
* try-now option (run failed), or the finished-with-problems line.
|
|
119
|
+
*/
|
|
120
|
+
export declare function replyOffersTryNow(reply: Pick<FormattedReply, "blocks">): boolean;
|
|
73
121
|
/** One fence, JSON on one line, not indented. */
|
|
74
122
|
export declare function hqBlockFence(blocks: ReplyBlock[]): string;
|
|
75
123
|
/** "6:02 AM" in the given zone. */
|