foliko 1.0.87 → 1.1.0
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/data/default.json +3 -108
- package/.agent/data/plugins-state.json +34 -1
- package/.agent/mcp_config.json +0 -1
- package/.agent/memory/core.md +1 -0
- package/.agent/memory/project/mnn93ogy-ypjn27.md +9 -0
- package/.agent/memory/project/mnn98fqy-5nhc1u.md +25 -0
- package/.agent/memory/user/mnm67t9m-x8rekk.md +9 -0
- package/.agent/memory/user/mnn5mmqh-w6aktx.md +11 -0
- package/.agent/memory/user/mnnbfhhn-dk1bd1.md +22 -0
- package/.agent/plugins/__pycache__/file_writer.cpython-312.pyc +0 -0
- package/.agent/plugins/poster-plugin/README.md +304 -0
- package/.agent/plugins/poster-plugin/fonts/PatuaOne-Regular.ttf +0 -0
- package/.agent/plugins/poster-plugin/fonts//345/276/256/350/275/257/351/233/205/351/273/221.ttf +0 -0
- package/.agent/plugins/poster-plugin/fonts//345/276/256/350/275/257/351/233/205/351/273/221/347/262/227/344/275/223.ttf +0 -0
- package/.agent/plugins/poster-plugin/index.js +13 -0
- package/.agent/plugins/poster-plugin/package.json +28 -0
- package/.agent/plugins/poster-plugin/src/canvas.js +161 -0
- package/.agent/plugins/poster-plugin/src/components/arrow.js +84 -0
- package/.agent/plugins/poster-plugin/src/components/avatar.js +71 -0
- package/.agent/plugins/poster-plugin/src/components/badge.js +85 -0
- package/.agent/plugins/poster-plugin/src/components/card.js +88 -0
- package/.agent/plugins/poster-plugin/src/components/chart.js +127 -0
- package/.agent/plugins/poster-plugin/src/components/chip.js +88 -0
- package/.agent/plugins/poster-plugin/src/components/columns.js +107 -0
- package/.agent/plugins/poster-plugin/src/components/cta.js +85 -0
- package/.agent/plugins/poster-plugin/src/components/divider.js +55 -0
- package/.agent/plugins/poster-plugin/src/components/feature.js +85 -0
- package/.agent/plugins/poster-plugin/src/components/featureGrid.js +112 -0
- package/.agent/plugins/poster-plugin/src/components/grid.js +118 -0
- package/.agent/plugins/poster-plugin/src/components/imageFrame.js +155 -0
- package/.agent/plugins/poster-plugin/src/components/index.js +62 -0
- package/.agent/plugins/poster-plugin/src/components/listItem.js +146 -0
- package/.agent/plugins/poster-plugin/src/components/notification.js +123 -0
- package/.agent/plugins/poster-plugin/src/components/progress.js +79 -0
- package/.agent/plugins/poster-plugin/src/components/progressCircle.js +117 -0
- package/.agent/plugins/poster-plugin/src/components/quote.js +97 -0
- package/.agent/plugins/poster-plugin/src/components/rating.js +85 -0
- package/.agent/plugins/poster-plugin/src/components/star.js +70 -0
- package/.agent/plugins/poster-plugin/src/components/statCard.js +105 -0
- package/.agent/plugins/poster-plugin/src/components/stepper.js +118 -0
- package/.agent/plugins/poster-plugin/src/components/table.js +159 -0
- package/.agent/plugins/poster-plugin/src/components/tagCloud.js +78 -0
- package/.agent/plugins/poster-plugin/src/components/timeline.js +105 -0
- package/.agent/plugins/poster-plugin/src/components/watermark.js +52 -0
- package/.agent/plugins/poster-plugin/src/composer.js +1904 -0
- package/.agent/plugins/poster-plugin/src/elements/artText.js +60 -0
- package/.agent/plugins/poster-plugin/src/elements/background.js +52 -0
- package/.agent/plugins/poster-plugin/src/elements/circle.js +31 -0
- package/.agent/plugins/poster-plugin/src/elements/image.js +71 -0
- package/.agent/plugins/poster-plugin/src/elements/index.js +26 -0
- package/.agent/plugins/poster-plugin/src/elements/line.js +23 -0
- package/.agent/plugins/poster-plugin/src/elements/polygon.js +32 -0
- package/.agent/plugins/poster-plugin/src/elements/rectangle.js +32 -0
- package/.agent/plugins/poster-plugin/src/elements/svg.js +92 -0
- package/.agent/plugins/poster-plugin/src/elements/text.js +38 -0
- package/.agent/plugins/poster-plugin/src/fonts.js +118 -0
- package/.agent/plugins/poster-plugin/src/index.js +1659 -0
- package/.agent/plugins/poster-plugin/src/presets.js +36 -0
- package/.agent/plugins/poster-plugin/src/templates/business.js +60 -0
- package/.agent/plugins/poster-plugin/src/templates/gradient.js +64 -0
- package/.agent/plugins/poster-plugin/src/templates/index.js +43 -0
- package/.agent/plugins/poster-plugin/src/templates/modern.js +69 -0
- package/.agent/plugins/poster-plugin/src/templates/simple.js +58 -0
- package/.agent/plugins/poster-plugin/src/templates/social.js +62 -0
- package/.agent/plugins/poster-plugin/src/templates/tech.js +84 -0
- package/.agent/sessions/cli_default.json +24265 -0
- package/.agent/weixin.json +6 -0
- package/.claude/settings.local.json +5 -8
- package/CLAUDE.md +144 -108
- package/docs/CONTEXT_DESIGN.md +1596 -0
- package/examples/test-concurrent-chat.js +60 -60
- package/output/beef-love-poster.png +0 -0
- package/package.json +2 -2
- package/plugins/default-plugins.js +2 -1
- package/plugins/extension-executor-plugin.js +11 -0
- package/plugins/memory-plugin.js +984 -0
- package/plugins/session-plugin.js +57 -1
- package/plugins/weixin-plugin.js +24 -22
- package/skills/poster-guide/SKILL.md +743 -0
- package/skills/python-plugin-dev/SKILL.md +238 -238
- package/skills/skill-guide/SKILL.md +130 -108
- package/src/capabilities/skill-manager.js +99 -0
- package/src/core/agent-chat.js +538 -138
- package/src/core/agent-context.js +188 -0
- package/src/core/agent.js +6 -2
- package/src/core/context-manager.js +283 -0
- package/src/core/framework.js +264 -3
- package/src/core/plugin-manager.js +79 -2
- package/src/core/request-context.js +98 -0
- package/src/core/session-context.js +341 -0
- package/src/core/session-storage.js +274 -0
- package/src/executors/mcp-executor.js +2 -2
- package/src/utils/index.js +239 -67
- package/src/utils/plugin-helpers.js +17 -0
- package//346/265/267/346/212/245/346/217/222/344/273/266.md +621 -0
- package/.agent/plugins/__pycache__/test_plugin.cpython-312.pyc +0 -0
- package/.agent/plugins/temp-repo/LICENSE +0 -201
- package/.agent/plugins/temp-repo/puppeteer-plugin/README.md +0 -147
- package/.agent/plugins/temp-repo/puppeteer-plugin/index.js +0 -1418
- package/.agent/plugins/temp-repo/puppeteer-plugin/package.json +0 -9
- package/.agent/plugins/test_plugin.py +0 -304
- package/examples/test-chat-debug.js +0 -102
- package/examples/test-chat-result.js +0 -76
- package/examples/test-chat-stream-diff.js +0 -63
|
@@ -1,60 +1,60 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 测试并发 chat 调用
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
const { Framework } = require('../src');
|
|
6
|
-
const AIPlugin = require('../plugins/ai-plugin');
|
|
7
|
-
const SessionPlugin = require('../plugins/session-plugin');
|
|
8
|
-
require('dotenv').config();
|
|
9
|
-
|
|
10
|
-
async function main() {
|
|
11
|
-
console.log('=== 测试并发 chat 调用 ===\n');
|
|
12
|
-
|
|
13
|
-
const framework = new Framework({ debug: false });
|
|
14
|
-
|
|
15
|
-
await framework.loadPlugin(
|
|
16
|
-
new AIPlugin({
|
|
17
|
-
provider: 'minimax',
|
|
18
|
-
model: 'MiniMax-M2.7',
|
|
19
|
-
apiKey: process.env.MINIMAX_API_KEY || 'your-api-key',
|
|
20
|
-
})
|
|
21
|
-
);
|
|
22
|
-
await framework.loadPlugin(new SessionPlugin());
|
|
23
|
-
|
|
24
|
-
const systemPrompt = `你是一个微信助手。`;
|
|
25
|
-
|
|
26
|
-
// 创建一个 agent(模拟单个用户)
|
|
27
|
-
const agent = framework.createAgent({
|
|
28
|
-
name: 'WeixinAgent',
|
|
29
|
-
systemPrompt: systemPrompt,
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
const sessionId = 'weixin_test_user';
|
|
33
|
-
const sessionPlugin = framework.pluginManager.get('session');
|
|
34
|
-
sessionPlugin.getOrCreateSession(sessionId, { metadata: { platform: 'weixin' } });
|
|
35
|
-
|
|
36
|
-
// 模拟 3 个并发 chat 调用
|
|
37
|
-
console.log('\n--- 并发发送 3 条消息 ---');
|
|
38
|
-
|
|
39
|
-
const results = await Promise.all([
|
|
40
|
-
agent.chat('你好', { sessionId }),
|
|
41
|
-
agent.chat('今天天气怎么样?', { sessionId }),
|
|
42
|
-
agent.chat('帮我查一下天气', { sessionId }),
|
|
43
|
-
]);
|
|
44
|
-
|
|
45
|
-
console.log('\n--- 结果 ---');
|
|
46
|
-
for (let i = 0; i < results.length; i++) {
|
|
47
|
-
const r = results[i];
|
|
48
|
-
console.log(`[${i}] message length: ${r.message?.length || 'EMPTY'}`);
|
|
49
|
-
console.log(`[${i}] message: ${r.message?.substring(0, 50) || 'EMPTY'}...`);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
// 检查 _messages 状态
|
|
53
|
-
const chatHandler = agent._chatHandler;
|
|
54
|
-
console.log(`\n[DEBUG] _messages count: ${chatHandler?._messages.length}`);
|
|
55
|
-
|
|
56
|
-
await framework.destroy();
|
|
57
|
-
console.log('\n[Done]');
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
main().catch(console.error);
|
|
1
|
+
/**
|
|
2
|
+
* 测试并发 chat 调用
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
const { Framework } = require('../src');
|
|
6
|
+
const AIPlugin = require('../plugins/ai-plugin');
|
|
7
|
+
const SessionPlugin = require('../plugins/session-plugin');
|
|
8
|
+
require('dotenv').config();
|
|
9
|
+
|
|
10
|
+
async function main() {
|
|
11
|
+
console.log('=== 测试并发 chat 调用 ===\n');
|
|
12
|
+
|
|
13
|
+
const framework = new Framework({ debug: false });
|
|
14
|
+
|
|
15
|
+
await framework.loadPlugin(
|
|
16
|
+
new AIPlugin({
|
|
17
|
+
provider: 'minimax',
|
|
18
|
+
model: 'MiniMax-M2.7',
|
|
19
|
+
apiKey: process.env.MINIMAX_API_KEY || 'your-api-key',
|
|
20
|
+
})
|
|
21
|
+
);
|
|
22
|
+
await framework.loadPlugin(new SessionPlugin());
|
|
23
|
+
|
|
24
|
+
const systemPrompt = `你是一个微信助手。`;
|
|
25
|
+
|
|
26
|
+
// 创建一个 agent(模拟单个用户)
|
|
27
|
+
const agent = framework.createAgent({
|
|
28
|
+
name: 'WeixinAgent',
|
|
29
|
+
systemPrompt: systemPrompt,
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const sessionId = 'weixin_test_user';
|
|
33
|
+
const sessionPlugin = framework.pluginManager.get('session');
|
|
34
|
+
sessionPlugin.getOrCreateSession(sessionId, { metadata: { platform: 'weixin' } });
|
|
35
|
+
|
|
36
|
+
// 模拟 3 个并发 chat 调用
|
|
37
|
+
console.log('\n--- 并发发送 3 条消息 ---');
|
|
38
|
+
|
|
39
|
+
const results = await Promise.all([
|
|
40
|
+
agent.chat('你好', { sessionId }),
|
|
41
|
+
agent.chat('今天天气怎么样?', { sessionId }),
|
|
42
|
+
agent.chat('帮我查一下天气', { sessionId }),
|
|
43
|
+
]);
|
|
44
|
+
|
|
45
|
+
console.log('\n--- 结果 ---');
|
|
46
|
+
for (let i = 0; i < results.length; i++) {
|
|
47
|
+
const r = results[i];
|
|
48
|
+
console.log(`[${i}] message length: ${r.message?.length || 'EMPTY'}`);
|
|
49
|
+
console.log(`[${i}] message: ${r.message?.substring(0, 50) || 'EMPTY'}...`);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// 检查 _messages 状态
|
|
53
|
+
const chatHandler = agent._chatHandler;
|
|
54
|
+
console.log(`\n[DEBUG] _messages count: ${chatHandler?._messages.length}`);
|
|
55
|
+
|
|
56
|
+
await framework.destroy();
|
|
57
|
+
console.log('\n[Done]');
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
main().catch(console.error);
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "foliko",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "简约的插件化 Agent 框架",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"@hono/node-server": "^1.19.11",
|
|
59
59
|
"@larksuiteoapi/node-sdk": "^1.59.0",
|
|
60
60
|
"@modelcontextprotocol/sdk": "^1.27.1",
|
|
61
|
-
"ai": "^6.0.
|
|
61
|
+
"ai": "^6.0.146",
|
|
62
62
|
"dotenv": "^17.3.1",
|
|
63
63
|
"gate-api": "^7.2.57",
|
|
64
64
|
"hono": "^4.12.9",
|
|
@@ -231,7 +231,8 @@ async function bootstrapDefaults(framework, config = {}) {
|
|
|
231
231
|
'install', 'ai', 'storage', 'tools', 'workflow', 'skill-manager',
|
|
232
232
|
'mcp-executor', 'extension-executor', 'shell-executor', 'python-executor', 'session', 'web',
|
|
233
233
|
'audit', 'rules', 'scheduler', 'file-system', 'think', 'ambient',
|
|
234
|
-
'python-plugin-loader', 'telegram', 'weixin', 'subagent-manager'
|
|
234
|
+
'python-plugin-loader', 'telegram', 'weixin', 'subagent-manager',
|
|
235
|
+
'memory'
|
|
235
236
|
])
|
|
236
237
|
|
|
237
238
|
// 辅助函数:检查插件是否应该加载
|
|
@@ -36,6 +36,17 @@ class ExtensionExecutorPlugin extends Plugin {
|
|
|
36
36
|
this._rescanPluginTools(plugin);
|
|
37
37
|
});
|
|
38
38
|
|
|
39
|
+
// 监听框架就绪事件,刷新所有动态注册的工具(确保在 install() 中通过 registerTool() 注册的工具能被扫描到)
|
|
40
|
+
framework.on('framework:ready', () => {
|
|
41
|
+
log.debug('Framework ready, rescanning all plugin tools...');
|
|
42
|
+
const plugins = framework.pluginManager.getAll();
|
|
43
|
+
for (const { instance: plugin } of plugins) {
|
|
44
|
+
this._scanPluginTools(plugin);
|
|
45
|
+
}
|
|
46
|
+
// 刷新所有 Agent 的扩展提示词
|
|
47
|
+
this._refreshAllAgentsExtPrompt(framework);
|
|
48
|
+
});
|
|
49
|
+
|
|
39
50
|
return this;
|
|
40
51
|
}
|
|
41
52
|
|