open-agents-ai 0.90.0 → 0.91.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 +51 -11
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -321,13 +321,20 @@ async function checkForUpdate(currentVersion, forceCheck = false) {
|
|
|
321
321
|
};
|
|
322
322
|
}
|
|
323
323
|
function performSilentUpdate() {
|
|
324
|
+
const installCmd = `npm install -g ${PACKAGE_NAME}@latest --prefer-online`;
|
|
324
325
|
try {
|
|
325
|
-
execSync(
|
|
326
|
-
stdio: "pipe",
|
|
327
|
-
timeout: 12e4
|
|
328
|
-
});
|
|
326
|
+
execSync(installCmd, { stdio: "pipe", timeout: 12e4 });
|
|
329
327
|
return true;
|
|
330
|
-
} catch {
|
|
328
|
+
} catch (err) {
|
|
329
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
330
|
+
if (/EACCES|permission denied/i.test(msg)) {
|
|
331
|
+
try {
|
|
332
|
+
execSync(`sudo -n ${installCmd}`, { stdio: "pipe", timeout: 12e4 });
|
|
333
|
+
return true;
|
|
334
|
+
} catch {
|
|
335
|
+
return false;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
331
338
|
return false;
|
|
332
339
|
}
|
|
333
340
|
}
|
|
@@ -30025,22 +30032,55 @@ async function handleUpdate(subcommand, ctx) {
|
|
|
30025
30032
|
return;
|
|
30026
30033
|
}
|
|
30027
30034
|
checkSpinner.stop(`Update available: v${info.currentVersion} \u2192 v${c2.bold(c2.green(info.latestVersion))}`);
|
|
30035
|
+
const { exec, execSync: es2 } = await import("node:child_process");
|
|
30036
|
+
let needsSudo = false;
|
|
30037
|
+
try {
|
|
30038
|
+
const prefix = es2("npm prefix -g", { encoding: "utf8", timeout: 5e3 }).trim();
|
|
30039
|
+
const { accessSync, constants } = await import("node:fs");
|
|
30040
|
+
try {
|
|
30041
|
+
accessSync(prefix, constants.W_OK);
|
|
30042
|
+
} catch {
|
|
30043
|
+
needsSudo = true;
|
|
30044
|
+
}
|
|
30045
|
+
} catch {
|
|
30046
|
+
}
|
|
30047
|
+
if (needsSudo) {
|
|
30048
|
+
renderInfo("Global npm directory requires elevated permissions.");
|
|
30049
|
+
renderInfo("You'll be asked for your password once \u2014 it covers all update steps.");
|
|
30050
|
+
process.stdout.write("\n");
|
|
30051
|
+
try {
|
|
30052
|
+
es2("sudo -v", { stdio: "inherit", timeout: 6e4 });
|
|
30053
|
+
} catch {
|
|
30054
|
+
renderWarning("Could not acquire sudo credentials. Try: sudo npm i -g open-agents-ai");
|
|
30055
|
+
return;
|
|
30056
|
+
}
|
|
30057
|
+
}
|
|
30058
|
+
const sudoPrefix = needsSudo ? "sudo " : "";
|
|
30028
30059
|
const installSpinner = startInlineSpinner("Installing update");
|
|
30029
|
-
const
|
|
30030
|
-
|
|
30031
|
-
|
|
30060
|
+
const installCmd = `${sudoPrefix}npm install -g open-agents-ai@latest --prefer-online`;
|
|
30061
|
+
let installOk = false;
|
|
30062
|
+
let installError = "";
|
|
30063
|
+
installOk = await new Promise((resolve31) => {
|
|
30064
|
+
const child = exec(installCmd, { timeout: 18e4 }, (err, _stdout, stderr) => {
|
|
30065
|
+
if (err)
|
|
30066
|
+
installError = (stderr || err.message || "").trim();
|
|
30067
|
+
resolve31(!err);
|
|
30068
|
+
});
|
|
30032
30069
|
child.stdout?.resume();
|
|
30033
|
-
child.stderr?.resume();
|
|
30034
30070
|
});
|
|
30035
30071
|
if (!installOk) {
|
|
30036
30072
|
installSpinner.stop("Update install failed.");
|
|
30037
|
-
|
|
30073
|
+
const errPreview = installError.split("\n").filter((l) => l.trim()).slice(-3).join("\n ");
|
|
30074
|
+
if (errPreview)
|
|
30075
|
+
renderWarning(`Error:
|
|
30076
|
+
${errPreview}`);
|
|
30077
|
+
renderWarning(`Try manually: ${sudoPrefix}npm i -g open-agents-ai`);
|
|
30038
30078
|
return;
|
|
30039
30079
|
}
|
|
30040
30080
|
installSpinner.stop(`Update installed (v${info.latestVersion}).`);
|
|
30041
30081
|
const rebuildSpinner = startInlineSpinner("Rebuilding native modules");
|
|
30042
30082
|
const rebuildOk = await new Promise((resolve31) => {
|
|
30043
|
-
const child = exec(
|
|
30083
|
+
const child = exec(`${sudoPrefix}npm rebuild -g open-agents-ai 2>/dev/null || true`, { timeout: 12e4 }, () => resolve31(true));
|
|
30044
30084
|
child.stdout?.resume();
|
|
30045
30085
|
child.stderr?.resume();
|
|
30046
30086
|
});
|
package/package.json
CHANGED