@eworkbase/sdk 0.3.6 → 0.4.1

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.
@@ -0,0 +1,443 @@
1
+ import { memo, useCallback, useEffect, useMemo, useRef, useState } from "react";
2
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
+ import Markdown from "react-markdown";
4
+ import remarkGfm from "remark-gfm";
5
+ //#region src/ui/ExecutionLogTimeline.dto.ts
6
+ let ExecutionLogDisplay = /* @__PURE__ */ function(ExecutionLogDisplay) {
7
+ ExecutionLogDisplay["Full"] = "full";
8
+ ExecutionLogDisplay["Compact"] = "compact";
9
+ return ExecutionLogDisplay;
10
+ }({});
11
+ //#endregion
12
+ //#region src/ui/execution-log-model.ts
13
+ const LOG_TITLE_LIMIT = 96;
14
+ const SLOW_CALL_MILLISECONDS = 3e4;
15
+ const LOG_STATUS_LABELS = /* @__PURE__ */ new Map([
16
+ ["pending", "等待中"],
17
+ ["in_progress", "进行中"],
18
+ ["completed", "已完成"],
19
+ ["failed", "失败"],
20
+ ["cancelled", "已取消"],
21
+ ["interrupted", "已中断"],
22
+ ["needs_action", "需处理"],
23
+ ["warning", "有警告"],
24
+ ["unknown", "未记录"]
25
+ ]);
26
+ /** Adapts existing evidence for both complete and compact readers without persisting derived events. */
27
+ function buildExecutionLogItems(record) {
28
+ const entries = (record.entries ?? []).map(logEntryItem);
29
+ const calls = [...new Map((record.children ?? []).map((call) => [call.id, call])).values()];
30
+ const routine = calls.filter(isRoutineCall);
31
+ const steps = record.steps ?? [];
32
+ const wrapper = Boolean(record.execution && entries.length && steps.length === 1 && steps[0].target?.kind === "plugin" && steps[0].target.id === record.execution.pluginId);
33
+ const items = [
34
+ ...entries,
35
+ ...wrapper ? [] : steps.map(logStepItem),
36
+ ...calls.filter((call) => !isRoutineCall(call)).map(logCallItem)
37
+ ];
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
+ });
51
+ if (record.warnings?.length) items.push({
52
+ id: "warnings",
53
+ anchors: [],
54
+ kind: "activity",
55
+ time: null,
56
+ title: "执行警告",
57
+ content: record.warnings.join("\n\n"),
58
+ status: "warning",
59
+ metadata: [],
60
+ evidence: [{
61
+ label: "警告",
62
+ content: record.warnings.join("\n")
63
+ }],
64
+ calls: []
65
+ });
66
+ for (const message of record.messages ?? []) items.push({
67
+ id: "message-" + message.id,
68
+ anchors: [],
69
+ kind: "activity",
70
+ time: validLogTime(message.createdAt),
71
+ title: shortenLogTitle(message.message),
72
+ content: "",
73
+ status: message.level === "error" ? "failed" : message.level === "warn" ? "warning" : "",
74
+ metadata: [],
75
+ evidence: [{
76
+ label: "运行诊断 · " + message.level,
77
+ 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;
85
+ });
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
+ const text = title.trim();
111
+ const file = /^(?:Read file|List files in) ['"](.+)['"]$/i.exec(text);
112
+ if (file) return (/^Read/i.test(text) ? "读取文件:" : "列出文件:") + file[1].split(/[\\/]/).filter(Boolean).at(-1);
113
+ if (/^Search for ['"]/i.test(text)) return "搜索内容";
114
+ if (/^(?:python\d*|node|bash|sh|zsh)\s/i.test(text)) return "执行命令:" + text.split(/\s/, 1)[0];
115
+ const firstLine = text.split(/\r?\n/, 1)[0];
116
+ return firstLine.length > LOG_TITLE_LIMIT ? firstLine.slice(0, LOG_TITLE_LIMIT) + "…" : firstLine || "执行记录";
117
+ }
118
+ 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
+ return {
129
+ id: "entry-" + entry.id,
130
+ anchors: [],
131
+ kind: entry.kind,
132
+ time: validLogTime(entry.time),
133
+ title,
134
+ content: entry.content.trim() === entry.title.trim() && entry.kind === "activity" ? "" : entry.content,
135
+ status: normalizeLogStatus(entry.status),
136
+ metadata: [],
137
+ evidence,
138
+ calls: []
139
+ };
140
+ }
141
+ function logStepItem(step) {
142
+ const evidence = [
143
+ {
144
+ label: "命令",
145
+ content: step.command
146
+ },
147
+ {
148
+ label: "标准输出",
149
+ content: step.stdout
150
+ },
151
+ {
152
+ label: "标准错误",
153
+ content: step.stderr
154
+ },
155
+ {
156
+ label: "处理说明",
157
+ content: step.manualActionMessage
158
+ }
159
+ ].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 = [
172
+ step.target?.label,
173
+ phases.get(step.phase ?? "") ?? step.phase,
174
+ step.provider
175
+ ].filter(Boolean).join(" · ");
176
+ 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
+ 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
+ });
191
+ return {
192
+ id: step.id,
193
+ anchors: step.legacyId && step.legacyId !== step.id ? [step.legacyId] : [],
194
+ kind: "activity",
195
+ time: validLogTime(timing?.startedAt ?? timing?.queuedAt),
196
+ title: shortenLogTitle(step.label),
197
+ content: [step.detail, step.manualActionMessage].filter(Boolean).join("\n\n"),
198
+ status: normalizeLogStatus(step.executionState ?? step.status),
199
+ metadata: logDurationMetadata(timing?.startedAt, timing?.finishedAt),
200
+ evidence,
201
+ calls: []
202
+ };
203
+ }
204
+ function logCallItem(call) {
205
+ return {
206
+ id: "call-" + call.id,
207
+ anchors: [],
208
+ kind: "activity",
209
+ time: validLogTime(call.createdAt),
210
+ title: shortenLogTitle(call.title),
211
+ content: "",
212
+ status: normalizeLogStatus(call.status) === "completed" && (call.hasWarnings || call.hasChildErrors) ? "warning" : normalizeLogStatus(call.status),
213
+ metadata: logDurationMetadata(call.createdAt, call.context.finishedAt),
214
+ evidence: [],
215
+ calls: [],
216
+ logId: call.id
217
+ };
218
+ }
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
+ function logDurationMetadata(start, end) {
225
+ if (!start || !end) return [];
226
+ const seconds = (Date.parse(end) - Date.parse(start)) / 1e3;
227
+ return Number.isFinite(seconds) && seconds >= 0 ? [seconds.toFixed(1) + " 秒"] : [];
228
+ }
229
+ function validLogTime(time) {
230
+ return time && Number.isFinite(Date.parse(time)) ? time : null;
231
+ }
232
+ //#endregion
233
+ //#region src/ui/ExecutionLogTimeline.tsx
234
+ /** 同一执行过程的完整阅读和紧凑预览;转换不写入存储,技术证据按需展开。 */
235
+ const MARKDOWN_PLUGINS = [remarkGfm];
236
+ const DISALLOWED_ELEMENTS = ["img"];
237
+ const CLOCK = new Intl.DateTimeFormat("zh-CN", {
238
+ hour: "2-digit",
239
+ minute: "2-digit",
240
+ second: "2-digit",
241
+ hour12: false
242
+ });
243
+ const RECENT_ENTRY_LIMIT = 20;
244
+ const LATEST_SCROLL_THRESHOLD = 24;
245
+ const ExecutionLogTimeline = memo(function ExecutionLogTimeline({ entries, record, display = "full", executionId, limit = RECENT_ENTRY_LIMIT, isLoading, error, onOpenLog }) {
246
+ const viewport = useRef(null);
247
+ const following = useRef(true);
248
+ const [isFollowing, setIsFollowing] = useState(true);
249
+ const isCompact = display === "compact";
250
+ const items = useMemo(() => buildExecutionLogItems(record ?? {
251
+ id: "",
252
+ title: "",
253
+ entries: [...entries ?? []]
254
+ }), [entries, record]);
255
+ const recent = isCompact ? items.slice(-limit) : items;
256
+ const handleLatest = useCallback(() => {
257
+ following.current = true;
258
+ setIsFollowing(true);
259
+ if (viewport.current) viewport.current.scrollTop = viewport.current.scrollHeight;
260
+ }, []);
261
+ const handleScroll = useCallback((event) => {
262
+ const { scrollTop, scrollHeight, clientHeight } = event.currentTarget;
263
+ const latest = scrollHeight - scrollTop - clientHeight <= LATEST_SCROLL_THRESHOLD;
264
+ following.current = latest;
265
+ setIsFollowing(latest);
266
+ }, []);
267
+ useEffect(handleLatest, [executionId, handleLatest]);
268
+ useEffect(() => {
269
+ if (isCompact && following.current && viewport.current) viewport.current.scrollTop = viewport.current.scrollHeight;
270
+ }, [items, isCompact]);
271
+ return /* @__PURE__ */ jsxs("section", {
272
+ className: "workbase-execution-log",
273
+ "data-display": display,
274
+ "aria-label": isCompact ? "最近执行动态" : "执行时间线",
275
+ children: [
276
+ error ? /* @__PURE__ */ jsx("p", {
277
+ className: "workbase-log-error",
278
+ role: "alert",
279
+ children: error
280
+ }) : null,
281
+ isLoading && !items.length ? /* @__PURE__ */ jsx("p", {
282
+ className: "workbase-log-note",
283
+ role: "status",
284
+ children: "正在读取执行记录…"
285
+ }) : null,
286
+ !items.length && !isLoading && !error ? /* @__PURE__ */ jsx("p", {
287
+ className: "workbase-log-note",
288
+ children: "尚无过程记录。"
289
+ }) : null,
290
+ /* @__PURE__ */ jsx("div", {
291
+ ref: viewport,
292
+ className: "workbase-log-viewport",
293
+ onScroll: isCompact ? handleScroll : void 0,
294
+ role: isCompact ? "region" : void 0,
295
+ "aria-label": isCompact ? "最近执行动态,可滚动" : void 0,
296
+ tabIndex: isCompact ? 0 : void 0,
297
+ children: /* @__PURE__ */ jsx("ol", {
298
+ className: "workbase-log-entries",
299
+ children: recent.map((item) => /* @__PURE__ */ jsx(LogItem, {
300
+ item,
301
+ isCompact,
302
+ onOpenLog
303
+ }, item.id))
304
+ })
305
+ }),
306
+ isCompact ? /* @__PURE__ */ jsx("div", {
307
+ className: "workbase-log-follow",
308
+ children: /* @__PURE__ */ jsx("button", {
309
+ type: "button",
310
+ className: "workbase-log-latest",
311
+ "data-following": isFollowing,
312
+ onClick: handleLatest,
313
+ children: "回到最新"
314
+ })
315
+ }) : null
316
+ ]
317
+ });
318
+ });
319
+ const LogItem = memo(function LogItem({ item, isCompact, onOpenLog }) {
320
+ const handleOpen = useCallback(() => {
321
+ if (item.logId) onOpenLog?.(item.logId);
322
+ }, [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
+ 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
+ ] });
389
+ const clock = item.time ? CLOCK.format(new Date(item.time)) : "时间未记录";
390
+ return /* @__PURE__ */ jsxs("li", {
391
+ id: isCompact ? void 0 : item.id,
392
+ tabIndex: isCompact ? void 0 : -1,
393
+ className: "workbase-log-entry",
394
+ "data-kind": item.kind,
395
+ "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", {
401
+ 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
+ })]
411
+ });
412
+ });
413
+ const LogEvidence = memo(function LogEvidence({ evidence }) {
414
+ const [copyState, setCopyState] = useState("");
415
+ const handleCopy = useCallback(async () => {
416
+ try {
417
+ await navigator.clipboard.writeText(evidence.content);
418
+ setCopyState("已复制");
419
+ } catch {
420
+ setCopyState("复制失败,请选择文本复制");
421
+ }
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", {
430
+ type: "button",
431
+ onClick: handleCopy,
432
+ children: "复制"
433
+ }), /* @__PURE__ */ jsx("span", {
434
+ role: "status",
435
+ children: copyState
436
+ })]
437
+ }),
438
+ /* @__PURE__ */ jsx("pre", { children: evidence.content })
439
+ ]
440
+ });
441
+ });
442
+ //#endregion
443
+ export { ExecutionLogDisplay, ExecutionLogTimeline, buildExecutionLogItems, executionLogStatusLabel };
package/dist/ui/index.css CHANGED
@@ -264,9 +264,9 @@ h2 {
264
264
  .configuration-tabs { display: flex; align-self: stretch; min-width: 0; gap: 24px; overflow-x: auto; }
265
265
  .configuration-tabs button { display: flex; align-items: center; justify-content: center; gap: 7px; flex: 0 0 auto; padding: 11px 0; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--color-muted); font: inherit; font-weight: 500; cursor: pointer; }
266
266
  .configuration-tabs button[aria-pressed="true"] { color: var(--color-foreground); border-bottom-color: var(--color-brand-gold); }
267
- .configuration-tabs button:hover { color: var(--color-foreground); }
267
+ .configuration-tabs button:hover:not(:disabled) { color: var(--color-foreground); }
268
268
  .configuration-tabs button span { color: var(--color-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
269
- .configuration-tabs button:disabled { cursor: default; }
269
+ .configuration-tabs button:disabled { cursor: not-allowed; opacity: .5; }
270
270
  .configuration-manager :is(button, input, select, textarea, summary, pre):focus-visible { outline: 2px solid var(--color-accent); outline-offset: 3px; }
271
271
  .configuration-manager .configuration-resource-grid { display: grid; grid-template-columns: 248px minmax(0, 1fr); align-items: stretch; min-height: 540px; border: 1px solid var(--color-border); border-radius: 10px; background: var(--color-surface); }
272
272
  .configuration-list { min-width: 0; padding: 20px 12px 12px; border-right: 1px solid var(--color-border); border-radius: 10px 0 0 10px; background: var(--color-surface-raised); }
@@ -274,23 +274,33 @@ h2 {
274
274
  .configuration-manager .configuration-list-heading h2 { margin: 0; font-size: 13px; font-weight: 600; }
275
275
  .configuration-search { width: 100%; min-height: 36px; min-width: 0; padding: 7px 10px; border: 1px solid var(--color-border); border-radius: 6px; background: var(--color-surface); color: var(--color-foreground); font: inherit; font-size: 12px; }
276
276
  .configuration-search::placeholder, .configuration-field :is(input, textarea)::placeholder { color: var(--color-tertiary); opacity: 1; }
277
+ .configuration-search:disabled { cursor: not-allowed; opacity: .5; background: var(--color-surface-muted); }
277
278
  .configuration-items { display: grid; align-content: start; gap: 4px; padding-top: 12px; max-height: 600px; overflow: auto; }
278
- .configuration-row { display: grid; gap: 5px; width: 100%; padding: 12px; border: 1px solid transparent; border-radius: 6px; text-align: left; color: inherit; background: transparent; font: inherit; cursor: pointer; overflow-wrap: anywhere; }
279
+ .configuration-item { position: relative; min-width: 0; }
280
+ .configuration-row { display: grid; gap: 5px; width: 100%; padding: 12px; padding-inline-end: 44px; border: 1px solid transparent; border-radius: 6px; text-align: left; color: inherit; background: transparent; font: inherit; cursor: pointer; overflow-wrap: anywhere; }
279
281
  .configuration-row strong { font-size: 13px; font-weight: 600; line-height: 1.5; }
280
282
  .configuration-row span { color: var(--color-muted); font-size: 11px; line-height: 1.5; }
281
- .configuration-row:hover { background: var(--color-surface-muted); }
283
+ .configuration-row:hover:not(:disabled) { background: var(--color-surface-muted); }
282
284
  .configuration-row[aria-current="true"] { border-color: var(--color-border); background: var(--color-surface); }
283
285
  .configuration-row[aria-current="true"] strong { color: var(--color-brand-deep); }
284
- .configuration-row:disabled { cursor: default; }
286
+ .configuration-row:disabled { cursor: not-allowed; }
287
+ .configuration-editing-notice { margin: 0 0 12px; color: var(--color-muted); font-size: 12px; }
285
288
  .configuration-row:disabled:not([aria-current="true"]) { opacity: .6; }
286
289
  .configuration-manager .configuration-list-footer { display: flex; justify-content: flex-start; margin: 16px 4px 0; padding-top: 16px; border-top: 1px solid var(--color-border); color: var(--color-muted); font-size: 12px; line-height: 1.7; }
287
290
  .configuration-detail { display: flex; flex-direction: column; min-width: 0; }
288
291
  .configuration-detail-header { display: flex; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; gap: 20px; padding: 26px 32px 22px; border-bottom: 1px solid var(--color-border); }
289
292
  .configuration-detail-header.is-editing { position: sticky; top: 0; z-index: 2; background: var(--color-surface); }
290
293
  .configuration-header-feedback { flex-basis: 100%; display: grid; gap: 12px; }
291
- .configuration-manager .configuration-header-feedback p { margin: 0; font-size: 12px; }
294
+ .configuration-manager .configuration-header-feedback > p { margin: 0; font-size: 12px; }
292
295
  .configuration-header-feedback .mantine-Alert-root { margin: 0; }
293
296
  .configuration-detail-header > div { min-width: 0; }
297
+ .configuration-delete { position: absolute; inset-block-start: 8px; inset-inline-end: 8px; width: 28px; height: 28px; padding: 4px; opacity: 0; pointer-events: none; }
298
+ .configuration-delete svg { width: 16px; height: 16px; }
299
+ .configuration-item:hover .configuration-delete,
300
+ .configuration-item:focus-within .configuration-delete { opacity: 1; pointer-events: auto; }
301
+ @media (hover: none), (pointer: coarse) {
302
+ .configuration-delete { opacity: 1; pointer-events: auto; }
303
+ }
294
304
  .configuration-manager .configuration-detail-header h2 { margin: 0; font-size: 20px; line-height: 1.4; font-weight: 600; letter-spacing: -.02em; overflow-wrap: anywhere; }
295
305
  .configuration-manager .configuration-detail-header p { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin: 8px 0 0; color: var(--color-muted); font-size: 12px; }
296
306
  .configuration-detail-header code { font-size: 11px; overflow-wrap: anywhere; }
@@ -1,157 +1,8 @@
1
- import { S as PluginExecutionSnapshot, m as PluginCommandExecutionResult } from "../types-Cl1kerLO.js";
2
- //#region src/ui/types.d.ts
3
- /**
4
- * Browser authoring API and transport contracts for Workbase plugin views.
5
- */
6
- type PluginUiPromptType = 'confirm' | 'multi-select' | 'select' | 'text';
7
- type PluginUiFileSelectionScope = 'project' | 'workspace';
8
- type PluginUiFileSelectionItemType = 'any' | 'directory' | 'file';
9
- interface PluginUiContextIdentity {
10
- readonly id: string;
11
- }
12
- interface PluginUiViewIdentity extends PluginUiContextIdentity {
13
- readonly pluginId: string;
14
- readonly title: string;
15
- }
16
- interface PluginUiInitializationPayload {
17
- readonly locale: string;
18
- readonly params: Readonly<Record<string, unknown>>;
19
- readonly project: PluginUiContextIdentity;
20
- readonly route: string | null;
21
- readonly theme: string;
22
- readonly view: PluginUiViewIdentity;
23
- readonly workspace: PluginUiContextIdentity;
24
- }
25
- interface WorkbasePluginUiDefinition {
26
- readonly onInit: (payload: PluginUiInitializationPayload) => void | Promise<void>;
27
- }
28
- interface PluginUiCommandExecuteOptions {
29
- readonly executionId?: string;
30
- }
31
- interface PluginUiNavigateOptions {
32
- readonly replace?: boolean;
33
- }
34
- interface PluginUiToastOptions {
35
- readonly description: string;
36
- readonly title: string;
37
- }
38
- interface PluginUiPromptChoice<Value = unknown> {
39
- readonly label: string;
40
- readonly value: Value;
41
- }
42
- interface PluginUiPromptOptions<Value = unknown> {
43
- readonly choices?: readonly PluginUiPromptChoice<Value>[];
44
- readonly defaultValue?: Value | readonly Value[] | null;
45
- readonly message: string;
46
- readonly searchable?: boolean;
47
- readonly submitLabel?: string;
48
- readonly title: string;
49
- readonly type: PluginUiPromptType;
50
- }
51
- interface PluginUiFileFilter {
52
- readonly extensions: readonly string[];
53
- readonly name: string;
54
- }
55
- interface PluginUiFileSelectOptions {
56
- readonly filters?: readonly PluginUiFileFilter[];
57
- readonly itemType?: PluginUiFileSelectionItemType;
58
- readonly multiple?: boolean;
59
- readonly rootPath?: string | null;
60
- readonly scope?: PluginUiFileSelectionScope;
61
- readonly title?: string;
62
- }
63
- interface PluginUiOutputOptions {
64
- readonly content: string;
65
- readonly description?: string | null;
66
- readonly id: string;
67
- readonly status?: string | null;
68
- readonly title: string;
69
- }
70
- /** A single authoritative execution update; removal retains its identity and revision. */
71
- interface PluginUiExecutionChange {
72
- readonly snapshot: PluginExecutionSnapshot;
73
- readonly removed: boolean;
74
- }
75
- interface PluginUiCommands {
76
- /** Subscribe before querying snapshots. Dispose when the view no longer consumes events. */
77
- readonly subscribe: (onChange: (change: PluginUiExecutionChange) => void) => Promise<() => Promise<void>>;
78
- /** Reveal the existing host question; does not create or answer a prompt. */
79
- readonly reply: (executionId: string) => Promise<void>;
80
- /** Clear one ended execution, or all when omitted; active runs, logs and Agent sessions are retained. */
81
- readonly clear: (executionId?: string) => Promise<void>;
82
- readonly start: (commandId: string, input: unknown, options?: PluginUiCommandExecuteOptions) => Promise<PluginExecutionSnapshot>;
83
- readonly query: (executionId?: string) => Promise<readonly PluginExecutionSnapshot[]>;
84
- readonly cancel: <Result = unknown>(executionId: string) => Promise<Result>;
85
- readonly execute: <Result = unknown>(commandId: string, input: unknown, options?: PluginUiCommandExecuteOptions) => Promise<PluginCommandExecutionResult<Result>>;
86
- }
87
- interface PluginUiStatus {
88
- readonly resolve: <Result = unknown>(statusId: string, input: unknown) => Promise<Result>;
89
- }
90
- interface PluginUiView {
91
- readonly call: <Result = unknown>(method: string, input: unknown) => Promise<Result>;
92
- }
93
- export declare enum PluginDesktopTarget {
94
- Editor = "editor",
95
- Terminal = "terminal",
96
- Folder = "folder",
97
- Chatgpt = "chatgpt"
98
- }
99
- interface PluginUiDesktopOpenOptions {
100
- readonly target: PluginDesktopTarget;
101
- /** Omit to use the current workspace root. */
102
- readonly repositoryId?: string;
103
- /** Existing path relative to the selected repository/workspace; defaults to its root. */
104
- readonly path?: string;
105
- }
106
- interface PluginUiDesktopOpenResult {
107
- readonly path: string;
108
- readonly targetId: string;
109
- }
110
- interface WorkbasePluginUi {
111
- /** Hides a resumable interaction without answering or cancelling it. */
112
- readonly dismiss: () => Promise<void>;
113
- /** Answers only the interaction currently hosted in this frame. Null cancels it. */
114
- readonly respond: (value: unknown | null) => Promise<void>;
115
- readonly closeOutput: <Result = unknown>(id: string) => Promise<Result>;
116
- readonly commands: PluginUiCommands;
117
- /** Available in ordinary plugin pages/tabs, including their detached windows. */
118
- readonly desktop: {
119
- readonly open: (options: PluginUiDesktopOpenOptions) => Promise<PluginUiDesktopOpenResult>;
120
- };
121
- readonly navigate: <Result = unknown>(to: string, options?: PluginUiNavigateOptions) => Promise<Result>;
122
- readonly openOutput: <Result = unknown>(options: PluginUiOutputOptions) => Promise<Result>;
123
- readonly selectFiles: (options?: PluginUiFileSelectOptions) => Promise<string | readonly string[] | null>;
124
- readonly showPrompt: <Value = unknown>(options: PluginUiPromptOptions<Value>) => Promise<Value | readonly Value[] | null>;
125
- readonly showToast: <Result = unknown>(options: PluginUiToastOptions) => Promise<Result>;
126
- readonly status: PluginUiStatus;
127
- readonly updateOutput: <Result = unknown>(options: PluginUiOutputOptions) => Promise<Result>;
128
- readonly view: PluginUiView;
129
- }
130
- interface PluginUiHostError extends Error {
131
- readonly code: string;
132
- }
133
- interface PluginUiHostMethods {
134
- readonly call: (method: string, params: unknown) => Promise<unknown>;
135
- readonly reportContentHeight: (height: number) => Promise<void>;
136
- readonly reportFatal: (message: string) => Promise<void>;
137
- }
138
- interface PluginUiClientMethods {
139
- readonly executionChanged: (change: PluginUiExecutionChange) => Promise<void>;
140
- readonly initialize: (payload: unknown) => Promise<void>;
141
- }
142
- interface PluginUiTransportConnection {
143
- readonly destroy: () => void;
144
- readonly promise: Promise<PluginUiHostMethods>;
145
- }
146
- interface PluginUiControllerOptions {
147
- readonly connectToHost: (methods: PluginUiClientMethods) => PluginUiTransportConnection;
148
- readonly targetWindow: Window & typeof globalThis;
149
- }
150
- //#endregion
1
+ import { C as PluginUiToastOptions, D as WorkbasePluginUi, E as PluginUiViewIdentity, O as WorkbasePluginUiDefinition, S as PluginUiStatus, T as PluginUiView, _ as PluginUiNavigateOptions, a as PluginUiContextIdentity, b as PluginUiPromptOptions, c as PluginUiDesktopOpenResult, d as PluginUiFileSelectOptions, f as PluginUiFileSelectionItemType, g as PluginUiInitializationPayload, h as PluginUiHostMethods, i as PluginUiCommands, l as PluginUiExecutionChange, m as PluginUiHostError, n as PluginUiClientMethods, o as PluginUiControllerOptions, p as PluginUiFileSelectionScope, r as PluginUiCommandExecuteOptions, s as PluginUiDesktopOpenOptions, t as PluginDesktopTarget, u as PluginUiFileFilter, v as PluginUiOutputOptions, w as PluginUiTransportConnection, x as PluginUiPromptType, y as PluginUiPromptChoice } from "../types-C8byxPji.js";
151
2
  //#region src/ui/controller.d.ts
152
3
  export declare function createPluginUiController(definition: WorkbasePluginUiDefinition, options: PluginUiControllerOptions): WorkbasePluginUi;
153
4
  //#endregion
154
5
  //#region src/ui/index.d.ts
155
6
  export declare function defineWorkbasePluginUi(definition: WorkbasePluginUiDefinition): WorkbasePluginUi;
156
7
  //#endregion
157
- export type { PluginUiClientMethods, PluginUiCommandExecuteOptions, PluginUiCommands, PluginUiContextIdentity, PluginUiControllerOptions, PluginUiDesktopOpenOptions, PluginUiDesktopOpenResult, PluginUiExecutionChange, PluginUiFileFilter, PluginUiFileSelectOptions, PluginUiFileSelectionItemType, PluginUiFileSelectionScope, PluginUiHostError, PluginUiHostMethods, PluginUiInitializationPayload, PluginUiNavigateOptions, PluginUiOutputOptions, PluginUiPromptChoice, PluginUiPromptOptions, PluginUiPromptType, PluginUiStatus, PluginUiToastOptions, PluginUiTransportConnection, PluginUiView, PluginUiViewIdentity, WorkbasePluginUi, WorkbasePluginUiDefinition };
8
+ export { PluginDesktopTarget, type PluginUiClientMethods, type PluginUiCommandExecuteOptions, type PluginUiCommands, type PluginUiContextIdentity, type PluginUiControllerOptions, type PluginUiDesktopOpenOptions, type PluginUiDesktopOpenResult, type PluginUiExecutionChange, type PluginUiFileFilter, type PluginUiFileSelectOptions, type PluginUiFileSelectionItemType, type PluginUiFileSelectionScope, type PluginUiHostError, type PluginUiHostMethods, type PluginUiInitializationPayload, type PluginUiNavigateOptions, type PluginUiOutputOptions, type PluginUiPromptChoice, type PluginUiPromptOptions, type PluginUiPromptType, type PluginUiStatus, type PluginUiToastOptions, type PluginUiTransportConnection, type PluginUiView, type PluginUiViewIdentity, type WorkbasePluginUi, type WorkbasePluginUiDefinition };
package/dist/ui/index.js CHANGED
@@ -194,6 +194,7 @@ function assertInitializationPayload(value) {
194
194
  }
195
195
  function isInitializationPayload(value) {
196
196
  if (!isRecord(value)) return false;
197
+ if (value.activationGeneration !== void 0 && (!Number.isSafeInteger(value.activationGeneration) || Number(value.activationGeneration) < 0)) return false;
197
198
  return isContextIdentity(value.project) && isContextIdentity(value.workspace) && isViewIdentity(value.view);
198
199
  }
199
200
  function isContextIdentity(value) {