File tree Expand file tree Collapse file tree
rsworkspace/crates/acp-nats-agent Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # acp-nats-agent
2+
3+ Server-side framework for building [ ACP] ( https://agentclientprotocol.com/ ) agents over NATS.
4+
5+ ## Architecture
6+
7+ ``` mermaid
8+ graph LR
9+ IDE <--> Bridge["Bridge (acp-nats-stdio)"] <--> NATS <--> Agent["Agent (acp-nats-agent)"]
10+ ```
11+
12+ ## Usage
13+
14+ ``` rust
15+ use acp_nats :: AcpPrefix ;
16+ use acp_nats_agent :: AgentSideNatsConnection ;
17+ use agent_client_protocol :: * ;
18+
19+ struct MyAgent ;
20+
21+ #[async_trait:: async_trait(? Send )]
22+ impl Agent for MyAgent {
23+ async fn initialize (& self , args : InitializeRequest ) -> Result <InitializeResponse > {
24+ Ok (InitializeResponse :: new (ProtocolVersion :: V0 ))
25+ }
26+
27+ async fn new_session (& self , args : NewSessionRequest ) -> Result <NewSessionResponse > {
28+ Ok (NewSessionResponse :: new (" session-123" ))
29+ }
30+
31+ async fn prompt (& self , args : PromptRequest ) -> Result <PromptResponse > {
32+ Ok (PromptResponse :: new (StopReason :: EndTurn ))
33+ }
34+ }
35+
36+ #[tokio:: main]
37+ async fn main () {
38+ let nats = async_nats :: connect (" localhost:4222" ). await . unwrap ();
39+
40+ let (connection , io_task ) = AgentSideNatsConnection :: new (
41+ MyAgent ,
42+ nats ,
43+ AcpPrefix :: new (" acp" ). unwrap (),
44+ | fut | { tokio :: task :: spawn_local (fut ); },
45+ );
46+
47+ let local = tokio :: task :: LocalSet :: new ();
48+ local . run_until (io_task ). await . unwrap ();
49+ }
50+ ```
You can’t perform that action at this time.
0 commit comments