foliko 2.0.6 → 2.0.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/.claude/settings.local.json +2 -1
- package/docs/public-api.md +3 -3
- package/examples/workflow.js +62 -57
- package/package.json +2 -3
- package/plugins/core/scheduler/CHANGELOG.md +31 -0
- package/plugins/core/scheduler/index.js +576 -638
- package/plugins/core/workflow/context.js +941 -0
- package/plugins/core/workflow/engine.js +66 -0
- package/plugins/core/workflow/examples/01-basic.js +42 -0
- package/plugins/core/workflow/examples/01-basic.json +30 -0
- package/plugins/core/workflow/examples/02-choice.js +75 -0
- package/plugins/core/workflow/examples/02-choice.json +59 -0
- package/plugins/core/workflow/examples/03-chain-style.js +114 -0
- package/plugins/core/workflow/examples/03-each.json +41 -0
- package/plugins/core/workflow/examples/04-parallel.js +52 -0
- package/plugins/core/workflow/examples/04-parallel.json +51 -0
- package/plugins/core/workflow/examples/05-chain-style.json +68 -0
- package/plugins/core/workflow/examples/05-each.js +65 -0
- package/plugins/core/workflow/examples/06-script.js +82 -0
- package/plugins/core/workflow/examples/07-module-export.js +43 -0
- package/plugins/core/workflow/examples/08-default-export.js +29 -0
- package/plugins/core/workflow/examples/09-next-with-args.js +50 -0
- package/plugins/core/workflow/examples/10-logger.js +34 -0
- package/plugins/core/workflow/examples/11-storage.js +68 -0
- package/plugins/core/workflow/examples/simple.js +77 -0
- package/plugins/core/workflow/examples/simple.json +75 -0
- package/plugins/core/workflow/index.js +124 -58
- package/plugins/core/workflow/js-runner.js +318 -0
- package/plugins/core/workflow/json-runner.js +323 -0
- package/plugins/core/workflow/stages/action.js +211 -0
- package/plugins/core/workflow/stages/choice.js +74 -0
- package/plugins/core/workflow/stages/delay.js +73 -0
- package/plugins/core/workflow/stages/each.js +123 -0
- package/plugins/core/workflow/stages/parallel.js +69 -0
- package/plugins/core/workflow/stages/try.js +142 -0
- package/plugins/executors/data-splitter/index.js +3 -2
- package/plugins/memory/index.js +10 -3
- package/sandbox/check-context.js +5 -0
- package/sandbox/test-context.js +27 -0
- package/sandbox/test-fixes.js +40 -0
- package/sandbox/test-hello-js.js +46 -0
- package/skills/workflows/SKILL.md +715 -613
- package/src/agent/chat.js +8 -1
- package/src/agent/main.js +5 -1
- package/src/cli/ui/chat-ui.js +4 -3
- package/src/common/json-safe.js +20 -0
- package/src/framework/framework.js +58 -2
- package/src/index.js +10 -0
- package/src/plugin/base.js +7 -4
- package/src/plugin/manager.js +95 -1
- package/src/utils/sandbox.js +1 -1
- package/skills/workflows/workflow-troubleshooting/DEBUGGING.md +0 -197
- package/skills/workflows/workflow-troubleshooting/SKILL.md +0 -331
|
@@ -1,331 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: workflow-troubleshooting
|
|
3
|
-
description: 工作流故障排除与修复指南。当工作流执行失败、工具调用失败、模板变量问题时调用此技能。
|
|
4
|
-
allowed-tools: python-executor, shell, read_file, write_file, execute_workflow, workflow_reload
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# 工作流故障排除指南
|
|
8
|
-
|
|
9
|
-
## 常见问题与解决方案
|
|
10
|
-
|
|
11
|
-
### 1. Unknown step type 错误
|
|
12
|
-
|
|
13
|
-
**原因**:使用了不支持的步骤类型,如 `action: "ext_call"`
|
|
14
|
-
|
|
15
|
-
**解决方案**:使用 `type: "tool"` + `tool: "ext_call"` 调用扩展工具
|
|
16
|
-
|
|
17
|
-
```json
|
|
18
|
-
// ❌ 错误
|
|
19
|
-
{ "action": "ext_call", "params": { ... } }
|
|
20
|
-
|
|
21
|
-
// ✅ 正确
|
|
22
|
-
{
|
|
23
|
-
"type": "tool",
|
|
24
|
-
"tool": "ext_call",
|
|
25
|
-
"args": {
|
|
26
|
-
"plugin": "skill",
|
|
27
|
-
"tool": "creator:creator",
|
|
28
|
-
"args": { "command": "-r 16:9" }
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
### 2. 工具参数问题:args vs params
|
|
34
|
-
|
|
35
|
-
**原因**:工作流引擎使用 `args` 字段传递工具参数,不是 `params`
|
|
36
|
-
|
|
37
|
-
**解决方案**:
|
|
38
|
-
|
|
39
|
-
```json
|
|
40
|
-
// ❌ 错误
|
|
41
|
-
{ "type": "tool", "tool": "fetch", "params": { "url": "https://..." } }
|
|
42
|
-
|
|
43
|
-
// ✅ 正确
|
|
44
|
-
{ "type": "tool", "tool": "fetch", "args": { "url": "https://..." } }
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
### 3. loop 循环语法错误
|
|
48
|
-
|
|
49
|
-
**正确语法**:
|
|
50
|
-
|
|
51
|
-
**固定次数循环**:
|
|
52
|
-
```json
|
|
53
|
-
{
|
|
54
|
-
"type": "loop",
|
|
55
|
-
"maxIterations": 10,
|
|
56
|
-
"loopVariable": "i",
|
|
57
|
-
"steps": [...]
|
|
58
|
-
}
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
**数组迭代循环(over)**:
|
|
62
|
-
```json
|
|
63
|
-
{
|
|
64
|
-
"type": "loop",
|
|
65
|
-
"over": "input.slides",
|
|
66
|
-
"as": "slide",
|
|
67
|
-
"index": "slideIndex",
|
|
68
|
-
"maxIterations": 10,
|
|
69
|
-
"steps": [...]
|
|
70
|
-
}
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
- `over`: 要迭代的数组路径
|
|
74
|
-
- `as`: 每个元素的变量名
|
|
75
|
-
- `index`: 索引变量名(从 0 开始)
|
|
76
|
-
|
|
77
|
-
- `maxIterations`: 最大迭代次数(必填)
|
|
78
|
-
- `loopVariable`: 循环计数器变量名(默认 `loopIndex`)
|
|
79
|
-
- `steps`: 循环执行的步骤数组
|
|
80
|
-
|
|
81
|
-
### 4. condition 条件语法错误
|
|
82
|
-
|
|
83
|
-
**原因**:使用了不存在的字段如 `if`、`then`
|
|
84
|
-
|
|
85
|
-
**正确语法**:
|
|
86
|
-
|
|
87
|
-
```json
|
|
88
|
-
{
|
|
89
|
-
"type": "condition",
|
|
90
|
-
"branches": [
|
|
91
|
-
{
|
|
92
|
-
"name": "条件1",
|
|
93
|
-
"condition": "context.variables.value > 10",
|
|
94
|
-
"steps": [...]
|
|
95
|
-
}
|
|
96
|
-
],
|
|
97
|
-
"defaultBranch": {
|
|
98
|
-
"steps": [...]
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
- `condition`: JavaScript 表达式字符串
|
|
104
|
-
- `branches`: 条件分支数组
|
|
105
|
-
- `defaultBranch`: 默认分支(可选)
|
|
106
|
-
|
|
107
|
-
### 5. switch 分支语法错误
|
|
108
|
-
|
|
109
|
-
**正确语法**:
|
|
110
|
-
|
|
111
|
-
```json
|
|
112
|
-
{
|
|
113
|
-
"type": "switch",
|
|
114
|
-
"value": "{{status}}",
|
|
115
|
-
"branches": [
|
|
116
|
-
{ "case": "success", "steps": [...] },
|
|
117
|
-
{ "case": "error", "steps": [...] }
|
|
118
|
-
],
|
|
119
|
-
"default": { "steps": [...] }
|
|
120
|
-
}
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
- `value`: 要匹配的值,支持 `{{variable}}` 引用
|
|
124
|
-
- `branches`: 分支数组,匹配 `case` 等于 `value` 的分支
|
|
125
|
-
- `default`: 默认分支
|
|
126
|
-
|
|
127
|
-
### 6. try-catch 语法错误
|
|
128
|
-
|
|
129
|
-
**正确语法**:
|
|
130
|
-
|
|
131
|
-
```json
|
|
132
|
-
{
|
|
133
|
-
"type": "try",
|
|
134
|
-
"try": {
|
|
135
|
-
"steps": [
|
|
136
|
-
{ "type": "tool", "tool": "可能失败的工具", "args": {} }
|
|
137
|
-
]
|
|
138
|
-
},
|
|
139
|
-
"catch": {
|
|
140
|
-
"steps": [...]
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
```
|
|
144
|
-
|
|
145
|
-
### 7. parallel 并行执行语法
|
|
146
|
-
|
|
147
|
-
**正确语法**:
|
|
148
|
-
|
|
149
|
-
```json
|
|
150
|
-
{
|
|
151
|
-
"type": "parallel",
|
|
152
|
-
"steps": [
|
|
153
|
-
{ "type": "tool", "tool": "task1", "args": {} },
|
|
154
|
-
{ "type": "tool", "tool": "task2", "args": {} }
|
|
155
|
-
]
|
|
156
|
-
}
|
|
157
|
-
```
|
|
158
|
-
|
|
159
|
-
## 调试技巧
|
|
160
|
-
|
|
161
|
-
### 1. 先单独测试每个步骤
|
|
162
|
-
|
|
163
|
-
创建简单的单步骤工作流验证工具是否可用:
|
|
164
|
-
|
|
165
|
-
```json
|
|
166
|
-
{
|
|
167
|
-
"name": "test-tool",
|
|
168
|
-
"steps": [
|
|
169
|
-
{
|
|
170
|
-
"type": "tool",
|
|
171
|
-
"name": "测试",
|
|
172
|
-
"tool": "notification_send",
|
|
173
|
-
"args": { "message": "测试消息" }
|
|
174
|
-
}
|
|
175
|
-
]
|
|
176
|
-
}
|
|
177
|
-
```
|
|
178
|
-
|
|
179
|
-
### 2. 使用 script 步骤调试变量
|
|
180
|
-
|
|
181
|
-
```json
|
|
182
|
-
{
|
|
183
|
-
"type": "script",
|
|
184
|
-
"name": "调试变量",
|
|
185
|
-
"outputVariable": "debug",
|
|
186
|
-
"script": "return JSON.stringify(context.variables, null, 2);"
|
|
187
|
-
}
|
|
188
|
-
```
|
|
189
|
-
|
|
190
|
-
### 3. 检查工具是否存在
|
|
191
|
-
|
|
192
|
-
使用 `workflow_list` 工具查看所有已注册的工作流工具。
|
|
193
|
-
|
|
194
|
-
### 4. 变量引用格式
|
|
195
|
-
|
|
196
|
-
| 格式 | 说明 |
|
|
197
|
-
| ---- | ---- |
|
|
198
|
-
| `{{result}}` | 上一步完整结果 |
|
|
199
|
-
| `{{result.field}}` | 从结果提取字段 |
|
|
200
|
-
| `{{lastResult}}` | result 的别名 |
|
|
201
|
-
| `{{variables.x}}` | 显式引用 variables |
|
|
202
|
-
| `{{input.x}}` | 引用工作流输入 |
|
|
203
|
-
| `${stepId.output}` | 引用指定步骤输出(兼容旧格式) |
|
|
204
|
-
|
|
205
|
-
## 完整工作流示例
|
|
206
|
-
|
|
207
|
-
### 示例:使用 ext_call 调用 skill 命令
|
|
208
|
-
|
|
209
|
-
```json
|
|
210
|
-
{
|
|
211
|
-
"name": "video-creator",
|
|
212
|
-
"description": "视频创作工作流示例",
|
|
213
|
-
"input": {
|
|
214
|
-
"title": "测试视频",
|
|
215
|
-
"slides": ["slide1", "slide2"]
|
|
216
|
-
},
|
|
217
|
-
"steps": [
|
|
218
|
-
{
|
|
219
|
-
"type": "tool",
|
|
220
|
-
"name": "创建项目",
|
|
221
|
-
"tool": "ext_call",
|
|
222
|
-
"args": {
|
|
223
|
-
"plugin": "skill",
|
|
224
|
-
"tool": "creator:creator",
|
|
225
|
-
"args": {
|
|
226
|
-
"command": "-r 16:9 -t true -v female-shaonv-jingpin"
|
|
227
|
-
}
|
|
228
|
-
},
|
|
229
|
-
"outputVariable": "videoId"
|
|
230
|
-
},
|
|
231
|
-
{
|
|
232
|
-
"type": "tool",
|
|
233
|
-
"name": "添加片头",
|
|
234
|
-
"tool": "ext_call",
|
|
235
|
-
"args": {
|
|
236
|
-
"plugin": "skill",
|
|
237
|
-
"tool": "creator:addCover",
|
|
238
|
-
"args": {
|
|
239
|
-
"command": "-i {{videoId}} -t '{{input.title}}'"
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
},
|
|
243
|
-
{
|
|
244
|
-
"type": "loop",
|
|
245
|
-
"name": "添加幻灯片",
|
|
246
|
-
"maxIterations": 10,
|
|
247
|
-
"loopVariable": "i",
|
|
248
|
-
"steps": [
|
|
249
|
-
{
|
|
250
|
-
"type": "condition",
|
|
251
|
-
"name": "检查是否还有幻灯片",
|
|
252
|
-
"branches": [
|
|
253
|
-
{
|
|
254
|
-
"name": "有幻灯片",
|
|
255
|
-
"condition": "context.variables.i < context.input.slides.length",
|
|
256
|
-
"steps": [
|
|
257
|
-
{
|
|
258
|
-
"type": "tool",
|
|
259
|
-
"name": "添加幻灯片",
|
|
260
|
-
"tool": "ext_call",
|
|
261
|
-
"args": {
|
|
262
|
-
"plugin": "skill",
|
|
263
|
-
"tool": "creator:addSlide",
|
|
264
|
-
"args": {
|
|
265
|
-
"command": "-i {{videoId}} -n {{i}}"
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
]
|
|
270
|
-
}
|
|
271
|
-
]
|
|
272
|
-
}
|
|
273
|
-
]
|
|
274
|
-
},
|
|
275
|
-
{
|
|
276
|
-
"type": "tool",
|
|
277
|
-
"name": "渲染视频",
|
|
278
|
-
"tool": "ext_call",
|
|
279
|
-
"args": {
|
|
280
|
-
"plugin": "skill",
|
|
281
|
-
"tool": "creator:render",
|
|
282
|
-
"args": {
|
|
283
|
-
"command": "-i {{videoId}} -o output.mp4"
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
]
|
|
288
|
-
}
|
|
289
|
-
```
|
|
290
|
-
|
|
291
|
-
## 快速修复清单
|
|
292
|
-
|
|
293
|
-
| 问题 | 修复 |
|
|
294
|
-
| ---- | ---- |
|
|
295
|
-
| `Unknown step type: ext_call` | 改用 `type: "tool"` + `tool: "ext_call"` |
|
|
296
|
-
| 工具参数不传递 | 将 `params` 改为 `args` |
|
|
297
|
-
| loop 不执行 | 检查 `maxIterations` 和 `steps` 字段 |
|
|
298
|
-
| condition 不生效 | 使用 `condition` 字段,不是 `if` |
|
|
299
|
-
| switch 不匹配 | 确保有 `default` 分支兜底 |
|
|
300
|
-
| 变量引用失败 | 使用 `{{result}}` 而非 `${result}` |
|
|
301
|
-
|
|
302
|
-
## 成功案例
|
|
303
|
-
|
|
304
|
-
### 视频创作工作流(已验证)
|
|
305
|
-
|
|
306
|
-
```json
|
|
307
|
-
{
|
|
308
|
-
"name": "hot-news-video",
|
|
309
|
-
"steps": [
|
|
310
|
-
{
|
|
311
|
-
"type": "tool",
|
|
312
|
-
"tool": "ext_call",
|
|
313
|
-
"args": {
|
|
314
|
-
"plugin": "skill",
|
|
315
|
-
"tool": "creator:creator",
|
|
316
|
-
"args": { "command": "-r 16:9 -t true -v female-shaonv-jingpin" }
|
|
317
|
-
},
|
|
318
|
-
"outputVariable": "videoId"
|
|
319
|
-
},
|
|
320
|
-
{
|
|
321
|
-
"type": "tool",
|
|
322
|
-
"tool": "ext_call",
|
|
323
|
-
"args": {
|
|
324
|
-
"plugin": "skill",
|
|
325
|
-
"tool": "creator:addCover",
|
|
326
|
-
"args": { "command": "-i {{videoId}} -t '{{input.title}}'" }
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
]
|
|
330
|
-
}
|
|
331
|
-
```
|