@flowgram.ai/runtime-interface 0.1.8
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 +264 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/index.d.mts +525 -0
- package/dist/index.d.ts +525 -0
- package/dist/index.js +318 -0
- package/dist/index.js.map +1 -0
- package/package.json +44 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.ts
|
|
31
|
+
var src_exports = {};
|
|
32
|
+
__export(src_exports, {
|
|
33
|
+
FlowGramAPIMethod: () => FlowGramAPIMethod,
|
|
34
|
+
FlowGramAPIModule: () => FlowGramAPIModule,
|
|
35
|
+
FlowGramAPIName: () => FlowGramAPIName,
|
|
36
|
+
FlowGramAPINames: () => FlowGramAPINames,
|
|
37
|
+
FlowGramAPIs: () => FlowGramAPIs,
|
|
38
|
+
FlowGramNode: () => FlowGramNode,
|
|
39
|
+
IEngine: () => IEngine,
|
|
40
|
+
IExecutor: () => IExecutor,
|
|
41
|
+
IValidation: () => IValidation,
|
|
42
|
+
ServerInfoDefine: () => ServerInfoDefine,
|
|
43
|
+
TaskCancelDefine: () => TaskCancelDefine,
|
|
44
|
+
TaskReportDefine: () => TaskReportDefine,
|
|
45
|
+
TaskResultDefine: () => TaskResultDefine,
|
|
46
|
+
TaskRunDefine: () => TaskRunDefine,
|
|
47
|
+
ValidationDefine: () => ValidationDefine,
|
|
48
|
+
WorkflowPortType: () => WorkflowPortType,
|
|
49
|
+
WorkflowStatus: () => WorkflowStatus,
|
|
50
|
+
WorkflowVariableType: () => WorkflowVariableType
|
|
51
|
+
});
|
|
52
|
+
module.exports = __toCommonJS(src_exports);
|
|
53
|
+
|
|
54
|
+
// src/api/validation/index.ts
|
|
55
|
+
var import_zod = __toESM(require("zod"));
|
|
56
|
+
|
|
57
|
+
// src/api/constant.ts
|
|
58
|
+
var FlowGramAPIMethod = /* @__PURE__ */ ((FlowGramAPIMethod2) => {
|
|
59
|
+
FlowGramAPIMethod2["GET"] = "GET";
|
|
60
|
+
FlowGramAPIMethod2["POST"] = "POST";
|
|
61
|
+
FlowGramAPIMethod2["PUT"] = "PUT";
|
|
62
|
+
FlowGramAPIMethod2["DELETE"] = "DELETE";
|
|
63
|
+
FlowGramAPIMethod2["PATCH"] = "PATCH";
|
|
64
|
+
return FlowGramAPIMethod2;
|
|
65
|
+
})(FlowGramAPIMethod || {});
|
|
66
|
+
var FlowGramAPIName = /* @__PURE__ */ ((FlowGramAPIName2) => {
|
|
67
|
+
FlowGramAPIName2["ServerInfo"] = "ServerInfo";
|
|
68
|
+
FlowGramAPIName2["TaskRun"] = "TaskRun";
|
|
69
|
+
FlowGramAPIName2["TaskReport"] = "TaskReport";
|
|
70
|
+
FlowGramAPIName2["TaskResult"] = "TaskResult";
|
|
71
|
+
FlowGramAPIName2["TaskCancel"] = "TaskCancel";
|
|
72
|
+
FlowGramAPIName2["Validation"] = "Validation";
|
|
73
|
+
return FlowGramAPIName2;
|
|
74
|
+
})(FlowGramAPIName || {});
|
|
75
|
+
var FlowGramAPIModule = /* @__PURE__ */ ((FlowGramAPIModule2) => {
|
|
76
|
+
FlowGramAPIModule2["Info"] = "Info";
|
|
77
|
+
FlowGramAPIModule2["Task"] = "Task";
|
|
78
|
+
FlowGramAPIModule2["Validation"] = "Validation";
|
|
79
|
+
return FlowGramAPIModule2;
|
|
80
|
+
})(FlowGramAPIModule || {});
|
|
81
|
+
|
|
82
|
+
// src/api/validation/index.ts
|
|
83
|
+
var ValidationDefine = {
|
|
84
|
+
name: "Validation" /* Validation */,
|
|
85
|
+
method: "POST" /* POST */,
|
|
86
|
+
path: "/validation",
|
|
87
|
+
module: "Validation" /* Validation */,
|
|
88
|
+
schema: {
|
|
89
|
+
input: import_zod.default.object({
|
|
90
|
+
schema: import_zod.default.string()
|
|
91
|
+
}),
|
|
92
|
+
output: import_zod.default.object({
|
|
93
|
+
valid: import_zod.default.boolean(),
|
|
94
|
+
nodeErrors: import_zod.default.array(
|
|
95
|
+
import_zod.default.object({
|
|
96
|
+
message: import_zod.default.string(),
|
|
97
|
+
nodeID: import_zod.default.string()
|
|
98
|
+
})
|
|
99
|
+
),
|
|
100
|
+
edgeErrors: import_zod.default.array(
|
|
101
|
+
import_zod.default.object({
|
|
102
|
+
message: import_zod.default.string(),
|
|
103
|
+
edge: import_zod.default.object({
|
|
104
|
+
sourceNodeID: import_zod.default.string(),
|
|
105
|
+
targetNodeID: import_zod.default.string(),
|
|
106
|
+
sourcePortID: import_zod.default.string().optional(),
|
|
107
|
+
targetPortID: import_zod.default.string().optional()
|
|
108
|
+
})
|
|
109
|
+
})
|
|
110
|
+
)
|
|
111
|
+
})
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
// src/api/task-run/index.ts
|
|
116
|
+
var import_zod3 = __toESM(require("zod"));
|
|
117
|
+
|
|
118
|
+
// src/api/schema.ts
|
|
119
|
+
var import_zod2 = __toESM(require("zod"));
|
|
120
|
+
var WorkflowIOZodSchema = import_zod2.default.record(import_zod2.default.string(), import_zod2.default.any());
|
|
121
|
+
var WorkflowSnapshotZodSchema = import_zod2.default.object({
|
|
122
|
+
id: import_zod2.default.string(),
|
|
123
|
+
nodeID: import_zod2.default.string(),
|
|
124
|
+
inputs: WorkflowIOZodSchema,
|
|
125
|
+
outputs: WorkflowIOZodSchema.optional(),
|
|
126
|
+
data: WorkflowIOZodSchema,
|
|
127
|
+
branch: import_zod2.default.string().optional()
|
|
128
|
+
});
|
|
129
|
+
var WorkflowStatusZodShape = {
|
|
130
|
+
status: import_zod2.default.string(),
|
|
131
|
+
terminated: import_zod2.default.boolean(),
|
|
132
|
+
startTime: import_zod2.default.number(),
|
|
133
|
+
endTime: import_zod2.default.number().optional(),
|
|
134
|
+
timeCost: import_zod2.default.number()
|
|
135
|
+
};
|
|
136
|
+
var WorkflowStatusZodSchema = import_zod2.default.object(WorkflowStatusZodShape);
|
|
137
|
+
var WorkflowZodSchema = {
|
|
138
|
+
Inputs: WorkflowIOZodSchema,
|
|
139
|
+
Outputs: WorkflowIOZodSchema,
|
|
140
|
+
Status: WorkflowStatusZodSchema,
|
|
141
|
+
Snapshot: WorkflowSnapshotZodSchema,
|
|
142
|
+
NodeReport: import_zod2.default.object({
|
|
143
|
+
id: import_zod2.default.string(),
|
|
144
|
+
...WorkflowStatusZodShape,
|
|
145
|
+
snapshots: import_zod2.default.array(WorkflowSnapshotZodSchema)
|
|
146
|
+
})
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
// src/api/task-run/index.ts
|
|
150
|
+
var TaskRunDefine = {
|
|
151
|
+
name: "TaskRun" /* TaskRun */,
|
|
152
|
+
method: "POST" /* POST */,
|
|
153
|
+
path: "/task/run",
|
|
154
|
+
module: "Task" /* Task */,
|
|
155
|
+
schema: {
|
|
156
|
+
input: import_zod3.default.object({
|
|
157
|
+
schema: import_zod3.default.string(),
|
|
158
|
+
inputs: WorkflowZodSchema.Inputs
|
|
159
|
+
}),
|
|
160
|
+
output: import_zod3.default.object({
|
|
161
|
+
taskID: import_zod3.default.string()
|
|
162
|
+
})
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
// src/api/task-result/index.ts
|
|
167
|
+
var import_zod4 = __toESM(require("zod"));
|
|
168
|
+
var TaskResultDefine = {
|
|
169
|
+
name: "TaskResult" /* TaskResult */,
|
|
170
|
+
method: "GET" /* GET */,
|
|
171
|
+
path: "/task/result",
|
|
172
|
+
module: "Task" /* Task */,
|
|
173
|
+
schema: {
|
|
174
|
+
input: import_zod4.default.object({
|
|
175
|
+
taskID: import_zod4.default.string()
|
|
176
|
+
}),
|
|
177
|
+
output: WorkflowZodSchema.Outputs
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
// src/api/task-report/index.ts
|
|
182
|
+
var import_zod5 = __toESM(require("zod"));
|
|
183
|
+
var TaskReportDefine = {
|
|
184
|
+
name: "TaskReport" /* TaskReport */,
|
|
185
|
+
method: "GET" /* GET */,
|
|
186
|
+
path: "/task/report",
|
|
187
|
+
module: "Task" /* Task */,
|
|
188
|
+
schema: {
|
|
189
|
+
input: import_zod5.default.object({
|
|
190
|
+
taskID: import_zod5.default.string()
|
|
191
|
+
}),
|
|
192
|
+
output: import_zod5.default.object({
|
|
193
|
+
id: import_zod5.default.string(),
|
|
194
|
+
inputs: WorkflowZodSchema.Inputs,
|
|
195
|
+
outputs: WorkflowZodSchema.Outputs,
|
|
196
|
+
workflowStatus: WorkflowZodSchema.Status,
|
|
197
|
+
reports: import_zod5.default.record(import_zod5.default.string(), WorkflowZodSchema.NodeReport)
|
|
198
|
+
})
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
// src/api/task-cancel/index.ts
|
|
203
|
+
var import_zod6 = __toESM(require("zod"));
|
|
204
|
+
var TaskCancelDefine = {
|
|
205
|
+
name: "TaskCancel" /* TaskCancel */,
|
|
206
|
+
method: "PUT" /* PUT */,
|
|
207
|
+
path: "/task/cancel",
|
|
208
|
+
module: "Task" /* Task */,
|
|
209
|
+
schema: {
|
|
210
|
+
input: import_zod6.default.object({
|
|
211
|
+
taskID: import_zod6.default.string()
|
|
212
|
+
}),
|
|
213
|
+
output: import_zod6.default.object({
|
|
214
|
+
success: import_zod6.default.boolean()
|
|
215
|
+
})
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
// src/api/server-info/index.ts
|
|
220
|
+
var import_zod7 = __toESM(require("zod"));
|
|
221
|
+
var ServerInfoDefine = {
|
|
222
|
+
name: "ServerInfo" /* ServerInfo */,
|
|
223
|
+
method: "GET" /* GET */,
|
|
224
|
+
path: "/info",
|
|
225
|
+
module: "Info" /* Info */,
|
|
226
|
+
schema: {
|
|
227
|
+
input: import_zod7.default.undefined(),
|
|
228
|
+
output: import_zod7.default.object({
|
|
229
|
+
name: import_zod7.default.string(),
|
|
230
|
+
runtime: import_zod7.default.string(),
|
|
231
|
+
version: import_zod7.default.string(),
|
|
232
|
+
time: import_zod7.default.string()
|
|
233
|
+
})
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
// src/api/define.ts
|
|
238
|
+
var FlowGramAPIs = {
|
|
239
|
+
["ServerInfo" /* ServerInfo */]: ServerInfoDefine,
|
|
240
|
+
["TaskRun" /* TaskRun */]: TaskRunDefine,
|
|
241
|
+
["TaskReport" /* TaskReport */]: TaskReportDefine,
|
|
242
|
+
["TaskResult" /* TaskResult */]: TaskResultDefine,
|
|
243
|
+
["TaskCancel" /* TaskCancel */]: TaskCancelDefine,
|
|
244
|
+
["Validation" /* Validation */]: ValidationDefine
|
|
245
|
+
};
|
|
246
|
+
var FlowGramAPINames = Object.keys(FlowGramAPIs);
|
|
247
|
+
|
|
248
|
+
// src/schema/constant.ts
|
|
249
|
+
var WorkflowPortType = /* @__PURE__ */ ((WorkflowPortType2) => {
|
|
250
|
+
WorkflowPortType2["Input"] = "input";
|
|
251
|
+
WorkflowPortType2["Output"] = "output";
|
|
252
|
+
return WorkflowPortType2;
|
|
253
|
+
})(WorkflowPortType || {});
|
|
254
|
+
var WorkflowVariableType = /* @__PURE__ */ ((WorkflowVariableType2) => {
|
|
255
|
+
WorkflowVariableType2["String"] = "string";
|
|
256
|
+
WorkflowVariableType2["Integer"] = "integer";
|
|
257
|
+
WorkflowVariableType2["Number"] = "number";
|
|
258
|
+
WorkflowVariableType2["Boolean"] = "boolean";
|
|
259
|
+
WorkflowVariableType2["Object"] = "object";
|
|
260
|
+
WorkflowVariableType2["Array"] = "array";
|
|
261
|
+
WorkflowVariableType2["Null"] = "null";
|
|
262
|
+
return WorkflowVariableType2;
|
|
263
|
+
})(WorkflowVariableType || {});
|
|
264
|
+
|
|
265
|
+
// src/node/constant.ts
|
|
266
|
+
var FlowGramNode = /* @__PURE__ */ ((FlowGramNode2) => {
|
|
267
|
+
FlowGramNode2["Root"] = "root";
|
|
268
|
+
FlowGramNode2["Start"] = "start";
|
|
269
|
+
FlowGramNode2["End"] = "end";
|
|
270
|
+
FlowGramNode2["LLM"] = "llm";
|
|
271
|
+
FlowGramNode2["code"] = "code";
|
|
272
|
+
FlowGramNode2["Condition"] = "condition";
|
|
273
|
+
FlowGramNode2["Loop"] = "loop";
|
|
274
|
+
FlowGramNode2["Comment"] = "comment";
|
|
275
|
+
FlowGramNode2["Group"] = "group";
|
|
276
|
+
return FlowGramNode2;
|
|
277
|
+
})(FlowGramNode || {});
|
|
278
|
+
|
|
279
|
+
// src/runtime/engine/index.ts
|
|
280
|
+
var IEngine = Symbol.for("Engine");
|
|
281
|
+
|
|
282
|
+
// src/runtime/executor/executor.ts
|
|
283
|
+
var IExecutor = Symbol.for("Executor");
|
|
284
|
+
|
|
285
|
+
// src/runtime/status/index.ts
|
|
286
|
+
var WorkflowStatus = /* @__PURE__ */ ((WorkflowStatus2) => {
|
|
287
|
+
WorkflowStatus2["Pending"] = "pending";
|
|
288
|
+
WorkflowStatus2["Processing"] = "processing";
|
|
289
|
+
WorkflowStatus2["Succeeded"] = "succeeded";
|
|
290
|
+
WorkflowStatus2["Failed"] = "failed";
|
|
291
|
+
WorkflowStatus2["Canceled"] = "canceled";
|
|
292
|
+
return WorkflowStatus2;
|
|
293
|
+
})(WorkflowStatus || {});
|
|
294
|
+
|
|
295
|
+
// src/runtime/validation/index.ts
|
|
296
|
+
var IValidation = Symbol.for("Validation");
|
|
297
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
298
|
+
0 && (module.exports = {
|
|
299
|
+
FlowGramAPIMethod,
|
|
300
|
+
FlowGramAPIModule,
|
|
301
|
+
FlowGramAPIName,
|
|
302
|
+
FlowGramAPINames,
|
|
303
|
+
FlowGramAPIs,
|
|
304
|
+
FlowGramNode,
|
|
305
|
+
IEngine,
|
|
306
|
+
IExecutor,
|
|
307
|
+
IValidation,
|
|
308
|
+
ServerInfoDefine,
|
|
309
|
+
TaskCancelDefine,
|
|
310
|
+
TaskReportDefine,
|
|
311
|
+
TaskResultDefine,
|
|
312
|
+
TaskRunDefine,
|
|
313
|
+
ValidationDefine,
|
|
314
|
+
WorkflowPortType,
|
|
315
|
+
WorkflowStatus,
|
|
316
|
+
WorkflowVariableType
|
|
317
|
+
});
|
|
318
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/api/validation/index.ts","../src/api/constant.ts","../src/api/task-run/index.ts","../src/api/schema.ts","../src/api/task-result/index.ts","../src/api/task-report/index.ts","../src/api/task-cancel/index.ts","../src/api/server-info/index.ts","../src/api/define.ts","../src/schema/constant.ts","../src/node/constant.ts","../src/runtime/engine/index.ts","../src/runtime/executor/executor.ts","../src/runtime/status/index.ts","../src/runtime/validation/index.ts"],"sourcesContent":["export * from './api';\nexport * from './schema';\nexport * from './node';\nexport * from './runtime';\nexport * from './client';\n","import z from 'zod';\n\nimport { ValidationResult } from '@runtime/index';\nimport { FlowGramAPIDefine } from '@api/type';\nimport { FlowGramAPIMethod, FlowGramAPIModule, FlowGramAPIName } from '@api/constant';\n\nexport interface ValidationReq {\n schema: string;\n}\n\nexport interface ValidationRes extends ValidationResult {}\n\nexport const ValidationDefine: FlowGramAPIDefine = {\n name: FlowGramAPIName.Validation,\n method: FlowGramAPIMethod.POST,\n path: '/validation',\n module: FlowGramAPIModule.Validation,\n schema: {\n input: z.object({\n schema: z.string(),\n }),\n output: z.object({\n valid: z.boolean(),\n nodeErrors: z.array(\n z.object({\n message: z.string(),\n nodeID: z.string(),\n })\n ),\n edgeErrors: z.array(\n z.object({\n message: z.string(),\n edge: z.object({\n sourceNodeID: z.string(),\n targetNodeID: z.string(),\n sourcePortID: z.string().optional(),\n targetPortID: z.string().optional(),\n }),\n })\n ),\n }),\n },\n};\n","export enum FlowGramAPIMethod {\n GET = 'GET',\n POST = 'POST',\n PUT = 'PUT',\n DELETE = 'DELETE',\n PATCH = 'PATCH',\n}\n\nexport enum FlowGramAPIName {\n ServerInfo = 'ServerInfo',\n TaskRun = 'TaskRun',\n TaskReport = 'TaskReport',\n TaskResult = 'TaskResult',\n TaskCancel = 'TaskCancel',\n Validation = 'Validation',\n}\n\nexport enum FlowGramAPIModule {\n Info = 'Info',\n Task = 'Task',\n Validation = 'Validation',\n}\n","import z from 'zod';\n\nimport { WorkflowInputs } from '@runtime/index';\nimport { FlowGramAPIDefine } from '@api/type';\nimport { WorkflowZodSchema } from '@api/schema';\nimport { FlowGramAPIMethod, FlowGramAPIModule, FlowGramAPIName } from '@api/constant';\n\nexport interface TaskRunInput {\n inputs: WorkflowInputs;\n schema: string;\n}\n\nexport interface TaskRunOutput {\n taskID: string;\n}\n\nexport const TaskRunDefine: FlowGramAPIDefine = {\n name: FlowGramAPIName.TaskRun,\n method: FlowGramAPIMethod.POST,\n path: '/task/run',\n module: FlowGramAPIModule.Task,\n schema: {\n input: z.object({\n schema: z.string(),\n inputs: WorkflowZodSchema.Inputs,\n }),\n output: z.object({\n taskID: z.string(),\n }),\n },\n};\n","import z from 'zod';\n\nconst WorkflowIOZodSchema = z.record(z.string(), z.any());\nconst WorkflowSnapshotZodSchema = z.object({\n id: z.string(),\n nodeID: z.string(),\n inputs: WorkflowIOZodSchema,\n outputs: WorkflowIOZodSchema.optional(),\n data: WorkflowIOZodSchema,\n branch: z.string().optional(),\n});\nconst WorkflowStatusZodShape = {\n status: z.string(),\n terminated: z.boolean(),\n startTime: z.number(),\n endTime: z.number().optional(),\n timeCost: z.number(),\n};\nconst WorkflowStatusZodSchema = z.object(WorkflowStatusZodShape);\n\nexport const WorkflowZodSchema = {\n Inputs: WorkflowIOZodSchema,\n Outputs: WorkflowIOZodSchema,\n Status: WorkflowStatusZodSchema,\n Snapshot: WorkflowSnapshotZodSchema,\n NodeReport: z.object({\n id: z.string(),\n ...WorkflowStatusZodShape,\n snapshots: z.array(WorkflowSnapshotZodSchema),\n }),\n};\n","import z from 'zod';\n\nimport { WorkflowOutputs } from '@runtime/index';\nimport { FlowGramAPIDefine } from '@api/type';\nimport { WorkflowZodSchema } from '@api/schema';\nimport { FlowGramAPIName, FlowGramAPIMethod, FlowGramAPIModule } from '@api/constant';\n\nexport interface TaskResultInput {\n taskID: string;\n}\n\nexport type TaskResultOutput = WorkflowOutputs | undefined;\n\nexport const TaskResultDefine: FlowGramAPIDefine = {\n name: FlowGramAPIName.TaskResult,\n method: FlowGramAPIMethod.GET,\n path: '/task/result',\n module: FlowGramAPIModule.Task,\n schema: {\n input: z.object({\n taskID: z.string(),\n }),\n output: WorkflowZodSchema.Outputs,\n },\n};\n","import z from 'zod';\n\nimport { IReport } from '@runtime/index';\nimport { FlowGramAPIDefine } from '@api/type';\nimport { WorkflowZodSchema } from '@api/schema';\nimport { FlowGramAPIName, FlowGramAPIMethod, FlowGramAPIModule } from '@api/constant';\n\nexport interface TaskReportInput {\n taskID: string;\n}\n\nexport type TaskReportOutput = IReport | undefined;\n\nexport const TaskReportDefine: FlowGramAPIDefine = {\n name: FlowGramAPIName.TaskReport,\n method: FlowGramAPIMethod.GET,\n path: '/task/report',\n module: FlowGramAPIModule.Task,\n schema: {\n input: z.object({\n taskID: z.string(),\n }),\n output: z.object({\n id: z.string(),\n inputs: WorkflowZodSchema.Inputs,\n outputs: WorkflowZodSchema.Outputs,\n workflowStatus: WorkflowZodSchema.Status,\n reports: z.record(z.string(), WorkflowZodSchema.NodeReport),\n }),\n },\n};\n","import z from 'zod';\n\nimport { FlowGramAPIDefine } from '@api/type';\nimport { FlowGramAPIName, FlowGramAPIMethod, FlowGramAPIModule } from '@api/constant';\n\nexport interface TaskCancelInput {\n taskID: string;\n}\n\nexport type TaskCancelOutput = {\n success: boolean;\n};\n\nexport const TaskCancelDefine: FlowGramAPIDefine = {\n name: FlowGramAPIName.TaskCancel,\n method: FlowGramAPIMethod.PUT,\n path: '/task/cancel',\n module: FlowGramAPIModule.Task,\n schema: {\n input: z.object({\n taskID: z.string(),\n }),\n output: z.object({\n success: z.boolean(),\n }),\n },\n};\n","import z from 'zod';\n\nimport { type FlowGramAPIDefine } from '@api/type';\nimport { FlowGramAPIMethod, FlowGramAPIModule, FlowGramAPIName } from '@api/constant';\n\nexport interface ServerInfoInput {}\n\nexport interface ServerInfoOutput {\n name: string;\n title: string;\n description: string;\n runtime: string;\n version: string;\n time: string;\n}\n\nexport const ServerInfoDefine: FlowGramAPIDefine = {\n name: FlowGramAPIName.ServerInfo,\n method: FlowGramAPIMethod.GET,\n path: '/info',\n module: FlowGramAPIModule.Info,\n schema: {\n input: z.undefined(),\n output: z.object({\n name: z.string(),\n runtime: z.string(),\n version: z.string(),\n time: z.string(),\n }),\n },\n};\n","import { ValidationDefine } from './validation';\nimport { FlowGramAPIDefines } from './type';\nimport { TaskRunDefine } from './task-run';\nimport { TaskResultDefine } from './task-result';\nimport { TaskReportDefine } from './task-report';\nimport { TaskCancelDefine } from './task-cancel';\nimport { ServerInfoDefine } from './server-info';\nimport { FlowGramAPIName } from './constant';\n\nexport const FlowGramAPIs: FlowGramAPIDefines = {\n [FlowGramAPIName.ServerInfo]: ServerInfoDefine,\n [FlowGramAPIName.TaskRun]: TaskRunDefine,\n [FlowGramAPIName.TaskReport]: TaskReportDefine,\n [FlowGramAPIName.TaskResult]: TaskResultDefine,\n [FlowGramAPIName.TaskCancel]: TaskCancelDefine,\n [FlowGramAPIName.Validation]: ValidationDefine,\n};\n\nexport const FlowGramAPINames = Object.keys(FlowGramAPIs) as FlowGramAPIName[];\n","export enum WorkflowPortType {\n Input = 'input',\n Output = 'output',\n}\n\nexport enum WorkflowVariableType {\n String = 'string',\n Integer = 'integer',\n Number = 'number',\n Boolean = 'boolean',\n Object = 'object',\n Array = 'array',\n Null = 'null',\n}\n","export enum FlowGramNode {\n Root = 'root',\n Start = 'start',\n End = 'end',\n LLM = 'llm',\n code = 'code',\n Condition = 'condition',\n Loop = 'loop',\n Comment = 'comment',\n Group = 'group',\n}\n","import { ITask } from '../task';\nimport { IExecutor } from '../executor';\nimport { INode } from '../document';\nimport { IContext } from '../context';\nimport { InvokeParams } from '../base';\n\nexport interface EngineServices {\n Executor: IExecutor;\n}\n\nexport interface IEngine {\n invoke(params: InvokeParams): ITask;\n executeNode(params: { context: IContext; node: INode }): Promise<void>;\n}\n\nexport const IEngine = Symbol.for('Engine');\n","import { ExecutionContext, ExecutionResult, INodeExecutor } from './node-executor';\n\nexport interface IExecutor {\n execute: (context: ExecutionContext) => Promise<ExecutionResult>;\n register: (executor: INodeExecutor) => void;\n}\n\nexport const IExecutor = Symbol.for('Executor');\n","export enum WorkflowStatus {\n Pending = 'pending',\n Processing = 'processing',\n Succeeded = 'succeeded',\n Failed = 'failed',\n Canceled = 'canceled',\n}\n\nexport interface StatusData {\n status: WorkflowStatus;\n terminated: boolean;\n startTime: number;\n endTime?: number;\n timeCost: number;\n}\n\nexport interface IStatus extends StatusData {\n id: string;\n process(): void;\n success(): void;\n fail(): void;\n cancel(): void;\n export(): StatusData;\n}\n\nexport interface IStatusCenter {\n workflow: IStatus;\n nodeStatus(nodeID: string): IStatus;\n init(): void;\n dispose(): void;\n getStatusNodeIDs(status: WorkflowStatus): string[];\n exportNodeStatus(): Record<string, StatusData>;\n}\n","import { WorkflowSchema } from '@schema/index';\n\nexport interface ValidationResult {\n valid: boolean;\n errors?: string[];\n}\n\nexport interface IValidation {\n validate(schema: WorkflowSchema): ValidationResult;\n}\n\nexport const IValidation = Symbol.for('Validation');\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,iBAAc;;;ACAP,IAAK,oBAAL,kBAAKA,uBAAL;AACL,EAAAA,mBAAA,SAAM;AACN,EAAAA,mBAAA,UAAO;AACP,EAAAA,mBAAA,SAAM;AACN,EAAAA,mBAAA,YAAS;AACT,EAAAA,mBAAA,WAAQ;AALE,SAAAA;AAAA,GAAA;AAQL,IAAK,kBAAL,kBAAKC,qBAAL;AACL,EAAAA,iBAAA,gBAAa;AACb,EAAAA,iBAAA,aAAU;AACV,EAAAA,iBAAA,gBAAa;AACb,EAAAA,iBAAA,gBAAa;AACb,EAAAA,iBAAA,gBAAa;AACb,EAA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AA,EAC3B,8BAA2B,GAAG;AAAA,EAC9B,8BAA2B,GAAG;AAAA,EAC9B,8BAA2B,GAAG;AAAA,EAC9B,8BAA2B,GAAG;AAChC;AAEO,IAAM,mBAAmB,OAAO,KAAK,YAAY;;;AClBjD,IAAK,mBAAL,kBAAKC,sBAAL;AACL,EAAAA,kBAAA,WAAQ;AACR,EAAAA,kBAAA,YAAS;AAFC,SAAAA;AAAA,GAAA;AAKL,IAAK,uBAAL,kBAAKC,0BAAL;AACL,EAAAA,sBAAA,YAAS;AACT,EAAAA,sBAAA,aAAU;AACV,EAAAA,sBAAA,YAAS;AACT,EAAAA,sBAAA,aAAU;AACV,EAAAA,sBAAA,YAAS;AACT,EAAAA,sBAAA,WAAQ;AACR,EAAAA,sBAAA,UAAO;AAPG,SAAAA;AAAA,GAAA;;;ACLL,IAAK,eAAL,kBAAKC,kBAAL;AACL,EAAAA,cAAA,UAAO;AACP,EAAAA,cAAA,WAAQ;AACR,EAAAA,cAAA,SAAM;AACN,EAAAA,cAAA,SAAM;AACN,EAAAA,cAAA,UAAO;AACP,EAAAA,cAAA,eAAY;AACZ,EAAAA,cAAA,UAAO;AACP,EAAAA,cAAA,aAAU;AACV,EAAAA,cAAA,WAAQ;AATE,SAAAA;AAAA,GAAA;;;ACeL,IAAM,UAAU,OAAO,IAAI,QAAQ;;;ACRnC,IAAM,YAAY,OAAO,IAAI,UAAU;;;ACPvC,IAAK,iBAAL,kBAAKC,oBAAL;AACL,EAAAA,gBAAA,aAAU;AACV,EAAAA,gBAAA,gBAAa;AACb,EAAAA,gBAAA,eAAY;AACZ,EAAAA,gBAAA,YAAS;AACT,EAAAA,gBAAA,cAAW;AALD,SAAAA;AAAA,GAAA;;;ACWL,IAAM,cAAc,OAAO,IAAI,YAAY;","names":["FlowGramAPIMethod","FlowGramAPIName","FlowGramAPIModule","z","import_zod","import_zod","z","z","import_zod","z","import_zod","z","import_zod","z","import_zod","z","WorkflowPortType","WorkflowVariableType","FlowGramNode","WorkflowStatus"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@flowgram.ai/runtime-interface",
|
|
3
|
+
"version": "0.1.8",
|
|
4
|
+
"homepage": "https://flowgram.ai/",
|
|
5
|
+
"repository": "https://github.com/bytedance/flowgram.ai",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"exports": {
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"import": "./dist/esm/index.js",
|
|
10
|
+
"require": "./dist/index.js"
|
|
11
|
+
},
|
|
12
|
+
"main": "./dist/index.js",
|
|
13
|
+
"module": "./dist/esm/index.js",
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"zod": "^3.24.4"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"eslint": "^8.54.0",
|
|
23
|
+
"tsup": "^8.0.1",
|
|
24
|
+
"typescript": "^5.0.4",
|
|
25
|
+
"vitest": "^0.34.6",
|
|
26
|
+
"@flowgram.ai/eslint-config": "0.2.8",
|
|
27
|
+
"@flowgram.ai/ts-config": "0.2.8"
|
|
28
|
+
},
|
|
29
|
+
"publishConfig": {
|
|
30
|
+
"access": "public",
|
|
31
|
+
"registry": "https://registry.npmjs.org/"
|
|
32
|
+
},
|
|
33
|
+
"scripts": {
|
|
34
|
+
"dev": "npm run watch",
|
|
35
|
+
"build": "npm run build:fast -- --dts-resolve",
|
|
36
|
+
"build:fast": "tsup src/index.ts --format cjs,esm --sourcemap --legacy-output",
|
|
37
|
+
"build:watch": "npm run build:fast -- --dts-resolve",
|
|
38
|
+
"clean": "rimraf dist",
|
|
39
|
+
"test": "exit 0",
|
|
40
|
+
"test:cov": "exit 0",
|
|
41
|
+
"ts-check": "tsc --noEmit",
|
|
42
|
+
"watch": "npm run build:fast -- --dts-resolve --watch --ignore-watch dist"
|
|
43
|
+
}
|
|
44
|
+
}
|