Feature: Add window-relative remote_mouse coords and PTY pipes in terminal_exec

New Windows clients append an optional 20-byte WINDOWINFO_MCP_DESKTOP block
(virtual desktop rect, magic 'VDCP') after the window list, so the server can
map window-relative coordinates into the capture frame. remote_mouse accepts
an optional window_hwnd; x/y and drag x2/y2 are then normalized against the
intersection of the window and the virtual desktop, which is exactly the
source rect of get_screenshot mode=window. The target window must be foreground
by default, and window_hwnd/expect_hwnd must agree when both are given.
structuredContent gains coordinateWindow and resolved (frame coords plus the
basis rect), so callers can verify the mapping.

terminal_exec now allows pipes, && and || in PTY sessions (ConPTY on Windows,
POSIX PTY on Linux) because the sentinel runs on its own line; legacy non-PTY
sessions still reject & and |. A read-only PeekTermSession lets the server
reject unsupported syntax before BeginTermCommand. POSIX still rejects bare
background & (&&, &>, 2>&1 stay allowed).

Docs: Mcp_Design.md sections 12.1/20.2/22 and Mcp_Terminal_Design.md 4.4/4.6
are synchronized with the protocol, the new validation order, and the basis
rect semantics.

Co-Authored-By: deepseek-flash
This commit is contained in:
yuanyuanxianganddeepseek-flash committed 2026-11-10 18:03:25 +01:00
1 parent 235a8a622c
commit 5501889d33
10 files changed
+383 -60

No files matched your search

+12 -1
View File
@@ -99,13 +99,24 @@ struct WindowEntry {
// minimized/maximized/isForeground/zOrder)。机器管理与远程控制共用同一字段口径。
Json::Value WindowEntryToJson(const WindowEntry& e);
// 窗口信息响应尾块里的虚拟桌面矩形(WINDOWINFO_MCP_DESKTOP 的解码结果)。
// valid=false 表示客户端是老版本、没带这个尾块。
struct WindowDesktopRect {
int32_t left = 0;
int32_t top = 0;
int32_t width = 0;
int32_t height = 0;
bool valid = false;
};
// 下发 COMMAND_MCP_WINDOW_INFO(主连接 RPC,不建子连接、不弹框),解析 TOKEN_MCP_WINDOW_INFO。
// timeoutMs <= 0 时取 McpServer().ToolTimeoutMs()。out 按客户端的 z 序返回。
// desktop(可选):新客户端的虚拟桌面矩形;老客户端保持 valid=false。
// 返回:0=ok;1=设备忙;2=发送失败/超时;3=响应畸形;4=客户端未声明 CLIENT_CAP_WINDOW_INFO。
// truncated(可选):true 表示客户端还有更多可见窗口没装进这个包(单包上限 96 条)。
int FetchWindowInfo(context* ctx, uint64_t devId, const char* tool, int timeoutMs,
std::vector<WindowEntry>& out, std::string& errMsg,
bool* truncated = nullptr);
bool* truncated = nullptr, WindowDesktopRect* desktop = nullptr);
// 客户端是否为 Windows 形态(EXE/DLL/MEXE/SC/MDLL);LNX / MAC / APK 返回 false。
// 用于「只有 Windows 客户端实现了这个能力」的判断(注册表、窗口、服务等)。