@indigoai-us/hq-cli 5.345.207 → 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 +105 -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/commands/storage-offload.d.ts +3 -2
- package/dist/commands/storage-offload.js +30 -16
- package/dist/commands/storage.js +2 -1
- 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
|
@@ -77,6 +77,10 @@ export interface UnitPlan {
|
|
|
77
77
|
drainSignal?: "SIGUSR2";
|
|
78
78
|
/** A new CLI version alone does not restart this unit; it restarts itself when idle. */
|
|
79
79
|
keepAcrossCliUpdates?: true;
|
|
80
|
+
/** Working directory for the process; the HQ folder, else the home folder, when absent. */
|
|
81
|
+
cwd?: string;
|
|
82
|
+
/** How long after SIGTERM the unit may keep running before SIGKILL; the supervisor's default when absent. */
|
|
83
|
+
stopGraceMs?: number;
|
|
80
84
|
/**
|
|
81
85
|
* Scheduled units only: before each timed run the supervisor asks
|
|
82
86
|
* `SupervisorDeps.runGuard` whether there is work. `spawn` runs as usual,
|
|
@@ -92,6 +96,26 @@ export interface SyncCoreRunning {
|
|
|
92
96
|
personal: boolean;
|
|
93
97
|
companies: ReadonlySet<string>;
|
|
94
98
|
}
|
|
99
|
+
/** An HQ Fleet bot on this machine, as the daemon sees it (see bot/fleet-daemon.ts). */
|
|
100
|
+
export interface FleetBotPlan {
|
|
101
|
+
name: string;
|
|
102
|
+
/** The gateway process, or null while the bot's HQ Fleet runtime is not fully installed. */
|
|
103
|
+
gateway: {
|
|
104
|
+
file: string;
|
|
105
|
+
args: string[];
|
|
106
|
+
env: Record<string, string>;
|
|
107
|
+
cwd: string;
|
|
108
|
+
} | null;
|
|
109
|
+
/** `hq bot auth <name>` has not run yet. */
|
|
110
|
+
authPending: boolean;
|
|
111
|
+
/** `hq bot start <name>` has not run yet. */
|
|
112
|
+
installPending: boolean;
|
|
113
|
+
/** The runtime's own LaunchAgent still exists (it could not be retired), by label. */
|
|
114
|
+
legacyAgent?: string;
|
|
115
|
+
/** A gateway for this bot started outside the daemon is still running; it has been asked to exit. */
|
|
116
|
+
outsideGateway?: number;
|
|
117
|
+
}
|
|
118
|
+
export declare const FLEET_BOT_STOP_GRACE_MS = 30000;
|
|
95
119
|
export declare const FLEET_BOTS_UPDATE_UNIT = "fleet-bots-update";
|
|
96
120
|
export declare const FLEET_BOTS_UPDATE_INTERVAL_SEC: number;
|
|
97
121
|
export declare const FLEET_BOTS_UPDATE_INITIAL_DELAY_SEC = 120;
|
|
@@ -154,7 +178,7 @@ export interface PlanContext {
|
|
|
154
178
|
/** ~/.hq-agent/kit.json exists. */
|
|
155
179
|
kitConfigured: boolean;
|
|
156
180
|
bots: readonly string[];
|
|
157
|
-
fleetBots?: readonly
|
|
181
|
+
fleetBots?: readonly FleetBotPlan[];
|
|
158
182
|
/** Name of a pre-daemon unit that still runs this unit id, or null. */
|
|
159
183
|
legacyOwner: (unitId: string) => string | null;
|
|
160
184
|
/** This CLI is a global install the updater can replace (not a project dependency). */
|
|
@@ -92,6 +92,7 @@ export function enabledServices(machineType, overrides) {
|
|
|
92
92
|
};
|
|
93
93
|
return SERVICE_NAMES.filter((s) => wanted(s) || implied(s));
|
|
94
94
|
}
|
|
95
|
+
export const FLEET_BOT_STOP_GRACE_MS = 30_000;
|
|
95
96
|
export const FLEET_BOTS_UPDATE_UNIT = "fleet-bots-update";
|
|
96
97
|
export const FLEET_BOTS_UPDATE_INTERVAL_SEC = 30 * 60;
|
|
97
98
|
export const FLEET_BOTS_UPDATE_INITIAL_DELAY_SEC = 120;
|
|
@@ -203,6 +204,9 @@ function planService(service, ctx) {
|
|
|
203
204
|
...ctx.legacySyncEnv,
|
|
204
205
|
...(vaultSync ? vaultSkipEnv(vaultSync) : {}),
|
|
205
206
|
HQ_SYNC_PASS_REQUEST_DIR: ctx.syncPassRequestsDir,
|
|
207
|
+
// feedback_65ee9e51: nobody watches an Outpost or agent machine's
|
|
208
|
+
// sync, so hq-cloud holds deletes of files other members created.
|
|
209
|
+
...(ctx.machineType === "outpost" || agentMachine ? { HQ_SYNC_UNATTENDED: "1" } : {}),
|
|
206
210
|
},
|
|
207
211
|
heartbeatTimeoutMs: ctx.syncHeartbeatTimeoutMs,
|
|
208
212
|
blocked: commonBlock,
|
|
@@ -352,7 +356,29 @@ function planService(service, ctx) {
|
|
|
352
356
|
}),
|
|
353
357
|
]
|
|
354
358
|
: [];
|
|
355
|
-
|
|
359
|
+
// On macOS the daemon runs each HQ Fleet gateway itself, so no bot needs
|
|
360
|
+
// its own login item (macOS reports each as "python" from an unknown
|
|
361
|
+
// developer). Elsewhere the runtime's own service manager keeps them.
|
|
362
|
+
const fleetUnits = ctx.platform === "darwin"
|
|
363
|
+
? (ctx.fleetBots ?? []).map((bot) => base(service, {
|
|
364
|
+
id: `fleet-bots:${bot.name}`,
|
|
365
|
+
description: `runs the HQ Fleet bot ${bot.name}`,
|
|
366
|
+
restart: "always",
|
|
367
|
+
command: bot.gateway ? { type: "exec", file: bot.gateway.file, args: bot.gateway.args } : null,
|
|
368
|
+
env: bot.gateway?.env ?? {},
|
|
369
|
+
...(bot.gateway ? { cwd: bot.gateway.cwd } : {}),
|
|
370
|
+
// The gateway finishes the reply it is sending before it exits; its own LaunchAgent gave it 25 s.
|
|
371
|
+
stopGraceMs: FLEET_BOT_STOP_GRACE_MS,
|
|
372
|
+
blocked: firstBlock([
|
|
373
|
+
[bot.authPending, `not signed in (run \`hq bot auth ${bot.name}\`)`],
|
|
374
|
+
[bot.installPending, `waiting for \`hq bot start ${bot.name}\``],
|
|
375
|
+
[bot.gateway === null, `the HQ Fleet runtime is not installed for ${bot.name} (run \`hq bot start ${bot.name}\`)`],
|
|
376
|
+
[bot.legacyAgent !== undefined, `still started by its own login item ${bot.legacyAgent} (run \`hq bot start ${bot.name}\`)`],
|
|
377
|
+
[bot.outsideGateway !== undefined, `waiting for its gateway started outside hq daemon (pid ${bot.outsideGateway}) to exit`],
|
|
378
|
+
]),
|
|
379
|
+
}))
|
|
380
|
+
: [];
|
|
381
|
+
if (ctx.bots.length === 0 && fleetUnits.length === 0) {
|
|
356
382
|
return fleetWatch.length > 0 ? fleetWatch : [base(service, { blocked: { state: "waiting", reason: "no local bots" } })];
|
|
357
383
|
}
|
|
358
384
|
return [
|
|
@@ -364,6 +390,7 @@ function planService(service, ctx) {
|
|
|
364
390
|
// A bot drains on SIGUSR2: running turns finish, then it exits.
|
|
365
391
|
drainSignal: "SIGUSR2",
|
|
366
392
|
})),
|
|
393
|
+
...fleetUnits,
|
|
367
394
|
...fleetWatch,
|
|
368
395
|
];
|
|
369
396
|
}
|
|
@@ -390,7 +417,7 @@ function planService(service, ctx) {
|
|
|
390
417
|
// timer for due keep-alive work, avoiding a fresh CLI process per poll.
|
|
391
418
|
intervalSec: 15,
|
|
392
419
|
initialDelaySec: 30,
|
|
393
|
-
command: { type: "hq", args: ["
|
|
420
|
+
command: { type: "hq", args: ["runners", "reconcile"] },
|
|
394
421
|
env: ctx.hqRoot ? { HQ_ROOT: ctx.hqRoot } : {},
|
|
395
422
|
...(ctx.machineType === "desktop"
|
|
396
423
|
? { runGuard: { name: "lanes-reconcile", idleIntervalSec: 60 } }
|
package/dist/lib/daemon/run.d.ts
CHANGED
|
@@ -101,7 +101,6 @@ export declare function daemonInstantSyncEnabled(env: NodeJS.ProcessEnv, configu
|
|
|
101
101
|
* background service, so it is not one of them.
|
|
102
102
|
*/
|
|
103
103
|
export declare function listLocalBots(root?: string): string[];
|
|
104
|
-
export declare function listFleetRuntimeBots(root?: string): string[];
|
|
105
104
|
/** Whose task `taskName` is: only the current user's own task may be taken over. */
|
|
106
105
|
export declare function windowsTaskOwner(taskName: string): WindowsTaskOwner;
|
|
107
106
|
export declare function probeLegacyUnits(platform: NodeJS.Platform, home: string): LegacyUnit[];
|
package/dist/lib/daemon/run.js
CHANGED
|
@@ -19,6 +19,7 @@ import { currentPackageUseLeaseInstall, currentPackageUseUpdateRequested } from
|
|
|
19
19
|
import { isLocalDependencyInstall, resolveRunningInstall } from "../../utils/version-gate.js";
|
|
20
20
|
import { agentKitPaths } from "../agent-kit/paths.js";
|
|
21
21
|
import { HQ_FLEET_RUNTIME_ENGINE_ID, readBotConfig } from "../bot/config.js";
|
|
22
|
+
import { planFleetBots } from "../bot/fleet-daemon.js";
|
|
22
23
|
import { botsRoot } from "../bot/paths.js";
|
|
23
24
|
import { CLAUDE_RUNNER_SCRIPT, CODEX_RUNNER_SCRIPT, enabledServices, planUnits } from "./catalog.js";
|
|
24
25
|
import { effectiveSyncOwner, readDaemonConfig } from "./config.js";
|
|
@@ -359,15 +360,6 @@ export function listLocalBots(root = botsRoot()) {
|
|
|
359
360
|
.map((d) => d.name)
|
|
360
361
|
.sort();
|
|
361
362
|
}
|
|
362
|
-
export function listFleetRuntimeBots(root = botsRoot()) {
|
|
363
|
-
if (!fs.existsSync(root))
|
|
364
|
-
return [];
|
|
365
|
-
return fs
|
|
366
|
-
.readdirSync(root, { withFileTypes: true })
|
|
367
|
-
.filter((d) => d.isDirectory() && readBotConfig(path.join(root, d.name))?.engine?.id === HQ_FLEET_RUNTIME_ENGINE_ID)
|
|
368
|
-
.map((d) => d.name)
|
|
369
|
-
.sort();
|
|
370
|
-
}
|
|
371
363
|
/** Whose task `taskName` is: only the current user's own task may be taken over. */
|
|
372
364
|
export function windowsTaskOwner(taskName) {
|
|
373
365
|
const run = (cmd, args) => {
|
|
@@ -1153,7 +1145,7 @@ export async function runDaemon(opts) {
|
|
|
1153
1145
|
!appManagesSync && Boolean(hqRoot && isSignedIn && runners.syncRunner),
|
|
1154
1146
|
syncHeartbeatTimeoutMs: syncHeartbeatTimeoutMs(env),
|
|
1155
1147
|
bots: listLocalBots(),
|
|
1156
|
-
fleetBots:
|
|
1148
|
+
fleetBots: planFleetBots({ platform, home, env, log: (message) => log("info", message) }),
|
|
1157
1149
|
legacyOwner: legacyOwnerLookup(legacy),
|
|
1158
1150
|
cliSelfUpdatable: updatable,
|
|
1159
1151
|
claudePath: findUserBinary("claude", env, home),
|
|
@@ -1197,7 +1189,7 @@ export async function runDaemon(opts) {
|
|
|
1197
1189
|
: [command.file, command.args];
|
|
1198
1190
|
[file, args] = backgroundQosCommand([file, args], unit.backgroundQos === true);
|
|
1199
1191
|
const logPath = paths.unitLogPath(unit.id);
|
|
1200
|
-
const cwd = unit.env.HQ_ROOT && fs.existsSync(unit.env.HQ_ROOT) ? unit.env.HQ_ROOT : home;
|
|
1192
|
+
const cwd = unit.cwd && fs.existsSync(unit.cwd) ? unit.cwd : unit.env.HQ_ROOT && fs.existsSync(unit.env.HQ_ROOT) ? unit.env.HQ_ROOT : home;
|
|
1201
1193
|
const childEnv = daemonChildOwnershipEnv(env, unit, succession ? succession.handoffPath : null);
|
|
1202
1194
|
const trackOwner = command.type === "hq";
|
|
1203
1195
|
if (unit.heartbeatTimeoutMs && succession) {
|
|
@@ -16,7 +16,7 @@ import { createResolver } from "./resolver.js";
|
|
|
16
16
|
export { createResolver };
|
|
17
17
|
import { createLineSplitter, encodeMessage, HQD_DEFAULT_REQUEST_TIMEOUT_MS, HQD_MAX_LINE_BYTES, parseRequestLine } from "./protocol.js";
|
|
18
18
|
import { SessionRegistry } from "./session-registry.js";
|
|
19
|
-
import {
|
|
19
|
+
import { sessionMetaCompanies } from "../core-utils/session-company.js";
|
|
20
20
|
import { journalAppend, JournalOpError } from "./ops/journal.js";
|
|
21
21
|
import { memoryGet, memoryPut, MemoryOpError } from "./ops/memory.js";
|
|
22
22
|
import { meshPresence, MeshOpError } from "./ops/mesh.js";
|
|
@@ -322,7 +322,19 @@ export async function startHqdServer(opts) {
|
|
|
322
322
|
throw new OpError("company_mismatch", `explicit company ${explicit} conflicts with bound company ${bound}`);
|
|
323
323
|
}
|
|
324
324
|
};
|
|
325
|
-
/**
|
|
325
|
+
/** The companies a session's own meta.yaml locks it to; [] when it has no usable persisted bind. */
|
|
326
|
+
const persistedCompanies = (sessionId) => opts.hqRoot && sessionId ? sessionMetaCompanies(opts.hqRoot, sessionId, env) : [];
|
|
327
|
+
/**
|
|
328
|
+
* A session that persisted a company bind may act only for the companies it
|
|
329
|
+
* locked. An explicit company, a cwd-linked company or a session.open company
|
|
330
|
+
* outside that lock is a conflict, not an override (feedback_76cb8dc3).
|
|
331
|
+
*/
|
|
332
|
+
const assertCompanyMatchesPersisted = (company, source, persisted) => {
|
|
333
|
+
if (company && persisted.length > 0 && !persisted.includes(company)) {
|
|
334
|
+
throw new OpError("company_mismatch", `${source} company ${company} conflicts with the session's persisted company ${persisted.join(",")}`);
|
|
335
|
+
}
|
|
336
|
+
};
|
|
337
|
+
/** Resolve a call's company while keeping any session, cwd or persisted binding authoritative. */
|
|
326
338
|
const companyFor = (args) => {
|
|
327
339
|
const explicit = stringArg(args, "company", false);
|
|
328
340
|
const runtime = stringArg(args, "runtime", false);
|
|
@@ -335,15 +347,19 @@ export async function startHqdServer(opts) {
|
|
|
335
347
|
}
|
|
336
348
|
const boundCompany = session?.company ?? cwdCompany;
|
|
337
349
|
assertCompanyMatchesBinding(explicit, boundCompany);
|
|
350
|
+
const persisted = persistedCompanies(sessionId);
|
|
351
|
+
assertCompanyMatchesPersisted(explicit, "explicit", persisted);
|
|
352
|
+
assertCompanyMatchesPersisted(session?.company ?? undefined, "session", persisted);
|
|
353
|
+
assertCompanyMatchesPersisted(cwdCompany, "cwd-bound", persisted);
|
|
338
354
|
if (explicit ?? boundCompany)
|
|
339
355
|
return explicit ?? boundCompany;
|
|
340
356
|
// Neither the call, the in-memory session nor the cwd names a company:
|
|
341
|
-
//
|
|
342
|
-
//
|
|
343
|
-
//
|
|
344
|
-
//
|
|
357
|
+
// use the session's own persisted bind (meta.yaml company_slug), which a
|
|
358
|
+
// company bot's runner writes for every turn and which survives a daemon
|
|
359
|
+
// restart. A bot at the unlinked HQ root then resolves its own company,
|
|
360
|
+
// and the policy check still scopes it to that one company
|
|
345
361
|
// (feedback_578dd8ff).
|
|
346
|
-
return
|
|
362
|
+
return persisted[0];
|
|
347
363
|
};
|
|
348
364
|
let hqMcp = opts.mcpBridge;
|
|
349
365
|
if (!isPipe) {
|
|
@@ -507,6 +523,9 @@ export async function startHqdServer(opts) {
|
|
|
507
523
|
const boundCompany = resolve(cwd).company;
|
|
508
524
|
assertCompanyMatchesBinding(explicit, boundCompany ?? undefined);
|
|
509
525
|
const company = explicit ?? boundCompany;
|
|
526
|
+
// Opening must not give the session a company its own persisted bind
|
|
527
|
+
// does not lock (feedback_76cb8dc3).
|
|
528
|
+
assertCompanyMatchesPersisted(company ?? undefined, explicit ? "explicit" : "cwd-bound", persistedCompanies(sessionId));
|
|
510
529
|
return sessions.open({ runtime, sessionId, cwd: canonicalDir(cwd), company });
|
|
511
530
|
}
|
|
512
531
|
case "session.get": {
|
|
@@ -505,7 +505,7 @@ export function createSupervisor(deps) {
|
|
|
505
505
|
* `drain`, a unit that has a drain signal gets it first and SIGTERM only
|
|
506
506
|
* after HANDOFF_DRAIN_MAX_MS; SIGKILL follows SIGTERM after STOP_ESCALATION_MS.
|
|
507
507
|
*/
|
|
508
|
-
const terminate = (slot, then, drain = false, killGraceMs = STOP_ESCALATION_MS) => {
|
|
508
|
+
const terminate = (slot, then, drain = false, killGraceMs = slot.plan.stopGraceMs ?? STOP_ESCALATION_MS) => {
|
|
509
509
|
clearPendingSyncCommandRestart(slot);
|
|
510
510
|
clearTimer(slot);
|
|
511
511
|
clearHeartbeatTimer(slot);
|
package/dist/lib/daemon/tools.js
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* it can update) and never updates a copy it cannot write.
|
|
9
9
|
*/
|
|
10
10
|
import * as path from "node:path";
|
|
11
|
+
import { npmGlobalInstallArgv } from "../../utils/npm-install-flags.js";
|
|
11
12
|
export const TOOL_NAMES = ["claude", "codex", "grok"];
|
|
12
13
|
/** npm package for tools that can be installed with npm. */
|
|
13
14
|
const NPM_PACKAGES = {
|
|
@@ -15,6 +16,17 @@ const NPM_PACKAGES = {
|
|
|
15
16
|
codex: "@openai/codex",
|
|
16
17
|
grok: "@vibe-kit/grok-cli",
|
|
17
18
|
};
|
|
19
|
+
/**
|
|
20
|
+
* Packages in each tool's npm install tree whose install scripts must run
|
|
21
|
+
* (npm 12 blocks unlisted ones). Claude Code's postinstall links its native
|
|
22
|
+
* binary; Codex ships its binary only as an optional dependency, which
|
|
23
|
+
* `--include=optional` keeps. Matches the HQ desktop app's allow-list.
|
|
24
|
+
*/
|
|
25
|
+
const NPM_ALLOW_SCRIPTS = {
|
|
26
|
+
claude: ["@anthropic-ai/claude-code"],
|
|
27
|
+
codex: [],
|
|
28
|
+
grok: [],
|
|
29
|
+
};
|
|
18
30
|
/** Environment each tool's own `update` command needs to run unattended. */
|
|
19
31
|
const UPDATE_ENV = {
|
|
20
32
|
codex: { CODEX_NON_INTERACTIVE: "1" },
|
|
@@ -88,7 +100,11 @@ export function toolUpdateCommand(name, install, platform = process.platform) {
|
|
|
88
100
|
const pkg = NPM_PACKAGES[name];
|
|
89
101
|
const prefix = pkg ? npmPrefixOf(install.realPath, pkg, platform) : null;
|
|
90
102
|
if (pkg && prefix) {
|
|
91
|
-
return {
|
|
103
|
+
return {
|
|
104
|
+
file: "npm",
|
|
105
|
+
args: npmGlobalInstallArgv(`${pkg}@latest`, { prefix, allowScripts: NPM_ALLOW_SCRIPTS[name] ?? [] }),
|
|
106
|
+
env: {},
|
|
107
|
+
};
|
|
92
108
|
}
|
|
93
109
|
return { file: install.path, args: ["update"], env: { ...(UPDATE_ENV[name] ?? {}) } };
|
|
94
110
|
}
|
|
@@ -9,12 +9,13 @@ import fs from "node:fs";
|
|
|
9
9
|
import { createRequire } from "node:module";
|
|
10
10
|
import path from "node:path";
|
|
11
11
|
import { planResolvedCommandSpawn } from "../../utils/windows-spawn.js";
|
|
12
|
+
import { HQ_CLI_NPM_REPAIR_COMMAND } from "../../utils/npm-install-flags.js";
|
|
12
13
|
const require = createRequire(import.meta.url);
|
|
13
14
|
export class SqliteBindingError extends Error {
|
|
14
15
|
constructor(cause) {
|
|
15
16
|
super("better-sqlite3 did not load. npm 11.16 and later skip its install script unless scripts are allowed, so the prebuilt binary was not downloaded. " +
|
|
16
17
|
"HQ tried to download the prebuild and it still failed. " +
|
|
17
|
-
|
|
18
|
+
`Fix: ${HQ_CLI_NPM_REPAIR_COMMAND}`);
|
|
18
19
|
this.name = "SqliteBindingError";
|
|
19
20
|
if (cause !== undefined)
|
|
20
21
|
this.cause = cause;
|
|
@@ -15,6 +15,8 @@ export interface BotsDoctorDeps {
|
|
|
15
15
|
claudeLogin?: () => ClaudeLoginCheck;
|
|
16
16
|
/** Whether and why a legacy bot moves to the HQ Fleet Runtime at its next start (tests). */
|
|
17
17
|
legacyMove?: (dir: string, config: BotConfig) => LegacyMoveState;
|
|
18
|
+
/** Whether hq daemon runs this Mac's HQ Fleet bots (tests). */
|
|
19
|
+
fleetDaemon?: () => boolean;
|
|
18
20
|
}
|
|
19
21
|
/** The last reported failure, unless a later turn worked. */
|
|
20
22
|
export declare function unresolvedLastFailure(status: BotStatusFile | null): BotStatusFile["lastFailure"] | null;
|
|
@@ -8,6 +8,8 @@ import * as os from "node:os";
|
|
|
8
8
|
import * as path from "node:path";
|
|
9
9
|
import { botsRoot, botDir, launchdLabel } from "../../bot/paths.js";
|
|
10
10
|
import { HQ_FLEET_RUNTIME_ENGINE_ID, readBotConfig } from "../../bot/config.js";
|
|
11
|
+
import { fleetBotsManagedByDaemon } from "../../bot/fleet-daemon.js";
|
|
12
|
+
import { fleetLocalLaunchAgentLabel, fleetLocalLaunchAgentPlist } from "../../bot/fleet-local.js";
|
|
11
13
|
import { checkClaudeCodeLogin, claudeLoginFix, describeClaudeLoginSources, } from "../../bot/claude-login.js";
|
|
12
14
|
import { isPidAlive, readBotStatus } from "../../bot/status.js";
|
|
13
15
|
import { legacyMoveState } from "../../bot/legacy-convert.js";
|
|
@@ -142,6 +144,15 @@ function runChecks(deps) {
|
|
|
142
144
|
});
|
|
143
145
|
}
|
|
144
146
|
}
|
|
147
|
+
if (!isLegacyBot(config) && (deps.fleetDaemon ?? (() => fleetBotsManagedByDaemon({ home })))() && fs.existsSync(fleetLocalLaunchAgentPlist(config.agentUid, home))) {
|
|
148
|
+
results.push({
|
|
149
|
+
status: "WARN",
|
|
150
|
+
checkId: `bots.${name}.own-login-item`,
|
|
151
|
+
target: fleetLocalLaunchAgentPlist(config.agentUid, home),
|
|
152
|
+
message: `${name} still has its own login item (${fleetLocalLaunchAgentLabel(config.agentUid)}), which macOS reports as "python" running in the background. hq daemon runs HQ Fleet bots on this Mac.`,
|
|
153
|
+
remediation: `hq bot start ${name}`,
|
|
154
|
+
});
|
|
155
|
+
}
|
|
145
156
|
const lastFailure = unresolvedLastFailure(status);
|
|
146
157
|
if (lastFailure) {
|
|
147
158
|
results.push({
|
|
@@ -30,6 +30,7 @@ import * as fs from "node:fs";
|
|
|
30
30
|
import * as os from "node:os";
|
|
31
31
|
import * as path from "node:path";
|
|
32
32
|
import { planCommandSpawn } from "../../../utils/windows-spawn.js";
|
|
33
|
+
import { npmGlobalInstallArgv } from "../../../utils/npm-install-flags.js";
|
|
33
34
|
/** The id of the AI-runtime-health family. */
|
|
34
35
|
export const RUNTIMES_FAMILY_ID = "runtimes";
|
|
35
36
|
/** Common id prefix for every result this family emits. */
|
|
@@ -54,7 +55,7 @@ export const AI_RUNTIMES = [
|
|
|
54
55
|
binary: "claude",
|
|
55
56
|
versionArgs: ["--version"],
|
|
56
57
|
probeArgs: ["-p", PROBE_PROMPT],
|
|
57
|
-
installHint:
|
|
58
|
+
installHint: `npm ${npmGlobalInstallArgv("@anthropic-ai/claude-code", { allowScripts: ["@anthropic-ai/claude-code"] }).join(" ")}`,
|
|
58
59
|
},
|
|
59
60
|
{
|
|
60
61
|
key: "codex",
|
|
@@ -68,7 +69,7 @@ export const AI_RUNTIMES = [
|
|
|
68
69
|
"read-only",
|
|
69
70
|
PROBE_PROMPT,
|
|
70
71
|
],
|
|
71
|
-
installHint:
|
|
72
|
+
installHint: `npm ${npmGlobalInstallArgv("@openai/codex", { allowScripts: [] }).join(" ")}`,
|
|
72
73
|
},
|
|
73
74
|
{
|
|
74
75
|
key: "grok",
|
|
@@ -9,7 +9,7 @@ import * as path from "node:path";
|
|
|
9
9
|
import { readDeviceConfig, } from "../../work-context/config.js";
|
|
10
10
|
import { outboxStats, listOutboxOperations } from "../../work-context/outbox.js";
|
|
11
11
|
import { outboxQuarantineStatusEnabled } from "../../work-context/outbox-quarantine-status-flag.js";
|
|
12
|
-
import { workContextRoot, workContextSessionsDir } from "../../work-context/paths.js";
|
|
12
|
+
import { isWorkContextSessionStateFileName, workContextRoot, workContextSessionsDir, } from "../../work-context/paths.js";
|
|
13
13
|
import { countDistinctHeldEvents, countJsonlLines, deadLetterNonEmpty, } from "../../mesh/live/spool.js";
|
|
14
14
|
import { workMeshDeadLetterPath, workMeshHeldPath, workMeshRoot, workMeshSpoolPath, } from "../../mesh/live/paths.js";
|
|
15
15
|
import { collectDaemonDoctor, formatDaemonDoctor, } from "../../mesh/live/daemon/doctor.js";
|
|
@@ -54,7 +54,10 @@ function runChecks(deps) {
|
|
|
54
54
|
});
|
|
55
55
|
}
|
|
56
56
|
else {
|
|
57
|
-
|
|
57
|
+
// Only `<sessionId>.json` is session state. Sidecars such as
|
|
58
|
+
// `<sessionId>.prd-snapshot.json` have their own shape and were counted
|
|
59
|
+
// as corrupt (feedback_e99bf6b5).
|
|
60
|
+
const files = fs.readdirSync(sessionsDir).filter(isWorkContextSessionStateFileName);
|
|
58
61
|
let corrupt = 0;
|
|
59
62
|
let healthy = 0;
|
|
60
63
|
for (const name of files) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type SpawnSyncReturns } from 'node:child_process';
|
|
2
|
-
export declare const HOOK_ENGINE_REPAIR = "npm install -g @indigoai-us/hq-cli --include=optional";
|
|
2
|
+
export declare const HOOK_ENGINE_REPAIR = "npm install -g @indigoai-us/hq-cli --allow-scripts=@indigoai-us/hq-cli --allow-scripts=better-sqlite3 --allow-scripts=node-llama-cpp --allow-scripts=tree-sitter-go --allow-scripts=tree-sitter-python --allow-scripts=tree-sitter-rust --allow-scripts=tree-sitter-typescript --allow-scripts=tree-sitter-javascript --include=optional";
|
|
3
3
|
export declare const HOOK_ENGINE_REPAIR_PIN = "hq core hook-engine-path --repair";
|
|
4
4
|
export interface EngineOptions {
|
|
5
5
|
home?: string;
|
|
@@ -7,7 +7,10 @@ const require = createRequire(import.meta.url);
|
|
|
7
7
|
// Capture metadata while the package-use lease protects this install tree.
|
|
8
8
|
// Resident commands may call doctor after an update removes the old manifest.
|
|
9
9
|
const cliManifest = JSON.parse(readFileSync(new URL('../../../package.json', import.meta.url), 'utf8'));
|
|
10
|
-
|
|
10
|
+
// Inlined so this file keeps importing only node builtins (it must load from a
|
|
11
|
+
// resident process after an update replaced the tree, and from postinstall).
|
|
12
|
+
// Equal to HQ_CLI_NPM_REPAIR_COMMAND; npm-install-flags.test.ts checks parity.
|
|
13
|
+
export const HOOK_ENGINE_REPAIR = 'npm install -g @indigoai-us/hq-cli --allow-scripts=@indigoai-us/hq-cli --allow-scripts=better-sqlite3 --allow-scripts=node-llama-cpp --allow-scripts=tree-sitter-go --allow-scripts=tree-sitter-python --allow-scripts=tree-sitter-rust --allow-scripts=tree-sitter-typescript --allow-scripts=tree-sitter-javascript --include=optional';
|
|
11
14
|
export const HOOK_ENGINE_REPAIR_PIN = 'hq core hook-engine-path --repair';
|
|
12
15
|
const platforms = new Set(['win32-x64', 'win32-arm64', 'darwin-x64', 'darwin-arm64', 'linux-x64', 'linux-arm64']);
|
|
13
16
|
/** US-020 must set this package capability when the replaced bash hooks retire. */
|
|
@@ -77,6 +77,8 @@ export interface MeetingIdentity {
|
|
|
77
77
|
}
|
|
78
78
|
/** Recordings that start this close together may be the same meeting. */
|
|
79
79
|
export declare const SAME_MEETING_WINDOW_MS: number;
|
|
80
|
+
/** A real calendar event id, or undefined for missing / Fireflies placeholder. */
|
|
81
|
+
export declare function usableCalendarEventId(id: string | undefined): string | undefined;
|
|
80
82
|
/**
|
|
81
83
|
* Whether two recordings are the same meeting: the same calendar event, or
|
|
82
84
|
* starts within 30 minutes plus the same call link, a matching title, or at
|
|
@@ -119,7 +119,7 @@ export const firefliesProvider = {
|
|
|
119
119
|
async read(gateway, meeting) {
|
|
120
120
|
const transcript = resultText(await gateway.call(FIREFLIES_TRANSCRIPT_TOOL, { transcriptId: meeting.id }));
|
|
121
121
|
const summary = resultText(await gateway.call(FIREFLIES_SUMMARY_TOOL, { transcriptId: meeting.id }));
|
|
122
|
-
const calId = firefliesField(transcript, "Cal Id");
|
|
122
|
+
const calId = usableCalendarEventId(firefliesField(transcript, "Cal Id"));
|
|
123
123
|
if (calId && !meeting.calendarEventId)
|
|
124
124
|
meeting.calendarEventId = calId;
|
|
125
125
|
const noSentences = /^Sentences:\s*No sentences\s*$/m.test(transcript) || transcript.trim() === "";
|
|
@@ -227,13 +227,24 @@ function urlKey(url) {
|
|
|
227
227
|
}
|
|
228
228
|
/** Recordings that start this close together may be the same meeting. */
|
|
229
229
|
export const SAME_MEETING_WINDOW_MS = 30 * 60 * 1000;
|
|
230
|
+
/** Fireflies writes this when a recording has no calendar invite. */
|
|
231
|
+
const NO_CALENDAR_EVENT = /^(no cal id|null|none|n\/a)$/i;
|
|
232
|
+
/** A real calendar event id, or undefined for missing / Fireflies placeholder. */
|
|
233
|
+
export function usableCalendarEventId(id) {
|
|
234
|
+
const v = id?.trim();
|
|
235
|
+
if (!v || NO_CALENDAR_EVENT.test(v))
|
|
236
|
+
return undefined;
|
|
237
|
+
return v;
|
|
238
|
+
}
|
|
230
239
|
/**
|
|
231
240
|
* Whether two recordings are the same meeting: the same calendar event, or
|
|
232
241
|
* starts within 30 minutes plus the same call link, a matching title, or at
|
|
233
242
|
* least two participants and more than half of the smaller list in common.
|
|
234
243
|
*/
|
|
235
244
|
export function sameMeeting(a, b) {
|
|
236
|
-
|
|
245
|
+
const calA = usableCalendarEventId(a.calendarEventId);
|
|
246
|
+
const calB = usableCalendarEventId(b.calendarEventId);
|
|
247
|
+
if (calA && calB && calA === calB)
|
|
237
248
|
return true;
|
|
238
249
|
if (Math.abs(a.startMs - b.startMs) > SAME_MEETING_WINDOW_MS)
|
|
239
250
|
return false;
|
|
@@ -24,7 +24,7 @@ export { LANES_STORE_REL, LANE_RECORDS_DIR, PENDING_INDEX_DIR, QUESTION_RECORDS_
|
|
|
24
24
|
export type { StoreDeps } from "./store.js";
|
|
25
25
|
export { DEFAULT_LANE_WATCH_INTERVAL_MS, MAX_LANE_WATCH_INTERVAL_MS, MAX_WATCHED_LANES, MAX_WATCH_OUTPUT_LINES, runLaneWatch, } from "./watch.js";
|
|
26
26
|
export type { LaneWatchDeps, LaneWatchResult } from "./watch.js";
|
|
27
|
-
export { MONITOR_ERROR_EXIT_CODE, MONITOR_ENGINES, MONITOR_MAX_TIMEOUT_MS, MONITOR_TASK_OUTPUT_MAX_BYTES, MONITOR_TRANSCRIPT_MAX_BYTES, MONITOR_UNCOVERED_EXIT_CODE, coveredLaneIds, isMonitorTaskLive, monitorReminderText, parseCanonicalWatchCommand, parseMonitorTranscript, readLiveMonitorEvidence, } from "./monitor.js";
|
|
27
|
+
export { MONITOR_ERROR_EXIT_CODE, MONITOR_ENGINES, MONITOR_MAX_TIMEOUT_MS, MONITOR_TASK_OUTPUT_MAX_BYTES, MONITOR_TRANSCRIPT_MAX_BYTES, MONITOR_UNCOVERED_EXIT_CODE, coveredLaneIds, expiredLaneIds, isMonitorTaskLive, monitorReminderText, parseCanonicalWatchCommand, parseMonitorTranscript, readLiveMonitorEvidence, } from "./monitor.js";
|
|
28
28
|
export type { LiveMonitorEvidenceOptions, MonitorEngine, MonitorEvidence, MonitorEvidenceReader, MonitorTaskEvidence, } from "./monitor.js";
|
|
29
29
|
export { IMDS_HOST, IMDS_INSTANCE_ID_URL, IMDS_TIMEOUT_MS, IMDS_TOKEN_URL, defaultReadImdsInstanceId, resolveMachineIdentity, } from "./machine-identity.js";
|
|
30
30
|
export type { MachineIdentity, MachineIdentityDeps } from "./machine-identity.js";
|
package/dist/lib/lanes/index.js
CHANGED
|
@@ -14,7 +14,7 @@ export { LANE_STORY_LEDGER_FLAG, buildLaneStatusSnapshot, formatLaneStatusHuman,
|
|
|
14
14
|
export { buildOutpostPickupCommand, parseOutpostPickupPayload, } from "./outpost-dispatch.js";
|
|
15
15
|
export { LANES_STORE_REL, LANE_RECORDS_DIR, PENDING_INDEX_DIR, QUESTION_RECORDS_DIR, appendCappedHistory, appendLaneAttribution, appendLaneSeniorHistory, appendQuestionRouting, createLane, createQuestion, isConflictSidecarName, laneRecordPath, lanesStoreRoot, listLaneIds, expandLocalLaneIdPrefix, LANE_ID_PREFIX_MIN, listQuestionIds, mergeLaneRecords, mergeQuestionRecords, mintLaneId, mintQuestionId, parseLaneRecord, parseQuestionRecord, pendingMarkerPath, questionRecordPath, readAllLanes, readLane, readQuestion, resolveStoreHqRoot, sanitizeHostComponent, tryReadLane, tryReadQuestion, retryUpdateLane, retryUpdateQuestion, syncLaneRecordFromOwner, updateLane, updateQuestion, withLaneHireLocks, } from "./store.js";
|
|
16
16
|
export { DEFAULT_LANE_WATCH_INTERVAL_MS, MAX_LANE_WATCH_INTERVAL_MS, MAX_WATCHED_LANES, MAX_WATCH_OUTPUT_LINES, runLaneWatch, } from "./watch.js";
|
|
17
|
-
export { MONITOR_ERROR_EXIT_CODE, MONITOR_ENGINES, MONITOR_MAX_TIMEOUT_MS, MONITOR_TASK_OUTPUT_MAX_BYTES, MONITOR_TRANSCRIPT_MAX_BYTES, MONITOR_UNCOVERED_EXIT_CODE, coveredLaneIds, isMonitorTaskLive, monitorReminderText, parseCanonicalWatchCommand, parseMonitorTranscript, readLiveMonitorEvidence, } from "./monitor.js";
|
|
17
|
+
export { MONITOR_ERROR_EXIT_CODE, MONITOR_ENGINES, MONITOR_MAX_TIMEOUT_MS, MONITOR_TASK_OUTPUT_MAX_BYTES, MONITOR_TRANSCRIPT_MAX_BYTES, MONITOR_UNCOVERED_EXIT_CODE, coveredLaneIds, expiredLaneIds, isMonitorTaskLive, monitorReminderText, parseCanonicalWatchCommand, parseMonitorTranscript, readLiveMonitorEvidence, } from "./monitor.js";
|
|
18
18
|
export { IMDS_HOST, IMDS_INSTANCE_ID_URL, IMDS_TIMEOUT_MS, IMDS_TOKEN_URL, defaultReadImdsInstanceId, resolveMachineIdentity, } from "./machine-identity.js";
|
|
19
19
|
export { PID_LIVENESS_DECISIONS, PROVIDER_COMMAND, PROVIDER_MODEL_FLAG, SPAWN_TERMINAL_REASONS, ANSWERED_QUESTIONS_FILE, appendModelFlag, armLaneWatcher, buildProviderCommand, parseCliModel, resolveLaneModel, defaultProveDetached, isPidRecordAlive, laneRunDir, missingPidProbe, nextEnvelopePath, markSpawnFailure, parsePidRecord, parseProcStat, parseSpawnTerminalReason, probePidRecord, readPidRecord, readProcStarttime, readProcStarttimeDetailed, readSpawnManifest, resumePrompt, envelopeInstruction, spawnLaneWorker, stopLaneProcesses, watcherMainPath, workerEnv, } from "./spawn.js";
|
|
20
20
|
export { SILENCE_MS, WATCHER_DECISION_EVENTS, WATCHER_OUT_MAX_BYTES, WATCHER_POLL_MS, WATCHER_SIGNAL_KINDS, appendCappedLog, appendWatcherSignal, applyTerminalToLane, classifyLaneExit, clearLaneStalled, isPidAlive, laneIdentityFromRecord, markLaneStalled, notifySlotFreed, parseWatcherSignalKind, readLatestEnvelope, runWatcherLoop, stalledReason, tickWatcher, watcherEventsPath, watcherLastSignalPath, watcherOutLogPath, writeWatcherDecision, } from "./watcher.js";
|
|
@@ -40,7 +40,21 @@ export interface LiveMonitorEvidenceOptions {
|
|
|
40
40
|
export declare function parseMonitorTranscript(text: string): MonitorTaskEvidence[];
|
|
41
41
|
/** Return argv only for the exact command form the gate arms. */
|
|
42
42
|
export declare function parseCanonicalWatchCommand(command: string): string[] | null;
|
|
43
|
+
/**
|
|
44
|
+
* A Monitor covers its lanes only inside the 30-minute cap. `persistent` is
|
|
45
|
+
* deliberately ignored: current Claude Code builds stop every Monitor at 30
|
|
46
|
+
* minutes whatever it was armed with, so the only way a lane stays covered is
|
|
47
|
+
* a Monitor re-armed within the last 30 minutes (feedback 208fd2ea).
|
|
48
|
+
*/
|
|
43
49
|
export declare function isMonitorTaskLive(task: MonitorTaskEvidence, now: Date): boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Lanes that HAD a watch Monitor in this session which has since ended on its
|
|
52
|
+
* own (the 30-minute cap passed, or its output shows it stopped or expired)
|
|
53
|
+
* and was not stopped with TaskStop. These lanes are uncovered because the
|
|
54
|
+
* Monitor needs re-arming, not because none was ever armed; the gate says so.
|
|
55
|
+
* A lane another live Monitor still covers is not included.
|
|
56
|
+
*/
|
|
57
|
+
export declare function expiredLaneIds(evidence: MonitorEvidence, now: Date): Set<string>;
|
|
44
58
|
export declare function coveredLaneIds(evidence: MonitorEvidence, now: Date): Set<string>;
|
|
45
59
|
export declare function readLiveMonitorEvidence(sessionId: string, options?: LiveMonitorEvidenceOptions): MonitorEvidence;
|
|
46
60
|
export type MonitorEvidenceReader = (sessionId: string) => MonitorEvidence | Promise<MonitorEvidence>;
|
|
@@ -193,7 +193,7 @@ export function parseCanonicalWatchCommand(command) {
|
|
|
193
193
|
if (tokens.length < 4)
|
|
194
194
|
return null;
|
|
195
195
|
const executable = path.basename(tokens[0]);
|
|
196
|
-
if (executable !== "hq" || tokens[1] !== "lanes" || tokens[2] !== "watch") {
|
|
196
|
+
if (executable !== "hq" || (tokens[1] !== "runners" && tokens[1] !== "lanes") || tokens[2] !== "watch") {
|
|
197
197
|
return null;
|
|
198
198
|
}
|
|
199
199
|
const laneIds = tokens.slice(3);
|
|
@@ -204,17 +204,55 @@ export function parseCanonicalWatchCommand(command) {
|
|
|
204
204
|
function taskOutputIsTerminal(outputText) {
|
|
205
205
|
return outputText ? TERMINAL_TASK_OUTPUT.test(outputText) : false;
|
|
206
206
|
}
|
|
207
|
+
function monitorDeadlineMs(task) {
|
|
208
|
+
const startedAt = Date.parse(task.startedAt);
|
|
209
|
+
if (!Number.isFinite(startedAt) || !Number.isFinite(task.timeoutMs) || task.timeoutMs <= 0) {
|
|
210
|
+
return null;
|
|
211
|
+
}
|
|
212
|
+
return startedAt + Math.min(task.timeoutMs, MONITOR_MAX_TIMEOUT_MS);
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* A Monitor covers its lanes only inside the 30-minute cap. `persistent` is
|
|
216
|
+
* deliberately ignored: current Claude Code builds stop every Monitor at 30
|
|
217
|
+
* minutes whatever it was armed with, so the only way a lane stays covered is
|
|
218
|
+
* a Monitor re-armed within the last 30 minutes (feedback 208fd2ea).
|
|
219
|
+
*/
|
|
207
220
|
export function isMonitorTaskLive(task, now) {
|
|
208
221
|
if (task.stopped || task.processAlive !== true)
|
|
209
222
|
return false;
|
|
210
223
|
if (taskOutputIsTerminal(task.outputText))
|
|
211
224
|
return false;
|
|
212
|
-
const
|
|
213
|
-
|
|
214
|
-
|
|
225
|
+
const deadline = monitorDeadlineMs(task);
|
|
226
|
+
return deadline !== null && now.getTime() < deadline;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Lanes that HAD a watch Monitor in this session which has since ended on its
|
|
230
|
+
* own (the 30-minute cap passed, or its output shows it stopped or expired)
|
|
231
|
+
* and was not stopped with TaskStop. These lanes are uncovered because the
|
|
232
|
+
* Monitor needs re-arming, not because none was ever armed; the gate says so.
|
|
233
|
+
* A lane another live Monitor still covers is not included.
|
|
234
|
+
*/
|
|
235
|
+
export function expiredLaneIds(evidence, now) {
|
|
236
|
+
const covered = coveredLaneIds(evidence, now);
|
|
237
|
+
const expired = new Set();
|
|
238
|
+
for (const task of evidence.tasks) {
|
|
239
|
+
if (task.stopped)
|
|
240
|
+
continue;
|
|
241
|
+
const laneIds = parseCanonicalWatchCommand(task.command);
|
|
242
|
+
if (!laneIds)
|
|
243
|
+
continue;
|
|
244
|
+
const deadline = monitorDeadlineMs(task);
|
|
245
|
+
if (deadline === null)
|
|
246
|
+
continue;
|
|
247
|
+
const ended = now.getTime() >= deadline || taskOutputIsTerminal(task.outputText);
|
|
248
|
+
if (!ended)
|
|
249
|
+
continue;
|
|
250
|
+
for (const laneId of laneIds) {
|
|
251
|
+
if (!covered.has(laneId))
|
|
252
|
+
expired.add(laneId);
|
|
253
|
+
}
|
|
215
254
|
}
|
|
216
|
-
|
|
217
|
-
return now.getTime() < deadline;
|
|
255
|
+
return expired;
|
|
218
256
|
}
|
|
219
257
|
export function coveredLaneIds(evidence, now) {
|
|
220
258
|
const covered = new Set();
|
|
@@ -350,7 +388,7 @@ function defaultProcessCommands() {
|
|
|
350
388
|
const WATCH_RUNTIME_EXECUTABLES = ["bun", "deno", "node", "nodejs", "ts-node", "tsx"];
|
|
351
389
|
// The hq executable path may contain spaces (the desktop toolchain installs
|
|
352
390
|
// under "~/Library/Application Support/Indigo HQ/..."), so the ps line cannot
|
|
353
|
-
// be split on whitespace to find it. Match the fixed "
|
|
391
|
+
// be split on whitespace to find it. Match the fixed "<group> watch <ids>" suffix
|
|
354
392
|
// on the raw line, then validate whatever precedes it as an hq invocation.
|
|
355
393
|
// A path form (absolute or ./, ../) is required so an unrelated leading
|
|
356
394
|
// command such as "vim /tmp/hq" is not absorbed into the path.
|
|
@@ -388,7 +426,10 @@ function processHasExactCommand(processCommands, command) {
|
|
|
388
426
|
const laneIds = parseCanonicalWatchCommand(command);
|
|
389
427
|
if (!laneIds)
|
|
390
428
|
return false;
|
|
391
|
-
|
|
429
|
+
// Match the group name the Monitor used: `hq runners watch` or the
|
|
430
|
+
// `hq lanes watch` alias produce different process lines.
|
|
431
|
+
const groupToken = command.trim().split(/\s+/u)[1];
|
|
432
|
+
const expectedSuffix = ` ${groupToken} watch ${laneIds.join(" ")}`;
|
|
392
433
|
return processCommands.some((rawLine) => {
|
|
393
434
|
const line = rawLine.trim().replace(/\s+/gu, " ");
|
|
394
435
|
if (!line.endsWith(expectedSuffix))
|
|
@@ -447,8 +488,8 @@ export function readLiveMonitorEvidence(sessionId, options = {}) {
|
|
|
447
488
|
export function monitorReminderText() {
|
|
448
489
|
return [
|
|
449
490
|
"For active Claude senior lanes, arm one live Claude Code Monitor task per uncovered lane:",
|
|
450
|
-
'Monitor(command="hq lanes watch <lane-id>...", timeout_ms=1800000
|
|
451
|
-
"
|
|
491
|
+
'Monitor(command="hq lanes watch <lane-id>...", timeout_ms=1800000)',
|
|
492
|
+
"Claude Code stops every Monitor after 30 minutes, so a lane stays covered only while a Monitor armed in the last 30 minutes watches it. Re-arm the same call when `hq lanes monitor-check --session <id>` reports the lane as expired.",
|
|
452
493
|
"The caller must pass `--engine codex` or `--engine grok` (or set HQ_LANE_ENGINE; deprecated alias HQ_CONDUCT_ENGINE) for sessions whose engine has no Claude Monitor tool; those engines are never required to provide one.",
|
|
453
494
|
].join("\n");
|
|
454
495
|
}
|
|
@@ -25,6 +25,8 @@ export interface OutpostDispatchResult {
|
|
|
25
25
|
exitCode: number | null;
|
|
26
26
|
stdout: string;
|
|
27
27
|
stderr: string;
|
|
28
|
+
/** True when the Outpost exec transport clipped stdout/stderr at its inline output limit. */
|
|
29
|
+
truncated?: boolean;
|
|
28
30
|
}
|
|
29
31
|
export interface OutpostLaneCommand {
|
|
30
32
|
action: "message" | "resume" | "stop" | "show" | "logs" | "grant" | "grant-target" | "reparent-target" | "approve-target" | "repair-company-target" | "set-target" | "blocked-escalation-target";
|
|
@@ -81,6 +83,7 @@ export interface OutpostExecPort {
|
|
|
81
83
|
exitCode?: number | null;
|
|
82
84
|
stdout?: string;
|
|
83
85
|
stderr?: string;
|
|
86
|
+
truncated?: boolean;
|
|
84
87
|
}>;
|
|
85
88
|
}
|
|
86
89
|
export declare function parseOutpostPickupPayload(raw: unknown): OutpostPickupPayload;
|
|
@@ -284,6 +284,7 @@ export async function dispatchOutpostPickup(port, input) {
|
|
|
284
284
|
exitCode: result.exitCode ?? null,
|
|
285
285
|
stdout: result.stdout ?? "",
|
|
286
286
|
stderr: result.stderr ?? "",
|
|
287
|
+
...(result.truncated === true ? { truncated: true } : {}),
|
|
287
288
|
};
|
|
288
289
|
}
|
|
289
290
|
catch (err) {
|