foliko 1.0.53 → 1.0.55

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.
@@ -217,7 +217,6 @@ async function bootstrapDefaults(framework, config = {}) {
217
217
  console.error('[Bootstrap] No config provided, skipping plugin loading')
218
218
  return
219
219
  }
220
-
221
220
  // 设置 bootstrap 模式,避免重复启动
222
221
  framework.pluginManager.setBootstrapping(true)
223
222
 
@@ -228,7 +227,7 @@ async function bootstrapDefaults(framework, config = {}) {
228
227
  const CORE_PLUGINS = new Set([
229
228
  'install', 'ai', 'storage', 'tools', 'workflow', 'skill-manager',
230
229
  'mcp-executor', 'shell-executor', 'python-executor', 'session', 'web',
231
- 'audit', 'rules', 'scheduler', 'file-system', 'think',
230
+ 'audit', 'rules', 'scheduler', 'file-system', 'think', 'ambient',
232
231
  'python-plugin-loader', 'telegram', 'weixin', 'subagent-manager'
233
232
  ])
234
233
 
@@ -237,7 +236,7 @@ async function bootstrapDefaults(framework, config = {}) {
237
236
  const shouldLoad = (plugin) => {
238
237
  const name = typeof plugin === 'string' ? plugin : (plugin.name || plugin.prototype?.name)
239
238
  if (framework.pluginManager.has(name)) {
240
- console.log(`[Bootstrap] ${name} Plugin already loaded, skipping`)
239
+ framework._debug&&console.log(`[Bootstrap] ${name} Plugin already loaded, skipping`)
241
240
  return false
242
241
  }
243
242
  // 系统插件(system: true)不能禁用
@@ -248,7 +247,7 @@ async function bootstrapDefaults(framework, config = {}) {
248
247
  isSystem = plugin.system === true
249
248
  }
250
249
  if (isSystem && framework.pluginManager.isEnabled(name) === false) {
251
- console.log(`[Bootstrap] ${name} is a system plugin, cannot be disabled`)
250
+ framework._debug&&console.log(`[Bootstrap] ${name} is a system plugin, cannot be disabled`)
252
251
  }
253
252
  return true
254
253
  }
@@ -257,7 +256,7 @@ async function bootstrapDefaults(framework, config = {}) {
257
256
  if (shouldLoad('install')) {
258
257
  const { InstallPlugin } = require('./install-plugin')
259
258
  await framework.loadPlugin(new InstallPlugin({ agentDir: agentConfig.agentDir }))
260
- console.log('[Bootstrap] Install Plugin loaded')
259
+ framework._debug&&console.log('[Bootstrap] Install Plugin loaded')
261
260
  }
262
261
 
263
262
  // 合并 skillsDirs 配置(bootstrap 传入的优先)
@@ -266,7 +265,7 @@ async function bootstrapDefaults(framework, config = {}) {
266
265
  ...(agentConfig.skillsDirs || [])
267
266
  ]
268
267
 
269
- console.log('[Bootstrap] Loading default plugins...')
268
+ framework._debug&&console.log('[Bootstrap] Loading default plugins...')
270
269
  // AI 插件(如果已禁用则跳过)
271
270
  if (!shouldLoad('ai') || !(aiConfig.provider || aiConfig.model || aiConfig.apiKey)) {
272
271
  // 跳过或已禁用
@@ -282,7 +281,7 @@ async function bootstrapDefaults(framework, config = {}) {
282
281
  baseURL: aiConfig.baseURL
283
282
  })
284
283
  await framework.loadPlugin(aiPlugin)
285
- console.log('[Bootstrap] AI Plugin loaded')
284
+ framework._debug&&console.log('[Bootstrap] AI Plugin loaded')
286
285
  }
287
286
 
288
287
  // 1.5 创建主 Agent(供 Telegram 等需要绑定 Agent 的插件使用)
@@ -290,39 +289,39 @@ async function bootstrapDefaults(framework, config = {}) {
290
289
  const { Agent } = require('../src/core/agent')
291
290
  const aiPlugin = framework.pluginManager.get('ai')
292
291
  const aiClient = aiPlugin ? aiPlugin.getAIClient() : null
293
- console.log('[Bootstrap] Creating Main Agent - aiClient:', !!aiClient)
292
+ framework._debug&&console.log('[Bootstrap] Creating Main Agent - aiClient:', !!aiClient)
294
293
 
295
294
  framework._mainAgent = new Agent(framework, {
296
295
  name: 'MainAgent',
297
- systemPrompt: '你是一个有帮助的AI助手。',
296
+ systemPrompt: '你是一个智能助手。当用户提出问题或任务时,你会主动分析需求,选择合适的工具来获取信息或执行操作。你善于将复杂任务拆解为多个步骤,通过工具协作完成。',
298
297
  model: aiConfig.model,
299
298
  provider: aiConfig.provider,
300
299
  apiKey: aiConfig.apiKey,
301
300
  baseURL: aiConfig.baseURL
302
301
  })
303
302
  framework._agents.push(framework._mainAgent)
304
- console.log('[Bootstrap] Main Agent created, has _chatHandler:', !!framework._mainAgent._chatHandler)
303
+ framework._debug&&console.log('[Bootstrap] Main Agent created, has _chatHandler:', !!framework._mainAgent._chatHandler)
305
304
  }
306
305
 
307
306
  // 2. Storage 存储插件
308
307
  if (shouldLoad('storage')) {
309
308
  const { StoragePlugin } = require('./storage-plugin')
310
309
  await framework.loadPlugin(new StoragePlugin())
311
- console.log('[Bootstrap] Storage Plugin loaded')
310
+ framework._debug&&console.log('[Bootstrap] Storage Plugin loaded')
312
311
  }
313
312
 
314
313
  // 3. 内置工具插件
315
314
  if (shouldLoad('tools')) {
316
315
  const { ToolsPlugin } = require('./tools-plugin')
317
316
  await framework.loadPlugin(new ToolsPlugin())
318
- console.log('[Bootstrap] Tools Plugin loaded')
317
+ framework._debug&&console.log('[Bootstrap] Tools Plugin loaded')
319
318
  }
320
319
 
321
320
  // 4. 工作流插件
322
321
  if (shouldLoad('workflow')) {
323
322
  const { WorkflowPlugin } = require('../src/capabilities/workflow-engine')
324
323
  await framework.loadPlugin(new WorkflowPlugin())
325
- console.log('[Bootstrap] Workflow Plugin loaded')
324
+ framework._debug&&console.log('[Bootstrap] Workflow Plugin loaded')
326
325
  }
327
326
 
328
327
  // 5. Skill 管理器插件
@@ -331,7 +330,7 @@ async function bootstrapDefaults(framework, config = {}) {
331
330
  const { SkillManagerPlugin } = require('../src/capabilities/skill-manager')
332
331
  // 传递所有 skills 目录
333
332
  await framework.loadPlugin(new SkillManagerPlugin({ skillsDirs }))
334
- console.log('[Bootstrap] Skill Manager loaded')
333
+ framework._debug&&console.log('[Bootstrap] Skill Manager loaded')
335
334
  }
336
335
  }
337
336
 
@@ -349,77 +348,84 @@ async function bootstrapDefaults(framework, config = {}) {
349
348
  }))
350
349
  const { MCPExecutorPlugin } = require('../src/executors/mcp-executor')
351
350
  await framework.loadPlugin(new MCPExecutorPlugin({ servers }))
352
- console.log(`[Bootstrap] MCP Executor loaded${servers.length > 0 ? ` (${servers.length} servers)` : ' (no servers)'}`)
351
+ framework._debug&&console.log(`[Bootstrap] MCP Executor loaded${servers.length > 0 ? ` (${servers.length} servers)` : ' (no servers)'}`)
353
352
  }
354
353
 
355
354
  // 7. Shell 执行器插件
356
355
  if (shouldLoad('shell-executor')) {
357
356
  const { ShellExecutorPlugin } = require('./shell-executor-plugin')
358
357
  await framework.loadPlugin(new ShellExecutorPlugin())
359
- console.log('[Bootstrap] Shell Executor loaded')
358
+ framework._debug&&console.log('[Bootstrap] Shell Executor loaded')
360
359
  }
361
360
 
362
361
  // 8. Python 执行器插件
363
362
  if (shouldLoad('python-executor')) {
364
363
  const { PythonExecutorPlugin } = require('./python-executor-plugin')
365
364
  await framework.loadPlugin(new PythonExecutorPlugin())
366
- console.log('[Bootstrap] Python Executor loaded')
365
+ framework._debug&&console.log('[Bootstrap] Python Executor loaded')
367
366
  }
368
367
 
369
368
  // 8.5 Web Web服务插件
370
369
  if (shouldLoad('web')) {
371
370
  const { WebPlugin } = require('./web-plugin')
372
371
  await framework.loadPlugin(new WebPlugin())
373
- console.log('[Bootstrap] Web Plugin loaded')
372
+ framework._debug&&console.log('[Bootstrap] Web Plugin loaded')
374
373
  }
375
374
 
376
375
  // 9. Session 会话管理插件
377
376
  if (shouldLoad('session')) {
378
377
  const { SessionPlugin } = require('./session-plugin')
379
378
  await framework.loadPlugin(new SessionPlugin())
380
- console.log('[Bootstrap] Session Plugin loaded')
379
+ framework._debug&&console.log('[Bootstrap] Session Plugin loaded')
381
380
  }
382
381
 
383
382
  // 10. Audit 审计日志插件
384
383
  if (shouldLoad('audit')) {
385
384
  const { AuditPlugin } = require('./audit-plugin')
386
385
  await framework.loadPlugin(new AuditPlugin())
387
- console.log('[Bootstrap] Audit Plugin loaded')
386
+ framework._debug&&console.log('[Bootstrap] Audit Plugin loaded')
388
387
  }
389
388
 
390
389
  // 10. Rules 规则引擎插件
391
390
  if (shouldLoad('rules')) {
392
391
  const { RulesPlugin } = require('./rules-plugin')
393
392
  await framework.loadPlugin(new RulesPlugin())
394
- console.log('[Bootstrap] Rules Plugin loaded')
393
+ framework._debug&&console.log('[Bootstrap] Rules Plugin loaded')
395
394
  }
396
395
 
397
396
  // 11. Scheduler 定时任务插件
398
397
  if (shouldLoad('scheduler')) {
399
398
  const { SchedulerPlugin } = require('./scheduler-plugin')
400
399
  await framework.loadPlugin(new SchedulerPlugin())
401
- console.log('[Bootstrap] Scheduler Plugin loaded')
400
+ framework._debug&&console.log('[Bootstrap] Scheduler Plugin loaded')
402
401
  }
403
402
 
404
403
  // 11. FileSystem 文件系统插件
405
404
  if (shouldLoad('file-system')) {
406
405
  const { FileSystemPlugin } = require('./file-system-plugin')
407
406
  await framework.loadPlugin(new FileSystemPlugin())
408
- console.log('[Bootstrap] FileSystem Plugin loaded')
407
+ framework._debug&&console.log('[Bootstrap] FileSystem Plugin loaded')
409
408
  }
410
409
 
411
410
  // 12. Think 主动思考插件
412
411
  if (shouldLoad('think')) {
413
412
  const { ThinkPlugin } = require('./think-plugin')
414
413
  await framework.loadPlugin(new ThinkPlugin())
415
- console.log('[Bootstrap] Think Plugin loaded')
414
+ framework._debug&&console.log('[Bootstrap] Think Plugin loaded')
415
+ }
416
+
417
+ // 12.1 Ambient Agent 插件
418
+ if (shouldLoad('ambient')) {
419
+ const { AmbientAgentPlugin } = require('./ambient-agent-plugin')
420
+ await framework.loadPlugin(new AmbientAgentPlugin())
421
+ framework._debug&&console.log('[Bootstrap] Ambient Agent Plugin loaded')
416
422
  }
417
423
 
418
424
  // 12.5 Python 插件加载器
419
425
  if (shouldLoad('python-plugin-loader')) {
420
426
  const { PythonPluginLoader } = require('./python-plugin-loader')
421
427
  await framework.loadPlugin(new PythonPluginLoader({ agentDir: agentConfig.agentDir }))
422
- console.log('[Bootstrap] Python Plugin Loader loaded')
428
+ framework._debug&&console.log('[Bootstrap] Python Plugin Loader loaded')
423
429
  }
424
430
 
425
431
  // 12.6 Telegram 插件(默认禁用,需要在 plugins.json 中设置 enabled: true)
@@ -483,7 +489,7 @@ async function bootstrapDefaults(framework, config = {}) {
483
489
  try {
484
490
  const { SubAgentManagerPlugin } = require('./subagent-plugin')
485
491
  await framework.loadPlugin(new SubAgentManagerPlugin({ agentsDir: agentConfig.agentsDir }))
486
- console.log('[Bootstrap] SubAgent Manager loaded')
492
+ framework._debug&&console.log('[Bootstrap] SubAgent Manager loaded')
487
493
  } catch (err) {
488
494
  console.warn('[Bootstrap] SubAgent Manager failed:', err.message)
489
495
  }
@@ -492,7 +498,7 @@ async function bootstrapDefaults(framework, config = {}) {
492
498
  // 13. 加载自定义插件
493
499
  await loadCustomPlugins(framework, agentConfig)
494
500
 
495
- console.log('[Bootstrap] All plugins loaded')
501
+ framework._debug&&console.log('[Bootstrap] All plugins loaded')
496
502
 
497
503
  // 统一启动所有插件(避免重复启动)
498
504
  await framework.pluginManager.startAll()
@@ -500,8 +506,8 @@ async function bootstrapDefaults(framework, config = {}) {
500
506
  // 清除 bootstrap 模式
501
507
  framework.pluginManager.setBootstrapping(false)
502
508
 
503
- console.log('[Bootstrap] Plugins:', framework.pluginManager.getAll().map(p => p.name))
504
- console.log('[Bootstrap] Tools:', framework.getTools().map(t => t.name))
509
+ framework._debug&&console.log('[Bootstrap] Loaded plugins ', framework.pluginManager.getAll().length)
510
+ framework._debug&&console.log('[Bootstrap] Loaded tools ', framework.getTools().length)
505
511
  }
506
512
 
507
513
  /**
@@ -537,7 +543,7 @@ function resolvePluginPath(pluginsDir, name) {
537
543
  if (fs.existsSync(indexPath)) {
538
544
  return { path: indexPath, type: 'folder' }
539
545
  }
540
- console.warn(`[resolvePluginPath] No entry point found for plugin folder: ${name}`)
546
+ //console.warn(`[resolvePluginPath] No entry point found for plugin folder: ${name}`)
541
547
  return null
542
548
  }
543
549
 
@@ -593,7 +599,7 @@ async function loadCustomPlugins(framework, agentConfig) {
593
599
  try {
594
600
  const resolved = resolvePluginPath(pluginsDir, pluginName)
595
601
  if (!resolved) {
596
- console.warn(`[Bootstrap] Cannot resolve plugin: ${pluginName}`)
602
+ //console.warn(`[Bootstrap] Cannot resolve plugin: ${pluginName}`)
597
603
  continue
598
604
  }
599
605
 
@@ -624,7 +630,7 @@ async function loadCustomPlugins(framework, agentConfig) {
624
630
  continue
625
631
  }
626
632
 
627
- console.log(`[Bootstrap] Loading custom plugin: ${pluginName} (${type})`)
633
+ //console.log(`[Bootstrap] Loading custom plugin: ${pluginName} (${type})`)
628
634
  // .agent/plugins 目录下的插件强制启用,不受 state 文件 enabled: false 影响
629
635
  await framework.pluginManager.load(plugin, { forceEnabled: true })
630
636
  } catch (err) {