@openagents-org/agent-connector 0.1.8 → 0.1.9
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 +22 -15
package/package.json
CHANGED
package/src/daemon.js
CHANGED
|
@@ -550,10 +550,25 @@ class Daemon {
|
|
|
550
550
|
this._sessionContextSent.add(contextKey);
|
|
551
551
|
}
|
|
552
552
|
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
553
|
+
// Write message to temp file to avoid cmd.exe argument length limits
|
|
554
|
+
const msgFile = path.join(this.config.configDir, `msg-${Date.now()}.tmp`);
|
|
555
|
+
fs.writeFileSync(msgFile, fullMessage, 'utf-8');
|
|
556
|
+
|
|
557
|
+
// Use a small node wrapper to read the message file and exec openclaw
|
|
558
|
+
// This avoids all cmd.exe quoting/length issues
|
|
559
|
+
const wrapperCode = [
|
|
560
|
+
`const msg = require("fs").readFileSync(${JSON.stringify(msgFile)}, "utf-8");`,
|
|
561
|
+
`const cp = require("child_process");`,
|
|
562
|
+
`const args = ${JSON.stringify(['agent', '--local', '--agent', agentId, '--session-id', sessionKey, '--json'])};`,
|
|
563
|
+
`args.push("--message", msg);`,
|
|
564
|
+
`const r = cp.spawnSync(${JSON.stringify(binary)}, args, { stdio: ["ignore", "pipe", "pipe"], env: process.env, shell: true, timeout: 600000 });`,
|
|
565
|
+
`try { require("fs").unlinkSync(${JSON.stringify(msgFile)}); } catch {}`,
|
|
566
|
+
`if (r.stdout) process.stdout.write(r.stdout);`,
|
|
567
|
+
`if (r.stderr) process.stderr.write(r.stderr);`,
|
|
568
|
+
`process.exit(r.status || 0);`,
|
|
569
|
+
].join('\n');
|
|
570
|
+
|
|
571
|
+
this._log(`${agentCfg.name} CLI: ${binary} agent --local --agent ${agentId} ... (via wrapper, msg ${fullMessage.length} chars)`);
|
|
557
572
|
|
|
558
573
|
const spawnEnv = { ...env };
|
|
559
574
|
if (IS_WINDOWS) {
|
|
@@ -563,22 +578,14 @@ class Daemon {
|
|
|
563
578
|
}
|
|
564
579
|
}
|
|
565
580
|
|
|
566
|
-
|
|
567
|
-
|
|
581
|
+
const spawnBinary = process.execPath; // node
|
|
582
|
+
const spawnArgs = ['-e', wrapperCode];
|
|
568
583
|
const spawnOpts = {
|
|
569
584
|
stdio: ['ignore', 'pipe', 'pipe'],
|
|
570
585
|
env: spawnEnv,
|
|
571
|
-
timeout:
|
|
586
|
+
timeout: 620000,
|
|
572
587
|
};
|
|
573
588
|
|
|
574
|
-
if (IS_WINDOWS) {
|
|
575
|
-
// Resolve .cmd shim to actual node script to avoid cmd.exe
|
|
576
|
-
// argument mangling and length limits
|
|
577
|
-
const resolved = this._resolveWindowsBinary(binary, spawnEnv);
|
|
578
|
-
spawnBinary = resolved.binary;
|
|
579
|
-
spawnArgs = [...resolved.prefix, ...args];
|
|
580
|
-
}
|
|
581
|
-
|
|
582
589
|
const proc = spawn(spawnBinary, spawnArgs, spawnOpts);
|
|
583
590
|
let stdout = '';
|
|
584
591
|
let stderr = '';
|