@indigoai-us/hq-cli 5.345.222 → 5.345.225
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 +89 -0
- package/assets/bot-workers/setup/context/quick-reference.md +2 -2
- package/assets/mesh-daemon/README.md +11 -12
- package/dist/command-catalog.generated.d.ts +79 -5
- package/dist/command-catalog.generated.js +95 -5
- package/dist/commands/bot.d.ts +1 -1
- package/dist/commands/bot.js +34 -33
- package/dist/commands/cloud-provision.d.ts +4 -1
- package/dist/commands/cloud-provision.js +7 -3
- package/dist/commands/cloud-retire.js +1 -1
- package/dist/commands/core-delegate-w1b.js +210 -188
- package/dist/commands/core-delegate.d.ts +5 -0
- package/dist/commands/core-dm-bind-native.d.ts +5 -1
- package/dist/commands/core-dm-bind-native.js +4 -0
- package/dist/commands/core-job-notify-native.d.ts +5 -1
- package/dist/commands/core-job-notify-native.js +8 -2
- package/dist/commands/core-jobs-native.d.ts +27 -1
- package/dist/commands/core-jobs-native.js +49 -28
- package/dist/commands/core-pipeline-conductor-native.js +7 -7
- package/dist/commands/core-pipeline-driver-native.js +5 -5
- package/dist/commands/core-refresh-vault-access-native.d.ts +5 -0
- package/dist/commands/core-refresh-vault-access-native.js +3 -1
- package/dist/commands/core-work-mesh-bind-trusted-native.js +1 -1
- package/dist/commands/daemon.d.ts +2 -0
- package/dist/commands/daemon.js +67 -1
- package/dist/commands/lanes-hold.d.ts +2 -27
- package/dist/commands/lanes-hold.js +3 -75
- package/dist/commands/lanes-loop.js +1 -1
- package/dist/commands/lanes-session-start.js +2 -2
- package/dist/commands/mesh.d.ts +12 -0
- package/dist/commands/mesh.js +13 -4
- package/dist/commands/monitor.js +1 -1
- package/dist/commands/packs.js +14 -3
- package/dist/commands/sync-core.js +31 -12
- package/dist/commands/whoami.d.ts +10 -17
- package/dist/commands/whoami.js +7 -79
- package/dist/data/command-states.json +13 -0
- package/dist/index.js +1 -1
- package/dist/lib/bot/fleet-cron.d.ts +26 -3
- package/dist/lib/bot/fleet-cron.js +44 -4
- package/dist/lib/bot/run.d.ts +4 -4
- package/dist/lib/bot/run.js +5 -3
- package/dist/lib/bot/signals-engine-flag.d.ts +53 -13
- package/dist/lib/bot/signals-engine-flag.js +202 -9
- package/dist/lib/daemon/catalog.d.ts +8 -5
- package/dist/lib/daemon/catalog.js +13 -7
- package/dist/lib/daemon/config.d.ts +5 -0
- package/dist/lib/daemon/config.js +6 -0
- package/dist/lib/daemon/lanes-monitor-state.d.ts +55 -0
- package/dist/lib/daemon/lanes-monitor-state.js +129 -0
- package/dist/lib/daemon/lanes-reconcile-loader.d.ts +7 -0
- package/dist/lib/daemon/lanes-reconcile-loader.js +13 -0
- package/dist/lib/daemon/machine-checks.d.ts +45 -0
- package/dist/lib/daemon/machine-checks.js +95 -11
- package/dist/lib/daemon/merge-sections.d.ts +165 -0
- package/dist/lib/daemon/merge-sections.js +556 -0
- package/dist/lib/daemon/native-notice-ledger.d.ts +9 -0
- package/dist/lib/daemon/native-notice-ledger.js +43 -0
- package/dist/lib/daemon/ops/policy.d.ts +1 -1
- package/dist/lib/daemon/ops/policy.js +1 -1
- package/dist/lib/daemon/protocol.d.ts +1 -1
- package/dist/lib/daemon/protocol.js +0 -6
- package/dist/lib/daemon/run.js +76 -3
- package/dist/lib/daemon/selfcheck.js +2 -2
- package/dist/lib/daemon/server.d.ts +2 -4
- package/dist/lib/daemon/server.js +5 -48
- package/dist/lib/daemon/state-file.d.ts +74 -4
- package/dist/lib/daemon/state-file.js +159 -19
- package/dist/lib/daemon/supervisor.d.ts +11 -1
- package/dist/lib/daemon/supervisor.js +86 -0
- package/dist/lib/daemon/updater.d.ts +2 -6
- package/dist/lib/daemon/updater.js +4 -11
- package/dist/lib/daemon/whoami-cache.d.ts +96 -0
- package/dist/lib/daemon/whoami-cache.js +244 -0
- package/dist/lib/flag-registry-worker-source.generated.d.ts +1 -1
- package/dist/lib/flag-registry-worker-source.generated.js +1 -1
- package/dist/lib/flag-registry-worker.js +33 -3
- package/dist/lib/flag-registry.js +13 -0
- package/dist/lib/hook-engine/coverage.d.ts +2 -0
- package/dist/lib/hook-engine/coverage.js +71 -0
- package/dist/lib/hook-engine/native-precompact-compatibility.json +449 -0
- package/dist/lib/hook-engine/reconcile.js +14 -8
- package/dist/lib/install/hook-target.d.ts +13 -3
- package/dist/lib/install/hook-target.js +14 -11
- package/dist/lib/lanes/envelope-repair-dispatch.js +1 -1
- package/dist/lib/lanes/monitor.d.ts +2 -0
- package/dist/lib/lanes/monitor.js +2 -1
- package/dist/lib/lanes/registry-flag.d.ts +6 -0
- package/dist/lib/lanes/registry-flag.js +3 -2
- package/dist/lib/lanes/repo-merge-hold.d.ts +39 -0
- package/dist/lib/lanes/repo-merge-hold.js +90 -0
- package/dist/lib/lanes/watcher-main.js +3 -3
- package/dist/lib/mesh/live/daemon/doctor.js +1 -1
- package/dist/lib/mesh/live/daemon/install.js +2 -2
- package/dist/lib/scan-packages/index.js +8 -9
- package/dist/lib/signals/engine.d.ts +8 -0
- package/dist/lib/signals/engine.js +15 -5
- package/dist/lib/sync-core/flag.d.ts +18 -0
- package/dist/lib/sync-core/flag.js +66 -0
- package/dist/lib/sync-core/reconcile.d.ts +6 -0
- package/dist/lib/sync-core/reconcile.js +15 -0
- package/dist/lib/sync-core/rollout-state.d.ts +2 -0
- package/dist/lib/sync-core/rollout-state.js +7 -0
- package/dist/lib/sync-core/vault-settings.d.ts +12 -1
- package/dist/lib/sync-core/vault-settings.js +23 -7
- package/dist/lib/windows/install-followup.js +1 -1
- package/dist/utils/client-health-contract.d.ts +1 -0
- package/dist/utils/client-health-contract.js +5 -0
- package/dist/utils/client-health.d.ts +2 -0
- package/dist/utils/client-health.js +40 -0
- package/dist/utils/cognito-session.d.ts +2 -14
- package/dist/utils/cognito-session.js +2 -40
- package/dist/utils/daemon-cli-version.d.ts +13 -0
- package/dist/utils/daemon-cli-version.js +47 -0
- package/dist/utils/duplicate-command-usage.js +1 -1
- package/dist/utils/machine-token-cache.d.ts +21 -0
- package/dist/utils/machine-token-cache.js +49 -0
- package/dist/utils/pack-contributions.d.ts +14 -2
- package/dist/utils/pack-contributions.js +31 -5
- package/dist/utils/resident-package-preload.js +4 -0
- package/dist/utils/whoami-identity.d.ts +54 -0
- package/dist/utils/whoami-identity.js +108 -0
- package/package.json +7 -7
- package/scripts/bench-core.mjs +34 -3
- package/dist/lib/daemon/ops/memory.d.ts +0 -18
- package/dist/lib/daemon/ops/memory.js +0 -65
- package/dist/lib/daemon/ops/mesh.d.ts +0 -38
- package/dist/lib/daemon/ops/mesh.js +0 -70
package/dist/commands/mesh.js
CHANGED
|
@@ -2604,7 +2604,7 @@ async function runMeshMode(action, opts) {
|
|
|
2604
2604
|
(mode !== act
|
|
2605
2605
|
? ` (note: HQ_MESH_MODE=${process.env.HQ_MESH_MODE} overrides → ${mode})`
|
|
2606
2606
|
: "") +
|
|
2607
|
-
`. Restart the daemon (hq
|
|
2607
|
+
`. Restart the daemon (hq daemon restart mesh) to apply.`);
|
|
2608
2608
|
return;
|
|
2609
2609
|
}
|
|
2610
2610
|
if (act === "check") {
|
|
@@ -3081,7 +3081,7 @@ export function registerMeshCommand(program, deps = {}) {
|
|
|
3081
3081
|
.command("run")
|
|
3082
3082
|
.description("Start the single-instance daemon (pid lock, spool watch, presence)")
|
|
3083
3083
|
.option("--hq-root <path>", "HQ tree root (else HQ_ROOT / persisted trusted roots); the Windows task passes this explicitly")
|
|
3084
|
-
.action((opts) => wrap(() =>
|
|
3084
|
+
.action((opts) => wrap(() => runMeshDaemonService(opts))());
|
|
3085
3085
|
daemon
|
|
3086
3086
|
.command("install")
|
|
3087
3087
|
.description("Install LaunchAgent (macOS), systemd user unit (Linux), or Scheduled Task (Windows)")
|
|
@@ -3104,7 +3104,7 @@ export function registerMeshCommand(program, deps = {}) {
|
|
|
3104
3104
|
.command("doctor")
|
|
3105
3105
|
.description("Report daemon running/MQTT/spool/held/dead-letter/outbox/flush health")
|
|
3106
3106
|
.option("--json", "Print machine-readable JSON")
|
|
3107
|
-
.action((opts) => wrap(() =>
|
|
3107
|
+
.action((opts) => wrap(() => runMeshDaemonDoctor(opts))());
|
|
3108
3108
|
mesh
|
|
3109
3109
|
.command("push-status")
|
|
3110
3110
|
.description("Report whether the owner DM push signal is live or stale, with the last event time")
|
|
@@ -3125,6 +3125,14 @@ async function runMeshPushStatus(opts) {
|
|
|
3125
3125
|
if (status.status === "stale")
|
|
3126
3126
|
process.exitCode = 1;
|
|
3127
3127
|
}
|
|
3128
|
+
/**
|
|
3129
|
+
* The resident Work Mesh loop. `hq daemon` runs it as its `mesh` service
|
|
3130
|
+
* (`hq daemon service mesh`); `hq mesh daemon run`, which older standalone
|
|
3131
|
+
* units still start, is retiring and runs the same loop.
|
|
3132
|
+
*/
|
|
3133
|
+
export async function runMeshDaemonService(opts = {}) {
|
|
3134
|
+
await runResidentCommandWithPackageLease("mesh-daemon", () => runDaemonRun(opts));
|
|
3135
|
+
}
|
|
3128
3136
|
async function runDaemonRun(opts = {}) {
|
|
3129
3137
|
const { runMeshDaemon } = await import("../lib/mesh/live/daemon/run.js");
|
|
3130
3138
|
const hqRoot = opts.hqRoot?.trim() || undefined;
|
|
@@ -3277,7 +3285,8 @@ export async function runDaemonStatus(opts, deps = {}) {
|
|
|
3277
3285
|
console.log(`mqtt: ${state.mqttState}`);
|
|
3278
3286
|
}
|
|
3279
3287
|
}
|
|
3280
|
-
|
|
3288
|
+
/** Work Mesh health report: `hq daemon doctor` (and the retiring `hq mesh daemon doctor`). */
|
|
3289
|
+
export async function runMeshDaemonDoctor(opts) {
|
|
3281
3290
|
// Same predicate as install: a repo's .claude/ is not an HQ root. Doctor
|
|
3282
3291
|
// only reads, so an unresolvable root is reported as absent, not fatal.
|
|
3283
3292
|
const report = collectDaemonDoctor({
|
package/dist/commands/monitor.js
CHANGED
|
@@ -465,7 +465,7 @@ export function invokeLaneMonitorMessage(hqRoot, meta, sequence, text, inProcess
|
|
|
465
465
|
const cliEntrypoint = process.argv[1];
|
|
466
466
|
if (!cliEntrypoint)
|
|
467
467
|
throw new LanesError("monitor_cli_path_missing", "Could not locate the hq CLI entry point for lane delivery.");
|
|
468
|
-
const result = spawnSync(process.execPath, [cliEntrypoint, "
|
|
468
|
+
const result = spawnSync(process.execPath, [cliEntrypoint, "runners", "_monitor-message", meta.target.laneId], {
|
|
469
469
|
cwd: meta.cwd,
|
|
470
470
|
env: { ...process.env, HQ_ROOT: hqRoot },
|
|
471
471
|
input: JSON.stringify({ text, monitor_id: meta.monitor_id, description: meta.description, sequence }),
|
package/dist/commands/packs.js
CHANGED
|
@@ -29,7 +29,7 @@ import { findHqRoot } from '../utils/manifest.js';
|
|
|
29
29
|
import { resolveHqRoot as resolveDetectedHqRoot } from './doctor.js';
|
|
30
30
|
import { anywhereRuntimeAllowed } from '../lib/anywhere-person-setting.js';
|
|
31
31
|
import { classify, PINNED_HQ_ANYWHERE_SOURCE, resolveLatest, parseMarketplaceSource, resolveLatestMarketplace, runScanPackages, installPack, } from './pack-install.js';
|
|
32
|
-
import { contributionLinks, linkStatus, listInstalledPacks, findDependentPacks, readPackManifest, unwirePack, unwirePackMcp, readHqVersion, readRecommendedPackages, packagesDir, } from '../utils/pack-contributions.js';
|
|
32
|
+
import { contributionLinks, linkStatus, listInstalledPacks, findDependentPacks, readPackManifest, unwirePack, unwireNamespacedSkills, unwirePackMcp, readHqVersion, readRecommendedPackages, packagesDir, } from '../utils/pack-contributions.js';
|
|
33
33
|
import { readInstalledPackSetup } from '../lib/packages/setup-block.js';
|
|
34
34
|
import { syncCodexPackHooks, syncCodexPackSkills } from '../lib/install/codex-pack-contributions.js';
|
|
35
35
|
function resolveRoot(opts) {
|
|
@@ -275,7 +275,11 @@ export async function runUpdate(name, opts, deps = {}) {
|
|
|
275
275
|
syncCodexPackSkills(pack.dir, pname, m.contributes?.skills ?? [], true);
|
|
276
276
|
// Un-wire old contributions first so a contribution dropped by the new
|
|
277
277
|
// version doesn't leave a dangling host symlink. installPack re-wires.
|
|
278
|
-
|
|
278
|
+
// The namespaced `<pack>:<skill>` hosts stay: the pack directory is
|
|
279
|
+
// replaced in place, so they keep resolving, and removing them would
|
|
280
|
+
// hide `/<pack>:<skill>` until the next reindex. Hosts of skills the new
|
|
281
|
+
// version dropped are removed after the install below.
|
|
282
|
+
unwirePack(hqRoot, pack.dir, m.contributes ?? {}, { keepNamespacedSkills: true });
|
|
279
283
|
const prevCwd = process.cwd();
|
|
280
284
|
if (opts.hqRoot)
|
|
281
285
|
process.chdir(hqRoot); // installPack resolves via findHqRoot()
|
|
@@ -294,6 +298,13 @@ export async function runUpdate(name, opts, deps = {}) {
|
|
|
294
298
|
if (opts.hqRoot)
|
|
295
299
|
process.chdir(prevCwd);
|
|
296
300
|
}
|
|
301
|
+
// An unreadable new manifest says nothing about which skills were
|
|
302
|
+
// dropped, so leave the namespaced hosts for reindex to reconcile.
|
|
303
|
+
const newManifest = readPackManifest(pack.dir).manifest;
|
|
304
|
+
if (newManifest) {
|
|
305
|
+
const newSkills = new Set(newManifest.contributes?.skills ?? []);
|
|
306
|
+
unwireNamespacedSkills(hqRoot, pack.dir, (m.contributes?.skills ?? []).filter((item) => !newSkills.has(item)));
|
|
307
|
+
}
|
|
297
308
|
results.push({ ...base, applied: true });
|
|
298
309
|
}
|
|
299
310
|
catch (e) {
|
|
@@ -471,7 +482,7 @@ export function registerPacksCommand(parent) {
|
|
|
471
482
|
.option('--allow-hooks', 'Install pack hooks without prompting')
|
|
472
483
|
.option('--allow-mcp', 'Register pack MCP servers without prompting')
|
|
473
484
|
.option('--branch', 'Follow the source branch instead of SHA-pinning')
|
|
474
|
-
.addOption(new Option('--registry', 'Update installed registry packages instead
|
|
485
|
+
.addOption(new Option('--registry', 'Update installed registry packages instead of content packs ([name] is the package slug)').conflicts([...CONTENT_PACK_UPDATE_OPTIONS]))
|
|
475
486
|
.action(async (name, opts) => {
|
|
476
487
|
if (opts.registry) {
|
|
477
488
|
// Exactly the `hq packages update [slug]` path: same function, lease,
|
|
@@ -3,13 +3,13 @@ import * as os from "node:os";
|
|
|
3
3
|
import * as path from "node:path";
|
|
4
4
|
import { ensureSyncCoreBinary, readSyncCorePin } from "../lib/sync-core/release.js";
|
|
5
5
|
import { readEngineStatus } from "../lib/sync-core/engine-home.js";
|
|
6
|
-
import { readCompanyRolloutFlag } from "../lib/sync-core/flag.js";
|
|
6
|
+
import { readCompanyDownloadStreams, readCompanyRolloutFlag } from "../lib/sync-core/flag.js";
|
|
7
7
|
import { reconcileSyncCore } from "../lib/sync-core/reconcile.js";
|
|
8
8
|
import { engineOwnedManifestScopes, manifestScopeArg } from "../lib/sync-core/manifest-scopes.js";
|
|
9
9
|
import { readSyncCoreRolloutState, syncCoreRolloutStatePath } from "../lib/sync-core/rollout-state.js";
|
|
10
10
|
import { readVaultSyncSwitches } from "../lib/vault-sync-switches.js";
|
|
11
11
|
import { isSyncCoreVaultUid } from "../lib/sync-core/vault-uid.js";
|
|
12
|
-
import { readSyncCoreVaultSettings, setSyncCoreVaultSetting, SyncCoreVaultSettingError, } from "../lib/sync-core/vault-settings.js";
|
|
12
|
+
import { effectiveEngineSettings, readSyncCoreVaultSettings, setSyncCoreVaultSetting, SyncCoreVaultSettingError, } from "../lib/sync-core/vault-settings.js";
|
|
13
13
|
function defaultDeps() {
|
|
14
14
|
return {
|
|
15
15
|
home: os.homedir(),
|
|
@@ -61,6 +61,7 @@ export async function runSyncCoreReconcile(opts, d = defaultDeps()) {
|
|
|
61
61
|
getEntity: async () => null,
|
|
62
62
|
}),
|
|
63
63
|
readRolloutFlag: (companyUid) => readCompanyRolloutFlag(companyUid, token, { env: d.env }),
|
|
64
|
+
readDownloadStreams: (companyUid) => readCompanyDownloadStreams(companyUid, token, { env: d.env }),
|
|
64
65
|
ensureBinary: (release) => ensureSyncCoreBinary({ home: d.home, platform: d.platform, arch: d.arch, release, env: d.env }),
|
|
65
66
|
platform: d.platform,
|
|
66
67
|
env: d.env,
|
|
@@ -231,29 +232,47 @@ export function resolveSyncCoreVault(home, name, opts = {}) {
|
|
|
231
232
|
return match[0].uid;
|
|
232
233
|
throw new SyncCoreVaultSettingError(`No vault named ${JSON.stringify(wanted)} is on the new sync engine on this machine. Pass a company slug from hq sync-core status, personal, or a vault uid.`);
|
|
233
234
|
}
|
|
234
|
-
function describeSettings(settings) {
|
|
235
|
-
if (!settings?.parallelDownloads)
|
|
236
|
-
return "parallel-downloads off (default)";
|
|
237
|
-
|
|
235
|
+
function describeSettings(settings, source) {
|
|
236
|
+
if (!settings?.parallelDownloads) {
|
|
237
|
+
return source === "computer" ? "parallel-downloads off (this computer)" : "parallel-downloads off (default)";
|
|
238
|
+
}
|
|
239
|
+
const text = `parallel-downloads on, download-streams ${settings.downloadStreams ?? "default"}`;
|
|
240
|
+
return source === "company" ? `${text} (company setting)` : text;
|
|
238
241
|
}
|
|
239
242
|
export function runSyncCoreConfig(vault, key, value, opts, d = defaultDeps()) {
|
|
240
243
|
try {
|
|
241
244
|
const clearing = key !== undefined && (value === "off" || value === "default");
|
|
242
245
|
const uid = resolveSyncCoreVault(d.home, vault, { clearing });
|
|
243
|
-
|
|
246
|
+
const onEngine = readSyncCoreRolloutState(d.home)?.vaults.find((entry) => entry.uid === uid);
|
|
247
|
+
let local;
|
|
244
248
|
if (key === undefined) {
|
|
245
|
-
|
|
249
|
+
local = readSyncCoreVaultSettings(d.home).get(uid);
|
|
246
250
|
}
|
|
247
251
|
else {
|
|
248
252
|
if (value === undefined)
|
|
249
253
|
throw new SyncCoreVaultSettingError(`Give a value for ${key}`);
|
|
250
|
-
|
|
254
|
+
// A vault no longer on the engine here has no company value to opt out
|
|
255
|
+
// of, so turning it off just removes the stale entry.
|
|
256
|
+
const stored = !onEngine && key === "parallel-downloads" && value === "off" ? "default" : value;
|
|
257
|
+
local = setSyncCoreVaultSetting(d.home, uid, key, stored);
|
|
251
258
|
}
|
|
259
|
+
const companyStreams = onEngine?.downloadStreams;
|
|
260
|
+
const settings = effectiveEngineSettings(local, companyStreams);
|
|
261
|
+
const source = local?.parallelDownloads !== undefined ? "computer" : settings ? "company" : "default";
|
|
252
262
|
if (opts.json) {
|
|
253
|
-
d.out(JSON.stringify({
|
|
263
|
+
d.out(JSON.stringify({
|
|
264
|
+
vault: uid,
|
|
265
|
+
parallelDownloads: settings?.parallelDownloads === true,
|
|
266
|
+
downloadStreams: settings?.downloadStreams ?? null,
|
|
267
|
+
source,
|
|
268
|
+
companyDownloadStreams: companyStreams ?? null,
|
|
269
|
+
}));
|
|
254
270
|
return;
|
|
255
271
|
}
|
|
256
|
-
d.out(`${uid}: ${describeSettings(settings)}`);
|
|
272
|
+
d.out(`${uid}: ${describeSettings(settings, source)}`);
|
|
273
|
+
if (source === "computer" && companyStreams !== undefined) {
|
|
274
|
+
d.out(`The company setting (${companyStreams} download streams) applies again after: hq sync-core config ${vault} parallel-downloads default`);
|
|
275
|
+
}
|
|
257
276
|
if (key !== undefined) {
|
|
258
277
|
d.out("Only this computer is changed. hq daemon restarts this vault's sync engine within about 15 seconds. Engine releases without parallel downloads ignore the setting.");
|
|
259
278
|
}
|
|
@@ -287,7 +306,7 @@ export function registerSyncCoreCommand(program, over = {}) {
|
|
|
287
306
|
});
|
|
288
307
|
syncCore
|
|
289
308
|
.command("config <vault> [key] [value]")
|
|
290
|
-
.description("Show or change this computer's new sync engine settings for one vault: parallel-downloads on|off, download-streams 1-32|default")
|
|
309
|
+
.description("Show or change this computer's new sync engine settings for one vault: parallel-downloads on|off|default (default follows the company setting), download-streams 1-32|default")
|
|
291
310
|
.option("--json", "Print JSON")
|
|
292
311
|
.action((vault, key, value, opts) => runSyncCoreConfig(vault, key, value, opts, deps()));
|
|
293
312
|
syncCore
|
|
@@ -2,25 +2,10 @@
|
|
|
2
2
|
* hq whoami — displays current user or 'not logged in'
|
|
3
3
|
*/
|
|
4
4
|
import { Command } from 'commander';
|
|
5
|
+
import { type WhoamiTokenIdentity } from "../utils/whoami-identity.js";
|
|
5
6
|
import { type PlanLimitStatus } from "../lib/billing/plan-lock.js";
|
|
7
|
+
export { resolveWhoamiIdentity, type WhoamiDisplayIdentity, type WhoamiTokenIdentity, } from "../utils/whoami-identity.js";
|
|
6
8
|
export declare const CLI_LIMIT_INVITE_TEAMMATE_FLAG = "cli.limit-invite-teammate-v1";
|
|
7
|
-
export interface WhoamiTokenIdentity {
|
|
8
|
-
email?: string;
|
|
9
|
-
sub?: string;
|
|
10
|
-
delegatedEmail?: string;
|
|
11
|
-
delegatedSub?: string;
|
|
12
|
-
entityType?: string;
|
|
13
|
-
entityUid?: string;
|
|
14
|
-
}
|
|
15
|
-
export interface WhoamiDisplayIdentity {
|
|
16
|
-
email?: string;
|
|
17
|
-
sub?: string;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Resolves the person represented by an ID token without pairing a delegated
|
|
21
|
-
* email with the token subject of the delegating machine.
|
|
22
|
-
*/
|
|
23
|
-
export declare function resolveWhoamiIdentity(identity: WhoamiTokenIdentity): WhoamiDisplayIdentity;
|
|
24
9
|
/**
|
|
25
10
|
* Bound on the person-uid lookup, so `--json` callers with short timeouts still
|
|
26
11
|
* get an answer. Kept at 1s: with every endpoint stalled, a whole `whoami
|
|
@@ -28,6 +13,14 @@ export declare function resolveWhoamiIdentity(identity: WhoamiTokenIdentity): Wh
|
|
|
28
13
|
* (foreground-network-budget.test.ts); 3s overran it.
|
|
29
14
|
*/
|
|
30
15
|
export declare const PERSON_UID_LOOKUP_TIMEOUT_MS = 1000;
|
|
16
|
+
/**
|
|
17
|
+
* The signed-in person's canonical `prs_*` uid for `whoami --json`. Person ID
|
|
18
|
+
* tokens carry no `custom:entityType`/`custom:entityUid` claims, so the token
|
|
19
|
+
* alone almost never has it; the vault's person-entity lookup does (the same
|
|
20
|
+
* rule `hq secrets --personal` uses). Best-effort: no session, a timeout or a
|
|
21
|
+
* network failure resolve to null and the rest of the identity still prints.
|
|
22
|
+
*/
|
|
23
|
+
export declare function readPersonUid(identity: WhoamiTokenIdentity): Promise<string | null>;
|
|
31
24
|
export declare function renderWhoamiPlanBlock(status: PlanLimitStatus, opts?: {
|
|
32
25
|
inviteTeammateEnabled?: boolean;
|
|
33
26
|
}): string | null;
|
package/dist/commands/whoami.js
CHANGED
|
@@ -3,51 +3,17 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import chalk from 'chalk';
|
|
5
5
|
import { loadCachedTokens, isExpiring, loadMachineCreds, } from '@indigoai-us/hq-cloud';
|
|
6
|
-
import {
|
|
6
|
+
import { buildWhoamiIdentity, peekWhoamiTokenIdentity as peekIdToken, resolveWhoamiIdentity, } from "../utils/whoami-identity.js";
|
|
7
7
|
import { ensureCognitoToken, loadMachineCachedTokens, resolveCognitoTokenSource, } from "../utils/cognito-session.js";
|
|
8
8
|
import { colorizePlanLimitNotice, fetchPlanLimitStatus, renderPlanLine, renderPlanLimitNotice, } from "../lib/billing/plan-lock.js";
|
|
9
9
|
import { resolveCompanyFlagGate, } from "../lib/flag-registry.js";
|
|
10
10
|
import { queuePlanLimitInviteTeammateExposure } from "../utils/cli-telemetry.js";
|
|
11
11
|
import { resolveCallerPersonUid } from "../utils/vault-api.js";
|
|
12
12
|
import { printDeletedCompanyNotices } from "../utils/deleted-company-notice.js";
|
|
13
|
-
import {
|
|
13
|
+
import { formatAuthExpiry } from "../utils/auth-expiry.js";
|
|
14
14
|
import { authStatusExitCode } from "../utils/auth-session-check.js";
|
|
15
|
+
export { resolveWhoamiIdentity, } from "../utils/whoami-identity.js";
|
|
15
16
|
export const CLI_LIMIT_INVITE_TEAMMATE_FLAG = "cli.limit-invite-teammate-v1";
|
|
16
|
-
/**
|
|
17
|
-
* Resolves the person represented by an ID token without pairing a delegated
|
|
18
|
-
* email with the token subject of the delegating machine.
|
|
19
|
-
*/
|
|
20
|
-
export function resolveWhoamiIdentity(identity) {
|
|
21
|
-
if (identity.email !== undefined && identity.sub !== undefined) {
|
|
22
|
-
return { email: identity.email, sub: identity.sub };
|
|
23
|
-
}
|
|
24
|
-
if (identity.delegatedEmail !== undefined && identity.delegatedSub !== undefined) {
|
|
25
|
-
return { email: identity.delegatedEmail, sub: identity.delegatedSub };
|
|
26
|
-
}
|
|
27
|
-
if (identity.email !== undefined || identity.sub !== undefined) {
|
|
28
|
-
return { email: identity.email, sub: identity.sub };
|
|
29
|
-
}
|
|
30
|
-
return {};
|
|
31
|
-
}
|
|
32
|
-
function peekIdToken(idToken) {
|
|
33
|
-
const decoded = decodeIdToken(idToken);
|
|
34
|
-
return {
|
|
35
|
-
email: typeof decoded.email === "string" ? decoded.email : undefined,
|
|
36
|
-
sub: typeof decoded.sub === "string" ? decoded.sub : undefined,
|
|
37
|
-
delegatedEmail: typeof decoded["custom:delegatedEmail"] === "string"
|
|
38
|
-
? decoded["custom:delegatedEmail"]
|
|
39
|
-
: undefined,
|
|
40
|
-
delegatedSub: typeof decoded["custom:delegatedSub"] === "string"
|
|
41
|
-
? decoded["custom:delegatedSub"]
|
|
42
|
-
: undefined,
|
|
43
|
-
entityType: typeof decoded["custom:entityType"] === "string"
|
|
44
|
-
? decoded["custom:entityType"]
|
|
45
|
-
: undefined,
|
|
46
|
-
entityUid: typeof decoded["custom:entityUid"] === "string"
|
|
47
|
-
? decoded["custom:entityUid"]
|
|
48
|
-
: undefined,
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
17
|
/**
|
|
52
18
|
* Bound on the person-uid lookup, so `--json` callers with short timeouts still
|
|
53
19
|
* get an answer. Kept at 1s: with every endpoint stalled, a whole `whoami
|
|
@@ -62,7 +28,7 @@ export const PERSON_UID_LOOKUP_TIMEOUT_MS = 1_000;
|
|
|
62
28
|
* rule `hq secrets --personal` uses). Best-effort: no session, a timeout or a
|
|
63
29
|
* network failure resolve to null and the rest of the identity still prints.
|
|
64
30
|
*/
|
|
65
|
-
async function readPersonUid(identity) {
|
|
31
|
+
export async function readPersonUid(identity) {
|
|
66
32
|
if (identity.entityType === 'person' && identity.entityUid)
|
|
67
33
|
return identity.entityUid;
|
|
68
34
|
try {
|
|
@@ -170,7 +136,7 @@ export function registerWhoamiCommand(program) {
|
|
|
170
136
|
.description('Show signed-in user and session expiry')
|
|
171
137
|
.option('--json', 'Output identity metadata as JSON (never tokens)')
|
|
172
138
|
.option('--company <slug>', 'Also report this company\'s billing and usage notice')
|
|
173
|
-
.option('--check', 'Exit 1 when there is no usable session,
|
|
139
|
+
.option('--check', 'Exit 1 when there is no usable session, so a script can test the exit status')
|
|
174
140
|
.action(async (opts) => {
|
|
175
141
|
try {
|
|
176
142
|
// Effective source (same as auth status / ensureCognitoToken): env
|
|
@@ -199,48 +165,10 @@ export function registerWhoamiCommand(program) {
|
|
|
199
165
|
}
|
|
200
166
|
async function printWhoami(opts, machine, cached) {
|
|
201
167
|
if (opts.json) {
|
|
202
|
-
const machineCreds = machine ? loadMachineCreds() : null;
|
|
203
|
-
const identityCache = machine ? loadMachineCachedTokens() : cached;
|
|
204
|
-
const identity = identityCache ? peekIdToken(identityCache.idToken) : {};
|
|
205
|
-
const displayedIdentity = resolveWhoamiIdentity(identity);
|
|
206
|
-
const claims = identityCache ? decodeIdToken(identityCache.idToken) : {};
|
|
207
|
-
// Modern credentials carry the canonical UID. Legacy caches may only
|
|
208
|
-
// supply a UID when their subject is bound to the selected username.
|
|
209
|
-
const boundLegacyAgent = machineCreds && identity.entityType === 'agent'
|
|
210
|
-
&& (claims['cognito:username'] === machineCreds.username
|
|
211
|
-
|| claims.username === machineCreds.username || claims.sub === machineCreds.username)
|
|
212
|
-
? identity.entityUid ?? null : null;
|
|
213
|
-
const agentUid = machineCreds?.entityUid !== undefined
|
|
214
|
-
? (machineCreds.entityUid.startsWith('agt_') ? machineCreds.entityUid : null)
|
|
215
|
-
: boundLegacyAgent;
|
|
216
168
|
// planLimits is additive: absent-or-null means UNKNOWN.
|
|
217
169
|
const planLimits = await readPlanLimits(opts.company);
|
|
218
|
-
const
|
|
219
|
-
|
|
220
|
-
console.log(JSON.stringify({
|
|
221
|
-
schemaVersion: 1,
|
|
222
|
-
authenticated,
|
|
223
|
-
tokenSource: machine ? 'machine' : 'person',
|
|
224
|
-
email: machine ? null : displayedIdentity.email ?? null,
|
|
225
|
-
// Cognito subject of the person shown in `email` (null for machine
|
|
226
|
-
// identities). Outpost jobs record owners by this id.
|
|
227
|
-
sub: machine ? null : displayedIdentity.sub ?? null,
|
|
228
|
-
// The human an Outpost session acts for, from the token's
|
|
229
|
-
// delegated claims, for machine and person sources alike.
|
|
230
|
-
delegatedEmail: identity.delegatedEmail !== undefined && identity.delegatedSub !== undefined
|
|
231
|
-
? identity.delegatedEmail : null,
|
|
232
|
-
delegatedSub: identity.delegatedEmail !== undefined && identity.delegatedSub !== undefined
|
|
233
|
-
? identity.delegatedSub : null,
|
|
234
|
-
personUid,
|
|
235
|
-
agentUid,
|
|
236
|
-
username: machineCreds?.username ?? null,
|
|
237
|
-
// Additive (what `hq auth status` reported): when the cached
|
|
238
|
-
// session expires, and whether it is inside the refresh window.
|
|
239
|
-
// Both are null when no session is cached.
|
|
240
|
-
sessionExpiresAt: identityCache ? authExpiryIso(identityCache.expiresAt) : null,
|
|
241
|
-
sessionExpiring: identityCache ? isExpiring(identityCache) : null,
|
|
242
|
-
planLimits,
|
|
243
|
-
}, null, 2));
|
|
170
|
+
const identity = await buildWhoamiIdentity(machine, cached, readPersonUid, () => loadMachineCachedTokens());
|
|
171
|
+
console.log(JSON.stringify({ ...identity, planLimits }, null, 2));
|
|
244
172
|
return;
|
|
245
173
|
}
|
|
246
174
|
if (machine) {
|
|
@@ -3,13 +3,26 @@
|
|
|
3
3
|
"commands": {
|
|
4
4
|
"auth login": { "state": "retiring", "replacedBy": "hq login" },
|
|
5
5
|
"auth logout": { "state": "retiring", "replacedBy": "hq logout" },
|
|
6
|
+
"auth status": { "state": "retiring", "replacedBy": "hq whoami --check" },
|
|
7
|
+
"bot set-model": { "state": "retiring", "replacedBy": "hq bot set --model" },
|
|
6
8
|
"crm entity get": { "state": "retiring" },
|
|
7
9
|
"crm entity list": { "state": "retiring" },
|
|
10
|
+
"mesh blocked": { "state": "retiring", "replacedBy": "hq mesh session blocked" },
|
|
11
|
+
"mesh daemon doctor": { "state": "retiring", "replacedBy": "hq daemon doctor" },
|
|
12
|
+
"mesh daemon install": { "state": "retiring", "replacedBy": "hq daemon install" },
|
|
13
|
+
"mesh daemon run": { "state": "retiring", "replacedBy": "hq daemon run" },
|
|
14
|
+
"mesh daemon status": { "state": "retiring", "replacedBy": "hq daemon status" },
|
|
15
|
+
"mesh daemon uninstall": { "state": "retiring", "replacedBy": "hq daemon disable mesh" },
|
|
16
|
+
"mesh done": { "state": "retiring", "replacedBy": "hq mesh session task-status --status done" },
|
|
17
|
+
"mesh note": { "state": "retiring", "replacedBy": "hq mesh session note" },
|
|
18
|
+
"mesh progress": { "state": "retiring", "replacedBy": "hq mesh session note" },
|
|
19
|
+
"mesh start": { "state": "retiring", "replacedBy": "hq mesh session task-status --status in_progress" },
|
|
8
20
|
"packages install": { "state": "retiring", "replacedBy": "hq install" },
|
|
9
21
|
"packages packs list": { "state": "retiring", "replacedBy": "hq packs list" },
|
|
10
22
|
"packages packs uninstall": { "state": "retiring", "replacedBy": "hq packs uninstall" },
|
|
11
23
|
"packages packs update": { "state": "retiring", "replacedBy": "hq packs update" },
|
|
12
24
|
"packages remove": { "state": "retiring", "replacedBy": "hq remove" },
|
|
25
|
+
"packages update": { "state": "retiring", "replacedBy": "hq packs update --registry" },
|
|
13
26
|
"report access": { "state": "retiring" },
|
|
14
27
|
"report discard-draft": { "state": "retiring" },
|
|
15
28
|
"report promote": { "state": "retiring" },
|
package/dist/index.js
CHANGED
|
@@ -216,7 +216,7 @@ export function installFollowupWouldDoWork(argv, env, platform) {
|
|
|
216
216
|
const args = argv.slice(2).filter((arg) => arg !== "--verbose");
|
|
217
217
|
if (args[0] === "mesh" && args[1] === "daemon")
|
|
218
218
|
return false;
|
|
219
|
-
if (args[0] === "daemon" && (args[1] === "run" || args[1] === "install"))
|
|
219
|
+
if (args[0] === "daemon" && (args[1] === "run" || args[1] === "install" || args[1] === "service"))
|
|
220
220
|
return false;
|
|
221
221
|
if (platform === "win32")
|
|
222
222
|
return /[/\\]node_modules[/\\]/i.test(argv[1] ?? "");
|
|
@@ -108,10 +108,15 @@ export interface EnsureFleetHotSignalSyncInput {
|
|
|
108
108
|
* cli.bot-signals-engine-job (default off). Every company still gets the
|
|
109
109
|
* daily 06:30 hot-signal-sync job; the flag picks what its script runs: the
|
|
110
110
|
* signals engine when true, the plain hot-channel sync when false. The script
|
|
111
|
-
* is rewritten on every call, so flipping the flag
|
|
112
|
-
* bot start without re-registering the
|
|
111
|
+
* is rewritten on every call, so flipping the flag (or turning a capture
|
|
112
|
+
* setting on) takes effect on the next bot start without re-registering the
|
|
113
|
+
* job.
|
|
114
|
+
*
|
|
115
|
+
* The flag is a company flag, so pass a function to answer per company (a
|
|
116
|
+
* personal bot has one job per company and each can differ). A boolean is
|
|
117
|
+
* the same answer for every company.
|
|
113
118
|
*/
|
|
114
|
-
signalsJobEnabled: boolean;
|
|
119
|
+
signalsJobEnabled: boolean | ((company: string) => boolean);
|
|
115
120
|
/**
|
|
116
121
|
* Whether this bot is the Executive bot (lib/bot/executive.ts). Other personal bots
|
|
117
122
|
* hand over only companies with a confirmed replacement job. Default true.
|
|
@@ -132,5 +137,23 @@ export interface EnsureFleetHotSignalSyncResult {
|
|
|
132
137
|
removed: string[];
|
|
133
138
|
}
|
|
134
139
|
export declare function fleetHotSignalSyncCompanies(config: EnsureFleetHotSignalSyncInput["config"], activeCompany: string | null, ownerCompanies?: readonly string[]): string[];
|
|
140
|
+
/**
|
|
141
|
+
* cli.bot-signals-engine-job, read for each company the bot has a
|
|
142
|
+
* hot-signal-sync job for: the answer for `signalsJobEnabled`. Only a company
|
|
143
|
+
* whose flag is on, and which the engine would not skip as prefs-off on this
|
|
144
|
+
* computer (signals_capture and ontology_capture both off), gets the engine
|
|
145
|
+
* script; the others keep the plain hot-channel sync. A company has one job
|
|
146
|
+
* and one script, so it is never run by both in a morning. Never throws: when
|
|
147
|
+
* the read itself throws, every company keeps the plain sync and `log` gets
|
|
148
|
+
* one line.
|
|
149
|
+
*
|
|
150
|
+
* The answer is taken when the script is written: each time `hq bot` syncs
|
|
151
|
+
* the bot's Fleet jobs (`hq bot start` and `restart` among them). A
|
|
152
|
+
* capture setting (or the flag) changed afterwards, in either direction,
|
|
153
|
+
* reaches the script the next time it is written. Until then a company whose
|
|
154
|
+
* capture was turned on keeps the plain sync, and a company whose capture was
|
|
155
|
+
* turned off keeps the engine script, which skips it as prefs-off.
|
|
156
|
+
*/
|
|
157
|
+
export declare function fleetHotSignalSyncEngineCompanies(input: Pick<EnsureFleetHotSignalSyncInput, "config" | "activeCompany" | "ownerCompanies" | "executive" | "executiveCompanies">, read?: (companies: readonly string[]) => Promise<ReadonlySet<string>>, log?: (message: string) => void): Promise<(company: string) => boolean>;
|
|
135
158
|
export declare function ensureFleetHotSignalSync(input: EnsureFleetHotSignalSyncInput): EnsureFleetHotSignalSyncResult;
|
|
136
159
|
//# sourceMappingURL=fleet-cron.d.ts.map
|
|
@@ -5,6 +5,7 @@ import { effectiveBotCompanies, effectiveBotKind } from "./config.js";
|
|
|
5
5
|
import { fleetLocalRuntimePython, stderrTail } from "./fleet-local.js";
|
|
6
6
|
import { readLocalJobs, withJobsLock, writeLocalJobs } from "./local-jobs.js";
|
|
7
7
|
import { signInCommand } from "./runtime-sign-in.js";
|
|
8
|
+
import { BOT_SIGNALS_ENGINE_JOB_FLAG, signalsEngineJobCompanies } from "./signals-engine-flag.js";
|
|
8
9
|
import { SIGNALS_FAILURE_PREFIX } from "../hot-channels/alert.js";
|
|
9
10
|
import { currentHotSignalSyncCompany, forgetHotSignalSyncRegistrationsExcept, hotSignalSyncJobCompany, fleetHotSignalSyncRegistered, markFleetHotSignalSyncRegistered, otherBotWithHotSignalSync, } from "./jobs/hot-signal-sync.js";
|
|
10
11
|
const RESULT_MARKER = "@@HQ_FLEET_CRON@@";
|
|
@@ -584,9 +585,45 @@ export function fleetHotSignalSyncCompanies(config, activeCompany, ownerCompanie
|
|
|
584
585
|
return owned;
|
|
585
586
|
return single ? [single] : [];
|
|
586
587
|
}
|
|
587
|
-
|
|
588
|
-
|
|
588
|
+
/** The companies this bot keeps a hot-signal-sync job for: its own, less the ones the Executive bot runs. */
|
|
589
|
+
function fleetHotSignalSyncJobCompanies(input) {
|
|
590
|
+
return fleetHotSignalSyncCompanies(input.config, input.activeCompany, input.ownerCompanies)
|
|
589
591
|
.filter((company) => input.executive !== false || !input.executiveCompanies?.includes(company));
|
|
592
|
+
}
|
|
593
|
+
/**
|
|
594
|
+
* cli.bot-signals-engine-job, read for each company the bot has a
|
|
595
|
+
* hot-signal-sync job for: the answer for `signalsJobEnabled`. Only a company
|
|
596
|
+
* whose flag is on, and which the engine would not skip as prefs-off on this
|
|
597
|
+
* computer (signals_capture and ontology_capture both off), gets the engine
|
|
598
|
+
* script; the others keep the plain hot-channel sync. A company has one job
|
|
599
|
+
* and one script, so it is never run by both in a morning. Never throws: when
|
|
600
|
+
* the read itself throws, every company keeps the plain sync and `log` gets
|
|
601
|
+
* one line.
|
|
602
|
+
*
|
|
603
|
+
* The answer is taken when the script is written: each time `hq bot` syncs
|
|
604
|
+
* the bot's Fleet jobs (`hq bot start` and `restart` among them). A
|
|
605
|
+
* capture setting (or the flag) changed afterwards, in either direction,
|
|
606
|
+
* reaches the script the next time it is written. Until then a company whose
|
|
607
|
+
* capture was turned on keeps the plain sync, and a company whose capture was
|
|
608
|
+
* turned off keeps the engine script, which skips it as prefs-off.
|
|
609
|
+
*/
|
|
610
|
+
export async function fleetHotSignalSyncEngineCompanies(input, read, log) {
|
|
611
|
+
let engine = new Set();
|
|
612
|
+
try {
|
|
613
|
+
const companies = fleetHotSignalSyncJobCompanies(input);
|
|
614
|
+
if (companies.length > 0) {
|
|
615
|
+
engine = await (read ?? ((list) => signalsEngineJobCompanies(list, { hqRoot: input.config.hqRoot, ...(log ? { log } : {}) })))(companies);
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
catch (error) {
|
|
619
|
+
engine = new Set();
|
|
620
|
+
const errorClass = error instanceof Error ? error.name : "unknown";
|
|
621
|
+
(log ?? ((message) => console.warn(`hq: ${message}`)))(`Could not read ${BOT_SIGNALS_ENGINE_JOB_FLAG} (${errorClass}); every company's hot-signal-sync job runs the hot-channel sync only.`);
|
|
622
|
+
}
|
|
623
|
+
return (company) => engine.has(company);
|
|
624
|
+
}
|
|
625
|
+
export function ensureFleetHotSignalSync(input) {
|
|
626
|
+
const companies = fleetHotSignalSyncJobCompanies(input);
|
|
590
627
|
const wanted = new Set(companies);
|
|
591
628
|
const jobs = input.ops.list();
|
|
592
629
|
const removed = [];
|
|
@@ -608,6 +645,9 @@ export function ensureFleetHotSignalSync(input) {
|
|
|
608
645
|
}
|
|
609
646
|
function ensureFleetHotSignalSyncFor(input, company, jobs) {
|
|
610
647
|
const scriptName = fleetHotSignalSyncScript(company);
|
|
648
|
+
const signalsEngine = typeof input.signalsJobEnabled === "function"
|
|
649
|
+
? input.signalsJobEnabled(company) === true
|
|
650
|
+
: input.signalsJobEnabled === true;
|
|
611
651
|
const scriptsDir = path.join(input.profileDir, "scripts");
|
|
612
652
|
fs.mkdirSync(scriptsDir, { recursive: true, mode: 0o700 });
|
|
613
653
|
const logFile = path.join(input.dir, "logs", "hot-signal-sync.log");
|
|
@@ -620,7 +660,7 @@ function ensureFleetHotSignalSyncFor(input, company, jobs) {
|
|
|
620
660
|
company,
|
|
621
661
|
hqRoot: input.config.hqRoot,
|
|
622
662
|
logFile,
|
|
623
|
-
signalsEngine
|
|
663
|
+
signalsEngine,
|
|
624
664
|
}), { mode: 0o600 });
|
|
625
665
|
fs.renameSync(temporary, scriptFile);
|
|
626
666
|
const current = jobs.find((job) => companyOfHotSignalSyncJob(job) === company) ?? null;
|
|
@@ -635,7 +675,7 @@ function ensureFleetHotSignalSyncFor(input, company, jobs) {
|
|
|
635
675
|
return { company, created: false, job: null, heldBy };
|
|
636
676
|
const job = input.ops.create({
|
|
637
677
|
name: FLEET_HOT_SIGNAL_SYNC_NAME,
|
|
638
|
-
prompt:
|
|
678
|
+
prompt: signalsEngine
|
|
639
679
|
? `Run the signals engine for ${company} and post to the owner only when it finds new signals.`
|
|
640
680
|
: `Run the hot-channel sync for ${company}.`,
|
|
641
681
|
schedule: FLEET_HOT_SIGNAL_SYNC_SCHEDULE,
|
package/dist/lib/bot/run.d.ts
CHANGED
|
@@ -142,13 +142,13 @@ export interface BotRunDeps {
|
|
|
142
142
|
}) => Promise<SignalsJobResult>;
|
|
143
143
|
/**
|
|
144
144
|
* US-006 AC9: the member's "Try now" answer to a signals job reply.
|
|
145
|
-
* Resolves cli.bot-signals-engine-job the
|
|
146
|
-
* returns null when
|
|
147
|
-
* before); otherwise the runner for one `--trigger chat --force` run of the
|
|
145
|
+
* Resolves cli.bot-signals-engine-job and the capture settings the same way
|
|
146
|
+
* a fired job does and returns null when the engine is not chosen (the
|
|
147
|
+
* message then goes to the model as before); otherwise the runner for one `--trigger chat --force` run of the
|
|
148
148
|
* signals engine through the job's own entry point, with its caps and lock.
|
|
149
149
|
* Unset = "Try now" is never handled here.
|
|
150
150
|
*/
|
|
151
|
-
signalsTryNow?: () => Promise<((input: SignalsTryNowInput) => Promise<SignalsJobResult>) | null>;
|
|
151
|
+
signalsTryNow?: (company: string) => Promise<((input: SignalsTryNowInput) => Promise<SignalsJobResult>) | null>;
|
|
152
152
|
heartbeatIntervalMs?: number;
|
|
153
153
|
readyComponents?: () => HeartbeatReadyComponents;
|
|
154
154
|
/** Override the rendered system prompt (tests). */
|
package/dist/lib/bot/run.js
CHANGED
|
@@ -2500,7 +2500,8 @@ export async function runBot(deps) {
|
|
|
2500
2500
|
* holds the company lock starts nothing, gets the "already running" reply,
|
|
2501
2501
|
* and leaves the offer as it was. Returns false (the normal model turn
|
|
2502
2502
|
* answers) when the text is not "Try now", no offer is open, the company
|
|
2503
|
-
* is no longer this bot's, or
|
|
2503
|
+
* is no longer this bot's, or the engine is not chosen for it
|
|
2504
|
+
* (cli.bot-signals-engine-job off, or capture off on this computer).
|
|
2504
2505
|
*/
|
|
2505
2506
|
const runSignalsTryNow = async (item, text) => {
|
|
2506
2507
|
const id = item.messageId;
|
|
@@ -2552,14 +2553,15 @@ export async function runBot(deps) {
|
|
|
2552
2553
|
log("info", `"Try now" ${id}: the offer for ${company} is not this bot's company any more; cleared it, answering with a model turn`);
|
|
2553
2554
|
return false;
|
|
2554
2555
|
}
|
|
2555
|
-
|
|
2556
|
+
// cli.bot-signals-engine-job is a company flag: read for the offer's company.
|
|
2557
|
+
run = await deps.signalsTryNow(company);
|
|
2556
2558
|
}
|
|
2557
2559
|
catch (err) {
|
|
2558
2560
|
log("warn", `"Try now" check failed (${err instanceof Error ? err.message : String(err)}); answering ${id} with a model turn`);
|
|
2559
2561
|
return false;
|
|
2560
2562
|
}
|
|
2561
2563
|
if (!run) {
|
|
2562
|
-
log("info", `"Try now" ${id}: ${BOT_SIGNALS_ENGINE_JOB_FLAG} is off; answering with a model turn`);
|
|
2564
|
+
log("info", `"Try now" ${id}: the signals engine does not run for ${company} (${BOT_SIGNALS_ENGINE_JOB_FLAG} is off for it, or its capture settings are off on this computer); answering with a model turn`);
|
|
2563
2565
|
return false;
|
|
2564
2566
|
}
|
|
2565
2567
|
const target = { kind: "dm", peerUid: config.ownerUid };
|