foliko 2.0.23 → 2.0.25
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/package.json +1 -1
- package/plugins/core/sub-agent/index.js +8 -4
- package/plugins/io/file-system/index.js +1 -1
- package/plugins/messaging/feishu/index.js +1 -1
- package/plugins/messaging/qq/index.js +5 -5
- package/plugins/messaging/telegram/index.js +2 -2
- package/plugins/messaging/weixin/index.js +1 -1
- package/src/common/constants.js +2 -2
- package/src/plugin/base.js +4 -3
package/package.json
CHANGED
|
@@ -49,6 +49,7 @@ class SubAgentPlugin extends Plugin {
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
start(framework) {
|
|
52
|
+
this._framework = framework
|
|
52
53
|
this._createSubAgent()
|
|
53
54
|
this._registerDelegateTool()
|
|
54
55
|
return this
|
|
@@ -59,7 +60,7 @@ class SubAgentPlugin extends Plugin {
|
|
|
59
60
|
if (!parentAgent) {
|
|
60
61
|
if (this._framework) {
|
|
61
62
|
this._framework.on('agent:created', (agent) => {
|
|
62
|
-
if (this._framework._mainAgent && agent === this._framework._mainAgent) {
|
|
63
|
+
if (this._framework && this._framework._mainAgent && agent === this._framework._mainAgent) {
|
|
63
64
|
this._parentAgent = agent
|
|
64
65
|
this._doCreateSubAgent(agent)
|
|
65
66
|
this._registerDelegateTool()
|
|
@@ -117,9 +118,11 @@ class SubAgentPlugin extends Plugin {
|
|
|
117
118
|
return this._framework._mainAgent
|
|
118
119
|
}
|
|
119
120
|
|
|
121
|
+
// 只有 MainAgent 才能作为 parent,不要返回 SubAgent
|
|
120
122
|
const agents = this._framework._agents || []
|
|
121
|
-
|
|
122
|
-
|
|
123
|
+
const mainAgent = agents.find(a => a.constructor.name === 'MainAgent')
|
|
124
|
+
if (mainAgent) {
|
|
125
|
+
return mainAgent
|
|
123
126
|
}
|
|
124
127
|
|
|
125
128
|
return null
|
|
@@ -515,7 +518,7 @@ class SubAgentManagerPlugin extends Plugin {
|
|
|
515
518
|
|
|
516
519
|
framework.registerTool({
|
|
517
520
|
name: 'subagent_call',
|
|
518
|
-
description: '
|
|
521
|
+
description: '【首选】委托任务给指定的子Agent处理。根据子Agent匹配表选择合适的Agent,用此工具调用。禁止用chat工具代替。',
|
|
519
522
|
inputSchema: z.object({
|
|
520
523
|
agentName: z.string().describe('子Agent名称'),
|
|
521
524
|
task: z.string().describe('任务描述')
|
|
@@ -763,6 +766,7 @@ class SubAgentManagerPlugin extends Plugin {
|
|
|
763
766
|
}
|
|
764
767
|
|
|
765
768
|
reload(framework) {
|
|
769
|
+
super.reload(framework); // 设置 this._framework,清理 prompts
|
|
766
770
|
for (const plugin of this._subAgents.values()) {
|
|
767
771
|
plugin.uninstall(framework)
|
|
768
772
|
}
|
|
@@ -45,7 +45,7 @@ class FileSystemPlugin extends Plugin {
|
|
|
45
45
|
|
|
46
46
|
this.tool.register({
|
|
47
47
|
name: 'chat',
|
|
48
|
-
description: '
|
|
48
|
+
description: '【最后手段】仅当需要独立分析、复杂推理或多轮思考时使用。子 Agent 和工具能完成的任务,禁止调用此工具。',
|
|
49
49
|
inputSchema: z.object({
|
|
50
50
|
message: z.string().describe('要发送的消息'),
|
|
51
51
|
systemPrompt: z.string().optional().describe('系统提示语'),
|
|
@@ -430,7 +430,7 @@ class FeishuPlugin extends Plugin {
|
|
|
430
430
|
}
|
|
431
431
|
} catch (err) {
|
|
432
432
|
log.error(' Chat error:', err)
|
|
433
|
-
await this._sendMessage(openId, `发生错误:${err.message}`, originalMsg)
|
|
433
|
+
//await this._sendMessage(openId, `发生错误:${err.message}`, originalMsg)
|
|
434
434
|
} finally {
|
|
435
435
|
this._pendingResponses.delete(openId)
|
|
436
436
|
}
|
|
@@ -654,11 +654,11 @@ class QQPlugin extends Plugin {
|
|
|
654
654
|
await agent.sendMessage(messageWithContext, { sessionId, priority: 1 })
|
|
655
655
|
} catch (err) {
|
|
656
656
|
log.error('Chat error:', err.message)
|
|
657
|
-
if (msgType === 'group') {
|
|
658
|
-
|
|
659
|
-
} else {
|
|
660
|
-
|
|
661
|
-
}
|
|
657
|
+
// if (msgType === 'group') {
|
|
658
|
+
// await this._sendGroupMessage(identifier, `发生错误:${err.message}`)
|
|
659
|
+
// } else {
|
|
660
|
+
// await this._sendMessage(identifier, `发生错误:${err.message}`)
|
|
661
|
+
// }
|
|
662
662
|
} finally {
|
|
663
663
|
}
|
|
664
664
|
}
|
|
@@ -415,8 +415,8 @@ class TelegramPlugin extends Plugin {
|
|
|
415
415
|
parse_mode: 'MarkdownV2'
|
|
416
416
|
})
|
|
417
417
|
} catch (err) {
|
|
418
|
-
|
|
419
|
-
|
|
418
|
+
log.error(' Chat error:', err)
|
|
419
|
+
//await this._bot.editMessageText(escapeMarkdown(`❌ 发生错误:${err.message}`), {
|
|
420
420
|
chat_id: chatId,
|
|
421
421
|
message_id: thinkingMsg.message_id
|
|
422
422
|
})
|
|
@@ -631,7 +631,7 @@ class WeixinPlugin extends Plugin {
|
|
|
631
631
|
await agent.sendMessage(text, { sessionId, priority: 1 })
|
|
632
632
|
} catch (err) {
|
|
633
633
|
log.error(' Chat error:', err.message)
|
|
634
|
-
await this._sendMessageBatch(originalMsg, userId, `发生错误:${err.message}`, true)
|
|
634
|
+
//await this._sendMessageBatch(originalMsg, userId, `发生错误:${err.message}`, true)
|
|
635
635
|
} finally {
|
|
636
636
|
this.stopTypingInterval()
|
|
637
637
|
}
|
package/src/common/constants.js
CHANGED
|
@@ -51,10 +51,10 @@ const DEFAULT_MAX_MESSAGES_PER_SESSION = 1000;
|
|
|
51
51
|
// ============================================================================
|
|
52
52
|
|
|
53
53
|
/** 保留最近的 N 条消息 */
|
|
54
|
-
const KEEP_RECENT_MESSAGES =
|
|
54
|
+
const KEEP_RECENT_MESSAGES = 50;
|
|
55
55
|
|
|
56
56
|
/** 压缩消息数量阈值 */
|
|
57
|
-
const COMPRESSION_MESSAGE_THRESHOLD =
|
|
57
|
+
const COMPRESSION_MESSAGE_THRESHOLD = 300;
|
|
58
58
|
|
|
59
59
|
/** 智能压缩启用 */
|
|
60
60
|
const ENABLE_SMART_COMPRESS = true;
|
package/src/plugin/base.js
CHANGED
|
@@ -854,10 +854,11 @@ class Plugin {
|
|
|
854
854
|
// 解析文件路径:相对路径基于插件文件目录,绝对路径直接用
|
|
855
855
|
let fullPath = filePath;
|
|
856
856
|
if (!path.isAbsolute(filePath)) {
|
|
857
|
-
//
|
|
857
|
+
// 优先使用 pluginManager 中存储的 sourcePath(最可靠)
|
|
858
858
|
let pluginDir = null;
|
|
859
|
-
|
|
860
|
-
|
|
859
|
+
const pmEntry = this._framework?.pluginManager?.get?.(this.name);
|
|
860
|
+
if (pmEntry?.sourcePath) {
|
|
861
|
+
pluginDir = path.dirname(path.resolve(pmEntry.sourcePath));
|
|
861
862
|
}
|
|
862
863
|
// 备用:使用栈追踪获取插件文件路径
|
|
863
864
|
if (!pluginDir) {
|