@oxecli/oxe 1.0.91 → 1.0.94
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 +9 -1
- package/dist/engine.js +9 -4
- package/dist/ui.js +73 -36
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -240,6 +240,12 @@ export class CLI {
|
|
|
240
240
|
else if (typ === "footer") {
|
|
241
241
|
process.stdout.write(mutedMarkdown(text) + "\n");
|
|
242
242
|
}
|
|
243
|
+
else if (typ === "warning") {
|
|
244
|
+
process.stdout.write(`\x1b[33m${text}\x1b[0m\n`);
|
|
245
|
+
}
|
|
246
|
+
else if (typ === "error") {
|
|
247
|
+
process.stdout.write(`\x1b[31m${text}\x1b[0m\n`);
|
|
248
|
+
}
|
|
243
249
|
else {
|
|
244
250
|
process.stdout.write(mutedMarkdown(text) + "\n");
|
|
245
251
|
}
|
|
@@ -457,7 +463,9 @@ export class CLI {
|
|
|
457
463
|
continue;
|
|
458
464
|
}
|
|
459
465
|
dockAppendContent(`\x1b[1;36m❯\x1b[0m ${userDisplayText(input, spans)}\n`);
|
|
460
|
-
|
|
466
|
+
// Empty the prompt field as soon as the prompt is sent. Only a draft
|
|
467
|
+
// typed while the query runs is restored into the next box.
|
|
468
|
+
this.lastPrompt = "";
|
|
461
469
|
queryStarted = true;
|
|
462
470
|
const stopCapture = startDraftCapture(() => engine.interrupt());
|
|
463
471
|
try {
|
package/dist/engine.js
CHANGED
|
@@ -484,14 +484,14 @@ export class InferenceEngine {
|
|
|
484
484
|
catch (err2) {
|
|
485
485
|
if (this.interrupted)
|
|
486
486
|
throw new Error("interrupt");
|
|
487
|
-
renderErrorPanel(`API Error: ${err2}
|
|
487
|
+
renderErrorPanel(`API Error: ${err2}`, story);
|
|
488
488
|
return;
|
|
489
489
|
}
|
|
490
490
|
}
|
|
491
491
|
else {
|
|
492
492
|
if (this.interrupted)
|
|
493
493
|
throw new Error("interrupt");
|
|
494
|
-
renderErrorPanel(`API Error: ${err}
|
|
494
|
+
renderErrorPanel(`API Error: ${err}`, story);
|
|
495
495
|
return;
|
|
496
496
|
}
|
|
497
497
|
}
|
|
@@ -586,9 +586,13 @@ export class InferenceEngine {
|
|
|
586
586
|
// The preceding tool action already leaves the cursor on a blank row, so
|
|
587
587
|
// no extra newline is needed above; renderPanel ends with its own "\n",
|
|
588
588
|
// and the prompt adds one leading "\n" -> exactly one blank row below.
|
|
589
|
+
const maxIterationMsg = "⚠ Max tool-call iterations reached for this turn. The work so far is " +
|
|
590
|
+
"saved. If you want the agent to keep going, type continue and the next " +
|
|
591
|
+
"step will resume from where it left off.";
|
|
589
592
|
renderPanel("[bold yellow]⚠ Max tool-call iterations reached for this turn.[/bold yellow]\n" +
|
|
590
593
|
"[yellow]The work so far is saved. If you want the agent to keep going, type " +
|
|
591
594
|
"[bold]continue[/bold] and the next step will resume from where it left off.[/yellow]", "Warning", "", false, "33");
|
|
595
|
+
story.push({ type: "warning", text: maxIterationMsg });
|
|
592
596
|
if (retryPrompts.length)
|
|
593
597
|
dropRetryPrompts(conversation, inputItems, retryPrompts);
|
|
594
598
|
stripOrphanCalls(conversation);
|
|
@@ -600,7 +604,7 @@ export class InferenceEngine {
|
|
|
600
604
|
if (err?.message === "interrupt" || err?.message === "eof") {
|
|
601
605
|
throw err;
|
|
602
606
|
}
|
|
603
|
-
renderErrorPanel(`Runtime Exception: ${err}
|
|
607
|
+
renderErrorPanel(`Runtime Exception: ${err}`, story);
|
|
604
608
|
}
|
|
605
609
|
finally {
|
|
606
610
|
this.inQuery = false;
|
|
@@ -621,8 +625,9 @@ export class InferenceEngine {
|
|
|
621
625
|
}
|
|
622
626
|
}
|
|
623
627
|
}
|
|
624
|
-
function renderErrorPanel(msg) {
|
|
628
|
+
function renderErrorPanel(msg, story) {
|
|
625
629
|
const text = msg.replace(/\[bold yellow\]|\[yellow\]|\[\/.*?\]/g, "");
|
|
626
630
|
renderPanel(text, "Error", "", true, "31");
|
|
631
|
+
story.push({ type: "error", text: `Error: ${text}` });
|
|
627
632
|
}
|
|
628
633
|
export { renderErrorPanel };
|
package/dist/ui.js
CHANGED
|
@@ -603,21 +603,39 @@ export function dockTearDown() {
|
|
|
603
603
|
dockFrameLines = [];
|
|
604
604
|
}
|
|
605
605
|
}
|
|
606
|
-
/** Park a transient spinner
|
|
607
|
-
*
|
|
608
|
-
*
|
|
609
|
-
*
|
|
606
|
+
/** Park a transient spinner row above the box. "flush" parks it directly under
|
|
607
|
+
* the preceding content (so a tool result is adjacent to its label); "blank"
|
|
608
|
+
* gives it its own blank row above. The single blank gap between content and
|
|
609
|
+
* box is always preserved. Idempotent while parked.
|
|
610
|
+
*
|
|
611
|
+
* This dock uses an erase-and-redraw model (never insert-lines), so it stays
|
|
612
|
+
* stable when the box sits near the bottom of a real terminal, where
|
|
613
|
+
* inserting lines would otherwise scroll the box off-screen. */
|
|
610
614
|
export function dockTransientStart(mode = "blank") {
|
|
611
615
|
if (!docked || dockBoxRows < 1)
|
|
612
616
|
return;
|
|
613
617
|
if (dockTransient)
|
|
614
618
|
return;
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
process.stdout.write("\x1b[1A");
|
|
619
|
-
|
|
620
|
-
|
|
619
|
+
dockEraseBox();
|
|
620
|
+
if (mode === "flush") {
|
|
621
|
+
// Park on the gap row directly under the preceding content (adjacent).
|
|
622
|
+
process.stdout.write("\x1b[1A\r");
|
|
623
|
+
process.stdout.write("\n");
|
|
624
|
+
process.stdout.write(dockFrameLines.join("\n"));
|
|
625
|
+
process.stdout.write(`\x1b[${dockBoxRows - 1}A`);
|
|
626
|
+
process.stdout.write("\x1b[1A\r");
|
|
627
|
+
dockRel = 1;
|
|
628
|
+
}
|
|
629
|
+
else {
|
|
630
|
+
// Park on a fresh spinner row that keeps a blank above and below it.
|
|
631
|
+
process.stdout.write("\n\n");
|
|
632
|
+
process.stdout.write(dockFrameLines.join("\n"));
|
|
633
|
+
process.stdout.write(`\x1b[${dockBoxRows - 1}A`);
|
|
634
|
+
process.stdout.write("\x1b[2A\r");
|
|
635
|
+
dockRel = 2;
|
|
636
|
+
}
|
|
637
|
+
docked = true;
|
|
638
|
+
dockGap = false;
|
|
621
639
|
dockTransient = true;
|
|
622
640
|
}
|
|
623
641
|
/** Erase the box and any transient rows above it, leaving the cursor at boxTop
|
|
@@ -642,9 +660,37 @@ function dockEraseBox() {
|
|
|
642
660
|
dockGap = true;
|
|
643
661
|
dockTransient = false;
|
|
644
662
|
}
|
|
645
|
-
/**
|
|
646
|
-
* (
|
|
647
|
-
|
|
663
|
+
/** Erase the box and transient rows, leaving the cursor on the transient row
|
|
664
|
+
* (so dockReplaceTransient can write new content in its place). */
|
|
665
|
+
function dockEraseBoxKeep() {
|
|
666
|
+
if (!docked || dockBoxRows < 1)
|
|
667
|
+
return;
|
|
668
|
+
process.stdout.write(`\x1b[${dockBoxRows - 1 + dockRel}B`);
|
|
669
|
+
for (let i = 0; i < dockBoxRows; i++) {
|
|
670
|
+
process.stdout.write("\r\x1b[K");
|
|
671
|
+
if (i < dockBoxRows - 1)
|
|
672
|
+
process.stdout.write("\x1b[1A");
|
|
673
|
+
}
|
|
674
|
+
process.stdout.write(`\x1b[${dockRel}A`);
|
|
675
|
+
docked = false;
|
|
676
|
+
dockRel = 0;
|
|
677
|
+
dockGap = true;
|
|
678
|
+
dockTransient = false;
|
|
679
|
+
}
|
|
680
|
+
/** Write one blank gap row then the box frame below the current row, and park
|
|
681
|
+
* the cursor at the box top. */
|
|
682
|
+
function dockRenderBox() {
|
|
683
|
+
if (dockBoxRows < 1)
|
|
684
|
+
return;
|
|
685
|
+
process.stdout.write("\n\n" + dockFrameLines.join("\n"));
|
|
686
|
+
process.stdout.write(`\x1b[${dockBoxRows - 1}A\r`);
|
|
687
|
+
dockRel = 0;
|
|
688
|
+
docked = true;
|
|
689
|
+
dockGap = false;
|
|
690
|
+
dockTransient = false;
|
|
691
|
+
}
|
|
692
|
+
/** Commit content at the box top, pushing the box down, preserving exactly one
|
|
693
|
+
* blank row between the content and the box. */
|
|
648
694
|
export function dockAppendContent(text) {
|
|
649
695
|
if (!text)
|
|
650
696
|
return;
|
|
@@ -652,18 +698,15 @@ export function dockAppendContent(text) {
|
|
|
652
698
|
process.stdout.write(text);
|
|
653
699
|
return;
|
|
654
700
|
}
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
process.stdout.write("\x1b[1B\r");
|
|
701
|
+
dockEraseBox();
|
|
702
|
+
process.stdout.write(text);
|
|
703
|
+
const tb = displayRows(text) - displayRows(text.replace(/\n+$/, ""));
|
|
704
|
+
if (tb > 0)
|
|
705
|
+
process.stdout.write(`\x1b[${tb}A`);
|
|
706
|
+
dockRenderBox();
|
|
662
707
|
}
|
|
663
|
-
/** Replace a transient spinner row
|
|
664
|
-
*
|
|
665
|
-
* down by `rows-1` if the content is taller than the transient row, write the
|
|
666
|
-
* content, and park the cursor at the boxTop with one blank row above it. */
|
|
708
|
+
/** Replace a transient spinner row with real (possibly multi-row) content, then
|
|
709
|
+
* re-dock, keeping exactly one blank row between content and box. */
|
|
667
710
|
export function dockReplaceTransient(text) {
|
|
668
711
|
if (!text)
|
|
669
712
|
return;
|
|
@@ -675,18 +718,12 @@ export function dockReplaceTransient(text) {
|
|
|
675
718
|
dockAppendContent(text);
|
|
676
719
|
return;
|
|
677
720
|
}
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
if (push > 0)
|
|
685
|
-
process.stdout.write(`\x1b[${push}L`);
|
|
686
|
-
process.stdout.write(body);
|
|
687
|
-
process.stdout.write("\x1b[2B\r");
|
|
688
|
-
dockRel = 0;
|
|
689
|
-
dockTransient = false;
|
|
721
|
+
dockEraseBoxKeep();
|
|
722
|
+
process.stdout.write(text);
|
|
723
|
+
const tb = displayRows(text) - displayRows(text.replace(/\n+$/, ""));
|
|
724
|
+
if (tb > 0)
|
|
725
|
+
process.stdout.write(`\x1b[${tb}A`);
|
|
726
|
+
dockRenderBox();
|
|
690
727
|
}
|
|
691
728
|
// ---------------------------------------------------------------------------
|
|
692
729
|
// Cursor & Spinner
|