foliko 1.0.65 → 1.0.66
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/settings.local.json +145 -142
- package/package.json +1 -1
- package/plugins/ambient-agent-plugin.js +158 -46
- package/plugins/email.js +49 -17
- package/skills/ambient-agent/SKILL.md +234 -0
- package/src/capabilities/workflow-engine.js +363 -181
- package/src/core/agent-chat.js +26 -4
|
@@ -1,142 +1,145 @@
|
|
|
1
|
-
{
|
|
2
|
-
"permissions": {
|
|
3
|
-
"allow": [
|
|
4
|
-
"Bash(grep -r \"dotenv\" \"D:/Code/vb-agent/\" --include=\"*.json\" 2>/dev/null | head -20)",
|
|
5
|
-
"Bash(cd \"D:/Code/vb-agent\" && pnpm add dotenv)",
|
|
6
|
-
"Bash(cd \"D:/Code/vb-agent\" && node -e \"const ai = require\\('ai'\\); console.log\\(Object.keys\\(ai\\).filter\\(k => k.toLowerCase\\(\\).includes\\('reason'\\) || k.toLowerCase\\(\\).includes\\('split'\\) || k.toLowerCase\\(\\).includes\\('think'\\)\\)\\)\")",
|
|
7
|
-
"Bash(cd \"D:/Code/vb-agent\" && node -e \"const ai = require\\('ai'\\); console.log\\(typeof ai.extractReasoningMiddleware, ai.extractReasoningMiddleware.toString\\(\\).substring\\(0, 500\\)\\)\")",
|
|
8
|
-
"Bash(cd \"D:/Code/vb-agent\" && node -e \"\nconst ai = require\\('ai'\\);\nconsole.log\\('=== extractReasoningMiddleware ==='\\);\nconsole.log\\(ai.extractReasoningMiddleware.toString\\(\\)\\);\nconsole.log\\('\\\\n=== isReasoningUIPart ==='\\);\nconsole.log\\(typeof ai.isReasoningUIPart\\);\n\")",
|
|
9
|
-
"Bash(cd \"D:/Code/vb-agent\" && node -e \"const ai = require\\('ai'\\); console.log\\(Object.keys\\(ai\\).filter\\(k => k.toLowerCase\\(\\).includes\\('split'\\)\\)\\)\")",
|
|
10
|
-
"Bash(cd \"D:/Code/vb-agent\" && pnpm add ink react)",
|
|
11
|
-
"Bash(cd \"D:/Code/vb-agent\" && node cli/bin/foliko.js --help)",
|
|
12
|
-
"Bash(cd \"D:/Code/vb-agent\" && timeout 2 node cli/bin/foliko.js chat 2>&1 || true)",
|
|
13
|
-
"Bash(cd \"D:/Code/vb-agent\" && node -e \"const mt = require\\('marked-terminal'\\); console.log\\(typeof mt, Object.keys\\(mt\\)\\)\")",
|
|
14
|
-
"Bash(cd \"D:/Code/vb-agent\" && timeout 3 node cli/bin/foliko.js chat 2>&1 || true)",
|
|
15
|
-
"Bash(echo \"你好\" | node cli/bin/foliko.js chat 2>&1 | head -50)",
|
|
16
|
-
"Bash(printf '思考一下1+1等于几\\\\n' | node cli/bin/foliko.js chat 2>&1 | head -100)",
|
|
17
|
-
"Bash(printf '1+1等于几\\\\n' | node cli/bin/foliko.js chat 2>&1)",
|
|
18
|
-
"Bash(node -e \"\nconst { renderLine } = require\\('./cli/src/utils/markdown'\\)\nconsole.log\\(renderLine\\('🎉 这是一个 emoji'\\)\\)\nconsole.log\\(renderLine\\('**粗体** 和 🎉'\\)\\)\n\")",
|
|
19
|
-
"Bash(node -e \"\nconst { render } = require\\('./cli/src/utils/markdown'\\)\nconst text = '🎉 今天是个好日子\\\\n## 标题\\\\n- 列表项1\\\\n- 列表项2'\nconsole.log\\(render\\(text\\)\\)\n\")",
|
|
20
|
-
"Bash(node -e \"\nconst { renderLine } = require\\('./cli/src/utils/markdown'\\)\n\n// 模拟emoji被截断的情况\nconst emoji = '🎉'\nconsole.log\\('完整的 emoji:', renderLine\\(emoji\\)\\)\n\n// 模拟截断 - emoji的UTF-8字节是 \\\\xF0\\\\x9F\\\\x8E\\\\x89\nconst partial = '\\\\xF0\\\\x9F' // 不完整的emoji\nconsole.log\\('截断的 emoji:', renderLine\\(partial\\)\\)\n\")",
|
|
21
|
-
"Bash(node -e \"\nconst isIncompleteUTF8 = \\(str\\) => {\n if \\(!str || str.length === 0\\) return false\n const lastChar = str.charCodeAt\\(str.length - 1\\)\n if \\(lastChar >= 0x80 && lastChar < 0xC0\\) return true\n return false\n}\n\n// 测试各种emoji\nconst tests = ['🎉', '📁', '⚡', '🛠️', '🔑', '💾', '📝', '⏰', '🔌', '📋']\ntests.forEach\\(e => {\n console.log\\(e, '完整:', !isIncompleteUTF8\\(e\\)\\)\n}\\)\n\n// 测试被截断的emoji \\(只保留第一字节\\)\nconst broken = '🎉'.slice\\(0, 1\\)\nconsole.log\\('截断emoji:', broken, '检测:', isIncompleteUTF8\\(broken\\)\\)\n\")",
|
|
22
|
-
"Bash(node -e \"\nconst { renderLine } = require\\('./cli/src/utils/markdown'\\)\nconsole.log\\('测试:', renderLine\\('📁 文件操作:读取、创建'\\)\\)\n\")",
|
|
23
|
-
"Bash(node -e \"\nconst hasIncompleteSurrogate = \\(str\\) => {\n if \\(!str || str.length === 0\\) return false\n const lastChar = str.charCodeAt\\(str.length - 1\\)\n console.log\\('检查:', str, 'lastChar:', lastChar.toString\\(16\\), '范围:', \\(lastChar >= 0xD800 && lastChar <= 0xDBFF\\)\\)\n return lastChar >= 0xD800 && lastChar <= 0xDBFF\n}\n\nconst chunk1 = '\\\\xD83C'\nconsole.log\\('结果:', hasIncompleteSurrogate\\(chunk1\\)\\)\n\")",
|
|
24
|
-
"Bash(cd D:/Code/vb-agent && node test-stream-emoji.js 2>&1)",
|
|
25
|
-
"Read(//d/Date/20260321/app/**)",
|
|
26
|
-
"Bash(node -e \":*)",
|
|
27
|
-
"Bash(node -e \"\nconst { loadAgentConfig } = require\\('./plugins/default-plugins'\\);\nconst config = loadAgentConfig\\('D:/Date/20260321/app/.agent'\\);\nconsole.log\\('skillsDirs:', config.skillsDirs\\);\n\")",
|
|
28
|
-
"Bash(cd D:/Code/vb-agent && pnpm install --shamefully-hoist 2>&1 | head -20)",
|
|
29
|
-
"Bash(cd D:/Code/vb-agent && rm -rf node_modules && pnpm install)",
|
|
30
|
-
"Bash(cd D:/Code/vb-agent && timeout 8 node test-tg.js 2>&1 || true)",
|
|
31
|
-
"Bash(cd D:/Code/vb-agent && timeout 10 node test-tg.js 2>&1 || true)",
|
|
32
|
-
"Bash(find /d/Code/vb-agent -name \"*email*\" -type f 2>/dev/null | grep -v node_modules | grep -v .git)",
|
|
33
|
-
"Bash(find /d/Code/vb-agent -maxdepth 2 -name \"*.md\" -type f 2>/dev/null | grep -v node_modules)",
|
|
34
|
-
"Bash(node -c plugins/default-plugins.js && node -c src/core/plugin-manager.js && echo \"Syntax OK\")",
|
|
35
|
-
"Bash(node -c plugins/install-plugin.js && echo \"Syntax OK\")",
|
|
36
|
-
"Bash(node -c cli/src/ui/chat-ui.js && echo \"Syntax OK\")",
|
|
37
|
-
"Bash(node -c plugins/default-plugins.js && echo \"Syntax OK\")",
|
|
38
|
-
"Bash(node -c plugins/scheduler-plugin.js && echo \"Syntax OK\")",
|
|
39
|
-
"Bash(node -c plugins/telegram-plugin.js && node -c plugins/scheduler-plugin.js && echo \"Syntax OK\")",
|
|
40
|
-
"Bash(node -c plugins/telegram-plugin.js && echo \"Syntax OK\")",
|
|
41
|
-
"WebSearch",
|
|
42
|
-
"Bash(npm ls:*)",
|
|
43
|
-
"Bash(cd node_modules/@chnak/weixin-bot && npm run build 2>&1)",
|
|
44
|
-
"Bash(cd node_modules/@chnak/weixin-bot && npx tsc 2>&1)",
|
|
45
|
-
"Bash(npm install:*)",
|
|
46
|
-
"Bash(cd node_modules/@chnak/weixin-bot && npx typescript --version && npx tsc 2>&1)",
|
|
47
|
-
"Bash(npx tsc:*)",
|
|
48
|
-
"Bash(node --check /d/Code/vb-agent/plugins/weixin-plugin.js 2>&1)",
|
|
49
|
-
"Bash(node --check /d/Code/vb-agent/plugins/telegram-plugin.js && node --check /d/Code/vb-agent/plugins/weixin-plugin.js && echo \"OK\")",
|
|
50
|
-
"Bash(node --check /d/Code/vb-agent/cli/src/ui/chat-ui.js && echo \"OK\")",
|
|
51
|
-
"Bash(npm uninstall:*)",
|
|
52
|
-
"Bash(rm -rf /tmp/weixin-bot && git clone https://github.com/chnak/weixin-bot.git /tmp/weixin-bot 2>&1)",
|
|
53
|
-
"Bash(mkdir -p node_modules/@chnak/weixin-bot && cp -r /tmp/weixin-bot/nodejs/* node_modules/@chnak/weixin-bot/ && cd node_modules/@chnak/weixin-bot && npm install 2>&1)",
|
|
54
|
-
"Bash(node --check /d/Code/vb-agent/plugins/weixin-plugin.js && echo \"OK\")",
|
|
55
|
-
"Bash(node -e \"import\\('@chnak/weixin-bot'\\).then\\(m => console.log\\('OK:', Object.keys\\(m\\)\\)\\).catch\\(e => console.error\\('Error:', e.message\\)\\)\")",
|
|
56
|
-
"Bash(npm run:*)",
|
|
57
|
-
"Bash(node -e \"const { WeixinBot } = require\\('@chnak/weixin-bot'\\); console.log\\(typeof WeixinBot\\)\" 2>&1)",
|
|
58
|
-
"Bash(node -e \"import\\('@chnak/weixin-bot'\\).then\\(m => console.log\\('OK:', typeof m.WeixinBot\\)\\).catch\\(e => console.error\\('Error:', e.message\\)\\)\" 2>&1)",
|
|
59
|
-
"Bash(ls -la D:/code/vb-agent/cli/bin/ && cat D:/code/vb-agent/cli/bin/*.js 2>/dev/null | head -50)",
|
|
60
|
-
"Bash(npm config:*)",
|
|
61
|
-
"Bash(node -c plugins/subagent-plugin.js 2>&1)",
|
|
62
|
-
"Bash(node -c plugins/default-plugins.js 2>&1)",
|
|
63
|
-
"Bash(node -c plugins/default-plugins.js && node -c src/core/plugin-manager.js && node -c plugins/tools-plugin.js 2>&1)",
|
|
64
|
-
"Bash(node -c src/core/plugin-base.js && node -c src/core/plugin-manager.js 2>&1)",
|
|
65
|
-
"Bash(node -c plugins/telegram-plugin.js && node -c plugins/weixin-plugin.js 2>&1)",
|
|
66
|
-
"Bash(node -c src/core/plugin-manager.js 2>&1)",
|
|
67
|
-
"Bash(node -c src/core/plugin-manager.js && node -c src/core/plugin-base.js && node -c plugins/default-plugins.js && node -c plugins/telegram-plugin.js && node -c plugins/weixin-plugin.js 2>&1)",
|
|
68
|
-
"Bash(node -e \"require\\('dotenv'\\).config\\(\\); console.log\\('PROVIDER:', process.env.FOLIKO_PROVIDER\\); console.log\\('MODEL:', process.env.FOLIKO_MODEL\\); console.log\\('KEY:', process.env.DEEPSEEK_API_KEY ? 'set' : 'not set'\\)\" 2>&1)",
|
|
69
|
-
"Bash(node cli/src/index.js chat 2>&1 | head -30)",
|
|
70
|
-
"Bash(node -e 'const { DEFAULT_PROVIDERS } = require\\(\"./src/core/provider\"\\); console.log\\(DEFAULT_PROVIDERS\\);')",
|
|
71
|
-
"Bash(node -e \"const dotenv = require\\('dotenv'\\); const result = dotenv.config\\(\\); console.log\\('Result:', result\\); console.log\\('PROVIDER after dotenv:', process.env.FOLIKO_PROVIDER\\);\" 2>&1)",
|
|
72
|
-
"Bash(node -c plugins/email.js && node -c plugins/default-plugins.js 2>&1)",
|
|
73
|
-
"Bash(node -c plugins/email.js 2>&1)",
|
|
74
|
-
"Bash(npm list:*)",
|
|
75
|
-
"Bash(node -e \"const {EmailPlugin} = require\\('./plugins/email'\\); const p = new EmailPlugin\\(\\); console.log\\('email plugin loaded ok'\\); console.log\\('enabled:', p.enabled\\); console.log\\('version:', p.version\\);\" 2>&1)",
|
|
76
|
-
"Bash(cd D:/Code/vb-agent && node -e \"console.log\\('IMAP_HOST:', process.env.IMAP_HOST\\); console.log\\('IMAP_USER:', process.env.IMAP_USER\\); console.log\\('IMAP_PORT:', process.env.IMAP_PORT\\);\")",
|
|
77
|
-
"Bash(node -e \"const sdk = require\\('@larksuiteoapi/node-sdk'\\); console.log\\(Object.keys\\(sdk\\)\\);\")",
|
|
78
|
-
"Bash(node -e \"const { WSClient } = require\\('@larksuiteoapi/node-sdk'\\); const sdk = new WSClient\\({}\\); console.log\\(Object.getOwnPropertyNames\\(Object.getPrototypeOf\\(sdk\\)\\)\\);\")",
|
|
79
|
-
"Bash(node -c src/core/framework.js 2>&1)",
|
|
80
|
-
"Bash(node -c plugins/telegram-plugin.js 2>&1)",
|
|
81
|
-
"Bash(node -c src/capabilities/skill-manager.js 2>&1)",
|
|
82
|
-
"Bash(node -c plugins/feishu-plugin.js 2>&1)",
|
|
83
|
-
"Bash(node debug-skills.js)",
|
|
84
|
-
"Bash(node -c src/capabilities/workflow-engine.js 2>&1)",
|
|
85
|
-
"Bash(node -c skills/workflow-guide/SKILL.md 2>&1 || head -10 skills/workflow-guide/SKILL.md)",
|
|
86
|
-
"Bash(ls plugins/*.js 2>&1)",
|
|
87
|
-
"Bash(node -c plugins/web-plugin.js 2>&1)",
|
|
88
|
-
"Bash(cd D:/code/vb-agent && node -e \"require\\('./plugins/web-plugin.js'\\)\" 2>&1)",
|
|
89
|
-
"Bash(cd D:/code/vb-agent && node -e \"\nconst { WebPlugin } = require\\('./plugins/web-plugin.js'\\);\nconst p = new WebPlugin\\(\\);\nconsole.log\\('Plugin created:', p.name, p.version\\);\n\" 2>&1)",
|
|
90
|
-
"Bash(cd D:/code/vb-agent && mkdir -p test-static && echo '<html><body>Hello Static</body></html>' > test-static/index.html)",
|
|
91
|
-
"mcp__plugin_context7_context7__resolve-library-id",
|
|
92
|
-
"mcp__plugin_context7_context7__query-docs",
|
|
93
|
-
"Bash(cd D:/code/vb-agent && rm test-hono.js)",
|
|
94
|
-
"Bash(curl -s http://localhost:3000/test 2>&1 || echo \"连接失败\")",
|
|
95
|
-
"Bash(cd D:/code/vb-agent && timeout 15 node examples/test-web-plugin.js 2>&1)",
|
|
96
|
-
"Bash(cd D:/code/vb-agent && timeout 60 node examples/test-chat.js 2>&1 | head -100)",
|
|
97
|
-
"Bash(cd D:/code/vb-agent && timeout 120 node examples/test-chat.js 2>&1 | tail -80)",
|
|
98
|
-
"Bash(cd D:/code/vb-agent && timeout 120 node examples/bootstrap.js 2>&1 | tail -100)",
|
|
99
|
-
"Bash(cd D:/code/vb-agent && timeout 10 node examples/test-web-plugin.js 2>&1)",
|
|
100
|
-
"Bash(curl -s -X POST http://localhost:3000/test-webhook \\\\\n -H \"Content-Type: application/json\" \\\\\n -d '{\"message\":\"test from curl\",\"sessionId\":\"web_test\"}')",
|
|
101
|
-
"Bash(curl -s http://localhost:3000/test 2>&1 || echo \"Connection failed\")",
|
|
102
|
-
"Bash(curl -s -X POST http://localhost:3000/webhook/test-webhook \\\\\n -H \"Content-Type: application/json\" \\\\\n -d '{\"message\":\"test from curl\",\"sessionId\":\"web_test\"}')",
|
|
103
|
-
"Bash(curl -s http://localhost:3000/webui/status)",
|
|
104
|
-
"Bash(curl -s http://localhost:3000/test)",
|
|
105
|
-
"Bash(curl -s -v -X POST http://localhost:3000/test-webhook \\\\\n -H \"Content-Type: application/json\" \\\\\n -d '{\"message\":\"test\"}' 2>&1 | head -30)",
|
|
106
|
-
"Bash(curl -s -X POST \"http://localhost:3000/webhook/test-webhook\" \\\\\n -H \"Content-Type: application/json\" \\\\\n -d '{\"message\":\"test\"}' 2>&1)",
|
|
107
|
-
"Bash(curl -s http://localhost:3000/webui/ 2>&1)",
|
|
108
|
-
"Bash(curl -s -X POST http://localhost:3000/webui/list-routes \\\\\n -H \"Content-Type: application/json\" \\\\\n -d '{}' 2>&1 || echo \"Endpoint not found\")",
|
|
109
|
-
"Bash(curl -s http://localhost:3000/ 2>&1)",
|
|
110
|
-
"Bash(curl -s -X POST \"http://localhost:3000/webhook/test-webhook\" \\\\\n -H \"Content-Type: application/json\" \\\\\n -d '{\"message\":\"test with prefix\"}')",
|
|
111
|
-
"Bash(netstat -ano | grep :3000 | head -5)",
|
|
112
|
-
"Bash(netstat -ano | grep :3000 | grep LISTENING)",
|
|
113
|
-
"Bash(curl -s -X POST http://localhost:3000/test-webhook \\\\\n -H \"Content-Type: application/json\" \\\\\n -d '{\"message\":\"test\",\"sessionId\":\"web_test\"}')",
|
|
114
|
-
"Bash(taskkill /F /IM node.exe 2>/dev/null; sleep 1; echo \"Node processes killed\")",
|
|
115
|
-
"Bash(netstat -ano | grep :3000)",
|
|
116
|
-
"Bash(taskkill //F //PID 19848)",
|
|
117
|
-
"Bash(curl -s -X POST \"http://localhost:3000/webhook/075s5s2umn4smn4f\" \\\\\n -H \"Content-Type: application/json\" \\\\\n -d '{\"test\":\"data\"}' 2>&1)",
|
|
118
|
-
"Bash(curl -s http://localhost:3000/api/hello 2>&1)",
|
|
119
|
-
"Bash(curl -v -X POST \"http://localhost:3000/webhook/075s5s2umn4smn4f\" \\\\\n -H \"Content-Type: application/json\" \\\\\n -d '{\"test\":\"data\"}' 2>&1 | head -30)",
|
|
120
|
-
"Bash(cd D:/code/vb-agent && timeout 30 node test-compression.js 2>&1)",
|
|
121
|
-
"Bash(cd D:/code/vb-agent && node -c src/core/agent-chat.js 2>&1)",
|
|
122
|
-
"Bash(cd D:/code/vb-agent && node -e \"require\\('./src/core/agent-chat.js'\\); console.log\\('模块加载成功'\\)\" 2>&1)",
|
|
123
|
-
"Bash(cd D:/code/vb-agent && node -e \"require\\('./src/core/agent.js'\\); console.log\\('Agent 加载成功'\\)\" 2>&1)",
|
|
124
|
-
"Bash(node -c src/capabilities/skill-manager.js && node -c src/executors/mcp-executor.js && node -c src/capabilities/workflow-engine.js && node -c src/core/plugin-manager.js 2>&1)",
|
|
125
|
-
"Bash(node -c src/core/plugin-manager.js && node -c plugins/tools-plugin.js 2>&1)",
|
|
126
|
-
"Bash(node -c plugins/default-plugins.js && node -c cli/src/commands/chat.js 2>&1)",
|
|
127
|
-
"Bash(node -c plugins/telegram-plugin.js && node -c plugins/feishu-plugin.js && node -c plugins/weixin-plugin.js 2>&1)",
|
|
128
|
-
"Bash(node -c src/core/agent.js 2>&1)",
|
|
129
|
-
"Bash(cd D:/code/vb-agent && node examples/bootstrap.js 2>&1 | head -50)",
|
|
130
|
-
"Bash(node -c plugins/proactive-agent-plugin.js 2>&1)",
|
|
131
|
-
"Bash(node -c src/index.js && node -c examples/proactive-example.js && node -c examples/proactive-advanced.js && echo \"All syntax OK\")",
|
|
132
|
-
"Bash(node -c plugins/proactive-agent-plugin.js && node -c plugins/default-plugins.js && echo \"All OK\")",
|
|
133
|
-
"Bash(node examples/basic.js 2>&1 | head -50)",
|
|
134
|
-
"Bash(node examples/ambient-example.js 2>&1 | head -80)",
|
|
135
|
-
"Bash(ls -la .agent/data/ambient/ 2>/dev/null && cat .agent/data/ambient/*.json 2>/dev/null | head -50)",
|
|
136
|
-
"Bash(node examples/basic.js 2>&1 | head -30)",
|
|
137
|
-
"Bash(node examples/bootstrap.js 2>&1 | head -40)",
|
|
138
|
-
"Bash(node test-debug.js 2>&1)",
|
|
139
|
-
"Bash(ls -la D:/Code/vb-agent/*.md 2>/dev/null || dir D:\\\\Code\\\\vb-agent\\\\*.md /b 2>nul)"
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
1
|
+
{
|
|
2
|
+
"permissions": {
|
|
3
|
+
"allow": [
|
|
4
|
+
"Bash(grep -r \"dotenv\" \"D:/Code/vb-agent/\" --include=\"*.json\" 2>/dev/null | head -20)",
|
|
5
|
+
"Bash(cd \"D:/Code/vb-agent\" && pnpm add dotenv)",
|
|
6
|
+
"Bash(cd \"D:/Code/vb-agent\" && node -e \"const ai = require\\('ai'\\); console.log\\(Object.keys\\(ai\\).filter\\(k => k.toLowerCase\\(\\).includes\\('reason'\\) || k.toLowerCase\\(\\).includes\\('split'\\) || k.toLowerCase\\(\\).includes\\('think'\\)\\)\\)\")",
|
|
7
|
+
"Bash(cd \"D:/Code/vb-agent\" && node -e \"const ai = require\\('ai'\\); console.log\\(typeof ai.extractReasoningMiddleware, ai.extractReasoningMiddleware.toString\\(\\).substring\\(0, 500\\)\\)\")",
|
|
8
|
+
"Bash(cd \"D:/Code/vb-agent\" && node -e \"\nconst ai = require\\('ai'\\);\nconsole.log\\('=== extractReasoningMiddleware ==='\\);\nconsole.log\\(ai.extractReasoningMiddleware.toString\\(\\)\\);\nconsole.log\\('\\\\n=== isReasoningUIPart ==='\\);\nconsole.log\\(typeof ai.isReasoningUIPart\\);\n\")",
|
|
9
|
+
"Bash(cd \"D:/Code/vb-agent\" && node -e \"const ai = require\\('ai'\\); console.log\\(Object.keys\\(ai\\).filter\\(k => k.toLowerCase\\(\\).includes\\('split'\\)\\)\\)\")",
|
|
10
|
+
"Bash(cd \"D:/Code/vb-agent\" && pnpm add ink react)",
|
|
11
|
+
"Bash(cd \"D:/Code/vb-agent\" && node cli/bin/foliko.js --help)",
|
|
12
|
+
"Bash(cd \"D:/Code/vb-agent\" && timeout 2 node cli/bin/foliko.js chat 2>&1 || true)",
|
|
13
|
+
"Bash(cd \"D:/Code/vb-agent\" && node -e \"const mt = require\\('marked-terminal'\\); console.log\\(typeof mt, Object.keys\\(mt\\)\\)\")",
|
|
14
|
+
"Bash(cd \"D:/Code/vb-agent\" && timeout 3 node cli/bin/foliko.js chat 2>&1 || true)",
|
|
15
|
+
"Bash(echo \"你好\" | node cli/bin/foliko.js chat 2>&1 | head -50)",
|
|
16
|
+
"Bash(printf '思考一下1+1等于几\\\\n' | node cli/bin/foliko.js chat 2>&1 | head -100)",
|
|
17
|
+
"Bash(printf '1+1等于几\\\\n' | node cli/bin/foliko.js chat 2>&1)",
|
|
18
|
+
"Bash(node -e \"\nconst { renderLine } = require\\('./cli/src/utils/markdown'\\)\nconsole.log\\(renderLine\\('🎉 这是一个 emoji'\\)\\)\nconsole.log\\(renderLine\\('**粗体** 和 🎉'\\)\\)\n\")",
|
|
19
|
+
"Bash(node -e \"\nconst { render } = require\\('./cli/src/utils/markdown'\\)\nconst text = '🎉 今天是个好日子\\\\n## 标题\\\\n- 列表项1\\\\n- 列表项2'\nconsole.log\\(render\\(text\\)\\)\n\")",
|
|
20
|
+
"Bash(node -e \"\nconst { renderLine } = require\\('./cli/src/utils/markdown'\\)\n\n// 模拟emoji被截断的情况\nconst emoji = '🎉'\nconsole.log\\('完整的 emoji:', renderLine\\(emoji\\)\\)\n\n// 模拟截断 - emoji的UTF-8字节是 \\\\xF0\\\\x9F\\\\x8E\\\\x89\nconst partial = '\\\\xF0\\\\x9F' // 不完整的emoji\nconsole.log\\('截断的 emoji:', renderLine\\(partial\\)\\)\n\")",
|
|
21
|
+
"Bash(node -e \"\nconst isIncompleteUTF8 = \\(str\\) => {\n if \\(!str || str.length === 0\\) return false\n const lastChar = str.charCodeAt\\(str.length - 1\\)\n if \\(lastChar >= 0x80 && lastChar < 0xC0\\) return true\n return false\n}\n\n// 测试各种emoji\nconst tests = ['🎉', '📁', '⚡', '🛠️', '🔑', '💾', '📝', '⏰', '🔌', '📋']\ntests.forEach\\(e => {\n console.log\\(e, '完整:', !isIncompleteUTF8\\(e\\)\\)\n}\\)\n\n// 测试被截断的emoji \\(只保留第一字节\\)\nconst broken = '🎉'.slice\\(0, 1\\)\nconsole.log\\('截断emoji:', broken, '检测:', isIncompleteUTF8\\(broken\\)\\)\n\")",
|
|
22
|
+
"Bash(node -e \"\nconst { renderLine } = require\\('./cli/src/utils/markdown'\\)\nconsole.log\\('测试:', renderLine\\('📁 文件操作:读取、创建'\\)\\)\n\")",
|
|
23
|
+
"Bash(node -e \"\nconst hasIncompleteSurrogate = \\(str\\) => {\n if \\(!str || str.length === 0\\) return false\n const lastChar = str.charCodeAt\\(str.length - 1\\)\n console.log\\('检查:', str, 'lastChar:', lastChar.toString\\(16\\), '范围:', \\(lastChar >= 0xD800 && lastChar <= 0xDBFF\\)\\)\n return lastChar >= 0xD800 && lastChar <= 0xDBFF\n}\n\nconst chunk1 = '\\\\xD83C'\nconsole.log\\('结果:', hasIncompleteSurrogate\\(chunk1\\)\\)\n\")",
|
|
24
|
+
"Bash(cd D:/Code/vb-agent && node test-stream-emoji.js 2>&1)",
|
|
25
|
+
"Read(//d/Date/20260321/app/**)",
|
|
26
|
+
"Bash(node -e \":*)",
|
|
27
|
+
"Bash(node -e \"\nconst { loadAgentConfig } = require\\('./plugins/default-plugins'\\);\nconst config = loadAgentConfig\\('D:/Date/20260321/app/.agent'\\);\nconsole.log\\('skillsDirs:', config.skillsDirs\\);\n\")",
|
|
28
|
+
"Bash(cd D:/Code/vb-agent && pnpm install --shamefully-hoist 2>&1 | head -20)",
|
|
29
|
+
"Bash(cd D:/Code/vb-agent && rm -rf node_modules && pnpm install)",
|
|
30
|
+
"Bash(cd D:/Code/vb-agent && timeout 8 node test-tg.js 2>&1 || true)",
|
|
31
|
+
"Bash(cd D:/Code/vb-agent && timeout 10 node test-tg.js 2>&1 || true)",
|
|
32
|
+
"Bash(find /d/Code/vb-agent -name \"*email*\" -type f 2>/dev/null | grep -v node_modules | grep -v .git)",
|
|
33
|
+
"Bash(find /d/Code/vb-agent -maxdepth 2 -name \"*.md\" -type f 2>/dev/null | grep -v node_modules)",
|
|
34
|
+
"Bash(node -c plugins/default-plugins.js && node -c src/core/plugin-manager.js && echo \"Syntax OK\")",
|
|
35
|
+
"Bash(node -c plugins/install-plugin.js && echo \"Syntax OK\")",
|
|
36
|
+
"Bash(node -c cli/src/ui/chat-ui.js && echo \"Syntax OK\")",
|
|
37
|
+
"Bash(node -c plugins/default-plugins.js && echo \"Syntax OK\")",
|
|
38
|
+
"Bash(node -c plugins/scheduler-plugin.js && echo \"Syntax OK\")",
|
|
39
|
+
"Bash(node -c plugins/telegram-plugin.js && node -c plugins/scheduler-plugin.js && echo \"Syntax OK\")",
|
|
40
|
+
"Bash(node -c plugins/telegram-plugin.js && echo \"Syntax OK\")",
|
|
41
|
+
"WebSearch",
|
|
42
|
+
"Bash(npm ls:*)",
|
|
43
|
+
"Bash(cd node_modules/@chnak/weixin-bot && npm run build 2>&1)",
|
|
44
|
+
"Bash(cd node_modules/@chnak/weixin-bot && npx tsc 2>&1)",
|
|
45
|
+
"Bash(npm install:*)",
|
|
46
|
+
"Bash(cd node_modules/@chnak/weixin-bot && npx typescript --version && npx tsc 2>&1)",
|
|
47
|
+
"Bash(npx tsc:*)",
|
|
48
|
+
"Bash(node --check /d/Code/vb-agent/plugins/weixin-plugin.js 2>&1)",
|
|
49
|
+
"Bash(node --check /d/Code/vb-agent/plugins/telegram-plugin.js && node --check /d/Code/vb-agent/plugins/weixin-plugin.js && echo \"OK\")",
|
|
50
|
+
"Bash(node --check /d/Code/vb-agent/cli/src/ui/chat-ui.js && echo \"OK\")",
|
|
51
|
+
"Bash(npm uninstall:*)",
|
|
52
|
+
"Bash(rm -rf /tmp/weixin-bot && git clone https://github.com/chnak/weixin-bot.git /tmp/weixin-bot 2>&1)",
|
|
53
|
+
"Bash(mkdir -p node_modules/@chnak/weixin-bot && cp -r /tmp/weixin-bot/nodejs/* node_modules/@chnak/weixin-bot/ && cd node_modules/@chnak/weixin-bot && npm install 2>&1)",
|
|
54
|
+
"Bash(node --check /d/Code/vb-agent/plugins/weixin-plugin.js && echo \"OK\")",
|
|
55
|
+
"Bash(node -e \"import\\('@chnak/weixin-bot'\\).then\\(m => console.log\\('OK:', Object.keys\\(m\\)\\)\\).catch\\(e => console.error\\('Error:', e.message\\)\\)\")",
|
|
56
|
+
"Bash(npm run:*)",
|
|
57
|
+
"Bash(node -e \"const { WeixinBot } = require\\('@chnak/weixin-bot'\\); console.log\\(typeof WeixinBot\\)\" 2>&1)",
|
|
58
|
+
"Bash(node -e \"import\\('@chnak/weixin-bot'\\).then\\(m => console.log\\('OK:', typeof m.WeixinBot\\)\\).catch\\(e => console.error\\('Error:', e.message\\)\\)\" 2>&1)",
|
|
59
|
+
"Bash(ls -la D:/code/vb-agent/cli/bin/ && cat D:/code/vb-agent/cli/bin/*.js 2>/dev/null | head -50)",
|
|
60
|
+
"Bash(npm config:*)",
|
|
61
|
+
"Bash(node -c plugins/subagent-plugin.js 2>&1)",
|
|
62
|
+
"Bash(node -c plugins/default-plugins.js 2>&1)",
|
|
63
|
+
"Bash(node -c plugins/default-plugins.js && node -c src/core/plugin-manager.js && node -c plugins/tools-plugin.js 2>&1)",
|
|
64
|
+
"Bash(node -c src/core/plugin-base.js && node -c src/core/plugin-manager.js 2>&1)",
|
|
65
|
+
"Bash(node -c plugins/telegram-plugin.js && node -c plugins/weixin-plugin.js 2>&1)",
|
|
66
|
+
"Bash(node -c src/core/plugin-manager.js 2>&1)",
|
|
67
|
+
"Bash(node -c src/core/plugin-manager.js && node -c src/core/plugin-base.js && node -c plugins/default-plugins.js && node -c plugins/telegram-plugin.js && node -c plugins/weixin-plugin.js 2>&1)",
|
|
68
|
+
"Bash(node -e \"require\\('dotenv'\\).config\\(\\); console.log\\('PROVIDER:', process.env.FOLIKO_PROVIDER\\); console.log\\('MODEL:', process.env.FOLIKO_MODEL\\); console.log\\('KEY:', process.env.DEEPSEEK_API_KEY ? 'set' : 'not set'\\)\" 2>&1)",
|
|
69
|
+
"Bash(node cli/src/index.js chat 2>&1 | head -30)",
|
|
70
|
+
"Bash(node -e 'const { DEFAULT_PROVIDERS } = require\\(\"./src/core/provider\"\\); console.log\\(DEFAULT_PROVIDERS\\);')",
|
|
71
|
+
"Bash(node -e \"const dotenv = require\\('dotenv'\\); const result = dotenv.config\\(\\); console.log\\('Result:', result\\); console.log\\('PROVIDER after dotenv:', process.env.FOLIKO_PROVIDER\\);\" 2>&1)",
|
|
72
|
+
"Bash(node -c plugins/email.js && node -c plugins/default-plugins.js 2>&1)",
|
|
73
|
+
"Bash(node -c plugins/email.js 2>&1)",
|
|
74
|
+
"Bash(npm list:*)",
|
|
75
|
+
"Bash(node -e \"const {EmailPlugin} = require\\('./plugins/email'\\); const p = new EmailPlugin\\(\\); console.log\\('email plugin loaded ok'\\); console.log\\('enabled:', p.enabled\\); console.log\\('version:', p.version\\);\" 2>&1)",
|
|
76
|
+
"Bash(cd D:/Code/vb-agent && node -e \"console.log\\('IMAP_HOST:', process.env.IMAP_HOST\\); console.log\\('IMAP_USER:', process.env.IMAP_USER\\); console.log\\('IMAP_PORT:', process.env.IMAP_PORT\\);\")",
|
|
77
|
+
"Bash(node -e \"const sdk = require\\('@larksuiteoapi/node-sdk'\\); console.log\\(Object.keys\\(sdk\\)\\);\")",
|
|
78
|
+
"Bash(node -e \"const { WSClient } = require\\('@larksuiteoapi/node-sdk'\\); const sdk = new WSClient\\({}\\); console.log\\(Object.getOwnPropertyNames\\(Object.getPrototypeOf\\(sdk\\)\\)\\);\")",
|
|
79
|
+
"Bash(node -c src/core/framework.js 2>&1)",
|
|
80
|
+
"Bash(node -c plugins/telegram-plugin.js 2>&1)",
|
|
81
|
+
"Bash(node -c src/capabilities/skill-manager.js 2>&1)",
|
|
82
|
+
"Bash(node -c plugins/feishu-plugin.js 2>&1)",
|
|
83
|
+
"Bash(node debug-skills.js)",
|
|
84
|
+
"Bash(node -c src/capabilities/workflow-engine.js 2>&1)",
|
|
85
|
+
"Bash(node -c skills/workflow-guide/SKILL.md 2>&1 || head -10 skills/workflow-guide/SKILL.md)",
|
|
86
|
+
"Bash(ls plugins/*.js 2>&1)",
|
|
87
|
+
"Bash(node -c plugins/web-plugin.js 2>&1)",
|
|
88
|
+
"Bash(cd D:/code/vb-agent && node -e \"require\\('./plugins/web-plugin.js'\\)\" 2>&1)",
|
|
89
|
+
"Bash(cd D:/code/vb-agent && node -e \"\nconst { WebPlugin } = require\\('./plugins/web-plugin.js'\\);\nconst p = new WebPlugin\\(\\);\nconsole.log\\('Plugin created:', p.name, p.version\\);\n\" 2>&1)",
|
|
90
|
+
"Bash(cd D:/code/vb-agent && mkdir -p test-static && echo '<html><body>Hello Static</body></html>' > test-static/index.html)",
|
|
91
|
+
"mcp__plugin_context7_context7__resolve-library-id",
|
|
92
|
+
"mcp__plugin_context7_context7__query-docs",
|
|
93
|
+
"Bash(cd D:/code/vb-agent && rm test-hono.js)",
|
|
94
|
+
"Bash(curl -s http://localhost:3000/test 2>&1 || echo \"连接失败\")",
|
|
95
|
+
"Bash(cd D:/code/vb-agent && timeout 15 node examples/test-web-plugin.js 2>&1)",
|
|
96
|
+
"Bash(cd D:/code/vb-agent && timeout 60 node examples/test-chat.js 2>&1 | head -100)",
|
|
97
|
+
"Bash(cd D:/code/vb-agent && timeout 120 node examples/test-chat.js 2>&1 | tail -80)",
|
|
98
|
+
"Bash(cd D:/code/vb-agent && timeout 120 node examples/bootstrap.js 2>&1 | tail -100)",
|
|
99
|
+
"Bash(cd D:/code/vb-agent && timeout 10 node examples/test-web-plugin.js 2>&1)",
|
|
100
|
+
"Bash(curl -s -X POST http://localhost:3000/test-webhook \\\\\n -H \"Content-Type: application/json\" \\\\\n -d '{\"message\":\"test from curl\",\"sessionId\":\"web_test\"}')",
|
|
101
|
+
"Bash(curl -s http://localhost:3000/test 2>&1 || echo \"Connection failed\")",
|
|
102
|
+
"Bash(curl -s -X POST http://localhost:3000/webhook/test-webhook \\\\\n -H \"Content-Type: application/json\" \\\\\n -d '{\"message\":\"test from curl\",\"sessionId\":\"web_test\"}')",
|
|
103
|
+
"Bash(curl -s http://localhost:3000/webui/status)",
|
|
104
|
+
"Bash(curl -s http://localhost:3000/test)",
|
|
105
|
+
"Bash(curl -s -v -X POST http://localhost:3000/test-webhook \\\\\n -H \"Content-Type: application/json\" \\\\\n -d '{\"message\":\"test\"}' 2>&1 | head -30)",
|
|
106
|
+
"Bash(curl -s -X POST \"http://localhost:3000/webhook/test-webhook\" \\\\\n -H \"Content-Type: application/json\" \\\\\n -d '{\"message\":\"test\"}' 2>&1)",
|
|
107
|
+
"Bash(curl -s http://localhost:3000/webui/ 2>&1)",
|
|
108
|
+
"Bash(curl -s -X POST http://localhost:3000/webui/list-routes \\\\\n -H \"Content-Type: application/json\" \\\\\n -d '{}' 2>&1 || echo \"Endpoint not found\")",
|
|
109
|
+
"Bash(curl -s http://localhost:3000/ 2>&1)",
|
|
110
|
+
"Bash(curl -s -X POST \"http://localhost:3000/webhook/test-webhook\" \\\\\n -H \"Content-Type: application/json\" \\\\\n -d '{\"message\":\"test with prefix\"}')",
|
|
111
|
+
"Bash(netstat -ano | grep :3000 | head -5)",
|
|
112
|
+
"Bash(netstat -ano | grep :3000 | grep LISTENING)",
|
|
113
|
+
"Bash(curl -s -X POST http://localhost:3000/test-webhook \\\\\n -H \"Content-Type: application/json\" \\\\\n -d '{\"message\":\"test\",\"sessionId\":\"web_test\"}')",
|
|
114
|
+
"Bash(taskkill /F /IM node.exe 2>/dev/null; sleep 1; echo \"Node processes killed\")",
|
|
115
|
+
"Bash(netstat -ano | grep :3000)",
|
|
116
|
+
"Bash(taskkill //F //PID 19848)",
|
|
117
|
+
"Bash(curl -s -X POST \"http://localhost:3000/webhook/075s5s2umn4smn4f\" \\\\\n -H \"Content-Type: application/json\" \\\\\n -d '{\"test\":\"data\"}' 2>&1)",
|
|
118
|
+
"Bash(curl -s http://localhost:3000/api/hello 2>&1)",
|
|
119
|
+
"Bash(curl -v -X POST \"http://localhost:3000/webhook/075s5s2umn4smn4f\" \\\\\n -H \"Content-Type: application/json\" \\\\\n -d '{\"test\":\"data\"}' 2>&1 | head -30)",
|
|
120
|
+
"Bash(cd D:/code/vb-agent && timeout 30 node test-compression.js 2>&1)",
|
|
121
|
+
"Bash(cd D:/code/vb-agent && node -c src/core/agent-chat.js 2>&1)",
|
|
122
|
+
"Bash(cd D:/code/vb-agent && node -e \"require\\('./src/core/agent-chat.js'\\); console.log\\('模块加载成功'\\)\" 2>&1)",
|
|
123
|
+
"Bash(cd D:/code/vb-agent && node -e \"require\\('./src/core/agent.js'\\); console.log\\('Agent 加载成功'\\)\" 2>&1)",
|
|
124
|
+
"Bash(node -c src/capabilities/skill-manager.js && node -c src/executors/mcp-executor.js && node -c src/capabilities/workflow-engine.js && node -c src/core/plugin-manager.js 2>&1)",
|
|
125
|
+
"Bash(node -c src/core/plugin-manager.js && node -c plugins/tools-plugin.js 2>&1)",
|
|
126
|
+
"Bash(node -c plugins/default-plugins.js && node -c cli/src/commands/chat.js 2>&1)",
|
|
127
|
+
"Bash(node -c plugins/telegram-plugin.js && node -c plugins/feishu-plugin.js && node -c plugins/weixin-plugin.js 2>&1)",
|
|
128
|
+
"Bash(node -c src/core/agent.js 2>&1)",
|
|
129
|
+
"Bash(cd D:/code/vb-agent && node examples/bootstrap.js 2>&1 | head -50)",
|
|
130
|
+
"Bash(node -c plugins/proactive-agent-plugin.js 2>&1)",
|
|
131
|
+
"Bash(node -c src/index.js && node -c examples/proactive-example.js && node -c examples/proactive-advanced.js && echo \"All syntax OK\")",
|
|
132
|
+
"Bash(node -c plugins/proactive-agent-plugin.js && node -c plugins/default-plugins.js && echo \"All OK\")",
|
|
133
|
+
"Bash(node examples/basic.js 2>&1 | head -50)",
|
|
134
|
+
"Bash(node examples/ambient-example.js 2>&1 | head -80)",
|
|
135
|
+
"Bash(ls -la .agent/data/ambient/ 2>/dev/null && cat .agent/data/ambient/*.json 2>/dev/null | head -50)",
|
|
136
|
+
"Bash(node examples/basic.js 2>&1 | head -30)",
|
|
137
|
+
"Bash(node examples/bootstrap.js 2>&1 | head -40)",
|
|
138
|
+
"Bash(node test-debug.js 2>&1)",
|
|
139
|
+
"Bash(ls -la D:/Code/vb-agent/*.md 2>/dev/null || dir D:\\\\Code\\\\vb-agent\\\\*.md /b 2>nul)",
|
|
140
|
+
"Bash(node -c src/capabilities/workflow-engine.js && node -c plugins/ambient-agent-plugin.js)",
|
|
141
|
+
"Bash(node -c plugins/ambient-agent-plugin.js)",
|
|
142
|
+
"Bash(node -c plugins/email.js)"
|
|
143
|
+
]
|
|
144
|
+
}
|
|
145
|
+
}
|
package/package.json
CHANGED
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
const { Plugin } = require('../src/core/plugin-base')
|
|
7
|
+
const { StepExecutor } = require('../src/capabilities/workflow-engine')
|
|
8
|
+
const { Agent } = require('../src/core/agent')
|
|
7
9
|
const { z } = require('zod')
|
|
8
10
|
const fs = require('fs')
|
|
9
11
|
const path = require('path')
|
|
@@ -202,7 +204,8 @@ class GoalManager {
|
|
|
202
204
|
const goal = this._goals.get(goalId)
|
|
203
205
|
if (!goal) return
|
|
204
206
|
goal.eventsReceived.push({
|
|
205
|
-
event: event.
|
|
207
|
+
event: event.type,
|
|
208
|
+
data: event.data,
|
|
206
209
|
timestamp: new Date()
|
|
207
210
|
})
|
|
208
211
|
this._persist()
|
|
@@ -257,7 +260,8 @@ class EventWatcher {
|
|
|
257
260
|
for (const goal of activeGoals) {
|
|
258
261
|
// 检查目标条件是否匹配此事件
|
|
259
262
|
if (this._isRelevantToGoal(goal, type, data)) {
|
|
260
|
-
|
|
263
|
+
// 将 data 展平到事件对象中,方便通过 {{_event.xxx}} 访问
|
|
264
|
+
this._goalManager.addEventToGoal(goal.id, { type, ...data })
|
|
261
265
|
}
|
|
262
266
|
}
|
|
263
267
|
}
|
|
@@ -359,6 +363,59 @@ class ExplorerLoop {
|
|
|
359
363
|
this._lastActionTime = 0
|
|
360
364
|
this._tickCount = 0
|
|
361
365
|
this._recentActivities = []
|
|
366
|
+
this._stepExecutor = new StepExecutor(framework)
|
|
367
|
+
this._ambientAgent = null
|
|
368
|
+
this._initAmbientAgent()
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* 初始化 Ambient 专用子 Agent
|
|
373
|
+
*/
|
|
374
|
+
_initAmbientAgent() {
|
|
375
|
+
const aiPlugin = this._framework.pluginManager?.get('ai')
|
|
376
|
+
const llmConfig = aiPlugin ? aiPlugin.getConfig() : {}
|
|
377
|
+
|
|
378
|
+
this._ambientAgent = new Agent(this._framework, {
|
|
379
|
+
name: 'ambient-worker',
|
|
380
|
+
systemPrompt: `你是 ambient-worker,一个专门执行后台任务的子 agent。
|
|
381
|
+
|
|
382
|
+
你的职责:
|
|
383
|
+
1. 执行 LLM 调用的任务(如生成回复、发送消息)
|
|
384
|
+
2. 不主动思考,只执行给定任务
|
|
385
|
+
3. 快速响应,不等待用户交互
|
|
386
|
+
|
|
387
|
+
当收到任务时,直接执行并返回结果。`,
|
|
388
|
+
model: llmConfig.model,
|
|
389
|
+
provider: llmConfig.provider,
|
|
390
|
+
apiKey: llmConfig.apiKey,
|
|
391
|
+
baseURL: llmConfig.baseURL
|
|
392
|
+
})
|
|
393
|
+
|
|
394
|
+
// 注册到主 agent(如果主 agent 已存在)
|
|
395
|
+
if (this._framework._mainAgent) {
|
|
396
|
+
this._registerAmbientWorker(this._framework._mainAgent)
|
|
397
|
+
} else {
|
|
398
|
+
// 等待主 agent 创建
|
|
399
|
+
this._framework.once('agent:created', (agent) => {
|
|
400
|
+
if (this._framework._mainAgent && agent === this._framework._mainAgent) {
|
|
401
|
+
this._registerAmbientWorker(agent)
|
|
402
|
+
}
|
|
403
|
+
})
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
/**
|
|
408
|
+
* 注册 ambient-worker 到主 agent
|
|
409
|
+
*/
|
|
410
|
+
_registerAmbientWorker(agent) {
|
|
411
|
+
if (!this._ambientAgent) return
|
|
412
|
+
agent.registerSubAgent(
|
|
413
|
+
'ambient-worker',
|
|
414
|
+
this._ambientAgent,
|
|
415
|
+
'后台任务执行器',
|
|
416
|
+
'执行需要 AI 能力的后台任务'
|
|
417
|
+
)
|
|
418
|
+
console.log('[Ambient] ambient-worker subagent registered')
|
|
362
419
|
}
|
|
363
420
|
|
|
364
421
|
start() {
|
|
@@ -512,57 +569,112 @@ class ExplorerLoop {
|
|
|
512
569
|
}
|
|
513
570
|
|
|
514
571
|
try {
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
const args = { ...action.args }
|
|
524
|
-
if (eventData) {
|
|
525
|
-
args._event = eventData
|
|
526
|
-
}
|
|
527
|
-
const result = await tool.execute(args, this._framework)
|
|
528
|
-
return result
|
|
529
|
-
} else if (action.type === 'message') {
|
|
530
|
-
const agent = this._getActiveAgent()
|
|
531
|
-
if (!agent) {
|
|
532
|
-
return { success: false, error: '没有可用的代理' }
|
|
533
|
-
}
|
|
534
|
-
// 如果有事件上下文,将其包含在消息中
|
|
535
|
-
let content = action.content
|
|
536
|
-
if (eventData) {
|
|
537
|
-
content = `${action.content}\n\n[事件上下文: ${JSON.stringify(eventData)}]`
|
|
538
|
-
}
|
|
539
|
-
const result = await agent.pushMessage(content)
|
|
540
|
-
return { success: true, result }
|
|
541
|
-
} else if (action.type === 'think') {
|
|
542
|
-
// 触发思考
|
|
543
|
-
const thinkPlugin = this._framework.pluginManager.get('think')
|
|
544
|
-
if (thinkPlugin) {
|
|
545
|
-
// 如果有事件上下文,将其包含在主题中
|
|
546
|
-
let topic = action.topic || 'Ambient代理反思'
|
|
547
|
-
if (eventData) {
|
|
548
|
-
topic = `${topic}\n\n[事件上下文: ${JSON.stringify(eventData)}]`
|
|
549
|
-
}
|
|
550
|
-
const result = await thinkPlugin._triggerThinking({
|
|
551
|
-
topic,
|
|
552
|
-
mode: action.mode || 'reflect',
|
|
553
|
-
depth: action.depth || 2
|
|
554
|
-
})
|
|
555
|
-
return result
|
|
556
|
-
}
|
|
557
|
-
return { success: false, error: '思考插件不可用' }
|
|
572
|
+
// 创建执行上下文
|
|
573
|
+
const context = {
|
|
574
|
+
input: {},
|
|
575
|
+
variables: {
|
|
576
|
+
_event: eventData,
|
|
577
|
+
_action: action
|
|
578
|
+
},
|
|
579
|
+
lastResult: null
|
|
558
580
|
}
|
|
559
581
|
|
|
560
|
-
|
|
582
|
+
// 将 action 转换为 step 配置
|
|
583
|
+
const step = this._actionToStep(action)
|
|
584
|
+
|
|
585
|
+
// message 和 think 类型使用专用子 agent 执行
|
|
586
|
+
if (step.type === 'message' || step.type === 'think') {
|
|
587
|
+
return await this._executeWithAmbientAgent(step, context)
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
// 其他类型使用 StepExecutor 直接执行
|
|
591
|
+
const result = await this._stepExecutor.executeStep(step, context)
|
|
592
|
+
return result
|
|
561
593
|
} catch (err) {
|
|
562
594
|
return { success: false, error: err.message }
|
|
563
595
|
}
|
|
564
596
|
}
|
|
565
597
|
|
|
598
|
+
/**
|
|
599
|
+
* 使用 ambient 子 agent 执行 AI 相关操作
|
|
600
|
+
*/
|
|
601
|
+
async _executeWithAmbientAgent(step, context) {
|
|
602
|
+
if (!this._ambientAgent) {
|
|
603
|
+
return { success: false, error: 'Ambient agent 未初始化' }
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
if (step.type === 'message') {
|
|
607
|
+
let content = step.content || ''
|
|
608
|
+
content = this._stepExecutor._resolveValue(content, context)
|
|
609
|
+
|
|
610
|
+
if (context.variables._event) {
|
|
611
|
+
content = `${content}\n\n[事件上下文: ${JSON.stringify(context.variables._event)}]`
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
try {
|
|
615
|
+
const result = await this._ambientAgent.pushMessage(content)
|
|
616
|
+
return { success: true, result }
|
|
617
|
+
} catch (err) {
|
|
618
|
+
return { success: false, error: err.message }
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
if (step.type === 'think') {
|
|
623
|
+
const thinkPlugin = this._framework.pluginManager?.get('think')
|
|
624
|
+
if (!thinkPlugin) {
|
|
625
|
+
return { success: false, error: '思考插件不可用' }
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
let topic = step.topic || 'Ambient代理反思'
|
|
629
|
+
topic = this._stepExecutor._resolveValue(topic, context)
|
|
630
|
+
|
|
631
|
+
if (context.variables._event) {
|
|
632
|
+
topic = `${topic}\n\n[事件上下文: ${JSON.stringify(context.variables._event)}]`
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
try {
|
|
636
|
+
const result = await thinkPlugin._triggerThinking({
|
|
637
|
+
topic,
|
|
638
|
+
mode: step.mode || 'reflect',
|
|
639
|
+
depth: step.depth || 2
|
|
640
|
+
})
|
|
641
|
+
return result
|
|
642
|
+
} catch (err) {
|
|
643
|
+
return { success: false, error: err.message }
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
return { success: false, error: `未知 AI 操作类型: ${step.type}` }
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
/**
|
|
651
|
+
* 将 action 转换为 step 配置
|
|
652
|
+
*/
|
|
653
|
+
_actionToStep(action) {
|
|
654
|
+
const step = {
|
|
655
|
+
id: action.id || `action_${Date.now()}`,
|
|
656
|
+
type: action.type,
|
|
657
|
+
name: action.name || action.id
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
switch (action.type) {
|
|
661
|
+
case 'tool':
|
|
662
|
+
step.tool = action.name
|
|
663
|
+
step.args = action.args || {}
|
|
664
|
+
break
|
|
665
|
+
case 'message':
|
|
666
|
+
step.content = action.content || ''
|
|
667
|
+
break
|
|
668
|
+
case 'think':
|
|
669
|
+
step.topic = action.topic || 'Ambient代理反思'
|
|
670
|
+
step.mode = action.mode || 'reflect'
|
|
671
|
+
step.depth = action.depth || 2
|
|
672
|
+
break
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
return step
|
|
676
|
+
}
|
|
677
|
+
|
|
566
678
|
_getActiveAgent() {
|
|
567
679
|
if (this._framework._mainAgent) {
|
|
568
680
|
return this._framework._mainAgent
|