open-agents-ai 0.90.0 → 0.92.0

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.
Files changed (2) hide show
  1. package/dist/index.js +100 -26
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -321,13 +321,20 @@ async function checkForUpdate(currentVersion, forceCheck = false) {
321
321
  };
322
322
  }
323
323
  function performSilentUpdate() {
324
+ const installCmd = `npm install -g ${PACKAGE_NAME}@latest --prefer-online`;
324
325
  try {
325
- execSync(`npm install -g ${PACKAGE_NAME}@latest --prefer-online`, {
326
- stdio: "pipe",
327
- timeout: 12e4
328
- });
326
+ execSync(installCmd, { stdio: "pipe", timeout: 12e4 });
329
327
  return true;
330
- } catch {
328
+ } catch (err) {
329
+ const msg = err instanceof Error ? err.message : String(err);
330
+ if (/EACCES|permission denied/i.test(msg)) {
331
+ try {
332
+ execSync(`sudo -n ${installCmd}`, { stdio: "pipe", timeout: 12e4 });
333
+ return true;
334
+ } catch {
335
+ return false;
336
+ }
337
+ }
331
338
  return false;
332
339
  }
333
340
  }
@@ -17179,10 +17186,10 @@ ${marker}` : marker);
17179
17186
  if (!this._workingDirectory)
17180
17187
  return;
17181
17188
  try {
17182
- const { mkdirSync: mkdirSync17, writeFileSync: writeFileSync15 } = __require("node:fs");
17189
+ const { mkdirSync: mkdirSync18, writeFileSync: writeFileSync16 } = __require("node:fs");
17183
17190
  const { join: join52 } = __require("node:path");
17184
17191
  const sessionDir = join52(this._workingDirectory, ".oa", "session", this._sessionId);
17185
- mkdirSync17(sessionDir, { recursive: true });
17192
+ mkdirSync18(sessionDir, { recursive: true });
17186
17193
  const checkpoint = {
17187
17194
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
17188
17195
  sessionId: this._sessionId,
@@ -17194,7 +17201,7 @@ ${marker}` : marker);
17194
17201
  memexEntryCount: this._memexArchive.size,
17195
17202
  fileRegistrySize: this._fileRegistry.size
17196
17203
  };
17197
- writeFileSync15(join52(sessionDir, "checkpoint.json"), JSON.stringify(checkpoint, null, 2));
17204
+ writeFileSync16(join52(sessionDir, "checkpoint.json"), JSON.stringify(checkpoint, null, 2));
17198
17205
  } catch {
17199
17206
  }
17200
17207
  }
@@ -30025,22 +30032,55 @@ async function handleUpdate(subcommand, ctx) {
30025
30032
  return;
30026
30033
  }
30027
30034
  checkSpinner.stop(`Update available: v${info.currentVersion} \u2192 v${c2.bold(c2.green(info.latestVersion))}`);
30035
+ const { exec, execSync: es2 } = await import("node:child_process");
30036
+ let needsSudo = false;
30037
+ try {
30038
+ const prefix = es2("npm prefix -g", { encoding: "utf8", timeout: 5e3 }).trim();
30039
+ const { accessSync, constants } = await import("node:fs");
30040
+ try {
30041
+ accessSync(prefix, constants.W_OK);
30042
+ } catch {
30043
+ needsSudo = true;
30044
+ }
30045
+ } catch {
30046
+ }
30047
+ if (needsSudo) {
30048
+ renderInfo("Global npm directory requires elevated permissions.");
30049
+ renderInfo("You'll be asked for your password once \u2014 it covers all update steps.");
30050
+ process.stdout.write("\n");
30051
+ try {
30052
+ es2("sudo -v", { stdio: "inherit", timeout: 6e4 });
30053
+ } catch {
30054
+ renderWarning("Could not acquire sudo credentials. Try: sudo npm i -g open-agents-ai");
30055
+ return;
30056
+ }
30057
+ }
30058
+ const sudoPrefix = needsSudo ? "sudo " : "";
30028
30059
  const installSpinner = startInlineSpinner("Installing update");
30029
- const { exec } = await import("node:child_process");
30030
- const installOk = await new Promise((resolve31) => {
30031
- const child = exec(`npm cache clean --force open-agents-ai 2>/dev/null; npm install -g open-agents-ai@latest --force`, { timeout: 18e4 }, (err) => resolve31(!err));
30060
+ const installCmd = `${sudoPrefix}npm install -g open-agents-ai@latest --prefer-online`;
30061
+ let installOk = false;
30062
+ let installError = "";
30063
+ installOk = await new Promise((resolve31) => {
30064
+ const child = exec(installCmd, { timeout: 18e4 }, (err, _stdout, stderr) => {
30065
+ if (err)
30066
+ installError = (stderr || err.message || "").trim();
30067
+ resolve31(!err);
30068
+ });
30032
30069
  child.stdout?.resume();
30033
- child.stderr?.resume();
30034
30070
  });
30035
30071
  if (!installOk) {
30036
30072
  installSpinner.stop("Update install failed.");
30037
- renderWarning("Try manually: npm i -g open-agents-ai");
30073
+ const errPreview = installError.split("\n").filter((l) => l.trim()).slice(-3).join("\n ");
30074
+ if (errPreview)
30075
+ renderWarning(`Error:
30076
+ ${errPreview}`);
30077
+ renderWarning(`Try manually: ${sudoPrefix}npm i -g open-agents-ai`);
30038
30078
  return;
30039
30079
  }
30040
30080
  installSpinner.stop(`Update installed (v${info.latestVersion}).`);
30041
30081
  const rebuildSpinner = startInlineSpinner("Rebuilding native modules");
30042
30082
  const rebuildOk = await new Promise((resolve31) => {
30043
- const child = exec("npm rebuild -g open-agents-ai 2>/dev/null || true", { timeout: 12e4 }, () => resolve31(true));
30083
+ const child = exec(`${sudoPrefix}npm rebuild -g open-agents-ai 2>/dev/null || true`, { timeout: 12e4 }, () => resolve31(true));
30044
30084
  child.stdout?.resume();
30045
30085
  child.stderr?.resume();
30046
30086
  });
@@ -38951,7 +38991,7 @@ var init_status_bar = __esm({
38951
38991
  return;
38952
38992
  const rows = process.stdout.rows ?? 24;
38953
38993
  const pos = this.rowPositions(rows);
38954
- process.stdout.write(`\x1B[${pos.inputStartRow};1H\x1B[2K`);
38994
+ process.stdout.write(`\x1B[${pos.inputStartRow};1H\x1B[2K\x1B[?25h`);
38955
38995
  }
38956
38996
  /** Strip ANSI escape codes to measure visible character width */
38957
38997
  static visWidth(s) {
@@ -39318,7 +39358,7 @@ var init_status_bar = __esm({
39318
39358
  buf += `\x1B[${row};1H\x1B[2K${prefix}${inputWrap.lines[i]}`;
39319
39359
  }
39320
39360
  const cursorTermRow = pos.inputStartRow + inputWrap.cursorRow;
39321
- buf += `\x1B[${pos.bottomSepRow};1H\x1B[2K${sep}\x1B[${pos.metricsRow};1H\x1B[2K${this.buildMetricsLine()}\x1B[?7h\x1B[?25h\x1B[${cursorTermRow};${inputWrap.cursorCol}H`;
39361
+ buf += `\x1B[${pos.bottomSepRow};1H\x1B[2K${sep}\x1B[${pos.metricsRow};1H\x1B[2K${this.buildMetricsLine()}\x1B[?7h\x1B[${cursorTermRow};${inputWrap.cursorCol}H\x1B[?25h`;
39322
39362
  process.stdout.write(buf);
39323
39363
  }
39324
39364
  /**
@@ -39346,7 +39386,8 @@ var init_status_bar = __esm({
39346
39386
  const w = getTermWidth();
39347
39387
  const pos = this.rowPositions(rows);
39348
39388
  const sep = c2.dim("\u2500".repeat(w));
39349
- const buf = `\x1B7\x1B[?7l\x1B[${pos.bufferRow};1H\x1B[2K${this.buildBufferContent(w)}\x1B[${pos.topSepRow};1H\x1B[2K${sep}\x1B[${pos.bottomSepRow};1H\x1B[2K${sep}\x1B[${pos.metricsRow};1H\x1B[2K${this.buildMetricsLine()}\x1B[?7h\x1B8`;
39389
+ const buf = `\x1B7\x1B[?7l\x1B[${pos.bufferRow};1H\x1B[2K${this.buildBufferContent(w)}\x1B[${pos.topSepRow};1H\x1B[2K${sep}\x1B[${pos.bottomSepRow};1H\x1B[2K${sep}\x1B[${pos.metricsRow};1H\x1B[2K${this.buildMetricsLine()}\x1B[?7h\x1B8` + // DEC restore cursor
39390
+ (this.writeDepth === 0 ? "\x1B[?25h" : "");
39350
39391
  process.stdout.write(buf);
39351
39392
  }
39352
39393
  /**
@@ -39467,8 +39508,9 @@ import { cwd } from "node:process";
39467
39508
  import { resolve as resolve28, join as join47, dirname as dirname16, extname as extname9 } from "node:path";
39468
39509
  import { createRequire as createRequire2 } from "node:module";
39469
39510
  import { fileURLToPath as fileURLToPath12 } from "node:url";
39470
- import { readFileSync as readFileSync27, rmSync as rmSync2, readdirSync as readdirSync14 } from "node:fs";
39511
+ import { readFileSync as readFileSync27, writeFileSync as writeFileSync14, appendFileSync as appendFileSync3, rmSync as rmSync2, readdirSync as readdirSync14, mkdirSync as mkdirSync16 } from "node:fs";
39471
39512
  import { existsSync as existsSync36 } from "node:fs";
39513
+ import { homedir as homedir13 } from "node:os";
39472
39514
  function formatTimeAgo(date) {
39473
39515
  const seconds = Math.floor((Date.now() - date.getTime()) / 1e3);
39474
39516
  if (seconds < 60)
@@ -40560,14 +40602,42 @@ Rationale: ${proposal.rationale}${provenanceNote}`;
40560
40602
  const hits = allCompletions.filter((c3) => c3.toLowerCase().startsWith(lower));
40561
40603
  return [hits, line];
40562
40604
  }
40605
+ const HISTORY_DIR = join47(homedir13(), ".open-agents");
40606
+ const HISTORY_FILE = join47(HISTORY_DIR, "repl-history");
40607
+ const MAX_HISTORY_LINES = 500;
40608
+ let savedHistory = [];
40609
+ try {
40610
+ if (existsSync36(HISTORY_FILE)) {
40611
+ const raw = readFileSync27(HISTORY_FILE, "utf8").trim();
40612
+ if (raw)
40613
+ savedHistory = raw.split("\n").reverse();
40614
+ }
40615
+ } catch {
40616
+ }
40563
40617
  const rl = readline2.createInterface({
40564
40618
  input: process.stdin,
40565
40619
  output: process.stdout,
40566
40620
  prompt: idlePrompt,
40567
40621
  terminal: true,
40568
- historySize: 100,
40622
+ historySize: MAX_HISTORY_LINES,
40623
+ history: savedHistory,
40569
40624
  completer
40570
40625
  });
40626
+ function persistHistoryLine(line) {
40627
+ if (!line.trim())
40628
+ return;
40629
+ try {
40630
+ mkdirSync16(HISTORY_DIR, { recursive: true });
40631
+ appendFileSync3(HISTORY_FILE, line + "\n", "utf8");
40632
+ if (Math.random() < 0.02) {
40633
+ const all = readFileSync27(HISTORY_FILE, "utf8").trim().split("\n");
40634
+ if (all.length > MAX_HISTORY_LINES) {
40635
+ writeFileSync14(HISTORY_FILE, all.slice(-MAX_HISTORY_LINES).join("\n") + "\n", "utf8");
40636
+ }
40637
+ }
40638
+ } catch {
40639
+ }
40640
+ }
40571
40641
  statusBar.setPromptText(idlePrompt, 2);
40572
40642
  statusBar.setCompletions(allCompletions);
40573
40643
  if (statusBar.isActive) {
@@ -40606,8 +40676,11 @@ Rationale: ${proposal.rationale}${provenanceNote}`;
40606
40676
  function writeContent(fn) {
40607
40677
  if (statusBar.isActive) {
40608
40678
  statusBar.beginContentWrite();
40609
- fn();
40610
- statusBar.endContentWrite();
40679
+ try {
40680
+ fn();
40681
+ } finally {
40682
+ statusBar.endContentWrite();
40683
+ }
40611
40684
  } else {
40612
40685
  fn();
40613
40686
  }
@@ -41577,6 +41650,7 @@ ${sessionCtx}` : "",
41577
41650
  pasteIndicatorShown = true;
41578
41651
  }
41579
41652
  rl.on("line", (line) => {
41653
+ persistHistoryLine(line);
41580
41654
  const input = line.trim();
41581
41655
  if (pendingSessionRestore) {
41582
41656
  pendingSessionRestore = false;
@@ -42681,7 +42755,7 @@ __export(config_exports, {
42681
42755
  configCommand: () => configCommand
42682
42756
  });
42683
42757
  import { join as join49, resolve as resolve30 } from "node:path";
42684
- import { homedir as homedir13 } from "node:os";
42758
+ import { homedir as homedir14 } from "node:os";
42685
42759
  import { cwd as cwd3 } from "node:process";
42686
42760
  function redactIfSensitive(key, value) {
42687
42761
  if (SENSITIVE_KEYS.has(key) && typeof value === "string" && value.length > 0) {
@@ -42739,7 +42813,7 @@ function handleShow(opts, config) {
42739
42813
  }
42740
42814
  }
42741
42815
  printSection("Config File");
42742
- printInfo(`~/.open-agents/config.json (${join49(homedir13(), ".open-agents", "config.json")})`);
42816
+ printInfo(`~/.open-agents/config.json (${join49(homedir14(), ".open-agents", "config.json")})`);
42743
42817
  printSection("Priority Chain");
42744
42818
  printInfo(" 1. CLI flags (--model, --backend-url, etc.)");
42745
42819
  printInfo(" 2. Project .oa/settings.json (--local)");
@@ -42997,7 +43071,7 @@ __export(eval_exports, {
42997
43071
  evalCommand: () => evalCommand
42998
43072
  });
42999
43073
  import { tmpdir as tmpdir7 } from "node:os";
43000
- import { mkdirSync as mkdirSync16, writeFileSync as writeFileSync14 } from "node:fs";
43074
+ import { mkdirSync as mkdirSync17, writeFileSync as writeFileSync15 } from "node:fs";
43001
43075
  import { join as join50 } from "node:path";
43002
43076
  async function evalCommand(opts, config) {
43003
43077
  const suiteName = opts.suite ?? "basic";
@@ -43124,8 +43198,8 @@ async function evalCommand(opts, config) {
43124
43198
  }
43125
43199
  function createTempEvalRepo() {
43126
43200
  const dir = join50(tmpdir7(), `open-agents-eval-${Date.now()}`);
43127
- mkdirSync16(dir, { recursive: true });
43128
- writeFileSync14(join50(dir, "package.json"), JSON.stringify({ name: "eval-repo", version: "0.0.0" }, null, 2) + "\n", "utf8");
43201
+ mkdirSync17(dir, { recursive: true });
43202
+ writeFileSync15(join50(dir, "package.json"), JSON.stringify({ name: "eval-repo", version: "0.0.0" }, null, 2) + "\n", "utf8");
43129
43203
  return dir;
43130
43204
  }
43131
43205
  var BASIC_SUITE, FULL_SUITE, SUITES;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "open-agents-ai",
3
- "version": "0.90.0",
3
+ "version": "0.92.0",
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",