@indigoai-us/hq-cli 5.345.214 → 5.345.215
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 +93 -0
- package/assets/scaffold/core/scripts/hq-delegate-verify.sh +5 -2
- package/dist/command-catalog.generated.d.ts +180 -13
- package/dist/command-catalog.generated.js +221 -13
- package/dist/commands/agents.d.ts +51 -1
- package/dist/commands/agents.js +154 -2
- package/dist/commands/bot-jobs.d.ts +2 -15
- package/dist/commands/bot-jobs.js +2 -94
- package/dist/commands/bot-runtime.d.ts +46 -5
- package/dist/commands/bot-runtime.js +228 -18
- package/dist/commands/bot.d.ts +16 -9
- package/dist/commands/bot.js +231 -55
- package/dist/commands/capacity.d.ts +4 -1
- package/dist/commands/capacity.js +46 -10
- package/dist/commands/cloud.d.ts +66 -13
- package/dist/commands/cloud.js +121 -40
- package/dist/commands/company-restore.d.ts +23 -0
- package/dist/commands/company-restore.js +128 -0
- package/dist/commands/company.js +2 -0
- package/dist/commands/core-delegate-w1b.js +15 -1
- package/dist/commands/core-policy.js +67 -8
- package/dist/commands/daemon.js +5 -0
- package/dist/commands/files-browse.d.ts +11 -4
- package/dist/commands/files-browse.js +21 -4
- package/dist/commands/files.d.ts +1 -1
- package/dist/commands/files.js +25 -11
- package/dist/commands/integrations-auth-rules.d.ts +27 -0
- package/dist/commands/integrations-auth-rules.js +79 -0
- package/dist/commands/integrations-connect.d.ts +10 -3
- package/dist/commands/integrations-connect.js +87 -13
- package/dist/commands/integrations-import.js +124 -12
- package/dist/commands/lanes.js +28 -11
- package/dist/commands/mesh.d.ts +2 -0
- package/dist/commands/mesh.js +60 -35
- package/dist/commands/sources.js +6 -0
- package/dist/commands/storage-offload.d.ts +12 -0
- package/dist/commands/storage-offload.js +41 -3
- package/dist/commands/sync-held.js +5 -2
- package/dist/commands/sync-mode.js +5 -0
- package/dist/commands/whoami.js +4 -0
- package/dist/lazy-commands.js +3 -5
- package/dist/lib/bot/config.d.ts +1 -0
- package/dist/lib/bot/config.js +10 -0
- package/dist/lib/bot/eventbridge-cron.d.ts +22 -0
- package/dist/lib/bot/eventbridge-cron.js +104 -0
- package/dist/lib/bot/fleet-cron.d.ts +8 -0
- package/dist/lib/bot/fleet-cron.js +35 -3
- package/dist/lib/bot/fleet-daemon.d.ts +46 -0
- package/dist/lib/bot/fleet-daemon.js +99 -1
- package/dist/lib/bot/fleet-local.d.ts +33 -1
- package/dist/lib/bot/fleet-local.js +215 -31
- package/dist/lib/bot/fleet-python.d.ts +3 -0
- package/dist/lib/bot/fleet-python.js +34 -4
- package/dist/lib/bot/fleet-runtime-sources.d.ts +15 -0
- package/dist/lib/bot/fleet-runtime-sources.js +30 -0
- package/dist/lib/bot/legacy-provider-login.d.ts +8 -0
- package/dist/lib/bot/legacy-provider-login.js +19 -2
- package/dist/lib/bot/probe.js +7 -1
- package/dist/lib/bot/prompt.js +1 -1
- package/dist/lib/bot/readiness.d.ts +8 -0
- package/dist/lib/bot/readiness.js +17 -3
- package/dist/lib/bot/run.js +20 -1
- package/dist/lib/bot/runtime/codex.js +1 -1
- package/dist/lib/bot/runtime/grok-acp.d.ts +5 -1
- package/dist/lib/bot/runtime/grok-acp.js +6 -3
- package/dist/lib/bot/runtime/index.js +19 -9
- package/dist/lib/bot/runtime/messages-stream.js +2 -2
- package/dist/lib/bot/runtime/types.d.ts +15 -0
- package/dist/lib/bot/runtime/types.js +9 -0
- package/dist/lib/bot/runtime-auth.d.ts +30 -0
- package/dist/lib/bot/runtime-auth.js +94 -3
- package/dist/lib/bot/runtime-failure.d.ts +23 -0
- package/dist/lib/bot/runtime-failure.js +43 -1
- package/dist/lib/bot/status.d.ts +2 -0
- package/dist/lib/capacity/accounts.d.ts +8 -0
- package/dist/lib/capacity/accounts.js +19 -0
- package/dist/lib/capacity/available.d.ts +154 -0
- package/dist/lib/capacity/available.js +905 -0
- package/dist/lib/capacity/codex-availability.d.ts +14 -1
- package/dist/lib/capacity/codex-availability.js +26 -1
- package/dist/lib/capacity/collectors/claude-oauth.d.ts +29 -2
- package/dist/lib/capacity/collectors/claude-oauth.js +104 -7
- package/dist/lib/capacity/collectors/codex.js +10 -7
- package/dist/lib/capacity/collectors/grok-refresh.d.ts +80 -0
- package/dist/lib/capacity/collectors/grok-refresh.js +189 -0
- package/dist/lib/capacity/collectors/grok.d.ts +5 -0
- package/dist/lib/capacity/collectors/grok.js +56 -5
- package/dist/lib/capacity/ledger.d.ts +37 -1
- package/dist/lib/capacity/ledger.js +207 -30
- package/dist/lib/capacity/project.d.ts +26 -0
- package/dist/lib/capacity/project.js +137 -8
- package/dist/lib/capacity/refusal-rows.d.ts +31 -0
- package/dist/lib/capacity/refusal-rows.js +61 -0
- package/dist/lib/capacity/refusal.d.ts +53 -2
- package/dist/lib/capacity/refusal.js +284 -65
- package/dist/lib/capacity/route.js +46 -11
- package/dist/lib/capacity/widget.d.ts +12 -1
- package/dist/lib/capacity/widget.js +91 -3
- package/dist/lib/daemon/catalog.js +11 -1
- package/dist/lib/daemon/resolver.d.ts +2 -0
- package/dist/lib/daemon/resolver.js +3 -0
- package/dist/lib/daemon/run.d.ts +9 -0
- package/dist/lib/daemon/run.js +54 -1
- package/dist/lib/daemon/server.d.ts +2 -0
- package/dist/lib/daemon/server.js +10 -1
- package/dist/lib/daemon/tcc-eperm.d.ts +153 -0
- package/dist/lib/daemon/tcc-eperm.js +310 -0
- package/dist/lib/db/sqlite-binding.d.ts +1 -0
- package/dist/lib/db/sqlite-binding.js +1 -1
- package/dist/lib/delivery/admission.d.ts +86 -0
- package/dist/lib/delivery/admission.js +148 -0
- package/dist/lib/delivery/artifacts.d.ts +105 -0
- package/dist/lib/delivery/artifacts.js +567 -0
- package/dist/lib/delivery/attempt-id.d.ts +13 -0
- package/dist/lib/delivery/attempt-id.js +16 -0
- package/dist/lib/delivery/backup.d.ts +78 -0
- package/dist/lib/delivery/backup.js +343 -0
- package/dist/lib/delivery/cache.d.ts +29 -0
- package/dist/lib/delivery/cache.js +33 -0
- package/dist/lib/delivery/contracts.d.ts +142 -0
- package/dist/lib/delivery/contracts.js +289 -0
- package/dist/lib/delivery/credentials.d.ts +54 -0
- package/dist/lib/delivery/credentials.js +119 -0
- package/dist/lib/delivery/disposable-target.d.ts +42 -0
- package/dist/lib/delivery/disposable-target.js +111 -0
- package/dist/lib/delivery/effects.d.ts +136 -0
- package/dist/lib/delivery/effects.js +541 -0
- package/dist/lib/delivery/enrollment.d.ts +146 -0
- package/dist/lib/delivery/enrollment.js +460 -0
- package/dist/lib/delivery/escalations.d.ts +51 -0
- package/dist/lib/delivery/escalations.js +60 -0
- package/dist/lib/delivery/identity.d.ts +25 -0
- package/dist/lib/delivery/identity.js +82 -0
- package/dist/lib/delivery/inbox.d.ts +116 -0
- package/dist/lib/delivery/inbox.js +260 -0
- package/dist/lib/delivery/lease.d.ts +80 -0
- package/dist/lib/delivery/lease.js +134 -0
- package/dist/lib/delivery/migrations.d.ts +255 -0
- package/dist/lib/delivery/migrations.js +823 -0
- package/dist/lib/delivery/mqtt-adapter.d.ts +50 -0
- package/dist/lib/delivery/mqtt-adapter.js +242 -0
- package/dist/lib/delivery/mqtt.d.ts +63 -0
- package/dist/lib/delivery/mqtt.js +119 -0
- package/dist/lib/delivery/outbox.d.ts +95 -0
- package/dist/lib/delivery/outbox.js +187 -0
- package/dist/lib/delivery/provenance.d.ts +129 -0
- package/dist/lib/delivery/provenance.js +93 -0
- package/dist/lib/delivery/reconciler.d.ts +215 -0
- package/dist/lib/delivery/reconciler.js +703 -0
- package/dist/lib/delivery/restore.d.ts +35 -0
- package/dist/lib/delivery/restore.js +134 -0
- package/dist/lib/delivery/rpc/client.d.ts +22 -0
- package/dist/lib/delivery/rpc/client.js +159 -0
- package/dist/lib/delivery/rpc/port.d.ts +40 -0
- package/dist/lib/delivery/rpc/port.js +16 -0
- package/dist/lib/delivery/rpc/server.d.ts +30 -0
- package/dist/lib/delivery/rpc/server.js +205 -0
- package/dist/lib/delivery/rpc/wire.d.ts +85 -0
- package/dist/lib/delivery/rpc/wire.js +143 -0
- package/dist/lib/delivery/store.d.ts +163 -0
- package/dist/lib/delivery/store.js +944 -0
- package/dist/lib/delivery/windows-service-install.d.ts +262 -0
- package/dist/lib/delivery/windows-service-install.js +892 -0
- package/dist/lib/delivery/workers/macos-job-helper.d.ts +103 -0
- package/dist/lib/delivery/workers/macos-job-helper.js +927 -0
- package/dist/lib/delivery/workers/macos.d.ts +191 -0
- package/dist/lib/delivery/workers/macos.js +943 -0
- package/dist/lib/delivery/workers/windows-job-helper.d.ts +35 -0
- package/dist/lib/delivery/workers/windows-job-helper.js +264 -0
- package/dist/lib/delivery/workers/windows-service-live.d.ts +121 -0
- package/dist/lib/delivery/workers/windows-service-live.js +711 -0
- package/dist/lib/delivery/workers/windows-service-runner.d.ts +33 -0
- package/dist/lib/delivery/workers/windows-service-runner.js +82 -0
- package/dist/lib/delivery/workers/windows-service.d.ts +140 -0
- package/dist/lib/delivery/workers/windows-service.js +584 -0
- package/dist/lib/delivery/workers/windows.d.ts +251 -0
- package/dist/lib/delivery/workers/windows.js +594 -0
- package/dist/lib/hot-channels/adapters/meetings.d.ts +15 -0
- package/dist/lib/hot-channels/adapters/meetings.js +36 -3
- package/dist/lib/hot-channels/signals-pass.d.ts +10 -0
- package/dist/lib/hot-channels/signals-pass.js +71 -2
- package/dist/lib/hot-channels/signals-redo.js +10 -2
- package/dist/lib/install/provider-wrappers.d.ts +2 -0
- package/dist/lib/install/provider-wrappers.js +68 -3
- package/dist/lib/lanes/watcher.js +35 -0
- package/dist/lib/signals/steps/extract.js +40 -4
- package/dist/schemas/hq-available-ai.v1.schema.json +76 -0
- package/dist/utils/catalog-runtime-paths.d.ts +34 -0
- package/dist/utils/catalog-runtime-paths.js +53 -0
- package/dist/utils/cognito-callback-port.d.ts +14 -0
- package/dist/utils/cognito-callback-port.js +24 -0
- package/dist/utils/cognito-session.js +3 -3
- package/dist/utils/deleted-company-notice.d.ts +59 -0
- package/dist/utils/deleted-company-notice.js +156 -0
- package/dist/utils/files-browse-acl.js +1 -1
- package/dist/utils/login-browser.d.ts +1 -1
- package/dist/utils/login-browser.js +7 -5
- package/dist/utils/resident-package-preload.js +30 -15
- package/dist/utils/vault-api.js +7 -0
- package/package.json +7 -7
package/dist/commands/bot.js
CHANGED
|
@@ -52,7 +52,7 @@ import { executiveStatus } from "../lib/bot/executive-settings.js";
|
|
|
52
52
|
import { describeExecutiveBotSource, resolveExecutiveBot, setExecutiveBot } from "../lib/bot/executive.js";
|
|
53
53
|
import { executiveHotSignalSyncCompanies } from "../lib/bot/executive-sync.js";
|
|
54
54
|
import { readBotListedProcess } from "../lib/bot/listed-running.js";
|
|
55
|
-
import { DEFAULT_BOT_READY_TIMEOUT_SECONDS, botReadinessReport, clearBotSetupStep, createSetupStepReporter, readBotSetupStep, waitForGatewayReady, writeBotSetupStep, } from "../lib/bot/readiness.js";
|
|
55
|
+
import { DEFAULT_BOT_READY_TIMEOUT_SECONDS, botReadinessReport, clearBotSetupStep, createSetupStepReporter, readBotSetupStep, waitForGatewayReady, fleetStatusCarriesReady, writeBotSetupStep, } from "../lib/bot/readiness.js";
|
|
56
56
|
import { ensureFleetHotSignalSync, fleetCronOps, migrateLegacyJobsToFleet } from "../lib/bot/fleet-cron.js";
|
|
57
57
|
import { resolvePackSetupPrompt } from "../lib/bot/pack-setup.js";
|
|
58
58
|
import { detectCodingToolActivity } from "../lib/bot/coding-tool-activity.js";
|
|
@@ -78,11 +78,12 @@ import { unresolvedLastFailure } from "../lib/doctor/checks/bots.js";
|
|
|
78
78
|
import { clearPendingSwitch, recoverPendingSwitchSafely, writePendingSwitch } from "../lib/bot/pending-switch.js";
|
|
79
79
|
import { classifyRuntimeFailure, isRuntimeUsageLimit, runtimeFailureReason, usageLimitResetsAt } from "../lib/bot/runtime-failure.js";
|
|
80
80
|
import { PROBE_DEFAULT_TIMEOUT_MS, probeBotRuntime } from "../lib/bot/probe.js";
|
|
81
|
-
import { BOT_LOGIN_RUNTIMES, botAuthEnv, botRuntimeAuth, capacityAccountHome, describeBotAuth, formatBotAuth, isBotLoginRuntime, restoreBotSessions, setAsideBotSessions, signInBotRuntime, signOutBotRuntime, withRuntimeAuth, } from "../lib/bot/runtime-auth.js";
|
|
82
|
-
import { BotApi, BotApiError, BOT_RESTORE_DEFAULTS, buildBotLocalConfig, describeBotLocalConfig, orphanBotRunMessage, parseBotLocalConfig, removeOrphanBotDaemon, botDaemonStatus, botDir, botCredsPath, botLogPath, botsRoot, botTokenStateDir, botWorkerRelDir, buildBotDaemonPaths, createBotLogger, deleteBotCreds, installBotDaemon, repairBotDaemonIfStale, healBotDaemonNodeFromJob, introDmText, isBotMemoryMode, botLocalMemoryDir, botMemoryMode, resolveBotMemoryDir, validateBotIntro, validateBotDisplayName, validateBotKickoff, validateBotEffort, validateBotModel, effectiveBotEffort, BOT_EFFORT_LEVELS, DEFAULT_BOT_EFFORT, BOT_MEMORY_MODES, BOT_KINDS, isBotKind, effectiveBotKind, effectiveBotCompanies, normalizeBotCompanies, SETUP_BOT_WORKER_ID, isBotRuntimeId, localNameForRemoteBot, remoteBotRunnability, isPidAlive, listBotWorkerOptions, patchBotConfig, readBotConfig, readBotCredsIdentity, readBotStatus, patchBotStatus, runtimeCrashSinceStart, resolveBotWorker, runBot, runtimeFor, scaffoldBotMemory, scaffoldBotWorker, startBotDaemon, stopBotDaemon, uninstallBotDaemon, validateBotName, writeBotConfig, writeBotCreds, BOT_RUNTIMES, BOT_INTRO_MAX_CHARS, BOT_DISPLAY_NAME_MAX_CHARS, BOT_KICKOFF_MAX_CHARS, detectBotPlatform, withBotLock, localBotRole, remoteBotRole, remoteBotDisplayName, personFacingName, writeCloudDisplayName, setupSlugFor, ASSISTANT_ROLE, HQ_FLEET_RUNTIME_ENGINE_ID, HQ_FLEET_LOCAL_RELEASE, authenticateFleetLocalBot, bootstrapFleetLocalBot, buildSystemPrompt, controlFleetBot as controlFleetLocalBot, fleetBotUnitId, fleetBotsManagedByDaemon,
|
|
81
|
+
import { BOT_LOGIN_RUNTIMES, botAuthEnv, botRuntimeAuth, capacityAccountHome, defaultSpawnBrowserSignIn, describeBotAuth, formatBotAuth, isBotLoginRuntime, restoreBotSessions, setAsideBotSessions, discardHeldBotLogin, holdPreviousBotLogin, restoreHeldBotLogin, signInBotRuntime, signOutBotRuntime, withRuntimeAuth, } from "../lib/bot/runtime-auth.js";
|
|
82
|
+
import { BotApi, BotApiError, BOT_RESTORE_DEFAULTS, buildBotLocalConfig, describeBotLocalConfig, orphanBotRunMessage, parseBotLocalConfig, removeOrphanBotDaemon, botDaemonStatus, botDir, botCredsPath, botLogPath, botsRoot, botTokenStateDir, botWorkerRelDir, buildBotDaemonPaths, createBotLogger, deleteBotCreds, installBotDaemon, repairBotDaemonIfStale, healBotDaemonNodeFromJob, introDmText, isBotMemoryMode, botLocalMemoryDir, botMemoryMode, resolveBotMemoryDir, validateBotIntro, validateBotDisplayName, validateBotKickoff, validateBotEffort, validateBotModel, effectiveBotEffort, BOT_EFFORT_LEVELS, DEFAULT_BOT_EFFORT, BOT_MEMORY_MODES, BOT_KINDS, isBotKind, effectiveBotKind, effectiveBotCompanies, normalizeBotCompanies, SETUP_BOT_WORKER_ID, isBotRuntimeId, botRuntimeFromBrainName, localNameForRemoteBot, remoteBotRunnability, isPidAlive, listBotWorkerOptions, patchBotConfig, readBotConfig, readBotCredsIdentity, readBotStatus, patchBotStatus, runtimeCrashSinceStart, resolveBotWorker, runBot, runtimeFor, scaffoldBotMemory, scaffoldBotWorker, startBotDaemon, stopBotDaemon, uninstallBotDaemon, validateBotName, writeBotConfig, writeBotCreds, BOT_RUNTIMES, BOT_INTRO_MAX_CHARS, BOT_DISPLAY_NAME_MAX_CHARS, BOT_KICKOFF_MAX_CHARS, detectBotPlatform, withBotLock, localBotRole, remoteBotRole, remoteBotDisplayName, personFacingName, writeCloudDisplayName, setupSlugFor, ASSISTANT_ROLE, HQ_FLEET_RUNTIME_ENGINE_ID, HQ_FLEET_LOCAL_RELEASE, authenticateFleetLocalBot, bootstrapFleetLocalBot, buildSystemPrompt, controlFleetBot as controlFleetLocalBot, ensureFleetBotDaemon, FleetDaemonStoppedError, fleetBotUnitId, fleetBotsManagedByDaemon, fleetLocalGatewayPid, fleetLocalProfileNeedsAdoption, fleetLocalServiceInstalled, fleetProviderForRuntime, importFleetLocalMachineCredential, importFleetLocalProviderLogin, fleetProviderNeedsSignIn, fleetOwnerCompanies, refreshFleetLocalInstructions, fleetLocalPromotionRuntime, installPinnedFleetLocalDistribution, installTargetFleetLocalDistribution, resolveFleetLocalPointerTarget, resolveFleetLocalTargetRelease, fleetLocalProfileDir, fleetProfileOwnerCompanies, fleetLocalChannels, readFleetLocalGatewayState, readFleetLocalIntroSentAt, readFleetLocalSignInNeeded, readPromptSources, removeFleetLocalBot, } from "../lib/bot/index.js";
|
|
83
83
|
import { gatedInteractiveLogin } from "../utils/interactive-caller.js";
|
|
84
|
-
import { fleetInstallProgressReporter, fleetRuntimeStatus, runBotAuthStatus, runBotRuntimeInstall, runBotRuntimeStatus } from "./bot-runtime.js";
|
|
84
|
+
import { brainSignInStatus, fleetInstallProgressReporter, fleetRuntimeStatus, runBotAuthStatus, runBotRuntimeInstall, runBotRuntimeStatus, runBotSignIn } from "./bot-runtime.js";
|
|
85
85
|
import { ensureFleetRuntimeInstalled } from "../lib/bot/fleet-local.js";
|
|
86
|
+
import { installFleetRuntimeSources, installOptionalFleetRuntimeSources } from "../lib/bot/fleet-runtime-sources.js";
|
|
86
87
|
function collectRepeated(value, previous) {
|
|
87
88
|
return [...previous, value];
|
|
88
89
|
}
|
|
@@ -380,6 +381,28 @@ function allBotDirs() {
|
|
|
380
381
|
return [];
|
|
381
382
|
}
|
|
382
383
|
}
|
|
384
|
+
/**
|
|
385
|
+
* Before a command that hands a bot to hq daemon: make sure the daemon is
|
|
386
|
+
* running (start it when its login item is installed but it is off). When it
|
|
387
|
+
* still is not up, fail with one plain sentence, and under --json leave the
|
|
388
|
+
* failure document on stdout first.
|
|
389
|
+
*/
|
|
390
|
+
function requireLiveBotDaemon(name, json) {
|
|
391
|
+
reportDaemonStopped(name, json, () => ensureFleetBotDaemon(name));
|
|
392
|
+
}
|
|
393
|
+
/** Run a hand-off; under --json, a daemon that could not be started leaves its failure document on stdout before the error exits non-zero. */
|
|
394
|
+
function reportDaemonStopped(name, json, run) {
|
|
395
|
+
try {
|
|
396
|
+
return run();
|
|
397
|
+
}
|
|
398
|
+
catch (err) {
|
|
399
|
+
if (json && err instanceof FleetDaemonStoppedError && err.jsonReported !== true) {
|
|
400
|
+
console.log(JSON.stringify({ ok: false, name, running: false, reason: err.reason, message: err.message }, null, 2));
|
|
401
|
+
Object.assign(err, { jsonReported: true });
|
|
402
|
+
}
|
|
403
|
+
throw err;
|
|
404
|
+
}
|
|
405
|
+
}
|
|
383
406
|
function refuseHeldFleetBot(dir) {
|
|
384
407
|
if (hasPromotionHold(dir))
|
|
385
408
|
throw new Error("This bot is held for cloud promotion. Continue its promotion before changing local settings or lifecycle.");
|
|
@@ -432,7 +455,7 @@ function runFleetRuntimeControl(name, config, action, output) {
|
|
|
432
455
|
syncFleetRuntimeJobs(name, botDir(name), config);
|
|
433
456
|
}
|
|
434
457
|
const installService = action === "install" || (config.fleetServiceInstallPending === true && (action === "start" || action === "restart"));
|
|
435
|
-
const result = controlFleetLocalBot(config.agentUid, installService ? "install" : action);
|
|
458
|
+
const result = reportDaemonStopped(name, json, () => controlFleetLocalBot(config.agentUid, installService ? "install" : action));
|
|
436
459
|
if (installService && result.ok)
|
|
437
460
|
patchBotConfig(botDir(name), { fleetServiceInstallPending: false, enabled: true });
|
|
438
461
|
if (output === "silent")
|
|
@@ -547,7 +570,7 @@ function rowFor(name, opts = {}) {
|
|
|
547
570
|
const executiveBot = opts.executiveBot === undefined ? resolveExecutiveBot() : opts.executiveBot;
|
|
548
571
|
const listed = readBotListedProcess(dir, config);
|
|
549
572
|
const fleet = listed.fleet;
|
|
550
|
-
const status = listed.status;
|
|
573
|
+
const status = fleet ? withFleetSignInNeeded(listed.status, config.agentUid) : listed.status;
|
|
551
574
|
const legacy = fleet ? null : opts.legacy ?? legacyMoveState(dir, config, legacyConvertSeams.providerLogin(dir, config));
|
|
552
575
|
const pid = listed.pid;
|
|
553
576
|
const processAlive = listed.running;
|
|
@@ -557,6 +580,8 @@ function rowFor(name, opts = {}) {
|
|
|
557
580
|
processAlive,
|
|
558
581
|
livePid: pid,
|
|
559
582
|
gateway: fleet ? readFleetLocalGatewayState(config.agentUid) : null,
|
|
583
|
+
status,
|
|
584
|
+
statusCarriesReady: fleet && fleetStatusCarriesReady(config.engine?.version),
|
|
560
585
|
});
|
|
561
586
|
// Turns this bot has taken and not finished: what "thinking" means.
|
|
562
587
|
const inflightTurns = readInflightTurns(dir);
|
|
@@ -611,7 +636,7 @@ function rowFor(name, opts = {}) {
|
|
|
611
636
|
daemonLoaded,
|
|
612
637
|
daemonNodeMissing,
|
|
613
638
|
dir,
|
|
614
|
-
introSentAt: config.introSentAt,
|
|
639
|
+
introSentAt: config.introSentAt ?? (fleet ? readFleetLocalIntroSentAt(config.agentUid) ?? undefined : undefined),
|
|
615
640
|
kind: effectiveBotKind(config),
|
|
616
641
|
companies: effectiveBotCompanies(config),
|
|
617
642
|
executive: executiveBot?.name === name,
|
|
@@ -994,7 +1019,7 @@ async function startFleetRuntimeBot(name, dir, config, output, extra) {
|
|
|
994
1019
|
const before = readBotStatus(dir);
|
|
995
1020
|
const alreadyRunning = !!before && before.state === "running" && isPidAlive(before.pid);
|
|
996
1021
|
const installService = adopted || config.fleetServiceInstallPending === true;
|
|
997
|
-
const result = controlFleetLocalBot(config.agentUid, installService ? "install" : alreadyRunning ? "restart" : "start");
|
|
1022
|
+
const result = reportDaemonStopped(name, output === "json", () => controlFleetLocalBot(config.agentUid, installService ? "install" : alreadyRunning ? "restart" : "start"));
|
|
998
1023
|
if (installService && result.ok)
|
|
999
1024
|
patchBotConfig(dir, { fleetServiceInstallPending: false, enabled: true });
|
|
1000
1025
|
const how = alreadyRunning ? "restarted by the HQ Fleet Runtime" : "started by the HQ Fleet Runtime";
|
|
@@ -1039,24 +1064,26 @@ async function installFleetRuntimeProfile(name, dir, config, opts = {}) {
|
|
|
1039
1064
|
if (!opts.force && !fleetLocalProfileNeedsAdoption(config.agentUid, { release: target.release }))
|
|
1040
1065
|
return null;
|
|
1041
1066
|
const progress = opts.progress ?? fleetInstallProgressReporter("silent");
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
}
|
|
1046
|
-
catch (err) {
|
|
1047
|
-
if (target.source !== "pointer" || target.localFile)
|
|
1048
|
-
throw err;
|
|
1049
|
-
if (opts.pointerOnly) {
|
|
1050
|
-
createBotLogger(dir)("warn", `could not install HQ Fleet Local ${target.release.version} (${err instanceof Error ? err.message : String(err)}); the bot stays on its current release`);
|
|
1051
|
-
return null;
|
|
1067
|
+
const sources = await installOptionalFleetRuntimeSources(async () => {
|
|
1068
|
+
try {
|
|
1069
|
+
return await installTargetFleetLocalDistribution({ target, onProgress: progress });
|
|
1052
1070
|
}
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1071
|
+
catch (err) {
|
|
1072
|
+
if (target.source !== "pointer" || target.localFile)
|
|
1073
|
+
throw err;
|
|
1074
|
+
if (opts.pointerOnly) {
|
|
1075
|
+
createBotLogger(dir)("warn", `could not install HQ Fleet Local ${target.release.version} (${err instanceof Error ? err.message : String(err)}); the bot stays on its current release`);
|
|
1076
|
+
return null;
|
|
1077
|
+
}
|
|
1078
|
+
createBotLogger(dir)("warn", `could not install HQ Fleet Local ${target.release.version} (${err instanceof Error ? err.message : String(err)}); staying on ${HQ_FLEET_LOCAL_RELEASE.version}`);
|
|
1079
|
+
if (!opts.force && !fleetLocalProfileNeedsAdoption(config.agentUid, { release: HQ_FLEET_LOCAL_RELEASE }))
|
|
1080
|
+
return null;
|
|
1081
|
+
return await installPinnedFleetLocalDistribution({ onProgress: progress });
|
|
1082
|
+
}
|
|
1083
|
+
}, { onProgress: progress });
|
|
1084
|
+
if (!sources)
|
|
1085
|
+
return null;
|
|
1086
|
+
const { installation, python } = sources;
|
|
1060
1087
|
const companyScope = effectiveBotKind(config) === "company"
|
|
1061
1088
|
? effectiveBotCompanies(config)
|
|
1062
1089
|
: await fleetOwnerCompanies();
|
|
@@ -1083,12 +1110,49 @@ async function installFleetRuntimeProfile(name, dir, config, opts = {}) {
|
|
|
1083
1110
|
* "unreadable output: trailing characters").
|
|
1084
1111
|
*/
|
|
1085
1112
|
/** Seams for the self-stop path, replaced in tests. */
|
|
1113
|
+
function withFleetSignInNeeded(status, agentUid) {
|
|
1114
|
+
const marker = readFleetLocalSignInNeeded(agentUid);
|
|
1115
|
+
if (!marker || !status)
|
|
1116
|
+
return status;
|
|
1117
|
+
return { ...status, runtimeSignIn: { state: "signed-out", runtime: marker.runtime, since: marker.since ?? status.startedAt } };
|
|
1118
|
+
}
|
|
1119
|
+
function botReloadsOwnLogin(config) {
|
|
1120
|
+
if (!isFleetRuntimeBot(config))
|
|
1121
|
+
return false;
|
|
1122
|
+
const pid = fleetLocalGatewayPid(config.agentUid);
|
|
1123
|
+
if (pid === null || !isPidAlive(pid))
|
|
1124
|
+
return false;
|
|
1125
|
+
return readFleetLocalSignInNeeded(config.agentUid) !== null;
|
|
1126
|
+
}
|
|
1127
|
+
export const FLEET_SIGN_IN_PICKUP_WAIT_MS = 20_000;
|
|
1128
|
+
function signInPickupWaitMs() {
|
|
1129
|
+
const raw = Number(process.env.HQ_BOT_SIGN_IN_PICKUP_WAIT_MS);
|
|
1130
|
+
return Number.isFinite(raw) && raw >= 0 ? raw : FLEET_SIGN_IN_PICKUP_WAIT_MS;
|
|
1131
|
+
}
|
|
1132
|
+
async function signInMarkerClears(agentUid, waitMs, stepMs = 500) {
|
|
1133
|
+
const deadline = Date.now() + waitMs;
|
|
1134
|
+
for (;;) {
|
|
1135
|
+
if (readFleetLocalSignInNeeded(agentUid) === null)
|
|
1136
|
+
return true;
|
|
1137
|
+
if (Date.now() >= deadline)
|
|
1138
|
+
return false;
|
|
1139
|
+
await new Promise((resolve) => setTimeout(resolve, stepMs));
|
|
1140
|
+
}
|
|
1141
|
+
}
|
|
1142
|
+
function greetingReport(sentAt) {
|
|
1143
|
+
return { sent: sentAt !== null, sentAt };
|
|
1144
|
+
}
|
|
1086
1145
|
export const botCreateSeams = {
|
|
1087
1146
|
/** The Claude Code login read the way the HQ Fleet Runtime reads it. */
|
|
1088
1147
|
claudeLogin: () => checkClaudeCodeLogin(),
|
|
1148
|
+
brainSignIn: brainSignInStatus,
|
|
1149
|
+
importBrainLogin: (agentUid, runtime) => {
|
|
1150
|
+
importFleetLocalProviderLogin(agentUid, runtime);
|
|
1151
|
+
},
|
|
1089
1152
|
runtimeStatus: fleetRuntimeStatus,
|
|
1090
1153
|
installRuntime: ensureFleetRuntimeInstalled,
|
|
1091
1154
|
waitForReady: waitForGatewayReady,
|
|
1155
|
+
greetingSentAt: (agentUid) => readFleetLocalIntroSentAt(agentUid),
|
|
1092
1156
|
};
|
|
1093
1157
|
/**
|
|
1094
1158
|
* A Claude bot on the HQ Fleet Runtime answers with the owner's Claude Code
|
|
@@ -1429,16 +1493,18 @@ async function runBotCreateLocked(name, opts) {
|
|
|
1429
1493
|
if (opts.legacyRuntime) {
|
|
1430
1494
|
throw Object.assign(new Error("--legacy-runtime is no longer supported: new bots run on the HQ Fleet Runtime. Drop --legacy-runtime."), { expected: true });
|
|
1431
1495
|
}
|
|
1432
|
-
|
|
1433
|
-
|
|
1496
|
+
const provider = opts.provider === undefined ? undefined : botRuntimeFromBrainName(opts.provider);
|
|
1497
|
+
if (provider === null) {
|
|
1498
|
+
throw Object.assign(new Error(`--provider must be one of ${BOT_RUNTIMES.join(", ")} (chatgpt is codex)`), { expected: true });
|
|
1434
1499
|
}
|
|
1435
|
-
|
|
1436
|
-
|
|
1500
|
+
const runtimeOption = opts.runtime === undefined ? undefined : botRuntimeFromBrainName(opts.runtime);
|
|
1501
|
+
if (runtimeOption === null) {
|
|
1502
|
+
throw Object.assign(new Error(`--runtime must be one of ${BOT_RUNTIMES.join(", ")} (chatgpt is codex)`), { expected: true });
|
|
1437
1503
|
}
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
throw Object.assign(new Error(`--runtime must be one of ${BOT_RUNTIMES.join(", ")}`), { expected: true });
|
|
1504
|
+
if (provider && runtimeOption && provider !== runtimeOption) {
|
|
1505
|
+
throw Object.assign(new Error("--provider and --runtime must name the same provider when both are used."), { expected: true });
|
|
1441
1506
|
}
|
|
1507
|
+
const runtime = provider ?? runtimeOption ?? "claude";
|
|
1442
1508
|
const memoryMode = opts.memory ?? "synced";
|
|
1443
1509
|
if (!isBotMemoryMode(memoryMode)) {
|
|
1444
1510
|
throw Object.assign(new Error(`--memory must be one of ${BOT_MEMORY_MODES.join(", ")}`), { expected: true });
|
|
@@ -1489,9 +1555,13 @@ async function runBotCreateLocked(name, opts) {
|
|
|
1489
1555
|
});
|
|
1490
1556
|
}
|
|
1491
1557
|
const fleetProvider = fleetProviderForRuntime(runtime, model);
|
|
1492
|
-
const fleetAuthPending = fleetProviderNeedsSignIn(fleetProvider);
|
|
1493
1558
|
if (fleetProvider.id === "anthropic")
|
|
1494
1559
|
requireClaudeCodeLoginForCreate(name);
|
|
1560
|
+
// A bot that starts now is handed to hq daemon where it runs this Mac's bots:
|
|
1561
|
+
// make sure it is up before HQ makes an identity for a bot that would never come online.
|
|
1562
|
+
// A ChatGPT or Grok bot starts now only when a login on this computer is found below.
|
|
1563
|
+
if (opts.start !== false && !fleetProviderNeedsSignIn(fleetProvider))
|
|
1564
|
+
requireLiveBotDaemon(name, opts.json);
|
|
1495
1565
|
const token = await ownerToken();
|
|
1496
1566
|
const owner = await resolveCallerPersonUid(token, undefined, { command: "hq bot create" });
|
|
1497
1567
|
if (!owner)
|
|
@@ -1588,13 +1658,17 @@ async function runBotCreateLocked(name, opts) {
|
|
|
1588
1658
|
const progress = fleetInstallProgressReporter(opts.json ? (opts.progress ? "json" : "silent") : "text");
|
|
1589
1659
|
const steps = createSetupStepReporter(opts.json ? (opts.progress ? "json" : "silent") : "text");
|
|
1590
1660
|
const fleetTarget = await resolveFleetLocalTargetRelease();
|
|
1661
|
+
const brainLogin = fleetProviderNeedsSignIn(fleetProvider)
|
|
1662
|
+
? await botCreateSeams.brainSignIn(runtime === "grok" ? "grok" : "chatgpt", { target: async () => fleetTarget })
|
|
1663
|
+
: null;
|
|
1664
|
+
const fleetAuthPending = brainLogin !== null && !brainLogin.signedIn;
|
|
1665
|
+
if (opts.start !== false && brainLogin?.signedIn === true)
|
|
1666
|
+
requireLiveBotDaemon(name, opts.json);
|
|
1591
1667
|
const runtimeStatus = await botCreateSeams.runtimeStatus({ target: fleetTarget });
|
|
1592
1668
|
if (!opts.json)
|
|
1593
1669
|
console.log(chalk.dim(`Setting up ${name} takes ${runtimeStatus.estimate}.`));
|
|
1594
1670
|
steps.begin("install");
|
|
1595
|
-
const fleetInstallation = await installTargetFleetLocalDistribution({ target: fleetTarget, onProgress: progress });
|
|
1596
|
-
progress({ phase: "python" });
|
|
1597
|
-
const fleetPython = await ensureFleetPython();
|
|
1671
|
+
const { installation: fleetInstallation, python: fleetPython } = await installFleetRuntimeSources(() => installTargetFleetLocalDistribution({ target: fleetTarget, onProgress: progress }), { onProgress: progress });
|
|
1598
1672
|
await botCreateSeams.installRuntime(fleetInstallation, { python: fleetPython, onProgress: progress });
|
|
1599
1673
|
steps.finish("install", runtimeStatus.installed ? "skipped" : "done");
|
|
1600
1674
|
steps.begin("identity");
|
|
@@ -1769,10 +1843,37 @@ async function runBotCreateLocked(name, opts) {
|
|
|
1769
1843
|
},
|
|
1770
1844
|
// Where hq daemon runs the bots, the runtime must not register its own
|
|
1771
1845
|
// login item; the daemon is asked to start the gateway below instead.
|
|
1772
|
-
{ start: startNow && !daemonRunsFleetBots, python: fleetPython, onProgress: progress });
|
|
1846
|
+
{ start: startNow && !daemonRunsFleetBots && brainLogin === null, python: fleetPython, onProgress: progress });
|
|
1847
|
+
if (startNow && brainLogin) {
|
|
1848
|
+
try {
|
|
1849
|
+
botCreateSeams.importBrainLogin(agentUid, runtime === "grok" ? "grok" : "codex");
|
|
1850
|
+
}
|
|
1851
|
+
catch (err) {
|
|
1852
|
+
const cause = err instanceof Error ? err.message : String(err);
|
|
1853
|
+
createBotLogger(dir)("warn", `could not reuse the ${runtimeDisplayName(runtime)} login on this computer (${cause}); ${name} needs its own sign-in`);
|
|
1854
|
+
patchBotConfig(dir, { fleetAuthPending: true, enabled: false });
|
|
1855
|
+
steps.finish("starting", "failed");
|
|
1856
|
+
steps.finish("ready", "skipped");
|
|
1857
|
+
throw Object.assign(new Error(`${name} was created, but the ${runtimeDisplayName(runtime)} login on this computer could not be reused (${cause}). Sign it in with ${fleetAuthCommand(name, { ...config, fleetAuthPending: true })}.`), { expected: true });
|
|
1858
|
+
}
|
|
1859
|
+
}
|
|
1860
|
+
let startedByDaemon = false;
|
|
1861
|
+
// The daemon was checked before the identity was made; if it stopped during
|
|
1862
|
+
// setup, the bot is created but reported offline with the reason, never as started.
|
|
1863
|
+
let daemonStopped = null;
|
|
1864
|
+
if (startNow && daemonRunsFleetBots) {
|
|
1865
|
+
try {
|
|
1866
|
+
startedByDaemon = controlFleetLocalBot(agentUid, "install").ok === true;
|
|
1867
|
+
}
|
|
1868
|
+
catch (err) {
|
|
1869
|
+
if (!(err instanceof FleetDaemonStoppedError))
|
|
1870
|
+
throw err;
|
|
1871
|
+
daemonStopped = err.message;
|
|
1872
|
+
}
|
|
1873
|
+
}
|
|
1874
|
+
const startedByRuntime = startNow && !daemonRunsFleetBots && brainLogin !== null && controlFleetLocalBot(agentUid, "install").ok === true;
|
|
1773
1875
|
syncFleetRuntimeJobs(name, dir, config);
|
|
1774
|
-
const
|
|
1775
|
-
const running = fleetBootstrap.running || startedByDaemon;
|
|
1876
|
+
const running = fleetBootstrap.running || startedByDaemon || startedByRuntime;
|
|
1776
1877
|
let readyWait = null;
|
|
1777
1878
|
if (!startNow) {
|
|
1778
1879
|
steps.finish("starting", "skipped");
|
|
@@ -1785,7 +1886,11 @@ async function runBotCreateLocked(name, opts) {
|
|
|
1785
1886
|
else {
|
|
1786
1887
|
steps.finish("starting", "done");
|
|
1787
1888
|
steps.begin("ready");
|
|
1788
|
-
readyWait = await botCreateSeams.waitForReady(agentUid, {
|
|
1889
|
+
readyWait = await botCreateSeams.waitForReady(agentUid, {
|
|
1890
|
+
timeoutMs: readyTimeoutMs,
|
|
1891
|
+
botDir: dir,
|
|
1892
|
+
statusCarriesReady: fleetStatusCarriesReady(fleetInstallation.engine.version),
|
|
1893
|
+
});
|
|
1789
1894
|
steps.finish("ready", readyWait.ready ? "done" : readyWait.failed ? "failed" : "timeout");
|
|
1790
1895
|
}
|
|
1791
1896
|
const readiness = !startNow || !running || readyWait?.failed ? "offline" : readyWait?.ready ? "ready" : "starting";
|
|
@@ -1831,6 +1936,8 @@ async function runBotCreateLocked(name, opts) {
|
|
|
1831
1936
|
if (fleetAuthPending) {
|
|
1832
1937
|
console.log(chalk.yellow(` sign it in before it can answer: hq bot auth ${name} --provider ${runtime === "grok" ? "grok" : "chatgpt"}`));
|
|
1833
1938
|
}
|
|
1939
|
+
if (daemonStopped)
|
|
1940
|
+
console.log(chalk.yellow(` ${daemonStopped}`));
|
|
1834
1941
|
const readyLine = createReadyLine(name, readiness, readyWait, readyTimeoutMs);
|
|
1835
1942
|
if (readyLine)
|
|
1836
1943
|
console.log(readyLine);
|
|
@@ -1843,10 +1950,11 @@ async function runBotCreateLocked(name, opts) {
|
|
|
1843
1950
|
...created_,
|
|
1844
1951
|
daemon: null,
|
|
1845
1952
|
running,
|
|
1846
|
-
how: startedByDaemon ? "started by hq daemon" : fleetBootstrap.running ? "started by the HQ Fleet Runtime" : null,
|
|
1953
|
+
how: startedByDaemon ? "started by hq daemon" : fleetBootstrap.running || startedByRuntime ? "started by the HQ Fleet Runtime" : null,
|
|
1847
1954
|
steps: steps.steps(),
|
|
1848
1955
|
readiness,
|
|
1849
1956
|
ready: readiness === "ready",
|
|
1957
|
+
greeting: greetingReport(botCreateSeams.greetingSentAt(agentUid)),
|
|
1850
1958
|
readyAt: readyWait?.readyAt ?? null,
|
|
1851
1959
|
readyWait: readyWait
|
|
1852
1960
|
? { timedOut: readyWait.timedOut, failed: readyWait.failed, waitedMs: readyWait.waitedMs, timeoutMs: readyTimeoutMs }
|
|
@@ -1854,7 +1962,7 @@ async function runBotCreateLocked(name, opts) {
|
|
|
1854
1962
|
message: createReadyMessage(name, readiness, readyWait, readyTimeoutMs),
|
|
1855
1963
|
state: status?.state ?? "unknown",
|
|
1856
1964
|
pid: status?.pid ?? null,
|
|
1857
|
-
lastError: status?.lastError ?? null,
|
|
1965
|
+
lastError: daemonStopped ?? status?.lastError ?? null,
|
|
1858
1966
|
}, null, 2));
|
|
1859
1967
|
}
|
|
1860
1968
|
}
|
|
@@ -2936,7 +3044,13 @@ export async function runBotSwitchAccount(nameArg, opts, deps = {}) {
|
|
|
2936
3044
|
if (!isBotRuntimeId(opts.runtime)) {
|
|
2937
3045
|
throw Object.assign(new Error(`--runtime must be one of ${BOT_RUNTIMES.join(", ")}`), { expected: true });
|
|
2938
3046
|
}
|
|
3047
|
+
if (opts.signIn && !isBotLoginRuntime(opts.runtime)) {
|
|
3048
|
+
throw Object.assign(new Error(`--sign-in supports ${BOT_LOGIN_RUNTIMES.join(", ")}; ${opts.runtime} has no login of its own for a bot. Nothing was changed.`), { expected: true });
|
|
3049
|
+
}
|
|
2939
3050
|
if (isFleetRuntimeBot(config)) {
|
|
3051
|
+
if (opts.signIn) {
|
|
3052
|
+
throw Object.assign(new Error(`${name} runs on the HQ Fleet Runtime, which signs in through its own path (hq bot auth). --sign-in is for model-CLI bots. Nothing was changed.`), { expected: true });
|
|
3053
|
+
}
|
|
2940
3054
|
if (opts.runtime === "grok") {
|
|
2941
3055
|
// The Fleet Grok sign-in reuses another bot's xAI login on this
|
|
2942
3056
|
// computer, so it cannot reach a different account.
|
|
@@ -2946,8 +3060,34 @@ export async function runBotSwitchAccount(nameArg, opts, deps = {}) {
|
|
|
2946
3060
|
}
|
|
2947
3061
|
const targetRuntime = opts.runtime;
|
|
2948
3062
|
const switching = targetRuntime !== config.runtime;
|
|
2949
|
-
|
|
2950
|
-
|
|
3063
|
+
let runtimeAuth;
|
|
3064
|
+
if (opts.signIn && isBotLoginRuntime(targetRuntime)) {
|
|
3065
|
+
// A login of the bot's own (~/.hq/bots/<name>/auth/<runtime>), signed
|
|
3066
|
+
// in fresh in the browser. The owner's sign-in and every other bot's
|
|
3067
|
+
// login are never touched. A previous own login is held aside and
|
|
3068
|
+
// put back when this sign-in fails or is cancelled. It is discarded
|
|
3069
|
+
// only after the new login succeeds.
|
|
3070
|
+
const authSpawn = deps.authSpawn;
|
|
3071
|
+
const held = holdPreviousBotLogin(dir, targetRuntime, authSpawn ? { spawn: authSpawn } : {});
|
|
3072
|
+
try {
|
|
3073
|
+
(deps.botSignIn ?? ((d, r) => signInBotRuntime(d, r, authSpawn ? { spawn: authSpawn, quietSpawn: authSpawn, preserveCredentialOnFailure: held } : { spawn: defaultSpawnBrowserSignIn, preserveCredentialOnFailure: held })))(dir, targetRuntime);
|
|
3074
|
+
}
|
|
3075
|
+
catch (err) {
|
|
3076
|
+
if (held) {
|
|
3077
|
+
restoreHeldBotLogin(dir, targetRuntime);
|
|
3078
|
+
throw Object.assign(new Error(`Sign-in did not finish, so ${name}'s previous ${targetRuntime} login was kept.`), { expected: true, cause: err });
|
|
3079
|
+
}
|
|
3080
|
+
throw err;
|
|
3081
|
+
}
|
|
3082
|
+
if (held)
|
|
3083
|
+
discardHeldBotLogin(dir, targetRuntime);
|
|
3084
|
+
createBotLogger(dir)("info", `switch-account: ${name} signed in to ${targetRuntime} with a login of its own`);
|
|
3085
|
+
runtimeAuth = withRuntimeAuth(config.runtimeAuth, targetRuntime, { mode: "own" });
|
|
3086
|
+
}
|
|
3087
|
+
else {
|
|
3088
|
+
// The owner's own sign-in for the target runtime.
|
|
3089
|
+
runtimeAuth = withRuntimeAuth(config.runtimeAuth, targetRuntime, null);
|
|
3090
|
+
}
|
|
2951
3091
|
return switchRuntimeOrAccount({
|
|
2952
3092
|
name,
|
|
2953
3093
|
dir,
|
|
@@ -3119,6 +3259,13 @@ export async function runBotAuth(nameArg, opts) {
|
|
|
3119
3259
|
if (opts.apiKey && !apiKey) {
|
|
3120
3260
|
throw Object.assign(new Error("No API key was received on stdin."), { expected: true });
|
|
3121
3261
|
}
|
|
3262
|
+
if (!apiKey && botRuntimeFromBrainName(opts.provider) === "claude" && !botCreateSeams.claudeLogin().signedIn) {
|
|
3263
|
+
const reason = `Claude Code is not signed in on this computer, so ${b.name} cannot answer.`;
|
|
3264
|
+
const brainSignIn = { provider: "claude", needed: true, reason, command: "claude /login" };
|
|
3265
|
+
if (opts.json)
|
|
3266
|
+
console.log(JSON.stringify({ ok: false, name: b.name, provider: "claude", signedIn: false, brainSignIn }, null, 2));
|
|
3267
|
+
throw Object.assign(new Error(`${reason} Sign in with claude /login, then run this again.`), { expected: true, brainSignIn, jsonReported: opts.json === true });
|
|
3268
|
+
}
|
|
3122
3269
|
// A legacy bot moves to the HQ Fleet Runtime as part of its sign-in. Its
|
|
3123
3270
|
// legacy runner stops for the sign-in and comes back if the sign-in fails.
|
|
3124
3271
|
const legacy = isFleetRuntimeBot(b.config) ? null : b.config;
|
|
@@ -3142,6 +3289,7 @@ export async function runBotAuth(nameArg, opts) {
|
|
|
3142
3289
|
if (legacy)
|
|
3143
3290
|
process.on("SIGINT", keepAliveOnInterrupt);
|
|
3144
3291
|
let result;
|
|
3292
|
+
let reloaded = false;
|
|
3145
3293
|
try {
|
|
3146
3294
|
result = await authenticateFleetLocalBot({
|
|
3147
3295
|
agentUid: b.config.agentUid,
|
|
@@ -3155,6 +3303,10 @@ export async function runBotAuth(nameArg, opts) {
|
|
|
3155
3303
|
openBrowser: opts.browser !== false,
|
|
3156
3304
|
}, {
|
|
3157
3305
|
control: (agentUid, action) => {
|
|
3306
|
+
if (action === "restart" && botReloadsOwnLogin(b.config)) {
|
|
3307
|
+
reloaded = true;
|
|
3308
|
+
return { ok: true, reloaded: true };
|
|
3309
|
+
}
|
|
3158
3310
|
if (fleetBotsManagedByDaemon()) {
|
|
3159
3311
|
if (legacy && engine)
|
|
3160
3312
|
writeBotConfig(b.dir, { ...(readBotConfig(b.dir) ?? legacy), engine });
|
|
@@ -3207,9 +3359,10 @@ export async function runBotAuth(nameArg, opts) {
|
|
|
3207
3359
|
model: result.model,
|
|
3208
3360
|
...(pending ? { fleetAuthPending: false, fleetServiceInstallPending: !result.restarted, enabled: result.restarted } : {}),
|
|
3209
3361
|
});
|
|
3210
|
-
const
|
|
3362
|
+
const retried = reloaded ? await signInMarkerClears(b.config.agentUid, signInPickupWaitMs()) : false;
|
|
3363
|
+
const running = await fleetGatewayComesUp(b.config.agentUid, result.restarted && !reloaded ? fleetStartWaitMs() : 0);
|
|
3211
3364
|
if (opts.json) {
|
|
3212
|
-
console.log(JSON.stringify({ ok: true, name: b.name, runtime: HQ_FLEET_RUNTIME_ENGINE_ID, ...result, needsSignIn: false, running, serviceInstallPending: pending && !result.restarted, ...(legacy ? { movedToFleet: true } : {}) }, null, 2));
|
|
3365
|
+
console.log(JSON.stringify({ ok: true, name: b.name, runtime: HQ_FLEET_RUNTIME_ENGINE_ID, ...result, ...(reloaded ? { restarted: false } : {}), signedIn: true, reloaded, retried, needsSignIn: false, running, serviceInstallPending: pending && !result.restarted, ...(legacy ? { movedToFleet: true } : {}) }, null, 2));
|
|
3213
3366
|
return { running };
|
|
3214
3367
|
}
|
|
3215
3368
|
console.log(running
|
|
@@ -3484,10 +3637,11 @@ async function adoptRemoteBotLocked(input) {
|
|
|
3484
3637
|
});
|
|
3485
3638
|
// A bot made on the HQ Fleet Runtime comes back on it, on the release this CLI pins.
|
|
3486
3639
|
const progress = input.progress ?? fleetInstallProgressReporter("silent");
|
|
3487
|
-
const
|
|
3488
|
-
|
|
3489
|
-
|
|
3490
|
-
const
|
|
3640
|
+
const fleetSources = fleetEngine
|
|
3641
|
+
? await installFleetRuntimeSources(() => installPinnedFleetLocalDistribution({ onProgress: progress }), { onProgress: progress })
|
|
3642
|
+
: null;
|
|
3643
|
+
const fleetInstallation = fleetSources?.installation ?? null;
|
|
3644
|
+
const fleetPython = fleetSources?.python ?? null;
|
|
3491
3645
|
if (fleetInstallation)
|
|
3492
3646
|
config.engine = fleetInstallation.engine;
|
|
3493
3647
|
writeBotConfig(dir, config);
|
|
@@ -3569,6 +3723,9 @@ export async function runBotAdopt(nameArg, opts) {
|
|
|
3569
3723
|
}
|
|
3570
3724
|
throw Object.assign(new Error(runnable.message), { expected: true });
|
|
3571
3725
|
}
|
|
3726
|
+
// Before new credentials are issued for a bot that would start under a stopped hq daemon.
|
|
3727
|
+
if (opts.start !== false)
|
|
3728
|
+
requireLiveBotDaemon(name, opts.json);
|
|
3572
3729
|
await withBotLock(name, async () => {
|
|
3573
3730
|
if (readBotConfig(dir)) {
|
|
3574
3731
|
throw Object.assign(new Error(`Bot "${name}" is already set up on this computer (${dir}). Start it with: hq bot start ${name}`), {
|
|
@@ -3632,7 +3789,15 @@ async function repairLocalBot(name, api, bot, daemon) {
|
|
|
3632
3789
|
const adopted = await adoptFleetRuntimeProfile(name, dir, config);
|
|
3633
3790
|
if (!adopted)
|
|
3634
3791
|
importFleetLocalMachineCredential(bot.agentUid, botCredsPath(dir));
|
|
3635
|
-
|
|
3792
|
+
let restarted;
|
|
3793
|
+
try {
|
|
3794
|
+
restarted = controlFleetLocalBot(bot.agentUid, adopted ? "install" : "restart").ok === true;
|
|
3795
|
+
}
|
|
3796
|
+
catch (err) {
|
|
3797
|
+
if (!(err instanceof FleetDaemonStoppedError))
|
|
3798
|
+
throw err;
|
|
3799
|
+
return `new credentials; the HQ Fleet Runtime did not restart: ${err.message}`;
|
|
3800
|
+
}
|
|
3636
3801
|
return restarted ? "new credentials, HQ Fleet Runtime restarted" : "new credentials; the HQ Fleet Runtime did not restart (hq bot start " + name + ")";
|
|
3637
3802
|
}
|
|
3638
3803
|
if (daemon && process.platform === "darwin") {
|
|
@@ -3653,6 +3818,9 @@ export async function runBotRestore(opts) {
|
|
|
3653
3818
|
json: opts.json,
|
|
3654
3819
|
emptyResult: { dryRun: opts.dryRun === true, restored: 0, repaired: 0, skipped: 0, failed: 0, bots: [] },
|
|
3655
3820
|
}));
|
|
3821
|
+
// Restored bots start under hq daemon where it runs this Mac's bots; make sure it is up first.
|
|
3822
|
+
if (opts.dryRun !== true && opts.start !== false && bots.length > 0)
|
|
3823
|
+
requireLiveBotDaemon("", opts.json);
|
|
3656
3824
|
const rows = [];
|
|
3657
3825
|
for (const bot of bots) {
|
|
3658
3826
|
const name = localNameForRemoteBot(bot);
|
|
@@ -3826,7 +3994,7 @@ export function registerBotCommand(program) {
|
|
|
3826
3994
|
.option("--kind <kind>", `personal (acts as you, everywhere you are) or company (acts as itself, as a member of its companies). Default: personal, or company when created from a company worker`)
|
|
3827
3995
|
.option("--company <slug>", "Company bots: a company the bot is a member of (repeat for several); the owner invites it on creation", collectRepeated, [])
|
|
3828
3996
|
.option("--runtime <runtime>", `Model provider the bot answers with: ${BOT_RUNTIMES.join("|")} (same as --provider; default claude)`)
|
|
3829
|
-
.option("--provider <provider>", `HQ Fleet provider: ${BOT_RUNTIMES.join("|")} (default claude)`)
|
|
3997
|
+
.option("--provider <provider>", `HQ Fleet provider: ${BOT_RUNTIMES.join("|")}, or chatgpt for codex (default claude)`)
|
|
3830
3998
|
.option("--hq-fleet-runtime", "Accepted for compatibility; every new bot runs on the HQ Fleet Runtime")
|
|
3831
3999
|
.option("--legacy-runtime", "No longer supported; new bots always run on the HQ Fleet Runtime")
|
|
3832
4000
|
.option("--model <model>", "Model the bot answers with")
|
|
@@ -3928,10 +4096,17 @@ export function registerBotCommand(program) {
|
|
|
3928
4096
|
.action((name, opts) => wrap(async () => { await runBotAuth(name, opts); })());
|
|
3929
4097
|
bot
|
|
3930
4098
|
.command("auth-status")
|
|
3931
|
-
.description("Say whether a
|
|
3932
|
-
.requiredOption("--provider <provider>", "
|
|
3933
|
-
.option("--json", "Print machine-readable JSON: { signedIn }")
|
|
4099
|
+
.description("Say whether a bot created now with this brain starts without a sign-in step, reusing a login already on this computer")
|
|
4100
|
+
.requiredOption("--provider <provider>", "Brain: claude, codex (or chatgpt) or grok")
|
|
4101
|
+
.option("--json", "Print machine-readable JSON: { provider, signedIn, source }")
|
|
3934
4102
|
.action((opts) => wrap(async () => { await runBotAuthStatus(opts); })());
|
|
4103
|
+
bot
|
|
4104
|
+
.command("sign-in")
|
|
4105
|
+
.description("Sign this computer in to ChatGPT or Grok through its own CLI, so new bots with that brain start without a sign-in step")
|
|
4106
|
+
.requiredOption("--provider <provider>", "Brain: codex (or chatgpt) or grok")
|
|
4107
|
+
.option("--json", "Print one JSON line per event (device code, messages) and a final result")
|
|
4108
|
+
.option("--no-browser", "Use the CLI's device-code login instead of its browser login")
|
|
4109
|
+
.action((opts) => wrap(async () => { await runBotSignIn(opts); })());
|
|
3935
4110
|
bot
|
|
3936
4111
|
.command("logs <name>")
|
|
3937
4112
|
.description("Show the bot's log")
|
|
@@ -3963,6 +4138,7 @@ export function registerBotCommand(program) {
|
|
|
3963
4138
|
.command("switch-account <name>")
|
|
3964
4139
|
.description("Move the bot onto another account (same provider or another), keeping its identity, worker, memory and jobs, then start it again. A model-CLI bot uses your own sign-in for --runtime, checked with one test turn first; a cut-off switch is rolled back by the next start or status. A Fleet Runtime bot uses the HQ Fleet sign-in (hq bot auth)")
|
|
3965
4140
|
.requiredOption("--runtime <runtime>", `${BOT_RUNTIMES.join("|")}`)
|
|
4141
|
+
.option("--sign-in", `Sign the bot in with a login of its own first (${BOT_LOGIN_RUNTIMES.join(", ")}): a browser sign-in for this bot only; your own sign-in is not touched`)
|
|
3966
4142
|
.option("--json", "Print machine-readable JSON")
|
|
3967
4143
|
.action((name, opts) => wrap(() => runBotSwitchAccount(name, opts))());
|
|
3968
4144
|
bot
|
|
@@ -12,6 +12,7 @@ import { Command } from "commander";
|
|
|
12
12
|
import { type CapacityState, type LedgerEvent, type LedgerOptions, type NowView, type ParserFailureEvent, type Reading, type ReadingSource } from "../lib/capacity/ledger.js";
|
|
13
13
|
import { type CapacityAccount } from "../lib/capacity/accounts.js";
|
|
14
14
|
import { type ClaudeRefreshLastEntry } from "../lib/capacity/collectors/claude-oauth.js";
|
|
15
|
+
import type { AvailableDeps } from "../lib/capacity/available.js";
|
|
15
16
|
export declare const CAPACITY_SCHEMA_VERSION: "hq-capacity-now-view.v1";
|
|
16
17
|
export declare const DOCTOR_SCHEMA_VERSION = "hq-capacity-doctor.v1";
|
|
17
18
|
export declare const PARSER_FAILURE_WINDOW_MS: number;
|
|
@@ -92,5 +93,7 @@ export declare function formatCapacityTable(view: NowView, nowMs: number, accoun
|
|
|
92
93
|
export declare function formatHistory(readings: Reading[]): string;
|
|
93
94
|
export declare function buildDoctorReport(options?: LedgerOptions): DoctorReport;
|
|
94
95
|
export declare function formatDoctor(report: DoctorReport): string;
|
|
95
|
-
export declare function registerCapacityCommand(program: Command
|
|
96
|
+
export declare function registerCapacityCommand(program: Command, deps?: {
|
|
97
|
+
available?: AvailableDeps;
|
|
98
|
+
}): Command;
|
|
96
99
|
//# sourceMappingURL=capacity.d.ts.map
|