@flowgram.ai/runtime-interface 0.1.0-alpha.10
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/dist/esm/index.js +286 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/index.d.mts +794 -0
- package/dist/index.d.ts +794 -0
- package/dist/index.js +341 -0
- package/dist/index.js.map +1 -0
- package/package.json +44 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,794 @@
|
|
|
1
|
+
import z from 'zod';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
5
|
+
* SPDX-License-Identifier: MIT
|
|
6
|
+
*/
|
|
7
|
+
declare enum FlowGramAPIMethod {
|
|
8
|
+
GET = "GET",
|
|
9
|
+
POST = "POST",
|
|
10
|
+
PUT = "PUT",
|
|
11
|
+
DELETE = "DELETE",
|
|
12
|
+
PATCH = "PATCH"
|
|
13
|
+
}
|
|
14
|
+
declare enum FlowGramAPIName {
|
|
15
|
+
ServerInfo = "ServerInfo",
|
|
16
|
+
TaskRun = "TaskRun",
|
|
17
|
+
TaskReport = "TaskReport",
|
|
18
|
+
TaskResult = "TaskResult",
|
|
19
|
+
TaskCancel = "TaskCancel",
|
|
20
|
+
Validation = "Validation"
|
|
21
|
+
}
|
|
22
|
+
declare enum FlowGramAPIModule {
|
|
23
|
+
Info = "Info",
|
|
24
|
+
Task = "Task",
|
|
25
|
+
Validation = "Validation"
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
30
|
+
* SPDX-License-Identifier: MIT
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
interface FlowGramAPIDefine {
|
|
34
|
+
name: FlowGramAPIName;
|
|
35
|
+
method: FlowGramAPIMethod;
|
|
36
|
+
path: `/${string}`;
|
|
37
|
+
module: FlowGramAPIModule;
|
|
38
|
+
schema: {
|
|
39
|
+
input: z.ZodFirstPartySchemaTypes;
|
|
40
|
+
output: z.ZodFirstPartySchemaTypes;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
interface FlowGramAPIDefines {
|
|
44
|
+
[key: string]: FlowGramAPIDefine;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
49
|
+
* SPDX-License-Identifier: MIT
|
|
50
|
+
*/
|
|
51
|
+
|
|
52
|
+
declare const FlowGramAPIs: FlowGramAPIDefines;
|
|
53
|
+
declare const FlowGramAPINames: FlowGramAPIName[];
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
57
|
+
* SPDX-License-Identifier: MIT
|
|
58
|
+
*/
|
|
59
|
+
type ContainerService = any;
|
|
60
|
+
interface IContainer {
|
|
61
|
+
get<T = ContainerService>(key: any): T;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
66
|
+
* SPDX-License-Identifier: MIT
|
|
67
|
+
*/
|
|
68
|
+
type VOData<T> = Omit<T, 'id'>;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
72
|
+
* SPDX-License-Identifier: MIT
|
|
73
|
+
*/
|
|
74
|
+
interface WorkflowEdgeSchema {
|
|
75
|
+
sourceNodeID: string;
|
|
76
|
+
targetNodeID: string;
|
|
77
|
+
sourcePortID?: string;
|
|
78
|
+
targetPortID?: string;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
83
|
+
* SPDX-License-Identifier: MIT
|
|
84
|
+
*/
|
|
85
|
+
type JsonSchemaBasicType = 'boolean' | 'string' | 'integer' | 'number' | 'object' | 'array' | 'map';
|
|
86
|
+
interface IJsonSchema<T = string> {
|
|
87
|
+
type: T;
|
|
88
|
+
default?: any;
|
|
89
|
+
title?: string;
|
|
90
|
+
description?: string;
|
|
91
|
+
enum?: (string | number)[];
|
|
92
|
+
properties?: Record<string, IJsonSchema<T>>;
|
|
93
|
+
additionalProperties?: IJsonSchema<T>;
|
|
94
|
+
items?: IJsonSchema<T>;
|
|
95
|
+
required?: string[];
|
|
96
|
+
$ref?: string;
|
|
97
|
+
extra?: {
|
|
98
|
+
index?: number;
|
|
99
|
+
weak?: boolean;
|
|
100
|
+
formComponent?: string;
|
|
101
|
+
[key: string]: any;
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
type IBasicJsonSchema = IJsonSchema<JsonSchemaBasicType>;
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
108
|
+
* SPDX-License-Identifier: MIT
|
|
109
|
+
*/
|
|
110
|
+
interface XYSchema {
|
|
111
|
+
x: number;
|
|
112
|
+
y: number;
|
|
113
|
+
}
|
|
114
|
+
type PositionSchema = XYSchema;
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
118
|
+
* SPDX-License-Identifier: MIT
|
|
119
|
+
*/
|
|
120
|
+
|
|
121
|
+
interface WorkflowNodeMetaSchema {
|
|
122
|
+
position: PositionSchema;
|
|
123
|
+
canvasPosition?: PositionSchema;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
128
|
+
* SPDX-License-Identifier: MIT
|
|
129
|
+
*/
|
|
130
|
+
interface IFlowConstantValue {
|
|
131
|
+
type: 'constant';
|
|
132
|
+
content?: string | number | boolean;
|
|
133
|
+
}
|
|
134
|
+
interface IFlowRefValue {
|
|
135
|
+
type: 'ref';
|
|
136
|
+
content?: string[];
|
|
137
|
+
}
|
|
138
|
+
interface IFlowExpressionValue {
|
|
139
|
+
type: 'expression';
|
|
140
|
+
content?: string;
|
|
141
|
+
}
|
|
142
|
+
interface IFlowTemplateValue {
|
|
143
|
+
type: 'template';
|
|
144
|
+
content?: string;
|
|
145
|
+
}
|
|
146
|
+
type IFlowValue = IFlowConstantValue | IFlowRefValue | IFlowExpressionValue | IFlowTemplateValue;
|
|
147
|
+
type IFlowConstantRefValue = IFlowConstantValue | IFlowRefValue;
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
151
|
+
* SPDX-License-Identifier: MIT
|
|
152
|
+
*/
|
|
153
|
+
|
|
154
|
+
interface WorkflowNodeSchema<T = string, D = any> {
|
|
155
|
+
id: string;
|
|
156
|
+
type: T;
|
|
157
|
+
meta: WorkflowNodeMetaSchema;
|
|
158
|
+
data: D & {
|
|
159
|
+
title?: string;
|
|
160
|
+
inputsValues?: Record<string, IFlowValue>;
|
|
161
|
+
inputs?: IJsonSchema;
|
|
162
|
+
outputs?: IJsonSchema;
|
|
163
|
+
[key: string]: any;
|
|
164
|
+
};
|
|
165
|
+
blocks?: WorkflowNodeSchema[];
|
|
166
|
+
edges?: WorkflowEdgeSchema[];
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
171
|
+
* SPDX-License-Identifier: MIT
|
|
172
|
+
*/
|
|
173
|
+
|
|
174
|
+
interface WorkflowSchema {
|
|
175
|
+
nodes: WorkflowNodeSchema[];
|
|
176
|
+
edges: WorkflowEdgeSchema[];
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
181
|
+
* SPDX-License-Identifier: MIT
|
|
182
|
+
*/
|
|
183
|
+
declare enum WorkflowPortType {
|
|
184
|
+
Input = "input",
|
|
185
|
+
Output = "output"
|
|
186
|
+
}
|
|
187
|
+
declare enum WorkflowVariableType {
|
|
188
|
+
String = "string",
|
|
189
|
+
Integer = "integer",
|
|
190
|
+
Number = "number",
|
|
191
|
+
Boolean = "boolean",
|
|
192
|
+
Object = "object",
|
|
193
|
+
Array = "array",
|
|
194
|
+
Null = "null"
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
199
|
+
* SPDX-License-Identifier: MIT
|
|
200
|
+
*/
|
|
201
|
+
type WorkflowInputs = Record<string, any>;
|
|
202
|
+
type WorkflowOutputs = Record<string, any>;
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
206
|
+
* SPDX-License-Identifier: MIT
|
|
207
|
+
*/
|
|
208
|
+
|
|
209
|
+
interface InvokeParams {
|
|
210
|
+
schema: WorkflowSchema;
|
|
211
|
+
inputs: WorkflowInputs;
|
|
212
|
+
}
|
|
213
|
+
type WorkflowRuntimeInvoke = (params: InvokeParams) => Promise<WorkflowInputs>;
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
217
|
+
* SPDX-License-Identifier: MIT
|
|
218
|
+
*/
|
|
219
|
+
|
|
220
|
+
interface VariableTypeInfo {
|
|
221
|
+
type: WorkflowVariableType;
|
|
222
|
+
itemsType?: WorkflowVariableType;
|
|
223
|
+
}
|
|
224
|
+
interface IVariable<T = Object> extends VariableTypeInfo {
|
|
225
|
+
id: string;
|
|
226
|
+
nodeID: string;
|
|
227
|
+
key: string;
|
|
228
|
+
value: T;
|
|
229
|
+
}
|
|
230
|
+
interface IVariableParseResult<T = unknown> extends VariableTypeInfo {
|
|
231
|
+
value: T;
|
|
232
|
+
type: WorkflowVariableType;
|
|
233
|
+
}
|
|
234
|
+
interface IVariableStore {
|
|
235
|
+
id: string;
|
|
236
|
+
store: Map<string, Map<string, IVariable>>;
|
|
237
|
+
setParent(parent: IVariableStore): void;
|
|
238
|
+
setVariable(params: {
|
|
239
|
+
nodeID: string;
|
|
240
|
+
key: string;
|
|
241
|
+
value: Object;
|
|
242
|
+
} & VariableTypeInfo): void;
|
|
243
|
+
setValue(params: {
|
|
244
|
+
nodeID: string;
|
|
245
|
+
variableKey: string;
|
|
246
|
+
variablePath?: string[];
|
|
247
|
+
value: Object;
|
|
248
|
+
}): void;
|
|
249
|
+
getValue<T = unknown>(params: {
|
|
250
|
+
nodeID: string;
|
|
251
|
+
variableKey: string;
|
|
252
|
+
variablePath?: string[];
|
|
253
|
+
}): IVariableParseResult<T> | null;
|
|
254
|
+
init(): void;
|
|
255
|
+
dispose(): void;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
260
|
+
* SPDX-License-Identifier: MIT
|
|
261
|
+
*/
|
|
262
|
+
declare enum WorkflowStatus {
|
|
263
|
+
Pending = "pending",
|
|
264
|
+
Processing = "processing",
|
|
265
|
+
Succeeded = "succeeded",
|
|
266
|
+
Failed = "failed",
|
|
267
|
+
Canceled = "canceled"
|
|
268
|
+
}
|
|
269
|
+
interface StatusData {
|
|
270
|
+
status: WorkflowStatus;
|
|
271
|
+
terminated: boolean;
|
|
272
|
+
startTime: number;
|
|
273
|
+
endTime?: number;
|
|
274
|
+
timeCost: number;
|
|
275
|
+
}
|
|
276
|
+
interface IStatus extends StatusData {
|
|
277
|
+
id: string;
|
|
278
|
+
process(): void;
|
|
279
|
+
success(): void;
|
|
280
|
+
fail(): void;
|
|
281
|
+
cancel(): void;
|
|
282
|
+
export(): StatusData;
|
|
283
|
+
}
|
|
284
|
+
interface IStatusCenter {
|
|
285
|
+
workflow: IStatus;
|
|
286
|
+
nodeStatus(nodeID: string): IStatus;
|
|
287
|
+
init(): void;
|
|
288
|
+
dispose(): void;
|
|
289
|
+
getStatusNodeIDs(status: WorkflowStatus): string[];
|
|
290
|
+
exportNodeStatus(): Record<string, StatusData>;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
295
|
+
* SPDX-License-Identifier: MIT
|
|
296
|
+
*/
|
|
297
|
+
|
|
298
|
+
interface SnapshotData {
|
|
299
|
+
nodeID: string;
|
|
300
|
+
inputs: WorkflowInputs;
|
|
301
|
+
outputs: WorkflowOutputs;
|
|
302
|
+
data: any;
|
|
303
|
+
branch?: string;
|
|
304
|
+
}
|
|
305
|
+
interface Snapshot extends SnapshotData {
|
|
306
|
+
id: string;
|
|
307
|
+
}
|
|
308
|
+
interface ISnapshot {
|
|
309
|
+
id: string;
|
|
310
|
+
data: Partial<SnapshotData>;
|
|
311
|
+
addData(data: Partial<SnapshotData>): void;
|
|
312
|
+
validate(): boolean;
|
|
313
|
+
export(): Snapshot;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
318
|
+
* SPDX-License-Identifier: MIT
|
|
319
|
+
*/
|
|
320
|
+
|
|
321
|
+
interface ISnapshotCenter {
|
|
322
|
+
id: string;
|
|
323
|
+
create(snapshot: Partial<SnapshotData>): ISnapshot;
|
|
324
|
+
exportAll(): Snapshot[];
|
|
325
|
+
export(): Record<string, Snapshot[]>;
|
|
326
|
+
init(): void;
|
|
327
|
+
dispose(): void;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
332
|
+
* SPDX-License-Identifier: MIT
|
|
333
|
+
*/
|
|
334
|
+
|
|
335
|
+
interface IOData {
|
|
336
|
+
inputs: WorkflowInputs;
|
|
337
|
+
outputs: WorkflowOutputs;
|
|
338
|
+
}
|
|
339
|
+
/** Input & Output */
|
|
340
|
+
interface IIOCenter {
|
|
341
|
+
inputs: WorkflowInputs;
|
|
342
|
+
outputs: WorkflowOutputs;
|
|
343
|
+
setInputs(inputs: WorkflowInputs): void;
|
|
344
|
+
setOutputs(outputs: WorkflowOutputs): void;
|
|
345
|
+
init(inputs: WorkflowInputs): void;
|
|
346
|
+
dispose(): void;
|
|
347
|
+
export(): IOData;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
352
|
+
* SPDX-License-Identifier: MIT
|
|
353
|
+
*/
|
|
354
|
+
declare enum FlowGramNode {
|
|
355
|
+
Root = "root",
|
|
356
|
+
Start = "start",
|
|
357
|
+
End = "end",
|
|
358
|
+
LLM = "llm",
|
|
359
|
+
code = "code",
|
|
360
|
+
Condition = "condition",
|
|
361
|
+
Loop = "loop",
|
|
362
|
+
Comment = "comment",
|
|
363
|
+
Group = "group",
|
|
364
|
+
BlockStart = "block-start",
|
|
365
|
+
BlockEnd = "block-end"
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
/**
|
|
369
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
370
|
+
* SPDX-License-Identifier: MIT
|
|
371
|
+
*/
|
|
372
|
+
|
|
373
|
+
interface IEdge {
|
|
374
|
+
id: string;
|
|
375
|
+
from: INode;
|
|
376
|
+
to: INode;
|
|
377
|
+
fromPort: IPort;
|
|
378
|
+
toPort: IPort;
|
|
379
|
+
}
|
|
380
|
+
interface CreateEdgeParams {
|
|
381
|
+
id: string;
|
|
382
|
+
from: INode;
|
|
383
|
+
to: INode;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
388
|
+
* SPDX-License-Identifier: MIT
|
|
389
|
+
*/
|
|
390
|
+
|
|
391
|
+
interface IPort {
|
|
392
|
+
id: string;
|
|
393
|
+
node: INode;
|
|
394
|
+
edges: IEdge[];
|
|
395
|
+
type: WorkflowPortType;
|
|
396
|
+
}
|
|
397
|
+
interface CreatePortParams {
|
|
398
|
+
id: string;
|
|
399
|
+
node: INode;
|
|
400
|
+
type: WorkflowPortType;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
/**
|
|
404
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
405
|
+
* SPDX-License-Identifier: MIT
|
|
406
|
+
*/
|
|
407
|
+
|
|
408
|
+
interface NodeDeclare {
|
|
409
|
+
inputsValues?: Record<string, IFlowValue>;
|
|
410
|
+
inputs?: IJsonSchema;
|
|
411
|
+
outputs?: IJsonSchema;
|
|
412
|
+
}
|
|
413
|
+
interface INode<T = any> {
|
|
414
|
+
id: string;
|
|
415
|
+
type: FlowGramNode;
|
|
416
|
+
name: string;
|
|
417
|
+
position: PositionSchema;
|
|
418
|
+
declare: NodeDeclare;
|
|
419
|
+
data: T;
|
|
420
|
+
ports: {
|
|
421
|
+
inputs: IPort[];
|
|
422
|
+
outputs: IPort[];
|
|
423
|
+
};
|
|
424
|
+
edges: {
|
|
425
|
+
inputs: IEdge[];
|
|
426
|
+
outputs: IEdge[];
|
|
427
|
+
};
|
|
428
|
+
parent: INode | null;
|
|
429
|
+
children: INode[];
|
|
430
|
+
prev: INode[];
|
|
431
|
+
next: INode[];
|
|
432
|
+
successors: INode[];
|
|
433
|
+
predecessors: INode[];
|
|
434
|
+
isBranch: boolean;
|
|
435
|
+
}
|
|
436
|
+
interface CreateNodeParams {
|
|
437
|
+
id: string;
|
|
438
|
+
type: FlowGramNode;
|
|
439
|
+
name: string;
|
|
440
|
+
position: PositionSchema;
|
|
441
|
+
variable?: NodeDeclare;
|
|
442
|
+
data?: any;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
/**
|
|
446
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
447
|
+
* SPDX-License-Identifier: MIT
|
|
448
|
+
*/
|
|
449
|
+
|
|
450
|
+
interface IDocument {
|
|
451
|
+
id: string;
|
|
452
|
+
nodes: INode[];
|
|
453
|
+
edges: IEdge[];
|
|
454
|
+
root: INode;
|
|
455
|
+
start: INode;
|
|
456
|
+
end: INode;
|
|
457
|
+
init(schema: WorkflowSchema): void;
|
|
458
|
+
dispose(): void;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
/**
|
|
462
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
463
|
+
* SPDX-License-Identifier: MIT
|
|
464
|
+
*/
|
|
465
|
+
|
|
466
|
+
interface IState {
|
|
467
|
+
id: string;
|
|
468
|
+
variableStore: IVariableStore;
|
|
469
|
+
init(): void;
|
|
470
|
+
dispose(): void;
|
|
471
|
+
getNodeInputs(node: INode): WorkflowInputs;
|
|
472
|
+
setNodeOutputs(params: {
|
|
473
|
+
node: INode;
|
|
474
|
+
outputs: WorkflowOutputs;
|
|
475
|
+
}): void;
|
|
476
|
+
parseRef<T = unknown>(ref: IFlowRefValue): IVariableParseResult<T> | null;
|
|
477
|
+
parseTemplate(template: IFlowTemplateValue): IVariableParseResult<string> | null;
|
|
478
|
+
parseValue<T = unknown>(flowValue: IFlowValue, type?: WorkflowVariableType): IVariableParseResult<T> | null;
|
|
479
|
+
isExecutedNode(node: INode): boolean;
|
|
480
|
+
addExecutedNode(node: INode): void;
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
/**
|
|
484
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
485
|
+
* SPDX-License-Identifier: MIT
|
|
486
|
+
*/
|
|
487
|
+
|
|
488
|
+
interface NodeReport extends StatusData {
|
|
489
|
+
id: string;
|
|
490
|
+
snapshots: Snapshot[];
|
|
491
|
+
}
|
|
492
|
+
interface IReport {
|
|
493
|
+
id: string;
|
|
494
|
+
inputs: WorkflowInputs;
|
|
495
|
+
outputs: WorkflowOutputs;
|
|
496
|
+
workflowStatus: StatusData;
|
|
497
|
+
reports: Record<string, NodeReport>;
|
|
498
|
+
}
|
|
499
|
+
interface IReporter {
|
|
500
|
+
snapshotCenter: ISnapshotCenter;
|
|
501
|
+
statusCenter: IStatusCenter;
|
|
502
|
+
init(): void;
|
|
503
|
+
dispose(): void;
|
|
504
|
+
export(): IReport;
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
/**
|
|
508
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
509
|
+
* SPDX-License-Identifier: MIT
|
|
510
|
+
*/
|
|
511
|
+
|
|
512
|
+
interface ContextData {
|
|
513
|
+
variableStore: IVariableStore;
|
|
514
|
+
state: IState;
|
|
515
|
+
document: IDocument;
|
|
516
|
+
ioCenter: IIOCenter;
|
|
517
|
+
snapshotCenter: ISnapshotCenter;
|
|
518
|
+
statusCenter: IStatusCenter;
|
|
519
|
+
reporter: IReporter;
|
|
520
|
+
}
|
|
521
|
+
interface IContext extends ContextData {
|
|
522
|
+
id: string;
|
|
523
|
+
init(params: InvokeParams): void;
|
|
524
|
+
dispose(): void;
|
|
525
|
+
sub(): IContext;
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
/**
|
|
529
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
530
|
+
* SPDX-License-Identifier: MIT
|
|
531
|
+
*/
|
|
532
|
+
|
|
533
|
+
interface ITask {
|
|
534
|
+
id: string;
|
|
535
|
+
processing: Promise<WorkflowOutputs>;
|
|
536
|
+
context: IContext;
|
|
537
|
+
cancel(): void;
|
|
538
|
+
}
|
|
539
|
+
interface TaskParams {
|
|
540
|
+
processing: Promise<WorkflowOutputs>;
|
|
541
|
+
context: IContext;
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
/**
|
|
545
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
546
|
+
* SPDX-License-Identifier: MIT
|
|
547
|
+
*/
|
|
548
|
+
|
|
549
|
+
interface EndNodeData {
|
|
550
|
+
title: string;
|
|
551
|
+
inputs: IJsonSchema<'object'>;
|
|
552
|
+
inputsValues: Record<string, IFlowConstantRefValue>;
|
|
553
|
+
}
|
|
554
|
+
type EndNodeSchema = WorkflowNodeSchema<FlowGramNode.End, EndNodeData>;
|
|
555
|
+
|
|
556
|
+
/**
|
|
557
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
558
|
+
* SPDX-License-Identifier: MIT
|
|
559
|
+
*/
|
|
560
|
+
|
|
561
|
+
interface LLMNodeData {
|
|
562
|
+
title: string;
|
|
563
|
+
inputs: IJsonSchema<'object'>;
|
|
564
|
+
outputs: IJsonSchema<'object'>;
|
|
565
|
+
inputValues: {
|
|
566
|
+
apiKey: IFlowConstantRefValue;
|
|
567
|
+
modelType: IFlowConstantRefValue;
|
|
568
|
+
baseURL: IFlowConstantRefValue;
|
|
569
|
+
temperature: IFlowConstantRefValue;
|
|
570
|
+
systemPrompt: IFlowConstantValue | IFlowTemplateValue;
|
|
571
|
+
prompt: IFlowConstantValue | IFlowTemplateValue;
|
|
572
|
+
};
|
|
573
|
+
}
|
|
574
|
+
type LLMNodeSchema = WorkflowNodeSchema<FlowGramNode.LLM, LLMNodeData>;
|
|
575
|
+
|
|
576
|
+
/**
|
|
577
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
578
|
+
* SPDX-License-Identifier: MIT
|
|
579
|
+
*/
|
|
580
|
+
|
|
581
|
+
interface StartNodeData {
|
|
582
|
+
title: string;
|
|
583
|
+
outputs: IJsonSchema<'object'>;
|
|
584
|
+
}
|
|
585
|
+
type StartNodeSchema = WorkflowNodeSchema<FlowGramNode.Start, StartNodeData>;
|
|
586
|
+
|
|
587
|
+
/**
|
|
588
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
589
|
+
* SPDX-License-Identifier: MIT
|
|
590
|
+
*/
|
|
591
|
+
|
|
592
|
+
interface LoopNodeData {
|
|
593
|
+
title: string;
|
|
594
|
+
loopFor: IFlowRefValue;
|
|
595
|
+
loopOutputs: Record<string, IFlowRefValue>;
|
|
596
|
+
}
|
|
597
|
+
type LoopNodeSchema = WorkflowNodeSchema<FlowGramNode.Loop, LoopNodeData>;
|
|
598
|
+
|
|
599
|
+
/**
|
|
600
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
601
|
+
* SPDX-License-Identifier: MIT
|
|
602
|
+
*/
|
|
603
|
+
declare enum ConditionOperation {
|
|
604
|
+
EQ = "eq",
|
|
605
|
+
NEQ = "neq",
|
|
606
|
+
GT = "gt",
|
|
607
|
+
GTE = "gte",
|
|
608
|
+
LT = "lt",
|
|
609
|
+
LTE = "lte",
|
|
610
|
+
IN = "in",
|
|
611
|
+
NIN = "nin",
|
|
612
|
+
CONTAINS = "contains",
|
|
613
|
+
NOT_CONTAINS = "not_contains",
|
|
614
|
+
IS_EMPTY = "is_empty",
|
|
615
|
+
IS_NOT_EMPTY = "is_not_empty",
|
|
616
|
+
IS_TRUE = "is_true",
|
|
617
|
+
IS_FALSE = "is_false"
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
/**
|
|
621
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
622
|
+
* SPDX-License-Identifier: MIT
|
|
623
|
+
*/
|
|
624
|
+
|
|
625
|
+
interface ConditionItem {
|
|
626
|
+
key: string;
|
|
627
|
+
value: {
|
|
628
|
+
left: IFlowRefValue;
|
|
629
|
+
operator: ConditionOperation;
|
|
630
|
+
right: IFlowConstantRefValue;
|
|
631
|
+
};
|
|
632
|
+
}
|
|
633
|
+
interface ConditionNodeData {
|
|
634
|
+
title: string;
|
|
635
|
+
conditions: ConditionItem[];
|
|
636
|
+
}
|
|
637
|
+
type ConditionNodeSchema = WorkflowNodeSchema<FlowGramNode.Condition, ConditionNodeData>;
|
|
638
|
+
|
|
639
|
+
/**
|
|
640
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
641
|
+
* SPDX-License-Identifier: MIT
|
|
642
|
+
*/
|
|
643
|
+
|
|
644
|
+
interface ExecutionContext {
|
|
645
|
+
node: INode;
|
|
646
|
+
inputs: WorkflowInputs;
|
|
647
|
+
container: IContainer;
|
|
648
|
+
runtime: IContext;
|
|
649
|
+
}
|
|
650
|
+
interface ExecutionResult {
|
|
651
|
+
outputs: WorkflowOutputs;
|
|
652
|
+
branch?: string;
|
|
653
|
+
}
|
|
654
|
+
interface INodeExecutor {
|
|
655
|
+
type: FlowGramNode;
|
|
656
|
+
execute: (context: ExecutionContext) => Promise<ExecutionResult>;
|
|
657
|
+
}
|
|
658
|
+
interface INodeExecutorFactory {
|
|
659
|
+
new (): INodeExecutor;
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
/**
|
|
663
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
664
|
+
* SPDX-License-Identifier: MIT
|
|
665
|
+
*/
|
|
666
|
+
|
|
667
|
+
interface IExecutor {
|
|
668
|
+
execute: (context: ExecutionContext) => Promise<ExecutionResult>;
|
|
669
|
+
register: (executor: INodeExecutor) => void;
|
|
670
|
+
}
|
|
671
|
+
declare const IExecutor: unique symbol;
|
|
672
|
+
|
|
673
|
+
/**
|
|
674
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
675
|
+
* SPDX-License-Identifier: MIT
|
|
676
|
+
*/
|
|
677
|
+
|
|
678
|
+
interface EngineServices {
|
|
679
|
+
Executor: IExecutor;
|
|
680
|
+
}
|
|
681
|
+
interface IEngine {
|
|
682
|
+
invoke(params: InvokeParams): ITask;
|
|
683
|
+
executeNode(params: {
|
|
684
|
+
context: IContext;
|
|
685
|
+
node: INode;
|
|
686
|
+
}): Promise<void>;
|
|
687
|
+
}
|
|
688
|
+
declare const IEngine: unique symbol;
|
|
689
|
+
|
|
690
|
+
/**
|
|
691
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
692
|
+
* SPDX-License-Identifier: MIT
|
|
693
|
+
*/
|
|
694
|
+
|
|
695
|
+
interface ValidationResult {
|
|
696
|
+
valid: boolean;
|
|
697
|
+
errors?: string[];
|
|
698
|
+
}
|
|
699
|
+
interface IValidation {
|
|
700
|
+
validate(schema: WorkflowSchema): ValidationResult;
|
|
701
|
+
}
|
|
702
|
+
declare const IValidation: unique symbol;
|
|
703
|
+
|
|
704
|
+
/**
|
|
705
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
706
|
+
* SPDX-License-Identifier: MIT
|
|
707
|
+
*/
|
|
708
|
+
|
|
709
|
+
interface TaskRunInput {
|
|
710
|
+
inputs: WorkflowInputs;
|
|
711
|
+
schema: string;
|
|
712
|
+
}
|
|
713
|
+
interface TaskRunOutput {
|
|
714
|
+
taskID: string;
|
|
715
|
+
}
|
|
716
|
+
declare const TaskRunDefine: FlowGramAPIDefine;
|
|
717
|
+
|
|
718
|
+
/**
|
|
719
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
720
|
+
* SPDX-License-Identifier: MIT
|
|
721
|
+
*/
|
|
722
|
+
|
|
723
|
+
interface ServerInfoInput {
|
|
724
|
+
}
|
|
725
|
+
interface ServerInfoOutput {
|
|
726
|
+
name: string;
|
|
727
|
+
title: string;
|
|
728
|
+
description: string;
|
|
729
|
+
runtime: string;
|
|
730
|
+
version: string;
|
|
731
|
+
time: string;
|
|
732
|
+
}
|
|
733
|
+
declare const ServerInfoDefine: FlowGramAPIDefine;
|
|
734
|
+
|
|
735
|
+
/**
|
|
736
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
737
|
+
* SPDX-License-Identifier: MIT
|
|
738
|
+
*/
|
|
739
|
+
|
|
740
|
+
interface TaskReportInput {
|
|
741
|
+
taskID: string;
|
|
742
|
+
}
|
|
743
|
+
type TaskReportOutput = IReport | undefined;
|
|
744
|
+
declare const TaskReportDefine: FlowGramAPIDefine;
|
|
745
|
+
|
|
746
|
+
/**
|
|
747
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
748
|
+
* SPDX-License-Identifier: MIT
|
|
749
|
+
*/
|
|
750
|
+
|
|
751
|
+
interface ValidationReq {
|
|
752
|
+
schema: string;
|
|
753
|
+
}
|
|
754
|
+
interface ValidationRes extends ValidationResult {
|
|
755
|
+
}
|
|
756
|
+
declare const ValidationDefine: FlowGramAPIDefine;
|
|
757
|
+
|
|
758
|
+
/**
|
|
759
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
760
|
+
* SPDX-License-Identifier: MIT
|
|
761
|
+
*/
|
|
762
|
+
|
|
763
|
+
interface TaskResultInput {
|
|
764
|
+
taskID: string;
|
|
765
|
+
}
|
|
766
|
+
type TaskResultOutput = WorkflowOutputs | undefined;
|
|
767
|
+
declare const TaskResultDefine: FlowGramAPIDefine;
|
|
768
|
+
|
|
769
|
+
/**
|
|
770
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
771
|
+
* SPDX-License-Identifier: MIT
|
|
772
|
+
*/
|
|
773
|
+
|
|
774
|
+
interface TaskCancelInput {
|
|
775
|
+
taskID: string;
|
|
776
|
+
}
|
|
777
|
+
type TaskCancelOutput = {
|
|
778
|
+
success: boolean;
|
|
779
|
+
};
|
|
780
|
+
declare const TaskCancelDefine: FlowGramAPIDefine;
|
|
781
|
+
|
|
782
|
+
/**
|
|
783
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
784
|
+
* SPDX-License-Identifier: MIT
|
|
785
|
+
*/
|
|
786
|
+
|
|
787
|
+
interface IRuntimeClient {
|
|
788
|
+
[FlowGramAPIName.TaskRun]: (input: TaskRunInput) => Promise<TaskRunOutput | undefined>;
|
|
789
|
+
[FlowGramAPIName.TaskReport]: (input: TaskReportInput) => Promise<TaskReportOutput | undefined>;
|
|
790
|
+
[FlowGramAPIName.TaskResult]: (input: TaskResultInput) => Promise<TaskResultOutput | undefined>;
|
|
791
|
+
[FlowGramAPIName.TaskCancel]: (input: TaskCancelInput) => Promise<TaskCancelOutput | undefined>;
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
export { type ConditionItem, type ConditionNodeSchema, ConditionOperation, type ContainerService, type ContextData, type CreateEdgeParams, type CreateNodeParams, type CreatePortParams, type EndNodeSchema, type EngineServices, type ExecutionContext, type ExecutionResult, type FlowGramAPIDefine, type FlowGramAPIDefines, FlowGramAPIMethod, FlowGramAPIModule, FlowGramAPIName, FlowGramAPINames, FlowGramAPIs, FlowGramNode, type IBasicJsonSchema, type IContainer, type IContext, type IDocument, type IEdge, IEngine, IExecutor, type IFlowConstantRefValue, type IFlowConstantValue, type IFlowRefValue, type IFlowTemplateValue, type IFlowValue, type IIOCenter, type IJsonSchema, type INode, type INodeExecutor, type INodeExecutorFactory, type IOData, type IPort, type IReport, type IReporter, type IRuntimeClient, type ISnapshot, type ISnapshotCenter, type IState, type IStatus, type IStatusCenter, type ITask, IValidation, type IVariable, type IVariableParseResult, type IVariableStore, type InvokeParams, type JsonSchemaBasicType, type LLMNodeSchema, type LoopNodeSchema, type NodeReport, type NodeDeclare as NodeVariable, type PositionSchema, ServerInfoDefine, type ServerInfoInput, type ServerInfoOutput, type Snapshot, type SnapshotData, type StartNodeSchema, type StatusData, TaskCancelDefine, type TaskCancelInput, type TaskCancelOutput, type TaskParams, TaskReportDefine, type TaskReportInput, type TaskReportOutput, TaskResultDefine, type TaskResultInput, type TaskResultOutput, TaskRunDefine, type TaskRunInput, type TaskRunOutput, type VOData, ValidationDefine, type ValidationReq, type ValidationRes, type ValidationResult, type WorkflowEdgeSchema, type WorkflowInputs, type WorkflowNodeMetaSchema, type WorkflowNodeSchema, type WorkflowOutputs, WorkflowPortType, type WorkflowRuntimeInvoke, type WorkflowSchema, WorkflowStatus, WorkflowVariableType, type XYSchema };
|