warden-agent 0.4.0 → 0.5.0
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/README.md +39 -4
- package/package.json +2 -2
- package/src/agent/catalog.mjs +18 -5
- package/src/agent/config.mjs +3 -0
- package/src/agent/images.mjs +165 -0
- package/src/agent/loop.mjs +73 -11
- package/src/agent/models.mjs +16 -3
- package/src/agent/prompt.mjs +5 -1
- package/src/agent/providers.mjs +105 -30
- package/src/agent/texttools.mjs +7 -1
- package/src/agent/tools.mjs +216 -26
- package/src/tui/app.mjs +729 -500
- package/src/tui/render.mjs +26 -4
- package/src/version.mjs +1 -1
package/src/tui/render.mjs
CHANGED
|
@@ -93,16 +93,38 @@ export function toolBody(c, display, { error, denied } = {}) {
|
|
|
93
93
|
|
|
94
94
|
// ---- spinner -----------------------------------------------------------------
|
|
95
95
|
|
|
96
|
+
// One status line, redrawn in place. label may be a function (re-evaluated on every frame); extra() adds text after it
|
|
97
|
+
// (e.g. what you are typing). The line is cut to the terminal width: a wrapped line could not be redrawn in place.
|
|
96
98
|
export class Spinner {
|
|
97
|
-
constructor(out = process.stdout, c = C
|
|
99
|
+
constructor(out = process.stdout, c = C, { hint = "", extra = null } = {}) {
|
|
100
|
+
this.out = out; this.c = c; this.timer = null; this.hint = hint; this.extra = extra; this.i = 0;
|
|
101
|
+
this.frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
|
|
102
|
+
}
|
|
103
|
+
get running() { return !!this.timer; }
|
|
104
|
+
elapsed() { return this.t0 ? Date.now() - this.t0 : 0; }
|
|
98
105
|
start(label = "Thinking") {
|
|
106
|
+
this.label = label;
|
|
99
107
|
if (!this.out.isTTY || this.timer) return;
|
|
100
|
-
this.t0 = Date.now();
|
|
101
|
-
|
|
102
|
-
|
|
108
|
+
this.t0 = Date.now();
|
|
109
|
+
this.draw(); this.timer = setInterval(() => this.draw(), 90);
|
|
110
|
+
}
|
|
111
|
+
draw() {
|
|
112
|
+
const s = Math.floor(this.elapsed() / 1000);
|
|
113
|
+
const label = typeof this.label === "function" ? this.label() : this.label;
|
|
114
|
+
let body = `${label}… ${s}s${this.hint ? " · " + this.hint : ""}${this.extra?.() || ""}`.replace(/[\r\n\t]+/g, " ");
|
|
115
|
+
const room = Math.max(20, (this.out.columns || 80) - 6);
|
|
116
|
+
if (body.length > room) body = body.slice(0, room - 1) + "…";
|
|
117
|
+
this.out.write(`\r\x1b[2K ${this.c.accent(this.frames[this.i++ % this.frames.length])} ${this.c.dim(body)}`);
|
|
103
118
|
}
|
|
104
119
|
setLabel(l) { this.label = l; }
|
|
120
|
+
// print a full line above the spinner without breaking it
|
|
121
|
+
print(line) {
|
|
122
|
+
if (!this.timer) { this.out.write(line + "\n"); return; }
|
|
123
|
+
this.out.write("\r\x1b[2K" + line + "\n"); this.draw();
|
|
124
|
+
}
|
|
105
125
|
stop() { if (!this.timer) return; clearInterval(this.timer); this.timer = null; this.out.write("\r\x1b[2K"); }
|
|
106
126
|
}
|
|
107
127
|
|
|
128
|
+
export const stripAnsi = (s) => String(s).replace(/\x1b\[[0-9;?]*[A-Za-z]/g, "");
|
|
129
|
+
|
|
108
130
|
export const fmtTokens = (n) => (n >= 1000 ? (n / 1000).toFixed(1) + "k" : String(n));
|
package/src/version.mjs
CHANGED