@indigoai-us/hq-cli 5.345.204 → 5.345.206
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 +40 -0
- package/dist/command-catalog.generated.d.ts +51 -1
- package/dist/command-catalog.generated.js +63 -1
- package/dist/commands/bot.d.ts +67 -0
- package/dist/commands/bot.js +301 -39
- package/dist/commands/cloud-off-gate.d.ts +9 -2
- package/dist/commands/cloud-off-gate.js +49 -13
- package/dist/commands/feedback.d.ts +26 -0
- package/dist/commands/feedback.js +91 -5
- package/dist/commands/install-global.d.ts +3 -1
- package/dist/commands/install-global.js +15 -4
- package/dist/commands/lanes.d.ts +2 -0
- package/dist/commands/lanes.js +9 -3
- package/dist/commands/mcp-serve.d.ts +5 -2
- package/dist/commands/mcp-serve.js +45 -3
- package/dist/commands/mcp-status.d.ts +3 -1
- package/dist/commands/mcp-status.js +24 -14
- package/dist/commands/secrets.js +11 -1
- package/dist/commands/sources.js +10 -15
- package/dist/index.js +7 -2
- package/dist/lib/bot/executive-settings.d.ts +13 -0
- package/dist/lib/bot/executive-settings.js +20 -17
- package/dist/lib/bot/executive-sync.d.ts +12 -0
- package/dist/lib/bot/executive-sync.js +36 -0
- package/dist/lib/bot/executive.d.ts +51 -0
- package/dist/lib/bot/executive.js +144 -0
- package/dist/lib/bot/fleet-cron.d.ts +7 -0
- package/dist/lib/bot/fleet-cron.js +2 -1
- package/dist/lib/bot/fleet-local.js +9 -9
- package/dist/lib/bot/jobs/executive-handover.d.ts +6 -0
- package/dist/lib/bot/jobs/executive-handover.js +33 -0
- package/dist/lib/bot/jobs/hot-signal-sync.d.ts +22 -0
- package/dist/lib/bot/jobs/hot-signal-sync.js +47 -0
- package/dist/lib/bot/listed-running.d.ts +16 -0
- package/dist/lib/bot/listed-running.js +16 -0
- package/dist/lib/bot/pending-switch.d.ts +51 -0
- package/dist/lib/bot/pending-switch.js +103 -0
- package/dist/lib/bot/run.js +27 -3
- package/dist/lib/bot/runtime-failure.js +19 -3
- package/dist/lib/bot/status.d.ts +20 -0
- package/dist/lib/company-skill-wrapper.js +29 -0
- package/dist/lib/daemon/hq-child-bootstrap.mjs +197 -2
- package/dist/lib/daemon/resolver.d.ts +14 -0
- package/dist/lib/daemon/resolver.js +96 -0
- package/dist/lib/daemon/run.d.ts +11 -0
- package/dist/lib/daemon/run.js +58 -6
- package/dist/lib/daemon/server.d.ts +2 -9
- package/dist/lib/daemon/server.js +3 -89
- package/dist/lib/doctor/checks/claude-wiring.js +41 -0
- package/dist/lib/doctor/checks/sync-health.d.ts +8 -0
- package/dist/lib/doctor/checks/sync-health.js +34 -2
- package/dist/lib/doctor/duplicate-hook-registrations.d.ts +34 -0
- package/dist/lib/doctor/duplicate-hook-registrations.js +130 -0
- package/dist/lib/doctor/fix/apply.js +79 -3
- package/dist/lib/doctor/fix/remediation.d.ts +1 -1
- package/dist/lib/doctor/fix/remediation.js +15 -0
- package/dist/lib/doctor/types.d.ts +1 -1
- package/dist/lib/doctor/types.js +1 -0
- package/dist/lib/lanes/links.d.ts +2 -0
- package/dist/lib/lanes/links.js +12 -1
- package/dist/lib/mcp/local-native-tools.d.ts +40 -0
- package/dist/lib/mcp/local-native-tools.js +111 -0
- package/dist/lib/mcp/tools.d.ts +2 -0
- package/dist/lib/mcp/tools.js +2 -0
- package/dist/lib/signals/steps/extract.d.ts +1 -1
- package/dist/lib/signals/steps/extract.js +4 -16
- package/dist/sentry-init.js +6 -0
- package/dist/utils/cli-network-lifecycle.d.ts +11 -1
- package/dist/utils/cli-network-lifecycle.js +36 -2
- package/dist/utils/daemon-helper-lifetime.d.ts +39 -0
- package/dist/utils/daemon-helper-lifetime.js +209 -0
- package/dist/utils/daemon-helper-markers.d.ts +24 -0
- package/dist/utils/daemon-helper-markers.js +53 -0
- package/dist/utils/mcp-launcher.d.ts +28 -0
- package/dist/utils/mcp-launcher.js +117 -0
- package/dist/utils/package-use-lease.d.ts +10 -0
- package/dist/utils/package-use-lease.js +31 -0
- package/dist/utils/resident-package-preload.js +4 -1
- package/docs/anywhere-runtime.md +7 -0
- package/package.json +7 -7
|
@@ -23,9 +23,10 @@
|
|
|
23
23
|
*/
|
|
24
24
|
import * as fs from 'fs';
|
|
25
25
|
import * as path from 'path';
|
|
26
|
-
import {
|
|
26
|
+
import { findExecutableOnPath } from '../utils/resolve-executable.js';
|
|
27
|
+
import { isStaleVersionedStorePath } from '../utils/mcp-launcher.js';
|
|
27
28
|
import { anywhereRuntimeEnabled } from './anywhere-runtime-flag.js';
|
|
28
|
-
import { claudeTargets, MCP_SUBPROCESS_PATH } from '../lib/install/claude-targets.js';
|
|
29
|
+
import { claudeTargets, HQ_MCP_SERVER_NAME, MCP_SUBPROCESS_PATH } from '../lib/install/claude-targets.js';
|
|
29
30
|
import { HQ_PACK_PROVENANCE_KEY, SECRET_REDACTION, backupRoot, claudeConfigFormat, claudeConfigPath, codexConfigFormat, codexConfigPath, CODEX_MCP_SERVERS_KEY, ConfigParseError, isCodexInstalled, readConfigDoc, resolveEnv, } from './mcp-registration.js';
|
|
30
31
|
// ---------------------------------------------------------------------------
|
|
31
32
|
// Pure status computation.
|
|
@@ -136,7 +137,7 @@ function pluginAndCodexMcpEquivalent(plugin, codex) {
|
|
|
136
137
|
const pluginEnv = plugin.env && typeof plugin.env === 'object' ? plugin.env : {};
|
|
137
138
|
const codexEnv = codex.env && typeof codex.env === 'object' ? codex.env : {};
|
|
138
139
|
const envMatch = JSON.stringify(envKeysOf(plugin)) === JSON.stringify(envKeysOf(codex)) ||
|
|
139
|
-
(globalNodeEntry && Object.keys(pluginEnv).length === 0 && Object.keys(codexEnv).length === 1 && codexEnv.PATH === MCP_SUBPROCESS_PATH);
|
|
140
|
+
(globalNodeEntry && Object.keys(pluginEnv).length === 0 && Object.keys(codexEnv).length === 1 && typeof codexEnv.PATH === 'string' && codexEnv.PATH.endsWith(MCP_SUBPROCESS_PATH));
|
|
140
141
|
return pluginTarget && codexTarget && JSON.stringify(headerKeysOf(plugin)) === JSON.stringify(headerKeysOf(codex)) && envMatch;
|
|
141
142
|
}
|
|
142
143
|
/** Scan the Claude runtime: read `~/.claude.json`, collect HQ-owned servers. */
|
|
@@ -197,7 +198,7 @@ function scanCodex(env) {
|
|
|
197
198
|
return { installed: true, parses, configPath, hqServers };
|
|
198
199
|
}
|
|
199
200
|
/** Build the per-runtime, per-server status from a scan (or its absence). */
|
|
200
|
-
function runtimeServerStatus(scan, name, checkHealth) {
|
|
201
|
+
function runtimeServerStatus(scan, name, checkHealth, runningCliEntry) {
|
|
201
202
|
if (!scan.installed)
|
|
202
203
|
return { presence: 'not-installed' };
|
|
203
204
|
if (!scan.parses)
|
|
@@ -211,22 +212,30 @@ function runtimeServerStatus(scan, name, checkHealth) {
|
|
|
211
212
|
target: targetOf(found.def),
|
|
212
213
|
headerKeys: headerKeysOf(found.def),
|
|
213
214
|
envKeys: envKeysOf(found.def),
|
|
214
|
-
...(checkHealth ? { healthy: isLaunchable(found.def) } : {}),
|
|
215
|
+
...(checkHealth ? { healthy: isLaunchable(name, found.def, runningCliEntry) } : {}),
|
|
215
216
|
};
|
|
216
217
|
}
|
|
217
218
|
/** True when a def can launch (see {@link RuntimeServerStatus.healthy}). */
|
|
218
|
-
function isLaunchable(def) {
|
|
219
|
+
function isLaunchable(name, def, runningCliEntry) {
|
|
219
220
|
if (transportOf(def) !== 'stdio')
|
|
220
221
|
return true;
|
|
221
222
|
const command = def.command;
|
|
222
|
-
if (typeof command !== 'string' || !commandIsLaunchable(command))
|
|
223
|
+
if (typeof command !== 'string' || !commandIsLaunchable(command, def))
|
|
223
224
|
return false;
|
|
224
225
|
const args = Array.isArray(def.args) ? def.args : [];
|
|
226
|
+
// The hq server's entry script pinned to a version-pinned store path other than
|
|
227
|
+
// the running CLI launches an old CLI. Only args[0] of the `hq` server is judged.
|
|
228
|
+
if (name === HQ_MCP_SERVER_NAME && typeof args[0] === 'string' && isStaleVersionedStorePath(args[0], runningCliEntry))
|
|
229
|
+
return false;
|
|
225
230
|
return args.every((a) => typeof a !== 'string' || !path.isAbsolute(a) || fs.existsSync(a));
|
|
226
231
|
}
|
|
227
|
-
/**
|
|
228
|
-
|
|
229
|
-
|
|
232
|
+
/**
|
|
233
|
+
* Absolute commands must exist and be executable. Bare commands resolve under the
|
|
234
|
+
* PATH the host will hand the server (the registered env.PATH), else the host PATH.
|
|
235
|
+
*/
|
|
236
|
+
function commandIsLaunchable(command, def) {
|
|
237
|
+
const registered = def.env && typeof def.env === 'object' ? def.env.PATH : undefined;
|
|
238
|
+
return findExecutableOnPath(command, typeof registered === 'string' ? registered : undefined) !== undefined;
|
|
230
239
|
}
|
|
231
240
|
/** List the most-recent backup dir names under `backupRoot` (newest first, capped). */
|
|
232
241
|
function recentBackups(env) {
|
|
@@ -255,7 +264,8 @@ function recentBackups(env) {
|
|
|
255
264
|
* differ). A malformed config marks that runtime `parses:false`/`unparseable`
|
|
256
265
|
* rather than throwing. Header VALUES are never read into the report.
|
|
257
266
|
*/
|
|
258
|
-
export function computeMcpStatus(env) {
|
|
267
|
+
export function computeMcpStatus(env, opts = {}) {
|
|
268
|
+
const runningCliEntry = opts.runningCliEntry ?? process.argv[1];
|
|
259
269
|
const checkHealth = anywhereRuntimeEnabled();
|
|
260
270
|
const claudeScan = scanClaude(env);
|
|
261
271
|
const codexScan = scanCodex(env);
|
|
@@ -274,8 +284,8 @@ export function computeMcpStatus(env) {
|
|
|
274
284
|
const names = new Set([...claudeScan.hqServers.keys(), ...codexScan.hqServers.keys()]);
|
|
275
285
|
const servers = [];
|
|
276
286
|
for (const name of [...names].sort()) {
|
|
277
|
-
const claude = runtimeServerStatus(claudeScan, name, checkHealth);
|
|
278
|
-
const codex = runtimeServerStatus(codexScan, name, checkHealth);
|
|
287
|
+
const claude = runtimeServerStatus(claudeScan, name, checkHealth, runningCliEntry);
|
|
288
|
+
const codex = runtimeServerStatus(codexScan, name, checkHealth, runningCliEntry);
|
|
279
289
|
// Prefer whichever runtime has the def for the top-level transport/target.
|
|
280
290
|
const claudeFound = claudeScan.hqServers.get(name);
|
|
281
291
|
const codexFound = codexScan.hqServers.get(name);
|
|
@@ -346,7 +356,7 @@ function renderRuntimeLine(label, st) {
|
|
|
346
356
|
case 'present': {
|
|
347
357
|
const parts = st.healthy === undefined
|
|
348
358
|
? ['present']
|
|
349
|
-
: [st.healthy ? 'present (healthy)' : 'present (UNHEALTHY: command not launchable)'];
|
|
359
|
+
: [st.healthy ? 'present (healthy)' : 'present (UNHEALTHY: command not launchable (missing, or pinned to an old CLI path; re-run `hq install --global`))'];
|
|
350
360
|
if (st.headerKeys && st.headerKeys.length > 0) {
|
|
351
361
|
parts.push(`headers: ${st.headerKeys.map((k) => `${k}=${SECRET_REDACTION}`).join(', ')}`);
|
|
352
362
|
}
|
package/dist/commands/secrets.js
CHANGED
|
@@ -68,6 +68,7 @@ export const SECRETS_EXEC_UNATTENDED_NO_COMPANY_MESSAGE = "hq secrets exec has n
|
|
|
68
68
|
"Pass --company <slug> (or --personal), or set HQ_SESSION_ID to the session this job runs under.";
|
|
69
69
|
import { removeCacheEntry, clearAllCache } from "../utils/secrets-cache.js";
|
|
70
70
|
import { isHqCliChild, releaseChildWrapperPackageUseLeaseAfterStart } from "../utils/child-wrapper-lease.js";
|
|
71
|
+
import { withPackageUseLeaseReleasedDuring } from "../utils/package-use-lease.js";
|
|
71
72
|
import { resolveDefaultHqRoot } from "../utils/hq-root-resolver.js";
|
|
72
73
|
import { fastFlagEnabledDefaultOn } from "../native-fast-route.js";
|
|
73
74
|
import { MULTI_COMPANY_SESSION_LOCK_FLAG } from "../lib/cli-flag-keys.js";
|
|
@@ -214,7 +215,16 @@ function parseDuration(input) {
|
|
|
214
215
|
return value * 24 * 60 * 60 * 1000;
|
|
215
216
|
return null;
|
|
216
217
|
}
|
|
218
|
+
// Waiting on a person is not package use. Drop the package-use lease while a
|
|
219
|
+
// prompt is open so a forgotten prompt cannot block HQ CLI updates for days
|
|
220
|
+
// (feedback_77165502); the lease is taken again once the answer arrives.
|
|
217
221
|
function confirmPrompt(message) {
|
|
222
|
+
return withPackageUseLeaseReleasedDuring(() => readConfirmationFromTerminal(message));
|
|
223
|
+
}
|
|
224
|
+
function promptSecretInteractively() {
|
|
225
|
+
return withPackageUseLeaseReleasedDuring(readSecretFromTerminal);
|
|
226
|
+
}
|
|
227
|
+
function readConfirmationFromTerminal(message) {
|
|
218
228
|
return import("node:readline").then(({ createInterface }) => {
|
|
219
229
|
const rl = createInterface({
|
|
220
230
|
input: process.stdin,
|
|
@@ -239,7 +249,7 @@ function readFromPipedStdin() {
|
|
|
239
249
|
process.stdin.on("error", reject);
|
|
240
250
|
});
|
|
241
251
|
}
|
|
242
|
-
function
|
|
252
|
+
function readSecretFromTerminal() {
|
|
243
253
|
return new Promise((resolve, reject) => {
|
|
244
254
|
process.stdout.write("Enter secret value: ");
|
|
245
255
|
if (process.stdin.isTTY) {
|
package/dist/commands/sources.js
CHANGED
|
@@ -47,6 +47,7 @@ import { S3Client } from "@aws-sdk/client-s3";
|
|
|
47
47
|
import { resolveCanonicalPersonUid } from "./cloud.js";
|
|
48
48
|
import { botsRoot as defaultBotsRoot } from "../lib/bot/paths.js";
|
|
49
49
|
import { ensureHotSignalSyncJob } from "../lib/bot/jobs/hot-signal-sync.js";
|
|
50
|
+
import { resolveExecutiveBot } from "../lib/bot/executive.js";
|
|
50
51
|
import { companyOfHotSignalSyncJob, fleetCronOps } from "../lib/bot/fleet-cron.js";
|
|
51
52
|
import { HQ_FLEET_RUNTIME_ENGINE_ID, readBotConfig } from "../lib/bot/config.js";
|
|
52
53
|
import { findHotSignalSyncJobs, lastRunsPerAdapter, parseDailyAt, renderScheduleReport, rescheduleDaily, toJobView, } from "../lib/hot-channels/schedule.js";
|
|
@@ -863,24 +864,18 @@ export async function runSchedule(options, overrides = {}) {
|
|
|
863
864
|
}
|
|
864
865
|
return finishScheduleReport(options, overrides, company, fleetJobView(fleetFound), [], now);
|
|
865
866
|
}
|
|
866
|
-
|
|
867
|
-
|
|
867
|
+
// The daily sync belongs to the Executive bot (hq bot eb).
|
|
868
|
+
const executiveBot = resolveExecutiveBot({ root: botsRootDir });
|
|
869
|
+
if (options.at !== undefined && executiveBot && fleetBotsIn(botsRootDir).some((bot) => bot.botName === executiveBot.name)) {
|
|
870
|
+
throw new Error(`The Executive bot ${executiveBot.name} runs on the HQ Fleet Runtime and has no hot-signal-sync job for ${company} yet. Start it once with \`hq bot start ${executiveBot.name}\` so it adds the job, then set the time again.`);
|
|
868
871
|
}
|
|
869
872
|
let found = findHotSignalSyncJobs(botsRootDir, company);
|
|
870
873
|
if (options.at !== undefined) {
|
|
871
|
-
if (found.length === 0) {
|
|
872
|
-
// Setting a time turns the daily sync on: register it on the
|
|
873
|
-
const
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone || "UTC";
|
|
877
|
-
const otherBotDirs = fs
|
|
878
|
-
.readdirSync(root, { withFileTypes: true })
|
|
879
|
-
.filter((d) => d.isDirectory())
|
|
880
|
-
.map((d) => path.join(root, d.name));
|
|
881
|
-
ensureHotSignalSyncJob(setupDir, { company, timezone, otherBotDirs }, now);
|
|
882
|
-
found = findHotSignalSyncJobs(root, company);
|
|
883
|
-
}
|
|
874
|
+
if (found.length === 0 && executiveBot) {
|
|
875
|
+
// Setting a time turns the daily sync on: register it on the Executive bot.
|
|
876
|
+
const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone || "UTC";
|
|
877
|
+
ensureHotSignalSyncJob(executiveBot.dir, { company, timezone }, now);
|
|
878
|
+
found = findHotSignalSyncJobs(botsRootDir, company);
|
|
884
879
|
}
|
|
885
880
|
if (found.length === 0)
|
|
886
881
|
throw new NoHotSignalSyncJobError(company);
|
package/dist/index.js
CHANGED
|
@@ -11,6 +11,7 @@ import { CLI_COMMAND_HELP_CATALOG_FLAG } from "./lib/cli-flag-keys.js";
|
|
|
11
11
|
// Also dependency-light: registers a process-level rejection boundary; its only
|
|
12
12
|
// heavy import (main.js) is lazy and reached only when a rejection fires.
|
|
13
13
|
import { installProcessRejectionBoundary } from "./unhandled-rejection-boundary.js";
|
|
14
|
+
import { daemonDirectReplacementEnv, installDaemonHelperLifetime } from "./utils/daemon-helper-lifetime.js";
|
|
14
15
|
import { installFastPathStreamErrorHandlers } from "./utils/fast-stream-errors.js";
|
|
15
16
|
import { installWindowsHideDefault } from "./utils/windows-hide-default.js";
|
|
16
17
|
import { fileURLToPath } from "node:url";
|
|
@@ -35,6 +36,10 @@ function cygpathMixedPath(value) {
|
|
|
35
36
|
// so runCli's finally still finalizes release health and flushes Sentry.
|
|
36
37
|
installProcessRejectionBoundary();
|
|
37
38
|
installFastPathStreamErrorHandlers();
|
|
39
|
+
// No-op unless the daemon spawned this process. Clears the one-shot owner
|
|
40
|
+
// markers before any command can start another hq process. Builtins only, so
|
|
41
|
+
// the fast path still does not load the command graph.
|
|
42
|
+
installDaemonHelperLifetime();
|
|
38
43
|
async function runMainWithInstallTreeRecovery() {
|
|
39
44
|
let runCli;
|
|
40
45
|
const { registerCommandsWithRecovery } = await import("./startup-registration.js");
|
|
@@ -44,7 +49,7 @@ async function runMainWithInstallTreeRecovery() {
|
|
|
44
49
|
runCli = (await import("./main.js")).runCli;
|
|
45
50
|
},
|
|
46
51
|
argv: process.argv,
|
|
47
|
-
env: process.env,
|
|
52
|
+
env: daemonDirectReplacementEnv(process.env),
|
|
48
53
|
entryPath: fileURLToPath(import.meta.url),
|
|
49
54
|
stderr: process.stderr,
|
|
50
55
|
});
|
|
@@ -96,7 +101,7 @@ const recoverFastImport = async (load, options = {}) => {
|
|
|
96
101
|
module = await load();
|
|
97
102
|
},
|
|
98
103
|
argv: process.argv,
|
|
99
|
-
env: process.env,
|
|
104
|
+
env: daemonDirectReplacementEnv(process.env),
|
|
100
105
|
entryPath: fileURLToPath(import.meta.url),
|
|
101
106
|
stderr: process.stderr,
|
|
102
107
|
reexecOnSettled: options.reexecOnSettled,
|
|
@@ -1,8 +1,21 @@
|
|
|
1
1
|
import { type BotConfig } from "./config.js";
|
|
2
2
|
export declare function executiveEnabled(home?: string): boolean;
|
|
3
|
+
/**
|
|
4
|
+
* Identity only: whether this bot is the Executive bot on this computer (the
|
|
5
|
+
* one resolver, lib/bot/executive.ts: chosen with hq bot eb, else the earliest
|
|
6
|
+
* personal bot). It never turns an Executive feature on; the daily
|
|
7
|
+
* hot-channel sync follows it for every user, opted in or not.
|
|
8
|
+
*/
|
|
9
|
+
export declare function isExecutiveIdentity(config: Pick<BotConfig, "name" | "kind" | "workerId">, home?: string): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Feature gate: whether this bot runs the Executive features (meeting rider,
|
|
12
|
+
* meeting detection, signal-to-lane, source report DMs). Requires BOTH the
|
|
13
|
+
* opt-in (executive.enabled === true) and the Executive identity.
|
|
14
|
+
*/
|
|
3
15
|
export declare function isExecutiveBot(config: Pick<BotConfig, "name" | "kind" | "workerId">, home?: string): boolean;
|
|
4
16
|
export declare function executiveStatus(config: Pick<BotConfig, "name" | "kind" | "workerId">, dir: string, home?: string): {
|
|
5
17
|
is_executive: boolean;
|
|
18
|
+
executive_identity: boolean;
|
|
6
19
|
rider_enabled: boolean;
|
|
7
20
|
detect_source_last: string | null;
|
|
8
21
|
last_detected_at: string | null;
|
|
@@ -12,6 +12,7 @@ import * as path from "node:path";
|
|
|
12
12
|
import * as os from "node:os";
|
|
13
13
|
import { effectiveBotKind } from "./config.js";
|
|
14
14
|
import { tailBotEvents } from "./events.js";
|
|
15
|
+
import { isExecutiveBotName } from "./executive.js";
|
|
15
16
|
export function executiveEnabled(home = os.homedir()) {
|
|
16
17
|
try {
|
|
17
18
|
const settings = JSON.parse(fs.readFileSync(path.join(home, ".hq/menubar.json"), "utf8"));
|
|
@@ -21,30 +22,32 @@ export function executiveEnabled(home = os.homedir()) {
|
|
|
21
22
|
return false;
|
|
22
23
|
}
|
|
23
24
|
}
|
|
24
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Identity only: whether this bot is the Executive bot on this computer (the
|
|
27
|
+
* one resolver, lib/bot/executive.ts: chosen with hq bot eb, else the earliest
|
|
28
|
+
* personal bot). It never turns an Executive feature on; the daily
|
|
29
|
+
* hot-channel sync follows it for every user, opted in or not.
|
|
30
|
+
*/
|
|
31
|
+
export function isExecutiveIdentity(config, home) {
|
|
25
32
|
if (effectiveBotKind(config) !== "personal")
|
|
26
33
|
return false;
|
|
34
|
+
// No explicit home: the resolver's own defaults (the real home, HQ_BOTS_ROOT and HQ_EXECUTIVE_FILE honored).
|
|
35
|
+
return isExecutiveBotName(config.name, home ? { home } : {});
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Feature gate: whether this bot runs the Executive features (meeting rider,
|
|
39
|
+
* meeting detection, signal-to-lane, source report DMs). Requires BOTH the
|
|
40
|
+
* opt-in (executive.enabled === true) and the Executive identity.
|
|
41
|
+
*/
|
|
42
|
+
export function isExecutiveBot(config, home) {
|
|
27
43
|
if (!executiveEnabled(home))
|
|
28
44
|
return false;
|
|
29
|
-
|
|
30
|
-
try {
|
|
31
|
-
const value = JSON.parse(fs.readFileSync(path.join(home, ".hq/executive.json"), "utf8"));
|
|
32
|
-
if (value?.bot != null) {
|
|
33
|
-
if (typeof value.bot !== "string" || !value.bot.trim())
|
|
34
|
-
return false;
|
|
35
|
-
name = value.bot;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
catch (err) {
|
|
39
|
-
if (err.code !== "ENOENT")
|
|
40
|
-
return false;
|
|
41
|
-
}
|
|
42
|
-
return config.name === name;
|
|
45
|
+
return isExecutiveIdentity(config, home);
|
|
43
46
|
}
|
|
44
|
-
export function executiveStatus(config, dir, home
|
|
47
|
+
export function executiveStatus(config, dir, home) {
|
|
45
48
|
const last = tailBotEvents(dir, (event) => event.event === "meeting.detected").at(-1);
|
|
46
49
|
return {
|
|
47
|
-
is_executive: isExecutiveBot(config, home), rider_enabled: executiveEnabled(home),
|
|
50
|
+
is_executive: isExecutiveBot(config, home), executive_identity: isExecutiveIdentity(config, home), rider_enabled: executiveEnabled(home),
|
|
48
51
|
// The first desktop producer did not set source.
|
|
49
52
|
detect_source_last: last ? (last.payload.source === "poll" ? "poll" : "desktop") : null,
|
|
50
53
|
last_detected_at: last?.at ?? null,
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ExecutiveBot } from "./executive.js";
|
|
2
|
+
import { type FleetCronJob } from "./fleet-cron.js";
|
|
3
|
+
/**
|
|
4
|
+
* Companies the Executive bot actually covers for the daily hot-channel sync.
|
|
5
|
+
* A local job counts only while `hq bot list` would show this bot running:
|
|
6
|
+
* jobs.json has no enabled flag, and a bot that ran once then stopped leaves
|
|
7
|
+
* the job behind. An enabled HQ Fleet job still counts when the local process
|
|
8
|
+
* is stopped. Registration markers, and a Fleet list that cannot be read, are
|
|
9
|
+
* not coverage.
|
|
10
|
+
*/
|
|
11
|
+
export declare function executiveHotSignalSyncCompanies(bot: ExecutiveBot, listFleet?: (agentUid: string) => FleetCronJob[]): string[];
|
|
12
|
+
//# sourceMappingURL=executive-sync.d.ts.map
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { readLocalJobs } from "./local-jobs.js";
|
|
2
|
+
import { hotSignalSyncJobCompany } from "./jobs/hot-signal-sync.js";
|
|
3
|
+
import { companyOfHotSignalSyncJob, fleetCronOps } from "./fleet-cron.js";
|
|
4
|
+
import { readBotListedProcess } from "./listed-running.js";
|
|
5
|
+
/**
|
|
6
|
+
* Companies the Executive bot actually covers for the daily hot-channel sync.
|
|
7
|
+
* A local job counts only while `hq bot list` would show this bot running:
|
|
8
|
+
* jobs.json has no enabled flag, and a bot that ran once then stopped leaves
|
|
9
|
+
* the job behind. An enabled HQ Fleet job still counts when the local process
|
|
10
|
+
* is stopped. Registration markers, and a Fleet list that cannot be read, are
|
|
11
|
+
* not coverage.
|
|
12
|
+
*/
|
|
13
|
+
export function executiveHotSignalSyncCompanies(bot, listFleet = (uid) => fleetCronOps(uid).list()) {
|
|
14
|
+
const companies = new Set();
|
|
15
|
+
if (readBotListedProcess(bot.dir, bot.config).running) {
|
|
16
|
+
for (const job of readLocalJobs(bot.dir)) {
|
|
17
|
+
const company = hotSignalSyncJobCompany(job.context);
|
|
18
|
+
if (company)
|
|
19
|
+
companies.add(company);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
if (bot.config.agentUid) {
|
|
23
|
+
try {
|
|
24
|
+
for (const job of listFleet(bot.config.agentUid)) {
|
|
25
|
+
const company = companyOfHotSignalSyncJob(job);
|
|
26
|
+
if (company && job.enabled !== false)
|
|
27
|
+
companies.add(company);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
// No readable Fleet schedule is not evidence of a replacement job.
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return [...companies];
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=executive-sync.js.map
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { type BotConfig, type BotRuntimeId } from "./config.js";
|
|
2
|
+
export declare const EXECUTIVE_FILE_REL: string;
|
|
3
|
+
export type ExecutiveBotSource = "chosen" | "default";
|
|
4
|
+
export interface ExecutiveBot {
|
|
5
|
+
name: string;
|
|
6
|
+
source: ExecutiveBotSource;
|
|
7
|
+
config: BotConfig;
|
|
8
|
+
/** ~/.hq/bots/<name> */
|
|
9
|
+
dir: string;
|
|
10
|
+
}
|
|
11
|
+
export interface ExecutiveChoice {
|
|
12
|
+
bot: string;
|
|
13
|
+
setAt?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface PersonalBotEntry {
|
|
16
|
+
name: string;
|
|
17
|
+
dir: string;
|
|
18
|
+
config: BotConfig;
|
|
19
|
+
createdAtMs: number;
|
|
20
|
+
}
|
|
21
|
+
export interface SetExecutiveBotResult {
|
|
22
|
+
name: string;
|
|
23
|
+
source: "chosen";
|
|
24
|
+
runtime: BotRuntimeId;
|
|
25
|
+
/** The effective Executive bot is a different bot than before the set. */
|
|
26
|
+
changed: boolean;
|
|
27
|
+
}
|
|
28
|
+
/** Where the store and the bots live. Defaults: the real home and ~/.hq/bots (HQ_BOTS_ROOT honored). */
|
|
29
|
+
export interface ExecutiveLocations {
|
|
30
|
+
home?: string;
|
|
31
|
+
/** The bots root; default botsRoot(home). */
|
|
32
|
+
root?: string;
|
|
33
|
+
env?: NodeJS.ProcessEnv;
|
|
34
|
+
}
|
|
35
|
+
/** ~/.hq/executive.json. With no explicit home, HQ_EXECUTIVE_FILE overrides the path (tests). */
|
|
36
|
+
export declare function executiveFilePath(home?: string, env?: NodeJS.ProcessEnv): string;
|
|
37
|
+
/** The stored choice, or null when the file is missing or does not name a bot. */
|
|
38
|
+
export declare function readExecutiveChoice(opts?: ExecutiveLocations): ExecutiveChoice | null;
|
|
39
|
+
export declare function writeExecutiveChoice(name: string, opts?: ExecutiveLocations, now?: Date): ExecutiveChoice;
|
|
40
|
+
/** Every personal bot set up here, earliest created first (name order breaks ties). */
|
|
41
|
+
export declare function listPersonalBots(opts?: ExecutiveLocations): PersonalBotEntry[];
|
|
42
|
+
export declare function resolveExecutiveBot(opts?: ExecutiveLocations): ExecutiveBot | null;
|
|
43
|
+
export declare function isExecutiveBotName(name: string, opts?: ExecutiveLocations): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Make `name` the Executive bot. The bot must be set up on this computer and
|
|
46
|
+
* be a personal bot; a company bot is refused.
|
|
47
|
+
*/
|
|
48
|
+
export declare function setExecutiveBot(name: string, opts?: ExecutiveLocations, now?: Date): SetExecutiveBotResult;
|
|
49
|
+
/** One plain sentence saying how the Executive bot was decided. */
|
|
50
|
+
export declare function describeExecutiveBotSource(bot: ExecutiveBot | null): string;
|
|
51
|
+
//# sourceMappingURL=executive.d.ts.map
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Executive bot (EB): the one personal local bot on this computer that
|
|
3
|
+
* builds the Daily Brief, extracts signals, runs the daily hot-channel sync,
|
|
4
|
+
* rides meetings and asks the owner's decisions.
|
|
5
|
+
*
|
|
6
|
+
* Store: ~/.hq/executive.json `{"bot":"<name>","setAt":"<ISO>"}` (the file
|
|
7
|
+
* the meeting rider introduced; `setAt` is added on write), 0600, written
|
|
8
|
+
* atomically and only by the CLI (`hq bot eb <name>`). The desktop app reads
|
|
9
|
+
* it and calls the CLI to change it. HQ_EXECUTIVE_FILE overrides the path
|
|
10
|
+
* (tests).
|
|
11
|
+
*
|
|
12
|
+
* Resolution: "chosen" when the file names a personal bot that exists here;
|
|
13
|
+
* otherwise "default", the personal bot created earliest (bot.json createdAt,
|
|
14
|
+
* else the folder's birth time, else its ctime; name order breaks ties); null
|
|
15
|
+
* when there is no personal bot. A chosen bot that was removed falls back to
|
|
16
|
+
* the default; the stale file stays until the next set.
|
|
17
|
+
*/
|
|
18
|
+
import * as fs from "node:fs";
|
|
19
|
+
import * as os from "node:os";
|
|
20
|
+
import * as path from "node:path";
|
|
21
|
+
import { effectiveBotKind, readBotConfig } from "./config.js";
|
|
22
|
+
import { botsRoot, validateBotName } from "./paths.js";
|
|
23
|
+
export const EXECUTIVE_FILE_REL = path.join(".hq", "executive.json");
|
|
24
|
+
/** ~/.hq/executive.json. With no explicit home, HQ_EXECUTIVE_FILE overrides the path (tests). */
|
|
25
|
+
export function executiveFilePath(home, env = process.env) {
|
|
26
|
+
if (home)
|
|
27
|
+
return path.join(home, EXECUTIVE_FILE_REL);
|
|
28
|
+
const override = env.HQ_EXECUTIVE_FILE?.trim();
|
|
29
|
+
return override || path.join(os.homedir(), EXECUTIVE_FILE_REL);
|
|
30
|
+
}
|
|
31
|
+
function locations(opts) {
|
|
32
|
+
const env = opts.env ?? process.env;
|
|
33
|
+
return { file: executiveFilePath(opts.home, env), root: opts.root ?? botsRoot(opts.home ?? os.homedir(), env) };
|
|
34
|
+
}
|
|
35
|
+
/** The stored choice, or null when the file is missing or does not name a bot. */
|
|
36
|
+
export function readExecutiveChoice(opts = {}) {
|
|
37
|
+
let raw;
|
|
38
|
+
try {
|
|
39
|
+
raw = JSON.parse(fs.readFileSync(locations(opts).file, "utf8"));
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
if (!raw || typeof raw !== "object")
|
|
45
|
+
return null;
|
|
46
|
+
const { bot, setAt } = raw;
|
|
47
|
+
if (typeof bot !== "string" || !bot.trim())
|
|
48
|
+
return null;
|
|
49
|
+
return { bot: bot.trim(), ...(typeof setAt === "string" ? { setAt } : {}) };
|
|
50
|
+
}
|
|
51
|
+
export function writeExecutiveChoice(name, opts = {}, now = new Date()) {
|
|
52
|
+
const choice = { bot: name, setAt: now.toISOString() };
|
|
53
|
+
const file = locations(opts).file;
|
|
54
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
55
|
+
const tmp = `${file}.${process.pid}.tmp`;
|
|
56
|
+
fs.writeFileSync(tmp, JSON.stringify(choice, null, 2) + "\n", { mode: 0o600 });
|
|
57
|
+
fs.chmodSync(tmp, 0o600);
|
|
58
|
+
fs.renameSync(tmp, file);
|
|
59
|
+
return choice;
|
|
60
|
+
}
|
|
61
|
+
function createdAtMs(dir, config) {
|
|
62
|
+
const fromConfig = typeof config.createdAt === "string" ? Date.parse(config.createdAt) : NaN;
|
|
63
|
+
if (Number.isFinite(fromConfig))
|
|
64
|
+
return fromConfig;
|
|
65
|
+
try {
|
|
66
|
+
const stat = fs.statSync(dir);
|
|
67
|
+
return stat.birthtimeMs > 0 ? stat.birthtimeMs : stat.ctimeMs;
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
return Number.POSITIVE_INFINITY;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/** Every personal bot set up here, earliest created first (name order breaks ties). */
|
|
74
|
+
export function listPersonalBots(opts = {}) {
|
|
75
|
+
const { root } = locations(opts);
|
|
76
|
+
let entries;
|
|
77
|
+
try {
|
|
78
|
+
entries = fs.readdirSync(root, { withFileTypes: true });
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
return [];
|
|
82
|
+
}
|
|
83
|
+
const bots = [];
|
|
84
|
+
for (const entry of entries) {
|
|
85
|
+
if (!entry.isDirectory())
|
|
86
|
+
continue;
|
|
87
|
+
const dir = path.join(root, entry.name);
|
|
88
|
+
let config;
|
|
89
|
+
try {
|
|
90
|
+
config = readBotConfig(dir);
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
config = null;
|
|
94
|
+
}
|
|
95
|
+
if (!config || effectiveBotKind(config) !== "personal")
|
|
96
|
+
continue;
|
|
97
|
+
bots.push({ name: entry.name, dir, config, createdAtMs: createdAtMs(dir, config) });
|
|
98
|
+
}
|
|
99
|
+
return bots.sort((a, b) => a.createdAtMs - b.createdAtMs || a.name.localeCompare(b.name));
|
|
100
|
+
}
|
|
101
|
+
export function resolveExecutiveBot(opts = {}) {
|
|
102
|
+
const personal = listPersonalBots(opts);
|
|
103
|
+
const choice = readExecutiveChoice(opts);
|
|
104
|
+
if (choice) {
|
|
105
|
+
const chosen = personal.find((bot) => bot.name === choice.bot);
|
|
106
|
+
if (chosen)
|
|
107
|
+
return { name: chosen.name, source: "chosen", config: chosen.config, dir: chosen.dir };
|
|
108
|
+
}
|
|
109
|
+
const first = personal[0];
|
|
110
|
+
return first ? { name: first.name, source: "default", config: first.config, dir: first.dir } : null;
|
|
111
|
+
}
|
|
112
|
+
export function isExecutiveBotName(name, opts = {}) {
|
|
113
|
+
return resolveExecutiveBot(opts)?.name === name;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Make `name` the Executive bot. The bot must be set up on this computer and
|
|
117
|
+
* be a personal bot; a company bot is refused.
|
|
118
|
+
*/
|
|
119
|
+
export function setExecutiveBot(name, opts = {}, now = new Date()) {
|
|
120
|
+
const valid = validateBotName(name);
|
|
121
|
+
const { root } = locations(opts);
|
|
122
|
+
const dir = path.join(root, valid);
|
|
123
|
+
const config = readBotConfig(dir);
|
|
124
|
+
if (!config) {
|
|
125
|
+
throw Object.assign(new Error(`No bot named "${valid}" is set up on this computer. See the bots here with: hq bot list`), { expected: true });
|
|
126
|
+
}
|
|
127
|
+
if (effectiveBotKind(config) !== "personal") {
|
|
128
|
+
const personal = listPersonalBots(opts).map((bot) => bot.name);
|
|
129
|
+
throw Object.assign(new Error(`${valid} is a company bot. The Executive bot must be a personal bot (one that acts as you).` +
|
|
130
|
+
(personal.length > 0 ? ` Personal bots here: ${personal.join(", ")}.` : " There is no personal bot on this computer yet.")), { expected: true });
|
|
131
|
+
}
|
|
132
|
+
const before = resolveExecutiveBot(opts);
|
|
133
|
+
writeExecutiveChoice(valid, opts, now);
|
|
134
|
+
return { name: valid, source: "chosen", runtime: config.runtime, changed: before?.name !== valid };
|
|
135
|
+
}
|
|
136
|
+
/** One plain sentence saying how the Executive bot was decided. */
|
|
137
|
+
export function describeExecutiveBotSource(bot) {
|
|
138
|
+
if (!bot)
|
|
139
|
+
return "No Executive bot: there is no personal bot on this computer. Create one with: hq bot create assistant";
|
|
140
|
+
if (bot.source === "chosen")
|
|
141
|
+
return `${bot.name} is the Executive bot (chosen with hq bot eb ${bot.name}).`;
|
|
142
|
+
return `${bot.name} is the Executive bot (the default: the first personal bot created on this computer; choose another with hq bot eb <name>).`;
|
|
143
|
+
}
|
|
144
|
+
//# sourceMappingURL=executive.js.map
|
|
@@ -104,6 +104,13 @@ export interface EnsureFleetHotSignalSyncInput {
|
|
|
104
104
|
* bot start without re-registering the job.
|
|
105
105
|
*/
|
|
106
106
|
signalsJobEnabled: boolean;
|
|
107
|
+
/**
|
|
108
|
+
* Whether this bot is the Executive bot (lib/bot/executive.ts). Other personal bots
|
|
109
|
+
* hand over only companies with a confirmed replacement job. Default true.
|
|
110
|
+
*/
|
|
111
|
+
executive?: boolean;
|
|
112
|
+
/** Companies with an actual replacement job on the Executive bot. */
|
|
113
|
+
executiveCompanies?: readonly string[];
|
|
107
114
|
now?: Date;
|
|
108
115
|
}
|
|
109
116
|
export interface FleetHotSignalSyncCompanyResult {
|
|
@@ -259,7 +259,8 @@ export function fleetHotSignalSyncCompanies(config, activeCompany, ownerCompanie
|
|
|
259
259
|
return single ? [single] : [];
|
|
260
260
|
}
|
|
261
261
|
export function ensureFleetHotSignalSync(input) {
|
|
262
|
-
const companies = fleetHotSignalSyncCompanies(input.config, input.activeCompany, input.ownerCompanies)
|
|
262
|
+
const companies = fleetHotSignalSyncCompanies(input.config, input.activeCompany, input.ownerCompanies)
|
|
263
|
+
.filter((company) => input.executive !== false || !input.executiveCompanies?.includes(company));
|
|
263
264
|
const wanted = new Set(companies);
|
|
264
265
|
const jobs = input.ops.list();
|
|
265
266
|
const removed = [];
|
|
@@ -80,15 +80,15 @@ export function sharedRuntimeLayout(root, id, platform) {
|
|
|
80
80
|
}
|
|
81
81
|
export const HQ_FLEET_LOCAL_RELEASE = {
|
|
82
82
|
repository: "indigoai-us/hq-fleet-local",
|
|
83
|
-
tag: "v0.4.
|
|
84
|
-
version: "0.4.
|
|
85
|
-
artifact: "hq-fleet-local-0.4.
|
|
86
|
-
artifactSha256: "
|
|
87
|
-
runtimeArtifact: "hq-fleet-runtime-
|
|
88
|
-
runtimeArtifactSha256: "
|
|
89
|
-
manifestSha256: "
|
|
90
|
-
signatureSha256: "
|
|
91
|
-
runtimeCommit: "
|
|
83
|
+
tag: "v0.4.28",
|
|
84
|
+
version: "0.4.28",
|
|
85
|
+
artifact: "hq-fleet-local-0.4.28.zip",
|
|
86
|
+
artifactSha256: "7ddb302db63e771aca6b53fa7cf295446016746e7dd508ecb1568ef8bdc40bfd",
|
|
87
|
+
runtimeArtifact: "hq-fleet-runtime-1f8e7cb662f4.tar.gz",
|
|
88
|
+
runtimeArtifactSha256: "44e53714fcaf2ce823d05a8a91f86806e4ce88d24e9c52aba853eb389ea4d85f",
|
|
89
|
+
manifestSha256: "a58834dd3a4abaa45a5eb180ad24de10df800ca561b80f45de5ab03d8d71e26d",
|
|
90
|
+
signatureSha256: "b3c3f338af6964417e1630ac735248c5969aebe946d65d14617a2429a32d4a17",
|
|
91
|
+
runtimeCommit: "1f8e7cb662f43836aa4edff167bcaf5e92998fb1",
|
|
92
92
|
};
|
|
93
93
|
/** hq-fleet-local trust/release-public.pem (rotated 2026-10-30; signed v0.4.17). */
|
|
94
94
|
export const HQ_FLEET_LOCAL_PUBLIC_KEY = `-----BEGIN PUBLIC KEY-----
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Remove the Executive-only jobs this bot holds and forget their markers. Returns how many jobs were removed. */
|
|
2
|
+
export declare function handOverExecutiveJobs(dir: string): {
|
|
3
|
+
removed: number;
|
|
4
|
+
forgot: boolean;
|
|
5
|
+
};
|
|
6
|
+
//# sourceMappingURL=executive-handover.d.ts.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* When a bot starts and is no longer the Executive bot (lib/bot/executive.ts),
|
|
3
|
+
* it drops the built-in jobs only the Executive bot runs: the meeting rider
|
|
4
|
+
* and the signal-to-lane jobs (the hot-signal-sync hand-over lives in
|
|
5
|
+
* hot-signal-sync.ts and fleet-cron.ts). Their builtin-jobs.json markers are
|
|
6
|
+
* cleared too, so the same bot registers them again if it becomes the
|
|
7
|
+
* Executive bot later.
|
|
8
|
+
*/
|
|
9
|
+
import { readLocalJobsStrict, withJobsLock, writeLocalJobs } from "../local-jobs.js";
|
|
10
|
+
import { readBuiltinJobsMarker, writeBuiltinJobsMarker } from "./hot-signal-sync.js";
|
|
11
|
+
import { MEETING_RIDER_JOB_KIND } from "./meeting-rider.js";
|
|
12
|
+
import { SIGNAL_TO_LANE_JOB_KIND } from "./signal-to-lane.js";
|
|
13
|
+
const EXECUTIVE_ONLY_JOB_KINDS = [MEETING_RIDER_JOB_KIND, SIGNAL_TO_LANE_JOB_KIND];
|
|
14
|
+
function isExecutiveOnlyMarker(key) {
|
|
15
|
+
return EXECUTIVE_ONLY_JOB_KINDS.some((kind) => key === kind || key.startsWith(`${kind}:`));
|
|
16
|
+
}
|
|
17
|
+
/** Remove the Executive-only jobs this bot holds and forget their markers. Returns how many jobs were removed. */
|
|
18
|
+
export function handOverExecutiveJobs(dir) {
|
|
19
|
+
return withJobsLock(dir, () => {
|
|
20
|
+
const jobs = readLocalJobsStrict(dir);
|
|
21
|
+
const kept = jobs.filter((job) => !EXECUTIVE_ONLY_JOB_KINDS.includes(String(job.context?.jobKind ?? "")));
|
|
22
|
+
if (kept.length !== jobs.length)
|
|
23
|
+
writeLocalJobs(dir, kept);
|
|
24
|
+
const marker = readBuiltinJobsMarker(dir);
|
|
25
|
+
const stale = Object.keys(marker.registered).filter(isExecutiveOnlyMarker);
|
|
26
|
+
for (const key of stale)
|
|
27
|
+
delete marker.registered[key];
|
|
28
|
+
if (stale.length > 0)
|
|
29
|
+
writeBuiltinJobsMarker(dir, marker);
|
|
30
|
+
return { removed: jobs.length - kept.length, forgot: stale.length > 0 };
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=executive-handover.js.map
|