foliko 1.1.67 → 1.1.69

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.
Files changed (157) hide show
  1. package/.claude/settings.local.json +19 -10
  2. package/.dockerignore +45 -45
  3. package/.env.example +56 -56
  4. package/CLAUDE.md +2 -2
  5. package/README.md +13 -13
  6. package/SPEC.md +3 -3
  7. package/cli/src/commands/chat.js +2 -20
  8. package/cli/src/commands/list.js +7 -6
  9. package/cli/src/commands/plugin.js +3 -2
  10. package/cli/src/daemon.js +2 -2
  11. package/cli/src/ui/chat-ui-old.js +15 -4
  12. package/cli/src/ui/chat-ui.js +236 -203
  13. package/cli/src/ui/footer-bar.js +20 -46
  14. package/cli/src/ui/message-bubble.js +24 -2
  15. package/cli/src/ui/status-bar.js +177 -0
  16. package/cli/src/utils/config.js +29 -0
  17. package/cli/src/utils/plugin-config.js +1 -1
  18. package/docker-compose.yml +33 -33
  19. package/docs/features.md +120 -120
  20. package/docs/quick-reference.md +160 -160
  21. package/docs/user-manual.md +1391 -1391
  22. package/examples/ambient-example.js +2 -2
  23. package/examples/bootstrap.js +3 -3
  24. package/examples/test-chat.js +1 -1
  25. package/examples/test-reload.js +1 -1
  26. package/examples/test-telegram.js +1 -1
  27. package/examples/test-tg-bot.js +1 -1
  28. package/examples/test-tg-simple.js +2 -2
  29. package/examples/test-tg.js +1 -1
  30. package/examples/test-think.js +1 -1
  31. package/examples/test-weixin-feishu.js +3 -3
  32. package/package.json +3 -1
  33. package/plugins/ambient-agent/index.js +1 -1
  34. package/plugins/audit-plugin.js +84 -29
  35. package/plugins/coordinator-plugin.js +14 -12
  36. package/plugins/data-splitter-plugin.js +323 -0
  37. package/plugins/default-plugins.js +23 -12
  38. package/plugins/email/index.js +1 -1
  39. package/plugins/extension-executor-plugin.js +87 -9
  40. package/plugins/feishu-plugin.js +118 -16
  41. package/plugins/file-system-plugin.js +68 -50
  42. package/plugins/gate-trading.js +10 -10
  43. package/plugins/install-plugin.js +7 -7
  44. package/plugins/memory-plugin.js +9 -12
  45. package/plugins/plugin-manager-plugin.js +12 -14
  46. package/plugins/python-executor-plugin.js +1 -1
  47. package/plugins/python-plugin-loader.js +1 -1
  48. package/plugins/qq-plugin.js +151 -24
  49. package/plugins/rules-plugin.js +8 -8
  50. package/plugins/scheduler-plugin.js +24 -20
  51. package/plugins/session-plugin.js +313 -397
  52. package/plugins/storage-plugin.js +235 -175
  53. package/plugins/subagent-plugin.js +17 -13
  54. package/plugins/telegram-plugin.js +116 -17
  55. package/plugins/think-plugin.js +64 -60
  56. package/plugins/tools-plugin.js +8 -8
  57. package/plugins/web-plugin.js +2 -2
  58. package/plugins/weixin-plugin.js +107 -24
  59. package/skills/find-skills/AGENTS.md +2 -2
  60. package/skills/find-skills/SKILL.md +133 -133
  61. package/skills/foliko-dev/AGENTS.md +236 -236
  62. package/skills/foliko-dev/SKILL.md +19 -19
  63. package/skills/mcp-usage/SKILL.md +200 -200
  64. package/skills/plugin-guide/SKILL.md +4 -4
  65. package/skills/python-plugin-dev/SKILL.md +5 -5
  66. package/skills/skill-guide/SKILL.md +104 -6
  67. package/skills/subagent-guide/SKILL.md +237 -237
  68. package/skills/workflow-guide/SKILL.md +646 -646
  69. package/src/capabilities/skill-manager.js +124 -17
  70. package/src/capabilities/workflow-engine.js +3 -3
  71. package/src/core/agent-chat.js +72 -26
  72. package/src/core/agent.js +17 -27
  73. package/src/core/branch-summary-auto.js +206 -0
  74. package/src/core/chat-session.js +45 -169
  75. package/src/core/command-registry.js +200 -0
  76. package/src/core/constants.js +198 -0
  77. package/src/core/context-compressor.js +702 -326
  78. package/src/core/context-manager.js +0 -1
  79. package/src/core/enhanced-context-compressor.js +210 -0
  80. package/src/core/framework.js +260 -84
  81. package/src/core/jsonl-storage.js +253 -0
  82. package/src/core/plugin-base.js +7 -5
  83. package/src/core/plugin-manager.js +15 -10
  84. package/src/core/provider-registry.js +159 -0
  85. package/src/core/provider.js +2 -0
  86. package/src/core/session-entry.js +225 -0
  87. package/src/core/session-manager.js +701 -0
  88. package/src/core/storage-manager.js +494 -0
  89. package/src/core/sub-agent-config.js +1 -1
  90. package/src/core/subagent.js +16 -135
  91. package/src/core/token-counter.js +177 -58
  92. package/src/core/tool-executor.js +2 -70
  93. package/src/core/ui-extension-context.js +174 -0
  94. package/src/executors/mcp-executor.js +27 -16
  95. package/src/utils/chat-queue.js +11 -22
  96. package/src/utils/data-splitter.js +345 -0
  97. package/src/utils/logger.js +152 -180
  98. package/src/utils/message-validator.js +283 -0
  99. package/src/utils/plugin-helpers.js +2 -2
  100. package/src/utils/retry.js +168 -22
  101. package/website_v2/docs/api.html +1 -1
  102. package/website_v2/docs/configuration.html +2 -2
  103. package/website_v2/docs/plugin-development.html +4 -4
  104. package/website_v2/docs/project-structure.html +2 -2
  105. package/website_v2/docs/skill-development.html +2 -2
  106. package/website_v2/index.html +1 -1
  107. package/website_v2/styles/animations.css +7 -7
  108. package/.agent/agents/backend-dev.md +0 -102
  109. package/.agent/agents/data-analyst.md +0 -117
  110. package/.agent/agents/devops.md +0 -115
  111. package/.agent/agents/frontend-dev.md +0 -94
  112. package/.agent/agents/network-requester.md +0 -44
  113. package/.agent/agents/poster-designer.md +0 -52
  114. package/.agent/agents/product-manager.md +0 -85
  115. package/.agent/agents/qa-engineer.md +0 -100
  116. package/.agent/agents/security-engineer.md +0 -99
  117. package/.agent/agents/team-lead.md +0 -137
  118. package/.agent/agents/ui-designer.md +0 -116
  119. package/.agent/data/default.json +0 -58
  120. package/.agent/data/email/processed-emails.json +0 -1
  121. package/.agent/data/plugins-state.json +0 -199
  122. package/.agent/data/scheduler/tasks.json +0 -1
  123. package/.agent/data/web/web-config.json +0 -5
  124. package/.agent/data/weixin/images/file_1776188148383jpg +0 -0
  125. package/.agent/data/weixin/images/file_1776188458326.jpg +0 -0
  126. package/.agent/data/weixin/images/file_1776188689423.jpg +0 -0
  127. package/.agent/data/weixin/images/file_1776188813604.jpg +0 -0
  128. package/.agent/data/weixin/images/file_1776189097450.jpg +0 -0
  129. package/.agent/data/weixin/videos/file_1776188318431.mp4 +0 -0
  130. package/.agent/data/weixin.json +0 -6
  131. package/.agent/mcp_config.json +0 -14
  132. package/.agent/memory/user/mof6gk94-kneeuh.md +0 -9
  133. package/.agent/package.json +0 -8
  134. package/.agent/plugins/marknative/README.md +0 -134
  135. package/.agent/plugins/marknative/fonts/SegoeUI Emoji.ttf +0 -0
  136. package/.agent/plugins/marknative/fonts.zip +0 -0
  137. package/.agent/plugins/marknative/index.js +0 -256
  138. package/.agent/plugins/marknative/package.json +0 -12
  139. package/.agent/plugins/test-plugin.py +0 -99
  140. package/.agent/plugins.json +0 -14
  141. package/.agent/python-scripts/test_sample.py +0 -24
  142. package/.agent/sessions/cli_default.json +0 -247
  143. package/.agent/skills/agent-browser/SKILL.md +0 -311
  144. package/.agent/skills/agent-browser/TEST_PLAN.md +0 -200
  145. package/.agent/skills/sysinfo/SKILL.md +0 -38
  146. package/.agent/skills/sysinfo/system-info.sh +0 -130
  147. package/.agent/skills/workflow/SKILL.md +0 -324
  148. package/.agent/test-agent.js +0 -35
  149. package/.agent/weixin.json +0 -6
  150. package/.agent/workflows/email-digest.json +0 -50
  151. package/.agent/workflows/file-backup.json +0 -21
  152. package/.agent/workflows/get-ip-notify.json +0 -32
  153. package/.agent/workflows/news-aggregator.json +0 -93
  154. package/.agent/workflows/news-dashboard-v2.json +0 -94
  155. package/.agent/workflows/notification-batch.json +0 -32
  156. package/src/core/session-context.js +0 -346
  157. package/src/core/session-storage.js +0 -295
@@ -1,247 +0,0 @@
1
- {
2
- "sessionId": "cli_default",
3
- "messages": [
4
- {
5
- "role": "user",
6
- "content": "你好"
7
- },
8
- {
9
- "role": "assistant",
10
- "content": [
11
- {
12
- "type": "text",
13
- "text": "<think>用户说\"你好\",这是一个简单的问候。我应该友好地回应,并简要介绍我能帮助的功能和服务。\n</think>\n\n你好!很高兴见到你 👋\n\n我是 Foliko 的智能助手,可以帮助你完成各种任务,包括:\n\n- **文件和代码操作**:读写文件、搜索代码、执行命令\n- **Web 请求**:发送 HTTP 请求、抓取网页数据\n- **任务自动化**:设置定时任务、管理工作流\n- **插件管理**:安装和管理各种功能插件\n- **记忆系统**:存储和检索信息\n- **子 Agent**:委托专业任务给专门的 AI 助手\n\n有什么我可以帮助你的吗?"
14
- }
15
- ]
16
- },
17
- {
18
- "role": "user",
19
- "content": "有什么好玩的"
20
- },
21
- {
22
- "role": "assistant",
23
- "content": [
24
- {
25
- "type": "text",
26
- "text": "<think>用户问有什么好玩的,这是一个比较开放的问题。我可以介绍一些有趣的玩法或者展示一下系统的能力。\n\n让我想想有什么好玩的:\n1. 可以展示一下海报制作功能\n2. 可以介绍一些插件功能\n3. 可以展示一下记忆系统\n4. 可以推荐一些有趣的工作流程\n\n不过我应该先了解一下用户感兴趣的方向,给出一些具体的建议。\n</think>\n\n好玩的有很多!给你几个方向:\n\n## 🎨 创意类\n- **海报制作**:用 poster 插件制作炫酷海报,支持文字、图形、图片组合\n- **Markdown 转图片**:把代码、文档渲染成精美的图片\n\n## 🔧 技术类\n- **自动化工作流**:创建多步骤任务流程,自动执行\n- **定时提醒**:设置定时任务,比如每小时提醒喝水\n- **浏览器自动化**:AI 帮你操作网页、填表、截图\n\n## 🧠 智能类\n- **深度思考**:触发 AI 自我分析、头脑风暴\n- **记忆系统**:存储你的偏好、经验,下次自动调用\n- **子 Agent**:让专业的 AI(前端、后端、测试工程师等)帮你完成任务\n\n## 🌐 网络类\n- **抓取网页**:获取网页内容、数据分析\n- **API 调用**:请求各种接口、获取实时数据\n\n---\n\n你想玩哪个?我可以带你体验一下 😊"
27
- }
28
- ]
29
- },
30
- {
31
- "role": "user",
32
- "content": "熟悉本项目"
33
- },
34
- {
35
- "role": "assistant",
36
- "content": [
37
- {
38
- "type": "text",
39
- "text": "<think>用户想要了解当前项目。我需要读取项目结构和主要文件来熟悉这个项目。\n</think>\n\n让我来探索一下这个项目!\n"
40
- },
41
- {
42
- "type": "tool-call",
43
- "toolCallId": "call_function_m4fr4soeknae_1",
44
- "toolName": "read_directory",
45
- "input": {
46
- "path": "."
47
- }
48
- }
49
- ]
50
- },
51
- {
52
- "role": "tool",
53
- "content": [
54
- {
55
- "type": "tool-result",
56
- "toolCallId": "call_function_m4fr4soeknae_1",
57
- "toolName": "read_directory",
58
- "output": {
59
- "type": "text",
60
- "value": "{\"success\":true,\"dirPath\":\".\",\"items\":[{\"name\":\".agent\",\"path\":\".agent\",\"type\":\"directory\",\"size\":null},{\"name\":\".claude\",\"path\":\".claude\",\"type\":\"directory\",\"size\":null},{\"name\":\".dockerignore\",\"path\":\".dockerignore\",\"type\":\"file\",\"size\":456},{\"name\":\".editorconfig\",\"path\":\".editorconfig\",\"type\":\"file\",\"size\":830},{\"name\":\".env\",\"path\":\".env\",\"type\":\"file\",\"size\":1108},{\"name\":\".env.example\",\"path\":\".env.example\",\"type\":\"file\",\"size\":1798},{\"name\":\".foliko.log\",\"path\":\".foliko.log\",\"type\":\"file\",\"size\":10662},{\"name\":\".husky\",\"path\":\".husky\",\"type\":\"directory\",\"size\":null},{\"name\":\".lintstagedrc\",\"path\":\".lintstagedrc\",\"type\":\"file\",\"size\":278},{\"name\":\".npmrc\",\"path\":\".npmrc\",\"type\":\"file\",\"size\":51},{\"name\":\".prettierignore\",\"path\":\".prettierignore\",\"type\":\"file\",\"size\":332},{\"name\":\".prettierrc\",\"path\":\".prettierrc\",\"type\":\"file\",\"size\":208},{\"name\":\"CLAUDE.md\",\"path\":\"CLAUDE.md\",\"type\":\"file\",\"size\":7223},{\"name\":\"cli\",\"path\":\"cli\",\"type\":\"directory\",\"size\":null},{\"name\":\"docker-compose.yml\",\"path\":\"docker-compose.yml\",\"type\":\"file\",\"size\":911},{\"name\":\"Dockerfile\",\"path\":\"Dockerfile\",\"type\":\"file\",\"size\":1514},{\"name\":\"docs\",\"path\":\"docs\",\"type\":\"directory\",\"size\":null},{\"name\":\"examples\",\"path\":\"examples\",\"type\":\"directory\",\"size\":null},{\"name\":\"images\",\"path\":\"images\",\"type\":\"directory\",\"size\":null},{\"name\":\"install.ps1\",\"path\":\"install.ps1\",\"type\":\"file\",\"size\":5625},{\"name\":\"install.sh\",\"path\":\"install.sh\",\"type\":\"file\",\"size\":3792},{\"name\":\"package.json\",\"path\":\"package.json\",\"type\":\"file\",\"size\":2348},{\"name\":\"plugins\",\"path\":\"plugins\",\"type\":\"directory\",\"size\":null},{\"name\":\"README.md\",\"path\":\"README.md\",\"type\":\"file\",\"size\":10427},{\"name\":\"skills\",\"path\":\"skills\",\"type\":\"directory\",\"size\":null},{\"name\":\"SPEC.md\",\"path\":\"SPEC.md\",\"type\":\"file\",\"size\":22808},{\"name\":\"src\",\"path\":\"src\",\"type\":\"directory\",\"size\":null},{\"name\":\"subagent.md\",\"path\":\"subagent.md\",\"type\":\"file\",\"size\":12149},{\"name\":\"system.md\",\"path\":\"system.md\",\"type\":\"file\",\"size\":43314},{\"name\":\"website_v2\",\"path\":\"website_v2\",\"type\":\"directory\",\"size\":null},{\"name\":\"xhs_auth.json\",\"path\":\"xhs_auth.json\",\"type\":\"file\",\"size\":51107},{\"name\":\"yarn.lock\",\"path\":\"yarn.lock\",\"type\":\"file\",\"size\":141672},{\"name\":\"海报插件.md\",\"path\":\"海报插件.md\",\"type\":\"file\",\"size\":16696}],\"total\":33}"
61
- }
62
- }
63
- ]
64
- },
65
- {
66
- "role": "assistant",
67
- "content": [
68
- {
69
- "type": "text",
70
- "text": "<think>让我继续探索项目结构,特别是 src 目录、plugins 目录和 skills 目录。\n</think>\n\n\n"
71
- },
72
- {
73
- "type": "tool-call",
74
- "toolCallId": "call_function_z80qhykshkk7_1",
75
- "toolName": "read_directory",
76
- "input": {
77
- "path": "src"
78
- }
79
- },
80
- {
81
- "type": "tool-call",
82
- "toolCallId": "call_function_z80qhykshkk7_2",
83
- "toolName": "read_directory",
84
- "input": {
85
- "path": "plugins"
86
- }
87
- },
88
- {
89
- "type": "tool-call",
90
- "toolCallId": "call_function_z80qhykshkk7_3",
91
- "toolName": "read_directory",
92
- "input": {
93
- "path": "skills"
94
- }
95
- },
96
- {
97
- "type": "tool-call",
98
- "toolCallId": "call_function_z80qhykshkk7_4",
99
- "toolName": "read",
100
- "input": {
101
- "path": "README.md"
102
- }
103
- }
104
- ]
105
- },
106
- {
107
- "role": "tool",
108
- "content": [
109
- {
110
- "type": "tool-result",
111
- "toolCallId": "call_function_z80qhykshkk7_1",
112
- "toolName": "read_directory",
113
- "output": {
114
- "type": "text",
115
- "value": "{\"success\":true,\"dirPath\":\"src\",\"items\":[{\"name\":\"agent\",\"path\":\"src\\\\agent\",\"type\":\"directory\",\"size\":null},{\"name\":\"capabilities\",\"path\":\"src\\\\capabilities\",\"type\":\"directory\",\"size\":null},{\"name\":\"core\",\"path\":\"src\\\\core\",\"type\":\"directory\",\"size\":null},{\"name\":\"executors\",\"path\":\"src\\\\executors\",\"type\":\"directory\",\"size\":null},{\"name\":\"index.js\",\"path\":\"src\\\\index.js\",\"type\":\"file\",\"size\":502},{\"name\":\"plugins\",\"path\":\"src\\\\plugins\",\"type\":\"directory\",\"size\":null},{\"name\":\"utils\",\"path\":\"src\\\\utils\",\"type\":\"directory\",\"size\":null}],\"total\":7}"
116
- }
117
- },
118
- {
119
- "type": "tool-result",
120
- "toolCallId": "call_function_z80qhykshkk7_2",
121
- "toolName": "read_directory",
122
- "output": {
123
- "type": "text",
124
- "value": "{\"success\":true,\"dirPath\":\"plugins\",\"items\":[{\"name\":\"ai-plugin.js\",\"path\":\"plugins\\\\ai-plugin.js\",\"type\":\"file\",\"size\":2338},{\"name\":\"ambient-agent\",\"path\":\"plugins\\\\ambient-agent\",\"type\":\"directory\",\"size\":null},{\"name\":\"audit-plugin.js\",\"path\":\"plugins\\\\audit-plugin.js\",\"type\":\"file\",\"size\":4684},{\"name\":\"coordinator-plugin.js\",\"path\":\"plugins\\\\coordinator-plugin.js\",\"type\":\"file\",\"size\":8893},{\"name\":\"default-plugins.js\",\"path\":\"plugins\\\\default-plugins.js\",\"type\":\"file\",\"size\":20136},{\"name\":\"email\",\"path\":\"plugins\\\\email\",\"type\":\"directory\",\"size\":null},{\"name\":\"extension-executor-plugin.js\",\"path\":\"plugins\\\\extension-executor-plugin.js\",\"type\":\"file\",\"size\":18824},{\"name\":\"feishu-plugin.js\",\"path\":\"plugins\\\\feishu-plugin.js\",\"type\":\"file\",\"size\":16285},{\"name\":\"file-system-plugin.js\",\"path\":\"plugins\\\\file-system-plugin.js\",\"type\":\"file\",\"size\":39751},{\"name\":\"gate-trading.js\",\"path\":\"plugins\\\\gate-trading.js\",\"type\":\"file\",\"size\":30419},{\"name\":\"install-plugin.js\",\"path\":\"plugins\\\\install-plugin.js\",\"type\":\"file\",\"size\":6033},{\"name\":\"memory-plugin.js\",\"path\":\"plugins\\\\memory-plugin.js\",\"type\":\"file\",\"size\":37656},{\"name\":\"plugin-manager-plugin.js\",\"path\":\"plugins\\\\plugin-manager-plugin.js\",\"type\":\"file\",\"size\":12479},{\"name\":\"python-executor-plugin.js\",\"path\":\"plugins\\\\python-executor-plugin.js\",\"type\":\"file\",\"size\":10130},{\"name\":\"python-plugin-loader.js\",\"path\":\"plugins\\\\python-plugin-loader.js\",\"type\":\"file\",\"size\":31425},{\"name\":\"qq-plugin.js\",\"path\":\"plugins\\\\qq-plugin.js\",\"type\":\"file\",\"size\":29164},{\"name\":\"rules-plugin.js\",\"path\":\"plugins\\\\rules-plugin.js\",\"type\":\"file\",\"size\":7569},{\"name\":\"scheduler-plugin.js\",\"path\":\"plugins\\\\scheduler-plugin.js\",\"type\":\"file\",\"size\":27964},{\"name\":\"session-plugin.js\",\"path\":\"plugins\\\\session-plugin.js\",\"type\":\"file\",\"size\":14815},{\"name\":\"shell-executor-plugin.js\",\"path\":\"plugins\\\\shell-executor-plugin.js\",\"type\":\"file\",\"size\":5426},{\"name\":\"storage-plugin.js\",\"path\":\"plugins\\\\storage-plugin.js\",\"type\":\"file\",\"size\":6754},{\"name\":\"subagent-plugin.js\",\"path\":\"plugins\\\\subagent-plugin.js\",\"type\":\"file\",\"size\":23855},{\"name\":\"telegram-plugin.js\",\"path\":\"plugins\\\\telegram-plugin.js\",\"type\":\"file\",\"size\":17909},{\"name\":\"think-plugin.js\",\"path\":\"plugins\\\\think-plugin.js\",\"type\":\"file\",\"size\":16977},{\"name\":\"tools-plugin.js\",\"path\":\"plugins\\\\tools-plugin.js\",\"type\":\"file\",\"size\":7861},{\"name\":\"web-plugin.js\",\"path\":\"plugins\\\\web-plugin.js\",\"type\":\"file\",\"size\":28764},{\"name\":\"weixin-plugin.js\",\"path\":\"plugins\\\\weixin-plugin.js\",\"type\":\"file\",\"size\":28114}],\"total\":27}"
125
- }
126
- },
127
- {
128
- "type": "tool-result",
129
- "toolCallId": "call_function_z80qhykshkk7_3",
130
- "toolName": "read_directory",
131
- "output": {
132
- "type": "text",
133
- "value": "{\"success\":true,\"dirPath\":\"skills\",\"items\":[{\"name\":\"ambient-agent\",\"path\":\"skills\\\\ambient-agent\",\"type\":\"directory\",\"size\":null},{\"name\":\"find-skills\",\"path\":\"skills\\\\find-skills\",\"type\":\"directory\",\"size\":null},{\"name\":\"foliko-dev\",\"path\":\"skills\\\\foliko-dev\",\"type\":\"directory\",\"size\":null},{\"name\":\"mcp-usage\",\"path\":\"skills\\\\mcp-usage\",\"type\":\"directory\",\"size\":null},{\"name\":\"plugin-guide\",\"path\":\"skills\\\\plugin-guide\",\"type\":\"directory\",\"size\":null},{\"name\":\"poster-guide\",\"path\":\"skills\\\\poster-guide\",\"type\":\"directory\",\"size\":null},{\"name\":\"python-plugin-dev\",\"path\":\"skills\\\\python-plugin-dev\",\"type\":\"directory\",\"size\":null},{\"name\":\"skill-guide\",\"path\":\"skills\\\\skill-guide\",\"type\":\"directory\",\"size\":null},{\"name\":\"subagent-guide\",\"path\":\"skills\\\\subagent-guide\",\"type\":\"directory\",\"size\":null},{\"name\":\"workflow-guide\",\"path\":\"skills\\\\workflow-guide\",\"type\":\"directory\",\"size\":null},{\"name\":\"workflow-troubleshooting\",\"path\":\"skills\\\\workflow-troubleshooting\",\"type\":\"directory\",\"size\":null}],\"total\":11}"
134
- }
135
- },
136
- {
137
- "type": "tool-result",
138
- "toolCallId": "call_function_z80qhykshkk7_4",
139
- "toolName": "read",
140
- "output": {
141
- "type": "text",
142
- "value": "{\"success\":true,\"filePath\":\"D:\\\\Code\\\\foliko\\\\README.md\",\"content\":\"# Foliko\\n\\n简约的插件化 Agent 框架\\n\\n## 特性\\n\\n- **插件化架构** - 核心简单,通过插件扩展功能\\n- **流式输出** - 支持实时流式输出\\n- **多 AI 支持** - 支持 Anthropic、DeepSeek、MiniMax 等\\n- **内置工具** - Shell、Python、MCP、文件系统等\\n- **技能系统** - 可扩展的 Skill 管理\\n- **会话管理** - 支持多会话切换\\n- **规则引擎** - 可配置的行为规则\\n- **子 Agent** - 支持多子 Agent 分工协作\\n- **Ambient Agent** - 持续后台运行,监控事件主动执行\\n- **统一通知** - 微信、飞书、Telegram 消息推送\\n\\n## 安装\\n\\n```bash\\n# 方式一:npm 安装\\nnpm install -g foliko\\n\\n# 方式二:Windows 一键脚本安装\\nirm https://folikoai.com/install.ps1 | iex\\n\\n# 方式三:Mac/Linux 一键脚本安装\\ncurl -fsSL https://folikoai.com/install.sh | bash\\n```\\n\\n## 快速开始\\n\\n```bash\\n# 全局安装后\\nfoliko chat\\n```\\n\\n## CLI 命令\\n\\n```bash\\n# 聊天模式(使用 .env 中的配置)\\nfoliko chat\\n\\n# 指定完整配置\\nfoliko chat --provider deepseek --model deepseek-chat --base-url https://api.deepseek.com/v1 --api-key sk-xxx\\n\\n# 只指定 provider(使用 provider 默认 model 和 baseURL)\\nfoliko chat --provider deepseek --api-key sk-xxx\\n\\n# 列出所有子Agent配置\\nfoliko list\\n```\\n\\n### 聊天内命令\\n\\n在 `foliko chat` 的对话界面中,可以直接输入自然语言来控制框架:\\n\\n**插件管理**\\n\\n```\\n开启微信插件\\n开启飞书插件\\n开启telegram插件\\n关闭微信插件\\n列出所有插件\\n重载所有插件\\n```\\n\\n**定时任务**\\n\\n```\\n10分钟后提醒我喝水\\n每天早上9点提醒我查看邮件\\n设置一个定时任务:2小时后提醒我开会\\n列出所有定时任务\\n取消定时任务\\n```\\n\\n**会话管理**\\n\\n```\\n创建一个新会话\\n列出所有会话\\n删除某个会话\\n获取会话历史\\n```\\n\\n**Ambient Agent**\\n\\n```\\n查看 Ambient Agent 状态\\n创建一个目标:监控新邮件\\n暂停 Ambient Agent\\n恢复 Ambient Agent\\n存储记忆:用户喜欢在早上处理邮件\\n检索记忆\\n```\\n\\n**子 Agent**\\n\\n```\\n列出所有子Agent\\n调用 backend-specialist 处理任务\\n重新加载子Agent配置\\n```\\n\\n**系统操作**\\n\\n```\\n执行 shell 命令:ls -la\\n安装 npm 包:lodash\\n执行 Python 代码\\n查看审计日志\\n清除当前会话历史\\n```\\n\\n这些命令会通过 Agent 调用相应的工具来执行。\\n\\n```\\nfoliko/\\n├── cli/ # 命令行入口\\n│ └── bin/foliko.js # CLI 入口\\n├── src/ # 核心框架\\n│ ├── core/ # 核心组件\\n│ ├── capabilities/ # 能力插件\\n│ └── executors/ # 执行器\\n├── plugins/ # 内置插件\\n├── skills/ # 技能目录\\n└── examples/ # 示例\\n```\\n\\n## 配置\\n\\n### 环境变量配置 (.env)\\n\\n在项目根目录创建 `.env` 文件:\\n\\n```bash\\n# ========== AI Configuration ==========\\n# AI Provider: minimax, deepseek, openai, anthropic 等\\nFOLIKO_PROVIDER=minimax\\n\\n# AI Model(如果未设置,使用 provider 默认值)\\n# MiniMax: MiniMax-M2.7\\n# DeepSeek: deepseek-chat, deepseek-coder 等\\nFOLIKO_MODEL=MiniMax-M2.7\\n\\n# API Base URL(如果未设置,使用 provider 默认值)\\n# MiniMax: https://api.minimaxi.com/v1\\n# DeepSeek: https://api.deepseek.com/v1\\nFOLIKO_BASE_URL=https://api.minimaxi.com/v1\\n\\n# API Key(通用,如果未设置则尝试 provider 专用 key)\\nFOLIKO_API_KEY=sk-your-api-key\\n\\n# Provider 专用 API Key(可选,如果 FOLIKO_API_KEY 未设置则使用这些)\\nDEEPSEEK_API_KEY=sk-your-deepseek-api-key\\nMINIMAX_API_KEY=sk-your-minimax-api-key\\n\\n# ========== Email Configuration ==========\\n# SMTP Settings (for sending emails)\\nSMTP_HOST=smtp.gmail.com\\nSMTP_PORT=587\\nSMTP_SECURE=false\\nSMTP_USER=your-email@gmail.com\\nSMTP_PASS=your-app-password\\n\\n# IMAP Settings (for reading emails)\\nIMAP_HOST=imap.gmail.com\\nIMAP_PORT=993\\nIMAP_USER=your-email@gmail.com\\nIMAP_PASS=your-app-password\\n\\n# Default sender email address\\nFROM_EMAIL=your-email@gmail.com\\n\\n# ========== Telegram Bot (optional) ==========\\nTELEGRAM_BOT_TOKEN=your-telegram-bot-token\\n\\n# ========== Feishu Bot (optional) ==========\\nFEISHU_APP_ID=cli_xxxxxxxxxxx\\nFEISHU_APP_SECRET=app_secret\\n\\n# ========== Web Server (optional) ==========\\n# Web 服务端口,默认 8088\\nWEB_PORT=3000\\n\\n# Web 服务主机,默认 127.0.0.1\\nWEB_HOST=127.0.0.1\\n\\n# 公网访问的 base URL(用于生成 webhook URL 等),不设置则使用 host:port,最好部署在docker中可以暴露自定义域名\\nWEB_BASE_URL=https://your-domain.com\\n\\n```\\n\\n**配置优先级**:命令行参数 > .env配置 > provider默认值\\n\\n### .agent 目录结构\\n\\n```\\n.agent/\\n├── config # 配置文件\\n├── ai.json # AI 配置\\n├── mcp_config.json # MCP 服务器配置\\n├── agents/ # 子Agent配置目录\\n├── plugins/ # 用户插件目录\\n├── skills/ # 用户技能目录\\n└── data/ # 数据目录\\n```\\n\\n### 子 Agent 配置 (.agent/agents/)\\n\\n在 `.agent/agents/` 目录下放置子 Agent 配置文件,支持 `.js`、`.json`、`.md` 格式:\\n\\n```\\n.agent/agents/\\n├── backend-specialist.md\\n├── frontend-specialist.md\\n└── database-architect.md\\n```\\n\\n#### JSON 格式\\n\\n```json\\n{\\n \\\"name\\\": \\\"backend-specialist\\\",\\n \\\"role\\\": \\\"Backend Specialist\\\",\\n \\\"description\\\": \\\"Expert in backend development\\\",\\n \\\"parentTools\\\": [\\\"read_file\\\", \\\"run_command\\\"]\\n}\\n```\\n\\n#### Markdown 格式\\n\\n````markdown\\n# Backend Specialist\\n\\n```json\\n{\\n \\\"name\\\": \\\"backend-specialist\\\",\\n \\\"role\\\": \\\"Backend Specialist\\\",\\n \\\"description\\\": \\\"Expert in backend development\\\",\\n \\\"parentTools\\\": [\\\"read_file\\\", \\\"run_command\\\"]\\n}\\n```\\n````\\n\\n````\\n\\n### ai.json 格式\\n\\n```json\\n{\\n \\\"provider\\\": \\\"minimax\\\",\\n \\\"model\\\": \\\"MiniMax-M2.7\\\",\\n \\\"apiKey\\\": \\\"your-api-key\\\",\\n \\\"baseURL\\\": \\\"https://api.minimaxi.com/v1\\\"\\n}\\n````\\n\\n### mcp_config.json 格式\\n\\n```json\\n{\\n \\\"mcpServers\\\": {\\n \\\"fetch\\\": {\\n \\\"command\\\": \\\"npx\\\",\\n \\\"args\\\": [\\\"-y\\\", \\\"@modelcontextprotocol/server-fetch\\\"]\\n }\\n }\\n}\\n```\\n\\n## 开发插件\\n\\n### 用户插件(.agent/plugins/)\\n\\n插件支持两种结构:**文件夹结构**(推荐)和**单文件结构**。\\n\\n#### 文件夹结构(推荐)\\n\\n```\\n.agent/plugins/my-plugin/\\n├── package.json # 可选,main 字段指定入口\\n├── index.js # 默认入口\\n└── node_modules/ # 可选,插件私有依赖\\n```\\n\\n```json\\n// package.json 示例\\n{\\n \\\"name\\\": \\\"my-plugin\\\",\\n \\\"main\\\": \\\"index.js\\\"\\n}\\n```\\n\\n```javascript\\n// .agent/plugins/my-plugin/index.js\\nmodule.exports = function (Plugin) {\\n return class MyPlugin extends Plugin {\\n constructor(config = {}) {\\n super();\\n this.name = 'my-plugin';\\n this.version = '1.0.0';\\n this.description = '我的工具插件';\\n this.priority = 10;\\n }\\n\\n install(framework) {\\n const { z } = require('zod');\\n framework.registerTool({\\n name: 'my_tool',\\n description: '我的工具',\\n inputSchema: z.object({\\n param: z.string().describe('参数描述'),\\n }),\\n execute: async (args, framework) => {\\n return { success: true, result: args.param };\\n },\\n });\\n return this;\\n }\\n };\\n};\\n```\\n\\n#### 单文件结构(兼容)\\n\\n```\\n.agent/plugins/my-plugin.js\\n```\\n\\n如果同时存在文件夹和同名 `.js` 文件,**文件夹优先**。\\n\\n**注意**:如果插件需要第三方库(如 `zod`),需要先安装:\\n\\n1. 创建插件文件/文件夹\\n2. 调用 `install` 工具安装依赖\\n3. 热重载插件\\n\\n### 技能开发\\n\\n在 `.agent/skills/` 下创建技能:\\n\\n```\\n.agent/skills/my-skill/\\n└── SKILL.md\\n```\\n\\nSKILL.md 格式:\\n\\n```markdown\\n---\\nname: my-skill\\ndescription: 技能描述\\nallowed-tools: tool1,tool2\\n---\\n\\n技能内容...\\n```\\n\\n## 内置工具\\n\\n### 通用工具\\n\\n| 工具 | 说明 |\\n| ---------------- | -------------------- |\\n| `loadSkill` | 加载技能 |\\n| `list_plugins` | 列出所有插件 |\\n| `list_tools` | 列出所有工具 |\\n| `reload_plugins` | 重载插件 |\\n| `shell` | 执行 Shell 命令 |\\n| `powershell` | 执行 PowerShell 命令 |\\n| `python-execute` | 执行 Python 代码 |\\n| `python_script` | 执行 Python 脚本 |\\n| `pip_install` | 安装 Python 包 |\\n| `install` | 安装 npm 包 |\\n| `mcp_reload` | 重载 MCP 服务器 |\\n| `audit_query` | 查询审计日志 |\\n\\n### 子 Agent 管理工具\\n\\n| 工具 | 说明 |\\n| ----------------- | ------------------------- |\\n| `subagent_list` | 列出所有子Agent |\\n| `subagent_call` | 调用指定的子Agent处理任务 |\\n| `subagent_reload` | 重新加载子Agent配置 |\\n\\n### 会话工具\\n\\n| 工具 | 说明 |\\n| ----------------- | ------------ |\\n| `session_create` | 创建会话 |\\n| `session_get` | 获取会话 |\\n| `session_list` | 列出所有会话 |\\n| `session_delete` | 删除会话 |\\n| `session_history` | 获取会话历史 |\\n\\n### 定时任务工具\\n\\n| 工具 | 说明 |\\n| ----------------- | -------------- |\\n| `schedule_task` | 创建定时任务 |\\n| `schedule_list` | 列出定时任务 |\\n| `schedule_cancel` | 取消定时任务 |\\n| `cron_examples` | 显示 cron 示例 |\\n\\n### Ambient Agent 工具\\n\\n| 工具 | 说明 |\\n| ------------------ | ------------------------------------ |\\n| `ambient_goals` | 管理目标(列出/创建/更新/删除/激活) |\\n| `ambient_status` | 获取 Ambient Agent 状态 |\\n| `ambient_think` | 触发主动思考 |\\n| `ambient_remember` | 存储/检索记忆 |\\n| `ambient_control` | 控制循环(暂停/恢复/调整) |\\n\\n### 通知事件\\n\\n消息插件(微信、飞书、Telegram)监听 `notification` 事件推送通知给用户:\\n\\n```javascript\\n{\\n title: '目标完成',\\n message: '目标 \\\"xxx\\\" 已完成',\\n source: 'scheduler', // 来源\\n level: 'success', // info | warning | success | error\\n sessionId: 'weixin_xxx'\\n}\\n```\\n\\n## 工作目录\\n\\nCLI 工作目录默认使用执行命令的目录。\\n\\n- `.agent/` 目录会创建在工作目录下\\n- 配置文件、插件、技能等都放在工作目录的 `.agent/` 下\\n\\n## 许可证\\n\\nMIT\\n\",\"size\":10427,\"lines\":442}"
143
- }
144
- }
145
- ]
146
- },
147
- {
148
- "role": "assistant",
149
- "content": [
150
- {
151
- "type": "text",
152
- "text": "<think>用户想了解这个项目。让我继续探索关键目录以获取更全面的信息。\n</think>\n\n\n"
153
- },
154
- {
155
- "type": "tool-call",
156
- "toolCallId": "call_function_ivr82cv57a3u_1",
157
- "toolName": "read_directory",
158
- "input": {
159
- "path": "src/core"
160
- }
161
- },
162
- {
163
- "type": "tool-call",
164
- "toolCallId": "call_function_ivr82cv57a3u_2",
165
- "toolName": "read_directory",
166
- "input": {
167
- "path": "src/agent"
168
- }
169
- },
170
- {
171
- "type": "tool-call",
172
- "toolCallId": "call_function_ivr82cv57a3u_3",
173
- "toolName": "read_directory",
174
- "input": {
175
- "path": "examples"
176
- }
177
- },
178
- {
179
- "type": "tool-call",
180
- "toolCallId": "call_function_ivr82cv57a3u_4",
181
- "toolName": "read",
182
- "input": {
183
- "path": "SPEC.md",
184
- "lines": 100
185
- }
186
- }
187
- ]
188
- },
189
- {
190
- "role": "tool",
191
- "content": [
192
- {
193
- "type": "tool-result",
194
- "toolCallId": "call_function_ivr82cv57a3u_1",
195
- "toolName": "read_directory",
196
- "output": {
197
- "type": "text",
198
- "value": "{\"success\":true,\"dirPath\":\"src/core\",\"items\":[{\"name\":\"agent-chat.js\",\"path\":\"src\\\\core\\\\agent-chat.js\",\"type\":\"file\",\"size\":30836},{\"name\":\"agent.js\",\"path\":\"src\\\\core\\\\agent.js\",\"type\":\"file\",\"size\":20768},{\"name\":\"chat-session.js\",\"path\":\"src\\\\core\\\\chat-session.js\",\"type\":\"file\",\"size\":13838},{\"name\":\"context-compressor.js\",\"path\":\"src\\\\core\\\\context-compressor.js\",\"type\":\"file\",\"size\":16635},{\"name\":\"context-manager.js\",\"path\":\"src\\\\core\\\\context-manager.js\",\"type\":\"file\",\"size\":3598},{\"name\":\"coordinator-manager.js\",\"path\":\"src\\\\core\\\\coordinator-manager.js\",\"type\":\"file\",\"size\":9741},{\"name\":\"framework.js\",\"path\":\"src\\\\core\\\\framework.js\",\"type\":\"file\",\"size\":29153},{\"name\":\"index.js\",\"path\":\"src\\\\core\\\\index.js\",\"type\":\"file\",\"size\":840},{\"name\":\"notification-manager.js\",\"path\":\"src\\\\core\\\\notification-manager.js\",\"type\":\"file\",\"size\":3607},{\"name\":\"plugin-base.js\",\"path\":\"src\\\\core\\\\plugin-base.js\",\"type\":\"file\",\"size\":9520},{\"name\":\"plugin-manager.js\",\"path\":\"src\\\\core\\\\plugin-manager.js\",\"type\":\"file\",\"size\":28608},{\"name\":\"provider.js\",\"path\":\"src\\\\core\\\\provider.js\",\"type\":\"file\",\"size\":3589},{\"name\":\"request-context.js\",\"path\":\"src\\\\core\\\\request-context.js\",\"type\":\"file\",\"size\":2411},{\"name\":\"session-context.js\",\"path\":\"src\\\\core\\\\session-context.js\",\"type\":\"file\",\"size\":8179},{\"name\":\"session-storage.js\",\"path\":\"src\\\\core\\\\session-storage.js\",\"type\":\"file\",\"size\":7018},{\"name\":\"sub-agent-config.js\",\"path\":\"src\\\\core\\\\sub-agent-config.js\",\"type\":\"file\",\"size\":5748},{\"name\":\"subagent.js\",\"path\":\"src\\\\core\\\\subagent.js\",\"type\":\"file\",\"size\":18271},{\"name\":\"system-prompt-builder.js\",\"path\":\"src\\\\core\\\\system-prompt-builder.js\",\"type\":\"file\",\"size\":2560},{\"name\":\"token-counter.js\",\"path\":\"src\\\\core\\\\token-counter.js\",\"type\":\"file\",\"size\":5031},{\"name\":\"tool-executor.js\",\"path\":\"src\\\\core\\\\tool-executor.js\",\"type\":\"file\",\"size\":7113},{\"name\":\"tool-registry.js\",\"path\":\"src\\\\core\\\\tool-registry.js\",\"type\":\"file\",\"size\":15147},{\"name\":\"tool-router.js\",\"path\":\"src\\\\core\\\\tool-router.js\",\"type\":\"file\",\"size\":6334},{\"name\":\"worker-agent.js\",\"path\":\"src\\\\core\\\\worker-agent.js\",\"type\":\"file\",\"size\":5351}],\"total\":23}"
199
- }
200
- },
201
- {
202
- "type": "tool-result",
203
- "toolCallId": "call_function_ivr82cv57a3u_2",
204
- "toolName": "read_directory",
205
- "output": {
206
- "type": "text",
207
- "value": "{\"success\":true,\"dirPath\":\"src/agent\",\"items\":[],\"total\":0}"
208
- }
209
- },
210
- {
211
- "type": "tool-result",
212
- "toolCallId": "call_function_ivr82cv57a3u_3",
213
- "toolName": "read_directory",
214
- "output": {
215
- "type": "text",
216
- "value": "{\"success\":true,\"dirPath\":\"examples\",\"items\":[{\"name\":\"ambient-example.js\",\"path\":\"examples\\\\ambient-example.js\",\"type\":\"file\",\"size\":6861},{\"name\":\"basic.js\",\"path\":\"examples\\\\basic.js\",\"type\":\"file\",\"size\":3018},{\"name\":\"bootstrap.js\",\"path\":\"examples\\\\bootstrap.js\",\"type\":\"file\",\"size\":3660},{\"name\":\"mcp-example.js\",\"path\":\"examples\\\\mcp-example.js\",\"type\":\"file\",\"size\":1346},{\"name\":\"skill-example.js\",\"path\":\"examples\\\\skill-example.js\",\"type\":\"file\",\"size\":1323},{\"name\":\"test-chat.js\",\"path\":\"examples\\\\test-chat.js\",\"type\":\"file\",\"size\":3790},{\"name\":\"test-concurrent-chat.js\",\"path\":\"examples\\\\test-concurrent-chat.js\",\"type\":\"file\",\"size\":1772},{\"name\":\"test-long-chat.js\",\"path\":\"examples\\\\test-long-chat.js\",\"type\":\"file\",\"size\":2651},{\"name\":\"test-mcp.js\",\"path\":\"examples\\\\test-mcp.js\",\"type\":\"file\",\"size\":2443},{\"name\":\"test-reload.js\",\"path\":\"examples\\\\test-reload.js\",\"type\":\"file\",\"size\":1609},{\"name\":\"test-session-chat.js\",\"path\":\"examples\\\\test-session-chat.js\",\"type\":\"file\",\"size\":2716},{\"name\":\"test-telegram.js\",\"path\":\"examples\\\\test-telegram.js\",\"type\":\"file\",\"size\":1515},{\"name\":\"test-tg-bot.js\",\"path\":\"examples\\\\test-tg-bot.js\",\"type\":\"file\",\"size\":1495},{\"name\":\"test-tg-simple.js\",\"path\":\"examples\\\\test-tg-simple.js\",\"type\":\"file\",\"size\":1269},{\"name\":\"test-tg.js\",\"path\":\"examples\\\\test-tg.js\",\"type\":\"file\",\"size\":1873},{\"name\":\"test-think.js\",\"path\":\"examples\\\\test-think.js\",\"type\":\"file\",\"size\":1274},{\"name\":\"test-web-plugin.js\",\"path\":\"examples\\\\test-web-plugin.js\",\"type\":\"file\",\"size\":3148},{\"name\":\"test-weixin-feishu.js\",\"path\":\"examples\\\\test-weixin-feishu.js\",\"type\":\"file\",\"size\":2768},{\"name\":\"workflow.js\",\"path\":\"examples\\\\workflow.js\",\"type\":\"file\",\"size\":3789}],\"total\":19}"
217
- }
218
- },
219
- {
220
- "type": "tool-result",
221
- "toolCallId": "call_function_ivr82cv57a3u_4",
222
- "toolName": "read",
223
- "output": {
224
- "type": "text",
225
- "value": "{\"success\":true,\"filePath\":\"D:\\\\Code\\\\foliko\\\\SPEC.md\",\"content\":\"# Foliko Framework 规划文档\\n\\n## 一、设计目标\\n\\n1. **纯 JS 实现** - 无 TypeScript,简明易懂\\n2. **架构简约** - 核心仅包含必要组件,通过插件扩展功能\\n3. **插件系统与 Agent 分离** - Agent 专注于对话推理,插件提供扩展能力\\n4. **手动热重载** - 不监测文件变化,通过 API 手动调用重载\\n\\n## 二、核心架构\\n\\n```\\n┌─────────────────────────────────────────────────┐\\n│ Foliko Framework │\\n├─────────────────────────────────────────────────┤\\n│ Framework (容器层) │\\n│ ├── pluginManager - 插件加载/卸载/重载 │\\n│ ├── toolRegistry - 工具注册表 │\\n│ ├── skillManager - Skill管理 (可选) │\\n│ └── eventEmitter - 事件总线 │\\n├─────────────────────────────────────────────────┤\\n│ Agent (对话层) │\\n│ ├── chat() - 对话接口 │\\n│ ├── tools - 从 Framework 获取 │\\n│ └── events - 事件监听 │\\n└─────────────────────────────────────────────────┘\\n```\\n\\n### 2.1 Framework 类\\n\\n```javascript\\nclass Framework {\\n constructor(config = {})\\n registerPlugin(plugin) // 注册插件\\n loadPlugin(pluginDef) // 加载插件\\n unloadPlugin(name) // 卸载插件\\n reloadPlugin(name) // 重载单个插件\\n reloadAllPlugins() // 重载所有插件\\n registerTool(tool) // 注册工具\\n getTools() // 获取所有工具\\n on(event, handler) // 监听事件\\n emit(event, data) // 触发事件\\n ready() // 等待初始化完成\\n}\\n```\\n\\n### 2.2 Agent 类\\n\\n```javascript\\n// 创建 Agent\\nconst agent = framework.createAgent({\\n name: 'MyAgent', // Agent 名称\\n systemPrompt: '你是一个助手', // 系统提示\\n\\n // 共享提示模板 (支持 {{VAR}} 占位符)\\n sharedPrompt: `工作目录: {{WORK_DIR}}`,\\n\\n // 元数据 (供 sharedPrompt 和自身使用)\\n metadata: {\\n projectName: 'MyProject',\\n version: '1.0.0',\\n },\\n});\\n\\n// 运行时元数据操作\\nagent.setMetadata('task', '数据分析'); // 设置单个\\nagent.setMetadata({ key: 'value' }); // 批量设置\\nagent.getMetadata('task'); // 获取\\nagent.deleteMetadata('task'); // 删除\\nagent.clearMetadata(); // 清空\\n```\\n\\n**内置占位符:**\\n| 占位符 | 说明 |\\n|--------|------|\\n| `{{WORK_DIR}}` | 工作目录 |\\n| `{{HOME_DIR}}` | 主目录 |\\n| `{{HOST_NAME}}` | 主机名 |\\n| `{{PLATFORM}}` | 平台 |\\n| `{{TIME}}` | 当前时间 |\\n| `{{DATE}}` | 当前日期 |\\n\\n**Agent 方法:**\\n\\n```javascript\\nclass Agent {\\n constructor(framework, config) // 创建 Agent\\n chat(message, options) // 发送消息\\n chatStream(message, options) // 流式发送消息\\n setSystemPrompt(prompt) // 设置系统提示\\n registerTool(tool) // 注册工具\\n getTools() // 获取工具列表\\n clearHistory() // 清空对话历史\\n getStatus() // 获取状态\\n destroy() // 销毁 Agent\\n\\n // 元数据管理\\n setMetadata(key, value) // 设置元数据\\n getMetadata(key) // 获取元数据\\n deleteMetadata(key) // 删除元数据\",\"size\":22808,\"lines\":null}"
226
- }
227
- }
228
- ]
229
- },
230
- {
231
- "role": "assistant",
232
- "content": [
233
- {
234
- "type": "text",
235
- "text": "<think>我已经收集了足够的信息来给用户介绍这个项目。让我整理一下关键信息。\n</think>\n\n## Foliko 项目概览\n\n**Foliko** 是一个简约的插件化 Agent 框架,用纯 JavaScript 实现(无 TypeScript)。\n\n---\n\n### 📁 项目结构\n\n```\nfoliko/\n├── src/ # 核心框架\n│ └── core/ # 核心组件\n│ ├── framework.js # 容器层,插件/工具管理\n│ ├── agent.js # Agent 对话层\n│ ├── plugin-manager.js\n│ ├── tool-registry.js\n│ └── ...\n├── plugins/ # 27 个内置插件\n│ ├── ai-plugin.js\n│ ├── memory-plugin.js\n│ ├── scheduler-plugin.js\n│ ├── web-plugin.js\n│ ├── weixin-plugin.js\n│ ├── feishu-plugin.js\n│ ├── telegram-plugin.js\n│ └── ...\n├── skills/ # 11 个内置技能\n│ ├── subagent-guide/\n│ ├── plugin-guide/\n│ ├── poster-guide/\n│ └── ...\n├── cli/ # 命令行入口\n├── examples/ # 19 个示例\n└── docs/ # 文档\n```\n\n---\n\n### 🔌 核心特性\n\n| 特性 | 说明 |\n|------|------|\n| **插件化架构** | 核心简单,通过插件扩展功能 |\n| **流式输出** | 支持实时流式输出 |\n| **多 AI 支持** | 支持 Anthropic、DeepSeek、MiniMax 等 |\n| **内置工具** | Shell、Python、MCP、文件系统等 |\n| **技能系统** | 可扩展的 Skill 管理 |\n| **会话管理** | 支持多会话切换 |\n| **规则引擎** | 可配置的行为规则 |\n| **子 Agent** | 支持多子 Agent 分工协作 |\n| **Ambient Agent** | 持续后台运行,监控事件主动执行 |\n| **统一通知** | 微信、飞书、Telegram 消息推送 |\n\n---\n\n### 🛠 内置插件(27个)\n\n- **AI & 执行**: `ai-plugin`, `shell-executor`, `python-executor`, `install-plugin`\n- **数据管理**: `memory-plugin`, `storage-plugin`, `session-plugin`, `audit-plugin`\n- **自动化**: `scheduler-plugin`, `think-plugin`, `rules-plugin`\n- **网络服务**: `web-plugin`, `plugin-manager`\n- **消息推送**: `weixin-plugin`, `feishu-plugin`, `telegram-plugin`, `email`\n- **业务集成**: `qq-plugin`, `gate-trading`\n- **高级**: `coordinator-plugin`, `ambient-agent`, `subagent-plugin`, `extension-executor`\n\n---\n\n### 🎯 设计原则\n\n1. **纯 JS 实现** - 无 TypeScript,简明易懂\n2. **架构简约** - 核心仅包含必要组件\n3. **插件与 Agent 分离** - Agent 专注对话推理,插件提供扩展\n4. **手动热重载** - 通过 API 手动调用,不监测文件变化\n\n---\n\n想深入了解哪个部分?比如:\n- 插件开发指南\n- 核心源码解析\n- 某个具体插件的实现"
236
- }
237
- ]
238
- }
239
- ],
240
- "variables": {},
241
- "metadata": {
242
- "createdAt": 1779713894381,
243
- "lastActive": 1779713894381,
244
- "messageCount": 0,
245
- "compressionCount": 0
246
- }
247
- }
@@ -1,311 +0,0 @@
1
- ---
2
- name: agent-browser
3
- description: 浏览器自动化工具,用于 AI 代理的网页操作。当用户说"打开浏览器"、"访问网页"、"抓取页面"、"填写表单"、"点击按钮"、"截图"、"网页自动化"时调用此技能。
4
- allowed-tools:
5
- - shell
6
- - execute_command
7
- - read_file
8
- - write_file
9
- license: Apache-2.0
10
- compatibility: v1.0.0
11
- ---
12
-
13
- # Agent Browser - 浏览器自动化技能
14
-
15
- ## 概述
16
-
17
- `agent-browser` 是 Vercel Labs 开发的浏览器自动化 CLI 工具,专为 AI 代理设计。基于 Chrome/Playwright,支持完整的网页交互功能。
18
-
19
- **官方文档**: https://agent-browser.dev
20
- **GitHub**: https://github.com/vercel-labs/agent-browser
21
-
22
- ## 安装
23
-
24
- ```bash
25
- # 全局安装(推荐)
26
- npm install -g agent-browser
27
- agent-browser install # 首次下载 Chrome
28
-
29
- # 或使用 npx(无需安装)
30
- npx agent-browser install
31
- ```
32
-
33
- ## 核心工作流程
34
-
35
- ### 1. 打开网页
36
- ```bash
37
- agent-browser open <url>
38
- # 示例
39
- agent-browser open https://example.com
40
- ```
41
-
42
- ### 2. 获取页面快照(AI 推荐)
43
- ```bash
44
- # 获取可访问性树和元素引用
45
- agent-browser snapshot -i
46
-
47
- # 输出示例:
48
- # - heading "Example Domain" [ref=e1] [level=1]
49
- # - button "Submit" [ref=e2]
50
- # - textbox "Email" [ref=e3]
51
- # - link "Learn more" [ref=e4]
52
- ```
53
-
54
- ### 3. 使用引用交互
55
- ```bash
56
- agent-browser click @e2 # 点击按钮
57
- agent-browser fill @e3 "test@example.com" # 填写输入框
58
- agent-browser get text @e1 # 获取文本
59
- agent-browser hover @e4 # 悬停链接
60
- ```
61
-
62
- ### 4. 截图
63
- ```bash
64
- agent-browser screenshot page.png # 保存截图
65
- agent-browser screenshot --full # 全页面截图
66
- agent-browser screenshot --annotate # 带编号标签的截图
67
- ```
68
-
69
- ### 5. 关闭浏览器
70
- ```bash
71
- agent-browser close
72
- ```
73
-
74
- ## 常用命令
75
-
76
- ### 页面导航
77
- ```bash
78
- agent-browser open <url> # 打开 URL
79
- agent-browser back # 后退
80
- agent-browser forward # 前进
81
- agent-browser reload # 刷新
82
- ```
83
-
84
- ### 元素交互
85
- ```bash
86
- agent-browser click <sel> # 点击元素
87
- agent-browser dblclick <sel> # 双击
88
- agent-browser hover <sel> # 悬停
89
- agent-browser focus <sel> # 聚焦
90
- agent-browser fill <sel> <text> # 清空并填写
91
- agent-browser type <sel> <text> # 追加输入
92
- agent-browser press <key> # 按键(Enter, Tab, Control+a)
93
- agent-browser select <sel> <value> # 下拉选择
94
- agent-browser check <sel> # 勾选
95
- agent-browser scroll <dir> [px] # 滚动(up/down/left/right)
96
- ```
97
-
98
- ### 获取信息
99
- ```bash
100
- agent-browser get text <sel> # 获取文本
101
- agent-browser get html <sel> # 获取 HTML
102
- agent-browser get value <sel> # 获取输入值
103
- agent-browser get attr <sel> <attr> # 获取属性
104
- agent-browser get title # 获取标题
105
- agent-browser get url # 获取 URL
106
- agent-browser get count <sel> # 计数元素
107
- ```
108
-
109
- ### 状态检查
110
- ```bash
111
- agent-browser is visible <sel> # 是否可见
112
- agent-browser is enabled <sel> # 是否可用
113
- agent-browser is checked <sel> # 是否勾选
114
- ```
115
-
116
- ### 语义定位器(AI 推荐)
117
- ```bash
118
- # 按 ARIA 角色查找
119
- agent-browser find role button click --name "Submit"
120
- agent-browser find role link text --name "More"
121
-
122
- # 按文本查找
123
- agent-browser find text "Sign In" click
124
-
125
- # 按标签查找
126
- agent-browser find label "Email" fill "test@test.com"
127
-
128
- # 按占位符查找
129
- agent-browser find placeholder "Search..." fill "query"
130
-
131
- # 按 testid 查找
132
- agent-browser find testid "submit-btn" click
133
-
134
- # 位置选择
135
- agent-browser find first ".item" click
136
- agent-browser find last "a" click
137
- agent-browser find nth 2 "a" text
138
- ```
139
-
140
- ### 等待
141
- ```bash
142
- agent-browser wait <selector> # 等待元素可见
143
- agent-browser wait <ms> # 等待毫秒
144
- agent-browser wait --text "Welcome" # 等待文本出现
145
- agent-browser wait --url "**/dash" # 等待 URL 匹配
146
- agent-browser wait --load networkidle # 等待网络空闲
147
- ```
148
-
149
- ### 网络拦截
150
- ```bash
151
- agent-browser network route <url> --abort # 阻止请求
152
- agent-browser network route <url> --body '<json>' # Mock 响应
153
- agent-browser network requests # 查看请求
154
- ```
155
-
156
- ### 键盘操作
157
- ```bash
158
- agent-browser keyboard type "Hello" # 键盘输入
159
- agent-browser keyboard inserttext "text" # 直接插入文本
160
- agent-browser keydown <key> # 按键按下
161
- agent-browser keyup <key> # 按键释放
162
- ```
163
-
164
- ### 鼠标操作
165
- ```bash
166
- agent-browser mouse move <x> <y> # 移动鼠标
167
- agent-browser mouse down [button] # 鼠标按下
168
- agent-browser mouse up [button] # 鼠标释放
169
- agent-browser mouse wheel <dy> [dx] # 滚轮滚动
170
- ```
171
-
172
- ### 剪贴板
173
- ```bash
174
- agent-browser clipboard read # 读取
175
- agent-browser clipboard write "Hello" # 写入
176
- ```
177
-
178
- ## 选择器类型
179
-
180
- ### 引用(推荐用于 AI)
181
- ```
182
- @e1, @e2, @e3 # 来自 snapshot 的元素引用
183
- ```
184
-
185
- ### CSS 选择器
186
- ```bash
187
- agent-browser click "#submit"
188
- agent-browser click ".class-name"
189
- agent-browser click "div > button"
190
- ```
191
-
192
- ### 文本和 XPath
193
- ```bash
194
- agent-browser click "text=Submit"
195
- agent-browser click "xpath=//button"
196
- ```
197
-
198
- ## 会话管理
199
-
200
- ```bash
201
- # 多会话隔离
202
- agent-browser --session session1 open site-a.com
203
- agent-browser --session session2 open site-b.com
204
-
205
- # 持久化配置
206
- agent-browser --profile ~/.myapp-profile open myapp.com
207
-
208
- # 自动保存/恢复状态
209
- agent-browser --session-name myapp open twitter.com
210
- ```
211
-
212
- ## 认证管理
213
-
214
- ```bash
215
- # 从已有 Chrome 导入认证状态
216
- agent-browser --auto-connect state save ./auth.json
217
- agent-browser --state ./auth.json open app.com
218
-
219
- # 或者用 session-name 自动持久化
220
- agent-browser --session-name myapp state load ./auth.json
221
- ```
222
-
223
- ## 调试功能
224
-
225
- ```bash
226
- agent-browser --headed # 显示浏览器窗口
227
- agent-browser console # 查看控制台消息
228
- agent-browser errors # 查看页面错误
229
- agent-browser highlight <sel> # 高亮元素
230
- agent-browser inspect # 打开 DevTools
231
- ```
232
-
233
- ## 选项
234
-
235
- | 选项 | 说明 |
236
- |------|------|
237
- | `--session <name>` | 使用隔离会话 |
238
- | `--profile <path>` | 持久化浏览器配置目录 |
239
- | `--state <path>` | 加载存储状态文件 |
240
- | `--headers <json>` | 设置 HTTP 头 |
241
- | `--headed` | 显示浏览器窗口 |
242
- | `--json` | JSON 输出(AI 推荐) |
243
- | `--annotate` | 带编号标签的截图 |
244
- | `--cdp <port>` | 通过 CDP 连接 |
245
- | `--allowed-domains` | 限制允许的域名 |
246
- | `--max-output <n>` | 最大输出字符数 |
247
-
248
- ## 最佳实践
249
-
250
- ### AI 推荐的交互流程
251
- ```bash
252
- # 1. 打开并获取快照
253
- agent-browser open example.com
254
- agent-browser snapshot -i --json # AI 解析树和引用
255
-
256
- # 2. AI 从快照识别目标元素
257
- # 3. 使用引用执行操作
258
- agent-browser click @e2
259
- agent-browser fill @e3 "input text"
260
-
261
- # 4. 页面变化后重新获取快照
262
- agent-browser snapshot -i --json
263
- ```
264
-
265
- ### 命令链
266
- ```bash
267
- # 使用 && 链接多个命令
268
- agent-browser open example.com && agent-browser wait --load networkidle && agent-browser snapshot -i
269
-
270
- # 管道输入批量命令
271
- echo '[["open","https://example.com"],["snapshot","-i"],["click","@e1"]]' | agent-browser batch --json
272
- ```
273
-
274
- ### 处理弹窗
275
- ```bash
276
- agent-browser dialog accept # 接受弹窗
277
- agent-browser dialog dismiss # 拒绝弹窗
278
- agent-browser dialog status # 检查弹窗状态
279
- ```
280
-
281
- ### 标签页操作
282
- ```bash
283
- agent-browser tab # 列出标签
284
- agent-browser tab new [url] # 新建标签
285
- agent-browser tab 1 # 切换到标签 1
286
- agent-browser tab close [n] # 关闭标签
287
- ```
288
-
289
- ## 注意事项
290
-
291
- 1. **首次使用**: 需要运行 `agent-browser install` 下载 Chrome
292
- 2. **超时**: 默认操作超时 25 秒,可通过 `AGENT_BROWSER_DEFAULT_TIMEOUT` 调整
293
- 3. **安全**: 敏感操作使用 `--confirm-actions eval,download` 确认
294
- 4. **会话**: 不同会话有独立的 cookies、历史、认证状态
295
- 5. **引用稳定性**: 每次 `snapshot` 后引用可能变化,需重新获取
296
-
297
- ## 故障排除
298
-
299
- ```bash
300
- # 查看帮助
301
- agent-browser --help
302
-
303
- # 调试模式
304
- agent-browser open example.com --debug
305
-
306
- # 安装 Chrome
307
- agent-browser install
308
-
309
- # 升级
310
- agent-browser upgrade
311
- ```