foliko 1.0.73 → 1.0.75
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agent/.shared/ui-ux-pro-max/data/charts.csv +26 -0
- package/.agent/.shared/ui-ux-pro-max/data/colors.csv +97 -0
- package/.agent/.shared/ui-ux-pro-max/data/icons.csv +101 -0
- package/.agent/.shared/ui-ux-pro-max/data/landing.csv +31 -0
- package/.agent/.shared/ui-ux-pro-max/data/products.csv +97 -0
- package/.agent/.shared/ui-ux-pro-max/data/prompts.csv +24 -0
- package/.agent/.shared/ui-ux-pro-max/data/react-performance.csv +45 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/flutter.csv +53 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/html-tailwind.csv +56 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/jetpack-compose.csv +53 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/nextjs.csv +53 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/nuxt-ui.csv +51 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/nuxtjs.csv +59 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/react-native.csv +52 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/react.csv +54 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/shadcn.csv +61 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/svelte.csv +54 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/swiftui.csv +51 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/vue.csv +50 -0
- package/.agent/.shared/ui-ux-pro-max/data/styles.csv +59 -0
- package/.agent/.shared/ui-ux-pro-max/data/typography.csv +58 -0
- package/.agent/.shared/ui-ux-pro-max/data/ui-reasoning.csv +101 -0
- package/.agent/.shared/ui-ux-pro-max/data/ux-guidelines.csv +100 -0
- package/.agent/.shared/ui-ux-pro-max/data/web-interface.csv +31 -0
- package/.agent/.shared/ui-ux-pro-max/scripts/__pycache__/core.cpython-313.pyc +0 -0
- package/.agent/.shared/ui-ux-pro-max/scripts/__pycache__/design_system.cpython-313.pyc +0 -0
- package/.agent/.shared/ui-ux-pro-max/scripts/core.py +258 -0
- package/.agent/.shared/ui-ux-pro-max/scripts/design_system.py +1067 -0
- package/.agent/.shared/ui-ux-pro-max/scripts/search.py +106 -0
- package/.agent/ARCHITECTURE.md +288 -0
- package/.agent/agents/ambient-agent.md +57 -0
- package/.agent/agents/debugger.md +55 -0
- package/.agent/agents/email-assistant.md +49 -0
- package/.agent/agents/file-manager.md +42 -0
- package/.agent/agents/python-developer.md +60 -0
- package/.agent/agents/scheduler.md +59 -0
- package/.agent/agents/web-developer.md +45 -0
- package/.agent/data/default.json +29 -0
- package/.agent/data/plugins-state.json +255 -0
- package/.agent/mcp_config.json +4 -0
- package/.agent/mcp_config_updated.json +12 -0
- package/.agent/plugins.json +5 -0
- package/.agent/rules/GEMINI.md +273 -0
- package/.agent/rules/allow-rule.md +77 -0
- package/.agent/rules/log-rule.md +83 -0
- package/.agent/rules/security-rule.md +93 -0
- package/.agent/scripts/auto_preview.py +148 -0
- package/.agent/scripts/checklist.py +217 -0
- package/.agent/scripts/session_manager.py +120 -0
- package/.agent/scripts/verify_all.py +327 -0
- package/.agent/skills/api-patterns/SKILL.md +81 -0
- package/.agent/skills/api-patterns/api-style.md +42 -0
- package/.agent/skills/api-patterns/auth.md +24 -0
- package/.agent/skills/api-patterns/documentation.md +26 -0
- package/.agent/skills/api-patterns/graphql.md +41 -0
- package/.agent/skills/api-patterns/rate-limiting.md +31 -0
- package/.agent/skills/api-patterns/response.md +37 -0
- package/.agent/skills/api-patterns/rest.md +40 -0
- package/.agent/skills/api-patterns/scripts/api_validator.py +211 -0
- package/.agent/skills/api-patterns/security-testing.md +122 -0
- package/.agent/skills/api-patterns/trpc.md +41 -0
- package/.agent/skills/api-patterns/versioning.md +22 -0
- package/.agent/skills/app-builder/SKILL.md +75 -0
- package/.agent/skills/app-builder/agent-coordination.md +71 -0
- package/.agent/skills/app-builder/feature-building.md +53 -0
- package/.agent/skills/app-builder/project-detection.md +34 -0
- package/.agent/skills/app-builder/scaffolding.md +118 -0
- package/.agent/skills/app-builder/tech-stack.md +40 -0
- package/.agent/skills/app-builder/templates/SKILL.md +39 -0
- package/.agent/skills/app-builder/templates/astro-static/TEMPLATE.md +76 -0
- package/.agent/skills/app-builder/templates/chrome-extension/TEMPLATE.md +92 -0
- package/.agent/skills/app-builder/templates/cli-tool/TEMPLATE.md +88 -0
- package/.agent/skills/app-builder/templates/electron-desktop/TEMPLATE.md +88 -0
- package/.agent/skills/app-builder/templates/express-api/TEMPLATE.md +83 -0
- package/.agent/skills/app-builder/templates/flutter-app/TEMPLATE.md +90 -0
- package/.agent/skills/app-builder/templates/monorepo-turborepo/TEMPLATE.md +90 -0
- package/.agent/skills/app-builder/templates/nextjs-fullstack/TEMPLATE.md +122 -0
- package/.agent/skills/app-builder/templates/nextjs-saas/TEMPLATE.md +122 -0
- package/.agent/skills/app-builder/templates/nextjs-static/TEMPLATE.md +169 -0
- package/.agent/skills/app-builder/templates/nuxt-app/TEMPLATE.md +134 -0
- package/.agent/skills/app-builder/templates/python-fastapi/TEMPLATE.md +83 -0
- package/.agent/skills/app-builder/templates/react-native-app/TEMPLATE.md +119 -0
- package/.agent/skills/architecture/SKILL.md +55 -0
- package/.agent/skills/architecture/context-discovery.md +43 -0
- package/.agent/skills/architecture/examples.md +94 -0
- package/.agent/skills/architecture/pattern-selection.md +68 -0
- package/.agent/skills/architecture/patterns-reference.md +50 -0
- package/.agent/skills/architecture/trade-off-analysis.md +77 -0
- package/.agent/skills/clean-code/SKILL.md +201 -0
- package/.agent/skills/doc.md +177 -0
- package/.agent/skills/frontend-design/SKILL.md +418 -0
- package/.agent/skills/frontend-design/animation-guide.md +331 -0
- package/.agent/skills/frontend-design/color-system.md +311 -0
- package/.agent/skills/frontend-design/decision-trees.md +418 -0
- package/.agent/skills/frontend-design/motion-graphics.md +306 -0
- package/.agent/skills/frontend-design/scripts/accessibility_checker.py +183 -0
- package/.agent/skills/frontend-design/scripts/ux_audit.py +722 -0
- package/.agent/skills/frontend-design/typography-system.md +345 -0
- package/.agent/skills/frontend-design/ux-psychology.md +1116 -0
- package/.agent/skills/frontend-design/visual-effects.md +383 -0
- package/.agent/skills/i18n-localization/SKILL.md +154 -0
- package/.agent/skills/i18n-localization/scripts/i18n_checker.py +241 -0
- package/.agent/skills/mcp-builder/SKILL.md +176 -0
- package/.agent/skills/web-design-guidelines/SKILL.md +57 -0
- package/.agent/workflows/brainstorm.md +113 -0
- package/.agent/workflows/create.md +59 -0
- package/.agent/workflows/debug.md +103 -0
- package/.agent/workflows/deploy.md +176 -0
- package/.agent/workflows/enhance.md +63 -0
- package/.agent/workflows/orchestrate.md +237 -0
- package/.agent/workflows/plan.md +89 -0
- package/.agent/workflows/preview.md +81 -0
- package/.agent/workflows/simple-test.md +42 -0
- package/.agent/workflows/status.md +86 -0
- package/.agent/workflows/structured-orchestrate.md +180 -0
- package/.agent/workflows/test.md +144 -0
- package/.agent/workflows/ui-ux-pro-max.md +296 -0
- package/.claude/settings.local.json +157 -149
- package/.editorconfig +56 -0
- package/.husky/pre-commit +4 -0
- package/.lintstagedrc +7 -0
- package/.prettierignore +29 -0
- package/.prettierrc +11 -0
- package/CLAUDE.md +2 -0
- package/README.md +64 -55
- package/SPEC.md +102 -61
- package/cli/bin/foliko.js +4 -4
- package/cli/src/commands/chat.js +53 -51
- package/cli/src/commands/list.js +40 -37
- package/cli/src/index.js +18 -18
- package/cli/src/ui/chat-ui.js +78 -76
- package/cli/src/utils/ansi.js +15 -15
- package/cli/src/utils/markdown.js +112 -116
- package/docker-compose.yml +1 -1
- package/docs/ai-sdk-optimization.md +655 -636
- package/docs/features.md +80 -80
- package/docs/quick-reference.md +49 -46
- package/docs/user-manual.md +411 -380
- package/examples/ambient-example.js +95 -97
- package/examples/basic.js +115 -110
- package/examples/bootstrap.js +52 -43
- package/examples/mcp-example.js +56 -53
- package/examples/skill-example.js +49 -49
- package/examples/test-chat.js +60 -58
- package/examples/test-mcp.js +49 -43
- package/examples/test-reload.js +38 -40
- package/examples/test-telegram.js +3 -3
- package/examples/test-tg-bot.js +7 -4
- package/examples/test-tg-simple.js +4 -3
- package/examples/test-tg.js +3 -3
- package/examples/test-think.js +13 -7
- package/examples/test-web-plugin.js +61 -56
- package/examples/test-weixin-feishu.js +40 -37
- package/examples/workflow.js +49 -49
- package/foliko-1.0.75.tgz +0 -0
- package/package.json +37 -3
- package/plugins/ai-plugin.js +7 -5
- package/plugins/ambient-agent/EventWatcher.js +113 -0
- package/plugins/ambient-agent/ExplorerLoop.js +640 -0
- package/plugins/ambient-agent/GoalManager.js +197 -0
- package/plugins/ambient-agent/Reflector.js +95 -0
- package/plugins/ambient-agent/StateStore.js +90 -0
- package/plugins/ambient-agent/constants.js +101 -0
- package/plugins/ambient-agent/index.js +579 -0
- package/plugins/default-plugins.js +62 -49
- package/plugins/email/constants.js +64 -0
- package/plugins/email/handlers.js +461 -0
- package/plugins/email/index.js +278 -0
- package/plugins/email/monitor.js +269 -0
- package/plugins/email/parser.js +138 -0
- package/plugins/email/reply.js +151 -0
- package/plugins/email/utils.js +124 -0
- package/plugins/feishu-plugin.js +23 -19
- package/plugins/file-system-plugin.js +469 -120
- package/plugins/install-plugin.js +6 -4
- package/plugins/python-executor-plugin.js +3 -1
- package/plugins/python-plugin-loader.js +10 -8
- package/plugins/rules-plugin.js +5 -3
- package/plugins/scheduler-plugin.js +18 -16
- package/plugins/session-plugin.js +3 -1
- package/plugins/storage-plugin.js +5 -3
- package/plugins/subagent-plugin.js +152 -92
- package/plugins/telegram-plugin.js +26 -19
- package/plugins/think-plugin.js +4 -2
- package/plugins/tools-plugin.js +3 -1
- package/plugins/web-plugin.js +15 -13
- package/plugins/weixin-plugin.js +43 -36
- package/reports/system-health-report-20260401.md +79 -0
- package/skills/ambient-agent/SKILL.md +49 -39
- package/skills/foliko-dev/AGENTS.md +64 -61
- package/skills/foliko-dev/SKILL.md +125 -119
- package/skills/mcp-usage/SKILL.md +19 -17
- package/skills/python-plugin-dev/SKILL.md +16 -15
- package/skills/skill-guide/SKILL.md +12 -12
- package/skills/subagent-guide/SKILL.md +237 -0
- package/skills/workflow-guide/SKILL.md +90 -45
- package/skills/workflow-troubleshooting/DEBUGGING.md +36 -21
- package/skills/workflow-troubleshooting/SKILL.md +156 -79
- package/src/capabilities/index.js +4 -4
- package/src/capabilities/skill-manager.js +211 -197
- package/src/capabilities/workflow-engine.js +461 -547
- package/src/core/agent-chat.js +426 -279
- package/src/core/agent.js +453 -248
- package/src/core/framework.js +183 -149
- package/src/core/index.js +8 -8
- package/src/core/plugin-base.js +52 -52
- package/src/core/plugin-manager.js +377 -281
- package/src/core/provider.js +35 -32
- package/src/core/sub-agent-config.js +264 -0
- package/src/core/system-prompt-builder.js +120 -0
- package/src/core/tool-registry.js +416 -33
- package/src/core/tool-router.js +149 -68
- package/src/executors/executor-base.js +58 -58
- package/src/executors/mcp-executor.js +269 -257
- package/src/index.js +5 -17
- package/src/utils/circuit-breaker.js +301 -0
- package/src/utils/error-boundary.js +363 -0
- package/src/utils/error.js +374 -0
- package/src/utils/event-emitter.js +20 -20
- package/src/utils/id.js +133 -0
- package/src/utils/index.js +217 -3
- package/src/utils/logger.js +181 -0
- package/src/utils/plugin-helpers.js +90 -0
- package/src/utils/retry.js +122 -0
- package/src/utils/sandbox.js +292 -0
- package/test/tool-registry-validation.test.js +218 -0
- package/test_report.md +70 -0
- package/website/docs/api.html +169 -107
- package/website/docs/configuration.html +296 -144
- package/website/docs/plugin-development.html +154 -85
- package/website/docs/project-structure.html +110 -109
- package/website/docs/skill-development.html +117 -61
- package/website/index.html +209 -205
- package/website/script.js +20 -17
- package/website/styles.css +1 -1
- package/plugins/ambient-agent-plugin.js +0 -1565
- package/plugins/email.js +0 -1142
|
@@ -6,6 +6,9 @@
|
|
|
6
6
|
const fs = require('fs')
|
|
7
7
|
const path = require('path')
|
|
8
8
|
const { Plugin } = require('../src/core/plugin-base')
|
|
9
|
+
const { logger } = require('../src/utils/logger')
|
|
10
|
+
const log = logger.child('AgentConfig')
|
|
11
|
+
const bootstrapLog = logger.child('Bootstrap')
|
|
9
12
|
|
|
10
13
|
/**
|
|
11
14
|
* 加载 .agent 目录下的配置
|
|
@@ -24,17 +27,17 @@ function loadAgentConfig(agentDir = '.agent') {
|
|
|
24
27
|
const resolvedDir = path.resolve(process.cwd(), agentDir)
|
|
25
28
|
|
|
26
29
|
if (!fs.existsSync(resolvedDir)) {
|
|
27
|
-
|
|
30
|
+
log.info(` .agent directory not found: ${resolvedDir}`)
|
|
28
31
|
return config
|
|
29
32
|
}
|
|
30
33
|
|
|
31
|
-
|
|
34
|
+
log.info(` Loading config from: ${resolvedDir}`)
|
|
32
35
|
|
|
33
36
|
// 添加 agents 目录(如果存在)
|
|
34
37
|
const agentsDir = path.join(resolvedDir, 'agents')
|
|
35
38
|
if (fs.existsSync(agentsDir)) {
|
|
36
39
|
config.agentsDir = agentsDir
|
|
37
|
-
|
|
40
|
+
log.info(` Found agents directory: ${agentsDir}`)
|
|
38
41
|
}
|
|
39
42
|
|
|
40
43
|
// 加载 config 文件(key=value 格式)
|
|
@@ -63,7 +66,7 @@ function loadAgentConfig(agentDir = '.agent') {
|
|
|
63
66
|
}
|
|
64
67
|
}
|
|
65
68
|
} catch (err) {
|
|
66
|
-
|
|
69
|
+
log.error(` Failed to load config:`, err.message)
|
|
67
70
|
}
|
|
68
71
|
}
|
|
69
72
|
|
|
@@ -75,7 +78,7 @@ function loadAgentConfig(agentDir = '.agent') {
|
|
|
75
78
|
const aiConfig = JSON.parse(content)
|
|
76
79
|
config.ai = { ...config.ai, ...aiConfig }
|
|
77
80
|
} catch (err) {
|
|
78
|
-
|
|
81
|
+
log.error(` Failed to load ai.json:`, err.message)
|
|
79
82
|
}
|
|
80
83
|
}
|
|
81
84
|
|
|
@@ -98,7 +101,7 @@ function loadAgentConfig(agentDir = '.agent') {
|
|
|
98
101
|
config.email = pluginsConfig.email
|
|
99
102
|
}
|
|
100
103
|
} catch (err) {
|
|
101
|
-
|
|
104
|
+
log.error(` Failed to load plugins.json:`, err.message)
|
|
102
105
|
}
|
|
103
106
|
}
|
|
104
107
|
|
|
@@ -109,7 +112,7 @@ function loadAgentConfig(agentDir = '.agent') {
|
|
|
109
112
|
const content = fs.readFileSync(weixinFile, 'utf-8')
|
|
110
113
|
config.weixin = { ...config.weixin, ...JSON.parse(content) }
|
|
111
114
|
} catch (err) {
|
|
112
|
-
|
|
115
|
+
log.error(` Failed to load weixin.json:`, err.message)
|
|
113
116
|
}
|
|
114
117
|
}
|
|
115
118
|
|
|
@@ -121,7 +124,7 @@ function loadAgentConfig(agentDir = '.agent') {
|
|
|
121
124
|
const mcpConfig = JSON.parse(content)
|
|
122
125
|
config.mcpServers = mcpConfig.mcpServers || {}
|
|
123
126
|
} catch (err) {
|
|
124
|
-
|
|
127
|
+
log.error(` Failed to load mcp_config.json:`, err.message)
|
|
125
128
|
}
|
|
126
129
|
}
|
|
127
130
|
|
|
@@ -129,7 +132,7 @@ function loadAgentConfig(agentDir = '.agent') {
|
|
|
129
132
|
const skillsDir = path.join(resolvedDir, 'skills')
|
|
130
133
|
if (fs.existsSync(resolvedDir) && !fs.existsSync(skillsDir)) {
|
|
131
134
|
fs.mkdirSync(skillsDir, { recursive: true })
|
|
132
|
-
|
|
135
|
+
log.info(` Created skills directory: ${skillsDir}`)
|
|
133
136
|
}
|
|
134
137
|
if (fs.existsSync(skillsDir)) {
|
|
135
138
|
config.skillsDirs.push(skillsDir)
|
|
@@ -139,7 +142,7 @@ function loadAgentConfig(agentDir = '.agent') {
|
|
|
139
142
|
const cmdskillsDir = path.join(cmdDir, 'skills')
|
|
140
143
|
if (fs.existsSync(resolvedDir) && !fs.existsSync(cmdskillsDir)) {
|
|
141
144
|
fs.mkdirSync(cmdskillsDir, { recursive: true })
|
|
142
|
-
|
|
145
|
+
log.info(` Created skills directory: ${cmdskillsDir}`)
|
|
143
146
|
}
|
|
144
147
|
if (fs.existsSync(cmdskillsDir)) {
|
|
145
148
|
config.skillsDirs.push(cmdskillsDir)
|
|
@@ -214,7 +217,7 @@ async function bootstrapDefaults(framework, config = {}) {
|
|
|
214
217
|
// 如果已经有配置,使用现有配置;否则加载
|
|
215
218
|
const agentConfig = config._config
|
|
216
219
|
if (!agentConfig) {
|
|
217
|
-
|
|
220
|
+
bootstrapLog.error(' No config provided, skipping plugin loading')
|
|
218
221
|
return
|
|
219
222
|
}
|
|
220
223
|
// 设置 bootstrap 模式,避免重复启动
|
|
@@ -236,7 +239,7 @@ async function bootstrapDefaults(framework, config = {}) {
|
|
|
236
239
|
const shouldLoad = (plugin) => {
|
|
237
240
|
const name = typeof plugin === 'string' ? plugin : (plugin.name || plugin.prototype?.name)
|
|
238
241
|
if (framework.pluginManager.has(name)) {
|
|
239
|
-
framework._debug&&
|
|
242
|
+
framework._debug&&bootstrapLog.debug(` ${name} Plugin already loaded, skipping`)
|
|
240
243
|
return false
|
|
241
244
|
}
|
|
242
245
|
// 系统插件(system: true)不能禁用
|
|
@@ -247,7 +250,7 @@ async function bootstrapDefaults(framework, config = {}) {
|
|
|
247
250
|
isSystem = plugin.system === true
|
|
248
251
|
}
|
|
249
252
|
if (isSystem && framework.pluginManager.isEnabled(name) === false) {
|
|
250
|
-
framework._debug&&
|
|
253
|
+
framework._debug&&bootstrapLog.debug(` ${name} is a system plugin, cannot be disabled`)
|
|
251
254
|
}
|
|
252
255
|
return true
|
|
253
256
|
}
|
|
@@ -256,7 +259,7 @@ async function bootstrapDefaults(framework, config = {}) {
|
|
|
256
259
|
if (shouldLoad('install')) {
|
|
257
260
|
const { InstallPlugin } = require('./install-plugin')
|
|
258
261
|
await framework.loadPlugin(new InstallPlugin({ agentDir: agentConfig.agentDir }))
|
|
259
|
-
framework._debug&&
|
|
262
|
+
framework._debug&&bootstrapLog.debug(' Install Plugin loaded')
|
|
260
263
|
}
|
|
261
264
|
|
|
262
265
|
// 合并 skillsDirs 配置(bootstrap 传入的优先)
|
|
@@ -265,7 +268,7 @@ async function bootstrapDefaults(framework, config = {}) {
|
|
|
265
268
|
...(agentConfig.skillsDirs || [])
|
|
266
269
|
]
|
|
267
270
|
|
|
268
|
-
framework._debug&&
|
|
271
|
+
framework._debug&&bootstrapLog.debug(' Loading default plugins...')
|
|
269
272
|
// AI 插件(如果已禁用则跳过)
|
|
270
273
|
if (!shouldLoad('ai') || !(aiConfig.provider || aiConfig.model || aiConfig.apiKey)) {
|
|
271
274
|
// 跳过或已禁用
|
|
@@ -281,7 +284,7 @@ async function bootstrapDefaults(framework, config = {}) {
|
|
|
281
284
|
baseURL: aiConfig.baseURL
|
|
282
285
|
})
|
|
283
286
|
await framework.loadPlugin(aiPlugin)
|
|
284
|
-
framework._debug&&
|
|
287
|
+
framework._debug&&bootstrapLog.debug(' AI Plugin loaded')
|
|
285
288
|
}
|
|
286
289
|
|
|
287
290
|
// 1.5 创建主 Agent(供 Telegram 等需要绑定 Agent 的插件使用)
|
|
@@ -289,9 +292,9 @@ async function bootstrapDefaults(framework, config = {}) {
|
|
|
289
292
|
const { Agent } = require('../src/core/agent')
|
|
290
293
|
const aiPlugin = framework.pluginManager.get('ai')
|
|
291
294
|
const aiClient = aiPlugin ? aiPlugin.getAIClient() : null
|
|
292
|
-
framework._debug&&
|
|
295
|
+
framework._debug&&bootstrapLog.debug(' Creating Main Agent - aiClient:', !!aiClient)
|
|
293
296
|
|
|
294
|
-
framework._mainAgent =
|
|
297
|
+
framework._mainAgent = framework.createAgent({
|
|
295
298
|
name: 'MainAgent',
|
|
296
299
|
systemPrompt: '你是一个智能助手。当用户提出问题或任务时,你会主动分析需求,选择合适的工具来获取信息或执行操作。你善于将复杂任务拆解为多个步骤,通过工具协作完成。',
|
|
297
300
|
model: aiConfig.model,
|
|
@@ -300,28 +303,28 @@ async function bootstrapDefaults(framework, config = {}) {
|
|
|
300
303
|
baseURL: aiConfig.baseURL
|
|
301
304
|
})
|
|
302
305
|
framework._agents.push(framework._mainAgent)
|
|
303
|
-
framework._debug&&
|
|
306
|
+
framework._debug&&bootstrapLog.debug(' Main Agent created, has _chatHandler:', !!framework._mainAgent._chatHandler)
|
|
304
307
|
}
|
|
305
308
|
|
|
306
309
|
// 2. Storage 存储插件
|
|
307
310
|
if (shouldLoad('storage')) {
|
|
308
311
|
const { StoragePlugin } = require('./storage-plugin')
|
|
309
312
|
await framework.loadPlugin(new StoragePlugin())
|
|
310
|
-
framework._debug&&
|
|
313
|
+
framework._debug&&bootstrapLog.debug(' Storage Plugin loaded')
|
|
311
314
|
}
|
|
312
315
|
|
|
313
316
|
// 3. 内置工具插件
|
|
314
317
|
if (shouldLoad('tools')) {
|
|
315
318
|
const { ToolsPlugin } = require('./tools-plugin')
|
|
316
319
|
await framework.loadPlugin(new ToolsPlugin())
|
|
317
|
-
framework._debug&&
|
|
320
|
+
framework._debug&&bootstrapLog.debug(' Tools Plugin loaded')
|
|
318
321
|
}
|
|
319
322
|
|
|
320
323
|
// 4. 工作流插件
|
|
321
324
|
if (shouldLoad('workflow')) {
|
|
322
325
|
const { WorkflowPlugin } = require('../src/capabilities/workflow-engine')
|
|
323
326
|
await framework.loadPlugin(new WorkflowPlugin())
|
|
324
|
-
framework._debug&&
|
|
327
|
+
framework._debug&&bootstrapLog.debug(' Workflow Plugin loaded')
|
|
325
328
|
}
|
|
326
329
|
|
|
327
330
|
// 5. Skill 管理器插件
|
|
@@ -330,7 +333,7 @@ async function bootstrapDefaults(framework, config = {}) {
|
|
|
330
333
|
const { SkillManagerPlugin } = require('../src/capabilities/skill-manager')
|
|
331
334
|
// 传递所有 skills 目录
|
|
332
335
|
await framework.loadPlugin(new SkillManagerPlugin({ skillsDirs }))
|
|
333
|
-
framework._debug&&
|
|
336
|
+
framework._debug&&bootstrapLog.debug(' Skill Manager loaded')
|
|
334
337
|
}
|
|
335
338
|
}
|
|
336
339
|
|
|
@@ -348,84 +351,84 @@ async function bootstrapDefaults(framework, config = {}) {
|
|
|
348
351
|
}))
|
|
349
352
|
const { MCPExecutorPlugin } = require('../src/executors/mcp-executor')
|
|
350
353
|
await framework.loadPlugin(new MCPExecutorPlugin({ servers }))
|
|
351
|
-
framework._debug&&
|
|
354
|
+
framework._debug&&bootstrapLog.debug(` MCP Executor loaded${servers.length > 0 ? ` (${servers.length} servers)` : ' (no servers)'}`)
|
|
352
355
|
}
|
|
353
356
|
|
|
354
357
|
// 7. Shell 执行器插件
|
|
355
358
|
if (shouldLoad('shell-executor')) {
|
|
356
359
|
const { ShellExecutorPlugin } = require('./shell-executor-plugin')
|
|
357
360
|
await framework.loadPlugin(new ShellExecutorPlugin())
|
|
358
|
-
framework._debug&&
|
|
361
|
+
framework._debug&&bootstrapLog.debug(' Shell Executor loaded')
|
|
359
362
|
}
|
|
360
363
|
|
|
361
364
|
// 8. Python 执行器插件
|
|
362
365
|
if (shouldLoad('python-executor')) {
|
|
363
366
|
const { PythonExecutorPlugin } = require('./python-executor-plugin')
|
|
364
367
|
await framework.loadPlugin(new PythonExecutorPlugin())
|
|
365
|
-
framework._debug&&
|
|
368
|
+
framework._debug&&bootstrapLog.debug(' Python Executor loaded')
|
|
366
369
|
}
|
|
367
370
|
|
|
368
371
|
// 8.5 Web Web服务插件
|
|
369
372
|
if (shouldLoad('web')) {
|
|
370
373
|
const { WebPlugin } = require('./web-plugin')
|
|
371
374
|
await framework.loadPlugin(new WebPlugin())
|
|
372
|
-
framework._debug&&
|
|
375
|
+
framework._debug&&bootstrapLog.debug(' Web Plugin loaded')
|
|
373
376
|
}
|
|
374
377
|
|
|
375
378
|
// 9. Session 会话管理插件
|
|
376
379
|
if (shouldLoad('session')) {
|
|
377
380
|
const { SessionPlugin } = require('./session-plugin')
|
|
378
381
|
await framework.loadPlugin(new SessionPlugin())
|
|
379
|
-
framework._debug&&
|
|
382
|
+
framework._debug&&bootstrapLog.debug(' Session Plugin loaded')
|
|
380
383
|
}
|
|
381
384
|
|
|
382
385
|
// 10. Audit 审计日志插件
|
|
383
386
|
if (shouldLoad('audit')) {
|
|
384
387
|
const { AuditPlugin } = require('./audit-plugin')
|
|
385
388
|
await framework.loadPlugin(new AuditPlugin())
|
|
386
|
-
framework._debug&&
|
|
389
|
+
framework._debug&&bootstrapLog.debug(' Audit Plugin loaded')
|
|
387
390
|
}
|
|
388
391
|
|
|
389
392
|
// 10. Rules 规则引擎插件
|
|
390
393
|
if (shouldLoad('rules')) {
|
|
391
394
|
const { RulesPlugin } = require('./rules-plugin')
|
|
392
395
|
await framework.loadPlugin(new RulesPlugin())
|
|
393
|
-
framework._debug&&
|
|
396
|
+
framework._debug&&bootstrapLog.debug(' Rules Plugin loaded')
|
|
394
397
|
}
|
|
395
398
|
|
|
396
399
|
// 11. Scheduler 定时任务插件
|
|
397
400
|
if (shouldLoad('scheduler')) {
|
|
398
401
|
const { SchedulerPlugin } = require('./scheduler-plugin')
|
|
399
402
|
await framework.loadPlugin(new SchedulerPlugin())
|
|
400
|
-
framework._debug&&
|
|
403
|
+
framework._debug&&bootstrapLog.debug(' Scheduler Plugin loaded')
|
|
401
404
|
}
|
|
402
405
|
|
|
403
406
|
// 11. FileSystem 文件系统插件
|
|
404
407
|
if (shouldLoad('file-system')) {
|
|
405
408
|
const { FileSystemPlugin } = require('./file-system-plugin')
|
|
406
409
|
await framework.loadPlugin(new FileSystemPlugin())
|
|
407
|
-
framework._debug&&
|
|
410
|
+
framework._debug&&bootstrapLog.debug(' FileSystem Plugin loaded')
|
|
408
411
|
}
|
|
409
412
|
|
|
410
413
|
// 12. Think 主动思考插件
|
|
411
414
|
if (shouldLoad('think')) {
|
|
412
415
|
const { ThinkPlugin } = require('./think-plugin')
|
|
413
416
|
await framework.loadPlugin(new ThinkPlugin())
|
|
414
|
-
framework._debug&&
|
|
417
|
+
framework._debug&&bootstrapLog.debug(' Think Plugin loaded')
|
|
415
418
|
}
|
|
416
419
|
|
|
417
420
|
// 12.1 Ambient Agent 插件
|
|
418
421
|
if (shouldLoad('ambient')) {
|
|
419
|
-
const { AmbientAgentPlugin } = require('./ambient-agent
|
|
422
|
+
const { AmbientAgentPlugin } = require('./ambient-agent')
|
|
420
423
|
await framework.loadPlugin(new AmbientAgentPlugin())
|
|
421
|
-
framework._debug&&
|
|
424
|
+
framework._debug&&bootstrapLog.debug(' Ambient Agent Plugin loaded')
|
|
422
425
|
}
|
|
423
426
|
|
|
424
427
|
// 12.5 Python 插件加载器
|
|
425
428
|
if (shouldLoad('python-plugin-loader')) {
|
|
426
429
|
const { PythonPluginLoader } = require('./python-plugin-loader')
|
|
427
430
|
await framework.loadPlugin(new PythonPluginLoader({ agentDir: agentConfig.agentDir }))
|
|
428
|
-
framework._debug&&
|
|
431
|
+
framework._debug&&bootstrapLog.debug(' Python Plugin Loader loaded')
|
|
429
432
|
}
|
|
430
433
|
|
|
431
434
|
// 12.6 Telegram 插件(默认禁用,需要在 plugins.json 中设置 enabled: true)
|
|
@@ -448,7 +451,7 @@ async function bootstrapDefaults(framework, config = {}) {
|
|
|
448
451
|
}
|
|
449
452
|
await framework.loadPlugin(new WeixinPlugin(weixinConfig))
|
|
450
453
|
} catch (err) {
|
|
451
|
-
|
|
454
|
+
bootstrapLog.warn(' WeChat Plugin not available:', err.message)
|
|
452
455
|
}
|
|
453
456
|
}
|
|
454
457
|
|
|
@@ -456,6 +459,9 @@ async function bootstrapDefaults(framework, config = {}) {
|
|
|
456
459
|
if (shouldLoad('email')) {
|
|
457
460
|
try {
|
|
458
461
|
const { Plugin } = require('../src/core/plugin-base')
|
|
462
|
+
const { logger } = require('../src/utils/logger')
|
|
463
|
+
const log = logger.child('AgentConfig')
|
|
464
|
+
const bootstrapLog = logger.child('Bootstrap')
|
|
459
465
|
const { EmailPlugin } = require('./email')
|
|
460
466
|
// 支持两种格式:email.smtp 或 email.config.smtp
|
|
461
467
|
const emailData = agentConfig.email || {}
|
|
@@ -467,7 +473,7 @@ async function bootstrapDefaults(framework, config = {}) {
|
|
|
467
473
|
}
|
|
468
474
|
await framework.loadPlugin(new EmailPlugin(emailConfig))
|
|
469
475
|
} catch (err) {
|
|
470
|
-
|
|
476
|
+
bootstrapLog.warn(' Email Plugin not available:', err.message)
|
|
471
477
|
}
|
|
472
478
|
}
|
|
473
479
|
|
|
@@ -480,25 +486,32 @@ async function bootstrapDefaults(framework, config = {}) {
|
|
|
480
486
|
}
|
|
481
487
|
await framework.loadPlugin(new FeishuPlugin(feishuConfig))
|
|
482
488
|
} catch (err) {
|
|
483
|
-
|
|
489
|
+
bootstrapLog.warn(' Feishu Plugin not available:', err.message)
|
|
484
490
|
}
|
|
485
491
|
}
|
|
486
492
|
|
|
487
493
|
// 12.10 SubAgent 管理器
|
|
488
494
|
if (shouldLoad('subagent-manager')) {
|
|
489
495
|
try {
|
|
496
|
+
// 先初始化 SubAgentConfigManager 并加载所有配置
|
|
497
|
+
const { SubAgentConfigManager } = require('../src/core/sub-agent-config')
|
|
498
|
+
const subAgentConfigManager = new SubAgentConfigManager(agentConfig.agentsDir)
|
|
499
|
+
subAgentConfigManager.loadAll()
|
|
500
|
+
framework._subAgentConfigManager = subAgentConfigManager
|
|
501
|
+
|
|
502
|
+
// 然后加载 SubAgentManagerPlugin
|
|
490
503
|
const { SubAgentManagerPlugin } = require('./subagent-plugin')
|
|
491
504
|
await framework.loadPlugin(new SubAgentManagerPlugin({ agentsDir: agentConfig.agentsDir }))
|
|
492
|
-
framework._debug&&
|
|
505
|
+
framework._debug&&bootstrapLog.debug(' SubAgent Manager loaded')
|
|
493
506
|
} catch (err) {
|
|
494
|
-
|
|
507
|
+
bootstrapLog.warn(' SubAgent Manager failed:', err.message)
|
|
495
508
|
}
|
|
496
509
|
}
|
|
497
510
|
|
|
498
511
|
// 13. 加载自定义插件
|
|
499
512
|
await loadCustomPlugins(framework, agentConfig)
|
|
500
513
|
|
|
501
|
-
framework._debug&&
|
|
514
|
+
framework._debug&&bootstrapLog.debug(' All plugins loaded')
|
|
502
515
|
|
|
503
516
|
// 统一启动所有插件(避免重复启动)
|
|
504
517
|
await framework.pluginManager.startAll()
|
|
@@ -506,8 +519,8 @@ async function bootstrapDefaults(framework, config = {}) {
|
|
|
506
519
|
// 清除 bootstrap 模式
|
|
507
520
|
framework.pluginManager.setBootstrapping(false)
|
|
508
521
|
|
|
509
|
-
framework._debug&&
|
|
510
|
-
framework._debug&&
|
|
522
|
+
framework._debug&&bootstrapLog.debug(' Loaded plugins ', framework.pluginManager.getAll().length)
|
|
523
|
+
framework._debug&&bootstrapLog.debug(' Loaded tools ', framework.getTools().length)
|
|
511
524
|
}
|
|
512
525
|
|
|
513
526
|
/**
|
|
@@ -535,7 +548,7 @@ function resolvePluginPath(pluginsDir, name) {
|
|
|
535
548
|
return { path: mainPath, type: 'folder' }
|
|
536
549
|
}
|
|
537
550
|
} catch (err) {
|
|
538
|
-
|
|
551
|
+
log.warn(` Failed to parse package.json for ${name}:`, err.message)
|
|
539
552
|
}
|
|
540
553
|
}
|
|
541
554
|
// 默认加载 index.js
|
|
@@ -543,7 +556,7 @@ function resolvePluginPath(pluginsDir, name) {
|
|
|
543
556
|
if (fs.existsSync(indexPath)) {
|
|
544
557
|
return { path: indexPath, type: 'folder' }
|
|
545
558
|
}
|
|
546
|
-
//
|
|
559
|
+
//log.warn(` No entry point found for plugin folder: ${name}`)
|
|
547
560
|
return null
|
|
548
561
|
}
|
|
549
562
|
|
|
@@ -599,7 +612,7 @@ async function loadCustomPlugins(framework, agentConfig) {
|
|
|
599
612
|
try {
|
|
600
613
|
const resolved = resolvePluginPath(pluginsDir, pluginName)
|
|
601
614
|
if (!resolved) {
|
|
602
|
-
//
|
|
615
|
+
//log.warn(` Cannot resolve plugin: ${pluginName}`)
|
|
603
616
|
continue
|
|
604
617
|
}
|
|
605
618
|
|
|
@@ -630,11 +643,11 @@ async function loadCustomPlugins(framework, agentConfig) {
|
|
|
630
643
|
continue
|
|
631
644
|
}
|
|
632
645
|
|
|
633
|
-
//
|
|
646
|
+
//bootstrapLog.debug(` Loading custom plugin: ${pluginName} (${type})`)
|
|
634
647
|
// .agent/plugins 目录下的插件强制启用,不受 state 文件 enabled: false 影响
|
|
635
648
|
await framework.pluginManager.load(plugin, { forceEnabled: true })
|
|
636
649
|
} catch (err) {
|
|
637
|
-
|
|
650
|
+
log.error(` Failed to load plugin ${pluginName}:`, err.message)
|
|
638
651
|
}
|
|
639
652
|
}
|
|
640
653
|
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Email 插件 - 常量定义
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* IMAP 文件夹列表
|
|
7
|
+
*/
|
|
8
|
+
const IMAP_FOLDERS = [
|
|
9
|
+
'INBOX', // 收件箱
|
|
10
|
+
'Drafts', // 草稿箱
|
|
11
|
+
'Sent', // 已发送
|
|
12
|
+
'Trash', // 垃圾箱
|
|
13
|
+
'Junk', // 广告邮件
|
|
14
|
+
'Archive' // 归档
|
|
15
|
+
]
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* 默认 SMTP 配置
|
|
19
|
+
*/
|
|
20
|
+
const DEFAULT_SMTP = {
|
|
21
|
+
host: process.env.SMTP_HOST || 'smtp.gmail.com',
|
|
22
|
+
port: parseInt(process.env.SMTP_PORT) || 587,
|
|
23
|
+
secure: process.env.SMTP_SECURE === 'true'
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* 默认 IMAP 配置
|
|
28
|
+
*/
|
|
29
|
+
const DEFAULT_IMAP = {
|
|
30
|
+
host: process.env.IMAP_HOST || 'imap.gmail.com',
|
|
31
|
+
port: parseInt(process.env.IMAP_PORT) || 993,
|
|
32
|
+
tls: true,
|
|
33
|
+
tlsOptions: { rejectUnauthorized: false }
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* IMAP 客户端标识
|
|
38
|
+
*/
|
|
39
|
+
const IMAP_CLIENT_INFO = {
|
|
40
|
+
name: process.env.IMAP_CLIENT_NAME || 'FolikoAgent',
|
|
41
|
+
version: process.env.IMAP_CLIENT_VERSION || '1.0.0',
|
|
42
|
+
vendor: process.env.IMAP_CLIENT_VENDOR || 'Foliko',
|
|
43
|
+
supportEmail: process.env.IMAP_CLIENT_SUPPORT_EMAIL || 'unknown@example.com'
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* 邮件默认值
|
|
48
|
+
*/
|
|
49
|
+
const EMAIL_DEFAULTS = {
|
|
50
|
+
box: 'INBOX',
|
|
51
|
+
limit: 10,
|
|
52
|
+
interval: 60, // 秒
|
|
53
|
+
timeout: 60000, // 毫秒
|
|
54
|
+
recentlyEmailTTL: 5 * 60 * 1000, // 5分钟
|
|
55
|
+
processedEmailTTL: 24 * 60 * 60 * 1000 // 24小时
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
module.exports = {
|
|
59
|
+
IMAP_FOLDERS,
|
|
60
|
+
DEFAULT_SMTP,
|
|
61
|
+
DEFAULT_IMAP,
|
|
62
|
+
IMAP_CLIENT_INFO,
|
|
63
|
+
EMAIL_DEFAULTS
|
|
64
|
+
}
|