myagent-ai 1.23.6 → 1.23.8
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/agents/main_agent.py +4 -5
- package/package.json +1 -1
- package/skills/file_send.py +4 -2
- package/web/api_server.py +11 -5
package/agents/main_agent.py
CHANGED
|
@@ -63,14 +63,13 @@ class MainAgent(BaseAgent):
|
|
|
63
63
|
</output>
|
|
64
64
|
|
|
65
65
|
注意事项:
|
|
66
|
-
1. toolstocal标签: 尽量一次性列出所有需执行工具调用的,多个"tool"工具调用只要按顺序重复堆叠tool
|
|
67
|
-
2.
|
|
68
|
-
3. 上下文中的记忆系统说明
|
|
66
|
+
1. toolstocal标签: 尽量一次性列出所有需执行工具调用的,多个"tool"工具调用只要按顺序重复堆叠tool标签即可,解析器会按顺序执行工具调用,最终全部执行完后,会连同所有结果,回调大语言模型。如果某个工具执行超时了,也会回调大模型,让大模型分析为什么超时,改用其他工具。要求每个工具调用尽快合并多个命令行,如生成文件后需要发送给用户时,务必用 && 将两个命令合并为一次调用。例如: myagent-ai docx-create -c '{...}' -t 标题 && myagent-ai send-file /path/to/file.docx 报告。这样可以减少一次LLM回调,加快响应速度。同理,创建PPT/Excel/PDF后发送也应用 && 拼接。
|
|
67
|
+
2. 上下文中的记忆系统说明
|
|
69
68
|
- <automemory>: 系统自动根据你通过 <remember> 保存的记忆和当前用户输入,搜索出的 top10 相关记忆。这些是你过去主动记住的内容(包含时间信息),可供参考。
|
|
70
69
|
- <recall_memory>: 你在上一轮通过 <recall> 指定的记忆搜索结果。系统根据你提供的关键字和时间点搜索了 top5 相关记忆。
|
|
71
70
|
- 两种记忆互补:automemory 是自动匹配的,recall_memory 是你主动指定搜索的。如果 automemory 不足,使用 <recall> 请求更多。
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
3. 工具使用指南 — 只有两个工具: command 和 web_control
|
|
72
|
+
4. 文件下载链接: 当文件通过 send-file 发送成功后,系统会返回下载链接,格式为 /api/file/文件ID。向用户展示下载链接时,应在前面加上服务器地址前缀,完整格式为: http://127.0.0.1:8767/api/file/文件ID。如果上下文中没有服务器地址,则直接展示相对路径 /api/file/文件ID 即可。
|
|
74
73
|
|
|
75
74
|
**command**(执行命令行,所有操作都通过它完成):
|
|
76
75
|
<tool><toolname>command</toolname><parms>{"command": "要执行的命令"}</parms><timeout>超时秒数</timeout></tool>
|
package/package.json
CHANGED
package/skills/file_send.py
CHANGED
|
@@ -110,6 +110,8 @@ class FileSendSkill:
|
|
|
110
110
|
size = stored_path.stat().st_size
|
|
111
111
|
|
|
112
112
|
base_url = get_public_base_url()
|
|
113
|
+
from urllib.parse import quote as _url_quote
|
|
114
|
+
safe_name = _url_quote(fpath.name)
|
|
113
115
|
result = {
|
|
114
116
|
"success": True,
|
|
115
117
|
"file_id": file_id,
|
|
@@ -117,8 +119,8 @@ class FileSendSkill:
|
|
|
117
119
|
"type": mime,
|
|
118
120
|
"size": size,
|
|
119
121
|
"description": description or f"文件: {fpath.name}",
|
|
120
|
-
"url": f"{base_url}/api/file/{file_id}",
|
|
121
|
-
"download_url": f"{base_url}/api/file/{file_id}/download",
|
|
122
|
+
"url": f"{base_url}/api/file/{file_id}/{safe_name}",
|
|
123
|
+
"download_url": f"{base_url}/api/file/{file_id}/download/{safe_name}",
|
|
122
124
|
}
|
|
123
125
|
|
|
124
126
|
# Send v2_file SSE event so frontend can display it
|
package/web/api_server.py
CHANGED
|
@@ -494,8 +494,12 @@ class ApiServer:
|
|
|
494
494
|
r.add_post("/api/chat/save-to-knowledge", self.handle_save_to_knowledge)
|
|
495
495
|
r.add_get("/ui/", self.handle_ui_index)
|
|
496
496
|
r.add_get("/", self.handle_index)
|
|
497
|
-
# [v1.16.17] 文件服务 API
|
|
498
|
-
|
|
497
|
+
# [v1.16.17] 文件服务 API (支持带文件名的路径: /api/file/{file_id}/{filename})
|
|
498
|
+
# file_path 格式: "file_id" 或 "file_id/filename"
|
|
499
|
+
r.add_get('/api/file/{file_path:.*}', self.handle_get_file)
|
|
500
|
+
# download 路由必须在上面之后,或用专门前缀区分
|
|
501
|
+
# 格式: /api/file/{file_id}/download 或 /api/file/{file_id}/download/{filename}
|
|
502
|
+
r.add_get('/api/file/{file_id}/download/{filename:.*}', self.handle_download_file)
|
|
499
503
|
r.add_get('/api/file/{file_id}/download', self.handle_download_file)
|
|
500
504
|
# [v1.17.0] 远程桌面 (VNC) API
|
|
501
505
|
r.add_get("/api/vnc/status", self.handle_vnc_status)
|
|
@@ -704,8 +708,10 @@ class ApiServer:
|
|
|
704
708
|
|
|
705
709
|
# --- File Serving (v1.16.17) ---
|
|
706
710
|
async def handle_get_file(self, request):
|
|
707
|
-
"""GET /api/file/{file_id} - 在新窗口中打开/预览文件"""
|
|
708
|
-
|
|
711
|
+
"""GET /api/file/{file_id}[/{filename}] - 在新窗口中打开/预览文件"""
|
|
712
|
+
file_path = request.match_info.get('file_path', '')
|
|
713
|
+
# 支持 "file_id" 和 "file_id/filename" 两种格式
|
|
714
|
+
file_id = file_path.split('/')[0] if '/' in file_path else file_path
|
|
709
715
|
if not file_id or len(file_id) < 8:
|
|
710
716
|
return web.Response(status=404, text="File not found")
|
|
711
717
|
fpath, mime = _find_upload_file(file_id)
|
|
@@ -734,7 +740,7 @@ class ApiServer:
|
|
|
734
740
|
return resp
|
|
735
741
|
|
|
736
742
|
async def handle_download_file(self, request):
|
|
737
|
-
"""GET /api/file/{file_id}/download - 强制下载文件"""
|
|
743
|
+
"""GET /api/file/{file_id}/download[/{filename}] - 强制下载文件"""
|
|
738
744
|
file_id = request.match_info.get('file_id', '')
|
|
739
745
|
if not file_id or len(file_id) < 8:
|
|
740
746
|
return web.Response(status=404, text="File not found")
|