@aidotnet/astra-gate 0.4.0 → 0.5.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/dist/index.js +88 -10
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -199,7 +199,8 @@ var CLIENT_KINDS = [
|
|
|
199
199
|
"omp",
|
|
200
200
|
"mimo-code",
|
|
201
201
|
"deepseek-harness",
|
|
202
|
-
"workbuddy"
|
|
202
|
+
"workbuddy",
|
|
203
|
+
"muse-code"
|
|
203
204
|
];
|
|
204
205
|
|
|
205
206
|
// src/commands/manage.ts
|
|
@@ -411,12 +412,76 @@ function runCapture(command, args, o = {}) {
|
|
|
411
412
|
function npmCommand(o) {
|
|
412
413
|
return o.npm ?? locateNpm(o);
|
|
413
414
|
}
|
|
415
|
+
function dirHasExecutable(dir, name) {
|
|
416
|
+
try {
|
|
417
|
+
fs2.accessSync(path3.join(dir, name), fs2.constants.X_OK);
|
|
418
|
+
return true;
|
|
419
|
+
} catch {
|
|
420
|
+
return false;
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
var NODE_BIN_DIRS = ["/opt/homebrew/bin", "/usr/local/bin"];
|
|
424
|
+
var SHELL_PATH_MARKER = /__ASTRA_PATH_START__([\s\S]*?)__ASTRA_PATH_END__/;
|
|
425
|
+
var cachedLoginShellPath = null;
|
|
426
|
+
function readLoginShellPath(env, timeoutMs = 5e3) {
|
|
427
|
+
return new Promise((resolve) => {
|
|
428
|
+
let out = "";
|
|
429
|
+
let done = false;
|
|
430
|
+
let timer = null;
|
|
431
|
+
const finish = (value) => {
|
|
432
|
+
if (done) return;
|
|
433
|
+
done = true;
|
|
434
|
+
if (timer) clearTimeout(timer);
|
|
435
|
+
resolve(value);
|
|
436
|
+
};
|
|
437
|
+
let child;
|
|
438
|
+
try {
|
|
439
|
+
child = spawn(env.SHELL || "/bin/zsh", ["-ilc", 'printf "__ASTRA_PATH_START__%s__ASTRA_PATH_END__" "$PATH"'], {
|
|
440
|
+
env,
|
|
441
|
+
stdio: ["ignore", "pipe", "ignore"]
|
|
442
|
+
});
|
|
443
|
+
} catch {
|
|
444
|
+
finish(null);
|
|
445
|
+
return;
|
|
446
|
+
}
|
|
447
|
+
timer = setTimeout(() => {
|
|
448
|
+
try {
|
|
449
|
+
child.kill("SIGKILL");
|
|
450
|
+
} catch {
|
|
451
|
+
}
|
|
452
|
+
finish(null);
|
|
453
|
+
}, timeoutMs);
|
|
454
|
+
child.stdout?.on("data", (d) => {
|
|
455
|
+
out += d.toString();
|
|
456
|
+
});
|
|
457
|
+
child.on("error", () => finish(null));
|
|
458
|
+
child.on("close", () => finish(SHELL_PATH_MARKER.exec(out)?.[1] || null));
|
|
459
|
+
});
|
|
460
|
+
}
|
|
461
|
+
async function withNodeOnPath(env, npm, o = {}) {
|
|
462
|
+
if ((o.platform ?? process.platform) === "win32") return env;
|
|
463
|
+
const current = (env.PATH ?? "").split(path3.delimiter).filter(Boolean);
|
|
464
|
+
const hasNode = (dirs) => dirs.some((d) => dirHasExecutable(d, "node"));
|
|
465
|
+
if (hasNode(current)) return env;
|
|
466
|
+
const extra = [...path3.isAbsolute(npm.command) ? [path3.dirname(npm.command)] : [], ...o.wellKnownBinDirs ?? NODE_BIN_DIRS];
|
|
467
|
+
let merged = [...current, ...extra.filter((d) => !current.includes(d))];
|
|
468
|
+
if (!hasNode(merged)) {
|
|
469
|
+
const lookup = o.loginShellPath ?? (() => cachedLoginShellPath ??= readLoginShellPath(env));
|
|
470
|
+
const shellPath = await lookup();
|
|
471
|
+
if (shellPath) {
|
|
472
|
+
const shellDirs = shellPath.split(path3.delimiter).filter(Boolean);
|
|
473
|
+
merged = [...merged, ...shellDirs.filter((d) => !merged.includes(d))];
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
return { ...env, PATH: merged.join(path3.delimiter) };
|
|
477
|
+
}
|
|
414
478
|
async function npmInstallIntoPrefix(prefix, spec, o = {}) {
|
|
415
479
|
const npm = npmCommand(o);
|
|
480
|
+
const env = await withNodeOnPath(npmChildEnv(o.env), npm, o);
|
|
416
481
|
const r = await runCapture(
|
|
417
482
|
npm.command,
|
|
418
483
|
[...npm.args, "install", "--prefix", prefix, "--no-audit", "--no-fund", "--loglevel", "error", spec],
|
|
419
|
-
{ env
|
|
484
|
+
{ env, platform: o.platform, timeoutMs: o.installTimeoutMs ?? 6e5 }
|
|
420
485
|
);
|
|
421
486
|
if (r.code !== 0) {
|
|
422
487
|
throw new Error(`Failed to install ${spec}: ${r.stderr.trim() || `npm exited with code ${r.code}`}`);
|
|
@@ -453,6 +518,14 @@ function writeInstallInfo(home, info2) {
|
|
|
453
518
|
fs3.writeFileSync(file, `${JSON.stringify(info2, null, 2)}
|
|
454
519
|
`);
|
|
455
520
|
}
|
|
521
|
+
function clearServerInfo(home, existing) {
|
|
522
|
+
const { serverPath: _serverPath, serverVersion: _serverVersion, updatedAt: _updatedAt, ...rest } = existing ?? {};
|
|
523
|
+
if (Object.keys(rest).length > 0) {
|
|
524
|
+
writeInstallInfo(home, { ...rest, updatedAt: (/* @__PURE__ */ new Date()).toISOString() });
|
|
525
|
+
} else {
|
|
526
|
+
fs3.rmSync(path4.join(home, "install.json"), { force: true });
|
|
527
|
+
}
|
|
528
|
+
}
|
|
456
529
|
function applyServerInfo(existing, server) {
|
|
457
530
|
return {
|
|
458
531
|
...existing ?? {},
|
|
@@ -757,6 +830,9 @@ async function rollback(o, previousInstall, backupPath, webRootSwapped, setState
|
|
|
757
830
|
if (restorePath) {
|
|
758
831
|
log(`Rolling back to ${restorePath}`);
|
|
759
832
|
writeInstallInfo(o.home, applyServerInfo(previousInstall, { serverPath: restorePath }));
|
|
833
|
+
} else {
|
|
834
|
+
log("Rolling back to the server bundled with the app");
|
|
835
|
+
clearServerInfo(o.home, previousInstall);
|
|
760
836
|
}
|
|
761
837
|
if (await o.control.isRunning()) await o.control.stop();
|
|
762
838
|
const serverDir = updatePaths(o.home).serverDir;
|
|
@@ -1154,7 +1230,7 @@ import { fileURLToPath } from "url";
|
|
|
1154
1230
|
// package.json
|
|
1155
1231
|
var package_default = {
|
|
1156
1232
|
name: "@aidotnet/astra-gate",
|
|
1157
|
-
version: "0.
|
|
1233
|
+
version: "0.5.0",
|
|
1158
1234
|
description: "Astra \u2014 a local AI gateway. Install, start, stop and manage the astra-server from the terminal.",
|
|
1159
1235
|
license: "MIT",
|
|
1160
1236
|
type: "module",
|
|
@@ -1185,12 +1261,12 @@ var package_default = {
|
|
|
1185
1261
|
commander: "^12.1.0"
|
|
1186
1262
|
},
|
|
1187
1263
|
optionalDependencies: {
|
|
1188
|
-
"@aidotnet/server-darwin-arm64": "0.
|
|
1189
|
-
"@aidotnet/server-darwin-x64": "0.
|
|
1190
|
-
"@aidotnet/server-linux-arm64": "0.
|
|
1191
|
-
"@aidotnet/server-linux-x64": "0.
|
|
1192
|
-
"@aidotnet/server-win32-arm64": "0.
|
|
1193
|
-
"@aidotnet/server-win32-x64": "0.
|
|
1264
|
+
"@aidotnet/server-darwin-arm64": "0.5.0",
|
|
1265
|
+
"@aidotnet/server-darwin-x64": "0.5.0",
|
|
1266
|
+
"@aidotnet/server-linux-arm64": "0.5.0",
|
|
1267
|
+
"@aidotnet/server-linux-x64": "0.5.0",
|
|
1268
|
+
"@aidotnet/server-win32-arm64": "0.5.0",
|
|
1269
|
+
"@aidotnet/server-win32-x64": "0.5.0"
|
|
1194
1270
|
},
|
|
1195
1271
|
devDependencies: {
|
|
1196
1272
|
"@aidotnet/update-core": "workspace:*",
|
|
@@ -2127,7 +2203,9 @@ async function updateServer(home, manifest, force) {
|
|
|
2127
2203
|
await applyServerUpdate({
|
|
2128
2204
|
home,
|
|
2129
2205
|
manifest,
|
|
2130
|
-
|
|
2206
|
+
// manifest.platforms is keyed by .NET RID (osx-arm64), not process.platform (darwin-arm64):
|
|
2207
|
+
// a wrong key silently drops the sha256 check.
|
|
2208
|
+
platformKey: plat.rid,
|
|
2131
2209
|
serverPackage: plat.serverPackage,
|
|
2132
2210
|
platform: plat.platform,
|
|
2133
2211
|
currentServerPath: readInstallJson(home)?.serverPath ?? null,
|