@amd-gaia/gaia 0.0.0 → 0.1.1
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/LICENSE +21 -0
- package/README.md +200 -6
- package/SKILL.md +473 -0
- package/SPEC.md +393 -0
- package/binaries.lock.json +78 -0
- package/dist/cli.d.ts +41 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +368 -0
- package/dist/cli.js.map +1 -0
- package/dist/errors.d.ts +32 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +42 -0
- package/dist/errors.js.map +1 -0
- package/dist/fetch.d.ts +110 -0
- package/dist/fetch.d.ts.map +1 -0
- package/dist/fetch.js +217 -0
- package/dist/fetch.js.map +1 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/lifecycle.d.ts +145 -0
- package/dist/lifecycle.d.ts.map +1 -0
- package/dist/lifecycle.js +397 -0
- package/dist/lifecycle.js.map +1 -0
- package/dist/logger.d.ts +13 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +30 -0
- package/dist/logger.js.map +1 -0
- package/dist/platform.d.ts +100 -0
- package/dist/platform.d.ts.map +1 -0
- package/dist/platform.js +202 -0
- package/dist/platform.js.map +1 -0
- package/dist/url.d.ts +4 -0
- package/dist/url.d.ts.map +1 -0
- package/dist/url.js +22 -0
- package/dist/url.js.map +1 -0
- package/package.json +57 -4
package/dist/cli.js
ADDED
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Copyright(C) 2025-2026 Advanced Micro Devices, Inc. All rights reserved.
|
|
3
|
+
// SPDX-License-Identifier: MIT
|
|
4
|
+
/**
|
|
5
|
+
* `gaia` — the one command that gets you running.
|
|
6
|
+
*
|
|
7
|
+
* npx @amd-gaia/gaia fetch + verify both binaries, then launch the TUI
|
|
8
|
+
* npx @amd-gaia/gaia fetch fetch + verify only
|
|
9
|
+
* npx @amd-gaia/gaia serve run the agent sidecar alone (REST, no TUI)
|
|
10
|
+
* npx @amd-gaia/gaia version print the lock manifest
|
|
11
|
+
*
|
|
12
|
+
* Every download is SHA-256 verified against `binaries.lock.json` before it is
|
|
13
|
+
* written, and a mismatch or a placeholder hash aborts the run. There is no
|
|
14
|
+
* "continue anyway" path.
|
|
15
|
+
*/
|
|
16
|
+
import { realpathSync } from "node:fs";
|
|
17
|
+
import path from "node:path";
|
|
18
|
+
import { fileURLToPath } from "node:url";
|
|
19
|
+
import { GaiaError } from "./errors.js";
|
|
20
|
+
import { daemonSidecarCacheDir, defaultCacheDir, fetchAll, fetchBinary, } from "./fetch.js";
|
|
21
|
+
import { DEFAULT_PORT, RESERVED_PORT, runTui, shutdown, startSidecar, } from "./lifecycle.js";
|
|
22
|
+
import { COMPONENTS, componentBaseUrl, componentLock, currentPlatformKey, loadLock, platformsFor, } from "./platform.js";
|
|
23
|
+
// Flags that consume a value. Being explicit avoids the footgun where
|
|
24
|
+
// `--base-url --force` silently swallows the next flag as a value.
|
|
25
|
+
const VALUE_FLAGS = new Set([
|
|
26
|
+
"base-url",
|
|
27
|
+
"platform",
|
|
28
|
+
"port",
|
|
29
|
+
"cache-dir",
|
|
30
|
+
"sidecar-dir",
|
|
31
|
+
"component",
|
|
32
|
+
]);
|
|
33
|
+
/** Raised for a malformed command line; the caller turns it into exit 2. */
|
|
34
|
+
export class UsageError extends Error {
|
|
35
|
+
}
|
|
36
|
+
export function parseArgs(argv) {
|
|
37
|
+
const out = { _: [], flags: {}, passthrough: [] };
|
|
38
|
+
for (let i = 0; i < argv.length; i++) {
|
|
39
|
+
const a = argv[i];
|
|
40
|
+
if (a === "--") {
|
|
41
|
+
out.passthrough = argv.slice(i + 1);
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
if (a.startsWith("--")) {
|
|
45
|
+
// Both `--flag value` and `--flag=value` — dropping the second silently
|
|
46
|
+
// would download from the default hub after the user pointed us elsewhere.
|
|
47
|
+
const eq = a.indexOf("=");
|
|
48
|
+
const key = eq === -1 ? a.slice(2) : a.slice(2, eq);
|
|
49
|
+
const inline = eq === -1 ? undefined : a.slice(eq + 1);
|
|
50
|
+
if (VALUE_FLAGS.has(key)) {
|
|
51
|
+
if (inline !== undefined) {
|
|
52
|
+
if (inline === "")
|
|
53
|
+
throw new UsageError(`--${key} was given an empty value`);
|
|
54
|
+
out.flags[key] = inline;
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
const next = argv[i + 1];
|
|
58
|
+
if (next === undefined || next.startsWith("--")) {
|
|
59
|
+
throw new UsageError(`--${key} expects a value`);
|
|
60
|
+
}
|
|
61
|
+
out.flags[key] = next;
|
|
62
|
+
i++;
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
if (inline !== undefined) {
|
|
66
|
+
throw new UsageError(`--${key} does not take a value (got '${a}')`);
|
|
67
|
+
}
|
|
68
|
+
out.flags[key] = true;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
else if (a === "-h") {
|
|
72
|
+
out.flags["help"] = true;
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
out._.push(a);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return out;
|
|
79
|
+
}
|
|
80
|
+
const HELP = `@amd-gaia/gaia — run GAIA locally on AMD Ryzen AI
|
|
81
|
+
|
|
82
|
+
Usage:
|
|
83
|
+
gaia [run] [options] [-- <tui args>] Fetch + verify both binaries, then launch the TUI
|
|
84
|
+
gaia fetch [options] Download + SHA-256 verify the binaries only
|
|
85
|
+
gaia serve [options] Run the agent sidecar alone (REST API, no TUI)
|
|
86
|
+
gaia version Print the lock manifest and this host's platform
|
|
87
|
+
gaia help Show this help
|
|
88
|
+
|
|
89
|
+
run options:
|
|
90
|
+
--base-url <url> Override the per-component download base URL from
|
|
91
|
+
binaries.lock.json (applies to every component fetched)
|
|
92
|
+
--cache-dir <dir> Where to cache the TUI binary
|
|
93
|
+
--sidecar-dir <dir> Where to install the agent sidecar
|
|
94
|
+
(default ~/.gaia/agents/gaia — the daemon's own cache)
|
|
95
|
+
--force Re-download even when a verified binary is already cached
|
|
96
|
+
-- <tui args> Forward everything after \`--\` to gaia-tui verbatim
|
|
97
|
+
|
|
98
|
+
fetch options:
|
|
99
|
+
--component <name> Fetch only one of: ${COMPONENTS.join(", ")} (default: both)
|
|
100
|
+
--platform <key> Override the platform key (e.g. linux-x64). Default: this host
|
|
101
|
+
plus every run option above.
|
|
102
|
+
|
|
103
|
+
serve options:
|
|
104
|
+
--port <n> Bind port (default ${DEFAULT_PORT}; ${RESERVED_PORT} is reserved and refused)
|
|
105
|
+
|
|
106
|
+
Notes:
|
|
107
|
+
* No binaries are committed to the repo. Every download is SHA-256 verified
|
|
108
|
+
against binaries.lock.json and FAILS LOUDLY on any mismatch.
|
|
109
|
+
* A placeholder hash in the lock blocks the fetch outright, so an unverifiable
|
|
110
|
+
binary can never be trusted.
|
|
111
|
+
* The agent sidecar has no arm64 Linux or arm64 Windows build; the TUI does.
|
|
112
|
+
\`gaia version\` prints the exact per-component platform matrix.
|
|
113
|
+
* The TUI is the published \`terminal-hub\` component — byte-identical to the
|
|
114
|
+
\`gaia tui\` a core install runs, so its behaviour cannot drift from it.
|
|
115
|
+
* Set DEBUG=gaia for download, spawn, and sidecar output on stderr.
|
|
116
|
+
`;
|
|
117
|
+
const flagStr = (args, k) => typeof args.flags[k] === "string" ? args.flags[k] : undefined;
|
|
118
|
+
/**
|
|
119
|
+
* Shared download options. `--platform` is accepted only by `fetch`: `run` and
|
|
120
|
+
* `serve` execute what they download, and honouring a foreign platform there
|
|
121
|
+
* would write a wrong-architecture binary into the daemon's cache and then try
|
|
122
|
+
* to spawn it.
|
|
123
|
+
*/
|
|
124
|
+
function downloadOptions(args, allowPlatform = false) {
|
|
125
|
+
const platformKey = flagStr(args, "platform");
|
|
126
|
+
if (platformKey !== undefined && !allowPlatform) {
|
|
127
|
+
throw new UsageError("--platform is only valid for `gaia fetch`. `run` and `serve` execute the " +
|
|
128
|
+
`binary, so it must be built for this host (${currentPlatformKey()}).`);
|
|
129
|
+
}
|
|
130
|
+
return {
|
|
131
|
+
baseUrl: flagStr(args, "base-url"),
|
|
132
|
+
...(allowPlatform && platformKey !== undefined ? { platformKey } : {}),
|
|
133
|
+
force: Boolean(args.flags["force"]),
|
|
134
|
+
tuiDir: flagStr(args, "cache-dir"),
|
|
135
|
+
sidecarDir: flagStr(args, "sidecar-dir"),
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* The child's PATH with this package's own bin directory removed.
|
|
140
|
+
*
|
|
141
|
+
* npm installs our shim as `gaia`, and the TUI starts the daemon by resolving
|
|
142
|
+
* `gaia` on PATH (tui/internal/daemon/client.go) expecting the *Python* CLI.
|
|
143
|
+
* Left alone, the TUI would re-invoke us with `daemon start` and the daemon would
|
|
144
|
+
* never come up. Returns undefined when PATH is unset.
|
|
145
|
+
*/
|
|
146
|
+
export function pathWithoutOwnShim(rawPath = process.env["PATH"], argv1 = process.argv[1]) {
|
|
147
|
+
if (rawPath === undefined || !argv1)
|
|
148
|
+
return rawPath;
|
|
149
|
+
const sep = process.platform === "win32" ? ";" : ":";
|
|
150
|
+
let ownBinDir;
|
|
151
|
+
try {
|
|
152
|
+
ownBinDir = path.resolve(path.dirname(argv1));
|
|
153
|
+
}
|
|
154
|
+
catch {
|
|
155
|
+
return rawPath;
|
|
156
|
+
}
|
|
157
|
+
const same = (dir) => {
|
|
158
|
+
const resolved = path.resolve(dir);
|
|
159
|
+
return process.platform === "win32"
|
|
160
|
+
? resolved.toLowerCase() === ownBinDir.toLowerCase()
|
|
161
|
+
: resolved === ownBinDir;
|
|
162
|
+
};
|
|
163
|
+
return rawPath
|
|
164
|
+
.split(sep)
|
|
165
|
+
.filter((d) => d !== "" && !same(d))
|
|
166
|
+
.join(sep);
|
|
167
|
+
}
|
|
168
|
+
/** Validate `--port`. Rejects out-of-range values and the reserved port. */
|
|
169
|
+
export function resolvePort(raw) {
|
|
170
|
+
const port = typeof raw === "string" ? Number(raw) : DEFAULT_PORT;
|
|
171
|
+
if (!Number.isInteger(port) || port <= 0 || port > 65535 || port === RESERVED_PORT) {
|
|
172
|
+
return {
|
|
173
|
+
error: `--port must be a port in 1..65535 and not ${RESERVED_PORT} (got ${String(raw)})`,
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
return { port };
|
|
177
|
+
}
|
|
178
|
+
async function cmdRun(args) {
|
|
179
|
+
const opts = downloadOptions(args);
|
|
180
|
+
process.stderr.write("[gaia] fetching and verifying the agent sidecar and the terminal UI ...\n");
|
|
181
|
+
const { sidecar, tui } = await fetchAll(opts);
|
|
182
|
+
process.stderr.write(`[gaia] sidecar ${sidecar.cached ? "cached" : "installed"} -> ${sidecar.binaryPath}\n` +
|
|
183
|
+
`[gaia] tui ${tui.cached ? "cached" : "installed"} -> ${tui.binaryPath}\n` +
|
|
184
|
+
"[gaia] starting the terminal UI ...\n");
|
|
185
|
+
// The TUI owns the daemon handshake and the daemon owns the sidecar process —
|
|
186
|
+
// the TUI never holds a sidecar bearer token, so starting one here would only
|
|
187
|
+
// fight it for the port. Our job is to put a *verified* binary where the daemon
|
|
188
|
+
// looks, which fetchAll just did.
|
|
189
|
+
const childPath = pathWithoutOwnShim();
|
|
190
|
+
return runTui({
|
|
191
|
+
binaryPath: tui.binaryPath,
|
|
192
|
+
args: args.passthrough,
|
|
193
|
+
env: childPath === undefined ? {} : { PATH: childPath, Path: childPath },
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
async function cmdFetch(args) {
|
|
197
|
+
const opts = downloadOptions(args, true);
|
|
198
|
+
const only = args.flags["component"];
|
|
199
|
+
const results = [];
|
|
200
|
+
if (typeof only === "string") {
|
|
201
|
+
if (!COMPONENTS.includes(only)) {
|
|
202
|
+
throw new UsageError(`unknown --component '${only}'; expected one of ${COMPONENTS.join(", ")}`);
|
|
203
|
+
}
|
|
204
|
+
const component = only;
|
|
205
|
+
const lock = loadLock();
|
|
206
|
+
results.push(await fetchBinary({
|
|
207
|
+
component,
|
|
208
|
+
lock,
|
|
209
|
+
outDir: component === "sidecar"
|
|
210
|
+
? (opts.sidecarDir ?? daemonSidecarCacheDir())
|
|
211
|
+
: (opts.tuiDir ?? defaultCacheDir(lock.agentVersion)),
|
|
212
|
+
baseUrl: opts.baseUrl,
|
|
213
|
+
platformKey: opts.platformKey,
|
|
214
|
+
force: opts.force,
|
|
215
|
+
}));
|
|
216
|
+
}
|
|
217
|
+
else {
|
|
218
|
+
const all = await fetchAll(opts);
|
|
219
|
+
results.push(all.sidecar, all.tui);
|
|
220
|
+
}
|
|
221
|
+
process.stdout.write(JSON.stringify({
|
|
222
|
+
ok: true,
|
|
223
|
+
binaries: results.map((r) => ({
|
|
224
|
+
component: r.component,
|
|
225
|
+
binaryPath: r.binaryPath,
|
|
226
|
+
platform: r.platformKey,
|
|
227
|
+
sha256: r.sha256,
|
|
228
|
+
cached: r.cached,
|
|
229
|
+
url: r.url,
|
|
230
|
+
})),
|
|
231
|
+
}, null, 2) + "\n");
|
|
232
|
+
return 0;
|
|
233
|
+
}
|
|
234
|
+
async function cmdServe(args) {
|
|
235
|
+
const parsed = resolvePort(args.flags["port"]);
|
|
236
|
+
if ("error" in parsed) {
|
|
237
|
+
process.stderr.write(`error: ${parsed.error}\n`);
|
|
238
|
+
return 2;
|
|
239
|
+
}
|
|
240
|
+
const { port } = parsed;
|
|
241
|
+
const opts = downloadOptions(args);
|
|
242
|
+
process.stderr.write("[gaia] fetching and verifying the agent sidecar ...\n");
|
|
243
|
+
const result = await fetchBinary({
|
|
244
|
+
component: "sidecar",
|
|
245
|
+
outDir: opts.sidecarDir ?? daemonSidecarCacheDir(),
|
|
246
|
+
baseUrl: opts.baseUrl,
|
|
247
|
+
force: opts.force,
|
|
248
|
+
});
|
|
249
|
+
// We own the lifecycle here (autoCleanup off) so the graceful shutdown below
|
|
250
|
+
// actually runs; the default auto-reaper would SIGKILL the tree first.
|
|
251
|
+
const sidecar = await startSidecar({
|
|
252
|
+
binaryPath: result.binaryPath,
|
|
253
|
+
port,
|
|
254
|
+
autoCleanup: false,
|
|
255
|
+
});
|
|
256
|
+
try {
|
|
257
|
+
process.stdout.write(`\n ▸ GAIA agent: ${sidecar.baseUrl}/v1/gaia/query\n`);
|
|
258
|
+
process.stdout.write(` Health: ${sidecar.baseUrl}/health\n`);
|
|
259
|
+
process.stdout.write(" Lemonade must be running for live queries. Ctrl+C to stop.\n\n");
|
|
260
|
+
await new Promise((resolve) => {
|
|
261
|
+
let stopping = false;
|
|
262
|
+
const stop = () => {
|
|
263
|
+
if (stopping)
|
|
264
|
+
return; // a second signal must not re-enter shutdown
|
|
265
|
+
stopping = true;
|
|
266
|
+
process.stderr.write("\n[gaia] stopping the sidecar ...\n");
|
|
267
|
+
void shutdown(sidecar).catch(() => undefined).finally(resolve);
|
|
268
|
+
};
|
|
269
|
+
// process.on, not once: a second Ctrl+C during the shutdown would
|
|
270
|
+
// otherwise hit Node's default disposition and kill us mid-teardown,
|
|
271
|
+
// orphaning the detached sidecar tree on port 8141. The `stopping` guard
|
|
272
|
+
// absorbs the repeats.
|
|
273
|
+
for (const sig of ["SIGINT", "SIGTERM", "SIGHUP"])
|
|
274
|
+
process.on(sig, stop);
|
|
275
|
+
});
|
|
276
|
+
return 0;
|
|
277
|
+
}
|
|
278
|
+
catch (e) {
|
|
279
|
+
await shutdown(sidecar).catch(() => undefined);
|
|
280
|
+
throw e;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
function cmdVersion() {
|
|
284
|
+
const lock = loadLock();
|
|
285
|
+
process.stdout.write(JSON.stringify({
|
|
286
|
+
agentVersion: lock.agentVersion,
|
|
287
|
+
schemaVersion: lock.schemaVersion,
|
|
288
|
+
currentPlatform: currentPlatformKey(),
|
|
289
|
+
// Per component: each ships from its own hub lane at its own version.
|
|
290
|
+
components: Object.fromEntries(COMPONENTS.map((c) => [
|
|
291
|
+
c,
|
|
292
|
+
{
|
|
293
|
+
componentVersion: componentLock(lock, c).componentVersion,
|
|
294
|
+
baseUrl: componentBaseUrl(lock, c),
|
|
295
|
+
platforms: platformsFor(lock, c),
|
|
296
|
+
},
|
|
297
|
+
])),
|
|
298
|
+
}, null, 2) + "\n");
|
|
299
|
+
return 0;
|
|
300
|
+
}
|
|
301
|
+
const KNOWN_COMMANDS = ["run", "fetch", "serve", "version", "help"];
|
|
302
|
+
export async function main(argv) {
|
|
303
|
+
const args = parseArgs(argv);
|
|
304
|
+
const explicit = args._[0];
|
|
305
|
+
const cmd = explicit ?? (args.flags["help"] ? "help" : "run");
|
|
306
|
+
if (args.flags["help"] && cmd !== "help") {
|
|
307
|
+
process.stdout.write(HELP);
|
|
308
|
+
return 0;
|
|
309
|
+
}
|
|
310
|
+
if (!KNOWN_COMMANDS.includes(cmd)) {
|
|
311
|
+
throw new UsageError(`unknown command '${cmd}'`);
|
|
312
|
+
}
|
|
313
|
+
// A dropped positional means a mistyped invocation whose flags may also be
|
|
314
|
+
// wrong; refuse rather than run something the user did not ask for.
|
|
315
|
+
const extra = explicit === undefined ? args._ : args._.slice(1);
|
|
316
|
+
if (extra.length > 0) {
|
|
317
|
+
throw new UsageError(`unexpected argument${extra.length > 1 ? "s" : ""} ${extra.map((a) => `'${a}'`).join(", ")}. ` +
|
|
318
|
+
"Arguments for the terminal UI go after a bare `--`.");
|
|
319
|
+
}
|
|
320
|
+
switch (cmd) {
|
|
321
|
+
case "run":
|
|
322
|
+
return cmdRun(args);
|
|
323
|
+
case "fetch":
|
|
324
|
+
return cmdFetch(args);
|
|
325
|
+
case "serve":
|
|
326
|
+
return cmdServe(args);
|
|
327
|
+
case "version":
|
|
328
|
+
return cmdVersion();
|
|
329
|
+
default:
|
|
330
|
+
process.stdout.write(HELP);
|
|
331
|
+
return 0;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
/** True when this file is the entry point (so importing it for tests is a no-op). */
|
|
335
|
+
function invokedDirectly() {
|
|
336
|
+
if (!process.argv[1])
|
|
337
|
+
return false;
|
|
338
|
+
try {
|
|
339
|
+
return realpathSync(fileURLToPath(import.meta.url)) === realpathSync(process.argv[1]);
|
|
340
|
+
}
|
|
341
|
+
catch {
|
|
342
|
+
return false;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
if (invokedDirectly()) {
|
|
346
|
+
main(process.argv.slice(2))
|
|
347
|
+
// exitCode rather than process.exit(): the latter can truncate the JSON
|
|
348
|
+
// `fetch`/`version` just wrote into an async stdout pipe.
|
|
349
|
+
.then((code) => {
|
|
350
|
+
process.exitCode = code;
|
|
351
|
+
})
|
|
352
|
+
.catch((e) => {
|
|
353
|
+
// Fail loudly with an actionable message; never swallow.
|
|
354
|
+
if (e instanceof UsageError) {
|
|
355
|
+
process.stderr.write(`error: ${e.message}\n\n${HELP}`);
|
|
356
|
+
process.exitCode = 2;
|
|
357
|
+
}
|
|
358
|
+
else if (e instanceof GaiaError) {
|
|
359
|
+
process.stderr.write(`[gaia] ${e.name}: ${e.message}\n`);
|
|
360
|
+
process.exitCode = 1;
|
|
361
|
+
}
|
|
362
|
+
else {
|
|
363
|
+
process.stderr.write(`[gaia] unexpected error: ${e.stack ?? e}\n`);
|
|
364
|
+
process.exitCode = 1;
|
|
365
|
+
}
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,2EAA2E;AAC3E,+BAA+B;AAC/B;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO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,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;QACX,yDAAyD;QACzD,IAAI,CAAC,YAAY,UAAU,EAAE,CAAC;YAC5B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,OAAO,OAAO,IAAI,EAAE,CAAC,CAAC;YACvD,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;QACvB,CAAC;aAAM,IAAI,CAAC,YAAY,SAAS,EAAE,CAAC;YAClC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC;YACzD,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;QACvB,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,4BAA6B,CAAW,CAAC,KAAK,IAAI,CAAC,IAAI,CAAC,CAAC;YAC9E,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;QACvB,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed error classes. Per the GAIA no-silent-fallback rule, every failure path
|
|
3
|
+
* raises one of these with an actionable message — never a swallowed error or a
|
|
4
|
+
* silently-degraded result.
|
|
5
|
+
*/
|
|
6
|
+
/** Base class so callers can `instanceof GaiaError` to catch any of ours. */
|
|
7
|
+
export declare class GaiaError extends Error {
|
|
8
|
+
constructor(message: string);
|
|
9
|
+
}
|
|
10
|
+
/** A downloaded binary's SHA-256 did not match `binaries.lock.json`. */
|
|
11
|
+
export declare class IntegrityError extends GaiaError {
|
|
12
|
+
}
|
|
13
|
+
/** Unsupported platform-arch, or no lock entry for a component on this host. */
|
|
14
|
+
export declare class PlatformError extends GaiaError {
|
|
15
|
+
}
|
|
16
|
+
/** The sidecar did not become healthy within the timeout. */
|
|
17
|
+
export declare class HealthTimeoutError extends GaiaError {
|
|
18
|
+
}
|
|
19
|
+
/** The sidecar's apiVersion is incompatible with what this package expects. */
|
|
20
|
+
export declare class VersionMismatchError extends GaiaError {
|
|
21
|
+
}
|
|
22
|
+
/** A binary could not be located on disk for spawning. */
|
|
23
|
+
export declare class BinaryNotFoundError extends GaiaError {
|
|
24
|
+
}
|
|
25
|
+
/** An HTTP request to the sidecar returned a non-2xx status. */
|
|
26
|
+
export declare class HttpError extends GaiaError {
|
|
27
|
+
readonly status: number;
|
|
28
|
+
readonly url: string;
|
|
29
|
+
readonly bodyText: string;
|
|
30
|
+
constructor(status: number, url: string, bodyText: string);
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AAEH,6EAA6E;AAC7E,qBAAa,SAAU,SAAQ,KAAK;gBACtB,OAAO,EAAE,MAAM;CAI5B;AAED,wEAAwE;AACxE,qBAAa,cAAe,SAAQ,SAAS;CAAG;AAEhD,gFAAgF;AAChF,qBAAa,aAAc,SAAQ,SAAS;CAAG;AAE/C,6DAA6D;AAC7D,qBAAa,kBAAmB,SAAQ,SAAS;CAAG;AAEpD,+EAA+E;AAC/E,qBAAa,oBAAqB,SAAQ,SAAS;CAAG;AAEtD,0DAA0D;AAC1D,qBAAa,mBAAoB,SAAQ,SAAS;CAAG;AAErD,gEAAgE;AAChE,qBAAa,SAAU,SAAQ,SAAS;aAEpB,MAAM,EAAE,MAAM;aACd,GAAG,EAAE,MAAM;aACX,QAAQ,EAAE,MAAM;gBAFhB,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,MAAM;CAInC"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// Copyright(C) 2025-2026 Advanced Micro Devices, Inc. All rights reserved.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
/**
|
|
4
|
+
* Typed error classes. Per the GAIA no-silent-fallback rule, every failure path
|
|
5
|
+
* raises one of these with an actionable message — never a swallowed error or a
|
|
6
|
+
* silently-degraded result.
|
|
7
|
+
*/
|
|
8
|
+
/** Base class so callers can `instanceof GaiaError` to catch any of ours. */
|
|
9
|
+
export class GaiaError extends Error {
|
|
10
|
+
constructor(message) {
|
|
11
|
+
super(message);
|
|
12
|
+
this.name = new.target.name;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
/** A downloaded binary's SHA-256 did not match `binaries.lock.json`. */
|
|
16
|
+
export class IntegrityError extends GaiaError {
|
|
17
|
+
}
|
|
18
|
+
/** Unsupported platform-arch, or no lock entry for a component on this host. */
|
|
19
|
+
export class PlatformError extends GaiaError {
|
|
20
|
+
}
|
|
21
|
+
/** The sidecar did not become healthy within the timeout. */
|
|
22
|
+
export class HealthTimeoutError extends GaiaError {
|
|
23
|
+
}
|
|
24
|
+
/** The sidecar's apiVersion is incompatible with what this package expects. */
|
|
25
|
+
export class VersionMismatchError extends GaiaError {
|
|
26
|
+
}
|
|
27
|
+
/** A binary could not be located on disk for spawning. */
|
|
28
|
+
export class BinaryNotFoundError extends GaiaError {
|
|
29
|
+
}
|
|
30
|
+
/** An HTTP request to the sidecar returned a non-2xx status. */
|
|
31
|
+
export class HttpError extends GaiaError {
|
|
32
|
+
status;
|
|
33
|
+
url;
|
|
34
|
+
bodyText;
|
|
35
|
+
constructor(status, url, bodyText) {
|
|
36
|
+
super(`HTTP ${status} from ${url}: ${bodyText || "(empty body)"}`);
|
|
37
|
+
this.status = status;
|
|
38
|
+
this.url = url;
|
|
39
|
+
this.bodyText = bodyText;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,+BAA+B;AAC/B;;;;GAIG;AAEH,6EAA6E;AAC7E,MAAM,OAAO,SAAU,SAAQ,KAAK;IAClC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC;IAC9B,CAAC;CACF;AAED,wEAAwE;AACxE,MAAM,OAAO,cAAe,SAAQ,SAAS;CAAG;AAEhD,gFAAgF;AAChF,MAAM,OAAO,aAAc,SAAQ,SAAS;CAAG;AAE/C,6DAA6D;AAC7D,MAAM,OAAO,kBAAmB,SAAQ,SAAS;CAAG;AAEpD,+EAA+E;AAC/E,MAAM,OAAO,oBAAqB,SAAQ,SAAS;CAAG;AAEtD,0DAA0D;AAC1D,MAAM,OAAO,mBAAoB,SAAQ,SAAS;CAAG;AAErD,gEAAgE;AAChE,MAAM,OAAO,SAAU,SAAQ,SAAS;IAEpB;IACA;IACA;IAHlB,YACkB,MAAc,EACd,GAAW,EACX,QAAgB;QAEhC,KAAK,CAAC,QAAQ,MAAM,SAAS,GAAG,KAAK,QAAQ,IAAI,cAAc,EAAE,CAAC,CAAC;QAJnD,WAAM,GAAN,MAAM,CAAQ;QACd,QAAG,GAAH,GAAG,CAAQ;QACX,aAAQ,GAAR,QAAQ,CAAQ;IAGlC,CAAC;CACF"}
|
package/dist/fetch.d.ts
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Binary fetcher for both components (`sidecar` and `tui`).
|
|
3
|
+
*
|
|
4
|
+
* Resolves the current platform → looks the component up in
|
|
5
|
+
* `binaries.lock.json` → downloads it from THAT COMPONENT's base URL
|
|
6
|
+
* (overridable) → **verifies its SHA-256 against the lock and fails loudly on
|
|
7
|
+
* any mismatch** → writes it into a cache dir → `chmod +x` on POSIX.
|
|
8
|
+
*
|
|
9
|
+
* The two components come from different hub lanes: the sidecar from
|
|
10
|
+
* `agents/gaia/<agentVersion>/`, the TUI from `agents/terminal-hub/<tuiVersion>/`
|
|
11
|
+
* (the same binary a core install runs as `gaia tui`). Each entry's base URL
|
|
12
|
+
* comes from its own component, never from a shared top-level one.
|
|
13
|
+
*
|
|
14
|
+
* The SHA verify is the security boundary: a tampered, truncated, or
|
|
15
|
+
* not-yet-published artifact is rejected before it can ever be spawned. There is
|
|
16
|
+
* NO "use it anyway" path, and a placeholder hash in the lock blocks the fetch
|
|
17
|
+
* outright rather than degrading to an unverified download.
|
|
18
|
+
*/
|
|
19
|
+
import { type BinaryLock, type ComponentName } from "./platform.js";
|
|
20
|
+
/**
|
|
21
|
+
* Where verified binaries are cached, keyed by agent version so a version bump
|
|
22
|
+
* never reuses the previous release's executables.
|
|
23
|
+
*/
|
|
24
|
+
export declare function defaultCacheDir(agentVersion: string): string;
|
|
25
|
+
/**
|
|
26
|
+
* The daemon's own sidecar cache — `~/.gaia/agents/gaia/`, mirroring
|
|
27
|
+
* `gaia.daemon.sidecars.fetch.default_cache_dir("gaia")`. Staging the verified
|
|
28
|
+
* sidecar here means the daemon's own fetch is a SHA-256 cache hit instead of a
|
|
29
|
+
* second download. This path is a cross-repo contract with the daemon.
|
|
30
|
+
*/
|
|
31
|
+
export declare function daemonSidecarCacheDir(agentId?: string): string;
|
|
32
|
+
export interface FetchOptions {
|
|
33
|
+
/** Which binary to fetch. */
|
|
34
|
+
component: ComponentName;
|
|
35
|
+
/** Directory the verified binary is written into. Required. */
|
|
36
|
+
outDir: string;
|
|
37
|
+
/**
|
|
38
|
+
* Override this component's `baseUrl` (e.g. a local mirror). Trailing slash
|
|
39
|
+
* optional. Applies to whichever component is being fetched — the two lanes'
|
|
40
|
+
* filenames never collide, so one flat mirror directory can serve both.
|
|
41
|
+
*/
|
|
42
|
+
baseUrl?: string;
|
|
43
|
+
/** Override the platform key (defaults to the current host). */
|
|
44
|
+
platformKey?: string;
|
|
45
|
+
/** Path to the lock file (defaults to the packaged binaries.lock.json). */
|
|
46
|
+
lockPath?: string;
|
|
47
|
+
/** A pre-loaded lock, to avoid re-reading it per component. */
|
|
48
|
+
lock?: BinaryLock;
|
|
49
|
+
/** Fetch override (tests). Defaults to global `fetch`. */
|
|
50
|
+
fetchImpl?: typeof fetch;
|
|
51
|
+
/** Re-download even when a verified binary is already cached. Default false. */
|
|
52
|
+
force?: boolean;
|
|
53
|
+
/** Abort the download after this many ms. Default 300000 (the sidecar is ~200MB). */
|
|
54
|
+
timeoutMs?: number;
|
|
55
|
+
}
|
|
56
|
+
export interface FetchResult {
|
|
57
|
+
component: ComponentName;
|
|
58
|
+
/** Absolute path to the written, verified executable. */
|
|
59
|
+
binaryPath: string;
|
|
60
|
+
/** The platform key resolved. */
|
|
61
|
+
platformKey: string;
|
|
62
|
+
/** The verified SHA-256 (lowercase hex). */
|
|
63
|
+
sha256: string;
|
|
64
|
+
/** Source URL the artifact was downloaded from. */
|
|
65
|
+
url: string;
|
|
66
|
+
/** True when the on-disk binary was reused (hash already matched). */
|
|
67
|
+
cached: boolean;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* SHA-256 of a file on disk, or null when it is simply absent. Any other error
|
|
71
|
+
* (a permission problem, a directory in the way) is re-raised: reading it as
|
|
72
|
+
* "no cache" would trigger a re-download that then fails on write with a far
|
|
73
|
+
* less useful message.
|
|
74
|
+
*/
|
|
75
|
+
export declare function fileSha256(filePath: string): Promise<string | null>;
|
|
76
|
+
/**
|
|
77
|
+
* Verify a buffer against an expected SHA-256. Throws `IntegrityError` loudly on
|
|
78
|
+
* mismatch — this is the no-silent-fallback integrity gate.
|
|
79
|
+
*/
|
|
80
|
+
export declare function verifySha256(buf: Buffer, expected: string, sourceLabel: string): string;
|
|
81
|
+
/**
|
|
82
|
+
* Fetch + verify + install one component's binary for the current platform.
|
|
83
|
+
*
|
|
84
|
+
* @throws PlatformError unsupported platform / incomplete entry / placeholder hash
|
|
85
|
+
* @throws IntegrityError SHA-256 mismatch
|
|
86
|
+
* @throws Error download/network failure (HTTP status surfaced)
|
|
87
|
+
*/
|
|
88
|
+
export declare function fetchBinary(opts: FetchOptions): Promise<FetchResult>;
|
|
89
|
+
export interface FetchAllOptions extends Omit<FetchOptions, "component" | "outDir"> {
|
|
90
|
+
/** Cache dir for the TUI. Defaults to `defaultCacheDir(lock.agentVersion)`. */
|
|
91
|
+
tuiDir?: string;
|
|
92
|
+
/** Cache dir for the sidecar. Defaults to the daemon's `~/.gaia/agents/gaia`. */
|
|
93
|
+
sidecarDir?: string;
|
|
94
|
+
}
|
|
95
|
+
export interface FetchAllResult {
|
|
96
|
+
sidecar: FetchResult;
|
|
97
|
+
tui: FetchResult;
|
|
98
|
+
lock: BinaryLock;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Fetch + verify BOTH binaries. Sequential on purpose: the sidecar is the large
|
|
102
|
+
* download and a failure there should not race a half-finished TUI download.
|
|
103
|
+
*
|
|
104
|
+
* The sidecar lands in the daemon's own cache dir so the daemon — which owns
|
|
105
|
+
* spawning it — finds it already verified instead of downloading it again.
|
|
106
|
+
*/
|
|
107
|
+
export declare function fetchAll(opts?: FetchAllOptions): Promise<FetchAllResult>;
|
|
108
|
+
/** Sync existence check, for the lifecycle layer. */
|
|
109
|
+
export declare function binaryExists(binaryPath: string): boolean;
|
|
110
|
+
//# sourceMappingURL=fetch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../src/fetch.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;GAiBG;AAWH,OAAO,EACL,KAAK,UAAU,EAEf,KAAK,aAAa,EAOnB,MAAM,eAAe,CAAC;AAIvB;;;GAGG;AACH,wBAAgB,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAE5D;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,SAAS,GAAG,MAAM,CAE9D;AAED,MAAM,WAAW,YAAY;IAC3B,6BAA6B;IAC7B,SAAS,EAAE,aAAa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