@openagents-org/agent-connector 0.1.1 → 0.1.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/package.json +1 -1
- package/src/daemon.js +21 -7
package/package.json
CHANGED
package/src/daemon.js
CHANGED
|
@@ -481,20 +481,34 @@ class Daemon {
|
|
|
481
481
|
|
|
482
482
|
this._log(`${agentCfg.name} CLI: ${binary} ${args.slice(0, 5).join(' ')} ...`);
|
|
483
483
|
|
|
484
|
+
const spawnEnv = { ...env };
|
|
485
|
+
if (IS_WINDOWS) {
|
|
486
|
+
const npmBin = path.join(process.env.APPDATA || '', 'npm');
|
|
487
|
+
if (npmBin && !(spawnEnv.PATH || '').includes(npmBin)) {
|
|
488
|
+
spawnEnv.PATH = npmBin + ';' + (spawnEnv.PATH || process.env.PATH || '');
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
// On Windows, .cmd shims need shell:true but that breaks argument
|
|
493
|
+
// quoting. Use execFileSync-style approach: resolve the .cmd to its
|
|
494
|
+
// target and run directly, or use spawn without shell and full path.
|
|
495
|
+
let spawnBinary = binary;
|
|
496
|
+
let spawnArgs = args;
|
|
484
497
|
const spawnOpts = {
|
|
485
498
|
stdio: ['ignore', 'pipe', 'pipe'],
|
|
486
|
-
env,
|
|
499
|
+
env: spawnEnv,
|
|
487
500
|
timeout: 600000,
|
|
488
501
|
};
|
|
502
|
+
|
|
489
503
|
if (IS_WINDOWS) {
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
504
|
+
// Find the actual .cmd shim and invoke via cmd.exe /C with proper quoting
|
|
505
|
+
spawnBinary = process.env.COMSPEC || 'cmd.exe';
|
|
506
|
+
// Wrap argument containing spaces in double quotes for cmd.exe
|
|
507
|
+
const quotedArgs = args.map((a) => a.includes(' ') ? `"${a}"` : a);
|
|
508
|
+
spawnArgs = ['/C', binary, ...quotedArgs];
|
|
495
509
|
}
|
|
496
510
|
|
|
497
|
-
const proc = spawn(
|
|
511
|
+
const proc = spawn(spawnBinary, spawnArgs, spawnOpts);
|
|
498
512
|
let stdout = '';
|
|
499
513
|
let stderr = '';
|
|
500
514
|
|