codetether-agent 4.7.0-a-002.4

A2A-native AI coding agent for the CodeTether ecosystem
Documentation
//! Browserctl DOM read action adapters.

use crate::browser::{BrowserCommand, BrowserError, BrowserOutput, request::ScopeRequest};
use crate::tool::browserctl::helpers::optional_string;
use crate::tool::browserctl::input::BrowserCtlInput;

/// Build and execute a text extraction command.
///
/// # Errors
///
/// Returns [`BrowserError`] when command execution fails.
pub(in crate::tool::browserctl) async fn text(
    input: &BrowserCtlInput,
) -> Result<BrowserOutput, BrowserError> {
    let request = ScopeRequest {
        selector: optional_string(&input.selector).map(str::to_string),
        frame_selector: optional_string(&input.frame_selector).map(str::to_string),
    };
    super::super::execute(input, BrowserCommand::Text(request)).await
}

/// Build and execute an HTML extraction command.
///
/// # Errors
///
/// Returns [`BrowserError`] when command execution fails.
pub(in crate::tool::browserctl) async fn html(
    input: &BrowserCtlInput,
) -> Result<BrowserOutput, BrowserError> {
    let request = ScopeRequest {
        selector: optional_string(&input.selector).map(str::to_string),
        frame_selector: optional_string(&input.frame_selector).map(str::to_string),
    };
    super::super::execute(input, BrowserCommand::Html(request)).await
}