foliko 1.0.74 → 1.0.76
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/.agent/.shared/ui-ux-pro-max/data/charts.csv +26 -0
- package/.agent/.shared/ui-ux-pro-max/data/colors.csv +97 -0
- package/.agent/.shared/ui-ux-pro-max/data/icons.csv +101 -0
- package/.agent/.shared/ui-ux-pro-max/data/landing.csv +31 -0
- package/.agent/.shared/ui-ux-pro-max/data/products.csv +97 -0
- package/.agent/.shared/ui-ux-pro-max/data/prompts.csv +24 -0
- package/.agent/.shared/ui-ux-pro-max/data/react-performance.csv +45 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/flutter.csv +53 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/html-tailwind.csv +56 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/jetpack-compose.csv +53 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/nextjs.csv +53 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/nuxt-ui.csv +51 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/nuxtjs.csv +59 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/react-native.csv +52 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/react.csv +54 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/shadcn.csv +61 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/svelte.csv +54 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/swiftui.csv +51 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/vue.csv +50 -0
- package/.agent/.shared/ui-ux-pro-max/data/styles.csv +59 -0
- package/.agent/.shared/ui-ux-pro-max/data/typography.csv +58 -0
- package/.agent/.shared/ui-ux-pro-max/data/ui-reasoning.csv +101 -0
- package/.agent/.shared/ui-ux-pro-max/data/ux-guidelines.csv +100 -0
- package/.agent/.shared/ui-ux-pro-max/data/web-interface.csv +31 -0
- package/.agent/.shared/ui-ux-pro-max/scripts/__pycache__/core.cpython-313.pyc +0 -0
- package/.agent/.shared/ui-ux-pro-max/scripts/__pycache__/design_system.cpython-313.pyc +0 -0
- package/.agent/.shared/ui-ux-pro-max/scripts/core.py +258 -0
- package/.agent/.shared/ui-ux-pro-max/scripts/design_system.py +1067 -0
- package/.agent/.shared/ui-ux-pro-max/scripts/search.py +106 -0
- package/.agent/ARCHITECTURE.md +288 -0
- package/.agent/agents/ambient-agent.md +57 -0
- package/.agent/agents/debugger.md +55 -0
- package/.agent/agents/email-assistant.md +49 -0
- package/.agent/agents/file-manager.md +42 -0
- package/.agent/agents/python-developer.md +60 -0
- package/.agent/agents/scheduler.md +59 -0
- package/.agent/agents/web-developer.md +45 -0
- package/.agent/data/default.json +29 -0
- package/.agent/data/plugins-state.json +255 -0
- package/.agent/mcp_config.json +4 -0
- package/.agent/mcp_config_updated.json +12 -0
- package/.agent/plugins.json +5 -0
- package/.agent/rules/GEMINI.md +273 -0
- package/.agent/rules/allow-rule.md +77 -0
- package/.agent/rules/log-rule.md +83 -0
- package/.agent/rules/security-rule.md +93 -0
- package/.agent/scripts/auto_preview.py +148 -0
- package/.agent/scripts/checklist.py +217 -0
- package/.agent/scripts/session_manager.py +120 -0
- package/.agent/scripts/verify_all.py +327 -0
- package/.agent/skills/api-patterns/SKILL.md +81 -0
- package/.agent/skills/api-patterns/api-style.md +42 -0
- package/.agent/skills/api-patterns/auth.md +24 -0
- package/.agent/skills/api-patterns/documentation.md +26 -0
- package/.agent/skills/api-patterns/graphql.md +41 -0
- package/.agent/skills/api-patterns/rate-limiting.md +31 -0
- package/.agent/skills/api-patterns/response.md +37 -0
- package/.agent/skills/api-patterns/rest.md +40 -0
- package/.agent/skills/api-patterns/scripts/api_validator.py +211 -0
- package/.agent/skills/api-patterns/security-testing.md +122 -0
- package/.agent/skills/api-patterns/trpc.md +41 -0
- package/.agent/skills/api-patterns/versioning.md +22 -0
- package/.agent/skills/app-builder/SKILL.md +75 -0
- package/.agent/skills/app-builder/agent-coordination.md +71 -0
- package/.agent/skills/app-builder/feature-building.md +53 -0
- package/.agent/skills/app-builder/project-detection.md +34 -0
- package/.agent/skills/app-builder/scaffolding.md +118 -0
- package/.agent/skills/app-builder/tech-stack.md +40 -0
- package/.agent/skills/app-builder/templates/SKILL.md +39 -0
- package/.agent/skills/app-builder/templates/astro-static/TEMPLATE.md +76 -0
- package/.agent/skills/app-builder/templates/chrome-extension/TEMPLATE.md +92 -0
- package/.agent/skills/app-builder/templates/cli-tool/TEMPLATE.md +88 -0
- package/.agent/skills/app-builder/templates/electron-desktop/TEMPLATE.md +88 -0
- package/.agent/skills/app-builder/templates/express-api/TEMPLATE.md +83 -0
- package/.agent/skills/app-builder/templates/flutter-app/TEMPLATE.md +90 -0
- package/.agent/skills/app-builder/templates/monorepo-turborepo/TEMPLATE.md +90 -0
- package/.agent/skills/app-builder/templates/nextjs-fullstack/TEMPLATE.md +122 -0
- package/.agent/skills/app-builder/templates/nextjs-saas/TEMPLATE.md +122 -0
- package/.agent/skills/app-builder/templates/nextjs-static/TEMPLATE.md +169 -0
- package/.agent/skills/app-builder/templates/nuxt-app/TEMPLATE.md +134 -0
- package/.agent/skills/app-builder/templates/python-fastapi/TEMPLATE.md +83 -0
- package/.agent/skills/app-builder/templates/react-native-app/TEMPLATE.md +119 -0
- package/.agent/skills/architecture/SKILL.md +55 -0
- package/.agent/skills/architecture/context-discovery.md +43 -0
- package/.agent/skills/architecture/examples.md +94 -0
- package/.agent/skills/architecture/pattern-selection.md +68 -0
- package/.agent/skills/architecture/patterns-reference.md +50 -0
- package/.agent/skills/architecture/trade-off-analysis.md +77 -0
- package/.agent/skills/clean-code/SKILL.md +201 -0
- package/.agent/skills/doc.md +177 -0
- package/.agent/skills/frontend-design/SKILL.md +418 -0
- package/.agent/skills/frontend-design/animation-guide.md +331 -0
- package/.agent/skills/frontend-design/color-system.md +311 -0
- package/.agent/skills/frontend-design/decision-trees.md +418 -0
- package/.agent/skills/frontend-design/motion-graphics.md +306 -0
- package/.agent/skills/frontend-design/scripts/accessibility_checker.py +183 -0
- package/.agent/skills/frontend-design/scripts/ux_audit.py +722 -0
- package/.agent/skills/frontend-design/typography-system.md +345 -0
- package/.agent/skills/frontend-design/ux-psychology.md +1116 -0
- package/.agent/skills/frontend-design/visual-effects.md +383 -0
- package/.agent/skills/i18n-localization/SKILL.md +154 -0
- package/.agent/skills/i18n-localization/scripts/i18n_checker.py +241 -0
- package/.agent/skills/mcp-builder/SKILL.md +176 -0
- package/.agent/skills/web-design-guidelines/SKILL.md +57 -0
- package/.agent/workflows/brainstorm.md +113 -0
- package/.agent/workflows/create.md +59 -0
- package/.agent/workflows/debug.md +103 -0
- package/.agent/workflows/deploy.md +176 -0
- package/.agent/workflows/enhance.md +63 -0
- package/.agent/workflows/orchestrate.md +237 -0
- package/.agent/workflows/plan.md +89 -0
- package/.agent/workflows/preview.md +81 -0
- package/.agent/workflows/simple-test.md +42 -0
- package/.agent/workflows/status.md +86 -0
- package/.agent/workflows/structured-orchestrate.md +180 -0
- package/.agent/workflows/test.md +144 -0
- package/.agent/workflows/ui-ux-pro-max.md +296 -0
- package/.claude/settings.local.json +11 -1
- package/.editorconfig +56 -0
- package/.husky/pre-commit +4 -0
- package/.lintstagedrc +7 -0
- package/.prettierignore +29 -0
- package/.prettierrc +11 -0
- package/CLAUDE.md +2 -0
- package/README.md +64 -55
- package/SPEC.md +102 -61
- package/cli/bin/foliko.js +11 -11
- package/cli/src/commands/chat.js +143 -141
- package/cli/src/commands/list.js +93 -90
- package/cli/src/index.js +75 -75
- package/cli/src/ui/chat-ui.js +201 -199
- package/cli/src/utils/ansi.js +40 -40
- package/cli/src/utils/markdown.js +292 -296
- package/docker-compose.yml +1 -1
- package/docs/ai-sdk-optimization.md +655 -643
- package/docs/features.md +80 -80
- package/docs/quick-reference.md +49 -46
- package/docs/user-manual.md +411 -380
- package/examples/ambient-example.js +194 -196
- package/examples/basic.js +50 -45
- package/examples/bootstrap.js +121 -112
- package/examples/mcp-example.js +19 -16
- package/examples/skill-example.js +20 -20
- package/examples/test-chat.js +137 -135
- package/examples/test-mcp.js +85 -79
- package/examples/test-reload.js +59 -61
- package/examples/test-telegram.js +50 -50
- package/examples/test-tg-bot.js +45 -42
- package/examples/test-tg-simple.js +47 -46
- package/examples/test-tg.js +62 -62
- package/examples/test-think.js +43 -37
- package/examples/test-web-plugin.js +103 -98
- package/examples/test-weixin-feishu.js +103 -100
- package/examples/workflow.js +158 -158
- package/package.json +37 -3
- package/plugins/ai-plugin.js +102 -100
- package/plugins/ambient-agent/EventWatcher.js +113 -0
- package/plugins/ambient-agent/ExplorerLoop.js +640 -0
- package/plugins/ambient-agent/GoalManager.js +197 -0
- package/plugins/ambient-agent/Reflector.js +95 -0
- package/plugins/ambient-agent/StateStore.js +90 -0
- package/plugins/ambient-agent/constants.js +101 -0
- package/plugins/ambient-agent/index.js +579 -0
- package/plugins/audit-plugin.js +187 -187
- package/plugins/default-plugins.js +662 -649
- package/plugins/email/constants.js +64 -0
- package/plugins/email/handlers.js +461 -0
- package/plugins/email/index.js +278 -0
- package/plugins/email/monitor.js +269 -0
- package/plugins/email/parser.js +138 -0
- package/plugins/email/reply.js +151 -0
- package/plugins/email/utils.js +124 -0
- package/plugins/feishu-plugin.js +481 -477
- package/plugins/file-system-plugin.js +826 -476
- package/plugins/install-plugin.js +199 -197
- package/plugins/python-executor-plugin.js +367 -365
- package/plugins/python-plugin-loader.js +481 -479
- package/plugins/rules-plugin.js +294 -292
- package/plugins/scheduler-plugin.js +691 -689
- package/plugins/session-plugin.js +369 -367
- package/plugins/shell-executor-plugin.js +197 -197
- package/plugins/storage-plugin.js +240 -238
- package/plugins/subagent-plugin.js +845 -785
- package/plugins/telegram-plugin.js +482 -475
- package/plugins/think-plugin.js +345 -343
- package/plugins/tools-plugin.js +196 -194
- package/plugins/web-plugin.js +606 -604
- package/plugins/weixin-plugin.js +545 -538
- package/reports/system-health-report-20260401.md +79 -0
- package/skills/ambient-agent/SKILL.md +49 -39
- package/skills/foliko-dev/AGENTS.md +64 -61
- package/skills/foliko-dev/SKILL.md +125 -119
- package/skills/mcp-usage/SKILL.md +19 -17
- package/skills/python-plugin-dev/SKILL.md +16 -15
- package/skills/skill-guide/SKILL.md +12 -12
- package/skills/subagent-guide/SKILL.md +237 -0
- package/skills/workflow-guide/SKILL.md +90 -45
- package/skills/workflow-troubleshooting/DEBUGGING.md +36 -21
- package/skills/workflow-troubleshooting/SKILL.md +156 -79
- package/src/capabilities/index.js +11 -11
- package/src/capabilities/skill-manager.js +609 -595
- package/src/capabilities/workflow-engine.js +1109 -1195
- package/src/core/agent-chat.js +882 -735
- package/src/core/agent.js +892 -688
- package/src/core/framework.js +465 -431
- package/src/core/index.js +19 -19
- package/src/core/plugin-base.js +219 -219
- package/src/core/plugin-manager.js +863 -767
- package/src/core/provider.js +114 -111
- package/src/core/sub-agent-config.js +264 -0
- package/src/core/system-prompt-builder.js +120 -0
- package/src/core/tool-registry.js +517 -134
- package/src/core/tool-router.js +297 -216
- package/src/executors/executor-base.js +12 -12
- package/src/executors/mcp-executor.js +741 -729
- package/src/index.js +25 -37
- package/src/utils/circuit-breaker.js +301 -0
- package/src/utils/error-boundary.js +363 -0
- package/src/utils/error.js +374 -0
- package/src/utils/event-emitter.js +97 -97
- package/src/utils/id.js +133 -0
- package/src/utils/index.js +217 -3
- package/src/utils/logger.js +181 -0
- package/src/utils/plugin-helpers.js +90 -0
- package/src/utils/retry.js +122 -0
- package/src/utils/sandbox.js +292 -0
- package/test/tool-registry-validation.test.js +218 -0
- package/test_report.md +70 -0
- package/website/docs/api.html +169 -107
- package/website/docs/configuration.html +296 -144
- package/website/docs/plugin-development.html +154 -85
- package/website/docs/project-structure.html +110 -109
- package/website/docs/skill-development.html +117 -61
- package/website/index.html +209 -205
- package/website/script.js +136 -133
- package/website/styles.css +1 -1
- package/plugins/ambient-agent-plugin.js +0 -1565
- package/plugins/email.js +0 -1142
|
@@ -9,6 +9,7 @@ allowed-tools: python-executor, shell, read_file, write_file, execute_workflow,
|
|
|
9
9
|
## 常见问题与解决方案
|
|
10
10
|
|
|
11
11
|
### 1. fetch 工具可用 ✅
|
|
12
|
+
|
|
12
13
|
**好消息**: 工作流引擎**支持** `fetch` 工具!可以直接在 steps 中使用:
|
|
13
14
|
|
|
14
15
|
```yaml
|
|
@@ -16,17 +17,19 @@ steps:
|
|
|
16
17
|
- type: tool
|
|
17
18
|
name: fetch
|
|
18
19
|
params:
|
|
19
|
-
url:
|
|
20
|
+
url: 'https://news.baidu.com'
|
|
20
21
|
timeout: 10000
|
|
21
|
-
output:
|
|
22
|
+
output: 'baidu_news'
|
|
22
23
|
```
|
|
23
24
|
|
|
24
25
|
**优势**:
|
|
26
|
+
|
|
25
27
|
- 原生支持,无需额外 sandbox 配置
|
|
26
28
|
- 语法简洁
|
|
27
29
|
- 自动处理超时和错误
|
|
28
30
|
|
|
29
31
|
### 2. 多个 fetch 步骤串联
|
|
32
|
+
|
|
30
33
|
**已验证可用**:
|
|
31
34
|
|
|
32
35
|
```yaml
|
|
@@ -34,23 +37,24 @@ steps:
|
|
|
34
37
|
- type: tool
|
|
35
38
|
name: fetch
|
|
36
39
|
params:
|
|
37
|
-
url:
|
|
38
|
-
output:
|
|
39
|
-
|
|
40
|
+
url: 'https://news.baidu.com'
|
|
41
|
+
output: 'baidu_news'
|
|
42
|
+
|
|
40
43
|
- type: tool
|
|
41
44
|
name: fetch
|
|
42
45
|
params:
|
|
43
|
-
url:
|
|
44
|
-
output:
|
|
45
|
-
|
|
46
|
+
url: 'https://feeds.bbci.co.uk/news/world/rss.xml'
|
|
47
|
+
output: 'bbc_news'
|
|
48
|
+
|
|
46
49
|
- type: tool
|
|
47
50
|
name: fetch
|
|
48
51
|
params:
|
|
49
|
-
url:
|
|
50
|
-
output:
|
|
52
|
+
url: 'https://www.reddit.com/r/popular/hot.json?limit=20'
|
|
53
|
+
output: 'reddit_news'
|
|
51
54
|
```
|
|
52
55
|
|
|
53
56
|
### 3. Python 脚本获取结果
|
|
57
|
+
|
|
54
58
|
**正确方式**: Python 脚本返回 JSON 格式字符串
|
|
55
59
|
|
|
56
60
|
```python
|
|
@@ -62,13 +66,16 @@ print(json.dumps(result)) # 输出 JSON 字符串
|
|
|
62
66
|
```
|
|
63
67
|
|
|
64
68
|
### 4. webhook 类型步骤
|
|
69
|
+
|
|
65
70
|
**警告**: `webhook` 类型需要 HTTP 服务支持,否则会失败。
|
|
71
|
+
|
|
66
72
|
- 如需接收外部数据,使用 `web_register_webhook` 注册路由
|
|
67
73
|
- 测试时改用 `tool` + `fetch` 组合
|
|
68
74
|
|
|
69
75
|
### 5. 变量传递问题
|
|
76
|
+
|
|
70
77
|
- **原因**: sandbox 环境无法访问主环境变量
|
|
71
|
-
- **解决方案**:
|
|
78
|
+
- **解决方案**:
|
|
72
79
|
- 使用上下文变量 `$.context.xxx`
|
|
73
80
|
- 或直接在脚本中硬编码(测试用)
|
|
74
81
|
|
|
@@ -82,35 +89,36 @@ print(json.dumps(result)) # 输出 JSON 字符串
|
|
|
82
89
|
## 成功案例
|
|
83
90
|
|
|
84
91
|
### 真实新闻聚合工作流
|
|
92
|
+
|
|
85
93
|
```yaml
|
|
86
|
-
name:
|
|
94
|
+
name: 'news-fetcher'
|
|
87
95
|
steps:
|
|
88
|
-
- type:
|
|
89
|
-
key:
|
|
90
|
-
value:
|
|
91
|
-
|
|
92
|
-
- type:
|
|
93
|
-
name:
|
|
96
|
+
- type: 'context'
|
|
97
|
+
key: 'current_time'
|
|
98
|
+
value: '$.time.current'
|
|
99
|
+
|
|
100
|
+
- type: 'tool'
|
|
101
|
+
name: 'fetch'
|
|
94
102
|
params:
|
|
95
|
-
url:
|
|
103
|
+
url: 'https://news.baidu.com'
|
|
96
104
|
timeout: 15000
|
|
97
|
-
output:
|
|
98
|
-
|
|
99
|
-
- type:
|
|
100
|
-
name:
|
|
105
|
+
output: 'baidu_news'
|
|
106
|
+
|
|
107
|
+
- type: 'tool'
|
|
108
|
+
name: 'fetch'
|
|
101
109
|
params:
|
|
102
|
-
url:
|
|
110
|
+
url: 'https://feeds.bbci.co.uk/news/world/rss.xml'
|
|
103
111
|
timeout: 15000
|
|
104
|
-
output:
|
|
105
|
-
|
|
106
|
-
- type:
|
|
107
|
-
name:
|
|
112
|
+
output: 'bbc_news'
|
|
113
|
+
|
|
114
|
+
- type: 'tool'
|
|
115
|
+
name: 'fetch'
|
|
108
116
|
params:
|
|
109
|
-
url:
|
|
117
|
+
url: 'https://www.reddit.com/r/popular/hot.json?limit=20'
|
|
110
118
|
timeout: 15000
|
|
111
|
-
output:
|
|
112
|
-
|
|
113
|
-
- type:
|
|
119
|
+
output: 'reddit_news'
|
|
120
|
+
|
|
121
|
+
- type: 'python'
|
|
114
122
|
script: |
|
|
115
123
|
import json
|
|
116
124
|
# 处理新闻数据...
|
|
@@ -119,14 +127,15 @@ steps:
|
|
|
119
127
|
```
|
|
120
128
|
|
|
121
129
|
### 网络不稳定时加代理
|
|
130
|
+
|
|
122
131
|
```yaml
|
|
123
|
-
- type:
|
|
124
|
-
name:
|
|
132
|
+
- type: 'tool'
|
|
133
|
+
name: 'fetch'
|
|
125
134
|
params:
|
|
126
|
-
url:
|
|
135
|
+
url: 'https://feeds.bbci.co.uk/news/world/rss.xml'
|
|
127
136
|
timeout: 15000
|
|
128
|
-
proxy: true
|
|
129
|
-
output:
|
|
137
|
+
proxy: true # 失败时自动启用
|
|
138
|
+
output: 'bbc_news'
|
|
130
139
|
```
|
|
131
140
|
|
|
132
141
|
## 复杂工作流步骤类型测试 ✅
|
|
@@ -134,31 +143,51 @@ steps:
|
|
|
134
143
|
以下步骤类型已通过完整测试验证:
|
|
135
144
|
|
|
136
145
|
### 1. parallel (并行执行) ✅
|
|
146
|
+
|
|
137
147
|
多个任务同时执行,提高效率:
|
|
138
148
|
|
|
139
149
|
```json
|
|
140
150
|
{
|
|
141
151
|
"type": "parallel",
|
|
142
152
|
"steps": [
|
|
143
|
-
{"type": "tool", "name": "get_time", "output": "current_time"},
|
|
144
|
-
{
|
|
145
|
-
|
|
153
|
+
{ "type": "tool", "name": "get_time", "output": "current_time" },
|
|
154
|
+
{
|
|
155
|
+
"type": "tool",
|
|
156
|
+
"name": "storage_set",
|
|
157
|
+
"params": { "key": "test", "value": "ok" },
|
|
158
|
+
"output": "storage_result"
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
"type": "tool",
|
|
162
|
+
"name": "fetch",
|
|
163
|
+
"params": { "url": "https://news.baidu.com" },
|
|
164
|
+
"output": "news"
|
|
165
|
+
}
|
|
146
166
|
]
|
|
147
167
|
}
|
|
148
168
|
```
|
|
149
169
|
|
|
150
170
|
### 2. condition (条件分支) ✅
|
|
171
|
+
|
|
151
172
|
支持 if/else 逻辑判断:
|
|
152
173
|
|
|
153
174
|
```json
|
|
154
175
|
{
|
|
155
176
|
"type": "condition",
|
|
156
|
-
"if": {"key": "$.context.storage_result", "equals": "success"},
|
|
177
|
+
"if": { "key": "$.context.storage_result", "equals": "success" },
|
|
157
178
|
"then": [
|
|
158
|
-
{
|
|
179
|
+
{
|
|
180
|
+
"type": "tool",
|
|
181
|
+
"name": "notification_send",
|
|
182
|
+
"params": { "title": "成功", "message": "条件成立" }
|
|
183
|
+
}
|
|
159
184
|
],
|
|
160
185
|
"else": [
|
|
161
|
-
{
|
|
186
|
+
{
|
|
187
|
+
"type": "tool",
|
|
188
|
+
"name": "notification_send",
|
|
189
|
+
"params": { "title": "失败", "message": "条件不成立" }
|
|
190
|
+
}
|
|
162
191
|
]
|
|
163
192
|
}
|
|
164
193
|
```
|
|
@@ -166,6 +195,7 @@ steps:
|
|
|
166
195
|
**支持的操作符**:`equals`, `not_equals`, `contains`, `greater_than`, `less_than`, `exists`, `not_exists`
|
|
167
196
|
|
|
168
197
|
### 3. loop (循环执行) ✅
|
|
198
|
+
|
|
169
199
|
支持指定次数的循环:
|
|
170
200
|
|
|
171
201
|
```json
|
|
@@ -173,12 +203,17 @@ steps:
|
|
|
173
203
|
"type": "loop",
|
|
174
204
|
"count": 3,
|
|
175
205
|
"steps": [
|
|
176
|
-
{
|
|
206
|
+
{
|
|
207
|
+
"type": "tool",
|
|
208
|
+
"name": "notification_send",
|
|
209
|
+
"params": { "title": "循环", "message": "第 {{index}} 次" }
|
|
210
|
+
}
|
|
177
211
|
]
|
|
178
212
|
}
|
|
179
213
|
```
|
|
180
214
|
|
|
181
215
|
### 4. switch (多分支) ✅
|
|
216
|
+
|
|
182
217
|
类似 switch-case 的多条件分支:
|
|
183
218
|
|
|
184
219
|
```json
|
|
@@ -186,31 +221,39 @@ steps:
|
|
|
186
221
|
"type": "switch",
|
|
187
222
|
"value": "$.context.status",
|
|
188
223
|
"cases": [
|
|
189
|
-
{
|
|
190
|
-
|
|
224
|
+
{
|
|
225
|
+
"value": "success",
|
|
226
|
+
"steps": [{ "type": "tool", "name": "notification_send", "params": { "title": "成功" } }]
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
"value": "error",
|
|
230
|
+
"steps": [{ "type": "tool", "name": "notification_send", "params": { "title": "错误" } }]
|
|
231
|
+
}
|
|
191
232
|
],
|
|
192
|
-
"default": [
|
|
193
|
-
{"type": "tool", "name": "notification_send", "params": {"title": "默认"}}
|
|
194
|
-
]
|
|
233
|
+
"default": [{ "type": "tool", "name": "notification_send", "params": { "title": "默认" } }]
|
|
195
234
|
}
|
|
196
235
|
```
|
|
197
236
|
|
|
198
237
|
### 5. try-catch (错误处理) ✅
|
|
238
|
+
|
|
199
239
|
捕获步骤执行中的错误,防止中断:
|
|
200
240
|
|
|
201
241
|
```json
|
|
202
242
|
{
|
|
203
243
|
"type": "try",
|
|
204
|
-
"steps": [
|
|
205
|
-
{"type": "tool", "name": "email_unread_count"}
|
|
206
|
-
],
|
|
244
|
+
"steps": [{ "type": "tool", "name": "email_unread_count" }],
|
|
207
245
|
"catch": [
|
|
208
|
-
{
|
|
246
|
+
{
|
|
247
|
+
"type": "tool",
|
|
248
|
+
"name": "notification_send",
|
|
249
|
+
"params": { "title": "捕获错误", "message": "邮件服务超时,使用备用方案" }
|
|
250
|
+
}
|
|
209
251
|
]
|
|
210
252
|
}
|
|
211
253
|
```
|
|
212
254
|
|
|
213
255
|
### 6. delay (延迟执行) ✅
|
|
256
|
+
|
|
214
257
|
在步骤之间添加延迟:
|
|
215
258
|
|
|
216
259
|
```json
|
|
@@ -221,6 +264,7 @@ steps:
|
|
|
221
264
|
```
|
|
222
265
|
|
|
223
266
|
### 7. nested workflow (嵌套工作流) ✅
|
|
267
|
+
|
|
224
268
|
在主工作流中调用子工作流:
|
|
225
269
|
|
|
226
270
|
```json
|
|
@@ -232,6 +276,7 @@ steps:
|
|
|
232
276
|
```
|
|
233
277
|
|
|
234
278
|
### 8. context (上下文变量) ✅
|
|
279
|
+
|
|
235
280
|
在步骤间传递数据:
|
|
236
281
|
|
|
237
282
|
```json
|
|
@@ -252,63 +297,95 @@ steps:
|
|
|
252
297
|
{
|
|
253
298
|
"type": "parallel",
|
|
254
299
|
"steps": [
|
|
255
|
-
{"type": "tool", "name": "get_time", "output": "time"},
|
|
256
|
-
{
|
|
257
|
-
|
|
300
|
+
{ "type": "tool", "name": "get_time", "output": "time" },
|
|
301
|
+
{
|
|
302
|
+
"type": "tool",
|
|
303
|
+
"name": "storage_set",
|
|
304
|
+
"params": { "key": "status", "value": "started" },
|
|
305
|
+
"output": "storage"
|
|
306
|
+
},
|
|
307
|
+
{ "type": "tool", "name": "storage_list", "output": "namespaces" }
|
|
258
308
|
]
|
|
259
309
|
},
|
|
260
310
|
{
|
|
261
311
|
"type": "condition",
|
|
262
|
-
"if": {"key": "$.context.storage", "exists": true},
|
|
312
|
+
"if": { "key": "$.context.storage", "exists": true },
|
|
263
313
|
"then": [
|
|
264
|
-
{
|
|
314
|
+
{
|
|
315
|
+
"type": "tool",
|
|
316
|
+
"name": "notification_send",
|
|
317
|
+
"params": { "title": "开始", "message": "工作流启动" }
|
|
318
|
+
}
|
|
265
319
|
]
|
|
266
320
|
},
|
|
267
|
-
{"type": "delay", "ms": 300},
|
|
321
|
+
{ "type": "delay", "ms": 300 },
|
|
268
322
|
{
|
|
269
323
|
"type": "loop",
|
|
270
324
|
"count": 2,
|
|
271
325
|
"steps": [
|
|
272
|
-
{
|
|
326
|
+
{
|
|
327
|
+
"type": "tool",
|
|
328
|
+
"name": "notification_send",
|
|
329
|
+
"params": { "title": "循环", "message": "第 {{index}} 次" }
|
|
330
|
+
}
|
|
273
331
|
]
|
|
274
332
|
},
|
|
275
333
|
{
|
|
276
334
|
"type": "switch",
|
|
277
335
|
"value": "$.context.storage",
|
|
278
336
|
"cases": [
|
|
279
|
-
{
|
|
337
|
+
{
|
|
338
|
+
"value": "started",
|
|
339
|
+
"steps": [
|
|
340
|
+
{
|
|
341
|
+
"type": "tool",
|
|
342
|
+
"name": "notification_send",
|
|
343
|
+
"params": { "title": "状态", "message": "已开始" }
|
|
344
|
+
}
|
|
345
|
+
]
|
|
346
|
+
}
|
|
280
347
|
],
|
|
281
348
|
"default": [
|
|
282
|
-
{
|
|
349
|
+
{
|
|
350
|
+
"type": "tool",
|
|
351
|
+
"name": "notification_send",
|
|
352
|
+
"params": { "title": "状态", "message": "默认状态" }
|
|
353
|
+
}
|
|
283
354
|
]
|
|
284
355
|
},
|
|
285
356
|
{
|
|
286
357
|
"type": "try",
|
|
287
|
-
"steps": [
|
|
288
|
-
{"type": "tool", "name": "email_unread_count"}
|
|
289
|
-
],
|
|
358
|
+
"steps": [{ "type": "tool", "name": "email_unread_count" }],
|
|
290
359
|
"catch": [
|
|
291
|
-
{
|
|
360
|
+
{
|
|
361
|
+
"type": "tool",
|
|
362
|
+
"name": "notification_send",
|
|
363
|
+
"params": { "title": "错误处理", "message": "捕获异常完成" }
|
|
364
|
+
}
|
|
292
365
|
]
|
|
293
366
|
},
|
|
294
|
-
{"type": "workflow", "name": "workflow_file-backup", "input": {}},
|
|
295
|
-
{
|
|
367
|
+
{ "type": "workflow", "name": "workflow_file-backup", "input": {} },
|
|
368
|
+
{
|
|
369
|
+
"type": "tool",
|
|
370
|
+
"name": "notification_send",
|
|
371
|
+
"params": { "title": "完成", "message": "复杂工作流执行成功" }
|
|
372
|
+
}
|
|
296
373
|
]
|
|
297
374
|
}
|
|
298
375
|
```
|
|
299
376
|
|
|
300
377
|
## 关键结论
|
|
301
378
|
|
|
302
|
-
| 场景
|
|
303
|
-
|
|
304
|
-
| 获取网络数据 | ✅ `fetch` 工具
|
|
379
|
+
| 场景 | 推荐方案 |
|
|
380
|
+
| ------------ | ---------------------------- |
|
|
381
|
+
| 获取网络数据 | ✅ `fetch` 工具 |
|
|
305
382
|
| 本地脚本处理 | ✅ `python` 类型 + JSON 输出 |
|
|
306
383
|
| 接收外部请求 | `webhook` 类型(需服务运行) |
|
|
307
|
-
| 串行任务
|
|
308
|
-
| 并行任务
|
|
309
|
-
| 条件分支
|
|
310
|
-
| 循环执行
|
|
311
|
-
| 多分支选择
|
|
312
|
-
| 错误处理
|
|
313
|
-
| 延迟等待
|
|
314
|
-
| 子工作流调用 | ✅ `workflow` 类型
|
|
384
|
+
| 串行任务 | ✅ 多个 `tool`/`python` 步骤 |
|
|
385
|
+
| 并行任务 | ✅ `parallel` 类型 |
|
|
386
|
+
| 条件分支 | ✅ `condition` 类型 |
|
|
387
|
+
| 循环执行 | ✅ `loop` 类型 |
|
|
388
|
+
| 多分支选择 | ✅ `switch` 类型 |
|
|
389
|
+
| 错误处理 | ✅ `try-catch` 类型 |
|
|
390
|
+
| 延迟等待 | ✅ `delay` 类型 |
|
|
391
|
+
| 子工作流调用 | ✅ `workflow` 类型 |
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Capabilities 能力模块导出
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
const { SkillManagerPlugin } = require('./skill-manager')
|
|
6
|
-
const { WorkflowPlugin } = require('./workflow-engine')
|
|
7
|
-
|
|
8
|
-
module.exports = {
|
|
9
|
-
SkillManagerPlugin,
|
|
10
|
-
WorkflowPlugin
|
|
11
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Capabilities 能力模块导出
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
const { SkillManagerPlugin } = require('./skill-manager');
|
|
6
|
+
const { WorkflowPlugin } = require('./workflow-engine');
|
|
7
|
+
|
|
8
|
+
module.exports = {
|
|
9
|
+
SkillManagerPlugin,
|
|
10
|
+
WorkflowPlugin,
|
|
11
|
+
};
|