open-agents-ai 0.104.3 → 0.104.4

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 +104 -44
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -33711,6 +33711,12 @@ var init_setup = __esm({
33711
33711
  function isOverlayActive() {
33712
33712
  return _overlayActive;
33713
33713
  }
33714
+ function overlayWrite(data) {
33715
+ if (_origStdoutWrite) {
33716
+ return _origStdoutWrite.call(process.stdout, data);
33717
+ }
33718
+ return process.stdout.write(data);
33719
+ }
33714
33720
  function bufferIfOverlay(stream, data) {
33715
33721
  if (!_overlayActive)
33716
33722
  return false;
@@ -33719,12 +33725,38 @@ function bufferIfOverlay(stream, data) {
33719
33725
  }
33720
33726
  function enterOverlay() {
33721
33727
  _depth++;
33722
- _overlayActive = true;
33728
+ if (_depth === 1) {
33729
+ _overlayActive = true;
33730
+ _origStdoutWrite = process.stdout.write.bind(process.stdout);
33731
+ _origStderrWrite = process.stderr.write.bind(process.stderr);
33732
+ process.stdout.write = function(chunk, ...args) {
33733
+ _buffer.push({ stream: "stdout", data: chunk });
33734
+ const cb = typeof args[args.length - 1] === "function" ? args[args.length - 1] : void 0;
33735
+ if (cb)
33736
+ cb();
33737
+ return true;
33738
+ };
33739
+ process.stderr.write = function(chunk, ...args) {
33740
+ _buffer.push({ stream: "stderr", data: chunk });
33741
+ const cb = typeof args[args.length - 1] === "function" ? args[args.length - 1] : void 0;
33742
+ if (cb)
33743
+ cb();
33744
+ return true;
33745
+ };
33746
+ }
33723
33747
  }
33724
33748
  function leaveOverlay() {
33725
33749
  _depth = Math.max(0, _depth - 1);
33726
33750
  if (_depth === 0) {
33727
33751
  _overlayActive = false;
33752
+ if (_origStdoutWrite) {
33753
+ process.stdout.write = _origStdoutWrite;
33754
+ _origStdoutWrite = null;
33755
+ }
33756
+ if (_origStderrWrite) {
33757
+ process.stderr.write = _origStderrWrite;
33758
+ _origStderrWrite = null;
33759
+ }
33728
33760
  const pending = _buffer;
33729
33761
  _buffer = [];
33730
33762
  for (const { stream, data } of pending) {
@@ -33736,13 +33768,15 @@ function leaveOverlay() {
33736
33768
  }
33737
33769
  }
33738
33770
  }
33739
- var _overlayActive, _depth, _buffer;
33771
+ var _overlayActive, _depth, _buffer, _origStdoutWrite, _origStderrWrite;
33740
33772
  var init_overlay_lock = __esm({
33741
33773
  "packages/cli/dist/tui/overlay-lock.js"() {
33742
33774
  "use strict";
33743
33775
  _overlayActive = false;
33744
33776
  _depth = 0;
33745
33777
  _buffer = [];
33778
+ _origStdoutWrite = null;
33779
+ _origStderrWrite = null;
33746
33780
  }
33747
33781
  });
33748
33782
 
@@ -33839,8 +33873,8 @@ function tuiSelect(opts) {
33839
33873
  stdin.setRawMode(true);
33840
33874
  }
33841
33875
  stdin.resume();
33842
- process.stdout.write("\x1B[?1049h\x1B[2J\x1B[H\x1B[?25l");
33843
33876
  enterOverlay();
33877
+ overlayWrite("\x1B[?1049h\x1B[2J\x1B[H\x1B[?25l");
33844
33878
  function clampScroll(displayList) {
33845
33879
  const cursorPos = displayList.indexOf(cursor);
33846
33880
  if (cursorPos < 0)
@@ -33854,7 +33888,7 @@ function tuiSelect(opts) {
33854
33888
  scrollOffset = Math.max(0, Math.min(maxOffset, scrollOffset));
33855
33889
  }
33856
33890
  function render() {
33857
- process.stdout.write("\x1B[H\x1B[2J");
33891
+ overlayWrite("\x1B[H\x1B[2J");
33858
33892
  const lines = [];
33859
33893
  if (title) {
33860
33894
  lines.push(`
@@ -33928,14 +33962,14 @@ function tuiSelect(opts) {
33928
33962
  }
33929
33963
  lines.push("");
33930
33964
  const output = lines.join("\n");
33931
- process.stdout.write(output);
33965
+ overlayWrite(output);
33932
33966
  lastRenderedLines = lines.length;
33933
33967
  }
33934
33968
  function cleanup() {
33935
33969
  stdin.removeListener("data", onData);
33936
33970
  process.stdout.removeListener("resize", onResize);
33971
+ overlayWrite("\x1B[?1049l\x1B[?25h");
33937
33972
  leaveOverlay();
33938
- process.stdout.write("\x1B[?1049l\x1B[?25h");
33939
33973
  if (typeof stdin.setRawMode === "function") {
33940
33974
  stdin.setRawMode(hadRawMode ?? false);
33941
33975
  }
@@ -34118,33 +34152,33 @@ function tuiSelect(opts) {
34118
34152
  return new Promise((inputResolve) => {
34119
34153
  let inputBuf = prefill;
34120
34154
  let inputCursor = prefill.length;
34121
- process.stdout.write("\x1B[?25h");
34155
+ overlayWrite("\x1B[?25h");
34122
34156
  function renderInput() {
34123
- process.stdout.write(`\x1B[${lastRenderedLines}A`);
34157
+ overlayWrite(`\x1B[${lastRenderedLines}A`);
34124
34158
  const saveFooter = lastRenderedLines;
34125
34159
  for (let i = 0; i < saveFooter; i++)
34126
- process.stdout.write("\x1B[B");
34127
- process.stdout.write("\x1B[2A");
34128
- process.stdout.write("\x1B[2K");
34160
+ overlayWrite("\x1B[B");
34161
+ overlayWrite("\x1B[2A");
34162
+ overlayWrite("\x1B[2K");
34129
34163
  const before = inputBuf.slice(0, inputCursor);
34130
34164
  const after = inputBuf.slice(inputCursor);
34131
- process.stdout.write(` ${selectColors.cyan("\u203A")} ${selectColors.bold(prompt)} ${before}\x1B[7m${after.charAt(0) || " "}\x1B[27m${after.slice(1)}`);
34132
- process.stdout.write("\n\x1B[2K");
34133
- process.stdout.write(` ${selectColors.dim("Enter confirm Esc cancel")}`);
34134
- process.stdout.write("\n");
34165
+ overlayWrite(` ${selectColors.cyan("\u203A")} ${selectColors.bold(prompt)} ${before}\x1B[7m${after.charAt(0) || " "}\x1B[27m${after.slice(1)}`);
34166
+ overlayWrite("\n\x1B[2K");
34167
+ overlayWrite(` ${selectColors.dim("Enter confirm Esc cancel")}`);
34168
+ overlayWrite("\n");
34135
34169
  }
34136
34170
  function onInputData(chunk) {
34137
34171
  const s = chunk.toString("utf8");
34138
34172
  if (s === "\r" || s === "\n") {
34139
34173
  stdin.removeListener("data", onInputData);
34140
34174
  stdin.on("data", onData);
34141
- process.stdout.write("\x1B[?25l");
34175
+ overlayWrite("\x1B[?25l");
34142
34176
  render();
34143
34177
  inputResolve(inputBuf);
34144
34178
  } else if (s === "\x1B" || s === "\x1B\x1B" || s === "") {
34145
34179
  stdin.removeListener("data", onInputData);
34146
34180
  stdin.on("data", onData);
34147
- process.stdout.write("\x1B[?25l");
34181
+ overlayWrite("\x1B[?25l");
34148
34182
  render();
34149
34183
  inputResolve(null);
34150
34184
  } else if (s === "\x7F" || s === "\b") {
@@ -34212,6 +34246,29 @@ import { extname as extname9, resolve as resolve27 } from "node:path";
34212
34246
  function ansi4(code, text) {
34213
34247
  return isTTY4 ? `\x1B[${code}m${text}\x1B[0m` : text;
34214
34248
  }
34249
+ function stripAnsi2(s) {
34250
+ return s.replace(/\x1B\[[0-9;]*m/g, "");
34251
+ }
34252
+ function fitToWidth(text, width) {
34253
+ const visible = stripAnsi2(text);
34254
+ if (visible.length >= width) {
34255
+ let visCount = 0;
34256
+ let i = 0;
34257
+ while (i < text.length && visCount < width) {
34258
+ if (text[i] === "\x1B") {
34259
+ const end = text.indexOf("m", i);
34260
+ if (end >= 0) {
34261
+ i = end + 1;
34262
+ continue;
34263
+ }
34264
+ }
34265
+ visCount++;
34266
+ i++;
34267
+ }
34268
+ return text.slice(0, i) + "\x1B[0m";
34269
+ }
34270
+ return text + " ".repeat(width - visible.length);
34271
+ }
34215
34272
  function showDropPanel(opts) {
34216
34273
  const { title, instruction = "Drag and drop a file here, or type/paste a path", allowedExtensions = [], typeLabel, rl } = opts;
34217
34274
  return new Promise((resolve_) => {
@@ -34232,53 +34289,56 @@ function showDropPanel(opts) {
34232
34289
  stdin.setRawMode(true);
34233
34290
  }
34234
34291
  stdin.resume();
34235
- process.stdout.write("\x1B[?1049h\x1B[2J\x1B[H\x1B[?25h");
34236
34292
  enterOverlay();
34293
+ overlayWrite("\x1B[?1049h\x1B[2J\x1B[H\x1B[?25h");
34237
34294
  let inputBuf = "";
34238
34295
  let errorMsg = "";
34239
34296
  function render() {
34240
- process.stdout.write("\x1B[H\x1B[2J");
34297
+ overlayWrite("\x1B[H\x1B[2J");
34241
34298
  const cols = process.stdout.columns ?? 80;
34242
34299
  const rows = process.stdout.rows ?? 24;
34243
- const borderH = "\u2508".repeat(Math.max(2, cols - 4));
34244
- const lines = [];
34245
- lines.push("");
34246
- lines.push(` ${dc.cyan(borderH)}`);
34247
- const contentLines = 8;
34248
- const topPad = Math.max(1, Math.floor((rows - contentLines) / 2) - 2);
34249
- for (let i = 0; i < topPad; i++) {
34250
- lines.push(` ${dc.cyan("\u250A")}${" ".repeat(Math.max(0, cols - 6))}${dc.cyan("\u250A")}`);
34251
- }
34252
- const titleLine = ` ${dc.cyan("\u250A")} ${dc.bold(title)}`;
34253
- lines.push(titleLine);
34254
- lines.push(` ${dc.cyan("\u250A")}`);
34255
- lines.push(` ${dc.cyan("\u250A")} ${dc.dim(instruction)}`);
34300
+ const textWidth = Math.max(10, cols - 9);
34301
+ const innerSpace = Math.max(10, cols - 6);
34302
+ const content = [];
34303
+ content.push(` ${fitToWidth(dc.bold(title), textWidth)} `);
34304
+ content.push(` ${" ".repeat(textWidth)} `);
34305
+ content.push(` ${fitToWidth(dc.dim(instruction), textWidth)} `);
34256
34306
  if (allowedExtensions.length > 0) {
34257
34307
  const extList = allowedExtensions.join(", ");
34258
34308
  const label = typeLabel ? `${typeLabel}: ` : "Accepted: ";
34259
- lines.push(` ${dc.cyan("\u250A")} ${dc.dim(label)}${dc.dim(extList)}`);
34309
+ content.push(` ${fitToWidth(dc.dim(label) + dc.dim(extList), textWidth)} `);
34260
34310
  }
34261
- lines.push(` ${dc.cyan("\u250A")}`);
34262
- const cursor = inputBuf.length > 0 ? inputBuf : dc.dim("waiting for file...");
34263
- lines.push(` ${dc.cyan("\u250A")} ${dc.cyan(">")} ${cursor}`);
34311
+ content.push(` ${" ".repeat(textWidth)} `);
34312
+ const cursorText = inputBuf.length > 0 ? inputBuf : dc.dim("waiting for file...");
34313
+ content.push(` ${fitToWidth(dc.cyan(">") + " " + cursorText, textWidth)} `);
34264
34314
  if (errorMsg) {
34265
- lines.push(` ${dc.cyan("\u250A")} ${dc.red(errorMsg)}`);
34315
+ content.push(` ${fitToWidth(dc.red(errorMsg), textWidth)} `);
34266
34316
  } else {
34267
- lines.push(` ${dc.cyan("\u250A")}`);
34317
+ content.push(` ${" ".repeat(textWidth)} `);
34268
34318
  }
34269
- const bottomPad = Math.max(1, rows - lines.length - 4);
34270
- for (let i = 0; i < bottomPad; i++) {
34271
- lines.push(` ${dc.cyan("\u250A")}${" ".repeat(Math.max(0, cols - 6))}${dc.cyan("\u250A")}`);
34319
+ const fixedChrome = 4;
34320
+ const availableForPadding = Math.max(0, rows - fixedChrome - content.length);
34321
+ const topPad = Math.max(0, Math.floor(availableForPadding / 2));
34322
+ const bottomPad = Math.max(0, availableForPadding - topPad);
34323
+ const lines = [];
34324
+ const borderH = "\u2508".repeat(Math.max(2, cols - 4));
34325
+ const emptyPipe = ` ${dc.cyan("\u250A")}${" ".repeat(innerSpace)}${dc.cyan("\u250A")}`;
34326
+ lines.push(` ${dc.cyan(borderH)}`);
34327
+ for (let i = 0; i < topPad; i++)
34328
+ lines.push(emptyPipe);
34329
+ for (const line of content) {
34330
+ lines.push(` ${dc.cyan("\u250A")}${line}${dc.cyan("\u250A")}`);
34272
34331
  }
34332
+ for (let i = 0; i < bottomPad; i++)
34333
+ lines.push(emptyPipe);
34273
34334
  lines.push(` ${dc.cyan(borderH)}`);
34274
34335
  lines.push(` ${dc.dim("Enter confirm Esc cancel")}`);
34275
- lines.push("");
34276
- process.stdout.write(lines.join("\n"));
34336
+ overlayWrite(lines.join("\n") + "\n");
34277
34337
  }
34278
34338
  function cleanup() {
34279
34339
  stdin.removeListener("data", onData);
34340
+ overlayWrite("\x1B[?1049l\x1B[?25h");
34280
34341
  leaveOverlay();
34281
- process.stdout.write("\x1B[?1049l\x1B[?25h");
34282
34342
  if (typeof stdin.setRawMode === "function") {
34283
34343
  stdin.setRawMode(hadRawMode ?? false);
34284
34344
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "open-agents-ai",
3
- "version": "0.104.3",
3
+ "version": "0.104.4",
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",