@anusornneal/chat-relay 0.12.0 → 0.13.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/cli/tui.mjs +14 -6
- package/package.json +1 -1
package/cli/tui.mjs
CHANGED
|
@@ -112,6 +112,8 @@ function statusStyle(value) {
|
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
function relayHealthStyle(health) {
|
|
115
|
+
const code = Number(health?.code);
|
|
116
|
+
if (Number.isFinite(code) && code >= 200 && code < 300) return STYLE.green;
|
|
115
117
|
switch (health?.state) {
|
|
116
118
|
case "reachable": return STYLE.green;
|
|
117
119
|
case "checking": return STYLE.yellow;
|
|
@@ -120,6 +122,8 @@ function relayHealthStyle(health) {
|
|
|
120
122
|
}
|
|
121
123
|
|
|
122
124
|
function relayHealthText(health) {
|
|
125
|
+
const code = Number(health?.code);
|
|
126
|
+
if (Number.isFinite(code) && code >= 200 && code < 300) return `● HTTP ${code}`;
|
|
123
127
|
switch (health?.state) {
|
|
124
128
|
case "reachable": return "● Online";
|
|
125
129
|
case "checking": return "◐ Checking";
|
|
@@ -238,7 +242,7 @@ function wrapText(value, width, maxLines = 3) {
|
|
|
238
242
|
export function formatTransactionRows(item, width = 110, { color = false } = {}) {
|
|
239
243
|
const requested = Number(width) || 110;
|
|
240
244
|
const usable = clamp(requested, Math.min(60, Math.max(1, requested)), 180);
|
|
241
|
-
const status = item.status === "running" ? "
|
|
245
|
+
const status = item.status === "running" ? "🟡" : item.ok === false ? "❌" : "✅";
|
|
242
246
|
if (usable < 32) {
|
|
243
247
|
const compact = truncateCells(`${clock(item.at)} ${status} ${item.summary || item.action || "Tool call"}`, usable);
|
|
244
248
|
if (!color) return [compact];
|
|
@@ -246,24 +250,28 @@ export function formatTransactionRows(item, width = 110, { color = false } = {})
|
|
|
246
250
|
return [paint(compact, glyphStyle)];
|
|
247
251
|
}
|
|
248
252
|
const prefix = `${clock(item.at)} ${status} `;
|
|
249
|
-
const
|
|
253
|
+
const prefixWidth = terminalCellWidth(prefix);
|
|
254
|
+
const continuationPrefix = " ".repeat(prefixWidth);
|
|
250
255
|
const duration = formatDuration(item.durationMs, item.status);
|
|
251
256
|
const suffix = " " + duration.padStart(8);
|
|
252
|
-
const summaryWidth = Math.max(4, usable -
|
|
257
|
+
const summaryWidth = Math.max(4, usable - prefixWidth - terminalCellWidth(suffix));
|
|
253
258
|
const summaryLines = wrapText(item.summary || item.action || "Tool call", summaryWidth, 3);
|
|
254
259
|
|
|
255
260
|
return summaryLines.map((line, index) => {
|
|
256
261
|
if (index === 0) {
|
|
257
|
-
|
|
262
|
+
const plainRow = prefix + line.padEnd(summaryWidth) + suffix;
|
|
263
|
+
if (!color) return plainRow;
|
|
264
|
+
if (item.ok === false) return paint(plainRow, STYLE.red);
|
|
258
265
|
const time = paint(clock(item.at), STYLE.gray);
|
|
259
|
-
const glyphStyle = item.status === "running" ? STYLE.yellow :
|
|
266
|
+
const glyphStyle = item.status === "running" ? STYLE.yellow : STYLE.green;
|
|
260
267
|
const glyph = paint(status, glyphStyle, STYLE.bold);
|
|
261
268
|
const summary = item.status === "running" ? paint(line.padEnd(summaryWidth), STYLE.bold) : line.padEnd(summaryWidth);
|
|
262
269
|
const timing = paint(suffix, STYLE.gray);
|
|
263
270
|
return `${time} ${glyph} ${summary}${timing}`;
|
|
264
271
|
}
|
|
265
272
|
if (!color) return continuationPrefix + line;
|
|
266
|
-
|
|
273
|
+
if (item.ok === false) return continuationPrefix + paint(line, STYLE.red);
|
|
274
|
+
return continuationPrefix + paint(line, STYLE.dim);
|
|
267
275
|
});
|
|
268
276
|
}
|
|
269
277
|
|
package/package.json
CHANGED