simple_acp 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.envrc +1 -0
- data/CHANGELOG.md +5 -0
- data/COMMITS.md +196 -0
- data/LICENSE.txt +21 -0
- data/README.md +385 -0
- data/Rakefile +13 -0
- data/docs/api/client-base.md +383 -0
- data/docs/api/index.md +159 -0
- data/docs/api/models.md +286 -0
- data/docs/api/server-base.md +379 -0
- data/docs/api/storage.md +347 -0
- data/docs/assets/images/simple_acp.jpg +0 -0
- data/docs/client/index.md +279 -0
- data/docs/client/sessions.md +324 -0
- data/docs/client/streaming.md +345 -0
- data/docs/client/sync-async.md +308 -0
- data/docs/core-concepts/agents.md +253 -0
- data/docs/core-concepts/events.md +337 -0
- data/docs/core-concepts/index.md +147 -0
- data/docs/core-concepts/messages.md +211 -0
- data/docs/core-concepts/runs.md +278 -0
- data/docs/core-concepts/sessions.md +281 -0
- data/docs/examples.md +659 -0
- data/docs/getting-started/configuration.md +166 -0
- data/docs/getting-started/index.md +62 -0
- data/docs/getting-started/installation.md +95 -0
- data/docs/getting-started/quick-start.md +189 -0
- data/docs/index.md +119 -0
- data/docs/server/creating-agents.md +360 -0
- data/docs/server/http-endpoints.md +411 -0
- data/docs/server/index.md +218 -0
- data/docs/server/multi-turn.md +329 -0
- data/docs/server/streaming.md +315 -0
- data/docs/storage/custom.md +414 -0
- data/docs/storage/index.md +176 -0
- data/docs/storage/memory.md +198 -0
- data/docs/storage/postgresql.md +350 -0
- data/docs/storage/redis.md +287 -0
- data/examples/01_basic/client.rb +88 -0
- data/examples/01_basic/server.rb +100 -0
- data/examples/02_async_execution/client.rb +107 -0
- data/examples/02_async_execution/server.rb +56 -0
- data/examples/03_run_management/client.rb +115 -0
- data/examples/03_run_management/server.rb +84 -0
- data/examples/04_rich_messages/client.rb +160 -0
- data/examples/04_rich_messages/server.rb +180 -0
- data/examples/05_await_resume/client.rb +164 -0
- data/examples/05_await_resume/server.rb +114 -0
- data/examples/06_agent_metadata/client.rb +188 -0
- data/examples/06_agent_metadata/server.rb +192 -0
- data/examples/README.md +252 -0
- data/examples/run_demo.sh +137 -0
- data/lib/simple_acp/client/base.rb +448 -0
- data/lib/simple_acp/client/sse.rb +141 -0
- data/lib/simple_acp/models/agent_manifest.rb +129 -0
- data/lib/simple_acp/models/await.rb +123 -0
- data/lib/simple_acp/models/base.rb +147 -0
- data/lib/simple_acp/models/errors.rb +102 -0
- data/lib/simple_acp/models/events.rb +256 -0
- data/lib/simple_acp/models/message.rb +235 -0
- data/lib/simple_acp/models/message_part.rb +225 -0
- data/lib/simple_acp/models/metadata.rb +161 -0
- data/lib/simple_acp/models/run.rb +298 -0
- data/lib/simple_acp/models/session.rb +137 -0
- data/lib/simple_acp/models/types.rb +210 -0
- data/lib/simple_acp/server/agent.rb +116 -0
- data/lib/simple_acp/server/app.rb +264 -0
- data/lib/simple_acp/server/base.rb +510 -0
- data/lib/simple_acp/server/context.rb +210 -0
- data/lib/simple_acp/server/falcon_runner.rb +61 -0
- data/lib/simple_acp/storage/base.rb +129 -0
- data/lib/simple_acp/storage/memory.rb +108 -0
- data/lib/simple_acp/storage/postgresql.rb +233 -0
- data/lib/simple_acp/storage/redis.rb +178 -0
- data/lib/simple_acp/version.rb +5 -0
- data/lib/simple_acp.rb +91 -0
- data/mkdocs.yml +152 -0
- data/sig/simple_acp.rbs +4 -0
- metadata +418 -0
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
# Configuration
|
|
2
|
+
|
|
3
|
+
SimpleAcp can be configured at multiple levels: global configuration, server options, and client options.
|
|
4
|
+
|
|
5
|
+
## Global Configuration
|
|
6
|
+
|
|
7
|
+
Use the global configure block to set default options:
|
|
8
|
+
|
|
9
|
+
```ruby
|
|
10
|
+
SimpleAcp.configure do |config|
|
|
11
|
+
config.default_storage = :memory # :memory, :redis, or :postgresql
|
|
12
|
+
config.logger = Logger.new(STDOUT)
|
|
13
|
+
end
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Server Configuration
|
|
17
|
+
|
|
18
|
+
### Basic Options
|
|
19
|
+
|
|
20
|
+
```ruby
|
|
21
|
+
server = SimpleAcp::Server::Base.new(
|
|
22
|
+
storage: SimpleAcp::Storage::Memory.new
|
|
23
|
+
)
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### Storage Backend
|
|
27
|
+
|
|
28
|
+
Choose the appropriate storage backend for your deployment:
|
|
29
|
+
|
|
30
|
+
=== "Memory (Default)"
|
|
31
|
+
|
|
32
|
+
```ruby
|
|
33
|
+
storage = SimpleAcp::Storage::Memory.new
|
|
34
|
+
server = SimpleAcp::Server::Base.new(storage: storage)
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Best for: Development, testing, single-process deployments
|
|
38
|
+
|
|
39
|
+
=== "Redis"
|
|
40
|
+
|
|
41
|
+
```ruby
|
|
42
|
+
require 'simple_acp/storage/redis'
|
|
43
|
+
|
|
44
|
+
storage = SimpleAcp::Storage::Redis.new(
|
|
45
|
+
url: ENV['REDIS_URL'] || 'redis://localhost:6379',
|
|
46
|
+
ttl: 86400, # 24 hours (default)
|
|
47
|
+
prefix: 'acp:' # Key prefix (default)
|
|
48
|
+
)
|
|
49
|
+
server = SimpleAcp::Server::Base.new(storage: storage)
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Best for: Multi-process deployments, horizontal scaling
|
|
53
|
+
|
|
54
|
+
=== "PostgreSQL"
|
|
55
|
+
|
|
56
|
+
```ruby
|
|
57
|
+
require 'simple_acp/storage/postgresql'
|
|
58
|
+
|
|
59
|
+
storage = SimpleAcp::Storage::PostgreSQL.new(
|
|
60
|
+
url: ENV['DATABASE_URL'] || 'postgres://localhost/simple_acp',
|
|
61
|
+
skip_setup: false # Auto-create tables (default: false)
|
|
62
|
+
)
|
|
63
|
+
server = SimpleAcp::Server::Base.new(storage: storage)
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Best for: Production deployments, data persistence
|
|
67
|
+
|
|
68
|
+
### HTTP Server Options
|
|
69
|
+
|
|
70
|
+
When running the HTTP server with Falcon:
|
|
71
|
+
|
|
72
|
+
```ruby
|
|
73
|
+
server.run(
|
|
74
|
+
port: 8000, # Listen port
|
|
75
|
+
host: '0.0.0.0' # Bind address
|
|
76
|
+
)
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Falcon uses fiber-based concurrency, efficiently handling thousands of concurrent SSE connections without manual thread configuration.
|
|
80
|
+
|
|
81
|
+
## Client Configuration
|
|
82
|
+
|
|
83
|
+
### Basic Options
|
|
84
|
+
|
|
85
|
+
```ruby
|
|
86
|
+
client = SimpleAcp::Client::Base.new(
|
|
87
|
+
base_url: 'http://localhost:8000',
|
|
88
|
+
timeout: 30 # Request timeout in seconds
|
|
89
|
+
)
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### With Authentication
|
|
93
|
+
|
|
94
|
+
```ruby
|
|
95
|
+
client = SimpleAcp::Client::Base.new(
|
|
96
|
+
base_url: 'http://localhost:8000',
|
|
97
|
+
headers: {
|
|
98
|
+
'Authorization' => "Bearer #{ENV['API_TOKEN']}"
|
|
99
|
+
}
|
|
100
|
+
)
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Session Configuration
|
|
104
|
+
|
|
105
|
+
```ruby
|
|
106
|
+
# Use a specific session for stateful interactions
|
|
107
|
+
client.use_session("user-123-session")
|
|
108
|
+
|
|
109
|
+
# All subsequent requests will use this session
|
|
110
|
+
client.run_sync(agent: "stateful-agent", input: "...")
|
|
111
|
+
client.run_sync(agent: "stateful-agent", input: "...")
|
|
112
|
+
|
|
113
|
+
# Clear when done
|
|
114
|
+
client.clear_session
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## Environment Variables
|
|
118
|
+
|
|
119
|
+
SimpleAcp respects these environment variables:
|
|
120
|
+
|
|
121
|
+
| Variable | Purpose | Default |
|
|
122
|
+
|----------|---------|---------|
|
|
123
|
+
| `REDIS_URL` | Redis connection URL | `redis://localhost:6379` |
|
|
124
|
+
| `DATABASE_URL` | PostgreSQL connection URL | `postgres://localhost/acp` |
|
|
125
|
+
|
|
126
|
+
## Agent Configuration
|
|
127
|
+
|
|
128
|
+
When registering agents, you can configure:
|
|
129
|
+
|
|
130
|
+
```ruby
|
|
131
|
+
server.agent(
|
|
132
|
+
"my-agent",
|
|
133
|
+
description: "Description shown in manifest",
|
|
134
|
+
input_content_types: ["text/plain", "application/json"],
|
|
135
|
+
output_content_types: ["text/plain"]
|
|
136
|
+
) do |context|
|
|
137
|
+
# Agent logic
|
|
138
|
+
end
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### Agent Options
|
|
142
|
+
|
|
143
|
+
| Option | Type | Description |
|
|
144
|
+
|--------|------|-------------|
|
|
145
|
+
| `description` | String | Human-readable description |
|
|
146
|
+
| `input_content_types` | Array | Accepted input MIME types |
|
|
147
|
+
| `output_content_types` | Array | Output MIME types produced |
|
|
148
|
+
| `metadata` | Hash | Custom metadata |
|
|
149
|
+
|
|
150
|
+
## Logging
|
|
151
|
+
|
|
152
|
+
Configure logging for debugging:
|
|
153
|
+
|
|
154
|
+
```ruby
|
|
155
|
+
# Enable debug logging
|
|
156
|
+
SimpleAcp.configure do |config|
|
|
157
|
+
config.logger = Logger.new(STDOUT)
|
|
158
|
+
config.logger.level = Logger::DEBUG
|
|
159
|
+
end
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
## Next Steps
|
|
163
|
+
|
|
164
|
+
- Explore [Core Concepts](../core-concepts/index.md)
|
|
165
|
+
- Learn about [Storage Backends](../storage/index.md) in detail
|
|
166
|
+
- Read the [Server Guide](../server/index.md) for advanced features
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# Getting Started
|
|
2
|
+
|
|
3
|
+
Welcome to SimpleAcp! This section will help you get up and running with the Agent Communication Protocol in Ruby.
|
|
4
|
+
|
|
5
|
+
## What You'll Learn
|
|
6
|
+
|
|
7
|
+
- [**Installation**](installation.md) - How to add SimpleAcp to your project
|
|
8
|
+
- [**Quick Start**](quick-start.md) - Build your first agent in minutes
|
|
9
|
+
- [**Configuration**](configuration.md) - Customize SimpleAcp for your needs
|
|
10
|
+
|
|
11
|
+
## Prerequisites
|
|
12
|
+
|
|
13
|
+
Before you begin, ensure you have:
|
|
14
|
+
|
|
15
|
+
- **Ruby 3.0 or later** - SimpleAcp uses modern Ruby features
|
|
16
|
+
- **Bundler** - For managing gem dependencies
|
|
17
|
+
|
|
18
|
+
## Installation Overview
|
|
19
|
+
|
|
20
|
+
Add SimpleAcp to your Gemfile:
|
|
21
|
+
|
|
22
|
+
```ruby
|
|
23
|
+
gem 'simple_acp'
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Then run:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
bundle install
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
That's it! You're ready to create your first agent.
|
|
33
|
+
|
|
34
|
+
## Next Steps
|
|
35
|
+
|
|
36
|
+
<div class="grid cards" markdown>
|
|
37
|
+
|
|
38
|
+
- :material-download:{ .lg .middle } **Installation**
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
Detailed installation instructions and optional dependencies
|
|
43
|
+
|
|
44
|
+
[:octicons-arrow-right-24: Install](installation.md)
|
|
45
|
+
|
|
46
|
+
- :material-rocket-launch:{ .lg .middle } **Quick Start**
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
Create your first agent server and client
|
|
51
|
+
|
|
52
|
+
[:octicons-arrow-right-24: Start building](quick-start.md)
|
|
53
|
+
|
|
54
|
+
- :material-cog:{ .lg .middle } **Configuration**
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
Learn about configuration options
|
|
59
|
+
|
|
60
|
+
[:octicons-arrow-right-24: Configure](configuration.md)
|
|
61
|
+
|
|
62
|
+
</div>
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# Installation
|
|
2
|
+
|
|
3
|
+
## Requirements
|
|
4
|
+
|
|
5
|
+
- Ruby 3.0 or later
|
|
6
|
+
- Bundler (recommended)
|
|
7
|
+
|
|
8
|
+
## Basic Installation
|
|
9
|
+
|
|
10
|
+
### Using Bundler (Recommended)
|
|
11
|
+
|
|
12
|
+
Add SimpleAcp to your `Gemfile`:
|
|
13
|
+
|
|
14
|
+
```ruby
|
|
15
|
+
gem 'simple_acp'
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Then install dependencies:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
bundle install
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### Direct Installation
|
|
25
|
+
|
|
26
|
+
Install the gem directly:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
gem install simple_acp
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Optional Dependencies
|
|
33
|
+
|
|
34
|
+
SimpleAcp has optional dependencies for different storage backends:
|
|
35
|
+
|
|
36
|
+
### Redis Storage
|
|
37
|
+
|
|
38
|
+
For distributed deployments with Redis:
|
|
39
|
+
|
|
40
|
+
```ruby
|
|
41
|
+
gem 'simple_acp'
|
|
42
|
+
gem 'redis', '~> 5.0'
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### PostgreSQL Storage
|
|
46
|
+
|
|
47
|
+
For persistent storage with PostgreSQL:
|
|
48
|
+
|
|
49
|
+
```ruby
|
|
50
|
+
gem 'simple_acp'
|
|
51
|
+
gem 'sequel', '~> 5.0'
|
|
52
|
+
gem 'pg', '~> 1.5'
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Verifying Installation
|
|
56
|
+
|
|
57
|
+
Create a simple test file to verify the installation:
|
|
58
|
+
|
|
59
|
+
```ruby
|
|
60
|
+
# test_install.rb
|
|
61
|
+
require 'simple_acp'
|
|
62
|
+
|
|
63
|
+
server = SimpleAcp::Server::Base.new
|
|
64
|
+
|
|
65
|
+
server.agent("test") do |context|
|
|
66
|
+
SimpleAcp::Models::Message.agent("SimpleAcp is working!")
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
puts "SimpleAcp version: #{SimpleAcp::VERSION}"
|
|
70
|
+
puts "Registered agents: #{server.agents.keys.join(', ')}"
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Run it:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
ruby test_install.rb
|
|
77
|
+
# SimpleAcp version: 0.1.0
|
|
78
|
+
# Registered agents: test
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Dependencies
|
|
82
|
+
|
|
83
|
+
SimpleAcp depends on these gems (automatically installed):
|
|
84
|
+
|
|
85
|
+
| Gem | Purpose |
|
|
86
|
+
|-----|---------|
|
|
87
|
+
| `roda` | HTTP routing and request handling |
|
|
88
|
+
| `falcon` | Fiber-based web server for efficient concurrency |
|
|
89
|
+
| `async` | Asynchronous I/O framework |
|
|
90
|
+
| `faraday` | HTTP client for agent clients |
|
|
91
|
+
| `concurrent-ruby` | Thread-safe data structures |
|
|
92
|
+
|
|
93
|
+
## Next Steps
|
|
94
|
+
|
|
95
|
+
Now that you have SimpleAcp installed, proceed to the [Quick Start](quick-start.md) guide to create your first agent.
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
# Quick Start
|
|
2
|
+
|
|
3
|
+
This guide walks you through creating your first ACP server and client.
|
|
4
|
+
|
|
5
|
+
## Creating an Agent Server
|
|
6
|
+
|
|
7
|
+
### Step 1: Create a Basic Server
|
|
8
|
+
|
|
9
|
+
```ruby
|
|
10
|
+
# server.rb
|
|
11
|
+
require 'simple_acp'
|
|
12
|
+
|
|
13
|
+
# Create the server
|
|
14
|
+
server = SimpleAcp::Server::Base.new
|
|
15
|
+
|
|
16
|
+
# Register a simple echo agent
|
|
17
|
+
server.agent("echo", description: "Echoes back your message") do |context|
|
|
18
|
+
text = context.input.first&.text_content || "Nothing to echo"
|
|
19
|
+
SimpleAcp::Models::Message.agent("You said: #{text}")
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Start the server
|
|
23
|
+
server.run(port: 8000)
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Run the server:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
ruby server.rb
|
|
30
|
+
# ACP Server (Falcon) running on http://0.0.0.0:8000
|
|
31
|
+
# Registered agents: echo
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Step 2: Test with curl
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
# Check server health
|
|
38
|
+
curl http://localhost:8000/ping
|
|
39
|
+
# {"status":"ok"}
|
|
40
|
+
|
|
41
|
+
# List available agents
|
|
42
|
+
curl http://localhost:8000/agents
|
|
43
|
+
# {"agents":[{"name":"echo","description":"Echoes back your message",...}]}
|
|
44
|
+
|
|
45
|
+
# Run the agent
|
|
46
|
+
curl -X POST http://localhost:8000/runs \
|
|
47
|
+
-H "Content-Type: application/json" \
|
|
48
|
+
-d '{
|
|
49
|
+
"agent_name": "echo",
|
|
50
|
+
"input": [{"role": "user", "parts": [{"content_type": "text/plain", "content": "Hello!"}]}]
|
|
51
|
+
}'
|
|
52
|
+
# {"run_id":"...","status":"completed","output":[{"role":"agent","parts":[{"content":"You said: Hello!"}]}]}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Using the Ruby Client
|
|
56
|
+
|
|
57
|
+
### Step 1: Create a Client
|
|
58
|
+
|
|
59
|
+
```ruby
|
|
60
|
+
# client.rb
|
|
61
|
+
require 'simple_acp'
|
|
62
|
+
|
|
63
|
+
client = SimpleAcp::Client::Base.new(base_url: "http://localhost:8000")
|
|
64
|
+
|
|
65
|
+
# Check connection
|
|
66
|
+
puts client.ping ? "Connected!" : "Connection failed"
|
|
67
|
+
|
|
68
|
+
# List available agents
|
|
69
|
+
response = client.agents
|
|
70
|
+
puts "Available agents: #{response.agents.map(&:name).join(', ')}"
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Step 2: Run Agents
|
|
74
|
+
|
|
75
|
+
```ruby
|
|
76
|
+
# Synchronous execution
|
|
77
|
+
run = client.run_sync(
|
|
78
|
+
agent: "echo",
|
|
79
|
+
input: [SimpleAcp::Models::Message.user("Hello, SimpleAcp!")]
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
puts "Status: #{run.status}"
|
|
83
|
+
puts "Response: #{run.output.first.text_content}"
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Step 3: Use Streaming
|
|
87
|
+
|
|
88
|
+
```ruby
|
|
89
|
+
# Streaming execution with events
|
|
90
|
+
client.run_stream(agent: "echo", input: "Streaming test") do |event|
|
|
91
|
+
case event
|
|
92
|
+
when SimpleAcp::Models::RunStartedEvent
|
|
93
|
+
puts "Run started: #{event.run_id}"
|
|
94
|
+
when SimpleAcp::Models::MessagePartEvent
|
|
95
|
+
print event.part.content
|
|
96
|
+
when SimpleAcp::Models::RunCompletedEvent
|
|
97
|
+
puts "\nCompleted!"
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Adding More Agents
|
|
103
|
+
|
|
104
|
+
### A Greeting Agent
|
|
105
|
+
|
|
106
|
+
```ruby
|
|
107
|
+
server.agent("greeter", description: "Personalized greetings") do |context|
|
|
108
|
+
name = context.input.first&.text_content || "World"
|
|
109
|
+
SimpleAcp::Models::Message.agent("Hello, #{name}! Welcome to SimpleAcp.")
|
|
110
|
+
end
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### A Multi-Response Agent
|
|
114
|
+
|
|
115
|
+
Agents can return multiple messages using an Enumerator:
|
|
116
|
+
|
|
117
|
+
```ruby
|
|
118
|
+
server.agent("countdown", description: "Counts down from a number") do |context|
|
|
119
|
+
n = context.input.first&.text_content.to_i
|
|
120
|
+
n = 5 if n <= 0
|
|
121
|
+
|
|
122
|
+
Enumerator.new do |yielder|
|
|
123
|
+
n.downto(1) do |i|
|
|
124
|
+
yielder << SimpleAcp::Server::RunYield.new(
|
|
125
|
+
SimpleAcp::Models::Message.agent("#{i}...")
|
|
126
|
+
)
|
|
127
|
+
sleep 0.5
|
|
128
|
+
end
|
|
129
|
+
yielder << SimpleAcp::Server::RunYield.new(
|
|
130
|
+
SimpleAcp::Models::Message.agent("Liftoff!")
|
|
131
|
+
)
|
|
132
|
+
end
|
|
133
|
+
end
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## Complete Example
|
|
137
|
+
|
|
138
|
+
Here's a complete example with both server and client:
|
|
139
|
+
|
|
140
|
+
=== "Server"
|
|
141
|
+
|
|
142
|
+
```ruby
|
|
143
|
+
# examples/server.rb
|
|
144
|
+
require 'simple_acp'
|
|
145
|
+
|
|
146
|
+
server = SimpleAcp::Server::Base.new
|
|
147
|
+
|
|
148
|
+
server.agent("echo") do |context|
|
|
149
|
+
text = context.input.first&.text_content
|
|
150
|
+
SimpleAcp::Models::Message.agent("Echo: #{text}")
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
server.agent("reverse") do |context|
|
|
154
|
+
text = context.input.first&.text_content || ""
|
|
155
|
+
SimpleAcp::Models::Message.agent(text.reverse)
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
server.agent("upcase") do |context|
|
|
159
|
+
text = context.input.first&.text_content || ""
|
|
160
|
+
SimpleAcp::Models::Message.agent(text.upcase)
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
puts "Starting server on port 8000..."
|
|
164
|
+
server.run(port: 8000)
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
=== "Client"
|
|
168
|
+
|
|
169
|
+
```ruby
|
|
170
|
+
# examples/client.rb
|
|
171
|
+
require 'simple_acp'
|
|
172
|
+
|
|
173
|
+
client = SimpleAcp::Client::Base.new(base_url: "http://localhost:8000")
|
|
174
|
+
|
|
175
|
+
# Test each agent
|
|
176
|
+
%w[echo reverse upcase].each do |agent_name|
|
|
177
|
+
run = client.run_sync(
|
|
178
|
+
agent: agent_name,
|
|
179
|
+
input: [SimpleAcp::Models::Message.user("Hello World")]
|
|
180
|
+
)
|
|
181
|
+
puts "#{agent_name}: #{run.output.first.text_content}"
|
|
182
|
+
end
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
## Next Steps
|
|
186
|
+
|
|
187
|
+
- Learn about [Configuration](configuration.md) options
|
|
188
|
+
- Understand [Core Concepts](../core-concepts/index.md) like messages, runs, and sessions
|
|
189
|
+
- Dive into the [Server Guide](../server/index.md) for advanced agent development
|
data/docs/index.md
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# SimpleAcp
|
|
2
|
+
|
|
3
|
+
!!! warning "CAUTION"
|
|
4
|
+
This project is under active development. The API and documentation may not necessarily reflect the current codebase.
|
|
5
|
+
|
|
6
|
+
<div class="grid" markdown>
|
|
7
|
+
|
|
8
|
+
<div markdown>
|
|
9
|
+
|
|
10
|
+
{ width="100%" }
|
|
11
|
+
|
|
12
|
+
</div>
|
|
13
|
+
|
|
14
|
+
<div markdown>
|
|
15
|
+
|
|
16
|
+
**A Ruby implementation of the Agent Communication Protocol (ACP)**
|
|
17
|
+
|
|
18
|
+
SimpleAcp provides an open protocol for communication between AI agents, applications, and humans. Build agent servers, connect with HTTP clients, and stream responses in real-time.
|
|
19
|
+
|
|
20
|
+
| | |
|
|
21
|
+
|---|---|
|
|
22
|
+
| :material-robot: Full ACP Protocol | :material-sync: Sync/Async/Stream |
|
|
23
|
+
| :material-message-text: Session Management | :material-image: Multimodal Messages |
|
|
24
|
+
| :material-database: Pluggable Storage | :material-lightning-bolt: SSE Streaming |
|
|
25
|
+
|
|
26
|
+
</div>
|
|
27
|
+
|
|
28
|
+
</div>
|
|
29
|
+
|
|
30
|
+
<p align="center" markdown>
|
|
31
|
+
[:material-download: Install](getting-started/installation.md){ .md-button .md-button--primary }
|
|
32
|
+
[:material-rocket-launch: Quick Start](getting-started/quick-start.md){ .md-button }
|
|
33
|
+
</p>
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Features
|
|
38
|
+
|
|
39
|
+
- **Full ACP Protocol Support**: Complete implementation including agents, runs, sessions, and events
|
|
40
|
+
- **Multiple Run Modes**: Synchronous, asynchronous, and streaming execution patterns
|
|
41
|
+
- **Session Management**: Maintain state and conversation history across interactions
|
|
42
|
+
- **Multimodal Messages**: Support for text, JSON, images, and URL references
|
|
43
|
+
- **Pluggable Storage**: In-memory, Redis, and PostgreSQL backends included
|
|
44
|
+
- **SSE Streaming**: Server-Sent Events for real-time response streaming
|
|
45
|
+
- **Falcon Server**: Fiber-based concurrency for efficient handling of thousands of concurrent connections
|
|
46
|
+
|
|
47
|
+
## Quick Example
|
|
48
|
+
|
|
49
|
+
```ruby
|
|
50
|
+
require 'simple_acp'
|
|
51
|
+
|
|
52
|
+
# Create a server with an agent
|
|
53
|
+
server = SimpleAcp::Server::Base.new
|
|
54
|
+
|
|
55
|
+
server.agent("greeter", description: "Greets users") do |context|
|
|
56
|
+
name = context.input.first&.text_content || "World"
|
|
57
|
+
SimpleAcp::Models::Message.agent("Hello, #{name}!")
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
server.run(port: 8000)
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
```ruby
|
|
64
|
+
# Connect with a client
|
|
65
|
+
client = SimpleAcp::Client::Base.new(base_url: "http://localhost:8000")
|
|
66
|
+
|
|
67
|
+
run = client.run_sync(
|
|
68
|
+
agent: "greeter",
|
|
69
|
+
input: [SimpleAcp::Models::Message.user("Alice")]
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
puts run.output.first.text_content
|
|
73
|
+
# => "Hello, Alice!"
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Architecture Overview
|
|
77
|
+
|
|
78
|
+
```mermaid
|
|
79
|
+
graph LR
|
|
80
|
+
subgraph Client
|
|
81
|
+
C[Client::Base]
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
subgraph Server
|
|
85
|
+
S[Server::Base]
|
|
86
|
+
A1[Agent 1]
|
|
87
|
+
A2[Agent 2]
|
|
88
|
+
ST[(Storage)]
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
C -->|HTTP/SSE| S
|
|
92
|
+
S --> A1
|
|
93
|
+
S --> A2
|
|
94
|
+
S --> ST
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
SimpleAcp follows a client-server architecture:
|
|
98
|
+
|
|
99
|
+
- **Server**: Hosts agents and handles HTTP requests via Roda/Falcon
|
|
100
|
+
- **Agents**: Process input and produce output messages
|
|
101
|
+
- **Client**: Communicates with servers over HTTP with optional SSE streaming
|
|
102
|
+
- **Storage**: Persists runs, sessions, and events
|
|
103
|
+
|
|
104
|
+
## Getting Started
|
|
105
|
+
|
|
106
|
+
Ready to build your first agent? Head to the [Installation](getting-started/installation.md) guide to get started.
|
|
107
|
+
|
|
108
|
+
[Get Started :material-arrow-right:](getting-started/installation.md){ .md-button .md-button--primary }
|
|
109
|
+
[View on GitHub :material-github:](https://github.com/MadBomber/simple_acp){ .md-button }
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## A Note on ACP as a Standard
|
|
114
|
+
|
|
115
|
+
This gem implements the Agent Communication Protocol specification, but I have reservations about ACP becoming "the" standard for agent-to-agent communication. Like MCP before it, ACP suffers from conceptual ambiguity—the protocol designers seem unable to clearly distinguish between what constitutes an "agent" versus a "tool." This fundamental confusion permeates both protocols.
|
|
116
|
+
|
|
117
|
+
Whether ACP achieves the same de facto adoption that MCP has gained remains to be seen. MCP's prevalence stems largely from momentum and network effects rather than technical superiority. ACP may follow the same path simply because it exists and others adopt it, not because it represents the best possible design for inter-agent communication.
|
|
118
|
+
|
|
119
|
+
For now, this implementation provides a practical way to work with ACP-compatible systems while we wait to see how the agent communication landscape evolves.
|