@amd-gaia/agent-ui 0.26.0-rc.4 → 0.26.0-rc.6
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/dist/assets/{AdvancedSettings-COFRGVnp.js → AdvancedSettings-8tGuuocd.js} +1 -1
- package/dist/assets/{ConnectorsPane-DabhbsAr.js → ConnectorsPane-BfS5fSIl.js} +1 -1
- package/dist/assets/{DocumentLibrary-Ds6RAGWd.js → DocumentLibrary-V2n1obTR.js} +1 -1
- package/dist/assets/{FileBrowser-D8tXh0O5.js → FileBrowser-D5gu5VB9.js} +1 -1
- package/dist/assets/{MemoryDashboard-CQt0o16Z.js → MemoryDashboard-D3BSEWvI.js} +1 -1
- package/dist/assets/{MobileAccessModal-CPeJrvAN.js → MobileAccessModal-DGKfraeR.js} +1 -1
- package/dist/assets/{ScheduleManager-Bk9_YEW6.js → ScheduleManager-BwuPu7-w.js} +1 -1
- package/dist/assets/{api-13Cql4sZ.js → api-c2Hja8UA.js} +1 -1
- package/dist/assets/index-BSZT2AHb.js +83 -0
- package/dist/assets/{index-LLooEbjq.css → index-LIIGp54f.css} +1 -1
- package/dist/assets/{useT-BNShbVIz.js → useT-9bLwAbF7.js} +2 -2
- package/dist/assets/{zap-BP1leAhK.js → zap-gjTc4oQN.js} +1 -1
- package/dist/index.html +4 -4
- package/dist/sw.js +1 -1
- package/main.cjs +17 -0
- package/package.json +1 -1
- package/services/auto-updater.cjs +10 -0
- package/services/backend-installer.cjs +157 -470
- package/dist/assets/index-B3y-e0-u.js +0 -83
|
@@ -4,8 +4,10 @@
|
|
|
4
4
|
/**
|
|
5
5
|
* backend-installer.cjs — Shared GAIA Python backend bootstrap logic.
|
|
6
6
|
*
|
|
7
|
-
* Single source of truth for
|
|
8
|
-
*
|
|
7
|
+
* Single source of truth for the GAIA backend the app runs. A packaged app
|
|
8
|
+
* runs the frozen `gaia` it ships (<resources>/core) and installs nothing; run
|
|
9
|
+
* from source, it installs `~/.gaia/venv` with `amd-gaia[ui]==<pinned-version>`.
|
|
10
|
+
* Called from both:
|
|
9
11
|
*
|
|
10
12
|
* - `bin/gaia-ui.cjs` (the npm CLI entry point)
|
|
11
13
|
* - `main.cjs` (the Electron app, on first-run bootstrap)
|
|
@@ -17,7 +19,7 @@
|
|
|
17
19
|
* - installBackend(opts) → Promise<void>
|
|
18
20
|
* - ensureBackend(opts) → Promise<string> (returns gaia bin path)
|
|
19
21
|
* - isBackendCurrent() → boolean (nothing to install or refresh)
|
|
20
|
-
* - stopRunningDaemon(opts) → Promise<void> (before
|
|
22
|
+
* - stopRunningDaemon(opts) → Promise<void> (before its files are replaced)
|
|
21
23
|
* - getInstalledVersion(gaiaBin) → string | null
|
|
22
24
|
* - findGaiaBin() → string | null
|
|
23
25
|
* - getState() / setState() → state machine helpers
|
|
@@ -34,7 +36,6 @@
|
|
|
34
36
|
"use strict";
|
|
35
37
|
|
|
36
38
|
const { spawn, spawnSync, execFileSync } = require("child_process");
|
|
37
|
-
const crypto = require("crypto");
|
|
38
39
|
const fs = require("fs");
|
|
39
40
|
const path = require("path");
|
|
40
41
|
const os = require("os");
|
|
@@ -55,6 +56,16 @@ const GAIA_PYTHON_BIN = IS_WINDOWS
|
|
|
55
56
|
? path.join(GAIA_VENV, "Scripts", "python.exe")
|
|
56
57
|
: path.join(GAIA_VENV, "bin", "python");
|
|
57
58
|
|
|
59
|
+
// The frozen `gaia` a packaged app ships (installer/core/freeze.py). A packaged
|
|
60
|
+
// app runs only this one; the venv below is for running the app from source.
|
|
61
|
+
const BUNDLED_GAIA_BIN = process.resourcesPath
|
|
62
|
+
? path.join(process.resourcesPath, "core", IS_WINDOWS ? "gaia.exe" : "gaia")
|
|
63
|
+
: null;
|
|
64
|
+
// Not ~/.gaia/core: install.sh unpacks its own gaia there.
|
|
65
|
+
const APPIMAGE_CORE_ROOT = path.join(GAIA_HOME, "app-core");
|
|
66
|
+
// Written last, so a copy a quit cut short is redone.
|
|
67
|
+
const APPIMAGE_CORE_DONE = ".copied";
|
|
68
|
+
|
|
58
69
|
const STATE_FILE = path.join(GAIA_HOME, "electron-install-state.json");
|
|
59
70
|
const LOG_FILE = path.join(GAIA_HOME, "electron-install.log");
|
|
60
71
|
// hub/installer.py writes this once the flagship is installed; first-run setup installs it.
|
|
@@ -78,55 +89,6 @@ const NETWORK_CHECK_TIMEOUT_MS = 5000;
|
|
|
78
89
|
const INSTALL_MAX_ATTEMPTS = 3;
|
|
79
90
|
const INSTALL_RETRY_BACKOFF_MS = 3000;
|
|
80
91
|
|
|
81
|
-
// ── Bundled `uv` binary ──────────────────────────────────────────────────────
|
|
82
|
-
//
|
|
83
|
-
// Issue #782 / T3: the AppImage now ships a pinned `uv` under
|
|
84
|
-
// `extraResources` (see electron-builder.yml). At runtime we copy it into
|
|
85
|
-
// `~/.gaia/bin/uv` with atomic-rename + SHA256 verification. The previous
|
|
86
|
-
// `curl | sh` path is retained only as an unpackaged-dev fallback so
|
|
87
|
-
// contributors running from source keep working.
|
|
88
|
-
//
|
|
89
|
-
// When bumping uv, update:
|
|
90
|
-
// - .github/workflows/build-installers.yml (tarball .tar.gz SHA256 — archive)
|
|
91
|
-
// - BUNDLED_UV_SHA256 below (extracted binary SHA256, linux-x64/win-x64 only)
|
|
92
|
-
//
|
|
93
|
-
// IMPORTANT: per-platform verification strategy differs:
|
|
94
|
-
// - linux-x64 / win-x64: BUNDLED_UV_SHA256 pins the raw extracted-binary
|
|
95
|
-
// digest (no post-build modification) — deterministic across CI runs.
|
|
96
|
-
// - mac-arm64: NOT pinned here. electron-builder code-signs the bundled uv
|
|
97
|
-
// during packaging (ad-hoc `identity=-` when no Developer ID cert is
|
|
98
|
-
// configured, which is every CI build today), and ad-hoc codesign output
|
|
99
|
-
// depends on the codesign/Xcode toolchain baked into the GitHub-hosted
|
|
100
|
-
// `macos-latest` runner image — which floats and is NOT reproducible
|
|
101
|
-
// across CI runs (observed: macos-15-arm64 vs macos-26-arm64 images
|
|
102
|
-
// produced two different digests for byte-identical source). A fixed
|
|
103
|
-
// SHA256 pin is therefore not deterministic on macOS and would fail
|
|
104
|
-
// ~half of CI runs and brick first-launch on user machines whenever the
|
|
105
|
-
// runner image rolls. Instead, ensureUv() and the dmg-structural-smoke
|
|
106
|
-
// test both run `codesign --verify --strict` against the bundled binary
|
|
107
|
-
// — this validates the on-disk signature is intact/untampered without
|
|
108
|
-
// depending on the exact signing bytes, and still fails loud on
|
|
109
|
-
// corruption or an actually-invalid signature.
|
|
110
|
-
const BUNDLED_UV_VERSION = "0.5.14";
|
|
111
|
-
const BUNDLED_UV_SHA256 = {
|
|
112
|
-
"linux-x64": "0e05d828b5708e8a927724124db3746396afddad6273c47283d7c562dc795bd6",
|
|
113
|
-
// The Windows extracted uv.exe SHA is populated by CI during the
|
|
114
|
-
// build step. The placeholder MUST be replaced in CI before packaging
|
|
115
|
-
// so runtime verification remains strict.
|
|
116
|
-
"win-x64": "055d55eec85a91cfb5e9c8bc7f6463f9883866796c5bcb205fbcdfed9c088c88",
|
|
117
|
-
// mac-arm64: intentionally absent. See the comment block above — the
|
|
118
|
-
// post-codesign digest is not deterministic across CI runner images, so
|
|
119
|
-
// mac-arm64 is verified via codesignVerify() (identity/signature validity)
|
|
120
|
-
// instead of a fixed SHA256 pin. bundledUvPlatformKey() still returns
|
|
121
|
-
// "mac-arm64"; callers must not treat a missing entry here as "unpinned
|
|
122
|
-
// platform" for darwin — see ensureUv()/installBundledUv().
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
const MANAGED_UV_DIR = path.join(GAIA_HOME, "bin");
|
|
126
|
-
const MANAGED_UV_BIN = IS_WINDOWS
|
|
127
|
-
? path.join(MANAGED_UV_DIR, "uv.exe")
|
|
128
|
-
: path.join(MANAGED_UV_DIR, "uv");
|
|
129
|
-
|
|
130
92
|
const STATES = Object.freeze({
|
|
131
93
|
IDLE: "idle",
|
|
132
94
|
INSTALLING: "installing",
|
|
@@ -457,10 +419,59 @@ function commandExists(cmd) {
|
|
|
457
419
|
return result.status === 0;
|
|
458
420
|
}
|
|
459
421
|
|
|
422
|
+
/** The `gaia` this packaged app ships, or null when it ships none. */
|
|
423
|
+
function shippedGaiaBin() {
|
|
424
|
+
return BUNDLED_GAIA_BIN && fs.existsSync(BUNDLED_GAIA_BIN) ? BUNDLED_GAIA_BIN : null;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
/** Where an AppImage keeps its copy of the shipped core for this version. */
|
|
428
|
+
function appImageCoreDir() {
|
|
429
|
+
return path.join(APPIMAGE_CORE_ROOT, toPep440(appVersion()));
|
|
430
|
+
}
|
|
431
|
+
|
|
460
432
|
/**
|
|
461
|
-
*
|
|
433
|
+
* The shipped `gaia` as the app runs it, or null until it can run. An
|
|
434
|
+
* AppImage's files vanish when the app quits, and the daemon outlives the app,
|
|
435
|
+
* so an AppImage runs a copy under ~/.gaia once ensureBundledCore has made it.
|
|
436
|
+
*/
|
|
437
|
+
function bundledGaiaBin() {
|
|
438
|
+
const shipped = shippedGaiaBin();
|
|
439
|
+
if (!shipped || !process.env.APPIMAGE) return shipped;
|
|
440
|
+
const dir = appImageCoreDir();
|
|
441
|
+
return fs.existsSync(path.join(dir, APPIMAGE_CORE_DONE)) ? path.join(dir, path.basename(shipped)) : null;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
/** bundledGaiaBin, after copying an AppImage's core out of its mount. */
|
|
445
|
+
async function ensureBundledCore() {
|
|
446
|
+
const shipped = shippedGaiaBin();
|
|
447
|
+
if (!shipped || !process.env.APPIMAGE) return shipped;
|
|
448
|
+
const ready = bundledGaiaBin();
|
|
449
|
+
if (ready) return ready;
|
|
450
|
+
const dir = appImageCoreDir();
|
|
451
|
+
log(`Copying the backend out of the AppImage to ${dir}`);
|
|
452
|
+
fs.rmSync(dir, { recursive: true, force: true });
|
|
453
|
+
await fs.promises.cp(path.dirname(shipped), dir, { recursive: true, verbatimSymlinks: true });
|
|
454
|
+
fs.writeFileSync(path.join(dir, APPIMAGE_CORE_DONE), appVersion());
|
|
455
|
+
const copy = bundledGaiaBin();
|
|
456
|
+
const older = listDir(APPIMAGE_CORE_ROOT).filter((name) => name !== path.basename(dir));
|
|
457
|
+
if (older.length) {
|
|
458
|
+
// A daemon from an older copy reads its files as it runs, so it stops first.
|
|
459
|
+
await stopRunningDaemon({ gaiaBin: copy });
|
|
460
|
+
for (const name of older) {
|
|
461
|
+
fs.rmSync(path.join(APPIMAGE_CORE_ROOT, name), { recursive: true, force: true });
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
return copy;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
/**
|
|
468
|
+
* Find the gaia binary. A packaged app runs only the one it ships; from
|
|
469
|
+
* source, the managed venv, else PATH.
|
|
462
470
|
*/
|
|
463
471
|
function findGaiaBin() {
|
|
472
|
+
if (shippedGaiaBin()) {
|
|
473
|
+
return bundledGaiaBin();
|
|
474
|
+
}
|
|
464
475
|
if (fs.existsSync(GAIA_BIN)) {
|
|
465
476
|
return GAIA_BIN;
|
|
466
477
|
}
|
|
@@ -633,9 +644,9 @@ function liveDaemonPid() {
|
|
|
633
644
|
* stop that fails with no daemon running (a broken venv, say) must not block
|
|
634
645
|
* the reinstall that repairs it.
|
|
635
646
|
*/
|
|
636
|
-
async function stopRunningDaemon({ timeoutMs = DAEMON_STOP_TIMEOUT_MS, signal } = {}) {
|
|
637
|
-
if (!fs.existsSync(
|
|
638
|
-
const result = await runCommand(
|
|
647
|
+
async function stopRunningDaemon({ gaiaBin = GAIA_BIN, timeoutMs = DAEMON_STOP_TIMEOUT_MS, signal } = {}) {
|
|
648
|
+
if (!fs.existsSync(gaiaBin) || (gaiaBin === GAIA_BIN && !fs.existsSync(GAIA_PYTHON_BIN))) return;
|
|
649
|
+
const result = await runCommand(gaiaBin, ["daemon", "stop"], {
|
|
639
650
|
stageLabel: "daemon",
|
|
640
651
|
timeoutMs,
|
|
641
652
|
signal,
|
|
@@ -666,7 +677,7 @@ async function stopRunningDaemon({ timeoutMs = DAEMON_STOP_TIMEOUT_MS, signal }
|
|
|
666
677
|
const why = result.timedOut
|
|
667
678
|
? `did not stop within ${Math.round(timeoutMs / 1000)} seconds`
|
|
668
679
|
: `could not be stopped (gaia daemon stop exit ${result.code})`;
|
|
669
|
-
log(`To stop it by hand: ${
|
|
680
|
+
log(`To stop it by hand: ${gaiaBin} daemon stop`);
|
|
670
681
|
throw new InstallError(
|
|
671
682
|
`GAIA's background service (the GAIA daemon, pid ${pid}) ${why}, so its files can't be updated.`,
|
|
672
683
|
{
|
|
@@ -1217,437 +1228,81 @@ function failureReason(output) {
|
|
|
1217
1228
|
}
|
|
1218
1229
|
|
|
1219
1230
|
/**
|
|
1220
|
-
*
|
|
1221
|
-
*
|
|
1222
|
-
*
|
|
1223
|
-
*/
|
|
1224
|
-
function bundledUvPlatformKey() {
|
|
1225
|
-
if (process.platform === "linux" && process.arch === "x64") return "linux-x64";
|
|
1226
|
-
if (process.platform === "win32" && process.arch === "x64") return "win-x64";
|
|
1227
|
-
if (process.platform === "darwin" && process.arch === "arm64") return "mac-arm64";
|
|
1228
|
-
return null;
|
|
1229
|
-
}
|
|
1230
|
-
|
|
1231
|
-
/**
|
|
1232
|
-
* Stream-SHA256 a file. Returns lowercase hex.
|
|
1233
|
-
*/
|
|
1234
|
-
function sha256File(filePath) {
|
|
1235
|
-
return new Promise((resolve, reject) => {
|
|
1236
|
-
const hash = crypto.createHash("sha256");
|
|
1237
|
-
const stream = fs.createReadStream(filePath);
|
|
1238
|
-
stream.on("error", reject);
|
|
1239
|
-
stream.on("data", (chunk) => hash.update(chunk));
|
|
1240
|
-
stream.on("end", () => resolve(hash.digest("hex")));
|
|
1241
|
-
});
|
|
1242
|
-
}
|
|
1243
|
-
|
|
1244
|
-
/**
|
|
1245
|
-
* Verify a macOS binary's code signature is structurally intact via
|
|
1246
|
-
* `codesign --verify --strict`. Used in place of a fixed SHA256 pin for
|
|
1247
|
-
* mac-arm64 (see the BUNDLED_UV_SHA256 comment) — ad-hoc-signed binaries
|
|
1248
|
-
* (identity=-, which is every CI build today) pass this check, but a
|
|
1249
|
-
* corrupted, tampered, or actually-unsigned binary fails it. This does NOT
|
|
1250
|
-
* depend on the specific bytes any given codesign/Xcode toolchain produces,
|
|
1251
|
-
* so it is stable across GitHub-hosted runner image rollovers where a fixed
|
|
1252
|
-
* digest pin is not.
|
|
1231
|
+
* Ensure `uv` is available. Only running the app from source gets here: a
|
|
1232
|
+
* packaged app ships its backend. Uses the uv on PATH, else installs it from
|
|
1233
|
+
* astral.sh.
|
|
1253
1234
|
*
|
|
1254
|
-
*
|
|
1255
|
-
* @returns {{ ok: boolean, output: string }}
|
|
1256
|
-
*/
|
|
1257
|
-
function codesignVerify(binPath) {
|
|
1258
|
-
const result = spawnSync("codesign", ["--verify", "--strict", binPath], {
|
|
1259
|
-
encoding: "utf8",
|
|
1260
|
-
});
|
|
1261
|
-
const output = `${result.stdout || ""}${result.stderr || ""}`.trim();
|
|
1262
|
-
return { ok: result.status === 0, output };
|
|
1263
|
-
}
|
|
1264
|
-
|
|
1265
|
-
/**
|
|
1266
|
-
* Resolve the bundled uv binary path inside the Electron resources dir.
|
|
1267
|
-
* Returns null if this isn't an Electron-packaged runtime (no
|
|
1268
|
-
* `process.resourcesPath`) or if the host platform isn't bundled.
|
|
1235
|
+
* Throws InstallError on failure.
|
|
1269
1236
|
*/
|
|
1270
|
-
function
|
|
1271
|
-
const
|
|
1272
|
-
|
|
1273
|
-
const resourcesPath = process.resourcesPath;
|
|
1274
|
-
if (!resourcesPath) return null;
|
|
1275
|
-
const candidate = path.join(
|
|
1276
|
-
resourcesPath,
|
|
1277
|
-
"vendor",
|
|
1278
|
-
"uv",
|
|
1279
|
-
key,
|
|
1280
|
-
IS_WINDOWS ? "uv.exe" : "uv"
|
|
1281
|
-
);
|
|
1282
|
-
return fs.existsSync(candidate) ? candidate : null;
|
|
1283
|
-
}
|
|
1237
|
+
async function ensureUv({ onProgress, signal } = {}) {
|
|
1238
|
+
const report = makeProgressReporter(onProgress);
|
|
1239
|
+
report(STAGES.ENSURE_UV, 0, "Checking uv (Python package manager)");
|
|
1284
1240
|
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
* Verification strategy differs by platform (see the BUNDLED_UV_SHA256
|
|
1290
|
-
* comment): mac-arm64 uses `codesign --verify --strict` (darwin only —
|
|
1291
|
-
* post-codesign SHA256 is not deterministic across CI runner images);
|
|
1292
|
-
* linux-x64 / win-x64 use the SHA256 pin in BUNDLED_UV_SHA256, which IS
|
|
1293
|
-
* deterministic for those platforms (no post-build re-signing).
|
|
1294
|
-
*
|
|
1295
|
-
* Writes to `uv.tmp-<pid>-<rand>` with mode 0o700, verifies, `chmod +x`,
|
|
1296
|
-
* then `fs.rename()` (atomic on same filesystem).
|
|
1297
|
-
*/
|
|
1298
|
-
async function installBundledUv(sourcePath, platformKey) {
|
|
1299
|
-
const isDarwin = platformKey === "mac-arm64";
|
|
1300
|
-
const expected = BUNDLED_UV_SHA256[platformKey];
|
|
1301
|
-
if (!isDarwin && (!expected || expected.startsWith("<"))) {
|
|
1302
|
-
// Enforce strict verification: builds MUST populate the expected SHA
|
|
1303
|
-
// for packaged binaries. Failing fast prevents shipping an unverified
|
|
1304
|
-
// uv binary which would be a supply-chain regression.
|
|
1305
|
-
throw new InstallError(
|
|
1306
|
-
`No bundled uv checksum registered for platform ${platformKey}. Build must populate BUNDLED_UV_SHA256.${platformKey}`,
|
|
1307
|
-
{ stage: STAGES.ENSURE_UV }
|
|
1308
|
-
);
|
|
1241
|
+
if (commandExists("uv")) {
|
|
1242
|
+
log("uv already on PATH (dev) — using system install");
|
|
1243
|
+
report(STAGES.ENSURE_UV, 100, "uv is already installed (system)");
|
|
1244
|
+
return;
|
|
1309
1245
|
}
|
|
1310
1246
|
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1247
|
+
log("No uv on PATH — installing it from astral.sh");
|
|
1248
|
+
let result;
|
|
1249
|
+
if (IS_WINDOWS) {
|
|
1250
|
+
result = await runCommand(
|
|
1251
|
+
"powershell",
|
|
1252
|
+
[
|
|
1253
|
+
"-ExecutionPolicy",
|
|
1254
|
+
"Bypass",
|
|
1255
|
+
"-Command",
|
|
1256
|
+
"irm https://astral.sh/uv/install.ps1 | iex",
|
|
1257
|
+
],
|
|
1258
|
+
{ stageLabel: "uv-install", signal }
|
|
1318
1259
|
);
|
|
1319
|
-
}
|
|
1320
|
-
|
|
1321
|
-
const rand = crypto.randomBytes(6).toString("hex");
|
|
1322
|
-
const tmpPath = path.join(
|
|
1323
|
-
MANAGED_UV_DIR,
|
|
1324
|
-
`uv.tmp-${process.pid}-${rand}${IS_WINDOWS ? ".exe" : ""}`
|
|
1325
|
-
);
|
|
1326
|
-
|
|
1327
|
-
// Copy source → tmp with restrictive mode.
|
|
1328
|
-
await new Promise((resolve, reject) => {
|
|
1329
|
-
const rs = fs.createReadStream(sourcePath);
|
|
1330
|
-
const ws = fs.createWriteStream(tmpPath, { mode: 0o700 });
|
|
1331
|
-
rs.on("error", reject);
|
|
1332
|
-
ws.on("error", reject);
|
|
1333
|
-
ws.on("finish", resolve);
|
|
1334
|
-
rs.pipe(ws);
|
|
1335
|
-
});
|
|
1336
|
-
|
|
1337
|
-
if (isDarwin) {
|
|
1338
|
-
// chmod BEFORE codesign --verify: codesign needs the execute bit to
|
|
1339
|
-
// resolve the binary's designated requirement on some toolchains.
|
|
1340
|
-
try {
|
|
1341
|
-
fs.chmodSync(tmpPath, 0o700);
|
|
1342
|
-
} catch (err) {
|
|
1343
|
-
log(`Warning: chmod on tmp uv failed: ${err.message}`);
|
|
1344
|
-
}
|
|
1345
|
-
const { ok, output } = codesignVerify(tmpPath);
|
|
1346
|
-
if (!ok) {
|
|
1347
|
-
try { fs.unlinkSync(tmpPath); } catch { /* ignore */ }
|
|
1348
|
-
throw new InstallError(
|
|
1349
|
-
`Bundled uv failed code signature verification (codesign --verify --strict): ${output || "no output"}`,
|
|
1350
|
-
{
|
|
1351
|
-
stage: STAGES.ENSURE_UV,
|
|
1352
|
-
suggestion:
|
|
1353
|
-
"The AppImage/installer may be corrupt. Re-download from https://amd-gaia.ai and try again.",
|
|
1354
|
-
}
|
|
1355
|
-
);
|
|
1356
|
-
}
|
|
1357
|
-
log("Bundled uv passed codesign --verify --strict");
|
|
1358
1260
|
} else {
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
try { fs.unlinkSync(tmpPath); } catch { /* ignore */ }
|
|
1364
|
-
throw new InstallError(
|
|
1365
|
-
`Could not hash copied uv binary: ${err.message}`,
|
|
1366
|
-
{ stage: STAGES.ENSURE_UV }
|
|
1367
|
-
);
|
|
1368
|
-
}
|
|
1369
|
-
|
|
1370
|
-
if (actual !== expected) {
|
|
1371
|
-
try { fs.unlinkSync(tmpPath); } catch { /* ignore */ }
|
|
1372
|
-
throw new InstallError(
|
|
1373
|
-
`Bundled uv SHA256 mismatch (expected ${expected}, got ${actual}).`,
|
|
1374
|
-
{
|
|
1375
|
-
stage: STAGES.ENSURE_UV,
|
|
1376
|
-
suggestion:
|
|
1377
|
-
"The AppImage/installer may be corrupt. Re-download from https://amd-gaia.ai and try again.",
|
|
1378
|
-
}
|
|
1379
|
-
);
|
|
1380
|
-
}
|
|
1381
|
-
|
|
1382
|
-
try {
|
|
1383
|
-
if (!IS_WINDOWS) fs.chmodSync(tmpPath, 0o700);
|
|
1384
|
-
} catch (err) {
|
|
1385
|
-
log(`Warning: chmod on tmp uv failed: ${err.message}`);
|
|
1386
|
-
}
|
|
1387
|
-
}
|
|
1388
|
-
|
|
1389
|
-
try {
|
|
1390
|
-
// rename() is atomic on the same filesystem on POSIX; on Windows
|
|
1391
|
-
// it requires the target not to exist, so unlink first.
|
|
1392
|
-
if (IS_WINDOWS && fs.existsSync(MANAGED_UV_BIN)) {
|
|
1393
|
-
try { fs.unlinkSync(MANAGED_UV_BIN); } catch { /* ignore */ }
|
|
1394
|
-
}
|
|
1395
|
-
fs.renameSync(tmpPath, MANAGED_UV_BIN);
|
|
1396
|
-
} catch (err) {
|
|
1397
|
-
try { fs.unlinkSync(tmpPath); } catch { /* ignore */ }
|
|
1398
|
-
throw new InstallError(
|
|
1399
|
-
`Could not install uv to ${MANAGED_UV_BIN}: ${err.message}`,
|
|
1400
|
-
{ stage: STAGES.ENSURE_UV }
|
|
1261
|
+
result = await runCommand(
|
|
1262
|
+
"bash",
|
|
1263
|
+
["-c", "curl -LsSf https://astral.sh/uv/install.sh | sh"],
|
|
1264
|
+
{ stageLabel: "uv-install", signal }
|
|
1401
1265
|
);
|
|
1402
1266
|
}
|
|
1403
1267
|
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
}
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
if (
|
|
1414
|
-
process.env.PATH &&
|
|
1415
|
-
!process.env.PATH.split(path.delimiter).includes(MANAGED_UV_DIR)
|
|
1416
|
-
) {
|
|
1417
|
-
process.env.PATH = `${MANAGED_UV_DIR}${path.delimiter}${process.env.PATH}`;
|
|
1418
|
-
log(`Prepended ${MANAGED_UV_DIR} to PATH for this process`);
|
|
1419
|
-
}
|
|
1420
|
-
}
|
|
1421
|
-
|
|
1422
|
-
/**
|
|
1423
|
-
* Ensure `uv` is available. Preference order (per issue #782 / T3):
|
|
1424
|
-
* 1. Managed copy at ~/.gaia/bin/uv already verified (warm-install fast path):
|
|
1425
|
-
* SHA256 pin on linux-x64/win-x64, `codesign --verify --strict` on mac-arm64.
|
|
1426
|
-
* 2. Bundled binary in process.resourcesPath/vendor/uv/<platform>/uv:
|
|
1427
|
-
* copy atomically to ~/.gaia/bin/uv with the same platform-appropriate
|
|
1428
|
-
* verification.
|
|
1429
|
-
* 3. DEV-ONLY fallback (app.isPackaged === false OR no resourcesPath):
|
|
1430
|
-
* the original `curl | sh` from astral.sh. Not a shipped-user path.
|
|
1431
|
-
* 4. System `uv` on PATH (last resort — unverified version).
|
|
1432
|
-
*
|
|
1433
|
-
* Throws InstallError on failure.
|
|
1434
|
-
*/
|
|
1435
|
-
async function ensureUv({ onProgress, isPackaged, signal } = {}) {
|
|
1436
|
-
const report = makeProgressReporter(onProgress);
|
|
1437
|
-
report(STAGES.ENSURE_UV, 0, "Checking uv (Python package manager)");
|
|
1438
|
-
|
|
1439
|
-
const platformKey = bundledUvPlatformKey();
|
|
1440
|
-
const isDarwin = platformKey === "mac-arm64";
|
|
1441
|
-
const expectedSha = platformKey ? BUNDLED_UV_SHA256[platformKey] : null;
|
|
1442
|
-
|
|
1443
|
-
// Fast path: warm install already on disk and still passes verification.
|
|
1444
|
-
if (isDarwin && fs.existsSync(MANAGED_UV_BIN)) {
|
|
1445
|
-
const { ok, output } = codesignVerify(MANAGED_UV_BIN);
|
|
1446
|
-
if (ok) {
|
|
1447
|
-
log(`Managed uv at ${MANAGED_UV_BIN} passed codesign --verify --strict — reusing`);
|
|
1448
|
-
addManagedBinToPath();
|
|
1449
|
-
report(STAGES.ENSURE_UV, 100, "uv ready (cached)");
|
|
1450
|
-
return;
|
|
1451
|
-
}
|
|
1452
|
-
log(`Managed uv failed codesign verification (${output || "no output"}) — replacing`);
|
|
1453
|
-
} else if (expectedSha && fs.existsSync(MANAGED_UV_BIN)) {
|
|
1454
|
-
try {
|
|
1455
|
-
const actual = await sha256File(MANAGED_UV_BIN);
|
|
1456
|
-
if (actual === expectedSha) {
|
|
1457
|
-
log(`Managed uv at ${MANAGED_UV_BIN} passed SHA256 check — reusing`);
|
|
1458
|
-
addManagedBinToPath();
|
|
1459
|
-
report(STAGES.ENSURE_UV, 100, "uv ready (cached)");
|
|
1460
|
-
return;
|
|
1268
|
+
if (result.code !== 0) {
|
|
1269
|
+
throw new InstallError(
|
|
1270
|
+
`Could not install uv automatically (exit code ${result.code}).`,
|
|
1271
|
+
{
|
|
1272
|
+
stage: STAGES.ENSURE_UV,
|
|
1273
|
+
code: result.code,
|
|
1274
|
+
suggestion: IS_WINDOWS
|
|
1275
|
+
? 'Install uv manually: powershell -c "irm https://astral.sh/uv/install.ps1 | iex"'
|
|
1276
|
+
: "Install uv manually: curl -LsSf https://astral.sh/uv/install.sh | sh",
|
|
1461
1277
|
}
|
|
1462
|
-
|
|
1463
|
-
`Managed uv hash mismatch (expected ${expectedSha}, got ${actual}) — replacing`
|
|
1464
|
-
);
|
|
1465
|
-
} catch (err) {
|
|
1466
|
-
log(`Could not verify managed uv: ${err.message} — replacing`);
|
|
1467
|
-
}
|
|
1278
|
+
);
|
|
1468
1279
|
}
|
|
1469
1280
|
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
// fixed digest isn't viable there); other platforms use the SHA256 pin,
|
|
1480
|
-
// which CI must have populated — a missing/placeholder value is a
|
|
1481
|
-
// build-time error, rejected at runtime here.
|
|
1482
|
-
if (isDarwin) {
|
|
1483
|
-
const { ok, output } = codesignVerify(bundled);
|
|
1484
|
-
if (!ok) {
|
|
1485
|
-
throw new InstallError(
|
|
1486
|
-
`Bundled uv resource failed code signature verification (codesign --verify --strict): ${output || "no output"}`,
|
|
1487
|
-
{
|
|
1488
|
-
stage: STAGES.ENSURE_UV,
|
|
1489
|
-
suggestion:
|
|
1490
|
-
"The installer appears to be corrupt. Re-download GAIA from https://amd-gaia.ai and try again.",
|
|
1491
|
-
}
|
|
1492
|
-
);
|
|
1493
|
-
}
|
|
1494
|
-
} else {
|
|
1495
|
-
const srcHash = await sha256File(bundled);
|
|
1496
|
-
if (srcHash !== expectedSha) {
|
|
1497
|
-
throw new InstallError(
|
|
1498
|
-
`Bundled uv resource SHA256 mismatch (expected ${expectedSha}, got ${srcHash}).`,
|
|
1499
|
-
{
|
|
1500
|
-
stage: STAGES.ENSURE_UV,
|
|
1501
|
-
suggestion:
|
|
1502
|
-
"The installer appears to be corrupt. Re-download GAIA from https://amd-gaia.ai and try again.",
|
|
1503
|
-
}
|
|
1504
|
-
);
|
|
1281
|
+
if (!commandExists("uv")) {
|
|
1282
|
+
const candidates = [
|
|
1283
|
+
path.join(os.homedir(), ".local", "bin"),
|
|
1284
|
+
path.join(os.homedir(), ".cargo", "bin"),
|
|
1285
|
+
];
|
|
1286
|
+
for (const uvDir of candidates) {
|
|
1287
|
+
if (process.env.PATH && !process.env.PATH.includes(uvDir)) {
|
|
1288
|
+
process.env.PATH = `${uvDir}${path.delimiter}${process.env.PATH}`;
|
|
1289
|
+
log(`Added ${uvDir} to PATH for this process`);
|
|
1505
1290
|
}
|
|
1506
1291
|
}
|
|
1507
|
-
await installBundledUv(bundled, platformKey);
|
|
1508
|
-
addManagedBinToPath();
|
|
1509
|
-
report(STAGES.ENSURE_UV, 100, "uv installed (bundled)");
|
|
1510
|
-
return;
|
|
1511
1292
|
}
|
|
1512
1293
|
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
return;
|
|
1521
|
-
}
|
|
1522
|
-
|
|
1523
|
-
log("[dev] No bundled uv and no system uv — falling back to curl|sh installer");
|
|
1524
|
-
let result;
|
|
1525
|
-
if (IS_WINDOWS) {
|
|
1526
|
-
result = await runCommand(
|
|
1527
|
-
"powershell",
|
|
1528
|
-
[
|
|
1529
|
-
"-ExecutionPolicy",
|
|
1530
|
-
"Bypass",
|
|
1531
|
-
"-Command",
|
|
1532
|
-
"irm https://astral.sh/uv/install.ps1 | iex",
|
|
1533
|
-
],
|
|
1534
|
-
{ stageLabel: "uv-install-dev", signal }
|
|
1535
|
-
);
|
|
1536
|
-
} else {
|
|
1537
|
-
result = await runCommand(
|
|
1538
|
-
"bash",
|
|
1539
|
-
["-c", "curl -LsSf https://astral.sh/uv/install.sh | sh"],
|
|
1540
|
-
{ stageLabel: "uv-install-dev", signal }
|
|
1541
|
-
);
|
|
1542
|
-
}
|
|
1543
|
-
|
|
1544
|
-
if (result.code !== 0) {
|
|
1545
|
-
throw new InstallError(
|
|
1546
|
-
`Could not install uv automatically (exit code ${result.code}).`,
|
|
1547
|
-
{
|
|
1548
|
-
stage: STAGES.ENSURE_UV,
|
|
1549
|
-
code: result.code,
|
|
1550
|
-
suggestion: IS_WINDOWS
|
|
1551
|
-
? 'Install uv manually: powershell -c "irm https://astral.sh/uv/install.ps1 | iex"'
|
|
1552
|
-
: "Install uv manually: curl -LsSf https://astral.sh/uv/install.sh | sh",
|
|
1553
|
-
}
|
|
1554
|
-
);
|
|
1555
|
-
}
|
|
1556
|
-
|
|
1557
|
-
if (!commandExists("uv")) {
|
|
1558
|
-
const candidates = [
|
|
1559
|
-
path.join(os.homedir(), ".local", "bin"),
|
|
1560
|
-
path.join(os.homedir(), ".cargo", "bin"),
|
|
1561
|
-
];
|
|
1562
|
-
for (const uvDir of candidates) {
|
|
1563
|
-
if (process.env.PATH && !process.env.PATH.includes(uvDir)) {
|
|
1564
|
-
process.env.PATH = `${uvDir}${path.delimiter}${process.env.PATH}`;
|
|
1565
|
-
log(`Added ${uvDir} to PATH for this process`);
|
|
1566
|
-
}
|
|
1567
|
-
}
|
|
1568
|
-
}
|
|
1569
|
-
|
|
1570
|
-
if (!commandExists("uv")) {
|
|
1571
|
-
throw new InstallError(
|
|
1572
|
-
"uv installed but not found on PATH. A shell restart may be required.",
|
|
1573
|
-
{
|
|
1574
|
-
stage: STAGES.ENSURE_UV,
|
|
1575
|
-
suggestion:
|
|
1576
|
-
"Restart your terminal or reboot, then re-launch GAIA. If the problem persists, install uv manually from https://astral.sh/uv",
|
|
1577
|
-
}
|
|
1578
|
-
);
|
|
1579
|
-
}
|
|
1580
|
-
|
|
1581
|
-
report(STAGES.ENSURE_UV, 100, "uv installed (dev fallback)");
|
|
1582
|
-
return;
|
|
1583
|
-
}
|
|
1584
|
-
|
|
1585
|
-
// Packaged Windows rescue: try the Astral PowerShell installer even when
|
|
1586
|
-
// running a packaged build. This provides an automated recovery path for
|
|
1587
|
-
// end users on clean machines that don't have uv and where the installer
|
|
1588
|
-
// build unexpectedly omitted a bundled binary. It is a last-resort and
|
|
1589
|
-
// non-fatal attempt; on failure we fall through to the generic error.
|
|
1590
|
-
if (IS_WINDOWS && !isDev) {
|
|
1591
|
-
log("Packaged Windows: attempting automated uv installer (rescue)");
|
|
1592
|
-
try {
|
|
1593
|
-
const rescue = await runCommand(
|
|
1594
|
-
"powershell",
|
|
1595
|
-
[
|
|
1596
|
-
"-ExecutionPolicy",
|
|
1597
|
-
"Bypass",
|
|
1598
|
-
"-Command",
|
|
1599
|
-
"irm https://astral.sh/uv/install.ps1 | iex",
|
|
1600
|
-
],
|
|
1601
|
-
{ stageLabel: "uv-install-packaged-rescue", signal }
|
|
1602
|
-
);
|
|
1603
|
-
if (rescue.code === 0) {
|
|
1604
|
-
// Ensure common install locations are present on PATH for this
|
|
1605
|
-
// process in case the installer placed uv in a user-local bin.
|
|
1606
|
-
const candidates = [
|
|
1607
|
-
path.join(os.homedir(), ".local", "bin"),
|
|
1608
|
-
path.join(os.homedir(), ".cargo", "bin"),
|
|
1609
|
-
];
|
|
1610
|
-
for (const uvDir of candidates) {
|
|
1611
|
-
if (process.env.PATH && !process.env.PATH.includes(uvDir)) {
|
|
1612
|
-
process.env.PATH = `${uvDir}${path.delimiter}${process.env.PATH}`;
|
|
1613
|
-
log(`Added ${uvDir} to PATH for this process`);
|
|
1614
|
-
}
|
|
1615
|
-
}
|
|
1616
|
-
if (commandExists("uv")) {
|
|
1617
|
-
log("Packaged Windows: uv installed and found on PATH (rescue succeeded)");
|
|
1618
|
-
addManagedBinToPath();
|
|
1619
|
-
report(STAGES.ENSURE_UV, 100, "uv ready (system, unverified)");
|
|
1620
|
-
return;
|
|
1621
|
-
}
|
|
1622
|
-
log("Packaged Windows: uv installer ran but uv not found on PATH");
|
|
1623
|
-
} else {
|
|
1624
|
-
log(`Packaged Windows: automated uv installer exited ${rescue.code}`);
|
|
1294
|
+
if (!commandExists("uv")) {
|
|
1295
|
+
throw new InstallError(
|
|
1296
|
+
"uv installed but not found on PATH. A shell restart may be required.",
|
|
1297
|
+
{
|
|
1298
|
+
stage: STAGES.ENSURE_UV,
|
|
1299
|
+
suggestion:
|
|
1300
|
+
"Restart your terminal or reboot, then re-launch GAIA. If the problem persists, install uv manually from https://astral.sh/uv",
|
|
1625
1301
|
}
|
|
1626
|
-
} catch (rescueErr) {
|
|
1627
|
-
if (rescueErr instanceof InstallCancelled) throw rescueErr;
|
|
1628
|
-
log(`Packaged Windows: rescue installer threw: ${rescueErr.message}`);
|
|
1629
|
-
}
|
|
1630
|
-
}
|
|
1631
|
-
|
|
1632
|
-
// Packaged build, but we somehow don't have a bundled binary for this
|
|
1633
|
-
// platform AND no system uv. Last-ditch: accept an unverified system uv
|
|
1634
|
-
// if present; otherwise fail with a clear message.
|
|
1635
|
-
if (commandExists("uv")) {
|
|
1636
|
-
log(
|
|
1637
|
-
`No bundled uv for ${process.platform}-${process.arch}, using system uv on PATH (unverified)`
|
|
1638
1302
|
);
|
|
1639
|
-
report(STAGES.ENSURE_UV, 100, "uv ready (system, unverified)");
|
|
1640
|
-
return;
|
|
1641
1303
|
}
|
|
1642
1304
|
|
|
1643
|
-
|
|
1644
|
-
`GAIA could not find or install its Python helper (uv) required to provision the backend.`,
|
|
1645
|
-
{
|
|
1646
|
-
stage: STAGES.ENSURE_UV,
|
|
1647
|
-
suggestion:
|
|
1648
|
-
"GAIA attempted automatic recovery but could not install uv. Please either: (a) click 'Install uv' in the dialog to let GAIA try again, or (b) install uv from https://astral.sh/uv and re-launch GAIA.",
|
|
1649
|
-
}
|
|
1650
|
-
);
|
|
1305
|
+
report(STAGES.ENSURE_UV, 100, "uv installed");
|
|
1651
1306
|
}
|
|
1652
1307
|
|
|
1653
1308
|
// ── Backend install ──────────────────────────────────────────────────────────
|
|
@@ -2079,8 +1734,12 @@ function _prefetchMarker(pep440) {
|
|
|
2079
1734
|
return path.join(PREFETCH_DIR, `${pep440}.ready`);
|
|
2080
1735
|
}
|
|
2081
1736
|
|
|
2082
|
-
/**
|
|
1737
|
+
/**
|
|
1738
|
+
* True when `version`'s backend needs no download: an app that ships its
|
|
1739
|
+
* backend gets it with the update, otherwise a prefetch left it in uv's cache.
|
|
1740
|
+
*/
|
|
2083
1741
|
function isBackendPrefetched(version) {
|
|
1742
|
+
if (shippedGaiaBin()) return true;
|
|
2084
1743
|
return Boolean(version) && fs.existsSync(_prefetchMarker(toPep440(version)));
|
|
2085
1744
|
}
|
|
2086
1745
|
|
|
@@ -2091,6 +1750,10 @@ function isBackendPrefetched(version) {
|
|
|
2091
1750
|
* Throws with uv's own words when the download fails.
|
|
2092
1751
|
*/
|
|
2093
1752
|
async function prefetchBackend(appVersion, { isPackaged } = {}) {
|
|
1753
|
+
if (isPackaged) {
|
|
1754
|
+
log("This app ships its own backend, so the update carries it and there is nothing to prefetch");
|
|
1755
|
+
return;
|
|
1756
|
+
}
|
|
2094
1757
|
if (process.env.GAIA_LOCAL_WHEEL) {
|
|
2095
1758
|
log("GAIA_LOCAL_WHEEL is set: the next launch installs that wheel, so there is nothing to prefetch");
|
|
2096
1759
|
return;
|
|
@@ -2154,7 +1817,14 @@ function _lastLines({ stdout, stderr }) {
|
|
|
2154
1817
|
*/
|
|
2155
1818
|
function isBackendCurrent() {
|
|
2156
1819
|
// A local wheel is reinstalled on every launch, as ensureBackend says.
|
|
2157
|
-
if (process.env.GAIA_LOCAL_WHEEL) return false;
|
|
1820
|
+
if (process.env.GAIA_LOCAL_WHEEL && !shippedGaiaBin()) return false;
|
|
1821
|
+
if (shippedGaiaBin()) {
|
|
1822
|
+
// The core is always current; an app version is done once it refreshed the agent.
|
|
1823
|
+
if (!bundledGaiaBin()) return false;
|
|
1824
|
+
const prev = getState();
|
|
1825
|
+
if (!prev) return !fs.existsSync(FLAGSHIP_SENTINEL);
|
|
1826
|
+
return prev.state === STATES.READY && toPep440(prev.version || "") === toPep440(appVersion());
|
|
1827
|
+
}
|
|
2158
1828
|
const bin = findGaiaBin();
|
|
2159
1829
|
if (!bin) return false;
|
|
2160
1830
|
const prev = getState();
|
|
@@ -2168,6 +1838,10 @@ function isBackendCurrent() {
|
|
|
2168
1838
|
* `gaia --version`, which starts Python and can take 20 s+ on a busy PC.
|
|
2169
1839
|
*/
|
|
2170
1840
|
function getInstalledVersion(gaiaBin) {
|
|
1841
|
+
// Built with the app, from the same commit.
|
|
1842
|
+
if (shippedGaiaBin() && gaiaBin === bundledGaiaBin()) {
|
|
1843
|
+
return toPep440(appVersion());
|
|
1844
|
+
}
|
|
2171
1845
|
if (gaiaBin === GAIA_BIN) {
|
|
2172
1846
|
// existsSync follows the venv's python symlink, so a removed base interpreter reads as missing.
|
|
2173
1847
|
if (!fs.existsSync(GAIA_PYTHON_BIN)) {
|
|
@@ -2243,6 +1917,19 @@ async function ensureBackend(opts = {}) {
|
|
|
2243
1917
|
openLog({ truncate: true });
|
|
2244
1918
|
|
|
2245
1919
|
try {
|
|
1920
|
+
const bundled = await ensureBundledCore();
|
|
1921
|
+
if (bundled) {
|
|
1922
|
+
log(`Using the GAIA backend this app ships: ${bundled}`);
|
|
1923
|
+
await refreshAgent(bundled, opts);
|
|
1924
|
+
return bundled;
|
|
1925
|
+
}
|
|
1926
|
+
if (opts.isPackaged) {
|
|
1927
|
+
throw new InstallError("This GAIA install is missing its backend.", {
|
|
1928
|
+
stage: STAGES.VERIFY,
|
|
1929
|
+
suggestion: `Reinstall GAIA from https://amd-gaia.ai/#install. Expected it at ${BUNDLED_GAIA_BIN}.`,
|
|
1930
|
+
});
|
|
1931
|
+
}
|
|
1932
|
+
|
|
2246
1933
|
const preChecks = await runPreChecks({ onProgress: opts.onProgress });
|
|
2247
1934
|
|
|
2248
1935
|
// Handle a pre-existing partial install first (before disk/network fails
|