@ai-setting/roy-agent-core 1.4.10 → 1.4.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.
- package/dist/config/index.js +23 -0
- package/dist/env/agent/index.js +3035 -0
- package/dist/env/commands/index.js +1685 -0
- package/dist/env/debug/formatters/index.js +639 -0
- package/dist/env/debug/index.js +2300 -0
- package/dist/env/hook/index.js +273 -0
- package/dist/env/index.js +12591 -0
- package/dist/env/llm/index.js +2736 -0
- package/dist/env/log-trace/index.js +1779 -0
- package/dist/env/mcp/index.js +2173 -0
- package/dist/env/mcp/tool/index.js +1149 -0
- package/dist/env/memory/built-in/index.js +225 -0
- package/dist/env/memory/index.js +2171 -0
- package/dist/env/memory/plugin/index.js +1263 -0
- package/dist/env/prompt/index.js +2107 -0
- package/dist/env/session/index.js +3594 -0
- package/dist/env/session/storage/index.js +2049 -0
- package/dist/env/skill/index.js +1635 -0
- package/dist/env/skill/tool/index.js +114 -0
- package/dist/env/task/delegate/index.js +1844 -0
- package/dist/env/task/hooks/index.js +67 -0
- package/dist/env/task/index.js +3578 -0
- package/dist/env/task/plugins/index.js +1626 -0
- package/dist/env/task/storage/index.js +1464 -0
- package/dist/env/task/tools/index.js +344 -0
- package/dist/env/task/tools/operation/index.js +270 -0
- package/dist/env/tool/built-in/index.js +1151 -0
- package/dist/env/tool/index.js +2284 -0
- package/dist/env/workflow/decorators/index.js +449 -0
- package/dist/env/workflow/engine/index.js +4391 -0
- package/dist/env/workflow/index.js +6214 -0
- package/dist/env/workflow/nodes/index.js +650 -0
- package/dist/env/workflow/service/index.js +262 -0
- package/dist/env/workflow/storage/index.js +1236 -0
- package/dist/env/workflow/tools/index.js +1081 -0
- package/dist/env/workflow/types/index.js +479 -0
- package/dist/env/workflow/utils/index.js +1631 -0
- package/dist/index.js +15006 -14265
- package/package.json +2 -2
|
@@ -0,0 +1,449 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
function __accessProp(key) {
|
|
7
|
+
return this[key];
|
|
8
|
+
}
|
|
9
|
+
var __toCommonJS = (from) => {
|
|
10
|
+
var entry = (__moduleCache ??= new WeakMap).get(from), desc;
|
|
11
|
+
if (entry)
|
|
12
|
+
return entry;
|
|
13
|
+
entry = __defProp({}, "__esModule", { value: true });
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (var key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(entry, key))
|
|
17
|
+
__defProp(entry, key, {
|
|
18
|
+
get: __accessProp.bind(from, key),
|
|
19
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
__moduleCache.set(from, entry);
|
|
23
|
+
return entry;
|
|
24
|
+
};
|
|
25
|
+
var __moduleCache;
|
|
26
|
+
var __returnValue = (v) => v;
|
|
27
|
+
function __exportSetter(name, newValue) {
|
|
28
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
29
|
+
}
|
|
30
|
+
var __export = (target, all) => {
|
|
31
|
+
for (var name in all)
|
|
32
|
+
__defProp(target, name, {
|
|
33
|
+
get: all[name],
|
|
34
|
+
enumerable: true,
|
|
35
|
+
configurable: true,
|
|
36
|
+
set: __exportSetter.bind(all, name)
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
var __legacyDecorateClassTS = function(decorators, target, key, desc) {
|
|
40
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
41
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
42
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
43
|
+
else
|
|
44
|
+
for (var i = decorators.length - 1;i >= 0; i--)
|
|
45
|
+
if (d = decorators[i])
|
|
46
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
47
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
48
|
+
};
|
|
49
|
+
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
50
|
+
var __require = import.meta.require;
|
|
51
|
+
|
|
52
|
+
// packages/core/src/env/workflow/decorators/decorator-node.ts
|
|
53
|
+
class DecoratorNode {
|
|
54
|
+
type = "decorator";
|
|
55
|
+
id;
|
|
56
|
+
methodName;
|
|
57
|
+
instance;
|
|
58
|
+
dependsOn;
|
|
59
|
+
timeout;
|
|
60
|
+
retryConfig;
|
|
61
|
+
constructor(definition) {
|
|
62
|
+
const config = definition.config;
|
|
63
|
+
this.id = definition.id;
|
|
64
|
+
this.methodName = config._methodName;
|
|
65
|
+
this.instance = config._instance;
|
|
66
|
+
this.dependsOn = definition.depends_on || [];
|
|
67
|
+
this.timeout = definition.timeout;
|
|
68
|
+
this.retryConfig = definition.retry;
|
|
69
|
+
}
|
|
70
|
+
async execute(context) {
|
|
71
|
+
const startTime = Date.now();
|
|
72
|
+
const method = this.instance[this.methodName];
|
|
73
|
+
if (typeof method !== "function") {
|
|
74
|
+
return {
|
|
75
|
+
success: false,
|
|
76
|
+
error: `Method '${this.methodName}' is not a function`,
|
|
77
|
+
duration: Date.now() - startTime
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
const input = this.prepareInput(context);
|
|
81
|
+
const result = await this.executeWithRetry(input, context.abort);
|
|
82
|
+
return {
|
|
83
|
+
success: !result.error,
|
|
84
|
+
output: result.output,
|
|
85
|
+
error: result.error,
|
|
86
|
+
duration: Date.now() - startTime,
|
|
87
|
+
metadata: {
|
|
88
|
+
methodName: this.methodName
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
prepareInput(context) {
|
|
93
|
+
const nodeOutputs = context.nodeOutputs;
|
|
94
|
+
if (this.dependsOn.length === 0) {
|
|
95
|
+
return context.input || {};
|
|
96
|
+
}
|
|
97
|
+
const input = {};
|
|
98
|
+
for (const depId of this.dependsOn) {
|
|
99
|
+
const depOutput = nodeOutputs instanceof Map ? nodeOutputs.get(depId) : nodeOutputs?.[depId];
|
|
100
|
+
if (depOutput && typeof depOutput === "object") {
|
|
101
|
+
if ("output" in depOutput) {
|
|
102
|
+
input[depId] = depOutput.output;
|
|
103
|
+
} else {
|
|
104
|
+
input[depId] = depOutput;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return input;
|
|
109
|
+
}
|
|
110
|
+
async executeWithRetry(input, abort) {
|
|
111
|
+
const maxAttempts = this.retryConfig?.max_attempts ?? 1;
|
|
112
|
+
const backoff = this.retryConfig?.backoff ?? "exponential";
|
|
113
|
+
const initialDelay = this.retryConfig?.initial_delay ?? 1000;
|
|
114
|
+
let lastError;
|
|
115
|
+
for (let attempt = 1;attempt <= maxAttempts; attempt++) {
|
|
116
|
+
if (abort?.aborted) {
|
|
117
|
+
return { error: "Execution aborted" };
|
|
118
|
+
}
|
|
119
|
+
try {
|
|
120
|
+
const output = await this.executeWithTimeout(input, abort);
|
|
121
|
+
return { output };
|
|
122
|
+
} catch (error) {
|
|
123
|
+
lastError = error instanceof Error ? error : new Error(String(error));
|
|
124
|
+
if (attempt < maxAttempts) {
|
|
125
|
+
const delay = this.calculateBackoff(backoff, initialDelay, attempt - 1);
|
|
126
|
+
await this.sleep(delay, abort);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return { error: lastError?.message || "Unknown error" };
|
|
131
|
+
}
|
|
132
|
+
async executeWithTimeout(input, abort) {
|
|
133
|
+
if (!this.timeout) {
|
|
134
|
+
return this.instance[this.methodName](input);
|
|
135
|
+
}
|
|
136
|
+
const timeoutPromise = new Promise((_, reject) => {
|
|
137
|
+
setTimeout(() => {
|
|
138
|
+
reject(new Error(`Execution timeout after ${this.timeout}ms`));
|
|
139
|
+
}, this.timeout);
|
|
140
|
+
});
|
|
141
|
+
return Promise.race([
|
|
142
|
+
this.instance[this.methodName](input),
|
|
143
|
+
timeoutPromise
|
|
144
|
+
]);
|
|
145
|
+
}
|
|
146
|
+
calculateBackoff(backoff, initialDelay, attempt) {
|
|
147
|
+
if (backoff === "exponential") {
|
|
148
|
+
return initialDelay * Math.pow(2, attempt);
|
|
149
|
+
}
|
|
150
|
+
return initialDelay;
|
|
151
|
+
}
|
|
152
|
+
sleep(ms, abort) {
|
|
153
|
+
return new Promise((resolve) => {
|
|
154
|
+
const timeout = setTimeout(resolve, ms);
|
|
155
|
+
abort?.addEventListener("abort", () => {
|
|
156
|
+
clearTimeout(timeout);
|
|
157
|
+
resolve();
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// packages/core/src/env/workflow/decorators/workflow.ts
|
|
164
|
+
import"reflect-metadata";
|
|
165
|
+
|
|
166
|
+
// packages/core/src/env/workflow/metadata/keys.ts
|
|
167
|
+
var WORKFLOW_METADATA_KEY = Symbol("workflow:metadata");
|
|
168
|
+
var NODE_METADATA_KEY = Symbol("workflow:node");
|
|
169
|
+
var EDGE_METADATA_KEY = Symbol("workflow:edges");
|
|
170
|
+
|
|
171
|
+
// packages/core/src/env/workflow/decorators/workflow.ts
|
|
172
|
+
function Workflow(options) {
|
|
173
|
+
return function(target) {
|
|
174
|
+
const metadata = {
|
|
175
|
+
name: options.name,
|
|
176
|
+
version: options.version || "1.0",
|
|
177
|
+
description: options.description,
|
|
178
|
+
entry: options.entry,
|
|
179
|
+
config: options.config,
|
|
180
|
+
tags: options.tags || [],
|
|
181
|
+
author: options.author
|
|
182
|
+
};
|
|
183
|
+
Reflect.defineMetadata(WORKFLOW_METADATA_KEY, metadata, target);
|
|
184
|
+
return target;
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
function getWorkflowMetadata(target) {
|
|
188
|
+
return Reflect.getMetadata(WORKFLOW_METADATA_KEY, target);
|
|
189
|
+
}
|
|
190
|
+
// packages/core/src/env/workflow/decorators/node-as.ts
|
|
191
|
+
import"reflect-metadata";
|
|
192
|
+
function NodeAs(options = {}) {
|
|
193
|
+
return function(target, propertyKey, descriptor) {
|
|
194
|
+
const methodName = String(propertyKey);
|
|
195
|
+
const nodeMetadata = {
|
|
196
|
+
nodeId: options.nodeId || methodName,
|
|
197
|
+
nodeType: options.nodeType || "tool",
|
|
198
|
+
name: options.name,
|
|
199
|
+
dependsOn: normalizeDependsOn(options.dependsOn),
|
|
200
|
+
condition: options.condition,
|
|
201
|
+
retry: options.retry,
|
|
202
|
+
timeout: options.timeout,
|
|
203
|
+
config: options.config || {},
|
|
204
|
+
methodName,
|
|
205
|
+
method: descriptor.value
|
|
206
|
+
};
|
|
207
|
+
const existingNodes = Reflect.getMetadata(NODE_METADATA_KEY, target) || [];
|
|
208
|
+
const existingIndex = existingNodes.findIndex((n) => n.methodName === methodName);
|
|
209
|
+
if (existingIndex >= 0) {
|
|
210
|
+
existingNodes[existingIndex] = nodeMetadata;
|
|
211
|
+
} else {
|
|
212
|
+
existingNodes.push(nodeMetadata);
|
|
213
|
+
}
|
|
214
|
+
Reflect.defineMetadata(NODE_METADATA_KEY, existingNodes, target);
|
|
215
|
+
return descriptor;
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
function normalizeDependsOn(dependsOn) {
|
|
219
|
+
if (!dependsOn) {
|
|
220
|
+
return [];
|
|
221
|
+
}
|
|
222
|
+
return Array.isArray(dependsOn) ? dependsOn : [dependsOn];
|
|
223
|
+
}
|
|
224
|
+
function getNodeMetadatas(target) {
|
|
225
|
+
return Reflect.getMetadata(NODE_METADATA_KEY, target) || [];
|
|
226
|
+
}
|
|
227
|
+
// packages/core/src/env/workflow/decorators/edge.ts
|
|
228
|
+
import"reflect-metadata";
|
|
229
|
+
function Edge(from, to) {
|
|
230
|
+
return function(target, propertyKey, descriptor) {
|
|
231
|
+
const edge = { from, to };
|
|
232
|
+
const existingEdges = Reflect.getMetadata(EDGE_METADATA_KEY, target) || [];
|
|
233
|
+
existingEdges.push(edge);
|
|
234
|
+
Reflect.defineMetadata(EDGE_METADATA_KEY, existingEdges, target);
|
|
235
|
+
return descriptor;
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
function WorkflowEdges(edges) {
|
|
239
|
+
return function(target) {
|
|
240
|
+
const edgeMetadatas = edges.map((edge) => ({
|
|
241
|
+
from: edge.from,
|
|
242
|
+
to: edge.to,
|
|
243
|
+
condition: edge.condition
|
|
244
|
+
}));
|
|
245
|
+
Reflect.defineMetadata(EDGE_METADATA_KEY, edgeMetadatas, target);
|
|
246
|
+
return target;
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
function getEdgeMetadatas(target) {
|
|
250
|
+
return Reflect.getMetadata(EDGE_METADATA_KEY, target) || [];
|
|
251
|
+
}
|
|
252
|
+
// packages/core/src/env/workflow/extractor/workflow-converter.ts
|
|
253
|
+
import"reflect-metadata";
|
|
254
|
+
class WorkflowConverter {
|
|
255
|
+
static extractWorkflowMetadata(targetClass) {
|
|
256
|
+
return getWorkflowMetadata(targetClass);
|
|
257
|
+
}
|
|
258
|
+
static extractNodeMetadatas(targetClass) {
|
|
259
|
+
return getNodeMetadatas(targetClass.prototype);
|
|
260
|
+
}
|
|
261
|
+
static extractEdgeMetadatas(targetClass) {
|
|
262
|
+
return getEdgeMetadatas(targetClass);
|
|
263
|
+
}
|
|
264
|
+
static fromClass(targetClass, instance) {
|
|
265
|
+
const workflowMeta = this.extractWorkflowMetadata(targetClass);
|
|
266
|
+
if (!workflowMeta) {
|
|
267
|
+
throw new Error("Class must be decorated with @Workflow");
|
|
268
|
+
}
|
|
269
|
+
const nodeMetadatas = this.extractNodeMetadatas(targetClass);
|
|
270
|
+
if (nodeMetadatas.length === 0) {
|
|
271
|
+
throw new Error("At least one method must be decorated with @NodeAs");
|
|
272
|
+
}
|
|
273
|
+
const edgeMetadatas = this.extractEdgeMetadatas(targetClass);
|
|
274
|
+
const nodeMap = this.buildNodeMap(nodeMetadatas, edgeMetadatas);
|
|
275
|
+
const nodes = Array.from(nodeMap.values()).map((meta) => ({
|
|
276
|
+
id: meta.nodeId,
|
|
277
|
+
type: meta.nodeType,
|
|
278
|
+
name: meta.name,
|
|
279
|
+
config: {
|
|
280
|
+
...meta.config,
|
|
281
|
+
_methodName: meta.methodName,
|
|
282
|
+
_instance: instance
|
|
283
|
+
},
|
|
284
|
+
depends_on: meta.dependsOn,
|
|
285
|
+
condition: meta.condition,
|
|
286
|
+
retry: meta.retry,
|
|
287
|
+
timeout: meta.timeout
|
|
288
|
+
}));
|
|
289
|
+
const entry = workflowMeta.entry || nodeMetadatas[0]?.nodeId || "unknown";
|
|
290
|
+
return {
|
|
291
|
+
name: workflowMeta.name,
|
|
292
|
+
version: workflowMeta.version || "1.0",
|
|
293
|
+
description: workflowMeta.description,
|
|
294
|
+
config: workflowMeta.config || {},
|
|
295
|
+
nodes,
|
|
296
|
+
entry,
|
|
297
|
+
outputs: [],
|
|
298
|
+
metadata: {
|
|
299
|
+
tags: workflowMeta.tags || [],
|
|
300
|
+
author: workflowMeta.author
|
|
301
|
+
}
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
static buildNodeMap(nodeMetadatas, edgeMetadatas) {
|
|
305
|
+
const nodeMap = new Map;
|
|
306
|
+
for (const nodeMeta of nodeMetadatas) {
|
|
307
|
+
nodeMap.set(nodeMeta.nodeId, { ...nodeMeta });
|
|
308
|
+
}
|
|
309
|
+
for (const edge of edgeMetadatas) {
|
|
310
|
+
const targetNode = nodeMap.get(edge.to);
|
|
311
|
+
if (targetNode) {
|
|
312
|
+
if (!targetNode.dependsOn.includes(edge.from)) {
|
|
313
|
+
targetNode.dependsOn = [...targetNode.dependsOn, edge.from];
|
|
314
|
+
}
|
|
315
|
+
if (edge.condition) {
|
|
316
|
+
if (targetNode.condition) {
|
|
317
|
+
targetNode.condition = `(${targetNode.condition}) AND (${edge.condition})`;
|
|
318
|
+
} else {
|
|
319
|
+
targetNode.condition = edge.condition;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
return nodeMap;
|
|
325
|
+
}
|
|
326
|
+
static validateWorkflowClass(targetClass) {
|
|
327
|
+
const errors = [];
|
|
328
|
+
const warnings = [];
|
|
329
|
+
const workflowMeta = this.extractWorkflowMetadata(targetClass);
|
|
330
|
+
if (!workflowMeta) {
|
|
331
|
+
errors.push("Class must be decorated with @Workflow");
|
|
332
|
+
return { valid: false, errors, warnings };
|
|
333
|
+
}
|
|
334
|
+
const nodeMetadatas = this.extractNodeMetadatas(targetClass);
|
|
335
|
+
if (nodeMetadatas.length === 0) {
|
|
336
|
+
errors.push("At least one method must be decorated with @NodeAs");
|
|
337
|
+
return { valid: false, errors, warnings };
|
|
338
|
+
}
|
|
339
|
+
const entry = workflowMeta.entry;
|
|
340
|
+
if (entry) {
|
|
341
|
+
const entries = Array.isArray(entry) ? entry : [entry];
|
|
342
|
+
for (const e of entries) {
|
|
343
|
+
if (!nodeMetadatas.find((n) => n.nodeId === e)) {
|
|
344
|
+
errors.push(`Entry node '${e}' not found`);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
for (const node of nodeMetadatas) {
|
|
349
|
+
for (const dep of node.dependsOn) {
|
|
350
|
+
if (!nodeMetadatas.find((n) => n.nodeId === dep)) {
|
|
351
|
+
errors.push(`Node '${node.nodeId}' depends on non-existent node '${dep}'`);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
if (this.hasCycle(nodeMetadatas)) {
|
|
356
|
+
errors.push("Workflow contains a cycle");
|
|
357
|
+
}
|
|
358
|
+
return {
|
|
359
|
+
valid: errors.length === 0,
|
|
360
|
+
errors,
|
|
361
|
+
warnings
|
|
362
|
+
};
|
|
363
|
+
}
|
|
364
|
+
static hasCycle(nodeMetadatas) {
|
|
365
|
+
const visited = new Set;
|
|
366
|
+
const recStack = new Set;
|
|
367
|
+
const adjList = new Map;
|
|
368
|
+
for (const node of nodeMetadatas) {
|
|
369
|
+
adjList.set(node.nodeId, []);
|
|
370
|
+
}
|
|
371
|
+
for (const node of nodeMetadatas) {
|
|
372
|
+
for (const dep of node.dependsOn) {
|
|
373
|
+
const deps = adjList.get(dep);
|
|
374
|
+
if (deps) {
|
|
375
|
+
deps.push(node.nodeId);
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
const dfs = (nodeId) => {
|
|
380
|
+
visited.add(nodeId);
|
|
381
|
+
recStack.add(nodeId);
|
|
382
|
+
const neighbors = adjList.get(nodeId) || [];
|
|
383
|
+
for (const neighbor of neighbors) {
|
|
384
|
+
if (!visited.has(neighbor)) {
|
|
385
|
+
if (dfs(neighbor)) {
|
|
386
|
+
return true;
|
|
387
|
+
}
|
|
388
|
+
} else if (recStack.has(neighbor)) {
|
|
389
|
+
return true;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
recStack.delete(nodeId);
|
|
393
|
+
return false;
|
|
394
|
+
};
|
|
395
|
+
for (const node of nodeMetadatas) {
|
|
396
|
+
if (!visited.has(node.nodeId)) {
|
|
397
|
+
if (dfs(node.nodeId)) {
|
|
398
|
+
return true;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
return false;
|
|
403
|
+
}
|
|
404
|
+
static async executeNode(nodeDef, context) {
|
|
405
|
+
const instance = nodeDef.config._instance;
|
|
406
|
+
const methodName = nodeDef.config._methodName;
|
|
407
|
+
if (!instance || !methodName) {
|
|
408
|
+
return { output: undefined, error: new Error("Missing method information") };
|
|
409
|
+
}
|
|
410
|
+
const method = instance[methodName];
|
|
411
|
+
if (typeof method !== "function") {
|
|
412
|
+
return { output: undefined, error: new Error(`Method ${methodName} is not a function`) };
|
|
413
|
+
}
|
|
414
|
+
const deps = nodeDef.depends_on || [];
|
|
415
|
+
let input = context.input;
|
|
416
|
+
if (deps.length > 0) {
|
|
417
|
+
input = {};
|
|
418
|
+
for (const depId of deps) {
|
|
419
|
+
input[depId] = context.previousOutputs.get(depId);
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
try {
|
|
423
|
+
const result = await method.call(instance, input);
|
|
424
|
+
return { output: result };
|
|
425
|
+
} catch (error) {
|
|
426
|
+
return {
|
|
427
|
+
output: undefined,
|
|
428
|
+
error: error instanceof Error ? error : new Error(String(error))
|
|
429
|
+
};
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
// packages/core/src/env/workflow/utils/create-workflow.ts
|
|
434
|
+
function createWorkflowFromClass(targetClass, options) {
|
|
435
|
+
const instance = options?.instance ?? new targetClass(...options?.constructorArgs ?? []);
|
|
436
|
+
return WorkflowConverter.fromClass(targetClass, instance);
|
|
437
|
+
}
|
|
438
|
+
export {
|
|
439
|
+
getWorkflowMetadata,
|
|
440
|
+
getNodeMetadatas,
|
|
441
|
+
getEdgeMetadatas,
|
|
442
|
+
createWorkflowFromClass,
|
|
443
|
+
WorkflowEdges,
|
|
444
|
+
WorkflowConverter,
|
|
445
|
+
Workflow,
|
|
446
|
+
NodeAs,
|
|
447
|
+
Edge,
|
|
448
|
+
DecoratorNode
|
|
449
|
+
};
|