mirror of
https://github.com/harivansh-afk/sandbox-agent.git
synced 2026-04-16 20:01:27 +00:00
chore: sync workspace changes
This commit is contained in:
parent
d24f983e2c
commit
bf58891edf
139 changed files with 5454 additions and 8986 deletions
|
|
@ -29,6 +29,7 @@ pub enum AgentId {
|
|||
Codex,
|
||||
Opencode,
|
||||
Amp,
|
||||
Mock,
|
||||
}
|
||||
|
||||
impl AgentId {
|
||||
|
|
@ -38,6 +39,7 @@ impl AgentId {
|
|||
AgentId::Codex => "codex",
|
||||
AgentId::Opencode => "opencode",
|
||||
AgentId::Amp => "amp",
|
||||
AgentId::Mock => "mock",
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -47,6 +49,7 @@ impl AgentId {
|
|||
AgentId::Codex => "codex",
|
||||
AgentId::Opencode => "opencode",
|
||||
AgentId::Amp => "amp",
|
||||
AgentId::Mock => "mock",
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -56,6 +59,7 @@ impl AgentId {
|
|||
"codex" => Some(AgentId::Codex),
|
||||
"opencode" => Some(AgentId::Opencode),
|
||||
"amp" => Some(AgentId::Amp),
|
||||
"mock" => Some(AgentId::Mock),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
|
@ -138,6 +142,11 @@ impl AgentManager {
|
|||
AgentId::Codex => install_codex(&install_path, self.platform, options.version.as_deref())?,
|
||||
AgentId::Opencode => install_opencode(&install_path, self.platform, options.version.as_deref())?,
|
||||
AgentId::Amp => install_amp(&install_path, self.platform, options.version.as_deref())?,
|
||||
AgentId::Mock => {
|
||||
if !install_path.exists() {
|
||||
fs::write(&install_path, b"mock")?;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(InstallResult {
|
||||
|
|
@ -147,6 +156,9 @@ impl AgentManager {
|
|||
}
|
||||
|
||||
pub fn is_installed(&self, agent: AgentId) -> bool {
|
||||
if agent == AgentId::Mock {
|
||||
return true;
|
||||
}
|
||||
self.binary_path(agent).exists()
|
||||
|| find_in_path(agent.binary_name()).is_some()
|
||||
|| default_install_dir().join(agent.binary_name()).exists()
|
||||
|
|
@ -157,6 +169,9 @@ impl AgentManager {
|
|||
}
|
||||
|
||||
pub fn version(&self, agent: AgentId) -> Result<Option<String>, AgentError> {
|
||||
if agent == AgentId::Mock {
|
||||
return Ok(Some("builtin".to_string()));
|
||||
}
|
||||
let path = self.resolve_binary(agent)?;
|
||||
let attempts = [vec!["--version"], vec!["version"], vec!["-V"]];
|
||||
for args in attempts {
|
||||
|
|
@ -173,6 +188,11 @@ impl AgentManager {
|
|||
}
|
||||
|
||||
pub fn spawn(&self, agent: AgentId, options: SpawnOptions) -> Result<SpawnResult, AgentError> {
|
||||
if agent == AgentId::Mock {
|
||||
return Err(AgentError::UnsupportedAgent {
|
||||
agent: agent.as_str().to_string(),
|
||||
});
|
||||
}
|
||||
if agent == AgentId::Codex {
|
||||
return self.spawn_codex_app_server(options);
|
||||
}
|
||||
|
|
@ -247,6 +267,11 @@ impl AgentManager {
|
|||
events,
|
||||
});
|
||||
}
|
||||
AgentId::Mock => {
|
||||
return Err(AgentError::UnsupportedAgent {
|
||||
agent: agent.as_str().to_string(),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
for (key, value) in options.env {
|
||||
|
|
@ -550,6 +575,11 @@ impl AgentManager {
|
|||
AgentId::Amp => {
|
||||
return Ok(build_amp_command(&path, &working_dir, options));
|
||||
}
|
||||
AgentId::Mock => {
|
||||
return Err(AgentError::UnsupportedAgent {
|
||||
agent: agent.as_str().to_string(),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
for (key, value) in &options.env {
|
||||
|
|
@ -844,6 +874,7 @@ fn extract_session_id(agent: AgentId, events: &[Value]) -> Option<String> {
|
|||
return Some(id);
|
||||
}
|
||||
}
|
||||
AgentId::Mock => {}
|
||||
}
|
||||
}
|
||||
None
|
||||
|
|
@ -921,6 +952,7 @@ fn extract_result_text(agent: AgentId, events: &[Value]) -> Option<String> {
|
|||
Some(buffer)
|
||||
}
|
||||
}
|
||||
AgentId::Mock => None,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -137,6 +137,7 @@ pub fn test_agents_from_env() -> Result<Vec<TestAgentConfig>, TestAgentConfigErr
|
|||
}
|
||||
credentials_with(anthropic_cred.clone(), openai_cred.clone())
|
||||
}
|
||||
AgentId::Mock => credentials_with(None, None),
|
||||
};
|
||||
configs.push(TestAgentConfig { agent, credentials });
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue