Skip to main content

agentmux_common/
ui_screenshot_types.rs

1// Copyright 2026, AgentMux Corp.
2// SPDX-License-Identifier: Apache-2.0
3
4//! The request and response of `POST /api/v1/ui/screenshot` (the `UI` tool's `screenshot`). Re-exported by `api_types`,
5//! where the rest of the UI requests are.
6
7use serde::{Deserialize, Serialize};
8
9use crate::api_types::UiAutomationAuth;
10
11/// `POST /api/v1/ui/screenshot`
12#[derive(Debug, Clone, Serialize, Deserialize)]
13pub struct UiScreenshotRequest {
14    #[serde(flatten)]
15    pub auth: UiAutomationAuth,
16    /// Target a browser pane this agent opened with `OpenBrowser`
17    /// (SPEC_AGENT_DRIVEN_BROWSER_PANES_2026_10_07.md ยง3). srv checks it
18    /// against its owner map; absent = the caller's own pane, as before.
19    #[serde(default, skip_serializing_if = "Option::is_none")]
20    pub pane: Option<String>,
21    /// A browser pane's whole page, beyond what the viewport shows.
22    #[serde(default, skip_serializing_if = "Option::is_none")]
23    pub full_page: Option<bool>,
24    /// Only this part of a browser pane's page.
25    #[serde(default, skip_serializing_if = "Option::is_none")]
26    pub region: Option<ScreenshotRegion>,
27    /// One canvas of a browser pane's page, by its reference from the last snapshot, at the size it was drawn at.
28    #[serde(default, skip_serializing_if = "Option::is_none")]
29    pub canvas: Option<String>,
30    /// Pixels of the image for each CSS pixel of the page, for `full_page`, `region` or `canvas`.
31    #[serde(default, skip_serializing_if = "Option::is_none")]
32    pub scale: Option<f64>,
33}
34
35/// A part of a page, in CSS pixels from its top left.
36#[derive(Debug, Clone, Serialize, Deserialize)]
37pub struct ScreenshotRegion {
38    pub x: f64,
39    pub y: f64,
40    pub width: f64,
41    pub height: f64,
42}
43
44/// Response for `POST /api/v1/ui/screenshot`. `path` is a file already
45/// written to disk (openable in the Editor, `Pane` open); `png_base64` is the
46/// same image inline, for a caller that can render an MCP `ImageContent`
47/// block directly without a second round trip.
48#[derive(Debug, Clone, Serialize, Deserialize)]
49pub struct UiScreenshotResponse {
50    pub path: String,
51    pub png_base64: String,
52    /// Something to tell the agent about the image (a page cut at the size limit).
53    #[serde(default, skip_serializing_if = "Option::is_none")]
54    pub note: Option<String>,
55}