agentmux_common/browser_control_types.rs
1// Copyright 2026, AgentMux Corp.
2// SPDX-License-Identifier: Apache-2.0
3
4//! The request types of the Browser actions that take back, take, give up and report on control of a pane (`retake`,
5//! `take_control`, `release`, `handoff_status`), zoom a pane (`zoom`) and find what is at a point of a screenshot (`locate`). Re-exported by `api_types`, where the rest of the browser requests are.
6
7use serde::{Deserialize, Serialize};
8
9use crate::api_types::UiAutomationAuth;
10
11/// `POST /api/v1/ui/browser/retake` — backs Browser's `retake`: the agent drives again a browser pane it lost to the
12/// person's Take over, once they gave it back. `pane` is required: it names the pane that was lost.
13#[derive(Debug, Clone, Serialize, Deserialize)]
14pub struct UiBrowserRetakeRequest {
15 #[serde(flatten)]
16 pub auth: UiAutomationAuth,
17 #[serde(default, skip_serializing_if = "Option::is_none")]
18 pub pane: Option<String>,
19}
20
21/// `POST /api/v1/ui/browser/take_control` — backs Browser's `take_control`: the agent drives a browser pane it did not open
22/// (found with Pane layout). `pane` is required. `allowed_origins` limits it to those sites, as `open` does; without it the
23/// pane is limited to the site it is on.
24#[derive(Debug, Clone, Serialize, Deserialize)]
25pub struct UiBrowserTakeControlRequest {
26 #[serde(flatten)]
27 pub auth: UiAutomationAuth,
28 #[serde(default, skip_serializing_if = "Option::is_none")]
29 pub pane: Option<String>,
30 #[serde(default, skip_serializing_if = "Option::is_none")]
31 pub allowed_origins: Option<Vec<String>>,
32}
33
34/// `POST /api/v1/ui/browser/release` — backs Browser's `release`: the agent stops driving a pane, which then has no driver.
35/// `pane` is required.
36#[derive(Debug, Clone, Serialize, Deserialize)]
37pub struct UiBrowserReleaseRequest {
38 #[serde(flatten)]
39 pub auth: UiAutomationAuth,
40 #[serde(default, skip_serializing_if = "Option::is_none")]
41 pub pane: Option<String>,
42}
43
44/// `POST /api/v1/ui/browser/handoff_status` — backs Browser's `handoff_status`: what became of a hand-off the agent asked
45/// the person for. By `handoff_id` (the hand-off's answer carries it), or the newest one on `pane`.
46#[derive(Debug, Clone, Serialize, Deserialize)]
47pub struct UiBrowserHandoffStatusRequest {
48 #[serde(flatten)]
49 pub auth: UiAutomationAuth,
50 #[serde(default, skip_serializing_if = "Option::is_none")]
51 pub pane: Option<String>,
52 #[serde(default, skip_serializing_if = "Option::is_none")]
53 pub handoff_id: Option<String>,
54}
55
56/// `POST /api/v1/ui/browser/request` — backs Browser's `request_status` and `cancel_request`: what became of a request
57/// the agent got "waiting for the person" for (docs/specs/SPEC_WAITING_CALLS_RETURN_AND_FREE_THE_TURN_2026_11_10.md),
58/// or take it down. By `request` (the waiting answer carries it), or the newest one on `pane`.
59#[derive(Debug, Clone, Serialize, Deserialize)]
60pub struct UiBrowserRequestRequest {
61 #[serde(flatten)]
62 pub auth: UiAutomationAuth,
63 #[serde(default, skip_serializing_if = "Option::is_none")]
64 pub request: Option<String>,
65 #[serde(default, skip_serializing_if = "Option::is_none")]
66 pub pane: Option<String>,
67 /// Take the request down instead of reading it.
68 #[serde(default)]
69 pub cancel: bool,
70}
71
72/// `POST /api/v1/ui/browser/zoom` — zoom a browser pane the agent drives, or put it back
73/// (docs/specs/SPEC_BROWSER_PANE_AGENT_ZOOM_2026_11_10.md). Exactly one of `factor`, `width`, `fit` and
74/// `reset`.
75#[derive(Debug, Clone, Serialize, Deserialize)]
76pub struct UiBrowserZoomRequest {
77 #[serde(flatten)]
78 pub auth: UiAutomationAuth,
79 /// Target a browser pane this agent opened or took control of; absent = the caller's own pane.
80 #[serde(default, skip_serializing_if = "Option::is_none")]
81 pub pane: Option<String>,
82 /// 0.25 to 2.0.
83 #[serde(default, skip_serializing_if = "Option::is_none")]
84 pub factor: Option<f64>,
85 /// A desktop viewport this many CSS pixels wide, scaled to fit the pane.
86 #[serde(default, skip_serializing_if = "Option::is_none")]
87 pub width: Option<f64>,
88 #[serde(default, skip_serializing_if = "Option::is_none")]
89 pub fit: Option<bool>,
90 #[serde(default, skip_serializing_if = "Option::is_none")]
91 pub reset: Option<bool>,
92}
93
94/// `POST /api/v1/ui/browser/locate` — backs Browser's `locate` and `click_at`: what a click at a point of
95/// a screenshot would land on, as a reference (forms-in-frames spec §4.6).
96#[derive(Debug, Clone, Serialize, Deserialize)]
97pub struct UiBrowserLocateRequest {
98 #[serde(flatten)]
99 pub auth: UiAutomationAuth,
100 /// Target a browser pane this agent opened with `OpenBrowser`; absent =
101 /// the caller's own pane.
102 #[serde(default, skip_serializing_if = "Option::is_none")]
103 pub pane: Option<String>,
104 /// The point, in pixels of the screenshot, from its top left corner.
105 pub x: f64,
106 pub y: f64,
107 /// The screenshot's width in pixels, which the host turns into the page's scale (absent: the point
108 /// is already in the page's own pixels).
109 #[serde(default, skip_serializing_if = "Option::is_none")]
110 pub image_width: Option<f64>,
111}
112
113/// `POST /api/v1/ui/browser/list` — backs Browser's `list`: the browser panes the caller opened and still has.
114#[derive(Debug, Clone, Serialize, Deserialize)]
115pub struct UiBrowserListRequest {
116 #[serde(flatten)]
117 pub auth: UiAutomationAuth,
118}
119
120/// `POST /api/v1/ui/browser/hide` — backs Browser's `hide`: put a floating pane the caller opened and the person sees back
121/// in the background. It takes the same arguments as `show`.
122pub type UiBrowserHideRequest = UiBrowserShowRequest;
123
124/// `POST /api/v1/ui/browser/show` — backs Browser's `show`: turn the caller's background session `pane` into a floating
125/// pane the person sees.
126#[derive(Debug, Clone, Serialize, Deserialize)]
127pub struct UiBrowserShowRequest {
128 #[serde(flatten)]
129 pub auth: UiAutomationAuth,
130 pub pane: String,
131}
132
133/// `POST /api/v1/ui/browser/scroll` - backs Browser's `scroll`: turn the wheel over a pane's page by `dx` and `dy` CSS pixels
134/// (right and down; negative left and up), or bring the element `ref` of the last snapshot into view. One of the two.
135#[derive(Debug, Clone, Serialize, Deserialize)]
136pub struct UiBrowserScrollRequest {
137 #[serde(flatten)]
138 pub auth: UiAutomationAuth,
139 #[serde(default, skip_serializing_if = "Option::is_none")]
140 pub pane: Option<String>,
141 #[serde(default, rename = "ref", skip_serializing_if = "Option::is_none")]
142 pub ref_: Option<String>,
143 #[serde(default, skip_serializing_if = "Option::is_none")]
144 pub dx: Option<f64>,
145 #[serde(default, skip_serializing_if = "Option::is_none")]
146 pub dy: Option<f64>,
147}
148
149/// Where a click or a drag in a canvas is: pixels of the canvas as `UI` `screenshot` with `canvas` shows it at the size it was
150/// drawn (from its top left). A click has `x` and `y`; a drag also has `to_x` and `to_y`, where the button is let go.
151#[derive(Debug, Clone, Serialize, Deserialize)]
152pub struct ActPoint {
153 pub x: f64,
154 pub y: f64,
155 #[serde(default, skip_serializing_if = "Option::is_none")]
156 pub to_x: Option<f64>,
157 #[serde(default, skip_serializing_if = "Option::is_none")]
158 pub to_y: Option<f64>,
159}