foliko 1.0.68 → 1.0.70
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 +148 -145
- package/examples/basic.js +110 -110
- package/examples/mcp-example.js +53 -53
- package/examples/skill-example.js +49 -49
- package/examples/test-mcp.js +79 -79
- package/examples/test-reload.js +61 -61
- package/package.json +1 -1
- package/plugins/ambient-agent-plugin.js +333 -22
- package/plugins/email.js +106 -20
- package/plugins/file-system-plugin.js +76 -30
- package/plugins/python-executor-plugin.js +41 -8
- package/plugins/scheduler-plugin.js +6 -10
- package/plugins/web-plugin.js +8 -6
- package/skills/ambient-agent/SKILL.md +84 -14
- package/skills/workflow-guide/SKILL.md +214 -2
- package/skills/workflow-troubleshooting/DEBUGGING.md +182 -0
- package/skills/workflow-troubleshooting/SKILL.md +314 -0
- package/src/capabilities/workflow-engine.js +367 -22
- package/src/core/agent-chat.js +109 -14
- package/src/core/framework.js +81 -1
- package/src/executors/executor-base.js +58 -58
- package/test-server.js +0 -25
- package/test.txt +0 -3
|
@@ -1,145 +1,148 @@
|
|
|
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
|
-
|
|
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
|
+
"Bash(node -e \"require\\('./plugins/ambient-agent-plugin.js'\\)\" 2>&1)",
|
|
144
|
+
"Bash(node -e \"\nconst { Framework } = require\\('./src/core/framework'\\);\nconst framework = new Framework\\(\\);\nframework.loadPlugin\\('./plugins/ambient-agent-plugin.js'\\).catch\\(console.error\\);\nsetTimeout\\(\\(\\) => {\n const tools = framework.getTools\\(\\);\n console.log\\('Registered tools:', tools.map\\(t => t.name\\)\\);\n}, 2000\\);\n\" 2>&1)",
|
|
145
|
+
"Bash(node -c plugins/scheduler-plugin.js 2>&1)"
|
|
146
|
+
]
|
|
147
|
+
}
|
|
148
|
+
}
|
package/examples/basic.js
CHANGED
|
@@ -1,110 +1,110 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 基础示例
|
|
3
|
-
* 展示如何使用 Framework 和 Agent
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
const { Framework } = require('../src')
|
|
7
|
-
const { AIPlugin } = require('../plugins/ai-plugin')
|
|
8
|
-
const { z } = require('zod')
|
|
9
|
-
|
|
10
|
-
async function main() {
|
|
11
|
-
// 创建框架实例
|
|
12
|
-
const framework = new Framework({ debug: true })
|
|
13
|
-
|
|
14
|
-
// 加载 AI 插件
|
|
15
|
-
await framework.loadPlugin(new AIPlugin({
|
|
16
|
-
provider: 'deepseek',
|
|
17
|
-
model: 'deepseek-chat',
|
|
18
|
-
apiKey: process.env.DEEPSEEK_API_KEY || 'your-api-key'
|
|
19
|
-
}))
|
|
20
|
-
|
|
21
|
-
// 注册自定义工具(使用 inputSchema 格式)
|
|
22
|
-
framework.registerTool({
|
|
23
|
-
name: 'hello',
|
|
24
|
-
description: '打招呼工具',
|
|
25
|
-
inputSchema: z.object({
|
|
26
|
-
name: z.string().optional().describe('姓名')
|
|
27
|
-
}),
|
|
28
|
-
execute: async (args) => {
|
|
29
|
-
return `Hello, ${args.name || 'World'}!`
|
|
30
|
-
}
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
// 注册计算器工具
|
|
34
|
-
framework.registerTool({
|
|
35
|
-
name: 'calculate',
|
|
36
|
-
description: '简单的计算器',
|
|
37
|
-
inputSchema: z.object({
|
|
38
|
-
expression: z.string().describe('数学表达式,如 2+3*4')
|
|
39
|
-
}),
|
|
40
|
-
execute: async (args) => {
|
|
41
|
-
try {
|
|
42
|
-
// 安全计算(仅支持基本运算)
|
|
43
|
-
const result = Function(`"use strict"; return (${args.expression})`)()
|
|
44
|
-
return { result }
|
|
45
|
-
} catch (e) {
|
|
46
|
-
return { error: e.message }
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
})
|
|
50
|
-
|
|
51
|
-
console.log('[Framework] Ready!')
|
|
52
|
-
console.log('[Tools]', framework.getTools().map(t => t.name))
|
|
53
|
-
|
|
54
|
-
// 创建 Agent
|
|
55
|
-
const agent = framework.createAgent({
|
|
56
|
-
name: 'MyAgent',
|
|
57
|
-
systemPrompt: '你是一个有帮助的助手。当需要计算时,使用 calculate 工具。'
|
|
58
|
-
})
|
|
59
|
-
|
|
60
|
-
// 监听事件
|
|
61
|
-
agent.on('tool-call', (tool) => {
|
|
62
|
-
console.log('[Agent] Tool call:', tool.name, tool.args)
|
|
63
|
-
})
|
|
64
|
-
|
|
65
|
-
agent.on('tool-result', (result) => {
|
|
66
|
-
console.log('[Agent] Tool result:', result.name, result.result)
|
|
67
|
-
})
|
|
68
|
-
|
|
69
|
-
// AI 对话示例
|
|
70
|
-
console.log('\n=== AI Chat Example ===')
|
|
71
|
-
try {
|
|
72
|
-
const response = await agent.chat('你好!')
|
|
73
|
-
console.log('[Agent] Response:', response.message)
|
|
74
|
-
} catch (err) {
|
|
75
|
-
console.error('[Agent] Error:', err.message)
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// 使用工具的对话示例
|
|
79
|
-
console.log('\n=== AI Chat with Tool Call ===')
|
|
80
|
-
try {
|
|
81
|
-
const response = await agent.chat('请帮我计算 (15 + 25) * 2 等于多少?')
|
|
82
|
-
console.log('[Agent] Response:', response.message)
|
|
83
|
-
} catch (err) {
|
|
84
|
-
console.error('[Agent] Error:', err.message)
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
// 流式对话示例
|
|
88
|
-
console.log('\n=== Streaming Chat ===')
|
|
89
|
-
try {
|
|
90
|
-
for await (const chunk of agent.chatStream('请用中文介绍一下你自己')) {
|
|
91
|
-
if (chunk.type === 'text') {
|
|
92
|
-
process.stdout.write(chunk.text)
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
console.log('\n')
|
|
96
|
-
} catch (err) {
|
|
97
|
-
console.error('[Agent] Stream Error:', err.message)
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
// 热重载示例
|
|
101
|
-
console.log('\n=== Hot Reload ===')
|
|
102
|
-
await framework.reloadPlugin('ai')
|
|
103
|
-
console.log('AI plugin reloaded!')
|
|
104
|
-
|
|
105
|
-
// 清理
|
|
106
|
-
await framework.destroy()
|
|
107
|
-
console.log('\n[Done]')
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
main().catch(console.error)
|
|
1
|
+
/**
|
|
2
|
+
* 基础示例
|
|
3
|
+
* 展示如何使用 Framework 和 Agent
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const { Framework } = require('../src')
|
|
7
|
+
const { AIPlugin } = require('../plugins/ai-plugin')
|
|
8
|
+
const { z } = require('zod')
|
|
9
|
+
|
|
10
|
+
async function main() {
|
|
11
|
+
// 创建框架实例
|
|
12
|
+
const framework = new Framework({ debug: true })
|
|
13
|
+
|
|
14
|
+
// 加载 AI 插件
|
|
15
|
+
await framework.loadPlugin(new AIPlugin({
|
|
16
|
+
provider: 'deepseek',
|
|
17
|
+
model: 'deepseek-chat',
|
|
18
|
+
apiKey: process.env.DEEPSEEK_API_KEY || 'your-api-key'
|
|
19
|
+
}))
|
|
20
|
+
|
|
21
|
+
// 注册自定义工具(使用 inputSchema 格式)
|
|
22
|
+
framework.registerTool({
|
|
23
|
+
name: 'hello',
|
|
24
|
+
description: '打招呼工具',
|
|
25
|
+
inputSchema: z.object({
|
|
26
|
+
name: z.string().optional().describe('姓名')
|
|
27
|
+
}),
|
|
28
|
+
execute: async (args) => {
|
|
29
|
+
return `Hello, ${args.name || 'World'}!`
|
|
30
|
+
}
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
// 注册计算器工具
|
|
34
|
+
framework.registerTool({
|
|
35
|
+
name: 'calculate',
|
|
36
|
+
description: '简单的计算器',
|
|
37
|
+
inputSchema: z.object({
|
|
38
|
+
expression: z.string().describe('数学表达式,如 2+3*4')
|
|
39
|
+
}),
|
|
40
|
+
execute: async (args) => {
|
|
41
|
+
try {
|
|
42
|
+
// 安全计算(仅支持基本运算)
|
|
43
|
+
const result = Function(`"use strict"; return (${args.expression})`)()
|
|
44
|
+
return { result }
|
|
45
|
+
} catch (e) {
|
|
46
|
+
return { error: e.message }
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
console.log('[Framework] Ready!')
|
|
52
|
+
console.log('[Tools]', framework.getTools().map(t => t.name))
|
|
53
|
+
|
|
54
|
+
// 创建 Agent
|
|
55
|
+
const agent = framework.createAgent({
|
|
56
|
+
name: 'MyAgent',
|
|
57
|
+
systemPrompt: '你是一个有帮助的助手。当需要计算时,使用 calculate 工具。'
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
// 监听事件
|
|
61
|
+
agent.on('tool-call', (tool) => {
|
|
62
|
+
console.log('[Agent] Tool call:', tool.name, tool.args)
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
agent.on('tool-result', (result) => {
|
|
66
|
+
console.log('[Agent] Tool result:', result.name, result.result)
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
// AI 对话示例
|
|
70
|
+
console.log('\n=== AI Chat Example ===')
|
|
71
|
+
try {
|
|
72
|
+
const response = await agent.chat('你好!')
|
|
73
|
+
console.log('[Agent] Response:', response.message)
|
|
74
|
+
} catch (err) {
|
|
75
|
+
console.error('[Agent] Error:', err.message)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// 使用工具的对话示例
|
|
79
|
+
console.log('\n=== AI Chat with Tool Call ===')
|
|
80
|
+
try {
|
|
81
|
+
const response = await agent.chat('请帮我计算 (15 + 25) * 2 等于多少?')
|
|
82
|
+
console.log('[Agent] Response:', response.message)
|
|
83
|
+
} catch (err) {
|
|
84
|
+
console.error('[Agent] Error:', err.message)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// 流式对话示例
|
|
88
|
+
console.log('\n=== Streaming Chat ===')
|
|
89
|
+
try {
|
|
90
|
+
for await (const chunk of agent.chatStream('请用中文介绍一下你自己')) {
|
|
91
|
+
if (chunk.type === 'text') {
|
|
92
|
+
process.stdout.write(chunk.text)
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
console.log('\n')
|
|
96
|
+
} catch (err) {
|
|
97
|
+
console.error('[Agent] Stream Error:', err.message)
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// 热重载示例
|
|
101
|
+
console.log('\n=== Hot Reload ===')
|
|
102
|
+
await framework.reloadPlugin('ai')
|
|
103
|
+
console.log('AI plugin reloaded!')
|
|
104
|
+
|
|
105
|
+
// 清理
|
|
106
|
+
await framework.destroy()
|
|
107
|
+
console.log('\n[Done]')
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
main().catch(console.error)
|