Skip to main content

codetether_agent/cli/browserctl/
args.rs

1use clap::{ArgAction, Parser, Subcommand};
2use std::path::PathBuf;
3
4use super::offline_args::OfflineCommand;
5
6#[derive(Parser, Debug)]
7#[command(
8    about = "Control a Chromium browser via the local DevTools Protocol",
9    long_about = "Control a local Chromium-family browser through Chrome DevTools Protocol.\n\nUse --ws-url with a ws://.../devtools/browser/... URL or http://127.0.0.1:9222. When omitted, Codetether probes local debug ports before launching a managed browser. Access is local-only and uses whatever browser profile/session that DevTools endpoint exposes."
10)]
11pub struct BrowserCtlArgs {
12    #[arg(long, global = true, env = "CODETETHER_BROWSER_WS_URL")]
13    pub ws_url: Option<String>,
14    #[arg(long, global = true)]
15    pub json: bool,
16    #[arg(long, global = true, default_value_t = true, action = ArgAction::Set)]
17    pub headless: bool,
18    #[command(subcommand)]
19    pub command: BrowserCtlCommand,
20}
21
22#[derive(Subcommand, Debug)]
23pub enum BrowserCtlCommand {
24    /// Attach to an existing DevTools endpoint or launch a managed browser
25    Start {
26        #[arg(long)]
27        executable_path: Option<String>,
28        #[arg(long)]
29        user_data_dir: Option<PathBuf>,
30    },
31    /// Stop the managed browser session for this process
32    Stop,
33    /// Show current browser session health
34    Health,
35    /// List tabs in the attached browser session
36    List,
37    /// Open a URL in the active tab
38    Open { url: String },
39    /// Read URL, title, viewport, and visible page text
40    Snapshot,
41    /// Evaluate JavaScript in the active tab
42    Eval {
43        expression: String,
44        #[arg(long, default_value_t = 30_000)]
45        timeout_ms: u64,
46    },
47    /// Capture a screenshot to a local path
48    Screenshot {
49        #[arg(long)]
50        path: PathBuf,
51        #[arg(long, default_value_t = true)]
52        full_page: bool,
53    },
54    /// TetherScript-backed offline probes: auth-trace, cookie-diff, explain-cors, record, replay
55    Offline {
56        #[command(subcommand)]
57        cmd: OfflineCommand,
58    },
59}