open-agents-ai 0.185.13 → 0.185.15
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/dist/index.js +2 -45
- package/dist/launcher.cjs +47 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -51541,51 +51541,8 @@ async function handleUpdate(subcommand, ctx) {
|
|
|
51541
51541
|
await new Promise((r) => setTimeout(r, 1500));
|
|
51542
51542
|
installOverlay.dismiss();
|
|
51543
51543
|
await new Promise((r) => setTimeout(r, 200));
|
|
51544
|
-
|
|
51545
|
-
|
|
51546
|
-
const { join: join76 } = await import("node:path");
|
|
51547
|
-
const { homedir: homedir20 } = await import("node:os");
|
|
51548
|
-
ctx.contextSave?.();
|
|
51549
|
-
const restartDir = join76(homedir20(), ".open-agents");
|
|
51550
|
-
mkdirSync30(restartDir, { recursive: true });
|
|
51551
|
-
const scriptPath2 = join76(restartDir, ".restart.sh");
|
|
51552
|
-
const oaBin = process.argv[1] ?? "oa";
|
|
51553
|
-
const script = [
|
|
51554
|
-
"#!/bin/sh",
|
|
51555
|
-
"# Auto-generated by /update \u2014 runs once then self-deletes",
|
|
51556
|
-
"sleep 0.3",
|
|
51557
|
-
// wait for parent to fully exit
|
|
51558
|
-
"clear",
|
|
51559
|
-
// clean terminal
|
|
51560
|
-
`__OA_RESUMED="${resumeFlag}" exec "${process.execPath}" "${oaBin}"`
|
|
51561
|
-
].join("\n");
|
|
51562
|
-
writeFileSync29(scriptPath2, script, { mode: 493 });
|
|
51563
|
-
try {
|
|
51564
|
-
chmodSync(scriptPath2, 493);
|
|
51565
|
-
} catch {
|
|
51566
|
-
}
|
|
51567
|
-
if (process.stdout.isTTY) {
|
|
51568
|
-
process.stdout.write("\x1B[?1000l\x1B[?1002l\x1B[?1003l\x1B[?1006l\x1B[r\x1B[?25h\x1B[?1049l\x1B[0m\x1B[2J\x1B[H\nRestarting oa...\n");
|
|
51569
|
-
}
|
|
51570
|
-
const { spawn: spawnChild } = await import("node:child_process");
|
|
51571
|
-
const child = spawnChild("sh", [scriptPath2], {
|
|
51572
|
-
stdio: "inherit",
|
|
51573
|
-
// inherit terminal (needed for oa's TUI)
|
|
51574
|
-
detached: true,
|
|
51575
|
-
// new process group
|
|
51576
|
-
env: { ...process.env, __OA_RESUMED: resumeFlag }
|
|
51577
|
-
});
|
|
51578
|
-
child.unref();
|
|
51579
|
-
process.exit(0);
|
|
51580
|
-
} catch (err) {
|
|
51581
|
-
if (process.stdout.isTTY) {
|
|
51582
|
-
process.stdout.write(`\x1B[?1002l\x1B[?1006l\x1B[?1049l\x1B[0m\x1B[2J\x1B[H
|
|
51583
|
-
Restart failed: ${err instanceof Error ? err.message : String(err)}
|
|
51584
|
-
Run manually: oa
|
|
51585
|
-
`);
|
|
51586
|
-
}
|
|
51587
|
-
process.exit(1);
|
|
51588
|
-
}
|
|
51544
|
+
ctx.contextSave?.();
|
|
51545
|
+
process.exit(120);
|
|
51589
51546
|
}
|
|
51590
51547
|
async function switchModel(query, ctx, local = false) {
|
|
51591
51548
|
try {
|
package/dist/launcher.cjs
CHANGED
|
@@ -381,9 +381,51 @@ if (nodeVersion < 22) {
|
|
|
381
381
|
}
|
|
382
382
|
}
|
|
383
383
|
|
|
384
|
-
//
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
384
|
+
// Restart-aware launcher loop.
|
|
385
|
+
// Exit code 120 = restart requested (from /update).
|
|
386
|
+
// The launcher spawns the ESM bundle as a child process. If it exits with
|
|
387
|
+
// code 120, the launcher resets the terminal and spawns again. This way the
|
|
388
|
+
// restart happens in a CLEAN new Node process with zero inherited state —
|
|
389
|
+
// no mouse tracking, no raw mode, no buffered stdin, no timers.
|
|
390
|
+
var cp = require("child_process");
|
|
391
|
+
var path = require("path");
|
|
392
|
+
|
|
393
|
+
function runOA() {
|
|
394
|
+
var bundlePath = path.join(__dirname, "index.js");
|
|
395
|
+
var child = cp.fork(bundlePath, process.argv.slice(2), {
|
|
396
|
+
stdio: "inherit",
|
|
397
|
+
env: process.env,
|
|
398
|
+
});
|
|
399
|
+
|
|
400
|
+
child.on("exit", function(code) {
|
|
401
|
+
if (code === 120) {
|
|
402
|
+
// Restart requested — reset terminal then spawn again
|
|
403
|
+
if (process.stdout.isTTY) {
|
|
404
|
+
process.stdout.write(
|
|
405
|
+
"\x1B[?1000l\x1B[?1002l\x1B[?1003l\x1B[?1006l\x1B[?1015l" +
|
|
406
|
+
"\x1B[0m\x1B[r\x1B[?25h\x1B[?1049l\x1B[2J\x1B[3J\x1B[H"
|
|
407
|
+
);
|
|
408
|
+
}
|
|
409
|
+
// Reset terminal line discipline
|
|
410
|
+
try { require("child_process").execSync("stty sane 2>/dev/null", { stdio: "pipe" }); } catch(e) {}
|
|
411
|
+
// Drain any buffered stdin
|
|
412
|
+
if (process.stdin.isTTY && typeof process.stdin.setRawMode === "function") {
|
|
413
|
+
try { process.stdin.setRawMode(false); } catch(e) {}
|
|
414
|
+
}
|
|
415
|
+
// Set __OA_RESUMED for the new instance
|
|
416
|
+
process.env.__OA_RESUMED = "update-only";
|
|
417
|
+
// Brief pause then restart
|
|
418
|
+
setTimeout(runOA, 500);
|
|
419
|
+
} else {
|
|
420
|
+
process.exit(code || 0);
|
|
421
|
+
}
|
|
422
|
+
});
|
|
423
|
+
|
|
424
|
+
child.on("error", function(err) {
|
|
425
|
+
console.error("Failed to start open-agents:", err.message || err);
|
|
426
|
+
process.exit(1);
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
runOA();
|
|
389
431
|
}
|
package/package.json
CHANGED