codetether-agent 4.7.0-a-002.4

A2A-native AI coding agent for the CodeTether ecosystem
Documentation
use clap::{ArgAction, Parser, Subcommand};
use std::path::PathBuf;

use super::offline_args::OfflineCommand;

#[derive(Parser, Debug)]
#[command(
    about = "Control a Chromium browser via the local DevTools Protocol",
    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."
)]
pub struct BrowserCtlArgs {
    #[arg(long, global = true, env = "CODETETHER_BROWSER_WS_URL")]
    pub ws_url: Option<String>,
    #[arg(long, global = true)]
    pub json: bool,
    #[arg(long, global = true, default_value_t = true, action = ArgAction::Set)]
    pub headless: bool,
    #[command(subcommand)]
    pub command: BrowserCtlCommand,
}

#[derive(Subcommand, Debug)]
pub enum BrowserCtlCommand {
    /// Attach to an existing DevTools endpoint or launch a managed browser
    Start {
        #[arg(long)]
        executable_path: Option<String>,
        #[arg(long)]
        user_data_dir: Option<PathBuf>,
    },
    /// Stop the managed browser session for this process
    Stop,
    /// Show current browser session health
    Health,
    /// List tabs in the attached browser session
    List,
    /// Open a URL in the active tab
    Open { url: String },
    /// Read URL, title, viewport, and visible page text
    Snapshot,
    /// Evaluate JavaScript in the active tab
    Eval {
        expression: String,
        #[arg(long, default_value_t = 30_000)]
        timeout_ms: u64,
    },
    /// Capture a screenshot to a local path
    Screenshot {
        #[arg(long)]
        path: PathBuf,
        #[arg(long, default_value_t = true)]
        full_page: bool,
    },
    /// TetherScript-backed offline probes: auth-trace, cookie-diff, explain-cors, record, replay
    Offline {
        #[command(subcommand)]
        cmd: OfflineCommand,
    },
}