@openagents-org/agent-launcher 0.2.66 → 0.2.67
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/claude.js +59 -28
package/package.json
CHANGED
package/src/adapters/claude.js
CHANGED
|
@@ -105,6 +105,51 @@ class ClaudeAdapter extends BaseAdapter {
|
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
+
/**
|
|
109
|
+
* Find the portable Node.js binary.
|
|
110
|
+
*/
|
|
111
|
+
_findNodeBin() {
|
|
112
|
+
const home = os.homedir();
|
|
113
|
+
const candidates = IS_WINDOWS
|
|
114
|
+
? [path.join(home, '.openagents', 'nodejs', 'node.exe')]
|
|
115
|
+
: [path.join(home, '.openagents', 'nodejs', 'bin', 'node'),
|
|
116
|
+
path.join(home, '.openagents', 'nodejs', 'node')];
|
|
117
|
+
for (const c of candidates) {
|
|
118
|
+
if (fs.existsSync(c)) return c;
|
|
119
|
+
}
|
|
120
|
+
return 'node';
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Resolve a binary shim/symlink to [nodeBin, jsEntryPoint].
|
|
125
|
+
* On Windows: parses .cmd shim to extract the JS path.
|
|
126
|
+
* On macOS/Linux: follows symlink to the actual .js file.
|
|
127
|
+
* Returns [nodeBin, jsPath] or null if resolution fails.
|
|
128
|
+
*/
|
|
129
|
+
_resolveToNodeCmd(binPath) {
|
|
130
|
+
const nodeBin = this._findNodeBin();
|
|
131
|
+
if (IS_WINDOWS && binPath.toLowerCase().endsWith('.cmd')) {
|
|
132
|
+
const cmdDir = path.dirname(path.resolve(binPath));
|
|
133
|
+
const cmdContent = fs.readFileSync(binPath, 'utf-8');
|
|
134
|
+
const jsMatch = cmdContent.match(/%dp0%\\([^\s"*?]+\.js)/i);
|
|
135
|
+
if (jsMatch) {
|
|
136
|
+
return [nodeBin, path.resolve(cmdDir, jsMatch[1])];
|
|
137
|
+
}
|
|
138
|
+
} else {
|
|
139
|
+
// Unix: symlink → resolve to actual .js file
|
|
140
|
+
try {
|
|
141
|
+
let target = binPath;
|
|
142
|
+
if (fs.lstatSync(binPath).isSymbolicLink()) {
|
|
143
|
+
target = path.resolve(path.dirname(binPath), fs.readlinkSync(binPath));
|
|
144
|
+
}
|
|
145
|
+
if (target.endsWith('.js') || target.endsWith('.mjs')) {
|
|
146
|
+
return [nodeBin, target];
|
|
147
|
+
}
|
|
148
|
+
} catch {}
|
|
149
|
+
}
|
|
150
|
+
return null;
|
|
151
|
+
}
|
|
152
|
+
|
|
108
153
|
_findClaudeBinary() {
|
|
109
154
|
const home = os.homedir();
|
|
110
155
|
|
|
@@ -268,20 +313,14 @@ class ClaudeAdapter extends BaseAdapter {
|
|
|
268
313
|
this._log('Could not find openagents binary — MCP tools may not be available');
|
|
269
314
|
}
|
|
270
315
|
|
|
271
|
-
//
|
|
272
|
-
//
|
|
316
|
+
// Resolve shim/symlink to node + JS entry point for MCP server
|
|
317
|
+
// (.cmd shims and #!/usr/bin/env node shebangs both fail as MCP commands)
|
|
273
318
|
let mcpCommand = oaBin;
|
|
274
319
|
let mcpFinalArgs = mcpArgs;
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
const cmdDir = path.dirname(path.resolve(oaBin));
|
|
280
|
-
const jsPath = path.resolve(cmdDir, jsMatch[1]);
|
|
281
|
-
const nodeExe = path.join(os.homedir(), '.openagents', 'nodejs', 'node.exe');
|
|
282
|
-
mcpCommand = fs.existsSync(nodeExe) ? nodeExe : 'node';
|
|
283
|
-
mcpFinalArgs = [jsPath, ...mcpArgs];
|
|
284
|
-
}
|
|
320
|
+
const mcpResolved = this._resolveToNodeCmd(oaBin);
|
|
321
|
+
if (mcpResolved) {
|
|
322
|
+
mcpCommand = mcpResolved[0];
|
|
323
|
+
mcpFinalArgs = [mcpResolved[1], ...mcpArgs];
|
|
285
324
|
}
|
|
286
325
|
|
|
287
326
|
const mcpConfig = {
|
|
@@ -365,22 +404,14 @@ class ClaudeAdapter extends BaseAdapter {
|
|
|
365
404
|
delete cleanEnv.CLAUDE_CODE_SESSION;
|
|
366
405
|
|
|
367
406
|
try {
|
|
368
|
-
//
|
|
369
|
-
//
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
if (jsMatch) {
|
|
377
|
-
const jsPath = path.resolve(cmdDir, jsMatch[1]);
|
|
378
|
-
const nodeExe = path.join(os.homedir(), '.openagents', 'nodejs', 'node.exe');
|
|
379
|
-
const nodeBin = fs.existsSync(nodeExe) ? nodeExe : 'node';
|
|
380
|
-
cmd = [nodeBin, jsPath, ...cmd.slice(1)];
|
|
381
|
-
} else {
|
|
382
|
-
cmd = ['cmd.exe', '/c', ...cmd];
|
|
383
|
-
}
|
|
407
|
+
// Always resolve shim/symlink to node + JS entry point.
|
|
408
|
+
// On Windows: .cmd shims need cmd.exe which creates visible windows.
|
|
409
|
+
// On macOS/Linux: #!/usr/bin/env node fails when node isn't on system PATH.
|
|
410
|
+
const resolved = this._resolveToNodeCmd(cmd[0]);
|
|
411
|
+
if (resolved) {
|
|
412
|
+
cmd = [resolved[0], resolved[1], ...cmd.slice(1)];
|
|
413
|
+
} else if (IS_WINDOWS && cmd[0].toLowerCase().endsWith('.cmd')) {
|
|
414
|
+
cmd = ['cmd.exe', '/c', ...cmd];
|
|
384
415
|
}
|
|
385
416
|
|
|
386
417
|
const proc = spawn(cmd[0], cmd.slice(1), {
|