@flowgram.ai/runtime-interface 0.1.0-alpha.10 → 0.1.0-alpha.12

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.
@@ -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
  /**
@@ -166,6 +165,20 @@ interface WorkflowNodeSchema<T = string, D = any> {
166
165
  edges?: WorkflowEdgeSchema[];
167
166
  }
168
167
 
168
+ /**
169
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
170
+ * SPDX-License-Identifier: MIT
171
+ */
172
+
173
+ interface WorkflowGroupSchema extends WorkflowNodeSchema {
174
+ data: {
175
+ title?: string;
176
+ color?: string;
177
+ parentID: string;
178
+ blockIDs: string[];
179
+ };
180
+ }
181
+
169
182
  /**
170
183
  * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
171
184
  * SPDX-License-Identifier: MIT
@@ -174,6 +187,7 @@ interface WorkflowNodeSchema<T = string, D = any> {
174
187
  interface WorkflowSchema {
175
188
  nodes: WorkflowNodeSchema[];
176
189
  edges: WorkflowEdgeSchema[];
190
+ groups?: WorkflowGroupSchema[];
177
191
  }
178
192
 
179
193
  /**
@@ -212,6 +226,20 @@ interface InvokeParams {
212
226
  }
213
227
  type WorkflowRuntimeInvoke = (params: InvokeParams) => Promise<WorkflowInputs>;
214
228
 
229
+ /**
230
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
231
+ * SPDX-License-Identifier: MIT
232
+ */
233
+
234
+ interface ValidationResult {
235
+ valid: boolean;
236
+ errors?: string[];
237
+ }
238
+ interface IValidation {
239
+ invoke(params: InvokeParams): ValidationResult;
240
+ }
241
+ declare const IValidation: unique symbol;
242
+
215
243
  /**
216
244
  * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
217
245
  * SPDX-License-Identifier: MIT
@@ -290,63 +318,6 @@ interface IStatusCenter {
290
318
  exportNodeStatus(): Record<string, StatusData>;
291
319
  }
292
320
 
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
321
  /**
351
322
  * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
352
323
  * SPDX-License-Identifier: MIT
@@ -356,13 +327,16 @@ declare enum FlowGramNode {
356
327
  Start = "start",
357
328
  End = "end",
358
329
  LLM = "llm",
359
- code = "code",
330
+ Code = "code",
360
331
  Condition = "condition",
361
332
  Loop = "loop",
362
333
  Comment = "comment",
363
334
  Group = "group",
364
335
  BlockStart = "block-start",
365
- BlockEnd = "block-end"
336
+ BlockEnd = "block-end",
337
+ HTTP = "http",
338
+ Break = "break",
339
+ Continue = "continue"
366
340
  }
367
341
 
368
342
  /**
@@ -473,6 +447,10 @@ interface IState {
473
447
  node: INode;
474
448
  outputs: WorkflowOutputs;
475
449
  }): void;
450
+ parseInputs(params: {
451
+ values: Record<string, IFlowValue>;
452
+ declare: IJsonSchema;
453
+ }): WorkflowInputs;
476
454
  parseRef<T = unknown>(ref: IFlowRefValue): IVariableParseResult<T> | null;
477
455
  parseTemplate(template: IFlowTemplateValue): IVariableParseResult<string> | null;
478
456
  parseValue<T = unknown>(flowValue: IFlowValue, type?: WorkflowVariableType): IVariableParseResult<T> | null;
@@ -480,6 +458,77 @@ interface IState {
480
458
  addExecutedNode(node: INode): void;
481
459
  }
482
460
 
461
+ /**
462
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
463
+ * SPDX-License-Identifier: MIT
464
+ */
465
+
466
+ interface SnapshotData {
467
+ nodeID: string;
468
+ inputs: WorkflowInputs;
469
+ outputs: WorkflowOutputs;
470
+ data: any;
471
+ branch?: string;
472
+ error?: string;
473
+ }
474
+ interface Snapshot extends SnapshotData {
475
+ id: string;
476
+ }
477
+ interface ISnapshot {
478
+ id: string;
479
+ data: Partial<SnapshotData>;
480
+ update(data: Partial<SnapshotData>): void;
481
+ validate(): boolean;
482
+ export(): Snapshot;
483
+ }
484
+
485
+ /**
486
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
487
+ * SPDX-License-Identifier: MIT
488
+ */
489
+
490
+ interface ISnapshotCenter {
491
+ id: string;
492
+ create(snapshot: Partial<SnapshotData>): ISnapshot;
493
+ exportAll(): Snapshot[];
494
+ export(): Record<string, Snapshot[]>;
495
+ init(): void;
496
+ dispose(): void;
497
+ }
498
+
499
+ /**
500
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
501
+ * SPDX-License-Identifier: MIT
502
+ */
503
+ declare enum WorkflowMessageType {
504
+ Log = "log",
505
+ Info = "info",
506
+ Debug = "debug",
507
+ Error = "error",
508
+ Warn = "warning"
509
+ }
510
+ interface MessageData {
511
+ message: string;
512
+ nodeID?: string;
513
+ timestamp?: number;
514
+ }
515
+ interface IMessage extends MessageData {
516
+ id: string;
517
+ type: WorkflowMessageType;
518
+ timestamp: number;
519
+ }
520
+ type WorkflowMessages = Record<WorkflowMessageType, IMessage[]>;
521
+ interface IMessageCenter {
522
+ init(): void;
523
+ dispose(): void;
524
+ log(data: MessageData): IMessage;
525
+ info(data: MessageData): IMessage;
526
+ debug(data: MessageData): IMessage;
527
+ error(data: MessageData): IMessage;
528
+ warn(data: MessageData): IMessage;
529
+ export(): WorkflowMessages;
530
+ }
531
+
483
532
  /**
484
533
  * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
485
534
  * SPDX-License-Identifier: MIT
@@ -489,33 +538,71 @@ interface NodeReport extends StatusData {
489
538
  id: string;
490
539
  snapshots: Snapshot[];
491
540
  }
541
+ type WorkflowReports = Record<string, NodeReport>;
492
542
  interface IReport {
493
543
  id: string;
494
544
  inputs: WorkflowInputs;
495
545
  outputs: WorkflowOutputs;
496
546
  workflowStatus: StatusData;
497
- reports: Record<string, NodeReport>;
547
+ reports: WorkflowReports;
548
+ messages: WorkflowMessages;
498
549
  }
499
550
  interface IReporter {
500
551
  snapshotCenter: ISnapshotCenter;
501
552
  statusCenter: IStatusCenter;
553
+ messageCenter: IMessageCenter;
502
554
  init(): void;
503
555
  dispose(): void;
504
556
  export(): IReport;
505
557
  }
506
558
 
559
+ /**
560
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
561
+ * SPDX-License-Identifier: MIT
562
+ */
563
+
564
+ interface IOData {
565
+ inputs: WorkflowInputs;
566
+ outputs: WorkflowOutputs;
567
+ }
568
+ /** Input & Output */
569
+ interface IIOCenter {
570
+ inputs: WorkflowInputs;
571
+ outputs: WorkflowOutputs;
572
+ setInputs(inputs: WorkflowInputs): void;
573
+ setOutputs(outputs: WorkflowOutputs): void;
574
+ init(inputs: WorkflowInputs): void;
575
+ dispose(): void;
576
+ export(): IOData;
577
+ }
578
+
579
+ /**
580
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
581
+ * SPDX-License-Identifier: MIT
582
+ */
583
+ interface ICache<K = string, V = any> {
584
+ init(): void;
585
+ dispose(): void;
586
+ get(key: K): V;
587
+ set(key: K, value: V): this;
588
+ delete(key: K): boolean;
589
+ has(key: K): boolean;
590
+ }
591
+
507
592
  /**
508
593
  * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
509
594
  * SPDX-License-Identifier: MIT
510
595
  */
511
596
 
512
597
  interface ContextData {
598
+ cache: ICache;
513
599
  variableStore: IVariableStore;
514
600
  state: IState;
515
601
  document: IDocument;
516
602
  ioCenter: IIOCenter;
517
603
  snapshotCenter: ISnapshotCenter;
518
604
  statusCenter: IStatusCenter;
605
+ messageCenter: IMessageCenter;
519
606
  reporter: IReporter;
520
607
  }
521
608
  interface IContext extends ContextData {
@@ -636,6 +723,96 @@ interface ConditionNodeData {
636
723
  }
637
724
  type ConditionNodeSchema = WorkflowNodeSchema<FlowGramNode.Condition, ConditionNodeData>;
638
725
 
726
+ /**
727
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
728
+ * SPDX-License-Identifier: MIT
729
+ */
730
+ declare enum HTTPMethod {
731
+ Get = "GET",
732
+ Post = "POST",
733
+ Put = "PUT",
734
+ Delete = "DELETE",
735
+ Patch = "PATCH",
736
+ Head = "HEAD"
737
+ }
738
+ declare enum HTTPBodyType {
739
+ None = "none",
740
+ FormData = "form-data",
741
+ XWwwFormUrlencoded = "x-www-form-urlencoded",
742
+ RawText = "raw-text",
743
+ JSON = "JSON",
744
+ Binary = "binary"
745
+ }
746
+
747
+ /**
748
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
749
+ * SPDX-License-Identifier: MIT
750
+ */
751
+
752
+ interface HTTPNodeData {
753
+ title: string;
754
+ outputs: IJsonSchema<'object'>;
755
+ api: {
756
+ method: HTTPMethod;
757
+ url: IFlowTemplateValue;
758
+ };
759
+ headers: IJsonSchema<'object'>;
760
+ headersValues: Record<string, IFlowConstantRefValue>;
761
+ params: IJsonSchema<'object'>;
762
+ paramsValues: Record<string, IFlowConstantRefValue>;
763
+ body: {
764
+ bodyType: HTTPBodyType;
765
+ json?: IFlowTemplateValue;
766
+ formData?: IJsonSchema<'object'>;
767
+ formDataValues?: Record<string, IFlowConstantRefValue>;
768
+ rawText?: IFlowTemplateValue;
769
+ binary?: IFlowTemplateValue;
770
+ xWwwFormUrlencoded?: IJsonSchema<'object'>;
771
+ xWwwFormUrlencodedValues?: Record<string, IFlowConstantRefValue>;
772
+ };
773
+ timeout: {
774
+ retryTimes: number;
775
+ timeout: number;
776
+ };
777
+ }
778
+
779
+ type HTTPNodeSchema = WorkflowNodeSchema<FlowGramNode.HTTP, HTTPNodeData>;
780
+
781
+ /**
782
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
783
+ * SPDX-License-Identifier: MIT
784
+ */
785
+
786
+ interface CodeNodeData {
787
+ title: string;
788
+ inputsValues: Record<string, IFlowValue>;
789
+ inputs: IJsonSchema<'object'>;
790
+ outputs: IJsonSchema<'object'>;
791
+ script: {
792
+ language: 'javascript';
793
+ content: string;
794
+ };
795
+ }
796
+ type CodeNodeSchema = WorkflowNodeSchema<FlowGramNode.Code, CodeNodeData>;
797
+
798
+ /**
799
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
800
+ * SPDX-License-Identifier: MIT
801
+ */
802
+
803
+ interface BreakNodeData {
804
+ }
805
+ type BreakNodeSchema = WorkflowNodeSchema<FlowGramNode.Break, BreakNodeData>;
806
+
807
+ /**
808
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
809
+ * SPDX-License-Identifier: MIT
810
+ */
811
+
812
+ interface ContinueNodeData {
813
+ }
814
+ type ContinueNodeSchema = WorkflowNodeSchema<FlowGramNode.Continue, ContinueNodeData>;
815
+
639
816
  /**
640
817
  * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
641
818
  * SPDX-License-Identifier: MIT
@@ -646,6 +823,7 @@ interface ExecutionContext {
646
823
  inputs: WorkflowInputs;
647
824
  container: IContainer;
648
825
  runtime: IContext;
826
+ snapshot: ISnapshot;
649
827
  }
650
828
  interface ExecutionResult {
651
829
  outputs: WorkflowOutputs;
@@ -676,6 +854,7 @@ declare const IExecutor: unique symbol;
676
854
  */
677
855
 
678
856
  interface EngineServices {
857
+ Validation: IValidation;
679
858
  Executor: IExecutor;
680
859
  }
681
860
  interface IEngine {
@@ -687,20 +866,6 @@ interface IEngine {
687
866
  }
688
867
  declare const IEngine: unique symbol;
689
868
 
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
869
  /**
705
870
  * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
706
871
  * SPDX-License-Identifier: MIT
@@ -748,12 +913,13 @@ declare const TaskReportDefine: FlowGramAPIDefine;
748
913
  * SPDX-License-Identifier: MIT
749
914
  */
750
915
 
751
- interface ValidationReq {
916
+ interface TaskValidateInput {
917
+ inputs: WorkflowInputs;
752
918
  schema: string;
753
919
  }
754
- interface ValidationRes extends ValidationResult {
920
+ interface TaskValidateOutput extends ValidationResult {
755
921
  }
756
- declare const ValidationDefine: FlowGramAPIDefine;
922
+ declare const TaskValidateDefine: FlowGramAPIDefine;
757
923
 
758
924
  /**
759
925
  * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
@@ -789,6 +955,7 @@ interface IRuntimeClient {
789
955
  [FlowGramAPIName.TaskReport]: (input: TaskReportInput) => Promise<TaskReportOutput | undefined>;
790
956
  [FlowGramAPIName.TaskResult]: (input: TaskResultInput) => Promise<TaskResultOutput | undefined>;
791
957
  [FlowGramAPIName.TaskCancel]: (input: TaskCancelInput) => Promise<TaskCancelOutput | undefined>;
958
+ [FlowGramAPIName.TaskValidate]: (input: TaskValidateInput) => Promise<TaskValidateOutput | undefined>;
792
959
  }
793
960
 
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 };
961
+ export { type BreakNodeSchema, type CodeNodeSchema, type ConditionItem, type ConditionNodeSchema, ConditionOperation, type ContainerService, type ContextData, type ContinueNodeSchema, type CreateEdgeParams, type CreateNodeParams, type CreatePortParams, type EndNodeSchema, type EngineServices, type ExecutionContext, type ExecutionResult, type FlowGramAPIDefine, type FlowGramAPIDefines, FlowGramAPIMethod, FlowGramAPIModule, FlowGramAPIName, FlowGramAPINames, FlowGramAPIs, FlowGramNode, HTTPBodyType, HTTPMethod, type HTTPNodeSchema, type IBasicJsonSchema, type ICache, 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 };