foliko 1.1.36 → 1.1.39
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/agents/network-requester.md +44 -0
- package/.agent/agents/poster-designer.md +52 -0
- package/.agent/agents/ui-designer.md +1 -1
- package/.agent/data/default.json +23 -407
- package/.agent/data/email/processed-emails.json +1 -0
- package/.agent/data/plugins-state.json +103 -200
- package/.agent/data/scheduler/tasks.json +1 -86
- package/.agent/data/web/web-config.json +5 -0
- package/.agent/data/weixin/images/file_1776188148383jpg +0 -0
- package/.agent/data/weixin/images/file_1776188458326.jpg +0 -0
- package/.agent/data/weixin/images/file_1776188689423.jpg +0 -0
- package/.agent/data/weixin/images/file_1776188813604.jpg +0 -0
- package/.agent/data/weixin/images/file_1776189097450.jpg +0 -0
- package/.agent/data/weixin/videos/file_1776188318431.mp4 +0 -0
- package/.agent/mcp_config.json +4 -17
- package/.agent/memory/user/mof6gk94-kneeuh.md +9 -0
- package/.agent/package.json +8 -0
- package/.agent/plugins/marknative/README.md +134 -0
- package/.agent/plugins/marknative/fonts/SegoeUI Emoji.ttf +0 -0
- package/.agent/plugins/marknative/fonts.zip +0 -0
- package/.agent/plugins/marknative/index.js +256 -0
- package/.agent/plugins/marknative/package.json +12 -0
- package/.agent/plugins/test-plugin.py +99 -0
- package/.agent/plugins.json +11 -5
- package/.agent/python-scripts/test_sample.py +24 -0
- package/.agent/sessions/cli_default.json +2415 -349
- package/.agent/sessions/default.json +82 -0
- package/.agent/sessions/qq_c2c_D960F12877541624D7B2C836110B3D0F.json +25 -0
- package/.agent/sessions/test-clean.json +26 -0
- package/.agent/sessions/test-compress.json +1462 -0
- package/.agent/sessions/test-session.json +13 -0
- package/.agent/sessions/weixin_test.json +22 -0
- package/.agent/sessions/weixin_test_user_123.json +11 -0
- package/.agent/skills/agent-browser/SKILL.md +311 -0
- package/.agent/skills/agent-browser/TEST_PLAN.md +200 -0
- package/.agent/skills/sysinfo/SKILL.md +38 -0
- package/.agent/skills/sysinfo/system-info.sh +130 -0
- package/.agent/skills/workflow/SKILL.md +324 -0
- package/.agent/test-agent.js +35 -0
- package/.agent/weixin.json +6 -0
- package/.agent/workflows/email-digest.json +50 -0
- package/.agent/workflows/file-backup.json +21 -0
- package/.agent/workflows/get-ip-notify.json +32 -0
- package/.agent/workflows/news-aggregator.json +93 -0
- package/.agent/workflows/news-dashboard-v2.json +94 -0
- package/.agent/workflows/notification-batch.json +32 -0
- package/.claude/settings.local.json +2 -1
- package/.env.example +56 -56
- package/README.md +441 -441
- package/cli/src/utils/debounce.js +6 -3
- package/docs/qq-bot.md +976 -0
- package/package.json +3 -1
- package/plugins/qq-plugin.js +939 -0
- package/plugins/scheduler-plugin.js +17 -17
- package/skills/find-skills/AGENTS.md +162 -162
- package/skills/find-skills/SKILL.md +133 -133
- package/src/core/agent-chat.js +11 -6
- package/temp_img.md +1 -0
- package/website_v2/styles/animations.css +7 -7
- package/.agent/.shared/ui-ux-pro-max/data/charts.csv +0 -26
- package/.agent/.shared/ui-ux-pro-max/data/colors.csv +0 -97
- package/.agent/.shared/ui-ux-pro-max/data/icons.csv +0 -101
- package/.agent/.shared/ui-ux-pro-max/data/landing.csv +0 -31
- package/.agent/.shared/ui-ux-pro-max/data/products.csv +0 -97
- package/.agent/.shared/ui-ux-pro-max/data/prompts.csv +0 -24
- package/.agent/.shared/ui-ux-pro-max/data/react-performance.csv +0 -45
- package/.agent/.shared/ui-ux-pro-max/data/stacks/flutter.csv +0 -53
- package/.agent/.shared/ui-ux-pro-max/data/stacks/html-tailwind.csv +0 -56
- package/.agent/.shared/ui-ux-pro-max/data/stacks/jetpack-compose.csv +0 -53
- package/.agent/.shared/ui-ux-pro-max/data/stacks/nextjs.csv +0 -53
- package/.agent/.shared/ui-ux-pro-max/data/stacks/nuxt-ui.csv +0 -51
- package/.agent/.shared/ui-ux-pro-max/data/stacks/nuxtjs.csv +0 -59
- package/.agent/.shared/ui-ux-pro-max/data/stacks/react-native.csv +0 -52
- package/.agent/.shared/ui-ux-pro-max/data/stacks/react.csv +0 -54
- package/.agent/.shared/ui-ux-pro-max/data/stacks/shadcn.csv +0 -61
- package/.agent/.shared/ui-ux-pro-max/data/stacks/svelte.csv +0 -54
- package/.agent/.shared/ui-ux-pro-max/data/stacks/swiftui.csv +0 -51
- package/.agent/.shared/ui-ux-pro-max/data/stacks/vue.csv +0 -50
- package/.agent/.shared/ui-ux-pro-max/data/styles.csv +0 -59
- package/.agent/.shared/ui-ux-pro-max/data/typography.csv +0 -58
- package/.agent/.shared/ui-ux-pro-max/data/ui-reasoning.csv +0 -101
- package/.agent/.shared/ui-ux-pro-max/data/ux-guidelines.csv +0 -100
- package/.agent/.shared/ui-ux-pro-max/data/web-interface.csv +0 -31
- 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 +0 -258
- package/.agent/.shared/ui-ux-pro-max/scripts/design_system.py +0 -1067
- package/.agent/.shared/ui-ux-pro-max/scripts/search.py +0 -106
- package/.agent/ARCHITECTURE.md +0 -288
- package/.agent/data/ambient/goals.json +0 -1
- package/.agent/data/puppeteer-sessions/undefined.json +0 -6
- 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/memory/feedback/mnygjgox-ualjip.md +0 -11
- package/.agent/memory/feedback/mnzugpej-esdwsr.md +0 -9
- package/.agent/memory/feedback/mo2quxke-saxs56.md +0 -9
- package/.agent/memory/feedback/mo9l6nw9-sm1ye2.md +0 -13
- package/.agent/memory/feedback/mo9uxkb3-bbxz3x.md +0 -9
- package/.agent/memory/feedback/mo9wpqy0-ftsez9.md +0 -13
- package/.agent/memory/feedback/mo9x2ps4-p7huqq.md +0 -11
- package/.agent/memory/feedback/mo9x2uay-z7ndjn.md +0 -9
- package/.agent/memory/feedback/mo9x2y7d-9wecyx.md +0 -9
- package/.agent/memory/feedback/mo9x39q3-nn7myt.md +0 -9
- package/.agent/memory/feedback/mo9xfir9-4g8a8j.md +0 -9
- package/.agent/memory/feedback/mo9xfui8-ujqrc6.md +0 -9
- package/.agent/memory/feedback/mocnx1wx-qtxxlh.md +0 -9
- package/.agent/memory/project/mnqx54u5-loqtoe.md +0 -9
- package/.agent/memory/project/mnqx84cv-mx6dmd.md +0 -9
- package/.agent/memory/project/mnsacuyr-hgtk5n.md +0 -20
- package/.agent/memory/project/mnu5hy2x-bjsg7u.md +0 -9
- package/.agent/memory/project/mny28ot4-8qe9au.md +0 -9
- package/.agent/memory/project/mnztftxj-af82rh.md +0 -9
- package/.agent/memory/project/mo0y04d0-bmaefl.md +0 -9
- package/.agent/memory/project/mo2iztxb-3c7v81.md +0 -9
- package/.agent/memory/project/mo2ssa5x-tpi1p3.md +0 -9
- package/.agent/memory/reference/mnre3cww-penbo1.md +0 -9
- package/.agent/memory/reference/mns9wn48-luerua.md +0 -14
- package/.agent/memory/reference/mns9yz5c-thc2s0.md +0 -16
- package/.agent/memory/reference/mnsfy4um-910f1o.md +0 -23
- package/.agent/memory/reference/mnsg37dp-lmfj18.md +0 -32
- package/.agent/memory/reference/mnsll60q-0j911u.md +0 -36
- package/.agent/memory/reference/mnsmlb5y-nej31u.md +0 -16
- package/.agent/memory/reference/mnssle72-yrot96.md +0 -9
- package/.agent/memory/reference/mnygj8nb-bjthmc.md +0 -20
- package/.agent/memory/reference/mnzfvs4m-ufyg9a.md +0 -12
- package/.agent/memory/user/mnsfuon6-l416q1.md +0 -21
- package/.agent/memory/user/mnsg9kut-95m7rf.md +0 -20
- package/.agent/memory/user/mnu2eo1v-yy6fhe.md +0 -9
- package/.agent/memory/user/mnu2etuo-8u8jk8.md +0 -9
- package/.agent/memory/user/mnx0rk6g-gsznjj.md +0 -9
- package/.agent/memory/user/mnyf1riz-4yo5yz.md +0 -9
- package/.agent/memory/user/mnzuh4cw-zvee8w.md +0 -13
- package/.agent/memory/user/mnzvewyj-jl67cq.md +0 -9
- package/.agent/memory/user/mnzwh9xo-43ys3f.md +0 -9
- package/.agent/memory/user/mo0ycvpn-eebsxc.md +0 -9
- package/.agent/memory/user/mo2k8c8n-132r2u.md +0 -9
- package/.agent/memory/user/mo6y2dei-5cf537.md +0 -13
- package/.agent/memory/user/mo9xsdo6-8vylww.md +0 -13
- package/.agent/plugins/puppeteer-plugin/README.md +0 -147
- package/.agent/plugins/puppeteer-plugin/index.js +0 -1422
- package/.agent/plugins/puppeteer-plugin/package.json +0 -9
- package/.agent/rules/GEMINI.md +0 -273
- package/.agent/rules/allow-rule.md +0 -77
- package/.agent/rules/log-rule.md +0 -83
- package/.agent/rules/security-rule.md +0 -93
- package/.agent/scripts/auto_preview.py +0 -148
- package/.agent/scripts/checklist.py +0 -217
- package/.agent/scripts/session_manager.py +0 -120
- package/.agent/scripts/verify_all.py +0 -327
- package/.agent/skills/doc.md +0 -177
- package/.agent/skills/fk-poster/SKILL.md +0 -1129
- package/.agent/skills/fkbuilder/SKILL.md +0 -730
- package/.agent/skills/mmx-cli/SKILL.md +0 -431
- package/.agent/workflows/brainstorm.md +0 -113
- package/.agent/workflows/create.md +0 -59
- package/.agent/workflows/debug.md +0 -103
- package/.agent/workflows/deploy.md +0 -176
- package/.agent/workflows/enhance.md +0 -63
- package/.agent/workflows/orchestrate.md +0 -237
- package/.agent/workflows/plan.md +0 -89
- package/.agent/workflows/preview.md +0 -81
- package/.agent/workflows/simple-test.md +0 -42
- package/.agent/workflows/status.md +0 -86
- package/.agent/workflows/structured-orchestrate.md +0 -180
- package/.agent/workflows/test.md +0 -144
- package/.agent/workflows/ui-ux-pro-max.md +0 -296
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# 系统信息查询脚本(跨平台支持)
|
|
3
|
+
# 用法: system-info [option]
|
|
4
|
+
# 选项: all (默认), cpu, memory, disk, network, system
|
|
5
|
+
|
|
6
|
+
OPTION=${1:-all}
|
|
7
|
+
|
|
8
|
+
echo "=========================================="
|
|
9
|
+
echo " System Info Report - $(date '+%Y-%m-%d %H:%M:%S')"
|
|
10
|
+
echo "=========================================="
|
|
11
|
+
echo ""
|
|
12
|
+
|
|
13
|
+
# 系统基本信息
|
|
14
|
+
show_system() {
|
|
15
|
+
echo "[System Info]"
|
|
16
|
+
echo " Hostname: $(hostname)"
|
|
17
|
+
echo " OS: $(uname -s)"
|
|
18
|
+
echo " Kernel: $(uname -r)"
|
|
19
|
+
echo " Arch: $(uname -m)"
|
|
20
|
+
echo ""
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
# CPU 信息
|
|
24
|
+
show_cpu() {
|
|
25
|
+
echo "[CPU Info]"
|
|
26
|
+
if [ -f /proc/cpuinfo ]; then
|
|
27
|
+
echo " Model: $(grep 'model name' /proc/cpuinfo | head -1 | cut -d':' -f2 | xargs)"
|
|
28
|
+
echo " Cores: $(grep -c ^processor /proc/cpuinfo)"
|
|
29
|
+
elif command -v powershell &> /dev/null; then
|
|
30
|
+
cpu_info=$(powershell -NoProfile -Command "
|
|
31
|
+
\$cpu = Get-CimInstance Win32_Processor | Select-Object -First 1
|
|
32
|
+
\$cores = (Get-CimInstance Win32_Processor | Measure-Object -Property NumberOfCores -Sum).Sum
|
|
33
|
+
\$threads = (Get-CimInstance Win32_Processor | Measure-Object -Property NumberOfLogicalProcessors -Sum).Sum
|
|
34
|
+
Write-Output \"\$(\$cpu.Name)|\$cores|\$threads\"
|
|
35
|
+
")
|
|
36
|
+
cpu_name=$(echo "$cpu_info" | cut -d'|' -f1)
|
|
37
|
+
cpu_cores=$(echo "$cpu_info" | cut -d'|' -f2)
|
|
38
|
+
cpu_threads=$(echo "$cpu_info" | cut -d'|' -f3)
|
|
39
|
+
echo " Model: $cpu_name"
|
|
40
|
+
echo " Cores: $cpu_cores"
|
|
41
|
+
echo " Threads: $cpu_threads"
|
|
42
|
+
else
|
|
43
|
+
echo " Model: $(sysctl -n machdep.cpu.brand_string 2>/dev/null || echo 'Unknown')"
|
|
44
|
+
fi
|
|
45
|
+
echo ""
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
# 内存信息
|
|
49
|
+
show_memory() {
|
|
50
|
+
echo "[Memory Info]"
|
|
51
|
+
if [ -f /proc/meminfo ]; then
|
|
52
|
+
mem_total=$(grep MemTotal /proc/meminfo | awk '{printf "%.2f GB", $2/1024/1024}')
|
|
53
|
+
mem_free=$(grep MemFree /proc/meminfo | awk '{printf "%.2f GB", $2/1024/1024}')
|
|
54
|
+
mem_avail=$(grep MemAvailable /proc/meminfo 2>/dev/null | awk '{printf "%.2f GB", $2/1024/1024}')
|
|
55
|
+
echo " Total: $mem_total"
|
|
56
|
+
echo " Free: $mem_free"
|
|
57
|
+
echo " Available: ${mem_avail:-N/A}"
|
|
58
|
+
elif command -v powershell &> /dev/null; then
|
|
59
|
+
mem_info=$(powershell -NoProfile -Command "
|
|
60
|
+
\$os = Get-CimInstance Win32_OperatingSystem
|
|
61
|
+
\$total = [math]::Round(\$os.TotalVisibleMemorySize / 1MB, 2)
|
|
62
|
+
\$free = [math]::Round(\$os.FreePhysicalMemory / 1MB, 2)
|
|
63
|
+
\$used = [math]::Round(\$total - \$free, 2)
|
|
64
|
+
\$pct = [math]::Round((\$used / \$total) * 100, 1)
|
|
65
|
+
Write-Output \"\$total|\$used|\$free|\$pct\"
|
|
66
|
+
")
|
|
67
|
+
total=$(echo "$mem_info" | cut -d'|' -f1)
|
|
68
|
+
used=$(echo "$mem_info" | cut -d'|' -f2)
|
|
69
|
+
free=$(echo "$mem_info" | cut -d'|' -f3)
|
|
70
|
+
pct=$(echo "$mem_info" | cut -d'|' -f4)
|
|
71
|
+
echo " Total: ${total} GB"
|
|
72
|
+
echo " Used: ${used} GB (${pct}%)"
|
|
73
|
+
echo " Free: ${free} GB"
|
|
74
|
+
else
|
|
75
|
+
echo " Unable to get memory info"
|
|
76
|
+
fi
|
|
77
|
+
echo ""
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
# 磁盘信息
|
|
81
|
+
show_disk() {
|
|
82
|
+
echo "[Disk Info]"
|
|
83
|
+
if command -v powershell &> /dev/null; then
|
|
84
|
+
# Windows PowerShell - 使用 UTF8 编码输出
|
|
85
|
+
powershell -NoProfile -Command "[Console]::OutputEncoding = [System.Text.Encoding]::UTF8; Get-CimInstance Win32_LogicalDisk -Filter \"DriveType=3\" | Format-Table -AutoSize | Out-String"
|
|
86
|
+
elif [ -f /proc/mounts ] && command -v df &> /dev/null; then
|
|
87
|
+
df -h | grep -E '^/dev/' | awk '{
|
|
88
|
+
printf " %s: Total %s, Used %s (%s), Free %s\n", $1, $2, $3, $5, $4
|
|
89
|
+
}'
|
|
90
|
+
else
|
|
91
|
+
echo " Unable to get disk info"
|
|
92
|
+
fi
|
|
93
|
+
echo ""
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
# 网络信息
|
|
97
|
+
show_network() {
|
|
98
|
+
echo "[Network Info]"
|
|
99
|
+
echo " IP Addresses:"
|
|
100
|
+
if command -v ip &> /dev/null; then
|
|
101
|
+
ip addr show | grep inet | grep -v '127.0.0.1' | awk '{printf " %s\n", $2}'
|
|
102
|
+
elif command -v ifconfig &> /dev/null; then
|
|
103
|
+
ifconfig | grep 'inet ' | grep -v '127.0.0.1' | awk '{printf " %s\n", $2}'
|
|
104
|
+
elif command -v powershell &> /dev/null; then
|
|
105
|
+
powershell -NoProfile -Command "Get-NetIPAddress -AddressFamily IPv4 | Where-Object { \$_.IPAddress -ne '127.0.0.1' } | ForEach-Object { Write-Output \" \$(\$_.IPAddress)\" }"
|
|
106
|
+
fi
|
|
107
|
+
echo ""
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
# 执行选项
|
|
111
|
+
case $OPTION in
|
|
112
|
+
all)
|
|
113
|
+
show_system
|
|
114
|
+
show_cpu
|
|
115
|
+
show_memory
|
|
116
|
+
show_disk
|
|
117
|
+
show_network
|
|
118
|
+
;;
|
|
119
|
+
cpu) show_cpu ;;
|
|
120
|
+
memory) show_memory ;;
|
|
121
|
+
disk) show_disk ;;
|
|
122
|
+
network) show_network ;;
|
|
123
|
+
system) show_system ;;
|
|
124
|
+
*)
|
|
125
|
+
echo "Usage: system-info [all|cpu|memory|disk|network|system]"
|
|
126
|
+
exit 1
|
|
127
|
+
;;
|
|
128
|
+
esac
|
|
129
|
+
|
|
130
|
+
echo "=========================================="
|
|
@@ -0,0 +1,324 @@
|
|
|
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
|
+
```
|
|
@@ -0,0 +1,35 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
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
|
+
}
|