foliko 1.1.6 → 1.1.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/.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 +412 -3
- package/.agent/data/plugins-state.json +177 -174
- package/.agent/data/puppeteer-sessions/undefined.json +6 -0
- package/.agent/data/weixin-media/2026-04-08/img_1775618677512.jpg +0 -0
- package/.agent/data/weixin-media/2026-04-08/img_1775619073340.jpg +0 -0
- package/.agent/data/weixin-media/2026-04-08/img_1775619097536.jpg +0 -0
- package/.agent/data/weixin-media/2026-04-08/img_1775619209388.jpg +0 -0
- package/.agent/mcp_config.json +11 -3
- package/.agent/memory/feedback/mnrdvj5i-ca3dkd.md +9 -0
- package/.agent/memory/feedback/mnre365e-7s4zax.md +9 -0
- package/.agent/memory/feedback/mnre36jn-nkfgmp.md +9 -0
- package/.agent/memory/feedback/mnre3805-kjiq6h.md +9 -0
- package/.agent/memory/feedback/mnsf66kp-b10rcd.md +9 -0
- package/.agent/memory/feedback/mnsi3sz8-p5g2cw.md +9 -0
- package/.agent/memory/feedback/mnsibe47-sv2ni1.md +9 -0
- package/.agent/memory/feedback/mnsic89w-nn228o.md +9 -0
- package/.agent/memory/feedback/mnsj1xe9-x83ba0.md +9 -0
- package/.agent/memory/feedback/mnsj21iv-wnwelx.md +9 -0
- package/.agent/memory/feedback/mnsj2g4a-cog7a2.md +9 -0
- package/.agent/memory/feedback/mnsj4js7-lktjp6.md +9 -0
- package/.agent/memory/feedback/mnsj5d4y-uglwvp.md +9 -0
- package/.agent/memory/feedback/mnslkuo9-uous66.md +24 -0
- package/.agent/memory/feedback/mnsm3vq0-megoil.md +9 -0
- package/.agent/memory/feedback/mnsnn5x2-sxcihd.md +9 -0
- package/.agent/memory/feedback/mnsnq17s-nabrn9.md +9 -0
- package/.agent/memory/feedback/mnsnybet-wz7rn3.md +9 -0
- package/.agent/memory/feedback/mnsrw0s7-7s9e30.md +9 -0
- package/.agent/memory/feedback/mnu5hpnd-tlm16q.md +9 -0
- package/.agent/memory/feedback/mnu60uqe-xuoxp4.md +9 -0
- package/.agent/memory/project/mnqx54u5-loqtoe.md +9 -0
- package/.agent/memory/project/mnqx84cv-mx6dmd.md +9 -0
- package/.agent/memory/project/mnsacuyr-hgtk5n.md +20 -0
- package/.agent/memory/project/mnu5hy2x-bjsg7u.md +9 -0
- package/.agent/memory/reference/mnre3cww-penbo1.md +9 -0
- package/.agent/memory/reference/mns9wn48-luerua.md +14 -0
- package/.agent/memory/reference/mns9yz5c-thc2s0.md +16 -0
- package/.agent/memory/reference/mnsfy4um-910f1o.md +23 -0
- package/.agent/memory/reference/mnsg37dp-lmfj18.md +32 -0
- package/.agent/memory/reference/mnsll60q-0j911u.md +36 -0
- package/.agent/memory/reference/mnsmlb5y-nej31u.md +16 -0
- package/.agent/memory/reference/mnssle72-yrot96.md +9 -0
- package/.agent/memory/user/mnsfuon6-l416q1.md +21 -0
- package/.agent/memory/user/mnsg9kut-95m7rf.md +20 -0
- package/.agent/memory/user/mnu2eo1v-yy6fhe.md +9 -0
- package/.agent/memory/user/mnu2etuo-8u8jk8.md +9 -0
- package/.agent/plugins/poster-plugin/fonts/NotoColorEmoji-Regular.ttf +0 -0
- package/.agent/plugins/poster-plugin/fonts/Symbola_hint.ttf +0 -0
- package/.agent/plugins/poster-plugin/package.json +3 -3
- package/.agent/plugins/poster-plugin/src/canvas.js +8 -0
- package/.agent/plugins/poster-plugin/src/components/barcode.js +5 -2
- package/.agent/plugins/poster-plugin/src/components/bubble.js +3 -2
- package/.agent/plugins/poster-plugin/src/components/button.js +74 -30
- package/.agent/plugins/poster-plugin/src/components/columns.js +97 -83
- package/.agent/plugins/poster-plugin/src/components/grid.js +104 -92
- package/.agent/plugins/poster-plugin/src/components/highlightText.js +2 -1
- package/.agent/plugins/poster-plugin/src/components/imageFrame.js +143 -93
- package/.agent/plugins/poster-plugin/src/components/quote.js +85 -13
- package/.agent/plugins/poster-plugin/src/components/ribbon.js +13 -9
- package/.agent/plugins/poster-plugin/src/components/seal.js +5 -3
- package/.agent/plugins/poster-plugin/src/components/star.js +3 -3
- package/.agent/plugins/poster-plugin/src/components/table.js +1 -1
- package/.agent/plugins/poster-plugin/src/components/watermark.js +4 -2
- package/.agent/plugins/poster-plugin/src/composer.js +181 -13
- package/.agent/plugins/poster-plugin/src/elements/artText.js +16 -7
- package/.agent/plugins/poster-plugin/src/elements/background.js +20 -5
- package/.agent/plugins/poster-plugin/src/elements/richText.js +160 -107
- package/.agent/plugins/poster-plugin/src/elements/text.js +48 -45
- package/.agent/plugins/poster-plugin/src/fonts.js +556 -125
- package/.agent/plugins/poster-plugin/src/index.js +46 -1
- package/.agent/plugins/poster-plugin/yarn.lock +186 -356
- package/.agent/plugins/puppeteer-plugin/README.md +147 -0
- package/.agent/plugins/puppeteer-plugin/index.js +1422 -0
- package/.agent/plugins/puppeteer-plugin/package.json +9 -0
- package/.agent/plugins.json +5 -11
- 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/sessions/cli_default.json +128 -5479
- 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/poster-design/SKILL.md +385 -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/.env.example +56 -56
- package/README.md +441 -441
- package/SPEC.md +735 -696
- package/output/foliko-poster.png +0 -0
- package/outputs/emoji-font-showcase.png +0 -0
- package/outputs/foliko-muji-style.png +0 -0
- package/package.json +3 -2
- package/plugins/ambient-agent/EventWatcher.js +33 -37
- package/plugins/ambient-agent/ExplorerLoop.js +338 -36
- package/plugins/ambient-agent/GoalManager.js +7 -3
- package/plugins/ambient-agent/StateStore.js +30 -1
- package/plugins/ambient-agent/constants.js +15 -1
- package/plugins/ambient-agent/index.js +26 -33
- package/plugins/coordinator-plugin.js +3 -3
- package/plugins/default-plugins.js +4 -3
- package/plugins/email/index.js +150 -36
- package/plugins/email/monitor.js +79 -5
- package/plugins/email/reply.js +15 -25
- package/plugins/extension-executor-plugin.js +184 -32
- package/plugins/feishu-plugin.js +2 -2
- package/plugins/file-system-plugin.js +57 -24
- package/plugins/memory-plugin.js +176 -64
- package/plugins/python-plugin-loader.js +79 -9
- package/plugins/scheduler-plugin.js +64 -24
- package/plugins/telegram-plugin.js +2 -2
- package/plugins/think-plugin.js +7 -2
- package/plugins/web-plugin.js +263 -4
- package/plugins/weixin-plugin.js +2 -2
- package/skills/ambient-agent/SKILL.md +342 -314
- package/skills/find-skills/AGENTS.md +162 -162
- package/skills/find-skills/SKILL.md +133 -133
- package/src/core/agent-chat.js +64 -9
- package/src/core/agent.js +216 -69
- package/src/core/tool-registry.js +5 -5
- package/src/executors/mcp-executor.js +453 -35
- package/src/utils/id.js +5 -0
- package/system.md +3629 -0
- package/.agent/agents/code-assistant.json +0 -17
- package/.agent/agents/email-assistant.json +0 -14
- package/.agent/agents/file-assistant.json +0 -18
- package/.agent/agents/orchestrator-demo.md +0 -53
- package/.agent/agents/orchestrator.json +0 -7
- package/.agent/agents/system-assistant.json +0 -15
- package/.agent/agents/web-assistant.json +0 -12
- package/.agent/data/ambient/goals.json +0 -50
- package/.agent/data/ambient/memories.json +0 -7
- package/.agent/data/scheduler/tasks.json +0 -1
- package/.agent/memory/core.md +0 -1
- package/.agent/memory/feedback/mnrsiuoc-e1ru74.md +0 -9
- package/.agent/memory/feedback/mnrt2mmz-98az6n.md +0 -9
- package/.agent/memory/feedback/mnrtqrhm-kxsicz.md +0 -9
- package/.agent/memory/feedback/mnrts8vg-i0ngzp.md +0 -15
- package/.agent/memory/feedback/mnrtt7jt-c0trb2.md +0 -9
- package/.agent/memory/feedback/mnruc2f0-5s52la.md +0 -16
- package/.agent/memory/feedback/mnrumbmx-63sa0v.md +0 -9
- package/.agent/memory/project/mnn93ogy-ypjn27.md +0 -9
- package/.agent/memory/project/mnn98fqy-5nhc1u.md +0 -25
- package/.agent/memory/project/mnrp7p5n-8enm2a.md +0 -31
- package/.agent/memory/project/mnrp9ifb-yynks0.md +0 -40
- package/.agent/memory/project/mnrpb3b8-f617s4.md +0 -25
- package/.agent/memory/project/mnrrmqgg-focprv.md +0 -9
- package/.agent/memory/project/mnrtykbh-6atsor.md +0 -9
- package/.agent/memory/project/mnru9jiu-kgau16.md +0 -35
- package/.agent/memory/reference/mnq3oenw-46haj6.md +0 -63
- package/.agent/memory/reference/mnq5qxm2-mjoooh.md +0 -116
- package/.agent/memory/reference/mnrnvpwo-rcqv9m.md +0 -52
- package/.agent/memory/reference/mnrovxvz-zy9xqm.md +0 -25
- package/.agent/memory/reference/mnroxabj-1b3930.md +0 -68
- package/.agent/memory/reference/mnrpjtlp-mnb9od.md +0 -35
- package/.agent/memory/reference/mnrps1x3-6b8xfm.md +0 -28
- package/.agent/memory/reference/mnrpt9ov-15er5w.md +0 -22
- package/.agent/memory/reference/mnrq82dn-y9tv9e.md +0 -50
- package/.agent/memory/reference/mnrqnr5v-v75drf.md +0 -34
- package/.agent/memory/reference/mnrrfzys-urudaf.md +0 -31
- package/.agent/memory/reference/mnrrocha-t0027n.md +0 -21
- package/.agent/memory/reference/mnrukklc-bxndsb.md +0 -35
- package/.agent/memory/user/mnm67t9m-x8rekk.md +0 -9
- package/.agent/memory/user/mnn5mmqh-w6aktx.md +0 -11
- package/.agent/memory/user/mnnbfhhn-dk1bd1.md +0 -22
- package/.agent/memory/user/mnrt39t8-8eosy0.md +0 -9
- package/.agent/package.json +0 -8
- package/.agent/plugins/__pycache__/file_writer.cpython-312.pyc +0 -0
- package/.agent/plugins/daytona/README.md +0 -89
- package/.agent/plugins/daytona/index.js +0 -377
- package/.agent/plugins/daytona/package.json +0 -12
- package/.agent/plugins/marknative/README.md +0 -134
- package/.agent/plugins/marknative/fonts/SegoeUI Emoji.ttf +0 -0
- package/.agent/plugins/marknative/fonts.zip +0 -0
- package/.agent/plugins/marknative/index.js +0 -256
- package/.agent/plugins/marknative/package.json +0 -12
- package/.agent/plugins/poster-plugin/emojis/rocket.png +0 -1
- package/.agent/plugins/poster-plugin/test-background.svg +0 -1
- package/.agent/plugins/poster-plugin/test-full-poster.svg +0 -2
- package/.agent/plugins/poster-plugin/test-image.png +0 -0
- package/.agent/plugins/system-info/index.js +0 -387
- package/.agent/plugins/system-info/package.json +0 -4
- package/.agent/plugins/system-info/test.js +0 -40
- package/.agent/python-scripts/test_sample.py +0 -24
- package/.agent/skills/agent-browser/SKILL.md +0 -311
- package/.agent/skills/agent-browser/TEST_PLAN.md +0 -200
- package/.agent/skills/sysinfo/SKILL.md +0 -38
- package/.agent/skills/sysinfo/system-info.sh +0 -130
- package/.agent/skills/workflow/SKILL.md +0 -324
- package/.agent/test-agent.js +0 -35
- package/.agent/weixin.json +0 -6
- package/.agent/workflows/email-digest.json +0 -50
- package/.agent/workflows/file-backup.json +0 -21
- package/.agent/workflows/get-ip-notify.json +0 -32
- package/.agent/workflows/news-aggregator.json +0 -93
- package/.agent/workflows/news-dashboard-v2.json +0 -94
- package/.agent/workflows/notification-batch.json +0 -32
- package/foliko-cloud-rising.png +0 -0
- package/foliko-dawn-of-ai.png +0 -0
- package/foliko-mindful-observation.png +0 -0
- package/foliko-stellar-dreams.png +0 -0
- package/foliko-zen-jing.png +0 -0
- package/foliko-zen-kong.png +0 -0
- package/foliko-zen-wu.png +0 -0
- package/zen_karesansui.png +0 -0
|
@@ -1,324 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: workflow
|
|
3
|
-
description: 工作流引擎 - 定义和执行结构化工作流,支持顺序、条件分支、循环、延迟、工具调用等步骤类型
|
|
4
|
-
allowed-tools: execute_workflow,reloadWorkflows
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# Workflow 工作流
|
|
8
|
-
|
|
9
|
-
工作流引擎用于定义和执行结构化的工作流程,支持多种步骤类型,可以组合使用实现复杂逻辑。
|
|
10
|
-
|
|
11
|
-
## 快速开始
|
|
12
|
-
|
|
13
|
-
### 创建工作流文件
|
|
14
|
-
|
|
15
|
-
工作流定义文件放在 `.agent/workflows/` 目录下,支持 `.json` 和 `.js` 格式:
|
|
16
|
-
|
|
17
|
-
```json
|
|
18
|
-
{
|
|
19
|
-
"name": "example-workflow",
|
|
20
|
-
"description": "示例工作流",
|
|
21
|
-
"steps": [
|
|
22
|
-
{ "type": "script", "name": "步骤1", "script": "return 'Hello';" },
|
|
23
|
-
{ "type": "tool", "name": "发送通知", "tool": "notification_send", "args": { "title": "标题", "message": "内容" } }
|
|
24
|
-
]
|
|
25
|
-
}
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
### 执行工作流
|
|
29
|
-
|
|
30
|
-
```javascript
|
|
31
|
-
// 通过 execute_workflow 工具执行
|
|
32
|
-
await execute_workflow({
|
|
33
|
-
workflow: "get-ip-notify" // 工作流名称(自动从 .agent/workflows/ 加载)
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
// 或直接传入工作流定义
|
|
37
|
-
await execute_workflow({
|
|
38
|
-
workflow: {
|
|
39
|
-
steps: [
|
|
40
|
-
{ "type": "script", "name": "Hello", "script": "return 'Hello World';" }
|
|
41
|
-
]
|
|
42
|
-
}
|
|
43
|
-
})
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
### 重要注意事项
|
|
47
|
-
|
|
48
|
-
1. **script 必须用 return 返回值**:`script` 是函数体,不是表达式
|
|
49
|
-
2. **JSON 中不能使用多行字符串**:所有 script 内容写成单行,用分号分隔
|
|
50
|
-
3. **JSON 中不能有注释**:注释会导致 JSON 解析失败
|
|
51
|
-
|
|
52
|
-
## 步骤类型
|
|
53
|
-
|
|
54
|
-
### 1. script - 脚本步骤
|
|
55
|
-
|
|
56
|
-
执行 JavaScript 代码,**必须用 return 返回值**:
|
|
57
|
-
|
|
58
|
-
```json
|
|
59
|
-
{
|
|
60
|
-
"type": "script",
|
|
61
|
-
"name": "计算",
|
|
62
|
-
"outputVariable": "result",
|
|
63
|
-
"script": "var a=10; var b=20; context.variables.sum=a+b; return a+b;"
|
|
64
|
-
}
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
**正确写法**:
|
|
68
|
-
```json
|
|
69
|
-
{ "script": "return context.variables.value + 1;" }
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
**错误写法**(缺少 return):
|
|
73
|
-
```json
|
|
74
|
-
{ "script": "context.variables.value + 1;" }
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
**JSON 中 script 只能写单行**,不能换行。如果逻辑复杂,建议拆成多个 script 步骤。
|
|
78
|
-
|
|
79
|
-
**script 中的可用对象**:
|
|
80
|
-
- `context.input` - 工作流输入参数
|
|
81
|
-
- `context.variables` - 工作流变量(可读写),存储在 outputVariable 中的值
|
|
82
|
-
- `context.lastResult` - 上一步骤的返回值
|
|
83
|
-
- `context.variables.loopIndex` - 循环中的当前索引
|
|
84
|
-
|
|
85
|
-
### 2. tool - 工具调用步骤
|
|
86
|
-
|
|
87
|
-
在工作流中调用框架注册的工具:
|
|
88
|
-
|
|
89
|
-
```json
|
|
90
|
-
{
|
|
91
|
-
"type": "tool",
|
|
92
|
-
"name": "发送通知",
|
|
93
|
-
"tool": "notification_send",
|
|
94
|
-
"args": {
|
|
95
|
-
"title": "标题",
|
|
96
|
-
"message": "内容"
|
|
97
|
-
},
|
|
98
|
-
"outputVariable": "result"
|
|
99
|
-
}
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
**参数说明**:
|
|
103
|
-
|
|
104
|
-
| 字段 | 类型 | 必填 | 说明 |
|
|
105
|
-
|------|------|------|------|
|
|
106
|
-
| `tool` | string | 是 | 工具名称 |
|
|
107
|
-
| `args` | object | 否 | 工具参数 |
|
|
108
|
-
| `outputVariable` | string | 否 | 结果保存到的变量名,可通过 `context.variables.xxx` 访问 |
|
|
109
|
-
|
|
110
|
-
**args 中支持变量引用**:
|
|
111
|
-
|
|
112
|
-
使用 `{{variableName}}` 语法引用 context.variables 中的变量:
|
|
113
|
-
|
|
114
|
-
```json
|
|
115
|
-
{
|
|
116
|
-
"type": "tool",
|
|
117
|
-
"name": "发送通知",
|
|
118
|
-
"tool": "notification_send",
|
|
119
|
-
"args": {
|
|
120
|
-
"title": "IP 信息",
|
|
121
|
-
"message": "当前公网IP: {{currentIp}}"
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
变量引用规则:
|
|
127
|
-
- `{{currentIp}}` → 从 context.variables.currentIp 获取
|
|
128
|
-
- `{{emailResult.success}}` → 支持嵌套属性访问
|
|
129
|
-
|
|
130
|
-
**完整示例 - 获取IP并发送通知**:
|
|
131
|
-
|
|
132
|
-
```json
|
|
133
|
-
{
|
|
134
|
-
"name": "get-ip-notify",
|
|
135
|
-
"description": "获取本机IP并发送通知",
|
|
136
|
-
"steps": [
|
|
137
|
-
{
|
|
138
|
-
"type": "tool",
|
|
139
|
-
"name": "获取IP信息",
|
|
140
|
-
"tool": "fetch",
|
|
141
|
-
"args": {
|
|
142
|
-
"url": "https://api.ipify.org?format=json",
|
|
143
|
-
"proxy": true
|
|
144
|
-
},
|
|
145
|
-
"outputVariable": "ipResult"
|
|
146
|
-
},
|
|
147
|
-
{
|
|
148
|
-
"type": "script",
|
|
149
|
-
"name": "提取IP",
|
|
150
|
-
"outputVariable": "currentIp",
|
|
151
|
-
"script": "var r=context.variables.ipResult; return (r&&r.success&&r.body)?(typeof r.body==='object'?r.body.ip:r.body.trim()):'获取失败';"
|
|
152
|
-
},
|
|
153
|
-
{
|
|
154
|
-
"type": "tool",
|
|
155
|
-
"name": "发送通知",
|
|
156
|
-
"tool": "notification_send",
|
|
157
|
-
"args": {
|
|
158
|
-
"title": "IP 信息",
|
|
159
|
-
"message": "当前公网IP: {{currentIp}}"
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
]
|
|
163
|
-
}
|
|
164
|
-
```
|
|
165
|
-
|
|
166
|
-
### 3. condition - 条件分支
|
|
167
|
-
|
|
168
|
-
根据条件选择执行分支:
|
|
169
|
-
|
|
170
|
-
```json
|
|
171
|
-
{
|
|
172
|
-
"type": "condition",
|
|
173
|
-
"name": "判断",
|
|
174
|
-
"branches": [
|
|
175
|
-
{
|
|
176
|
-
"name": "大于10",
|
|
177
|
-
"condition": "context.variables.value > 10",
|
|
178
|
-
"steps": [
|
|
179
|
-
{ "type": "script", "name": "处理大数", "script": "context.variables.status='big'; return true;" }
|
|
180
|
-
]
|
|
181
|
-
},
|
|
182
|
-
{
|
|
183
|
-
"name": "小于等于10",
|
|
184
|
-
"condition": "context.variables.value <= 10",
|
|
185
|
-
"steps": [
|
|
186
|
-
{ "type": "script", "name": "处理小数", "script": "context.variables.status='small'; return true;" }
|
|
187
|
-
]
|
|
188
|
-
}
|
|
189
|
-
]
|
|
190
|
-
}
|
|
191
|
-
```
|
|
192
|
-
|
|
193
|
-
**condition 中的 condition 写法**:
|
|
194
|
-
- 比较运算符:`>`、`<`、`>=`、`<=`、`===`、`!==`
|
|
195
|
-
- 逻辑运算符:`&&`、`||`、`!`
|
|
196
|
-
- 必须返回 boolean 值
|
|
197
|
-
|
|
198
|
-
### 4. loop - 循环步骤
|
|
199
|
-
|
|
200
|
-
重复执行一组步骤:
|
|
201
|
-
|
|
202
|
-
```json
|
|
203
|
-
{
|
|
204
|
-
"type": "loop",
|
|
205
|
-
"name": "循环3次",
|
|
206
|
-
"maxIterations": 3,
|
|
207
|
-
"loopVariable": "i",
|
|
208
|
-
"until": "context.variables.i >= 2",
|
|
209
|
-
"steps": [
|
|
210
|
-
{ "type": "script", "name": "迭代", "script": "context.variables.count=context.variables.i+1; return context.variables.i;" }
|
|
211
|
-
]
|
|
212
|
-
}
|
|
213
|
-
```
|
|
214
|
-
|
|
215
|
-
### 5. delay - 延迟步骤
|
|
216
|
-
|
|
217
|
-
等待指定时间:
|
|
218
|
-
|
|
219
|
-
```json
|
|
220
|
-
{
|
|
221
|
-
"type": "delay",
|
|
222
|
-
"name": "等待1秒",
|
|
223
|
-
"delayMs": 1000
|
|
224
|
-
}
|
|
225
|
-
```
|
|
226
|
-
|
|
227
|
-
### 6. sequential - 顺序步骤
|
|
228
|
-
|
|
229
|
-
将多个步骤组合为顺序执行(可嵌套使用):
|
|
230
|
-
|
|
231
|
-
```json
|
|
232
|
-
{
|
|
233
|
-
"type": "sequential",
|
|
234
|
-
"name": "顺序执行",
|
|
235
|
-
"steps": [
|
|
236
|
-
{ "type": "script", "name": "步骤1", "script": "return 1;" },
|
|
237
|
-
{ "type": "script", "name": "步骤2", "script": "return 2;" }
|
|
238
|
-
]
|
|
239
|
-
}
|
|
240
|
-
```
|
|
241
|
-
|
|
242
|
-
## sessionId 传递
|
|
243
|
-
|
|
244
|
-
工作流执行时会自动获取当前 sessionId,所有 tool 调用都会使用该 sessionId。
|
|
245
|
-
|
|
246
|
-
**调用流程**:
|
|
247
|
-
1. `execute_workflow` 从执行上下文获取 sessionId
|
|
248
|
-
2. sessionId 存入 `context.variables._sessionId`
|
|
249
|
-
3. ToolStep 执行工具时使用该 sessionId
|
|
250
|
-
|
|
251
|
-
**这确保了通知会发送到当前会话**。
|
|
252
|
-
|
|
253
|
-
## 工具
|
|
254
|
-
|
|
255
|
-
### execute_workflow
|
|
256
|
-
|
|
257
|
-
执行指定的工作流。
|
|
258
|
-
|
|
259
|
-
```javascript
|
|
260
|
-
// 按名称执行(从 .agent/workflows/ 加载)
|
|
261
|
-
await execute_workflow({
|
|
262
|
-
workflow: "get-ip-notify"
|
|
263
|
-
})
|
|
264
|
-
|
|
265
|
-
// 传入工作流定义
|
|
266
|
-
await execute_workflow({
|
|
267
|
-
workflow: {
|
|
268
|
-
steps: [
|
|
269
|
-
{ "type": "script", "script": "return 'test';" }
|
|
270
|
-
]
|
|
271
|
-
}
|
|
272
|
-
})
|
|
273
|
-
|
|
274
|
-
// 带输入参数
|
|
275
|
-
await execute_workflow({
|
|
276
|
-
workflow: "my-workflow",
|
|
277
|
-
input: { key: "value" }
|
|
278
|
-
})
|
|
279
|
-
```
|
|
280
|
-
|
|
281
|
-
### reloadWorkflows
|
|
282
|
-
|
|
283
|
-
重载所有工作流(当添加或修改工作流后调用)。
|
|
284
|
-
|
|
285
|
-
```javascript
|
|
286
|
-
await reloadWorkflows()
|
|
287
|
-
```
|
|
288
|
-
|
|
289
|
-
## 最佳实践
|
|
290
|
-
|
|
291
|
-
1. **script 必须 return**:`script` 是函数体,必须用 return 返回值
|
|
292
|
-
2. **JSON 中 script 单行写**:用分号分隔多个语句,不要换行
|
|
293
|
-
3. **拆分复杂逻辑**:复杂的 script 拆成多个简单步骤
|
|
294
|
-
4. **使用 outputVariable**:需要跨步骤使用的值,存入 context.variables
|
|
295
|
-
5. **条件判断加 else**:condition 分支要有兜底处理
|
|
296
|
-
6. **合理设置循环次数**:loop 的 maxIterations 不要过大
|
|
297
|
-
|
|
298
|
-
**错误示例**:
|
|
299
|
-
```json
|
|
300
|
-
// ❌ 错误 - script 没有 return
|
|
301
|
-
{ "type": "script", "script": "context.variables.count + 1;" }
|
|
302
|
-
|
|
303
|
-
// ❌ 错误 - JSON 多行字符串
|
|
304
|
-
{
|
|
305
|
-
"script": "
|
|
306
|
-
const a = 10;
|
|
307
|
-
return a + 1;
|
|
308
|
-
"
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
// ❌ 错误 - JSON 中有注释
|
|
312
|
-
{
|
|
313
|
-
"script": "return 1; // 这是注释"
|
|
314
|
-
}
|
|
315
|
-
```
|
|
316
|
-
|
|
317
|
-
**正确示例**:
|
|
318
|
-
```json
|
|
319
|
-
// ✅ 正确
|
|
320
|
-
{ "type": "script", "outputVariable": "count", "script": "return (context.variables.count||0) + 1;" }
|
|
321
|
-
|
|
322
|
-
// ✅ 正确 - 复杂逻辑拆成多步
|
|
323
|
-
{ "type": "script", "script": "context.variables.a=10; context.variables.b=20; return context.variables.a+context.variables.b;" }
|
|
324
|
-
```
|
package/.agent/test-agent.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
const fs = require("fs");
|
|
2
|
-
const path = require("path");
|
|
3
|
-
|
|
4
|
-
const agentsDir = path.join(".", "agents");
|
|
5
|
-
const files = fs.readdirSync(agentsDir);
|
|
6
|
-
console.log("子Agent文件:", files);
|
|
7
|
-
|
|
8
|
-
const { SubAgentConfigManager } = require("../src/core/sub-agent-config.js");
|
|
9
|
-
const configManager = new SubAgentConfigManager(agentsDir);
|
|
10
|
-
|
|
11
|
-
// 需要调用 loadAll() 来加载配置
|
|
12
|
-
configManager.loadAll();
|
|
13
|
-
|
|
14
|
-
const configs = configManager.getAll();
|
|
15
|
-
console.log("\n加载的子Agent配置:", configs.map(c => c.getName()));
|
|
16
|
-
|
|
17
|
-
// 测试 getAllConfigs
|
|
18
|
-
const configs2 = configManager.getAllConfigs();
|
|
19
|
-
console.log("getAllConfigs():", configs2.size, "个");
|
|
20
|
-
configs2.forEach((config, name) => {
|
|
21
|
-
console.log(` - ${name}: valid=${config.isValid()}`);
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
// 测试 orchestrator-demo
|
|
25
|
-
const demoConfig = configManager.get("orchestrator-demo");
|
|
26
|
-
if (demoConfig) {
|
|
27
|
-
console.log("\norchestrator-demo 配置:");
|
|
28
|
-
console.log(" 名称:", demoConfig.getName());
|
|
29
|
-
console.log(" 描述:", demoConfig.getDescription());
|
|
30
|
-
console.log(" 技能:", demoConfig.getSkills());
|
|
31
|
-
console.log(" 工具:", demoConfig.getTools());
|
|
32
|
-
console.log(" 模型:", demoConfig.getModel());
|
|
33
|
-
} else {
|
|
34
|
-
console.log("\n未找到 orchestrator-demo 配置");
|
|
35
|
-
}
|
package/.agent/weixin.json
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "email-digest",
|
|
3
|
-
"description": "邮件摘要工作流 - 读取未读邮件并生成摘要",
|
|
4
|
-
"steps": [
|
|
5
|
-
{
|
|
6
|
-
"type": "tool",
|
|
7
|
-
"name": "获取未读数",
|
|
8
|
-
"tool": "email_unread_count",
|
|
9
|
-
"args": {},
|
|
10
|
-
"outputVariable": "unreadResult"
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
"type": "condition",
|
|
14
|
-
"name": "检查是否有新邮件",
|
|
15
|
-
"branches": [
|
|
16
|
-
{
|
|
17
|
-
"name": "有新邮件",
|
|
18
|
-
"condition": "context.variables.unreadResult && context.variables.unreadResult.unreadCount > 0",
|
|
19
|
-
"steps": [
|
|
20
|
-
{
|
|
21
|
-
"type": "script",
|
|
22
|
-
"name": "记录状态",
|
|
23
|
-
"script": "context.variables.status='有新邮件'; return true;"
|
|
24
|
-
}
|
|
25
|
-
]
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
"name": "无新邮件",
|
|
29
|
-
"condition": "!context.variables.unreadResult || context.variables.unreadResult.unreadCount === 0",
|
|
30
|
-
"steps": [
|
|
31
|
-
{
|
|
32
|
-
"type": "script",
|
|
33
|
-
"name": "记录状态",
|
|
34
|
-
"script": "context.variables.status='无新邮件'; return false;"
|
|
35
|
-
}
|
|
36
|
-
]
|
|
37
|
-
}
|
|
38
|
-
]
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
"type": "tool",
|
|
42
|
-
"name": "发送通知",
|
|
43
|
-
"tool": "notification_send",
|
|
44
|
-
"args": {
|
|
45
|
-
"title": "邮件摘要",
|
|
46
|
-
"message": "未读邮件数: {{unreadResult.unreadCount}}"
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
]
|
|
50
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "file-backup",
|
|
3
|
-
"description": "文件备份工作流",
|
|
4
|
-
"steps": [
|
|
5
|
-
{
|
|
6
|
-
"type": "script",
|
|
7
|
-
"name": "准备路径",
|
|
8
|
-
"outputVariable": "backupInfo",
|
|
9
|
-
"script": "context.variables.source='.'; context.variables.dest='/backup'; return {source:'.',dest:'/backup'};"
|
|
10
|
-
},
|
|
11
|
-
{
|
|
12
|
-
"type": "tool",
|
|
13
|
-
"name": "发送通知",
|
|
14
|
-
"tool": "notification_send",
|
|
15
|
-
"args": {
|
|
16
|
-
"title": "备份开始",
|
|
17
|
-
"message": "开始备份文件"
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
]
|
|
21
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "get-ip-notify",
|
|
3
|
-
"description": "从 ifconfig.me 获取公网 IP 地址并发送系统通知",
|
|
4
|
-
"steps": [
|
|
5
|
-
{
|
|
6
|
-
"type": "tool",
|
|
7
|
-
"name": "获取IP信息",
|
|
8
|
-
"tool": "fetch",
|
|
9
|
-
"args": {
|
|
10
|
-
"url": "https://ifconfig.me/ip",
|
|
11
|
-
"timeout": 30000,
|
|
12
|
-
"proxy": true
|
|
13
|
-
},
|
|
14
|
-
"outputVariable": "ipResult"
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
"type": "script",
|
|
18
|
-
"name": "提取IP",
|
|
19
|
-
"outputVariable": "currentIp",
|
|
20
|
-
"script": "var r=context.variables.ipResult; var ip=r&&r.success&&r.body?r.body.trim():null; return ip||'获取失败';"
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
"type": "tool",
|
|
24
|
-
"name": "发送通知",
|
|
25
|
-
"tool": "notification_send",
|
|
26
|
-
"args": {
|
|
27
|
-
"title": "IP 信息",
|
|
28
|
-
"message": "当前公网IP: {{currentIp}}"
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
]
|
|
32
|
-
}
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "news-aggregator",
|
|
3
|
-
"description": "从多个新闻源(百度新闻、BBC、Reddit)获取新闻,整理生成网页",
|
|
4
|
-
"steps": [
|
|
5
|
-
{
|
|
6
|
-
"type": "script",
|
|
7
|
-
"name": "初始化新闻存储",
|
|
8
|
-
"outputVariable": "allNews",
|
|
9
|
-
"script": "context.variables.allNews=[]; context.variables.sources=['百度新闻','BBC','Reddit']; return context.variables.allNews;"
|
|
10
|
-
},
|
|
11
|
-
{
|
|
12
|
-
"type": "tool",
|
|
13
|
-
"name": "获取百度新闻",
|
|
14
|
-
"tool": "fetch",
|
|
15
|
-
"args": {
|
|
16
|
-
"url": "https://top.baidu.com/board?tab=realtime",
|
|
17
|
-
"timeout": 15000,
|
|
18
|
-
"proxy": true
|
|
19
|
-
},
|
|
20
|
-
"outputVariable": "baiduNewsResult"
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
"type": "tool",
|
|
24
|
-
"name": "获取BBC新闻",
|
|
25
|
-
"tool": "fetch",
|
|
26
|
-
"args": {
|
|
27
|
-
"url": "https://feeds.bbci.co.uk/news/world/rss.xml",
|
|
28
|
-
"timeout": 15000,
|
|
29
|
-
"proxy": true
|
|
30
|
-
},
|
|
31
|
-
"outputVariable": "bbcNewsResult"
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
"type": "tool",
|
|
35
|
-
"name": "获取Reddit新闻",
|
|
36
|
-
"tool": "fetch",
|
|
37
|
-
"args": {
|
|
38
|
-
"url": "https://www.reddit.com/r/news/.json?limit=20",
|
|
39
|
-
"timeout": 15000,
|
|
40
|
-
"proxy": true
|
|
41
|
-
},
|
|
42
|
-
"outputVariable": "redditNewsResult"
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
"type": "script",
|
|
46
|
-
"name": "处理百度新闻",
|
|
47
|
-
"outputVariable": "baiduNews",
|
|
48
|
-
"script": "var r=context.variables.baiduNewsResult; if(r&&r.success&&r.body){try{var matches=r.body.match(/href=\"\\/news\\/([^\"]+)\"[^>]*>([^<]+)<\\/a>/g);if(!matches)matches=r.body.match(/\"query\":\"([^\"]+)\"/g);var items=[];if(matches)for(var i=0;i<Math.min(matches.length,10);i++){var m=matches[i].match(/\"query\":\"([^\"]+)\"/)||matches[i].match(/>([^<]+)</);if(m&&m[1])items.push(m[1].trim());}context.variables.baiduNews=items.length?items:['百度新闻:页面解析中...'];}catch(e){context.variables.baiduNews=['百度新闻:获取成功'];}}else{context.variables.baiduNews=['百度新闻:获取失败'];}return context.variables.baiduNews;"
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
"type": "script",
|
|
52
|
-
"name": "处理BBC新闻",
|
|
53
|
-
"outputVariable": "bbcNews",
|
|
54
|
-
"script": "var r=context.variables.bbcNewsResult; var items=[]; if(r&&r.success&&r.body){try{var titles=r.body.match(/<title><!\\[CDATA\\[([^\\]]+)\\]\\]><\\/title>/g)||r.body.match(/<title>([^<]+)<\\/title>/g);if(titles)for(var i=1;i<Math.min(titles.length,11);i++){var m=titles[i].match(/\\[([^\\]]+)\\]/);if(m&&m[1]&&m[1]!=='BBC News')items.push(m[1]);}}catch(e){}if(items.length===0)items=['BBC:获取成功'];}else{items=['BBC:获取失败'];}context.variables.bbcNews=items; return items;"
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
"type": "script",
|
|
58
|
-
"name": "处理Reddit新闻",
|
|
59
|
-
"outputVariable": "redditNews",
|
|
60
|
-
"script": "var r=context.variables.redditNewsResult; var items=[]; if(r&&r.success&&r.body){try{var data=typeof r.body==='string'?JSON.parse(r.body):r.body;if(data&&data.data&&data.data.children){data.data.children.slice(0,10).forEach(function(item){if(item.data&&item.data.title)items.push(item.data.title);});}}catch(e){}if(items.length===0)items=['Reddit:获取成功'];}else{items=['Reddit:获取失败'];}context.variables.redditNews=items; return items;"
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
"type": "script",
|
|
64
|
-
"name": "生成HTML网页",
|
|
65
|
-
"outputVariable": "htmlContent",
|
|
66
|
-
"script": "var now=new Date();var dateStr=now.toLocaleDateString('zh-CN',{year:'numeric',month:'long',day:'numeric',hour:'2-digit',minute:'2-digit'});var baidu=context.variables.baiduNews||[];var bbc=context.variables.bbcNews||[];var reddit=context.variables.redditNews||[];var html='<!DOCTYPE html>\\n<html lang=\"zh-CN\">\\n<head>\\n<meta charset=\"UTF-8\">\\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\\n<title>全球新闻聚合 - '+dateStr+'</title>\\n<style>\\n*{margin:0;padding:0;box-sizing:border-box;}\\nbody{font-family:-apple-system,BlinkMacSystemFont,\"Segoe UI\",Roboto,\"Helvetica Neue\",Arial,sans-serif;background:linear-gradient(135deg,#667eea 0%,#764ba2 100%);min-height:100vh;padding:20px;}\\n.container{max-width:1200px;margin:0 auto;}\\nh1{text-align:center;color:#fff;margin-bottom:30px;font-size:2.5em;text-shadow:2px 2px 4px rgba(0,0,0,0.3);}\\n.grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(350px,1fr));gap:25px;}\\n.card{background:#fff;border-radius:16px;overflow:hidden;box-shadow:0 10px 40px rgba(0,0,0,0.2);transition:transform 0.3s ease;}\\n.card:hover{transform:translateY(-5px);}\\n.card-header{padding:20px;color:#fff;font-weight:bold;font-size:1.3em;}\\n.card-header.baidu{background:linear-gradient(135deg,#4e54c8,#8f94fb);}\\n.card-header.bbc{background:linear-gradient(135deg,#b21f1f,#f64f59);}\\n.card-header.reddit{background:linear-gradient(135deg,#ff4500,#ff6a33);}\\n.card-body{padding:20px;}\\n.news-list{list-style:none;}\\n.news-list li{padding:12px 0;border-bottom:1px solid #eee;cursor:pointer;transition:all 0.2s;}\\n.news-list li:last-child{border-bottom:none;}\\n.news-list li:hover{color:#667eea;padding-left:10px;}\\n.news-list li::before{content:\"• \";color:#667eea;font-weight:bold;margin-right:8px;}\\n.timestamp{text-align:center;color:#999;font-size:0.9em;margin-top:20px;}\\n</style>\\n</head>\\n<body>\\n<div class=\"container\">\\n<h1>📰 全球新闻聚合</h1>\\n<div class=\"grid\">\\n<div class=\"card\"><div class=\"card-header baidu\">🇨🇳 百度新闻</div><div class=\"card-body\"><ul class=\"news-list\">';baidu.forEach(function(n){html+='<li>'+n+'</li>';});html+='</ul></div></div>\\n<div class=\"card\"><div class=\"card-header bbc\">🇬🇧 BBC News</div><div class=\"card-body\"><ul class=\"news-list\">';bbc.forEach(function(n){html+='<li>'+n+'</li>';});html+='</ul></div></div>\\n<div class=\"card\"><div class=\"card-header reddit\">🤖 Reddit News</div><div class=\"card-body\"><ul class=\"news-list\">';reddit.forEach(function(n){html+='<li>'+n+'</li>';});html+='</ul></div></div>\\n</div>\\n<p class=\"timestamp\">更新时间: '+dateStr+' | 数据来源: 百度新闻、BBC、Reddit</p>\\n</div>\\n</body>\\n</html>';return html;"
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
"type": "script",
|
|
70
|
-
"name": "生成文件名",
|
|
71
|
-
"outputVariable": "filePath",
|
|
72
|
-
"script": "var now=new Date();var dateStr=now.toISOString().slice(0,10).replace(/-/g,'');var timestamp=Date.now();context.variables.filePath='D:/Code/vb-agent/news-'+dateStr+'-'+timestamp+'.html';return context.variables.filePath;"
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
"type": "tool",
|
|
76
|
-
"name": "保存HTML文件",
|
|
77
|
-
"tool": "write_file",
|
|
78
|
-
"args": {
|
|
79
|
-
"path": "{{filePath}}",
|
|
80
|
-
"content": "{{htmlContent}}"
|
|
81
|
-
}
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
"type": "tool",
|
|
85
|
-
"name": "发送完成通知",
|
|
86
|
-
"tool": "notification_send",
|
|
87
|
-
"args": {
|
|
88
|
-
"title": "📰 新闻聚合完成",
|
|
89
|
-
"message": "已从百度新闻、BBC、Reddit获取新闻\\n网页已生成: {{filePath}}"
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
]
|
|
93
|
-
}
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "news-dashboard-v2",
|
|
3
|
-
"description": "新闻汇总工作流v2 - 从网络获取真实新闻数据并生成网页",
|
|
4
|
-
"version": "2.2",
|
|
5
|
-
"steps": [
|
|
6
|
-
{
|
|
7
|
-
"id": "step-1",
|
|
8
|
-
"type": "tool",
|
|
9
|
-
"name": "获取当前日期时间",
|
|
10
|
-
"tool": "get_time",
|
|
11
|
-
"output": "dateResult"
|
|
12
|
-
},
|
|
13
|
-
{
|
|
14
|
-
"id": "step-2",
|
|
15
|
-
"type": "tool",
|
|
16
|
-
"name": "获取百度热搜",
|
|
17
|
-
"tool": "fetch",
|
|
18
|
-
"args": {
|
|
19
|
-
"url": "https://top.baidu.com/board?tab=realtime",
|
|
20
|
-
"timeout": 15000,
|
|
21
|
-
"proxy": true
|
|
22
|
-
},
|
|
23
|
-
"output": "baiduResult"
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
"id": "step-3",
|
|
27
|
-
"type": "tool",
|
|
28
|
-
"name": "获取BBC国际新闻",
|
|
29
|
-
"tool": "fetch",
|
|
30
|
-
"args": {
|
|
31
|
-
"url": "https://feeds.bbci.co.uk/news/world/rss.xml",
|
|
32
|
-
"timeout": 15000,
|
|
33
|
-
"proxy": true
|
|
34
|
-
},
|
|
35
|
-
"output": "bbcResult"
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
"id": "step-4",
|
|
39
|
-
"type": "tool",
|
|
40
|
-
"name": "获取Reddit热门",
|
|
41
|
-
"tool": "fetch",
|
|
42
|
-
"args": {
|
|
43
|
-
"url": "https://www.reddit.com/r/popular/hot.json?limit=15",
|
|
44
|
-
"timeout": 15000,
|
|
45
|
-
"proxy": true
|
|
46
|
-
},
|
|
47
|
-
"output": "redditResult"
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
"id": "step-5",
|
|
51
|
-
"type": "tool",
|
|
52
|
-
"name": "获取香港新闻",
|
|
53
|
-
"tool": "fetch",
|
|
54
|
-
"args": {
|
|
55
|
-
"url": "https://rsshub.app/rsshub/rss",
|
|
56
|
-
"timeout": 15000,
|
|
57
|
-
"proxy": true
|
|
58
|
-
},
|
|
59
|
-
"output": "hkResult"
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
"id": "step-6",
|
|
63
|
-
"type": "script",
|
|
64
|
-
"name": "处理新闻数据",
|
|
65
|
-
"script": "var dateResult = context.variables.dateResult || {};\nvar baiduResult = context.variables.baiduResult || {};\nvar bbcResult = context.variables.bbcResult || {};\nvar redditResult = context.variables.redditResult || {};\nvar hkResult = context.variables.hkResult || {};\n\nvar dateStr = (dateResult.beijingTime || dateResult.formatted || {}).beijingTime || new Date().toLocaleString('zh-CN');\nvar baiduRaw = typeof baiduResult === 'string' ? baiduResult : (baiduResult.body || baiduResult.content || JSON.stringify(baiduResult));\nvar bbcRaw = typeof bbcResult === 'string' ? bbcResult : (bbcResult.body || bbcResult.content || JSON.stringify(bbcResult));\nvar redditRaw = typeof redditResult === 'string' ? redditResult : (redditResult.body || redditResult.content || JSON.stringify(redditResult));\nvar hkRaw = typeof hkResult === 'string' ? hkResult : (hkResult.body || hkResult.content || JSON.stringify(hkResult));\n\nvar baiduNews = [];\nif (baiduRaw) {\n var titleMatch = baiduRaw.match(/<a[^>]*class=\"c-single-text-ellipsis\"[^>]*>([^<]+)<\\/a>/g);\n if (titleMatch) {\n for (var i = 0; i < Math.min(titleMatch.length, 20); i++) {\n baiduNews.push({rank: i + 1, title: titleMatch[i].replace(/<[^>]+>/g, '').trim()});\n }\n }\n}\n\nvar bbcNews = [];\nif (bbcRaw) {\n var itemMatch = bbcRaw.match(/<item[^>]*>[\\s\\S]*?<\\/item>/g);\n if (itemMatch) {\n for (var i = 0; i < Math.min(itemMatch.length, 15); i++) {\n var t = itemMatch[i].match(/<title>([^<]+)<\\/title>/);\n var l = itemMatch[i].match(/<link>([^<]+)<\\/link>/);\n if (t) {\n bbcNews.push({title: t[1].trim(), link: l ? l[1].trim() : '#'});\n }\n }\n }\n}\n\nvar redditNews = [];\nif (redditRaw) {\n try {\n var data = JSON.parse(redditRaw);\n var children = (data.data || {}).children || [];\n for (var i = 0; i < Math.min(children.length, 10); i++) {\n var d = children[i].data || {};\n redditNews.push({rank: i + 1, title: d.title || '', score: d.score || 0, subreddit: d.subreddit || ''});\n }\n } catch(e) {}\n}\n\nvar hkNews = [];\nif (hkRaw) {\n var itemMatch = hkRaw.match(/<item[^>]*>[\\s\\S]*?<\\/item>/g);\n if (itemMatch) {\n for (var i = 0; i < Math.min(itemMatch.length, 10); i++) {\n var t = itemMatch[i].match(/<title>([^<]+)<\\/title>/);\n var l = itemMatch[i].match(/<link>([^<]+)<\\/link>/);\n if (t) {\n hkNews.push({title: t[1].trim(), link: l ? l[1].trim() : '#'});\n }\n }\n }\n}\n\nreturn {date: dateStr, baidu: baiduNews, bbc: bbcNews, reddit: redditNews, hk: hkNews};",
|
|
66
|
-
"output": "processedNews"
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
"id": "step-7",
|
|
70
|
-
"type": "script",
|
|
71
|
-
"name": "生成完整HTML",
|
|
72
|
-
"script": "var newsData = context.variables.processedNews || {};\nvar dateStr = newsData.date || new Date().toLocaleString('zh-CN');\nvar baidu = newsData.baidu || [];\nvar bbc = newsData.bbc || [];\nvar reddit = newsData.reddit || [];\nvar hk = newsData.hk || [];\n\nfunction renderRank(rank, isHot) {\n if (isHot && rank <= 3) {\n var colors = ['#ff6b6b', '#ffa502', '#26de81'];\n return '<span style=\"background:' + colors[rank - 1] + ';color:white;padding:2px 8px;border-radius:4px;font-weight:bold;\">' + rank + '</span>';\n }\n return '<span style=\"color:#888;\">' + rank + '</span>';\n}\n\nfunction renderItem(item, index, isHot) {\n var rank = index + 1;\n var title = item.title || '';\n var link = item.link || '#';\n var score = item.score || 0;\n var subreddit = item.subreddit || '';\n var rankHtml = renderRank(rank, isHot);\n if (link && link !== '#') {\n return '<li class=\"news-item\">' + rankHtml + ' <a href=\"' + link + '\" target=\"_blank\">' + title + '</a></li>';\n } else if (subreddit) {\n return '<li class=\"news-item\">' + rankHtml + ' <span style=\"color:#ff4500;\">r/' + subreddit + '</span> ' + title + ' <span style=\"color:#888;font-size:0.8em;\">▲ ' + score + '</span></li>';\n }\n return '<li class=\"news-item\">' + rankHtml + ' ' + title + '</li>';\n}\n\nfunction renderList(items, isHot) {\n return items.map(function(item, i) { return renderItem(item, i, isHot); }).join('\\n');\n}\n\nvar html = '<!DOCTYPE html><html lang=\"zh-CN\"><head><meta charset=\"UTF-8\"><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"><title>新闻汇总 - ' + dateStr + '</title><style>*{box-sizing:border-box;margin:0;padding:0}body{font-family:-apple-system,BlinkMacSystemFont,\"Segoe UI\",Roboto,sans-serif;background:linear-gradient(135deg,#667eea 0%,#764ba2 100%);min-height:100vh;padding:20px}.container{max-width:1200px;margin:0 auto}header{text-align:center;color:white;padding:30px 0}header h1{font-size:2.5em;margin-bottom:10px;text-shadow:2px 2px 4px rgba(0,0,0,0.2)}header p{opacity:0.9;font-size:1.1em}.tabs{display:flex;gap:10px;margin-bottom:20px;flex-wrap:wrap;justify-content:center}.tab-btn{padding:12px 24px;border:none;border-radius:25px;cursor:pointer;font-size:1em;font-weight:600;transition:all 0.3s;background:rgba(255,255,255,0.2);color:white}.tab-btn:hover,.tab-btn.active{background:white;color:#667eea}.tab-content{display:none;background:white;border-radius:20px;padding:30px;box-shadow:0 20px 60px rgba(0,0,0,0.2)}.tab-content.active{display:block}.tab-content h2{color:#333;margin-bottom:20px;padding-bottom:10px;border-bottom:3px solid #667eea;display:inline-block}.news-item{padding:12px 0;border-bottom:1px solid #eee;display:flex;align-items:center;gap:10px}.news-item:last-child{border-bottom:none}.news-item a{color:#333;text-decoration:none;flex:1}.news-item a:hover{color:#667eea}.news-list{list-style:none}.empty{color:#888;text-align:center;padding:40px}@media(max-width:768px){body{padding:10px}header h1{font-size:1.8em}.tab-btn{padding:10px 16px;font-size:0.9em}.tab-content{padding:20px}}</style></head><body><div class=\"container\"><header><h1>📰 新闻汇总</h1><p>更新时间: ' + dateStr + '</p></header><div class=\"tabs\"><button class=\"tab-btn active\" onclick=\"showTab(\\'baidu\\')\">🔥 百度热搜</button><button class=\"tab-btn\" onclick=\"showTab(\\'bbc\\')\">🌍 BBC国际</button><button class=\"tab-btn\" onclick=\"showTab(\\'hk\\')\">🇭🇰 香港新闻</button><button class=\"tab-btn\" onclick=\"showTab(\\'reddit\\')\">💬 Reddit热帖</button></div><div id=\"baidu\" class=\"tab-content active\"><h2>🔥 百度热搜</h2><ul class=\"news-list\">' + (baidu.length > 0 ? renderList(baidu, true) : '<li class=\"empty\">正在获取数据...</li>') + '</ul></div><div id=\"bbc\" class=\"tab-content\"><h2>🌍 BBC国际新闻</h2><ul class=\"news-list\">' + (bbc.length > 0 ? renderList(bbc, false) : '<li class=\"empty\">正在获取数据...</li>') + '</ul></div><div id=\"hk\" class=\"tab-content\"><h2>🇭🇰 香港新闻</h2><ul class=\"news-list\">' + (hk.length > 0 ? renderList(hk, false) : '<li class=\"empty\">正在获取数据...</li>') + '</ul></div><div id=\"reddit\" class=\"tab-content\"><h2>💬 Reddit热门帖子</h2><ul class=\"news-list\">' + (reddit.length > 0 ? renderList(reddit, false) : '<li class=\"empty\">正在获取数据...</li>') + '</ul></div></div><script>function showTab(n){document.querySelectorAll(\".tab-content\").forEach(function(e){e.classList.remove(\"active\")});document.querySelectorAll(\".tab-btn\").forEach(function(e){e.classList.remove(\"active\")});document.getElementById(n).classList.add(\"active\");event.target.classList.add(\"active\")}</script></body></html>';\nreturn html;",
|
|
73
|
-
"output": "finalHtml"
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
"id": "step-8",
|
|
77
|
-
"type": "tool",
|
|
78
|
-
"name": "保存HTML文件",
|
|
79
|
-
"tool": "write_file",
|
|
80
|
-
"args": {
|
|
81
|
-
"path": "D:\\Code\\vb-agent\\news.html",
|
|
82
|
-
"content": "${step-7.output}"
|
|
83
|
-
},
|
|
84
|
-
"output": "savedPath"
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
"id": "step-9",
|
|
88
|
-
"type": "script",
|
|
89
|
-
"name": "返回结果",
|
|
90
|
-
"script": "return JSON.stringify({success: true, message: '新闻汇总工作流执行完成', output_file: 'D:\\\\Code\\\\vb-agent\\\\news.html', note: '新闻数据已从网络获取并生成网页'}, null, 2);",
|
|
91
|
-
"output": "workflowResult"
|
|
92
|
-
}
|
|
93
|
-
]
|
|
94
|
-
}
|