mirror of
https://github.com/harivansh-afk/sandbox-agent.git
synced 2026-04-16 09:04:29 +00:00
Add comprehensive tracing instrumentation across the entire agent startup path (gigacode CLI, ACP HTTP adapter, agent installation, and process spawning) to enable detailed performance profiling. Replace npm-based agent process launchers that use npx (incurring resolution overhead on every spawn) with pre-installed npm packages, reducing startup latency. Improve error diagnostics when agent processes crash by capturing exit codes and stderr tails. Update error handling to map exited processes to dedicated error variants with actionable error messages. Co-authored-by: Claude Haiku 4.5 <noreply@anthropic.com>
62 lines
1.6 KiB
Rust
62 lines
1.6 KiB
Rust
use std::time::Duration;
|
|
|
|
use acp_http_adapter::{run_server, ServerConfig};
|
|
use clap::Parser;
|
|
|
|
#[derive(Debug, Parser)]
|
|
#[command(name = "acp-http-adapter")]
|
|
#[command(about = "Minimal ACP HTTP->stdio adapter", version)]
|
|
struct Cli {
|
|
#[arg(long, default_value = "127.0.0.1")]
|
|
host: String,
|
|
|
|
#[arg(long, default_value_t = 7591)]
|
|
port: u16,
|
|
|
|
#[arg(long)]
|
|
registry_json: String,
|
|
|
|
#[arg(long)]
|
|
registry_agent_id: Option<String>,
|
|
|
|
#[arg(long)]
|
|
rpc_timeout_ms: Option<u64>,
|
|
}
|
|
|
|
#[tokio::main]
|
|
async fn main() {
|
|
if let Err(err) = run().await {
|
|
tracing::error!(error = %err, "acp-http-adapter failed");
|
|
std::process::exit(1);
|
|
}
|
|
}
|
|
|
|
async fn run() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
|
|
let started = std::time::Instant::now();
|
|
tracing_subscriber::fmt()
|
|
.with_env_filter(
|
|
tracing_subscriber::EnvFilter::try_from_default_env()
|
|
.unwrap_or_else(|_| tracing_subscriber::EnvFilter::new("info")),
|
|
)
|
|
.compact()
|
|
.init();
|
|
|
|
let cli = Cli::parse();
|
|
tracing::info!(
|
|
host = %cli.host,
|
|
port = cli.port,
|
|
startup_ms = started.elapsed().as_millis() as u64,
|
|
"acp-http-adapter.run: starting server"
|
|
);
|
|
run_server(ServerConfig {
|
|
host: cli.host,
|
|
port: cli.port,
|
|
registry_json: cli.registry_json,
|
|
registry_agent_id: cli.registry_agent_id,
|
|
rpc_timeout: cli
|
|
.rpc_timeout_ms
|
|
.map(Duration::from_millis)
|
|
.unwrap_or_else(|| Duration::from_secs(120)),
|
|
})
|
|
.await
|
|
}
|