typeduck-codex-web 0.1.0

A browser interface for Codex CLI sessions
Documentation
use std::path::PathBuf;

use clap::Parser;
use codex_web::WebOptions;

/// Run Codex sessions in a local browser interface.
#[derive(Debug, Parser)]
#[command(name = "typeduck-codex-web", version)]
struct Cli {
    /// TCP port to listen on. Uses an available port when omitted.
    #[arg(long, default_value_t = 0)]
    port: u16,

    /// Do not open the session in the default browser.
    #[arg(long)]
    no_open: bool,

    /// Tell the agent to use the specified directory as its working root.
    #[arg(long = "cd", short = 'C', value_name = "DIR")]
    cwd: Option<PathBuf>,

    /// Path or command name for the Codex CLI executable.
    #[arg(long, default_value = "codex", value_name = "PATH")]
    codex_bin: PathBuf,

    /// Override a configuration value that would otherwise be loaded from config.toml.
    #[arg(short = 'c', value_name = "KEY=VALUE")]
    config_overrides: Vec<String>,

    /// Error out when config.toml contains unknown fields.
    #[arg(long, default_value_t = false)]
    strict_config: bool,
}

#[tokio::main]
async fn main() -> std::io::Result<()> {
    let cli = Cli::parse();
    codex_web::run(WebOptions {
        port: cli.port,
        open_browser: !cli.no_open,
        cwd: cli.cwd.unwrap_or(std::env::current_dir()?),
        codex_executable: cli.codex_bin,
        config_overrides: cli.config_overrides,
        strict_config: cli.strict_config,
    })
    .await
}