refactor: rename sandbox-daemon to sandbox-agent

This commit is contained in:
Nathan Flurry 2026-01-25 02:30:12 -08:00
parent f92ecd9b9a
commit a49ea094f3
41 changed files with 808 additions and 134 deletions

View file

@ -1,12 +1,17 @@
[package]
name = "sandbox-daemon-openapi-gen"
version = "0.1.0"
edition = "2021"
name = "sandbox-agent-openapi-gen"
version.workspace = true
edition.workspace = true
authors.workspace = true
license.workspace = true
build = "build.rs"
[dependencies]
tracing = "0.1"
tracing-logfmt = "0.3"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
[build-dependencies]
sandbox-daemon-core = { path = "../sandbox-daemon" }
sandbox-agent-core = { path = "../sandbox-agent" }
serde_json = "1.0"
utoipa = "4.2"

View file

@ -1,12 +1,13 @@
use std::fs;
use std::io::{self, Write};
use std::path::Path;
use sandbox_daemon_core::router::ApiDoc;
use sandbox_agent_core::router::ApiDoc;
use utoipa::OpenApi;
fn main() {
println!("cargo:rerun-if-changed=../sandbox-daemon/src/router.rs");
println!("cargo:rerun-if-changed=../sandbox-daemon/src/lib.rs");
emit_stdout("cargo:rerun-if-changed=../sandbox-agent/src/router.rs");
emit_stdout("cargo:rerun-if-changed=../sandbox-agent/src/lib.rs");
let out_dir = std::env::var("OUT_DIR").expect("OUT_DIR not set");
let out_path = Path::new(&out_dir).join("openapi.json");
@ -16,5 +17,15 @@ fn main() {
.expect("Failed to serialize OpenAPI spec");
fs::write(&out_path, json).expect("Failed to write OpenAPI spec");
println!("cargo:warning=Generated OpenAPI spec at {}", out_path.display());
emit_stdout(&format!(
"cargo:warning=Generated OpenAPI spec at {}",
out_path.display()
));
}
fn emit_stdout(message: &str) {
let mut out = io::stdout();
let _ = out.write_all(message.as_bytes());
let _ = out.write_all(b"\n");
let _ = out.flush();
}

View file

@ -1,8 +1,12 @@
use std::env;
use std::fs;
use std::io::Write;
use std::path::PathBuf;
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt, EnvFilter};
fn main() {
init_logging();
let mut out: Option<PathBuf> = None;
let mut stdout = false;
let mut args = env::args().skip(1).peekable();
@ -26,15 +30,30 @@ fn main() {
}
}
let schema = sandbox_daemon_openapi_gen::OPENAPI_JSON;
let schema = sandbox_agent_openapi_gen::OPENAPI_JSON;
if stdout {
println!("{schema}");
write_stdout(schema);
return;
}
let out = out.unwrap_or_else(|| PathBuf::from("openapi.json"));
if let Err(err) = fs::write(&out, schema) {
eprintln!("failed to write {}: {err}", out.display());
tracing::error!(path = %out.display(), error = %err, "failed to write openapi schema");
std::process::exit(1);
}
}
fn init_logging() {
let filter = EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new("info"));
tracing_subscriber::registry()
.with(filter)
.with(tracing_logfmt::builder().layer().with_writer(std::io::stderr))
.init();
}
fn write_stdout(text: &str) {
let mut out = std::io::stdout();
let _ = out.write_all(text.as_bytes());
let _ = out.write_all(b"\n");
let _ = out.flush();
}