@oxecli/oxe 1.0.32 → 1.0.34

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/engine.js +19 -3
  2. package/package.json +1 -1
package/dist/engine.js CHANGED
@@ -49,6 +49,7 @@ export class InferenceEngine {
49
49
  inQuery = false;
50
50
  activeAbort = null;
51
51
  interrupted = false;
52
+ queryHasOutput = false;
52
53
  temperature;
53
54
  storedResponseIds = [];
54
55
  constructor(config) {
@@ -158,6 +159,15 @@ export class InferenceEngine {
158
159
  process.stdout.write(mutedMarkdown(text) + "\n\n");
159
160
  this.workRows = displayRows(text) + 1;
160
161
  }
162
+ clearWorkLine() {
163
+ if (!this.workActive || this.workRows < 1)
164
+ return;
165
+ for (let i = 0; i < this.workRows; i++) {
166
+ process.stdout.write("\x1b[1A\x1b[2K");
167
+ }
168
+ this.workActive = false;
169
+ this.workRows = 0;
170
+ }
161
171
  async streamOnce(inputItems, stats, story, previousResponseId) {
162
172
  let content = "";
163
173
  let committedLen = 0;
@@ -264,6 +274,8 @@ export class InferenceEngine {
264
274
  finishThinking(true);
265
275
  }
266
276
  else if (etype === "response.output_text.delta") {
277
+ if (event.delta)
278
+ this.queryHasOutput = true;
267
279
  reportWorking();
268
280
  finishThinking(true);
269
281
  content += event.delta;
@@ -291,7 +303,10 @@ export class InferenceEngine {
291
303
  // the elapsed "Thought for Xs" (mirrors Python's `still_thinking` handling).
292
304
  const stillThinking = thinkingStart !== null;
293
305
  finishThinking(stillThinking);
294
- reportWorking();
306
+ if (this.interrupted && !this.queryHasOutput)
307
+ this.clearWorkLine();
308
+ else
309
+ reportWorking();
295
310
  if (content.slice(committedLen))
296
311
  printAiChunk(content.slice(committedLen));
297
312
  }
@@ -424,6 +439,7 @@ export class InferenceEngine {
424
439
  async executeQuery(userPrompt, inputItems, story, pasteSpans) {
425
440
  this.inQuery = true;
426
441
  this.interrupted = false;
442
+ this.queryHasOutput = false;
427
443
  this.activeAbort = new AbortController();
428
444
  hideCursor();
429
445
  inputItems.push({
@@ -539,7 +555,8 @@ export class InferenceEngine {
539
555
  return;
540
556
  }
541
557
  if (!calls.length) {
542
- process.stdout.write("\n" + summary() + "\n");
558
+ const gap = text.endsWith("\n\n") ? "" : text.endsWith("\n") ? "\n" : "\n\n";
559
+ process.stdout.write(gap + summary() + "\n");
543
560
  story.push({ type: "footer", text: footerText() });
544
561
  attachFooter(conversation);
545
562
  attachFooter(inputItems);
@@ -615,6 +632,5 @@ export class InferenceEngine {
615
632
  function renderErrorPanel(msg) {
616
633
  const text = msg.replace(/\[bold yellow\]|\[yellow\]|\[\/.*?\]/g, "");
617
634
  renderPanel(text, "Error", "", true, "31");
618
- process.stdout.write("\n");
619
635
  }
620
636
  export { renderErrorPanel };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oxecli/oxe",
3
- "version": "1.0.32",
3
+ "version": "1.0.34",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },