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.
Files changed (238) hide show
  1. package/.agent/.shared/ui-ux-pro-max/data/charts.csv +26 -0
  2. package/.agent/.shared/ui-ux-pro-max/data/colors.csv +97 -0
  3. package/.agent/.shared/ui-ux-pro-max/data/icons.csv +101 -0
  4. package/.agent/.shared/ui-ux-pro-max/data/landing.csv +31 -0
  5. package/.agent/.shared/ui-ux-pro-max/data/products.csv +97 -0
  6. package/.agent/.shared/ui-ux-pro-max/data/prompts.csv +24 -0
  7. package/.agent/.shared/ui-ux-pro-max/data/react-performance.csv +45 -0
  8. package/.agent/.shared/ui-ux-pro-max/data/stacks/flutter.csv +53 -0
  9. package/.agent/.shared/ui-ux-pro-max/data/stacks/html-tailwind.csv +56 -0
  10. package/.agent/.shared/ui-ux-pro-max/data/stacks/jetpack-compose.csv +53 -0
  11. package/.agent/.shared/ui-ux-pro-max/data/stacks/nextjs.csv +53 -0
  12. package/.agent/.shared/ui-ux-pro-max/data/stacks/nuxt-ui.csv +51 -0
  13. package/.agent/.shared/ui-ux-pro-max/data/stacks/nuxtjs.csv +59 -0
  14. package/.agent/.shared/ui-ux-pro-max/data/stacks/react-native.csv +52 -0
  15. package/.agent/.shared/ui-ux-pro-max/data/stacks/react.csv +54 -0
  16. package/.agent/.shared/ui-ux-pro-max/data/stacks/shadcn.csv +61 -0
  17. package/.agent/.shared/ui-ux-pro-max/data/stacks/svelte.csv +54 -0
  18. package/.agent/.shared/ui-ux-pro-max/data/stacks/swiftui.csv +51 -0
  19. package/.agent/.shared/ui-ux-pro-max/data/stacks/vue.csv +50 -0
  20. package/.agent/.shared/ui-ux-pro-max/data/styles.csv +59 -0
  21. package/.agent/.shared/ui-ux-pro-max/data/typography.csv +58 -0
  22. package/.agent/.shared/ui-ux-pro-max/data/ui-reasoning.csv +101 -0
  23. package/.agent/.shared/ui-ux-pro-max/data/ux-guidelines.csv +100 -0
  24. package/.agent/.shared/ui-ux-pro-max/data/web-interface.csv +31 -0
  25. package/.agent/.shared/ui-ux-pro-max/scripts/__pycache__/core.cpython-313.pyc +0 -0
  26. package/.agent/.shared/ui-ux-pro-max/scripts/__pycache__/design_system.cpython-313.pyc +0 -0
  27. package/.agent/.shared/ui-ux-pro-max/scripts/core.py +258 -0
  28. package/.agent/.shared/ui-ux-pro-max/scripts/design_system.py +1067 -0
  29. package/.agent/.shared/ui-ux-pro-max/scripts/search.py +106 -0
  30. package/.agent/ARCHITECTURE.md +288 -0
  31. package/.agent/agents/ambient-agent.md +57 -0
  32. package/.agent/agents/debugger.md +55 -0
  33. package/.agent/agents/email-assistant.md +49 -0
  34. package/.agent/agents/file-manager.md +42 -0
  35. package/.agent/agents/python-developer.md +60 -0
  36. package/.agent/agents/scheduler.md +59 -0
  37. package/.agent/agents/web-developer.md +45 -0
  38. package/.agent/data/default.json +29 -0
  39. package/.agent/data/plugins-state.json +255 -0
  40. package/.agent/mcp_config.json +4 -0
  41. package/.agent/mcp_config_updated.json +12 -0
  42. package/.agent/plugins.json +5 -0
  43. package/.agent/rules/GEMINI.md +273 -0
  44. package/.agent/rules/allow-rule.md +77 -0
  45. package/.agent/rules/log-rule.md +83 -0
  46. package/.agent/rules/security-rule.md +93 -0
  47. package/.agent/scripts/auto_preview.py +148 -0
  48. package/.agent/scripts/checklist.py +217 -0
  49. package/.agent/scripts/session_manager.py +120 -0
  50. package/.agent/scripts/verify_all.py +327 -0
  51. package/.agent/skills/api-patterns/SKILL.md +81 -0
  52. package/.agent/skills/api-patterns/api-style.md +42 -0
  53. package/.agent/skills/api-patterns/auth.md +24 -0
  54. package/.agent/skills/api-patterns/documentation.md +26 -0
  55. package/.agent/skills/api-patterns/graphql.md +41 -0
  56. package/.agent/skills/api-patterns/rate-limiting.md +31 -0
  57. package/.agent/skills/api-patterns/response.md +37 -0
  58. package/.agent/skills/api-patterns/rest.md +40 -0
  59. package/.agent/skills/api-patterns/scripts/api_validator.py +211 -0
  60. package/.agent/skills/api-patterns/security-testing.md +122 -0
  61. package/.agent/skills/api-patterns/trpc.md +41 -0
  62. package/.agent/skills/api-patterns/versioning.md +22 -0
  63. package/.agent/skills/app-builder/SKILL.md +75 -0
  64. package/.agent/skills/app-builder/agent-coordination.md +71 -0
  65. package/.agent/skills/app-builder/feature-building.md +53 -0
  66. package/.agent/skills/app-builder/project-detection.md +34 -0
  67. package/.agent/skills/app-builder/scaffolding.md +118 -0
  68. package/.agent/skills/app-builder/tech-stack.md +40 -0
  69. package/.agent/skills/app-builder/templates/SKILL.md +39 -0
  70. package/.agent/skills/app-builder/templates/astro-static/TEMPLATE.md +76 -0
  71. package/.agent/skills/app-builder/templates/chrome-extension/TEMPLATE.md +92 -0
  72. package/.agent/skills/app-builder/templates/cli-tool/TEMPLATE.md +88 -0
  73. package/.agent/skills/app-builder/templates/electron-desktop/TEMPLATE.md +88 -0
  74. package/.agent/skills/app-builder/templates/express-api/TEMPLATE.md +83 -0
  75. package/.agent/skills/app-builder/templates/flutter-app/TEMPLATE.md +90 -0
  76. package/.agent/skills/app-builder/templates/monorepo-turborepo/TEMPLATE.md +90 -0
  77. package/.agent/skills/app-builder/templates/nextjs-fullstack/TEMPLATE.md +122 -0
  78. package/.agent/skills/app-builder/templates/nextjs-saas/TEMPLATE.md +122 -0
  79. package/.agent/skills/app-builder/templates/nextjs-static/TEMPLATE.md +169 -0
  80. package/.agent/skills/app-builder/templates/nuxt-app/TEMPLATE.md +134 -0
  81. package/.agent/skills/app-builder/templates/python-fastapi/TEMPLATE.md +83 -0
  82. package/.agent/skills/app-builder/templates/react-native-app/TEMPLATE.md +119 -0
  83. package/.agent/skills/architecture/SKILL.md +55 -0
  84. package/.agent/skills/architecture/context-discovery.md +43 -0
  85. package/.agent/skills/architecture/examples.md +94 -0
  86. package/.agent/skills/architecture/pattern-selection.md +68 -0
  87. package/.agent/skills/architecture/patterns-reference.md +50 -0
  88. package/.agent/skills/architecture/trade-off-analysis.md +77 -0
  89. package/.agent/skills/clean-code/SKILL.md +201 -0
  90. package/.agent/skills/doc.md +177 -0
  91. package/.agent/skills/frontend-design/SKILL.md +418 -0
  92. package/.agent/skills/frontend-design/animation-guide.md +331 -0
  93. package/.agent/skills/frontend-design/color-system.md +311 -0
  94. package/.agent/skills/frontend-design/decision-trees.md +418 -0
  95. package/.agent/skills/frontend-design/motion-graphics.md +306 -0
  96. package/.agent/skills/frontend-design/scripts/accessibility_checker.py +183 -0
  97. package/.agent/skills/frontend-design/scripts/ux_audit.py +722 -0
  98. package/.agent/skills/frontend-design/typography-system.md +345 -0
  99. package/.agent/skills/frontend-design/ux-psychology.md +1116 -0
  100. package/.agent/skills/frontend-design/visual-effects.md +383 -0
  101. package/.agent/skills/i18n-localization/SKILL.md +154 -0
  102. package/.agent/skills/i18n-localization/scripts/i18n_checker.py +241 -0
  103. package/.agent/skills/mcp-builder/SKILL.md +176 -0
  104. package/.agent/skills/web-design-guidelines/SKILL.md +57 -0
  105. package/.agent/workflows/brainstorm.md +113 -0
  106. package/.agent/workflows/create.md +59 -0
  107. package/.agent/workflows/debug.md +103 -0
  108. package/.agent/workflows/deploy.md +176 -0
  109. package/.agent/workflows/enhance.md +63 -0
  110. package/.agent/workflows/orchestrate.md +237 -0
  111. package/.agent/workflows/plan.md +89 -0
  112. package/.agent/workflows/preview.md +81 -0
  113. package/.agent/workflows/simple-test.md +42 -0
  114. package/.agent/workflows/status.md +86 -0
  115. package/.agent/workflows/structured-orchestrate.md +180 -0
  116. package/.agent/workflows/test.md +144 -0
  117. package/.agent/workflows/ui-ux-pro-max.md +296 -0
  118. package/.claude/settings.local.json +11 -1
  119. package/.editorconfig +56 -0
  120. package/.husky/pre-commit +4 -0
  121. package/.lintstagedrc +7 -0
  122. package/.prettierignore +29 -0
  123. package/.prettierrc +11 -0
  124. package/CLAUDE.md +2 -0
  125. package/README.md +64 -55
  126. package/SPEC.md +102 -61
  127. package/cli/bin/foliko.js +11 -11
  128. package/cli/src/commands/chat.js +143 -141
  129. package/cli/src/commands/list.js +93 -90
  130. package/cli/src/index.js +75 -75
  131. package/cli/src/ui/chat-ui.js +201 -199
  132. package/cli/src/utils/ansi.js +40 -40
  133. package/cli/src/utils/markdown.js +292 -296
  134. package/docker-compose.yml +1 -1
  135. package/docs/ai-sdk-optimization.md +655 -643
  136. package/docs/features.md +80 -80
  137. package/docs/quick-reference.md +49 -46
  138. package/docs/user-manual.md +411 -380
  139. package/examples/ambient-example.js +194 -196
  140. package/examples/basic.js +50 -45
  141. package/examples/bootstrap.js +121 -112
  142. package/examples/mcp-example.js +19 -16
  143. package/examples/skill-example.js +20 -20
  144. package/examples/test-chat.js +137 -135
  145. package/examples/test-mcp.js +85 -79
  146. package/examples/test-reload.js +59 -61
  147. package/examples/test-telegram.js +50 -50
  148. package/examples/test-tg-bot.js +45 -42
  149. package/examples/test-tg-simple.js +47 -46
  150. package/examples/test-tg.js +62 -62
  151. package/examples/test-think.js +43 -37
  152. package/examples/test-web-plugin.js +103 -98
  153. package/examples/test-weixin-feishu.js +103 -100
  154. package/examples/workflow.js +158 -158
  155. package/package.json +37 -3
  156. package/plugins/ai-plugin.js +102 -100
  157. package/plugins/ambient-agent/EventWatcher.js +113 -0
  158. package/plugins/ambient-agent/ExplorerLoop.js +640 -0
  159. package/plugins/ambient-agent/GoalManager.js +197 -0
  160. package/plugins/ambient-agent/Reflector.js +95 -0
  161. package/plugins/ambient-agent/StateStore.js +90 -0
  162. package/plugins/ambient-agent/constants.js +101 -0
  163. package/plugins/ambient-agent/index.js +579 -0
  164. package/plugins/audit-plugin.js +187 -187
  165. package/plugins/default-plugins.js +662 -649
  166. package/plugins/email/constants.js +64 -0
  167. package/plugins/email/handlers.js +461 -0
  168. package/plugins/email/index.js +278 -0
  169. package/plugins/email/monitor.js +269 -0
  170. package/plugins/email/parser.js +138 -0
  171. package/plugins/email/reply.js +151 -0
  172. package/plugins/email/utils.js +124 -0
  173. package/plugins/feishu-plugin.js +481 -477
  174. package/plugins/file-system-plugin.js +826 -476
  175. package/plugins/install-plugin.js +199 -197
  176. package/plugins/python-executor-plugin.js +367 -365
  177. package/plugins/python-plugin-loader.js +481 -479
  178. package/plugins/rules-plugin.js +294 -292
  179. package/plugins/scheduler-plugin.js +691 -689
  180. package/plugins/session-plugin.js +369 -367
  181. package/plugins/shell-executor-plugin.js +197 -197
  182. package/plugins/storage-plugin.js +240 -238
  183. package/plugins/subagent-plugin.js +845 -785
  184. package/plugins/telegram-plugin.js +482 -475
  185. package/plugins/think-plugin.js +345 -343
  186. package/plugins/tools-plugin.js +196 -194
  187. package/plugins/web-plugin.js +606 -604
  188. package/plugins/weixin-plugin.js +545 -538
  189. package/reports/system-health-report-20260401.md +79 -0
  190. package/skills/ambient-agent/SKILL.md +49 -39
  191. package/skills/foliko-dev/AGENTS.md +64 -61
  192. package/skills/foliko-dev/SKILL.md +125 -119
  193. package/skills/mcp-usage/SKILL.md +19 -17
  194. package/skills/python-plugin-dev/SKILL.md +16 -15
  195. package/skills/skill-guide/SKILL.md +12 -12
  196. package/skills/subagent-guide/SKILL.md +237 -0
  197. package/skills/workflow-guide/SKILL.md +90 -45
  198. package/skills/workflow-troubleshooting/DEBUGGING.md +36 -21
  199. package/skills/workflow-troubleshooting/SKILL.md +156 -79
  200. package/src/capabilities/index.js +11 -11
  201. package/src/capabilities/skill-manager.js +609 -595
  202. package/src/capabilities/workflow-engine.js +1109 -1195
  203. package/src/core/agent-chat.js +882 -735
  204. package/src/core/agent.js +892 -688
  205. package/src/core/framework.js +465 -431
  206. package/src/core/index.js +19 -19
  207. package/src/core/plugin-base.js +219 -219
  208. package/src/core/plugin-manager.js +863 -767
  209. package/src/core/provider.js +114 -111
  210. package/src/core/sub-agent-config.js +264 -0
  211. package/src/core/system-prompt-builder.js +120 -0
  212. package/src/core/tool-registry.js +517 -134
  213. package/src/core/tool-router.js +297 -216
  214. package/src/executors/executor-base.js +12 -12
  215. package/src/executors/mcp-executor.js +741 -729
  216. package/src/index.js +25 -37
  217. package/src/utils/circuit-breaker.js +301 -0
  218. package/src/utils/error-boundary.js +363 -0
  219. package/src/utils/error.js +374 -0
  220. package/src/utils/event-emitter.js +97 -97
  221. package/src/utils/id.js +133 -0
  222. package/src/utils/index.js +217 -3
  223. package/src/utils/logger.js +181 -0
  224. package/src/utils/plugin-helpers.js +90 -0
  225. package/src/utils/retry.js +122 -0
  226. package/src/utils/sandbox.js +292 -0
  227. package/test/tool-registry-validation.test.js +218 -0
  228. package/test_report.md +70 -0
  229. package/website/docs/api.html +169 -107
  230. package/website/docs/configuration.html +296 -144
  231. package/website/docs/plugin-development.html +154 -85
  232. package/website/docs/project-structure.html +110 -109
  233. package/website/docs/skill-development.html +117 -61
  234. package/website/index.html +209 -205
  235. package/website/script.js +136 -133
  236. package/website/styles.css +1 -1
  237. package/plugins/ambient-agent-plugin.js +0 -1565
  238. 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: "https://news.baidu.com"
20
+ url: 'https://news.baidu.com'
20
21
  timeout: 10000
21
- output: "baidu_news"
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: "https://news.baidu.com"
38
- output: "baidu_news"
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: "https://feeds.bbci.co.uk/news/world/rss.xml"
44
- output: "bbc_news"
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: "https://www.reddit.com/r/popular/hot.json?limit=20"
50
- output: "reddit_news"
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: "news-fetcher"
94
+ name: 'news-fetcher'
87
95
  steps:
88
- - type: "context"
89
- key: "current_time"
90
- value: "$.time.current"
91
-
92
- - type: "tool"
93
- name: "fetch"
96
+ - type: 'context'
97
+ key: 'current_time'
98
+ value: '$.time.current'
99
+
100
+ - type: 'tool'
101
+ name: 'fetch'
94
102
  params:
95
- url: "https://news.baidu.com"
103
+ url: 'https://news.baidu.com'
96
104
  timeout: 15000
97
- output: "baidu_news"
98
-
99
- - type: "tool"
100
- name: "fetch"
105
+ output: 'baidu_news'
106
+
107
+ - type: 'tool'
108
+ name: 'fetch'
101
109
  params:
102
- url: "https://feeds.bbci.co.uk/news/world/rss.xml"
110
+ url: 'https://feeds.bbci.co.uk/news/world/rss.xml'
103
111
  timeout: 15000
104
- output: "bbc_news"
105
-
106
- - type: "tool"
107
- name: "fetch"
112
+ output: 'bbc_news'
113
+
114
+ - type: 'tool'
115
+ name: 'fetch'
108
116
  params:
109
- url: "https://www.reddit.com/r/popular/hot.json?limit=20"
117
+ url: 'https://www.reddit.com/r/popular/hot.json?limit=20'
110
118
  timeout: 15000
111
- output: "reddit_news"
112
-
113
- - type: "python"
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: "tool"
124
- name: "fetch"
132
+ - type: 'tool'
133
+ name: 'fetch'
125
134
  params:
126
- url: "https://feeds.bbci.co.uk/news/world/rss.xml"
135
+ url: 'https://feeds.bbci.co.uk/news/world/rss.xml'
127
136
  timeout: 15000
128
- proxy: true # 失败时自动启用
129
- output: "bbc_news"
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
- {"type": "tool", "name": "storage_set", "params": {"key": "test", "value": "ok"}, "output": "storage_result"},
145
- {"type": "tool", "name": "fetch", "params": {"url": "https://news.baidu.com"}, "output": "news"}
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
- {"type": "tool", "name": "notification_send", "params": {"title": "成功", "message": "条件成立"}}
179
+ {
180
+ "type": "tool",
181
+ "name": "notification_send",
182
+ "params": { "title": "成功", "message": "条件成立" }
183
+ }
159
184
  ],
160
185
  "else": [
161
- {"type": "tool", "name": "notification_send", "params": {"title": "失败", "message": "条件不成立"}}
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
- {"type": "tool", "name": "notification_send", "params": {"title": "循环", "message": "第 {{index}} 次"}}
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
- {"value": "success", "steps": [{"type": "tool", "name": "notification_send", "params": {"title": "成功"}}]},
190
- {"value": "error", "steps": [{"type": "tool", "name": "notification_send", "params": {"title": "错误"}}]}
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
- {"type": "tool", "name": "notification_send", "params": {"title": "捕获错误", "message": "邮件服务超时,使用备用方案"}}
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
- {"type": "tool", "name": "storage_set", "params": {"key": "status", "value": "started"}, "output": "storage"},
257
- {"type": "tool", "name": "storage_list", "output": "namespaces"}
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
- {"type": "tool", "name": "notification_send", "params": {"title": "开始", "message": "工作流启动"}}
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
- {"type": "tool", "name": "notification_send", "params": {"title": "循环", "message": "第 {{index}} 次"}}
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
- {"value": "started", "steps": [{"type": "tool", "name": "notification_send", "params": {"title": "状态", "message": "已开始"}}]}
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
- {"type": "tool", "name": "notification_send", "params": {"title": "状态", "message": "默认状态"}}
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
- {"type": "tool", "name": "notification_send", "params": {"title": "错误处理", "message": "捕获异常完成"}}
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
- {"type": "tool", "name": "notification_send", "params": {"title": "完成", "message": "复杂工作流执行成功"}}
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
- | 串行任务 | ✅ 多个 `tool`/`python` 步骤 |
308
- | 并行任务 | ✅ `parallel` 类型 |
309
- | 条件分支 | ✅ `condition` 类型 |
310
- | 循环执行 | ✅ `loop` 类型 |
311
- | 多分支选择 | ✅ `switch` 类型 |
312
- | 错误处理 | ✅ `try-catch` 类型 |
313
- | 延迟等待 | ✅ `delay` 类型 |
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
+ };