@indigoai-us/hq-cli 5.345.220 → 5.345.222
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 +164 -0
- package/dist/command-catalog.generated.d.ts +175 -2
- package/dist/command-catalog.generated.js +213 -2
- package/dist/commands/auth.js +6 -2
- package/dist/commands/bot-runtime.d.ts +18 -5
- package/dist/commands/bot-runtime.js +29 -12
- package/dist/commands/bot.d.ts +39 -2
- package/dist/commands/bot.js +140 -11
- package/dist/commands/core-delegate-w1b.js +9 -3
- package/dist/commands/core-stop-autosave.d.ts +21 -0
- package/dist/commands/core-stop-autosave.js +300 -0
- package/dist/commands/core.js +2 -0
- package/dist/commands/daemon.d.ts +6 -0
- package/dist/commands/daemon.js +46 -8
- package/dist/commands/doctor-usage.d.ts +5 -0
- package/dist/commands/doctor-usage.js +25 -0
- package/dist/commands/env.d.ts +49 -4
- package/dist/commands/env.js +355 -5
- package/dist/commands/lanes-shared.d.ts +3 -0
- package/dist/commands/lanes.d.ts +3 -0
- package/dist/commands/lanes.js +87 -3
- package/dist/commands/link.d.ts +2 -0
- package/dist/commands/link.js +14 -2
- package/dist/commands/mesh.js +23 -3
- package/dist/commands/sources.js +3 -3
- package/dist/commands/sync-core.d.ts +7 -0
- package/dist/commands/sync-core.js +132 -3
- package/dist/commands/whoami.js +96 -80
- package/dist/data/command-states.json +3 -0
- package/dist/lib/bot/config.d.ts +17 -0
- package/dist/lib/bot/config.js +13 -0
- package/dist/lib/bot/fleet-cron.js +24 -2
- package/dist/lib/bot/fleet-local.d.ts +30 -2
- package/dist/lib/bot/fleet-local.js +60 -1
- package/dist/lib/bot/grok-login-scope.d.ts +36 -0
- package/dist/lib/bot/grok-login-scope.js +93 -0
- package/dist/lib/bot/legacy-provider-login.d.ts +32 -9
- package/dist/lib/bot/legacy-provider-login.js +28 -22
- package/dist/lib/bot/runtime-sign-in-check.js +6 -1
- package/dist/lib/bot/runtime-sign-in.d.ts +2 -0
- package/dist/lib/core-utils/sentry-report.js +2 -0
- package/dist/lib/daemon/catalog.js +2 -0
- package/dist/lib/daemon/install.d.ts +2 -1
- package/dist/lib/daemon/install.js +9 -0
- package/dist/lib/daemon/legacy.d.ts +1 -0
- package/dist/lib/daemon/legacy.js +5 -2
- package/dist/lib/daemon/machine-check-owner.d.ts +2 -0
- package/dist/lib/daemon/machine-check-owner.js +6 -1
- package/dist/lib/daemon/machine-checks.d.ts +29 -2
- package/dist/lib/daemon/machine-checks.js +64 -13
- package/dist/lib/daemon/mesh-owner.d.ts +45 -0
- package/dist/lib/daemon/mesh-owner.js +166 -0
- package/dist/lib/daemon/native-notice-ledger.d.ts +27 -0
- package/dist/lib/daemon/native-notice-ledger.js +113 -0
- package/dist/lib/daemon/run.d.ts +15 -0
- package/dist/lib/daemon/run.js +137 -11
- package/dist/lib/daemon/selfcheck.d.ts +35 -2
- package/dist/lib/daemon/selfcheck.js +118 -9
- package/dist/lib/daemon/stop-autosave-lock.d.ts +19 -0
- package/dist/lib/daemon/stop-autosave-lock.js +166 -0
- package/dist/lib/daemon/stop-autosave.d.ts +28 -0
- package/dist/lib/daemon/stop-autosave.js +111 -0
- package/dist/lib/daemon/stop-diagnostics.d.ts +11 -0
- package/dist/lib/daemon/stop-diagnostics.js +136 -0
- package/dist/lib/daemon/stop-job-executor.d.ts +19 -0
- package/dist/lib/daemon/stop-job-executor.js +126 -0
- package/dist/lib/daemon/stop-jobs.d.ts +93 -0
- package/dist/lib/daemon/stop-jobs.js +599 -0
- package/dist/lib/doctor/checks/fleet-hook-core.js +1 -1
- package/dist/lib/doctor/checks/host-core.js +1 -1
- package/dist/lib/environment/access-probes.d.ts +234 -0
- package/dist/lib/environment/access-probes.js +918 -0
- package/dist/lib/environment/profile.d.ts +15 -2
- package/dist/lib/environment/profile.js +55 -20
- package/dist/lib/environment/rfc3339.d.ts +8 -0
- package/dist/lib/environment/rfc3339.js +26 -0
- package/dist/lib/environment/work-requirements.d.ts +169 -0
- package/dist/lib/environment/work-requirements.js +389 -0
- package/dist/lib/hook-engine/coverage.d.ts +146 -7
- package/dist/lib/hook-engine/coverage.js +1480 -4
- package/dist/lib/hook-engine/fleet-registration.js +2 -2
- package/dist/lib/hook-engine/git-stop-config.json +513 -0
- package/dist/lib/hook-engine/native-stop-compatibility.json +362 -0
- package/dist/lib/hook-engine/reconcile.js +2 -2
- package/dist/lib/hot-channels/alert.d.ts +2 -2
- package/dist/lib/hot-channels/alert.js +8 -5
- package/dist/lib/hot-channels/signals-pass.d.ts +126 -17
- package/dist/lib/hot-channels/signals-pass.js +296 -17
- package/dist/lib/hot-channels/signals-runtime.d.ts +30 -0
- package/dist/lib/hot-channels/signals-runtime.js +82 -0
- package/dist/lib/install/hook-target.js +1 -1
- package/dist/lib/lanes/host-capacity.d.ts +26 -2
- package/dist/lib/lanes/host-capacity.js +17 -2
- package/dist/lib/lanes/host-compute.d.ts +90 -0
- package/dist/lib/lanes/host-compute.js +185 -0
- package/dist/lib/lanes/index.d.ts +2 -0
- package/dist/lib/lanes/index.js +1 -0
- package/dist/lib/lanes/reconcile.js +22 -1
- package/dist/lib/lanes/resource-usage.d.ts +155 -0
- package/dist/lib/lanes/resource-usage.js +589 -0
- package/dist/lib/lanes/run-size.d.ts +46 -0
- package/dist/lib/lanes/run-size.js +197 -0
- package/dist/lib/lanes/store.js +27 -0
- package/dist/lib/lanes/throttle.d.ts +36 -1
- package/dist/lib/lanes/throttle.js +47 -10
- package/dist/lib/lanes/types.d.ts +40 -0
- package/dist/lib/lanes/types.js +2 -2
- package/dist/lib/lanes/watcher.js +13 -4
- package/dist/lib/lanes/worker-process.d.ts +25 -2
- package/dist/lib/lanes/worker-process.js +71 -19
- package/dist/lib/mesh/live/daemon/config.d.ts +8 -1
- package/dist/lib/mesh/live/daemon/config.js +16 -0
- package/dist/lib/mesh/live/daemon/install.d.ts +31 -2
- package/dist/lib/mesh/live/daemon/install.js +142 -1
- package/dist/lib/mesh/live/daemon/login-home.d.ts +5 -0
- package/dist/lib/mesh/live/daemon/login-home.js +27 -0
- package/dist/lib/mesh/live/daemon/unit-home.d.ts +49 -0
- package/dist/lib/mesh/live/daemon/unit-home.js +134 -0
- package/dist/lib/placement/match.d.ts +192 -0
- package/dist/lib/placement/match.js +667 -0
- package/dist/lib/registry/registry.d.ts +35 -7
- package/dist/lib/registry/registry.js +88 -13
- package/dist/lib/safe-store.d.ts +14 -0
- package/dist/lib/safe-store.js +77 -4
- package/dist/lib/scan-packages/index.js +24 -2
- package/dist/lib/search-index/index.d.ts +88 -4
- package/dist/lib/search-index/index.js +288 -24
- package/dist/lib/search-index/max-doc-bytes.d.ts +17 -6
- package/dist/lib/search-index/max-doc-bytes.js +49 -23
- package/dist/lib/service-manager/startup-migration.d.ts +1 -0
- package/dist/lib/service-manager/startup-migration.js +3 -0
- package/dist/lib/signals/codex-lockdown.d.ts +79 -0
- package/dist/lib/signals/codex-lockdown.js +271 -0
- package/dist/lib/signals/codex-login.d.ts +37 -0
- package/dist/lib/signals/codex-login.js +83 -0
- package/dist/lib/signals/engine.d.ts +27 -0
- package/dist/lib/signals/engine.js +70 -0
- package/dist/lib/signals/reply.js +22 -1
- package/dist/lib/signals/run-record.js +6 -1
- package/dist/lib/signals/settings.d.ts +5 -0
- package/dist/lib/signals/settings.js +2 -0
- package/dist/lib/signals/steps/extract.d.ts +85 -9
- package/dist/lib/signals/steps/extract.js +317 -68
- package/dist/lib/signals/steps/types.d.ts +2 -0
- package/dist/lib/sync-core/engine-holds.d.ts +14 -0
- package/dist/lib/sync-core/engine-holds.js +60 -0
- package/dist/lib/sync-core/engine-home.d.ts +37 -1
- package/dist/lib/sync-core/engine-home.js +119 -16
- package/dist/lib/sync-core/reconcile.js +8 -0
- package/dist/lib/sync-core/rollout-state.d.ts +2 -1
- package/dist/lib/sync-core/rollout-state.js +5 -2
- package/dist/lib/sync-core/vault-settings.d.ts +21 -0
- package/dist/lib/sync-core/vault-settings.js +131 -0
- package/dist/lib/sync-core/vault-uid.d.ts +2 -0
- package/dist/lib/sync-core/vault-uid.js +4 -0
- package/dist/lib/windows/install-followup.d.ts +2 -0
- package/dist/lib/windows/install-followup.js +4 -1
- package/dist/schemas/hq-work-requirements.v1.schema.json +145 -0
- package/dist/utils/auth-session-check.d.ts +16 -0
- package/dist/utils/auth-session-check.js +16 -0
- package/dist/utils/client-health-contract.d.ts +6 -0
- package/dist/utils/client-health-contract.js +13 -0
- package/dist/utils/client-health.d.ts +7 -0
- package/dist/utils/client-health.js +22 -1
- package/dist/utils/command-usage.d.ts +40 -0
- package/dist/utils/command-usage.js +61 -0
- package/dist/utils/duplicate-command-usage.d.ts +72 -0
- package/dist/utils/duplicate-command-usage.js +125 -0
- package/dist/utils/host-registration.js +5 -2
- package/dist/utils/pack-contributions.d.ts +3 -0
- package/dist/utils/pack-contributions.js +110 -23
- package/dist/utils/resident-package-preload.js +4 -0
- package/dist/utils/self-update.d.ts +3 -1
- package/dist/utils/self-update.js +56 -11
- package/dist/utils/sentry-fingerprint.js +9 -0
- package/dist/utils/update-lock.d.ts +151 -14
- package/dist/utils/update-lock.js +782 -46
- package/dist/utils/version-gate.js +12 -2
- package/dist/utils/windows-bash.d.ts +2 -0
- package/dist/utils/windows-bash.js +2 -1
- package/package.json +9 -8
- package/scripts/bench-core-compare.mjs +313 -0
- package/scripts/bench-core.mjs +399 -12
- package/scripts/check-function-manifest.mjs +116 -3
package/dist/commands/link.js
CHANGED
|
@@ -11,7 +11,7 @@ import { ensureCognitoToken } from "../utils/cognito-session.js";
|
|
|
11
11
|
import { listActiveMembershipCompanies } from "../lib/mesh/api.js";
|
|
12
12
|
import { anywhereRuntimeAllowed } from "../lib/anywhere-person-setting.js";
|
|
13
13
|
import { readCompaniesManifestMap } from "../lib/work-context/repo-remote.js";
|
|
14
|
-
import { canonicalDir, keyForDir, readRegistry, registryDir, registryFile, removeEntriesForDir, resolveCompanyForDir, seedFromManifest, setEntry, writeRegistry, } from "../lib/registry/registry.js";
|
|
14
|
+
import { canonicalDir, keyForDir, readRegistry, registryDir, registryFile, removeEntriesForDir, resolveCompanyForDir, seedFromManifest, setEntry, wouldBindEnclosingRemote, writeRegistry, } from "../lib/registry/registry.js";
|
|
15
15
|
async function requireAnywhereRuntime(deps) {
|
|
16
16
|
if (!(await (deps.runtimeAllowed ?? (() => anywhereRuntimeAllowed()))())) {
|
|
17
17
|
throw new Error("HQ Anywhere is disabled until both the runtime flag and your person setting are on.");
|
|
@@ -34,6 +34,9 @@ export async function linkFolder(company, dir, deps = {}) {
|
|
|
34
34
|
if (!slug)
|
|
35
35
|
throw Object.assign(new Error("Company slug is required."), { expected: true });
|
|
36
36
|
const folder = targetDir(dir);
|
|
37
|
+
if (wouldBindEnclosingRemote(folder)) {
|
|
38
|
+
throw Object.assign(new Error(`Refusing to link ${folder}: it sits inside another git work tree, so the registry key would be that repo's origin and every folder in the repo would resolve to '${slug}'. Link a standalone checkout instead.`), { expected: true });
|
|
39
|
+
}
|
|
37
40
|
const memberships = await (deps.listMemberships ?? defaultListMemberships)();
|
|
38
41
|
const match = memberships.find((m) => m.companySlug.toLowerCase() === slug.toLowerCase() || m.companyUid === slug);
|
|
39
42
|
if (!match) {
|
|
@@ -63,7 +66,16 @@ export function resolveCompany(dir, deps = {}) {
|
|
|
63
66
|
catch (err) {
|
|
64
67
|
return { company: null, reason: err.message };
|
|
65
68
|
}
|
|
66
|
-
return resolveCompanyForDir(registry, folder);
|
|
69
|
+
return resolveCompanyForDir(registry, folder, { hqRoot: layoutHqRoot(deps) });
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* The HQ root the companies/<slug> layout fallback may trust: an explicit
|
|
73
|
+
* dependency or $HQ_ROOT only. Never a cwd walk or CLAUDE_PROJECT_DIR, which
|
|
74
|
+
* in a session started outside HQ is that foreign folder.
|
|
75
|
+
*/
|
|
76
|
+
function layoutHqRoot(deps) {
|
|
77
|
+
const raw = deps.hqRoot ?? process.env.HQ_ROOT ?? "";
|
|
78
|
+
return raw.trim() ? path.resolve(raw.trim()) : null;
|
|
67
79
|
}
|
|
68
80
|
/** Seed manifest-sourced entries; called by `hq install --global` (US-005). */
|
|
69
81
|
export function seedRegistryFromHqRoot(hqRoot, deps = {}) {
|
package/dist/commands/mesh.js
CHANGED
|
@@ -40,8 +40,9 @@ import { generateUlid } from "../lib/mesh/live/ulid.js";
|
|
|
40
40
|
import { readLegacyBacklog } from "../lib/mesh/live/emit-replay.js";
|
|
41
41
|
import { resolveMeshEmitMode, writeMeshConfigMode, } from "../lib/mesh/live/daemon/mode.js";
|
|
42
42
|
import { workMeshRoot } from "../lib/mesh/live/paths.js";
|
|
43
|
-
import { buildInstallPaths, daemonServiceIsLoaded, daemonServiceStatus, detectPlatform, installDaemonIfStale, installDaemonService, resolveAbsoluteNodeBinary, resolveRunningCliEntry, uninstallDaemonService, } from "../lib/mesh/live/daemon/install.js";
|
|
44
|
-
import { findAncestorHqRoot, resolveInstallHqRoot, } from "../lib/mesh/live/daemon/config.js";
|
|
43
|
+
import { buildInstallPaths, daemonServiceIsLoaded, daemonServiceStatus, detectPlatform, installDaemonIfStale, installDaemonService, resolveAbsoluteNodeBinary, resolveRunningCliEntry, uninstallDaemonService, installedUnitHqRoot, } from "../lib/mesh/live/daemon/install.js";
|
|
44
|
+
import { findAncestorHqRoot, resolveIfStaleHqRoot, resolveInstallHqRoot, } from "../lib/mesh/live/daemon/config.js";
|
|
45
|
+
import { daemonDir as meshDaemonDir } from "../lib/mesh/live/daemon/paths.js";
|
|
45
46
|
import { collectDaemonDoctor, formatCliIdentityLines, formatDaemonDoctor, } from "../lib/mesh/live/daemon/doctor.js";
|
|
46
47
|
import { readDaemonState } from "../lib/mesh/live/daemon/state.js";
|
|
47
48
|
import { defaultRunCommand } from "../lib/service-manager/launchd.js";
|
|
@@ -62,6 +63,7 @@ import { deriveRemoteOwnerSlug, deriveRepoIdentityKey, } from "../lib/work-conte
|
|
|
62
63
|
import { promptRepoCompany, } from "../lib/work-context/repo-prompt.js";
|
|
63
64
|
import { requeueQuarantinedOutbox } from "../lib/work-context/outbox.js";
|
|
64
65
|
import { handOffInstallHere } from "../lib/daemon/handoff.js";
|
|
66
|
+
import { repairServiceUnitsFromOtherHome } from "../lib/daemon/mesh-owner.js";
|
|
65
67
|
import { runResidentCommandWithPackageLease } from "../utils/resident-package-preload.js";
|
|
66
68
|
export function formatCheckLines(threads, company, projectId) {
|
|
67
69
|
if (threads.length === 0) {
|
|
@@ -3139,6 +3141,18 @@ async function runDaemonInstall(opts) {
|
|
|
3139
3141
|
// `hq daemon` runs mesh on this machine: installing a second unit would run it twice.
|
|
3140
3142
|
// An explicit --hq-root is verified the same way as below and saved for the daemon.
|
|
3141
3143
|
const explicitRoot = opts.hqRoot ? resolveInstallHqRoot({ explicit: opts.hqRoot }).root : undefined;
|
|
3144
|
+
if (opts.ifStale && !opts.systemUser) {
|
|
3145
|
+
const repair = repairServiceUnitsFromOtherHome({ home: os.homedir(), env: process.env, hqRoot: explicitRoot ?? process.env.HQ_ROOT });
|
|
3146
|
+
for (const message of repair.messages)
|
|
3147
|
+
console.error(message);
|
|
3148
|
+
if (repair.failed)
|
|
3149
|
+
process.exitCode = 1;
|
|
3150
|
+
if (repair.meshReplaced) {
|
|
3151
|
+
const message = repair.messages.join(" ");
|
|
3152
|
+
console.log(opts.json ? JSON.stringify({ ok: true, action: "repaired", reinstalled: true, message }) : message);
|
|
3153
|
+
return;
|
|
3154
|
+
}
|
|
3155
|
+
}
|
|
3142
3156
|
const handedOff = opts.systemUser
|
|
3143
3157
|
? null
|
|
3144
3158
|
: handOffInstallHere(["mesh"], process.env, { hqRoot: explicitRoot, ifStale: opts.ifStale });
|
|
@@ -3148,7 +3162,13 @@ async function runDaemonInstall(opts) {
|
|
|
3148
3162
|
}
|
|
3149
3163
|
// Verified root only: a repo's own .claude/ must never become the daemon's
|
|
3150
3164
|
// HQ root (that path is persisted as trusted and used for attribution).
|
|
3151
|
-
const hqRoot =
|
|
3165
|
+
const hqRoot = opts.ifStale
|
|
3166
|
+
? resolveIfStaleHqRoot({
|
|
3167
|
+
explicit: opts.hqRoot,
|
|
3168
|
+
daemonDirectory: meshDaemonDir(undefined, os.homedir(), process.env),
|
|
3169
|
+
installedUnitRoot: installedUnitHqRoot(os.homedir()),
|
|
3170
|
+
})
|
|
3171
|
+
: resolveInstallHqRoot({ explicit: opts.hqRoot });
|
|
3152
3172
|
const paths = buildInstallPaths({
|
|
3153
3173
|
systemUser: opts.systemUser,
|
|
3154
3174
|
hqRoot: hqRoot.root,
|
package/dist/commands/sources.js
CHANGED
|
@@ -38,6 +38,7 @@ import { audienceKey } from "../lib/hot-channels/audience.js";
|
|
|
38
38
|
import { appendRunLedgerEntry, ledgerDay, readRunLedger, RUN_TRIGGERS, summarizeRunLedger, } from "../lib/hot-channels/ledger.js";
|
|
39
39
|
import { createClaudeSignalsPass, DEFAULT_MAX_SIGNAL_DOCS, readPendingSignals, SignalsPassError, } from "../lib/hot-channels/signals-pass.js";
|
|
40
40
|
import { recordSignalsPassClaudeLogin } from "../lib/hot-channels/signals-claude-login.js";
|
|
41
|
+
import { executiveSignalsRuntimeOptions } from "../lib/hot-channels/signals-runtime.js";
|
|
41
42
|
import { backlogRunResult, parseSince, queueSignalsRedo, selectSignalsRedo, SignalsRedoUsageError, } from "../lib/hot-channels/signals-redo.js";
|
|
42
43
|
import { assertSafeSegment } from "../lib/hot-channels/landing.js";
|
|
43
44
|
import { acquireSyncLock, SYNC_LOCK_BUSY_REASON } from "../lib/hot-channels/sync-lock.js";
|
|
@@ -49,7 +50,6 @@ import { S3Client } from "@aws-sdk/client-s3";
|
|
|
49
50
|
import { resolveCanonicalPersonUid } from "./cloud.js";
|
|
50
51
|
import { botsRoot as defaultBotsRoot } from "../lib/bot/paths.js";
|
|
51
52
|
// The same main-bot runtime the signals engine's extract step uses.
|
|
52
|
-
import { defaultResolveBotRuntime } from "../lib/signals/steps/extract.js";
|
|
53
53
|
import { ensureHotSignalSyncJob } from "../lib/bot/jobs/hot-signal-sync.js";
|
|
54
54
|
import { resolveExecutiveBot } from "../lib/bot/executive.js";
|
|
55
55
|
import { companyOfHotSignalSyncJob, fleetCronOps } from "../lib/bot/fleet-cron.js";
|
|
@@ -608,7 +608,7 @@ export async function runSync(options, overrides = {}) {
|
|
|
608
608
|
...(overrides.registry ? { registry: overrides.registry } : {}),
|
|
609
609
|
...(overrides.now ? { now: overrides.now } : {}),
|
|
610
610
|
...(overrides.createSelections ? { createSelections: overrides.createSelections } : {}),
|
|
611
|
-
signalsGenerated: overrides.signalsGenerated ?? createClaudeSignalsPass({ hqRoot: options.hqRoot, company,
|
|
611
|
+
signalsGenerated: overrides.signalsGenerated ?? createClaudeSignalsPass({ hqRoot: options.hqRoot, company, ...executiveSignalsRuntimeOptions(), onClaudeLogin: recordSignalsPassClaudeLogin }),
|
|
612
612
|
// The CLI has no owner-DM sender: the terminal is the primary alert here.
|
|
613
613
|
signalsAlert: {
|
|
614
614
|
sendOwnerDm: async (text) => {
|
|
@@ -724,7 +724,7 @@ export async function runSignalsRedo(options, overrides = {}) {
|
|
|
724
724
|
});
|
|
725
725
|
const pass = overrides.createPass
|
|
726
726
|
? overrides.createPass(maxDocs)
|
|
727
|
-
: createClaudeSignalsPass({ hqRoot: options.hqRoot, company, maxDocs,
|
|
727
|
+
: createClaudeSignalsPass({ hqRoot: options.hqRoot, company, maxDocs, ...executiveSignalsRuntimeOptions(), onClaudeLogin: recordSignalsPassClaudeLogin });
|
|
728
728
|
for (const channel of channels) {
|
|
729
729
|
try {
|
|
730
730
|
report.signalsWritten += await pass(backlogRunResult(channel), { beforeWrite: lock.assertHeld });
|
|
@@ -15,6 +15,7 @@ export interface SyncCoreCommandDeps {
|
|
|
15
15
|
arch: string;
|
|
16
16
|
out: (line: string) => void;
|
|
17
17
|
err: (line: string) => void;
|
|
18
|
+
now?: () => Date;
|
|
18
19
|
}
|
|
19
20
|
export declare function runSyncCoreReconcile(opts: SyncCoreReconcileCommandOptions, d?: SyncCoreCommandDeps): Promise<SyncCoreReconcileResult>;
|
|
20
21
|
export interface SyncCoreManifestCommandOptions {
|
|
@@ -35,5 +36,11 @@ export declare function runSyncCoreManifest(opts: SyncCoreManifestCommandOptions
|
|
|
35
36
|
export declare function runSyncCoreStatus(opts: {
|
|
36
37
|
json?: boolean;
|
|
37
38
|
}, d?: SyncCoreCommandDeps): void;
|
|
39
|
+
export declare function resolveSyncCoreVault(home: string, name: string, opts?: {
|
|
40
|
+
clearing?: boolean;
|
|
41
|
+
}): string;
|
|
42
|
+
export declare function runSyncCoreConfig(vault: string, key: string | undefined, value: string | undefined, opts: {
|
|
43
|
+
json?: boolean;
|
|
44
|
+
}, d?: SyncCoreCommandDeps): void;
|
|
38
45
|
export declare function registerSyncCoreCommand(program: Command, over?: Partial<SyncCoreCommandDeps>): void;
|
|
39
46
|
//# sourceMappingURL=sync-core.d.ts.map
|
|
@@ -2,11 +2,14 @@ import * as fs from "node:fs";
|
|
|
2
2
|
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
|
+
import { readEngineStatus } from "../lib/sync-core/engine-home.js";
|
|
5
6
|
import { readCompanyRolloutFlag } from "../lib/sync-core/flag.js";
|
|
6
7
|
import { reconcileSyncCore } from "../lib/sync-core/reconcile.js";
|
|
7
8
|
import { engineOwnedManifestScopes, manifestScopeArg } from "../lib/sync-core/manifest-scopes.js";
|
|
8
9
|
import { readSyncCoreRolloutState, syncCoreRolloutStatePath } from "../lib/sync-core/rollout-state.js";
|
|
9
10
|
import { readVaultSyncSwitches } from "../lib/vault-sync-switches.js";
|
|
11
|
+
import { isSyncCoreVaultUid } from "../lib/sync-core/vault-uid.js";
|
|
12
|
+
import { readSyncCoreVaultSettings, setSyncCoreVaultSetting, SyncCoreVaultSettingError, } from "../lib/sync-core/vault-settings.js";
|
|
10
13
|
function defaultDeps() {
|
|
11
14
|
return {
|
|
12
15
|
home: os.homedir(),
|
|
@@ -109,10 +112,81 @@ export async function runSyncCoreManifest(opts, d = defaultDeps()) {
|
|
|
109
112
|
process.exitCode = 1;
|
|
110
113
|
return results;
|
|
111
114
|
}
|
|
115
|
+
function ago(at, now) {
|
|
116
|
+
const ms = now.getTime() - Date.parse(at);
|
|
117
|
+
if (!Number.isFinite(ms) || ms < 0)
|
|
118
|
+
return "";
|
|
119
|
+
const minutes = Math.floor(ms / 60_000);
|
|
120
|
+
if (minutes < 1)
|
|
121
|
+
return " (under a minute ago)";
|
|
122
|
+
if (minutes < 120)
|
|
123
|
+
return ` (${minutes} minute${minutes === 1 ? "" : "s"} ago)`;
|
|
124
|
+
const hours = Math.floor(minutes / 60);
|
|
125
|
+
if (hours < 48)
|
|
126
|
+
return ` (${hours} hours ago)`;
|
|
127
|
+
return ` (${Math.floor(hours / 24)} days ago)`;
|
|
128
|
+
}
|
|
129
|
+
function engineStatusLines(engine, full, now) {
|
|
130
|
+
if (!engine)
|
|
131
|
+
return [" no engine status yet (the engine has not written status.json)"];
|
|
132
|
+
const lines = [];
|
|
133
|
+
const live = engine.cycle;
|
|
134
|
+
if (live) {
|
|
135
|
+
const progress = live.phase === "planning"
|
|
136
|
+
? ""
|
|
137
|
+
: `: ${live.uploadsDone} of ${live.uploadsTotal} uploads, ${live.downloadsDone} of ${live.downloadsTotal} downloads, ${live.failed} failed`;
|
|
138
|
+
lines.push(` cycle running since ${live.startedAt}${ago(live.startedAt, now)}, ${live.phase}${progress}`);
|
|
139
|
+
if (live.currentPath)
|
|
140
|
+
lines.push(` moving ${live.currentPath}`);
|
|
141
|
+
if (live.stale && live.updatedAt) {
|
|
142
|
+
lines.push(` no progress written since ${live.updatedAt}${ago(live.updatedAt, now)}; the engine may have stopped in the middle of this cycle`);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
const c = engine.lastCycle;
|
|
146
|
+
if (c) {
|
|
147
|
+
const extras = [
|
|
148
|
+
...(c.unsupported > 0 ? [`${c.unsupported} unsupported`] : []),
|
|
149
|
+
...(c.skipped > 0 ? [`${c.skipped} skipped`] : []),
|
|
150
|
+
...(c.transferFailures > 0 ? [`${c.transferFailures} failed transfer${c.transferFailures === 1 ? "" : "s"}`] : []),
|
|
151
|
+
];
|
|
152
|
+
lines.push(` last cycle ${c.at}${ago(c.at, now)}${c.fullVault ? "" : ", one-file canary"}: ${c.planned} planned, ${c.completed} completed, ${c.pending} pending, ${c.held} held, ${c.notApplied} not applied${extras.length > 0 ? `, ${extras.join(", ")}` : ""}; ${c.success ? "everything planned was applied" : "work is left"}`);
|
|
153
|
+
if (c.listed > 0) {
|
|
154
|
+
lines.push(` listed work${c.truncated ? ` (first ${c.listed} items only)` : ""}: ${c.uploads} uploads, ${c.downloads} downloads, ${c.deletes} deletes, ${c.conflicts} conflict or merge copies, ${c.deferred} deferred`);
|
|
155
|
+
}
|
|
156
|
+
if (c.transfersQueued)
|
|
157
|
+
lines.push(` ${c.transfersQueued} transfer${c.transfersQueued === 1 ? "" : "s"} left for the next cycle`);
|
|
158
|
+
if (c.requestPauseUntil)
|
|
159
|
+
lines.push(` paused by the request limit until ${c.requestPauseUntil}`);
|
|
160
|
+
if (c.requestBreakerUntil)
|
|
161
|
+
lines.push(` slowed down by the request breaker until ${c.requestBreakerUntil}`);
|
|
162
|
+
if (c.transferWaitUntil)
|
|
163
|
+
lines.push(` waiting until ${c.transferWaitUntil} before sending again, after transfers failed in transit`);
|
|
164
|
+
if (c.snapshotWaitUntil)
|
|
165
|
+
lines.push(` waiting until ${c.snapshotWaitUntil} to read the vault again`);
|
|
166
|
+
}
|
|
167
|
+
else if (full && !live) {
|
|
168
|
+
lines.push(" no finished cycle yet");
|
|
169
|
+
}
|
|
170
|
+
const running = [
|
|
171
|
+
...(engine.engineVersion ? [`hq-syncd ${engine.engineVersion}`] : []),
|
|
172
|
+
...(engine.startedAt ? [`started ${engine.startedAt}`] : []),
|
|
173
|
+
...(engine.requests24h !== undefined ? [`${engine.requests24h} requests in the last 24 hours`] : []),
|
|
174
|
+
];
|
|
175
|
+
if (running.length > 0)
|
|
176
|
+
lines.push(` ${running.join(", ")}`);
|
|
177
|
+
return lines;
|
|
178
|
+
}
|
|
112
179
|
export function runSyncCoreStatus(opts, d = defaultDeps()) {
|
|
113
180
|
const state = readSyncCoreRolloutState(d.home);
|
|
114
181
|
if (opts.json) {
|
|
115
|
-
d.
|
|
182
|
+
const jsonNow = (d.now ?? (() => new Date()))();
|
|
183
|
+
d.out(JSON.stringify(state && {
|
|
184
|
+
...state,
|
|
185
|
+
vaults: state.vaults.map((vault) => {
|
|
186
|
+
const engine = readEngineStatus(vault.engineHome, vault.uid, jsonNow);
|
|
187
|
+
return engine ? { ...vault, engine } : vault;
|
|
188
|
+
}),
|
|
189
|
+
}, null, 2));
|
|
116
190
|
return;
|
|
117
191
|
}
|
|
118
192
|
if (!state) {
|
|
@@ -120,16 +194,18 @@ export function runSyncCoreStatus(opts, d = defaultDeps()) {
|
|
|
120
194
|
return;
|
|
121
195
|
}
|
|
122
196
|
const switches = readVaultSyncSwitches(d.home);
|
|
197
|
+
const now = (d.now ?? (() => new Date()))();
|
|
123
198
|
d.out(`engine ${state.release} at ${state.binaryPath}, last read ${state.readAt}`);
|
|
124
199
|
if (state.error)
|
|
125
200
|
d.out(`warning: ${state.error}`);
|
|
126
201
|
for (const vault of state.vaults) {
|
|
127
202
|
const legacyOff = vault.kind === "personal" ? switches.personalOff : switches.offCompanies.has(vault.slug ?? "");
|
|
128
203
|
d.out(` ${vault.uid} ${vault.kind}${vault.slug ? ` ${vault.slug}` : ""} ${vault.phase === "full" ? "full" : "read-only"} legacy sync ${legacyOff ? "off" : "still on"} home ${vault.engineHome}`);
|
|
204
|
+
for (const line of engineStatusLines(readEngineStatus(vault.engineHome, vault.uid, now), vault.phase === "full", now))
|
|
205
|
+
d.out(line);
|
|
129
206
|
if (vault.firstCycle) {
|
|
130
207
|
const c = vault.firstCycle;
|
|
131
|
-
d.out(` first full cycle ${c.at}: ${c.planned} planned, ${c.completed} completed, ${c.pending} pending, ${c.held} held, ${c.notApplied} not applied`);
|
|
132
|
-
d.out(` listed work${c.truncated ? ` (first ${c.listed} items only)` : ""}: ${c.uploads} uploads, ${c.downloads} downloads, ${c.deletes} deletes, ${c.conflicts} conflict or merge copies, ${c.deferred} deferred`);
|
|
208
|
+
d.out(` first full cycle ${c.at} (recorded at the switch): ${c.planned} planned, ${c.completed} completed, ${c.pending} pending, ${c.held} held, ${c.notApplied} not applied`);
|
|
133
209
|
}
|
|
134
210
|
}
|
|
135
211
|
for (const skip of state.skipped ?? [])
|
|
@@ -139,6 +215,54 @@ export function runSyncCoreStatus(opts, d = defaultDeps()) {
|
|
|
139
215
|
if (state.vaults.length === 0)
|
|
140
216
|
d.out(" no vault is switched to the new sync engine");
|
|
141
217
|
}
|
|
218
|
+
export function resolveSyncCoreVault(home, name, opts = {}) {
|
|
219
|
+
const wanted = name.trim();
|
|
220
|
+
const vaults = readSyncCoreRolloutState(home)?.vaults ?? [];
|
|
221
|
+
if (isSyncCoreVaultUid(wanted)) {
|
|
222
|
+
if (vaults.some((vault) => vault.uid === wanted))
|
|
223
|
+
return wanted;
|
|
224
|
+
if (opts.clearing && readSyncCoreVaultSettings(home).has(wanted))
|
|
225
|
+
return wanted;
|
|
226
|
+
}
|
|
227
|
+
const match = wanted === "personal"
|
|
228
|
+
? vaults.filter((vault) => vault.kind === "personal")
|
|
229
|
+
: vaults.filter((vault) => vault.kind === "company" && vault.slug === wanted);
|
|
230
|
+
if (match.length === 1)
|
|
231
|
+
return match[0].uid;
|
|
232
|
+
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
|
+
function describeSettings(settings) {
|
|
235
|
+
if (!settings?.parallelDownloads)
|
|
236
|
+
return "parallel-downloads off (default)";
|
|
237
|
+
return `parallel-downloads on, download-streams ${settings.downloadStreams ?? "default"}`;
|
|
238
|
+
}
|
|
239
|
+
export function runSyncCoreConfig(vault, key, value, opts, d = defaultDeps()) {
|
|
240
|
+
try {
|
|
241
|
+
const clearing = key !== undefined && (value === "off" || value === "default");
|
|
242
|
+
const uid = resolveSyncCoreVault(d.home, vault, { clearing });
|
|
243
|
+
let settings;
|
|
244
|
+
if (key === undefined) {
|
|
245
|
+
settings = readSyncCoreVaultSettings(d.home).get(uid);
|
|
246
|
+
}
|
|
247
|
+
else {
|
|
248
|
+
if (value === undefined)
|
|
249
|
+
throw new SyncCoreVaultSettingError(`Give a value for ${key}`);
|
|
250
|
+
settings = setSyncCoreVaultSetting(d.home, uid, key, value);
|
|
251
|
+
}
|
|
252
|
+
if (opts.json) {
|
|
253
|
+
d.out(JSON.stringify({ vault: uid, parallelDownloads: settings?.parallelDownloads === true, downloadStreams: settings?.downloadStreams ?? null }));
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
d.out(`${uid}: ${describeSettings(settings)}`);
|
|
257
|
+
if (key !== undefined) {
|
|
258
|
+
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
|
+
}
|
|
260
|
+
}
|
|
261
|
+
catch (error) {
|
|
262
|
+
d.err(error instanceof Error ? error.message : String(error));
|
|
263
|
+
process.exitCode = 1;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
142
266
|
export function registerSyncCoreCommand(program, over = {}) {
|
|
143
267
|
const deps = () => ({ ...defaultDeps(), ...over });
|
|
144
268
|
const syncCore = program
|
|
@@ -161,6 +285,11 @@ export function registerSyncCoreCommand(program, over = {}) {
|
|
|
161
285
|
process.exitCode = 1;
|
|
162
286
|
}
|
|
163
287
|
});
|
|
288
|
+
syncCore
|
|
289
|
+
.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")
|
|
291
|
+
.option("--json", "Print JSON")
|
|
292
|
+
.action((vault, key, value, opts) => runSyncCoreConfig(vault, key, value, opts, deps()));
|
|
164
293
|
syncCore
|
|
165
294
|
.command("status")
|
|
166
295
|
.description("Show which vaults are on the new sync engine on this machine")
|
package/dist/commands/whoami.js
CHANGED
|
@@ -11,6 +11,7 @@ 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
13
|
import { authExpiryIso, formatAuthExpiry } from "../utils/auth-expiry.js";
|
|
14
|
+
import { authStatusExitCode } from "../utils/auth-session-check.js";
|
|
14
15
|
export const CLI_LIMIT_INVITE_TEAMMATE_FLAG = "cli.limit-invite-teammate-v1";
|
|
15
16
|
/**
|
|
16
17
|
* Resolves the person represented by an ID token without pairing a delegated
|
|
@@ -169,6 +170,7 @@ export function registerWhoamiCommand(program) {
|
|
|
169
170
|
.description('Show signed-in user and session expiry')
|
|
170
171
|
.option('--json', 'Output identity metadata as JSON (never tokens)')
|
|
171
172
|
.option('--company <slug>', 'Also report this company\'s billing and usage notice')
|
|
173
|
+
.option('--check', 'Exit 1 when there is no usable session, like `hq auth status`')
|
|
172
174
|
.action(async (opts) => {
|
|
173
175
|
try {
|
|
174
176
|
// Effective source (same as auth status / ensureCognitoToken): env
|
|
@@ -176,87 +178,18 @@ export function registerWhoamiCommand(program) {
|
|
|
176
178
|
// after a definitive person-refresh rejection marked the session rejected.
|
|
177
179
|
const machine = resolveCognitoTokenSource() === "machine";
|
|
178
180
|
const cached = loadCachedTokens();
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
const claims = identityCache ? decodeIdToken(identityCache.idToken) : {};
|
|
185
|
-
// Modern credentials carry the canonical UID. Legacy caches may only
|
|
186
|
-
// supply a UID when their subject is bound to the selected username.
|
|
187
|
-
const boundLegacyAgent = machineCreds && identity.entityType === 'agent'
|
|
188
|
-
&& (claims['cognito:username'] === machineCreds.username
|
|
189
|
-
|| claims.username === machineCreds.username || claims.sub === machineCreds.username)
|
|
190
|
-
? identity.entityUid ?? null : null;
|
|
191
|
-
const agentUid = machineCreds?.entityUid !== undefined
|
|
192
|
-
? (machineCreds.entityUid.startsWith('agt_') ? machineCreds.entityUid : null)
|
|
193
|
-
: boundLegacyAgent;
|
|
194
|
-
// planLimits is additive: absent-or-null means UNKNOWN.
|
|
195
|
-
const planLimits = await readPlanLimits(opts.company);
|
|
196
|
-
const authenticated = machine ? Boolean(machineCreds) : Boolean(cached && !isExpiring(cached, 0));
|
|
197
|
-
const personUid = !machine && authenticated ? await readPersonUid(identity) : null;
|
|
198
|
-
console.log(JSON.stringify({
|
|
199
|
-
schemaVersion: 1,
|
|
200
|
-
authenticated,
|
|
181
|
+
// `--check` keeps the `hq auth status` exit contract (US-041). Read
|
|
182
|
+
// from the same state auth status reads, before any lookup below
|
|
183
|
+
// could refresh the cache, and with the same shared predicate.
|
|
184
|
+
const checkExitCode = opts.check
|
|
185
|
+
? authStatusExitCode({
|
|
201
186
|
tokenSource: machine ? 'machine' : 'person',
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
delegatedEmail: identity.delegatedEmail !== undefined && identity.delegatedSub !== undefined
|
|
209
|
-
? identity.delegatedEmail : null,
|
|
210
|
-
delegatedSub: identity.delegatedEmail !== undefined && identity.delegatedSub !== undefined
|
|
211
|
-
? identity.delegatedSub : null,
|
|
212
|
-
personUid,
|
|
213
|
-
agentUid,
|
|
214
|
-
username: machineCreds?.username ?? null,
|
|
215
|
-
// Additive (what `hq auth status` reported): when the cached
|
|
216
|
-
// session expires, and whether it is inside the refresh window.
|
|
217
|
-
// Both are null when no session is cached.
|
|
218
|
-
sessionExpiresAt: identityCache ? authExpiryIso(identityCache.expiresAt) : null,
|
|
219
|
-
sessionExpiring: identityCache ? isExpiring(identityCache) : null,
|
|
220
|
-
planLimits,
|
|
221
|
-
}, null, 2));
|
|
222
|
-
return;
|
|
223
|
-
}
|
|
224
|
-
if (machine) {
|
|
225
|
-
// Machine identities (company agents) mint sessions on demand from
|
|
226
|
-
// long-lived creds — report the machine identity honestly even when
|
|
227
|
-
// no session is cached yet.
|
|
228
|
-
const username = loadMachineCreds()?.username ?? 'unknown';
|
|
229
|
-
const entityUid = cached
|
|
230
|
-
? peekIdToken(cached.idToken).entityUid
|
|
231
|
-
: undefined;
|
|
232
|
-
console.log(`Machine identity ${username}${entityUid ? ` (agent ${entityUid})` : ''} — sessions mint automatically`);
|
|
233
|
-
// Machine tokens live in the daemon state dir, never ~/.hq.
|
|
234
|
-
const machineSession = loadMachineCachedTokens();
|
|
235
|
-
if (machineSession)
|
|
236
|
-
console.log(sessionStatusLine(machineSession));
|
|
237
|
-
console.log(`token source: machine`);
|
|
238
|
-
await printPlanBlock(opts.company);
|
|
239
|
-
return;
|
|
240
|
-
}
|
|
241
|
-
if (!cached) {
|
|
242
|
-
// No session, so no session status or token source to report.
|
|
243
|
-
console.log("Not logged in. Run 'hq login' to authenticate.");
|
|
244
|
-
return;
|
|
245
|
-
}
|
|
246
|
-
if (isExpiring(cached, 0)) {
|
|
247
|
-
const who = resolveWhoamiIdentity(peekIdToken(cached.idToken)).email ?? 'unknown';
|
|
248
|
-
console.log(chalk.yellow(`Session expired for ${who}. Run 'hq login' to re-authenticate.`));
|
|
249
|
-
console.log(chalk.dim('token source: person'));
|
|
250
|
-
return;
|
|
251
|
-
}
|
|
252
|
-
const { email, sub } = resolveWhoamiIdentity(peekIdToken(cached.idToken));
|
|
253
|
-
console.log(`Logged in as ${email ?? 'unknown'}${sub ? ` (${sub})` : ''}`);
|
|
254
|
-
console.log(sessionStatusLine(cached));
|
|
255
|
-
console.log(chalk.dim('token source: person'));
|
|
256
|
-
await printPlanBlock(opts.company);
|
|
257
|
-
// Person sessions only: a deleted company is otherwise invisible here.
|
|
258
|
-
// Bounded like the person-uid lookup, on stderr, and never a failure.
|
|
259
|
-
await printDeletedCompanyNotices({ timeoutMs: PERSON_UID_LOOKUP_TIMEOUT_MS });
|
|
187
|
+
cached: machine ? loadMachineCachedTokens() : cached,
|
|
188
|
+
})
|
|
189
|
+
: 0;
|
|
190
|
+
await printWhoami(opts, machine, cached);
|
|
191
|
+
if (checkExitCode !== 0)
|
|
192
|
+
process.exit(checkExitCode);
|
|
260
193
|
}
|
|
261
194
|
catch (error) {
|
|
262
195
|
console.error(chalk.red('Error:'), error instanceof Error ? error.message : 'Unknown error');
|
|
@@ -264,4 +197,87 @@ export function registerWhoamiCommand(program) {
|
|
|
264
197
|
}
|
|
265
198
|
});
|
|
266
199
|
}
|
|
200
|
+
async function printWhoami(opts, machine, cached) {
|
|
201
|
+
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
|
+
// planLimits is additive: absent-or-null means UNKNOWN.
|
|
217
|
+
const planLimits = await readPlanLimits(opts.company);
|
|
218
|
+
const authenticated = machine ? Boolean(machineCreds) : Boolean(cached && !isExpiring(cached, 0));
|
|
219
|
+
const personUid = !machine && authenticated ? await readPersonUid(identity) : null;
|
|
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));
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
if (machine) {
|
|
247
|
+
// Machine identities (company agents) mint sessions on demand from
|
|
248
|
+
// long-lived creds — report the machine identity honestly even when
|
|
249
|
+
// no session is cached yet.
|
|
250
|
+
const username = loadMachineCreds()?.username ?? 'unknown';
|
|
251
|
+
const entityUid = cached
|
|
252
|
+
? peekIdToken(cached.idToken).entityUid
|
|
253
|
+
: undefined;
|
|
254
|
+
console.log(`Machine identity ${username}${entityUid ? ` (agent ${entityUid})` : ''} — sessions mint automatically`);
|
|
255
|
+
// Machine tokens live in the daemon state dir, never ~/.hq.
|
|
256
|
+
const machineSession = loadMachineCachedTokens();
|
|
257
|
+
if (machineSession)
|
|
258
|
+
console.log(sessionStatusLine(machineSession));
|
|
259
|
+
console.log(`token source: machine`);
|
|
260
|
+
await printPlanBlock(opts.company);
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
if (!cached) {
|
|
264
|
+
// No session, so no session status or token source to report.
|
|
265
|
+
console.log("Not logged in. Run 'hq login' to authenticate.");
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
if (isExpiring(cached, 0)) {
|
|
269
|
+
const who = resolveWhoamiIdentity(peekIdToken(cached.idToken)).email ?? 'unknown';
|
|
270
|
+
console.log(chalk.yellow(`Session expired for ${who}. Run 'hq login' to re-authenticate.`));
|
|
271
|
+
console.log(chalk.dim('token source: person'));
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
const { email, sub } = resolveWhoamiIdentity(peekIdToken(cached.idToken));
|
|
275
|
+
console.log(`Logged in as ${email ?? 'unknown'}${sub ? ` (${sub})` : ''}`);
|
|
276
|
+
console.log(sessionStatusLine(cached));
|
|
277
|
+
console.log(chalk.dim('token source: person'));
|
|
278
|
+
await printPlanBlock(opts.company);
|
|
279
|
+
// Person sessions only: a deleted company is otherwise invisible here.
|
|
280
|
+
// Bounded like the person-uid lookup, on stderr, and never a failure.
|
|
281
|
+
await printDeletedCompanyNotices({ timeoutMs: PERSON_UID_LOOKUP_TIMEOUT_MS });
|
|
282
|
+
}
|
|
267
283
|
//# sourceMappingURL=whoami.js.map
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schema": 1,
|
|
3
3
|
"commands": {
|
|
4
|
+
"auth login": { "state": "retiring", "replacedBy": "hq login" },
|
|
5
|
+
"auth logout": { "state": "retiring", "replacedBy": "hq logout" },
|
|
4
6
|
"crm entity get": { "state": "retiring" },
|
|
5
7
|
"crm entity list": { "state": "retiring" },
|
|
8
|
+
"packages install": { "state": "retiring", "replacedBy": "hq install" },
|
|
6
9
|
"packages packs list": { "state": "retiring", "replacedBy": "hq packs list" },
|
|
7
10
|
"packages packs uninstall": { "state": "retiring", "replacedBy": "hq packs uninstall" },
|
|
8
11
|
"packages packs update": { "state": "retiring", "replacedBy": "hq packs update" },
|
package/dist/lib/bot/config.d.ts
CHANGED
|
@@ -178,7 +178,24 @@ export interface BotConfig {
|
|
|
178
178
|
* capacity account home. Names only, never a credential.
|
|
179
179
|
*/
|
|
180
180
|
runtimeAuth?: BotRuntimeAuthMap;
|
|
181
|
+
/**
|
|
182
|
+
* Which model the local hot-channel signals pass uses (signals-pass.ts).
|
|
183
|
+
* Unset or "claude": Claude Code, as before. "bot": the bot's own runtime,
|
|
184
|
+
* which today takes effect for a Codex bot only (a Claude bot already runs
|
|
185
|
+
* on Claude; Grok is not supported). Per bot and local; set with
|
|
186
|
+
* `hq bot set <name> --signals-runtime bot|claude`.
|
|
187
|
+
*/
|
|
188
|
+
signalsRuntime?: BotSignalsRuntimeSetting;
|
|
181
189
|
}
|
|
190
|
+
/** The `signalsRuntime` values bot.json accepts. */
|
|
191
|
+
export declare const BOT_SIGNALS_RUNTIME_SETTINGS: readonly ["claude", "bot"];
|
|
192
|
+
export type BotSignalsRuntimeSetting = (typeof BOT_SIGNALS_RUNTIME_SETTINGS)[number];
|
|
193
|
+
/**
|
|
194
|
+
* The tool the hot-channel signals pass runs on for this bot: Codex only for
|
|
195
|
+
* a Codex bot that opted in with `signalsRuntime: "bot"`, Claude Code for
|
|
196
|
+
* every other bot (and for no bot at all).
|
|
197
|
+
*/
|
|
198
|
+
export declare function signalsPassRuntime(config: Pick<BotConfig, "runtime" | "signalsRuntime"> | null | undefined): "claude" | "codex";
|
|
182
199
|
export declare function readBotConfig(dir: string): BotConfig | null;
|
|
183
200
|
export declare function writeBotConfig(dir: string, config: BotConfig): void;
|
|
184
201
|
/** "local" when the memory folder is an absolute path outside the HQ tree. */
|
package/dist/lib/bot/config.js
CHANGED
|
@@ -204,6 +204,19 @@ export function validateBotKickoff(text) {
|
|
|
204
204
|
}
|
|
205
205
|
return trimmed;
|
|
206
206
|
}
|
|
207
|
+
/** The `signalsRuntime` values bot.json accepts. */
|
|
208
|
+
export const BOT_SIGNALS_RUNTIME_SETTINGS = ["claude", "bot"];
|
|
209
|
+
/**
|
|
210
|
+
* The tool the hot-channel signals pass runs on for this bot: Codex only for
|
|
211
|
+
* a Codex bot that opted in with `signalsRuntime: "bot"`, Claude Code for
|
|
212
|
+
* every other bot (and for no bot at all).
|
|
213
|
+
*/
|
|
214
|
+
export function signalsPassRuntime(config) {
|
|
215
|
+
// Whether that bot's Codex login may be used (an HQ Fleet Runtime bot's may
|
|
216
|
+
// not) is decided in one place, signalsCodexLogin; `hq bot set` refuses the
|
|
217
|
+
// opt-in where it fails, and a pass that meets it reports codex-logged-out.
|
|
218
|
+
return config?.runtime === "codex" && config.signalsRuntime === "bot" ? "codex" : "claude";
|
|
219
|
+
}
|
|
207
220
|
export function readBotConfig(dir) {
|
|
208
221
|
const p = botConfigPath(dir);
|
|
209
222
|
if (!fs.existsSync(p))
|
|
@@ -341,9 +341,27 @@ def classify(out, err, code):
|
|
|
341
341
|
text = ANSI.sub('', (err or '') + '\n' + (out or ''))
|
|
342
342
|
if re.search(r"HQ session has expired|not signed in to HQ|Sign in to HQ first|run .hq login", text, re.I):
|
|
343
343
|
return 'you are signed out of HQ', FIXES['hq_signed_out']
|
|
344
|
-
# Before the plain claude checks: a Codex main bot
|
|
344
|
+
# Before the plain claude checks: a Codex main bot whose signals still run
|
|
345
|
+
# on Claude Code is pointed at running them on its own Codex.
|
|
345
346
|
if re.search(r'claude-logged-out-codex-bot', text, re.I):
|
|
346
|
-
return "your main bot runs on Codex, but signals from hot-channel sync
|
|
347
|
+
return "your main bot runs on Codex, but signals from hot-channel sync run on Claude Code, which is not installed or not signed in on this computer", FIXES['codex_bot_needs_claude']
|
|
348
|
+
# A Codex bot that runs signals on its own Codex (signalsRuntime "bot").
|
|
349
|
+
if re.search(r'codex could not start:.*\bENOENT\b|spawn codex ENOENT', text, re.I):
|
|
350
|
+
return 'Codex is not installed on this computer', FIXES['codex_signed_out']
|
|
351
|
+
if re.search(r'codex-logged-out|codex (reported it )?is not logged in|codex could not start|codex login is not usable', text, re.I):
|
|
352
|
+
return 'Codex is signed out on this computer', FIXES['codex_signed_out']
|
|
353
|
+
codex_timed_out = re.search(r'codex timed out after \d+ ?ms on (\S+)', text, re.I)
|
|
354
|
+
if codex_timed_out or re.search(r'codex-timeout', text, re.I):
|
|
355
|
+
key = codex_timed_out.group(1).rstrip('.,;:)\'"') if codex_timed_out else ''
|
|
356
|
+
if re.match(r'^sources/[A-Za-z0-9._/-]+\.md$', key) and '..' not in key:
|
|
357
|
+
return 'Codex ran out of time on one document', FIXES['claude_timeout_key'].replace('KEY', key)
|
|
358
|
+
return 'Codex ran out of time on one document', FIXES['claude_timeout']
|
|
359
|
+
if re.search(r'codex-usage-limit|codex is out of usage', text, re.I):
|
|
360
|
+
return 'Codex is out of usage on this account', FIXES['codex_usage_limit']
|
|
361
|
+
if re.search(r'codex-bad-output', text, re.I):
|
|
362
|
+
return 'Codex gave replies the signals step could not read', FIXES['claude_bad_output']
|
|
363
|
+
if re.search(r'codex-provider-error', text, re.I):
|
|
364
|
+
return 'Codex reported an error', FIXES['claude_provider_error']
|
|
347
365
|
if re.search(r'claude could not start:.*\bENOENT\b|spawn claude ENOENT', text, re.I):
|
|
348
366
|
return 'Claude Code is not installed on this computer', FIXES['claude_missing']
|
|
349
367
|
if re.search(r'claude-logged-out|claude (reported it )?is not logged in|claude could not start', text, re.I):
|
|
@@ -443,7 +461,11 @@ export function renderFleetHotSignalSyncScript(input) {
|
|
|
443
461
|
// The desktop app first (Settings → AI tools lists Claude Code with a
|
|
444
462
|
// "Connect Claude" or "Install Claude" button), the terminal as the fallback.
|
|
445
463
|
claude_signed_out: claudeSignInFix,
|
|
464
|
+
// A Fleet bot's signals run on Claude Code (an HQ Fleet Runtime bot cannot lend its Codex login), so the fix is the Claude sign-in.
|
|
446
465
|
codex_bot_needs_claude: claudeSignInFix,
|
|
466
|
+
// Settings → AI tools lists Codex with a "Connect Codex" or "Install Codex" button.
|
|
467
|
+
codex_signed_out: `open HQ, go to Settings → AI tools, and use the Codex button there (Connect Codex, or Install Codex if it is not installed yet). Or run \`${signInCommand("codex")}\` in a terminal on this computer.`,
|
|
468
|
+
codex_usage_limit: `wait for your Codex usage to reset, then run \`hq sources signals --company ${input.company} --since DATE\` to build the missing signals.`,
|
|
447
469
|
claude_missing: `install Claude Code (\`npm install -g @anthropic-ai/claude-code\`), then run \`${signInCommand("claude")}\`.`,
|
|
448
470
|
claude_timeout_key: `run \`hq sources signals --company ${input.company} --key KEY\` to retry that document.`,
|
|
449
471
|
claude_timeout: "the next run retries the document.",
|