foliko 2.0.7 → 2.0.9

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.
@@ -1,66 +1,66 @@
1
- /**
2
- * FlowEngine v2 - Main entry point for v2 workflow system
3
- * Supports JSON and JS workflow formats
4
- */
5
-
6
- const { JsonRunner } = require('./json-runner');
7
- const { JsRunner } = require('./js-runner');
8
-
9
- class FlowEngine {
10
- constructor(framework) {
11
- this.framework = framework;
12
- this._jsonRunner = new JsonRunner(framework);
13
- this._jsRunner = new JsRunner(framework);
14
- this._log = require('../../../src/common/logger').logger.child('FlowEngine');
15
- }
16
-
17
- /**
18
- * Execute a workflow
19
- * @param {Object|string} workflow - Workflow definition
20
- * @param {Object} input - Input data
21
- * @param {string} sessionId - Session ID
22
- * @returns {Promise<Object>} execution result
23
- */
24
- async execute(workflow, input = {}, sessionId = null) {
25
- // Parse workflow if string
26
- if (typeof workflow === 'string') {
27
- try {
28
- workflow = JSON.parse(workflow);
29
- // It's JSON, use JsonRunner
30
- return await this._jsonRunner.execute(workflow, input, sessionId);
31
- } catch {
32
- // Not JSON, treat as JS workflow
33
- return await this._jsRunner.execute(workflow, input, sessionId);
34
- }
35
- }
36
-
37
- // Object format detection
38
- // v2 JSON: has flow + stages
39
- if (workflow.flow && Array.isArray(workflow.stages)) {
40
- return await this._jsonRunner.execute(workflow, input, sessionId);
41
- }
42
-
43
- // Assume JS format if it's a function (exported)
44
- if (typeof workflow === 'function') {
45
- return await this._jsRunner.execute(workflow, input, sessionId);
46
- }
47
-
48
- throw new Error(`Invalid workflow format. Expected { flow, stages } or JS function.`);
49
- }
50
-
51
- /**
52
- * Get the JSON runner for direct access
53
- */
54
- getJsonRunner() {
55
- return this._jsonRunner;
56
- }
57
-
58
- /**
59
- * Get the JS runner for direct access
60
- */
61
- getJsRunner() {
62
- return this._jsRunner;
63
- }
64
- }
65
-
66
- module.exports = { FlowEngine };
1
+ /**
2
+ * FlowEngine v2 - Main entry point for v2 workflow system
3
+ * Supports JSON and JS workflow formats
4
+ */
5
+
6
+ const { JsonRunner } = require('./json-runner');
7
+ const { JsRunner } = require('./js-runner');
8
+
9
+ class FlowEngine {
10
+ constructor(framework) {
11
+ this.framework = framework;
12
+ this._jsonRunner = new JsonRunner(framework);
13
+ this._jsRunner = new JsRunner(framework);
14
+ this._log = require('../../../src/common/logger').logger.child('FlowEngine');
15
+ }
16
+
17
+ /**
18
+ * Execute a workflow
19
+ * @param {Object|string} workflow - Workflow definition
20
+ * @param {Object} input - Input data
21
+ * @param {string} sessionId - Session ID
22
+ * @returns {Promise<Object>} execution result
23
+ */
24
+ async execute(workflow, input = {}, sessionId = null) {
25
+ // Parse workflow if string
26
+ if (typeof workflow === 'string') {
27
+ try {
28
+ workflow = JSON.parse(workflow);
29
+ // It's JSON, use JsonRunner
30
+ return await this._jsonRunner.execute(workflow, input, sessionId);
31
+ } catch {
32
+ // Not JSON, treat as JS workflow
33
+ return await this._jsRunner.execute(workflow, input, sessionId);
34
+ }
35
+ }
36
+
37
+ // Object format detection
38
+ // v2 JSON: has flow + stages
39
+ if (workflow.flow && Array.isArray(workflow.stages)) {
40
+ return await this._jsonRunner.execute(workflow, input, sessionId);
41
+ }
42
+
43
+ // Assume JS format if it's a function (exported)
44
+ if (typeof workflow === 'function') {
45
+ return await this._jsRunner.execute(workflow, input, sessionId);
46
+ }
47
+
48
+ throw new Error(`Invalid workflow format. Expected { flow, stages } or JS function.`);
49
+ }
50
+
51
+ /**
52
+ * Get the JSON runner for direct access
53
+ */
54
+ getJsonRunner() {
55
+ return this._jsonRunner;
56
+ }
57
+
58
+ /**
59
+ * Get the JS runner for direct access
60
+ */
61
+ getJsRunner() {
62
+ return this._jsRunner;
63
+ }
64
+ }
65
+
66
+ module.exports = { FlowEngine };
@@ -876,8 +876,8 @@ class WorkflowPlugin extends Plugin {
876
876
  constructor(config = {}) {
877
877
  super();
878
878
  this.name = 'workflow';
879
- this.version = '1.0.0';
880
- this.description = '工作流引擎,支持结构化工作流定义和执行';
879
+ this.version = '2.0.0';
880
+ this.description = '工作流引擎 v2(FlowEngine + JsonRunner + JsRunner + FlowContext)';
881
881
  this.priority = 6;
882
882
  this.system = true;
883
883
  this._framework = null;