Feature(Go): get_screenshot over the main-connection preview RPC
COMMAND_SCREEN_PREVIEW_REQ (247) / TOKEN_SCREEN_PREVIEW_RSP (248) is a request/reply pair on the device's main connection: the client captures, scales and encodes the frame itself, so no sub-connection is opened and no screen-session slot is taken. get_screenshot can therefore run while a human is watching the same machine. The server keeps one pending request per device in a small table, matches replies by reqId and drops foreign or late ones, and bounds a round trip with an 8s timer. A missing CLIENT_CAP_SCREEN_PREVIEW bit is refused with -32005 before anything is sent; region/window/monitor parameters are refused with the same code because the v2 CLIENT_CAP_SCREEN_REGION extension is not implemented in this build. Status 4 maps to -32602 because the caller can fix the target, while capture/encode failures stay -32000. Windows clients return JPEG directly. Linux clients have no JPEG encoder and return top-down BGRX, which the server converts (R/B swap, opaque alpha) before wrapping the frame as an MCP image item. The image item is new to the content envelope; text tools keep text-only items. Verified live against x64\Debug\ghost.exe (JPEG FF D8 FF, decoded size matches metadata, max_width clamped to 64) and against linux/ghost under WSL (BGRX path, valid JPEG, black frame from the known Xwayland capture limitation). gofmt/vet clean, unit and -race tests green. Co-Authored-By: deepseek-flash
This commit is contained in:
1 parent
808747f9d2
commit
5227d4d78e
6 files changed
+947
-37
No files matched your search
@@ -37,9 +37,14 @@ type toolResult struct {
|
||||
IsError bool `json:"isError"`
|
||||
}
|
||||
|
||||
// contentItem is one MCP content block. Text tools fill Text; get_screenshot
|
||||
// emits an image block (Data is base64, MimeType image/jpeg), so both the text
|
||||
// and image fields are optional on the wire.
|
||||
type contentItem struct {
|
||||
Type string `json:"type"`
|
||||
Text string `json:"text"`
|
||||
Type string `json:"type"`
|
||||
Text string `json:"text,omitempty"`
|
||||
Data string `json:"data,omitempty"`
|
||||
MimeType string `json:"mimeType,omitempty"`
|
||||
}
|
||||
|
||||
func newToolResult(text string, structured any) toolResult {
|
||||
|
||||
Reference in new issue
Block a user