agent.libx.js 0.89.8 → 0.89.9

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
@@ -5564,6 +5564,7 @@ function createLineEditor(out) {
5564
5564
  // cyan
5565
5565
  };
5566
5566
  let curRow = 0;
5567
+ let activeRedraw;
5567
5568
  function render(s, promptArg, maxVisible, status) {
5568
5569
  const cols = out.columns ?? 80;
5569
5570
  const mode = !s.searching ? inputMode(s.buf) : void 0;
@@ -5595,9 +5596,11 @@ function createLineEditor(out) {
5595
5596
  let footerRows = 0;
5596
5597
  const footer = status?.();
5597
5598
  if (footer) {
5598
- const f = visibleWidth(footer) > cols - 1 ? footer.slice(0, cols - 2) + "\u2026" : footer;
5599
- out.write("\r\n" + dim2(f));
5600
- footerRows = 1;
5599
+ for (const line of footer.split("\n")) {
5600
+ const f = visibleWidth(line) > cols - 1 ? line.slice(0, cols - 2) + "\u2026" : line;
5601
+ out.write("\r\n" + dim2(f));
5602
+ footerRows++;
5603
+ }
5601
5604
  }
5602
5605
  const up = inputRows + menuRows + footerRows - cursorRow;
5603
5606
  if (up > 0) out.write(`\x1B[${up}A`);
@@ -5621,6 +5624,10 @@ function createLineEditor(out) {
5621
5624
  curRow = 0;
5622
5625
  render(s, opts.prompt, maxVisible, opts.status);
5623
5626
  };
5627
+ activeRedraw = () => {
5628
+ curRow = 0;
5629
+ render(s, opts.prompt, maxVisible, opts.status);
5630
+ };
5624
5631
  process.on("SIGWINCH", onResize);
5625
5632
  return new Promise((resolve4) => {
5626
5633
  const redraw = () => render(s, opts.prompt, maxVisible, opts.status);
@@ -5685,6 +5692,7 @@ function createLineEditor(out) {
5685
5692
  render(s, opts.prompt, maxVisible, opts.status);
5686
5693
  };
5687
5694
  const finish = () => {
5695
+ activeRedraw = void 0;
5688
5696
  if (ticker) clearInterval(ticker);
5689
5697
  process.stdin.off("keypress", onKey);
5690
5698
  process.removeListener("SIGWINCH", onResize);
@@ -5697,7 +5705,7 @@ function createLineEditor(out) {
5697
5705
  process.stdin.on("keypress", onKey);
5698
5706
  });
5699
5707
  }
5700
- return { readLine };
5708
+ return { readLine, redrawNow: () => activeRedraw?.() };
5701
5709
  }
5702
5710
  function selectMenu(out, opts) {
5703
5711
  if (!out.isTTY || !process.stdin.isTTY || !opts.items.length) return Promise.resolve(null);
@@ -6817,6 +6825,7 @@ async function repl(args, ai, cfg, cwd) {
6817
6825
  const agent = await makeAgent(args, ai, cfg, mounted.flatMap((m) => m.tools));
6818
6826
  const duplex = args.duplex;
6819
6827
  let dx;
6828
+ let editorRef;
6820
6829
  let workerOptions;
6821
6830
  let duplexPersist = () => {
6822
6831
  };
@@ -6841,17 +6850,19 @@ async function repl(args, ai, cfg, cwd) {
6841
6850
  base.flushText();
6842
6851
  process.stdout.write("\n");
6843
6852
  duplexPersist();
6853
+ editorRef?.redrawNow();
6844
6854
  return;
6845
6855
  }
6846
6856
  if (e.kind === "task_done" && e.data?.text) {
6847
6857
  const lines = String(e.data.text).split("\n");
6848
6858
  const shown = lines.slice(0, previewLines());
6849
- err("\n" + dim(` \u29BF ${e.message}
6859
+ err("\r\x1B[2K\n" + dim(` \u29BF ${e.message}
6850
6860
  `) + shown.map((l) => dim(` ${l}
6851
6861
  `)).join(""));
6852
6862
  if (lines.length > shown.length) err(dim(` \u2026 (+${lines.length - shown.length} more lines)
6853
6863
  `));
6854
6864
  duplexAccount(e.data);
6865
+ editorRef?.redrawNow();
6855
6866
  return;
6856
6867
  }
6857
6868
  base.notify(e);
@@ -7076,11 +7087,13 @@ async function repl(args, ai, cfg, cwd) {
7076
7087
  if (data) resumeInto(data);
7077
7088
  else err(red(" no such session\n"));
7078
7089
  };
7090
+ const announcedTasks = /* @__PURE__ */ new Set();
7079
7091
  const turn = async (task) => {
7080
7092
  const r = await runTurn(face, store, session, task, duplex ? void 0 : checkpoints, cwd, sendVia);
7081
7093
  if (dx) {
7082
- const running = [...dx.tasks.values()].filter((t) => t.status === "running");
7083
- if (running.length) err(cyan(` \u25D4 ${running.length === 1 ? `task ${running[0].id} (${running[0].label})` : `${running.length} tasks`} still working in the background`) + dim(" \u2014 the result will appear here; keep chatting meanwhile\n"));
7094
+ const fresh = [...dx.tasks.values()].filter((t) => t.status === "running" && !announcedTasks.has(t.id));
7095
+ fresh.forEach((t) => announcedTasks.add(t.id));
7096
+ if (fresh.length) err(cyan(` \u25D4 ${fresh.length === 1 ? `task ${fresh[0].id} (${fresh[0].label})` : `${fresh.length} tasks`} working in the background`) + dim(" \u2014 the result will appear here; keep chatting meanwhile\n"));
7084
7097
  }
7085
7098
  return r;
7086
7099
  };
@@ -7628,6 +7641,7 @@ ${extra}` : body);
7628
7641
  return { hits, token, describe };
7629
7642
  };
7630
7643
  const editor = createLineEditor(process.stderr);
7644
+ editorRef = editor;
7631
7645
  let aborting = false;
7632
7646
  let pendingRewind = false;
7633
7647
  if (process.stdin.isTTY) {
@@ -7684,11 +7698,13 @@ ${extra}` : body);
7684
7698
  const r = work.reasoning;
7685
7699
  if (r && r !== "off") parts.push(`reasoning:${r}`);
7686
7700
  if (verboseOutput) parts.push("verbose");
7687
- if (dx?.tasks.size) {
7701
+ const taskLines = [];
7702
+ if (dx) {
7688
7703
  const frames = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
7689
- parts.push(`tasks: ${[...dx.tasks.values()].map((t) => t.status === "running" ? `${frames[tick++ % frames.length]} ${t.id} working\u2026` : `${t.id}:${t.status}`).join(" ")}`);
7704
+ for (const t of dx.tasks.values()) if (t.status === "running") taskLines.push(`\u25D4 ${frames[tick % frames.length]} ${t.id} ${t.label} \u2014 working in background\u2026`);
7705
+ if (taskLines.length) tick++;
7690
7706
  }
7691
- return parts.join(" \xB7 ");
7707
+ return [...taskLines, parts.join(" \xB7 ")].filter(Boolean).join("\n");
7692
7708
  };
7693
7709
  const result = await readMultiline((cont) => editor.readLine({
7694
7710
  prompt: cont ? contPrompt : promptStr,