1use std::path::Path;
2use std::rc::Rc;
3
4use agent_servers::AgentServer;
5use anyhow::Result;
6use gpui::{App, AppContext, Entity, Task};
7use project::Project;
8
9use crate::{templates::Templates, NativeAgent, NativeAgentConnection};
10
11#[derive(Clone)]
12pub struct NativeAgentServer;
13
14impl AgentServer for NativeAgentServer {
15 fn name(&self) -> &'static str {
16 "Native Agent"
17 }
18
19 fn empty_state_headline(&self) -> &'static str {
20 "Native Agent"
21 }
22
23 fn empty_state_message(&self) -> &'static str {
24 "How can I help you today?"
25 }
26
27 fn logo(&self) -> ui::IconName {
28 // Using the ZedAssistant icon as it's the native built-in agent
29 ui::IconName::ZedAssistant
30 }
31
32 fn connect(
33 &self,
34 _root_dir: &Path,
35 _project: &Entity<Project>,
36 cx: &mut App,
37 ) -> Task<Result<Rc<dyn acp_thread::AgentConnection>>> {
38 cx.spawn(async move |cx| {
39 // Create templates (you might want to load these from files or resources)
40 let templates = Templates::new();
41
42 // Create the native agent
43 let agent = cx.update(|cx| cx.new(|_| NativeAgent::new(templates)))?;
44
45 // Create the connection wrapper
46 let connection = NativeAgentConnection(agent);
47
48 Ok(Rc::new(connection) as Rc<dyn acp_thread::AgentConnection>)
49 })
50 }
51}