@anusornneal/chat-relay 1.3.4 โ 1.3.5
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 +61 -46
- package/package.json +1 -1
package/cli/tui.mjs
CHANGED
|
@@ -238,14 +238,11 @@ function wrapText(value, width, maxLines = 3) {
|
|
|
238
238
|
export function formatTransactionRows(item, width = 110, { color = false } = {}) {
|
|
239
239
|
const requested = Number(width) || 110;
|
|
240
240
|
const usable = clamp(requested, Math.min(60, Math.max(1, requested)), 180);
|
|
241
|
-
const status = item.status === "running" ? "๐ก" : item.ok === false ? "โ" : "โ
";
|
|
242
241
|
if (usable < 32) {
|
|
243
|
-
const compact = truncateCells(`${clock(item.at)} ${
|
|
244
|
-
|
|
245
|
-
const glyphStyle = item.status === "running" ? STYLE.yellow : item.ok === false ? STYLE.red : STYLE.green;
|
|
246
|
-
return [paint(compact, glyphStyle)];
|
|
242
|
+
const compact = truncateCells(`${clock(item.at)} ${item.summary || item.action || "Tool call"}`, usable);
|
|
243
|
+
return [color && item.ok === false ? paint(compact, STYLE.red) : compact];
|
|
247
244
|
}
|
|
248
|
-
const prefix = `${clock(item.at)}
|
|
245
|
+
const prefix = `${clock(item.at)} `;
|
|
249
246
|
const prefixWidth = terminalCellWidth(prefix);
|
|
250
247
|
const continuationPrefix = " ".repeat(prefixWidth);
|
|
251
248
|
const duration = formatDuration(item.durationMs, item.status);
|
|
@@ -263,11 +260,9 @@ export function formatTransactionRows(item, width = 110, { color = false } = {})
|
|
|
263
260
|
if (!color) return plainRow;
|
|
264
261
|
if (item.ok === false) return paint(plainRow, STYLE.red);
|
|
265
262
|
const time = paint(clock(item.at), STYLE.gray);
|
|
266
|
-
const glyphStyle = item.status === "running" ? STYLE.yellow : STYLE.green;
|
|
267
|
-
const glyph = paint(status, glyphStyle, STYLE.bold);
|
|
268
263
|
const summary = item.status === "running" ? paint(line.padEnd(summaryWidth), STYLE.bold) : line.padEnd(summaryWidth);
|
|
269
264
|
const timing = paint(suffix, STYLE.gray);
|
|
270
|
-
return `${time} ${
|
|
265
|
+
return `${time} ${summary}${timing}`;
|
|
271
266
|
}
|
|
272
267
|
if (!color) return continuationPrefix + line;
|
|
273
268
|
if (item.ok === false) return continuationPrefix + paint(line, STYLE.red);
|
|
@@ -332,51 +327,78 @@ function activityCategory(item) {
|
|
|
332
327
|
return "Agent";
|
|
333
328
|
}
|
|
334
329
|
|
|
330
|
+
function activityIcon(item) {
|
|
331
|
+
const action = String(item.action || "").toLowerCase();
|
|
332
|
+
const title = String(item.operation || item.summary || "").toLowerCase();
|
|
333
|
+
if (/search/.test(action) || /^(start|search)\b/.test(title)) return "๐";
|
|
334
|
+
if (/(^|\.)(read|readmany|getcontent)(_|$|\.)/.test(action) || /^read\b/.test(title)) return "๐";
|
|
335
|
+
if (/(^|\.)(write|edit|move|mkdir|delete)(_|$|\.)/.test(action) || /^(write|edit|create|delete|move)\b/.test(title)) return "โ๏ธ";
|
|
336
|
+
if (activityCategory(item) === "Terminal") return "๐";
|
|
337
|
+
if (activityCategory(item) === "Filesystem") return "๐";
|
|
338
|
+
return "";
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
function activitySourceIcon(category) {
|
|
342
|
+
return { Filesystem: "๐", Terminal: "๐", Desktop: "๐ฅ๏ธ", Learn: "๐ง " }[category] || "โ๏ธ";
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
function shortActivityDetail(value, project) {
|
|
346
|
+
const normalized = String(value || "").replace(/\\/g, "/").replace(/\s+/g, " ").trim();
|
|
347
|
+
if (!normalized) return "";
|
|
348
|
+
const projectName = String(project || "").toLowerCase();
|
|
349
|
+
const rootMatch = normalized.match(/(?:[A-Za-z]:)?\/[^\s]*?\/Projects\/([^/\s]+)\//i);
|
|
350
|
+
if (rootMatch) {
|
|
351
|
+
const beginning = normalized.slice(0, rootMatch.index);
|
|
352
|
+
const tail = normalized.slice(rootMatch.index + rootMatch[0].length);
|
|
353
|
+
return beginning + (rootMatch[1].toLowerCase() === projectName ? "" : rootMatch[1] + "/") + tail;
|
|
354
|
+
}
|
|
355
|
+
return normalized.replace(/(?:[A-Za-z]:)?\/[^\s]*?\/Projects\//ig, "");
|
|
356
|
+
}
|
|
357
|
+
|
|
335
358
|
function activityTitle(item) {
|
|
336
359
|
const value = String(item.operation || item.summary || item.action || "Tool call").replace(/\s+/g, " ").trim();
|
|
337
360
|
if (!item.operation && /^Run (?:Write-Output|Get-Command|Get-Content|Set-Variable|Start-Process)\b/i.test(value)) {
|
|
338
361
|
return "Execute terminal command";
|
|
339
362
|
}
|
|
340
363
|
// Preserve the familiar Learn marker even when an operation is humanized.
|
|
341
|
-
|
|
364
|
+
if (activityCategory(item) === "Learn") return value.startsWith("๐ง ") ? value : "๐ง " + value;
|
|
365
|
+
const icon = activityIcon(item);
|
|
366
|
+
const cleaned = value.replace(/^(?:Start Search|Search|Read|Write|Filesystem|Terminal)\b\s*/i, "").trim();
|
|
367
|
+
return icon ? icon + " " + (cleaned || value) : value;
|
|
342
368
|
}
|
|
343
369
|
|
|
344
370
|
function activityRows(item, width, { color = false, twoLines = false } = {}) {
|
|
345
371
|
const limit = Math.max(1, width);
|
|
346
372
|
const project = String(item.project || "General");
|
|
347
373
|
const title = activityTitle(item);
|
|
348
|
-
const symbol = item.status === "running" ? "โ" : item.ok === false ? "ร" : "โ";
|
|
349
|
-
const symbolColor = item.status === "running" ? MONITOR.warning : item.ok === false ? MONITOR.bad : MONITOR.good;
|
|
350
374
|
const time = clock(item.at);
|
|
351
375
|
if (limit < 52) {
|
|
352
|
-
if (limit <= 2) return [tint(truncateCells(
|
|
376
|
+
if (limit <= 2) return [tint(truncateCells(title, limit), item.ok === false ? MONITOR.bad : MONITOR.bright, color)];
|
|
353
377
|
const prefix = limit >= 37 ? time.slice(0, 5) + " " : "";
|
|
354
|
-
const bodyWidth = Math.max(0, limit - terminalCellWidth(prefix)
|
|
378
|
+
const bodyWidth = Math.max(0, limit - terminalCellWidth(prefix));
|
|
355
379
|
const projectText = truncateCells(project + " ยท ", bodyWidth);
|
|
356
380
|
const titleText = truncateCells(title, Math.max(0, bodyWidth - terminalCellWidth(projectText)));
|
|
357
|
-
|
|
358
|
-
return [
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
: plain];
|
|
381
|
+
if (!color) return [prefix + projectText + titleText];
|
|
382
|
+
if (item.ok === false) return [tint(prefix + projectText + titleText, MONITOR.bad, true)];
|
|
383
|
+
return [tint(prefix, MONITOR.dim, true) + tint(projectText, MONITOR.muted, true)
|
|
384
|
+
+ tint(titleText, MONITOR.bright, true)];
|
|
362
385
|
}
|
|
363
|
-
const opStart =
|
|
386
|
+
const opStart = 10;
|
|
364
387
|
const durationWidth = 10;
|
|
365
388
|
const operationWidth = Math.max(1, limit - opStart - durationWidth);
|
|
366
389
|
const duration = formatDuration(item.durationMs, item.status);
|
|
367
390
|
const operation = cellPad(title, operationWidth);
|
|
368
391
|
const prefix = cellPad(time, 8) + " ";
|
|
369
392
|
const ending = cellPad(duration, durationWidth);
|
|
370
|
-
const headline =
|
|
371
|
-
? tint(prefix
|
|
372
|
-
:
|
|
393
|
+
const headline = item.ok === false
|
|
394
|
+
? tint(prefix + operation + ending, MONITOR.bad, color)
|
|
395
|
+
: color
|
|
396
|
+
? tint(prefix, MONITOR.dim, true) + tint(operation, MONITOR.bright, true) + tint(ending, MONITOR.dim, true)
|
|
397
|
+
: prefix + operation + ending;
|
|
373
398
|
if (!twoLines) return [headline];
|
|
374
399
|
|
|
375
400
|
const category = activityCategory(item);
|
|
376
|
-
const
|
|
377
|
-
? " ยท Error: " + String(item.error).replace(/\s+/g, " ").slice(0, 70)
|
|
378
|
-
: item.detail ? " ยท " + String(item.detail).replace(/\s+/g, " ").slice(0, 100) : "";
|
|
379
|
-
const secondary = " ยท " + category + extra;
|
|
401
|
+
const secondary = " ยท " + activitySourceIcon(category);
|
|
380
402
|
// Keep request/response telemetry in transaction state but leave it out of
|
|
381
403
|
// the monitoring view, where it competes with operation and project context.
|
|
382
404
|
const textWidth = Math.max(1, limit - opStart);
|
|
@@ -384,10 +406,16 @@ function activityRows(item, width, { color = false, twoLines = false } = {}) {
|
|
|
384
406
|
const rest = truncateCells(secondary, Math.max(0, textWidth - terminalCellWidth(name)));
|
|
385
407
|
const metadata = " ".repeat(opStart)
|
|
386
408
|
+ (color
|
|
387
|
-
? tint(name, item.project ? MONITOR.muted : MONITOR.dim, true)
|
|
409
|
+
? tint(name, item.ok === false ? MONITOR.bad : item.project ? MONITOR.muted : MONITOR.dim, true)
|
|
388
410
|
+ tint(rest, item.ok === false ? MONITOR.bad : MONITOR.dim, true)
|
|
389
411
|
: name + rest);
|
|
390
|
-
|
|
412
|
+
const rows = [headline, metadata];
|
|
413
|
+
const extra = item.error && item.ok === false ? "Error: " + shortActivityDetail(item.error, project)
|
|
414
|
+
: shortActivityDetail(item.detail, project);
|
|
415
|
+
if (extra) {
|
|
416
|
+
rows.push(" ".repeat(opStart) + tint(truncateCells(extra, Math.max(1, limit - opStart)), item.ok === false ? MONITOR.bad : MONITOR.dim, color));
|
|
417
|
+
}
|
|
418
|
+
return rows;
|
|
391
419
|
}
|
|
392
420
|
|
|
393
421
|
function monitorCapabilities(state, width, color) {
|
|
@@ -437,25 +465,12 @@ function monitoringSummary(state, width, layout, color) {
|
|
|
437
465
|
}
|
|
438
466
|
|
|
439
467
|
function headingRow(width, color) {
|
|
440
|
-
const left = cellPad("TIME",
|
|
441
|
-
const op = cellPad("OPERATION", Math.max(1, width -
|
|
468
|
+
const left = cellPad("TIME", 10);
|
|
469
|
+
const op = cellPad("OPERATION", Math.max(1, width - 20));
|
|
442
470
|
const right = cellPad("DURATION", 10);
|
|
443
471
|
return tint(left + op + right, MONITOR.muted, color);
|
|
444
472
|
}
|
|
445
473
|
|
|
446
|
-
function monitorFooter(width, color, online, demo = false) {
|
|
447
|
-
const hint = width >= 65
|
|
448
|
-
? "โโ Scroll ยท End " + (demo ? "Newest" : "Live") + " ยท Ctrl+C Exit"
|
|
449
|
-
: "Ctrl+C Exit";
|
|
450
|
-
const status = demo ? "โ Offline preview" : online ? "โ Connected" : "โ Disconnected";
|
|
451
|
-
if (terminalCellWidth(hint) + terminalCellWidth(status) + 3 > width) {
|
|
452
|
-
return tint(truncateCells(hint, width), MONITOR.dim, color);
|
|
453
|
-
}
|
|
454
|
-
return tint(hint, MONITOR.dim, color)
|
|
455
|
-
+ " ".repeat(width - terminalCellWidth(hint) - terminalCellWidth(status))
|
|
456
|
-
+ tint(status, demo ? MONITOR.accent : online ? MONITOR.accent : MONITOR.warning, color);
|
|
457
|
-
}
|
|
458
|
-
|
|
459
474
|
export class RemoteTui {
|
|
460
475
|
constructor({
|
|
461
476
|
config,
|
|
@@ -559,7 +574,7 @@ export class RemoteTui {
|
|
|
559
574
|
let summaryRows = layout === "wide" ? 4 : layout === "medium" ? 3 : 1;
|
|
560
575
|
let dividerRows = usableHeight >= 6 ? 1 : 0;
|
|
561
576
|
let headingRows = layout === "tiny" ? 0 : 2;
|
|
562
|
-
const footerRows =
|
|
577
|
+
const footerRows = 0;
|
|
563
578
|
let fixedRows = 1 + topLine + summaryRows + dividerRows + 1 + headingRows + footerRows;
|
|
564
579
|
if (fixedRows >= usableHeight && layout !== "tiny") {
|
|
565
580
|
layout = "tiny";
|
|
@@ -816,7 +831,7 @@ export class RemoteTui {
|
|
|
816
831
|
}
|
|
817
832
|
lines.push(...visible);
|
|
818
833
|
while (lines.length < usableHeight - footerRows) lines.push("");
|
|
819
|
-
|
|
834
|
+
|
|
820
835
|
const screen = lines.slice(0, Math.max(1, usableHeight)).join("\n");
|
|
821
836
|
if (screen !== this.previousFrame) {
|
|
822
837
|
this.previousFrame = screen;
|
package/package.json
CHANGED