myagent-ai 1.23.9 → 1.23.10
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 +2 -4
- package/web/api_server.py +5 -11
package/package.json
CHANGED
package/skills/file_send.py
CHANGED
|
@@ -110,8 +110,6 @@ 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)
|
|
115
113
|
result = {
|
|
116
114
|
"success": True,
|
|
117
115
|
"file_id": file_id,
|
|
@@ -119,8 +117,8 @@ class FileSendSkill:
|
|
|
119
117
|
"type": mime,
|
|
120
118
|
"size": size,
|
|
121
119
|
"description": description or f"文件: {fpath.name}",
|
|
122
|
-
"url": f"{base_url}/api/file/{file_id}
|
|
123
|
-
"download_url": f"{base_url}/api/file/{file_id}/download
|
|
120
|
+
"url": f"{base_url}/api/file/{file_id}?name={fpath.name}",
|
|
121
|
+
"download_url": f"{base_url}/api/file/{file_id}/download?name={fpath.name}",
|
|
124
122
|
}
|
|
125
123
|
|
|
126
124
|
# Send v2_file SSE event so frontend can display it
|
package/web/api_server.py
CHANGED
|
@@ -494,12 +494,8 @@ 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
|
-
|
|
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)
|
|
497
|
+
# [v1.16.17] 文件服务 API
|
|
498
|
+
r.add_get('/api/file/{file_id}', self.handle_get_file)
|
|
503
499
|
r.add_get('/api/file/{file_id}/download', self.handle_download_file)
|
|
504
500
|
# [v1.17.0] 远程桌面 (VNC) API
|
|
505
501
|
r.add_get("/api/vnc/status", self.handle_vnc_status)
|
|
@@ -708,10 +704,8 @@ class ApiServer:
|
|
|
708
704
|
|
|
709
705
|
# --- File Serving (v1.16.17) ---
|
|
710
706
|
async def handle_get_file(self, request):
|
|
711
|
-
"""GET /api/file/{file_id}
|
|
712
|
-
|
|
713
|
-
# 支持 "file_id" 和 "file_id/filename" 两种格式
|
|
714
|
-
file_id = file_path.split('/')[0] if '/' in file_path else file_path
|
|
707
|
+
"""GET /api/file/{file_id} - 在新窗口中打开/预览文件"""
|
|
708
|
+
file_id = request.match_info.get('file_id', '')
|
|
715
709
|
if not file_id or len(file_id) < 8:
|
|
716
710
|
return web.Response(status=404, text="File not found")
|
|
717
711
|
fpath, mime = _find_upload_file(file_id)
|
|
@@ -740,7 +734,7 @@ class ApiServer:
|
|
|
740
734
|
return resp
|
|
741
735
|
|
|
742
736
|
async def handle_download_file(self, request):
|
|
743
|
-
"""GET /api/file/{file_id}/download
|
|
737
|
+
"""GET /api/file/{file_id}/download - 强制下载文件"""
|
|
744
738
|
file_id = request.match_info.get('file_id', '')
|
|
745
739
|
if not file_id or len(file_id) < 8:
|
|
746
740
|
return web.Response(status=404, text="File not found")
|