@eworkbase/sdk 0.4.2 → 0.4.4

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,5 +1,5 @@
1
1
  import { memo, useCallback, useEffect, useMemo, useRef, useState } from "react";
2
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
3
  import Markdown from "react-markdown";
4
4
  import remarkGfm from "remark-gfm";
5
5
  //#region src/ui/ExecutionLogTimeline.dto.ts
@@ -10,8 +10,6 @@ let ExecutionLogDisplay = /* @__PURE__ */ function(ExecutionLogDisplay) {
10
10
  }({});
11
11
  //#endregion
12
12
  //#region src/ui/execution-log-model.ts
13
- const LOG_TITLE_LIMIT = 96;
14
- const SLOW_CALL_MILLISECONDS = 3e4;
15
13
  const LOG_STATUS_LABELS = /* @__PURE__ */ new Map([
16
14
  ["pending", "等待中"],
17
15
  ["in_progress", "进行中"],
@@ -23,204 +21,187 @@ const LOG_STATUS_LABELS = /* @__PURE__ */ new Map([
23
21
  ["warning", "有警告"],
24
22
  ["unknown", "未记录"]
25
23
  ]);
26
- /** Adapts existing evidence for both complete and compact readers without persisting derived events. */
27
- function buildExecutionLogItems(record) {
24
+ const LOG_PHASE_LABELS = /* @__PURE__ */ new Map([
25
+ ["preflight", "访问检查"],
26
+ ["tools", "工具准备"],
27
+ ["repositories", "仓库处理"],
28
+ ["environment", "项目环境"],
29
+ ["plugins", "插件"],
30
+ ["verification", "结果检查"],
31
+ ["configuration", "项目配置"],
32
+ ["publication", "配置发布"],
33
+ ["execution", "执行任务"]
34
+ ]);
35
+ /** Merge loaded related records into the same reader; unresolved calls retain their navigation. */
36
+ function buildExecutionLogItems(record, relatedRecords = []) {
37
+ const records = [...new Map([record, ...relatedRecords].map((source) => [source.id, source])).values()];
38
+ const loadedIds = new Set(records.map(({ id }) => id));
39
+ return records.flatMap((source) => recordItems(source).map((item) => {
40
+ const logId = item.logId && !loadedIds.has(item.logId) ? item.logId : void 0;
41
+ return source.id === record.id ? {
42
+ ...item,
43
+ logId
44
+ } : {
45
+ ...item,
46
+ logId,
47
+ id: source.id + ":" + item.id,
48
+ anchors: [],
49
+ metadata: [source.title, ...item.metadata]
50
+ };
51
+ })).sort((first, second) => {
52
+ if (first.time && second.time) return Date.parse(first.time) - Date.parse(second.time);
53
+ if (first.time === second.time) return 0;
54
+ return first.time ? -1 : 1;
55
+ });
56
+ }
57
+ function executionLogStatusLabel(status) {
58
+ return LOG_STATUS_LABELS.get(normalizeLogStatus(status)) ?? status;
59
+ }
60
+ function normalizeLogStatus(status) {
61
+ if (!status) return "";
62
+ if ([
63
+ "ready",
64
+ "prepared",
65
+ "succeeded",
66
+ "completed"
67
+ ].includes(status)) return "completed";
68
+ if (["running", "in_progress"].includes(status)) return "in_progress";
69
+ if (["queued", "pending"].includes(status)) return "pending";
70
+ if ([
71
+ "invalid",
72
+ "missing",
73
+ "needs-action",
74
+ "manual-action-required",
75
+ "unsupported-platform"
76
+ ].includes(status)) return "needs_action";
77
+ return status;
78
+ }
79
+ function recordItems(record) {
28
80
  const entries = (record.entries ?? []).map(logEntryItem);
29
81
  const calls = [...new Map((record.children ?? []).map((call) => [call.id, call])).values()];
30
- const routine = calls.filter(isRoutineCall);
31
82
  const steps = record.steps ?? [];
32
83
  const wrapper = Boolean(record.execution && entries.length && steps.length === 1 && steps[0].target?.kind === "plugin" && steps[0].target.id === record.execution.pluginId);
33
84
  const items = [
34
85
  ...entries,
35
86
  ...wrapper ? [] : steps.map(logStepItem),
36
- ...calls.filter((call) => !isRoutineCall(call)).map(logCallItem)
87
+ ...calls.map(logCallItem)
37
88
  ];
38
- const wrapperItem = wrapper ? logStepItem(steps[0]) : null;
39
- if (routine.length || wrapperItem) items.push({
40
- id: "execution-evidence",
41
- anchors: wrapper ? [...new Set([steps[0].id, steps[0].legacyId ?? ""].filter(Boolean))] : [],
42
- kind: "activity",
43
- time: validLogTime(record.context?.finishedAt ?? record.createdAt),
44
- title: "执行详情",
45
- content: wrapperItem?.content ?? "",
46
- status: wrapperItem?.status ?? "",
47
- metadata: routine.length ? [routine.length + " 项辅助调用"] : [],
48
- evidence: wrapperItem?.evidence ?? [],
49
- calls: routine
50
- });
89
+ if (wrapper) {
90
+ const result = logStepItem(steps[0]);
91
+ items.push({
92
+ ...result,
93
+ id: "execution-evidence",
94
+ anchors: [.../* @__PURE__ */ new Set([steps[0].id, ...result.anchors])],
95
+ time: validLogTime(record.context?.finishedAt),
96
+ title: "执行结果"
97
+ });
98
+ }
51
99
  if (record.warnings?.length) items.push({
52
100
  id: "warnings",
53
101
  anchors: [],
54
102
  kind: "activity",
55
103
  time: null,
56
104
  title: "执行警告",
57
- content: record.warnings.join("\n\n"),
105
+ content: "",
58
106
  status: "warning",
59
107
  metadata: [],
60
108
  evidence: [{
109
+ kind: "details",
61
110
  label: "警告",
62
111
  content: record.warnings.join("\n")
63
- }],
64
- calls: []
112
+ }]
65
113
  });
66
114
  for (const message of record.messages ?? []) items.push({
67
115
  id: "message-" + message.id,
68
116
  anchors: [],
69
117
  kind: "activity",
70
118
  time: validLogTime(message.createdAt),
71
- title: shortenLogTitle(message.message),
119
+ title: "运行诊断",
72
120
  content: "",
73
121
  status: message.level === "error" ? "failed" : message.level === "warn" ? "warning" : "",
74
- metadata: [],
122
+ metadata: [message.level],
75
123
  evidence: [{
76
- label: "运行诊断 · " + message.level,
124
+ kind: "details",
125
+ label: "诊断输出",
77
126
  content: message.message
78
- }],
79
- calls: []
80
- });
81
- return items.sort((first, second) => {
82
- if (first.time && second.time) return Date.parse(first.time) - Date.parse(second.time);
83
- if (first.time === second.time) return 0;
84
- return first.time ? -1 : 1;
127
+ }]
85
128
  });
86
- }
87
- function executionLogStatusLabel(status) {
88
- return LOG_STATUS_LABELS.get(normalizeLogStatus(status)) ?? status;
89
- }
90
- function normalizeLogStatus(status) {
91
- if (!status) return "";
92
- if ([
93
- "ready",
94
- "prepared",
95
- "succeeded",
96
- "completed"
97
- ].includes(status)) return "completed";
98
- if (["running", "in_progress"].includes(status)) return "in_progress";
99
- if (["queued", "pending"].includes(status)) return "pending";
100
- if ([
101
- "invalid",
102
- "missing",
103
- "needs-action",
104
- "manual-action-required",
105
- "unsupported-platform"
106
- ].includes(status)) return "needs_action";
107
- return status;
108
- }
109
- function shortenLogTitle(title) {
110
- let text = title.trim();
111
- const file = /^(?:Read file|List files in) ['"](.+)['"]$/i.exec(text);
112
- if (file) text = (/^Read/i.test(text) ? "读取文件:" : "列出文件:") + file[1].split(/[\\/]/).filter(Boolean).at(-1);
113
- if (/^Search for ['"]/i.test(text)) text = text.replace(/^Search for\s+/i, "搜索内容:");
114
- if (/^(?:python\d*|node|bash|sh|zsh)\s/i.test(text)) text = "执行命令:" + text;
115
- const firstLine = text.split(/\r?\n/, 1)[0];
116
- return firstLine.length > LOG_TITLE_LIMIT ? firstLine.slice(0, LOG_TITLE_LIMIT) + "…" : firstLine || "执行记录";
129
+ return items;
117
130
  }
118
131
  function logEntryItem(entry) {
119
- const title = entry.kind === "message" && entry.content.trim() ? shortenLogTitle(entry.content) : shortenLogTitle(entry.title);
120
- const evidence = entry.details ? [{
121
- label: "参数与原始输出",
122
- content: entry.details
123
- }] : [];
124
- if (entry.kind === "activity" && title !== entry.title) evidence.unshift({
125
- label: "原始操作",
126
- content: entry.title
127
- });
128
132
  return {
129
133
  id: "entry-" + entry.id,
130
134
  anchors: [],
131
135
  kind: entry.kind,
132
136
  time: validLogTime(entry.time),
133
- title,
137
+ title: entry.title,
134
138
  content: entry.content.trim() === entry.title.trim() && entry.kind === "activity" ? "" : entry.content,
135
139
  status: normalizeLogStatus(entry.status),
136
140
  metadata: [],
137
- evidence,
138
- calls: []
141
+ evidence: entry.details ? [{
142
+ kind: "details",
143
+ label: "调用记录",
144
+ content: entry.details
145
+ }] : []
139
146
  };
140
147
  }
141
148
  function logStepItem(step) {
142
149
  const evidence = [
143
150
  {
151
+ kind: "command",
144
152
  label: "命令",
145
153
  content: step.command
146
154
  },
147
155
  {
156
+ kind: "output",
148
157
  label: "标准输出",
149
158
  content: step.stdout
150
159
  },
151
160
  {
161
+ kind: "error",
152
162
  label: "标准错误",
153
163
  content: step.stderr
154
- },
155
- {
156
- label: "处理说明",
157
- content: step.manualActionMessage
158
164
  }
159
165
  ].filter((block) => Boolean(block.content));
160
- const phases = /* @__PURE__ */ new Map([
161
- ["preflight", "访问检查"],
162
- ["tools", "工具准备"],
163
- ["repositories", "仓库处理"],
164
- ["environment", "项目环境"],
165
- ["plugins", "插件"],
166
- ["verification", "结果检查"],
167
- ["configuration", "项目配置"],
168
- ["publication", "配置发布"],
169
- ["execution", "执行任务"]
170
- ]);
171
- const context = [
166
+ const context = [...new Set([
172
167
  step.target?.label,
173
- phases.get(step.phase ?? "") ?? step.phase,
168
+ LOG_PHASE_LABELS.get(step.phase ?? "") ?? step.phase,
174
169
  step.provider
175
- ].filter(Boolean).join(" · ");
170
+ ].filter((label) => Boolean(label)))];
176
171
  const timing = step.timing;
177
- const dates = timing ? [
178
- timing.queuedAt ? "排队:" + timing.queuedAt : "",
179
- "开始:" + (timing.startedAt ?? "未记录"),
180
- "结束:" + (timing.finishedAt ?? "未记录")
181
- ].filter(Boolean).join("\n") : "";
182
- if (context || dates) evidence.unshift({
183
- label: "执行信息",
184
- content: [context, dates].filter(Boolean).join("\n")
185
- });
186
172
  const queued = timing?.queuedAt && timing?.startedAt ? (Date.parse(timing.startedAt) - Date.parse(timing.queuedAt)) / 1e3 : null;
187
- if (queued !== null && Number.isFinite(queued) && queued >= 0) evidence.push({
188
- label: "等待时间",
189
- content: queued.toFixed(1) + " 秒"
190
- });
173
+ const waiting = queued !== null && Number.isFinite(queued) && queued > 0 ? ["等待 " + queued.toFixed(1) + " 秒"] : [];
191
174
  return {
192
175
  id: step.id,
193
176
  anchors: step.legacyId && step.legacyId !== step.id ? [step.legacyId] : [],
194
177
  kind: "activity",
195
178
  time: validLogTime(timing?.startedAt ?? timing?.queuedAt),
196
- title: shortenLogTitle(step.label),
197
- content: [step.detail, step.manualActionMessage].filter(Boolean).join("\n\n"),
179
+ title: step.label,
180
+ content: [...new Set([step.detail, step.manualActionMessage].filter(Boolean))].join("\n\n"),
198
181
  status: normalizeLogStatus(step.executionState ?? step.status),
199
- metadata: logDurationMetadata(timing?.startedAt, timing?.finishedAt),
200
- evidence,
201
- calls: []
182
+ metadata: [
183
+ ...context.filter((label) => label !== step.label),
184
+ ...logDurationMetadata(timing?.startedAt, timing?.finishedAt),
185
+ ...waiting
186
+ ],
187
+ evidence
202
188
  };
203
189
  }
204
190
  function logCallItem(call) {
191
+ const status = normalizeLogStatus(call.status);
205
192
  return {
206
193
  id: "call-" + call.id,
207
194
  anchors: [],
208
195
  kind: "activity",
209
196
  time: validLogTime(call.createdAt),
210
- title: shortenLogTitle(call.title),
197
+ title: call.title,
211
198
  content: "",
212
- status: normalizeLogStatus(call.status) === "completed" && (call.hasWarnings || call.hasChildErrors) ? "warning" : normalizeLogStatus(call.status),
199
+ status: status === "completed" && (call.hasWarnings || call.hasChildErrors) ? "warning" : status,
213
200
  metadata: logDurationMetadata(call.createdAt, call.context.finishedAt),
214
201
  evidence: [],
215
- calls: [],
216
202
  logId: call.id
217
203
  };
218
204
  }
219
- function isRoutineCall(call) {
220
- const isProjectTask = ["project-task", "plugin-task"].includes(call.operationKind);
221
- const isSlow = Boolean(call.context.finishedAt && Date.parse(call.context.finishedAt) - Date.parse(call.createdAt) >= SLOW_CALL_MILLISECONDS);
222
- return normalizeLogStatus(call.status) === "completed" && !call.hasWarnings && !call.hasChildErrors && !isProjectTask && !isSlow;
223
- }
224
205
  function logDurationMetadata(start, end) {
225
206
  if (!start || !end) return [];
226
207
  const seconds = (Date.parse(end) - Date.parse(start)) / 1e3;
@@ -231,7 +212,7 @@ function validLogTime(time) {
231
212
  }
232
213
  //#endregion
233
214
  //#region src/ui/ExecutionLogTimeline.tsx
234
- /** 同一执行过程的完整阅读和紧凑预览;转换不写入存储,技术证据按需展开。 */
215
+ /** 连续展示命令、输出与消息;完整日志和工作区预览共用阅读与复制交互。 */
235
216
  const MARKDOWN_PLUGINS = [remarkGfm];
236
217
  const DISALLOWED_ELEMENTS = ["img"];
237
218
  const CLOCK = new Intl.DateTimeFormat("zh-CN", {
@@ -242,7 +223,8 @@ const CLOCK = new Intl.DateTimeFormat("zh-CN", {
242
223
  });
243
224
  const RECENT_ENTRY_LIMIT = 20;
244
225
  const LATEST_SCROLL_THRESHOLD = 24;
245
- const ExecutionLogTimeline = memo(function ExecutionLogTimeline({ entries, record, display = "full", executionId, limit = RECENT_ENTRY_LIMIT, isLoading, error, onOpenLog }) {
226
+ const LOG_KIND_LABELS = /* @__PURE__ */ new Map([["question", "提问"], ["answer", "回答"]]);
227
+ const ExecutionLogTimeline = memo(function ExecutionLogTimeline({ entries, record, relatedRecords, display = "full", executionId, limit = RECENT_ENTRY_LIMIT, isLoading, error, onOpenLog }) {
246
228
  const viewport = useRef(null);
247
229
  const following = useRef(true);
248
230
  const [isFollowing, setIsFollowing] = useState(true);
@@ -251,7 +233,11 @@ const ExecutionLogTimeline = memo(function ExecutionLogTimeline({ entries, recor
251
233
  id: "",
252
234
  title: "",
253
235
  entries: [...entries ?? []]
254
- }), [entries, record]);
236
+ }, relatedRecords), [
237
+ entries,
238
+ record,
239
+ relatedRecords
240
+ ]);
255
241
  const recent = isCompact ? items.slice(-limit) : items;
256
242
  const handleLatest = useCallback(() => {
257
243
  following.current = true;
@@ -271,7 +257,7 @@ const ExecutionLogTimeline = memo(function ExecutionLogTimeline({ entries, recor
271
257
  return /* @__PURE__ */ jsxs("section", {
272
258
  className: "workbase-execution-log",
273
259
  "data-display": display,
274
- "aria-label": isCompact ? "最近执行动态" : "执行时间线",
260
+ "aria-label": isCompact ? "最近执行动态" : "执行日志",
275
261
  children: [
276
262
  error ? /* @__PURE__ */ jsx("p", {
277
263
  className: "workbase-log-error",
@@ -320,123 +306,122 @@ const LogItem = memo(function LogItem({ item, isCompact, onOpenLog }) {
320
306
  const handleOpen = useCallback(() => {
321
307
  if (item.logId) onOpenLog?.(item.logId);
322
308
  }, [item.logId, onOpenLog]);
323
- const handleCall = useCallback((event) => {
324
- const logId = event.currentTarget.dataset.logId;
325
- if (logId && item.calls.some((call) => call.id === logId)) onOpenLog?.(logId);
326
- }, [item.calls, onOpenLog]);
327
309
  const hasBody = Boolean(item.content.trim()) && (item.kind === "message" || item.content.trim() !== item.title.trim());
328
- const hasDetails = hasBody || item.evidence.length > 0 || item.calls.length > 0 || item.metadata.length > 0 || Boolean(item.logId);
329
- const needsAttention = [
330
- "failed",
331
- "needs_action",
332
- "warning",
333
- "interrupted"
334
- ].includes(item.status);
335
- const heading = /* @__PURE__ */ jsxs("span", {
336
- className: "workbase-log-heading",
337
- children: [
338
- /* @__PURE__ */ jsx("strong", {
339
- title: isCompact ? item.title : void 0,
340
- children: !isCompact && item.kind === "message" ? "进展" : item.title
341
- }),
342
- !isCompact && item.metadata.length ? /* @__PURE__ */ jsx("span", {
343
- className: "workbase-log-note",
344
- children: item.metadata.join(" · ")
345
- }) : null,
346
- item.status ? /* @__PURE__ */ jsx("span", {
347
- className: "workbase-log-status",
348
- "data-status": item.status,
349
- children: executionLogStatusLabel(item.status)
350
- }) : null
351
- ]
352
- });
353
- const body = /* @__PURE__ */ jsxs(Fragment, { children: [
354
- hasBody ? /* @__PURE__ */ jsx("div", {
355
- className: "workbase-log-content",
356
- "data-markdown-source": "",
357
- children: /* @__PURE__ */ jsx(Markdown, {
358
- remarkPlugins: MARKDOWN_PLUGINS,
359
- skipHtml: true,
360
- disallowedElements: DISALLOWED_ELEMENTS,
361
- children: item.content
362
- })
363
- }) : null,
364
- item.logId && onOpenLog ? /* @__PURE__ */ jsx("button", {
365
- type: "button",
366
- className: "workbase-log-link",
367
- onClick: handleOpen,
368
- children: "查看执行记录"
369
- }) : null,
370
- item.calls.length ? /* @__PURE__ */ jsx("ul", {
371
- className: "workbase-log-calls",
372
- children: item.calls.map((call) => /* @__PURE__ */ jsxs("li", { children: [
373
- /* @__PURE__ */ jsx("span", { children: call.title }),
374
- /* @__PURE__ */ jsx("span", {
375
- className: "workbase-log-note",
376
- children: executionLogStatusLabel(call.status)
377
- }),
378
- onOpenLog ? /* @__PURE__ */ jsx("button", {
379
- type: "button",
380
- className: "workbase-log-link",
381
- "data-log-id": call.id,
382
- onClick: handleCall,
383
- children: "查看记录"
384
- }) : null
385
- ] }, call.id))
386
- }) : null,
387
- item.evidence.map((evidence) => /* @__PURE__ */ jsx(LogEvidence, { evidence }, evidence.label))
388
- ] });
310
+ const kindLabel = LOG_KIND_LABELS.get(item.kind);
311
+ const heading = item.kind === "message" ? "进展" : item.title;
389
312
  const clock = item.time ? CLOCK.format(new Date(item.time)) : "时间未记录";
390
- return /* @__PURE__ */ jsxs("li", {
313
+ return /* @__PURE__ */ jsx("li", {
391
314
  id: isCompact ? void 0 : item.id,
392
315
  tabIndex: isCompact ? void 0 : -1,
393
316
  className: "workbase-log-entry",
394
317
  "data-kind": item.kind,
395
318
  "data-status": item.status,
396
- children: [/* @__PURE__ */ jsx("time", {
397
- className: "workbase-log-time",
398
- dateTime: item.time ?? void 0,
399
- children: clock
400
- }), /* @__PURE__ */ jsxs("div", {
319
+ children: /* @__PURE__ */ jsxs("div", {
401
320
  className: "workbase-log-body",
402
- children: [!isCompact ? item.anchors.map((anchor) => /* @__PURE__ */ jsx("span", {
403
- id: anchor,
404
- className: "workbase-log-anchor"
405
- }, anchor)) : null, !isCompact && item.kind === "activity" && hasDetails ? /* @__PURE__ */ jsxs("details", {
406
- className: "workbase-log-operation",
407
- open: needsAttention,
408
- children: [/* @__PURE__ */ jsx("summary", { children: heading }), body]
409
- }) : /* @__PURE__ */ jsxs(Fragment, { children: [heading, !isCompact ? body : null] })]
410
- })]
321
+ children: [
322
+ !isCompact ? item.anchors.map((anchor) => /* @__PURE__ */ jsx("span", {
323
+ id: anchor,
324
+ className: "workbase-log-anchor"
325
+ }, anchor)) : null,
326
+ /* @__PURE__ */ jsxs("div", {
327
+ className: "workbase-log-heading",
328
+ children: [
329
+ kindLabel ? /* @__PURE__ */ jsx("span", {
330
+ className: "workbase-log-kind",
331
+ children: kindLabel
332
+ }) : null,
333
+ /* @__PURE__ */ jsx("strong", { children: heading }),
334
+ item.status ? /* @__PURE__ */ jsx("span", {
335
+ className: "workbase-log-status",
336
+ "data-status": item.status,
337
+ children: executionLogStatusLabel(item.status)
338
+ }) : null,
339
+ item.metadata.length ? /* @__PURE__ */ jsx("span", {
340
+ className: "workbase-log-note",
341
+ children: item.metadata.join(" · ")
342
+ }) : null,
343
+ /* @__PURE__ */ jsx("time", {
344
+ className: "workbase-log-time",
345
+ dateTime: item.time ?? void 0,
346
+ children: clock
347
+ })
348
+ ]
349
+ }),
350
+ hasBody ? /* @__PURE__ */ jsx("div", {
351
+ className: "workbase-log-content",
352
+ "data-markdown-source": "",
353
+ children: /* @__PURE__ */ jsx(Markdown, {
354
+ remarkPlugins: MARKDOWN_PLUGINS,
355
+ skipHtml: true,
356
+ disallowedElements: DISALLOWED_ELEMENTS,
357
+ children: item.content
358
+ })
359
+ }) : null,
360
+ item.evidence.length ? /* @__PURE__ */ jsx(LogEvidence, { evidence: item.evidence }) : null,
361
+ item.logId && onOpenLog ? /* @__PURE__ */ jsx("button", {
362
+ type: "button",
363
+ className: "workbase-log-link",
364
+ onClick: handleOpen,
365
+ children: "打开关联记录"
366
+ }) : null
367
+ ]
368
+ })
411
369
  });
412
370
  });
413
371
  const LogEvidence = memo(function LogEvidence({ evidence }) {
414
372
  const [copyState, setCopyState] = useState("");
373
+ const command = evidence.find(({ kind }) => kind === "command");
374
+ const output = evidence.filter(({ kind }) => kind !== "command");
375
+ const label = command ? "命令与输出" : "输出";
415
376
  const handleCopy = useCallback(async () => {
416
377
  try {
417
- await navigator.clipboard.writeText(evidence.content);
378
+ await navigator.clipboard.writeText(evidence.map(({ content }) => content).join("\n\n"));
418
379
  setCopyState("已复制");
419
380
  } catch {
420
381
  setCopyState("复制失败,请选择文本复制");
421
382
  }
422
- }, [evidence.content]);
423
- return /* @__PURE__ */ jsxs("details", {
424
- className: "workbase-log-details",
425
- children: [
426
- /* @__PURE__ */ jsx("summary", { children: evidence.label }),
427
- /* @__PURE__ */ jsxs("div", {
428
- className: "workbase-log-copy",
429
- children: [/* @__PURE__ */ jsx("button", {
383
+ }, [evidence]);
384
+ useEffect(() => {
385
+ setCopyState("");
386
+ }, [evidence]);
387
+ return /* @__PURE__ */ jsxs("div", {
388
+ className: "workbase-log-terminal",
389
+ role: "group",
390
+ "aria-label": label,
391
+ children: [/* @__PURE__ */ jsxs("div", {
392
+ className: "workbase-log-toolbar",
393
+ children: [
394
+ command ? /* @__PURE__ */ jsxs("pre", {
395
+ "aria-label": command.label,
396
+ children: [/* @__PURE__ */ jsx("span", {
397
+ className: "workbase-log-prompt",
398
+ "aria-hidden": "true",
399
+ children: "$ "
400
+ }), /* @__PURE__ */ jsx("code", { children: command.content })]
401
+ }) : /* @__PURE__ */ jsx("span", { children: label }),
402
+ /* @__PURE__ */ jsx("span", {
403
+ className: "workbase-log-copy",
404
+ role: "status",
405
+ children: copyState
406
+ }),
407
+ /* @__PURE__ */ jsx("button", {
430
408
  type: "button",
431
409
  onClick: handleCopy,
410
+ "aria-label": "复制" + label,
432
411
  children: "复制"
433
- }), /* @__PURE__ */ jsx("span", {
434
- role: "status",
435
- children: copyState
436
- })]
437
- }),
438
- /* @__PURE__ */ jsx("pre", { children: evidence.content })
439
- ]
412
+ })
413
+ ]
414
+ }), output.map((block) => /* @__PURE__ */ jsxs("div", {
415
+ className: "workbase-log-stream",
416
+ "data-stream": block.kind,
417
+ children: [block.kind === "error" ? /* @__PURE__ */ jsx("span", {
418
+ className: "workbase-log-stream-label",
419
+ children: block.label
420
+ }) : null, /* @__PURE__ */ jsx("pre", {
421
+ "aria-label": block.label,
422
+ children: /* @__PURE__ */ jsx("code", { children: block.content })
423
+ })]
424
+ }, block.kind + block.label))]
440
425
  });
441
426
  });
442
427
  //#endregion