open-agents-ai 0.22.1 → 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.
Files changed (2) hide show
  1. package/dist/preinstall.cjs +173 -0
  2. package/package.json +4 -1
@@ -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.1",
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
  },