use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize, Default, schemars::JsonSchema)]
pub struct OpenArgs {
#[serde(flatten)]
pub operation: crate::ActionSettings,
pub url: String,
pub headers: Option<serde_json::Value>,
pub user_agent: Option<String>,
#[serde(default)]
pub bypass_csp: bool,
pub inject_js: Option<String>,
pub load_state: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default, schemars::JsonSchema)]
pub struct SnapshotArgs {
#[serde(default)]
pub interactive: bool,
#[serde(default)]
pub all: bool,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default, schemars::JsonSchema)]
pub struct ObserveArgs {
#[schemars(
description = "Filter: 'inputs' for form elements, 'buttons' for buttons and links, or 'all' for all observed elements."
)]
pub filter: Option<String>,
#[schemars(description = "Maximum elements to return.")]
pub max: Option<usize>,
#[serde(default)]
pub structured: bool,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default, schemars::JsonSchema)]
pub struct ScreenshotArgs {
pub output: Option<String>,
#[serde(default)]
pub annotate: bool,
#[serde(default)]
#[schemars(description = "Image format; PNG when omitted.")]
pub format: Option<crate::sidecar::ScreenshotFormat>,
#[serde(default)]
#[schemars(range(max = 100), description = "JPEG or WebP quality, 0 to 100.")]
pub quality: Option<u8>,
#[serde(default)]
#[schemars(description = "Document-relative CSS pixel region; conflicts with full_page.")]
pub clip: Option<crate::sidecar::ScreenshotClip>,
#[serde(default)]
#[schemars(description = "Capture the whole scrollable page instead of the viewport.")]
pub full_page: bool,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default, schemars::JsonSchema)]
pub struct RecordingStartArgs {
#[schemars(description = "Absolute path of the MP4 file to write.")]
pub path: String,
#[serde(default)]
#[schemars(description = "UUID naming this recording; generated when omitted.")]
pub recording_id: Option<String>,
#[serde(default)]
pub max_width: Option<u32>,
#[serde(default)]
pub max_height: Option<u32>,
#[serde(default)]
#[schemars(range(min = 1, max = 120))]
pub fps: Option<u32>,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default, schemars::JsonSchema)]
pub struct RecordingIdArgs {
#[schemars(description = "Recording UUID returned by recording_start.")]
pub recording_id: String,
}
#[derive(Debug, Clone, Serialize, Deserialize, schemars::JsonSchema)]
pub struct EmulateArgs {
#[serde(default = "default_viewport_width")]
pub width: u32,
#[serde(default = "default_viewport_height")]
pub height: u32,
#[serde(default = "default_device_pixel_ratio")]
pub dpr: f64,
#[serde(default)]
pub desktop: bool,
#[serde(default)]
pub reset: bool,
}
impl Default for EmulateArgs {
fn default() -> Self {
Self {
width: default_viewport_width(),
height: default_viewport_height(),
dpr: default_device_pixel_ratio(),
desktop: false,
reset: false,
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize, Default, schemars::JsonSchema)]
pub struct TextArgs {
#[schemars(description = "Text substring to search for, matched case-insensitively.")]
pub text: String,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default, schemars::JsonSchema)]
pub struct TargetArgs {
#[serde(flatten)]
pub operation: crate::ActionSettings,
#[schemars(
description = "Target element. Supports scoped refs from view, text:Submit, placeholder:Email, role:button, css:form button, id:my-btn, or plain text search."
)]
pub target: String,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default, schemars::JsonSchema)]
pub struct FillArgs {
#[serde(flatten)]
pub operation: crate::ActionSettings,
#[schemars(
description = "Target input. Supports scoped refs from view, text:Email, placeholder:Enter code, css:input.search, id:email-field, or plain text search."
)]
pub target: String,
#[schemars(description = "Text to type into the element.")]
pub text: String,
#[serde(default)]
pub input_mode: crate::InputMode,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default, schemars::JsonSchema)]
pub struct SelectArgs {
#[serde(flatten)]
pub operation: crate::ActionSettings,
#[schemars(
description = "Target select element by scoped reference, text, CSS selector, id, or role."
)]
pub target: String,
#[schemars(description = "Option value or visible text to select.")]
pub value: String,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default, schemars::JsonSchema)]
pub struct KeyArgs {
#[serde(flatten)]
pub operation: crate::ActionSettings,
#[schemars(
description = "Key to press, for example Enter, Tab, Escape, ArrowDown, or Backspace."
)]
pub key: String,
}
#[derive(Debug, Clone, Copy, Serialize, Deserialize, schemars::JsonSchema)]
#[serde(rename_all = "lowercase")]
pub enum MouseButton {
Left,
Middle,
Right,
Back,
Forward,
}
#[derive(Debug, Clone, Serialize, Deserialize, schemars::JsonSchema)]
pub struct MouseButtonArgs {
#[schemars(description = "Viewport horizontal coordinate in CSS pixels.")]
pub x: f64,
#[schemars(description = "Viewport vertical coordinate in CSS pixels.")]
pub y: f64,
#[schemars(description = "Mouse button to hold or release.")]
pub button: MouseButton,
}
#[derive(Debug, Clone, Serialize, Deserialize, schemars::JsonSchema)]
pub struct MouseMoveArgs {
#[schemars(description = "Viewport horizontal coordinate in CSS pixels.")]
pub x: f64,
#[schemars(description = "Viewport vertical coordinate in CSS pixels.")]
pub y: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default, schemars::JsonSchema)]
pub struct ScriptArgs {
#[serde(default)]
pub arguments: Vec<serde_json::Value>,
#[serde(default)]
pub raw: bool,
pub code: Option<String>,
pub file: Option<String>,
pub max_size: Option<usize>,
#[serde(default)]
pub no_await: bool,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default, schemars::JsonSchema)]
pub struct FrameEvalArgs {
#[schemars(
description = "CSS selector matching exactly one iframe/frame in the top document, or id:<frame-id> from frames for explicit/nested selection. Bare URLs and indices are not supported. Evaluation uses an isolated world, not page-owned JavaScript globals."
)]
pub frame: String,
pub code: Option<String>,
pub file: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default, schemars::JsonSchema)]
pub struct FetchArgs {
pub url: String,
pub method: Option<String>,
pub headers: Option<serde_json::Value>,
pub body: Option<String>,
pub redirect: Option<String>,
#[serde(default)]
pub body_only: bool,
#[schemars(
description = "Raw text byte limit: default 8192, maximum 16777216; zero inspects headers only.",
range(max = 16777216)
)]
pub max_body: Option<usize>,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default, schemars::JsonSchema)]
pub struct SetCookieArgs {
pub name: String,
pub value: String,
pub domain: Option<String>,
pub path: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default, schemars::JsonSchema)]
pub struct DeleteCookieArgs {
pub name: String,
pub domain: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default, schemars::JsonSchema)]
pub struct StorageArgs {
pub key: Option<String>,
#[serde(default)]
pub session_storage: bool,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default, schemars::JsonSchema)]
pub struct SetStorageArgs {
pub key: String,
pub value: String,
#[serde(default)]
pub session_storage: bool,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default, schemars::JsonSchema)]
pub struct PathArgs {
#[schemars(description = "File path.")]
pub path: String,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default, schemars::JsonSchema)]
pub struct LoadStateArgs {
pub path: String,
#[serde(default)]
pub no_navigate: bool,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default, schemars::JsonSchema)]
pub struct HeadersArgs {
pub headers_json: String,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default, schemars::JsonSchema)]
pub struct ConsoleArgs {
#[serde(default)]
pub clear: bool,
pub level: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default, schemars::JsonSchema)]
pub struct ClearFlagArgs {
#[serde(default)]
pub clear: bool,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default, schemars::JsonSchema)]
pub struct TabNewArgs {
#[schemars(description = "Optional URL to navigate to. If omitted, opens a blank tab.")]
pub url: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default, schemars::JsonSchema)]
pub struct TabIdArgs {
#[schemars(description = "Tab ID from list_tabs.")]
pub tab_id: String,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default, schemars::JsonSchema)]
pub struct CloneFromArgs {
pub source: String,
pub to: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default, schemars::JsonSchema)]
pub struct WaitArgs {
#[serde(default)]
pub expect: Option<crate::Expectation>,
pub ms: Option<u64>,
pub text: Option<String>,
pub url: Option<String>,
pub load: Option<String>,
#[serde(default)]
#[schemars(description = "CSS selector to wait for; see `state`.")]
pub selector: Option<String>,
#[serde(default)]
#[schemars(description = "What the selector must become. Defaults to visible.")]
pub state: Option<WaitSelectorState>,
pub timeout: Option<u64>,
}
#[derive(
Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Default, schemars::JsonSchema,
)]
#[serde(rename_all = "lowercase")]
pub enum WaitSelectorState {
Attached,
#[default]
Visible,
Hidden,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default, schemars::JsonSchema)]
pub struct DialogAcceptArgs {
#[serde(default)]
#[schemars(
description = "Text to enter for a prompt() dialog; ignored for alert and confirm."
)]
pub prompt_text: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default, schemars::JsonSchema)]
pub struct SelectorArgs {
#[schemars(description = "CSS selector of the element.")]
pub selector: String,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default, schemars::JsonSchema)]
pub struct AttributeArgs {
#[schemars(description = "CSS selector of the element.")]
pub selector: String,
#[schemars(description = "Attribute name, for example href.")]
pub name: String,
}
#[derive(Debug, Clone, Serialize, Deserialize, schemars::JsonSchema)]
pub struct ClickShadowArgs {
#[schemars(description = "CSS selector, matched through open and closed shadow roots.")]
pub selector: String,
#[serde(default)]
#[schemars(description = "Frame ID from `frames`; the top frame when omitted.")]
pub frame_id: Option<String>,
#[serde(default = "default_click_shadow_timeout_ms")]
pub timeout_ms: u64,
}
fn default_click_shadow_timeout_ms() -> u64 {
10_000
}
#[derive(Debug, Clone, Serialize, Deserialize, Default, schemars::JsonSchema)]
pub struct PathStringArgs {
#[schemars(description = "Target path, for example /docs or /about.")]
pub path: String,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default, schemars::JsonSchema)]
pub struct FakeCameraArgs {
pub file: String,
#[serde(default)]
pub loop_video: bool,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default, schemars::JsonSchema)]
pub struct WasmReadArgs {
pub addr: String,
pub len: usize,
pub memory: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default, schemars::JsonSchema)]
pub struct WasmWriteArgs {
pub addr: String,
pub hex: String,
pub memory: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize, schemars::JsonSchema)]
pub struct WasmFindArgs {
pub pattern: String,
pub start: Option<String>,
pub end: Option<String>,
#[serde(default = "default_wasm_find_max")]
pub max: usize,
pub memory: Option<String>,
}
impl Default for WasmFindArgs {
fn default() -> Self {
Self {
pattern: String::new(),
start: None,
end: None,
max: default_wasm_find_max(),
memory: None,
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize, schemars::JsonSchema)]
pub struct InterceptAddArgs {
pub url_pattern: String,
pub capture: Option<String>,
pub respond: Option<String>,
#[serde(default = "default_intercept_status")]
pub status: u16,
}
impl Default for InterceptAddArgs {
fn default() -> Self {
Self {
url_pattern: String::new(),
capture: None,
respond: None,
status: default_intercept_status(),
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize, Default, schemars::JsonSchema)]
pub struct IdArgs {
pub id: String,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default, schemars::JsonSchema)]
pub struct ModeArgs {
pub mode: String,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default, schemars::JsonSchema)]
pub struct DomainArgs {
pub domain: String,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default, schemars::JsonSchema)]
pub struct CaptchaInjectArgs {
pub token: String,
#[serde(default = "default_captcha_type")]
pub captcha_type: String,
pub callback: Option<String>,
pub click_after: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default, schemars::JsonSchema)]
pub struct NetworkRecordStartArgs {
#[serde(default)]
pub patterns: Vec<String>,
#[serde(default)]
pub no_bodies: bool,
#[serde(default = "default_max_body_bytes")]
pub max_body_bytes: usize,
#[serde(default)]
pub clear: bool,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default, schemars::JsonSchema)]
pub struct NetworkLogArgs {
pub limit: Option<usize>,
pub pattern: Option<String>,
pub method: Option<String>,
pub status: Option<u16>,
pub since: Option<u64>,
#[serde(default)]
pub compact: bool,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default, schemars::JsonSchema)]
pub struct NetworkShowArgs {
pub id: u64,
#[serde(default)]
pub body: bool,
pub max_body: Option<usize>,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default, schemars::JsonSchema)]
pub struct NetworkWaitArgs {
pub pattern: Option<String>,
pub method: Option<String>,
pub status: Option<u16>,
pub timeout: Option<u64>,
pub since: Option<u64>,
#[serde(default)]
pub include_existing: bool,
}
#[derive(Debug, Clone, Serialize, Deserialize, schemars::JsonSchema)]
pub struct NetworkExportArgs {
pub path: String,
#[serde(default = "default_network_export_format")]
pub format: String,
pub settle_ms: Option<u64>,
}
impl Default for NetworkExportArgs {
fn default() -> Self {
Self {
path: String::new(),
format: default_network_export_format(),
settle_ms: None,
}
}
}
fn default_max_body_bytes() -> usize {
10 * 1024 * 1024
}
fn default_network_export_format() -> String {
"har".to_string()
}
fn default_viewport_width() -> u32 {
390
}
fn default_viewport_height() -> u32 {
844
}
fn default_device_pixel_ratio() -> f64 {
2.0
}
fn default_wasm_find_max() -> usize {
20
}
fn default_intercept_status() -> u16 {
200
}
fn default_captcha_type() -> String {
"auto".to_string()
}