@openagents-org/agent-connector 0.1.9 → 0.1.10
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 +12 -1
package/package.json
CHANGED
package/src/daemon.js
CHANGED
|
@@ -559,9 +559,20 @@ class Daemon {
|
|
|
559
559
|
const wrapperCode = [
|
|
560
560
|
`const msg = require("fs").readFileSync(${JSON.stringify(msgFile)}, "utf-8");`,
|
|
561
561
|
`const cp = require("child_process");`,
|
|
562
|
+
`const path = require("path");`,
|
|
562
563
|
`const args = ${JSON.stringify(['agent', '--local', '--agent', agentId, '--session-id', sessionKey, '--json'])};`,
|
|
563
564
|
`args.push("--message", msg);`,
|
|
564
|
-
|
|
565
|
+
// Resolve the .cmd shim to find the actual JS entry point
|
|
566
|
+
`let bin = ${JSON.stringify(binary)};`,
|
|
567
|
+
`try {`,
|
|
568
|
+
` const w = cp.execSync("where " + bin, { encoding: "utf-8", timeout: 5000 }).split(/\\r?\\n/)[0].trim();`,
|
|
569
|
+
` if (w.endsWith(".cmd")) {`,
|
|
570
|
+
` const c = require("fs").readFileSync(w, "utf-8");`,
|
|
571
|
+
` const m = c.match(/"([^"]+\\.js)"/);`,
|
|
572
|
+
` if (m) { args.unshift(m[1].replace("%~dp0\\\\", path.dirname(w) + "\\\\")); bin = process.execPath; }`,
|
|
573
|
+
` }`,
|
|
574
|
+
`} catch {}`,
|
|
575
|
+
`const r = cp.spawnSync(bin, args, { stdio: ["ignore", "pipe", "pipe"], env: process.env, timeout: 600000 });`,
|
|
565
576
|
`try { require("fs").unlinkSync(${JSON.stringify(msgFile)}); } catch {}`,
|
|
566
577
|
`if (r.stdout) process.stdout.write(r.stdout);`,
|
|
567
578
|
`if (r.stderr) process.stderr.write(r.stderr);`,
|