63 lines
2.0 KiB
Rust
63 lines
2.0 KiB
Rust
//! Shared CLI options for the dispatcher and its headless executable.
|
|
use clap::Args;
|
|
use prometeu_host_headless::automation::Limits;
|
|
|
|
#[derive(Args, Debug)]
|
|
pub struct HeadlessArgs {
|
|
/// Use the versioned JSONL stdin/stdout protocol (required).
|
|
#[arg(long, required = true)]
|
|
pub stdio: bool,
|
|
#[arg(long, default_value_t = 600)]
|
|
pub max_frames: u64,
|
|
#[arg(long, default_value_t = 65536)]
|
|
pub max_command_bytes: usize,
|
|
#[arg(long, default_value_t = 33554432)]
|
|
pub max_response_bytes: usize,
|
|
#[arg(long, default_value_t = 5000)]
|
|
pub handshake_timeout_ms: u64,
|
|
#[arg(long, default_value_t = 60000)]
|
|
pub call_timeout_ms: u64,
|
|
#[arg(long, default_value_t = 5000)]
|
|
pub shutdown_timeout_ms: u64,
|
|
}
|
|
|
|
impl HeadlessArgs {
|
|
pub fn limits(&self) -> Limits {
|
|
Limits {
|
|
max_frames: self.max_frames,
|
|
max_command_bytes: self.max_command_bytes,
|
|
max_response_bytes: self.max_response_bytes,
|
|
handshake_timeout_ms: self.handshake_timeout_ms,
|
|
call_timeout_ms: self.call_timeout_ms,
|
|
shutdown_timeout_ms: self.shutdown_timeout_ms,
|
|
}
|
|
}
|
|
|
|
pub fn forwarded_args(&self) -> Vec<String> {
|
|
vec![
|
|
"--stdio".into(),
|
|
"--max-frames".into(),
|
|
self.max_frames.to_string(),
|
|
"--max-command-bytes".into(),
|
|
self.max_command_bytes.to_string(),
|
|
"--max-response-bytes".into(),
|
|
self.max_response_bytes.to_string(),
|
|
"--handshake-timeout-ms".into(),
|
|
self.handshake_timeout_ms.to_string(),
|
|
"--call-timeout-ms".into(),
|
|
self.call_timeout_ms.to_string(),
|
|
"--shutdown-timeout-ms".into(),
|
|
self.shutdown_timeout_ms.to_string(),
|
|
]
|
|
}
|
|
}
|
|
|
|
pub fn run_headless(args: HeadlessArgs) -> std::io::Result<()> {
|
|
prometeu_host_headless::automation::serve(
|
|
std::io::BufReader::new(std::io::stdin()),
|
|
std::io::stdout(),
|
|
args.limits(),
|
|
env!("CARGO_PKG_VERSION"),
|
|
)
|
|
}
|