@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,217 @@
1
+ /**
2
+ * dsh-workflow-lite — 文件仓储:唯一的副作用边界。
3
+ *
4
+ * 这一层兑现四条硬规矩:
5
+ * 1. **单文件原子写**——一切写入都经 `atomic.writeFileAtomic`;
6
+ * 2. **进程内锁的粒度 = 一次工具调用全程**(含预检与全部文件写)——`withLock` 把写路径串行化,
7
+ * 所以 `delete_node` 的"删节点 + 连带删边"不可能被另一个写插进来;
8
+ * 3. **写前哈希比对 + 字段级合并**——不一致不算冲突:按 `node.id` / `edge.id` 合并,
9
+ * 只有「同一个 node 的 `data` 双方都改过」或「同一个 `id` 一方删、一方改」才回 `conflict`;
10
+ * 合并期间基线又变则重试(有上限,见 {@link MAX_MERGE_ATTEMPTS});
11
+ * 4. **绝不隐式创建**——除 `write_node` 的 upsert 以外,写 action 指向不存在的图一律 `not_found`。
12
+ *
13
+ * 失败**不抛**(除真 IO 故障的 errno 翻译外):返回 `{ ok: false, error: ToolError['error'] }`,
14
+ * `code ∈ { not_found, invalid_args, blocked, conflict, io_error }`。
15
+ *
16
+ * 校验分工:本模块只把「读出的文本 → 文档」交给**注入的** `validate`(`shared/validate.ts`
17
+ * 落地后由 host 装配),外加两条只有存储层才知道的判据——`workflow_dir_collision`
18
+ * (`.json` 与同名目录并存)与"合并后的终稿先自检再落盘"(用 `readDocument` 复核 canonical 文本)。
19
+ * @module @xiaoso/dsh-workflow-lite/host/store/repository
20
+ */
21
+ import { type ChangedEntry, type ExecutionMode, type Handoff, type InputData, type ListResult, type NodeData, type OutputSpec, type Point, type ResourceItem, type ReusePolicy, type ToolError, type ToolWarning, type ValidationProblem, type VersionEntry, type WorkflowDocument, type WriteResult } from '../../shared/types.ts';
22
+ import { type ValidationReport } from '../../shared/validate.ts';
23
+ /** 合并-重试的上限:合并期间磁盘还在变就再读一次,超过这个次数即认输报 `conflict`。 */
24
+ export declare const MAX_MERGE_ATTEMPTS = 5;
25
+ /** 撞名自动加序号的上限(`-2` … `-99`)。 */
26
+ export declare const MAX_SEQUENTIAL = 99;
27
+ export interface LoadResult {
28
+ /** 名字归一后的图名(`not_found` 时也给出,便于上层报错)。 */
29
+ name: string;
30
+ /** 可加载时的规范化文档;**保存级问题 ⇒ `null`**。 */
31
+ document: WorkflowDocument | null;
32
+ /** 磁盘上的原文(供只读错误态展示);不存在时 `null`。 */
33
+ text: string | null;
34
+ /** 原文的整图哈希(写前比对的基线);不存在时 `null`。 */
35
+ hash: string | null;
36
+ /** 读入阶段的问题,含 `warning` / `hint`(上层按 `level` 分流)。 */
37
+ problems: ValidationProblem[];
38
+ /** `false` ⇒ 拒绝加载:要么保存级非空,要么文档不可用。 */
39
+ loadable: boolean;
40
+ /** 那个文件在不在。`loadable=false` 时用它区分 `not_found` 与 `blocked`。 */
41
+ exists: boolean;
42
+ }
43
+ export interface SaveOptions {
44
+ /** 加载时记录的整图哈希;`null` = 没有基线(退化为"以磁盘为基线"的合并,不报冲突)。 */
45
+ baseHash: string | null;
46
+ /** 画布「保留我的」:冲突也写(冲突 id 以本地为准)。**工具写路径不要传**。 */
47
+ force?: boolean;
48
+ }
49
+ export interface SaveResult {
50
+ /** 写回后磁盘内容的整图哈希 ⇒ 新的基线。 */
51
+ hash: string;
52
+ changed: ChangedEntry[];
53
+ warnings: ToolWarning[];
54
+ }
55
+ /** 仓储的统一返回:成功 `{ ok: true, result }`,失败 `{ ok: false, error }`(就是 `ToolError` 的字段)。 */
56
+ export type Outcome<T> = {
57
+ ok: true;
58
+ result: T;
59
+ } | {
60
+ ok: false;
61
+ error: ToolError['error'];
62
+ };
63
+ /**
64
+ * 文档级校验器——`shared/validate.ts` 的入口在 host 装配时注入(缺省不做文档级校验)。
65
+ *
66
+ * 图名要一起给:校验层有两条规则依赖它(图名的文件名约束、同名目录占位)。
67
+ * `maxNodes` 这类活配置由装配方闭包进来,仓储不认识 Config。
68
+ */
69
+ export type DocumentValidator = (document: WorkflowDocument, workflow: string) => ValidationProblem[];
70
+ export interface RepositoryOptions {
71
+ /** 数据根目录(Config 的 `dataDir`,默认 `~/.dsh/workflow-lite`)。 */
72
+ dataDir: string;
73
+ /** 见 {@link DocumentValidator}。 */
74
+ validate?: DocumentValidator;
75
+ }
76
+ /** `write_node` 的语义入参——`undefined` 一律表示"不改这一项"。 */
77
+ export interface NodeUpsert {
78
+ /** 节点 id(图内大小写不敏感唯一);不存在即新建。 */
79
+ id: string;
80
+ /** `data.prompt`;允许空串(空 `prompt` 是编译级,不拦落盘)。 */
81
+ content?: string;
82
+ /** 显示名;空串 = 清除(回落渲染 `id`)。 */
83
+ label?: string;
84
+ /**
85
+ * 它写的文件(一个路径);`false` / `null` = 不写任何文件。产出放在资源节点里:
86
+ * 路径已有资源就连上,没有就新建(见 `shared/resources.ts` 的 `setStepOutputs`)。
87
+ */
88
+ output?: string | false | null;
89
+ /** 一个或多个写入的文件(可带生成规则);给了它就整份替换(`noOutput` 仍然优先)。 */
90
+ outputs?: OutputSpec[];
91
+ /** 一句话描述;空串 = 清除。 */
92
+ description?: string;
93
+ /** `true` ⇒ 不写任何文件(与 `output` 同时给出时以本字段为准)。 */
94
+ noOutput?: boolean;
95
+ /** 从 `templates/nodes/<from>.json` 取 `data` 本体(**不复制模板的 `id` 与 `position`**)。 */
96
+ fromTemplate?: string;
97
+ /** 显式坐标;缺省时新建节点留 `{0,0}` 并报 `position_filled` 提示(布局由上层跑)。 */
98
+ position?: Point;
99
+ }
100
+ /**
101
+ * `write_node` 带 `input`:新建或改一个输入节点。给了的字段才改(`kind` 换了会按新题型重新规范化选项与默认值);
102
+ * 文字字段空串 = 清除。
103
+ */
104
+ export interface InputUpsert {
105
+ id: string;
106
+ question?: string;
107
+ kind?: InputData['kind'] | 'text';
108
+ options?: string[];
109
+ default?: string | string[];
110
+ placeholder?: string;
111
+ hint?: string;
112
+ required?: boolean;
113
+ position?: Point;
114
+ }
115
+ /** `write_resource`:新建或修改一个资源节点。给了的字段才改;`items` 给了就整份替换。 */
116
+ export interface ResourceUpsert {
117
+ /** 资源节点 id;缺省 = 新建,按名字或第一项起一个。 */
118
+ id?: string;
119
+ /** 名字;空串 = 清除。 */
120
+ label?: string;
121
+ /** 描述;空串 = 清除。 */
122
+ description?: string;
123
+ items?: ResourceItem[];
124
+ position?: Point;
125
+ }
126
+ /** 改工作流设置时给的字段(没给的不动)。 */
127
+ export interface SettingsPatch {
128
+ outputRoot?: string;
129
+ mode?: ExecutionMode;
130
+ reuse?: ReusePolicy;
131
+ setGoal?: boolean;
132
+ runState?: boolean;
133
+ }
134
+ export interface Repository {
135
+ readonly dataDir: string;
136
+ /** 首次启动按需创建 `workflows/` 与 `templates/nodes/`(**不建 `.dispatch/`**)。 */
137
+ ensureLayout(): Promise<Outcome<{
138
+ created: string[];
139
+ }>>;
140
+ load(workflow: string): Promise<LoadResult>;
141
+ save(workflow: string, next: WorkflowDocument, options: SaveOptions): Promise<Outcome<SaveResult>>;
142
+ list(): Promise<ListResult>;
143
+ create(workflow: string): Promise<Outcome<WriteResult>>;
144
+ rename(workflow: string, to: string): Promise<Outcome<WriteResult>>;
145
+ remove(workflow: string): Promise<Outcome<WriteResult>>;
146
+ /** 列一个工作流存下的版本(新的在前),标出哪个和磁盘上现在的内容一样。 */
147
+ listVersions(workflow: string): Promise<Outcome<VersionEntry[]>>;
148
+ /** 把磁盘上现在的样子存成新版本。和已有的某个版本内容一样就不存(`invalid_args`,`detail.same`)。 */
149
+ saveVersion(workflow: string, note: string): Promise<Outcome<VersionEntry>>;
150
+ /** 读一个版本的整张图(切换前看看会变什么)。 */
151
+ readVersion(workflow: string, n: number): Promise<Outcome<{
152
+ entry: VersionEntry;
153
+ document: WorkflowDocument;
154
+ }>>;
155
+ /**
156
+ * 切到某个版本:现在的内容还没存成版本时先自动存一份(`saved`),再把那个版本写回工作流。
157
+ * 回新的整图哈希。
158
+ */
159
+ restoreVersion(workflow: string, n: number): Promise<Outcome<{
160
+ hash: string;
161
+ saved: VersionEntry | null;
162
+ }>>;
163
+ /** 改版本说明。 */
164
+ noteVersion(workflow: string, n: number, note: string): Promise<Outcome<VersionEntry>>;
165
+ deleteVersion(workflow: string, n: number): Promise<Outcome<{
166
+ removed: true;
167
+ }>>;
168
+ /** 读一个节点模板的 `data` 本体(拿去用:半成品一律挡掉)。 */
169
+ readTemplate(name: string): Promise<Outcome<NodeData>>;
170
+ /**
171
+ * 新建一个节点模板文件(`templates/nodes/<名>.json`)。
172
+ *
173
+ * 名字撞了报 `conflict`:**不覆盖、也不自动加序号**——名字是人在对话框里指着输的,
174
+ * 悄悄改名会让他找不到刚建的那个。
175
+ */
176
+ createNodeTemplate(name: string, data: NodeData): Promise<Outcome<WriteResult>>;
177
+ /**
178
+ * 读一个节点模板给人**编辑**:只挡保存级(文件坏了),提示词还空着之类的编译级问题照样给出来——
179
+ * 半成品正是要打开来改的。(`readTemplate` 是"拿去用"的那条路,半成品一律挡掉。)
180
+ */
181
+ readNodeTemplateDraft(name: string): Promise<Outcome<NodeData>>;
182
+ /**
183
+ * 覆盖保存一个**已存在**的节点模板;给了 `from` 且与 `name` 不同就是"改名并保存":
184
+ * 新名字被占用报 `conflict`(不覆盖别人的),写好新文件再删旧文件。
185
+ */
186
+ saveNodeTemplate(name: string, data: NodeData, from?: string): Promise<Outcome<WriteResult>>;
187
+ /** 删除一个节点模板文件。不存在报 `not_found`。 */
188
+ deleteNodeTemplate(name: string): Promise<Outcome<WriteResult>>;
189
+ writeNode(workflow: string, upsert: NodeUpsert): Promise<Outcome<WriteResult>>;
190
+ writeResource(workflow: string, upsert: ResourceUpsert): Promise<Outcome<WriteResult>>;
191
+ writeInput(workflow: string, upsert: InputUpsert): Promise<Outcome<WriteResult>>;
192
+ setLabel(workflow: string, node: string, label: string): Promise<Outcome<WriteResult>>;
193
+ /** 改工作流设置(产出根目录、执行方式、复用执行者、设定目标、记录运行状态);给了的字段才改。 */
194
+ configure(workflow: string, patch: SettingsPatch): Promise<Outcome<WriteResult>>;
195
+ deleteNode(workflow: string, node: string): Promise<Outcome<WriteResult>>;
196
+ connect(workflow: string, source: string, target: string, when?: string, handoff?: Handoff | false | null, update?: boolean): Promise<Outcome<WriteResult>>;
197
+ disconnect(workflow: string, source: string, target: string, when?: string): Promise<Outcome<WriteResult>>;
198
+ }
199
+ /**
200
+ * `shared/validate.ts` 的 `ValidationReport` → 仓储的 `ValidationProblem[]`。
201
+ * 装配时的接线就是这两行(`maxNodes` 是活配置,用闭包每次重读):
202
+ *
203
+ * ```ts
204
+ * createRepository({
205
+ * dataDir,
206
+ * validate: (document, workflow) =>
207
+ * reportProblems(validateDocument(document, { workflowName: workflow, maxNodes: cfg.maxNodes })),
208
+ * })
209
+ * ```
210
+ */
211
+ export declare function reportProblems(report: ValidationReport): ValidationProblem[];
212
+ /** 把非阻塞问题(警告 / 提示)转成工具线格式的 `warnings`。 */
213
+ export declare function problemsToWarnings(problems: readonly ValidationProblem[]): ToolWarning[];
214
+ /** `before → after` 的变更摘要(`save` 回告用)。 */
215
+ export declare function diffDocuments(before: WorkflowDocument | null, after: WorkflowDocument): ChangedEntry[];
216
+ /** 建一个仓储。`validate` 由 host 在装配时接上 `shared/validate.ts`。 */
217
+ export declare function createRepository(options: RepositoryOptions): Repository;
@@ -0,0 +1,38 @@
1
+ /**
2
+ * dsh-workflow-lite — 工作流版本的文件形状:`versions/<图名>/<序号>.json`。
3
+ *
4
+ * 一个版本一个文件,文件里是元信息加整张图:
5
+ *
6
+ * ```json
7
+ * { "format": 1, "n": 3, "createdAt": 1759650000000, "note": "跑通了审查环", "document": { … } }
8
+ * ```
9
+ *
10
+ * 切换到别的版本之前自动存的那份多一个 `autoBefore`(切到的版本号)。
11
+ * 本模块只管读、写、比内容;锁、和磁盘上现在那份比对、切换时写回工作流,都在仓储里。
12
+ *
13
+ * @module @xiaoso/dsh-workflow-lite/host/store/versions
14
+ */
15
+ import type { WorkflowDocument } from '../../shared/types.ts';
16
+ /** 读出来的一个版本;文件坏了 `document` 是 `null`。 */
17
+ export interface StoredVersion {
18
+ n: number;
19
+ createdAt: number;
20
+ note: string;
21
+ autoBefore?: number;
22
+ document: WorkflowDocument | null;
23
+ }
24
+ /** 版本文件的规范写法。 */
25
+ export declare function versionText(version: StoredVersion & {
26
+ document: WorkflowDocument;
27
+ }): string;
28
+ /** 解析一个版本文件;读不出来的字段给缺省,图读不出来就是 `null`。 */
29
+ export declare function parseVersion(text: string, n: number): StoredVersion;
30
+ /** 这个工作流存下的全部版本,新的在前。目录不在 = 没有版本。 */
31
+ export declare function readVersions(dataDir: string, name: string): Promise<StoredVersion[]>;
32
+ /** 只数个数(列工作流时用,不读内容)。 */
33
+ export declare function countVersions(dataDir: string, name: string): Promise<number>;
34
+ /**
35
+ * 比内容用的键:规范写法,但不算视口——平移缩放画布不算改了工作流。
36
+ * 卡片位置算(挪了卡片就是另一个样子,切换时会看到「布局」那一行)。
37
+ */
38
+ export declare function contentKey(document: WorkflowDocument): string;