@amd-gaia/gaia 0.1.0 → 0.2.0
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 +244 -0
- package/LICENSE +21 -0
- package/README.md +225 -6
- package/SKILL.md +597 -0
- package/SPEC.md +537 -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 +493 -0
- package/dist/cli.js.map +1 -0
- package/dist/errors.d.ts +41 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +51 -0
- package/dist/errors.js.map +1 -0
- package/dist/fetch.d.ts +111 -0
- package/dist/fetch.d.ts.map +1 -0
- package/dist/fetch.js +369 -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 +162 -0
- package/dist/lifecycle.d.ts.map +1 -0
- package/dist/lifecycle.js +613 -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 +66 -15
package/dist/cli.js
ADDED
|
@@ -0,0 +1,493 @@
|
|
|
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 { readFileSync, readdirSync, 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
|
+
Must be https unless --allow-insecure-base-url is given.
|
|
93
|
+
--allow-insecure-base-url
|
|
94
|
+
Permit a non-https --base-url (a trusted local mirror)
|
|
95
|
+
--cache-dir <dir> Where to cache the TUI binary
|
|
96
|
+
--sidecar-dir <dir> Where to install the agent sidecar
|
|
97
|
+
(default ~/.gaia/agents/gaia — the daemon's own cache)
|
|
98
|
+
--force Re-download even when a verified binary is already cached
|
|
99
|
+
-- <tui args> Forward everything after \`--\` to gaia-tui verbatim
|
|
100
|
+
|
|
101
|
+
fetch options:
|
|
102
|
+
--component <name> Fetch only one of: ${COMPONENTS.join(", ")} (default: both)
|
|
103
|
+
--platform <key> Override the platform key (e.g. linux-x64). Default: this host
|
|
104
|
+
plus every run option above.
|
|
105
|
+
|
|
106
|
+
serve options:
|
|
107
|
+
--port <n> Bind port (default ${DEFAULT_PORT}; ${RESERVED_PORT} is reserved and refused)
|
|
108
|
+
--base-url, --sidecar-dir, --force as above. \`serve\` never downloads the TUI,
|
|
109
|
+
so --cache-dir is refused rather than ignored.
|
|
110
|
+
|
|
111
|
+
Notes:
|
|
112
|
+
* No binaries are committed to the repo. Every download is SHA-256 verified
|
|
113
|
+
against binaries.lock.json and FAILS LOUDLY on any mismatch.
|
|
114
|
+
* A placeholder hash in the lock blocks the fetch outright, so an unverifiable
|
|
115
|
+
binary can never be trusted.
|
|
116
|
+
* The agent sidecar has no arm64 Linux or arm64 Windows build; the TUI does.
|
|
117
|
+
\`gaia version\` prints the exact per-component platform matrix.
|
|
118
|
+
* The TUI is the published \`terminal-hub\` component — byte-identical to the
|
|
119
|
+
\`gaia tui\` a core install runs, so its behaviour cannot drift from it.
|
|
120
|
+
* Set DEBUG=gaia for download, spawn, and sidecar output on stderr.
|
|
121
|
+
`;
|
|
122
|
+
const flagStr = (args, k) => typeof args.flags[k] === "string" ? args.flags[k] : undefined;
|
|
123
|
+
/**
|
|
124
|
+
* Which commands actually READ each value flag, and why the others refuse it.
|
|
125
|
+
* A flag a command ignores is worse than one it rejects: `run --port 9000`
|
|
126
|
+
* used to parse fine and silently come up on the default port.
|
|
127
|
+
*/
|
|
128
|
+
const VALUE_FLAG_SCOPE = {
|
|
129
|
+
"base-url": { commands: ["run", "fetch", "serve"], why: "it only affects downloads" },
|
|
130
|
+
"sidecar-dir": { commands: ["run", "fetch", "serve"], why: "it only affects downloads" },
|
|
131
|
+
platform: {
|
|
132
|
+
commands: ["fetch"],
|
|
133
|
+
why: "`run` and `serve` execute the binary, so it must be built for this host " +
|
|
134
|
+
`(${currentPlatformKey()})`,
|
|
135
|
+
},
|
|
136
|
+
port: {
|
|
137
|
+
commands: ["serve"],
|
|
138
|
+
why: "only `serve` binds a port; `run` reaches the agent through the daemon, which picks its own",
|
|
139
|
+
},
|
|
140
|
+
component: {
|
|
141
|
+
commands: ["fetch"],
|
|
142
|
+
why: "`run` needs both binaries and `serve` needs the sidecar, so neither can fetch a subset",
|
|
143
|
+
},
|
|
144
|
+
"cache-dir": {
|
|
145
|
+
commands: ["run", "fetch"],
|
|
146
|
+
why: "it caches the TUI, which `serve` never downloads (use --sidecar-dir)",
|
|
147
|
+
},
|
|
148
|
+
};
|
|
149
|
+
/** Refuse a value flag the chosen command would otherwise silently ignore. */
|
|
150
|
+
function assertFlagsInScope(args, cmd) {
|
|
151
|
+
for (const [flag, scope] of Object.entries(VALUE_FLAG_SCOPE)) {
|
|
152
|
+
if (args.flags[flag] === undefined || scope.commands.includes(cmd))
|
|
153
|
+
continue;
|
|
154
|
+
throw new UsageError(`--${flag} is not valid for \`gaia ${cmd}\` — ${scope.why}. ` +
|
|
155
|
+
`It is accepted by: ${scope.commands.map((c) => `\`gaia ${c}\``).join(", ")}.`);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Require https for a download source. Integrity still holds over plaintext
|
|
160
|
+
* (the SHA is pinned), but a MITM then surfaces as a baffling IntegrityError
|
|
161
|
+
* instead of the transport failure it is.
|
|
162
|
+
*/
|
|
163
|
+
function checkedBaseUrl(args) {
|
|
164
|
+
const raw = flagStr(args, "base-url");
|
|
165
|
+
if (raw === undefined)
|
|
166
|
+
return undefined;
|
|
167
|
+
let parsed;
|
|
168
|
+
try {
|
|
169
|
+
parsed = new URL(raw);
|
|
170
|
+
}
|
|
171
|
+
catch {
|
|
172
|
+
throw new UsageError(`--base-url '${raw}' is not a valid absolute URL (expected e.g. https://host/path).`);
|
|
173
|
+
}
|
|
174
|
+
if (parsed.protocol !== "https:" && !args.flags["allow-insecure-base-url"]) {
|
|
175
|
+
throw new UsageError(`--base-url '${raw}' uses ${parsed.protocol}, not https. Downloads are ` +
|
|
176
|
+
"SHA-256 verified either way, but plaintext turns tampering into a " +
|
|
177
|
+
"confusing integrity failure instead of a transport error. Use an https " +
|
|
178
|
+
"URL, or pass --allow-insecure-base-url for a trusted local mirror.");
|
|
179
|
+
}
|
|
180
|
+
return raw;
|
|
181
|
+
}
|
|
182
|
+
/** Shared download options. Scope and scheme are validated before we get here. */
|
|
183
|
+
function downloadOptions(args, allowPlatform = false) {
|
|
184
|
+
const platformKey = flagStr(args, "platform");
|
|
185
|
+
return {
|
|
186
|
+
baseUrl: checkedBaseUrl(args),
|
|
187
|
+
...(allowPlatform && platformKey !== undefined ? { platformKey } : {}),
|
|
188
|
+
force: Boolean(args.flags["force"]),
|
|
189
|
+
tuiDir: flagStr(args, "cache-dir"),
|
|
190
|
+
sidecarDir: flagStr(args, "sidecar-dir"),
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* The child's PATH with this package's own bin directory removed.
|
|
195
|
+
*
|
|
196
|
+
* npm installs our shim as `gaia`, and the TUI starts the daemon by resolving
|
|
197
|
+
* `gaia` on PATH (tui/internal/daemon/client.go) expecting the *Python* CLI.
|
|
198
|
+
* Left alone, the TUI would re-invoke us with `daemon start` and the daemon would
|
|
199
|
+
* never come up. Returns undefined when PATH is unset.
|
|
200
|
+
*/
|
|
201
|
+
export function pathWithoutOwnShim(rawPath = process.env["PATH"], argv1 = process.argv[1]) {
|
|
202
|
+
if (rawPath === undefined || !argv1)
|
|
203
|
+
return rawPath;
|
|
204
|
+
const sep = process.platform === "win32" ? ";" : ":";
|
|
205
|
+
let ownBinDir;
|
|
206
|
+
let ownName;
|
|
207
|
+
try {
|
|
208
|
+
ownBinDir = path.resolve(path.dirname(argv1));
|
|
209
|
+
ownName = path.basename(argv1);
|
|
210
|
+
}
|
|
211
|
+
catch {
|
|
212
|
+
return rawPath;
|
|
213
|
+
}
|
|
214
|
+
const same = (dir) => {
|
|
215
|
+
const resolved = path.resolve(dir);
|
|
216
|
+
return process.platform === "win32"
|
|
217
|
+
? resolved.toLowerCase() === ownBinDir.toLowerCase()
|
|
218
|
+
: resolved === ownBinDir;
|
|
219
|
+
};
|
|
220
|
+
const entries = rawPath.split(sep).filter((d) => d !== "");
|
|
221
|
+
const ours = entries.filter((d) => same(d) || shimTargetsScript(d, argv1));
|
|
222
|
+
const kept = entries.filter((d) => !ours.includes(d));
|
|
223
|
+
const shared = ours.filter((d) => !isExclusivelyOurs(d, same(d) ? ownName : "gaia"));
|
|
224
|
+
return [...kept, ...shared].join(sep);
|
|
225
|
+
}
|
|
226
|
+
/** Match npm's symlink or generated cmd/PowerShell wrapper to this script. */
|
|
227
|
+
function shimTargetsScript(dir, script) {
|
|
228
|
+
const canonical = (file) => {
|
|
229
|
+
try {
|
|
230
|
+
const resolved = realpathSync(file);
|
|
231
|
+
return process.platform === "win32" ? resolved.toLowerCase() : resolved;
|
|
232
|
+
}
|
|
233
|
+
catch {
|
|
234
|
+
return undefined; // no resolvable executable at this candidate
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
const expected = canonical(script);
|
|
238
|
+
if (!expected)
|
|
239
|
+
return false;
|
|
240
|
+
for (const name of ["gaia", "gaia.cmd", "gaia.ps1"]) {
|
|
241
|
+
const shim = path.join(dir, name);
|
|
242
|
+
if (canonical(shim) === expected)
|
|
243
|
+
return true;
|
|
244
|
+
if (!name.includes("."))
|
|
245
|
+
continue;
|
|
246
|
+
let contents;
|
|
247
|
+
try {
|
|
248
|
+
contents = readFileSync(shim, "utf8");
|
|
249
|
+
}
|
|
250
|
+
catch {
|
|
251
|
+
continue; // this PATH directory does not contain a readable wrapper
|
|
252
|
+
}
|
|
253
|
+
for (const match of contents.matchAll(/["'](?:%dp0%|\$basedir)[\\/]([^"']+)["']/gi)) {
|
|
254
|
+
const target = path.resolve(dir, match[1].replace(/[\\/]/g, path.sep));
|
|
255
|
+
if (canonical(target) === expected)
|
|
256
|
+
return true;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
return false;
|
|
260
|
+
}
|
|
261
|
+
/** True when every file in `dir` is a shim for `name` (`gaia`, `gaia.cmd`, …). */
|
|
262
|
+
function isExclusivelyOurs(dir, name) {
|
|
263
|
+
const stem = name.replace(/\.(cmd|bat|ps1|exe)$/i, "");
|
|
264
|
+
let entries;
|
|
265
|
+
try {
|
|
266
|
+
entries = readdirSync(dir);
|
|
267
|
+
}
|
|
268
|
+
catch {
|
|
269
|
+
return false; // unreadable → treat as shared, the non-destructive branch
|
|
270
|
+
}
|
|
271
|
+
return (entries.length > 0 &&
|
|
272
|
+
entries.every((e) => e.replace(/\.(cmd|bat|ps1|exe)$/i, "") === stem));
|
|
273
|
+
}
|
|
274
|
+
/** Validate `--port`. Rejects out-of-range values and the reserved port. */
|
|
275
|
+
export function resolvePort(raw) {
|
|
276
|
+
// Strict digits, not Number(): that accepts "0x2710", " 80 ", and "1e3",
|
|
277
|
+
// so a typo would quietly bind a port the user never named.
|
|
278
|
+
const port = typeof raw === "string" ? (/^\d+$/.test(raw) ? Number(raw) : NaN) : DEFAULT_PORT;
|
|
279
|
+
if (!Number.isInteger(port) || port <= 0 || port > 65535 || port === RESERVED_PORT) {
|
|
280
|
+
return {
|
|
281
|
+
error: `--port must be a port in 1..65535 and not ${RESERVED_PORT} (got ${String(raw)})`,
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
return { port };
|
|
285
|
+
}
|
|
286
|
+
async function cmdRun(args) {
|
|
287
|
+
const opts = downloadOptions(args);
|
|
288
|
+
process.stderr.write("[gaia] fetching and verifying the agent sidecar and the terminal UI ...\n");
|
|
289
|
+
const { sidecar, tui } = await fetchAll(opts);
|
|
290
|
+
process.stderr.write(`[gaia] sidecar ${sidecar.cached ? "cached" : "installed"} -> ${sidecar.binaryPath}\n` +
|
|
291
|
+
`[gaia] tui ${tui.cached ? "cached" : "installed"} -> ${tui.binaryPath}\n` +
|
|
292
|
+
"[gaia] starting the terminal UI ...\n");
|
|
293
|
+
// The TUI owns the daemon handshake and the daemon owns the sidecar process —
|
|
294
|
+
// the TUI never holds a sidecar bearer token, so starting one here would only
|
|
295
|
+
// fight it for the port. Our job is to put a *verified* binary where the daemon
|
|
296
|
+
// looks, which fetchAll just did.
|
|
297
|
+
const childPath = pathWithoutOwnShim();
|
|
298
|
+
return runTui({
|
|
299
|
+
binaryPath: tui.binaryPath,
|
|
300
|
+
args: args.passthrough,
|
|
301
|
+
env: childPath === undefined ? {} : { PATH: childPath, Path: childPath },
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
async function cmdFetch(args) {
|
|
305
|
+
const opts = downloadOptions(args, true);
|
|
306
|
+
const only = args.flags["component"];
|
|
307
|
+
const results = [];
|
|
308
|
+
if (typeof only === "string") {
|
|
309
|
+
if (!COMPONENTS.includes(only)) {
|
|
310
|
+
throw new UsageError(`unknown --component '${only}'; expected one of ${COMPONENTS.join(", ")}`);
|
|
311
|
+
}
|
|
312
|
+
const component = only;
|
|
313
|
+
const lock = loadLock();
|
|
314
|
+
results.push(await fetchBinary({
|
|
315
|
+
component,
|
|
316
|
+
lock,
|
|
317
|
+
outDir: component === "sidecar"
|
|
318
|
+
? (opts.sidecarDir ?? daemonSidecarCacheDir())
|
|
319
|
+
: (opts.tuiDir ?? defaultCacheDir(lock.agentVersion)),
|
|
320
|
+
baseUrl: opts.baseUrl,
|
|
321
|
+
platformKey: opts.platformKey,
|
|
322
|
+
force: opts.force,
|
|
323
|
+
}));
|
|
324
|
+
}
|
|
325
|
+
else {
|
|
326
|
+
const all = await fetchAll(opts);
|
|
327
|
+
results.push(all.sidecar, all.tui);
|
|
328
|
+
}
|
|
329
|
+
process.stdout.write(JSON.stringify({
|
|
330
|
+
ok: true,
|
|
331
|
+
binaries: results.map((r) => ({
|
|
332
|
+
component: r.component,
|
|
333
|
+
binaryPath: r.binaryPath,
|
|
334
|
+
platform: r.platformKey,
|
|
335
|
+
sha256: r.sha256,
|
|
336
|
+
cached: r.cached,
|
|
337
|
+
url: r.url,
|
|
338
|
+
})),
|
|
339
|
+
}, null, 2) + "\n");
|
|
340
|
+
return 0;
|
|
341
|
+
}
|
|
342
|
+
const SERVE_SIGNALS = ["SIGINT", "SIGTERM", "SIGHUP"];
|
|
343
|
+
async function cmdServe(args) {
|
|
344
|
+
const parsed = resolvePort(args.flags["port"]);
|
|
345
|
+
if ("error" in parsed) {
|
|
346
|
+
process.stderr.write(`error: ${parsed.error}\n`);
|
|
347
|
+
return 2;
|
|
348
|
+
}
|
|
349
|
+
const { port } = parsed;
|
|
350
|
+
const opts = downloadOptions(args);
|
|
351
|
+
process.stderr.write("[gaia] fetching and verifying the agent sidecar ...\n");
|
|
352
|
+
const result = await fetchBinary({
|
|
353
|
+
component: "sidecar",
|
|
354
|
+
outDir: opts.sidecarDir ?? daemonSidecarCacheDir(),
|
|
355
|
+
baseUrl: opts.baseUrl,
|
|
356
|
+
force: opts.force,
|
|
357
|
+
});
|
|
358
|
+
// We own the lifecycle here (autoCleanup off) so the graceful shutdown below
|
|
359
|
+
// actually runs; the default auto-reaper would SIGKILL the tree first.
|
|
360
|
+
const sidecar = await startSidecar({
|
|
361
|
+
binaryPath: result.binaryPath,
|
|
362
|
+
port,
|
|
363
|
+
autoCleanup: false,
|
|
364
|
+
});
|
|
365
|
+
try {
|
|
366
|
+
process.stdout.write(`\n ▸ GAIA agent: ${sidecar.baseUrl}/v1/gaia/query\n`);
|
|
367
|
+
process.stdout.write(` Health: ${sidecar.baseUrl}/health\n`);
|
|
368
|
+
process.stdout.write(" Lemonade must be running for live queries. Ctrl+C to stop.\n\n");
|
|
369
|
+
let stop;
|
|
370
|
+
const stopped = new Promise((resolve) => {
|
|
371
|
+
let stopping = false;
|
|
372
|
+
stop = () => {
|
|
373
|
+
if (stopping) {
|
|
374
|
+
// Absorbed, so say what is happening — otherwise a repeat Ctrl+C
|
|
375
|
+
// during a slow teardown just looks like a frozen terminal.
|
|
376
|
+
process.stderr.write(`[gaia] already stopping the sidecar (pid ${String(sidecar.child.pid)}); ` +
|
|
377
|
+
"waiting for its process tree to exit ...\n");
|
|
378
|
+
return;
|
|
379
|
+
}
|
|
380
|
+
stopping = true;
|
|
381
|
+
process.stderr.write("\n[gaia] stopping the sidecar ...\n");
|
|
382
|
+
void shutdown(sidecar).catch(() => undefined).finally(resolve);
|
|
383
|
+
};
|
|
384
|
+
// process.on, not once: a second Ctrl+C during the shutdown would
|
|
385
|
+
// otherwise hit Node's default disposition and kill us mid-teardown,
|
|
386
|
+
// orphaning the detached sidecar tree on port 8141. The `stopping` guard
|
|
387
|
+
// absorbs the repeats.
|
|
388
|
+
for (const sig of SERVE_SIGNALS)
|
|
389
|
+
process.on(sig, stop);
|
|
390
|
+
});
|
|
391
|
+
try {
|
|
392
|
+
await stopped;
|
|
393
|
+
}
|
|
394
|
+
finally {
|
|
395
|
+
// Left installed, they would swallow every later signal AND suppress
|
|
396
|
+
// Node's default disposition, so Ctrl+C would stop working entirely.
|
|
397
|
+
for (const sig of SERVE_SIGNALS)
|
|
398
|
+
process.removeListener(sig, stop);
|
|
399
|
+
}
|
|
400
|
+
return 0;
|
|
401
|
+
}
|
|
402
|
+
catch (e) {
|
|
403
|
+
await shutdown(sidecar).catch(() => undefined);
|
|
404
|
+
throw e;
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
function cmdVersion() {
|
|
408
|
+
const lock = loadLock();
|
|
409
|
+
process.stdout.write(JSON.stringify({
|
|
410
|
+
agentVersion: lock.agentVersion,
|
|
411
|
+
schemaVersion: lock.schemaVersion,
|
|
412
|
+
currentPlatform: currentPlatformKey(),
|
|
413
|
+
// Per component: each ships from its own hub lane at its own version.
|
|
414
|
+
components: Object.fromEntries(COMPONENTS.map((c) => [
|
|
415
|
+
c,
|
|
416
|
+
{
|
|
417
|
+
componentVersion: componentLock(lock, c).componentVersion,
|
|
418
|
+
baseUrl: componentBaseUrl(lock, c),
|
|
419
|
+
platforms: platformsFor(lock, c),
|
|
420
|
+
},
|
|
421
|
+
])),
|
|
422
|
+
}, null, 2) + "\n");
|
|
423
|
+
return 0;
|
|
424
|
+
}
|
|
425
|
+
const KNOWN_COMMANDS = ["run", "fetch", "serve", "version", "help"];
|
|
426
|
+
export async function main(argv) {
|
|
427
|
+
const args = parseArgs(argv);
|
|
428
|
+
const explicit = args._[0];
|
|
429
|
+
const cmd = explicit ?? (args.flags["help"] ? "help" : "run");
|
|
430
|
+
if (args.flags["help"] && cmd !== "help") {
|
|
431
|
+
process.stdout.write(HELP);
|
|
432
|
+
return 0;
|
|
433
|
+
}
|
|
434
|
+
if (!KNOWN_COMMANDS.includes(cmd)) {
|
|
435
|
+
throw new UsageError(`unknown command '${cmd}'`);
|
|
436
|
+
}
|
|
437
|
+
// A dropped positional means a mistyped invocation whose flags may also be
|
|
438
|
+
// wrong; refuse rather than run something the user did not ask for.
|
|
439
|
+
const extra = explicit === undefined ? args._ : args._.slice(1);
|
|
440
|
+
if (extra.length > 0) {
|
|
441
|
+
throw new UsageError(`unexpected argument${extra.length > 1 ? "s" : ""} ${extra.map((a) => `'${a}'`).join(", ")}. ` +
|
|
442
|
+
"Arguments for the terminal UI go after a bare `--`.");
|
|
443
|
+
}
|
|
444
|
+
assertFlagsInScope(args, cmd);
|
|
445
|
+
switch (cmd) {
|
|
446
|
+
case "run":
|
|
447
|
+
return cmdRun(args);
|
|
448
|
+
case "fetch":
|
|
449
|
+
return cmdFetch(args);
|
|
450
|
+
case "serve":
|
|
451
|
+
return cmdServe(args);
|
|
452
|
+
case "version":
|
|
453
|
+
return cmdVersion();
|
|
454
|
+
default:
|
|
455
|
+
process.stdout.write(HELP);
|
|
456
|
+
return 0;
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
/** True when this file is the entry point (so importing it for tests is a no-op). */
|
|
460
|
+
function invokedDirectly() {
|
|
461
|
+
if (!process.argv[1])
|
|
462
|
+
return false;
|
|
463
|
+
try {
|
|
464
|
+
return realpathSync(fileURLToPath(import.meta.url)) === realpathSync(process.argv[1]);
|
|
465
|
+
}
|
|
466
|
+
catch {
|
|
467
|
+
return false;
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
if (invokedDirectly()) {
|
|
471
|
+
main(process.argv.slice(2))
|
|
472
|
+
// exitCode rather than process.exit(): the latter can truncate the JSON
|
|
473
|
+
// `fetch`/`version` just wrote into an async stdout pipe.
|
|
474
|
+
.then((code) => {
|
|
475
|
+
process.exitCode = code;
|
|
476
|
+
})
|
|
477
|
+
.catch((e) => {
|
|
478
|
+
// Fail loudly with an actionable message; never swallow.
|
|
479
|
+
if (e instanceof UsageError) {
|
|
480
|
+
process.stderr.write(`error: ${e.message}\n\n${HELP}`);
|
|
481
|
+
process.exitCode = 2;
|
|
482
|
+
}
|
|
483
|
+
else if (e instanceof GaiaError) {
|
|
484
|
+
process.stderr.write(`[gaia] ${e.name}: ${e.message}\n`);
|
|
485
|
+
process.exitCode = 1;
|
|
486
|
+
}
|
|
487
|
+
else {
|
|
488
|
+
process.stderr.write(`[gaia] unexpected error: ${e.stack ?? e}\n`);
|
|
489
|
+
process.exitCode = 1;
|
|
490
|
+
}
|
|
491
|
+
});
|
|
492
|
+
}
|
|
493
|
+
//# 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":[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0D;SACzD,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE;QACb,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;IAC1B,CAAC,CAAC;SACD,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,41 @@
|
|
|
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
|
+
/** The sidecar we spawned died; anything answering its port is not ours. */
|
|
26
|
+
export declare class SidecarExitedError extends GaiaError {
|
|
27
|
+
}
|
|
28
|
+
/** The bind port was already taken before we spawned anything. */
|
|
29
|
+
export declare class PortInUseError extends GaiaError {
|
|
30
|
+
}
|
|
31
|
+
/** A 2xx response whose body is not the JSON the contract promises. */
|
|
32
|
+
export declare class MalformedResponseError extends GaiaError {
|
|
33
|
+
}
|
|
34
|
+
/** An HTTP request to the sidecar returned a non-2xx status. */
|
|
35
|
+
export declare class HttpError extends GaiaError {
|
|
36
|
+
readonly status: number;
|
|
37
|
+
readonly url: string;
|
|
38
|
+
readonly bodyText: string;
|
|
39
|
+
constructor(status: number, url: string, bodyText: string);
|
|
40
|
+
}
|
|
41
|
+
//# 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,4EAA4E;AAC5E,qBAAa,kBAAmB,SAAQ,SAAS;CAAG;AAEpD,kEAAkE;AAClE,qBAAa,cAAe,SAAQ,SAAS;CAAG;AAEhD,uEAAuE;AACvE,qBAAa,sBAAuB,SAAQ,SAAS;CAAG;AAExD,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,51 @@
|
|
|
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
|
+
/** The sidecar we spawned died; anything answering its port is not ours. */
|
|
31
|
+
export class SidecarExitedError extends GaiaError {
|
|
32
|
+
}
|
|
33
|
+
/** The bind port was already taken before we spawned anything. */
|
|
34
|
+
export class PortInUseError extends GaiaError {
|
|
35
|
+
}
|
|
36
|
+
/** A 2xx response whose body is not the JSON the contract promises. */
|
|
37
|
+
export class MalformedResponseError extends GaiaError {
|
|
38
|
+
}
|
|
39
|
+
/** An HTTP request to the sidecar returned a non-2xx status. */
|
|
40
|
+
export class HttpError extends GaiaError {
|
|
41
|
+
status;
|
|
42
|
+
url;
|
|
43
|
+
bodyText;
|
|
44
|
+
constructor(status, url, bodyText) {
|
|
45
|
+
super(`HTTP ${status} from ${url}: ${bodyText || "(empty body)"}`);
|
|
46
|
+
this.status = status;
|
|
47
|
+
this.url = url;
|
|
48
|
+
this.bodyText = bodyText;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
//# 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;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