agent.libx.js 0.89.1 → 0.89.3

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/cli.js CHANGED
@@ -4640,6 +4640,7 @@ function completePath(listDir, ref) {
4640
4640
  // cli/lineEditor.ts
4641
4641
  import { emitKeypressEvents } from "readline";
4642
4642
  var visibleWidth = (s) => s.replace(/\x1b\[[0-9;]*m/g, "").length;
4643
+ var isPrintable = (str) => !!str && !/[\x00-\x1f\x7f]/.test(str);
4643
4644
  var EditorState = class _EditorState {
4644
4645
  // pending operator awaiting a motion (dd/dw/cc)
4645
4646
  constructor(suggest, history = [], classifyPaste, onEmptyPaste, vimEnabled = false) {
@@ -5092,7 +5093,7 @@ function applyKey(s, key, str) {
5092
5093
  s.searchBack();
5093
5094
  return "none";
5094
5095
  }
5095
- if (str && !key?.ctrl && !key?.meta && /^[\x20-\x7e]$/.test(str)) {
5096
+ if (!key?.ctrl && !key?.meta && isPrintable(str)) {
5096
5097
  s.searchType(str);
5097
5098
  return "none";
5098
5099
  }
@@ -5185,7 +5186,7 @@ function applyKey(s, key, str) {
5185
5186
  s.del();
5186
5187
  return "none";
5187
5188
  }
5188
- if (str && !key?.ctrl && !key?.meta && /^[\x20-\x7e]$/.test(str)) {
5189
+ if (!key?.ctrl && !key?.meta && isPrintable(str)) {
5189
5190
  s.insert(str);
5190
5191
  return "none";
5191
5192
  }
@@ -5453,7 +5454,7 @@ function selectMenu(out, opts) {
5453
5454
  filter = filter.slice(0, -1);
5454
5455
  applyFilter();
5455
5456
  draw();
5456
- } else if (opts.filterable && _s && !key?.ctrl && !key?.meta && /^[\x20-\x7e]$/.test(_s)) {
5457
+ } else if (opts.filterable && !key?.ctrl && !key?.meta && isPrintable(_s)) {
5457
5458
  filter += _s;
5458
5459
  applyFilter();
5459
5460
  draw();
@@ -6405,18 +6406,28 @@ async function repl(args, ai, cfg, cwd) {
6405
6406
  void closeMcp(mounted);
6406
6407
  process.exit(130);
6407
6408
  });
6408
- const isStreamTeardown = (e) => /NGHTTP2_FRAME_SIZE_ERROR|ERR_HTTP2_STREAM_ERROR/.test(`${e?.code ?? ""} ${e?.rawMessage ?? ""} ${e?.message ?? ""}`);
6409
- const onFatal = (kind) => (e) => {
6410
- if (isStreamTeardown(e)) {
6411
- log11.debug(`suppressed ${kind} (connect/HTTP-2 stream teardown on cancel)`, e);
6409
+ const isCancelTeardown = (e) => {
6410
+ if (!e) return false;
6411
+ if (e.code === 20 || e.cause?.code === 20) return true;
6412
+ const blob = `${e.code ?? ""} ${e.name ?? ""} ${e.cause?.name ?? ""} ${e.rawMessage ?? ""} ${e.message ?? ""}`;
6413
+ return /NGHTTP2_FRAME_SIZE_ERROR|ERR_HTTP2_STREAM_ERROR|operation was aborted|\bAbortError\b/i.test(blob);
6414
+ };
6415
+ process.on("unhandledRejection", (e) => {
6416
+ if (isCancelTeardown(e)) {
6417
+ log11.debug("suppressed unhandledRejection (cursor stream cancel)", e);
6418
+ return;
6419
+ }
6420
+ log11.error("unhandledRejection", e);
6421
+ });
6422
+ process.on("uncaughtException", (e) => {
6423
+ if (isCancelTeardown(e)) {
6424
+ log11.debug("suppressed uncaughtException (cursor stream cancel)", e);
6412
6425
  return;
6413
6426
  }
6414
6427
  console.error(e);
6415
6428
  void closeMcp(mounted);
6416
6429
  process.exit(1);
6417
- };
6418
- process.on("unhandledRejection", onFatal("unhandledRejection"));
6419
- process.on("uncaughtException", onFatal("uncaughtException"));
6430
+ });
6420
6431
  const store = new SessionStore(cwd);
6421
6432
  let session = startSession(args, store, agent, cwd);
6422
6433
  const checkpoints = args.vfs || args.boddb ? new CheckpointStack(agent.options.fs) : new GitCheckpoints({ workTree: cwd, gitDir: join8(cwd, ".agent", "checkpoints.git"), addDirs: args.addDirs, sessionId: session.meta.id });