@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
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,577 @@
|
|
|
1
|
+
import { GateRuling, WORKFLOW_REF_PATTERN, WORK_ITEM_STATUSES, WorkItemStatus, WorkflowDocFrontmatter, WorkflowDocFrontmatterSchema, WorkflowEdge, WorkflowGate, WorkflowItem, actionContextSchema, actionResultSchema, actionSchema, actionTypeSchema, alertDtoSchema, alertTypeDtoSchema, auditLogDtoSchema, createDefinitionInputSchema, createInstanceInputSchema, createTriggerInputSchema, definitionDtoSchema, feedApplyTagsActionSchema, feedEventFilterSchema, feedEventNameSchema, feedEventPayloadSchema, feedEventTriggerSchema, feedSummarizeActionSchema, instanceDtoSchema, instanceQueryParamsSchema, instanceStatusDtoSchema, llmCompleteActionSchema, metricTypeDtoSchema, monitoringDashboardDtoSchema, nodeExecutionDtoSchema, nodeExecutionStatusDtoSchema, parseEdgeLine, parseGateLine, parseGateRuling, parseItemLine, performanceMetricDtoSchema, stateTransitionDtoSchema, trendPointDtoSchema, triggerDtoSchema, triggerTypeDtoSchema, updateDefinitionInputSchema, updateTriggerInputSchema, webhookSendActionSchema, workflowEdgeDtoSchema, workflowNodeDtoSchema } from "./schemas.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
//#region src/types/definition.d.ts
|
|
4
|
+
type DefinitionDTO = {
|
|
5
|
+
id: string;
|
|
6
|
+
name: string;
|
|
7
|
+
description: string | null;
|
|
8
|
+
version: number;
|
|
9
|
+
nodes: WorkflowNodeDTO[];
|
|
10
|
+
edges: WorkflowEdgeDTO[];
|
|
11
|
+
initialState: string;
|
|
12
|
+
states: string[];
|
|
13
|
+
publishedAt: string | null;
|
|
14
|
+
createdAt: string;
|
|
15
|
+
updatedAt: string;
|
|
16
|
+
};
|
|
17
|
+
type WorkflowNodeDTO = {
|
|
18
|
+
nodeId: string;
|
|
19
|
+
name: string;
|
|
20
|
+
type: string;
|
|
21
|
+
properties: Record<string, unknown>;
|
|
22
|
+
position: {
|
|
23
|
+
x: number;
|
|
24
|
+
y: number;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
type WorkflowEdgeDTO = {
|
|
28
|
+
edgeId: string;
|
|
29
|
+
sourceNodeId: string;
|
|
30
|
+
targetNodeId: string;
|
|
31
|
+
condition?: string;
|
|
32
|
+
label?: string;
|
|
33
|
+
};
|
|
34
|
+
type CreateDefinitionInput = {
|
|
35
|
+
name: string;
|
|
36
|
+
description?: string;
|
|
37
|
+
nodes: WorkflowNodeDTO[];
|
|
38
|
+
edges: WorkflowEdgeDTO[];
|
|
39
|
+
initialState: string;
|
|
40
|
+
states: string[];
|
|
41
|
+
transitions: StateTransitionDTO[];
|
|
42
|
+
};
|
|
43
|
+
type StateTransitionDTO = {
|
|
44
|
+
from: string;
|
|
45
|
+
to: string;
|
|
46
|
+
event: string;
|
|
47
|
+
guard?: string;
|
|
48
|
+
action?: string;
|
|
49
|
+
};
|
|
50
|
+
type UpdateDefinitionInput = Partial<CreateDefinitionInput>;
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region src/types/instance.d.ts
|
|
53
|
+
type InstanceDTO = {
|
|
54
|
+
id: string;
|
|
55
|
+
definitionId: string;
|
|
56
|
+
definitionVersion: number;
|
|
57
|
+
status: InstanceStatusDTO;
|
|
58
|
+
currentState: string;
|
|
59
|
+
previousState: string | null;
|
|
60
|
+
currentNodeId: string | null;
|
|
61
|
+
variables: Record<string, unknown>;
|
|
62
|
+
startedAt: string | null;
|
|
63
|
+
completedAt: string | null;
|
|
64
|
+
createdAt: string;
|
|
65
|
+
updatedAt: string;
|
|
66
|
+
};
|
|
67
|
+
type InstanceStatusDTO = 'pending' | 'running' | 'paused' | 'completed' | 'cancelled' | 'failed';
|
|
68
|
+
type NodeExecutionDTO = {
|
|
69
|
+
id: string;
|
|
70
|
+
instanceId: string;
|
|
71
|
+
nodeId: string;
|
|
72
|
+
nodeName: string;
|
|
73
|
+
nodeType: string;
|
|
74
|
+
status: NodeExecutionStatusDTO;
|
|
75
|
+
startedAt: string | null;
|
|
76
|
+
completedAt: string | null;
|
|
77
|
+
error: string | null;
|
|
78
|
+
createdAt: string;
|
|
79
|
+
};
|
|
80
|
+
type NodeExecutionStatusDTO = 'pending' | 'running' | 'completed' | 'failed' | 'skipped';
|
|
81
|
+
type CreateInstanceInput = {
|
|
82
|
+
definitionId: string;
|
|
83
|
+
input?: Record<string, unknown>;
|
|
84
|
+
};
|
|
85
|
+
type InstanceQueryParams = {
|
|
86
|
+
status?: InstanceStatusDTO;
|
|
87
|
+
definitionId?: string;
|
|
88
|
+
page?: number;
|
|
89
|
+
pageSize?: number;
|
|
90
|
+
};
|
|
91
|
+
//#endregion
|
|
92
|
+
//#region src/types/trigger.d.ts
|
|
93
|
+
/**
|
|
94
|
+
* 触发器对外暴露的传输结构
|
|
95
|
+
*/
|
|
96
|
+
type TriggerDTO = {
|
|
97
|
+
id: string;
|
|
98
|
+
definitionId: string;
|
|
99
|
+
name: string;
|
|
100
|
+
type: TriggerTypeDTO;
|
|
101
|
+
config: Record<string, unknown>;
|
|
102
|
+
enabled: boolean;
|
|
103
|
+
lastTriggeredAt: string | null;
|
|
104
|
+
createdAt: string;
|
|
105
|
+
updatedAt: string;
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* 触发器类型枚举
|
|
109
|
+
*
|
|
110
|
+
* - timer:定时触发
|
|
111
|
+
* - webhook:Webhook 触发
|
|
112
|
+
* - event:通用事件触发
|
|
113
|
+
* - feed.event:feed 事件触发(W-2,Phase 2)
|
|
114
|
+
*/
|
|
115
|
+
type TriggerTypeDTO = 'timer' | 'webhook' | 'event' | 'feed.event';
|
|
116
|
+
/**
|
|
117
|
+
* 创建触发器的入参
|
|
118
|
+
*/
|
|
119
|
+
type CreateTriggerInput = {
|
|
120
|
+
definitionId: string;
|
|
121
|
+
name: string;
|
|
122
|
+
type: TriggerTypeDTO;
|
|
123
|
+
config: Record<string, unknown>;
|
|
124
|
+
};
|
|
125
|
+
/**
|
|
126
|
+
* 更新触发器的入参
|
|
127
|
+
*/
|
|
128
|
+
type UpdateTriggerInput = Partial<CreateTriggerInput>;
|
|
129
|
+
//#endregion
|
|
130
|
+
//#region src/types/monitoring.d.ts
|
|
131
|
+
type AuditLogDTO = {
|
|
132
|
+
id: string;
|
|
133
|
+
instanceId: string;
|
|
134
|
+
nodeId: string | null;
|
|
135
|
+
action: string;
|
|
136
|
+
fromStatus: string | null;
|
|
137
|
+
toStatus: string;
|
|
138
|
+
operator: string | null;
|
|
139
|
+
detail: Record<string, unknown>;
|
|
140
|
+
createdAt: string;
|
|
141
|
+
};
|
|
142
|
+
type AlertDTO = {
|
|
143
|
+
id: string;
|
|
144
|
+
definitionId: string;
|
|
145
|
+
type: AlertTypeDTO;
|
|
146
|
+
threshold: number;
|
|
147
|
+
notifyConfig: Record<string, unknown>;
|
|
148
|
+
enabled: boolean;
|
|
149
|
+
lastTriggeredAt: string | null;
|
|
150
|
+
createdAt: string;
|
|
151
|
+
updatedAt: string;
|
|
152
|
+
};
|
|
153
|
+
type AlertTypeDTO = 'timeout' | 'failure_rate' | 'slow_execution';
|
|
154
|
+
type PerformanceMetricDTO = {
|
|
155
|
+
id: string;
|
|
156
|
+
definitionId: string;
|
|
157
|
+
metricType: MetricTypeDTO;
|
|
158
|
+
value: number;
|
|
159
|
+
period: string;
|
|
160
|
+
calculatedAt: string;
|
|
161
|
+
};
|
|
162
|
+
type MetricTypeDTO = 'avg_duration' | 'success_rate' | 'failure_rate' | 'timeout_rate' | 'instance_count';
|
|
163
|
+
type MonitoringDashboardDTO = {
|
|
164
|
+
runningInstances: number;
|
|
165
|
+
successRate: number;
|
|
166
|
+
avgDuration: number;
|
|
167
|
+
failureAlerts: number;
|
|
168
|
+
trend: TrendPointDTO[];
|
|
169
|
+
};
|
|
170
|
+
type TrendPointDTO = {
|
|
171
|
+
date: string;
|
|
172
|
+
value: number;
|
|
173
|
+
};
|
|
174
|
+
//#endregion
|
|
175
|
+
//#region src/types/feed-event-trigger.d.ts
|
|
176
|
+
/**
|
|
177
|
+
* feed 事件名称类型
|
|
178
|
+
*/
|
|
179
|
+
type FeedEventName = z.infer<typeof feedEventNameSchema>;
|
|
180
|
+
/**
|
|
181
|
+
* feed 事件过滤条件类型
|
|
182
|
+
*/
|
|
183
|
+
type FeedEventFilter = z.infer<typeof feedEventFilterSchema>;
|
|
184
|
+
/**
|
|
185
|
+
* feed 事件触发器配置类型
|
|
186
|
+
*
|
|
187
|
+
* 工作流 trigger.type 为 'feed.event' 时的配置结构。
|
|
188
|
+
*/
|
|
189
|
+
type FeedEventTrigger = z.infer<typeof feedEventTriggerSchema>;
|
|
190
|
+
/**
|
|
191
|
+
* feed 事件 payload 类型
|
|
192
|
+
*
|
|
193
|
+
* feed 项目在事件触发时传递给工作流上下文的事件数据。
|
|
194
|
+
*/
|
|
195
|
+
type FeedEventPayload = z.infer<typeof feedEventPayloadSchema>;
|
|
196
|
+
//#endregion
|
|
197
|
+
//#region src/types/action-executor.d.ts
|
|
198
|
+
/**
|
|
199
|
+
* action 类型枚举
|
|
200
|
+
*/
|
|
201
|
+
type ActionType = z.infer<typeof actionTypeSchema>;
|
|
202
|
+
/**
|
|
203
|
+
* feed.applyTags action 输入类型
|
|
204
|
+
*/
|
|
205
|
+
type FeedApplyTagsAction = z.infer<typeof feedApplyTagsActionSchema>;
|
|
206
|
+
/**
|
|
207
|
+
* feed.summarize action 输入类型
|
|
208
|
+
*/
|
|
209
|
+
type FeedSummarizeAction = z.infer<typeof feedSummarizeActionSchema>;
|
|
210
|
+
/**
|
|
211
|
+
* llm.complete action 输入类型
|
|
212
|
+
*/
|
|
213
|
+
type LlmCompleteAction = z.infer<typeof llmCompleteActionSchema>;
|
|
214
|
+
/**
|
|
215
|
+
* webhook.send action 输入类型
|
|
216
|
+
*/
|
|
217
|
+
type WebhookSendAction = z.infer<typeof webhookSendActionSchema>;
|
|
218
|
+
/**
|
|
219
|
+
* action 联合类型
|
|
220
|
+
*
|
|
221
|
+
* 所有内置 action 的联合类型,按 type 字段区分。
|
|
222
|
+
*/
|
|
223
|
+
type Action = z.infer<typeof actionSchema>;
|
|
224
|
+
/**
|
|
225
|
+
* action 执行上下文类型
|
|
226
|
+
*
|
|
227
|
+
* 工作流引擎在执行 action 节点时传入的上下文信息。
|
|
228
|
+
*/
|
|
229
|
+
type ActionContext = z.infer<typeof actionContextSchema>;
|
|
230
|
+
/**
|
|
231
|
+
* action 执行结果类型
|
|
232
|
+
*
|
|
233
|
+
* action handler 执行完成后返回的结果。
|
|
234
|
+
*/
|
|
235
|
+
type ActionResult = z.infer<typeof actionResultSchema>;
|
|
236
|
+
//#endregion
|
|
237
|
+
//#region src/constants/workflow.d.ts
|
|
238
|
+
/**
|
|
239
|
+
* 工作流节点类型枚举
|
|
240
|
+
*/
|
|
241
|
+
declare const NODE_TYPES: readonly ['StartEvent', 'EndEvent', 'UserTask', 'ServiceTask', 'ExclusiveGateway', 'ParallelGateway', 'InclusiveGateway', 'SubProcess', 'TimerEvent', 'ErrorEvent', 'SignalEvent'];
|
|
242
|
+
/**
|
|
243
|
+
* 工作流实例状态枚举
|
|
244
|
+
*/
|
|
245
|
+
declare const INSTANCE_STATUSES: readonly ['pending', 'running', 'paused', 'completed', 'cancelled', 'failed'];
|
|
246
|
+
/**
|
|
247
|
+
* 节点执行状态枚举
|
|
248
|
+
*/
|
|
249
|
+
declare const NODE_EXECUTION_STATUSES: readonly ['pending', 'running', 'completed', 'failed', 'skipped'];
|
|
250
|
+
/**
|
|
251
|
+
* 触发器类型枚举
|
|
252
|
+
*/
|
|
253
|
+
declare const TRIGGER_TYPES: readonly ['timer', 'webhook', 'event', 'feed.event'];
|
|
254
|
+
/**
|
|
255
|
+
* feed 事件名称枚举(W-2,Phase 2)
|
|
256
|
+
*
|
|
257
|
+
* 用于 feed.event 触发器订阅 feed 项目暴露的事件总线。
|
|
258
|
+
*/
|
|
259
|
+
declare const FEED_EVENT_NAMES: readonly [
|
|
260
|
+
/**
|
|
261
|
+
* 新条目入库事件
|
|
262
|
+
*/
|
|
263
|
+
'item.ingested',
|
|
264
|
+
/**
|
|
265
|
+
* 信息源抓取完成事件
|
|
266
|
+
*/
|
|
267
|
+
'source.fetched',
|
|
268
|
+
/**
|
|
269
|
+
* 条目过滤事件
|
|
270
|
+
*/
|
|
271
|
+
'item.filtered',
|
|
272
|
+
/**
|
|
273
|
+
* 行业识别事件
|
|
274
|
+
*/
|
|
275
|
+
'industry.detected'];
|
|
276
|
+
/**
|
|
277
|
+
* 告警类型枚举
|
|
278
|
+
*/
|
|
279
|
+
declare const ALERT_TYPES: readonly ['timeout', 'failure_rate', 'slow_execution'];
|
|
280
|
+
/**
|
|
281
|
+
* 工作流内置 action 类型枚举(W-3,Phase 2)
|
|
282
|
+
*
|
|
283
|
+
* - feed.applyTags:调用 feed F-2 applyTags 为条目打标签
|
|
284
|
+
* - feed.summarize:调用 feed F-3 summarize 生成摘要
|
|
285
|
+
* - llm.complete:调用 agent LlmCompletePort 完成文本
|
|
286
|
+
* - webhook.send:调用 webhook 项目发送 webhook
|
|
287
|
+
*
|
|
288
|
+
* D-08 决策:不暴露 DSL 编辑 UI,action 通过自然语言编译的 DSL 执行。
|
|
289
|
+
*/
|
|
290
|
+
declare const ACTION_TYPES: readonly ['feed.applyTags', 'feed.summarize', 'llm.complete', 'webhook.send'];
|
|
291
|
+
/**
|
|
292
|
+
* 监控指标类型枚举
|
|
293
|
+
*/
|
|
294
|
+
declare const METRIC_TYPES: readonly ['avg_duration', 'success_rate', 'failure_rate', 'timeout_rate', 'instance_count'];
|
|
295
|
+
/**
|
|
296
|
+
* 分页查询默认每页条数
|
|
297
|
+
*/
|
|
298
|
+
declare const DEFAULT_PAGE_SIZE = 20;
|
|
299
|
+
/**
|
|
300
|
+
* 分页查询每页最大条数上限
|
|
301
|
+
*/
|
|
302
|
+
declare const MAX_PAGE_SIZE = 100;
|
|
303
|
+
//#endregion
|
|
304
|
+
//#region src/utils/declaration-frontmatter.utils.d.ts
|
|
305
|
+
/**
|
|
306
|
+
* 声明档 frontmatter 解析(极简 YAML 方言 + 字符串数组扩展;自足实现零外部依赖)
|
|
307
|
+
*
|
|
308
|
+
* 方言与 data-engine stringifyFrontmatter 同源:顶层标量 + 字符串数组
|
|
309
|
+
* (`key:` 后随 ` - item` 行);数组/嵌套之外的结构不在声明档契约内。
|
|
310
|
+
*/
|
|
311
|
+
/**
|
|
312
|
+
* 声明档解析结果(frontmatter 标量与字符串数组 + 正文)
|
|
313
|
+
*/
|
|
314
|
+
type ParsedDeclaration = {
|
|
315
|
+
/**
|
|
316
|
+
* 顶层标量键值
|
|
317
|
+
*/
|
|
318
|
+
readonly head: Record<string, string>;
|
|
319
|
+
/**
|
|
320
|
+
* 字符串数组键值(空数组键不出现)
|
|
321
|
+
*/
|
|
322
|
+
readonly arrays: Record<string, readonly string[]>;
|
|
323
|
+
/**
|
|
324
|
+
* 正文(frontmatter 结束标记之后全文)
|
|
325
|
+
*/
|
|
326
|
+
readonly body: string;
|
|
327
|
+
};
|
|
328
|
+
/**
|
|
329
|
+
* 解析声明档(frontmatter 标量 + 字符串数组;非法行跳过)
|
|
330
|
+
*
|
|
331
|
+
* @param documentText - 文档全文
|
|
332
|
+
* @returns 解析结果(无 frontmatter 时 head/arrays 为空对象、body 为全文)
|
|
333
|
+
*/
|
|
334
|
+
declare function parseDeclaration(documentText: string): ParsedDeclaration;
|
|
335
|
+
//#endregion
|
|
336
|
+
//#region src/utils/dag.utils.d.ts
|
|
337
|
+
/**
|
|
338
|
+
* DAG 机件(环检测 + 拓扑分层 + 依赖满足判定)
|
|
339
|
+
*
|
|
340
|
+
* 共享基础(设计对齐 scheduler workflow 域已验证机件;真源归本包,禁止再镜像)。
|
|
341
|
+
*/
|
|
342
|
+
/**
|
|
343
|
+
* 依赖边(from 完成后 to 可启)
|
|
344
|
+
*/
|
|
345
|
+
type DependencyEdge = {
|
|
346
|
+
readonly from: string;
|
|
347
|
+
readonly to: string;
|
|
348
|
+
};
|
|
349
|
+
/**
|
|
350
|
+
* 环检测(DFS 三色标记;返回首个环路径,无环为 null)
|
|
351
|
+
*
|
|
352
|
+
* @param edges - 依赖边集合
|
|
353
|
+
*/
|
|
354
|
+
declare function detectCycle(edges: readonly DependencyEdge[]): readonly string[] | null;
|
|
355
|
+
/**
|
|
356
|
+
* 依赖满足判定(全部前置达完成/验收才算满足;无前置视为满足)
|
|
357
|
+
*
|
|
358
|
+
* @param node - 目标工作项 id
|
|
359
|
+
* @param edges - 依赖边集合
|
|
360
|
+
* @param settled - 已闭环(完成/验收)的工作项集合
|
|
361
|
+
*/
|
|
362
|
+
declare function dependenciesMet(node: string, edges: readonly DependencyEdge[], settled: ReadonlySet<string>): boolean;
|
|
363
|
+
//#endregion
|
|
364
|
+
//#region src/utils/work-item-rules.utils.d.ts
|
|
365
|
+
/**
|
|
366
|
+
* 工作项合法状态转移表(状态机唯一注册点;供编辑工具与判定器共用的规则真源)
|
|
367
|
+
*/
|
|
368
|
+
declare const ALLOWED_STATUS_TRANSITIONS: Readonly<Record<WorkItemStatus, readonly WorkItemStatus[]>>;
|
|
369
|
+
/**
|
|
370
|
+
* 非法转移错误形态
|
|
371
|
+
*/
|
|
372
|
+
type InvalidTransitionError = {
|
|
373
|
+
/**
|
|
374
|
+
* 错误码
|
|
375
|
+
*/
|
|
376
|
+
readonly code: 'INVALID_TRANSITION';
|
|
377
|
+
/**
|
|
378
|
+
* 人读信息(含合法后继清单)
|
|
379
|
+
*/
|
|
380
|
+
readonly message: string;
|
|
381
|
+
};
|
|
382
|
+
/**
|
|
383
|
+
* 判定状态转移合法性(注册表执法)
|
|
384
|
+
*
|
|
385
|
+
* @param from - 当前状态
|
|
386
|
+
* @param to - 目标状态
|
|
387
|
+
* @returns 合法时为 null;非法时携带合法后继清单
|
|
388
|
+
*/
|
|
389
|
+
declare function checkStatusTransition(from: WorkItemStatus, to: WorkItemStatus): InvalidTransitionError | null;
|
|
390
|
+
/**
|
|
391
|
+
* 工作项视图(快照派生:依赖满足与可启动判定)
|
|
392
|
+
*/
|
|
393
|
+
type WorkItemView = {
|
|
394
|
+
/**
|
|
395
|
+
* 工作项 id
|
|
396
|
+
*/
|
|
397
|
+
readonly id: string;
|
|
398
|
+
/**
|
|
399
|
+
* 执行状态(声明档现状)
|
|
400
|
+
*/
|
|
401
|
+
readonly status: WorkItemStatus;
|
|
402
|
+
/**
|
|
403
|
+
* 依赖是否满足(全部前置达 done/dropped)
|
|
404
|
+
*/
|
|
405
|
+
readonly depsMet: boolean;
|
|
406
|
+
/**
|
|
407
|
+
* 派生标注:todo 且依赖未满足
|
|
408
|
+
*/
|
|
409
|
+
readonly blockedOnPrerequisite: boolean;
|
|
410
|
+
/**
|
|
411
|
+
* 现在是否可启动(todo + 依赖满足 + 挂靠门已批准或无门)
|
|
412
|
+
*/
|
|
413
|
+
readonly canStart: boolean;
|
|
414
|
+
};
|
|
415
|
+
/**
|
|
416
|
+
* 未决裁定视图项
|
|
417
|
+
*/
|
|
418
|
+
type PendingRulingView = {
|
|
419
|
+
/**
|
|
420
|
+
* 门键(at:kind)
|
|
421
|
+
*/
|
|
422
|
+
readonly key: string;
|
|
423
|
+
/**
|
|
424
|
+
* 挂靠位置
|
|
425
|
+
*/
|
|
426
|
+
readonly at: string;
|
|
427
|
+
/**
|
|
428
|
+
* 门类型
|
|
429
|
+
*/
|
|
430
|
+
readonly kind: string;
|
|
431
|
+
/**
|
|
432
|
+
* 说明
|
|
433
|
+
*/
|
|
434
|
+
readonly note: string;
|
|
435
|
+
/**
|
|
436
|
+
* 裁定状态(pending 未裁 / escalated 升级待裁)
|
|
437
|
+
*/
|
|
438
|
+
readonly rulingStatus: 'pending' | 'escalated';
|
|
439
|
+
};
|
|
440
|
+
/**
|
|
441
|
+
* 工作流声明视图(判定器输出:全部工作项视图 + 未决裁定清单)
|
|
442
|
+
*/
|
|
443
|
+
type WorkflowView = {
|
|
444
|
+
/**
|
|
445
|
+
* 工作项视图清单(按声明序)
|
|
446
|
+
*/
|
|
447
|
+
readonly items: readonly WorkItemView[];
|
|
448
|
+
/**
|
|
449
|
+
* 未决裁定清单(pending 与 escalated)
|
|
450
|
+
*/
|
|
451
|
+
readonly pendingRulings: readonly PendingRulingView[];
|
|
452
|
+
};
|
|
453
|
+
/**
|
|
454
|
+
* 派生工作流声明视图(纯函数:声明现状 → 可启动/阻塞/未决裁定视图)
|
|
455
|
+
*
|
|
456
|
+
* @param items - 工作项清单(声明档现状)
|
|
457
|
+
* @param edges - 依赖边清单
|
|
458
|
+
* @param gates - 裁定门清单(含裁定事实)
|
|
459
|
+
*/
|
|
460
|
+
declare function deriveWorkflowView(items: readonly WorkflowItem[], edges: readonly WorkflowEdge[], gates: readonly WorkflowGate[]): WorkflowView;
|
|
461
|
+
//#endregion
|
|
462
|
+
//#region src/utils/index.d.ts
|
|
463
|
+
declare function getPagination(page?: number, pageSize?: number): {
|
|
464
|
+
offset: number;
|
|
465
|
+
limit: number;
|
|
466
|
+
};
|
|
467
|
+
declare function getTotalPages(total: number, pageSize: number): number;
|
|
468
|
+
declare function formatDate(date: string | Date): string;
|
|
469
|
+
//#endregion
|
|
470
|
+
//#region src/ports/feed-event.port.d.ts
|
|
471
|
+
/**
|
|
472
|
+
* feed 事件订阅句柄
|
|
473
|
+
*
|
|
474
|
+
* 由 subscribe 方法返回,调用 unsubscribe 取消订阅。
|
|
475
|
+
*/
|
|
476
|
+
type FeedEventSubscription = {
|
|
477
|
+
/**
|
|
478
|
+
* 取消订阅,释放底层资源
|
|
479
|
+
*/
|
|
480
|
+
unsubscribe: () => Promise<void> | void;
|
|
481
|
+
};
|
|
482
|
+
/**
|
|
483
|
+
* feed 事件处理器
|
|
484
|
+
*
|
|
485
|
+
* 事件到达时被调用,接收事件 payload。
|
|
486
|
+
* 工作流引擎在此处理器中启动新的工作流实例并注入 payload 作为上下文输入。
|
|
487
|
+
*/
|
|
488
|
+
type FeedEventHandler = {
|
|
489
|
+
/**
|
|
490
|
+
* 事件处理回调
|
|
491
|
+
*
|
|
492
|
+
* @param payload - feed 事件 payload
|
|
493
|
+
*/
|
|
494
|
+
handle: (payload: FeedEventPayload) => Promise<void> | void;
|
|
495
|
+
};
|
|
496
|
+
/**
|
|
497
|
+
* feed 事件端口
|
|
498
|
+
*
|
|
499
|
+
* 工作流引擎通过此端口订阅 feed 事件总线,
|
|
500
|
+
* 当 feed 项目有新条目/抓取/过滤/行业识别事件时触发回调。
|
|
501
|
+
*
|
|
502
|
+
* 依赖 feed 项目 F-2 暴露事件端口实现。
|
|
503
|
+
*/
|
|
504
|
+
type FeedEventPort = {
|
|
505
|
+
/**
|
|
506
|
+
* 订阅指定 feed 事件
|
|
507
|
+
*
|
|
508
|
+
* @param eventName - 订阅的事件名称
|
|
509
|
+
* @param handler - 事件处理器
|
|
510
|
+
* @param filter - 可选事件过滤条件
|
|
511
|
+
* @returns 订阅句柄,用于取消订阅
|
|
512
|
+
*/
|
|
513
|
+
subscribe: (eventName: FeedEventName, handler: FeedEventHandler, filter?: FeedEventFilter) => Promise<FeedEventSubscription>;
|
|
514
|
+
/**
|
|
515
|
+
* 检查 feed 事件端口是否可用
|
|
516
|
+
*
|
|
517
|
+
* @returns 端口是否可用
|
|
518
|
+
*/
|
|
519
|
+
isAvailable: () => Promise<boolean>;
|
|
520
|
+
};
|
|
521
|
+
/**
|
|
522
|
+
* feed 事件端口 DI 令牌
|
|
523
|
+
*/
|
|
524
|
+
declare const FEED_EVENT_PORT_TOKEN: unique symbol;
|
|
525
|
+
//#endregion
|
|
526
|
+
//#region src/ports/action-executor.port.d.ts
|
|
527
|
+
/**
|
|
528
|
+
* 单个 action handler 函数签名
|
|
529
|
+
*
|
|
530
|
+
* 注册到 ActionExecutorPort 中,按 action.type 路由调用。
|
|
531
|
+
*
|
|
532
|
+
* @param action - 待执行的 action(具体子类型由注册时的 actionType 决定)
|
|
533
|
+
* @param context - action 执行上下文
|
|
534
|
+
* @returns 执行结果
|
|
535
|
+
*/
|
|
536
|
+
type ActionHandler = (action: Action, context: ActionContext) => Promise<ActionResult>;
|
|
537
|
+
/**
|
|
538
|
+
* action 执行器端口
|
|
539
|
+
*
|
|
540
|
+
* 工作流引擎通过此端口调度内置 action。
|
|
541
|
+
* execution 子插件在初始化时注册各 actionType 的 handler,
|
|
542
|
+
* 工作流执行到 action 节点时调用 execute 方法。
|
|
543
|
+
*/
|
|
544
|
+
type ActionExecutorPort = {
|
|
545
|
+
/**
|
|
546
|
+
* 执行指定 action
|
|
547
|
+
*
|
|
548
|
+
* 根据 action.type 路由到注册的 handler 执行。
|
|
549
|
+
* 未注册的 actionType 返回失败结果。
|
|
550
|
+
*
|
|
551
|
+
* @param action - 待执行的 action
|
|
552
|
+
* @param context - action 执行上下文
|
|
553
|
+
* @returns 执行结果
|
|
554
|
+
*/
|
|
555
|
+
execute: (action: Action, context: ActionContext) => Promise<ActionResult>;
|
|
556
|
+
/**
|
|
557
|
+
* 注册 action handler
|
|
558
|
+
*
|
|
559
|
+
* 为指定 actionType 注册 handler,重复注册将覆盖旧 handler。
|
|
560
|
+
*
|
|
561
|
+
* @param actionType - action 类型
|
|
562
|
+
* @param handler - action 处理器
|
|
563
|
+
*/
|
|
564
|
+
registerHandler: (actionType: ActionType, handler: ActionHandler) => void;
|
|
565
|
+
/**
|
|
566
|
+
* 检查 action 执行器是否可用
|
|
567
|
+
*
|
|
568
|
+
* @returns 端口是否可用
|
|
569
|
+
*/
|
|
570
|
+
isAvailable: () => Promise<boolean>;
|
|
571
|
+
};
|
|
572
|
+
/**
|
|
573
|
+
* action 执行器端口 DI 令牌
|
|
574
|
+
*/
|
|
575
|
+
declare const ACTION_EXECUTOR_PORT_TOKEN: unique symbol;
|
|
576
|
+
//#endregion
|
|
577
|
+
export { ACTION_EXECUTOR_PORT_TOKEN, ACTION_TYPES, ALERT_TYPES, ALLOWED_STATUS_TRANSITIONS, Action, ActionContext, ActionExecutorPort, ActionHandler, ActionResult, ActionType, AlertDTO, AlertTypeDTO, AuditLogDTO, CreateDefinitionInput, CreateInstanceInput, CreateTriggerInput, DEFAULT_PAGE_SIZE, DefinitionDTO, DependencyEdge, FEED_EVENT_NAMES, FEED_EVENT_PORT_TOKEN, FeedApplyTagsAction, FeedEventFilter, FeedEventHandler, FeedEventName, FeedEventPayload, FeedEventPort, FeedEventSubscription, FeedEventTrigger, FeedSummarizeAction, GateRuling, INSTANCE_STATUSES, InstanceDTO, InstanceQueryParams, InstanceStatusDTO, InvalidTransitionError, LlmCompleteAction, MAX_PAGE_SIZE, METRIC_TYPES, MetricTypeDTO, MonitoringDashboardDTO, NODE_EXECUTION_STATUSES, NODE_TYPES, NodeExecutionDTO, NodeExecutionStatusDTO, ParsedDeclaration, PendingRulingView, PerformanceMetricDTO, StateTransitionDTO, TRIGGER_TYPES, TrendPointDTO, TriggerDTO, TriggerTypeDTO, UpdateDefinitionInput, UpdateTriggerInput, WORKFLOW_REF_PATTERN, WORK_ITEM_STATUSES, WebhookSendAction, WorkItemStatus, WorkItemView, WorkflowDocFrontmatter, WorkflowDocFrontmatterSchema, WorkflowEdge, WorkflowEdgeDTO, WorkflowGate, WorkflowItem, WorkflowNodeDTO, WorkflowView, actionContextSchema, actionResultSchema, actionSchema, actionTypeSchema, alertDtoSchema, alertTypeDtoSchema, auditLogDtoSchema, checkStatusTransition, createDefinitionInputSchema, createInstanceInputSchema, createTriggerInputSchema, definitionDtoSchema, dependenciesMet, deriveWorkflowView, detectCycle, feedApplyTagsActionSchema, feedEventFilterSchema, feedEventNameSchema, feedEventPayloadSchema, feedEventTriggerSchema, feedSummarizeActionSchema, formatDate, getPagination, getTotalPages, instanceDtoSchema, instanceQueryParamsSchema, instanceStatusDtoSchema, llmCompleteActionSchema, metricTypeDtoSchema, monitoringDashboardDtoSchema, nodeExecutionDtoSchema, nodeExecutionStatusDtoSchema, parseDeclaration, parseEdgeLine, parseGateLine, parseGateRuling, parseItemLine, performanceMetricDtoSchema, stateTransitionDtoSchema, trendPointDtoSchema, triggerDtoSchema, triggerTypeDtoSchema, updateDefinitionInputSchema, updateTriggerInputSchema, webhookSendActionSchema, workflowEdgeDtoSchema, workflowNodeDtoSchema };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import{A as e,B as t,C as n,D as r,E as i,F as a,G as o,H as s,I as ee,J as te,K as c,L as l,M as u,N as d,O as f,P as p,Q as m,R as h,S as g,T as _,U as v,V as y,W as b,X as x,Y as S,Z as C,_ as w,a as T,b as E,c as D,d as O,f as k,g as A,h as j,i as M,j as N,k as P,l as F,m as ne,n as I,o as L,p as R,q as z,r as B,s as V,t as H,u as U,v as W,w as G,x as K,y as q,z as J}from"./schemas-D0Zuq8_5.js";function Y(e){return e.length>=2&&e.startsWith(`"`)&&e.endsWith(`"`)?e.slice(1,-1):e}function X(e){if(!e.startsWith(`---
|
|
2
|
+
`))return e;let t=e.indexOf(`
|
|
3
|
+
---
|
|
4
|
+
`,4);return t===-1?e:e.slice(t+5)}function Z(e){let t={},n={},r=X(e);if(!e.startsWith(`---
|
|
5
|
+
`))return{head:t,arrays:n,body:r};let i=e.indexOf(`
|
|
6
|
+
---
|
|
7
|
+
`,4);if(i===-1)return{head:t,arrays:n,body:r};let a=e.slice(4,i).split(`
|
|
8
|
+
`),o=null;for(let e of a){if(e.startsWith(` - `)&&o!==null){let t=Y(e.slice(4).trim());n[o]=[...n[o]??[],t];continue}if(o=null,e.endsWith(`: []`)){o=e.slice(0,-4),n[o]=[];continue}if(e.endsWith(`:`)){o=e.slice(0,-1),n[o]=[];continue}let r=e.indexOf(`: `);r>0&&!e.startsWith(` `)&&(t[e.slice(0,r)]=Y(e.slice(r+2)))}return{head:t,arrays:n,body:r}}function re(e){let t=new Map;for(let n of e)t.set(n.from,[...t.get(n.from)??[],n.to]);let n=new Map,r=[],i=e=>{let a=n.get(e)??0;if(a===1){let t=r.indexOf(e);return[...r.slice(t),e]}if(a===2)return null;n.set(e,1),r.push(e);for(let n of t.get(e)??[]){let e=i(n);if(e!==null)return e}return r.pop(),n.set(e,2),null},a=[...new Set(e.flatMap(e=>[e.from,e.to]))].sort((e,t)=>e<t?-1:1);for(let e of a){let t=i(e);if(t!==null)return t}return null}function ie(e,t,n){return t.filter(t=>t.to===e).every(e=>n.has(e.from))}const Q={todo:[`doing`,`blocked`,`dropped`],doing:[`blocked`,`done`,`dropped`],blocked:[`todo`,`doing`,`dropped`],done:[`todo`,`dropped`],dropped:[`todo`]};function ae(e,t){let n=Q[e];return n===void 0?{code:`INVALID_TRANSITION`,message:`未知状态:${e}`}:n.includes(t)?null:{code:`INVALID_TRANSITION`,message:`非法转移:${e} → ${t}(合法后继:${n.join(` / `)})`}}function oe(e){return e===`done`||e===`dropped`}function $(e,t,n){let r=new Set(e.filter(e=>oe(e.status)).map(e=>e.id)),i=new Set(n.filter(e=>e.ruling.status!==`approved`&&e.at!==`workflow`).map(e=>e.at));return{items:e.map(e=>{let n=t.filter(t=>t.to===e.id).every(e=>r.has(e.from));return{id:e.id,status:e.status,depsMet:n,blockedOnPrerequisite:e.status===`todo`&&!n,canStart:e.status===`todo`&&n&&!i.has(e.id)}}),pendingRulings:n.filter(e=>e.ruling.status===`pending`||e.ruling.status===`escalated`).map(e=>({key:`${e.at}:${e.kind}`,at:e.at,kind:e.kind,note:e.note,rulingStatus:e.ruling.status}))}}function se(e,t){let n=Math.min(t??20,100);return{offset:(Math.max(e??1,1)-1)*n,limit:n}}function ce(e,t){return Math.ceil(e/t)}function le(e){return new Date(e).toISOString()}const ue=Symbol(`FEED_EVENT_PORT_TOKEN`),de=Symbol(`ACTION_EXECUTOR_PORT_TOKEN`);export{de as ACTION_EXECUTOR_PORT_TOKEN,v as ACTION_TYPES,b as ALERT_TYPES,Q as ALLOWED_STATUS_TRANSITIONS,o as DEFAULT_PAGE_SIZE,c as FEED_EVENT_NAMES,ue as FEED_EVENT_PORT_TOKEN,z as INSTANCE_STATUSES,te as MAX_PAGE_SIZE,S as METRIC_TYPES,x as NODE_EXECUTION_STATUSES,C as NODE_TYPES,m as TRIGGER_TYPES,e as WORKFLOW_REF_PATTERN,N as WORK_ITEM_STATUSES,u as WorkflowDocFrontmatterSchema,H as actionContextSchema,I as actionResultSchema,B as actionSchema,M as actionTypeSchema,R as alertDtoSchema,ne as alertTypeDtoSchema,j as auditLogDtoSchema,ae as checkStatusTransition,l as createDefinitionInputSchema,G as createInstanceInputSchema,E as createTriggerInputSchema,h as definitionDtoSchema,ie as dependenciesMet,$ as deriveWorkflowView,re as detectCycle,T as feedApplyTagsActionSchema,F as feedEventFilterSchema,U as feedEventNameSchema,O as feedEventPayloadSchema,k as feedEventTriggerSchema,L as feedSummarizeActionSchema,le as formatDate,se as getPagination,ce as getTotalPages,_ as instanceDtoSchema,i as instanceQueryParamsSchema,r as instanceStatusDtoSchema,V as llmCompleteActionSchema,A as metricTypeDtoSchema,w as monitoringDashboardDtoSchema,f as nodeExecutionDtoSchema,P as nodeExecutionStatusDtoSchema,Z as parseDeclaration,d as parseEdgeLine,p as parseGateLine,a as parseGateRuling,ee as parseItemLine,W as performanceMetricDtoSchema,J as stateTransitionDtoSchema,q as trendPointDtoSchema,K as triggerDtoSchema,g as triggerTypeDtoSchema,t as updateDefinitionInputSchema,n as updateTriggerInputSchema,D as webhookSendActionSchema,y as workflowEdgeDtoSchema,s as workflowNodeDtoSchema};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import*as e from"zod";import{z as t}from"zod";const n=[`StartEvent`,`EndEvent`,`UserTask`,`ServiceTask`,`ExclusiveGateway`,`ParallelGateway`,`InclusiveGateway`,`SubProcess`,`TimerEvent`,`ErrorEvent`,`SignalEvent`],r=[`pending`,`running`,`paused`,`completed`,`cancelled`,`failed`],i=[`pending`,`running`,`completed`,`failed`,`skipped`],a=[`timer`,`webhook`,`event`,`feed.event`],o=[`item.ingested`,`source.fetched`,`item.filtered`,`industry.detected`],s=[`timeout`,`failure_rate`,`slow_execution`],c=[`feed.applyTags`,`feed.summarize`,`llm.complete`,`webhook.send`],l=[`avg_duration`,`success_rate`,`failure_rate`,`timeout_rate`,`instance_count`],u=20,d=100,f=t.object({nodeId:t.string(),name:t.string(),type:t.enum(n),properties:t.record(t.string(),t.unknown()),position:t.object({x:t.number(),y:t.number()})}),p=t.object({edgeId:t.string(),sourceNodeId:t.string(),targetNodeId:t.string(),condition:t.string().optional(),label:t.string().optional()}),m=t.object({from:t.string(),to:t.string(),event:t.string(),guard:t.string().optional(),action:t.string().optional()}),h=t.object({name:t.string(),description:t.string().optional(),nodes:t.array(f),edges:t.array(p),initialState:t.string(),states:t.array(t.string()),transitions:t.array(m)}),g=h.partial(),ee=t.object({id:t.string(),name:t.string(),description:t.string().nullable(),version:t.number(),nodes:t.array(f),edges:t.array(p),initialState:t.string(),states:t.array(t.string()),publishedAt:t.string().nullable(),createdAt:t.string(),updatedAt:t.string()}),_=[`todo`,`doing`,`blocked`,`done`,`dropped`],v=/^[a-z0-9]+(?:-[a-z0-9]+)*$/,y=RegExp(`^([a-z0-9]+(?:-[a-z0-9]+)*) \\| (.+) \\| (task:[a-z0-9][a-z0-9-]*\\/[a-z0-9\\/-]+|ref:[a-z0-9][a-z0-9-]*\\/[a-z0-9\\/. _-]+) \\| (todo|doing|blocked|done|dropped)$`),b=/^(pending)$|^(approved|rejected|escalated):([^:|]+)(?::([^:|]+))?$/,x=/^([a-z0-9]+(?:-[a-z0-9]+)*|workflow) \| ([a-z0-9-]+) \| ([^|]+?) \| (pending|(?:(?:approved|rejected|escalated):[^:|]+(?::[^:|]+)?))$/,S=/^([a-z0-9]+(?:-[a-z0-9]+)*) -> ([a-z0-9]+(?:-[a-z0-9]+)*)$/,C=e.strictObject({id:e.string().regex(v),title:e.string().min(1),status:e.enum([`draft`,`active`,`completed`,`archived`]),items:e.array(e.string()),edges:e.array(e.string().regex(S)).optional(),gates:e.array(e.string()).optional()});function w(t){let n=y.exec(t);if(!n)return null;let r=n[1],i=n[2],a=n[3],o=n[4];if(r===void 0||i===void 0||a===void 0||o===void 0)return null;let s=e.enum(_).safeParse(o);return s.success?{id:r,title:i,ref:a,status:s.data}:null}function T(e){let t=S.exec(e);if(!t)return null;let n=t[1],r=t[2];return n===void 0||r===void 0?null:{from:n,to:r}}function E(t){let n=b.exec(t);if(!n)return null;let r=n[1]??n[2];if(r===void 0)return null;let i=e.enum([`pending`,`approved`,`rejected`,`escalated`]).safeParse(r);if(!i.success)return null;let a=n[3],o=n[4];return{status:i.data,...a===void 0?{}:{decidedBy:a},...o===void 0?{}:{evidence:o}}}function D(e){let t=x.exec(e);if(!t)return null;let n=t[1],r=t[2],i=t[3],a=t[4];if(n===void 0||r===void 0||i===void 0||a===void 0)return null;let o=E(a);return o===null?null:{at:n,kind:r,note:i,ruling:o}}const te=/^workflow:(global|[a-z0-9][a-z0-9-]*)\/([a-z0-9]+(?:-[a-z0-9]+)*)$/,O=t.enum(r),k=t.enum(i),A=t.object({id:t.string(),instanceId:t.string(),nodeId:t.string(),nodeName:t.string(),nodeType:t.string(),status:k,startedAt:t.string().nullable(),completedAt:t.string().nullable(),error:t.string().nullable(),createdAt:t.string()}),j=t.object({id:t.string(),definitionId:t.string(),definitionVersion:t.number(),status:O,currentState:t.string(),previousState:t.string().nullable(),currentNodeId:t.string().nullable(),variables:t.record(t.string(),t.unknown()),startedAt:t.string().nullable(),completedAt:t.string().nullable(),createdAt:t.string(),updatedAt:t.string()}),M=t.object({definitionId:t.string(),input:t.record(t.string(),t.unknown()).optional()}),N=t.object({status:O.optional(),definitionId:t.string().optional(),page:t.number().optional(),pageSize:t.number().optional()}),P=t.enum(a),F=t.object({id:t.string(),definitionId:t.string(),name:t.string(),type:P,config:t.record(t.string(),t.unknown()),enabled:t.boolean(),lastTriggeredAt:t.string().nullable(),createdAt:t.string(),updatedAt:t.string()}),I=t.object({definitionId:t.string(),name:t.string(),type:P,config:t.record(t.string(),t.unknown())}),L=I.partial(),R=t.enum(s),z=t.enum(l),B=t.object({id:t.string(),instanceId:t.string(),nodeId:t.string().nullable(),action:t.string(),fromStatus:t.string().nullable(),toStatus:t.string(),operator:t.string().nullable(),detail:t.record(t.string(),t.unknown()),createdAt:t.string()}),V=t.object({id:t.string(),definitionId:t.string(),type:R,threshold:t.number(),notifyConfig:t.record(t.string(),t.unknown()),enabled:t.boolean(),lastTriggeredAt:t.string().nullable(),createdAt:t.string(),updatedAt:t.string()}),H=t.object({id:t.string(),definitionId:t.string(),metricType:z,value:t.number(),period:t.string(),calculatedAt:t.string()}),U=t.object({date:t.string(),value:t.number()}),W=t.object({runningInstances:t.number(),successRate:t.number(),avgDuration:t.number(),failureAlerts:t.number(),trend:t.array(U)}),G=t.enum(o),K=t.object({sourceId:t.string().optional(),subscriptionId:t.string().optional(),industry:t.string().optional(),tags:t.array(t.string()).optional()}).optional(),q=t.object({type:t.literal(`feed.event`),eventName:G,filter:K}),J=t.object({eventName:G,itemId:t.string().optional(),sourceId:t.string().optional(),data:t.record(t.string(),t.unknown())}),Y=t.enum(c),X=t.object({type:t.literal(`feed.applyTags`),itemId:t.string(),tags:t.array(t.string()),source:t.enum([`manual`,`rule`,`workflow`]).optional()}),Z=t.object({type:t.literal(`feed.summarize`),itemId:t.string(),level:t.enum([`micro`,`short`,`structured`])}),Q=t.object({type:t.literal(`llm.complete`),prompt:t.string(),systemPrompt:t.string().optional(),maxTokens:t.number().optional(),temperature:t.number().min(0).max(1).optional()}),$=t.object({type:t.literal(`webhook.send`),url:t.string(),method:t.enum([`GET`,`POST`,`PUT`,`PATCH`,`DELETE`]).optional(),headers:t.record(t.string(),t.string()).optional(),body:t.unknown().optional()}),ne=t.discriminatedUnion(`type`,[X,Z,Q,$]),re=t.object({instanceId:t.string(),definitionId:t.string(),nodeId:t.string(),variables:t.record(t.string(),t.unknown()),input:t.unknown()}),ie=t.object({success:t.boolean(),data:t.unknown().optional(),error:t.string().optional()});export{te as A,g as B,L as C,O as D,N as E,E as F,u as G,f as H,w as I,d as J,o as K,h as L,C as M,T as N,A as O,D as P,a as Q,ee as R,P as S,j as T,c as U,p as V,s as W,i as X,l as Y,n as Z,W as _,X as a,I as b,$ as c,J as d,q as f,z as g,B as h,Y as i,_ as j,k,K as l,R as m,ie as n,Z as o,V as p,r as q,ne as r,Q as s,re as t,G as u,H as v,M as w,F as x,U as y,m as z};
|