@dsh-workbench/shared 1.5.5-rc.0 → 1.5.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/dist/api/dsh.d.ts +9 -1
  2. package/dist/components/card/ApprovalPlan.css +3 -0
  3. package/dist/components/card/ApprovalPlan.js +7 -2
  4. package/dist/components/card/LongTaskRow.css +32 -0
  5. package/dist/components/card/LongTaskRow.d.ts +8 -2
  6. package/dist/components/card/LongTaskRow.js +26 -5
  7. package/dist/components/card/board-module.d.ts +35 -4
  8. package/dist/components/card/use-text-marquee.d.ts +15 -0
  9. package/dist/components/card/use-text-marquee.js +66 -0
  10. package/dist/components/feedback/ProgressBar.css +56 -0
  11. package/dist/components/feedback/ProgressBar.d.ts +25 -0
  12. package/dist/components/feedback/ProgressBar.js +22 -0
  13. package/dist/config/constants.d.ts +2 -0
  14. package/dist/config/constants.js +2 -0
  15. package/dist/contract/guards.d.ts +1 -0
  16. package/dist/contract/guards.js +3 -0
  17. package/dist/contract/long-task.d.ts +56 -0
  18. package/dist/contract/long-task.js +41 -0
  19. package/dist/contract/protocol/long-tasks.d.ts +8 -2
  20. package/dist/contract/unit.d.ts +1 -0
  21. package/dist/host/diy/diy-preset.d.ts +1 -1
  22. package/dist/host/diy/diy-preset.js +3 -3
  23. package/dist/host/flow/create.d.ts +2 -1
  24. package/dist/host/flow/create.js +6 -0
  25. package/dist/host/flow/dsh-journal.d.ts +3 -0
  26. package/dist/host/flow/dsh-journal.js +55 -0
  27. package/dist/host/flow/journal.d.ts +20 -0
  28. package/dist/host/flow/journal.js +30 -0
  29. package/dist/host/flow/open.js +43 -26
  30. package/dist/host/flow/task.js +12 -1
  31. package/dist/host/flow/types.d.ts +5 -0
  32. package/dist/host/platform/integration/browser-launch.d.ts +1 -0
  33. package/dist/host/platform/integration/browser-launch.js +9 -2
  34. package/dist/host/profile/bundle-manager.js +4 -6
  35. package/dist/host/unit/long-task-host.d.ts +18 -0
  36. package/dist/host/unit/long-task-host.js +44 -0
  37. package/dist/host/unit/long-task-progress.d.ts +3 -0
  38. package/dist/host/unit/long-task-progress.js +32 -0
  39. package/dist/host/unit/long-task.d.ts +14 -38
  40. package/dist/host/unit/long-task.js +95 -94
  41. package/dist/host/unit/unit-face.d.ts +2 -1
  42. package/dist/host/unit/with-intervention-retry.d.ts +20 -0
  43. package/dist/host/unit/with-intervention-retry.js +45 -0
  44. package/dist/host.d.ts +30 -19
  45. package/dist/host.js +30 -19
  46. package/dist/i18n/en.js +33 -7
  47. package/dist/i18n/index.d.ts +33 -7
  48. package/dist/i18n/zh.d.ts +32 -6
  49. package/dist/i18n/zh.js +32 -6
  50. package/dist/index.d.ts +4 -2
  51. package/dist/index.js +4 -2
  52. package/package.json +2 -1
  53. package/src/api/dsh.ts +12 -1
  54. package/src/components/card/ApprovalPlan.css +3 -0
  55. package/src/components/card/ApprovalPlan.tsx +9 -2
  56. package/src/components/card/LongTaskRow.css +32 -0
  57. package/src/components/card/LongTaskRow.tsx +51 -4
  58. package/src/components/card/__tests__/ApprovalPlan.test.tsx +50 -0
  59. package/src/components/card/__tests__/long-task-row.test.ts +64 -2
  60. package/src/components/card/board-module.ts +36 -4
  61. package/src/components/card/use-text-marquee.ts +79 -0
  62. package/src/components/feedback/ProgressBar.css +56 -0
  63. package/src/components/feedback/ProgressBar.tsx +60 -0
  64. package/src/config/constants.ts +3 -0
  65. package/src/contract/__tests__/long-task.test.ts +43 -1
  66. package/src/contract/guards.ts +4 -0
  67. package/src/contract/long-task.ts +75 -0
  68. package/src/contract/protocol/long-tasks.ts +9 -1
  69. package/src/contract/unit.ts +1 -0
  70. package/src/host/diy/__tests__/diy-preset.test.ts +2 -0
  71. package/src/host/diy/diy-preset.ts +3 -2
  72. package/src/host/flow/__tests__/dsh-journal.test.ts +56 -0
  73. package/src/host/flow/__tests__/flow-create.test.ts +41 -1
  74. package/src/host/flow/__tests__/flow-open.test.ts +32 -0
  75. package/src/host/flow/create.ts +8 -5
  76. package/src/host/flow/dsh-journal.ts +74 -0
  77. package/src/host/flow/journal.ts +46 -0
  78. package/src/host/flow/open.ts +41 -26
  79. package/src/host/flow/task.ts +11 -1
  80. package/src/host/flow/types.ts +6 -0
  81. package/src/host/platform/integration/__tests__/browser-launch.test.ts +27 -0
  82. package/src/host/platform/integration/browser-launch.ts +15 -3
  83. package/src/host/profile/bundle-manager.ts +4 -7
  84. package/src/host/unit/__tests__/long-task.test.ts +203 -2
  85. package/src/host/unit/long-task-host.ts +64 -0
  86. package/src/host/unit/long-task-progress.ts +37 -0
  87. package/src/host/unit/long-task.ts +112 -126
  88. package/src/host/unit/unit-face.ts +2 -1
  89. package/src/host/unit/with-intervention-retry.ts +55 -0
  90. package/src/host.ts +31 -20
  91. package/src/i18n/en.ts +33 -7
  92. package/src/i18n/zh.ts +32 -6
  93. package/src/index.ts +4 -2
package/dist/api/dsh.d.ts CHANGED
@@ -7,6 +7,8 @@ import type { AgentPresetRegistry, PresetDefinition } from '@deepseek-ai/dsh-age
7
7
  import type { ProfileContext } from '@deepseek-ai/dsh-app-boot';
8
8
  import type { IndexInjection, WebRoute } from '@deepseek-ai/dsh-host-webserver';
9
9
  import type { dshHomePath } from '@deepseek-ai/dsh-home-paths';
10
+ import type { Session, SessionId, SessionStore } from '@deepseek-ai/dsh-session';
11
+ import type { SessionController } from '@deepseek-ai/dsh-api-session-controller';
10
12
  import type { PluginInstallRequestId, PluginManager } from '@deepseek-ai/dsh-plugin-manager';
11
13
  import type Hmr from '@deepseek-ai/dsh-hmr';
12
14
  import type { ApprovalService } from '@deepseek-ai/dsh-user-approval';
@@ -97,6 +99,12 @@ export type DshSubagentResult = SubagentResult;
97
99
  /** 一条消息内容块(子 agent 的 prompt 与输出都是它)。 */
98
100
  export type DshContentBlock = ContentBlock;
99
101
  /** 一条会话 id 的 branded 串(子 agent 可以预先指定)。 */
100
- export type DshSessionId = import('@deepseek-ai/dsh-session').SessionId;
102
+ export type DshSessionId = SessionId;
103
+ /** 一条活着的 dsh 会话:插件记录与 projection 都从它读写。 */
104
+ export type DshSession = Session;
105
+ /** 宿主侧的会话名册(服务名 `sessions`);这里只用按 id 取会话。 */
106
+ export type DshSessionStore = Pick<SessionStore, 'get'>;
107
+ /** 宿主侧的会话控制器(服务名 `sessionController`):这里只用建一条会话。 */
108
+ export type DshSessionController = Pick<SessionController, 'create'>;
101
109
  /** 子 agent 结构化输出收的那份对象根 JSON Schema(dsh 的受支持子集)。 */
102
110
  export type DshObjectJsonSchema = import('@deepseek-ai/dsh-tools').ObjectJsonSchema;
@@ -34,6 +34,9 @@
34
34
  color: var(--dsw-alias-label-primary);
35
35
  overflow-wrap: anywhere;
36
36
  }
37
+ .wb-approvalLine {
38
+ display: block;
39
+ }
37
40
  .wb-approvalWarn {
38
41
  color: var(--dsw-alias-label-secondary);
39
42
  }
@@ -1,5 +1,10 @@
1
1
  import { h } from '../../lib/react.js';
2
2
  import './ApprovalPlan.css';
3
+ function linesOf(value) {
4
+ if (!Array.isArray(value))
5
+ return value;
6
+ return value.map((line, index) => h('span', { className: 'wb-approvalLine', key: String(index) }, line));
7
+ }
3
8
  /**
4
9
  * 审批屏那张"这次要做什么"的表:一行一项,上面可给一句附注、下面可给一句警告。
5
10
  * @returns 一个 div。
@@ -9,7 +14,7 @@ export function ApprovalPlan({ rows, hint, warn, children }) {
9
14
  hint === undefined ? null : h("p", { className: "wb-approvalHint" }, hint),
10
15
  h("dl", { className: "wb-approvalRows" }, rows.map((row, index) => (h("div", { className: "wb-approvalRow", key: String(index) },
11
16
  h("dt", { className: "wb-approvalLabel" }, row.label),
12
- h("dd", { className: "wb-approvalValue" }, row.value))))),
17
+ h("dd", { className: "wb-approvalValue" }, linesOf(row.value)))))),
13
18
  children,
14
- warn === undefined ? null : h("p", { className: "wb-approvalWarn" }, warn)));
19
+ warn === undefined ? null : h("p", { className: "wb-approvalWarn" }, linesOf(warn))));
15
20
  }
@@ -44,6 +44,20 @@
44
44
  overflow: auto;
45
45
  }
46
46
 
47
+ .wb-longTaskProgress {
48
+ display: flex;
49
+ align-items: center;
50
+ gap: var(--wb-len-8);
51
+ }
52
+
53
+ .wb-longTaskProgressText {
54
+ flex: none;
55
+ font-size: var(--dsw-font-xxxs-11-font-size);
56
+ line-height: var(--wb-line-16);
57
+ color: var(--dsw-alias-label-tertiary);
58
+ font-variant-numeric: tabular-nums;
59
+ }
60
+
47
61
  .wb-longTaskHeadEnd {
48
62
  display: inline-flex;
49
63
  flex: none;
@@ -186,6 +200,19 @@
186
200
  text-overflow: ellipsis;
187
201
  }
188
202
 
203
+ .wb-longTaskDense .wb-longTaskHeadRow {
204
+ height: auto;
205
+ min-height: var(--wb-len-24);
206
+ overflow: visible;
207
+ }
208
+
209
+ .wb-longTaskDense .wb-longTaskHeadline {
210
+ width: auto;
211
+ max-width: 100%;
212
+ white-space: normal;
213
+ overflow-wrap: anywhere;
214
+ }
215
+
189
216
  .wb-longTaskMeta {
190
217
  margin: 0;
191
218
  min-width: 0;
@@ -235,6 +262,11 @@
235
262
  color: var(--dsw-alias-state-error-primary);
236
263
  }
237
264
 
265
+ .wb-longTaskStepRow[data-kind='pending'] .wb-longTaskStepText {
266
+ color: var(--dsw-alias-label-tertiary);
267
+ opacity: 0.7;
268
+ }
269
+
238
270
  .wb-longTaskStepLink {
239
271
  flex: none;
240
272
  font-size: inherit;
@@ -1,4 +1,4 @@
1
- import { type LongTaskInterventionField, type LongTaskStatus, type LongTaskStepRow } from '../../contract/long-task.js';
1
+ import { type LongTaskInterventionField, type LongTaskProgress, type LongTaskStatus, type LongTaskStepRow } from '../../contract/long-task.js';
2
2
  import './LongTaskRow.css';
3
3
  /**
4
4
  * 长任务行尾的一个链接:地址与文字。
@@ -75,8 +75,14 @@ export interface LongTaskRowProps {
75
75
  readonly dotLabel?: string | undefined;
76
76
  /** 第几次重试那行的文案;只在 `attempt > 1` 时用,不给不画。 */
77
77
  readonly attemptLabel?: ((attempt: number) => string) | undefined;
78
- /** 紧凑档(默认 false)。 */
78
+ /** 紧凑档(默认 false);进度条降到 2px,数字由调用点并进 `meta`。 */
79
79
  readonly dense?: boolean | undefined;
80
+ /** 这一趟走到哪了;不合法或没给就一根条都不画。 */
81
+ readonly progress?: LongTaskProgress | undefined;
82
+ /** 计划里还没开始的步骤(只有给了计划才有);展开时排在已发生的步骤后面。 */
83
+ readonly pending?: readonly string[] | undefined;
84
+ /** 进度条的读屏名;不给就不挂 `aria-label`。 */
85
+ readonly progressLabel?: string | undefined;
80
86
  /** 失败原因;不给不画。 */
81
87
  readonly problem?: string | undefined;
82
88
  /** 行尾的链接,通常指向产物或日志。 */
@@ -1,4 +1,5 @@
1
- import { LONG_TASK_LINK_MAX, longTaskDot, longTaskIsLive, longTaskStopPress, longTaskStopStage, LONG_TASK_STOP_ARM_MS, } from '../../contract/long-task.js';
1
+ import { LONG_TASK_LINK_MAX, longTaskDot, longTaskIsLive, longTaskProgressIsValid, longTaskStopPress, longTaskStopStage, LONG_TASK_STOP_ARM_MS, } from '../../contract/long-task.js';
2
+ import { ProgressBar } from '../feedback/ProgressBar.js';
2
3
  import { Link } from '../layout/Link.js';
3
4
  import { Fragment, h, useEffect, useState } from '../../lib/react.js';
4
5
  import { Button, CodeBlock, DisclosureRow, IconCodeOutlineRegular, IconStopFillRegular, StateDot, } from '@deepseek-ai/dsh-client-ui-primitives';
@@ -111,30 +112,50 @@ export function LongTaskRow(props) {
111
112
  const problem = props.problem ?? '';
112
113
  const raw = (props.raw ?? '').trim();
113
114
  const steps = props.steps ?? [];
115
+ const pending = (props.pending ?? []).filter((text) => text.trim() !== '');
114
116
  const stop = props.stop;
115
117
  const busy = stop?.busy === true;
116
118
  const stopWhy = stop?.failed ?? '';
117
119
  const stopPending = stopFired && live && !busy && stopWhy === '' ? stop?.pending ?? '' : '';
120
+ const progress = props.progress === undefined || !longTaskProgressIsValid(props.progress)
121
+ ? undefined
122
+ : props.progress;
123
+ const progressTone = props.status === 'ok'
124
+ ? 'ok'
125
+ : props.status === 'failed'
126
+ ? 'bad'
127
+ : props.status === 'stopped'
128
+ ? 'neutral'
129
+ : props.status === 'needs-human' || props.status === 'needs-login'
130
+ ? 'warn'
131
+ : 'busy';
118
132
  useEffect(() => {
119
133
  if (failed)
120
134
  setStepsOpen(true);
121
135
  }, [failed]);
122
- const expandable = props.stepsTitle !== undefined && (history.length > 0 || steps.length > 0);
136
+ const expandable = props.stepsTitle !== undefined && (history.length > 0 || steps.length > 0 || pending.length > 0);
123
137
  const stepShown = step !== '' && !props.headline.includes(step);
124
138
  const dotNode = props.dotLabel === undefined ? (h(StateDot, { state: dot, size: 10 })) : (h("span", { role: "img", "aria-label": props.dotLabel },
125
139
  h(StateDot, { state: dot, size: 10 })));
126
140
  return (h("div", { className: props.dense === true ? 'wb-longTask wb-longTaskDense' : 'wb-longTask' },
127
- h(DisclosureRow, { icon: dotNode, title: props.headline, open: expandable && stepsOpen, expandable: expandable, expandOnRowClick: true, previewChevron: true, titleClassName: "wb-longTaskHeadline", onToggle: () => setStepsOpen((value) => !value), headerAccessory: h("span", { className: "wb-longTaskHeadEnd" },
141
+ h(DisclosureRow, { icon: dotNode, title: props.headline, open: expandable && stepsOpen, expandable: expandable, expandOnRowClick: true, previewChevron: true, titleClassName: "wb-longTaskHeadline", rowClassName: "wb-longTaskHeadRow", onToggle: () => setStepsOpen((value) => !value), headerAccessory: h("span", { className: "wb-longTaskHeadEnd" },
128
142
  (props.links ?? []).map((link) => (h(RowLink, { href: link.href, key: `${link.text}@${link.href}`, text: link.text }))),
129
143
  props.login === undefined ? null : (h(Button, { type: "button", size: "sm", variant: "outline", onClick: props.login.onOpen }, props.login.label)),
130
144
  meta === '' ? null : h("span", { className: "wb-longTaskMeta" }, meta),
131
145
  stop === undefined ? null : (h(StopControl, { stop: stop, onFired: () => setStopFired(true) }))) },
132
146
  stepShown ? h("p", { className: "wb-longTaskStep" }, step) : null,
133
- history.length === 0 ? (h(CodeBlock, { code: steps.join('\n'), className: "wb-longTaskDump", showHeader: props.copyLabel !== undefined, copyLabel: props.copyLabel ?? '', copiedLabel: props.copiedLabel ?? '' })) : (h("ul", { className: "wb-longTaskSteps" }, history.map((row, index) => (h(StepRow, { key: `${String(index)}:${row.text}`, row: row, live: live, last: index === history.length - 1, ...(props.attemptLabel === undefined ? {} : { attemptLabel: props.attemptLabel }) })))))),
147
+ history.length === 0 && pending.length === 0 ? (h(CodeBlock, { code: steps.join('\n'), className: "wb-longTaskDump", showHeader: props.copyLabel !== undefined, copyLabel: props.copyLabel ?? '', copiedLabel: props.copiedLabel ?? '' })) : (h("ul", { className: "wb-longTaskSteps" },
148
+ history.map((row, index) => (h(StepRow, { key: `${String(index)}:${row.text}`, row: row, live: live, last: index === history.length - 1, ...(props.attemptLabel === undefined ? {} : { attemptLabel: props.attemptLabel }) }))),
149
+ pending.map((text) => (h("li", { className: "wb-longTaskStepRow", "data-kind": "pending", key: `pending:${text}` },
150
+ h(StateDot, { state: "idle", size: 8 }),
151
+ h("span", { className: "wb-longTaskStepText" }, text))))))),
134
152
  stopPending === '' ? null : h("p", { className: "wb-longTaskStopPending" }, stopPending),
135
153
  props.intervention === undefined ? null : (h(InterventionNeed, { intervention: props.intervention })),
136
154
  problem === '' ? null : h("p", { className: "wb-longTaskProblem" }, problem),
137
155
  stopWhy === '' ? null : h("p", { className: "wb-longTaskStopWhy" }, stopWhy),
138
156
  raw === '' || props.rawTitle === undefined ? null : (h(DumpBlock, { icon: h(IconCodeOutlineRegular, { size: 14 }), title: props.rawTitle, open: rawOpen, onToggle: () => setRawOpen(!rawOpen) },
139
- h(CodeBlock, { code: raw, className: "wb-longTaskDump", showHeader: props.copyLabel !== undefined, copyLabel: props.copyLabel ?? '', copiedLabel: props.copiedLabel ?? '' })))));
157
+ h(CodeBlock, { code: raw, className: "wb-longTaskDump", showHeader: props.copyLabel !== undefined, copyLabel: props.copyLabel ?? '', copiedLabel: props.copiedLabel ?? '' }))),
158
+ progress === undefined ? null : (h("div", { className: "wb-longTaskProgress" },
159
+ h(ProgressBar, { progress: progress, size: props.dense === true ? 2 : 4, tone: progressTone, ...(props.progressLabel === undefined ? {} : { label: props.progressLabel }) }),
160
+ props.dense === true ? null : (h("span", { className: "wb-longTaskProgressText" }, `${String(progress.done)}/${String(progress.total)}`))))));
140
161
  }
@@ -302,24 +302,55 @@ export interface ApprovalInput {
302
302
  readonly tool: string;
303
303
  readonly args: Readonly<Record<string, unknown>>;
304
304
  }
305
+ /**
306
+ * 一条可以分多行的审批值:单字符串是一行,字符串数组由外壳按行排版。
307
+ */
308
+ export type ApprovalLines = string | readonly string[];
305
309
  /**
306
310
  * 审批详情里的一行附加事实:标签与值都由模块给。
307
311
  */
308
312
  export interface ApprovalPlanExtra {
313
+ /**
314
+ * 附加行的标签。
315
+ */
309
316
  readonly label: string;
310
- readonly value: string;
317
+ /**
318
+ * 附加行的值;字符串数组每项一行,最多 6 行。
319
+ */
320
+ readonly value: ApprovalLines;
311
321
  }
312
322
  /**
313
323
  * 模块审批详情的四行数据:对象、修改后、目标位置、影响范围,外加可选的领域标签、附加行与警告。
314
324
  */
315
325
  export interface ApprovalPlanData {
326
+ /**
327
+ * 修改项:这次改的是哪个对象。
328
+ */
316
329
  readonly object: string;
317
- readonly change: string;
330
+ /**
331
+ * 修改后:改成什么;多条事实用字符串数组,最多 6 行。
332
+ */
333
+ readonly change: ApprovalLines;
334
+ /**
335
+ * 目标位置:这次改在哪里。
336
+ */
318
337
  readonly target: string;
319
- readonly impact: string;
338
+ /**
339
+ * 影响范围:还会波及什么;多条事实用字符串数组,最多 6 行。
340
+ */
341
+ readonly impact: ApprovalLines;
342
+ /**
343
+ * 对象标签,默认「修改项」。
344
+ */
320
345
  readonly objectLabel?: string | undefined;
346
+ /**
347
+ * 附加事实行。
348
+ */
321
349
  readonly extra?: readonly ApprovalPlanExtra[] | undefined;
322
- readonly warn?: string | undefined;
350
+ /**
351
+ * 警告;多条事实用字符串数组,最多 6 行。
352
+ */
353
+ readonly warn?: ApprovalLines | undefined;
323
354
  }
324
355
  /**
325
356
  * 带四行数据的模块审批面:`plan` 是下限,`render` 可选地接管详情区(同步纯函数,不直接调 hook)。
@@ -0,0 +1,15 @@
1
+ /**
2
+ * 把一段被容器裁掉的文字在指针停留时横向推出来:会话列表的标题、长任务行的标题都用它。
3
+ */
4
+ export interface TextMarquee {
5
+ /** 指针进来:先量溢出,够一截才开始推;减少动效偏好下直接推到末尾。 */
6
+ enter(): void;
7
+ /** 指针离开:立刻回到起点,清掉两个 data 标记。 */
8
+ leave(): void;
9
+ }
10
+ /**
11
+ * 悬停推进的横向跑马灯:按帧累加 scrollLeft,回到起点即复位。
12
+ * @param target 现取滚动容器(元素归调用方所有,可能在子树里)。
13
+ * @returns 一对 enter / leave 指针回调。
14
+ */
15
+ export declare function useTextMarquee(target: () => HTMLElement | null): TextMarquee;
@@ -0,0 +1,66 @@
1
+ import { useEffect, useMemo, useRef } from 'react';
2
+ const MIN_REVEAL_PX = 8;
3
+ const PX_PER_MS = 0.03;
4
+ function placeTitle(title, left, range) {
5
+ title.scrollTo({ left, behavior: 'instant' });
6
+ if (left > 0)
7
+ title.dataset.scrolled = '';
8
+ else
9
+ delete title.dataset.scrolled;
10
+ if (left < range)
11
+ title.dataset.clipped = '';
12
+ else
13
+ delete title.dataset.clipped;
14
+ }
15
+ function restTitle(title) {
16
+ title.scrollTo({ left: 0, behavior: 'instant' });
17
+ delete title.dataset.scrolled;
18
+ delete title.dataset.clipped;
19
+ }
20
+ /**
21
+ * 悬停推进的横向跑马灯:按帧累加 scrollLeft,回到起点即复位。
22
+ * @param target 现取滚动容器(元素归调用方所有,可能在子树里)。
23
+ * @returns 一对 enter / leave 指针回调。
24
+ */
25
+ export function useTextMarquee(target) {
26
+ const frame = useRef(0);
27
+ const resolve = useRef(target);
28
+ useEffect(() => {
29
+ resolve.current = target;
30
+ });
31
+ useEffect(() => () => {
32
+ cancelAnimationFrame(frame.current);
33
+ }, []);
34
+ return useMemo(() => ({
35
+ enter: () => {
36
+ const element = resolve.current();
37
+ if (element === null)
38
+ return;
39
+ const range = element.scrollWidth - element.clientWidth;
40
+ if (range <= MIN_REVEAL_PX)
41
+ return;
42
+ if (window.matchMedia('(prefers-reduced-motion: reduce)').matches) {
43
+ placeTitle(element, range, range);
44
+ return;
45
+ }
46
+ cancelAnimationFrame(frame.current);
47
+ let previous;
48
+ let position = 0;
49
+ const step = (now) => {
50
+ position += previous === undefined ? 0 : (now - previous) * PX_PER_MS;
51
+ previous = now;
52
+ placeTitle(element, Math.min(position, range), range);
53
+ if (position < range)
54
+ frame.current = requestAnimationFrame(step);
55
+ };
56
+ frame.current = requestAnimationFrame(step);
57
+ },
58
+ leave: () => {
59
+ cancelAnimationFrame(frame.current);
60
+ const element = resolve.current();
61
+ if (element === null)
62
+ return;
63
+ restTitle(element);
64
+ },
65
+ }), []);
66
+ }
@@ -0,0 +1,56 @@
1
+ .wb-progress {
2
+ display: flex;
3
+ flex: 1 1 auto;
4
+ width: 100%;
5
+ min-width: 0;
6
+ overflow: hidden;
7
+ border-radius: var(--wb-radius-pill);
8
+ corner-shape: round;
9
+ background: var(--dsw-alias-bg-skeleton);
10
+ pointer-events: none;
11
+ }
12
+
13
+ .wb-progress-6 {
14
+ height: var(--wb-len-6);
15
+ }
16
+
17
+ .wb-progress-4 {
18
+ height: var(--wb-len-4);
19
+ }
20
+
21
+ .wb-progress-2 {
22
+ height: var(--wb-len-2);
23
+ }
24
+
25
+ .wb-progressFill {
26
+ height: 100%;
27
+ border-radius: var(--wb-radius-pill);
28
+ corner-shape: round;
29
+ transition: width var(--wb-dur-1-5) ease;
30
+ }
31
+
32
+ @media (prefers-reduced-motion: reduce) {
33
+ .wb-progressFill {
34
+ transition: none;
35
+ }
36
+ }
37
+
38
+ .wb-progressFillNeutral {
39
+ background: var(--dsw-alias-label-tertiary);
40
+ }
41
+
42
+ .wb-progressFillOk {
43
+ background: var(--dsw-alias-state-success-primary);
44
+ }
45
+
46
+ .wb-progressFillWarn {
47
+ background: var(--dsw-alias-state-warn-primary);
48
+ }
49
+
50
+ .wb-progressFillBad {
51
+ background: var(--dsw-alias-state-error-primary);
52
+ }
53
+
54
+ .wb-progressFillBusy {
55
+ background: var(--dsw-alias-state-business-primary);
56
+ }
@@ -0,0 +1,25 @@
1
+ import { type LongTaskProgress } from '../../contract/long-task.js';
2
+ import './ProgressBar.css';
3
+ /**
4
+ * 进度条的色档:与卡片指标的档位同一套令牌。
5
+ */
6
+ export type ProgressBarTone = 'neutral' | 'ok' | 'warn' | 'bad' | 'busy';
7
+ /**
8
+ * `ProgressBar` 的契约:走到哪、一共多少、多高、什么色。
9
+ */
10
+ export interface ProgressBarProps {
11
+ /** 进度:`done` / `total` 两个数。不合法时整根条不画。 */
12
+ readonly progress: LongTaskProgress;
13
+ /** 条高像素:6 是卡片指标档,4 是长任务普通档,2 是紧凑档(左栏列表)。默认 4。 */
14
+ readonly size?: 6 | 4 | 2;
15
+ /** 色档,默认按「在走」取主色。 */
16
+ readonly tone?: ProgressBarTone;
17
+ /** 读屏用的名字;给了才挂读屏可见的进角色。 */
18
+ readonly label?: string | undefined;
19
+ }
20
+ /**
21
+ * 一根进度条:轨道 + 填充,宽度按百分比。
22
+ * @param props 进度、条高、色档与读屏名。
23
+ * @returns 有进度时是一根带 `progressbar` 角色的条;没有合法进度时什么都不画。
24
+ */
25
+ export declare function ProgressBar({ progress, size, tone, label }: ProgressBarProps): JSX.Element | null;
@@ -0,0 +1,22 @@
1
+ import { h } from '../../lib/react.js';
2
+ import { longTaskProgressIsValid, longTaskProgressPercent, } from '../../contract/long-task.js';
3
+ import './ProgressBar.css';
4
+ const FILL = {
5
+ neutral: 'wb-progressFillNeutral',
6
+ ok: 'wb-progressFillOk',
7
+ warn: 'wb-progressFillWarn',
8
+ bad: 'wb-progressFillBad',
9
+ busy: 'wb-progressFillBusy',
10
+ };
11
+ /**
12
+ * 一根进度条:轨道 + 填充,宽度按百分比。
13
+ * @param props 进度、条高、色档与读屏名。
14
+ * @returns 有进度时是一根带 `progressbar` 角色的条;没有合法进度时什么都不画。
15
+ */
16
+ export function ProgressBar({ progress, size = 4, tone = 'busy', label }) {
17
+ if (!longTaskProgressIsValid(progress))
18
+ return null;
19
+ const width = longTaskProgressPercent(progress) ?? 0;
20
+ return (h("div", { className: `wb-progress wb-progress-${String(size)}`, role: "progressbar", "aria-valuemin": 0, "aria-valuemax": progress.total, "aria-valuenow": progress.done, "aria-valuetext": `${String(progress.done)}/${String(progress.total)}`, ...(label === undefined ? {} : { 'aria-label': label }) },
21
+ h("div", { className: `wb-progressFill ${FILL[tone]}`, style: { width: `${String(width)}%` } })));
22
+ }
@@ -50,6 +50,8 @@ export declare const DIY_DEBUG_SERVICE = "workbenchDiyDebug";
50
50
  export declare const DIY_RECORD_SERVICE = "workbenchDiyRecord";
51
51
  /** 会话投影服务的 dsh 服务名(`sessionProjections`):宿主经 `stateOf(session, 'agentPreset')` 读那一档。 */
52
52
  export declare const SESSION_PROJECTIONS_SERVICE = "sessionProjections";
53
+ /** 会话名册服务的 dsh 服务名(`sessions`):按 id 拿 Session,写 plugin record。 */
54
+ export declare const SESSION_STORE_SERVICE = "sessions";
53
55
  /** 面板清单一次取回的行数上限(条):外部模块拿它当分页参数。 */
54
56
  export declare const PANEL_LIST_LIMIT = 50;
55
57
  /** 单次运行时调用的默认超时(毫秒);调用点没传 `timeoutMs` 时按它算。 */
@@ -50,6 +50,8 @@ export const DIY_DEBUG_SERVICE = "workbenchDiyDebug";
50
50
  export const DIY_RECORD_SERVICE = "workbenchDiyRecord";
51
51
  /** 会话投影服务的 dsh 服务名(`sessionProjections`):宿主经 `stateOf(session, 'agentPreset')` 读那一档。 */
52
52
  export const SESSION_PROJECTIONS_SERVICE = "sessionProjections";
53
+ /** 会话名册服务的 dsh 服务名(`sessions`):按 id 拿 Session,写 plugin record。 */
54
+ export const SESSION_STORE_SERVICE = "sessions";
53
55
  /** 面板清单一次取回的行数上限(条):外部模块拿它当分页参数。 */
54
56
  export const PANEL_LIST_LIMIT = 50;
55
57
  /** 单次运行时调用的默认超时(毫秒);调用点没传 `timeoutMs` 时按它算。 */
@@ -1,4 +1,5 @@
1
1
  export declare function text(value: unknown): string;
2
+ export declare function texts(value: unknown): string[];
2
3
  export declare function isRecord(value: unknown): value is Readonly<Record<string, unknown>>;
3
4
  export declare function asRecord(value: unknown): Readonly<Record<string, unknown>> | undefined;
4
5
  export declare function outsideKeys(value: Readonly<Record<string, unknown>>, allowed: readonly string[]): string[];
@@ -1,6 +1,9 @@
1
1
  export function text(value) {
2
2
  return typeof value === 'string' ? value.trim() : '';
3
3
  }
4
+ export function texts(value) {
5
+ return Array.isArray(value) ? value.filter((item) => typeof item === 'string') : [];
6
+ }
4
7
  export function isRecord(value) {
5
8
  return typeof value === 'object' && value !== null && !Array.isArray(value);
6
9
  }
@@ -26,6 +26,55 @@ export interface LongTaskLink {
26
26
  }
27
27
  export declare const LONG_TASK_LINK_MAX = 3;
28
28
  export declare const LONG_TASK_HISTORY_MAX = 20;
29
+ /**
30
+ * 这一趟走到哪了:`done` 是已完成的数量,`total` 是一共多少。
31
+ * 没有单位词 —— 外壳只画 `3/7` 与一根条;「步」还是「项」由模块自己在步骤文案里说。
32
+ */
33
+ export interface LongTaskProgress {
34
+ readonly done: number;
35
+ readonly total: number;
36
+ }
37
+ /**
38
+ * 进度是否可用:两个有限数、`total > 0`、`done` 落在 `[0, total]`。
39
+ * 不合法的进度一律当作「没有进度」,界面上不画条 —— 不夹到边界,免得把坏数字画成好数字。
40
+ * @param progress 模块或注册表给的进度。
41
+ * @returns 可用为 `true`。
42
+ */
43
+ export declare function longTaskProgressIsValid(progress: LongTaskProgress): boolean;
44
+ /**
45
+ * 把进度折成 0..100 的百分比,供那根条用。
46
+ * @param progress 进度;没给就当没有进度。
47
+ * @returns 百分比;没给或不合法回 `null`。
48
+ */
49
+ /**
50
+ * 计划里的一步:`id` 与步骤事件里的 `stepId` 对齐,`title` 只是给展开里那行用的名字。
51
+ */
52
+ export interface LongTaskPlanStep {
53
+ readonly id: string;
54
+ readonly title?: string | undefined;
55
+ }
56
+ /**
57
+ * 这一趟打算走几步:给步骤表(能顺带列出没开始的步骤),或只给个数。
58
+ * 数字由外壳从步骤事件自己数,模块不报 `done`。
59
+ */
60
+ export type LongTaskPlan = {
61
+ readonly steps: readonly LongTaskPlanStep[];
62
+ } | {
63
+ readonly total: number;
64
+ };
65
+ /**
66
+ * 计划的总步数;两种写法都认,`total` 不合法时回 0(当作没有计划)。
67
+ * @param plan 模块声明的计划。
68
+ * @returns 步数。
69
+ */
70
+ export declare function longTaskPlanTotalOf(plan: LongTaskPlan): number;
71
+ /**
72
+ * 计划里的步骤表;只给了个数的那种回空表(列不出没开始的步骤)。
73
+ * @param plan 模块声明的计划。
74
+ * @returns 步骤表。
75
+ */
76
+ export declare function longTaskPlanStepsOf(plan: LongTaskPlan): readonly LongTaskPlanStep[];
77
+ export declare function longTaskProgressPercent(progress: LongTaskProgress | undefined): number | null;
29
78
  /**
30
79
  * 回执字段的输入类型:`text` 明文,`secret` 密码框(值同样只回给模块)。
31
80
  */
@@ -83,6 +132,13 @@ export interface LongTaskStepRow {
83
132
  * @returns <unit>/runs。
84
133
  */
85
134
  export declare function runsRouteOf(unit: string): string;
135
+ /**
136
+ * 「看过了」那条写路由(走 actions 通道的资源名):`<单元>/runs/seen`。
137
+ * 收尾后由外壳在列表把它渲染出来时发,清掉工作区选择器与会话行上的「已完成」提示。
138
+ * @param unit 单元 id。
139
+ * @returns <单元>/runs/seen。
140
+ */
141
+ export declare function seenRouteOf(unit: string): string;
86
142
  /**
87
143
  * 停止那条写路由(走 actions 通道的资源名):`<单元>/runs/stop`。
88
144
  * @param unit 单元 id。
@@ -1,5 +1,37 @@
1
1
  export const LONG_TASK_LINK_MAX = 3;
2
2
  export const LONG_TASK_HISTORY_MAX = 20;
3
+ /**
4
+ * 进度是否可用:两个有限数、`total > 0`、`done` 落在 `[0, total]`。
5
+ * 不合法的进度一律当作「没有进度」,界面上不画条 —— 不夹到边界,免得把坏数字画成好数字。
6
+ * @param progress 模块或注册表给的进度。
7
+ * @returns 可用为 `true`。
8
+ */
9
+ export function longTaskProgressIsValid(progress) {
10
+ const { done, total } = progress;
11
+ return Number.isFinite(done) && Number.isFinite(total) && total > 0 && done >= 0 && done <= total;
12
+ }
13
+ /**
14
+ * 计划的总步数;两种写法都认,`total` 不合法时回 0(当作没有计划)。
15
+ * @param plan 模块声明的计划。
16
+ * @returns 步数。
17
+ */
18
+ export function longTaskPlanTotalOf(plan) {
19
+ const total = 'steps' in plan ? plan.steps.length : plan.total;
20
+ return Number.isFinite(total) && total > 0 ? total : 0;
21
+ }
22
+ /**
23
+ * 计划里的步骤表;只给了个数的那种回空表(列不出没开始的步骤)。
24
+ * @param plan 模块声明的计划。
25
+ * @returns 步骤表。
26
+ */
27
+ export function longTaskPlanStepsOf(plan) {
28
+ return 'steps' in plan ? plan.steps : [];
29
+ }
30
+ export function longTaskProgressPercent(progress) {
31
+ if (progress === undefined || !longTaskProgressIsValid(progress))
32
+ return null;
33
+ return (progress.done / progress.total) * 100;
34
+ }
3
35
  /**
4
36
  * 单元的长任务读口路由。
5
37
  * @param unit 单元 id。
@@ -8,6 +40,15 @@ export const LONG_TASK_HISTORY_MAX = 20;
8
40
  export function runsRouteOf(unit) {
9
41
  return `${unit}/runs`;
10
42
  }
43
+ /**
44
+ * 「看过了」那条写路由(走 actions 通道的资源名):`<单元>/runs/seen`。
45
+ * 收尾后由外壳在列表把它渲染出来时发,清掉工作区选择器与会话行上的「已完成」提示。
46
+ * @param unit 单元 id。
47
+ * @returns <单元>/runs/seen。
48
+ */
49
+ export function seenRouteOf(unit) {
50
+ return `${unit}/runs/seen`;
51
+ }
11
52
  /**
12
53
  * 停止那条写路由(走 actions 通道的资源名):`<单元>/runs/stop`。
13
54
  * @param unit 单元 id。
@@ -1,6 +1,11 @@
1
- import type { LongTaskIntervention, LongTaskLink, LongTaskStatus, LongTaskStepRow } from '../long-task.js';
1
+ import type { LongTaskIntervention, LongTaskLink, LongTaskPlanStep, LongTaskProgress, LongTaskStatus, LongTaskStepRow } from '../long-task.js';
2
2
  export declare const LONG_TASKS_ROUTE = "long-tasks";
3
- export interface ShellLongTaskRow {
3
+ interface ShellLongTaskSeenFields {
4
+ readonly seen?: boolean | undefined;
5
+ readonly progress?: LongTaskProgress | undefined;
6
+ readonly plan?: readonly LongTaskPlanStep[] | undefined;
7
+ }
8
+ export interface ShellLongTaskRow extends ShellLongTaskSeenFields {
4
9
  readonly unit: string;
5
10
  readonly id: string;
6
11
  readonly workspace: string;
@@ -27,3 +32,4 @@ export interface ShellLongTaskRow {
27
32
  export interface ShellLongTasksPayload {
28
33
  readonly runs: readonly ShellLongTaskRow[];
29
34
  }
35
+ export {};
@@ -89,6 +89,7 @@ export interface PluginRelease {
89
89
  */
90
90
  export interface UnitManifest {
91
91
  readonly id: string;
92
+ readonly skillId?: string;
92
93
  readonly title?: UnitTitle;
93
94
  readonly titleKey: string;
94
95
  readonly description?: string;
@@ -43,4 +43,4 @@ export declare function diyPresetSourcesOf(entries: Iterable<DshLoaderEntry>): r
43
43
  * @param skillsDir 工作台的 `skills/` 绝对路径。
44
44
  * @param sourceId 来源模式的 id,报错时点名用。
45
45
  */
46
- export declare function diyPresetFrom(source: unknown, skillsDir: string, sourceId?: string): DshAgentPresetDefinition;
46
+ export declare function diyPresetFrom(source: unknown, skillsDir: string, sourceId?: string, sourceName?: string): DshAgentPresetDefinition;