open-agents-ai 0.185.14 → 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 CHANGED
@@ -51541,58 +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
- try {
51545
- const { writeFileSync: writeFileSync29, mkdirSync: mkdirSync30, chmodSync } = await import("node:fs");
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 1",
51557
- // wait for parent to FULLY exit (0.3 was too short)
51558
- // Aggressively reset terminal — disable ALL mouse modes, reset attributes,
51559
- // clear screen. This runs BEFORE oa starts so mouse sequences from the
51560
- // dead parent's terminal state are flushed.
51561
- "printf '\\033[?1000l\\033[?1002l\\033[?1003l\\033[?1006l\\033[?1015l'",
51562
- "printf '\\033[0m\\033[r\\033[?25h'",
51563
- // reset attrs, scroll region, show cursor
51564
- "stty sane 2>/dev/null",
51565
- // reset terminal line discipline
51566
- "clear",
51567
- `__OA_RESUMED="${resumeFlag}" exec "${process.execPath}" "${oaBin}"`
51568
- ].join("\n");
51569
- writeFileSync29(scriptPath2, script, { mode: 493 });
51570
- try {
51571
- chmodSync(scriptPath2, 493);
51572
- } catch {
51573
- }
51574
- if (process.stdout.isTTY) {
51575
- 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");
51576
- }
51577
- const { spawn: spawnChild } = await import("node:child_process");
51578
- const child = spawnChild("sh", [scriptPath2], {
51579
- stdio: "inherit",
51580
- // inherit terminal (needed for oa's TUI)
51581
- detached: true,
51582
- // new process group
51583
- env: { ...process.env, __OA_RESUMED: resumeFlag }
51584
- });
51585
- child.unref();
51586
- process.exit(0);
51587
- } catch (err) {
51588
- if (process.stdout.isTTY) {
51589
- process.stdout.write(`\x1B[?1002l\x1B[?1006l\x1B[?1049l\x1B[0m\x1B[2J\x1B[H
51590
- Restart failed: ${err instanceof Error ? err.message : String(err)}
51591
- Run manually: oa
51592
- `);
51593
- }
51594
- process.exit(1);
51595
- }
51544
+ ctx.contextSave?.();
51545
+ process.exit(120);
51596
51546
  }
51597
51547
  async function switchModel(query, ctx, local = false) {
51598
51548
  try {
package/dist/launcher.cjs CHANGED
@@ -381,9 +381,51 @@ if (nodeVersion < 22) {
381
381
  }
382
382
  }
383
383
 
384
- // Load the ESM bundle
385
- import("./index.js").catch(function(err) {
386
- console.error("Failed to load open-agents:", err.message || err);
387
- process.exit(1);
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "open-agents-ai",
3
- "version": "0.185.14",
3
+ "version": "0.185.15",
4
4
  "description": "AI coding agent powered by open-source models (Ollama/vLLM) — interactive TUI with agentic tool-calling loop",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",