mirror of
https://github.com/harivansh-afk/sandbox-agent.git
synced 2026-04-15 09:01:17 +00:00
chore: cargo fmt
This commit is contained in:
parent
f0191579c0
commit
2a00a03eca
22 changed files with 96 additions and 93 deletions
14
Cargo.toml
14
Cargo.toml
|
|
@ -3,7 +3,7 @@ resolver = "2"
|
||||||
members = ["server/packages/*", "gigacode"]
|
members = ["server/packages/*", "gigacode"]
|
||||||
|
|
||||||
[workspace.package]
|
[workspace.package]
|
||||||
version = "0.1.6"
|
version = "0.1.7-rc.1"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
authors = [ "Rivet Gaming, LLC <developer@rivet.gg>" ]
|
authors = [ "Rivet Gaming, LLC <developer@rivet.gg>" ]
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
|
|
@ -12,12 +12,12 @@ description = "Universal API for automatic coding agents in sandboxes. Supprots
|
||||||
|
|
||||||
[workspace.dependencies]
|
[workspace.dependencies]
|
||||||
# Internal crates
|
# Internal crates
|
||||||
sandbox-agent = { version = "0.1.6", path = "server/packages/sandbox-agent" }
|
sandbox-agent = { version = "0.1.7-rc.1", path = "server/packages/sandbox-agent" }
|
||||||
sandbox-agent-error = { version = "0.1.6", path = "server/packages/error" }
|
sandbox-agent-error = { version = "0.1.7-rc.1", path = "server/packages/error" }
|
||||||
sandbox-agent-agent-management = { version = "0.1.6", path = "server/packages/agent-management" }
|
sandbox-agent-agent-management = { version = "0.1.7-rc.1", path = "server/packages/agent-management" }
|
||||||
sandbox-agent-agent-credentials = { version = "0.1.6", path = "server/packages/agent-credentials" }
|
sandbox-agent-agent-credentials = { version = "0.1.7-rc.1", path = "server/packages/agent-credentials" }
|
||||||
sandbox-agent-universal-agent-schema = { version = "0.1.6", path = "server/packages/universal-agent-schema" }
|
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.6", path = "server/packages/extracted-agent-schemas" }
|
sandbox-agent-extracted-agent-schemas = { version = "0.1.7-rc.1", path = "server/packages/extracted-agent-schemas" }
|
||||||
|
|
||||||
# Serialization
|
# Serialization
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use sandbox_agent::cli::{
|
use sandbox_agent::cli::{
|
||||||
CliConfig, CliError, Command, GigacodeCli, OpencodeArgs, init_logging, run_command,
|
init_logging, run_command, CliConfig, CliError, Command, GigacodeCli, OpencodeArgs,
|
||||||
};
|
};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@sandbox-agent/cli-shared",
|
"name": "@sandbox-agent/cli-shared",
|
||||||
"version": "0.1.6",
|
"version": "0.1.7-rc.1",
|
||||||
"description": "Shared helpers for sandbox-agent CLI and SDK",
|
"description": "Shared helpers for sandbox-agent CLI and SDK",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@sandbox-agent/cli",
|
"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",
|
"description": "CLI for sandbox-agent - run AI coding agents in sandboxes",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@sandbox-agent/cli-darwin-arm64",
|
"name": "@sandbox-agent/cli-darwin-arm64",
|
||||||
"version": "0.1.6",
|
"version": "0.1.7-rc.1",
|
||||||
"description": "sandbox-agent CLI binary for macOS ARM64",
|
"description": "sandbox-agent CLI binary for macOS ARM64",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@sandbox-agent/cli-darwin-x64",
|
"name": "@sandbox-agent/cli-darwin-x64",
|
||||||
"version": "0.1.6",
|
"version": "0.1.7-rc.1",
|
||||||
"description": "sandbox-agent CLI binary for macOS x64",
|
"description": "sandbox-agent CLI binary for macOS x64",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@sandbox-agent/cli-linux-arm64",
|
"name": "@sandbox-agent/cli-linux-arm64",
|
||||||
"version": "0.1.6",
|
"version": "0.1.7-rc.1",
|
||||||
"description": "sandbox-agent CLI binary for Linux arm64",
|
"description": "sandbox-agent CLI binary for Linux arm64",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@sandbox-agent/cli-linux-x64",
|
"name": "@sandbox-agent/cli-linux-x64",
|
||||||
"version": "0.1.6",
|
"version": "0.1.7-rc.1",
|
||||||
"description": "sandbox-agent CLI binary for Linux x64",
|
"description": "sandbox-agent CLI binary for Linux x64",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@sandbox-agent/cli-win32-x64",
|
"name": "@sandbox-agent/cli-win32-x64",
|
||||||
"version": "0.1.6",
|
"version": "0.1.7-rc.1",
|
||||||
"description": "sandbox-agent CLI binary for Windows x64",
|
"description": "sandbox-agent CLI binary for Windows x64",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@sandbox-agent/gigacode",
|
"name": "@sandbox-agent/gigacode",
|
||||||
"version": "0.1.6",
|
"version": "0.1.7-rc.1",
|
||||||
"description": "Gigacode CLI (sandbox-agent with OpenCode attach by default)",
|
"description": "Gigacode CLI (sandbox-agent with OpenCode attach by default)",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@sandbox-agent/gigacode-darwin-arm64",
|
"name": "@sandbox-agent/gigacode-darwin-arm64",
|
||||||
"version": "0.1.6",
|
"version": "0.1.7-rc.1",
|
||||||
"description": "gigacode CLI binary for macOS arm64",
|
"description": "gigacode CLI binary for macOS arm64",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@sandbox-agent/gigacode-darwin-x64",
|
"name": "@sandbox-agent/gigacode-darwin-x64",
|
||||||
"version": "0.1.6",
|
"version": "0.1.7-rc.1",
|
||||||
"description": "gigacode CLI binary for macOS x64",
|
"description": "gigacode CLI binary for macOS x64",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@sandbox-agent/gigacode-linux-arm64",
|
"name": "@sandbox-agent/gigacode-linux-arm64",
|
||||||
"version": "0.1.6",
|
"version": "0.1.7-rc.1",
|
||||||
"description": "gigacode CLI binary for Linux arm64",
|
"description": "gigacode CLI binary for Linux arm64",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@sandbox-agent/gigacode-linux-x64",
|
"name": "@sandbox-agent/gigacode-linux-x64",
|
||||||
"version": "0.1.6",
|
"version": "0.1.7-rc.1",
|
||||||
"description": "gigacode CLI binary for Linux x64",
|
"description": "gigacode CLI binary for Linux x64",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@sandbox-agent/gigacode-win32-x64",
|
"name": "@sandbox-agent/gigacode-win32-x64",
|
||||||
"version": "0.1.6",
|
"version": "0.1.7-rc.1",
|
||||||
"description": "gigacode CLI binary for Windows x64",
|
"description": "gigacode CLI binary for Windows x64",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "sandbox-agent",
|
"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.",
|
"description": "Universal API for automatic coding agents in sandboxes. Supprots Claude Code, Codex, OpenCode, and Amp.",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|
|
||||||
|
|
@ -11,12 +11,10 @@ use clap::{Args, Parser, Subcommand};
|
||||||
mod build_version {
|
mod build_version {
|
||||||
include!(concat!(env!("OUT_DIR"), "/version.rs"));
|
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::{build_router_with_state, shutdown_servers};
|
||||||
use crate::router::{
|
use crate::router::{
|
||||||
AgentInstallRequest, AppState, AuthConfig, BrandingMode, CreateSessionRequest,
|
AgentInstallRequest, AppState, AuthConfig, BrandingMode, CreateSessionRequest, MessageRequest,
|
||||||
MessageRequest, PermissionReply, PermissionReplyRequest, QuestionReplyRequest,
|
PermissionReply, PermissionReplyRequest, QuestionReplyRequest,
|
||||||
};
|
};
|
||||||
use crate::router::{
|
use crate::router::{
|
||||||
AgentListResponse, AgentModelsResponse, AgentModesResponse, CreateSessionResponse,
|
AgentListResponse, AgentModelsResponse, AgentModesResponse, CreateSessionResponse,
|
||||||
|
|
@ -25,6 +23,8 @@ use crate::router::{
|
||||||
use crate::server_logs::ServerLogs;
|
use crate::server_logs::ServerLogs;
|
||||||
use crate::telemetry;
|
use crate::telemetry;
|
||||||
use crate::ui;
|
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::agents::{AgentId, AgentManager, InstallOptions};
|
||||||
use sandbox_agent_agent_management::credentials::{
|
use sandbox_agent_agent_management::credentials::{
|
||||||
extract_all_credentials, AuthType, CredentialExtractionOptions, ExtractedCredentials,
|
extract_all_credentials, AuthType, CredentialExtractionOptions, ExtractedCredentials,
|
||||||
|
|
@ -459,7 +459,11 @@ pub fn run_sandbox_agent() -> Result<(), CliError> {
|
||||||
token,
|
token,
|
||||||
no_token,
|
no_token,
|
||||||
} = cli;
|
} = cli;
|
||||||
let config = CliConfig { token, no_token, gigacode: false };
|
let config = CliConfig {
|
||||||
|
token,
|
||||||
|
no_token,
|
||||||
|
gigacode: false,
|
||||||
|
};
|
||||||
if let Err(err) = init_logging(&command) {
|
if let Err(err) = init_logging(&command) {
|
||||||
eprintln!("failed to init logging: {err}");
|
eprintln!("failed to init logging: {err}");
|
||||||
return Err(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> {
|
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"))?;
|
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();
|
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> {
|
fn run_daemon(command: &DaemonCommand, cli: &CliConfig) -> Result<(), CliError> {
|
||||||
let token = cli.token.as_deref();
|
let token = cli.token.as_deref();
|
||||||
match command {
|
match command {
|
||||||
DaemonCommand::Start(args) => {
|
DaemonCommand::Start(args) => crate::daemon::start(cli, &args.host, args.port, token),
|
||||||
crate::daemon::start(cli, &args.host, args.port, token)
|
DaemonCommand::Stop(args) => crate::daemon::stop(&args.host, args.port),
|
||||||
}
|
|
||||||
DaemonCommand::Stop(args) => {
|
|
||||||
crate::daemon::stop(&args.host, args.port)
|
|
||||||
}
|
|
||||||
DaemonCommand::Status(args) => {
|
DaemonCommand::Status(args) => {
|
||||||
let st = crate::daemon::status(&args.host, args.port, token)?;
|
let st = crate::daemon::status(&args.host, args.port, token)?;
|
||||||
write_stderr_line(&st.to_string())?;
|
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));
|
return Ok(PathBuf::from(path));
|
||||||
}
|
}
|
||||||
if let Some(path) = find_in_path("opencode") {
|
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);
|
return Ok(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -309,12 +309,7 @@ pub fn status(host: &str, port: u16, token: Option<&str>) -> Result<DaemonStatus
|
||||||
Ok(DaemonStatus::NotRunning)
|
Ok(DaemonStatus::NotRunning)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn start(
|
pub fn start(cli: &CliConfig, host: &str, port: u16, token: Option<&str>) -> Result<(), CliError> {
|
||||||
cli: &CliConfig,
|
|
||||||
host: &str,
|
|
||||||
port: u16,
|
|
||||||
token: Option<&str>,
|
|
||||||
) -> Result<(), CliError> {
|
|
||||||
let base_url = format!("http://{host}:{port}");
|
let base_url = format!("http://{host}:{port}");
|
||||||
let pid_path = daemon_pid_path(host, port);
|
let pid_path = daemon_pid_path(host, port);
|
||||||
let log_path = daemon_log_path(host, port);
|
let log_path = daemon_log_path(host, port);
|
||||||
|
|
@ -451,9 +446,7 @@ pub fn ensure_running(
|
||||||
// Check build version
|
// Check build version
|
||||||
if !is_version_current(host, port) {
|
if !is_version_current(host, port) {
|
||||||
let old = read_daemon_version(host, port).unwrap_or_else(|| "unknown".to_string());
|
let old = read_daemon_version(host, port).unwrap_or_else(|| "unknown".to_string());
|
||||||
eprintln!(
|
eprintln!("daemon outdated (build {old} -> {BUILD_ID}), restarting...");
|
||||||
"daemon outdated (build {old} -> {BUILD_ID}), restarting..."
|
|
||||||
);
|
|
||||||
stop(host, port)?;
|
stop(host, port)?;
|
||||||
return start(cli, host, port, token);
|
return start(cli, host, port, token);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
//! Sandbox agent core utilities.
|
//! Sandbox agent core utilities.
|
||||||
|
|
||||||
mod agent_server_logs;
|
mod agent_server_logs;
|
||||||
|
pub mod cli;
|
||||||
pub mod credentials;
|
pub mod credentials;
|
||||||
pub mod daemon;
|
pub mod daemon;
|
||||||
pub mod opencode_compat;
|
pub mod opencode_compat;
|
||||||
|
|
@ -8,4 +9,3 @@ pub mod router;
|
||||||
pub mod server_logs;
|
pub mod server_logs;
|
||||||
pub mod telemetry;
|
pub mod telemetry;
|
||||||
pub mod ui;
|
pub mod ui;
|
||||||
pub mod cli;
|
|
||||||
|
|
|
||||||
|
|
@ -414,17 +414,15 @@ async fn ensure_backing_session(
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
Ok(_) => Ok(()),
|
Ok(_) => Ok(()),
|
||||||
Err(SandboxError::SessionAlreadyExists { .. }) => {
|
Err(SandboxError::SessionAlreadyExists { .. }) => state
|
||||||
state
|
.inner
|
||||||
.inner
|
.session_manager()
|
||||||
.session_manager()
|
.set_session_overrides(session_id, model, variant)
|
||||||
.set_session_overrides(session_id, model, variant)
|
.await
|
||||||
.await
|
.or_else(|err| match err {
|
||||||
.or_else(|err| match err {
|
SandboxError::SessionNotFound { .. } => Ok(()),
|
||||||
SandboxError::SessionNotFound { .. } => Ok(()),
|
other => Err(other),
|
||||||
other => Err(other),
|
}),
|
||||||
})
|
|
||||||
}
|
|
||||||
Err(err) => Err(err),
|
Err(err) => Err(err),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -822,8 +820,8 @@ async fn resolve_session_agent(
|
||||||
if resolved_agent.is_none() {
|
if resolved_agent.is_none() {
|
||||||
provider_id = cache.default_group.clone();
|
provider_id = cache.default_group.clone();
|
||||||
model_id = default_model_id.clone();
|
model_id = default_model_id.clone();
|
||||||
resolved_agent =
|
resolved_agent = resolve_agent_from_model(&cache, &provider_id, &model_id)
|
||||||
resolve_agent_from_model(&cache, &provider_id, &model_id).or_else(|| Some(default_agent_id()));
|
.or_else(|| Some(default_agent_id()));
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut resolved_agent_id: Option<String> = None;
|
let mut resolved_agent_id: Option<String> = None;
|
||||||
|
|
@ -1998,7 +1996,11 @@ async fn apply_item_event(
|
||||||
let input_value = runtime
|
let input_value = runtime
|
||||||
.tool_args_by_call
|
.tool_args_by_call
|
||||||
.get(call_id)
|
.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)
|
.map(Value::Object)
|
||||||
.unwrap_or_else(|| json!({}));
|
.unwrap_or_else(|| json!({}));
|
||||||
let state_value = json!({
|
let state_value = json!({
|
||||||
|
|
@ -2066,7 +2068,6 @@ async fn apply_item_event(
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn apply_tool_item_event(
|
async fn apply_tool_item_event(
|
||||||
|
|
@ -2405,9 +2406,11 @@ async fn apply_item_delta(
|
||||||
.unwrap_or_else(|| format!("{}_text", message_id));
|
.unwrap_or_else(|| format!("{}_text", message_id));
|
||||||
let part = build_text_part_with_id(&session_id, &message_id, &part_id, &text);
|
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;
|
upsert_message_part(&state.opencode, &session_id, &message_id, part.clone()).await;
|
||||||
state
|
state.opencode.emit_event(part_event_with_delta(
|
||||||
.opencode
|
"message.part.updated",
|
||||||
.emit_event(part_event_with_delta("message.part.updated", &part, Some(&delta)));
|
&part,
|
||||||
|
Some(&delta),
|
||||||
|
));
|
||||||
let _ = state
|
let _ = state
|
||||||
.opencode
|
.opencode
|
||||||
.update_runtime(&session_id, |runtime| {
|
.update_runtime(&session_id, |runtime| {
|
||||||
|
|
@ -2623,9 +2626,7 @@ async fn oc_config_patch(Json(body): Json<Value>) -> impl IntoResponse {
|
||||||
responses((status = 200)),
|
responses((status = 200)),
|
||||||
tag = "opencode"
|
tag = "opencode"
|
||||||
)]
|
)]
|
||||||
async fn oc_config_providers(
|
async fn oc_config_providers(State(state): State<Arc<OpenCodeAppState>>) -> impl IntoResponse {
|
||||||
State(state): State<Arc<OpenCodeAppState>>,
|
|
||||||
) -> impl IntoResponse {
|
|
||||||
let cache = opencode_model_cache(&state).await;
|
let cache = opencode_model_cache(&state).await;
|
||||||
let mut grouped: BTreeMap<String, Vec<&OpenCodeModelEntry>> = BTreeMap::new();
|
let mut grouped: BTreeMap<String, Vec<&OpenCodeModelEntry>> = BTreeMap::new();
|
||||||
for entry in &cache.entries {
|
for entry in &cache.entries {
|
||||||
|
|
@ -3950,9 +3951,7 @@ async fn oc_question_reject(
|
||||||
responses((status = 200)),
|
responses((status = 200)),
|
||||||
tag = "opencode"
|
tag = "opencode"
|
||||||
)]
|
)]
|
||||||
async fn oc_provider_list(
|
async fn oc_provider_list(State(state): State<Arc<OpenCodeAppState>>) -> impl IntoResponse {
|
||||||
State(state): State<Arc<OpenCodeAppState>>,
|
|
||||||
) -> impl IntoResponse {
|
|
||||||
let cache = opencode_model_cache(&state).await;
|
let cache = opencode_model_cache(&state).await;
|
||||||
let mut grouped: BTreeMap<String, Vec<&OpenCodeModelEntry>> = BTreeMap::new();
|
let mut grouped: BTreeMap<String, Vec<&OpenCodeModelEntry>> = BTreeMap::new();
|
||||||
for entry in &cache.entries {
|
for entry in &cache.entries {
|
||||||
|
|
@ -3999,9 +3998,7 @@ async fn oc_provider_list(
|
||||||
responses((status = 200)),
|
responses((status = 200)),
|
||||||
tag = "opencode"
|
tag = "opencode"
|
||||||
)]
|
)]
|
||||||
async fn oc_provider_auth(
|
async fn oc_provider_auth(State(state): State<Arc<OpenCodeAppState>>) -> impl IntoResponse {
|
||||||
State(state): State<Arc<OpenCodeAppState>>,
|
|
||||||
) -> impl IntoResponse {
|
|
||||||
let cache = opencode_model_cache(&state).await;
|
let cache = opencode_model_cache(&state).await;
|
||||||
let mut auth_map = serde_json::Map::new();
|
let mut auth_map = serde_json::Map::new();
|
||||||
for group_id in cache.group_names.keys() {
|
for group_id in cache.group_names.keys() {
|
||||||
|
|
|
||||||
|
|
@ -91,7 +91,11 @@ impl AppState {
|
||||||
Self::with_branding(auth, agent_manager, BrandingMode::default())
|
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 agent_manager = Arc::new(agent_manager);
|
||||||
let session_manager = Arc::new(SessionManager::new(agent_manager.clone()));
|
let session_manager = Arc::new(SessionManager::new(agent_manager.clone()));
|
||||||
session_manager
|
session_manager
|
||||||
|
|
@ -3392,11 +3396,12 @@ impl SessionManager {
|
||||||
"limit": null
|
"limit": null
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
let rx = server
|
let rx =
|
||||||
.send_request(id, &request)
|
server
|
||||||
.ok_or_else(|| SandboxError::StreamError {
|
.send_request(id, &request)
|
||||||
message: "failed to send model/list request".to_string(),
|
.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 result = tokio::time::timeout(Duration::from_secs(30), rx).await;
|
||||||
let value = match result {
|
let value = match result {
|
||||||
|
|
@ -4758,10 +4763,7 @@ fn parse_opencode_models(value: &Value) -> Option<AgentModelsResponse> {
|
||||||
|
|
||||||
let mut default_model = None;
|
let mut default_model = None;
|
||||||
for provider_id in provider_order {
|
for provider_id in provider_order {
|
||||||
if let Some(model_id) = default_map
|
if let Some(model_id) = default_map.get(&provider_id).and_then(Value::as_str) {
|
||||||
.get(&provider_id)
|
|
||||||
.and_then(Value::as_str)
|
|
||||||
{
|
|
||||||
default_model = Some(format!("{provider_id}/{model_id}"));
|
default_model = Some(format!("{provider_id}/{model_id}"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -7017,20 +7019,19 @@ fn build_anthropic_headers(
|
||||||
AuthType::ApiKey => {
|
AuthType::ApiKey => {
|
||||||
let value =
|
let value =
|
||||||
reqwest::header::HeaderValue::from_str(&credentials.api_key).map_err(|_| {
|
reqwest::header::HeaderValue::from_str(&credentials.api_key).map_err(|_| {
|
||||||
SandboxError::StreamError {
|
SandboxError::StreamError {
|
||||||
message: "invalid anthropic api key header".to_string(),
|
message: "invalid anthropic api key header".to_string(),
|
||||||
}
|
}
|
||||||
})?;
|
})?;
|
||||||
headers.insert("x-api-key", value);
|
headers.insert("x-api-key", value);
|
||||||
}
|
}
|
||||||
AuthType::Oauth => {
|
AuthType::Oauth => {
|
||||||
let value = format!("Bearer {}", credentials.api_key);
|
let value = format!("Bearer {}", credentials.api_key);
|
||||||
let header =
|
let header = reqwest::header::HeaderValue::from_str(&value).map_err(|_| {
|
||||||
reqwest::header::HeaderValue::from_str(&value).map_err(|_| {
|
SandboxError::StreamError {
|
||||||
SandboxError::StreamError {
|
message: "invalid anthropic oauth header".to_string(),
|
||||||
message: "invalid anthropic oauth header".to_string(),
|
}
|
||||||
}
|
})?;
|
||||||
})?;
|
|
||||||
headers.insert(reqwest::header::AUTHORIZATION, header);
|
headers.insert(reqwest::header::AUTHORIZATION, header);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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();
|
let eid = load_or_create_id();
|
||||||
TelemetryEvent {
|
TelemetryEvent {
|
||||||
p: "sandbox-agent".to_string(),
|
p: "sandbox-agent".to_string(),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue