@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.
Files changed (2) hide show
  1. package/cli/tui.mjs +61 -46
  2. 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)} ${status} ${item.summary || item.action || "Tool call"}`, usable);
244
- if (!color) return [compact];
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)} ${status} `;
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} ${glyph} ${summary}${timing}`;
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
- return activityCategory(item) === "Learn" && !value.startsWith("๐Ÿง ") ? "๐Ÿง  " + value : value;
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(symbol, limit), symbolColor, color)];
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) - 2);
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
- const plain = prefix + symbol + " " + projectText + titleText;
358
- return [color
359
- ? tint(prefix, MONITOR.dim, true) + tint(symbol, symbolColor, true) + " "
360
- + tint(projectText, MONITOR.muted, true) + tint(titleText, MONITOR.bright, true)
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 = 13;
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 = color
371
- ? tint(prefix, MONITOR.dim, true) + tint(symbol, symbolColor, true) + " " + tint(operation, MONITOR.bright, true) + tint(ending, MONITOR.dim, true)
372
- : prefix + symbol + " " + operation + ending;
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 extra = item.error && item.ok === false
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
- return [headline, metadata];
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", 13);
441
- const op = cellPad("OPERATION", Math.max(1, width - 23));
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 = usableHeight >= 6 ? 1 : 0;
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
- if (footerRows) lines.push(monitorFooter(width, this.colorEnabled, online, this.demoMode));
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anusornneal/chat-relay",
3
- "version": "1.3.4",
3
+ "version": "1.3.5",
4
4
  "description": "Zero-checkout remote MCP agent for ChatGPT with terminal, filesystem, process, multi-user, and multi-agent support.",
5
5
  "type": "module",
6
6
  "bin": {