222 lines
7.8 KiB
Rust
222 lines
7.8 KiB
Rust
use crate::models::agent::AgentType;
|
|
|
|
#[derive(Debug, Clone)]
|
|
pub enum AgentDistribution {
|
|
Npx {
|
|
version: &'static str,
|
|
package: &'static str,
|
|
/// The command name provided by this npx package (e.g. "gemini", "openclaw").
|
|
cmd: &'static str,
|
|
args: &'static [&'static str],
|
|
env: &'static [(&'static str, &'static str)],
|
|
/// Minimum Node.js version required, e.g. "22.12.0". None means no specific requirement.
|
|
node_required: Option<&'static str>,
|
|
},
|
|
Binary {
|
|
version: &'static str,
|
|
cmd: &'static str,
|
|
args: &'static [&'static str],
|
|
env: &'static [(&'static str, &'static str)],
|
|
platforms: &'static [PlatformBinary],
|
|
},
|
|
}
|
|
|
|
#[derive(Debug, Clone)]
|
|
pub struct PlatformBinary {
|
|
pub platform: &'static str,
|
|
pub url: &'static str,
|
|
}
|
|
|
|
#[derive(Debug, Clone)]
|
|
pub struct AcpAgentMeta {
|
|
pub agent_type: AgentType,
|
|
pub name: &'static str,
|
|
pub description: &'static str,
|
|
pub distribution: AgentDistribution,
|
|
}
|
|
|
|
impl AcpAgentMeta {
|
|
pub fn registry_version(&self) -> Option<&'static str> {
|
|
match &self.distribution {
|
|
AgentDistribution::Npx { version, .. }
|
|
| AgentDistribution::Binary { version, .. } => Some(*version),
|
|
}
|
|
}
|
|
}
|
|
|
|
pub fn current_platform() -> &'static str {
|
|
#[cfg(all(target_os = "macos", target_arch = "aarch64"))]
|
|
{
|
|
"darwin-aarch64"
|
|
}
|
|
#[cfg(all(target_os = "macos", target_arch = "x86_64"))]
|
|
{
|
|
"darwin-x86_64"
|
|
}
|
|
#[cfg(all(target_os = "linux", target_arch = "aarch64"))]
|
|
{
|
|
"linux-aarch64"
|
|
}
|
|
#[cfg(all(target_os = "linux", target_arch = "x86_64"))]
|
|
{
|
|
"linux-x86_64"
|
|
}
|
|
#[cfg(all(target_os = "windows", target_arch = "aarch64"))]
|
|
{
|
|
"windows-aarch64"
|
|
}
|
|
#[cfg(all(target_os = "windows", target_arch = "x86_64"))]
|
|
{
|
|
"windows-x86_64"
|
|
}
|
|
}
|
|
|
|
pub fn all_acp_agents() -> Vec<AgentType> {
|
|
vec![
|
|
AgentType::ClaudeCode,
|
|
AgentType::Codex,
|
|
AgentType::Gemini,
|
|
AgentType::OpenClaw,
|
|
AgentType::OpenCode,
|
|
]
|
|
}
|
|
|
|
pub fn registry_id_for(agent_type: AgentType) -> &'static str {
|
|
match agent_type {
|
|
AgentType::ClaudeCode => "claude-acp",
|
|
AgentType::Codex => "codex-acp",
|
|
AgentType::Gemini => "gemini",
|
|
AgentType::OpenClaw => "openclaw-acp",
|
|
AgentType::OpenCode => "opencode",
|
|
}
|
|
}
|
|
|
|
pub fn from_registry_id(id: &str) -> Option<AgentType> {
|
|
match id {
|
|
"claude-acp" => Some(AgentType::ClaudeCode),
|
|
"codex-acp" => Some(AgentType::Codex),
|
|
"gemini" => Some(AgentType::Gemini),
|
|
"openclaw-acp" => Some(AgentType::OpenClaw),
|
|
"opencode" => Some(AgentType::OpenCode),
|
|
_ => None,
|
|
}
|
|
}
|
|
|
|
pub fn get_agent_meta(agent_type: AgentType) -> AcpAgentMeta {
|
|
debug_assert_eq!(
|
|
from_registry_id(registry_id_for(agent_type)),
|
|
Some(agent_type)
|
|
);
|
|
match agent_type {
|
|
AgentType::ClaudeCode => AcpAgentMeta {
|
|
agent_type,
|
|
name: "Claude Code",
|
|
description: "ACP wrapper for Anthropic's Claude",
|
|
distribution: AgentDistribution::Npx {
|
|
version: "0.22.2",
|
|
package: "@zed-industries/claude-agent-acp@0.22.2",
|
|
cmd: "claude-agent-acp",
|
|
args: &[],
|
|
env: &[],
|
|
node_required: None,
|
|
},
|
|
},
|
|
AgentType::Codex => AcpAgentMeta {
|
|
agent_type,
|
|
name: "Codex CLI",
|
|
description: "ACP adapter for OpenAI's coding assistant",
|
|
distribution: AgentDistribution::Binary {
|
|
version: "0.10.0",
|
|
cmd: "codex-acp",
|
|
args: &[],
|
|
env: &[],
|
|
platforms: &[
|
|
PlatformBinary {
|
|
platform: "darwin-aarch64",
|
|
url: "https://github.com/zed-industries/codex-acp/releases/download/v0.10.0/codex-acp-0.10.0-aarch64-apple-darwin.tar.gz",
|
|
},
|
|
PlatformBinary {
|
|
platform: "darwin-x86_64",
|
|
url: "https://github.com/zed-industries/codex-acp/releases/download/v0.10.0/codex-acp-0.10.0-x86_64-apple-darwin.tar.gz",
|
|
},
|
|
PlatformBinary {
|
|
platform: "linux-aarch64",
|
|
url: "https://github.com/zed-industries/codex-acp/releases/download/v0.10.0/codex-acp-0.10.0-aarch64-unknown-linux-gnu.tar.gz",
|
|
},
|
|
PlatformBinary {
|
|
platform: "linux-x86_64",
|
|
url: "https://github.com/zed-industries/codex-acp/releases/download/v0.10.0/codex-acp-0.10.0-x86_64-unknown-linux-gnu.tar.gz",
|
|
},
|
|
PlatformBinary {
|
|
platform: "windows-aarch64",
|
|
url: "https://github.com/zed-industries/codex-acp/releases/download/v0.10.0/codex-acp-0.10.0-aarch64-pc-windows-msvc.zip",
|
|
},
|
|
PlatformBinary {
|
|
platform: "windows-x86_64",
|
|
url: "https://github.com/zed-industries/codex-acp/releases/download/v0.10.0/codex-acp-0.10.0-x86_64-pc-windows-msvc.zip",
|
|
},
|
|
],
|
|
},
|
|
},
|
|
AgentType::Gemini => AcpAgentMeta {
|
|
agent_type,
|
|
name: "Gemini CLI",
|
|
description: "Google's official CLI for Gemini",
|
|
distribution: AgentDistribution::Npx {
|
|
version: "0.34.0",
|
|
package: "@google/gemini-cli@0.34.0",
|
|
cmd: "gemini",
|
|
args: &["--acp"],
|
|
env: &[],
|
|
node_required: None,
|
|
},
|
|
},
|
|
AgentType::OpenClaw => AcpAgentMeta {
|
|
agent_type,
|
|
name: "OpenClaw",
|
|
description: "OpenClaw is a personal AI assistant you run on your own devices.",
|
|
distribution: AgentDistribution::Npx {
|
|
version: "2026.3.13",
|
|
package: "openclaw@2026.3.13",
|
|
cmd: "openclaw",
|
|
args: &["acp"],
|
|
env: &[],
|
|
node_required: Some("22.12.0"),
|
|
},
|
|
},
|
|
AgentType::OpenCode => AcpAgentMeta {
|
|
agent_type,
|
|
name: "OpenCode",
|
|
description: "The open source coding agent",
|
|
distribution: AgentDistribution::Binary {
|
|
version: "1.2.27",
|
|
cmd: "opencode",
|
|
args: &["acp"],
|
|
env: &[],
|
|
platforms: &[
|
|
PlatformBinary {
|
|
platform: "darwin-aarch64",
|
|
url: "https://github.com/anomalyco/opencode/releases/download/v1.2.27/opencode-darwin-arm64.zip",
|
|
},
|
|
PlatformBinary {
|
|
platform: "darwin-x86_64",
|
|
url: "https://github.com/anomalyco/opencode/releases/download/v1.2.27/opencode-darwin-x64.zip",
|
|
},
|
|
PlatformBinary {
|
|
platform: "linux-aarch64",
|
|
url: "https://github.com/anomalyco/opencode/releases/download/v1.2.27/opencode-linux-arm64.tar.gz",
|
|
},
|
|
PlatformBinary {
|
|
platform: "linux-x86_64",
|
|
url: "https://github.com/anomalyco/opencode/releases/download/v1.2.27/opencode-linux-x64.tar.gz",
|
|
},
|
|
PlatformBinary {
|
|
platform: "windows-x86_64",
|
|
url: "https://github.com/anomalyco/opencode/releases/download/v1.2.27/opencode-windows-x64.zip",
|
|
},
|
|
],
|
|
},
|
|
},
|
|
}
|
|
}
|