Initial release: cloud browser with auth and one-click deploy on port 32450

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-27 10:57:37 +08:00
commit 65f5caf4d9
20 changed files with 2118 additions and 0 deletions
+70
View File
@@ -0,0 +1,70 @@
from typing import Any
from app.browser_manager import BrowserManager, BrowserSession
async def handle_input(
manager: BrowserManager,
session: BrowserSession,
payload: dict[str, Any],
) -> dict[str, Any] | None:
action = payload.get("action")
if not action:
return None
manager.touch(session)
page = session.page
if action == "click":
x = float(payload.get("x", 0))
y = float(payload.get("y", 0))
button = payload.get("button", "left")
await page.mouse.click(x, y, button=button)
return {"type": "ack", "action": action}
if action == "dblclick":
x = float(payload.get("x", 0))
y = float(payload.get("y", 0))
await page.mouse.dblclick(x, y)
return {"type": "ack", "action": action}
if action == "mousemove":
x = float(payload.get("x", 0))
y = float(payload.get("y", 0))
await page.mouse.move(x, y)
return None
if action == "wheel":
delta_x = float(payload.get("deltaX", 0))
delta_y = float(payload.get("deltaY", 0))
await page.mouse.wheel(delta_x, delta_y)
return {"type": "ack", "action": action}
if action == "keydown":
key = payload.get("key")
if not key:
return None
await page.keyboard.down(key)
return {"type": "ack", "action": action}
if action == "keyup":
key = payload.get("key")
if not key:
return None
await page.keyboard.up(key)
return {"type": "ack", "action": action}
if action == "type":
text = payload.get("text", "")
if text:
await page.keyboard.type(text)
return {"type": "ack", "action": action}
if action == "press":
key = payload.get("key")
if not key:
return None
await page.keyboard.press(key)
return {"type": "ack", "action": action}
return {"type": "error", "message": f"未知操作: {action}"}