@openagents-org/agent-launcher 0.2.51 → 0.2.53
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/package.json +1 -1
- package/src/adapters/openclaw.js +23 -37
- package/src/installer.js +10 -1
package/package.json
CHANGED
package/src/adapters/openclaw.js
CHANGED
|
@@ -55,33 +55,19 @@ class OpenClawAdapter extends BaseAdapter {
|
|
|
55
55
|
// ------------------------------------------------------------------
|
|
56
56
|
|
|
57
57
|
_findOpenclawBinary() {
|
|
58
|
+
// We know exactly where openclaw is — installed via --prefix ~/.openagents/nodejs
|
|
59
|
+
const home = process.env.USERPROFILE || process.env.HOME || '';
|
|
60
|
+
const portableDir = path.join(home, '.openagents', 'nodejs');
|
|
61
|
+
const mjs = path.join(portableDir, 'node_modules', 'openclaw', 'openclaw.mjs');
|
|
62
|
+
if (fs.existsSync(mjs)) return mjs;
|
|
63
|
+
|
|
64
|
+
// Fallback: check if openclaw is on PATH (system install)
|
|
58
65
|
try {
|
|
59
66
|
const cmd = IS_WINDOWS ? 'where openclaw' : 'which openclaw';
|
|
60
|
-
const {
|
|
61
|
-
const result = execSync(cmd, { encoding: 'utf-8', timeout: 5000, env: getEnhancedEnv() })
|
|
67
|
+
const result = execSync(cmd, { encoding: 'utf-8', timeout: 5000, stdio: ['pipe', 'pipe', 'pipe'] })
|
|
62
68
|
.split(/\r?\n/)[0].trim();
|
|
63
69
|
if (result) return result;
|
|
64
70
|
} catch {}
|
|
65
|
-
|
|
66
|
-
// Check common npm global directories
|
|
67
|
-
const dirs = [];
|
|
68
|
-
const home = process.env.USERPROFILE || process.env.HOME || '';
|
|
69
|
-
// --prefix installs put .bin shims in node_modules/.bin/
|
|
70
|
-
if (home) dirs.push(path.join(home, '.openagents', 'nodejs', 'node_modules', '.bin'));
|
|
71
|
-
if (IS_WINDOWS) {
|
|
72
|
-
if (home) dirs.push(path.join(home, '.openagents', 'nodejs'));
|
|
73
|
-
const appdata = process.env.APPDATA || '';
|
|
74
|
-
if (appdata) dirs.push(path.join(appdata, 'npm'));
|
|
75
|
-
} else {
|
|
76
|
-
if (home) dirs.push(path.join(home, '.openagents', 'nodejs', 'bin'));
|
|
77
|
-
dirs.push('/usr/local/bin');
|
|
78
|
-
}
|
|
79
|
-
for (const d of dirs) {
|
|
80
|
-
for (const name of ['openclaw.cmd', 'openclaw']) {
|
|
81
|
-
const candidate = path.join(d, name);
|
|
82
|
-
if (fs.existsSync(candidate)) return candidate;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
71
|
return null;
|
|
86
72
|
}
|
|
87
73
|
|
|
@@ -245,21 +231,21 @@ class OpenClawAdapter extends BaseAdapter {
|
|
|
245
231
|
const stderrFd = fs.openSync(stderrFile, 'w');
|
|
246
232
|
this._log('Spawn: stderr → ' + stderrFile);
|
|
247
233
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
234
|
+
// Always spawn node + openclaw.mjs directly (no shims, no cmd.exe, cross-platform)
|
|
235
|
+
const portableDir = path.join(os.homedir(), '.openagents', 'nodejs');
|
|
236
|
+
const nodeBin = IS_WINDOWS
|
|
237
|
+
? path.join(portableDir, 'node.exe')
|
|
238
|
+
: path.join(portableDir, 'bin', 'node');
|
|
239
|
+
const openclawMjs = path.join(portableDir, 'node_modules', 'openclaw', 'openclaw.mjs');
|
|
240
|
+
|
|
241
|
+
let spawnBin, spawnArgs;
|
|
242
|
+
if (fs.existsSync(nodeBin) && fs.existsSync(openclawMjs)) {
|
|
243
|
+
spawnBin = nodeBin;
|
|
244
|
+
spawnArgs = [openclawMjs, ...args];
|
|
245
|
+
} else {
|
|
246
|
+
// Fallback: try the binary path directly (system install)
|
|
247
|
+
spawnBin = binary;
|
|
248
|
+
spawnArgs = args;
|
|
263
249
|
}
|
|
264
250
|
const proc = spawn(spawnBin, spawnArgs, {
|
|
265
251
|
stdio: ['ignore', 'pipe', stderrFd],
|
package/src/installer.js
CHANGED
|
@@ -39,7 +39,16 @@ class Installer {
|
|
|
39
39
|
// Fast check: marker file
|
|
40
40
|
if (this._hasMarker(agentType)) return true;
|
|
41
41
|
|
|
42
|
-
//
|
|
42
|
+
// Definitive check: does the package exist in our node_modules?
|
|
43
|
+
const portableDir = path.join(os.homedir(), '.openagents', 'nodejs');
|
|
44
|
+
const globalModules = path.join(portableDir, 'node_modules');
|
|
45
|
+
const entry = this.registry.getEntry(agentType);
|
|
46
|
+
const npmPkg = entry && entry.install ? entry.install.npm_package : null;
|
|
47
|
+
const binary = entry && entry.install ? entry.install.binary : agentType;
|
|
48
|
+
const pkgDir = path.join(globalModules, npmPkg || binary);
|
|
49
|
+
if (fs.existsSync(path.join(pkgDir, 'package.json'))) return true;
|
|
50
|
+
|
|
51
|
+
// Fallback: check if binary exists on PATH (system install)
|
|
43
52
|
const binaryPath = this._whichBinary(agentType);
|
|
44
53
|
if (!binaryPath) return false;
|
|
45
54
|
|