dsh-any-agent 0.6.1 → 0.6.3

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/src/live-view.mjs CHANGED
@@ -76,6 +76,9 @@ function newConv(id) {
76
76
  opened_at: null,
77
77
  last_ts: null,
78
78
  closed: false,
79
+ /** DSH 会话累计 token(含不在 live 里的更早回合)。 */
80
+ session_tokens: null,
81
+ context: null,
79
82
  runs: [],
80
83
  };
81
84
  }
@@ -98,10 +101,43 @@ function newRun(id) {
98
101
  auto_approvals: null,
99
102
  auto_escalations: null,
100
103
  writer: null,
104
+ /** 本回合 token 增量 {input, output, cache_read, cache_write}(来自 usage 事件)。 */
105
+ tokens: null,
106
+ /** 上下文窗口占用 {used, window}。 */
107
+ context: null,
101
108
  items: [],
102
109
  };
103
110
  }
104
111
 
112
+ const TOKEN_KEYS = ['input', 'output', 'cache_read', 'cache_write'];
113
+
114
+ /** 规整一组 token 计数;不是对象时返回 null。 */
115
+ function cleanTokens(t) {
116
+ if (!t || typeof t !== 'object') return null;
117
+ const out = {};
118
+ for (const k of TOKEN_KEYS) out[k] = Number.isFinite(t[k]) && t[k] > 0 ? t[k] : 0;
119
+ return out;
120
+ }
121
+
122
+ /** 输入总量(未命中缓存 + 缓存读 + 缓存写)。 */
123
+ export function tokenInputTotal(t) {
124
+ return t ? t.input + t.cache_read + t.cache_write : 0;
125
+ }
126
+
127
+ /** 缓存命中率(缓存读 / 输入总量),没有输入时为 null。 */
128
+ export function cacheHitRate(t) {
129
+ const all = tokenInputTotal(t);
130
+ return all > 0 ? t.cache_read / all : null;
131
+ }
132
+
133
+ /** 1234 → 1.2k,1500000 → 1.5M。 */
134
+ export function fmtTokens(n) {
135
+ if (!Number.isFinite(n)) return '';
136
+ if (n < 1000) return String(Math.round(n));
137
+ if (n < 1e6) return `${(n / 1000).toFixed(n < 10_000 ? 1 : 0)}k`;
138
+ return `${(n / 1e6).toFixed(n < 1e7 ? 2 : 1)}M`;
139
+ }
140
+
105
141
  /**
106
142
  * 事件归并器。纯内存、与文件无关,方便单测。
107
143
  * `apply(ev)` 吃一条事件;`view()` 给出可序列化的调用链快照。
@@ -238,6 +274,18 @@ export class LiveState {
238
274
  }
239
275
  break;
240
276
  }
277
+ case 'usage': {
278
+ const r = this.#run(c, ev.run);
279
+ if (r) {
280
+ const t = cleanTokens(ev.tokens);
281
+ if (t) r.tokens = t;
282
+ if (ev.context && Number.isFinite(ev.context.window)) r.context = { used: ev.context.used ?? 0, window: ev.context.window };
283
+ }
284
+ const s = cleanTokens(ev.session_tokens);
285
+ if (s) c.session_tokens = s;
286
+ if (ev.context && Number.isFinite(ev.context.window)) c.context = { used: ev.context.used ?? 0, window: ev.context.window };
287
+ break;
288
+ }
241
289
  case 'interject': {
242
290
  const r = this.#run(c, ev.run, { create: false });
243
291
  if (r) this.#push(r, { kind: 'interject', at: ev.ts, mode: ev.mode ?? null, text_preview: ev.text_preview ?? null, pending_run: ev.pending_run ?? null });
@@ -307,6 +355,9 @@ export class LiveState {
307
355
  opened_at: c.opened_at,
308
356
  last_ts: c.last_ts,
309
357
  state,
358
+ /** 会话累计(DSH 自己记的,含更早的回合);没有就用 live 里各回合之和。 */
359
+ tokens: c.session_tokens ?? sumTokens(runs.map((r) => r.tokens)),
360
+ context: c.context,
310
361
  runs,
311
362
  };
312
363
  });
@@ -329,12 +380,25 @@ export class LiveState {
329
380
  queued: convs.reduce((n, c) => n + c.runs.filter((r) => r.status === 'queued').length, 0),
330
381
  pending_approvals: convs.reduce((n, c) => n + c.runs.reduce((m, r) => m + r.pending_approvals, 0), 0),
331
382
  escalations: convs.reduce((n, c) => n + c.runs.reduce((m, r) => m + r.escalations, 0), 0),
383
+ tokens: sumTokens(convs.map((c) => c.tokens)),
332
384
  },
333
385
  groups: [...groups.values()],
334
386
  };
335
387
  }
336
388
  }
337
389
 
390
+ /** 把若干组 token 计数相加;全是空时返回 null。 */
391
+ export function sumTokens(list) {
392
+ let any = false;
393
+ const out = { input: 0, output: 0, cache_read: 0, cache_write: 0 };
394
+ for (const t of list) {
395
+ if (!t) continue;
396
+ any = true;
397
+ for (const k of TOKEN_KEYS) out[k] += t[k] ?? 0;
398
+ }
399
+ return any ? out : null;
400
+ }
401
+
338
402
  function rank(state) {
339
403
  return state === 'running' ? 0 : state === 'queued' ? 1 : state === 'idle' ? 2 : 3;
340
404
  }
@@ -437,7 +501,11 @@ export class LiveTail {
437
501
  return changed;
438
502
  }
439
503
 
440
- /** 标题:DSH 原生标题(投影缓存)> 注册表 titleHint > conv.open 的 title_hint。 */
504
+ /**
505
+ * 标题:调用方给的 title_hint(注册表 > conv.open 事件)> DSH 原生标题(投影缓存)。
506
+ * DSH 原生标题只是首条 prompt 的截断前缀("在当前目录做一个简易的、可"),
507
+ * 有显式 title_hint 时它更可读。
508
+ */
441
509
  #refreshTitles() {
442
510
  const t = Date.now();
443
511
  if (t - this.titlesAt < TITLE_TTL_MS) return false;
@@ -452,16 +520,15 @@ export class LiveTail {
452
520
  }
453
521
  }
454
522
  let changed = false;
455
- for (const id of this.state.convs.keys()) {
456
- let title = null;
457
- if (this.readTitle) {
523
+ for (const [id, conv] of this.state.convs) {
524
+ let title = hints.get(id) ?? conv.title_hint ?? null;
525
+ if (!title && this.readTitle) {
458
526
  try {
459
527
  title = this.readTitle(id) ?? null;
460
528
  } catch {
461
529
  title = null;
462
530
  }
463
531
  }
464
- title = title ?? hints.get(id) ?? null;
465
532
  if (title && this.titles.get(id) !== title) {
466
533
  this.titles.set(id, title);
467
534
  changed = true;
@@ -475,6 +542,190 @@ export class LiveTail {
475
542
  }
476
543
  }
477
544
 
545
+ // ── 终端原地刷新(watch) ───────────────────────────────────────
546
+
547
+ const ANSI_RE = /\x1b\[[0-9;?]*[A-Za-z]/y;
548
+
549
+ /** 单个码点在终端里占几列:CJK / 全角 / emoji 记 2,其余 1(框线字符在主流终端里是 1)。 */
550
+ export function charWidth(cp) {
551
+ if (cp < 0x1100) return 1;
552
+ if (
553
+ (cp >= 0x1100 && cp <= 0x115f) ||
554
+ (cp >= 0x2e80 && cp <= 0x303e) ||
555
+ (cp >= 0x3041 && cp <= 0x33ff) ||
556
+ (cp >= 0x3400 && cp <= 0x4dbf) ||
557
+ (cp >= 0x4e00 && cp <= 0x9fff) ||
558
+ (cp >= 0xa000 && cp <= 0xa4cf) ||
559
+ (cp >= 0xac00 && cp <= 0xd7a3) ||
560
+ (cp >= 0xf900 && cp <= 0xfaff) ||
561
+ (cp >= 0xfe30 && cp <= 0xfe4f) ||
562
+ (cp >= 0xff00 && cp <= 0xff60) ||
563
+ (cp >= 0xffe0 && cp <= 0xffe6) ||
564
+ (cp >= 0x1f300 && cp <= 0x1faff) ||
565
+ (cp >= 0x20000 && cp <= 0x3fffd)
566
+ ) {
567
+ return 2;
568
+ }
569
+ return 1;
570
+ }
571
+
572
+ /** 可见宽度(忽略 ANSI 颜色序列)。 */
573
+ export function displayWidth(s) {
574
+ let w = 0;
575
+ for (let i = 0; i < s.length; ) {
576
+ ANSI_RE.lastIndex = i;
577
+ const m = ANSI_RE.exec(s);
578
+ if (m) {
579
+ i += m[0].length;
580
+ continue;
581
+ }
582
+ const cp = s.codePointAt(i);
583
+ w += charWidth(cp);
584
+ i += cp > 0xffff ? 2 : 1;
585
+ }
586
+ return w;
587
+ }
588
+
589
+ /**
590
+ * 把一行截到 `cols` 列以内(保留颜色序列,超出时末尾放 `…`)。
591
+ * 不截的话长行会折到下一行,原地刷新时整棵树就错位了。
592
+ */
593
+ export function clipLine(s, cols) {
594
+ if (!(cols > 1) || displayWidth(s) <= cols) return s;
595
+ let w = 0;
596
+ let out = '';
597
+ for (let i = 0; i < s.length; ) {
598
+ ANSI_RE.lastIndex = i;
599
+ const m = ANSI_RE.exec(s);
600
+ if (m) {
601
+ out += m[0];
602
+ i += m[0].length;
603
+ continue;
604
+ }
605
+ const cp = s.codePointAt(i);
606
+ const cw = charWidth(cp);
607
+ if (w + cw > cols - 1) break;
608
+ out += String.fromCodePoint(cp);
609
+ w += cw;
610
+ i += cp > 0xffff ? 2 : 1;
611
+ }
612
+ return out + '…\x1b[0m';
613
+ }
614
+
615
+ // ── 界面语言 ────────────────────────────────────────────────
616
+
617
+ /** watch / dashboard 命令行界面的两份文案。函数式条目负责插值。 */
618
+ export const TEXT = {
619
+ zh: {
620
+ header: (c, r) => `DSH live · ${c} 会话 · ${r} 运行中`,
621
+ queued: (n) => `${n} 排队`,
622
+ pending: (n) => `${n} 待审批`,
623
+ escalations: (n) => `⚠ ${n} 次提权`,
624
+ tokens: (i, o) => `token 入 ${i} / 出 ${o}`,
625
+ unknownClient: '未知客户端',
626
+ exited: ' (已退出)',
627
+ running: '运行中',
628
+ queuedState: '排队',
629
+ closed: '已释放',
630
+ idle: '空闲',
631
+ total: (i, o) => ` · 累计 ${i}/${o}`,
632
+ context: (p) => ` · 上下文 ${p}%`,
633
+ untitled: '(无标题)',
634
+ tools: (n) => `${n} 工具`,
635
+ runEscalations: (n) => `⚠${n} 提权`,
636
+ earlier: (n) => `…前面还有 ${n} 条`,
637
+ noMatch: (q) => `没有匹配 ${q} 的会话。`,
638
+ empty: '还没有任何事件。派一次活(dsh_send)之后这里就会出现。',
639
+ approval: '审批',
640
+ waiting: ' → 等待裁决',
641
+ interject: '插话',
642
+ interrupt: '■ 中断',
643
+ hiddenRows: (n) => `…还有 ${n} 行没显示(给会话 id 前缀、或用 --runs / --items 收窄)`,
644
+ footer: (time, dir) => `更新于 ${time} · live 目录: ${dir} · Ctrl+C 退出`,
645
+ },
646
+ en: {
647
+ header: (c, r) => `DSH live · ${c} conversation${c === 1 ? '' : 's'} · ${r} running`,
648
+ queued: (n) => `${n} queued`,
649
+ pending: (n) => `${n} awaiting approval`,
650
+ escalations: (n) => `⚠ ${n} escalation${n === 1 ? '' : 's'}`,
651
+ tokens: (i, o) => `tokens in ${i} / out ${o}`,
652
+ unknownClient: 'unknown client',
653
+ exited: ' (exited)',
654
+ running: 'running',
655
+ queuedState: 'queued',
656
+ closed: 'released',
657
+ idle: 'idle',
658
+ total: (i, o) => ` · total ${i}/${o}`,
659
+ context: (p) => ` · context ${p}%`,
660
+ untitled: '(untitled)',
661
+ tools: (n) => `${n} tool${n === 1 ? '' : 's'}`,
662
+ runEscalations: (n) => `⚠${n} escalation${n === 1 ? '' : 's'}`,
663
+ earlier: (n) => `…${n} earlier`,
664
+ noMatch: (q) => `No conversation matches ${q}.`,
665
+ empty: 'No events yet. Dispatch something (dsh_send) and it shows up here.',
666
+ approval: 'approval',
667
+ waiting: ' → awaiting decision',
668
+ interject: 'interject',
669
+ interrupt: '■ interrupted',
670
+ hiddenRows: (n) => `…${n} more line${n === 1 ? '' : 's'} hidden (pass a conversation id prefix, or narrow with --runs / --items)`,
671
+ footer: (time, dir) => `updated ${time} · live dir: ${dir} · Ctrl+C to quit`,
672
+ },
673
+ };
674
+
675
+ /**
676
+ * 界面语言:显式 `zh` / `en` 优先;否则看 DSH_MCP_LANG,再看 LC_ALL / LC_MESSAGES / LANG,
677
+ * 最后看系统区域设置(Windows 上通常没有 LANG)。以 zh 开头 → 中文,其余 → 英文。
678
+ */
679
+ export function detectLang(explicit = null, env = process.env, locale = null) {
680
+ const pick = (v) => (typeof v === 'string' && v.trim() ? v.trim().toLowerCase() : null);
681
+ const norm = (v) => (v.startsWith('zh') ? 'zh' : 'en');
682
+ const direct = pick(explicit) ?? pick(env.DSH_MCP_LANG);
683
+ if (direct === 'zh' || direct === 'en') return direct;
684
+ if (direct) return norm(direct);
685
+ const fromEnv = pick(env.LC_ALL) ?? pick(env.LC_MESSAGES) ?? pick(env.LANG);
686
+ if (fromEnv && fromEnv !== 'c' && fromEnv !== 'posix') return norm(fromEnv);
687
+ let sys = locale;
688
+ if (!sys) {
689
+ try {
690
+ sys = Intl.DateTimeFormat().resolvedOptions().locale;
691
+ } catch {
692
+ sys = 'en';
693
+ }
694
+ }
695
+ return norm(String(sys).toLowerCase());
696
+ }
697
+
698
+ const T = (lang) => TEXT[lang] ?? TEXT.zh;
699
+
700
+ /**
701
+ * 把一帧文本排成"适合这个终端"的行:截宽、截高(超出的行数在最后一行说明)。
702
+ * 纯函数,方便测试。
703
+ */
704
+ export function layoutFrame(text, { cols = 120, rows = 40, lang = 'zh' } = {}) {
705
+ let lines = String(text).split('\n').map((l) => clipLine(l, cols));
706
+ if (rows > 2 && lines.length > rows) {
707
+ const hidden = lines.length - (rows - 1);
708
+ lines = lines.slice(0, rows - 1);
709
+ lines.push(clipLine(`\x1b[2m${T(lang).hiddenRows(hidden)}\x1b[0m`, cols));
710
+ }
711
+ return lines;
712
+ }
713
+
714
+ /**
715
+ * 计算从上一帧到这一帧要写的终端序列:只重写变化的行,多出来的旧行清掉。
716
+ * 第一帧(prev 为 null)整屏重画。返回要写出的字符串(无变化时为空串)。
717
+ */
718
+ export function diffFrame(prev, next) {
719
+ let out = '';
720
+ if (!prev) out += '\x1b[H\x1b[2J';
721
+ for (let i = 0; i < next.length; i++) {
722
+ if (prev && prev[i] === next[i]) continue;
723
+ out += `\x1b[${i + 1};1H${next[i]}\x1b[0m\x1b[K`;
724
+ }
725
+ if (prev && prev.length > next.length) out += `\x1b[${next.length + 1};1H\x1b[J`;
726
+ return out;
727
+ }
728
+
478
729
  // ── 终端渲染(watch) ───────────────────────────────────────────
479
730
 
480
731
  const STATUS_MARK = {
@@ -511,8 +762,10 @@ function clip(s, n) {
511
762
  * @param {number} [opts.runs] 每个会话显示最近几轮(默认 3)
512
763
  * @param {number} [opts.items] 每轮显示最后几条工具/审批(默认 12)
513
764
  * @param {boolean} [opts.color] ANSI 颜色
765
+ * @param {'zh'|'en'} [opts.lang] 界面语言(默认中文)
514
766
  */
515
- export function renderText(view, { conv = null, runs = 3, items = 12, color = false } = {}) {
767
+ export function renderText(view, { conv = null, runs = 3, items = 12, color = false, lang = 'zh' } = {}) {
768
+ const L = T(lang);
516
769
  const c = (code, s) => (color ? `\x1b[${code}m${s}\x1b[0m` : s);
517
770
  const dim = (s) => c('2', s);
518
771
  const warn = (s) => c('33', s);
@@ -521,24 +774,27 @@ export function renderText(view, { conv = null, runs = 3, items = 12, color = fa
521
774
  const out = [];
522
775
  const t = view.totals;
523
776
  out.push(
524
- `DSH live · ${t.conversations} 会话 · ${t.running} 运行中` +
525
- (t.queued ? ` · ${t.queued} 排队` : '') +
526
- (t.pending_approvals ? ` · ${warn(`${t.pending_approvals} 待审批`)}` : '') +
527
- (t.escalations ? ` · ${warn(`⚠ ${t.escalations} 次提权`)}` : ''),
777
+ L.header(t.conversations, t.running) +
778
+ (t.queued ? ` · ${L.queued(t.queued)}` : '') +
779
+ (t.pending_approvals ? ` · ${warn(L.pending(t.pending_approvals))}` : '') +
780
+ (t.escalations ? ` · ${warn(L.escalations(t.escalations))}` : '') +
781
+ (t.tokens ? ` · ${L.tokens(fmtTokens(tokenInputTotal(t.tokens)), fmtTokens(t.tokens.output))}` : ''),
528
782
  );
529
783
  let shown = 0;
530
784
  for (const g of view.groups) {
531
785
  const convs = conv ? g.conversations.filter((x) => x.id.startsWith(conv)) : g.conversations;
532
786
  if (!convs.length) continue;
533
787
  out.push('');
534
- out.push(`${g.client ?? '未知客户端'} ${dim(`pid ${g.pid ?? '?'}${g.alive ? '' : ' (已退出)'}`)}`);
788
+ out.push(`${g.client ?? L.unknownClient} ${dim(`pid ${g.pid ?? '?'}${g.alive ? '' : L.exited}`)}`);
535
789
  convs.forEach((cv, ci) => {
536
790
  shown++;
537
791
  const lastConv = ci === convs.length - 1;
538
792
  const p1 = lastConv ? '└─ ' : '├─ ';
539
793
  const p1c = lastConv ? ' ' : '│ ';
540
- const stateTxt = cv.state === 'running' ? good('运行中') : cv.state === 'queued' ? warn('排队') : dim(cv.state === 'closed' ? '已释放' : '空闲');
541
- out.push(`${p1}${shortId(cv.id)} ${clip(cv.title ?? '(无标题)', 40)} ${stateTxt} ${dim(`${cv.permission ?? ''} · ${clip(cv.cwd ?? '', 50)}`)}`);
794
+ const stateTxt = cv.state === 'running' ? good(L.running) : cv.state === 'queued' ? warn(L.queuedState) : dim(cv.state === 'closed' ? L.closed : L.idle);
795
+ const ctx = cv.context && cv.context.window ? L.context(Math.round((cv.context.used / cv.context.window) * 100)) : '';
796
+ const tok = cv.tokens ? L.total(fmtTokens(tokenInputTotal(cv.tokens)), fmtTokens(cv.tokens.output)) : '';
797
+ out.push(`${p1}${shortId(cv.id)} ${clip(cv.title ?? L.untitled, 40)} ${stateTxt}${dim(tok + ctx)} ${dim(`${cv.permission ?? ''} · ${clip(cv.cwd ?? '', 50)}`)}`);
542
798
  const rs = cv.runs.slice(-runs);
543
799
  rs.forEach((r, ri) => {
544
800
  const lastRun = ri === rs.length - 1;
@@ -550,19 +806,20 @@ export function renderText(view, { conv = null, runs = 3, items = 12, color = fa
550
806
  r.via ? `[${r.via}]` : null,
551
807
  r.status,
552
808
  r.duration_ms != null ? fmtMs(r.duration_ms) : null,
553
- r.tool_count != null ? `${r.tool_count} 工具` : null,
554
- r.escalations ? warn(`⚠${r.escalations} 提权`) : null,
555
- r.pending_approvals ? warn(`${r.pending_approvals} 待审批`) : null,
809
+ r.tool_count != null ? L.tools(r.tool_count) : null,
810
+ r.tokens ? `${fmtTokens(tokenInputTotal(r.tokens))}↑ ${fmtTokens(r.tokens.output)}↓ tok` : null,
811
+ r.escalations ? warn(L.runEscalations(r.escalations)) : null,
812
+ r.pending_approvals ? warn(L.pending(r.pending_approvals)) : null,
556
813
  ].filter(Boolean);
557
814
  out.push(`${p2}${markC} ${r.run} ${meta.join(' · ')}${r.prompt_preview ? ` ${dim(`“${clip(r.prompt_preview, 60)}”`)}` : ''}`);
558
815
  if (r.error) out.push(`${p2c} ${bad(clip(r.error, 100))}`);
559
816
  const its = r.items.slice(-items);
560
- if (r.items.length > its.length) out.push(`${p2c} ${dim(`…前面还有 ${r.items.length - its.length} 条`)}`);
561
- for (const it of its) out.push(p2c + ' ' + renderItem(it, { warn, bad, good, dim }, cv.cwd));
817
+ if (r.items.length > its.length) out.push(`${p2c} ${dim(L.earlier(r.items.length - its.length))}`);
818
+ for (const it of its) out.push(p2c + ' ' + renderItem(it, { warn, bad, good, dim }, cv.cwd, L));
562
819
  });
563
820
  });
564
821
  }
565
- if (!shown) out.push('', dim(conv ? `没有匹配 ${conv} 的会话。` : '还没有任何事件。派一次活(dsh_send)之后这里就会出现。'));
822
+ if (!shown) out.push('', dim(conv ? L.noMatch(conv) : L.empty));
566
823
  return out.join('\n');
567
824
  }
568
825
 
@@ -575,18 +832,18 @@ export function relToCwd(text, cwd) {
575
832
  return out.split(root).join('.');
576
833
  }
577
834
 
578
- function renderItem(it, { warn, bad, good, dim }, cwd) {
835
+ function renderItem(it, { warn, bad, good, dim }, cwd, L = TEXT.zh) {
579
836
  if (it.kind === 'tool') {
580
837
  const st = it.status === 'completed' ? good('✓') : it.status === 'failed' ? bad('✗') : it.status === 'unfinished' ? dim('·') : warn('▶');
581
838
  const what = relToCwd(it.input_preview ?? (it.title !== it.name ? it.title : '') ?? '', cwd);
582
839
  return `${st} ${it.name ?? it.title ?? it.id ?? 'tool'}${what ? ` ${dim(clip(what, 70))}` : ''}${it.elapsed_ms != null ? ` ${dim(fmtMs(it.elapsed_ms))}` : ''}`;
583
840
  }
584
841
  if (it.kind === 'approval') {
585
- const decided = it.decided ? ` → ${it.decided.decision ?? it.decided.effective ?? ''}${it.decided.by ? `(${it.decided.by})` : ''}` : it.mode === 'ask' ? warn(' → 等待裁决') : '';
842
+ const decided = it.decided ? ` → ${it.decided.decision ?? it.decided.effective ?? ''}${it.decided.by ? `(${it.decided.by})` : ''}` : it.mode === 'ask' ? warn(L.waiting) : '';
586
843
  const esc = it.escalation ? warn(` ⚠ ${it.escalation}`) : '';
587
- return `${warn('◆')} 审批 ${it.mode ?? ''}${esc}${decided}${it.command_preview ? ` ${dim(clip(relToCwd(it.command_preview, cwd), 60))}` : ''}`;
844
+ return `${warn('◆')} ${L.approval} ${it.mode ?? ''}${esc}${decided}${it.command_preview ? ` ${dim(clip(relToCwd(it.command_preview, cwd), 60))}` : ''}`;
588
845
  }
589
- if (it.kind === 'interject') return `${warn('↪')} 插话(${it.mode ?? ''})${it.text_preview ? ` ${dim(clip(it.text_preview, 60))}` : ''}`;
590
- if (it.kind === 'interrupt') return bad('■ 中断');
846
+ if (it.kind === 'interject') return `${warn('↪')} ${L.interject}(${it.mode ?? ''})${it.text_preview ? ` ${dim(clip(it.text_preview, 60))}` : ''}`;
847
+ if (it.kind === 'interrupt') return bad(L.interrupt);
591
848
  return dim(it.kind);
592
849
  }