chore: cargo fmt

This commit is contained in:
Nathan Flurry 2026-02-06 03:27:32 -08:00
parent f0191579c0
commit 2a00a03eca
22 changed files with 96 additions and 93 deletions

View file

@ -3,7 +3,7 @@ resolver = "2"
members = ["server/packages/*", "gigacode"]
[workspace.package]
version = "0.1.6"
version = "0.1.7-rc.1"
edition = "2021"
authors = [ "Rivet Gaming, LLC <developer@rivet.gg>" ]
license = "Apache-2.0"
@ -12,12 +12,12 @@ description = "Universal API for automatic coding agents in sandboxes. Supprots
[workspace.dependencies]
# Internal crates
sandbox-agent = { version = "0.1.6", path = "server/packages/sandbox-agent" }
sandbox-agent-error = { version = "0.1.6", path = "server/packages/error" }
sandbox-agent-agent-management = { version = "0.1.6", path = "server/packages/agent-management" }
sandbox-agent-agent-credentials = { version = "0.1.6", path = "server/packages/agent-credentials" }
sandbox-agent-universal-agent-schema = { version = "0.1.6", path = "server/packages/universal-agent-schema" }
sandbox-agent-extracted-agent-schemas = { version = "0.1.6", path = "server/packages/extracted-agent-schemas" }
sandbox-agent = { version = "0.1.7-rc.1", path = "server/packages/sandbox-agent" }
sandbox-agent-error = { version = "0.1.7-rc.1", path = "server/packages/error" }
sandbox-agent-agent-management = { version = "0.1.7-rc.1", path = "server/packages/agent-management" }
sandbox-agent-agent-credentials = { version = "0.1.7-rc.1", path = "server/packages/agent-credentials" }
sandbox-agent-universal-agent-schema = { version = "0.1.7-rc.1", path = "server/packages/universal-agent-schema" }
sandbox-agent-extracted-agent-schemas = { version = "0.1.7-rc.1", path = "server/packages/extracted-agent-schemas" }
# Serialization
serde = { version = "1.0", features = ["derive"] }

View file

@ -1,6 +1,6 @@
use clap::Parser;
use sandbox_agent::cli::{
CliConfig, CliError, Command, GigacodeCli, OpencodeArgs, init_logging, run_command,
init_logging, run_command, CliConfig, CliError, Command, GigacodeCli, OpencodeArgs,
};
fn main() {

View file

@ -1,6 +1,6 @@
{
"name": "@sandbox-agent/cli-shared",
"version": "0.1.6",
"version": "0.1.7-rc.1",
"description": "Shared helpers for sandbox-agent CLI and SDK",
"license": "Apache-2.0",
"repository": {

View file

@ -1,6 +1,6 @@
{
"name": "@sandbox-agent/cli",
"version": "0.1.6",
"version": "0.1.7-rc.1",
"description": "CLI for sandbox-agent - run AI coding agents in sandboxes",
"license": "Apache-2.0",
"repository": {

View file

@ -1,6 +1,6 @@
{
"name": "@sandbox-agent/cli-darwin-arm64",
"version": "0.1.6",
"version": "0.1.7-rc.1",
"description": "sandbox-agent CLI binary for macOS ARM64",
"license": "Apache-2.0",
"repository": {

View file

@ -1,6 +1,6 @@
{
"name": "@sandbox-agent/cli-darwin-x64",
"version": "0.1.6",
"version": "0.1.7-rc.1",
"description": "sandbox-agent CLI binary for macOS x64",
"license": "Apache-2.0",
"repository": {

View file

@ -1,6 +1,6 @@
{
"name": "@sandbox-agent/cli-linux-arm64",
"version": "0.1.6",
"version": "0.1.7-rc.1",
"description": "sandbox-agent CLI binary for Linux arm64",
"license": "Apache-2.0",
"repository": {

View file

@ -1,6 +1,6 @@
{
"name": "@sandbox-agent/cli-linux-x64",
"version": "0.1.6",
"version": "0.1.7-rc.1",
"description": "sandbox-agent CLI binary for Linux x64",
"license": "Apache-2.0",
"repository": {

View file

@ -1,6 +1,6 @@
{
"name": "@sandbox-agent/cli-win32-x64",
"version": "0.1.6",
"version": "0.1.7-rc.1",
"description": "sandbox-agent CLI binary for Windows x64",
"license": "Apache-2.0",
"repository": {

View file

@ -1,6 +1,6 @@
{
"name": "@sandbox-agent/gigacode",
"version": "0.1.6",
"version": "0.1.7-rc.1",
"description": "Gigacode CLI (sandbox-agent with OpenCode attach by default)",
"license": "Apache-2.0",
"repository": {

View file

@ -1,6 +1,6 @@
{
"name": "@sandbox-agent/gigacode-darwin-arm64",
"version": "0.1.6",
"version": "0.1.7-rc.1",
"description": "gigacode CLI binary for macOS arm64",
"license": "Apache-2.0",
"repository": {

View file

@ -1,6 +1,6 @@
{
"name": "@sandbox-agent/gigacode-darwin-x64",
"version": "0.1.6",
"version": "0.1.7-rc.1",
"description": "gigacode CLI binary for macOS x64",
"license": "Apache-2.0",
"repository": {

View file

@ -1,6 +1,6 @@
{
"name": "@sandbox-agent/gigacode-linux-arm64",
"version": "0.1.6",
"version": "0.1.7-rc.1",
"description": "gigacode CLI binary for Linux arm64",
"license": "Apache-2.0",
"repository": {

View file

@ -1,6 +1,6 @@
{
"name": "@sandbox-agent/gigacode-linux-x64",
"version": "0.1.6",
"version": "0.1.7-rc.1",
"description": "gigacode CLI binary for Linux x64",
"license": "Apache-2.0",
"repository": {

View file

@ -1,6 +1,6 @@
{
"name": "@sandbox-agent/gigacode-win32-x64",
"version": "0.1.6",
"version": "0.1.7-rc.1",
"description": "gigacode CLI binary for Windows x64",
"license": "Apache-2.0",
"repository": {

View file

@ -1,6 +1,6 @@
{
"name": "sandbox-agent",
"version": "0.1.6",
"version": "0.1.7-rc.1",
"description": "Universal API for automatic coding agents in sandboxes. Supprots Claude Code, Codex, OpenCode, and Amp.",
"license": "Apache-2.0",
"repository": {

View file

@ -11,12 +11,10 @@ use clap::{Args, Parser, Subcommand};
mod build_version {
include!(concat!(env!("OUT_DIR"), "/version.rs"));
}
use reqwest::blocking::Client as HttpClient;
use reqwest::Method;
use crate::router::{build_router_with_state, shutdown_servers};
use crate::router::{
AgentInstallRequest, AppState, AuthConfig, BrandingMode, CreateSessionRequest,
MessageRequest, PermissionReply, PermissionReplyRequest, QuestionReplyRequest,
AgentInstallRequest, AppState, AuthConfig, BrandingMode, CreateSessionRequest, MessageRequest,
PermissionReply, PermissionReplyRequest, QuestionReplyRequest,
};
use crate::router::{
AgentListResponse, AgentModelsResponse, AgentModesResponse, CreateSessionResponse,
@ -25,6 +23,8 @@ use crate::router::{
use crate::server_logs::ServerLogs;
use crate::telemetry;
use crate::ui;
use reqwest::blocking::Client as HttpClient;
use reqwest::Method;
use sandbox_agent_agent_management::agents::{AgentId, AgentManager, InstallOptions};
use sandbox_agent_agent_management::credentials::{
extract_all_credentials, AuthType, CredentialExtractionOptions, ExtractedCredentials,
@ -459,7 +459,11 @@ pub fn run_sandbox_agent() -> Result<(), CliError> {
token,
no_token,
} = cli;
let config = CliConfig { token, no_token, gigacode: false };
let config = CliConfig {
token,
no_token,
gigacode: false,
};
if let Err(err) = init_logging(&command) {
eprintln!("failed to init logging: {err}");
return Err(err);
@ -585,7 +589,11 @@ fn run_api(command: &ApiCommand, cli: &CliConfig) -> Result<(), CliError> {
}
fn run_opencode(cli: &CliConfig, args: &OpencodeArgs) -> Result<(), CliError> {
let name = if cli.gigacode { "Gigacode" } else { "OpenCode command" };
let name = if cli.gigacode {
"Gigacode"
} else {
"OpenCode command"
};
write_stderr_line(&format!("\nEXPERIMENTAL: Please report bugs to:\n- GitHub: https://github.com/rivet-dev/sandbox-agent/issues\n- Discord: https://rivet.dev/discord\n\n{name} is powered by:\n- OpenCode (TUI): https://opencode.ai/\n- Sandbox Agent SDK (multi-agent compatibility): https://sandboxagent.dev/\n\n"))?;
let token = cli.token.clone();
@ -628,12 +636,8 @@ fn run_opencode(cli: &CliConfig, args: &OpencodeArgs) -> Result<(), CliError> {
fn run_daemon(command: &DaemonCommand, cli: &CliConfig) -> Result<(), CliError> {
let token = cli.token.as_deref();
match command {
DaemonCommand::Start(args) => {
crate::daemon::start(cli, &args.host, args.port, token)
}
DaemonCommand::Stop(args) => {
crate::daemon::stop(&args.host, args.port)
}
DaemonCommand::Start(args) => crate::daemon::start(cli, &args.host, args.port, token),
DaemonCommand::Stop(args) => crate::daemon::stop(&args.host, args.port),
DaemonCommand::Status(args) => {
let st = crate::daemon::status(&args.host, args.port, token)?;
write_stderr_line(&st.to_string())?;
@ -848,7 +852,10 @@ fn resolve_opencode_bin(explicit: Option<&PathBuf>) -> Result<PathBuf, CliError>
return Ok(PathBuf::from(path));
}
if let Some(path) = find_in_path("opencode") {
write_stderr_line(&format!("using opencode binary from PATH: {}", path.display()))?;
write_stderr_line(&format!(
"using opencode binary from PATH: {}",
path.display()
))?;
return Ok(path);
}

View file

@ -309,12 +309,7 @@ pub fn status(host: &str, port: u16, token: Option<&str>) -> Result<DaemonStatus
Ok(DaemonStatus::NotRunning)
}
pub fn start(
cli: &CliConfig,
host: &str,
port: u16,
token: Option<&str>,
) -> Result<(), CliError> {
pub fn start(cli: &CliConfig, host: &str, port: u16, token: Option<&str>) -> Result<(), CliError> {
let base_url = format!("http://{host}:{port}");
let pid_path = daemon_pid_path(host, port);
let log_path = daemon_log_path(host, port);
@ -451,9 +446,7 @@ pub fn ensure_running(
// Check build version
if !is_version_current(host, port) {
let old = read_daemon_version(host, port).unwrap_or_else(|| "unknown".to_string());
eprintln!(
"daemon outdated (build {old} -> {BUILD_ID}), restarting..."
);
eprintln!("daemon outdated (build {old} -> {BUILD_ID}), restarting...");
stop(host, port)?;
return start(cli, host, port, token);
}

View file

@ -1,6 +1,7 @@
//! Sandbox agent core utilities.
mod agent_server_logs;
pub mod cli;
pub mod credentials;
pub mod daemon;
pub mod opencode_compat;
@ -8,4 +9,3 @@ pub mod router;
pub mod server_logs;
pub mod telemetry;
pub mod ui;
pub mod cli;

View file

@ -414,17 +414,15 @@ async fn ensure_backing_session(
.await
{
Ok(_) => Ok(()),
Err(SandboxError::SessionAlreadyExists { .. }) => {
state
.inner
.session_manager()
.set_session_overrides(session_id, model, variant)
.await
.or_else(|err| match err {
SandboxError::SessionNotFound { .. } => Ok(()),
other => Err(other),
})
}
Err(SandboxError::SessionAlreadyExists { .. }) => state
.inner
.session_manager()
.set_session_overrides(session_id, model, variant)
.await
.or_else(|err| match err {
SandboxError::SessionNotFound { .. } => Ok(()),
other => Err(other),
}),
Err(err) => Err(err),
}
}
@ -822,8 +820,8 @@ async fn resolve_session_agent(
if resolved_agent.is_none() {
provider_id = cache.default_group.clone();
model_id = default_model_id.clone();
resolved_agent =
resolve_agent_from_model(&cache, &provider_id, &model_id).or_else(|| Some(default_agent_id()));
resolved_agent = resolve_agent_from_model(&cache, &provider_id, &model_id)
.or_else(|| Some(default_agent_id()));
}
let mut resolved_agent_id: Option<String> = None;
@ -1998,7 +1996,11 @@ async fn apply_item_event(
let input_value = runtime
.tool_args_by_call
.get(call_id)
.and_then(|args| tool_input_from_arguments(Some(args.as_str())).as_object().cloned())
.and_then(|args| {
tool_input_from_arguments(Some(args.as_str()))
.as_object()
.cloned()
})
.map(Value::Object)
.unwrap_or_else(|| json!({}));
let state_value = json!({
@ -2066,7 +2068,6 @@ async fn apply_item_event(
_ => {}
}
}
}
async fn apply_tool_item_event(
@ -2405,9 +2406,11 @@ async fn apply_item_delta(
.unwrap_or_else(|| format!("{}_text", message_id));
let part = build_text_part_with_id(&session_id, &message_id, &part_id, &text);
upsert_message_part(&state.opencode, &session_id, &message_id, part.clone()).await;
state
.opencode
.emit_event(part_event_with_delta("message.part.updated", &part, Some(&delta)));
state.opencode.emit_event(part_event_with_delta(
"message.part.updated",
&part,
Some(&delta),
));
let _ = state
.opencode
.update_runtime(&session_id, |runtime| {
@ -2623,9 +2626,7 @@ async fn oc_config_patch(Json(body): Json<Value>) -> impl IntoResponse {
responses((status = 200)),
tag = "opencode"
)]
async fn oc_config_providers(
State(state): State<Arc<OpenCodeAppState>>,
) -> impl IntoResponse {
async fn oc_config_providers(State(state): State<Arc<OpenCodeAppState>>) -> impl IntoResponse {
let cache = opencode_model_cache(&state).await;
let mut grouped: BTreeMap<String, Vec<&OpenCodeModelEntry>> = BTreeMap::new();
for entry in &cache.entries {
@ -3950,9 +3951,7 @@ async fn oc_question_reject(
responses((status = 200)),
tag = "opencode"
)]
async fn oc_provider_list(
State(state): State<Arc<OpenCodeAppState>>,
) -> impl IntoResponse {
async fn oc_provider_list(State(state): State<Arc<OpenCodeAppState>>) -> impl IntoResponse {
let cache = opencode_model_cache(&state).await;
let mut grouped: BTreeMap<String, Vec<&OpenCodeModelEntry>> = BTreeMap::new();
for entry in &cache.entries {
@ -3999,9 +3998,7 @@ async fn oc_provider_list(
responses((status = 200)),
tag = "opencode"
)]
async fn oc_provider_auth(
State(state): State<Arc<OpenCodeAppState>>,
) -> impl IntoResponse {
async fn oc_provider_auth(State(state): State<Arc<OpenCodeAppState>>) -> impl IntoResponse {
let cache = opencode_model_cache(&state).await;
let mut auth_map = serde_json::Map::new();
for group_id in cache.group_names.keys() {

View file

@ -91,7 +91,11 @@ impl AppState {
Self::with_branding(auth, agent_manager, BrandingMode::default())
}
pub fn with_branding(auth: AuthConfig, agent_manager: AgentManager, branding: BrandingMode) -> Self {
pub fn with_branding(
auth: AuthConfig,
agent_manager: AgentManager,
branding: BrandingMode,
) -> Self {
let agent_manager = Arc::new(agent_manager);
let session_manager = Arc::new(SessionManager::new(agent_manager.clone()));
session_manager
@ -3392,11 +3396,12 @@ impl SessionManager {
"limit": null
}
});
let rx = server
.send_request(id, &request)
.ok_or_else(|| SandboxError::StreamError {
message: "failed to send model/list request".to_string(),
})?;
let rx =
server
.send_request(id, &request)
.ok_or_else(|| SandboxError::StreamError {
message: "failed to send model/list request".to_string(),
})?;
let result = tokio::time::timeout(Duration::from_secs(30), rx).await;
let value = match result {
@ -4758,10 +4763,7 @@ fn parse_opencode_models(value: &Value) -> Option<AgentModelsResponse> {
let mut default_model = None;
for provider_id in provider_order {
if let Some(model_id) = default_map
.get(&provider_id)
.and_then(Value::as_str)
{
if let Some(model_id) = default_map.get(&provider_id).and_then(Value::as_str) {
default_model = Some(format!("{provider_id}/{model_id}"));
break;
}
@ -7017,20 +7019,19 @@ fn build_anthropic_headers(
AuthType::ApiKey => {
let value =
reqwest::header::HeaderValue::from_str(&credentials.api_key).map_err(|_| {
SandboxError::StreamError {
message: "invalid anthropic api key header".to_string(),
}
})?;
SandboxError::StreamError {
message: "invalid anthropic api key header".to_string(),
}
})?;
headers.insert("x-api-key", value);
}
AuthType::Oauth => {
let value = format!("Bearer {}", credentials.api_key);
let header =
reqwest::header::HeaderValue::from_str(&value).map_err(|_| {
SandboxError::StreamError {
message: "invalid anthropic oauth header".to_string(),
}
})?;
let header = reqwest::header::HeaderValue::from_str(&value).map_err(|_| {
SandboxError::StreamError {
message: "invalid anthropic oauth header".to_string(),
}
})?;
headers.insert(reqwest::header::AUTHORIZATION, header);
}
}

View file

@ -135,7 +135,12 @@ fn build_beacon_event(dt: i64) -> TelemetryEvent<BeaconData> {
)
}
fn new_event<D: Serialize>(dt: i64, entity_type: &str, event_name: &str, data: D) -> TelemetryEvent<D> {
fn new_event<D: Serialize>(
dt: i64,
entity_type: &str,
event_name: &str,
data: D,
) -> TelemetryEvent<D> {
let eid = load_or_create_id();
TelemetryEvent {
p: "sandbox-agent".to_string(),