#![forbid(unsafe_code)]
#![warn(missing_docs)]
#![warn(clippy::all)]
#![warn(clippy::pedantic)]
#![allow(clippy::module_name_repetitions)]
mod annotations;
mod command;
mod config;
mod error;
mod exec;
mod manager;
mod schema;
mod selector;
pub mod selectors;
mod server;
mod subcommands;
mod tool;
mod walk;
pub use annotations::ToolAnnotations;
pub use command::{command, generate_tools, handle, run, run_from};
pub use config::{Config, DescriptionMode};
pub use error::{Error, Result};
pub use schema::SchemaType;
pub use selector::{
BoxedNext, CmdMatcher, FlagMatcher, Middleware, MiddlewareCtx, MiddlewareResult, Selector,
};
pub use tool::{ToolInput, ToolOutput};
#[doc(hidden)]
pub mod __test_internal {
pub use crate::server::BrontesServer;
pub use crate::server::http::serve_http;
pub use crate::server::http::{
Acceptor, SHUTDOWN_GRACE, TokioTcpAcceptor, bind_default_acceptor, serve_http_with,
};
#[cfg(unix)]
pub use crate::subcommands::signal::{
SignalSource, TokioUnixSignalSource, spawn_signal_listener_with,
};
pub use hyper_util::rt::TokioIo;
#[must_use]
pub fn render_flag_argv(
flag_name: &str,
value: &serde_json::Value,
tool_name: &str,
) -> Vec<String> {
let mut out: Vec<String> = Vec::new();
crate::exec::append_flag_for_test(&mut out, flag_name, value, tool_name);
out
}
pub async fn drain_capped<R>(
reader: R,
stream_label: &'static str,
tool_name: String,
) -> Vec<u8>
where
R: tokio::io::AsyncRead + Unpin,
{
crate::exec::read_capped_for_test(reader, stream_label, tool_name).await
}
pub const OUTPUT_CAP_BYTES: usize = crate::exec::OUTPUT_CAP_BYTES;
#[must_use]
pub fn parse_start_log_level(matches: &clap::ArgMatches) -> Option<tracing::Level> {
crate::subcommands::start::parse_log_level_for_test(matches)
}
#[must_use]
pub fn start_subcommand() -> clap::Command {
crate::subcommands::start::build_for_test()
}
#[must_use]
pub fn parse_stream_log_level(matches: &clap::ArgMatches) -> Option<tracing::Level> {
crate::subcommands::stream::parse_log_level_for_test(matches)
}
#[must_use]
pub fn stream_subcommand() -> clap::Command {
crate::subcommands::stream::build_for_test()
}
pub async fn stream_run_with_cancel(
matches: &clap::ArgMatches,
cli: clap::Command,
cfg: Option<crate::Config>,
cancel: tokio_util::sync::CancellationToken,
) -> crate::Result<()> {
crate::subcommands::stream::run_with_cancel(matches, cli, cfg, cancel).await
}
pub async fn serve_stdio_with<R, W>(
cli: clap::Command,
cfg: crate::Config,
transport: (R, W),
cancel: tokio_util::sync::CancellationToken,
) -> crate::Result<()>
where
R: tokio::io::AsyncRead + Send + Unpin + 'static,
W: tokio::io::AsyncWrite + Send + Unpin + 'static,
{
crate::server::stdio::serve_stdio_with(cli, cfg, transport, cancel).await
}
pub fn editor_run(
editor: &str,
matches: &clap::ArgMatches,
_cli: &clap::Command,
) -> crate::Result<()> {
match editor {
"claude" => crate::subcommands::editor::claude::run(matches, None),
"cursor" => crate::subcommands::editor::cursor::run(matches, None),
"vscode" => crate::subcommands::editor::vscode::run(matches, None),
"zed" => crate::subcommands::editor::zed::run(matches, None),
other => Err(crate::Error::Config(format!(
"editor_run: unknown editor {other:?}"
))),
}
}
}