Skip to main content

agent_first_http/cli/cmd/
capabilities.rs

1//! `afhttp capabilities` subcommand.
2
3use clap::Args as ClapArgs;
4
5use crate::cli::output;
6use crate::sdk::Client;
7use crate::shared::error::Error;
8
9#[derive(ClapArgs, Debug)]
10pub struct Args {
11    /// CDP endpoint of the running host (e.g. `ws://127.0.0.1:9222`). Falls back to `AFHTTP_ENDPOINT_URL`.
12    #[arg(long = "endpoint-url", env = "AFHTTP_ENDPOINT_URL")]
13    pub endpoint: String,
14    /// Bearer token, if the host was started with `--token-secret`.
15    /// Falls back to `AFHTTP_TOKEN_SECRET`.
16    #[arg(long = "token-secret", env = "AFHTTP_TOKEN_SECRET")]
17    pub token: Option<String>,
18}
19
20pub async fn run(args: Args) -> Result<(), Error> {
21    let mut client = Client::connect(&args.endpoint)?;
22    if let Some(t) = args.token.as_deref() {
23        client = client.with_token(t);
24    }
25    let response = client.capabilities().await?;
26    output::emit("capabilities", &response)
27}