myagent-ai 1.47.26 → 1.47.27
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/aiskills/chromedev_mcp.py +47 -19
- package/core/vnc_manager.py +1299 -137
- package/main.py +19 -1
- package/package.json +1 -1
- package/start.js +5 -1
- package/tray_manager.py +20 -2
- package/web/ui/admin/admin-sites.js +6 -15
- package/web/ui/chat/chat_container.html +2 -2
|
@@ -189,27 +189,55 @@ def _ensure_display() -> Optional[str]:
|
|
|
189
189
|
logger.info(f"VNC 远程桌面已在运行,复用显示: {display}")
|
|
190
190
|
return display
|
|
191
191
|
|
|
192
|
-
# VNC 未运行 → 尝试自动启动
|
|
192
|
+
# [v1.47.13] VNC 未运行 → 尝试自动启动
|
|
193
|
+
# 修复: 不能在 ThreadPoolExecutor + asyncio.run 中直接调用 vnc.start()!
|
|
194
|
+
# 因为 vnc.start() 内部用 asyncio.Lock(),跨 event loop 会导致死锁。
|
|
195
|
+
# 正确做法:在单独线程中用 asyncio.run 启动,然后轮询等待 VNC 就绪。
|
|
193
196
|
try:
|
|
194
197
|
import asyncio
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
198
|
+
import concurrent.futures
|
|
199
|
+
|
|
200
|
+
def _start_vnc_in_thread():
|
|
201
|
+
try:
|
|
202
|
+
return asyncio.run(vnc.start())
|
|
203
|
+
except Exception as e:
|
|
204
|
+
return {"success": False, "message": str(e)}
|
|
205
|
+
|
|
206
|
+
with concurrent.futures.ThreadPoolExecutor(max_workers=1) as pool:
|
|
207
|
+
future = pool.submit(_start_vnc_in_thread)
|
|
208
|
+
|
|
209
|
+
max_wait = 60
|
|
210
|
+
check_interval = 2
|
|
211
|
+
elapsed = 0
|
|
212
|
+
while elapsed < max_wait:
|
|
213
|
+
if vnc.is_running:
|
|
214
|
+
display = vnc.display
|
|
215
|
+
os.environ["DISPLAY"] = display
|
|
216
|
+
logger.info(f"VNC 远程桌面已启动,复用显示: {display}")
|
|
217
|
+
return display
|
|
218
|
+
|
|
219
|
+
try:
|
|
220
|
+
result = future.result(timeout=0.1)
|
|
221
|
+
if result.get("success") or vnc.is_running:
|
|
222
|
+
display = vnc.display
|
|
223
|
+
os.environ["DISPLAY"] = display
|
|
224
|
+
logger.info(f"VNC 远程桌面已启动,显示: {display}")
|
|
225
|
+
return display
|
|
226
|
+
else:
|
|
227
|
+
logger.warning(f"VNC 启动失败: {result.get('message', '')}")
|
|
228
|
+
break
|
|
229
|
+
except concurrent.futures.TimeoutError:
|
|
230
|
+
pass
|
|
231
|
+
|
|
232
|
+
import time
|
|
233
|
+
time.sleep(check_interval)
|
|
234
|
+
elapsed += check_interval
|
|
235
|
+
|
|
236
|
+
if vnc.is_running:
|
|
237
|
+
display = vnc.display
|
|
238
|
+
os.environ["DISPLAY"] = display
|
|
239
|
+
return display
|
|
240
|
+
|
|
213
241
|
except Exception as e:
|
|
214
242
|
logger.warning(f"VNC 自动启动异常: {e}")
|
|
215
243
|
|