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.
Files changed (104) hide show
  1. package/.agent/data/default.json +3 -108
  2. package/.agent/data/plugins-state.json +34 -1
  3. package/.agent/mcp_config.json +0 -1
  4. package/.agent/memory/core.md +1 -0
  5. package/.agent/memory/project/mnn93ogy-ypjn27.md +9 -0
  6. package/.agent/memory/project/mnn98fqy-5nhc1u.md +25 -0
  7. package/.agent/memory/user/mnm67t9m-x8rekk.md +9 -0
  8. package/.agent/memory/user/mnn5mmqh-w6aktx.md +11 -0
  9. package/.agent/memory/user/mnnbfhhn-dk1bd1.md +22 -0
  10. package/.agent/plugins/__pycache__/file_writer.cpython-312.pyc +0 -0
  11. package/.agent/plugins/poster-plugin/README.md +304 -0
  12. package/.agent/plugins/poster-plugin/fonts/PatuaOne-Regular.ttf +0 -0
  13. package/.agent/plugins/poster-plugin/fonts//345/276/256/350/275/257/351/233/205/351/273/221.ttf +0 -0
  14. 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
  15. package/.agent/plugins/poster-plugin/index.js +13 -0
  16. package/.agent/plugins/poster-plugin/package.json +28 -0
  17. package/.agent/plugins/poster-plugin/src/canvas.js +161 -0
  18. package/.agent/plugins/poster-plugin/src/components/arrow.js +84 -0
  19. package/.agent/plugins/poster-plugin/src/components/avatar.js +71 -0
  20. package/.agent/plugins/poster-plugin/src/components/badge.js +85 -0
  21. package/.agent/plugins/poster-plugin/src/components/card.js +88 -0
  22. package/.agent/plugins/poster-plugin/src/components/chart.js +127 -0
  23. package/.agent/plugins/poster-plugin/src/components/chip.js +88 -0
  24. package/.agent/plugins/poster-plugin/src/components/columns.js +107 -0
  25. package/.agent/plugins/poster-plugin/src/components/cta.js +85 -0
  26. package/.agent/plugins/poster-plugin/src/components/divider.js +55 -0
  27. package/.agent/plugins/poster-plugin/src/components/feature.js +85 -0
  28. package/.agent/plugins/poster-plugin/src/components/featureGrid.js +112 -0
  29. package/.agent/plugins/poster-plugin/src/components/grid.js +118 -0
  30. package/.agent/plugins/poster-plugin/src/components/imageFrame.js +155 -0
  31. package/.agent/plugins/poster-plugin/src/components/index.js +62 -0
  32. package/.agent/plugins/poster-plugin/src/components/listItem.js +146 -0
  33. package/.agent/plugins/poster-plugin/src/components/notification.js +123 -0
  34. package/.agent/plugins/poster-plugin/src/components/progress.js +79 -0
  35. package/.agent/plugins/poster-plugin/src/components/progressCircle.js +117 -0
  36. package/.agent/plugins/poster-plugin/src/components/quote.js +97 -0
  37. package/.agent/plugins/poster-plugin/src/components/rating.js +85 -0
  38. package/.agent/plugins/poster-plugin/src/components/star.js +70 -0
  39. package/.agent/plugins/poster-plugin/src/components/statCard.js +105 -0
  40. package/.agent/plugins/poster-plugin/src/components/stepper.js +118 -0
  41. package/.agent/plugins/poster-plugin/src/components/table.js +159 -0
  42. package/.agent/plugins/poster-plugin/src/components/tagCloud.js +78 -0
  43. package/.agent/plugins/poster-plugin/src/components/timeline.js +105 -0
  44. package/.agent/plugins/poster-plugin/src/components/watermark.js +52 -0
  45. package/.agent/plugins/poster-plugin/src/composer.js +1904 -0
  46. package/.agent/plugins/poster-plugin/src/elements/artText.js +60 -0
  47. package/.agent/plugins/poster-plugin/src/elements/background.js +52 -0
  48. package/.agent/plugins/poster-plugin/src/elements/circle.js +31 -0
  49. package/.agent/plugins/poster-plugin/src/elements/image.js +71 -0
  50. package/.agent/plugins/poster-plugin/src/elements/index.js +26 -0
  51. package/.agent/plugins/poster-plugin/src/elements/line.js +23 -0
  52. package/.agent/plugins/poster-plugin/src/elements/polygon.js +32 -0
  53. package/.agent/plugins/poster-plugin/src/elements/rectangle.js +32 -0
  54. package/.agent/plugins/poster-plugin/src/elements/svg.js +92 -0
  55. package/.agent/plugins/poster-plugin/src/elements/text.js +38 -0
  56. package/.agent/plugins/poster-plugin/src/fonts.js +118 -0
  57. package/.agent/plugins/poster-plugin/src/index.js +1659 -0
  58. package/.agent/plugins/poster-plugin/src/presets.js +36 -0
  59. package/.agent/plugins/poster-plugin/src/templates/business.js +60 -0
  60. package/.agent/plugins/poster-plugin/src/templates/gradient.js +64 -0
  61. package/.agent/plugins/poster-plugin/src/templates/index.js +43 -0
  62. package/.agent/plugins/poster-plugin/src/templates/modern.js +69 -0
  63. package/.agent/plugins/poster-plugin/src/templates/simple.js +58 -0
  64. package/.agent/plugins/poster-plugin/src/templates/social.js +62 -0
  65. package/.agent/plugins/poster-plugin/src/templates/tech.js +84 -0
  66. package/.agent/sessions/cli_default.json +24265 -0
  67. package/.agent/weixin.json +6 -0
  68. package/.claude/settings.local.json +5 -8
  69. package/CLAUDE.md +144 -108
  70. package/docs/CONTEXT_DESIGN.md +1596 -0
  71. package/examples/test-concurrent-chat.js +60 -60
  72. package/output/beef-love-poster.png +0 -0
  73. package/package.json +2 -2
  74. package/plugins/default-plugins.js +2 -1
  75. package/plugins/extension-executor-plugin.js +11 -0
  76. package/plugins/memory-plugin.js +984 -0
  77. package/plugins/session-plugin.js +57 -1
  78. package/plugins/weixin-plugin.js +24 -22
  79. package/skills/poster-guide/SKILL.md +743 -0
  80. package/skills/python-plugin-dev/SKILL.md +238 -238
  81. package/skills/skill-guide/SKILL.md +130 -108
  82. package/src/capabilities/skill-manager.js +99 -0
  83. package/src/core/agent-chat.js +538 -138
  84. package/src/core/agent-context.js +188 -0
  85. package/src/core/agent.js +6 -2
  86. package/src/core/context-manager.js +283 -0
  87. package/src/core/framework.js +264 -3
  88. package/src/core/plugin-manager.js +79 -2
  89. package/src/core/request-context.js +98 -0
  90. package/src/core/session-context.js +341 -0
  91. package/src/core/session-storage.js +274 -0
  92. package/src/executors/mcp-executor.js +2 -2
  93. package/src/utils/index.js +239 -67
  94. package/src/utils/plugin-helpers.js +17 -0
  95. package//346/265/267/346/212/245/346/217/222/344/273/266.md +621 -0
  96. package/.agent/plugins/__pycache__/test_plugin.cpython-312.pyc +0 -0
  97. package/.agent/plugins/temp-repo/LICENSE +0 -201
  98. package/.agent/plugins/temp-repo/puppeteer-plugin/README.md +0 -147
  99. package/.agent/plugins/temp-repo/puppeteer-plugin/index.js +0 -1418
  100. package/.agent/plugins/temp-repo/puppeteer-plugin/package.json +0 -9
  101. package/.agent/plugins/test_plugin.py +0 -304
  102. package/examples/test-chat-debug.js +0 -102
  103. package/examples/test-chat-result.js +0 -76
  104. package/examples/test-chat-stream-diff.js +0 -63
@@ -1,9 +0,0 @@
1
- {
2
- "name": "puppeteer-plugin",
3
- "version": "1.0.0",
4
- "description": "Puppeteer 网页自动化操作插件,支持 Session 保存、页面截图、元素交互等",
5
- "main": "index.js",
6
- "dependencies": {
7
- "puppeteer-core": "^24.40.0"
8
- }
9
- }
@@ -1,304 +0,0 @@
1
- # .agent/plugins/test_plugin.py
2
- """
3
- Python 测试插件 - 提供单元测试和覆盖率测试功能
4
- """
5
-
6
- PLUGIN = {
7
- "name": "test_plugin",
8
- "version": "1.0.0",
9
- "description": "Python 单元测试和覆盖率测试插件"
10
- }
11
-
12
- TOOLS = [
13
- {
14
- "name": "run_tests",
15
- "description": "运行 Python 测试文件或目录中的测试用例",
16
- "params": {
17
- "path": "string",
18
- "verbose": "boolean",
19
- "pattern": "string"
20
- }
21
- },
22
- {
23
- "name": "create_test",
24
- "description": "创建单元测试文件模板",
25
- "params": {
26
- "path": "string",
27
- "class_name": "string",
28
- "test_methods": "array",
29
- "module_name": "string"
30
- }
31
- },
32
- {
33
- "name": "run_coverage",
34
- "description": "运行测试并生成覆盖率报告",
35
- "params": {
36
- "path": "string",
37
- "source": "string",
38
- "report_type": "string"
39
- }
40
- },
41
- {
42
- "name": "assert_equal",
43
- "description": "断言两个值相等(测试辅助)",
44
- "params": {
45
- "actual": "any",
46
- "expected": "any",
47
- "message": "string"
48
- }
49
- },
50
- {
51
- "name": "mock_function",
52
- "description": "创建模拟函数用于测试",
53
- "params": {
54
- "return_value": "any",
55
- "side_effect": "array",
56
- "called_count": "number"
57
- }
58
- }
59
- ]
60
-
61
- # === 工具实现 ===
62
-
63
- import os
64
- import json
65
- import subprocess
66
- import traceback
67
- from datetime import datetime
68
-
69
-
70
- def run_tests(params):
71
- """运行 Python 测试文件或目录中的测试用例"""
72
- path = params.get("path", ".")
73
- verbose = params.get("verbose", True)
74
- pattern = params.get("pattern", "test_*.py")
75
-
76
- if not os.path.exists(path):
77
- return {"success": False, "error": f"Path not found: {path}"}
78
-
79
- # 构建 pytest 命令
80
- cmd = ["pytest", path]
81
- if verbose:
82
- cmd.append("-v")
83
-
84
- try:
85
- result = subprocess.run(
86
- cmd,
87
- capture_output=True,
88
- text=True,
89
- timeout=60
90
- )
91
-
92
- output = result.stdout + result.stderr
93
-
94
- return {
95
- "success": result.returncode == 0,
96
- "result": {
97
- "passed": result.returncode == 0,
98
- "output": output,
99
- "return_code": result.returncode
100
- }
101
- }
102
- except subprocess.TimeoutExpired:
103
- return {"success": False, "error": "Test execution timed out"}
104
- except Exception as e:
105
- return {"success": False, "error": str(e)}
106
-
107
-
108
- def create_test(params):
109
- """创建单元测试文件模板"""
110
- path = params.get("path")
111
- class_name = params.get("class_name", "TestModule")
112
- test_methods = params.get("test_methods", ["test_case"])
113
- module_name = params.get("module_name", "")
114
-
115
- if not path:
116
- return {"success": False, "error": "path is required"}
117
-
118
- # 确保目录存在
119
- os.makedirs(os.path.dirname(path) if os.path.dirname(path) else ".", exist_ok=True)
120
-
121
- # 生成测试模板
122
- template = f'''"""
123
- 测试模块 - {datetime.now().strftime("%Y-%m-%d %H:%M:%S")}
124
- """
125
-
126
- import unittest
127
- {"import " + module_name if module_name else ""}
128
-
129
-
130
- class {class_name}(unittest.TestCase):
131
- """{class_name} 测试类"""
132
- '''
133
-
134
- for method in test_methods:
135
- template += f'''
136
- def {method}(self):
137
- """测试用例: {method}"""
138
- # TODO: 实现测试逻辑
139
- self.assertTrue(True)
140
- '''
141
-
142
- template += '''
143
-
144
- if __name__ == "__main__":
145
- unittest.main()
146
- '''
147
-
148
- try:
149
- with open(path, "w", encoding="utf-8") as f:
150
- f.write(template)
151
-
152
- return {
153
- "success": True,
154
- "result": {
155
- "path": path,
156
- "class_name": class_name,
157
- "methods": test_methods
158
- }
159
- }
160
- except Exception as e:
161
- return {"success": False, "error": str(e)}
162
-
163
-
164
- def run_coverage(params):
165
- """运行测试并生成覆盖率报告"""
166
- path = params.get("path", ".")
167
- source = params.get("source", "")
168
- report_type = params.get("report_type", "term")
169
-
170
- if not os.path.exists(path):
171
- return {"success": False, "error": f"Path not found: {path}"}
172
-
173
- # 构建 coverage 命令
174
- cmd = ["coverage", "run", "-m", "pytest", path]
175
- if source:
176
- cmd = ["coverage", "run", "--source", source, "-m", "pytest", path]
177
-
178
- try:
179
- # 运行测试
180
- subprocess.run(cmd, capture_output=True, timeout=60)
181
-
182
- # 生成报告
183
- if report_type == "term":
184
- report_result = subprocess.run(
185
- ["coverage", "report"],
186
- capture_output=True,
187
- text=True
188
- )
189
- output = report_result.stdout
190
- elif report_type == "html":
191
- subprocess.run(
192
- ["coverage", "html", "-d", "htmlcov"],
193
- capture_output=True,
194
- timeout=30
195
- )
196
- output = "Coverage HTML report generated at htmlcov/"
197
- elif report_type == "json":
198
- report_result = subprocess.run(
199
- ["coverage", "json"],
200
- capture_output=True,
201
- text=True
202
- )
203
- output = report_result.stdout
204
- else:
205
- output = "Unknown report type"
206
-
207
- return {
208
- "success": True,
209
- "result": {
210
- "report": output,
211
- "type": report_type
212
- }
213
- }
214
- except subprocess.TimeoutExpired:
215
- return {"success": False, "error": "Coverage execution timed out"}
216
- except FileNotFoundError:
217
- return {"success": False, "error": "coverage module not installed. Run: pip install coverage"}
218
- except Exception as e:
219
- return {"success": False, "error": str(e)}
220
-
221
-
222
- def assert_equal(params):
223
- """断言两个值相等(测试辅助)"""
224
- actual = params.get("actual")
225
- expected = params.get("expected")
226
- message = params.get("message", "")
227
-
228
- try:
229
- # 处理 JSON 字符串比较
230
- if isinstance(actual, str):
231
- try:
232
- actual = json.loads(actual)
233
- except (json.JSONDecodeError, TypeError):
234
- pass
235
-
236
- if isinstance(expected, str):
237
- try:
238
- expected = json.loads(expected)
239
- except (json.JSONDecodeError, TypeError):
240
- pass
241
-
242
- if actual == expected:
243
- return {
244
- "success": True,
245
- "result": {
246
- "passed": True,
247
- "message": f"Assertion passed: {actual} == {expected}",
248
- "actual": actual,
249
- "expected": expected
250
- }
251
- }
252
- else:
253
- return {
254
- "success": True,
255
- "result": {
256
- "passed": False,
257
- "message": f"Assertion failed: {actual} != {expected}",
258
- "actual": actual,
259
- "expected": expected
260
- }
261
- }
262
- except Exception as e:
263
- return {"success": False, "error": str(e)}
264
-
265
-
266
- def mock_function(params):
267
- """创建模拟函数用于测试"""
268
- return_value = params.get("return_value")
269
- side_effect = params.get("side_effect", [])
270
- called_count = params.get("called_count", 0)
271
-
272
- class MockResult:
273
- def __init__(self):
274
- self.call_count = 0
275
- self.call_args = []
276
- self.side_effects = side_effect
277
-
278
- def __call__(self, *args, **kwargs):
279
- self.call_count += 1
280
- self.call_args.append({"args": args, "kwargs": kwargs})
281
-
282
- # 如果有 side_effect,按顺序返回
283
- if self.side_effects:
284
- index = min(self.call_count - 1, len(self.side_effects) - 1)
285
- return self.side_effects[index]
286
-
287
- return return_value
288
-
289
- def reset(self):
290
- self.call_count = 0
291
- self.call_args = []
292
-
293
- mock = MockResult()
294
- mock.call_count = called_count
295
-
296
- return {
297
- "success": True,
298
- "result": {
299
- "mock_type": "MockFunction",
300
- "return_value": return_value,
301
- "side_effects": side_effect,
302
- "description": "Use this mock function in your tests"
303
- }
304
- }
@@ -1,102 +0,0 @@
1
- /**
2
- * chat() 持续聊天调试测试
3
- * 专门测试 chat 方法为什么不返回数据
4
- */
5
-
6
- const { Framework } = require('../src');
7
- const AIPlugin = require('../plugins/ai-plugin');
8
- require('dotenv').config();
9
-
10
- async function main() {
11
- console.log('=== chat() 持续聊天调试测试 ===\n');
12
-
13
- // 创建框架
14
- const framework = new Framework({ debug: true });
15
-
16
- // 使用 MiniMax (Agent SDK)
17
- await framework.loadPlugin(
18
- new AIPlugin({
19
- provider: 'minimax',
20
- model: 'MiniMax-M2.7',
21
- apiKey: process.env.MINIMAX_API_KEY || 'your-api-key',
22
- })
23
- );
24
-
25
- // 注册一个简单的测试工具
26
- const { z } = require('zod');
27
- framework.registerTool({
28
- name: 'test_tool',
29
- description: '测试工具,返回传入的参数',
30
- inputSchema: z.object({
31
- msg: z.string().describe('要返回的消息'),
32
- }),
33
- execute: async (args) => {
34
- console.log('[DEBUG] test_tool called with:', args);
35
- return `工具收到: ${args.msg}`;
36
- },
37
- });
38
-
39
- console.log('[Framework] Ready!');
40
- console.log('[Tools]', framework.getTools().map((t) => t.name));
41
-
42
- // 创建 Agent
43
- const agent = framework.createAgent({
44
- name: 'DebugAgent',
45
- systemPrompt: '你是一个有帮助的助手。如果用户要求使用工具,请使用工具。',
46
- });
47
-
48
- // 监听所有事件
49
- agent.on('tool-call', (tool) => {
50
- console.log('[Event] tool-call:', tool.name, tool.args);
51
- });
52
-
53
- agent.on('tool-result', (result) => {
54
- console.log('[Event] tool-result:', result.name, '->', JSON.stringify(result.result).substring(0, 200));
55
- });
56
-
57
- agent.on('error', (err) => {
58
- console.error('[Event] error:', err.error);
59
- });
60
-
61
- // 测试函数
62
- const testChat = async (question, round) => {
63
- console.log(`\n========== Round ${round} ==========`);
64
- console.log(`[User] ${question}`);
65
-
66
- try {
67
- // 打印 result 的完整结构
68
- const result = await agent.chat(question);
69
- console.log(`\n[DEBUG] result keys:`, Object.keys(result));
70
- console.log(`[DEBUG] result:`, JSON.stringify(result, null, 2).substring(0, 500));
71
-
72
- if (result.message) {
73
- console.log(`\n[Agent] ${result.message}`);
74
- } else {
75
- console.log(`\n[WARNING] result.message is empty!`);
76
- }
77
-
78
- // 打印当前消息历史长度
79
- const chatHandler = agent._chatHandler;
80
- if (chatHandler) {
81
- console.log(`[DEBUG] _messages.length:`, chatHandler._messages.length);
82
- console.log(`[DEBUG] compression count:`, chatHandler._compressionCount);
83
- }
84
- } catch (err) {
85
- console.error(`\n[Error]`, err.message);
86
- console.error(err.stack);
87
- }
88
- };
89
-
90
- // 执行多轮测试
91
- await testChat('你好,介绍一下你自己', 1);
92
- await testChat('请用 test_tool 工具返回 "hello world"', 2);
93
- await testChat('今天天气不错,你觉得呢?', 3);
94
- await testChat('帮我计算 123 + 456 等于多少', 4);
95
- await testChat('再说一次你的名字', 5);
96
-
97
- console.log('\n========== 测试完成 ==========');
98
-
99
- await framework.destroy();
100
- }
101
-
102
- main().catch(console.error);
@@ -1,76 +0,0 @@
1
- /**
2
- * 测试 chat() 返回值的完整结构
3
- */
4
-
5
- const { Framework } = require('../src');
6
- const AIPlugin = require('../plugins/ai-plugin');
7
- require('dotenv').config();
8
-
9
- async function main() {
10
- console.log('=== 测试 chat() 返回值结构 ===\n');
11
-
12
- const framework = new Framework({ debug: true });
13
-
14
- await framework.loadPlugin(
15
- new AIPlugin({
16
- provider: 'minimax',
17
- model: 'MiniMax-M2.7',
18
- apiKey: process.env.MINIMAX_API_KEY || 'your-api-key',
19
- })
20
- );
21
-
22
- const { z } = require('zod');
23
- framework.registerTool({
24
- name: 'echo',
25
- description: '返回输入的内容',
26
- inputSchema: z.object({
27
- msg: z.string().describe('要返回的消息'),
28
- }),
29
- execute: async (args) => {
30
- return `工具收到: ${args.msg}`;
31
- },
32
- });
33
-
34
- console.log('[Framework] Ready!');
35
-
36
- const agent = framework.createAgent({
37
- name: 'TestAgent',
38
- systemPrompt: '你是一个有帮助的助手。',
39
- });
40
-
41
- // 测试 1:简单对话
42
- console.log('\n--- 测试 1:简单对话 ---');
43
- try {
44
- const result = await agent.chat('你好');
45
- console.log('[DEBUG] result:', JSON.stringify(result, null, 2));
46
- console.log('[DEBUG] result 顶层 keys:', Object.keys(result));
47
- } catch (err) {
48
- console.error('[Error]', err.message);
49
- }
50
-
51
- // 测试 2:触发工具调用
52
- console.log('\n--- 测试 2:触发工具调用 ---');
53
- try {
54
- const result = await agent.chat('请用 echo 工具返回 "hello"');
55
- console.log('[DEBUG] result:', JSON.stringify(result, null, 2));
56
- console.log('[DEBUG] result 顶层 keys:', Object.keys(result));
57
- } catch (err) {
58
- console.error('[Error]', err.message);
59
- }
60
-
61
- // 测试 3:多次对话(累积上下文)
62
- console.log('\n--- 测试 3:多次对话 ---');
63
- try {
64
- await agent.chat('你好');
65
- await agent.chat('今天天气不错');
66
- const result = await agent.chat('我刚才说什么了?');
67
- console.log('[DEBUG] result:', JSON.stringify(result, null, 2));
68
- } catch (err) {
69
- console.error('[Error]', err.message);
70
- }
71
-
72
- await framework.destroy();
73
- console.log('\n[Done]');
74
- }
75
-
76
- main().catch(console.error);
@@ -1,63 +0,0 @@
1
- /**
2
- * 测试 chat 和 chatStream 的差异
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 vs chatStream 差异 ===\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
- const agent = framework.createAgent({
27
- name: 'TestAgent',
28
- systemPrompt: systemPrompt,
29
- });
30
-
31
- const sessionId = 'test_session';
32
- const sessionPlugin = framework.pluginManager.get('session');
33
- sessionPlugin.getOrCreateSession(sessionId, { metadata: {} });
34
-
35
- // 测试 chat
36
- console.log('--- Test 1: chat() ---');
37
- const result1 = await agent.chat('你好,介绍一下自己', { sessionId });
38
- console.log('chat result.message length:', result1.message?.length);
39
- console.log('chat result.message:', result1.message?.substring(0, 100));
40
-
41
- // 测试 chatStream
42
- console.log('\n--- Test 2: chatStream() ---');
43
- let streamText = '';
44
- for await (const chunk of agent.chatStream('今天天气怎么样?', { sessionId })) {
45
- if (chunk.type === 'text') {
46
- streamText += chunk.text;
47
- }
48
- }
49
- console.log('chatStream full text length:', streamText.length);
50
- console.log('chatStream full text:', streamText.substring(0, 100));
51
-
52
- // 测试更多轮对话后的 chat
53
- console.log('\n--- Test 3: 多轮后 chat() ---');
54
- await agent.chat('再说一次你的名字', { sessionId });
55
- const result3 = await agent.chat('我叫什么?', { sessionId });
56
- console.log('chat result.message length:', result3.message?.length);
57
- console.log('chat result.message:', result3.message?.substring(0, 100));
58
-
59
- await framework.destroy();
60
- console.log('\n[Done]');
61
- }
62
-
63
- main().catch(console.error);