foliko 1.1.75 → 1.1.76
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/settings.local.json +5 -1
- package/.dockerignore +45 -45
- package/.env.example +56 -56
- package/cli/src/ui/chat-ui.js +56 -126
- package/cli/src/ui/components/agent-mention-provider.js +175 -0
- package/cli/src/ui/components/chained-autocomplete-provider.js +64 -0
- package/cli/src/ui/{footer-bar.js → components/footer-bar.js} +2 -2
- package/docker-compose.yml +33 -33
- package/docs/features.md +120 -120
- package/docs/quick-reference.md +160 -160
- package/package.json +1 -1
- package/plugins/ai-plugin.js +3 -3
- package/plugins/ambient-agent/ExplorerLoop.js +17 -17
- package/plugins/ambient-agent/index.js +2 -2
- package/plugins/data-splitter-plugin.js +9 -9
- package/plugins/default-plugins.js +7 -8
- package/plugins/extension-executor-plugin.js +2 -2
- package/plugins/feishu-plugin.js +5 -5
- package/plugins/install-plugin.js +4 -4
- package/plugins/memory-plugin.js +1 -1
- package/plugins/plugin-manager-plugin.js +9 -8
- package/plugins/python-plugin-loader.js +2 -2
- package/plugins/qq-plugin.js +4 -4
- package/plugins/rules-plugin.js +2 -2
- package/plugins/scheduler-plugin.js +13 -13
- package/plugins/session-plugin.js +2 -2
- package/plugins/subagent-plugin.js +1 -1
- package/plugins/telegram-plugin.js +6 -6
- package/plugins/think-plugin.js +4 -4
- package/plugins/tools-plugin.js +1 -1
- package/plugins/web-plugin.js +16 -16
- package/skills/find-skills/SKILL.md +133 -133
- package/skills/foliko-dev/AGENTS.md +236 -236
- package/skills/mcp-usage/SKILL.md +200 -200
- package/skills/subagent-guide/SKILL.md +237 -237
- package/skills/workflow-guide/SKILL.md +646 -646
- package/src/capabilities/skill-manager.js +5 -5
- package/src/capabilities/workflow-engine.js +5 -5
- package/src/core/agent-chat.js +8 -8
- package/src/core/agent.js +80 -5
- package/src/core/branch-summary-auto.js +4 -4
- package/src/core/chat-session.js +1 -0
- package/src/core/session-entry.js +14 -6
- package/src/core/session-manager.js +15 -3
- package/src/executors/mcp-executor.js +21 -25
- package/src/utils/data-splitter.js +3 -3
- package/src/utils/message-validator.js +1 -1
- package/website_v2/styles/animations.css +7 -7
- /package/cli/src/ui/{message-bubble.js → components/message-bubble.js} +0 -0
- /package/cli/src/ui/{status-bar.js → components/status-bar.js} +0 -0
|
@@ -87,7 +87,7 @@ class InstallPlugin extends Plugin {
|
|
|
87
87
|
? path.resolve(process.cwd(), targetPath)
|
|
88
88
|
: this._agentDir
|
|
89
89
|
|
|
90
|
-
log.info(` Installing ${packageName} to ${installPath}...`)
|
|
90
|
+
//log.info(` Installing ${packageName} to ${installPath}...`)
|
|
91
91
|
|
|
92
92
|
// 确保目标目录存在
|
|
93
93
|
if (!fs.existsSync(installPath)) {
|
|
@@ -100,7 +100,7 @@ class InstallPlugin extends Plugin {
|
|
|
100
100
|
cwd: installPath
|
|
101
101
|
})
|
|
102
102
|
|
|
103
|
-
log.info(` Successfully installed ${packageName}`)
|
|
103
|
+
//log.info(` Successfully installed ${packageName}`)
|
|
104
104
|
|
|
105
105
|
return {
|
|
106
106
|
success: true,
|
|
@@ -127,7 +127,7 @@ class InstallPlugin extends Plugin {
|
|
|
127
127
|
? path.resolve(process.cwd(), targetPath)
|
|
128
128
|
: pkgDir
|
|
129
129
|
|
|
130
|
-
log.info(` Installing dependencies from ${resolvedPkgPath} to ${installPath}...`)
|
|
130
|
+
//log.info(` Installing dependencies from ${resolvedPkgPath} to ${installPath}...`)
|
|
131
131
|
|
|
132
132
|
// 读取 package.json 获取要安装的包
|
|
133
133
|
const pkg = JSON.parse(fs.readFileSync(resolvedPkgPath, 'utf-8'))
|
|
@@ -155,7 +155,7 @@ class InstallPlugin extends Plugin {
|
|
|
155
155
|
cwd: pkgDir
|
|
156
156
|
})
|
|
157
157
|
|
|
158
|
-
log.info(` Successfully installed ${packages.length} packages`)
|
|
158
|
+
//log.info(` Successfully installed ${packages.length} packages`)
|
|
159
159
|
|
|
160
160
|
return {
|
|
161
161
|
success: true,
|
package/plugins/memory-plugin.js
CHANGED
|
@@ -139,7 +139,7 @@ class PluginManagerPlugin extends Plugin {
|
|
|
139
139
|
*/
|
|
140
140
|
async _listPlugins(repo) {
|
|
141
141
|
try {
|
|
142
|
-
log.info(`Listing plugins from ${repo}...`);
|
|
142
|
+
//log.info(`Listing plugins from ${repo}...`);
|
|
143
143
|
|
|
144
144
|
const repoInfo = parseGitUrl(repo);
|
|
145
145
|
if (!repoInfo) {
|
|
@@ -244,7 +244,7 @@ class PluginManagerPlugin extends Plugin {
|
|
|
244
244
|
const tmpDir = path.join(require('os').tmpdir(), `foliko-plugin-publish-${Date.now()}`);
|
|
245
245
|
|
|
246
246
|
try {
|
|
247
|
-
log.info(`Publishing plugin "${pluginName}" to ${repo}...`);
|
|
247
|
+
//log.info(`Publishing plugin "${pluginName}" to ${repo}...`);
|
|
248
248
|
|
|
249
249
|
// 克隆仓库
|
|
250
250
|
fs.mkdirSync(tmpDir, { recursive: true });
|
|
@@ -253,7 +253,7 @@ class PluginManagerPlugin extends Plugin {
|
|
|
253
253
|
try {
|
|
254
254
|
gitCommand(`clone ${repo} "${tmpDir}" --depth 1`, process.cwd());
|
|
255
255
|
} catch (err) {
|
|
256
|
-
log.info('Initializing new repository...');
|
|
256
|
+
//log.info('Initializing new repository...');
|
|
257
257
|
fs.mkdirSync(tmpDir, { recursive: true });
|
|
258
258
|
gitCommand('init', tmpDir);
|
|
259
259
|
gitCommand(`remote add origin ${repo}`, tmpDir);
|
|
@@ -267,7 +267,7 @@ class PluginManagerPlugin extends Plugin {
|
|
|
267
267
|
// 复制插件
|
|
268
268
|
let pluginContent = null;
|
|
269
269
|
if (fs.existsSync(pluginSourceDir) && fs.statSync(pluginSourceDir).isDirectory()) {
|
|
270
|
-
log.info('Copying plugin directory...');
|
|
270
|
+
// log.info('Copying plugin directory...');
|
|
271
271
|
copyDirRecursive(pluginSourceDir, pluginDir);
|
|
272
272
|
|
|
273
273
|
const mainJsPath = path.join(pluginSourceDir, `${pluginName}.js`);
|
|
@@ -275,7 +275,7 @@ class PluginManagerPlugin extends Plugin {
|
|
|
275
275
|
pluginContent = fs.readFileSync(mainJsPath, 'utf-8');
|
|
276
276
|
}
|
|
277
277
|
} else {
|
|
278
|
-
log.info('Copying plugin file...');
|
|
278
|
+
//log.info('Copying plugin file...');
|
|
279
279
|
pluginContent = fs.readFileSync(pluginPath, 'utf-8');
|
|
280
280
|
const targetPath = path.join(pluginDir, `${pluginName}.js`);
|
|
281
281
|
fs.writeFileSync(targetPath, pluginContent);
|
|
@@ -289,6 +289,7 @@ class PluginManagerPlugin extends Plugin {
|
|
|
289
289
|
// 创建 README.md
|
|
290
290
|
const readmePath = path.join(pluginDir, 'README.md');
|
|
291
291
|
if (!fs.existsSync(readmePath)) {
|
|
292
|
+
//log.info('Creating README.md...');
|
|
292
293
|
const descMatch = pluginContent?.match(/\*\*Description\*\*:\s*(.+)/) ||
|
|
293
294
|
pluginContent?.match(/description[:\s]+(.+)/i);
|
|
294
295
|
const desc = descMatch ? descMatch[1] : `Foliko plugin: ${pluginName}`;
|
|
@@ -310,7 +311,7 @@ class PluginManagerPlugin extends Plugin {
|
|
|
310
311
|
gitCommand(`commit -m "Add/update plugin: ${pluginName}"`, tmpDir);
|
|
311
312
|
gitCommand(`push ${isNewRepo ? '-u' : ''} origin main`, tmpDir);
|
|
312
313
|
|
|
313
|
-
log.info(`Plugin "${pluginName}" published successfully!`);
|
|
314
|
+
//log.info(`Plugin "${pluginName}" published successfully!`);
|
|
314
315
|
|
|
315
316
|
return {
|
|
316
317
|
success: true,
|
|
@@ -334,7 +335,7 @@ class PluginManagerPlugin extends Plugin {
|
|
|
334
335
|
const tmpDir = path.join(require('os').tmpdir(), `foliko-plugin-install-${Date.now()}`);
|
|
335
336
|
|
|
336
337
|
try {
|
|
337
|
-
log.info(`Installing plugin "${pluginName}" from ${repo}...`);
|
|
338
|
+
//log.info(`Installing plugin "${pluginName}" from ${repo}...`);
|
|
338
339
|
|
|
339
340
|
// 克隆仓库
|
|
340
341
|
fs.mkdirSync(tmpDir, { recursive: true });
|
|
@@ -381,7 +382,7 @@ class PluginManagerPlugin extends Plugin {
|
|
|
381
382
|
fs.copyFileSync(sourcePath, path.join(targetDir, `${pluginName}.js`));
|
|
382
383
|
}
|
|
383
384
|
|
|
384
|
-
log.info(`Plugin "${pluginName}" installed to ${targetDir}`);
|
|
385
|
+
//log.info(`Plugin "${pluginName}" installed to ${targetDir}`);
|
|
385
386
|
|
|
386
387
|
return {
|
|
387
388
|
success: true,
|
|
@@ -326,7 +326,7 @@ class PythonPluginLoader extends Plugin {
|
|
|
326
326
|
info: pluginInfo,
|
|
327
327
|
code: fs.readFileSync(pluginPath, 'utf-8')
|
|
328
328
|
})
|
|
329
|
-
log.info(` Loaded: ${pluginName}`)
|
|
329
|
+
//log.info(` Loaded: ${pluginName}`)
|
|
330
330
|
|
|
331
331
|
// 注册插件的每个工具
|
|
332
332
|
if (pluginInfo.tools && Array.isArray(pluginInfo.tools)) {
|
|
@@ -340,7 +340,7 @@ class PythonPluginLoader extends Plugin {
|
|
|
340
340
|
}
|
|
341
341
|
}
|
|
342
342
|
|
|
343
|
-
log.info(` Total Python plugins: ${this._pythonPlugins.size}`)
|
|
343
|
+
//log.info(` Total Python plugins: ${this._pythonPlugins.size}`)
|
|
344
344
|
}
|
|
345
345
|
|
|
346
346
|
/**
|
package/plugins/qq-plugin.js
CHANGED
|
@@ -404,7 +404,7 @@ class QQPlugin extends Plugin {
|
|
|
404
404
|
markdownSupport: this.config.markdownSupport,
|
|
405
405
|
})
|
|
406
406
|
|
|
407
|
-
log.info('QQ Bot 已连接')
|
|
407
|
+
//log.info('QQ Bot 已连接')
|
|
408
408
|
|
|
409
409
|
// 预先创建默认 session scope,避免收到消息时延迟
|
|
410
410
|
this._ensureDefaultSessionScopes()
|
|
@@ -430,7 +430,7 @@ class QQPlugin extends Plugin {
|
|
|
430
430
|
this._setupSessionScopeListeners(groupAgent, groupSessionId, null, defaultGroupId, 'group')
|
|
431
431
|
}
|
|
432
432
|
|
|
433
|
-
log.info('Default session scopes prepared')
|
|
433
|
+
//log.info('Default session scopes prepared')
|
|
434
434
|
} catch (err) {
|
|
435
435
|
log.warn('Failed to prepare default session scopes:', err.message)
|
|
436
436
|
}
|
|
@@ -499,7 +499,7 @@ class QQPlugin extends Plugin {
|
|
|
499
499
|
async _handleInteraction(event) {
|
|
500
500
|
try {
|
|
501
501
|
const { button_data, button_id } = event.raw?.data?.resolved || {}
|
|
502
|
-
log.info(`Button interaction: ${button_id} - ${button_data}`)
|
|
502
|
+
//log.info(`Button interaction: ${button_id} - ${button_data}`)
|
|
503
503
|
|
|
504
504
|
// 确认交互
|
|
505
505
|
await this._client.acknowledgeInteraction(event.id, 0, {
|
|
@@ -1038,7 +1038,7 @@ class QQPlugin extends Plugin {
|
|
|
1038
1038
|
if (this._client) {
|
|
1039
1039
|
this._client.disconnect()
|
|
1040
1040
|
this._client = null
|
|
1041
|
-
log.info('Bot stopped')
|
|
1041
|
+
//log.info('Bot stopped')
|
|
1042
1042
|
}
|
|
1043
1043
|
}
|
|
1044
1044
|
|
package/plugins/rules-plugin.js
CHANGED
|
@@ -171,7 +171,7 @@ class RulesPlugin extends Plugin {
|
|
|
171
171
|
const resolvedDir = path.resolve(process.cwd(), rulesDir)
|
|
172
172
|
|
|
173
173
|
if (!fs.existsSync(resolvedDir)) {
|
|
174
|
-
log.info(` Rules directory not found: ${resolvedDir}`)
|
|
174
|
+
//log.info(` Rules directory not found: ${resolvedDir}`)
|
|
175
175
|
return
|
|
176
176
|
}
|
|
177
177
|
|
|
@@ -191,7 +191,7 @@ class RulesPlugin extends Plugin {
|
|
|
191
191
|
this._rules.push(rule)
|
|
192
192
|
}
|
|
193
193
|
|
|
194
|
-
log.info(` Loaded ${rules.length} rules from ${file}`)
|
|
194
|
+
//log.info(` Loaded ${rules.length} rules from ${file}`)
|
|
195
195
|
}
|
|
196
196
|
} catch (err) {
|
|
197
197
|
log.error(` Failed to load rules: ${err.message}`)
|
|
@@ -578,12 +578,12 @@ class SchedulerPlugin extends Plugin {
|
|
|
578
578
|
const savedTasks = this._taskStore.loadTasks()
|
|
579
579
|
if (!savedTasks || savedTasks.length === 0) return
|
|
580
580
|
|
|
581
|
-
log.info(` 加载 ${savedTasks.length} 个持久化任务...`)
|
|
581
|
+
//log.info(` 加载 ${savedTasks.length} 个持久化任务...`)
|
|
582
582
|
|
|
583
583
|
for (const saved of savedTasks) {
|
|
584
584
|
// 跳过已过期的任务或已清理的任务
|
|
585
585
|
if (saved.type === 'once' && saved.runCount > 0) {
|
|
586
|
-
log.info(` 跳过已完成的一次性任务: ${saved.name}`)
|
|
586
|
+
//log.info(` 跳过已完成的一次性任务: ${saved.name}`)
|
|
587
587
|
continue
|
|
588
588
|
}
|
|
589
589
|
|
|
@@ -597,7 +597,7 @@ class SchedulerPlugin extends Plugin {
|
|
|
597
597
|
})
|
|
598
598
|
this._tasks.set(task.id, task)
|
|
599
599
|
this._taskStats.total++
|
|
600
|
-
log.info(` 已恢复 Cron 任务: ${task.name}`)
|
|
600
|
+
//log.info(` 已恢复 Cron 任务: ${task.name}`)
|
|
601
601
|
} catch (err) {
|
|
602
602
|
log.error(` 恢复 Cron 任务失败: ${task.name}`, err.message)
|
|
603
603
|
}
|
|
@@ -610,7 +610,7 @@ class SchedulerPlugin extends Plugin {
|
|
|
610
610
|
})
|
|
611
611
|
this._tasks.set(task.id, task)
|
|
612
612
|
this._taskStats.total++
|
|
613
|
-
log.info(` 已恢复 Shell Cron 任务: ${task.name}`)
|
|
613
|
+
//log.info(` 已恢复 Shell Cron 任务: ${task.name}`)
|
|
614
614
|
} catch (err) {
|
|
615
615
|
log.error(` 恢复 Shell Cron 任务失败: ${task.name}`, err.message)
|
|
616
616
|
}
|
|
@@ -625,7 +625,7 @@ class SchedulerPlugin extends Plugin {
|
|
|
625
625
|
}, newDelay)
|
|
626
626
|
this._tasks.set(task.id, task)
|
|
627
627
|
this._taskStats.total++
|
|
628
|
-
log.info(` 已恢复一次性任务: ${task.name},将在 ${newDelay}ms 后执行`)
|
|
628
|
+
//log.info(` 已恢复一次性任务: ${task.name},将在 ${newDelay}ms 后执行`)
|
|
629
629
|
}
|
|
630
630
|
}
|
|
631
631
|
// 重新调度绝对时间任务
|
|
@@ -638,9 +638,9 @@ class SchedulerPlugin extends Plugin {
|
|
|
638
638
|
}, delay)
|
|
639
639
|
this._tasks.set(task.id, task)
|
|
640
640
|
this._taskStats.total++
|
|
641
|
-
log.info(` 已恢复一次性任务: ${task.name},将在 ${runAt} 执行`)
|
|
641
|
+
//log.info(` 已恢复一次性任务: ${task.name},将在 ${runAt} 执行`)
|
|
642
642
|
} else {
|
|
643
|
-
log.info(` 跳过已过期的任务: ${task.name}`)
|
|
643
|
+
//log.info(` 跳过已过期的任务: ${task.name}`)
|
|
644
644
|
}
|
|
645
645
|
}
|
|
646
646
|
}
|
|
@@ -665,12 +665,12 @@ class SchedulerPlugin extends Plugin {
|
|
|
665
665
|
* 执行任务
|
|
666
666
|
*/
|
|
667
667
|
async _executeTask(task) {
|
|
668
|
-
// log.info(` Executing task: ${task.name} (${task.id})`)
|
|
669
|
-
// log.info(` Message: ${task.message}`)
|
|
670
|
-
// if (task.sessionId) {
|
|
671
|
-
// log.info(` Target session: ${task.sessionId}`)
|
|
672
|
-
// }
|
|
673
|
-
// log.info(` LLM mode: ${task.llm ? 'enabled' : 'disabled'}`)
|
|
668
|
+
// //log.info(` Executing task: ${task.name} (${task.id})`)
|
|
669
|
+
// //log.info(` Message: ${task.message}`)
|
|
670
|
+
// // if (task.sessionId) {
|
|
671
|
+
// // //log.info(` Target session: ${task.sessionId}`)
|
|
672
|
+
// // }
|
|
673
|
+
// //log.info(` LLM mode: ${task.llm ? 'enabled' : 'disabled'}`)
|
|
674
674
|
|
|
675
675
|
task.lastRun = new Date()
|
|
676
676
|
task.runCount++
|
|
@@ -405,7 +405,7 @@ class SessionPlugin extends Plugin {
|
|
|
405
405
|
this._cleanupTimer = setInterval(async () => {
|
|
406
406
|
await this._doCleanup();
|
|
407
407
|
}, this.config.cleanupInterval);
|
|
408
|
-
log.info(`Auto cleanup started (interval: ${this.config.cleanupInterval}ms)`);
|
|
408
|
+
//log.info(`Auto cleanup started (interval: ${this.config.cleanupInterval}ms)`);
|
|
409
409
|
}
|
|
410
410
|
|
|
411
411
|
/**
|
|
@@ -449,7 +449,7 @@ class SessionPlugin extends Plugin {
|
|
|
449
449
|
}
|
|
450
450
|
|
|
451
451
|
if (cleanedCount > 0) {
|
|
452
|
-
log.info(`Auto cleanup completed: cleaned ${cleanedCount} sessions`);
|
|
452
|
+
//log.info(`Auto cleanup completed: cleaned ${cleanedCount} sessions`);
|
|
453
453
|
}
|
|
454
454
|
} catch (err) {
|
|
455
455
|
log.error(`Auto cleanup error: ${err.message}`);
|
|
@@ -590,7 +590,7 @@ class SubAgentManagerPlugin extends Plugin {
|
|
|
590
590
|
const agentsDir = this.config.agentsDir || path.join(process.cwd(), '.foliko', 'agents')
|
|
591
591
|
//log.info(' _loadAgentsFromDir called, agentsDir:', agentsDir)
|
|
592
592
|
if (!fs.existsSync(agentsDir)) {
|
|
593
|
-
log.info(' agentsDir not found or does not exist')
|
|
593
|
+
//log.info(' agentsDir not found or does not exist')
|
|
594
594
|
return
|
|
595
595
|
}
|
|
596
596
|
|
|
@@ -75,7 +75,7 @@ class TelegramPlugin extends Plugin {
|
|
|
75
75
|
if (this._sessionPlugin) {
|
|
76
76
|
this._sessionDeleteHandler = (sessionId) => {
|
|
77
77
|
if (sessionId.startsWith('telegram_')) {
|
|
78
|
-
log.info(` Session deleted: ${sessionId}`)
|
|
78
|
+
// log.info(` Session deleted: ${sessionId}`)
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
this._sessionPlugin.on('session:deleted', this._sessionDeleteHandler)
|
|
@@ -90,7 +90,7 @@ class TelegramPlugin extends Plugin {
|
|
|
90
90
|
const TelegramBot = require('node-telegram-bot-api')
|
|
91
91
|
this._bot = new TelegramBot(this.config.botToken, { polling: true })
|
|
92
92
|
|
|
93
|
-
log.info(' Bot started successfully')
|
|
93
|
+
// log.info(' Bot started successfully')
|
|
94
94
|
|
|
95
95
|
this._bot.setMyCommands([
|
|
96
96
|
{ command: 'start', description: '显示帮助信息' },
|
|
@@ -108,7 +108,7 @@ class TelegramPlugin extends Plugin {
|
|
|
108
108
|
|
|
109
109
|
if (this._framework) {
|
|
110
110
|
this._framework.on('agent:created', (agent) => {
|
|
111
|
-
log.info(' New agent created:', agent.name)
|
|
111
|
+
// log.info(' New agent created:', agent.name)
|
|
112
112
|
})
|
|
113
113
|
|
|
114
114
|
// 监听统一通知事件
|
|
@@ -178,7 +178,7 @@ class TelegramPlugin extends Plugin {
|
|
|
178
178
|
|
|
179
179
|
try {
|
|
180
180
|
await this._bot.sendMessage(chatId, notificationText)
|
|
181
|
-
log.info(` Notification sent to chat ${chatId}`)
|
|
181
|
+
// log.info(` Notification sent to chat ${chatId}`)
|
|
182
182
|
} catch (err) {
|
|
183
183
|
log.error(` Failed to send notification:`, err.message)
|
|
184
184
|
}
|
|
@@ -199,7 +199,7 @@ class TelegramPlugin extends Plugin {
|
|
|
199
199
|
|
|
200
200
|
try {
|
|
201
201
|
await this._bot.sendMessage(chatId, notificationText)
|
|
202
|
-
log.info(` Webhook notification sent to chat ${chatId}`)
|
|
202
|
+
// log.info(` Webhook notification sent to chat ${chatId}`)
|
|
203
203
|
} catch (err) {
|
|
204
204
|
log.error(` Failed to send webhook notification:`, err.message)
|
|
205
205
|
}
|
|
@@ -627,7 +627,7 @@ class TelegramPlugin extends Plugin {
|
|
|
627
627
|
if (this._bot) {
|
|
628
628
|
this._bot.stopPolling()
|
|
629
629
|
this._bot = null
|
|
630
|
-
log.info(' Bot stopped')
|
|
630
|
+
// log.info(' Bot stopped')
|
|
631
631
|
}
|
|
632
632
|
}
|
|
633
633
|
|
package/plugins/think-plugin.js
CHANGED
|
@@ -107,7 +107,7 @@ class ThinkPlugin extends Plugin {
|
|
|
107
107
|
_createThinkSubagent() {
|
|
108
108
|
const aiPlugin = this._framework.pluginManager?.get('ai');
|
|
109
109
|
const aiConfig = aiPlugin ? aiPlugin.getConfig() : {};
|
|
110
|
-
log.info(`[Think] createSubAgent AI config: provider=${aiConfig.provider}, model=${aiConfig.model}, hasKey=${!!aiConfig.apiKey}`);
|
|
110
|
+
// log.info(`[Think] createSubAgent AI config: provider=${aiConfig.provider}, model=${aiConfig.model}, hasKey=${!!aiConfig.apiKey}`);
|
|
111
111
|
return this._framework.createSubAgent({
|
|
112
112
|
name: 'think',
|
|
113
113
|
role: '思考助手',
|
|
@@ -159,13 +159,13 @@ class ThinkPlugin extends Plugin {
|
|
|
159
159
|
|
|
160
160
|
// 优先使用外部传入的 agent,否则使用缓存的 think agent
|
|
161
161
|
const thinkAgent = externalAgent || this._thinkAgent || (this._thinkAgent = this._createThinkSubagent())
|
|
162
|
-
log.info(`[Think] thinkAgent apiKey: ${thinkAgent.apiKey ? thinkAgent.apiKey.substring(0,8) + '...' : 'null'}, provider: ${thinkAgent.provider}, model: ${thinkAgent.model}`)
|
|
162
|
+
// log.info(`[Think] thinkAgent apiKey: ${thinkAgent.apiKey ? thinkAgent.apiKey.substring(0,8) + '...' : 'null'}, provider: ${thinkAgent.provider}, model: ${thinkAgent.model}`)
|
|
163
163
|
|
|
164
164
|
let result
|
|
165
165
|
if (contextMessages && contextMessages.length > 0) {
|
|
166
166
|
// 持续对话模式:传入上下文消息
|
|
167
167
|
const messages = [...contextMessages, { role: 'user', content: reflectPrompt }]
|
|
168
|
-
log.info(`[Think] round with context: contextLen=${contextMessages.length}, totalMsgs=${messages.length}`);
|
|
168
|
+
// log.info(`[Think] round with context: contextLen=${contextMessages.length}, totalMsgs=${messages.length}`);
|
|
169
169
|
result = await thinkAgent.chat(messages)
|
|
170
170
|
} else {
|
|
171
171
|
// 普通模式:新对话
|
|
@@ -182,7 +182,7 @@ class ThinkPlugin extends Plugin {
|
|
|
182
182
|
timestamp: new Date()
|
|
183
183
|
}
|
|
184
184
|
|
|
185
|
-
log.info(`[Think] result.messages length: ${result.messages ? result.messages.length : 'undefined/null'}, success: ${result.success}, msgLen: ${(result.message || '').length}`);
|
|
185
|
+
// log.info(`[Think] result.messages length: ${result.messages ? result.messages.length : 'undefined/null'}, success: ${result.success}, msgLen: ${(result.message || '').length}`);
|
|
186
186
|
this._thoughts.push(thought)
|
|
187
187
|
if (this._thoughts.length > 100) {
|
|
188
188
|
this._thoughts = this._thoughts.slice(-100)
|
package/plugins/tools-plugin.js
CHANGED
package/plugins/web-plugin.js
CHANGED
|
@@ -131,7 +131,7 @@ class WebPlugin extends Plugin {
|
|
|
131
131
|
const config = this._webStore.loadConfig()
|
|
132
132
|
if (!config) return
|
|
133
133
|
|
|
134
|
-
log.info(` 加载 Web 配置...`)
|
|
134
|
+
// log.info(` 加载 Web 配置...`)
|
|
135
135
|
|
|
136
136
|
// 恢复前先清空,避免 install -> reload 重复加载导致数据翻倍
|
|
137
137
|
this._routes = []
|
|
@@ -153,7 +153,7 @@ class WebPlugin extends Plugin {
|
|
|
153
153
|
description: route.description || ''
|
|
154
154
|
})
|
|
155
155
|
hasRoutes = true
|
|
156
|
-
log.info(` 恢复路由: ${route.method} ${route.path}`)
|
|
156
|
+
// log.info(` 恢复路由: ${route.method} ${route.path}`)
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
159
|
}
|
|
@@ -169,7 +169,7 @@ class WebPlugin extends Plugin {
|
|
|
169
169
|
awaitResponse: webhook.awaitResponse || false
|
|
170
170
|
})
|
|
171
171
|
hasWebhooks = true
|
|
172
|
-
log.info(` 恢复 Webhook: ${webhook.path}`)
|
|
172
|
+
// log.info(` 恢复 Webhook: ${webhook.path}`)
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
175
|
}
|
|
@@ -184,14 +184,14 @@ class WebPlugin extends Plugin {
|
|
|
184
184
|
options: staticItem.options || { dotfiles: 'ignore', index: 'index.html' }
|
|
185
185
|
})
|
|
186
186
|
hasStatics = true
|
|
187
|
-
log.info(` 恢复静态资源: ${staticItem.urlPath} -> ${staticItem.folder}`)
|
|
187
|
+
// log.info(` 恢复静态资源: ${staticItem.urlPath} -> ${staticItem.folder}`)
|
|
188
188
|
}
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
191
|
|
|
192
192
|
// 如果有恢复的路由/webhook/静态资源,自动启动服务器
|
|
193
193
|
if ((hasRoutes || hasWebhooks || hasStatics) && !this._server) {
|
|
194
|
-
log.info(` 恢复的 Web 配置需要启动服务器...`)
|
|
194
|
+
// log.info(` 恢复的 Web 配置需要启动服务器...`)
|
|
195
195
|
this._startServer().catch(err => {
|
|
196
196
|
log.error(` 自动启动服务器失败:`, err.message)
|
|
197
197
|
})
|
|
@@ -371,7 +371,7 @@ class WebPlugin extends Plugin {
|
|
|
371
371
|
hostname: this._host
|
|
372
372
|
})
|
|
373
373
|
const serverUrl = this._getUrl()
|
|
374
|
-
log.info(` Server started on ${serverUrl}`)
|
|
374
|
+
// log.info(` Server started on ${serverUrl}`)
|
|
375
375
|
return {
|
|
376
376
|
success: true,
|
|
377
377
|
message: `Server started on ${serverUrl}`,
|
|
@@ -397,7 +397,7 @@ class WebPlugin extends Plugin {
|
|
|
397
397
|
this._server.close()
|
|
398
398
|
this._server = null
|
|
399
399
|
this._app = null
|
|
400
|
-
log.info(' Server stopped')
|
|
400
|
+
// log.info(' Server stopped')
|
|
401
401
|
return { success: true, message: 'Server stopped' }
|
|
402
402
|
}
|
|
403
403
|
|
|
@@ -527,7 +527,7 @@ class WebPlugin extends Plugin {
|
|
|
527
527
|
// 不等待,立即返回
|
|
528
528
|
webhookAgent.chat(`${prompt}\n\n数据:\n${JSON.stringify(webhookData, null, 2)}`).then(result => {
|
|
529
529
|
const responseText = result.message || ''
|
|
530
|
-
log.info(` Webhook processed (${webhook.path}), LLM response (${responseText.length} chars)`)
|
|
530
|
+
// log.info(` Webhook processed (${webhook.path}), LLM response (${responseText.length} chars)`)
|
|
531
531
|
|
|
532
532
|
// 添加到 session 历史
|
|
533
533
|
if (sessionId) {
|
|
@@ -558,7 +558,7 @@ class WebPlugin extends Plugin {
|
|
|
558
558
|
try {
|
|
559
559
|
const result = await webhookAgent.chat(`${prompt}\n\n数据:\n${JSON.stringify(webhookData, null, 2)}`)
|
|
560
560
|
const responseText = result.message || result.text || ''
|
|
561
|
-
log.info(` Webhook processed (${webhook.path}), LLM response (${responseText.length} chars)`)
|
|
561
|
+
// log.info(` Webhook processed (${webhook.path}), LLM response (${responseText.length} chars)`)
|
|
562
562
|
|
|
563
563
|
// 添加到 session 历史
|
|
564
564
|
if (sessionId) {
|
|
@@ -608,7 +608,7 @@ class WebPlugin extends Plugin {
|
|
|
608
608
|
// 持久化保存
|
|
609
609
|
this._saveConfig()
|
|
610
610
|
|
|
611
|
-
log.info(` Route registered: ${method} ${path}`)
|
|
611
|
+
// log.info(` Route registered: ${method} ${path}`)
|
|
612
612
|
return { success: true, message: `Route ${method} ${path} registered`, url: this._getUrl(path), route: { method, path, description } }
|
|
613
613
|
}
|
|
614
614
|
|
|
@@ -631,7 +631,7 @@ class WebPlugin extends Plugin {
|
|
|
631
631
|
// 持久化保存
|
|
632
632
|
this._saveConfig()
|
|
633
633
|
|
|
634
|
-
log.info(` Webhook registered: ${webhookPath}`)
|
|
634
|
+
// log.info(` Webhook registered: ${webhookPath}`)
|
|
635
635
|
return {
|
|
636
636
|
success: true,
|
|
637
637
|
message: `Webhook registered`,
|
|
@@ -661,7 +661,7 @@ class WebPlugin extends Plugin {
|
|
|
661
661
|
// 持久化保存
|
|
662
662
|
this._saveConfig()
|
|
663
663
|
|
|
664
|
-
log.info(` Static registered: ${normalizedPath} -> ${folder}`)
|
|
664
|
+
// log.info(` Static registered: ${normalizedPath} -> ${folder}`)
|
|
665
665
|
return {
|
|
666
666
|
success: true,
|
|
667
667
|
message: `Static folder registered`,
|
|
@@ -689,7 +689,7 @@ class WebPlugin extends Plugin {
|
|
|
689
689
|
|
|
690
690
|
this._routes.splice(index, 1)
|
|
691
691
|
this._saveConfig()
|
|
692
|
-
log.info(` Route deleted: ${method} ${path}`)
|
|
692
|
+
// log.info(` Route deleted: ${method} ${path}`)
|
|
693
693
|
return { success: true, message: `Route deleted: ${method} ${path}` }
|
|
694
694
|
}
|
|
695
695
|
|
|
@@ -708,7 +708,7 @@ class WebPlugin extends Plugin {
|
|
|
708
708
|
|
|
709
709
|
this._webhooks.delete(found)
|
|
710
710
|
this._saveConfig()
|
|
711
|
-
log.info(` Webhook deleted: ${found}`)
|
|
711
|
+
// log.info(` Webhook deleted: ${found}`)
|
|
712
712
|
return { success: true, message: `Webhook deleted: ${found}` }
|
|
713
713
|
}
|
|
714
714
|
|
|
@@ -721,7 +721,7 @@ class WebPlugin extends Plugin {
|
|
|
721
721
|
|
|
722
722
|
this._statics.splice(index, 1)
|
|
723
723
|
this._saveConfig()
|
|
724
|
-
log.info(` Static deleted: ${normalizedPath}`)
|
|
724
|
+
// log.info(` Static deleted: ${normalizedPath}`)
|
|
725
725
|
return { success: true, message: `Static folder deleted: ${normalizedPath}` }
|
|
726
726
|
}
|
|
727
727
|
|
|
@@ -788,7 +788,7 @@ class WebPlugin extends Plugin {
|
|
|
788
788
|
async _parseBody(c) {
|
|
789
789
|
try {
|
|
790
790
|
const rawText = await c.req.text()
|
|
791
|
-
log.info(rawText)
|
|
791
|
+
// log.info(rawText)
|
|
792
792
|
if (!rawText) return {}
|
|
793
793
|
return JSON.parse(rawText)
|
|
794
794
|
} catch (e) {
|