@each1024/pi-mini-mode 2.0.19 → 2.0.21

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.
@@ -1,3 +1,4 @@
1
+ import type { UiLanguage } from "./settings.ts";
1
2
  import { finiteNumber, formatSpeed, formatUsd, outputSpeed, speedColor, DECODE_SPEED_MIN_OUTPUT, type SpeedColor, type UsageLike } from "./usage.ts";
2
3
 
3
4
  /** Footer redraw cadence while a turn is streaming. */
@@ -33,6 +34,50 @@ export interface SpeedMetric {
33
34
  color?: SpeedColor | "text" | "muted";
34
35
  }
35
36
 
37
+ const SPEED_COPY: Record<UiLanguage, {
38
+ average: string;
39
+ live: string;
40
+ ttft: string;
41
+ decode: string;
42
+ output: string;
43
+ input: string;
44
+ cacheRead: string;
45
+ cacheWrite: string;
46
+ cacheWrite1h: string;
47
+ reasoning: string;
48
+ totalTokens: string;
49
+ cost: string;
50
+ }> = {
51
+ zh: {
52
+ average: "平均速度",
53
+ live: "实时速度",
54
+ ttft: "首字吐字",
55
+ decode: "解码用时",
56
+ output: "输出 token",
57
+ input: "输入 token",
58
+ cacheRead: "缓存读取",
59
+ cacheWrite: "缓存写入",
60
+ cacheWrite1h: "写入 1h",
61
+ reasoning: "推理 token",
62
+ totalTokens: "合计 token",
63
+ cost: "费用",
64
+ },
65
+ en: {
66
+ average: "Avg speed",
67
+ live: "Live speed",
68
+ ttft: "First token",
69
+ decode: "Decode time",
70
+ output: "Output tokens",
71
+ input: "Input tokens",
72
+ cacheRead: "Cache read",
73
+ cacheWrite: "Cache write",
74
+ cacheWrite1h: "Cache write 1h",
75
+ reasoning: "Reasoning tokens",
76
+ totalTokens: "Total tokens",
77
+ cost: "Cost",
78
+ },
79
+ };
80
+
36
81
  interface Sample {
37
82
  t: number;
38
83
  tokens: number;
@@ -148,7 +193,7 @@ export function createTokenSpeedTracker() {
148
193
  let liveBaseTokens = 0;
149
194
  let samples: Sample[] = [];
150
195
  let usage: UsageSnapshot = {};
151
- let frozen: SpeedMetric[] | undefined;
196
+ let frozen: Record<UiLanguage, SpeedMetric[]> | undefined;
152
197
  let runTokens = 0;
153
198
  let runElapsedMs = 0;
154
199
  let currentModelKey = "__default__";
@@ -209,29 +254,30 @@ export function createTokenSpeedTracker() {
209
254
  return outputSpeed(settledCount(), decodeStartedAt ?? firstTokenAt, end);
210
255
  };
211
256
 
212
- const collect = (): SpeedMetric[] => {
257
+ const collect = (lang: UiLanguage = "zh"): SpeedMetric[] => {
258
+ const copy = SPEED_COPY[lang] ?? SPEED_COPY.zh;
213
259
  const rows: SpeedMetric[] = [];
214
260
  const now = lastNow || Date.now();
215
261
  const average = runningAverage(now);
216
- if (average !== undefined) rows.push({ label: "平均速度", value: formatSpeed(average, true), color: speedColor(average) });
217
- if (streaming && lastLive !== undefined) rows.push({ label: "实时速度", value: formatSpeed(lastLive, true), color: speedColor(lastLive) });
262
+ if (average !== undefined) rows.push({ label: copy.average, value: formatSpeed(average, true), color: speedColor(average) });
263
+ if (streaming && lastLive !== undefined) rows.push({ label: copy.live, value: formatSpeed(lastLive, true), color: speedColor(lastLive) });
218
264
  const origin = turnStartedAt ?? assistantStartedAt;
219
265
  if (firstTokenAt !== undefined && origin !== undefined && firstTokenAt > origin) {
220
- rows.push({ label: "首字吐字", value: formatDuration(firstTokenAt - origin), color: "text" });
266
+ rows.push({ label: copy.ttft, value: formatDuration(firstTokenAt - origin), color: "text" });
221
267
  }
222
268
  const decodeStart = streaming ? firstTokenAt : (decodeStartedAt ?? firstTokenAt);
223
269
  const decodeEnd = streaming ? now : segmentEndedAt;
224
270
  if (decodeStart !== undefined && decodeEnd !== undefined && decodeEnd - decodeStart >= SPEED_REFRESH_MS) {
225
- rows.push({ label: "解码用时", value: formatDuration(decodeEnd - decodeStart), color: "text" });
271
+ rows.push({ label: copy.decode, value: formatDuration(decodeEnd - decodeStart), color: "text" });
226
272
  }
227
273
  const counts: Array<[keyof UsageSnapshot, string]> = [
228
- ["output", "输出 token"],
229
- ["input", "输入 token"],
230
- ["cacheRead", "缓存读取"],
231
- ["cacheWrite", "缓存写入"],
232
- ["cacheWrite1h", "写入 1h"],
233
- ["reasoning", "推理 token"],
234
- ["totalTokens", "合计 token"],
274
+ ["output", copy.output],
275
+ ["input", copy.input],
276
+ ["cacheRead", copy.cacheRead],
277
+ ["cacheWrite", copy.cacheWrite],
278
+ ["cacheWrite1h", copy.cacheWrite1h],
279
+ ["reasoning", copy.reasoning],
280
+ ["totalTokens", copy.totalTokens],
235
281
  ];
236
282
  for (const [key, label] of counts) {
237
283
  const value = usage[key];
@@ -239,11 +285,11 @@ export function createTokenSpeedTracker() {
239
285
  rows.push({ label, value: formatCount(value), color: "text" });
240
286
  }
241
287
  if (usage.output === undefined && !streaming && settledCount() >= DECODE_SPEED_MIN_OUTPUT) {
242
- rows.push({ label: "输出 token", value: formatCount(settledCount()), color: "text" });
288
+ rows.push({ label: copy.output, value: formatCount(settledCount()), color: "text" });
243
289
  }
244
- if (usage.cost !== undefined && usage.cost > 0) rows.push({ label: "费用", value: formatUsd(usage.cost), color: "muted" });
290
+ if (usage.cost !== undefined && usage.cost > 0) rows.push({ label: copy.cost, value: formatUsd(usage.cost), color: "muted" });
245
291
  if (rows.length === 0 && displayed !== undefined) {
246
- rows.push({ label: "平均速度", value: formatSpeed(displayed, true), color: speedColor(displayed) });
292
+ rows.push({ label: copy.average, value: formatSpeed(displayed, true), color: speedColor(displayed) });
247
293
  }
248
294
  return rows;
249
295
  };
@@ -435,7 +481,7 @@ export function createTokenSpeedTracker() {
435
481
  } else {
436
482
  displayed = lastReliable;
437
483
  }
438
- frozen = collect();
484
+ frozen = { zh: collect("zh"), en: collect("en") };
439
485
  return average !== undefined;
440
486
  },
441
487
  noteNested(output: unknown, startedAt: number, endedAt: number): boolean {
@@ -453,9 +499,10 @@ export function createTokenSpeedTracker() {
453
499
  streaming(): boolean {
454
500
  return streaming;
455
501
  },
456
- metrics(): SpeedMetric[] {
457
- if (streaming && lastLive === undefined && frozen?.length) return frozen;
458
- return collect();
502
+ metrics(lang: UiLanguage = "zh"): SpeedMetric[] {
503
+ const resolved = lang === "en" ? "en" : "zh";
504
+ if (streaming && lastLive === undefined && frozen?.[resolved]?.length) return frozen[resolved];
505
+ return collect(resolved);
459
506
  },
460
507
  reset() {
461
508
  displayed = undefined;
@@ -44,8 +44,10 @@ export function attachTranscript(tui: unknown, view: TranscriptView, options: No
44
44
  // as a transcript identity check.
45
45
  const renderDescriptor = Object.getOwnPropertyDescriptor(document, "render");
46
46
  const mouseDescriptor = Object.getOwnPropertyDescriptor(document, "handleMouse");
47
+ const invalidateDescriptor = Object.getOwnPropertyDescriptor(document, "invalidate");
47
48
  const originalRender = document.render;
48
49
  const originalMouse = document.handleMouse;
50
+ const originalInvalidate = document.invalidate;
49
51
  const now = options.now ?? Date.now;
50
52
  const schedule = options.schedule ?? ((callback, delay) => {
51
53
  const timer = setTimeout(callback, delay);
@@ -103,8 +105,16 @@ export function attachTranscript(tui: unknown, view: TranscriptView, options: No
103
105
  if (event.y < viewOffset || event.y >= viewOffset + viewHeight) return;
104
106
  return view.handleMouse?.({ ...event, y: event.y - viewOffset, height: viewHeight });
105
107
  };
108
+ // Theme changes call ui.invalidate(), which reaches this document but not the
109
+ // minimal view: it is not a TUI child, and the widget invalidate is a no-op.
110
+ // Turn-line caches omit theme, so refresh them here. Native children still run.
111
+ const invalidate: NonNullable<Component["invalidate"]> = () => {
112
+ originalInvalidate?.call(document);
113
+ view.invalidate?.();
114
+ };
106
115
  document.render = render;
107
116
  document.handleMouse = mouse;
117
+ document.invalidate = invalidate;
108
118
  // Dock events never reach the document. Observe normalized events without
109
119
  // stealing wheel/selection or changing Pi's mouse protocol/listener order.
110
120
  const restoreDock = view.clearHover ? host.children.slice(1).map(child => {
@@ -162,5 +172,9 @@ export function attachTranscript(tui: unknown, view: TranscriptView, options: No
162
172
  if (mouseDescriptor) Object.defineProperty(document, "handleMouse", mouseDescriptor);
163
173
  else { delete document.handleMouse; if (document.handleMouse !== originalMouse) document.handleMouse = originalMouse; }
164
174
  }
175
+ if (document.invalidate === invalidate) {
176
+ if (invalidateDescriptor) Object.defineProperty(document, "invalidate", invalidateDescriptor);
177
+ else { delete (document as Partial<Component>).invalidate; if (document.invalidate !== originalInvalidate) document.invalidate = originalInvalidate; }
178
+ }
165
179
  };
166
180
  }
@@ -1,13 +1,14 @@
1
1
  import { Text, truncateToWidth, visibleWidth } from "@earendil-works/pi-tui";
2
2
  import { getMarkdownTheme, type ExtensionContext } from "@earendil-works/pi-coding-agent";
3
3
  import { diagramMarkdown, isMarkdownProse, renderMinimalMarkdown } from "./minimal-markdown.ts";
4
+ import type { UiLanguage } from "./settings.ts";
4
5
  import { clean, record, supervisorNotice, supervisorNoticeBody } from "./transcript-notices.ts";
5
6
 
6
7
  const renderMarkdownBody = (body: string, width: number, theme?: ExtensionContext["ui"]["theme"]) => isMarkdownProse(body)
7
8
  ? renderMinimalMarkdown(body, Math.max(1, width), getMarkdownTheme(), theme?.getBgAnsi?.("userMessageBg") ?? "", undefined, diagramMarkdown)
8
9
  : new Text(body, 0, 0).render(Math.max(1, width));
9
10
 
10
- export function compactGoalCard(entry: unknown, theme: ExtensionContext["ui"]["theme"], width: number, expanded: boolean): string[] | undefined {
11
+ export function compactGoalCard(entry: unknown, theme: ExtensionContext["ui"]["theme"], width: number, expanded: boolean, lang: UiLanguage = "zh"): string[] | undefined {
11
12
  const item = record(entry);
12
13
  if (item?.customType !== "pi-codex-goal") return;
13
14
  const data = record(item.data);
@@ -17,7 +18,7 @@ export function compactGoalCard(entry: unknown, theme: ExtensionContext["ui"]["t
17
18
  // worth adding to the compact transcript.
18
19
  if (!objective || width <= 0) return;
19
20
  const status = typeof goal?.status === "string" ? clean(goal.status) : "active";
20
- const control = truncateToWidth(expanded ? "[收起]" : "[详情]", width, "");
21
+ const control = truncateToWidth(lang === "en" ? (expanded ? "[Collapse]" : "[Details]") : (expanded ? "[收起]" : "[详情]"), width, "");
21
22
  const title = theme.fg(expanded ? "accent" : "muted", `${control} ◉ Goal · ${status}`);
22
23
  const hint = theme.fg(expanded ? "accent" : "muted", " · Ctrl+O");
23
24
  const summary = truncateToWidth(objective, Math.max(0, width - visibleWidth(title) - visibleWidth(hint) - 3), "…");
@@ -26,13 +27,13 @@ export function compactGoalCard(entry: unknown, theme: ExtensionContext["ui"]["t
26
27
  return rows;
27
28
  }
28
29
 
29
- export function compactSupervisorNotice(message: unknown, theme: ExtensionContext["ui"]["theme"], width: number, expanded: boolean, label = "", history: unknown[] = [message]): string[] | undefined {
30
- const notice = supervisorNotice(message);
30
+ export function compactSupervisorNotice(message: unknown, theme: ExtensionContext["ui"]["theme"], width: number, expanded: boolean, label = "", history: unknown[] = [message], lang: UiLanguage = "zh"): string[] | undefined {
31
+ const notice = supervisorNotice(message, lang);
31
32
  if (!notice) return;
32
33
  if (width <= 0) return [];
33
34
  const { state, color, summary } = notice;
34
35
  const effectiveLabel = label || (notice.showLabel ? notice.label ?? "" : "");
35
- const control = truncateToWidth(expanded ? "[收起]" : "[详情]", width, "");
36
+ const control = truncateToWidth(lang === "en" ? (expanded ? "[Collapse]" : "[Details]") : (expanded ? "[收起]" : "[详情]"), width, "");
36
37
  const hint = " · Ctrl+O";
37
38
  let heading: string;
38
39
  let summaryText: string;
@@ -56,7 +57,7 @@ export function compactSupervisorNotice(message: unknown, theme: ExtensionContex
56
57
  if (expanded) {
57
58
  const bodies: string[] = [];
58
59
  for (const original of history) {
59
- const body = supervisorNoticeBody(original);
60
+ const body = supervisorNoticeBody(original, lang);
60
61
  if (body && !bodies.includes(body)) bodies.push(body);
61
62
  }
62
63
  for (const body of bodies) {
@@ -1,5 +1,6 @@
1
1
  import type { Component } from "@earendil-works/pi-tui";
2
2
  import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
3
+ import type { UiLanguage } from "./settings.ts";
3
4
  import { compactGoalCard, compactSupervisorNotice } from "./transcript-cards.ts";
4
5
  import { cacheMissLine, formatCacheTokens, isSupervisorReply, record, supervisorNotice } from "./transcript-notices.ts";
5
6
 
@@ -23,6 +24,7 @@ export interface NoticeOptions {
23
24
  supervisor?: {
24
25
  theme: ExtensionContext["ui"]["theme"];
25
26
  expanded: () => boolean;
27
+ language?: () => UiLanguage;
26
28
  handledRunIds?: () => Set<string>;
27
29
  onNotices?: (groups: Map<string | Component, { first: Component; messages: unknown[]; selected: unknown; notice: NonNullable<ReturnType<typeof supervisorNotice>> }>) => void;
28
30
  };
@@ -48,11 +50,12 @@ export function createTurnNoticeRenderer(chat: { children: Component[] }, option
48
50
  return width => {
49
51
  const notices = new Map<number, NoticeRows>();
50
52
  const expanded = options.supervisor?.expanded() ?? false;
53
+ const lang: UiLanguage = options.supervisor?.language?.() ?? "zh";
51
54
  if (expanded !== globalExpanded) { expandedNotices.clear(); globalExpanded = expanded; }
52
55
  const groups = new Map<string | Component, { first: Component; messages: unknown[]; selected: unknown; notice: NonNullable<ReturnType<typeof supervisorNotice>> }>();
53
56
  if (options.supervisor) for (const child of chat.children) {
54
57
  const message = supervisorEnvelope(child);
55
- const notice = supervisorNotice(message);
58
+ const notice = supervisorNotice(message, lang);
56
59
  if (!notice) continue;
57
60
  const key = notice.key ?? child;
58
61
  const group = groups.get(key);
@@ -113,8 +116,8 @@ export function createTurnNoticeRenderer(chat: { children: Component[] }, option
113
116
  continue;
114
117
  }
115
118
  if (child.constructor.name === "CustomEntryComponent"
116
- && !(options.supervisor && supervisorNotice(supervisorEnvelope(child)))) {
117
- const goalRows = options.supervisor && compactGoalCard((child as unknown as { entry?: unknown }).entry, options.supervisor.theme, width, expandedNotices.get(child) ?? false);
119
+ && !(options.supervisor && supervisorNotice(supervisorEnvelope(child), lang))) {
120
+ const goalRows = options.supervisor && compactGoalCard((child as unknown as { entry?: unknown }).entry, options.supervisor.theme, width, expandedNotices.get(child) ?? false, lang);
118
121
  const rows = notices.get(turn) ?? [];
119
122
  if (!goalRows) {
120
123
  rows.push(...child.render(width));
@@ -133,7 +136,7 @@ export function createTurnNoticeRenderer(chat: { children: Component[] }, option
133
136
  if (child.constructor.name === "CustomMessageComponent" || child.constructor.name === "CustomEntryComponent") {
134
137
  const rows = notices.get(turn) ?? [];
135
138
  const message = supervisorEnvelope(child);
136
- const notice = options.supervisor && supervisorNotice(message);
139
+ const notice = options.supervisor && supervisorNotice(message, lang);
137
140
  const key = notice ? notice.key ?? child : child;
138
141
  const group = groups.get(key);
139
142
  if (group && group.first !== child) continue;
@@ -144,11 +147,11 @@ export function createTurnNoticeRenderer(chat: { children: Component[] }, option
144
147
  const open = expandedNotices.get(key) ?? expanded;
145
148
  const label = group.notice.showLabel
146
149
  ? group.notice.label ?? ""
147
- : groups.size > 1 ? group.notice.label || `任务 ${groupKeys.indexOf(key) + 1}` : "";
150
+ : groups.size > 1 ? group.notice.label || (lang === "en" ? `Task ${groupKeys.indexOf(key) + 1}` : `任务 ${groupKeys.indexOf(key) + 1}`) : "";
148
151
  const targets = controls.get(turn) ?? [];
149
152
  targets.push({ y: rows.length, width, key, expanded: open });
150
153
  controls.set(turn, targets);
151
- rows.push(...compactSupervisorNotice(group.selected, options.supervisor.theme, width, open, label, group.messages)!);
154
+ rows.push(...compactSupervisorNotice(group.selected, options.supervisor.theme, width, open, label, group.messages, lang)!);
152
155
  } else rows.push(...child.render(width));
153
156
  notices.set(turn, rows);
154
157
  continue;
@@ -1,9 +1,63 @@
1
1
  import { stripVTControlCharacters } from "node:util";
2
+ import type { UiLanguage } from "./settings.ts";
2
3
 
3
4
  export const record = (value: unknown): Record<string, unknown> | undefined => value && typeof value === "object" && !Array.isArray(value) ? value as Record<string, unknown> : undefined;
4
5
  export const clean = (text: string) => stripVTControlCharacters(text).replace(/[\x00-\x1f\x7f]/g, " ").replace(/\s+/g, " ").trim();
5
6
  export const isSupervisorReply = (message: unknown) => record(message)?.customType === "subagent_supervisor_reply";
6
7
 
8
+ const NOTICE_COPY: Record<UiLanguage, {
9
+ toolFailures: string;
10
+ completionGuard: string;
11
+ internalState: string;
12
+ internalSummary: string;
13
+ failedState: string;
14
+ completedState: string;
15
+ subtaskFailed: string;
16
+ subtaskCompleted: string;
17
+ attentionState: string;
18
+ workflowFailedSummary: string;
19
+ waitingReply: string;
20
+ questionState: string;
21
+ decisionState: string;
22
+ progressState: string;
23
+ noSummary: string;
24
+ }> = {
25
+ zh: {
26
+ toolFailures: "工具执行失败",
27
+ completionGuard: "任务完成受阻",
28
+ internalState: "内部协作",
29
+ internalSummary: "代理间沟通已收纳",
30
+ failedState: "执行失败",
31
+ completedState: "已完成",
32
+ subtaskFailed: "子任务失败",
33
+ subtaskCompleted: "子任务已完成",
34
+ attentionState: "需要关注",
35
+ workflowFailedSummary: "工作流包含失败子任务",
36
+ waitingReply: "等待回复",
37
+ questionState: "需要提问",
38
+ decisionState: "需要裁决",
39
+ progressState: "进度",
40
+ noSummary: "暂无摘要",
41
+ },
42
+ en: {
43
+ toolFailures: "Tool execution failed",
44
+ completionGuard: "Task completion blocked",
45
+ internalState: "Internal",
46
+ internalSummary: "Subagent communication folded",
47
+ failedState: "Failed",
48
+ completedState: "Completed",
49
+ subtaskFailed: "Subtask failed",
50
+ subtaskCompleted: "Subtask completed",
51
+ attentionState: "Needs attention",
52
+ workflowFailedSummary: "Workflow has failed subtasks",
53
+ waitingReply: "Waiting for reply",
54
+ questionState: "Question",
55
+ decisionState: "Decision needed",
56
+ progressState: "Progress",
57
+ noSummary: "No summary",
58
+ },
59
+ };
60
+
7
61
  /** Structured interview questions are the prompt; IDs and reply hints stay out. */
8
62
  export function formatInterview(interview: unknown): string {
9
63
  const data = record(interview);
@@ -35,7 +89,8 @@ function withInterview(body: string, interview: unknown): string {
35
89
  return body ? `${body}\n${questions}` : questions;
36
90
  }
37
91
 
38
- export function extractNoticeBody(message: unknown): string {
92
+ export function extractNoticeBody(message: unknown, lang: UiLanguage = "zh"): string {
93
+ const copy = NOTICE_COPY[lang] ?? NOTICE_COPY.zh;
39
94
  const item = record(message);
40
95
  if (!item) return typeof message === "string" ? clean(message) : "";
41
96
  const details = record(item.details);
@@ -52,7 +107,7 @@ export function extractNoticeBody(message: unknown): string {
52
107
  if (body) {
53
108
  let cleanBody = stripVTControlCharacters(body).replace(/^UPDATE:\s*/i, "").trim();
54
109
  const failureReason = typeof event?.reason === "string" && ["tool_failures", "completion_guard"].includes(event.reason)
55
- ? event.reason === "tool_failures" ? "工具执行失败" : "任务完成受阻"
110
+ ? event.reason === "tool_failures" ? copy.toolFailures : copy.completionGuard
56
111
  : undefined;
57
112
  if (failureReason && !cleanBody.includes(failureReason)) cleanBody = `[${failureReason}] ${cleanBody}`;
58
113
  return withInterview(cleanBody, interview);
@@ -81,7 +136,8 @@ export function extractNoticeBody(message: unknown): string {
81
136
  }
82
137
 
83
138
  /** Only pi-subagents' known envelopes carry state; prose is never a status signal. */
84
- export function supervisorNotice(message: unknown) {
139
+ export function supervisorNotice(message: unknown, lang: UiLanguage = "zh") {
140
+ const copy = NOTICE_COPY[lang] ?? NOTICE_COPY.zh;
85
141
  const item = record(message);
86
142
  if (item?.customType === "subagent_supervisor_reply") {
87
143
  const data = record(item.data);
@@ -99,9 +155,9 @@ export function supervisorNotice(message: unknown) {
99
155
  agent: data.agent,
100
156
  internal: true,
101
157
  alert: false,
102
- state: "内部协作",
158
+ state: copy.internalState,
103
159
  color: "muted" as const,
104
- summary: "代理间沟通已收纳",
160
+ summary: copy.internalSummary,
105
161
  body: stripVTControlCharacters(data.message).trim(),
106
162
  };
107
163
  }
@@ -126,9 +182,9 @@ export function supervisorNotice(message: unknown) {
126
182
  runIds,
127
183
  internal: false,
128
184
  alert: failed,
129
- state: failed ? "执行失败" : "已完成",
185
+ state: failed ? copy.failedState : copy.completedState,
130
186
  color: failed ? "error" as const : "muted" as const,
131
- summary: error || (failed ? "子任务失败" : "子任务已完成"),
187
+ summary: error || (failed ? copy.subtaskFailed : copy.subtaskCompleted),
132
188
  label: clean(header[2]),
133
189
  showLabel: true,
134
190
  body: content,
@@ -165,10 +221,10 @@ export function supervisorNotice(message: unknown) {
165
221
  runIds,
166
222
  internal: false,
167
223
  alert: failed || attention,
168
- state: failed ? "执行失败" : attention ? "需要关注" : "已完成",
224
+ state: failed ? copy.failedState : attention ? copy.attentionState : copy.completedState,
169
225
  color: failed ? "error" as const : attention ? "warning" as const : "muted" as const,
170
- summary: failed && status === "completed" ? "工作流包含失败子任务"
171
- : clean(preview) || (failed ? "子任务失败" : attention ? "等待回复" : "子任务已完成"),
226
+ summary: failed && status === "completed" ? copy.workflowFailedSummary
227
+ : clean(preview) || (failed ? copy.subtaskFailed : attention ? copy.waitingReply : copy.subtaskCompleted),
172
228
  label: clean(header[2]),
173
229
  showLabel: true,
174
230
  body: content,
@@ -202,10 +258,10 @@ export function supervisorNotice(message: unknown) {
202
258
  const key = runId && Number.isInteger(index) && Number(index) >= 0
203
259
  && !data.nestedRunId && !data.nestingPath ? JSON.stringify([runId, index]) : undefined;
204
260
  return { key, runId, internal, alert: failed || attention,
205
- state: failed ? "执行失败" : ask ? (details.reason === "interview_request" ? "需要提问" : "需要裁决")
206
- : attention ? "需要关注" : internal ? "内部协作" : "进度",
261
+ state: failed ? copy.failedState : ask ? (details.reason === "interview_request" ? copy.questionState : copy.decisionState)
262
+ : attention ? copy.attentionState : internal ? copy.internalState : copy.progressState,
207
263
  color: failed ? "error" as const : attention ? "warning" as const : "muted" as const,
208
- summary: internal ? "代理间沟通已收纳" : question || (ask ? interviewTitle || "等待回复" : "暂无摘要"),
264
+ summary: internal ? copy.internalSummary : question || (ask ? interviewTitle || copy.waitingReply : copy.noSummary),
209
265
  label: typeof data.label === "string" ? clean(data.label) : typeof data.taskPreview === "string" ? clean(data.taskPreview) : undefined,
210
266
  body: question,
211
267
  agent: typeof data.agent === "string" ? data.agent : undefined,
@@ -213,12 +269,12 @@ export function supervisorNotice(message: unknown) {
213
269
  }
214
270
 
215
271
  /** Progress is a status preview, not detail prose; decisions and failures remain inspectable. */
216
- export function supervisorNoticeBody(message: unknown): string {
272
+ export function supervisorNoticeBody(message: unknown, lang: UiLanguage = "zh"): string {
217
273
  const item = record(message);
218
274
  if (item?.customType === "subagent_supervisor_request" && record(item.details)?.reason === "progress_update") return "";
219
- const notice = supervisorNotice(message);
275
+ const notice = supervisorNotice(message, lang);
220
276
  if (item?.type === "custom" && item.customType === "subagent_supervisor_reply") return notice?.body ?? "";
221
- return notice?.alert || notice?.internal ? extractNoticeBody(message) : "";
277
+ return notice?.alert || notice?.internal ? extractNoticeBody(message, lang) : "";
222
278
  }
223
279
 
224
280
  /** Pi writes one warning line per miss (`Cache miss…: N tokens re-billed`). */