@flowgram.ai/runtime-interface 0.2.22 → 0.2.24

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/index.d.mts CHANGED
@@ -17,12 +17,11 @@ declare enum FlowGramAPIName {
17
17
  TaskReport = "TaskReport",
18
18
  TaskResult = "TaskResult",
19
19
  TaskCancel = "TaskCancel",
20
- Validation = "Validation"
20
+ TaskValidate = "TaskValidate"
21
21
  }
22
22
  declare enum FlowGramAPIModule {
23
23
  Info = "Info",
24
- Task = "Task",
25
- Validation = "Validation"
24
+ Task = "Task"
26
25
  }
27
26
 
28
27
  /**
@@ -94,6 +93,9 @@ interface IJsonSchema<T = string> {
94
93
  items?: IJsonSchema<T>;
95
94
  required?: string[];
96
95
  $ref?: string;
96
+ key?: number;
97
+ name?: string;
98
+ isPropertyRequired?: boolean;
97
99
  extra?: {
98
100
  index?: number;
99
101
  weak?: boolean;
@@ -212,6 +214,20 @@ interface InvokeParams {
212
214
  }
213
215
  type WorkflowRuntimeInvoke = (params: InvokeParams) => Promise<WorkflowInputs>;
214
216
 
217
+ /**
218
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
219
+ * SPDX-License-Identifier: MIT
220
+ */
221
+
222
+ interface ValidationResult {
223
+ valid: boolean;
224
+ errors?: string[];
225
+ }
226
+ interface IValidation {
227
+ invoke(params: InvokeParams): ValidationResult;
228
+ }
229
+ declare const IValidation: unique symbol;
230
+
215
231
  /**
216
232
  * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
217
233
  * SPDX-License-Identifier: MIT
@@ -290,63 +306,6 @@ interface IStatusCenter {
290
306
  exportNodeStatus(): Record<string, StatusData>;
291
307
  }
292
308
 
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
309
  /**
351
310
  * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
352
311
  * SPDX-License-Identifier: MIT
@@ -360,7 +319,9 @@ declare enum FlowGramNode {
360
319
  Condition = "condition",
361
320
  Loop = "loop",
362
321
  Comment = "comment",
363
- Group = "group"
322
+ Group = "group",
323
+ BlockStart = "block-start",
324
+ BlockEnd = "block-end"
364
325
  }
365
326
 
366
327
  /**
@@ -427,6 +388,8 @@ interface INode<T = any> {
427
388
  children: INode[];
428
389
  prev: INode[];
429
390
  next: INode[];
391
+ successors: INode[];
392
+ predecessors: INode[];
430
393
  isBranch: boolean;
431
394
  }
432
395
  interface CreateNodeParams {
@@ -476,6 +439,77 @@ interface IState {
476
439
  addExecutedNode(node: INode): void;
477
440
  }
478
441
 
442
+ /**
443
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
444
+ * SPDX-License-Identifier: MIT
445
+ */
446
+
447
+ interface SnapshotData {
448
+ nodeID: string;
449
+ inputs: WorkflowInputs;
450
+ outputs: WorkflowOutputs;
451
+ data: any;
452
+ branch?: string;
453
+ error?: string;
454
+ }
455
+ interface Snapshot extends SnapshotData {
456
+ id: string;
457
+ }
458
+ interface ISnapshot {
459
+ id: string;
460
+ data: Partial<SnapshotData>;
461
+ update(data: Partial<SnapshotData>): void;
462
+ validate(): boolean;
463
+ export(): Snapshot;
464
+ }
465
+
466
+ /**
467
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
468
+ * SPDX-License-Identifier: MIT
469
+ */
470
+
471
+ interface ISnapshotCenter {
472
+ id: string;
473
+ create(snapshot: Partial<SnapshotData>): ISnapshot;
474
+ exportAll(): Snapshot[];
475
+ export(): Record<string, Snapshot[]>;
476
+ init(): void;
477
+ dispose(): void;
478
+ }
479
+
480
+ /**
481
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
482
+ * SPDX-License-Identifier: MIT
483
+ */
484
+ declare enum WorkflowMessageType {
485
+ Log = "log",
486
+ Info = "info",
487
+ Debug = "debug",
488
+ Error = "error",
489
+ Warn = "warning"
490
+ }
491
+ interface MessageData {
492
+ message: string;
493
+ nodeID?: string;
494
+ timestamp?: number;
495
+ }
496
+ interface IMessage extends MessageData {
497
+ id: string;
498
+ type: WorkflowMessageType;
499
+ timestamp: number;
500
+ }
501
+ type WorkflowMessages = Record<WorkflowMessageType, IMessage[]>;
502
+ interface IMessageCenter {
503
+ init(): void;
504
+ dispose(): void;
505
+ log(data: MessageData): IMessage;
506
+ info(data: MessageData): IMessage;
507
+ debug(data: MessageData): IMessage;
508
+ error(data: MessageData): IMessage;
509
+ warn(data: MessageData): IMessage;
510
+ export(): WorkflowMessages;
511
+ }
512
+
479
513
  /**
480
514
  * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
481
515
  * SPDX-License-Identifier: MIT
@@ -485,21 +519,44 @@ interface NodeReport extends StatusData {
485
519
  id: string;
486
520
  snapshots: Snapshot[];
487
521
  }
522
+ type WorkflowReports = Record<string, NodeReport>;
488
523
  interface IReport {
489
524
  id: string;
490
525
  inputs: WorkflowInputs;
491
526
  outputs: WorkflowOutputs;
492
527
  workflowStatus: StatusData;
493
- reports: Record<string, NodeReport>;
528
+ reports: WorkflowReports;
529
+ messages: WorkflowMessages;
494
530
  }
495
531
  interface IReporter {
496
532
  snapshotCenter: ISnapshotCenter;
497
533
  statusCenter: IStatusCenter;
534
+ messageCenter: IMessageCenter;
498
535
  init(): void;
499
536
  dispose(): void;
500
537
  export(): IReport;
501
538
  }
502
539
 
540
+ /**
541
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
542
+ * SPDX-License-Identifier: MIT
543
+ */
544
+
545
+ interface IOData {
546
+ inputs: WorkflowInputs;
547
+ outputs: WorkflowOutputs;
548
+ }
549
+ /** Input & Output */
550
+ interface IIOCenter {
551
+ inputs: WorkflowInputs;
552
+ outputs: WorkflowOutputs;
553
+ setInputs(inputs: WorkflowInputs): void;
554
+ setOutputs(outputs: WorkflowOutputs): void;
555
+ init(inputs: WorkflowInputs): void;
556
+ dispose(): void;
557
+ export(): IOData;
558
+ }
559
+
503
560
  /**
504
561
  * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
505
562
  * SPDX-License-Identifier: MIT
@@ -512,6 +569,7 @@ interface ContextData {
512
569
  ioCenter: IIOCenter;
513
570
  snapshotCenter: ISnapshotCenter;
514
571
  statusCenter: IStatusCenter;
572
+ messageCenter: IMessageCenter;
515
573
  reporter: IReporter;
516
574
  }
517
575
  interface IContext extends ContextData {
@@ -545,8 +603,7 @@ interface TaskParams {
545
603
  interface EndNodeData {
546
604
  title: string;
547
605
  inputs: IJsonSchema<'object'>;
548
- outputs: IJsonSchema<'object'>;
549
- outputValues: Record<string, IFlowConstantRefValue>;
606
+ inputsValues: Record<string, IFlowConstantRefValue>;
550
607
  }
551
608
  type EndNodeSchema = WorkflowNodeSchema<FlowGramNode.End, EndNodeData>;
552
609
 
@@ -581,6 +638,58 @@ interface StartNodeData {
581
638
  }
582
639
  type StartNodeSchema = WorkflowNodeSchema<FlowGramNode.Start, StartNodeData>;
583
640
 
641
+ /**
642
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
643
+ * SPDX-License-Identifier: MIT
644
+ */
645
+
646
+ interface LoopNodeData {
647
+ title: string;
648
+ loopFor: IFlowRefValue;
649
+ loopOutputs: Record<string, IFlowRefValue>;
650
+ }
651
+ type LoopNodeSchema = WorkflowNodeSchema<FlowGramNode.Loop, LoopNodeData>;
652
+
653
+ /**
654
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
655
+ * SPDX-License-Identifier: MIT
656
+ */
657
+ declare enum ConditionOperation {
658
+ EQ = "eq",
659
+ NEQ = "neq",
660
+ GT = "gt",
661
+ GTE = "gte",
662
+ LT = "lt",
663
+ LTE = "lte",
664
+ IN = "in",
665
+ NIN = "nin",
666
+ CONTAINS = "contains",
667
+ NOT_CONTAINS = "not_contains",
668
+ IS_EMPTY = "is_empty",
669
+ IS_NOT_EMPTY = "is_not_empty",
670
+ IS_TRUE = "is_true",
671
+ IS_FALSE = "is_false"
672
+ }
673
+
674
+ /**
675
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
676
+ * SPDX-License-Identifier: MIT
677
+ */
678
+
679
+ interface ConditionItem {
680
+ key: string;
681
+ value: {
682
+ left: IFlowRefValue;
683
+ operator: ConditionOperation;
684
+ right: IFlowConstantRefValue;
685
+ };
686
+ }
687
+ interface ConditionNodeData {
688
+ title: string;
689
+ conditions: ConditionItem[];
690
+ }
691
+ type ConditionNodeSchema = WorkflowNodeSchema<FlowGramNode.Condition, ConditionNodeData>;
692
+
584
693
  /**
585
694
  * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
586
695
  * SPDX-License-Identifier: MIT
@@ -621,6 +730,7 @@ declare const IExecutor: unique symbol;
621
730
  */
622
731
 
623
732
  interface EngineServices {
733
+ Validation: IValidation;
624
734
  Executor: IExecutor;
625
735
  }
626
736
  interface IEngine {
@@ -632,20 +742,6 @@ interface IEngine {
632
742
  }
633
743
  declare const IEngine: unique symbol;
634
744
 
635
- /**
636
- * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
637
- * SPDX-License-Identifier: MIT
638
- */
639
-
640
- interface ValidationResult {
641
- valid: boolean;
642
- errors?: string[];
643
- }
644
- interface IValidation {
645
- validate(schema: WorkflowSchema): ValidationResult;
646
- }
647
- declare const IValidation: unique symbol;
648
-
649
745
  /**
650
746
  * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
651
747
  * SPDX-License-Identifier: MIT
@@ -693,12 +789,13 @@ declare const TaskReportDefine: FlowGramAPIDefine;
693
789
  * SPDX-License-Identifier: MIT
694
790
  */
695
791
 
696
- interface ValidationReq {
792
+ interface TaskValidateInput {
793
+ inputs: WorkflowInputs;
697
794
  schema: string;
698
795
  }
699
- interface ValidationRes extends ValidationResult {
796
+ interface TaskValidateOutput extends ValidationResult {
700
797
  }
701
- declare const ValidationDefine: FlowGramAPIDefine;
798
+ declare const TaskValidateDefine: FlowGramAPIDefine;
702
799
 
703
800
  /**
704
801
  * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
@@ -734,6 +831,7 @@ interface IRuntimeClient {
734
831
  [FlowGramAPIName.TaskReport]: (input: TaskReportInput) => Promise<TaskReportOutput | undefined>;
735
832
  [FlowGramAPIName.TaskResult]: (input: TaskResultInput) => Promise<TaskResultOutput | undefined>;
736
833
  [FlowGramAPIName.TaskCancel]: (input: TaskCancelInput) => Promise<TaskCancelOutput | undefined>;
834
+ [FlowGramAPIName.TaskValidate]: (input: TaskValidateInput) => Promise<TaskValidateOutput | undefined>;
737
835
  }
738
836
 
739
- export { 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 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 };
837
+ 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 IMessage, type IMessageCenter, 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 MessageData, 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, TaskValidateDefine, type TaskValidateInput, type TaskValidateOutput, type VOData, type ValidationResult, type WorkflowEdgeSchema, type WorkflowInputs, WorkflowMessageType, type WorkflowMessages, type WorkflowNodeMetaSchema, type WorkflowNodeSchema, type WorkflowOutputs, WorkflowPortType, type WorkflowReports, type WorkflowRuntimeInvoke, type WorkflowSchema, WorkflowStatus, WorkflowVariableType, type XYSchema };