micro-models-agent 0.24.9 → 0.24.11

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/main.js +57 -14
  2. package/package.json +1 -1
package/dist/main.js CHANGED
@@ -25728,6 +25728,7 @@ init_colors();
25728
25728
  init_colors();
25729
25729
  init_i18n();
25730
25730
  init_table();
25731
+ init_string_width();
25731
25732
  var KW = /\b(import|export|from|const|let|var|function|return|if|else|for|while|do|switch|case|break|continue|new|class|extends|implements|interface|type|enum|namespace|module|declare|abstract|async|await|yield|throw|try|catch|finally|typeof|instanceof|in|of|as|is|keyof|readonly|static|private|public|protected|get|set|constructor|this|super|void|never|any|unknown|boolean|string|number|symbol|object|true|false|null|undefined|default)\b/g;
25732
25733
  var STRING = /('[^']*'|"[^"]*"|`[^`]*`)/g;
25733
25734
  var COMMENT = /(\/\/[^\n]*|\/\*[\s\S]*?\*\/|#[^\n]*)/g;
@@ -25776,9 +25777,13 @@ class FormattingStream {
25776
25777
  tableBuffer = [];
25777
25778
  onWrite;
25778
25779
  width;
25779
- constructor(onWrite, width) {
25780
+ streaming;
25781
+ partialEmitted = false;
25782
+ lastPartial = "";
25783
+ constructor(onWrite, width, streaming = false) {
25780
25784
  this.onWrite = onWrite;
25781
25785
  this.width = width ?? getTerminalWidth();
25786
+ this.streaming = streaming;
25782
25787
  }
25783
25788
  write(chunk) {
25784
25789
  this.buffer += chunk;
@@ -25787,10 +25792,13 @@ class FormattingStream {
25787
25792
  `)) !== -1) {
25788
25793
  const line = this.buffer.slice(0, idx);
25789
25794
  this.buffer = this.buffer.slice(idx + 1);
25795
+ this.clearPartial();
25790
25796
  this.processLine(line);
25791
25797
  }
25798
+ this.emitPartial(this.buffer);
25792
25799
  }
25793
25800
  flush() {
25801
+ this.clearPartial();
25794
25802
  if (this.inCodeBlock && this.codeLines.length > 0) {
25795
25803
  this.emitCodeBlock();
25796
25804
  }
@@ -25806,9 +25814,40 @@ class FormattingStream {
25806
25814
  }
25807
25815
  return;
25808
25816
  }
25809
- this.onWrite(this.formatLine(line));
25817
+ this.emitLine(this.formatLine(line));
25810
25818
  }
25811
25819
  }
25820
+ emitLine(text) {
25821
+ this.onWrite(text, true);
25822
+ }
25823
+ emitRaw(text) {
25824
+ this.onWrite(text, false);
25825
+ }
25826
+ clearPartial() {
25827
+ if (!this.streaming || !this.partialEmitted)
25828
+ return;
25829
+ const rows = Math.max(1, Math.ceil(stringWidth(this.lastPartial) / Math.max(1, this.width)));
25830
+ for (let i = 0;i < rows; i++) {
25831
+ this.emitRaw("\x1B[2K");
25832
+ if (i < rows - 1)
25833
+ this.emitRaw("\x1B[1A");
25834
+ }
25835
+ this.emitRaw("\r");
25836
+ this.lastPartial = "";
25837
+ this.partialEmitted = false;
25838
+ }
25839
+ emitPartial(text) {
25840
+ if (!this.streaming || !text)
25841
+ return;
25842
+ if (this.inCodeBlock || this.tableBuffer.length > 0) {
25843
+ this.clearPartial();
25844
+ return;
25845
+ }
25846
+ this.clearPartial();
25847
+ this.emitRaw(text);
25848
+ this.lastPartial = text;
25849
+ this.partialEmitted = true;
25850
+ }
25812
25851
  processLine(line) {
25813
25852
  if (line.trim() === "```" || line.trim().startsWith("```")) {
25814
25853
  if (this.inCodeBlock) {
@@ -25831,7 +25870,7 @@ class FormattingStream {
25831
25870
  if (this.tableBuffer.length > 0) {
25832
25871
  this.flushTable();
25833
25872
  }
25834
- this.onWrite(this.formatLine(line));
25873
+ this.emitLine(this.formatLine(line));
25835
25874
  }
25836
25875
  flushTable() {
25837
25876
  const lines = this.tableBuffer;
@@ -25839,11 +25878,11 @@ class FormattingStream {
25839
25878
  const hasSeparator = lines.length >= 2 && /^\s*\|?[\s:|-]+\|?\s*$/.test(lines[1].trim());
25840
25879
  if (hasSeparator) {
25841
25880
  for (const l of formatTable(lines, { maxWidth: this.width })) {
25842
- this.onWrite(l);
25881
+ this.emitLine(l);
25843
25882
  }
25844
25883
  } else {
25845
25884
  for (const l of lines) {
25846
- this.onWrite(this.formatLine(l));
25885
+ this.emitLine(this.formatLine(l));
25847
25886
  }
25848
25887
  }
25849
25888
  }
@@ -25855,12 +25894,12 @@ class FormattingStream {
25855
25894
  const highlighted = highlight(code, this.codeLang);
25856
25895
  const lang = this.codeLang ? ` ${this.codeLang} ` : " ";
25857
25896
  const top = pc.dim(`┌─${lang}${"─".repeat(Math.max(0, this.width - 3 - lang.length))}┐`);
25858
- this.onWrite(top);
25897
+ this.emitLine(top);
25859
25898
  for (const l of highlighted.split(`
25860
25899
  `)) {
25861
- this.onWrite(pc.dim("│ ") + l);
25900
+ this.emitLine(pc.dim("│ ") + l);
25862
25901
  }
25863
- this.onWrite(pc.dim(`└${"─".repeat(Math.max(0, this.width - 1))}┘`));
25902
+ this.emitLine(pc.dim(`└${"─".repeat(Math.max(0, this.width - 1))}┘`));
25864
25903
  }
25865
25904
  this.codeLines = [];
25866
25905
  this.codeLang = "";
@@ -25972,8 +26011,8 @@ class Renderer {
25972
26011
  stream: this.err,
25973
26012
  width: this.width
25974
26013
  });
25975
- this.fmt = new FormattingStream((line) => this.out.write(`${line}
25976
- `), this.width);
26014
+ this.fmt = new FormattingStream((line, eol) => this.out.write(eol ? `${line}
26015
+ ` : line), this.width, this.rich);
25977
26016
  }
25978
26017
  text(chunk) {
25979
26018
  this.endCard();
@@ -25982,6 +26021,7 @@ class Renderer {
25982
26021
  }
25983
26022
  meta(chunk) {
25984
26023
  this.spinner.stop();
26024
+ this.fmt.clearPartial();
25985
26025
  if (this.card) {
25986
26026
  this.card.body.push(chunk);
25987
26027
  } else {
@@ -25990,6 +26030,7 @@ class Renderer {
25990
26030
  }
25991
26031
  reasoning(chunk) {
25992
26032
  this.spinner.stop();
26033
+ this.fmt.clearPartial();
25993
26034
  this.out.write(pc.dim(chunk));
25994
26035
  }
25995
26036
  thinkingStart() {
@@ -26001,6 +26042,7 @@ class Renderer {
26001
26042
  toolStart(tool, args) {
26002
26043
  this.endCard();
26003
26044
  this.spinner.stop();
26045
+ this.fmt.clearPartial();
26004
26046
  const summary = summarizeArgs2(args);
26005
26047
  if (!this.rich) {
26006
26048
  this.out.write(`
@@ -26052,11 +26094,13 @@ ${pc.dim("⚙")} ${friendlyTool(tool)}${summary ? ` ${pc.dim(summary)}` : ""}
26052
26094
  raw(text) {
26053
26095
  this.endCard();
26054
26096
  this.spinner.stop();
26097
+ this.fmt.clearPartial();
26055
26098
  this.out.write(text);
26056
26099
  }
26057
26100
  error(text) {
26058
26101
  this.endCard();
26059
26102
  this.spinner.stop();
26103
+ this.fmt.clearPartial();
26060
26104
  this.err.write(`${pc.red(text)}
26061
26105
  `);
26062
26106
  }
@@ -26260,9 +26304,8 @@ class Repl {
26260
26304
  this.running = false;
26261
26305
  });
26262
26306
  if (process.stdin.isTTY) {
26263
- readline2.emitKeypressEvents(process.stdin);
26264
- process.stdin.on("keypress", (str, key) => {
26265
- if (key && key.name === "escape") {
26307
+ process.stdin.on("data", (chunk) => {
26308
+ if (chunk.length === 1 && chunk[0] === 27) {
26266
26309
  const now = Date.now();
26267
26310
  if (now - this.lastEscTime < this.doubleEscDelay) {
26268
26311
  if (this.agentRunning) {
@@ -26276,7 +26319,7 @@ ${t("repl.interrupt")}
26276
26319
  }
26277
26320
  this.lastEscTime = now;
26278
26321
  }
26279
- if (key && key.ctrl && key.name === "v" && !this.agentRunning) {
26322
+ if (chunk.length === 1 && chunk[0] === 22 && !this.agentRunning) {
26280
26323
  this.handlePasteImage();
26281
26324
  }
26282
26325
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "micro-models-agent",
3
- "version": "0.24.9",
3
+ "version": "0.24.11",
4
4
  "description": "Micro Models Agent (MMA) — LLM agent harness for small models (Qwen3.5-9B, 32K-64K context)",
5
5
  "type": "module",
6
6
  "bin": {