open-agents-ai 0.103.38 → 0.103.40
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 +6 -2
- package/dist/preinstall.cjs +320 -91
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -12615,7 +12615,11 @@ async function handleCmd(cmd) {
|
|
|
12615
12615
|
}
|
|
12616
12616
|
|
|
12617
12617
|
// Query models from the backend
|
|
12618
|
-
|
|
12618
|
+
var rawUrl = args.ollama_url || process.env.OLLAMA_URL || 'http://localhost:11434';
|
|
12619
|
+
// For passthrough: normalize URL \u2014 strip /v1/chat/completions, /v1, etc. so we can append our own paths
|
|
12620
|
+
const ollamaUrl = isPassthrough
|
|
12621
|
+
? rawUrl.replace(/\\/+$/, '').replace(/\\/chat\\/completions$/, '').replace(/\\/completions$/, '').replace(/\\/models(\\/.*)?$/, '').replace(/\\/v1$/, '').replace(/\\/+$/, '')
|
|
12622
|
+
: rawUrl;
|
|
12619
12623
|
let models = [];
|
|
12620
12624
|
|
|
12621
12625
|
if (isPassthrough) {
|
|
@@ -46966,7 +46970,7 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
|
|
|
46966
46970
|
let targetUrl;
|
|
46967
46971
|
if (kindOrUrl === "passthrough" || passthrough) {
|
|
46968
46972
|
kind = "custom";
|
|
46969
|
-
targetUrl = config.backendUrl;
|
|
46973
|
+
targetUrl = normalizeBaseUrl(config.backendUrl);
|
|
46970
46974
|
passthrough = true;
|
|
46971
46975
|
} else if (knownKinds.includes(kindOrUrl)) {
|
|
46972
46976
|
kind = kindOrUrl;
|
package/dist/preinstall.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// preinstall hook — runs BEFORE npm installs dependencies.
|
|
3
|
-
// Pure
|
|
4
|
-
//
|
|
5
|
-
//
|
|
3
|
+
// Pure CJS (no ESM, no backticks) so it works on any Node version.
|
|
4
|
+
// Cross-platform: Linux, macOS, Windows (cmd, PowerShell, Git Bash).
|
|
5
|
+
// If Node is too old, guides the user through installing Node 22.
|
|
6
6
|
var nodeVersion = parseInt(process.versions.node, 10);
|
|
7
7
|
|
|
8
8
|
if (nodeVersion >= 22) {
|
|
@@ -23,36 +23,32 @@ var path = require("path");
|
|
|
23
23
|
var fs = require("fs");
|
|
24
24
|
var childProcess = require("child_process");
|
|
25
25
|
var readline = require("readline");
|
|
26
|
+
var https = require("https");
|
|
27
|
+
var http = require("http");
|
|
26
28
|
|
|
27
|
-
var platform = os.platform();
|
|
29
|
+
var platform = os.platform(); // "win32", "linux", "darwin"
|
|
28
30
|
var arch = os.arch();
|
|
31
|
+
var isWindows = platform === "win32";
|
|
29
32
|
|
|
30
33
|
console.log("");
|
|
31
|
-
console.log("
|
|
32
|
-
console.log("
|
|
33
|
-
console.log("
|
|
34
|
+
console.log(" +---------------------------------------------------+");
|
|
35
|
+
console.log(" | open-agents -- Node.js Check |");
|
|
36
|
+
console.log(" +---------------------------------------------------+");
|
|
34
37
|
console.log("");
|
|
35
38
|
console.log(" Your Node.js: " + process.version);
|
|
36
39
|
console.log(" Required: >= 22.0.0");
|
|
37
40
|
console.log(" Platform: " + platform + "/" + arch);
|
|
38
41
|
console.log("");
|
|
39
42
|
|
|
40
|
-
//
|
|
41
|
-
var nvmDir = process.env.NVM_DIR || path.join(os.homedir(), ".nvm");
|
|
42
|
-
var hasNvm = false;
|
|
43
|
-
try { fs.statSync(path.join(nvmDir, "nvm.sh")); hasNvm = true; } catch (e) {}
|
|
44
|
-
|
|
45
|
-
var rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
46
|
-
|
|
47
|
-
function ask(question, cb) {
|
|
48
|
-
rl.question(question, function(answer) {
|
|
49
|
-
cb(answer.trim().toLowerCase());
|
|
50
|
-
});
|
|
51
|
-
}
|
|
43
|
+
// ── Cross-platform helpers ───────────────────────────────────────────────
|
|
52
44
|
|
|
53
45
|
function hasCmd(cmd) {
|
|
54
46
|
try {
|
|
55
|
-
|
|
47
|
+
if (isWindows) {
|
|
48
|
+
childProcess.execSync("where " + cmd, { stdio: "pipe", timeout: 5000 });
|
|
49
|
+
} else {
|
|
50
|
+
childProcess.execSync("which " + cmd, { stdio: "pipe", timeout: 3000 });
|
|
51
|
+
}
|
|
56
52
|
return true;
|
|
57
53
|
} catch (e) {
|
|
58
54
|
return false;
|
|
@@ -69,76 +65,267 @@ function run(cmd, opts) {
|
|
|
69
65
|
}
|
|
70
66
|
}
|
|
71
67
|
|
|
68
|
+
var rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
69
|
+
|
|
70
|
+
function ask(question, cb) {
|
|
71
|
+
rl.question(question, function(answer) {
|
|
72
|
+
cb(answer.trim().toLowerCase());
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
|
|
72
76
|
function bail(msg) {
|
|
73
77
|
console.log(msg);
|
|
74
78
|
rl.close();
|
|
75
79
|
process.exit(1);
|
|
76
80
|
}
|
|
77
81
|
|
|
78
|
-
//
|
|
79
|
-
|
|
80
|
-
|
|
82
|
+
// ── Node.js-native HTTPS downloader (works everywhere, no curl needed) ──
|
|
83
|
+
|
|
84
|
+
function download(url, cb) {
|
|
85
|
+
var mod = url.indexOf("https:") === 0 ? https : http;
|
|
86
|
+
mod.get(url, function(res) {
|
|
87
|
+
// Follow redirects (301/302/307/308)
|
|
88
|
+
if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
|
|
89
|
+
download(res.headers.location, cb);
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
if (res.statusCode !== 200) {
|
|
93
|
+
cb(new Error("HTTP " + res.statusCode + " from " + url), null);
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
var chunks = [];
|
|
97
|
+
res.on("data", function(chunk) { chunks.push(chunk); });
|
|
98
|
+
res.on("end", function() { cb(null, Buffer.concat(chunks)); });
|
|
99
|
+
res.on("error", function(err) { cb(err, null); });
|
|
100
|
+
}).on("error", function(err) { cb(err, null); });
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function downloadToFile(url, dest, cb) {
|
|
104
|
+
download(url, function(err, data) {
|
|
105
|
+
if (err) { cb(err); return; }
|
|
106
|
+
try {
|
|
107
|
+
fs.writeFileSync(dest, data);
|
|
108
|
+
cb(null);
|
|
109
|
+
} catch (e) {
|
|
110
|
+
cb(e);
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// ── Shell / downloader detection ─────────────────────────────────────────
|
|
116
|
+
|
|
117
|
+
// Returns a shell command prefix for piped downloads, or null.
|
|
118
|
+
// On Windows, we prefer the Node.js-native download() function instead.
|
|
119
|
+
function getShellDownloader() {
|
|
120
|
+
if (hasCmd("curl")) return "curl -fsSL";
|
|
81
121
|
if (hasCmd("wget")) return "wget -qO-";
|
|
82
122
|
return null;
|
|
83
123
|
}
|
|
84
124
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
125
|
+
function getShell() {
|
|
126
|
+
if (isWindows) return null; // Windows doesn't use bash shells for nvm
|
|
127
|
+
return process.env.SHELL || "/bin/bash";
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// ── nvm detection (Unix) ─────────────────────────────────────────────────
|
|
131
|
+
|
|
132
|
+
var nvmDir = process.env.NVM_DIR || path.join(os.homedir(), ".nvm");
|
|
133
|
+
var hasNvm = false;
|
|
134
|
+
try { fs.statSync(path.join(nvmDir, "nvm.sh")); hasNvm = true; } catch (e) {}
|
|
135
|
+
|
|
136
|
+
// nvm-windows detection
|
|
137
|
+
var nvmWinDir = process.env.NVM_HOME || "";
|
|
138
|
+
var hasNvmWin = false;
|
|
139
|
+
if (isWindows) {
|
|
140
|
+
if (!nvmWinDir) {
|
|
141
|
+
// Common install location
|
|
142
|
+
var appData = process.env.APPDATA || path.join(os.homedir(), "AppData", "Roaming");
|
|
143
|
+
nvmWinDir = path.join(appData, "nvm");
|
|
144
|
+
}
|
|
145
|
+
try { fs.statSync(path.join(nvmWinDir, "nvm.exe")); hasNvmWin = true; } catch (e) {}
|
|
146
|
+
if (!hasNvmWin) { try { hasNvmWin = hasCmd("nvm"); } catch (e) {} }
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// ── Windows flow ─────────────────────────────────────────────────────────
|
|
89
150
|
|
|
90
|
-
|
|
151
|
+
function windowsInstallNode(next) {
|
|
152
|
+
console.log(" Windows detected. Checking Node.js install options...");
|
|
91
153
|
console.log("");
|
|
92
154
|
|
|
93
|
-
|
|
155
|
+
// Option 1: nvm-windows is installed
|
|
156
|
+
if (hasNvmWin) {
|
|
157
|
+
console.log(" nvm-windows found.");
|
|
158
|
+
ask(" Install Node.js 22 via nvm? [Y/n] ", function(a) {
|
|
159
|
+
if (a === "n" || a === "no") {
|
|
160
|
+
bail("\n Install manually:\n nvm install 22\n nvm use 22\n npm i -g open-agents-ai\n");
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
var ok = run("nvm install 22") && run("nvm use 22");
|
|
164
|
+
if (!ok) {
|
|
165
|
+
bail("\n nvm install failed. Try manually:\n nvm install 22\n nvm use 22\n npm i -g open-agents-ai\n");
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
next();
|
|
169
|
+
});
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// Option 2: winget available (Windows 10 1709+ / Windows 11)
|
|
174
|
+
if (hasCmd("winget")) {
|
|
175
|
+
ask(" Install Node.js 22 via winget? [Y/n] ", function(a) {
|
|
176
|
+
if (a === "n" || a === "no") {
|
|
177
|
+
windowsFallbackInstructions();
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
var ok = run("winget install -e --id OpenJS.NodeJS.LTS --accept-source-agreements --accept-package-agreements");
|
|
181
|
+
if (ok) {
|
|
182
|
+
console.log("");
|
|
183
|
+
console.log(" Node.js 22 installed via winget.");
|
|
184
|
+
console.log(" Please close and reopen your terminal, then run:");
|
|
185
|
+
console.log(" npm i -g open-agents-ai");
|
|
186
|
+
console.log("");
|
|
187
|
+
rl.close();
|
|
188
|
+
process.exit(0);
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
console.log(" winget install failed, trying alternative...");
|
|
192
|
+
windowsDirectDownload(next);
|
|
193
|
+
});
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// Option 3: choco available
|
|
198
|
+
if (hasCmd("choco")) {
|
|
199
|
+
ask(" Install Node.js 22 via Chocolatey? [Y/n] ", function(a) {
|
|
200
|
+
if (a === "n" || a === "no") {
|
|
201
|
+
windowsFallbackInstructions();
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
var ok = run("choco install nodejs-lts -y");
|
|
205
|
+
if (ok) {
|
|
206
|
+
console.log("");
|
|
207
|
+
console.log(" Node.js installed via Chocolatey.");
|
|
208
|
+
console.log(" Please close and reopen your terminal, then run:");
|
|
209
|
+
console.log(" npm i -g open-agents-ai");
|
|
210
|
+
console.log("");
|
|
211
|
+
rl.close();
|
|
212
|
+
process.exit(0);
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
console.log(" choco install failed, trying alternative...");
|
|
216
|
+
windowsDirectDownload(next);
|
|
217
|
+
});
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// Option 4: scoop available
|
|
222
|
+
if (hasCmd("scoop")) {
|
|
223
|
+
ask(" Install Node.js 22 via scoop? [Y/n] ", function(a) {
|
|
224
|
+
if (a === "n" || a === "no") {
|
|
225
|
+
windowsFallbackInstructions();
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
var ok = run("scoop install nodejs-lts");
|
|
229
|
+
if (ok) {
|
|
230
|
+
console.log("");
|
|
231
|
+
console.log(" Node.js installed via scoop.");
|
|
232
|
+
console.log(" Please close and reopen your terminal, then run:");
|
|
233
|
+
console.log(" npm i -g open-agents-ai");
|
|
234
|
+
console.log("");
|
|
235
|
+
rl.close();
|
|
236
|
+
process.exit(0);
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
console.log(" scoop install failed, trying direct download...");
|
|
240
|
+
windowsDirectDownload(next);
|
|
241
|
+
});
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
// Option 5: direct MSI download via Node.js native https
|
|
246
|
+
windowsDirectDownload(next);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
function windowsDirectDownload(next) {
|
|
250
|
+
var msiArch = arch === "x64" ? "x64" : arch === "arm64" ? "arm64" : "x86";
|
|
251
|
+
var msiUrl = "https://nodejs.org/dist/v22.16.0/node-v22.16.0-" + msiArch + ".msi";
|
|
252
|
+
var msiDest = path.join(os.tmpdir(), "node-v22-installer.msi");
|
|
253
|
+
|
|
254
|
+
ask(" Download Node.js 22 installer directly? [Y/n] ", function(a) {
|
|
94
255
|
if (a === "n" || a === "no") {
|
|
95
|
-
|
|
96
|
-
"\n Install manually:\n" +
|
|
97
|
-
" sudo apt install curl (Debian/Ubuntu)\n" +
|
|
98
|
-
" sudo dnf install curl (Fedora)\n" +
|
|
99
|
-
" sudo pacman -S curl (Arch)\n"
|
|
100
|
-
);
|
|
256
|
+
windowsFallbackInstructions();
|
|
101
257
|
return;
|
|
102
258
|
}
|
|
103
259
|
console.log("");
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
ok = run("sudo -n dnf install -y curl 2>/dev/null || sudo dnf install -y curl");
|
|
109
|
-
} else if (hasCmd("pacman")) {
|
|
110
|
-
ok = run("sudo -n pacman -S --noconfirm curl 2>/dev/null || sudo pacman -S --noconfirm curl");
|
|
111
|
-
} else if (hasCmd("apk")) {
|
|
112
|
-
ok = run("apk add curl");
|
|
113
|
-
} else {
|
|
114
|
-
console.log(" No supported package manager found (tried apt, dnf, pacman, apk).");
|
|
115
|
-
}
|
|
260
|
+
console.log(" Downloading Node.js 22 from nodejs.org...");
|
|
261
|
+
console.log(" URL: " + msiUrl);
|
|
262
|
+
console.log(" (this may take a moment)");
|
|
263
|
+
console.log("");
|
|
116
264
|
|
|
117
|
-
|
|
265
|
+
downloadToFile(msiUrl, msiDest, function(err) {
|
|
266
|
+
if (err) {
|
|
267
|
+
console.log(" Download failed: " + (err.message || err));
|
|
268
|
+
console.log("");
|
|
269
|
+
windowsFallbackInstructions();
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
console.log(" Downloaded to: " + msiDest);
|
|
118
273
|
console.log("");
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
"
|
|
124
|
-
|
|
125
|
-
|
|
274
|
+
console.log(" Launching installer...");
|
|
275
|
+
var ok = run("msiexec /i \"" + msiDest + "\"");
|
|
276
|
+
if (ok) {
|
|
277
|
+
console.log("");
|
|
278
|
+
console.log(" Node.js 22 installer completed.");
|
|
279
|
+
console.log(" Close and reopen your terminal, then run:");
|
|
280
|
+
console.log(" npm i -g open-agents-ai");
|
|
281
|
+
console.log("");
|
|
282
|
+
} else {
|
|
283
|
+
console.log("");
|
|
284
|
+
console.log(" Installer may have been cancelled or requires admin privileges.");
|
|
285
|
+
console.log(" Run the installer manually:");
|
|
286
|
+
console.log(" " + msiDest);
|
|
287
|
+
console.log("");
|
|
288
|
+
console.log(" Then reopen your terminal and run:");
|
|
289
|
+
console.log(" npm i -g open-agents-ai");
|
|
290
|
+
console.log("");
|
|
291
|
+
}
|
|
292
|
+
rl.close();
|
|
293
|
+
process.exit(0);
|
|
294
|
+
});
|
|
126
295
|
});
|
|
127
296
|
}
|
|
128
297
|
|
|
129
|
-
function
|
|
298
|
+
function windowsFallbackInstructions() {
|
|
299
|
+
bail(
|
|
300
|
+
"\n Install Node.js 22 manually:\n\n" +
|
|
301
|
+
" Option 1 — Download from nodejs.org:\n" +
|
|
302
|
+
" https://nodejs.org/en/download/\n\n" +
|
|
303
|
+
" Option 2 — winget (Windows 10/11):\n" +
|
|
304
|
+
" winget install OpenJS.NodeJS.LTS\n\n" +
|
|
305
|
+
" Option 3 — Chocolatey:\n" +
|
|
306
|
+
" choco install nodejs-lts\n\n" +
|
|
307
|
+
" Option 4 — nvm-windows:\n" +
|
|
308
|
+
" https://github.com/coreybutler/nvm-windows/releases\n" +
|
|
309
|
+
" nvm install 22 && nvm use 22\n\n" +
|
|
310
|
+
" Then re-run: npm i -g open-agents-ai\n"
|
|
311
|
+
);
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
// ── Unix flow (Linux / macOS) ────────────────────────────────────────────
|
|
315
|
+
|
|
316
|
+
function unixInstallNvm(next) {
|
|
130
317
|
if (hasNvm) {
|
|
131
318
|
console.log(" nvm found at " + nvmDir);
|
|
132
319
|
console.log("");
|
|
133
320
|
next();
|
|
134
321
|
return;
|
|
135
322
|
}
|
|
323
|
+
|
|
136
324
|
ask(" nvm is not installed. Install nvm now? [Y/n] ", function(a) {
|
|
137
325
|
if (a === "n" || a === "no") {
|
|
138
326
|
bail(
|
|
139
327
|
"\n Install nvm manually:\n" +
|
|
140
328
|
" curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash\n" +
|
|
141
|
-
" # or: wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash\n" +
|
|
142
329
|
" source ~/.bashrc\n" +
|
|
143
330
|
" nvm install 22\n" +
|
|
144
331
|
" npm i -g open-agents-ai\n"
|
|
@@ -146,19 +333,46 @@ function doInstallNvm(dl, next) {
|
|
|
146
333
|
return;
|
|
147
334
|
}
|
|
148
335
|
console.log("");
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
336
|
+
|
|
337
|
+
// Try shell downloader first (curl/wget), fall back to Node.js native https
|
|
338
|
+
var dl = getShellDownloader();
|
|
339
|
+
if (dl) {
|
|
340
|
+
var ok = run(dl + " https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash");
|
|
341
|
+
if (ok) {
|
|
342
|
+
nvmDir = process.env.NVM_DIR || path.join(os.homedir(), ".nvm");
|
|
343
|
+
hasNvm = true;
|
|
344
|
+
console.log("");
|
|
345
|
+
next();
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
153
348
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
console.log("");
|
|
157
|
-
|
|
349
|
+
|
|
350
|
+
// Fallback: download nvm install script via Node.js https module
|
|
351
|
+
console.log(" Downloading nvm install script via Node.js...");
|
|
352
|
+
download("https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh", function(err, data) {
|
|
353
|
+
if (err) {
|
|
354
|
+
bail("\n Could not download nvm install script: " + (err.message || err) +
|
|
355
|
+
"\n Install nvm manually: https://github.com/nvm-sh/nvm#installing-and-updating\n");
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
var scriptPath = path.join(os.tmpdir(), "nvm-install.sh");
|
|
359
|
+
fs.writeFileSync(scriptPath, data, { mode: 0o755 });
|
|
360
|
+
var shell = getShell();
|
|
361
|
+
var ok = run(shell + " " + scriptPath);
|
|
362
|
+
try { fs.unlinkSync(scriptPath); } catch (e) {}
|
|
363
|
+
if (!ok) {
|
|
364
|
+
bail("\n nvm install failed. See https://github.com/nvm-sh/nvm#installing-and-updating\n");
|
|
365
|
+
return;
|
|
366
|
+
}
|
|
367
|
+
nvmDir = process.env.NVM_DIR || path.join(os.homedir(), ".nvm");
|
|
368
|
+
hasNvm = true;
|
|
369
|
+
console.log("");
|
|
370
|
+
next();
|
|
371
|
+
});
|
|
158
372
|
});
|
|
159
373
|
}
|
|
160
374
|
|
|
161
|
-
function
|
|
375
|
+
function unixInstallNode(next) {
|
|
162
376
|
ask(" Install Node.js 22 via nvm? [Y/n] ", function(a) {
|
|
163
377
|
if (a === "n" || a === "no") {
|
|
164
378
|
bail(
|
|
@@ -169,7 +383,7 @@ function doInstallNode(next) {
|
|
|
169
383
|
return;
|
|
170
384
|
}
|
|
171
385
|
console.log("");
|
|
172
|
-
var shell =
|
|
386
|
+
var shell = getShell();
|
|
173
387
|
var cmd = 'export NVM_DIR="' + nvmDir + '" && ' +
|
|
174
388
|
'[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" && ' +
|
|
175
389
|
"nvm install 22 && nvm alias default 22";
|
|
@@ -183,7 +397,7 @@ function doInstallNode(next) {
|
|
|
183
397
|
});
|
|
184
398
|
}
|
|
185
399
|
|
|
186
|
-
// Find the Node 22 binary installed by nvm
|
|
400
|
+
// Find the Node 22 binary installed by nvm (Unix only)
|
|
187
401
|
function findNode22Bin() {
|
|
188
402
|
var versionsDir = path.join(nvmDir, "versions", "node");
|
|
189
403
|
try {
|
|
@@ -196,7 +410,7 @@ function findNode22Bin() {
|
|
|
196
410
|
}
|
|
197
411
|
} catch (e) {}
|
|
198
412
|
try {
|
|
199
|
-
var shell =
|
|
413
|
+
var shell = getShell();
|
|
200
414
|
var result = childProcess.execSync(
|
|
201
415
|
shell + ' -c \'export NVM_DIR="' + nvmDir + '" && [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" && nvm which 22\'',
|
|
202
416
|
{ encoding: "utf8", stdio: ["pipe", "pipe", "pipe"], timeout: 10000 }
|
|
@@ -206,7 +420,7 @@ function findNode22Bin() {
|
|
|
206
420
|
return null;
|
|
207
421
|
}
|
|
208
422
|
|
|
209
|
-
function
|
|
423
|
+
function unixReinstall() {
|
|
210
424
|
ask(" Reinstall open-agents under Node 22? [Y/n] ", function(a) {
|
|
211
425
|
if (a === "n" || a === "no") {
|
|
212
426
|
console.log(
|
|
@@ -218,7 +432,7 @@ function doReinstall() {
|
|
|
218
432
|
return;
|
|
219
433
|
}
|
|
220
434
|
console.log("");
|
|
221
|
-
var shell =
|
|
435
|
+
var shell = getShell();
|
|
222
436
|
var cmd = 'export OA_SELF_UPGRADE=1 && export NVM_DIR="' + nvmDir + '" && ' +
|
|
223
437
|
'[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" && ' +
|
|
224
438
|
"nvm use 22 && npm i -g open-agents-ai";
|
|
@@ -234,12 +448,12 @@ function doReinstall() {
|
|
|
234
448
|
}
|
|
235
449
|
console.log("");
|
|
236
450
|
|
|
237
|
-
// Tell the user exactly how to launch
|
|
451
|
+
// Tell the user exactly how to launch
|
|
238
452
|
var node22 = findNode22Bin();
|
|
239
453
|
var binHint = node22 ? path.dirname(node22) : "~/.nvm/versions/node/v22.x.x/bin";
|
|
240
|
-
console.log("
|
|
241
|
-
console.log("
|
|
242
|
-
console.log("
|
|
454
|
+
console.log(" +---------------------------------------------------+");
|
|
455
|
+
console.log(" | Done! Node 22 installed + open-agents ready. |");
|
|
456
|
+
console.log(" +---------------------------------------------------+");
|
|
243
457
|
console.log("");
|
|
244
458
|
console.log(" To launch immediately (no new terminal needed):");
|
|
245
459
|
console.log(" " + binHint + "/oa");
|
|
@@ -253,27 +467,42 @@ function doReinstall() {
|
|
|
253
467
|
});
|
|
254
468
|
}
|
|
255
469
|
|
|
256
|
-
//
|
|
470
|
+
// ── Main flow — branch on platform ───────────────────────────────────────
|
|
471
|
+
|
|
257
472
|
ask(" Install Node.js 22 now? [Y/n] ", function(a) {
|
|
258
473
|
if (a === "n" || a === "no") {
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
474
|
+
if (isWindows) {
|
|
475
|
+
windowsFallbackInstructions();
|
|
476
|
+
} else {
|
|
477
|
+
bail(
|
|
478
|
+
"\n To install manually:\n" +
|
|
479
|
+
" curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash\n" +
|
|
480
|
+
" source ~/.bashrc\n" +
|
|
481
|
+
" nvm install 22\n" +
|
|
482
|
+
" nvm alias default 22\n" +
|
|
483
|
+
" npm i -g open-agents-ai\n"
|
|
484
|
+
);
|
|
485
|
+
}
|
|
268
486
|
return;
|
|
269
487
|
}
|
|
270
488
|
console.log("");
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
489
|
+
|
|
490
|
+
if (isWindows) {
|
|
491
|
+
windowsInstallNode(function() {
|
|
492
|
+
console.log("");
|
|
493
|
+
console.log(" Node.js 22 should now be available.");
|
|
494
|
+
console.log(" Close and reopen your terminal, then run:");
|
|
495
|
+
console.log(" npm i -g open-agents-ai");
|
|
496
|
+
console.log("");
|
|
497
|
+
rl.close();
|
|
498
|
+
process.exit(0);
|
|
499
|
+
});
|
|
500
|
+
} else {
|
|
501
|
+
// Unix flow: ensure downloader -> nvm -> node 22 -> reinstall
|
|
502
|
+
unixInstallNvm(function() {
|
|
503
|
+
unixInstallNode(function() {
|
|
504
|
+
unixReinstall();
|
|
276
505
|
});
|
|
277
506
|
});
|
|
278
|
-
}
|
|
507
|
+
}
|
|
279
508
|
});
|
package/package.json
CHANGED