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.
Files changed (80) hide show
  1. checksums.yaml +7 -0
  2. data/.envrc +1 -0
  3. data/CHANGELOG.md +5 -0
  4. data/COMMITS.md +196 -0
  5. data/LICENSE.txt +21 -0
  6. data/README.md +385 -0
  7. data/Rakefile +13 -0
  8. data/docs/api/client-base.md +383 -0
  9. data/docs/api/index.md +159 -0
  10. data/docs/api/models.md +286 -0
  11. data/docs/api/server-base.md +379 -0
  12. data/docs/api/storage.md +347 -0
  13. data/docs/assets/images/simple_acp.jpg +0 -0
  14. data/docs/client/index.md +279 -0
  15. data/docs/client/sessions.md +324 -0
  16. data/docs/client/streaming.md +345 -0
  17. data/docs/client/sync-async.md +308 -0
  18. data/docs/core-concepts/agents.md +253 -0
  19. data/docs/core-concepts/events.md +337 -0
  20. data/docs/core-concepts/index.md +147 -0
  21. data/docs/core-concepts/messages.md +211 -0
  22. data/docs/core-concepts/runs.md +278 -0
  23. data/docs/core-concepts/sessions.md +281 -0
  24. data/docs/examples.md +659 -0
  25. data/docs/getting-started/configuration.md +166 -0
  26. data/docs/getting-started/index.md +62 -0
  27. data/docs/getting-started/installation.md +95 -0
  28. data/docs/getting-started/quick-start.md +189 -0
  29. data/docs/index.md +119 -0
  30. data/docs/server/creating-agents.md +360 -0
  31. data/docs/server/http-endpoints.md +411 -0
  32. data/docs/server/index.md +218 -0
  33. data/docs/server/multi-turn.md +329 -0
  34. data/docs/server/streaming.md +315 -0
  35. data/docs/storage/custom.md +414 -0
  36. data/docs/storage/index.md +176 -0
  37. data/docs/storage/memory.md +198 -0
  38. data/docs/storage/postgresql.md +350 -0
  39. data/docs/storage/redis.md +287 -0
  40. data/examples/01_basic/client.rb +88 -0
  41. data/examples/01_basic/server.rb +100 -0
  42. data/examples/02_async_execution/client.rb +107 -0
  43. data/examples/02_async_execution/server.rb +56 -0
  44. data/examples/03_run_management/client.rb +115 -0
  45. data/examples/03_run_management/server.rb +84 -0
  46. data/examples/04_rich_messages/client.rb +160 -0
  47. data/examples/04_rich_messages/server.rb +180 -0
  48. data/examples/05_await_resume/client.rb +164 -0
  49. data/examples/05_await_resume/server.rb +114 -0
  50. data/examples/06_agent_metadata/client.rb +188 -0
  51. data/examples/06_agent_metadata/server.rb +192 -0
  52. data/examples/README.md +252 -0
  53. data/examples/run_demo.sh +137 -0
  54. data/lib/simple_acp/client/base.rb +448 -0
  55. data/lib/simple_acp/client/sse.rb +141 -0
  56. data/lib/simple_acp/models/agent_manifest.rb +129 -0
  57. data/lib/simple_acp/models/await.rb +123 -0
  58. data/lib/simple_acp/models/base.rb +147 -0
  59. data/lib/simple_acp/models/errors.rb +102 -0
  60. data/lib/simple_acp/models/events.rb +256 -0
  61. data/lib/simple_acp/models/message.rb +235 -0
  62. data/lib/simple_acp/models/message_part.rb +225 -0
  63. data/lib/simple_acp/models/metadata.rb +161 -0
  64. data/lib/simple_acp/models/run.rb +298 -0
  65. data/lib/simple_acp/models/session.rb +137 -0
  66. data/lib/simple_acp/models/types.rb +210 -0
  67. data/lib/simple_acp/server/agent.rb +116 -0
  68. data/lib/simple_acp/server/app.rb +264 -0
  69. data/lib/simple_acp/server/base.rb +510 -0
  70. data/lib/simple_acp/server/context.rb +210 -0
  71. data/lib/simple_acp/server/falcon_runner.rb +61 -0
  72. data/lib/simple_acp/storage/base.rb +129 -0
  73. data/lib/simple_acp/storage/memory.rb +108 -0
  74. data/lib/simple_acp/storage/postgresql.rb +233 -0
  75. data/lib/simple_acp/storage/redis.rb +178 -0
  76. data/lib/simple_acp/version.rb +5 -0
  77. data/lib/simple_acp.rb +91 -0
  78. data/mkdocs.yml +152 -0
  79. data/sig/simple_acp.rbs +4 -0
  80. metadata +418 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 44961e2fe55d5ba23c23e44c245123d361fba3a18b060e831980b1014c0119b9
4
+ data.tar.gz: 5b2e422e4371ad0ab79cbe008f30fd95ed1108815488c62e702a33ddba2cb318
5
+ SHA512:
6
+ metadata.gz: 6c8dd8ad7df331dfd3dc79eeba570644838d24fb387a8637062fcef8e8b31e0d2521a2506e5cf895e3a457fac7f80bf7f0dc14826de53db0e478187d5fa6cb98
7
+ data.tar.gz: c70fdc2c466b7ddc85a5a616a973585d044ea35b9eb26b21a4908b7d2e4e057b55e69546980ffcaa47d97093fe3733ea20312074553f2ecad403a639d2236a40
data/.envrc ADDED
@@ -0,0 +1 @@
1
+ export RR=`pwd`
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2026-01-17
4
+
5
+ - Initial release
data/COMMITS.md ADDED
@@ -0,0 +1,196 @@
1
+ ---
2
+ url: https://www.conventionalcommits.org/en/v1.0.0/
3
+ title: Conventional Commits
4
+ description: A specification for adding human and machine readable meaning to commit messages
5
+ access_date: 2025-07-31T20:51:29.000Z
6
+ current_date: 2025-07-31T20:51:29.601Z
7
+ ---
8
+
9
+ # Conventional Commits
10
+
11
+ A specification for adding human and machine readable meaning to commit messages
12
+
13
+ Quick Summary Full Specification Contribute
14
+
15
+ # Conventional Commits 1.0.0
16
+
17
+ ## Summary
18
+
19
+ The Conventional Commits specification is a lightweight convention on top of commit messages. It provides an easy set of rules for creating an explicit commit history; which makes it easier to write automated tools on top of. This convention dovetails with SemVer, by describing the features, fixes, and breaking changes made in commit messages.
20
+
21
+ The commit message should be structured as follows:
22
+
23
+ ---
24
+
25
+ ```
26
+ <type>[optional scope]: <description>
27
+
28
+ [optional body]
29
+
30
+ [optional footer(s)]
31
+
32
+ ```
33
+
34
+ ---
35
+
36
+ The commit contains the following structural elements, to communicate intent to the consumers of your library:
37
+
38
+ 1. **fix:** a commit of the _type_ `fix` patches a bug in your codebase (this correlates with `PATCH` in Semantic Versioning).
39
+ 2. **feat:** a commit of the _type_ `feat` introduces a new feature to the codebase (this correlates with `MINOR` in Semantic Versioning).
40
+ 3. **BREAKING CHANGE:** a commit that has a footer `BREAKING CHANGE:`, or appends a `!` after the type/scope, introduces a breaking API change (correlating with `MAJOR` in Semantic Versioning). A BREAKING CHANGE can be part of commits of any _type_.
41
+ 4. _types_ other than `fix:` and `feat:` are allowed, for example @commitlint/config-conventional (based on the Angular convention) recommends `build:`, `chore:`,`ci:`, `docs:`, `style:`, `refactor:`, `perf:`, `test:`, and others.
42
+ 5. _footers_ other than `BREAKING CHANGE: <description>` may be provided and follow a convention similar to git trailer format.
43
+
44
+ Additional types are not mandated by the Conventional Commits specification, and have no implicit effect in Semantic Versioning (unless they include a BREAKING CHANGE). A scope may be provided to a commit’s type, to provide additional contextual information and is contained within parenthesis, e.g., `feat(parser): add ability to parse arrays`.
45
+
46
+ ## Examples
47
+
48
+ ### Commit message with description and breaking change footer
49
+
50
+ ```
51
+ feat: allow provided config object to extend other configs
52
+
53
+ BREAKING CHANGE: `extends` key in config file is now used for extending other config files
54
+
55
+ ```
56
+
57
+ ### Commit message with `!` to draw attention to breaking change
58
+
59
+ ```
60
+ feat!: send an email to the customer when a product is shipped
61
+
62
+ ```
63
+
64
+ ### Commit message with scope and `!` to draw attention to breaking change
65
+
66
+ ```
67
+ feat(api)!: send an email to the customer when a product is shipped
68
+
69
+ ```
70
+
71
+ ### Commit message with both `!` and BREAKING CHANGE footer
72
+
73
+ ```
74
+ chore!: drop support for Node 6
75
+
76
+ BREAKING CHANGE: use JavaScript features not available in Node 6.
77
+
78
+ ```
79
+
80
+ ### Commit message with no body
81
+
82
+ ```
83
+ docs: correct spelling of CHANGELOG
84
+
85
+ ```
86
+
87
+ ### Commit message with scope
88
+
89
+ ```
90
+ feat(lang): add Polish language
91
+
92
+ ```
93
+
94
+ ### Commit message with multi-paragraph body and multiple footers
95
+
96
+ ```
97
+ fix: prevent racing of requests
98
+
99
+ Introduce a request id and a reference to latest request. Dismiss
100
+ incoming responses other than from latest request.
101
+
102
+ Remove timeouts which were used to mitigate the racing issue but are
103
+ obsolete now.
104
+
105
+ Reviewed-by: Z
106
+ Refs: #123
107
+
108
+ ```
109
+
110
+ ## Specification
111
+
112
+ The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in this document are to be interpreted as described in RFC 2119.
113
+
114
+ 1. Commits MUST be prefixed with a type, which consists of a noun, `feat`, `fix`, etc., followed by the OPTIONAL scope, OPTIONAL `!`, and REQUIRED terminal colon and space.
115
+ 2. The type `feat` MUST be used when a commit adds a new feature to your application or library.
116
+ 3. The type `fix` MUST be used when a commit represents a bug fix for your application.
117
+ 4. A scope MAY be provided after a type. A scope MUST consist of a noun describing a section of the codebase surrounded by parenthesis, e.g., `fix(parser):`
118
+ 5. A description MUST immediately follow the colon and space after the type/scope prefix. The description is a short summary of the code changes, e.g., _fix: array parsing issue when multiple spaces were contained in string_.
119
+ 6. A longer commit body MAY be provided after the short description, providing additional contextual information about the code changes. The body MUST begin one blank line after the description.
120
+ 7. A commit body is free-form and MAY consist of any number of newline separated paragraphs.
121
+ 8. One or more footers MAY be provided one blank line after the body. Each footer MUST consist of a word token, followed by either a `:<space>` or `<space>#` separator, followed by a string value (this is inspired by the git trailer convention).
122
+ 9. A footer’s token MUST use `-` in place of whitespace characters, e.g., `Acked-by` (this helps differentiate the footer section from a multi-paragraph body). An exception is made for `BREAKING CHANGE`, which MAY also be used as a token.
123
+ 10. A footer’s value MAY contain spaces and newlines, and parsing MUST terminate when the next valid footer token/separator pair is observed.
124
+ 11. Breaking changes MUST be indicated in the type/scope prefix of a commit, or as an entry in the footer.
125
+ 12. If included as a footer, a breaking change MUST consist of the uppercase text BREAKING CHANGE, followed by a colon, space, and description, e.g.,_BREAKING CHANGE: environment variables now take precedence over config files_.
126
+ 13. If included in the type/scope prefix, breaking changes MUST be indicated by a`!` immediately before the `:`. If `!` is used, `BREAKING CHANGE:` MAY be omitted from the footer section, and the commit description SHALL be used to describe the breaking change.
127
+ 14. Types other than `feat` and `fix` MAY be used in your commit messages, e.g., _docs: update ref docs._
128
+ 15. The units of information that make up Conventional Commits MUST NOT be treated as case sensitive by implementors, with the exception of BREAKING CHANGE which MUST be uppercase.
129
+ 16. BREAKING-CHANGE MUST be synonymous with BREAKING CHANGE, when used as a token in a footer.
130
+
131
+ ## Why Use Conventional Commits
132
+
133
+ * Automatically generating CHANGELOGs.
134
+ * Automatically determining a semantic version bump (based on the types of commits landed).
135
+ * Communicating the nature of changes to teammates, the public, and other stakeholders.
136
+ * Triggering build and publish processes.
137
+ * Making it easier for people to contribute to your projects, by allowing them to explore a more structured commit history.
138
+
139
+ ## FAQ
140
+
141
+ ### How should I deal with commit messages in the initial development phase?
142
+
143
+ We recommend that you proceed as if you’ve already released the product. Typically _somebody_, even if it’s your fellow software developers, is using your software. They’ll want to know what’s fixed, what breaks etc.
144
+
145
+ ### Are the types in the commit title uppercase or lowercase?
146
+
147
+ Any casing may be used, but it’s best to be consistent.
148
+
149
+ ### What do I do if the commit conforms to more than one of the commit types?
150
+
151
+ Go back and make multiple commits whenever possible. Part of the benefit of Conventional Commits is its ability to drive us to make more organized commits and PRs.
152
+
153
+ ### Doesn’t this discourage rapid development and fast iteration?
154
+
155
+ It discourages moving fast in a disorganized way. It helps you be able to move fast long term across multiple projects with varied contributors.
156
+
157
+ ### Might Conventional Commits lead developers to limit the type of commits they make because they’ll be thinking in the types provided?
158
+
159
+ Conventional Commits encourages us to make more of certain types of commits such as fixes. Other than that, the flexibility of Conventional Commits allows your team to come up with their own types and change those types over time.
160
+
161
+ ### How does this relate to SemVer?
162
+
163
+ `fix` type commits should be translated to `PATCH` releases. `feat` type commits should be translated to `MINOR` releases. Commits with `BREAKING CHANGE` in the commits, regardless of type, should be translated to `MAJOR` releases.
164
+
165
+ ### How should I version my extensions to the Conventional Commits Specification, e.g. `@jameswomack/conventional-commit-spec`?
166
+
167
+ We recommend using SemVer to release your own extensions to this specification (and encourage you to make these extensions!)
168
+
169
+ ### What do I do if I accidentally use the wrong commit type?
170
+
171
+ #### When you used a type that’s of the spec but not the correct type, e.g. `fix` instead of `feat`
172
+
173
+ Prior to merging or releasing the mistake, we recommend using `git rebase -i` to edit the commit history. After release, the cleanup will be different according to what tools and processes you use.
174
+
175
+ #### When you used a type _not_ of the spec, e.g. `feet` instead of `feat`
176
+
177
+ In a worst case scenario, it’s not the end of the world if a commit lands that does not meet the Conventional Commits specification. It simply means that commit will be missed by tools that are based on the spec.
178
+
179
+ ### Do all my contributors need to use the Conventional Commits specification?
180
+
181
+ No! If you use a squash based workflow on Git lead maintainers can clean up the commit messages as they’re merged—adding no workload to casual committers. A common workflow for this is to have your git system automatically squash commits from a pull request and present a form for the lead maintainer to enter the proper git commit message for the merge.
182
+
183
+ ### How does Conventional Commits handle revert commits?
184
+
185
+ Reverting code can be complicated: are you reverting multiple commits? if you revert a feature, should the next release instead be a patch?
186
+
187
+ Conventional Commits does not make an explicit effort to define revert behavior. Instead we leave it to tooling authors to use the flexibility of _types_ and _footers_ to develop their logic for handling reverts.
188
+
189
+ One recommendation is to use the `revert` type, and a footer that references the commit SHAs that are being reverted:
190
+
191
+ ```
192
+ revert: let us never again speak of the noodle incident
193
+
194
+ Refs: 676104e, a215868
195
+
196
+ ```
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2026 Dewayne VanHoozer
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,385 @@
1
+ # SimpleAcp
2
+
3
+ > **CAUTION:** This project is under active development. The API and documentation may not necessarily reflect the current codebase.
4
+
5
+ <table>
6
+ <tr>
7
+ <td width="40%">
8
+ <img src="docs/assets/images/simple_acp.jpg" alt="SimpleAcp - Robots communicating in binary" width="100%">
9
+ </td>
10
+ <td width="60%" valign="top">
11
+ <strong>A Ruby implementation of the Agent Communication Protocol (ACP)</strong>
12
+ <br><br>
13
+ SimpleAcp provides an open protocol for communication between AI agents, applications, and humans. Build agent servers that host multiple agents, connect with HTTP clients, and stream responses in real-time via Server-Sent Events.
14
+ <br><br>
15
+ <table>
16
+ <tr>
17
+ <td>:robot: Full ACP Protocol</td>
18
+ <td>:arrows_counterclockwise: Sync/Async/Stream</td>
19
+ </tr>
20
+ <tr>
21
+ <td>:speech_balloon: Session Management</td>
22
+ <td>:framed_picture: Multimodal Messages</td>
23
+ </tr>
24
+ <tr>
25
+ <td>:floppy_disk: Pluggable Storage</td>
26
+ <td>:zap: SSE Streaming</td>
27
+ </tr>
28
+ </table>
29
+ </td>
30
+ </tr>
31
+ </table>
32
+
33
+ <p align="center">
34
+ <a href="https://madbomber.github.io/simple_acp/getting-started/installation/">Install</a> •
35
+ <a href="https://madbomber.github.io/simple_acp/getting-started/quick-start/">Quick Start</a> •
36
+ <a href="https://madbomber.github.io/simple_acp/">Documentation</a> •
37
+ <a href="https://github.com/i-am-bee/acp">ACP Specification</a>
38
+ </p>
39
+
40
+ ---
41
+
42
+ ## Features
43
+
44
+ - **Full ACP Protocol Support**: Implements the ACP specification including agents, runs, sessions, and events
45
+ - **Multiple Run Modes**: Synchronous, asynchronous, and streaming execution
46
+ - **Session Management**: Maintain state and conversation history across interactions
47
+ - **Multimodal Messages**: Support for text, JSON, images, and URL references
48
+ - **Pluggable Storage**: In-memory, Redis, and PostgreSQL backends
49
+ - **SSE Streaming**: Server-Sent Events for real-time response streaming
50
+ - **Falcon Server**: Fiber-based concurrency for efficient handling of concurrent connections
51
+
52
+ ## Documentation
53
+
54
+ For comprehensive guides, tutorials, and API reference, visit the **[SimpleAcp Documentation](https://madbomber.github.io/simple_acp/)**.
55
+
56
+ The documentation covers:
57
+
58
+ - [Installation & Quick Start](https://madbomber.github.io/simple_acp/getting-started/installation/)
59
+ - [Core Concepts](https://madbomber.github.io/simple_acp/core-concepts/) (Messages, Agents, Runs, Sessions, Events)
60
+ - [Server Guide](https://madbomber.github.io/simple_acp/server/) (Creating Agents, Streaming, Multi-Turn Conversations)
61
+ - [Client Guide](https://madbomber.github.io/simple_acp/client/) (Sync/Async, Streaming, Session Management)
62
+ - [Storage Backends](https://madbomber.github.io/simple_acp/storage/) (Memory, Redis, PostgreSQL, Custom)
63
+ - [API Reference](https://madbomber.github.io/simple_acp/api/)
64
+
65
+ ## Installation
66
+
67
+ Add this line to your application's Gemfile:
68
+
69
+ ```ruby
70
+ gem 'simple_acp'
71
+ ```
72
+
73
+ Or install it directly:
74
+
75
+ ```bash
76
+ gem install simple_acp
77
+ ```
78
+
79
+ ## Quick Start
80
+
81
+ ### Creating an Agent Server
82
+
83
+ ```ruby
84
+ require 'simple_acp'
85
+
86
+ server = SimpleAcp::Server::Base.new
87
+
88
+ # Register an agent using block syntax
89
+ server.agent("echo", description: "Echoes everything") do |context|
90
+ Enumerator.new do |yielder|
91
+ context.input.each do |message|
92
+ yielder << SimpleAcp::Server::RunYield.new(
93
+ SimpleAcp::Models::Message.agent(message.text_content)
94
+ )
95
+ end
96
+ end
97
+ end
98
+
99
+ # Register a simple greeting agent
100
+ server.agent("greeter", description: "Greets the user") do |context|
101
+ name = context.input.first&.text_content || "World"
102
+ SimpleAcp::Models::Message.agent("Hello, #{name}!")
103
+ end
104
+
105
+ # Start the server
106
+ server.run(port: 8000)
107
+ ```
108
+
109
+ ### Using the Client
110
+
111
+ ```ruby
112
+ require 'simple_acp'
113
+
114
+ client = SimpleAcp::Client::Base.new(base_url: "http://localhost:8000")
115
+
116
+ # List available agents
117
+ agents = client.agents
118
+ puts agents.agents.map(&:name)
119
+
120
+ # Run an agent synchronously
121
+ run = client.run_sync(
122
+ agent: "echo",
123
+ input: [SimpleAcp::Models::Message.user("Hello, SimpleAcp!")]
124
+ )
125
+
126
+ puts run.output.first.text_content
127
+ # => "Hello, SimpleAcp!"
128
+
129
+ # Run with streaming
130
+ client.run_stream(agent: "echo", input: "Streaming test") do |event|
131
+ case event
132
+ when SimpleAcp::Models::MessagePartEvent
133
+ print event.part.content
134
+ when SimpleAcp::Models::RunCompletedEvent
135
+ puts "\nDone!"
136
+ end
137
+ end
138
+ ```
139
+
140
+ ## API Reference
141
+
142
+ ### Server
143
+
144
+ The `SimpleAcp::Server::Base` class hosts agents and handles incoming requests.
145
+
146
+ ```ruby
147
+ server = SimpleAcp::Server::Base.new(storage: SimpleAcp::Storage::Memory.new)
148
+
149
+ # Register agents
150
+ server.agent("name", description: "...", input_content_types: ["text/plain"]) do |context|
151
+ # context.input - array of input messages
152
+ # context.session - current session (if any)
153
+ # context.history - conversation history
154
+ # context.state - session state
155
+ # context.set_state(data) - update session state
156
+ # context.await_message(prompt) - request client input
157
+
158
+ # Return messages or yield them for streaming
159
+ SimpleAcp::Models::Message.agent("Response")
160
+ end
161
+
162
+ # Run programmatically
163
+ run = server.run_sync(agent_name: "name", input: messages)
164
+
165
+ # Or start HTTP server
166
+ server.run(port: 8000)
167
+ ```
168
+
169
+ ### Client
170
+
171
+ The `SimpleAcp::Client::Base` class communicates with ACP servers.
172
+
173
+ ```ruby
174
+ client = SimpleAcp::Client::Base.new(base_url: "http://localhost:8000")
175
+
176
+ # Discovery
177
+ client.ping # Health check
178
+ client.agents # List agents
179
+ client.agent("name") # Get agent manifest
180
+
181
+ # Execution
182
+ client.run_sync(agent: "name", input: messages)
183
+ client.run_async(agent: "name", input: messages)
184
+ client.run_stream(agent: "name", input: messages) { |event| ... }
185
+
186
+ # Run management
187
+ client.run_status(run_id)
188
+ client.run_events(run_id)
189
+ client.run_cancel(run_id)
190
+
191
+ # Resume awaited runs
192
+ client.run_resume_sync(run_id: id, await_resume: resume_payload)
193
+ client.run_resume_stream(run_id: id, await_resume: resume_payload) { |e| ... }
194
+
195
+ # Session management
196
+ client.use_session(session_id)
197
+ client.clear_session
198
+ ```
199
+
200
+ ### Models
201
+
202
+ #### Message
203
+
204
+ ```ruby
205
+ # Create messages
206
+ SimpleAcp::Models::Message.user("Hello")
207
+ SimpleAcp::Models::Message.agent("Response")
208
+
209
+ # With multiple parts
210
+ SimpleAcp::Models::Message.user(
211
+ SimpleAcp::Models::MessagePart.text("Some text"),
212
+ SimpleAcp::Models::MessagePart.json({ key: "value" })
213
+ )
214
+
215
+ # Access content
216
+ message.role # "user" or "agent"
217
+ message.parts # Array of MessagePart
218
+ message.text_content # Combined text from all parts
219
+ ```
220
+
221
+ #### MessagePart
222
+
223
+ ```ruby
224
+ # Factory methods
225
+ SimpleAcp::Models::MessagePart.text("Hello")
226
+ SimpleAcp::Models::MessagePart.json({ key: "value" })
227
+ SimpleAcp::Models::MessagePart.image(base64_data, mime_type: "image/png")
228
+ SimpleAcp::Models::MessagePart.from_url("https://...", content_type: "image/jpeg")
229
+
230
+ # Properties
231
+ part.content_type # MIME type
232
+ part.content # Inline content
233
+ part.content_url # URL reference
234
+ part.content_encoding # "plain" or "base64"
235
+ part.text? # Is text content?
236
+ part.json? # Is JSON content?
237
+ part.image? # Is image content?
238
+ ```
239
+
240
+ #### Run
241
+
242
+ ```ruby
243
+ run.run_id # UUID
244
+ run.agent_name # Agent that executed
245
+ run.status # Current status
246
+ run.output # Output messages
247
+ run.error # Error if failed
248
+ run.session_id # Associated session
249
+
250
+ # Status checks
251
+ run.terminal? # Is in final state?
252
+ run.completed?
253
+ run.failed?
254
+ run.cancelled?
255
+ run.awaiting?
256
+ ```
257
+
258
+ ### Storage Backends
259
+
260
+ #### Memory (Default)
261
+
262
+ ```ruby
263
+ storage = SimpleAcp::Storage::Memory.new
264
+ server = SimpleAcp::Server::Base.new(storage: storage)
265
+ ```
266
+
267
+ #### Redis
268
+
269
+ ```ruby
270
+ require 'simple_acp/storage/redis'
271
+
272
+ storage = SimpleAcp::Storage::Redis.new(
273
+ url: "redis://localhost:6379",
274
+ ttl: 86400 # 24 hours
275
+ )
276
+ server = SimpleAcp::Server::Base.new(storage: storage)
277
+ ```
278
+
279
+ #### PostgreSQL
280
+
281
+ ```ruby
282
+ require 'simple_acp/storage/postgresql'
283
+
284
+ storage = SimpleAcp::Storage::PostgreSQL.new(
285
+ url: "postgres://localhost/simple_acp_production"
286
+ )
287
+ server = SimpleAcp::Server::Base.new(storage: storage)
288
+ ```
289
+
290
+ ## Advanced Usage
291
+
292
+ ### Stateful Agents with Sessions
293
+
294
+ ```ruby
295
+ server.agent("counter") do |context|
296
+ count = (context.state || 0) + 1
297
+ context.set_state(count)
298
+ SimpleAcp::Models::Message.agent("Count: #{count}")
299
+ end
300
+
301
+ # Client maintains session across requests
302
+ client.use_session("my-session")
303
+ client.run_sync(agent: "counter", input: "increment") # Count: 1
304
+ client.run_sync(agent: "counter", input: "increment") # Count: 2
305
+ ```
306
+
307
+ ### Awaiting Client Input
308
+
309
+ ```ruby
310
+ server.agent("questioner") do |context|
311
+ Enumerator.new do |yielder|
312
+ # Ask a question
313
+ result = context.await_message(
314
+ SimpleAcp::Models::Message.agent("What is your name?")
315
+ )
316
+ yielder << result
317
+
318
+ # When resumed, result will contain the client's response
319
+ # This part runs after run_resume is called
320
+ name = context.resume_message&.text_content
321
+ yielder << SimpleAcp::Server::RunYield.new(
322
+ SimpleAcp::Models::Message.agent("Hello, #{name}!")
323
+ )
324
+ end
325
+ end
326
+
327
+ # Client side
328
+ run = client.run_sync(agent: "questioner", input: "start")
329
+ # run.awaiting? => true
330
+
331
+ run = client.run_resume_sync(
332
+ run_id: run.run_id,
333
+ await_resume: SimpleAcp::Models::MessageAwaitResume.new(
334
+ message: SimpleAcp::Models::Message.user("Alice")
335
+ )
336
+ )
337
+ # run.output includes "Hello, Alice!"
338
+ ```
339
+
340
+ ## HTTP API Endpoints
341
+
342
+ When running as an HTTP server, these endpoints are available:
343
+
344
+ - `GET /ping` - Health check
345
+ - `GET /agents` - List agents
346
+ - `GET /agents/:name` - Get agent manifest
347
+ - `POST /runs` - Create a run
348
+ - `GET /runs/:id` - Get run status
349
+ - `POST /runs/:id` - Resume awaited run
350
+ - `POST /runs/:id/cancel` - Cancel run
351
+ - `GET /runs/:id/events` - Get run events
352
+ - `GET /session/:id` - Get session info
353
+
354
+ ## Development
355
+
356
+ ```bash
357
+ # Install dependencies
358
+ bundle install
359
+
360
+ # Run tests
361
+ bundle exec rake test
362
+
363
+ # Run a specific test
364
+ bundle exec ruby -Ilib:test test/simple_acp/models/message_test.rb
365
+ ```
366
+
367
+ ## A Note on ACP as a Standard
368
+
369
+ 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.
370
+
371
+ 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.
372
+
373
+ 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.
374
+
375
+ ## License
376
+
377
+ Apache License 2.0 - See LICENSE file for details.
378
+
379
+ ## Contributing
380
+
381
+ 1. Fork it
382
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
383
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
384
+ 4. Push to the branch (`git push origin my-new-feature`)
385
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rake/testtask"
5
+
6
+ Rake::TestTask.new(:test) do |t|
7
+ t.libs << "test"
8
+ t.libs << "lib"
9
+ t.test_files = FileList["test/**/*_test.rb"]
10
+ t.warning = false
11
+ end
12
+
13
+ task default: :test