myagent-ai 1.23.7 → 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/package.json +1 -1
- package/skills/file_send.py +4 -2
- package/web/api_server.py +11 -5
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")
|