mirror of
https://github.com/harivansh-afk/sandbox-agent.git
synced 2026-04-15 09:01:17 +00:00
Merge pull request #148 from bobbythelobster/add-cursor-agent-support
Add cursor-agent support
This commit is contained in:
commit
4322cb1d8e
2 changed files with 45 additions and 4 deletions
|
|
@ -21,6 +21,7 @@ pub enum AgentId {
|
|||
Codex,
|
||||
Opencode,
|
||||
Amp,
|
||||
Cursor,
|
||||
Mock,
|
||||
}
|
||||
|
||||
|
|
@ -31,6 +32,7 @@ impl AgentId {
|
|||
AgentId::Codex => "codex",
|
||||
AgentId::Opencode => "opencode",
|
||||
AgentId::Amp => "amp",
|
||||
AgentId::Cursor => "cursor",
|
||||
AgentId::Mock => "mock",
|
||||
}
|
||||
}
|
||||
|
|
@ -41,6 +43,7 @@ impl AgentId {
|
|||
AgentId::Codex => "codex",
|
||||
AgentId::Opencode => "opencode",
|
||||
AgentId::Amp => "amp",
|
||||
AgentId::Cursor => "cursor-agent",
|
||||
AgentId::Mock => "mock",
|
||||
}
|
||||
}
|
||||
|
|
@ -51,6 +54,7 @@ impl AgentId {
|
|||
"codex" => Some(AgentId::Codex),
|
||||
"opencode" => Some(AgentId::Opencode),
|
||||
"amp" => Some(AgentId::Amp),
|
||||
"cursor" => Some(AgentId::Cursor),
|
||||
"mock" => Some(AgentId::Mock),
|
||||
_ => None,
|
||||
}
|
||||
|
|
@ -151,6 +155,7 @@ impl AgentManager {
|
|||
install_opencode(&install_path, self.platform, options.version.as_deref())?
|
||||
}
|
||||
AgentId::Amp => install_amp(&install_path, self.platform, options.version.as_deref())?,
|
||||
AgentId::Cursor => install_cursor(&install_path, self.platform, options.version.as_deref())?,
|
||||
AgentId::Mock => {
|
||||
if !install_path.exists() {
|
||||
fs::write(&install_path, b"mock")?;
|
||||
|
|
@ -268,6 +273,18 @@ impl AgentManager {
|
|||
}
|
||||
command.arg(&options.prompt);
|
||||
}
|
||||
AgentId::Cursor => {
|
||||
// cursor-agent typically runs as HTTP server on localhost:32123
|
||||
// For CLI usage similar to opencode
|
||||
command.arg("run").arg("--format").arg("json");
|
||||
if let Some(model) = options.model.as_deref() {
|
||||
command.arg("-m").arg(model);
|
||||
}
|
||||
if let Some(session_id) = options.session_id.as_deref() {
|
||||
command.arg("-s").arg(session_id);
|
||||
}
|
||||
command.arg(&options.prompt);
|
||||
}
|
||||
AgentId::Amp => {
|
||||
let output = spawn_amp(&path, &working_dir, &options)?;
|
||||
let stdout = String::from_utf8_lossy(&output.stdout).to_string();
|
||||
|
|
@ -1199,6 +1216,30 @@ fn find_in_path(binary_name: &str) -> Option<PathBuf> {
|
|||
None
|
||||
}
|
||||
|
||||
fn install_cursor(path: &Path, platform: Platform, _version: Option<&str>) -> Result<(), AgentError> {
|
||||
// Note: cursor-agent binary URL needs to be verified
|
||||
// Cursor Pro includes cursor-agent, typically installed via: curl -fsS https://cursor.com/install | bash
|
||||
// For sandbox-agent, we need standalone cursor-agent binary
|
||||
// TODO: Determine correct download URL for cursor-agent releases
|
||||
|
||||
let platform_segment = match platform {
|
||||
Platform::LinuxX64 | Platform::LinuxX64Musl => "linux-x64",
|
||||
Platform::LinuxArm64 => "linux-arm64",
|
||||
Platform::MacosArm64 => "darwin-arm64",
|
||||
Platform::MacosX64 => "darwin-x64",
|
||||
};
|
||||
|
||||
// Placeholder URL - needs to be updated with actual cursor-agent release URL
|
||||
let url = Url::parse(&format!(
|
||||
"https://cursor.com/api/v1/releases/latest/download/cursor-agent-{platform_segment}",
|
||||
platform_segment = platform_segment
|
||||
))?;
|
||||
|
||||
let bytes = download_bytes(&url)?;
|
||||
write_executable(path, &bytes)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn download_bytes(url: &Url) -> Result<Vec<u8>, AgentError> {
|
||||
let client = Client::builder().build()?;
|
||||
let mut response = client.get(url.clone()).send()?;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue