open-agents-ai 0.22.0 → 0.22.2

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/launcher.cjs CHANGED
@@ -1,21 +1,118 @@
1
1
  #!/usr/bin/env node
2
2
  // Node version gate — uses only ES5 syntax so it parses on any Node version.
3
- // Gives a clear error instead of a cryptic "SyntaxError: Unexpected token ??"
3
+ // On old Node: offers to install Node 20 via nvm with y/n prompts.
4
4
  var nodeVersion = parseInt(process.versions.node, 10);
5
+
5
6
  if (nodeVersion < 18) {
6
- console.error(
7
- "\n open-agents requires Node.js >= 18 (you have " + process.version + ")\n\n" +
8
- " Install Node 20 via nvm:\n" +
9
- " curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash\n" +
10
- " source ~/.bashrc\n" +
11
- " nvm install 20\n" +
12
- " nvm use 20\n" +
13
- " npm i -g open-agents-ai\n"
7
+ var os = require("os");
8
+ var path = require("path");
9
+ var childProcess = require("child_process");
10
+ var readline = require("readline");
11
+
12
+ var platform = os.platform();
13
+ var arch = os.arch();
14
+
15
+ console.log(
16
+ "\n open-agents requires Node.js >= 18 (you have " + process.version + ")" +
17
+ "\n Platform: " + platform + "/" + arch + "\n"
14
18
  );
15
- process.exit(1);
19
+
20
+ // Check if nvm is already installed
21
+ var nvmDir = process.env.NVM_DIR || path.join(os.homedir(), ".nvm");
22
+ var hasNvm = false;
23
+ try {
24
+ require("fs").statSync(path.join(nvmDir, "nvm.sh"));
25
+ hasNvm = true;
26
+ } catch (e) {}
27
+
28
+ var rl = readline.createInterface({ input: process.stdin, output: process.stdout });
29
+
30
+ function ask(question, cb) {
31
+ rl.question(question, function(answer) {
32
+ cb(answer.trim().toLowerCase());
33
+ });
34
+ }
35
+
36
+ function run(cmd, opts) {
37
+ console.log(" $ " + cmd);
38
+ try {
39
+ childProcess.execSync(cmd, Object.assign({ stdio: "inherit" }, opts || {}));
40
+ return true;
41
+ } catch (e) {
42
+ console.error(" Command failed: " + (e.message || e));
43
+ return false;
44
+ }
45
+ }
46
+
47
+ function installNode() {
48
+ if (!hasNvm) {
49
+ console.log("\n nvm not found. Installing nvm first...\n");
50
+ var ok = run("curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash");
51
+ if (!ok) {
52
+ console.error("\n nvm install failed. Install manually:");
53
+ console.error(" https://github.com/nvm-sh/nvm#installing-and-updating\n");
54
+ rl.close();
55
+ process.exit(1);
56
+ }
57
+ // Re-source nvm for this session
58
+ nvmDir = process.env.NVM_DIR || path.join(os.homedir(), ".nvm");
59
+ } else {
60
+ console.log("\n nvm found at " + nvmDir + "\n");
61
+ }
62
+
63
+ // nvm is a shell function, so we run through bash
64
+ var shell = process.env.SHELL || "/bin/bash";
65
+ var nvmCmd = 'export NVM_DIR="' + nvmDir + '" && ' +
66
+ '[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" && ' +
67
+ "nvm install 20 && nvm use 20 && nvm alias default 20";
68
+
69
+ console.log(" Installing Node.js 20...\n");
70
+ var ok = run(shell + ' -c \'' + nvmCmd + "'");
71
+ if (!ok) {
72
+ console.error("\n Node 20 install failed.\n");
73
+ rl.close();
74
+ process.exit(1);
75
+ }
76
+
77
+ // Now reinstall open-agents under the new Node
78
+ console.log("\n Node 20 installed. Reinstalling open-agents...\n");
79
+ var reinstallCmd = 'export NVM_DIR="' + nvmDir + '" && ' +
80
+ '[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" && ' +
81
+ "npm i -g open-agents-ai";
82
+ var ok2 = run(shell + ' -c \'' + reinstallCmd + "'");
83
+ if (!ok2) {
84
+ console.error("\n Reinstall failed. After opening a new terminal, run:");
85
+ console.error(" npm i -g open-agents-ai\n");
86
+ rl.close();
87
+ process.exit(1);
88
+ }
89
+
90
+ console.log(
91
+ "\n Done! Open a new terminal (or run: source ~/.bashrc) then run:" +
92
+ "\n oa\n"
93
+ );
94
+ rl.close();
95
+ process.exit(0);
96
+ }
97
+
98
+ ask(" Install Node.js 20 now? [Y/n] ", function(answer) {
99
+ if (answer === "n" || answer === "no") {
100
+ console.log(
101
+ "\n To install manually:\n" +
102
+ " curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash\n" +
103
+ " source ~/.bashrc\n" +
104
+ " nvm install 20\n" +
105
+ " npm i -g open-agents-ai\n"
106
+ );
107
+ rl.close();
108
+ process.exit(1);
109
+ }
110
+ installNode();
111
+ });
112
+ } else {
113
+ // Node >= 18 — load the ESM bundle
114
+ import("./index.js").catch(function(err) {
115
+ console.error("Failed to load open-agents:", err.message || err);
116
+ process.exit(1);
117
+ });
16
118
  }
17
- // Dynamic import works in Node 12+ and loads the ESM bundle
18
- import("./index.js").catch(function(err) {
19
- console.error("Failed to load open-agents:", err.message || err);
20
- process.exit(1);
21
- });
@@ -0,0 +1,173 @@
1
+ #!/usr/bin/env node
2
+ // preinstall hook — runs BEFORE npm installs dependencies.
3
+ // Pure ES5 so it works on any Node version. If Node is too old,
4
+ // walks the user through installing Node 20 via nvm, then re-runs
5
+ // npm i -g open-agents-ai under the new Node and exits.
6
+ var nodeVersion = parseInt(process.versions.node, 10);
7
+
8
+ if (nodeVersion >= 18) {
9
+ // Good to go — let npm continue installing deps normally
10
+ process.exit(0);
11
+ }
12
+
13
+ var os = require("os");
14
+ var path = require("path");
15
+ var fs = require("fs");
16
+ var childProcess = require("child_process");
17
+ var readline = require("readline");
18
+
19
+ var platform = os.platform();
20
+ var arch = os.arch();
21
+
22
+ console.log("");
23
+ console.log(" ┌─────────────────────────────────────────────────┐");
24
+ console.log(" │ open-agents — Node.js Check │");
25
+ console.log(" └─────────────────────────────────────────────────┘");
26
+ console.log("");
27
+ console.log(" Your Node.js: " + process.version);
28
+ console.log(" Required: >= 18.0.0");
29
+ console.log(" Platform: " + platform + "/" + arch);
30
+ console.log("");
31
+
32
+ // Detect if nvm is already installed
33
+ var nvmDir = process.env.NVM_DIR || path.join(os.homedir(), ".nvm");
34
+ var hasNvm = false;
35
+ try { fs.statSync(path.join(nvmDir, "nvm.sh")); hasNvm = true; } catch (e) {}
36
+
37
+ var rl = readline.createInterface({ input: process.stdin, output: process.stdout });
38
+
39
+ function ask(question, cb) {
40
+ rl.question(question, function(answer) {
41
+ cb(answer.trim().toLowerCase());
42
+ });
43
+ }
44
+
45
+ function run(cmd, opts) {
46
+ console.log(" $ " + cmd);
47
+ try {
48
+ childProcess.execSync(cmd, Object.assign({ stdio: "inherit" }, opts || {}));
49
+ return true;
50
+ } catch (e) {
51
+ return false;
52
+ }
53
+ }
54
+
55
+ function bail(msg) {
56
+ console.log(msg);
57
+ rl.close();
58
+ process.exit(1);
59
+ }
60
+
61
+ function doInstallNvm(next) {
62
+ if (hasNvm) {
63
+ console.log(" nvm found at " + nvmDir);
64
+ console.log("");
65
+ next();
66
+ return;
67
+ }
68
+ ask(" nvm is not installed. Install nvm now? [Y/n] ", function(a) {
69
+ if (a === "n" || a === "no") {
70
+ bail(
71
+ "\n Install nvm manually:\n" +
72
+ " curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash\n" +
73
+ " source ~/.bashrc\n" +
74
+ " nvm install 20\n" +
75
+ " npm i -g open-agents-ai\n"
76
+ );
77
+ return;
78
+ }
79
+ console.log("");
80
+ var ok = run("curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash");
81
+ if (!ok) {
82
+ bail("\n nvm install failed. See https://github.com/nvm-sh/nvm#installing-and-updating\n");
83
+ return;
84
+ }
85
+ nvmDir = process.env.NVM_DIR || path.join(os.homedir(), ".nvm");
86
+ hasNvm = true;
87
+ console.log("");
88
+ next();
89
+ });
90
+ }
91
+
92
+ function doInstallNode(next) {
93
+ ask(" Install Node.js 20 via nvm? [Y/n] ", function(a) {
94
+ if (a === "n" || a === "no") {
95
+ bail(
96
+ "\n Install manually:\n" +
97
+ " nvm install 20 && nvm alias default 20\n" +
98
+ " npm i -g open-agents-ai\n"
99
+ );
100
+ return;
101
+ }
102
+ console.log("");
103
+ var shell = process.env.SHELL || "/bin/bash";
104
+ var cmd = 'export NVM_DIR="' + nvmDir + '" && ' +
105
+ '[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" && ' +
106
+ "nvm install 20 && nvm alias default 20";
107
+ var ok = run(shell + " -c '" + cmd + "'");
108
+ if (!ok) {
109
+ bail("\n Node 20 install failed.\n");
110
+ return;
111
+ }
112
+ console.log("");
113
+ next();
114
+ });
115
+ }
116
+
117
+ function doReinstall() {
118
+ ask(" Reinstall open-agents under Node 20? [Y/n] ", function(a) {
119
+ if (a === "n" || a === "no") {
120
+ console.log(
121
+ "\n Open a new terminal, then run:\n" +
122
+ " npm i -g open-agents-ai\n"
123
+ );
124
+ rl.close();
125
+ process.exit(1);
126
+ return;
127
+ }
128
+ console.log("");
129
+ var shell = process.env.SHELL || "/bin/bash";
130
+ var cmd = 'export NVM_DIR="' + nvmDir + '" && ' +
131
+ '[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" && ' +
132
+ "nvm use 20 && npm i -g open-agents-ai";
133
+ var ok = run(shell + " -c '" + cmd + "'");
134
+ if (!ok) {
135
+ console.log(
136
+ "\n Reinstall failed. Open a new terminal, then run:\n" +
137
+ " npm i -g open-agents-ai\n"
138
+ );
139
+ rl.close();
140
+ process.exit(1);
141
+ return;
142
+ }
143
+ console.log("");
144
+ console.log(" ┌─────────────────────────────────────────────────┐");
145
+ console.log(" │ Done! Open a new terminal, then run: oa │");
146
+ console.log(" └─────────────────────────────────────────────────┘");
147
+ console.log("");
148
+ rl.close();
149
+ // Exit 1 to stop the OLD npm from continuing to install broken deps
150
+ process.exit(1);
151
+ });
152
+ }
153
+
154
+ // Walk through the steps
155
+ ask(" Install Node.js 20 now? [Y/n] ", function(a) {
156
+ if (a === "n" || a === "no") {
157
+ bail(
158
+ "\n To install manually:\n" +
159
+ " curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash\n" +
160
+ " source ~/.bashrc\n" +
161
+ " nvm install 20\n" +
162
+ " nvm alias default 20\n" +
163
+ " npm i -g open-agents-ai\n"
164
+ );
165
+ return;
166
+ }
167
+ console.log("");
168
+ doInstallNvm(function() {
169
+ doInstallNode(function() {
170
+ doReinstall();
171
+ });
172
+ });
173
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "open-agents-ai",
3
- "version": "0.22.0",
3
+ "version": "0.22.2",
4
4
  "description": "AI coding agent powered by open-source models (Ollama/vLLM) — interactive TUI with agentic tool-calling loop",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -40,6 +40,9 @@
40
40
  "bugs": {
41
41
  "url": "https://github.com/robit-man/open-agents/issues"
42
42
  },
43
+ "scripts": {
44
+ "preinstall": "node dist/preinstall.cjs"
45
+ },
43
46
  "engines": {
44
47
  "node": ">=18.0.0"
45
48
  },