foliko 1.0.30 → 1.0.31

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.
@@ -1,78 +1,79 @@
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
- ]
77
- }
78
- }
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
+ ]
78
+ }
79
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foliko",
3
- "version": "1.0.30",
3
+ "version": "1.0.31",
4
4
  "description": "简约的插件化 Agent 框架",
5
5
  "main": "src/index.js",
6
6
  "bin": {
package/plugins/email.js CHANGED
@@ -15,16 +15,6 @@ class EmailPlugin extends Plugin {
15
15
  this.priority = 10
16
16
  // 默认不启用,需要在 plugins.json 中设置 enabled: true
17
17
  this.enabled = false
18
- // IMAP ID 信息
19
- this.config = {
20
- ...config,
21
- clientId: config.clientId || {
22
- name: 'FolikoAgent',
23
- version: '1.0.0',
24
- vendor: 'Foliko',
25
- supportEmail: config.imap?.user || 'unknown@example.com'
26
- }
27
- }
28
18
  }
29
19
 
30
20
  install(framework) {
@@ -105,42 +95,22 @@ class EmailPlugin extends Plugin {
105
95
  // 配置邮箱连接
106
96
  this._framework.registerTool({
107
97
  name: 'email_configure',
108
- description: '配置邮箱连接参数',
109
- inputSchema: z.object({
110
- smtp_host: z.string().optional().describe('SMTP服务器地址'),
111
- smtp_port: z.number().optional().describe('SMTP端口'),
112
- smtp_secure: z.boolean().optional().describe('是否使用SSL/TLS'),
113
- smtp_user: z.string().optional().describe('SMTP用户名'),
114
- smtp_pass: z.string().optional().describe('SMTP密码'),
115
- imap_host: z.string().optional().describe('IMAP服务器地址'),
116
- imap_port: z.number().optional().describe('IMAP端口'),
117
- imap_user: z.string().optional().describe('IMAP用户名'),
118
- imap_pass: z.string().optional().describe('IMAP密码'),
119
- from_email: z.string().optional().describe('默认发件人地址'),
120
- client_id_name: z.string().optional().describe('IMAP客户端名称'),
121
- client_id_version: z.string().optional().describe('IMAP客户端版本'),
122
- client_id_vendor: z.string().optional().describe('IMAP客户端厂商'),
123
- client_id_support_email: z.string().optional().describe('IMAP客户端支持邮箱')
124
- }),
125
- execute: async (args) => {
126
- // 处理 clientId 字段
127
- if (args.client_id_name || args.client_id_version || args.client_id_vendor || args.client_id_support_email) {
128
- this.config.clientId = {
129
- name: args.client_id_name || this.config.clientId?.name || 'FolikoAgent',
130
- version: args.client_id_version || this.config.clientId?.version || '1.0.0',
131
- vendor: args.client_id_vendor || this.config.clientId?.vendor || 'Foliko',
132
- supportEmail: args.client_id_support_email || this.config.clientId?.supportEmail
133
- }
134
- delete args.client_id_name
135
- delete args.client_id_version
136
- delete args.client_id_vendor
137
- delete args.client_id_support_email
138
- }
139
- Object.assign(this.config, args)
98
+ description: '查看邮箱配置(实际配置通过环境变量设置)',
99
+ inputSchema: z.object({}),
100
+ execute: async () => {
140
101
  return {
141
102
  success: true,
142
- message: '邮箱配置已更新',
143
- config: this.config
103
+ message: '邮箱配置通过环境变量设置',
104
+ config: {
105
+ smtp_host: process.env.SMTP_HOST || 'smtp.gmail.com',
106
+ smtp_port: process.env.SMTP_PORT || 587,
107
+ smtp_secure: process.env.SMTP_SECURE || 'false',
108
+ imap_host: process.env.IMAP_HOST || 'imap.gmail.com',
109
+ imap_port: process.env.IMAP_PORT || 993,
110
+ from_email: process.env.FROM_EMAIL || '(未设置)',
111
+ client_name: process.env.IMAP_CLIENT_NAME || 'FolikoAgent',
112
+ client_version: process.env.IMAP_CLIENT_VERSION || '1.0.0'
113
+ }
144
114
  }
145
115
  }
146
116
  })
@@ -151,19 +121,19 @@ class EmailPlugin extends Plugin {
151
121
  const nodemailer = require('nodemailer')
152
122
 
153
123
  const smtpConfig = {
154
- host: this.config.smtp_host || process.env.SMTP_HOST || 'smtp.gmail.com',
155
- port: this.config.smtp_port || process.env.SMTP_PORT || 587,
156
- secure: (this.config.smtp_secure || process.env.SMTP_SECURE || 'false') === 'true',
124
+ host: process.env.SMTP_HOST || 'smtp.gmail.com',
125
+ port: parseInt(process.env.SMTP_PORT) || 587,
126
+ secure: process.env.SMTP_SECURE === 'true',
157
127
  auth: {
158
- user: this.config.smtp_user || process.env.SMTP_USER,
159
- pass: this.config.smtp_pass || process.env.SMTP_PASS
128
+ user: process.env.SMTP_USER,
129
+ pass: process.env.SMTP_PASS
160
130
  }
161
131
  }
162
132
 
163
133
  const transporter = nodemailer.createTransport(smtpConfig)
164
134
 
165
135
  const mailOptions = {
166
- from: this.config.from_email || process.env.FROM_EMAIL || smtpConfig.auth.user,
136
+ from: process.env.FROM_EMAIL || smtpConfig.auth.user,
167
137
  to: args.to,
168
138
  subject: args.subject,
169
139
  text: args.isHtml ? undefined : args.body,
@@ -195,16 +165,16 @@ class EmailPlugin extends Plugin {
195
165
  const { simpleParser } = require('mailparser')
196
166
 
197
167
  const imapConfig = {
198
- user: args.user || this.config.imap_user || process.env.IMAP_USER,
199
- password: args.password || this.config.imap_pass || process.env.IMAP_PASS,
200
- host: args.host || this.config.imap_host || process.env.IMAP_HOST,
201
- port: args.port || this.config.imap_port || 993,
168
+ user: args.user || process.env.IMAP_USER,
169
+ password: args.password || process.env.IMAP_PASS,
170
+ host: args.host || process.env.IMAP_HOST,
171
+ port: args.port || parseInt(process.env.IMAP_PORT) || 993,
202
172
  tls: true,
203
173
  tlsOptions: { rejectUnauthorized: false },
204
174
  id: {
205
- name: this.config.clientId?.name || 'FolikoAgent',
206
- version: this.config.clientId?.version || '1.0.0',
207
- vendor: this.config.clientId?.vendor || 'Foliko'
175
+ name: process.env.IMAP_CLIENT_NAME || 'FolikoAgent',
176
+ version: process.env.IMAP_CLIENT_VERSION || '1.0.0',
177
+ vendor: process.env.IMAP_CLIENT_VENDOR || 'Foliko'
208
178
  }
209
179
  }
210
180
 
@@ -233,17 +203,17 @@ class EmailPlugin extends Plugin {
233
203
  const Imap = require('imap-mkl')
234
204
 
235
205
  const imapConfig = {
236
- user: args.user || this.config.imap_user || process.env.IMAP_USER,
237
- password: args.password || this.config.imap_pass || process.env.IMAP_PASS,
238
- host: args.host || this.config.imap_host || process.env.IMAP_HOST,
239
- port: args.port || this.config.imap_port || 993,
206
+ user: args.user || process.env.IMAP_USER,
207
+ password: args.password || process.env.IMAP_PASS,
208
+ host: args.host || process.env.IMAP_HOST,
209
+ port: args.port || parseInt(process.env.IMAP_PORT) || 993,
240
210
  tls: true,
241
211
  tlsOptions: { rejectUnauthorized: false },
242
212
  id: {
243
- name: this.config.clientId?.name || 'FolikoAgent',
244
- version: this.config.clientId?.version || '1.0.0',
245
- vendor: this.config.clientId?.vendor || 'Foliko',
246
- 'support-email': this.config.clientId?.supportEmail || 'unknown@example.com'
213
+ name: process.env.IMAP_CLIENT_NAME || 'FolikoAgent',
214
+ version: process.env.IMAP_CLIENT_VERSION || '1.0.0',
215
+ vendor: process.env.IMAP_CLIENT_VENDOR || 'Foliko',
216
+ 'support-email': process.env.IMAP_CLIENT_SUPPORT_EMAIL || 'unknown@example.com'
247
217
  }
248
218
  }
249
219
 
@@ -268,17 +238,17 @@ class EmailPlugin extends Plugin {
268
238
  const Imap = require('imap-mkl')
269
239
 
270
240
  const imapConfig = {
271
- user: args.user || this.config.imap_user || process.env.IMAP_USER,
272
- password: args.password || this.config.imap_pass || process.env.IMAP_PASS,
273
- host: args.host || this.config.imap_host || process.env.IMAP_HOST,
274
- port: args.port || this.config.imap_port || 993,
241
+ user: args.user || process.env.IMAP_USER,
242
+ password: args.password || process.env.IMAP_PASS,
243
+ host: args.host || process.env.IMAP_HOST,
244
+ port: args.port || parseInt(process.env.IMAP_PORT) || 993,
275
245
  tls: true,
276
246
  tlsOptions: { rejectUnauthorized: false },
277
247
  id: {
278
- name: this.config.clientId?.name || 'FolikoAgent',
279
- version: this.config.clientId?.version || '1.0.0',
280
- vendor: this.config.clientId?.vendor || 'Foliko',
281
- 'support-email': this.config.clientId?.supportEmail || 'unknown@example.com'
248
+ name: process.env.IMAP_CLIENT_NAME || 'FolikoAgent',
249
+ version: process.env.IMAP_CLIENT_VERSION || '1.0.0',
250
+ vendor: process.env.IMAP_CLIENT_VENDOR || 'Foliko',
251
+ 'support-email': process.env.IMAP_CLIENT_SUPPORT_EMAIL || 'unknown@example.com'
282
252
  }
283
253
  }
284
254
 
@@ -314,7 +284,9 @@ class EmailPlugin extends Plugin {
314
284
  return reject(err)
315
285
  }
316
286
 
317
- let searchFilter = searchCriteria ? [searchCriteria] : ['ALL']
287
+ let searchFilter = searchCriteria
288
+ ? searchCriteria.split(' ').filter(Boolean)
289
+ : ['ALL']
318
290
  if (unreadOnly) {
319
291
  searchFilter = ['UNSEEN']
320
292
  }
@@ -334,24 +306,33 @@ class EmailPlugin extends Plugin {
334
306
  const f = imap.fetch(fetchIds, { bodies: '' })
335
307
 
336
308
  f.on('message', (msg) => {
337
- const email = {}
309
+ let email = {}
310
+ let parserDone = false
311
+
312
+ const finishEmail = () => {
313
+ if (parserDone) {
314
+ emails.push(email)
315
+ }
316
+ }
338
317
 
339
318
  msg.on('body', (stream) => {
340
- simpleParser(stream, (err, mail) => {
341
- if (err) {
342
- email.error = err.message
343
- } else {
344
- email.subject = mail.subject
345
- email.from = mail.from?.text || ''
346
- email.to = mail.to?.text || ''
347
- email.date = mail.date?.toISOString() || ''
348
- email.text = mail.text
349
- email.html = mail.html
350
- email.attachments = mail.attachments?.map(a => ({
351
- filename: a.filename,
352
- contentType: a.contentType
353
- })) || []
354
- }
319
+ simpleParser(stream).then(mail => {
320
+ email.subject = mail.subject
321
+ email.from = mail.from?.text || ''
322
+ email.to = mail.to?.text || ''
323
+ email.date = mail.date?.toISOString() || ''
324
+ email.text = mail.text || mail.textAsHtml || ''
325
+ email.html = mail.html
326
+ email.attachments = mail.attachments?.map(a => ({
327
+ filename: a.filename,
328
+ contentType: a.contentType
329
+ })) || []
330
+ parserDone = true
331
+ finishEmail()
332
+ }).catch(err => {
333
+ email.error = err.message
334
+ parserDone = true
335
+ finishEmail()
355
336
  })
356
337
  })
357
338
 
@@ -362,7 +343,8 @@ class EmailPlugin extends Plugin {
362
343
  })
363
344
 
364
345
  msg.on('end', () => {
365
- emails.push(email)
346
+ // 如果没有 body,parserDone 已经是 true
347
+ finishEmail()
366
348
  })
367
349
  })
368
350