From 273283cfffb0faf90f91ea745292e21295870f68 Mon Sep 17 00:00:00 2001 From: invin_huo Date: Sat, 25 Oct 2025 13:00:51 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=A4=A7=E6=AE=B5=E7=B2=98=E8=B4=B4?= =?UTF-8?q?=E6=A3=80=E6=B5=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Html/apps/services/backboard_service.py | 16 ++++++++++++++++ Html/apps/sockets/namespaces.py | 13 ++++++++++++- Html/backboardManager.py | 2 +- Html/db/data/user/agnes.json | 2 +- Html/db/data/user/ttt.json | 2 +- 5 files changed, 31 insertions(+), 4 deletions(-) diff --git a/Html/apps/services/backboard_service.py b/Html/apps/services/backboard_service.py index 3bfbdfa..1f670cc 100644 --- a/Html/apps/services/backboard_service.py +++ b/Html/apps/services/backboard_service.py @@ -1,8 +1,11 @@ # myapp/services/backboard_service.py import os from flask import current_app +from flask_socketio import emit from backboardManager import Backboard # 你已有的类 from ..utils.sudoUtil import sudo_open +from ..extension_ase.ase_client import HSAEngineClient +from manager import ChatManager def _to_wsl_path_if_needed(path: str) -> str: cfg = current_app.config["VSCODE_WEB_PATH"] @@ -44,6 +47,19 @@ def realtime_response(config: dict, realtime_action: dict) -> None: bb.pasted_content = realtime_action.get("content") with open(os.path.join(bb.root_path, bb.active_file_path), "r", encoding="utf-8") as f: bb.active_file_content = f.read() + #处理粘贴事件 + + # paste_data = { + # 'pasted_file_path': file_path, + # 'pasted_content': bb.pasted_content, + # 'pasted_content_length': len(bb.pasted_content) + # } + # emit('paste_detected', paste_data) + + #判断一下,如果粘帖内容过多就发送,后期可加入更多条件判断 + if bb.pasted_content and len(bb.pasted_content) > 300: + chatmanager.ase_client.send("pasted_detected_in", {"file_path": file_path, "content": bb.pasted_content}) + elif rtype == "fileEdit": file_path = realtime_action.get("filePath") diff --git a/Html/apps/sockets/namespaces.py b/Html/apps/sockets/namespaces.py index d6846f9..fbafc80 100644 --- a/Html/apps/sockets/namespaces.py +++ b/Html/apps/sockets/namespaces.py @@ -126,6 +126,12 @@ class AgentNamespace(Namespace): entry=self, init_data={'room': user_uuid} ) + user_uuid2ase_client[user_uuid].register_route_with_entry( + route='paste_detected', + callback=self.receive_ase_paste_detected, + entry=self, + init_data={'room': user_uuid} + ) user_uuid2ase_client[user_uuid].connect() @@ -179,6 +185,12 @@ class AgentNamespace(Namespace): ase_client.send_text("chapter-start", "") namespace_entry.emit('message', "Multi-Agents服务已连接", room=init_data['room'], namespace='/agent') + #接受消息回来直接让message监听发送 + def receive_ase_paste_detected(client_entry: HSAEngineClient, namespace_entry: Namespace, data, init_data): + print("receive_ase_paste_detected", data) + client_entry.chatmanager.chat_historys.append({'role': 'assistant', 'content': data['data']}) + namespace_entry.emit('message', data['data'], room=init_data['room'], namespace='/agent') + def receive_ase_dialog(client_entry: HSAEngineClient, namespace_entry: Namespace, data, init_data): print("receive_ase_dialog", data) client_entry.chatmanager.chat_historys.append({'role': 'assistant', 'content': data['data']}) @@ -195,7 +207,6 @@ class AgentNamespace(Namespace): def receive_ase_process(client_entry: HSAEngineClient, namespace_entry: Namespace, data, init_data): namespace_entry.emit('process', data['data'], room=init_data['room'], namespace='/agent') - def receive_ase_judge(client_entry: HSAEngineClient, namespace_entry: Namespace, data, init_data): print("receive_ase_judge", data) namespace_entry.emit('request_function', data, room=init_data['room'], namespace='/agent') # data 是一个列表 /dict也支持 diff --git a/Html/backboardManager.py b/Html/backboardManager.py index 3c288cd..4b535db 100644 --- a/Html/backboardManager.py +++ b/Html/backboardManager.py @@ -20,7 +20,7 @@ class Backboard: self.pasted_file_path = "" self.pasted_content = "" - + def next_chapter(self): self.enter_chapter_time = time.time() diff --git a/Html/db/data/user/agnes.json b/Html/db/data/user/agnes.json index 5d1f87e..bc0ff21 100644 --- a/Html/db/data/user/agnes.json +++ b/Html/db/data/user/agnes.json @@ -1 +1 @@ -{"username": "agnes"} \ No newline at end of file +{"username": "Agnes"} \ No newline at end of file diff --git a/Html/db/data/user/ttt.json b/Html/db/data/user/ttt.json index ad7f8e1..11ec9a2 100644 --- a/Html/db/data/user/ttt.json +++ b/Html/db/data/user/ttt.json @@ -1 +1 @@ -{"username": "ttt"} \ No newline at end of file +{"username": "Ttt"} \ No newline at end of file From ff0148e54154caf6c280a1a145ee6abaa29a9afb Mon Sep 17 00:00:00 2001 From: invin_huo Date: Sat, 25 Oct 2025 15:16:22 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E7=B2=98=E8=B4=B4=E6=A3=80=E6=B5=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 ++-- code-server-like/static/js/code-like-extension.js | 2 +- code-server-like/static/js/terminal.js | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 5849c19..cdfd433 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ api_key = sk-aMpnWklN2IbsK44d1kNpy6YOP9bk1pdPJjFeEmbb0a5ytEFf model=gpt-4.1-nano [VSCODE_WEB] -url = https://hsamooc.com +url = https://hsamooc.cn #http://asengine.net:8282 [VSCODE_WEB_PATH] is_wsl = true @@ -43,7 +43,7 @@ dir = db/data/user/ [COURSE_DATA] dir = db/data/course/ [MONGO] -uri = mongodb://admin:12138cake@hsamooc.com:27017/hsamooc_test?authSource=admin +uri = mongodb://admin:12138cake@hsamooc.cn:27017/hsamooc_test?authSource=admin [TENCENT_COS] secret_id = AKIDZ0EG4f2FE0YszsXzEF5h5GDwSlOtDLGx diff --git a/code-server-like/static/js/code-like-extension.js b/code-server-like/static/js/code-like-extension.js index 3a25e08..2c4e9f7 100644 --- a/code-server-like/static/js/code-like-extension.js +++ b/code-server-like/static/js/code-like-extension.js @@ -60,7 +60,7 @@ function ChangeWorkspacefileTree(fileTree) { // vscode.window.showInformationMessage('Connecting to server...'); -vs_socket = io('wss://hsamooc.com/vscode'); +vs_socket = io('wss://hsamooc.cn/vscode'); vs_socket.on('connect', () => { // vscode.window.showInformationMessage('Connected to server'); console.log('Connected to server'); diff --git a/code-server-like/static/js/terminal.js b/code-server-like/static/js/terminal.js index ec5fe16..04e4da1 100644 --- a/code-server-like/static/js/terminal.js +++ b/code-server-like/static/js/terminal.js @@ -24,7 +24,7 @@ }); }); - socket = io('https://hsamooc.com/vsc-like',{path:'/vsc-like-ws'}); + socket = io('https://hsamooc.cn/vsc-like',{path:'/vsc-like-ws'}); const status = document.getElementById("status") socket.on("pty_output", function(data){ From 9ce212e92007d99f3f6dba619b021bf4505002d4 Mon Sep 17 00:00:00 2001 From: invin_huo Date: Sat, 25 Oct 2025 15:16:56 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E7=B2=98=E8=B4=B4=E6=A3=80=E6=B5=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Html/apps/services/backboard_service.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Html/apps/services/backboard_service.py b/Html/apps/services/backboard_service.py index 1f670cc..7d4cb57 100644 --- a/Html/apps/services/backboard_service.py +++ b/Html/apps/services/backboard_service.py @@ -57,7 +57,7 @@ def realtime_response(config: dict, realtime_action: dict) -> None: # emit('paste_detected', paste_data) #判断一下,如果粘帖内容过多就发送,后期可加入更多条件判断 - if bb.pasted_content and len(bb.pasted_content) > 300: + if bb.pasted_content and len(bb.pasted_content) > 250: chatmanager.ase_client.send("pasted_detected_in", {"file_path": file_path, "content": bb.pasted_content})