foliko 2.0.22 → 2.0.23
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/.editorconfig +56 -56
- package/.lintstagedrc +7 -7
- package/.prettierignore +29 -29
- package/.prettierrc +11 -11
- package/Dockerfile +63 -63
- package/install.ps1 +129 -129
- package/install.sh +121 -121
- package/package.json +2 -5
- package/plugins/core/workflow/context.js +941 -941
- package/plugins/core/workflow/engine.js +66 -66
- package/plugins/core/workflow/js-runner.js +318 -318
- package/plugins/core/workflow/json-runner.js +323 -323
- package/plugins/core/workflow/stages/choice.js +74 -74
- package/plugins/core/workflow/stages/each.js +123 -123
- package/plugins/core/workflow/stages/parallel.js +69 -69
- package/skills/find-skills/SKILL.md +133 -133
- package/src/agent/chat.js +188 -221
- package/src/agent/sub.js +28 -25
- package/src/agent/tool-loop.js +648 -0
- package/src/llm/provider.js +12 -28
- package/src/plugin/base.js +17 -14
- package/src/plugin/manager.js +19 -0
- package/tests/core/chat-tool.test.js +187 -187
- package/tests/core/disable-thinking.test.js +64 -0
- package/tests/core/reasoning-content.test.js +129 -0
- package/tests/core/strip-stale-tool-calls.test.js +154 -0
- package/tests/core/tool-loop.test.js +208 -0
|
@@ -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 };
|