@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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { execFileSync, spawn, spawnSync } from "node:child_process";
|
|
1
|
+
import { execFile, execFileSync, spawn, spawnSync } from "node:child_process";
|
|
2
2
|
import * as crypto from "node:crypto";
|
|
3
3
|
import * as fs from "node:fs";
|
|
4
4
|
import * as os from "node:os";
|
|
@@ -537,7 +537,51 @@ export function parseFleetLocalReleasePin(value) {
|
|
|
537
537
|
if (![pin.artifactSha256, pin.runtimeArtifactSha256, pin.manifestSha256, pin.signatureSha256].every((hash) => SHA256_RE.test(hash))) {
|
|
538
538
|
return null;
|
|
539
539
|
}
|
|
540
|
-
|
|
540
|
+
if (record.environmentArtifacts === undefined)
|
|
541
|
+
return pin;
|
|
542
|
+
const environmentArtifacts = parseEnvironmentArtifacts(record.environmentArtifacts, pin.version);
|
|
543
|
+
return environmentArtifacts ? { ...pin, environmentArtifacts } : null;
|
|
544
|
+
}
|
|
545
|
+
const ENVIRONMENT_PLATFORM_RE = /^[a-z0-9]+-[a-z0-9_]+$/;
|
|
546
|
+
function parseEnvironmentArtifacts(value, version) {
|
|
547
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
548
|
+
return null;
|
|
549
|
+
const artifacts = {};
|
|
550
|
+
for (const [platform, entry] of Object.entries(value)) {
|
|
551
|
+
if (!ENVIRONMENT_PLATFORM_RE.test(platform) || !entry || typeof entry !== "object" || Array.isArray(entry))
|
|
552
|
+
return null;
|
|
553
|
+
const { name, sha256, size } = entry;
|
|
554
|
+
if (name !== `hq-fleet-local-wheels-${version}-${platform}.tar`)
|
|
555
|
+
return null;
|
|
556
|
+
if (typeof sha256 !== "string" || !SHA256_RE.test(sha256))
|
|
557
|
+
return null;
|
|
558
|
+
if (typeof size !== "number" || !Number.isSafeInteger(size) || size <= 0)
|
|
559
|
+
return null;
|
|
560
|
+
artifacts[platform] = { name, sha256, size };
|
|
561
|
+
}
|
|
562
|
+
return artifacts;
|
|
563
|
+
}
|
|
564
|
+
export function fleetEnvironmentPlatform(platform = process.platform, arch = process.arch) {
|
|
565
|
+
return `${platform}-${arch}`;
|
|
566
|
+
}
|
|
567
|
+
export function releaseWheelhouse(release, platform) {
|
|
568
|
+
return release.environmentArtifacts?.[platform] ?? null;
|
|
569
|
+
}
|
|
570
|
+
export function verifyFleetLocalWheelhouse(file, artifact, manifest, platform, release) {
|
|
571
|
+
let signed;
|
|
572
|
+
try {
|
|
573
|
+
const parsed = JSON.parse(manifest.toString("utf8"));
|
|
574
|
+
signed = parsed.environment?.wheelhouses?.[platform];
|
|
575
|
+
}
|
|
576
|
+
catch {
|
|
577
|
+
signed = undefined;
|
|
578
|
+
}
|
|
579
|
+
if (!signed || signed.asset !== artifact.name || signed.sha256 !== artifact.sha256 || signed.size !== artifact.size) {
|
|
580
|
+
throw expectedError(`HQ Fleet Local ${release.version} bundled packages for ${platform} do not match the signed manifest.`);
|
|
581
|
+
}
|
|
582
|
+
if (fs.statSync(file).size !== artifact.size || fileSha256(file) !== artifact.sha256) {
|
|
583
|
+
throw expectedError(`HQ Fleet Local ${release.version} bundled packages for ${platform} failed their hash check. The download was discarded; retry, and report it with \`hq bug\` if it happens again.`);
|
|
584
|
+
}
|
|
541
585
|
}
|
|
542
586
|
export function parseFleetLocalReleasePointer(body, now = Date.now()) {
|
|
543
587
|
if (!body || typeof body !== "object" || Array.isArray(body))
|
|
@@ -756,16 +800,17 @@ function discardDownloads(target) {
|
|
|
756
800
|
return;
|
|
757
801
|
}
|
|
758
802
|
}
|
|
759
|
-
async function downloadReleaseFiles(release, fetcher, resolve, cachedRuntime, target, onProgress, stallMs) {
|
|
803
|
+
async function downloadReleaseFiles(release, fetcher, resolve, cachedRuntime, target, onProgress, stallMs, wheelhouse = null) {
|
|
760
804
|
fs.mkdirSync(target, { recursive: true, mode: 0o700 });
|
|
761
805
|
const pinned = new Map([
|
|
762
806
|
[release.artifact, release.artifactSha256],
|
|
763
807
|
[release.runtimeArtifact, release.runtimeArtifactSha256],
|
|
764
808
|
["release-manifest.json", release.manifestSha256],
|
|
765
809
|
["release-manifest.sig", release.signatureSha256],
|
|
810
|
+
...(wheelhouse ? [[wheelhouse.name, wheelhouse.sha256]] : []),
|
|
766
811
|
]);
|
|
767
812
|
const downloaded = new Map();
|
|
768
|
-
const wanted = RELEASE_FILE_NAMES(release).filter((name) => {
|
|
813
|
+
const wanted = [...RELEASE_FILE_NAMES(release), ...(wheelhouse ? [wheelhouse.name] : [])].filter((name) => {
|
|
769
814
|
if (name === release.runtimeArtifact && cachedRuntime) {
|
|
770
815
|
downloaded.set(name, cachedRuntime);
|
|
771
816
|
return false;
|
|
@@ -797,10 +842,12 @@ async function downloadReleaseFiles(release, fetcher, resolve, cachedRuntime, ta
|
|
|
797
842
|
runtimeArchive: fs.readFileSync(downloaded.get(release.runtimeArtifact)),
|
|
798
843
|
manifest: fs.readFileSync(downloaded.get("release-manifest.json")),
|
|
799
844
|
signature: fs.readFileSync(downloaded.get("release-manifest.sig")),
|
|
845
|
+
...(wheelhouse ? { wheelhouse: downloaded.get(wheelhouse.name) } : {}),
|
|
800
846
|
};
|
|
801
847
|
}
|
|
802
|
-
async function downloadFleetLocalReleaseFromHq(release, fetcher, links, cachedRuntime, target, onProgress, stallMs, allowFileLinks = false) {
|
|
803
|
-
|
|
848
|
+
async function downloadFleetLocalReleaseFromHq(release, fetcher, links, cachedRuntime, target, onProgress, stallMs, allowFileLinks = false, wheelhouse = null) {
|
|
849
|
+
const bundle = wheelhouse && links.has(wheelhouse.name) ? wheelhouse : null;
|
|
850
|
+
for (const name of [...RELEASE_FILE_NAMES(release), ...(bundle ? [bundle.name] : [])]) {
|
|
804
851
|
if (name === release.runtimeArtifact && cachedRuntime)
|
|
805
852
|
continue;
|
|
806
853
|
const url = links.get(name);
|
|
@@ -815,9 +862,9 @@ async function downloadFleetLocalReleaseFromHq(release, fetcher, links, cachedRu
|
|
|
815
862
|
const cdn = cdnUsable ? links.get(fleetReleaseCdnLinkName(name)) : undefined;
|
|
816
863
|
const candidates = cdn && trustedReleaseCdnLink(cdn) ? [cdn] : [];
|
|
817
864
|
return { urls: [...candidates, links.get(name)] };
|
|
818
|
-
}, cachedRuntime, target, onProgress, stallMs);
|
|
865
|
+
}, cachedRuntime, target, onProgress, stallMs, bundle);
|
|
819
866
|
}
|
|
820
|
-
async function downloadFleetLocalRelease(release, fetcher, token, cachedRuntime, target, onProgress, stallMs) {
|
|
867
|
+
async function downloadFleetLocalRelease(release, fetcher, token, cachedRuntime, target, onProgress, stallMs, wheelhouse = null) {
|
|
821
868
|
const headers = {
|
|
822
869
|
Accept: "application/vnd.github+json",
|
|
823
870
|
Authorization: `Bearer ${token}`,
|
|
@@ -833,7 +880,8 @@ async function downloadFleetLocalRelease(release, fetcher, token, cachedRuntime,
|
|
|
833
880
|
const assets = new Map((body.assets ?? [])
|
|
834
881
|
.filter((asset) => !!asset.name && !!asset.url)
|
|
835
882
|
.map((asset) => [asset.name, asset.url]));
|
|
836
|
-
|
|
883
|
+
const bundle = wheelhouse && assets.has(wheelhouse.name) ? wheelhouse : null;
|
|
884
|
+
for (const name of [...RELEASE_FILE_NAMES(release), ...(bundle ? [bundle.name] : [])]) {
|
|
837
885
|
if (name === release.runtimeArtifact && cachedRuntime)
|
|
838
886
|
continue;
|
|
839
887
|
const url = assets.get(name);
|
|
@@ -843,7 +891,7 @@ async function downloadFleetLocalRelease(release, fetcher, token, cachedRuntime,
|
|
|
843
891
|
throw expectedError(`HQ Fleet Local ${release.tag} returned an untrusted asset URL for ${name}.`);
|
|
844
892
|
}
|
|
845
893
|
}
|
|
846
|
-
return downloadReleaseFiles(release, fetcher, (name) => ({ urls: [assets.get(name)], headers: { ...headers, Accept: "application/octet-stream" } }), cachedRuntime, target, onProgress, stallMs);
|
|
894
|
+
return downloadReleaseFiles(release, fetcher, (name) => ({ urls: [assets.get(name)], headers: { ...headers, Accept: "application/octet-stream" } }), cachedRuntime, target, onProgress, stallMs, bundle);
|
|
847
895
|
}
|
|
848
896
|
function installedFiles(dir, release) {
|
|
849
897
|
const archive = path.join(dir, release.artifact);
|
|
@@ -870,6 +918,8 @@ function installFiles(target, files, release, publicKey) {
|
|
|
870
918
|
fs.writeFileSync(path.join(staging, release.runtimeArtifact), files.runtimeArchive, { mode: 0o644 });
|
|
871
919
|
fs.writeFileSync(path.join(staging, "release-manifest.json"), files.manifest, { mode: 0o644 });
|
|
872
920
|
fs.writeFileSync(path.join(staging, "release-manifest.sig"), files.signature, { mode: 0o644 });
|
|
921
|
+
if (files.wheelhouse)
|
|
922
|
+
fs.renameSync(files.wheelhouse, path.join(staging, path.basename(files.wheelhouse)));
|
|
873
923
|
fs.writeFileSync(path.join(staging, "release-public.pem"), publicKeyList(publicKey).join(""), { mode: 0o644 });
|
|
874
924
|
fs.writeFileSync(path.join(staging, "install.json"), `${JSON.stringify({ schemaVersion: 1, release, engine: engineMetadata(release) }, null, 2)}\n`, { mode: 0o644 });
|
|
875
925
|
if (fs.existsSync(target))
|
|
@@ -937,20 +987,32 @@ export async function installPinnedFleetLocalDistribution(deps = {}) {
|
|
|
937
987
|
const root = deps.fleetHome ?? fleetHome();
|
|
938
988
|
const dir = path.join(root, "distributions", "hq-fleet-local", release.version);
|
|
939
989
|
const onProgress = deps.onProgress;
|
|
990
|
+
const environmentPlatform = fleetEnvironmentPlatform(deps.platform ?? process.platform, deps.arch ?? process.arch);
|
|
991
|
+
const wheelhouse = releaseWheelhouse(release, environmentPlatform);
|
|
940
992
|
const warnCompatibility = (manifest) => {
|
|
941
993
|
const warning = fleetLocalCliCompatibilityWarning(manifest, release);
|
|
942
994
|
if (warning)
|
|
943
995
|
process.stderr.write(`Warning: ${warning}\n`);
|
|
944
996
|
};
|
|
945
|
-
const
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
997
|
+
const installedWheelhouse = () => {
|
|
998
|
+
if (!wheelhouse)
|
|
999
|
+
return null;
|
|
1000
|
+
const file = path.join(dir, wheelhouse.name);
|
|
1001
|
+
return fs.existsSync(file) ? file : null;
|
|
1002
|
+
};
|
|
1003
|
+
const installation = () => {
|
|
1004
|
+
const bundle = installedWheelhouse();
|
|
1005
|
+
return {
|
|
1006
|
+
release,
|
|
1007
|
+
dir,
|
|
1008
|
+
archive: path.join(dir, release.artifact),
|
|
1009
|
+
runtimeArchive: path.join(dir, release.runtimeArtifact),
|
|
1010
|
+
manifest: path.join(dir, "release-manifest.json"),
|
|
1011
|
+
signature: path.join(dir, "release-manifest.sig"),
|
|
1012
|
+
engine: engineMetadata(release),
|
|
1013
|
+
...(bundle ? { wheelhouse: bundle, environmentPlatform } : {}),
|
|
1014
|
+
};
|
|
1015
|
+
};
|
|
954
1016
|
const current = filesMatchPin(installedFiles(dir, release), release);
|
|
955
1017
|
if (current) {
|
|
956
1018
|
verifyFleetLocalRelease(current, release, publicKey);
|
|
@@ -975,7 +1037,7 @@ export async function installPinnedFleetLocalDistribution(deps = {}) {
|
|
|
975
1037
|
const target = downloadsDir(root, release);
|
|
976
1038
|
let files;
|
|
977
1039
|
if (links) {
|
|
978
|
-
files = await downloadFleetLocalReleaseFromHq(release, fetcher, links, cachedRuntime, target, onProgress, deps.downloadStallMs, deps.allowFileLinks === true);
|
|
1040
|
+
files = await downloadFleetLocalReleaseFromHq(release, fetcher, links, cachedRuntime, target, onProgress, deps.downloadStallMs, deps.allowFileLinks === true, wheelhouse);
|
|
979
1041
|
}
|
|
980
1042
|
else {
|
|
981
1043
|
let githubToken;
|
|
@@ -985,11 +1047,13 @@ export async function installPinnedFleetLocalDistribution(deps = {}) {
|
|
|
985
1047
|
catch (error) {
|
|
986
1048
|
throw noReleaseSourceError(release, lookup.reason) ?? error;
|
|
987
1049
|
}
|
|
988
|
-
files = await downloadFleetLocalRelease(release, fetcher, githubToken, cachedRuntime, target, onProgress, deps.downloadStallMs);
|
|
1050
|
+
files = await downloadFleetLocalRelease(release, fetcher, githubToken, cachedRuntime, target, onProgress, deps.downloadStallMs, wheelhouse);
|
|
989
1051
|
}
|
|
990
1052
|
onProgress?.({ phase: "verify" });
|
|
991
1053
|
try {
|
|
992
1054
|
verifyFleetLocalRelease(files, release, publicKey);
|
|
1055
|
+
if (files.wheelhouse && wheelhouse)
|
|
1056
|
+
verifyFleetLocalWheelhouse(files.wheelhouse, wheelhouse, files.manifest, environmentPlatform, release);
|
|
993
1057
|
}
|
|
994
1058
|
catch (error) {
|
|
995
1059
|
discardDownloads(target);
|
|
@@ -1648,6 +1712,42 @@ export function writeFleetLocalFirstStart(profileDir, firstStart) {
|
|
|
1648
1712
|
fs.renameSync(temporary, destination);
|
|
1649
1713
|
return destination;
|
|
1650
1714
|
}
|
|
1715
|
+
const SIGN_IN_PROVIDER_RUNTIME = { anthropic: "claude", "openai-codex": "codex", "xai-oauth": "grok" };
|
|
1716
|
+
const SIGN_IN_LOGINS = new Set(["claude-code", "codex-cli", "grok-cli", "bot"]);
|
|
1717
|
+
export function fleetLocalSignInNeededPath(agentUid, deps = {}) {
|
|
1718
|
+
return path.join(profileRoot(agentUid, deps.fleetHome ?? fleetHome()), "state", "sign-in-needed.json");
|
|
1719
|
+
}
|
|
1720
|
+
export function readFleetLocalSignInNeeded(agentUid, deps = {}) {
|
|
1721
|
+
if (!/^agt_[A-Za-z0-9_-]+$/.test(agentUid))
|
|
1722
|
+
return null;
|
|
1723
|
+
let record;
|
|
1724
|
+
try {
|
|
1725
|
+
record = JSON.parse(fs.readFileSync(fleetLocalSignInNeededPath(agentUid, deps), "utf8"));
|
|
1726
|
+
}
|
|
1727
|
+
catch {
|
|
1728
|
+
return null;
|
|
1729
|
+
}
|
|
1730
|
+
if (!record || typeof record !== "object" || Array.isArray(record))
|
|
1731
|
+
return null;
|
|
1732
|
+
const runtime = typeof record.provider === "string" ? SIGN_IN_PROVIDER_RUNTIME[record.provider] : undefined;
|
|
1733
|
+
if (!runtime)
|
|
1734
|
+
return null;
|
|
1735
|
+
const login = typeof record.personSignIn === "string" && SIGN_IN_LOGINS.has(record.personSignIn) ? record.personSignIn : null;
|
|
1736
|
+
const since = typeof record.since === "string" && Number.isFinite(Date.parse(record.since)) ? record.since : null;
|
|
1737
|
+
return { runtime, login, since };
|
|
1738
|
+
}
|
|
1739
|
+
export function readFleetLocalIntroSentAt(agentUid, deps = {}) {
|
|
1740
|
+
if (!/^agt_[A-Za-z0-9_-]+$/.test(agentUid))
|
|
1741
|
+
return null;
|
|
1742
|
+
try {
|
|
1743
|
+
const record = JSON.parse(fs.readFileSync(path.join(profileRoot(agentUid, deps.fleetHome ?? fleetHome()), "first-start.json"), "utf8"));
|
|
1744
|
+
const at = record?.introSentAt;
|
|
1745
|
+
return typeof at === "string" && Number.isFinite(Date.parse(at)) ? at : null;
|
|
1746
|
+
}
|
|
1747
|
+
catch {
|
|
1748
|
+
return null;
|
|
1749
|
+
}
|
|
1750
|
+
}
|
|
1651
1751
|
export function writeFleetLocalSoul(agentUid, systemPrompt, deps = {}) {
|
|
1652
1752
|
if (!/^agt_[A-Za-z0-9_-]+$/.test(agentUid)) {
|
|
1653
1753
|
throw expectedError(`Cannot use an HQ Fleet profile for invalid bot id ${agentUid}.`);
|
|
@@ -1885,6 +1985,47 @@ function checkedRun(run, executable, args, options, label, spawn) {
|
|
|
1885
1985
|
throw expectedError(`HQ Fleet Local ${label} failed.${tail ? `\n${tail}` : ""}`);
|
|
1886
1986
|
}
|
|
1887
1987
|
}
|
|
1988
|
+
export const FLEET_WHEELHOUSE_EXIT = { installed: 0, verificationFailed: 2, unavailable: 3, installFailed: 4 };
|
|
1989
|
+
function installFromWheelhouse(installation, python, runtimePython, runtimeSource, distributionSource, env, spawn) {
|
|
1990
|
+
const platform = installation.environmentPlatform;
|
|
1991
|
+
const artifact = releaseWheelhouse(installation.release, platform);
|
|
1992
|
+
const wheelhouse = installation.wheelhouse;
|
|
1993
|
+
if (!artifact || !fs.existsSync(wheelhouse))
|
|
1994
|
+
return "fallback";
|
|
1995
|
+
verifyFleetLocalWheelhouse(wheelhouse, artifact, fs.readFileSync(installation.manifest), platform, installation.release);
|
|
1996
|
+
const installer = path.join(distributionSource, "src", "hq_fleet_local", "environment.py");
|
|
1997
|
+
if (!fs.existsSync(installer))
|
|
1998
|
+
return "fallback";
|
|
1999
|
+
const { stdio } = pipeInheritedStdio(["ignore", 2, 2]);
|
|
2000
|
+
const result = spawn(python.python, [
|
|
2001
|
+
"-I",
|
|
2002
|
+
installer,
|
|
2003
|
+
"install",
|
|
2004
|
+
"--uv",
|
|
2005
|
+
python.uv,
|
|
2006
|
+
"--python",
|
|
2007
|
+
runtimePython,
|
|
2008
|
+
"--platform",
|
|
2009
|
+
platform,
|
|
2010
|
+
"--manifest",
|
|
2011
|
+
installation.manifest,
|
|
2012
|
+
"--wheelhouse",
|
|
2013
|
+
wheelhouse,
|
|
2014
|
+
"--runtime-source",
|
|
2015
|
+
runtimeSource,
|
|
2016
|
+
"--distribution-source",
|
|
2017
|
+
distributionSource,
|
|
2018
|
+
], { maxBuffer: 16 * 1024 * 1024, stdio, env, windowsHide: true });
|
|
2019
|
+
copyChildOutput(result.stdout);
|
|
2020
|
+
copyChildOutput(result.stderr);
|
|
2021
|
+
if (!result.error && result.status === FLEET_WHEELHOUSE_EXIT.installed)
|
|
2022
|
+
return "installed";
|
|
2023
|
+
if (!result.error && result.status === FLEET_WHEELHOUSE_EXIT.verificationFailed) {
|
|
2024
|
+
throw expectedError(`HQ Fleet Local ${installation.release.version} bundled packages failed verification, so nothing was installed from them. ` +
|
|
2025
|
+
"Retry; if it happens again, report it with `hq bug`.");
|
|
2026
|
+
}
|
|
2027
|
+
return "fallback";
|
|
2028
|
+
}
|
|
1888
2029
|
/** A FleetLocalSpawn backed by an execFileSync-shaped runner (stderr is only known on failure). */
|
|
1889
2030
|
export function spawnFromRun(run) {
|
|
1890
2031
|
return (executable, args, options) => {
|
|
@@ -2038,6 +2179,35 @@ export function fleetLocalProviderAuthStatus(agentUid, provider, deps = {}) {
|
|
|
2038
2179
|
return null;
|
|
2039
2180
|
}
|
|
2040
2181
|
}
|
|
2182
|
+
function execFileText(executable, args, options) {
|
|
2183
|
+
return new Promise((resolve, reject) => {
|
|
2184
|
+
execFile(executable, args, { ...options, encoding: "utf8", windowsHide: true }, (error, stdout) => {
|
|
2185
|
+
if (error)
|
|
2186
|
+
reject(error);
|
|
2187
|
+
else
|
|
2188
|
+
resolve(String(stdout));
|
|
2189
|
+
});
|
|
2190
|
+
});
|
|
2191
|
+
}
|
|
2192
|
+
export async function fleetLocalProviderAuthStatusAsync(agentUid, provider, deps = {}) {
|
|
2193
|
+
let files;
|
|
2194
|
+
try {
|
|
2195
|
+
files = fleetLocalExecutables(agentUid, deps);
|
|
2196
|
+
}
|
|
2197
|
+
catch {
|
|
2198
|
+
return null;
|
|
2199
|
+
}
|
|
2200
|
+
try {
|
|
2201
|
+
const output = await (deps.runAsync ?? execFileText)(files.helper, ["auth", "status", "--profile", files.profileDir, "--bot-id", agentUid, "--provider", provider], { timeout: 15_000 });
|
|
2202
|
+
const status = JSON.parse(output);
|
|
2203
|
+
if (!status || typeof status !== "object" || Array.isArray(status))
|
|
2204
|
+
return null;
|
|
2205
|
+
return { authenticated: status.authenticated === true, ...(typeof status.authType === "string" ? { authType: status.authType } : {}) };
|
|
2206
|
+
}
|
|
2207
|
+
catch {
|
|
2208
|
+
return null;
|
|
2209
|
+
}
|
|
2210
|
+
}
|
|
2041
2211
|
/** The helper waits this long for a sign-in import before the move counts as failed. */
|
|
2042
2212
|
const FLEET_PROVIDER_IMPORT_TIMEOUT_MS = 60_000;
|
|
2043
2213
|
/**
|
|
@@ -2127,16 +2297,30 @@ async function installSharedFleetRuntime(installation, root, python, platform, r
|
|
|
2127
2297
|
], { stdio: "ignore", env: uvEnv }, "environment creation");
|
|
2128
2298
|
const runtimePython = venvExecutable(runtimeDir, "python", platform);
|
|
2129
2299
|
onProgress?.({ phase: "packages" });
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
"
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2300
|
+
const bundled = installation.wheelhouse && installation.environmentPlatform
|
|
2301
|
+
? installFromWheelhouse(installation, python, runtimePython, runtimeSource, distributionSource, uvEnv, spawn)
|
|
2302
|
+
: "unavailable";
|
|
2303
|
+
if (bundled === "fallback") {
|
|
2304
|
+
fs.rmSync(runtimeDir, { recursive: true, force: true });
|
|
2305
|
+
checkedRun(run, python.uv, [
|
|
2306
|
+
"venv",
|
|
2307
|
+
"--no-config",
|
|
2308
|
+
"--python",
|
|
2309
|
+
python.python,
|
|
2310
|
+
runtimeDir,
|
|
2311
|
+
], { stdio: "ignore", env: uvEnv }, "environment creation");
|
|
2312
|
+
}
|
|
2313
|
+
if (bundled !== "installed")
|
|
2314
|
+
checkedRun(run, python.uv, [
|
|
2315
|
+
"pip",
|
|
2316
|
+
"install",
|
|
2317
|
+
"--no-config",
|
|
2318
|
+
"--python",
|
|
2319
|
+
runtimePython,
|
|
2320
|
+
"--editable",
|
|
2321
|
+
`${runtimeSource}[mcp,anthropic]`,
|
|
2322
|
+
distributionSource,
|
|
2323
|
+
], { stdio: ["ignore", 2, 2], env: uvEnv }, "package installation", spawn);
|
|
2140
2324
|
if (!executables.every((name) => fs.existsSync(venvExecutable(runtimeDir, name, platform)))) {
|
|
2141
2325
|
throw expectedError("HQ Fleet Local installed without its runtime executables.");
|
|
2142
2326
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
type Exec = (executable: string, args: string[], options: Record<string, unknown>) => Buffer | string;
|
|
2
|
+
type AsyncExec = (executable: string, args: string[], options: Record<string, unknown>) => Promise<void>;
|
|
2
3
|
export interface FleetPythonToolAsset {
|
|
3
4
|
name: string;
|
|
4
5
|
sha256: string;
|
|
@@ -14,6 +15,8 @@ export interface FleetPythonDeps {
|
|
|
14
15
|
arch?: NodeJS.Architecture;
|
|
15
16
|
fetch?: typeof fetch;
|
|
16
17
|
run?: Exec;
|
|
18
|
+
runAsync?: AsyncExec;
|
|
19
|
+
signal?: AbortSignal;
|
|
17
20
|
tool?: FleetPythonToolPin;
|
|
18
21
|
pythonVersion?: string;
|
|
19
22
|
env?: NodeJS.ProcessEnv;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { execFileSync } from "node:child_process";
|
|
1
|
+
import { execFile, execFileSync } from "node:child_process";
|
|
2
2
|
import * as crypto from "node:crypto";
|
|
3
3
|
import * as fs from "node:fs";
|
|
4
4
|
import * as path from "node:path";
|
|
5
5
|
import { fleetHome } from "./fleet-local.js";
|
|
6
6
|
import { withBotLock } from "./lock.js";
|
|
7
|
+
import { anySignal } from "../../utils/vault-api.js";
|
|
7
8
|
export const HQ_FLEET_PYTHON_VERSION = "3.13.17";
|
|
8
9
|
export const HQ_FLEET_PYTHON_TOOL = {
|
|
9
10
|
repository: "astral-sh/uv",
|
|
@@ -37,7 +38,7 @@ function causeOf(error, timeoutMs) {
|
|
|
37
38
|
if (error && typeof error === "object") {
|
|
38
39
|
const failure = error;
|
|
39
40
|
// A child killed by execFileSync's timeout: say so instead of a bare signal.
|
|
40
|
-
if (failure.code === "ETIMEDOUT") {
|
|
41
|
+
if (failure.code === "ETIMEDOUT" || (failure.killed === true && failure.code !== "ABORT_ERR" && timeoutMs !== undefined)) {
|
|
41
42
|
return timeoutMs !== undefined ? `timed out after ${Math.round(timeoutMs / 1000)}s` : "timed out";
|
|
42
43
|
}
|
|
43
44
|
const stderr = failure.stderr === undefined ? "" : (Buffer.isBuffer(failure.stderr) ? failure.stderr.toString("utf8") : String(failure.stderr));
|
|
@@ -46,6 +47,8 @@ function causeOf(error, timeoutMs) {
|
|
|
46
47
|
return tail;
|
|
47
48
|
if (typeof failure.status === "number")
|
|
48
49
|
return `exit code ${failure.status}`;
|
|
50
|
+
if (typeof failure.code === "number")
|
|
51
|
+
return `exit code ${failure.code}`;
|
|
49
52
|
if (failure.message)
|
|
50
53
|
return failure.message;
|
|
51
54
|
}
|
|
@@ -121,7 +124,14 @@ async function installTool(deps) {
|
|
|
121
124
|
const url = `https://github.com/${tool.repository}/releases/download/${tool.version}/${asset.name}`;
|
|
122
125
|
let response;
|
|
123
126
|
try {
|
|
124
|
-
|
|
127
|
+
const timeout = AbortSignal.timeout(FLEET_PYTHON_TOOL_DOWNLOAD_TIMEOUT_MS);
|
|
128
|
+
const combined = deps.signal ? anySignal([timeout, deps.signal]) : null;
|
|
129
|
+
try {
|
|
130
|
+
response = await fetcher(url, { signal: combined ? combined.signal : timeout });
|
|
131
|
+
}
|
|
132
|
+
finally {
|
|
133
|
+
combined?.dispose();
|
|
134
|
+
}
|
|
125
135
|
}
|
|
126
136
|
catch {
|
|
127
137
|
throw expectedError("Could not download the HQ Fleet Local runtime installer. Check your internet connection and retry.");
|
|
@@ -181,6 +191,25 @@ function isInside(parent, child, platform) {
|
|
|
181
191
|
const relative = path.relative(fold(realpathOrSelf(parent)), fold(realpathOrSelf(child)));
|
|
182
192
|
return relative !== "" && !relative.startsWith("..") && !path.isAbsolute(relative);
|
|
183
193
|
}
|
|
194
|
+
function runAsync(deps) {
|
|
195
|
+
if (deps.runAsync)
|
|
196
|
+
return deps.runAsync;
|
|
197
|
+
if (deps.run) {
|
|
198
|
+
const run = deps.run;
|
|
199
|
+
return async (executable, args, options) => {
|
|
200
|
+
run(executable, args, options);
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
return (executable, args, options) => new Promise((resolve, reject) => {
|
|
204
|
+
const { stdio: _stdio, ...rest } = options;
|
|
205
|
+
execFile(executable, args, { ...rest, encoding: "buffer", maxBuffer: 16 * 1024 * 1024 }, (error) => {
|
|
206
|
+
if (error)
|
|
207
|
+
reject(error);
|
|
208
|
+
else
|
|
209
|
+
resolve();
|
|
210
|
+
});
|
|
211
|
+
});
|
|
212
|
+
}
|
|
184
213
|
async function ensureFleetPythonLocked(root, deps) {
|
|
185
214
|
const platform = deps.platform ?? process.platform;
|
|
186
215
|
const run = deps.run ?? execFileSync;
|
|
@@ -190,12 +219,13 @@ async function ensureFleetPythonLocked(root, deps) {
|
|
|
190
219
|
const env = fleetUvEnv(pythonDir, deps.env ?? process.env);
|
|
191
220
|
fs.mkdirSync(pythonDir, { recursive: true, mode: 0o700 });
|
|
192
221
|
try {
|
|
193
|
-
|
|
222
|
+
await runAsync(deps)(uv, ["python", "install", version, "--no-config", "--no-bin", "--no-registry", "--install-dir", pythonDir], {
|
|
194
223
|
stdio: ["ignore", "ignore", "pipe"],
|
|
195
224
|
env,
|
|
196
225
|
windowsHide: true,
|
|
197
226
|
timeout: FLEET_PYTHON_INSTALL_TIMEOUT_MS,
|
|
198
227
|
killSignal: "SIGKILL",
|
|
228
|
+
...(deps.signal ? { signal: deps.signal } : {}),
|
|
199
229
|
});
|
|
200
230
|
}
|
|
201
231
|
catch (error) {
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type FleetPython } from "./fleet-python.js";
|
|
2
|
+
import type { FleetInstallProgressListener } from "./fleet-local.js";
|
|
3
|
+
export interface FleetRuntimeSources<T> {
|
|
4
|
+
installation: T;
|
|
5
|
+
python: FleetPython;
|
|
6
|
+
}
|
|
7
|
+
export interface FleetRuntimeSourcesDeps {
|
|
8
|
+
onProgress?: FleetInstallProgressListener;
|
|
9
|
+
ensurePython?: (deps: {
|
|
10
|
+
signal: AbortSignal;
|
|
11
|
+
}) => Promise<FleetPython>;
|
|
12
|
+
}
|
|
13
|
+
export declare function installFleetRuntimeSources<T>(distribution: () => Promise<T>, deps?: FleetRuntimeSourcesDeps): Promise<FleetRuntimeSources<T>>;
|
|
14
|
+
export declare function installOptionalFleetRuntimeSources<T>(distribution: () => Promise<T | null>, deps?: FleetRuntimeSourcesDeps): Promise<FleetRuntimeSources<T> | null>;
|
|
15
|
+
//# sourceMappingURL=fleet-runtime-sources.d.ts.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ensureFleetPython } from "./fleet-python.js";
|
|
2
|
+
async function withPythonAlongside(distribution, deps) {
|
|
3
|
+
const controller = new AbortController();
|
|
4
|
+
const python = (deps.ensurePython ?? ((options) => ensureFleetPython(options)))({ signal: controller.signal });
|
|
5
|
+
python.catch(() => undefined);
|
|
6
|
+
let installation;
|
|
7
|
+
try {
|
|
8
|
+
installation = await distribution();
|
|
9
|
+
}
|
|
10
|
+
catch (error) {
|
|
11
|
+
controller.abort();
|
|
12
|
+
throw error;
|
|
13
|
+
}
|
|
14
|
+
if (installation === null) {
|
|
15
|
+
controller.abort();
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
deps.onProgress?.({ phase: "python" });
|
|
19
|
+
return { installation, python: await python };
|
|
20
|
+
}
|
|
21
|
+
export async function installFleetRuntimeSources(distribution, deps = {}) {
|
|
22
|
+
const sources = await withPythonAlongside(distribution, deps);
|
|
23
|
+
if (!sources)
|
|
24
|
+
throw new Error("HQ Fleet Local installed no distribution.");
|
|
25
|
+
return sources;
|
|
26
|
+
}
|
|
27
|
+
export async function installOptionalFleetRuntimeSources(distribution, deps = {}) {
|
|
28
|
+
return withPythonAlongside(distribution, deps);
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=fleet-runtime-sources.js.map
|
|
@@ -27,6 +27,14 @@ export interface GrokLoginProbeDeps {
|
|
|
27
27
|
/** The helper asks the keychain per profile, so one list of bots shares a scan this long. */
|
|
28
28
|
export declare const GROK_HOLDER_SCAN_TTL_MS = 30000;
|
|
29
29
|
export declare function resetGrokHolderScan(): void;
|
|
30
|
+
export interface GrokLoginProbeAsyncDeps {
|
|
31
|
+
profiles?: () => Array<{
|
|
32
|
+
agentUid: string;
|
|
33
|
+
profileDir: string;
|
|
34
|
+
}>;
|
|
35
|
+
status?: (agentUid: string) => Promise<FleetLocalProviderAuthStatus | null>;
|
|
36
|
+
}
|
|
37
|
+
export declare function grokLoginReadableHereAsync(exclude: string, deps?: GrokLoginProbeAsyncDeps): Promise<LegacyProviderLogin>;
|
|
30
38
|
/** Mirrors the helper's `_existing_machine_oauth`: another Fleet bot here holds a Grok OAuth login. */
|
|
31
39
|
export declare function grokLoginReadableHere(exclude: string, deps?: GrokLoginProbeDeps, now?: number): LegacyProviderLogin;
|
|
32
40
|
export declare const GROK_CLI_AUTH_ISSUER = "https://auth.x.ai";
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
import * as fs from "node:fs";
|
|
20
20
|
import * as os from "node:os";
|
|
21
21
|
import * as path from "node:path";
|
|
22
|
-
import { cachedFleetLocalTargetRelease, fleetLocalProviderAuthStatus, fleetReleaseImportsGrokCli, listFleetLocalProfiles } from "./fleet-local.js";
|
|
22
|
+
import { cachedFleetLocalTargetRelease, fleetLocalProviderAuthStatus, fleetLocalProviderAuthStatusAsync, fleetReleaseImportsGrokCli, listFleetLocalProfiles } from "./fleet-local.js";
|
|
23
23
|
import { botOwnAuthHome, botRuntimeAuth, capacityAccountHome } from "./runtime-auth.js";
|
|
24
24
|
export function codexCliAuthPath(home) {
|
|
25
25
|
return path.join(home, "auth.json");
|
|
@@ -111,9 +111,26 @@ function grokHolders(deps, now) {
|
|
|
111
111
|
grokHolderScan = scan;
|
|
112
112
|
return scan;
|
|
113
113
|
}
|
|
114
|
+
export async function grokLoginReadableHereAsync(exclude, deps = {}) {
|
|
115
|
+
const profiles = (deps.profiles ?? listFleetLocalProfiles)();
|
|
116
|
+
const status = deps.status ?? ((agentUid) => fleetLocalProviderAuthStatusAsync(agentUid, "xai-oauth"));
|
|
117
|
+
const answers = await Promise.all(profiles.map((profile) => status(profile.agentUid)));
|
|
118
|
+
const holders = [];
|
|
119
|
+
const unanswered = [];
|
|
120
|
+
answers.forEach((found, index) => {
|
|
121
|
+
const agentUid = profiles[index].agentUid;
|
|
122
|
+
if (found === null)
|
|
123
|
+
unanswered.push(agentUid);
|
|
124
|
+
else if (found.authenticated && found.authType === "oauth")
|
|
125
|
+
holders.push(agentUid);
|
|
126
|
+
});
|
|
127
|
+
return grokLoginFromScan({ holders, uids: profiles.map((profile) => profile.agentUid), unanswered }, exclude);
|
|
128
|
+
}
|
|
114
129
|
/** Mirrors the helper's `_existing_machine_oauth`: another Fleet bot here holds a Grok OAuth login. */
|
|
115
130
|
export function grokLoginReadableHere(exclude, deps = {}, now = Date.now()) {
|
|
116
|
-
|
|
131
|
+
return grokLoginFromScan(grokHolders(deps, now), exclude);
|
|
132
|
+
}
|
|
133
|
+
function grokLoginFromScan(scan, exclude) {
|
|
117
134
|
const other = (agentUid) => agentUid.toLowerCase() !== exclude.toLowerCase();
|
|
118
135
|
const holder = scan.holders.find(other);
|
|
119
136
|
if (holder)
|
package/dist/lib/bot/probe.js
CHANGED
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
import * as fs from "node:fs";
|
|
16
16
|
import * as os from "node:os";
|
|
17
17
|
import * as path from "node:path";
|
|
18
|
-
import {
|
|
18
|
+
import { recordUsageLimitRefusal } from "../capacity/refusal.js";
|
|
19
|
+
import { classifyRuntimeError, isReportedRuntimeError, isRuntimeUsageLimit, usageLimitResetsAt } from "./runtime-failure.js";
|
|
19
20
|
import { runtimeDisplayName } from "./runtime-sign-in.js";
|
|
20
21
|
import { RuntimeError, runRuntimeTurn, runtimeFor } from "./runtime/index.js";
|
|
21
22
|
import { turnEnv } from "./run.js";
|
|
@@ -92,6 +93,11 @@ export async function probeBotRuntime(opts) {
|
|
|
92
93
|
const cls = classifyRuntimeError(err);
|
|
93
94
|
const limited = cls === "transient" && isRuntimeUsageLimit(raw);
|
|
94
95
|
const resetsAt = limited ? usageLimitResetsAt(raw) : undefined;
|
|
96
|
+
// Only the runtime's own reported error records: raw stderr can be the
|
|
97
|
+
// model's progress text quoting a limit message.
|
|
98
|
+
if (limited && isReportedRuntimeError(err)) {
|
|
99
|
+
recordUsageLimitRefusal({ provider: opts.runtime, turnEnv: opts.env ?? process.env, text: raw });
|
|
100
|
+
}
|
|
95
101
|
return {
|
|
96
102
|
ok: false,
|
|
97
103
|
class: cls,
|
package/dist/lib/bot/prompt.js
CHANGED
|
@@ -294,7 +294,7 @@ export function botKindParagraph(input) {
|
|
|
294
294
|
}
|
|
295
295
|
const ownerContext = input.fleetRuntime
|
|
296
296
|
? `The runtime labels every message with the sender's HQ identity: messages from ${input.ownerUid} are your owner's, and only those carry your owner's authority. ` +
|
|
297
|
-
`When you need to know which companies your owner belongs to,
|
|
297
|
+
`When you need to know which companies your owner belongs to, call the hq_companies_list tool yourself; \`hq whoami\` does not list companies. Never guess. ` +
|
|
298
298
|
`Other people read your answers in rooms: in a room, never state which companies your owner belongs to, and never repeat anything from their files or your DMs.`
|
|
299
299
|
: `Direct messages from your owner start with an "Owner context" block checked with your owner's own sign-in; that is the only source for your owner's companies. ` +
|
|
300
300
|
`If it says the check failed, say you could not check; never say your owner has no company unless that block says so. ` +
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type FleetLocalGatewayState } from "./fleet-local.js";
|
|
2
|
+
import { type BotStatusFile } from "./status.js";
|
|
2
3
|
export type BotReadiness = "creating" | "installing" | "starting" | "ready" | "offline";
|
|
3
4
|
export declare const BOT_READINESS_VALUES: readonly BotReadiness[];
|
|
4
5
|
export type BotSetupStep = "identity" | "install" | "starting" | "ready";
|
|
@@ -22,7 +23,12 @@ export interface ReadinessFacts {
|
|
|
22
23
|
processAlive: boolean;
|
|
23
24
|
livePid?: number | null;
|
|
24
25
|
gateway: Pick<FleetLocalGatewayState, "gatewayState" | "ready" | "pid"> | null;
|
|
26
|
+
status?: Pick<BotStatusFile, "pid" | "ready"> | null;
|
|
27
|
+
statusCarriesReady?: boolean;
|
|
25
28
|
}
|
|
29
|
+
export declare const FLEET_STATUS_READY_MIN_VERSION = "0.4.30";
|
|
30
|
+
export declare function fleetStatusCarriesReady(engineVersion: string | null | undefined): boolean;
|
|
31
|
+
export declare function fleetGatewayReadyForChat(gateway: Pick<FleetLocalGatewayState, "gatewayState" | "ready" | "pid"> | null, status: Pick<BotStatusFile, "pid" | "ready"> | null | undefined, statusCarriesReady: boolean): boolean;
|
|
26
32
|
export declare function deriveBotReadiness(facts: ReadinessFacts): BotReadiness;
|
|
27
33
|
export interface BotReadinessReport {
|
|
28
34
|
readiness: BotReadiness;
|
|
@@ -51,6 +57,8 @@ export declare function waitForGatewayReady(agentUid: string, opts: {
|
|
|
51
57
|
now?: () => number;
|
|
52
58
|
sleep?: (ms: number) => Promise<void>;
|
|
53
59
|
alive?: (pid: number) => boolean;
|
|
60
|
+
botDir?: string;
|
|
61
|
+
statusCarriesReady?: boolean;
|
|
54
62
|
}): Promise<ReadyWaitResult>;
|
|
55
63
|
export type SetupStepStatus = "pending" | "active" | "done" | "skipped" | "timeout" | "failed";
|
|
56
64
|
export interface SetupStepRecord {
|