@indigoai-us/hq-cli 5.345.208 → 5.345.210
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +98 -0
- package/assets/scaffold/core/scripts/derive-trigger-facts.sh +22 -3
- package/dist/command-catalog.generated.d.ts +33 -8
- package/dist/command-catalog.generated.js +40 -8
- package/dist/command-registration-plan.d.ts +2 -2
- package/dist/command-registration-plan.js +1 -1
- package/dist/commands/access.js +11 -5
- package/dist/commands/agents.d.ts +8 -0
- package/dist/commands/agents.js +5 -0
- package/dist/commands/bot.d.ts +8 -0
- package/dist/commands/bot.js +67 -7
- package/dist/commands/channels.js +4 -0
- package/dist/commands/cloud.d.ts +83 -2
- package/dist/commands/cloud.js +161 -31
- package/dist/commands/company.d.ts +9 -0
- package/dist/commands/company.js +44 -14
- package/dist/commands/core-checkpoint-native.js +21 -0
- package/dist/commands/core-derive-trigger-facts-native.js +14 -3
- package/dist/commands/core-generate-workers-registry-fast.d.ts +1 -1
- package/dist/commands/core-generate-workers-registry-fast.js +7 -1
- package/dist/commands/core-job-run-native.d.ts +8 -0
- package/dist/commands/core-job-run-native.js +11 -3
- package/dist/commands/core-jobs-native.js +1 -1
- package/dist/commands/core-register-project-native.js +31 -1
- package/dist/commands/core-scan-packages-fast.d.ts +1 -1
- package/dist/commands/core-scan-packages-fast.js +8 -1
- package/dist/commands/core.js +12 -3
- package/dist/commands/dm-attach.d.ts +10 -0
- package/dist/commands/dm-attach.js +33 -5
- package/dist/commands/integrations-connect.js +47 -2
- package/dist/commands/lanes-session-start.d.ts +17 -0
- package/dist/commands/lanes-session-start.js +281 -13
- package/dist/commands/lanes-watch.js +11 -3
- package/dist/commands/lanes.d.ts +4 -0
- package/dist/commands/lanes.js +95 -22
- package/dist/commands/library.d.ts +10 -0
- package/dist/commands/library.js +30 -3
- package/dist/commands/meetings.d.ts +42 -0
- package/dist/commands/meetings.js +157 -12
- package/dist/commands/mesh.js +3 -0
- package/dist/commands/monitor.d.ts +6 -0
- package/dist/commands/monitor.js +29 -19
- package/dist/commands/onboard.js +8 -1
- package/dist/commands/sources.js +7 -3
- package/dist/index.js +9 -0
- package/dist/lanes-monitor-check-argv.d.ts +1 -1
- package/dist/lanes-monitor-check-argv.js +2 -2
- package/dist/lanes-session-start-argv.d.ts +4 -1
- package/dist/lanes-session-start-argv.js +5 -2
- package/dist/lib/bot/fleet-daemon.d.ts +101 -0
- package/dist/lib/bot/fleet-daemon.js +227 -0
- package/dist/lib/bot/fleet-local.d.ts +26 -0
- package/dist/lib/bot/fleet-local.js +51 -2
- package/dist/lib/bot/index.d.ts +1 -0
- package/dist/lib/bot/index.js +1 -0
- package/dist/lib/bot/jobs/hot-signal-sync.d.ts +4 -0
- package/dist/lib/bot/jobs/hot-signal-sync.js +8 -1
- package/dist/lib/bot/log.js +3 -1
- package/dist/lib/bot/probe.js +2 -0
- package/dist/lib/bot/run.js +28 -3
- package/dist/lib/bot/runtime-failure.d.ts +4 -2
- package/dist/lib/bot/runtime-failure.js +9 -1
- package/dist/lib/bot/status.d.ts +17 -0
- package/dist/lib/bot/status.js +53 -2
- package/dist/lib/capacity/collectors/claude-oauth.d.ts +5 -5
- package/dist/lib/capacity/collectors/claude-oauth.js +6 -6
- package/dist/lib/core-utils/native-scaffold-help.d.ts +16 -0
- package/dist/lib/core-utils/native-scaffold-help.js +26 -0
- package/dist/lib/core-utils/session-company.d.ts +25 -8
- package/dist/lib/core-utils/session-company.js +59 -17
- package/dist/lib/daemon/catalog.d.ts +25 -1
- package/dist/lib/daemon/catalog.js +29 -2
- package/dist/lib/daemon/run.d.ts +0 -1
- package/dist/lib/daemon/run.js +3 -11
- package/dist/lib/daemon/server.js +26 -7
- package/dist/lib/daemon/supervisor.js +1 -1
- package/dist/lib/daemon/tools.js +17 -1
- package/dist/lib/db/sqlite-binding.js +2 -1
- package/dist/lib/doctor/checks/bots.d.ts +2 -0
- package/dist/lib/doctor/checks/bots.js +11 -0
- package/dist/lib/doctor/checks/runtime-health.js +3 -2
- package/dist/lib/doctor/checks/work-context.js +5 -2
- package/dist/lib/hook-engine/resolve.d.ts +1 -1
- package/dist/lib/hook-engine/resolve.js +4 -1
- package/dist/lib/hot-channels/adapters/meeting-providers.d.ts +2 -0
- package/dist/lib/hot-channels/adapters/meeting-providers.js +13 -2
- package/dist/lib/lanes/index.d.ts +1 -1
- package/dist/lib/lanes/index.js +1 -1
- package/dist/lib/lanes/monitor.d.ts +14 -0
- package/dist/lib/lanes/monitor.js +51 -10
- package/dist/lib/lanes/outpost-dispatch.d.ts +3 -0
- package/dist/lib/lanes/outpost-dispatch.js +1 -0
- package/dist/lib/lanes/store.d.ts +1 -1
- package/dist/lib/lanes/store.js +2 -1
- package/dist/lib/mesh/client.js +7 -1
- package/dist/lib/mesh/live/backfill-held.d.ts +3 -0
- package/dist/lib/mesh/live/backfill-held.js +167 -7
- package/dist/lib/mesh/live/flush.d.ts +7 -0
- package/dist/lib/mesh/live/flush.js +10 -1
- package/dist/lib/monitor.d.ts +9 -0
- package/dist/lib/monitor.js +33 -7
- package/dist/lib/onboarding/orchestrator.js +269 -132
- package/dist/lib/onboarding/types.d.ts +2 -0
- package/dist/lib/scaffold-cli-floor.js +2 -1
- package/dist/lib/signals/failure-alert.js +3 -1
- package/dist/lib/work-context/organize.d.ts +6 -0
- package/dist/lib/work-context/organize.js +28 -0
- package/dist/lib/work-context/paths.d.ts +9 -0
- package/dist/lib/work-context/paths.js +15 -0
- package/dist/lib/work-context/prd-sync.js +2 -1
- package/dist/runners-alias.d.ts +54 -0
- package/dist/runners-alias.js +86 -0
- package/dist/utils/install-tree-torn.js +5 -3
- package/dist/utils/npm-install-flags.d.ts +27 -0
- package/dist/utils/npm-install-flags.js +68 -0
- package/dist/utils/package-use-lease.js +1 -1
- package/dist/utils/qmd-native-binding-error.js +2 -1
- package/dist/utils/self-update.js +2 -1
- package/dist/utils/staged-install.js +2 -1
- package/dist/utils/staged-npm-install.js +2 -1
- package/dist/utils/upload-author.d.ts +2 -1
- package/dist/utils/upload-author.js +9 -5
- package/dist/utils/version-check.js +2 -1
- package/dist/utils/version-gate.js +7 -6
- package/package.json +7 -7
- package/scripts/install-hook-engine.mjs +7 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
|
-
import { spawn } from "node:child_process";
|
|
2
|
+
import { spawn, spawnSync } from "node:child_process";
|
|
3
3
|
import os from "node:os";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import { createHash, randomUUID } from "node:crypto";
|
|
@@ -26,8 +26,8 @@ function readSessionMetaValue(text, key) {
|
|
|
26
26
|
function writeCodexSessionDefaults(root, env, payload, debug) {
|
|
27
27
|
if (env.HQ_HARNESS !== "codex")
|
|
28
28
|
return;
|
|
29
|
-
const sessionId = payload
|
|
30
|
-
if (!sessionId
|
|
29
|
+
const sessionId = validPayloadSessionId(payload);
|
|
30
|
+
if (!sessionId)
|
|
31
31
|
return;
|
|
32
32
|
let model = typeof payload.model === "string" ? payload.model : "";
|
|
33
33
|
if (/\s/.test(model))
|
|
@@ -83,15 +83,278 @@ function writeCodexSessionDefaults(root, env, payload, debug) {
|
|
|
83
83
|
debug(`hq lanes session-start: Codex metadata bootstrap failed (${kind})`);
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
|
+
const PERSONAL_SETTINGS = path.join("personal", "settings", "orchestrator.yaml");
|
|
87
|
+
const CORE_SETTINGS = path.join("core", "settings", "orchestrator.yaml");
|
|
88
|
+
/** Shell `[ -f file ]`: a regular file, following symlinks. */
|
|
89
|
+
function isRegularFile(file) {
|
|
90
|
+
try {
|
|
91
|
+
return fs.statSync(file).isFile();
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Lines inside the top-level `conduct:` map, with the block rules of hq-core's
|
|
99
|
+
* `yaml_runner` awk (core/scripts/conduct-runner-resolve.sh): the block starts
|
|
100
|
+
* after a `conduct:` line and ends at the next column-0 line that is not a
|
|
101
|
+
* comment. Blank lines and column-0 comments stay inside it.
|
|
102
|
+
*/
|
|
103
|
+
function conductBlockLines(text) {
|
|
104
|
+
const lines = [];
|
|
105
|
+
let inBlock = false;
|
|
106
|
+
for (const line of text.split("\n")) {
|
|
107
|
+
if (/^conduct:/.test(line)) {
|
|
108
|
+
inBlock = true;
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
if (inBlock && /^[^ #]/.test(line))
|
|
112
|
+
inBlock = false;
|
|
113
|
+
if (inBlock)
|
|
114
|
+
lines.push(line);
|
|
115
|
+
}
|
|
116
|
+
return lines;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* `default_enabled` from personal/settings/orchestrator.yaml when that file
|
|
120
|
+
* exists, otherwise core/settings/orchestrator.yaml. False when neither exists.
|
|
121
|
+
*/
|
|
86
122
|
function enabledFromSettings(root) {
|
|
87
|
-
const personal = path.join(root,
|
|
88
|
-
const settings = fs.existsSync(personal) ? personal : path.join(root,
|
|
123
|
+
const personal = path.join(root, PERSONAL_SETTINGS);
|
|
124
|
+
const settings = fs.existsSync(personal) ? personal : path.join(root, CORE_SETTINGS);
|
|
89
125
|
if (!fs.existsSync(settings))
|
|
90
126
|
return false;
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
127
|
+
for (const line of conductBlockLines(fs.readFileSync(settings, "utf8"))) {
|
|
128
|
+
const value = /^\s+default_enabled:\s*["']?(true|false|yes|no|on|off|1|0)["']?\s*(?:#.*)?$/i.exec(line)?.[1]?.toLowerCase();
|
|
129
|
+
if (value !== undefined)
|
|
130
|
+
return value === "true" || value === "yes" || value === "on" || value === "1";
|
|
131
|
+
}
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
134
|
+
/** Maps a `conduct.runner` value to a runner. Legacy `mixed` and `lane` read as `runner`. */
|
|
135
|
+
function normalizeConductRunner(value) {
|
|
136
|
+
switch (value?.trim().toLowerCase()) {
|
|
137
|
+
case "subagent": return "subagent";
|
|
138
|
+
case "runner":
|
|
139
|
+
case "mixed":
|
|
140
|
+
case "lane": return "runner";
|
|
141
|
+
default: return null;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* hq-core's `yaml_runner` for one file: the first ` runner:` line (exactly two
|
|
146
|
+
* spaces) inside the `conduct:` block, its first word with quotes removed.
|
|
147
|
+
* Null when the file is not a regular file or has no value. Throws when the
|
|
148
|
+
* file exists but cannot be read.
|
|
149
|
+
*/
|
|
150
|
+
function yamlRunner(file) {
|
|
151
|
+
if (!isRegularFile(file))
|
|
152
|
+
return null;
|
|
153
|
+
for (const line of conductBlockLines(fs.readFileSync(file, "utf8"))) {
|
|
154
|
+
if (!/^ {2}runner:/.test(line))
|
|
155
|
+
continue;
|
|
156
|
+
// The second field, split on runs of spaces and tabs as awk splits $2.
|
|
157
|
+
const value = (line.replace(/^[ \t]+/, "").split(/[ \t]+/)[1] ?? "").replace(/["']/g, "");
|
|
158
|
+
return value || null;
|
|
159
|
+
}
|
|
160
|
+
return null;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* `conduct.runner` with hq-core's per-key fallback: the personal file's value,
|
|
164
|
+
* then the core file's. A personal file that has other `conduct:` keys but no
|
|
165
|
+
* `runner:` still falls through to core. An unreadable file is skipped and
|
|
166
|
+
* reported, so the caller can decline to write a pin from it.
|
|
167
|
+
*/
|
|
168
|
+
function conductRunnerSetting(root) {
|
|
169
|
+
let readFailed = false;
|
|
170
|
+
for (const settings of [PERSONAL_SETTINGS, CORE_SETTINGS]) {
|
|
171
|
+
try {
|
|
172
|
+
const value = yamlRunner(path.join(root, settings));
|
|
173
|
+
if (value !== null)
|
|
174
|
+
return { value, readFailed };
|
|
175
|
+
}
|
|
176
|
+
catch {
|
|
177
|
+
readFailed = true;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
return { value: null, readFailed };
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Resolve `conduct.runner` from settings, personal then core per key. A missing
|
|
184
|
+
* file, a missing key, or an unknown value resolves to `subagent`.
|
|
185
|
+
*/
|
|
186
|
+
export function conductRunnerFromSettings(root) {
|
|
187
|
+
return normalizeConductRunner(conductRunnerSetting(root).value ?? undefined) ?? "subagent";
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* hq-core ships this resolver in the same release that teaches
|
|
191
|
+
* conduct-standing.sh the `subagent | runner` values. Older hq-core reads the
|
|
192
|
+
* `conduct_runner` pin and exits on any value other than `mixed`, `subagent` or
|
|
193
|
+
* `lane`, so its presence decides which values are safe to write.
|
|
194
|
+
*/
|
|
195
|
+
const CONDUCT_RUNNER_RESOLVER = path.join("core", "scripts", "conduct-runner-resolve.sh");
|
|
196
|
+
/** True when the installed hq-core reads `conduct_runner: subagent|runner`. */
|
|
197
|
+
export function hqCoreReadsRunnerPin(root) {
|
|
198
|
+
try {
|
|
199
|
+
return fs.statSync(path.join(root, CONDUCT_RUNNER_RESOLVER)).isFile();
|
|
200
|
+
}
|
|
201
|
+
catch {
|
|
202
|
+
return false;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
/** The values older hq-core's resolve_runner accepts, compared exactly as it does. */
|
|
206
|
+
const LEGACY_CONDUCT_RUNNER_PINS = new Set(["mixed", "subagent", "lane"]);
|
|
207
|
+
/**
|
|
208
|
+
* The value to record for older hq-core: the setting's own value when it is one
|
|
209
|
+
* that hq-core reads (so `mixed` keeps its routing), `runner` as `lane`, and
|
|
210
|
+
* nothing when the setting is missing or unknown (hq-core then applies its own
|
|
211
|
+
* default, as it did before).
|
|
212
|
+
*/
|
|
213
|
+
function legacyConductRunnerPin(settingValue) {
|
|
214
|
+
if (settingValue === null)
|
|
215
|
+
return null;
|
|
216
|
+
if (LEGACY_CONDUCT_RUNNER_PINS.has(settingValue))
|
|
217
|
+
return settingValue;
|
|
218
|
+
return normalizeConductRunner(settingValue) === "runner" ? "lane" : null;
|
|
219
|
+
}
|
|
220
|
+
/** Logged once when conduct.runner is runner and the conduct-runners skill is not installed. */
|
|
221
|
+
export const CONDUCT_RUNNERS_CORE_MISSING_LINE = "hq runners session-start: conduct.runner is runner but .claude/skills/conduct-runners/conductor-core.md is missing; using .claude/skills/conduct/conductor-core.md";
|
|
222
|
+
const CONDUCT_SKILL_DIRS = {
|
|
223
|
+
subagent: "conduct",
|
|
224
|
+
runner: "conduct-runners",
|
|
225
|
+
};
|
|
226
|
+
function conductorCorePath(root, runner) {
|
|
227
|
+
return path.join(root, ".claude", "skills", CONDUCT_SKILL_DIRS[runner], "conductor-core.md");
|
|
228
|
+
}
|
|
229
|
+
function validPayloadSessionId(payload) {
|
|
230
|
+
const sessionId = payload.session_id ?? payload.sessionId;
|
|
231
|
+
if (!sessionId || !/^[A-Za-z0-9._-]+$/.test(sessionId) || sessionId === "." || sessionId === "..")
|
|
232
|
+
return null;
|
|
233
|
+
return sessionId;
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Upper bound on one run of hq-core's conduct-runner-resolve.sh. hq-core's
|
|
237
|
+
* SessionStart hook gives the whole CLI 2 s, so the resolver gets a fraction of
|
|
238
|
+
* that: a stalled resolver costs the pin, and the inject block still prints.
|
|
239
|
+
*/
|
|
240
|
+
export const CONDUCT_RUNNER_RESOLVE_TIMEOUT_MS = 500;
|
|
241
|
+
/**
|
|
242
|
+
* Ask the installed hq-core which runner this session uses, by running its
|
|
243
|
+
* conduct-runner-resolve.sh from the HQ root. Returns null, so that no pin is
|
|
244
|
+
* written, when the resolver fails, times out, or prints anything other than
|
|
245
|
+
* `subagent` or `runner`. The resolver's stderr is never forwarded.
|
|
246
|
+
*/
|
|
247
|
+
function resolveRunnerWithHqCore(root, sessionId, env, debug) {
|
|
248
|
+
const result = spawnSync("/bin/sh", [path.join(root, CONDUCT_RUNNER_RESOLVER), "--session-id", sessionId, "--root", root], {
|
|
249
|
+
cwd: root,
|
|
250
|
+
env,
|
|
251
|
+
encoding: "utf8",
|
|
252
|
+
timeout: CONDUCT_RUNNER_RESOLVE_TIMEOUT_MS,
|
|
253
|
+
killSignal: "SIGKILL",
|
|
254
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
255
|
+
maxBuffer: 64 * 1024,
|
|
256
|
+
});
|
|
257
|
+
if (result.error || result.status !== 0) {
|
|
258
|
+
debug("hq runners session-start: conduct-runner-resolve.sh failed; no conduct_runner pin written");
|
|
259
|
+
return null;
|
|
260
|
+
}
|
|
261
|
+
const value = result.stdout.trim();
|
|
262
|
+
if (value === "subagent" || value === "runner")
|
|
263
|
+
return value;
|
|
264
|
+
debug("hq runners session-start: conduct-runner-resolve.sh printed an unknown runner; no conduct_runner pin written");
|
|
265
|
+
return null;
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Resolve the runner for this session and record it as `conduct_runner` in the
|
|
269
|
+
* session's meta.yaml. The file is only updated when it already exists; the HQ
|
|
270
|
+
* master hook creates it before this command runs.
|
|
271
|
+
*
|
|
272
|
+
* When the installed hq-core ships conduct-runner-resolve.sh, the pin is the
|
|
273
|
+
* value that script prints, so the CLI and /conduct cannot disagree. If the
|
|
274
|
+
* script fails, nothing is written. Older hq-core gets its own vocabulary from
|
|
275
|
+
* the settings reader, and a pin it already reads is left alone.
|
|
276
|
+
*/
|
|
277
|
+
function resolveSessionConductRunner(root, payload, env, debug) {
|
|
278
|
+
const setting = conductRunnerSetting(root);
|
|
279
|
+
const fromSettings = normalizeConductRunner(setting.value ?? undefined) ?? "subagent";
|
|
280
|
+
const sessionId = validPayloadSessionId(payload);
|
|
281
|
+
if (!sessionId)
|
|
282
|
+
return fromSettings;
|
|
283
|
+
const sessionDir = path.join(root, "workspace", "sessions", sessionId);
|
|
284
|
+
const metaPath = path.join(sessionDir, "meta.yaml");
|
|
285
|
+
let text;
|
|
286
|
+
try {
|
|
287
|
+
text = fs.readFileSync(metaPath, "utf8");
|
|
288
|
+
}
|
|
289
|
+
catch {
|
|
290
|
+
return fromSettings;
|
|
291
|
+
}
|
|
292
|
+
const pinned = readSessionMetaValue(text, "conduct_runner").trim();
|
|
293
|
+
let resolved = normalizeConductRunner(pinned) ?? fromSettings;
|
|
294
|
+
let target;
|
|
295
|
+
if (hqCoreReadsRunnerPin(root)) {
|
|
296
|
+
const fromCore = resolveRunnerWithHqCore(root, sessionId, env, debug);
|
|
297
|
+
if (fromCore === null)
|
|
298
|
+
return resolved;
|
|
299
|
+
resolved = fromCore;
|
|
300
|
+
target = fromCore;
|
|
301
|
+
}
|
|
302
|
+
else {
|
|
303
|
+
// Older hq-core's /conduct exits on `runner`, so never write it there.
|
|
304
|
+
if (LEGACY_CONDUCT_RUNNER_PINS.has(pinned))
|
|
305
|
+
return resolved;
|
|
306
|
+
target = normalizeConductRunner(pinned) === "runner"
|
|
307
|
+
? "lane"
|
|
308
|
+
: setting.readFailed ? null : legacyConductRunnerPin(setting.value);
|
|
309
|
+
}
|
|
310
|
+
if (target === null || pinned === target)
|
|
311
|
+
return resolved;
|
|
312
|
+
const line = `conduct_runner: ${target}\n`;
|
|
313
|
+
const matcher = /^[ \t]*conduct_runner:.*(?:\r?\n|$)/m;
|
|
314
|
+
// Other SessionStart hooks can rewrite meta.yaml at the same time (the master
|
|
315
|
+
// hook runs them in parallel), so never write back a stale copy of the file.
|
|
316
|
+
if (!matcher.test(text)) {
|
|
317
|
+
// A new key is appended in place: whatever another hook wrote stays.
|
|
318
|
+
// No O_CREAT, so a file removed since the read is not recreated.
|
|
319
|
+
let fd;
|
|
320
|
+
try {
|
|
321
|
+
fd = fs.openSync(metaPath, fs.constants.O_WRONLY | fs.constants.O_APPEND | (fs.constants.O_NOFOLLOW ?? 0));
|
|
322
|
+
fs.writeSync(fd, `${text.endsWith("\n") || !text ? "" : "\n"}${line}`);
|
|
323
|
+
}
|
|
324
|
+
catch (error) {
|
|
325
|
+
const kind = error instanceof Error ? error.name : "Error";
|
|
326
|
+
debug(`hq runners session-start: conduct_runner metadata write failed (${kind})`);
|
|
327
|
+
}
|
|
328
|
+
finally {
|
|
329
|
+
if (fd !== undefined)
|
|
330
|
+
fs.closeSync(fd);
|
|
331
|
+
}
|
|
332
|
+
return resolved;
|
|
333
|
+
}
|
|
334
|
+
// A legacy or unknown value is replaced, unless meta.yaml changed since it
|
|
335
|
+
// was read; then the other hook's change is kept and the session still runs
|
|
336
|
+
// with the resolved value.
|
|
337
|
+
const tempPath = path.join(sessionDir, `.meta-${process.pid}-${randomUUID()}.tmp`);
|
|
338
|
+
try {
|
|
339
|
+
fs.writeFileSync(tempPath, text.replace(matcher, line), { mode: 0o600 });
|
|
340
|
+
if (fs.readFileSync(metaPath, "utf8") !== text) {
|
|
341
|
+
debug("hq runners session-start: meta.yaml changed during conduct_runner update; kept the other change");
|
|
342
|
+
}
|
|
343
|
+
else {
|
|
344
|
+
fs.renameSync(tempPath, metaPath);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
catch (error) {
|
|
348
|
+
const kind = error instanceof Error ? error.name : "Error";
|
|
349
|
+
debug(`hq runners session-start: conduct_runner metadata write failed (${kind})`);
|
|
350
|
+
}
|
|
351
|
+
finally {
|
|
352
|
+
try {
|
|
353
|
+
fs.rmSync(tempPath, { force: true });
|
|
354
|
+
}
|
|
355
|
+
catch { /* best-effort temp cleanup */ }
|
|
356
|
+
}
|
|
357
|
+
return resolved;
|
|
95
358
|
}
|
|
96
359
|
function isUnattended(env) {
|
|
97
360
|
const flags = `${env.HQ_UNATTENDED ?? ""}${env.HQ_SESSION_UNATTENDED ?? ""}${env.CLAUDE_HEADLESS ?? ""}`;
|
|
@@ -379,13 +642,18 @@ export async function runLaneSessionStart(options = {}) {
|
|
|
379
642
|
return;
|
|
380
643
|
if (!forceOn && isUnattended(env))
|
|
381
644
|
return;
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
enabled = true;
|
|
645
|
+
// HQ_AUTO_CONDUCT=1 turns conduct on without reading the settings file.
|
|
646
|
+
const enabled = forceOn || enabledFromSettings(root);
|
|
385
647
|
if (!enabled)
|
|
386
648
|
return;
|
|
387
649
|
writeCodexSessionDefaults(root, env, payload, debug);
|
|
388
|
-
const
|
|
650
|
+
const runner = resolveSessionConductRunner(root, payload, env, debug);
|
|
651
|
+
let core = conductorCorePath(root, runner);
|
|
652
|
+
if (runner === "runner" && !fs.existsSync(core)) {
|
|
653
|
+
// Older hq-core has no conduct-runners skill; its default block still applies.
|
|
654
|
+
core = conductorCorePath(root, "subagent");
|
|
655
|
+
stderr.write(`${CONDUCT_RUNNERS_CORE_MISSING_LINE}\n`);
|
|
656
|
+
}
|
|
389
657
|
if (!fs.existsSync(core))
|
|
390
658
|
return;
|
|
391
659
|
const block = extractConductorBlock(fs.readFileSync(core, "utf8"));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { accountStatus, coveredLaneIds, loadLanesConfig, MAX_WATCHED_LANES, MONITOR_ENGINES, MONITOR_MAX_TIMEOUT_MS, MONITOR_UNCOVERED_EXIT_CODE, monitorReminderText, runLaneWatch, } from "../lib/lanes/index.js";
|
|
1
|
+
import { accountStatus, coveredLaneIds, expiredLaneIds, loadLanesConfig, MAX_WATCHED_LANES, MONITOR_ENGINES, MONITOR_MAX_TIMEOUT_MS, MONITOR_UNCOVERED_EXIT_CODE, monitorReminderText, runLaneWatch, } from "../lib/lanes/index.js";
|
|
2
2
|
import { LEAD_LANE_KEEP_ALIVE_FLAG } from "../lib/lanes/keep-alive.js";
|
|
3
3
|
import { resolveLaneCompany } from "../lib/lanes/lane-company.js";
|
|
4
4
|
import { readLanesRegistryFlag } from "../lib/lanes/registry-flag.js";
|
|
@@ -27,7 +27,7 @@ function monitorCallsForLaneIds(laneIds) {
|
|
|
27
27
|
calls.push({
|
|
28
28
|
command: `hq lanes watch ${chunk.join(" ")}`,
|
|
29
29
|
timeout_ms: MONITOR_MAX_TIMEOUT_MS,
|
|
30
|
-
persistent:
|
|
30
|
+
persistent: false,
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
33
|
return calls;
|
|
@@ -166,6 +166,8 @@ export function createLaneWatchHandlers(deps) {
|
|
|
166
166
|
const covered = coveredLaneIds(evidence, ctx.now());
|
|
167
167
|
const activeIds = activeLanes.map((lane) => lane.lane_id);
|
|
168
168
|
const uncovered = activeIds.filter((laneId) => !covered.has(laneId));
|
|
169
|
+
const expired = expiredLaneIds(evidence, ctx.now());
|
|
170
|
+
const expiredUncovered = uncovered.filter((laneId) => expired.has(laneId));
|
|
169
171
|
const monitorCalls = monitorCallsForLaneIds(uncovered);
|
|
170
172
|
if (opts.json) {
|
|
171
173
|
printJson({
|
|
@@ -176,6 +178,9 @@ export function createLaneWatchHandlers(deps) {
|
|
|
176
178
|
active_lane_ids: activeIds,
|
|
177
179
|
covered_lane_ids: activeIds.filter((laneId) => covered.has(laneId)),
|
|
178
180
|
uncovered_lane_ids: uncovered,
|
|
181
|
+
// Uncovered because this session's Monitor for the lane reached the
|
|
182
|
+
// 30-minute cap (or ended), so the fix is to re-arm it.
|
|
183
|
+
expired_lane_ids: expiredUncovered,
|
|
179
184
|
monitor_call: monitorCalls.length === 1 ? monitorCalls[0] : null,
|
|
180
185
|
monitor_calls: monitorCalls,
|
|
181
186
|
});
|
|
@@ -183,8 +188,11 @@ export function createLaneWatchHandlers(deps) {
|
|
|
183
188
|
else if (uncovered.length > 0) {
|
|
184
189
|
for (const laneId of uncovered)
|
|
185
190
|
console.log(`uncovered lane: ${laneId}`);
|
|
191
|
+
if (expiredUncovered.length > 0) {
|
|
192
|
+
console.log(`Monitor ended (Claude Code stops every Monitor after 30 minutes), re-arm it: ${expiredUncovered.join(" ")}`);
|
|
193
|
+
}
|
|
186
194
|
for (const monitorCall of monitorCalls) {
|
|
187
|
-
console.log(`Monitor(command=${JSON.stringify(monitorCall.command)}, timeout_ms=${monitorCall.timeout_ms}
|
|
195
|
+
console.log(`Monitor(command=${JSON.stringify(monitorCall.command)}, timeout_ms=${monitorCall.timeout_ms})`);
|
|
188
196
|
}
|
|
189
197
|
}
|
|
190
198
|
return uncovered.length > 0 ? MONITOR_UNCOVERED_EXIT_CODE : 0;
|
package/dist/commands/lanes.d.ts
CHANGED
|
@@ -189,5 +189,9 @@ export declare function applyResumeProfileAndEffort(hqRoot: string, current: Lan
|
|
|
189
189
|
}): void;
|
|
190
190
|
export declare function stopCommittedState(state: LaneRecord["state"]): "cancelled" | "killed";
|
|
191
191
|
export declare function readLaneReapStopEnabled(hqRoot: string, lane: LaneRecord, env: NodeJS.ProcessEnv): Promise<boolean>;
|
|
192
|
+
/** Group help: a runner is the detached CLI machinery behind an advanced-mode conduct lane. */
|
|
193
|
+
export declare const RUNNERS_GROUP_DESCRIPTION = "Detached CLI machinery that runs a conduct lane in advanced mode";
|
|
194
|
+
export declare function registerRunnersCommand(parent: Command, deps?: LanesCommandDeps): Command;
|
|
195
|
+
/** Compatibility export for in-process callers during the lanes transition. */
|
|
192
196
|
export declare function registerLanesCommand(parent: Command, deps?: LanesCommandDeps): Command;
|
|
193
197
|
//# sourceMappingURL=lanes.d.ts.map
|
package/dist/commands/lanes.js
CHANGED
|
@@ -111,6 +111,7 @@ import { defaultProbe, validateProfileLaneModel, validateLaneModel, } from "../l
|
|
|
111
111
|
import { readLaneClaudeCredential } from "../lib/lanes/claude-credential.js";
|
|
112
112
|
import { parseCliModel, refuseOutpostSelfTarget, resolveLaneModel, FOREGROUND_ONLY_RULE, STANDING_AUTHORIZATION, selfReviewRule, tempHomeRule, spawnLaneWorker, spawnEnvelopeRepairRequest, laneRunDir, readSpawnManifest, stopLaneProcesses, } from "../lib/lanes/spawn.js";
|
|
113
113
|
import { handOffInstallHere } from "../lib/daemon/handoff.js";
|
|
114
|
+
import { LANES_ALIAS, RUNNERS_COMMAND, shouldWriteLanesAliasDeprecation, writeLanesAliasDeprecation } from "../runners-alias.js";
|
|
114
115
|
export { spawnLaneWorker };
|
|
115
116
|
export function openPullRequestsForProject(hqRoot, metadata) {
|
|
116
117
|
const configured = metadata.repos;
|
|
@@ -251,7 +252,7 @@ const monitorLaneMessageApis = new WeakMap();
|
|
|
251
252
|
/** Build the same lane message handlers used by `hq lanes _monitor-message`, without a CLI process boundary. */
|
|
252
253
|
export function createMonitorLaneMessageApi(hqRoot, cwd, env = process.env) {
|
|
253
254
|
const program = new Command();
|
|
254
|
-
|
|
255
|
+
registerRunnersCommand(program, {
|
|
255
256
|
hqRoot: () => hqRoot,
|
|
256
257
|
cwd: () => cwd,
|
|
257
258
|
env: { ...env, HQ_ROOT: hqRoot },
|
|
@@ -1612,6 +1613,13 @@ async function loadHostCapacitySnapshots(ctx, hqRoot, config = loadLanesConfig(h
|
|
|
1612
1613
|
}
|
|
1613
1614
|
const outpostLaneListMemo = new WeakMap();
|
|
1614
1615
|
const MAX_OUTPOST_LANE_LIST_BYTES = 480 * 1024;
|
|
1616
|
+
/** Tails `hq lanes logs` retries with when an Outpost's full logs are clipped. */
|
|
1617
|
+
const REMOTE_LOGS_FALLBACK_TAILS = [200, 20];
|
|
1618
|
+
/** Whether an Outpost exec result hit the inline output limit and was clipped. */
|
|
1619
|
+
function outpostExecOutputClipped(result) {
|
|
1620
|
+
return result.truncated === true ||
|
|
1621
|
+
Buffer.byteLength(result.stdout, "utf8") >= MAX_OUTPOST_LANE_LIST_BYTES;
|
|
1622
|
+
}
|
|
1615
1623
|
function normalizedLaneListQuery(query) {
|
|
1616
1624
|
const laneIds = query.laneIds === undefined
|
|
1617
1625
|
? undefined
|
|
@@ -4922,6 +4930,27 @@ async function dispatchCreatedOutpostLane(ctx, input) {
|
|
|
4922
4930
|
if (isLanesError(err) && err.error === "outpost_delivery_unconfirmed" && err.details.outcome_unknown === true) {
|
|
4923
4931
|
throw err;
|
|
4924
4932
|
}
|
|
4933
|
+
// The pickup exec was submitted, but the wait for its result ended (a
|
|
4934
|
+
// timeout or a failed poll). The Outpost may already run the lane, so this
|
|
4935
|
+
// is an unknown outcome, not a failed dispatch. Writing `failed` here made
|
|
4936
|
+
// `hq lanes watch` report a running Outpost lane as terminal while
|
|
4937
|
+
// `hq lanes show` read it running from its owner (feedback_b929c4a8).
|
|
4938
|
+
if (isLanesError(err) &&
|
|
4939
|
+
err.error === DISPATCH_TERMINAL_REASON &&
|
|
4940
|
+
err.details.outcome_unknown === true &&
|
|
4941
|
+
typeof err.details.command_id === "string" &&
|
|
4942
|
+
err.details.command_id.trim() !== "") {
|
|
4943
|
+
const commandId = err.details.command_id.trim();
|
|
4944
|
+
const retained = retainQueuedOutpostAfterUnknownDelivery(hqRoot, lane.lane_id, outpostId, commandId);
|
|
4945
|
+
throw new LanesError("outpost_delivery_unconfirmed", `Outpost ${outpostId} did not confirm pickup for lane ${lane.lane_id} before the wait ended (${err.message}); the queued lane will be reconciled against its owner`, {
|
|
4946
|
+
outpost_id: outpostId,
|
|
4947
|
+
lane_id: lane.lane_id,
|
|
4948
|
+
command_id: commandId,
|
|
4949
|
+
done: false,
|
|
4950
|
+
outcome_unknown: true,
|
|
4951
|
+
state: retained.state,
|
|
4952
|
+
});
|
|
4953
|
+
}
|
|
4925
4954
|
if (isLanesError(err) &&
|
|
4926
4955
|
err.error === DISPATCH_TERMINAL_REASON &&
|
|
4927
4956
|
readLane(hqRoot, lane.lane_id).state === "failed") {
|
|
@@ -8708,26 +8737,49 @@ async function runLogs(ctx, laneId, opts) {
|
|
|
8708
8737
|
})) {
|
|
8709
8738
|
const outpostId = lane.host.id;
|
|
8710
8739
|
const waitMs = outpostSingleLaneWaitMs(ctx.env);
|
|
8740
|
+
// A finished lane's full streams can pass the Outpost exec output limit.
|
|
8741
|
+
// The clipped stdout is not JSON, so without a tail the read fails as
|
|
8742
|
+
// outpost_lane_logs_invalid (feedback_b929c4a8). When the caller set no
|
|
8743
|
+
// --tail, retry with smaller tails: the completion envelope is at the end.
|
|
8744
|
+
const attempts = tail === undefined
|
|
8745
|
+
? [undefined, ...REMOTE_LOGS_FALLBACK_TAILS]
|
|
8746
|
+
: [tail];
|
|
8711
8747
|
let dispatched;
|
|
8712
|
-
|
|
8713
|
-
|
|
8714
|
-
|
|
8715
|
-
|
|
8716
|
-
|
|
8717
|
-
|
|
8718
|
-
|
|
8719
|
-
|
|
8720
|
-
|
|
8721
|
-
|
|
8722
|
-
|
|
8723
|
-
|
|
8724
|
-
|
|
8725
|
-
|
|
8726
|
-
|
|
8727
|
-
|
|
8748
|
+
let appliedTail;
|
|
8749
|
+
for (const attemptTail of attempts) {
|
|
8750
|
+
let result;
|
|
8751
|
+
try {
|
|
8752
|
+
result = await ctx.dispatchOutpostExec({
|
|
8753
|
+
outpostId,
|
|
8754
|
+
command: buildOutpostLaneCommand({
|
|
8755
|
+
action: "logs",
|
|
8756
|
+
laneId,
|
|
8757
|
+
hqBinary: outpostCliOverride(ctx, outpostId),
|
|
8758
|
+
...(attemptTail === undefined ? {} : { tail: String(attemptTail) }),
|
|
8759
|
+
json: true,
|
|
8760
|
+
}),
|
|
8761
|
+
timeoutSeconds: Math.ceil(waitMs / 1000),
|
|
8762
|
+
waitMs,
|
|
8763
|
+
});
|
|
8764
|
+
}
|
|
8765
|
+
catch (error) {
|
|
8766
|
+
throw new LanesError("outpost_lane_logs_unavailable", `Could not read logs for lane ${laneId} from Outpost ${outpostId}: ${dispatchErrorMessage(error)}`, { lane_id: laneId, outpost_id: outpostId, wait_ms: waitMs, wait_env: OUTPOST_SINGLE_LANE_WAIT_ENV });
|
|
8767
|
+
}
|
|
8768
|
+
if (result.done !== true || result.status !== "Success" || result.exitCode !== 0) {
|
|
8769
|
+
throw new LanesError("outpost_lane_logs_unavailable", `Outpost ${outpostId} did not return logs for lane ${laneId}`, { lane_id: laneId, outpost_id: outpostId, status: result.status, exit_code: result.exitCode });
|
|
8770
|
+
}
|
|
8771
|
+
if (!outpostExecOutputClipped(result)) {
|
|
8772
|
+
dispatched = result;
|
|
8773
|
+
appliedTail = attemptTail;
|
|
8774
|
+
break;
|
|
8775
|
+
}
|
|
8728
8776
|
}
|
|
8729
|
-
if (dispatched
|
|
8730
|
-
throw new LanesError("
|
|
8777
|
+
if (dispatched === undefined) {
|
|
8778
|
+
throw new LanesError("outpost_lane_logs_too_large", `Logs for lane ${laneId} on Outpost ${outpostId} exceed the ${Math.floor(MAX_OUTPOST_LANE_LIST_BYTES / 1024)} KiB Outpost exec output limit; rerun with a smaller --tail`, {
|
|
8779
|
+
lane_id: laneId,
|
|
8780
|
+
outpost_id: outpostId,
|
|
8781
|
+
...(tail === undefined ? { tried_tails: REMOTE_LOGS_FALLBACK_TAILS } : { tail }),
|
|
8782
|
+
});
|
|
8731
8783
|
}
|
|
8732
8784
|
let body;
|
|
8733
8785
|
try {
|
|
@@ -8743,6 +8795,11 @@ async function runLogs(ctx, laneId, opts) {
|
|
|
8743
8795
|
!Array.isArray(body.streams)) {
|
|
8744
8796
|
throw new LanesError("outpost_lane_logs_invalid", `Outpost ${outpostId} returned a malformed logs payload for lane ${laneId}`, { lane_id: laneId, outpost_id: outpostId });
|
|
8745
8797
|
}
|
|
8798
|
+
if (tail === undefined && appliedTail !== undefined) {
|
|
8799
|
+
process.stderr.write(`hq lanes: full logs for lane ${laneId} exceed the Outpost exec output limit; showing the last ${appliedTail} lines of each stream\n`);
|
|
8800
|
+
printJson({ ...body, tail_applied: appliedTail });
|
|
8801
|
+
return;
|
|
8802
|
+
}
|
|
8746
8803
|
printJson(body);
|
|
8747
8804
|
return;
|
|
8748
8805
|
}
|
|
@@ -10297,7 +10354,9 @@ export async function readLaneReapStopEnabled(hqRoot, lane, env) {
|
|
|
10297
10354
|
defaultValue: true,
|
|
10298
10355
|
});
|
|
10299
10356
|
}
|
|
10300
|
-
|
|
10357
|
+
/** Group help: a runner is the detached CLI machinery behind an advanced-mode conduct lane. */
|
|
10358
|
+
export const RUNNERS_GROUP_DESCRIPTION = "Detached CLI machinery that runs a conduct lane in advanced mode";
|
|
10359
|
+
export function registerRunnersCommand(parent, deps = {}) {
|
|
10301
10360
|
const ctx = resolveDeps(deps);
|
|
10302
10361
|
const storyHandlers = createLaneStoryHandlers({
|
|
10303
10362
|
assertLaneRunsHereForOperatorMutation,
|
|
@@ -10495,8 +10554,18 @@ export function registerLanesCommand(parent, deps = {}) {
|
|
|
10495
10554
|
timeoutPath,
|
|
10496
10555
|
});
|
|
10497
10556
|
const lanes = parent
|
|
10498
|
-
.command(
|
|
10499
|
-
.
|
|
10557
|
+
.command(RUNNERS_COMMAND)
|
|
10558
|
+
.alias(LANES_ALIAS)
|
|
10559
|
+
.description(RUNNERS_GROUP_DESCRIPTION);
|
|
10560
|
+
// `hq lanes` is a deprecated alias: name the replacement once on stderr for
|
|
10561
|
+
// a person at a terminal. The parent hook sees the token Commander matched,
|
|
10562
|
+
// so human subcommands, help forms and the lazy route print it, and
|
|
10563
|
+
// `hq runners` prints nothing. Hook-run subcommands, `--json` and output
|
|
10564
|
+
// that is not a terminal stay silent: HQ core's hooks fail on any stderr.
|
|
10565
|
+
parent.hook("preSubcommand", (thisCommand, subCommand) => {
|
|
10566
|
+
if (subCommand === lanes && shouldWriteLanesAliasDeprecation(thisCommand.args))
|
|
10567
|
+
writeLanesAliasDeprecation();
|
|
10568
|
+
});
|
|
10500
10569
|
registerLaneSessionStartCommand(lanes);
|
|
10501
10570
|
registerLanesLinkCommand(lanes);
|
|
10502
10571
|
registerLaneChecksCommand(lanes, {
|
|
@@ -11392,4 +11461,8 @@ export function registerLanesCommand(parent, deps = {}) {
|
|
|
11392
11461
|
attachJsonNoop(lanes);
|
|
11393
11462
|
return lanes;
|
|
11394
11463
|
}
|
|
11464
|
+
/** Compatibility export for in-process callers during the lanes transition. */
|
|
11465
|
+
export function registerLanesCommand(parent, deps = {}) {
|
|
11466
|
+
return registerRunnersCommand(parent, deps);
|
|
11467
|
+
}
|
|
11395
11468
|
//# sourceMappingURL=lanes.js.map
|
|
@@ -5,6 +5,14 @@ import { type CompaniesManifestMap } from "../lib/work-context/repo-remote.js";
|
|
|
5
5
|
import { type LibraryCompany, type LibraryAddResult } from "./library-add.js";
|
|
6
6
|
/** Mirrors hq-pro's MAX_ASSET_SEARCH_TAGS / tag length bound. */
|
|
7
7
|
export declare const MAX_LIBRARY_SEARCH_TAGS = 20;
|
|
8
|
+
/** Mirrors hq-pro's CONTENT_SEARCH_LIMIT_CAP: the largest page /v1/search returns. */
|
|
9
|
+
export declare const MAX_LIBRARY_SEARCH_COUNT = 50;
|
|
10
|
+
/**
|
|
11
|
+
* `-n, --count`: a whole number of 1 or more. The offline index has no cap, so
|
|
12
|
+
* the parser does not apply the cloud's; the cloud request is capped in
|
|
13
|
+
* runLibrarySearch, which says so in the result.
|
|
14
|
+
*/
|
|
15
|
+
export declare function parseLibrarySearchCount(value: string): number;
|
|
8
16
|
export interface LibrarySearchOptions {
|
|
9
17
|
tags: string[];
|
|
10
18
|
company?: string;
|
|
@@ -23,6 +31,8 @@ export interface LibrarySearchResult {
|
|
|
23
31
|
source: "cloud" | "local";
|
|
24
32
|
/** Set on a local result: the transport code that forced the fallback. */
|
|
25
33
|
fallbackReason?: string;
|
|
34
|
+
/** Set on a cloud result when --count asked for more than one server page holds. */
|
|
35
|
+
cappedAt?: number;
|
|
26
36
|
results: LibraryAssetHit[];
|
|
27
37
|
}
|
|
28
38
|
export interface LibrarySearchDeps {
|