codetether_browser/browser/command.rs
1//! Browser command messages accepted by a [`BrowserSession`](crate::browser::BrowserSession).
2//!
3//! The command enum keeps tool-facing request parsing separate from the
4//! session backend that executes each operation.
5
6use super::request::{
7 AxiosRequest, ClickTextRequest, CloseTabRequest, DiagnoseRequest, EvalRequest, FetchRequest,
8 FillRequest, KeyPressRequest, NavigationRequest, NetworkLogRequest, NewTabRequest,
9 ReplayRequest, ScopeRequest, ScreenshotRequest, ScrollRequest, SelectorRequest, StartRequest,
10 TabSelectRequest, ToggleRequest, TypeRequest, UploadRequest, WaitRequest, XhrRequest,
11};
12
13/// Operation that can be executed against a browser session.
14///
15/// Variants carry the request payload needed by the native TetherScript backend
16/// and by callers that route browserctl actions through the shared browser
17/// service.
18pub enum BrowserCommand {
19 /// Report session health.
20 Health,
21 /// Start a browser session.
22 Start(StartRequest),
23 /// Stop the active browser session.
24 Stop,
25 /// Return a structured page snapshot.
26 Snapshot,
27 /// Navigate the current tab.
28 Goto(NavigationRequest),
29 /// Move back in the current tab history.
30 Back,
31 /// Reload the current tab.
32 Reload,
33 /// Wait for a selector or timeout.
34 Wait(WaitRequest),
35 /// Click an element by selector.
36 Click(SelectorRequest),
37 /// Move the pointer over an element by selector.
38 Hover(SelectorRequest),
39 /// Focus an element by selector.
40 Focus(SelectorRequest),
41 /// Blur an element by selector.
42 Blur(SelectorRequest),
43 /// Scroll the current page or selected element.
44 Scroll(ScrollRequest),
45 /// Upload files through an input element.
46 Upload(UploadRequest),
47 /// Fill an input-like element.
48 Fill(FillRequest),
49 /// Type text into the active page.
50 Type(TypeRequest),
51 /// Press a keyboard key.
52 Press(KeyPressRequest),
53 /// Read text content.
54 Text(ScopeRequest),
55 /// Read HTML content.
56 Html(ScopeRequest),
57 /// Evaluate JavaScript in the current page.
58 Eval(EvalRequest),
59 /// Click by visible text.
60 ClickText(ClickTextRequest),
61 /// Fill an input through the native path.
62 FillNative(FillRequest),
63 /// Toggle a checkbox-like control.
64 Toggle(ToggleRequest),
65 /// Capture a screenshot.
66 Screenshot(ScreenshotRequest),
67 /// Click at page coordinates.
68 MouseClick(super::request::PointerClick),
69 /// Type raw keyboard text.
70 KeyboardType(super::request::KeyboardTypeRequest),
71 /// Press a named keyboard key.
72 KeyboardPress(super::request::KeyboardPressRequest),
73 /// List open tabs.
74 Tabs,
75 /// Select a tab by index.
76 TabsSelect(TabSelectRequest),
77 /// Open a new tab.
78 TabsNew(NewTabRequest),
79 /// Close a tab.
80 TabsClose(CloseTabRequest),
81 /// Return recorded network events.
82 NetworkLog(NetworkLogRequest),
83 /// Issue a fetch-style HTTP request.
84 Fetch(FetchRequest),
85 /// Issue an axios-style HTTP request.
86 Axios(AxiosRequest),
87 /// Issue an XHR-style HTTP request.
88 Xhr(XhrRequest),
89 /// Replay a captured HTTP request.
90 Replay(ReplayRequest),
91 /// Return backend diagnostics.
92 Diagnose(DiagnoseRequest),
93}