Skip to content

Commit a990f7c

Browse files
committed
docs(acp-nats-agent): add README
Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
1 parent 8df36ff commit a990f7c

1 file changed

Lines changed: 50 additions & 0 deletions

File tree

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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+
```

0 commit comments

Comments
 (0)