feat(M1): MCP 截图坐标空间统一——de_screenshot 附 native_size,de_tap/de_swipe 接受截图坐标由 server 按比例换算原生(模型只感知截图坐标系)

This commit is contained in:
2026-09-04 12:47:09 +08:00
parent 084ed59ad5
commit d7b6d83cd8
2 changed files with 46 additions and 6 deletions
+13
View File
@@ -80,6 +80,19 @@ class PlatformClient:
f"截图 HTTP {r.status_code}")
return r.content, r.headers.get("X-Screen-State", "unknown")
def screen_size(self, serial):
"""屏幕原生分辨率(GET /api/screen/size),返回 (w, h)。"""
r = self._get("/api/screen/size", serial=serial)
if r.status_code == 503:
raise PlatformError("device_offline", r.text[:120])
if r.status_code != 200:
raise PlatformError("platform_unavailable",
f"分辨率 HTTP {r.status_code}")
j = r.json() or {}
if not j.get("ok"):
raise PlatformError("device_offline", str(j.get("error", "取分辨率失败"))[:120])
return int(j["width"]), int(j["height"])
def tap(self, serial, x, y):
"""点击(POST /api/screen/tap)。"""
r = self._post("/api/screen/tap", json={"serial": serial,