@xiaoso/dsh-workflow-lite 0.0.0-stage → 0.1.0

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 (156) hide show
  1. package/LICENSE +24 -0
  2. package/README.en.md +84 -0
  3. package/README.md +83 -2
  4. package/THIRD_PARTY_NOTICES.md +762 -0
  5. package/assets/icon-full.webp +0 -0
  6. package/assets/icon.webp +0 -0
  7. package/assets/wordmark.png +0 -0
  8. package/cordis.patch.yml +3 -0
  9. package/lib/client.js +127442 -0
  10. package/lib/index.mjs +9613 -0
  11. package/lib/types/client/app/addStep.d.ts +25 -0
  12. package/lib/types/client/app/desktop.d.ts +52 -0
  13. package/lib/types/client/app/host.d.ts +29 -0
  14. package/lib/types/client/app/sessions.d.ts +117 -0
  15. package/lib/types/client/app/theme.d.ts +27 -0
  16. package/lib/types/client/app/usePluginConfig.d.ts +59 -0
  17. package/lib/types/client/app/useRunFile.d.ts +24 -0
  18. package/lib/types/client/app/useRunGraph.d.ts +51 -0
  19. package/lib/types/client/app/useRunHistory.d.ts +21 -0
  20. package/lib/types/client/app/useRuns.d.ts +84 -0
  21. package/lib/types/client/app/useVersions.d.ts +50 -0
  22. package/lib/types/client/app/useWorkflow.d.ts +67 -0
  23. package/lib/types/client/app/viewport.d.ts +14 -0
  24. package/lib/types/client/i18n.d.ts +930 -0
  25. package/lib/types/client/index.d.ts +18 -0
  26. package/lib/types/client/model/connect.d.ts +44 -0
  27. package/lib/types/client/model/editor.d.ts +252 -0
  28. package/lib/types/client/model/fileKind.d.ts +15 -0
  29. package/lib/types/client/model/hostPath.d.ts +15 -0
  30. package/lib/types/client/model/htmlPreview.d.ts +24 -0
  31. package/lib/types/client/model/hubRuns.d.ts +45 -0
  32. package/lib/types/client/model/layout.d.ts +83 -0
  33. package/lib/types/client/model/library.d.ts +109 -0
  34. package/lib/types/client/model/nudge.d.ts +43 -0
  35. package/lib/types/client/model/pathSample.d.ts +26 -0
  36. package/lib/types/client/model/route.d.ts +121 -0
  37. package/lib/types/client/model/runDraft.d.ts +68 -0
  38. package/lib/types/client/model/runGraph.d.ts +15 -0
  39. package/lib/types/client/model/runHistory.d.ts +40 -0
  40. package/lib/types/client/model/themes.d.ts +87 -0
  41. package/lib/types/client/model/time.d.ts +7 -0
  42. package/lib/types/client/rpc.d.ts +42 -0
  43. package/lib/types/client/ui/AppearancePicker.d.ts +23 -0
  44. package/lib/types/client/ui/Canvas.d.ts +76 -0
  45. package/lib/types/client/ui/Confirm.d.ts +42 -0
  46. package/lib/types/client/ui/DocViewer.d.ts +67 -0
  47. package/lib/types/client/ui/Dock.d.ts +13 -0
  48. package/lib/types/client/ui/FileTag.d.ts +9 -0
  49. package/lib/types/client/ui/FileViewer.d.ts +30 -0
  50. package/lib/types/client/ui/FlowStreaks.d.ts +40 -0
  51. package/lib/types/client/ui/Handoff.d.ts +30 -0
  52. package/lib/types/client/ui/HostPicker.d.ts +31 -0
  53. package/lib/types/client/ui/HubDialog.d.ts +38 -0
  54. package/lib/types/client/ui/HubRunRow.d.ts +22 -0
  55. package/lib/types/client/ui/HubRuns.d.ts +19 -0
  56. package/lib/types/client/ui/HubSettings.d.ts +20 -0
  57. package/lib/types/client/ui/HubStorage.d.ts +18 -0
  58. package/lib/types/client/ui/HubWorkflowList.d.ts +21 -0
  59. package/lib/types/client/ui/HubWorkflowRow.d.ts +33 -0
  60. package/lib/types/client/ui/HubWorkflows.d.ts +26 -0
  61. package/lib/types/client/ui/HubWorkspacePicker.d.ts +16 -0
  62. package/lib/types/client/ui/Icon.d.ts +83 -0
  63. package/lib/types/client/ui/InputPanel.d.ts +37 -0
  64. package/lib/types/client/ui/InputsDialog.d.ts +22 -0
  65. package/lib/types/client/ui/Inspector.d.ts +51 -0
  66. package/lib/types/client/ui/Issues.d.ts +15 -0
  67. package/lib/types/client/ui/Launch.d.ts +30 -0
  68. package/lib/types/client/ui/Library.d.ts +23 -0
  69. package/lib/types/client/ui/LinkRow.d.ts +31 -0
  70. package/lib/types/client/ui/Markdown.d.ts +21 -0
  71. package/lib/types/client/ui/NodeHeads.d.ts +47 -0
  72. package/lib/types/client/ui/NoteDrawer.d.ts +21 -0
  73. package/lib/types/client/ui/OpenWith.d.ts +21 -0
  74. package/lib/types/client/ui/Outputs.d.ts +61 -0
  75. package/lib/types/client/ui/PanelHead.d.ts +21 -0
  76. package/lib/types/client/ui/PlanDialog.d.ts +18 -0
  77. package/lib/types/client/ui/PreviewCard.d.ts +38 -0
  78. package/lib/types/client/ui/QuickAdd.d.ts +30 -0
  79. package/lib/types/client/ui/ResourceItemDialog.d.ts +33 -0
  80. package/lib/types/client/ui/ResourceItems.d.ts +30 -0
  81. package/lib/types/client/ui/ResourcePanel.d.ts +26 -0
  82. package/lib/types/client/ui/Resources.d.ts +43 -0
  83. package/lib/types/client/ui/RunDraftBar.d.ts +35 -0
  84. package/lib/types/client/ui/RunEdge.d.ts +29 -0
  85. package/lib/types/client/ui/RunFiles.d.ts +24 -0
  86. package/lib/types/client/ui/RunInput.d.ts +26 -0
  87. package/lib/types/client/ui/RunItemDialog.d.ts +43 -0
  88. package/lib/types/client/ui/RunModeSwitch.d.ts +14 -0
  89. package/lib/types/client/ui/RunNav.d.ts +22 -0
  90. package/lib/types/client/ui/RunNodeState.d.ts +42 -0
  91. package/lib/types/client/ui/RunOverview.d.ts +27 -0
  92. package/lib/types/client/ui/RunPosition.d.ts +24 -0
  93. package/lib/types/client/ui/RunResource.d.ts +40 -0
  94. package/lib/types/client/ui/RunStatusMenu.d.ts +28 -0
  95. package/lib/types/client/ui/RunStep.d.ts +45 -0
  96. package/lib/types/client/ui/RunTopBar.d.ts +42 -0
  97. package/lib/types/client/ui/RunView.d.ts +43 -0
  98. package/lib/types/client/ui/SettingsDialog.d.ts +25 -0
  99. package/lib/types/client/ui/SettingsFields.d.ts +37 -0
  100. package/lib/types/client/ui/SkillPicker.d.ts +25 -0
  101. package/lib/types/client/ui/SkillPreview.d.ts +27 -0
  102. package/lib/types/client/ui/StepMark.d.ts +16 -0
  103. package/lib/types/client/ui/StepPanel.d.ts +26 -0
  104. package/lib/types/client/ui/ThemePicker.d.ts +13 -0
  105. package/lib/types/client/ui/TipLayer.d.ts +17 -0
  106. package/lib/types/client/ui/TopBar.d.ts +32 -0
  107. package/lib/types/client/ui/VersionList.d.ts +19 -0
  108. package/lib/types/client/ui/VersionRow.d.ts +19 -0
  109. package/lib/types/client/ui/VersionsDialog.d.ts +18 -0
  110. package/lib/types/client/ui/WorkflowRow.d.ts +32 -0
  111. package/lib/types/client/ui/WorkflowSwitcher.d.ts +20 -0
  112. package/lib/types/client/ui/WorkflowView.d.ts +27 -0
  113. package/lib/types/client/ui/lines.d.ts +13 -0
  114. package/lib/types/client/ui/primitives.d.ts +119 -0
  115. package/lib/types/client/ui/resourceUi.d.ts +49 -0
  116. package/lib/types/client/ui/stepIcons.d.ts +10 -0
  117. package/lib/types/host/authoringSkill.d.ts +17 -0
  118. package/lib/types/host/config.d.ts +54 -0
  119. package/lib/types/host/hostFs.d.ts +69 -0
  120. package/lib/types/host/plan.d.ts +68 -0
  121. package/lib/types/host/pluginConfig.d.ts +57 -0
  122. package/lib/types/host/rpc.d.ts +45 -0
  123. package/lib/types/host/runs/files.d.ts +37 -0
  124. package/lib/types/host/runs/notice.d.ts +21 -0
  125. package/lib/types/host/runs/service.d.ts +258 -0
  126. package/lib/types/host/runs/skill.d.ts +16 -0
  127. package/lib/types/host/runs/storage.d.ts +16 -0
  128. package/lib/types/host/runs/store.d.ts +56 -0
  129. package/lib/types/host/skillView.d.ts +22 -0
  130. package/lib/types/host/store/atomic.d.ts +34 -0
  131. package/lib/types/host/store/materialize.d.ts +19 -0
  132. package/lib/types/host/store/merge.d.ts +25 -0
  133. package/lib/types/host/store/paths.d.ts +86 -0
  134. package/lib/types/host/store/repository.d.ts +217 -0
  135. package/lib/types/host/store/versions.d.ts +38 -0
  136. package/lib/types/host/tool/tool.d.ts +432 -0
  137. package/lib/types/index.d.ts +35 -0
  138. package/lib/types/shared/appearance.d.ts +49 -0
  139. package/lib/types/shared/compile.d.ts +71 -0
  140. package/lib/types/shared/graph.d.ts +54 -0
  141. package/lib/types/shared/graphDiff.d.ts +29 -0
  142. package/lib/types/shared/inputs.d.ts +46 -0
  143. package/lib/types/shared/limits.d.ts +77 -0
  144. package/lib/types/shared/model.d.ts +122 -0
  145. package/lib/types/shared/naming.d.ts +59 -0
  146. package/lib/types/shared/outputPaths.d.ts +49 -0
  147. package/lib/types/shared/resources.d.ts +98 -0
  148. package/lib/types/shared/runCursor.d.ts +54 -0
  149. package/lib/types/shared/runState.d.ts +221 -0
  150. package/lib/types/shared/runSync.d.ts +24 -0
  151. package/lib/types/shared/types.d.ts +488 -0
  152. package/lib/types/shared/validate.d.ts +54 -0
  153. package/lib/types/shared/wire.d.ts +600 -0
  154. package/locale/en.json +6 -0
  155. package/locale/zh.json +6 -0
  156. package/package.json +144 -4
@@ -0,0 +1,20 @@
1
+ /**
2
+ * dsh-workflow-lite — 顶栏左边的工作流名字与它的下拉:切换、改名、删除、新建。
3
+ *
4
+ * 改名和删除挂在列表的每一行上(见 {@link WorkflowRow}),哪张都能直接改,不用先切过去;
5
+ * 底下只留跟「正开着的这张」有关的「从磁盘重新加载」和「新建」。
6
+ * 双击顶栏上的名字、或刚新建好时,名字就地变成输入框改正开着的这张。
7
+ *
8
+ * @module @xiaoso/dsh-workflow-lite/client/ui/WorkflowSwitcher
9
+ */
10
+ import type { Runs } from '../app/useRuns.ts';
11
+ import type { Workflow } from '../app/useWorkflow.ts';
12
+ import type { T } from '../i18n.ts';
13
+ export interface WorkflowSwitcherProps {
14
+ t: T;
15
+ wf: Workflow;
16
+ /** 本会话的工作流实例(下拉里「本会话的实例」那一段)。 */
17
+ runs: Runs;
18
+ onOpenRun(id: string): void;
19
+ }
20
+ export declare function WorkflowSwitcher(props: WorkflowSwitcherProps): React.JSX.Element;
@@ -0,0 +1,27 @@
1
+ /**
2
+ * dsh-workflow-lite — 工作流视图(会话页的一个 tab):把发动机、画布与各块面板接起来。
3
+ *
4
+ * 版式:画布铺满,顶栏、步骤库、属性面板、缩放条浮在上面。属性面板只在选中东西时出现。
5
+ * 键盘:快捷键挂在视图根上——视图内任何地方拿到焦点都能冒上来,又出不了这个视图
6
+ * (挂 window 会隔着整页抢宿主的按键)。输入框里一律让开。
7
+ *
8
+ * @module @xiaoso/dsh-workflow-lite/client/ui/WorkflowView
9
+ */
10
+ import type { PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots';
11
+ import type { Desktop } from '../app/desktop.ts';
12
+ import { type SessionBridge } from '../app/sessions.ts';
13
+ import type { NS } from '../i18n.ts';
14
+ import { type WorkflowLiteRpc } from '../rpc.ts';
15
+ /** 客户端入口注入的业务面。 */
16
+ export interface WorkflowViewInjected {
17
+ rpc: WorkflowLiteRpc;
18
+ /** 这个 tab 所在的会话。 */
19
+ sessionId?: string;
20
+ /** 会话列表与发消息(「执行」用);宿主缺相应服务时不给。 */
21
+ sessions?: SessionBridge;
22
+ /** 用系统程序打开文件;宿主没有桌面能力时不给。 */
23
+ desktop?: Desktop;
24
+ }
25
+ /** 槽位给这个组件的完整 props。 */
26
+ export type WorkflowViewProps = PropsRuntime<'conversation.view'> & PropsLocale<typeof NS> & WorkflowViewInjected;
27
+ export declare function WorkflowView(props: WorkflowViewProps): React.JSX.Element;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * 八种线的颜色:画布上的线、箭头、光带、线上的牌子,面板里的标签和图例都从这里取,
3
+ * 永远是同一个色。色值在 shell.module.css 的 `--wl-flow-*` / `--wl-io-*`。
4
+ * 输入 → 步骤(交回答)用一档中性的墨色:色环上七个色都占满了,再加一个彩色总会和某一个撞;
5
+ * 它另有第二重记号——点线、输入卡。
6
+ */
7
+ /** 步骤之间的线按条件分四种:总是 / 通过 / 未通过 / 自定义条件。 */
8
+ export type WhenKind = 'always' | 'pass' | 'fail' | 'custom';
9
+ /** 连着文件或输入的线:整份写出 / 在原文件上更新 / 读取 / 交回答(输入 → 步骤)。 */
10
+ export type Access = 'produce' | 'update' | 'read' | 'ask';
11
+ export declare function whenKind(when: string | undefined): WhenKind;
12
+ export declare const WHEN_COLOR: Record<WhenKind, string>;
13
+ export declare const ACCESS_COLOR: Record<Access, string>;
@@ -0,0 +1,119 @@
1
+ /**
2
+ * dsh-workflow-lite — 小件:类名拼接、点外面关闭、分段选择、浮层。
3
+ *
4
+ * @module @xiaoso/dsh-workflow-lite/client/ui/primitives
5
+ */
6
+ import { type RefObject } from 'react';
7
+ /** 拼类名,跳过假值。 */
8
+ export declare function cx(...names: (string | false | null | undefined)[]): string;
9
+ /**
10
+ * 在 `ref` 之外按下指针就关掉。
11
+ *
12
+ * 监听挂在 `document` 的**捕获**阶段:React Flow 会在自己的按下处理里拦截冒泡,
13
+ * 冒泡阶段的监听收不到"点在画布上"这一下。
14
+ */
15
+ export declare function useDismiss(open: boolean, ref: RefObject<HTMLElement | null>, onClose: () => void): void;
16
+ /**
17
+ * 触发器 + 浮层。浮层不走 portal:留在视图根的子树里,设计令牌照常继承。
18
+ * `Esc` 在这里消化掉(不再冒到视图根去取消画布上的选中)。
19
+ *
20
+ * `hold`:浮层里正有一件事没做完(行内改名、挂在某一行上的确认卡)——点外面先只结束那件事,
21
+ * 浮层留着,再点一下才收。浮层本身可聚焦(不进 Tab 序):里面的按钮跟着一行被删掉时焦点有处可去,
22
+ * Esc 照样能收起。
23
+ */
24
+ export declare function Popover(props: {
25
+ open: boolean;
26
+ onClose: () => void;
27
+ trigger: React.ReactNode;
28
+ children: React.ReactNode;
29
+ align?: 'start' | 'end';
30
+ up?: boolean;
31
+ className?: string;
32
+ label: string;
33
+ hold?: boolean;
34
+ }): React.JSX.Element;
35
+ /** 分段选择(单选)。选中格下面那块滑块靠 `transform` 滑过去。 */
36
+ export declare function Segmented<V extends string>(props: {
37
+ label: string;
38
+ value: V;
39
+ /** `color`:选项前的小色点(比如条件的四种线色),和画布上对应的东西同色。 */
40
+ options: readonly {
41
+ value: V;
42
+ label: string;
43
+ color?: string;
44
+ }[];
45
+ onChange: (value: V) => void;
46
+ disabled?: boolean;
47
+ /** 每格的 `data-testid` 是 `${testId}-${value}`。 */
48
+ testId?: string;
49
+ }): React.JSX.Element;
50
+ export declare const ModalHostProvider: import("react").Provider<HTMLElement | null>;
51
+ /**
52
+ * 模态框:遮罩 + 居中的一张卡。
53
+ *
54
+ * - 键盘事件一律在这里截住:React 的合成事件会顺着组件树(而不是 DOM 树)冒泡,不截的话
55
+ * 在模态框里按 Delete / Esc 会冒到视图根,删掉画布上选中的步骤。
56
+ * - Esc 与点遮罩都走 `onDismiss`;调用方据此决定"有没写完的改动时不关"。
57
+ * - 只有按下与松开都落在遮罩上才算点遮罩:在输入框里拖选文字、松手落在外面,不该把框关掉。
58
+ * - Tab 在框内循环;关掉后焦点还给打开它的那个按钮。
59
+ */
60
+ export declare function Modal(props: {
61
+ label: string;
62
+ onDismiss(): void;
63
+ children: React.ReactNode;
64
+ className?: string;
65
+ testId?: string;
66
+ }): React.JSX.Element;
67
+ export type FloatState = 'off' | 'hover' | 'pinned';
68
+ /**
69
+ * 悬停浮层的状态与摆位(「?」说明、画布连线上的交接卡片共用)。
70
+ *
71
+ * - 浮层挂到视图根(和模态框同一个挂载点):不被滚动区裁掉,也不会把滚动区撑出滚动条;
72
+ * 画布缩放时字号也不跟着变小。
73
+ * - 鼠标可以从触发器移进浮层:离开触发器后稍等一下再收,进了浮层就不收;浮层接住指针,
74
+ * 里面的文字能选中复制,点击不会穿透到后面。
75
+ * - 在触发器与浮层之外按下指针、滚动、滚轮缩放画布都收起;Esc 只收浮层。
76
+ * - 先按"触发器正下方、左边对齐"放(`align: 'end'` 右边对齐;`'auto'` 触发器在视图右半边就右对齐),
77
+ * 量出高度后下面放不下就翻到上方,左右夹在视图里。
78
+ */
79
+ export declare function useFloat<A extends HTMLElement>(options: {
80
+ openMs: number;
81
+ closeMs: number;
82
+ width: number;
83
+ align?: 'start' | 'end' | 'auto';
84
+ /** 与触发器的间距,缺省 6。 */
85
+ gap?: number;
86
+ }): {
87
+ state: FloatState;
88
+ setState: (next: FloatState | ((current: FloatState) => FloatState)) => void;
89
+ anchorRef: RefObject<A>;
90
+ panelRef: RefObject<HTMLDivElement>;
91
+ /** 取消还没生效的悬停开 / 关。 */
92
+ cancel: () => void;
93
+ /** 悬停触发:挂到触发器上。 */
94
+ hoverProps: {
95
+ onPointerEnter: () => void;
96
+ onPointerLeave: () => void;
97
+ };
98
+ onKeyDown: (event: React.KeyboardEvent) => void;
99
+ /** 把浮层内容包一层定位壳,挂到视图根。 */
100
+ render: (props: {
101
+ className: string;
102
+ testId?: string | undefined;
103
+ label?: string;
104
+ /** 默认 `tooltip`;二次确认这类要操作的浮层用 `alertdialog`。 */
105
+ role?: 'tooltip' | 'alertdialog';
106
+ children: React.ReactNode;
107
+ }) => React.ReactNode;
108
+ };
109
+ /**
110
+ * 「?」说明:平时只占一个小图标,悬停 / 聚焦 / 点击时浮出一段说明(浮层行为见 {@link useFloat})。
111
+ * 点「?」钉住(触屏也能用),点别处或按 Esc 收起。
112
+ */
113
+ export declare function HelpTip(props: {
114
+ label: string;
115
+ children: React.ReactNode;
116
+ testId?: string;
117
+ }): React.JSX.Element;
118
+ /** 把一段文字写进剪贴板;环境不允许就安静地失败。 */
119
+ export declare function copyText(text: string): Promise<boolean>;
@@ -0,0 +1,49 @@
1
+ /**
2
+ * dsh-workflow-lite — 资源在界面上的样子:每种内容的图标与名字、一项内容的简短写法、起名与查重。
3
+ *
4
+ * 画布的资源卡、属性面板、实例视图都从这里取,同一种内容到哪儿都是同一个图标、同一种写法。
5
+ *
6
+ * @module @xiaoso/dsh-workflow-lite/client/ui/resourceUi
7
+ */
8
+ import type { ResourceItem, ResourceKind, WorkflowDocument, WorkflowNode } from '../../shared/types.ts';
9
+ import type { HostSkillEntry } from '../../shared/wire.ts';
10
+ import type { LocaleKey } from '../i18n.ts';
11
+ import type { IconName } from './Icon.tsx';
12
+ /** 呈现顺序 = 「添加」菜单里的顺序。 */
13
+ export declare const KIND_ORDER: readonly ResourceKind[];
14
+ export declare const KIND_ICON: Record<ResourceKind, IconName>;
15
+ export declare const KIND_LABEL: Record<ResourceKind, LocaleKey>;
16
+ /**
17
+ * 卡片上一项的写法:文件与文件夹取最后一段,网址去掉协议,自定义取第一行
18
+ * (自定义文字常是 Markdown:去掉行首的标题 `#`、列表 `-`、引用 `>` 记号)。
19
+ */
20
+ export declare function itemText(item: ResourceItem): string;
21
+ /** 面板清单里一项的名字:网址只取主机名(整条网址放在下面一行),其余同 {@link itemText}。 */
22
+ export declare function itemName(item: ResourceItem): string;
23
+ /**
24
+ * 面板清单里一项的位置(名字下面那一行):文件与文件夹是路径(相对路径有步骤写它时换成产出根目录下的
25
+ * 实际位置),网址是整条网址;Skill 与自定义没有位置(空串,界面上写种类)。
26
+ */
27
+ export declare function itemLocation(item: ResourceItem, root: string | undefined, written: boolean): {
28
+ text: string;
29
+ mono: boolean;
30
+ };
31
+ /** 往资源里加几项:空值照加(等着填),和已有的重复的跳过,满了就停。 */
32
+ export declare function addItems(items: readonly ResourceItem[], fresh: readonly ResourceItem[], max: number): ResourceItem[];
33
+ /** 筛选 skill:名字或说明里有这几个字(不分大小写)。 */
34
+ export declare function filterSkills(skills: readonly HostSkillEntry[], filter: string): readonly HostSkillEntry[];
35
+ /** skill 从哪来,给人看的两种说法(清单里的小签、预览里的全称);不认识的来源原样给。 */
36
+ export declare function skillSource(source: string, t: (key: LocaleKey) => string): {
37
+ short: string;
38
+ full: string;
39
+ };
40
+ /** 节点的显示名:步骤取名称,资源取名字(没有就第一项),输入取问题。 */
41
+ export declare function stepName(node: WorkflowNode | undefined, fallback: string): string;
42
+ /** 路径的最后一段(卡片标题里放不下整条路径)。 */
43
+ export declare function baseName(path: string): string;
44
+ /** 图里没被资源占用的文件路径:`x.md` 被占了就 `x-2.md`、`x-3.md`… */
45
+ export declare function freeFilePath(doc: WorkflowDocument, want: string): string;
46
+ /** 同一个资源里两项是不是重复(种类相同、值规范化后相同)。 */
47
+ export declare function sameItem(a: ResourceItem, b: ResourceItem): boolean;
48
+ /** 是不是同一个节点。 */
49
+ export declare function sameId(a: string, b: string): boolean;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * dsh-workflow-lite — 步骤卡的图标库:每个图标的笔画(24 栅格、描边,和 `Icon.tsx` 同一套画法)。
3
+ *
4
+ * 名字清单在 `shared/appearance.ts`(host 也要用它校验、给新步骤挑样子);这里用
5
+ * `Record<StepIcon, string>` 对齐,清单里加了名字却忘了画,类型检查就过不去。
6
+ *
7
+ * @module @xiaoso/dsh-workflow-lite/client/ui/stepIcons
8
+ */
9
+ import type { StepIcon } from '../../shared/appearance.ts';
10
+ export declare const STEP_ICON_PATHS: Record<StepIcon, string>;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * dsh-workflow-lite — 按需 skill `workflow-authoring`:怎么设计一张工作流图。
3
+ *
4
+ * 工具描述只列能力(有哪些 action、参数是什么);步骤怎么拆、产物怎么传、资源说明怎么写、
5
+ * 建完怎么自检,都放在这里,模型要建图、改图时才读(目录里只常驻一句摘要)。
6
+ * 内容来自真实使用里反复出现的问题:步骤拆得太碎、中间产物没接给下游、提示词说要改的文件图里没连、
7
+ * 循环跑几轮后台账和状态文档越写越长、每轮写法都不一样、自检时反复编译留下一堆实例。
8
+ *
9
+ * @module @xiaoso/dsh-workflow-lite/host/authoringSkill
10
+ */
11
+ import type { Context } from '@deepseek-ai/cordis';
12
+ export declare const AUTHORING_SKILL = "workflow-authoring";
13
+ /**
14
+ * 注册 skill;`skills` 服务不在时由调用方跳过。
15
+ * @returns 注销器。
16
+ */
17
+ export declare function registerAuthoringSkill(ctx: Context): () => void;
@@ -0,0 +1,54 @@
1
+ /**
2
+ * dsh-workflow-lite — 配置面。
3
+ *
4
+ * 六个键,默认值全部写在 schema 里(**不硬编码在代码里**)。字段类型是
5
+ * `Volatile`:设置表单投影的正是这些字段,写入落进当前 profile 的 Cordis patch,
6
+ * 运行中的插件读的是**活引用**——一次配置写入就地更新它,不重挂插件。
7
+ *
8
+ * 部署相关的取值一律走这里:`dataDir`(数据根)、`maxNodes`、`maxResultBytes`
9
+ * (单次返回字节上限)、`saveDebounceMs`、`routePrefix`、`installSkill`。
10
+ *
11
+ * @module @xiaoso/dsh-workflow-lite/host/config
12
+ */
13
+ import type { Volatile } from '@deepseek-ai/cordis';
14
+ import z from '@deepseek-ai/schemastery';
15
+ /** 设置命名空间——同一个 kebab-case 串也是 locale 的 NS。 */
16
+ export declare const WORKFLOW_LITE_SETTINGS_NS = "workflow-lite";
17
+ /** 插件在 profile 里的那一行的 id(`cordis.patch.yml` 的 `insert.id`)。 */
18
+ export declare const WORKFLOW_LITE_ROW_ID = "workflow-lite";
19
+ /** 解析后的活配置。 */
20
+ export interface WorkflowLiteSettings {
21
+ /** 数据根目录。`workflows/`、`templates/` 与 `.dispatch/` 都在它下面。 */
22
+ dataDir: Volatile<string>;
23
+ /** 画布改动落盘的防抖毫秒数。**拖动过程中不写盘,指针停稳后才写一次。** */
24
+ saveDebounceMs: Volatile<number>;
25
+ /** 单图节点数上限。超出:落盘允许、自动布局不跑、**编译挡住**。 */
26
+ maxNodes: Volatile<number>;
27
+ /** 单次工具 / RPC 返回的字节上限。超限**报错而不截断**。 */
28
+ maxResultBytes: Volatile<number>;
29
+ /** 画布 ↔ host 的同源路由前缀。插件不自开端口。 */
30
+ routePrefix: Volatile<string>;
31
+ /** 是否随插件注册按需 skill `workflow-authoring`(设计图)与 `workflow-run-state`(运行状态)。 */
32
+ installSkill: Volatile<boolean>;
33
+ }
34
+ /**
35
+ * 运行期 schema。字段一律 `volatile()`(只有这类字段设置表单才能编辑),
36
+ * 并且都带**约束**——配错了要响亮失败,不要静默取一个坏值。
37
+ */
38
+ export declare const Config: z<Schemastery.ObjectS<NoInfer<{
39
+ dataDir: z<string, string, "volatile-defined">;
40
+ saveDebounceMs: z<number, number, "volatile-defined">;
41
+ maxNodes: z<number, number, "volatile-defined">;
42
+ maxResultBytes: z<number, number, "volatile-defined">;
43
+ routePrefix: z<string, string, "volatile-defined">;
44
+ installSkill: z<boolean, boolean, "volatile-defined">;
45
+ }>>, Schemastery.ObjectT<NoInfer<{
46
+ dataDir: z<string, string, "volatile-defined">;
47
+ saveDebounceMs: z<number, number, "volatile-defined">;
48
+ maxNodes: z<number, number, "volatile-defined">;
49
+ maxResultBytes: z<number, number, "volatile-defined">;
50
+ routePrefix: z<string, string, "volatile-defined">;
51
+ installSkill: z<boolean, boolean, "volatile-defined">;
52
+ }>>, "plain">;
53
+ /** 六个键的名字(测试与文档用,避免两处各写一遍)。 */
54
+ export declare const CONFIG_KEYS: readonly ["dataDir", "saveDebounceMs", "maxNodes", "maxResultBytes", "routePrefix", "installSkill"];
@@ -0,0 +1,69 @@
1
+ /**
2
+ * dsh-workflow-lite — 主机上的东西:资源节点「选文件 / 选文件夹 / 选 Skill」时列给画布看。
3
+ *
4
+ * - {@link listHostDir}:列一个目录里有什么(只给名字和是不是目录,**不读内容**),外加几个可以跳去的根;
5
+ * - {@link listSkills}:会话里的 agent 能用的 skill(只列模型能用的);{@link readSkill}:读一个的全文。
6
+ *
7
+ * 只读。画布那头是本机用户自己在选路径,选中的路径原样进图,执行时由模型自己去读。
8
+ *
9
+ * @module @xiaoso/dsh-workflow-lite/host/hostFs
10
+ */
11
+ import type { HostListResponse, HostSkillResponse, HostSkillsResponse } from '../shared/wire.ts';
12
+ import type { Outcome } from './store/repository.ts';
13
+ /**
14
+ * 列一个目录。`path` 缺省 = `cwd`(会话的工作区),再缺省 = 用户主目录;相对路径按 `cwd` 解析。
15
+ */
16
+ export declare function listHostDir(request: {
17
+ path?: string;
18
+ cwd?: string;
19
+ }): Promise<Outcome<HostListResponse>>;
20
+ /** 一条 skill 的摘要(`ctx.skills.list()` 给的那几样)。 */
21
+ interface SkillSummaryLike {
22
+ name: string;
23
+ description: string;
24
+ source: string;
25
+ /** SKILL.md 的绝对路径;插件运行时注册的 skill 没有。 */
26
+ path?: string;
27
+ whenToUse?: string;
28
+ invocation: {
29
+ modelInvocable: boolean;
30
+ };
31
+ }
32
+ /** 读 skill 时的作用域与工作区(`scope` 是 DSH 的不透明作用域键)。 */
33
+ interface SkillLookup {
34
+ cwd?: string;
35
+ scope?: object;
36
+ }
37
+ /** `ctx.skills` 用到的那一点(只借形状,不 import 运行时)。 */
38
+ export interface SkillLister {
39
+ list(options: SkillLookup): Promise<readonly SkillSummaryLike[]>;
40
+ get(name: string, options: SkillLookup): Promise<(SkillSummaryLike & {
41
+ content: string;
42
+ }) | undefined>;
43
+ }
44
+ /**
45
+ * 以谁的眼光看 skill:DSH 的本地 skill(项目的 `.dsh/skills`、`~/.agents/skills`…)是挂在
46
+ * **agent 预设**底下的,只有带上那个预设的作用域才读得到;不带作用域只剩全局那一层(内置的、
47
+ * 插件注册的)。读完调 `release` 还回作用域。
48
+ */
49
+ export interface SkillView {
50
+ skills: SkillLister;
51
+ scope?: object;
52
+ release?: () => Promise<void>;
53
+ }
54
+ /** 给一个会话(可以不给)找出看 skill 的视角;没装 skill 服务回 `undefined`。 */
55
+ export type SkillViewer = (session: string | undefined) => Promise<SkillView | undefined>;
56
+ /**
57
+ * 会话里的 agent 能用的 skill(只列模型能用的,执行时是模型去加载它们);没装 skill 服务就是空的。
58
+ */
59
+ export declare function listSkills(viewer: SkillViewer | undefined, request: {
60
+ cwd?: string;
61
+ session?: string;
62
+ }): Promise<HostSkillsResponse>;
63
+ /** 读一个 skill 的全文(SKILL.md 去掉头部元数据后的正文),给画布预览。 */
64
+ export declare function readSkill(viewer: SkillViewer | undefined, request: {
65
+ name: string;
66
+ cwd?: string;
67
+ session?: string;
68
+ }): Promise<Outcome<HostSkillResponse>>;
69
+ export {};
@@ -0,0 +1,68 @@
1
+ /**
2
+ * dsh-workflow-lite — 编译编排。
3
+ *
4
+ * 纯函数编译器(`shared/compile.ts`)不认识磁盘;这一层负责**把它需要的东西凑齐**:
5
+ * 图(从仓储读,或实例的快照)、任务描述的路径、以及该图的校验结论(进 ⑥ 段)。
6
+ *
7
+ * 计划永远对着一个**工作流实例**出:
8
+ * - 给了实例(`options.instance`):任务描述写进实例目录的 `tasks/`,产出根目录里的 `{instance}`
9
+ * 换成实例 id,开了「记录运行状态」就带上「运行状态」段——这就是模型拿到的那份;
10
+ * - 没给(画布预览、整卷版):同一份计划,只是实例 id 还没有,路径与段落里留着 `{instance}`,
11
+ * 不写任何文件。预览与执行时拿到的内容逐段对得上。
12
+ *
13
+ * 失败姿态:有编译级问题时 `plan` 为空串、`problems` 必填,
14
+ * **绝不返回一份残缺计划**;写任务描述失败 ⇒ `io_error`(图本身没坏,不该是 `invalid_args`)。
15
+ *
16
+ * @module @xiaoso/dsh-workflow-lite/host/plan
17
+ */
18
+ import type { InputAnswer, PlanId, ToolWarning, ValidationProblem, WorkflowDocument } from '../shared/types.ts';
19
+ import { type Outcome, type Repository } from './store/repository.ts';
20
+ /** 计划对着的实例。 */
21
+ export interface PlanInstance {
22
+ id: string;
23
+ /** 实例目录(任务描述 `tasks/`、状态 `state.yaml`、默认产出 `out/` 都在这里)。 */
24
+ dir: string;
25
+ /** 记运行状态:计划末尾带「运行状态」段。 */
26
+ tracked: boolean;
27
+ }
28
+ /** 编译入参。 */
29
+ export interface CompileOptions {
30
+ /** `true` = 整卷版(内联正文,给人读);缺省 = 派发版。 */
31
+ full?: boolean;
32
+ goal?: string;
33
+ /** 实例:给了就按它出计划、把任务描述写进实例目录;不给是预览(留 `{instance}`,不写文件)。 */
34
+ instance?: PlanInstance;
35
+ /**
36
+ * 用户对输入节点的回答。不给 = 预览(回答处写「执行时填写」);给了 = 真的要执行
37
+ * (没回答的用默认值,必填的还空着就是编译级)。
38
+ */
39
+ answers?: Readonly<Record<string, InputAnswer>>;
40
+ }
41
+ export interface CompileBundle {
42
+ /** 内容哈希前 8 位(实例的快照把实例 id 定进了产出根目录,所以每个实例各不相同)。 */
43
+ planId: PlanId;
44
+ /** 派发计划(或整卷版)文本;有编译级问题时为空串。 */
45
+ plan: string;
46
+ /** **只装编译级问题**(阻塞编译的那几条)。 */
47
+ problems: ValidationProblem[];
48
+ /** 警告与提示(非阻塞),含该图读入阶段报出的那些。 */
49
+ warnings: ToolWarning[];
50
+ /** 任务描述路径(步骤 id → 绝对路径);预览时路径里是 `{instance}`。 */
51
+ payloadPaths: Record<string, string>;
52
+ }
53
+ /**
54
+ * 编译一张图(仓储里的模板)。
55
+ *
56
+ * - 保存级问题 ⇒ `blocked`(图都加载不了,谈不上编译);图不存在 ⇒ `not_found`。
57
+ * - 编译级问题 ⇒ 成功返回但 `plan` 为空串、`problems` 非空,**且不写文件**。
58
+ */
59
+ export declare function compileWorkflow(repository: Repository, dataDir: string, name: string, options?: CompileOptions,
60
+ /** 执行者的工作区根;由调用方从会话取(工具从 `exec` 取,RPC 从前端给)。 */
61
+ cwd?: string): Promise<Outcome<CompileBundle>>;
62
+ /**
63
+ * 编译一份已经读进来的图(工作流实例的快照走这里:它不在 `workflows/` 里)。
64
+ * @param problems - 该图的校验结论(进 ⑥ 段与 `warnings`)。
65
+ */
66
+ export declare function compileDocument(dataDir: string, name: string, document: WorkflowDocument, problems: readonly ValidationProblem[], options?: CompileOptions, cwd?: string): Promise<Outcome<CompileBundle>>;
67
+ /** 该图的警告与提示(画布校验面板用)。 */
68
+ export declare function nonBlockingProblems(problems: readonly ValidationProblem[]): ValidationProblem[];
@@ -0,0 +1,57 @@
1
+ /**
2
+ * dsh-workflow-lite — 工作流中心「设置」页的后端:经 DSH 的设置服务(`ctx.settings`)读写本插件自己那一行配置。
3
+ *
4
+ * - 只露 {@link PLUGIN_CONFIG_KEYS} 那几项;`routePrefix` 这类接线细节不给人改。
5
+ * - 写入走设置服务的路径编辑(`mutate`):它按完整 Config 校验、落进当前 profile 的 patch、
6
+ * 就地更新运行中的活配置;带修订号,别人先改过就拒绝,不悄悄覆盖。
7
+ * - 设置服务不在(精简的 profile)时只读:页面照样显示现值,告诉人这里改不了。
8
+ *
9
+ * 本插件在 profile 里那一行的 id 通常就是 `workflow-lite`(`cordis.patch.yml` 里写的);
10
+ * 有人手动换了 id 时,退回去找「字段正好是这几项」的那一行。
11
+ *
12
+ * @module @xiaoso/dsh-workflow-lite/host/pluginConfig
13
+ */
14
+ import { type PluginConfigValues, type PluginConfigView } from '../shared/wire.ts';
15
+ /** 用到的那一小截设置服务(`@deepseek-ai/dsh-settings` 的 `SettingsForms`)。 */
16
+ export interface SettingsPort {
17
+ readonly writable: boolean;
18
+ describe(options?: {
19
+ redactSecrets?: boolean;
20
+ }): readonly SettingsRow[];
21
+ mutate(ns: string, ops: readonly ({
22
+ op: 'set';
23
+ path: readonly string[];
24
+ value: unknown;
25
+ } | {
26
+ op: 'unset';
27
+ path: readonly string[];
28
+ })[], expectedRevision?: number): Promise<void>;
29
+ }
30
+ export interface SettingsRow {
31
+ ns: string;
32
+ revision: number;
33
+ value: unknown;
34
+ base?: unknown;
35
+ user?: unknown;
36
+ }
37
+ type Outcome<T> = {
38
+ ok: true;
39
+ result: T;
40
+ } | {
41
+ ok: false;
42
+ error: {
43
+ code: string;
44
+ message: string;
45
+ };
46
+ };
47
+ /** 设置服务不在时页面要的现值(从活配置读)。 */
48
+ export type LiveValues = () => PluginConfigValues;
49
+ export declare function readPluginConfig(port: SettingsPort | undefined, live: LiveValues): PluginConfigView;
50
+ export declare function writePluginConfig(port: SettingsPort | undefined, live: LiveValues,
51
+ /** 线上来的原样(键名、值都还没核对过)。 */
52
+ write: {
53
+ revision: number;
54
+ set?: Record<string, unknown>;
55
+ reset?: readonly string[];
56
+ }): Promise<Outcome<PluginConfigView>>;
57
+ export {};
@@ -0,0 +1,45 @@
1
+ /**
2
+ * dsh-workflow-lite — 画布的后端路由。
3
+ *
4
+ * 一个 endpoint 一条精确 Fetch 路由,挂在共享 Connection 的 `/api` 通道上
5
+ * (与生态里其它插件同一条路)。载波负责 Host/Origin + 浏览器会话策略,
6
+ * 我们只解码标准 `client-request` 信封、分派、再按标准 `server-response` 回。
7
+ *
8
+ * 注册走 `ctx.inject(['connection'])` 的子上下文——这样**插件在没有 web 的 profile 里
9
+ * 也能只带工具起来**(RPC 是画布专用,缺它不该让整个插件停摆)。
10
+ *
11
+ * 入参一律**从原始记录里逐字段读**(不做类型断言);图文档走 `normalizeDocument`
12
+ * 做形状归一,坏形状在这里就被挡成 `invalid_args`,不会渗进仓储。
13
+ *
14
+ * @module @xiaoso/dsh-workflow-lite/host/rpc
15
+ */
16
+ import type { Context } from '@deepseek-ai/cordis';
17
+ import { type SkillViewer } from './hostFs.ts';
18
+ import { type LiveValues, type SettingsPort } from './pluginConfig.ts';
19
+ import type { RunService } from './runs/service.ts';
20
+ import { type Repository } from './store/repository.ts';
21
+ /** 路由需要的活依赖。 */
22
+ export interface RpcDeps {
23
+ repository: Repository;
24
+ dataDir: () => string;
25
+ /** 画布要用的两个活配置值(`graph/list` 一并回给它,见 `GraphListResponse`)。 */
26
+ limits: () => {
27
+ maxNodes: number;
28
+ saveDebounceMs: number;
29
+ };
30
+ /** 工作流实例(`run/*`)。 */
31
+ runs: RunService;
32
+ /** 看 DSH 的 skill(选 Skill、预览 SKILL.md 用);没给就当没装 skill 服务。 */
33
+ skills?: SkillViewer;
34
+ /** 「设置」页:DSH 的设置服务(不在时回 `undefined`,页面只读)与活配置的现值。 */
35
+ config: {
36
+ port: () => SettingsPort | undefined;
37
+ live: LiveValues;
38
+ };
39
+ }
40
+ /**
41
+ * 注册全部画布路由。
42
+ * @param ctx - **已绑定 `connection`** 的子上下文。
43
+ * @param deps - 仓储与数据根。
44
+ */
45
+ export declare function registerWorkflowLiteRpc(ctx: Context, deps: RpcDeps): void;
@@ -0,0 +1,37 @@
1
+ /**
2
+ * dsh-workflow-lite — 实例里的文件:给画布看一眼(资源面板与查看框)。
3
+ *
4
+ * 只读、只认这个实例名下的文件:要么是快照里某个资源的文件项,要么是落在实例工作区里的相对路径
5
+ * (模型在状态文件 `outputs` 里写的那些)。随手传进来的工作区外路径一律拒绝——这条路由不是通用的读文件口子。
6
+ *
7
+ * 读多少:小文本整份回去(`RUN_FILE_TEXT_MAX`),大了只回元信息让前端说"太大了";
8
+ * 前 8 KB 里有 NUL 字节就当二进制。
9
+ *
10
+ * @module @xiaoso/dsh-workflow-lite/host/runs/files
11
+ */
12
+ import type { InstanceRecord } from '../../shared/runState.ts';
13
+ import type { WorkflowDocument } from '../../shared/types.ts';
14
+ import { type RunFileResponse } from '../../shared/wire.ts';
15
+ import type { Outcome } from '../store/repository.ts';
16
+ /** 要看哪份:快照里某个资源的第几项,或实例工作区里的相对路径。 */
17
+ export type RunFileTarget = {
18
+ node: string;
19
+ item: number;
20
+ } | {
21
+ path: string;
22
+ };
23
+ /**
24
+ * 快照里一个资源的第几项实际在哪(还没拼工作区);不是文件 / 文件夹就是 `null`。
25
+ * 相对路径:有步骤写这个资源时在产出根目录下,只被读时相对工作区。
26
+ */
27
+ export declare function itemLocation(document: WorkflowDocument, node: string, item: number): string | null;
28
+ /**
29
+ * 把目标解析成绝对路径与给人看的相对路径;越界或找不到就是错误。
30
+ * @param underRoot - 相对路径按产出根目录解析(模型报告产出时可能是相对根目录写的)。
31
+ */
32
+ export declare function resolveRunFile(record: InstanceRecord, document: WorkflowDocument, target: RunFileTarget, underRoot?: boolean): Outcome<{
33
+ full: string;
34
+ display: string;
35
+ }>;
36
+ /** 读一份文件给画布:小文本带正文,其余(含文件夹)只有元信息。 */
37
+ export declare function readRunFile(full: string, display: string): Promise<RunFileResponse>;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * dsh-workflow-lite — 把"用户修改了运行状态"送进会话。
3
+ *
4
+ * 和 `dsh-task-runner` 的后台任务完成通知同一套机制:一条 `form: 'notice'` 的用户角色消息,
5
+ * 对话里显示成一行摘要,展开就是完整的注入内容(用户看得到模型收到了什么)。
6
+ * 用 `steer` 投递:会话空闲就开一轮,正在跑就在下一步接上。
7
+ *
8
+ * @module @xiaoso/dsh-workflow-lite/host/runs/notice
9
+ */
10
+ import type { Context } from '@deepseek-ai/cordis';
11
+ import { type ContextFormed } from '@deepseek-ai/dsh-llm';
12
+ import type { Notify } from './service.ts';
13
+ declare module '@deepseek-ai/dsh-llm' {
14
+ interface MessageSourceMap {
15
+ 'workflow-lite': {
16
+ kind: 'workflow-lite';
17
+ } & ContextFormed;
18
+ }
19
+ }
20
+ /** 造一个投递函数:会话的 agent 不在运行时回 `false`(调用方把通知暂存起来)。 */
21
+ export declare function createNotify(ctx: Context): Notify;