@oxecli/oxe 1.0.30 → 1.0.32

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/engine.js CHANGED
@@ -492,11 +492,15 @@ export class InferenceEngine {
492
492
  respId = res.responseId;
493
493
  }
494
494
  catch (err2) {
495
+ if (this.interrupted)
496
+ throw new Error("interrupt");
495
497
  renderErrorPanel(`API Error: ${err2}`);
496
498
  return;
497
499
  }
498
500
  }
499
501
  else {
502
+ if (this.interrupted)
503
+ throw new Error("interrupt");
500
504
  renderErrorPanel(`API Error: ${err}`);
501
505
  return;
502
506
  }
package/dist/ui.js CHANGED
@@ -118,7 +118,41 @@ export function markupToAnsi(text) {
118
118
  // Lightweight markdown -> ANSI
119
119
  // ---------------------------------------------------------------------------
120
120
  export function markdownToAnsi(text) {
121
- const lines = text.split("\n");
121
+ const width = Math.max(terminalWidth() || 80, 1);
122
+ const lines = text.split("\n").flatMap((raw) => {
123
+ if (!raw || raw.length <= width)
124
+ return [raw];
125
+ const indent = raw.match(/^\s*/)?.[0] ?? "";
126
+ const words = raw.trim().split(/\s+/);
127
+ const wrapped = [];
128
+ let current = indent;
129
+ for (const word of words) {
130
+ if (word.length > width) {
131
+ if (current.trim())
132
+ wrapped.push(current);
133
+ current = "";
134
+ for (let i = 0; i < word.length; i += width) {
135
+ const part = word.slice(i, i + width);
136
+ if (part.length === width)
137
+ wrapped.push(part);
138
+ else
139
+ current = part;
140
+ }
141
+ continue;
142
+ }
143
+ const next = current.trim() ? `${current} ${word}` : `${current}${word}`;
144
+ if (current.trim() && next.length > width) {
145
+ wrapped.push(current);
146
+ current = `${indent}${word}`;
147
+ }
148
+ else {
149
+ current = next;
150
+ }
151
+ }
152
+ if (current || !wrapped.length)
153
+ wrapped.push(current);
154
+ return wrapped;
155
+ });
122
156
  const out = [];
123
157
  let inCode = false;
124
158
  let codeBuf = [];
@@ -715,8 +749,10 @@ export function askBottomPrompt(label = "You", prefix = "❯", history = []) {
715
749
  process.stdin.setEncoding("utf-8");
716
750
  process.stdin.on("data", (d) => chunks.push(Buffer.from(String(d))));
717
751
  process.stdin.on("end", () => {
718
- const text = Buffer.concat(chunks).toString();
719
- resolve([text.trim(), []]);
752
+ const text = Buffer.concat(chunks).toString().replace(/\r\n/g, "\n").replace(/\r/g, "\n");
753
+ // Piped input commonly ends with the transport newline from the
754
+ // shell. Preserve every newline the user supplied before it.
755
+ resolve([text.endsWith("\n") ? text.slice(0, -1) : text, []]);
720
756
  });
721
757
  return;
722
758
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oxecli/oxe",
3
- "version": "1.0.30",
3
+ "version": "1.0.32",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },