@longzai-intelligence-workflow/core 0.0.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.
- package/CHANGELOG.md +20 -0
- package/README.md +14 -0
- package/coverage/.lcov.info.0d8fc8c4f6acaa77.tmp +159 -0
- package/coverage/.lcov.info.1ca0aee1c681607a.tmp +61 -0
- package/coverage/.lcov.info.5a9690152fb62c73.tmp +159 -0
- package/coverage/.lcov.info.984d9ad89a4b1598.tmp +12 -0
- package/coverage/.lcov.info.a607374a9831c63e.tmp +61 -0
- package/coverage/.lcov.info.b58246c9a6df7fc5.tmp +167 -0
- package/coverage/.lcov.info.b5f068b7c1d63f36.tmp +12 -0
- package/coverage/.lcov.info.bbac83a4ec8a1294.tmp +159 -0
- package/coverage/.lcov.info.bf3e6cf9d98abfc0.tmp +159 -0
- package/coverage/.lcov.info.fb2d882b78dc47d4.tmp +169 -0
- package/coverage/lcov.info +169 -0
- package/dist/index.d.ts +577 -0
- package/dist/index.js +8 -0
- package/dist/schemas-D0Zuq8_5.js +1 -0
- package/dist/schemas.d.ts +684 -0
- package/dist/schemas.js +1 -0
- package/docs/overview.md +17 -0
- package/lzi-builder.config.ts +13 -0
- package/lzi-dev.config.ts +7 -0
- package/oxlint.config.ts +6 -0
- package/package.json +38 -0
- package/src/__tests__/helpers/setup.ts +9 -0
- package/src/__tests__/unit/constants.test.ts +129 -0
- package/src/__tests__/unit/utils.test.ts +156 -0
- package/src/__tests__/work-item-rules.test.ts +90 -0
- package/src/constants/index.ts +1 -0
- package/src/constants/workflow.ts +114 -0
- package/src/index.ts +16 -0
- package/src/ports/action-executor.port.ts +73 -0
- package/src/ports/feed-event.port.ts +74 -0
- package/src/ports/index.ts +9 -0
- package/src/schemas/action-executor.schema.ts +209 -0
- package/src/schemas/api.schema.ts +11 -0
- package/src/schemas/definition.schema.ts +53 -0
- package/src/schemas/feed-event-trigger.schema.ts +102 -0
- package/src/schemas/index.ts +8 -0
- package/src/schemas/instance.schema.ts +47 -0
- package/src/schemas/monitoring.schema.ts +53 -0
- package/src/schemas/trigger.schema.ts +26 -0
- package/src/schemas/workflow-doc.schema.ts +365 -0
- package/src/types/action-executor.ts +64 -0
- package/src/types/api.ts +10 -0
- package/src/types/definition.ts +49 -0
- package/src/types/feed-event-trigger.ts +38 -0
- package/src/types/index.ts +6 -0
- package/src/types/instance.ts +49 -0
- package/src/types/monitoring.ts +54 -0
- package/src/types/trigger.ts +39 -0
- package/src/utils/dag.utils.ts +95 -0
- package/src/utils/declaration-frontmatter.utils.ts +138 -0
- package/src/utils/index.ts +19 -0
- package/src/utils/work-item-rules.utils.ts +194 -0
- package/tsconfig/.cache/build.tsbuildinfo +1 -0
- package/tsconfig/.cache/node.tsbuildinfo +1 -0
- package/tsconfig/.cache/test.tsbuildinfo +1 -0
- package/tsconfig/app.json +12 -0
- package/tsconfig/build.json +15 -0
- package/tsconfig/node.json +12 -0
- package/tsconfig/test.json +15 -0
- package/tsconfig.json +15 -0
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* workflow 声明档契约(frontmatter 结构领域真源——归属引擎主仓 core 包)
|
|
3
|
+
*
|
|
4
|
+
* 声明域方言 = 标量 + 字符串数组(declaration-frontmatter 方言)。
|
|
5
|
+
* 行内结构四段制:items = `<id> | <标题> | <指针> | <状态>`;
|
|
6
|
+
* gates = `<挂靠> | <类型> | <说明> | <裁定>`——执行状态与裁定事实归声明档(属主维护)。
|
|
7
|
+
* 依赖方向铁律:工具仓消费引擎契约,引擎不依赖工具仓(对齐 arxiv 家族与 ADR 0098 拓扑)。
|
|
8
|
+
*/
|
|
9
|
+
import * as z from 'zod';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* 工作项执行状态枚举(对齐台账家族词汇;执行状态归声明档,属主手改)
|
|
13
|
+
*/
|
|
14
|
+
export const WORK_ITEM_STATUSES = ['todo', 'doing', 'blocked', 'done', 'dropped'] as const;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* 工作项执行状态类型
|
|
18
|
+
*/
|
|
19
|
+
export type WorkItemStatus = (typeof WORK_ITEM_STATUSES)[number];
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* kebab-case slug(id 与文件名 stem,去 .workflow.md)
|
|
23
|
+
*/
|
|
24
|
+
const KEBAB_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* 工作项指针备选:`task:<仓>/<slug>`(task 台账引用)或 `ref:<仓>/<仓内路径>`
|
|
28
|
+
*/
|
|
29
|
+
const ITEM_REF_ALTERNATION = 'task:[a-z0-9][a-z0-9-]*\\/[a-z0-9\\/-]+|ref:[a-z0-9][a-z0-9-]*\\/[a-z0-9\\/. _-]+';
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* 工作项行:`<itemId> | <标题> | <指针> | <状态>`(四段制)
|
|
33
|
+
*/
|
|
34
|
+
const ITEM_LINE_PATTERN = new RegExp(
|
|
35
|
+
`^([a-z0-9]+(?:-[a-z0-9]+)*) \\| (.+) \\| (${ITEM_REF_ALTERNATION}) \\| (todo|doing|blocked|done|dropped)$`,
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* 裁定段:`pending` 或 `<结果>:<决定者>:<凭据>`(已裁必带决定者,凭据可省)
|
|
40
|
+
*/
|
|
41
|
+
const GATE_RULING_PATTERN = /^(pending)$|^(approved|rejected|escalated):([^:|]+)(?::([^:|]+))?$/;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* 裁定门行:`<挂靠> | <类型> | <说明> | <裁定>`(四段制;说明段禁含管道符)
|
|
45
|
+
*/
|
|
46
|
+
const GATE_LINE_PATTERN =
|
|
47
|
+
/^([a-z0-9]+(?:-[a-z0-9]+)*|workflow) \| ([a-z0-9-]+) \| ([^|]+?) \| (pending|(?:(?:approved|rejected|escalated):[^:|]+(?::[^:|]+)?))$/;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* 依赖边:`<from> -> <to>`(两端均为工作项 id)
|
|
51
|
+
*/
|
|
52
|
+
const EDGE_PATTERN = /^([a-z0-9]+(?:-[a-z0-9]+)*) -> ([a-z0-9]+(?:-[a-z0-9]+)*)$/;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* 工作项(解析后形态)
|
|
56
|
+
*/
|
|
57
|
+
export type WorkflowItem = {
|
|
58
|
+
/**
|
|
59
|
+
* 工作项 id(工作流内唯一)
|
|
60
|
+
*/
|
|
61
|
+
readonly id: string;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* 标题(人读)
|
|
65
|
+
*/
|
|
66
|
+
readonly title: string;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* 指针(task 台账引用或 ref 路径引用)
|
|
70
|
+
*/
|
|
71
|
+
readonly ref: string;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* 执行状态(声明档承载,属主维护)
|
|
75
|
+
*/
|
|
76
|
+
readonly status: WorkItemStatus;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* 依赖边(解析后形态)
|
|
81
|
+
*/
|
|
82
|
+
export type WorkflowEdge = {
|
|
83
|
+
/**
|
|
84
|
+
* 前置工作项 id
|
|
85
|
+
*/
|
|
86
|
+
readonly from: string;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* 后继工作项 id
|
|
90
|
+
*/
|
|
91
|
+
readonly to: string;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* 裁定事实(裁定段解析形态)
|
|
96
|
+
*/
|
|
97
|
+
export type GateRuling = {
|
|
98
|
+
/**
|
|
99
|
+
* 裁定状态(pending 未裁;approved/rejected/escalated 已裁)
|
|
100
|
+
*/
|
|
101
|
+
readonly status: 'pending' | 'approved' | 'rejected' | 'escalated';
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* 决定者(已裁时携带)
|
|
105
|
+
*/
|
|
106
|
+
readonly decidedBy?: string;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* 凭据指针(裁决记录文件路径等)
|
|
110
|
+
*/
|
|
111
|
+
readonly evidence?: string;
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* 裁定门(解析后形态)
|
|
116
|
+
*/
|
|
117
|
+
export type WorkflowGate = {
|
|
118
|
+
/**
|
|
119
|
+
* 挂靠位置(工作项 id 或 `workflow` 工作流级)
|
|
120
|
+
*/
|
|
121
|
+
readonly at: string;
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* 门类型(如 ruling = 人类裁定门)
|
|
125
|
+
*/
|
|
126
|
+
readonly kind: string;
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* 说明(禁含管道符)
|
|
130
|
+
*/
|
|
131
|
+
readonly note: string;
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* 裁定事实(归声明档,裁定人维护)
|
|
135
|
+
*/
|
|
136
|
+
readonly ruling: GateRuling;
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* workflow 声明档 frontmatter schema(方言字符串数组 + 行内结构形态执法)
|
|
141
|
+
*/
|
|
142
|
+
export const WorkflowDocFrontmatterSchema = z.strictObject({
|
|
143
|
+
/**
|
|
144
|
+
* 工作流 id(= 文件名 stem,去 .workflow.md)
|
|
145
|
+
*/
|
|
146
|
+
id: z.string().regex(KEBAB_PATTERN),
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* 工作流标题
|
|
150
|
+
*/
|
|
151
|
+
title: z.string().min(1),
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* 声明状态(声明域生命周期,区别于执行状态)
|
|
155
|
+
*/
|
|
156
|
+
status: z.enum(['draft', 'active', 'completed', 'archived']),
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* 工作项清单(行内方言四段制,逐行经 parseItemLine 执法)
|
|
160
|
+
*/
|
|
161
|
+
items: z.array(z.string()),
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* 依赖边(行内方言:`<from> -> <to>`;可选)
|
|
165
|
+
*/
|
|
166
|
+
edges: z.array(z.string().regex(EDGE_PATTERN)).optional(),
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* 裁定门(行内方言四段制,逐行经 parseGateLine 执法;可选)
|
|
170
|
+
*/
|
|
171
|
+
gates: z.array(z.string()).optional(),
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* 声明档 frontmatter 形态(schema 推断)
|
|
176
|
+
*/
|
|
177
|
+
export type WorkflowDocFrontmatter = z.infer<typeof WorkflowDocFrontmatterSchema>;
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* 解析工作项行(四段制)
|
|
181
|
+
*
|
|
182
|
+
* @param line - 行内方言文本
|
|
183
|
+
* @returns 解析成功时为工作项形态,失败时为 null
|
|
184
|
+
*/
|
|
185
|
+
export function parseItemLine(line: string): WorkflowItem | null {
|
|
186
|
+
/**
|
|
187
|
+
* 行内四段切分结果
|
|
188
|
+
*/
|
|
189
|
+
const matched = ITEM_LINE_PATTERN.exec(line);
|
|
190
|
+
if (!matched) {
|
|
191
|
+
return null;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* 工作项 id 捕获段(索引访问可能为 undefined,判空后收窄)
|
|
196
|
+
*/
|
|
197
|
+
const id = matched[1];
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* 工作项标题捕获段(索引访问可能为 undefined,判空后收窄)
|
|
201
|
+
*/
|
|
202
|
+
const title = matched[2];
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* 工作项指针捕获段(索引访问可能为 undefined,判空后收窄)
|
|
206
|
+
*/
|
|
207
|
+
const ref = matched[3];
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* 执行状态捕获段(索引访问可能为 undefined,判空后收窄)
|
|
211
|
+
*/
|
|
212
|
+
const status = matched[4];
|
|
213
|
+
if (id === undefined || title === undefined || ref === undefined || status === undefined) {
|
|
214
|
+
return null;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* 状态段枚举守卫 schema(zod 收窄,零 as 断言)
|
|
219
|
+
*/
|
|
220
|
+
const itemStatusGuardSchema = z.enum(WORK_ITEM_STATUSES);
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* 状态段枚举校验结果
|
|
224
|
+
*/
|
|
225
|
+
const statusChecked = itemStatusGuardSchema.safeParse(status);
|
|
226
|
+
if (!statusChecked.success) {
|
|
227
|
+
return null;
|
|
228
|
+
}
|
|
229
|
+
return { id, title, ref, status: statusChecked.data };
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* 解析依赖边行
|
|
234
|
+
*
|
|
235
|
+
* @param line - 行内方言文本
|
|
236
|
+
* @returns 解析成功时为依赖边形态,失败时为 null
|
|
237
|
+
*/
|
|
238
|
+
export function parseEdgeLine(line: string): WorkflowEdge | null {
|
|
239
|
+
/**
|
|
240
|
+
* 行内两段切分结果
|
|
241
|
+
*/
|
|
242
|
+
const matched = EDGE_PATTERN.exec(line);
|
|
243
|
+
if (!matched) {
|
|
244
|
+
return null;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* 前置工作项 id 捕获段(索引访问可能为 undefined,判空后收窄)
|
|
249
|
+
*/
|
|
250
|
+
const from = matched[1];
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* 后继工作项 id 捕获段(索引访问可能为 undefined,判空后收窄)
|
|
254
|
+
*/
|
|
255
|
+
const to = matched[2];
|
|
256
|
+
if (from === undefined || to === undefined) {
|
|
257
|
+
return null;
|
|
258
|
+
}
|
|
259
|
+
return { from, to };
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* 解析裁定段(`pending` 或 `<结果>:<决定者>:<凭据>`)
|
|
264
|
+
*
|
|
265
|
+
* @param segment - 裁定段文本
|
|
266
|
+
* @returns 解析成功时为裁定事实形态,失败时为 null
|
|
267
|
+
*/
|
|
268
|
+
export function parseGateRuling(segment: string): GateRuling | null {
|
|
269
|
+
/**
|
|
270
|
+
* 裁定段切分结果
|
|
271
|
+
*/
|
|
272
|
+
const matched = GATE_RULING_PATTERN.exec(segment);
|
|
273
|
+
if (!matched) {
|
|
274
|
+
return null;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* 裁定状态捕获段(索引访问可能为 undefined,判空后收窄)
|
|
279
|
+
*/
|
|
280
|
+
const status = matched[1] ?? matched[2];
|
|
281
|
+
if (status === undefined) {
|
|
282
|
+
return null;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* 裁定状态枚举守卫 schema(zod 收窄,零 as 断言)
|
|
287
|
+
*/
|
|
288
|
+
const rulingStatusGuardSchema = z.enum(['pending', 'approved', 'rejected', 'escalated']);
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* 裁定状态枚举校验结果
|
|
292
|
+
*/
|
|
293
|
+
const statusChecked = rulingStatusGuardSchema.safeParse(status);
|
|
294
|
+
if (!statusChecked.success) {
|
|
295
|
+
return null;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* 决定者捕获段(pending 时缺席)
|
|
300
|
+
*/
|
|
301
|
+
const decidedBy = matched[3];
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* 凭据指针捕获段(可省)
|
|
305
|
+
*/
|
|
306
|
+
const evidence = matched[4];
|
|
307
|
+
return {
|
|
308
|
+
status: statusChecked.data,
|
|
309
|
+
...(decidedBy !== undefined ? { decidedBy } : {}),
|
|
310
|
+
...(evidence !== undefined ? { evidence } : {}),
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* 解析裁定门行(四段制)
|
|
316
|
+
*
|
|
317
|
+
* @param line - 行内方言文本
|
|
318
|
+
* @returns 解析成功时为裁定门形态,失败时为 null
|
|
319
|
+
*/
|
|
320
|
+
export function parseGateLine(line: string): WorkflowGate | null {
|
|
321
|
+
/**
|
|
322
|
+
* 行内四段切分结果
|
|
323
|
+
*/
|
|
324
|
+
const matched = GATE_LINE_PATTERN.exec(line);
|
|
325
|
+
if (!matched) {
|
|
326
|
+
return null;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* 挂靠位置捕获段(索引访问可能为 undefined,判空后收窄)
|
|
331
|
+
*/
|
|
332
|
+
const at = matched[1];
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* 门类型捕获段(索引访问可能为 undefined,判空后收窄)
|
|
336
|
+
*/
|
|
337
|
+
const kind = matched[2];
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* 说明捕获段(禁含管道符;索引访问可能为 undefined,判空后收窄)
|
|
341
|
+
*/
|
|
342
|
+
const note = matched[3];
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* 裁定段捕获文本(索引访问可能为 undefined,判空后收窄)
|
|
346
|
+
*/
|
|
347
|
+
const rulingSegment = matched[4];
|
|
348
|
+
if (at === undefined || kind === undefined || note === undefined || rulingSegment === undefined) {
|
|
349
|
+
return null;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* 裁定事实解析结果
|
|
354
|
+
*/
|
|
355
|
+
const ruling = parseGateRuling(rulingSegment);
|
|
356
|
+
if (ruling === null) {
|
|
357
|
+
return null;
|
|
358
|
+
}
|
|
359
|
+
return { at, kind, note, ruling };
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* 家族引用(条目档 frontmatter 的 ref 字段值)
|
|
364
|
+
*/
|
|
365
|
+
export const WORKFLOW_REF_PATTERN = /^workflow:(global|[a-z0-9][a-z0-9-]*)\/([a-z0-9]+(?:-[a-z0-9]+)*)$/;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* action 执行器类型定义(W-3,Phase 2)
|
|
3
|
+
*
|
|
4
|
+
* 从 Zod Schema 推导类型,供 execution 子插件、action handler 实现、
|
|
5
|
+
* 工作流运行时与外部消费方共享类型契约。
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type {
|
|
9
|
+
actionContextSchema,
|
|
10
|
+
actionResultSchema,
|
|
11
|
+
actionSchema,
|
|
12
|
+
actionTypeSchema,
|
|
13
|
+
feedApplyTagsActionSchema,
|
|
14
|
+
feedSummarizeActionSchema,
|
|
15
|
+
llmCompleteActionSchema,
|
|
16
|
+
webhookSendActionSchema,
|
|
17
|
+
} from '../schemas';
|
|
18
|
+
import type { z } from 'zod';
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* action 类型枚举
|
|
22
|
+
*/
|
|
23
|
+
export type ActionType = z.infer<typeof actionTypeSchema>;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* feed.applyTags action 输入类型
|
|
27
|
+
*/
|
|
28
|
+
export type FeedApplyTagsAction = z.infer<typeof feedApplyTagsActionSchema>;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* feed.summarize action 输入类型
|
|
32
|
+
*/
|
|
33
|
+
export type FeedSummarizeAction = z.infer<typeof feedSummarizeActionSchema>;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* llm.complete action 输入类型
|
|
37
|
+
*/
|
|
38
|
+
export type LlmCompleteAction = z.infer<typeof llmCompleteActionSchema>;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* webhook.send action 输入类型
|
|
42
|
+
*/
|
|
43
|
+
export type WebhookSendAction = z.infer<typeof webhookSendActionSchema>;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* action 联合类型
|
|
47
|
+
*
|
|
48
|
+
* 所有内置 action 的联合类型,按 type 字段区分。
|
|
49
|
+
*/
|
|
50
|
+
export type Action = z.infer<typeof actionSchema>;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* action 执行上下文类型
|
|
54
|
+
*
|
|
55
|
+
* 工作流引擎在执行 action 节点时传入的上下文信息。
|
|
56
|
+
*/
|
|
57
|
+
export type ActionContext = z.infer<typeof actionContextSchema>;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* action 执行结果类型
|
|
61
|
+
*
|
|
62
|
+
* action handler 执行完成后返回的结果。
|
|
63
|
+
*/
|
|
64
|
+
export type ActionResult = z.infer<typeof actionResultSchema>;
|
package/src/types/api.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 通用 API 响应类型已清理
|
|
3
|
+
*
|
|
4
|
+
* 历史上此文件导出 ApiResponse、PaginatedResponse、PaginationInfo、ApiError 等通用 API 类型,
|
|
5
|
+
* 但经核查无任何外部消费方(apps/web 与 packages/sdk 均使用 @longzai-intelligence-transport/http
|
|
6
|
+
* 提供的 ApiResponse,或在各自模块内本地定义 apiResponseSchema)。
|
|
7
|
+
*
|
|
8
|
+
* 为清理死代码,此文件内容已被清空,文件本身保留以维持包结构骨架。
|
|
9
|
+
*/
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export type DefinitionDTO = {
|
|
2
|
+
id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
description: string | null;
|
|
5
|
+
version: number;
|
|
6
|
+
nodes: WorkflowNodeDTO[];
|
|
7
|
+
edges: WorkflowEdgeDTO[];
|
|
8
|
+
initialState: string;
|
|
9
|
+
states: string[];
|
|
10
|
+
publishedAt: string | null;
|
|
11
|
+
createdAt: string;
|
|
12
|
+
updatedAt: string;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export type WorkflowNodeDTO = {
|
|
16
|
+
nodeId: string;
|
|
17
|
+
name: string;
|
|
18
|
+
type: string;
|
|
19
|
+
properties: Record<string, unknown>;
|
|
20
|
+
position: { x: number; y: number };
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export type WorkflowEdgeDTO = {
|
|
24
|
+
edgeId: string;
|
|
25
|
+
sourceNodeId: string;
|
|
26
|
+
targetNodeId: string;
|
|
27
|
+
condition?: string;
|
|
28
|
+
label?: string;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export type CreateDefinitionInput = {
|
|
32
|
+
name: string;
|
|
33
|
+
description?: string;
|
|
34
|
+
nodes: WorkflowNodeDTO[];
|
|
35
|
+
edges: WorkflowEdgeDTO[];
|
|
36
|
+
initialState: string;
|
|
37
|
+
states: string[];
|
|
38
|
+
transitions: StateTransitionDTO[];
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export type StateTransitionDTO = {
|
|
42
|
+
from: string;
|
|
43
|
+
to: string;
|
|
44
|
+
event: string;
|
|
45
|
+
guard?: string;
|
|
46
|
+
action?: string;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export type UpdateDefinitionInput = Partial<CreateDefinitionInput>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* feed 事件触发器类型定义(W-2,Phase 2)
|
|
3
|
+
*
|
|
4
|
+
* 从 Zod Schema 推导类型,供 trigger 子插件、execution 子插件、
|
|
5
|
+
* 工作流运行时与外部消费方共享类型契约。
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type {
|
|
9
|
+
feedEventFilterSchema,
|
|
10
|
+
feedEventNameSchema,
|
|
11
|
+
feedEventPayloadSchema,
|
|
12
|
+
feedEventTriggerSchema,
|
|
13
|
+
} from '../schemas';
|
|
14
|
+
import type { z } from 'zod';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* feed 事件名称类型
|
|
18
|
+
*/
|
|
19
|
+
export type FeedEventName = z.infer<typeof feedEventNameSchema>;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* feed 事件过滤条件类型
|
|
23
|
+
*/
|
|
24
|
+
export type FeedEventFilter = z.infer<typeof feedEventFilterSchema>;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* feed 事件触发器配置类型
|
|
28
|
+
*
|
|
29
|
+
* 工作流 trigger.type 为 'feed.event' 时的配置结构。
|
|
30
|
+
*/
|
|
31
|
+
export type FeedEventTrigger = z.infer<typeof feedEventTriggerSchema>;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* feed 事件 payload 类型
|
|
35
|
+
*
|
|
36
|
+
* feed 项目在事件触发时传递给工作流上下文的事件数据。
|
|
37
|
+
*/
|
|
38
|
+
export type FeedEventPayload = z.infer<typeof feedEventPayloadSchema>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export type InstanceDTO = {
|
|
2
|
+
id: string;
|
|
3
|
+
definitionId: string;
|
|
4
|
+
definitionVersion: number;
|
|
5
|
+
status: InstanceStatusDTO;
|
|
6
|
+
currentState: string;
|
|
7
|
+
previousState: string | null;
|
|
8
|
+
currentNodeId: string | null;
|
|
9
|
+
variables: Record<string, unknown>;
|
|
10
|
+
startedAt: string | null;
|
|
11
|
+
completedAt: string | null;
|
|
12
|
+
createdAt: string;
|
|
13
|
+
updatedAt: string;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export type InstanceStatusDTO =
|
|
17
|
+
| 'pending'
|
|
18
|
+
| 'running'
|
|
19
|
+
| 'paused'
|
|
20
|
+
| 'completed'
|
|
21
|
+
| 'cancelled'
|
|
22
|
+
| 'failed';
|
|
23
|
+
|
|
24
|
+
export type NodeExecutionDTO = {
|
|
25
|
+
id: string;
|
|
26
|
+
instanceId: string;
|
|
27
|
+
nodeId: string;
|
|
28
|
+
nodeName: string;
|
|
29
|
+
nodeType: string;
|
|
30
|
+
status: NodeExecutionStatusDTO;
|
|
31
|
+
startedAt: string | null;
|
|
32
|
+
completedAt: string | null;
|
|
33
|
+
error: string | null;
|
|
34
|
+
createdAt: string;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export type NodeExecutionStatusDTO = 'pending' | 'running' | 'completed' | 'failed' | 'skipped';
|
|
38
|
+
|
|
39
|
+
export type CreateInstanceInput = {
|
|
40
|
+
definitionId: string;
|
|
41
|
+
input?: Record<string, unknown>;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export type InstanceQueryParams = {
|
|
45
|
+
status?: InstanceStatusDTO;
|
|
46
|
+
definitionId?: string;
|
|
47
|
+
page?: number;
|
|
48
|
+
pageSize?: number;
|
|
49
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export type AuditLogDTO = {
|
|
2
|
+
id: string;
|
|
3
|
+
instanceId: string;
|
|
4
|
+
nodeId: string | null;
|
|
5
|
+
action: string;
|
|
6
|
+
fromStatus: string | null;
|
|
7
|
+
toStatus: string;
|
|
8
|
+
operator: string | null;
|
|
9
|
+
detail: Record<string, unknown>;
|
|
10
|
+
createdAt: string;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export type AlertDTO = {
|
|
14
|
+
id: string;
|
|
15
|
+
definitionId: string;
|
|
16
|
+
type: AlertTypeDTO;
|
|
17
|
+
threshold: number;
|
|
18
|
+
notifyConfig: Record<string, unknown>;
|
|
19
|
+
enabled: boolean;
|
|
20
|
+
lastTriggeredAt: string | null;
|
|
21
|
+
createdAt: string;
|
|
22
|
+
updatedAt: string;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export type AlertTypeDTO = 'timeout' | 'failure_rate' | 'slow_execution';
|
|
26
|
+
|
|
27
|
+
export type PerformanceMetricDTO = {
|
|
28
|
+
id: string;
|
|
29
|
+
definitionId: string;
|
|
30
|
+
metricType: MetricTypeDTO;
|
|
31
|
+
value: number;
|
|
32
|
+
period: string;
|
|
33
|
+
calculatedAt: string;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export type MetricTypeDTO =
|
|
37
|
+
| 'avg_duration'
|
|
38
|
+
| 'success_rate'
|
|
39
|
+
| 'failure_rate'
|
|
40
|
+
| 'timeout_rate'
|
|
41
|
+
| 'instance_count';
|
|
42
|
+
|
|
43
|
+
export type MonitoringDashboardDTO = {
|
|
44
|
+
runningInstances: number;
|
|
45
|
+
successRate: number;
|
|
46
|
+
avgDuration: number;
|
|
47
|
+
failureAlerts: number;
|
|
48
|
+
trend: TrendPointDTO[];
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export type TrendPointDTO = {
|
|
52
|
+
date: string;
|
|
53
|
+
value: number;
|
|
54
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 触发器对外暴露的传输结构
|
|
3
|
+
*/
|
|
4
|
+
export type TriggerDTO = {
|
|
5
|
+
id: string;
|
|
6
|
+
definitionId: string;
|
|
7
|
+
name: string;
|
|
8
|
+
type: TriggerTypeDTO;
|
|
9
|
+
config: Record<string, unknown>;
|
|
10
|
+
enabled: boolean;
|
|
11
|
+
lastTriggeredAt: string | null;
|
|
12
|
+
createdAt: string;
|
|
13
|
+
updatedAt: string;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* 触发器类型枚举
|
|
18
|
+
*
|
|
19
|
+
* - timer:定时触发
|
|
20
|
+
* - webhook:Webhook 触发
|
|
21
|
+
* - event:通用事件触发
|
|
22
|
+
* - feed.event:feed 事件触发(W-2,Phase 2)
|
|
23
|
+
*/
|
|
24
|
+
export type TriggerTypeDTO = 'timer' | 'webhook' | 'event' | 'feed.event';
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* 创建触发器的入参
|
|
28
|
+
*/
|
|
29
|
+
export type CreateTriggerInput = {
|
|
30
|
+
definitionId: string;
|
|
31
|
+
name: string;
|
|
32
|
+
type: TriggerTypeDTO;
|
|
33
|
+
config: Record<string, unknown>;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* 更新触发器的入参
|
|
38
|
+
*/
|
|
39
|
+
export type UpdateTriggerInput = Partial<CreateTriggerInput>;
|