acp-sdk 0.1.0 → 0.2.0
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 +4 -4
- data/CHANGELOG.md +10 -0
- data/README.md +43 -31
- data/lib/acp/agent_connection/client.rb +68 -2
- data/lib/acp/agent_connection/optional_method/authenticate.rb +21 -0
- data/lib/acp/agent_connection/optional_method/close_session.rb +21 -0
- data/lib/acp/agent_connection/optional_method/delete_session.rb +21 -0
- data/lib/acp/agent_connection/optional_method/list_sessions.rb +21 -0
- data/lib/acp/agent_connection/optional_method/load_session.rb +21 -0
- data/lib/acp/agent_connection/optional_method/resume_session.rb +21 -0
- data/lib/acp/agent_connection/optional_method.rb +1 -25
- data/lib/acp/agent_connection.rb +39 -26
- data/lib/acp/types.rb +4 -0
- data/lib/acp/version.rb +1 -1
- data/sig/generated/acp/agent_connection/client.rbs +42 -0
- data/sig/generated/acp/agent_connection/optional_method/authenticate.rbs +13 -0
- data/sig/generated/acp/agent_connection/optional_method/close_session.rbs +13 -0
- data/sig/generated/acp/agent_connection/optional_method/delete_session.rbs +13 -0
- data/sig/generated/acp/agent_connection/optional_method/list_sessions.rbs +13 -0
- data/sig/generated/acp/agent_connection/optional_method/load_session.rbs +13 -0
- data/sig/generated/acp/agent_connection/optional_method/resume_session.rbs +13 -0
- data/sig/generated/acp/agent_connection/optional_method.rbs +1 -18
- data/sig/generated/acp/agent_connection.rbs +9 -8
- data/sig/generated/acp/types.rbs +4 -0
- data/sig/manual/acp/agent_connection/optional_method/authenticate.rbs +6 -0
- data/sig/manual/acp/agent_connection/optional_method/close_session.rbs +6 -0
- data/sig/manual/acp/agent_connection/optional_method/delete_session.rbs +6 -0
- data/sig/manual/acp/agent_connection/optional_method/list_sessions.rbs +6 -0
- data/sig/manual/acp/agent_connection/optional_method/load_session.rbs +6 -0
- data/sig/manual/acp/agent_connection/optional_method/resume_session.rbs +6 -0
- data/sig/manual/acp/agent_connection.rbs +49 -0
- metadata +21 -4
- data/sig/manual/acp/types.rbs +0 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4fcba010891683b66eaf2fd2ae8bf9ae27e2aeb13b76666cc8c4478dfb7c4e9a
|
|
4
|
+
data.tar.gz: 5045a772ca2f080a7566ad3556a16087b3d15f4cbd39c3ed0ee5ae4dfe0ab521
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c1a7eb1a2fc03be127272d8e3a97564c014691d1b582bd317f1da7b7022f250d603a09a811ef1271a9133e2bcf2fa5a6c7cde1f7d7ffe8c08a1f37fa28080d71
|
|
7
|
+
data.tar.gz: 4d006a52359dfdde15978220b83b9d7b10251b44c73a66c43be7a4259c0646a559b39ee05b09b1010e6b0108a95945751ad2cf0ffea4c6f9f1be041a0d4efbfa
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.2.0](https://github.com/bottrall/acp-sdk/compare/v0.1.0...v0.2.0) (2026-09-30)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* authenticate on ACP::AgentConnection ([#23](https://github.com/bottrall/acp-sdk/issues/23)) ([aac2bdd](https://github.com/bottrall/acp-sdk/commit/aac2bddbada2108bad3397d8f2c7bcdd617e8e0f))
|
|
9
|
+
* filesystem methods on ACP::AgentConnection::Client ([#20](https://github.com/bottrall/acp-sdk/issues/20)) ([a15d942](https://github.com/bottrall/acp-sdk/commit/a15d942d1fe48cd7042732f64ea6d94cdd191549)), closes [#10](https://github.com/bottrall/acp-sdk/issues/10)
|
|
10
|
+
* optional session methods on ACP::AgentConnection ([#24](https://github.com/bottrall/acp-sdk/issues/24)) ([952f906](https://github.com/bottrall/acp-sdk/commit/952f906e32bf455bac40effeb3d32fa6dea95904))
|
|
11
|
+
* terminal methods on ACP::AgentConnection::Client ([#22](https://github.com/bottrall/acp-sdk/issues/22)) ([b4108b8](https://github.com/bottrall/acp-sdk/commit/b4108b8570a36d78a2c1231c04f7c1f697848318))
|
|
12
|
+
|
|
3
13
|
## 0.1.0 (2026-09-30)
|
|
4
14
|
|
|
5
15
|
|
data/README.md
CHANGED
|
@@ -1,20 +1,43 @@
|
|
|
1
1
|
# acp-sdk
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://rubygems.org/gems/acp-sdk)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
A Ruby SDK for the [Agent Client Protocol](https://agentclientprotocol.com) (ACP). It covers both sides of the protocol:
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
- **Agent side** (`ACP::AgentConnection`): expose your agent to ACP clients such as Zed and JetBrains.
|
|
8
|
+
- **Client side** (`ACP::ClientConnection`): drive ACP agents from Ruby, for an editor integration or for tests.
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
Every ACP request, response and notification is a generated Ruby class under `ACP::Types`, and messages travel as JSON-RPC over stdio. The SDK speaks ACP protocol version 1.
|
|
10
11
|
|
|
11
|
-
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
Requires Ruby 4.0 or later.
|
|
15
|
+
|
|
16
|
+
Add the gem to your Gemfile:
|
|
17
|
+
|
|
18
|
+
```sh
|
|
19
|
+
bundle add acp-sdk
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Or install it directly:
|
|
23
|
+
|
|
24
|
+
```sh
|
|
25
|
+
gem install acp-sdk
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Then require it:
|
|
29
|
+
|
|
30
|
+
```ruby
|
|
31
|
+
require 'acp/sdk'
|
|
32
|
+
```
|
|
12
33
|
|
|
13
34
|
## Serving an agent
|
|
14
35
|
|
|
15
|
-
An agent is a plain Ruby object. `ACP::AgentConnection` answers `initialize` itself, turns each request into its generated `ACP::Types` object, calls the agent, and sends back what it returns. The factory block receives an `ACP::AgentConnection::Client` handle, which the agent keeps for sending session updates
|
|
36
|
+
An agent is a plain Ruby object. `ACP::AgentConnection` answers `initialize` itself, turns each request into its generated `ACP::Types` object, calls the agent, and sends back what it returns. The factory block receives an `ACP::AgentConnection::Client` handle, which the agent keeps for sending session updates, asking permission, reading and writing files, and running commands in terminals.
|
|
16
37
|
|
|
17
38
|
```ruby
|
|
39
|
+
require 'acp/sdk'
|
|
40
|
+
|
|
18
41
|
connection = ACP::AgentConnection.new(
|
|
19
42
|
transport: ACP::Transport::Stdio.new(input: $stdin, output: $stdout),
|
|
20
43
|
capabilities: ACP::Types::AgentCapabilities.new(load_session: true),
|
|
@@ -25,18 +48,25 @@ connection.start.join
|
|
|
25
48
|
|
|
26
49
|
The agent's contract:
|
|
27
50
|
|
|
28
|
-
- It defines `new_session`, `prompt` and `cancel`. `load_session` and `
|
|
51
|
+
- It defines `new_session`, `prompt` and `cancel`. `load_session`, `list_sessions`, `resume_session`, `close_session` and `delete_session` are required only when `capabilities` advertises `load_session` or `session_capabilities.list`, `.resume`, `.close` or `.delete`, and `authenticate` only when `auth_methods` is non-empty; `start` raises `ArgumentError` when one is advertised but missing, and a method that is not advertised is answered with `-32601`. `change_session_mode` and `change_session_config_option` are optional, since modes and config options are offered per session rather than in `initialize`; `session/set_mode` and `session/set_config_option` are answered with `-32601` when the agent does not define them. `session_created`, if defined, runs right after the `session/new` reply is sent.
|
|
29
52
|
- Each request method returns its response type or an `ACP::Transport::ResponseError`, which is sent as the error reply. Params that do not match the schema are answered with `-32602` before the agent sees them.
|
|
30
53
|
- `cancel` runs on the transport's reader thread, so it must return quickly: set a flag and let the prompt notice it.
|
|
31
54
|
- After a cancel, the agent must itself end the turn with `stopReason: cancelled`. `ACP::AgentConnection` does not enforce it.
|
|
32
55
|
- `client.capabilities` is `nil` until the client sends `initialize`.
|
|
56
|
+
- `client.read_text_file` and `client.write_text_file` take an `ACP::Types::ReadTextFileRequest` or `ACP::Types::WriteTextFileRequest` and return the response type or an `ACP::Transport::ResponseError`. Unless `client.capabilities` advertises `fs.read_text_file` or `fs.write_text_file`, they return `-32601` without sending anything to the client.
|
|
57
|
+
- `client.create_terminal`, `client.terminal_output`, `client.wait_for_terminal_exit`, `client.kill_terminal` and `client.release_terminal` take the matching `ACP::Types` request (`CreateTerminalRequest`, `TerminalOutputRequest`, `WaitForTerminalExitRequest`, `KillTerminalRequest`, `ReleaseTerminalRequest`) and return its response type or an `ACP::Transport::ResponseError`. Unless `client.capabilities` advertises `terminal`, they return `-32601` without sending anything to the client. The agent must release every terminal it creates.
|
|
58
|
+
|
|
59
|
+
[`examples/echo_agent.rb`](https://github.com/bottrall/acp-sdk/blob/main/examples/echo_agent.rb) is a complete agent that streams updates, asks permission, handles cancellation, reads and writes files and runs commands through the client (`/read <path>`, `/write <path> <text>` and `/run <command> [args]`, each advertised as a slash command only when the client supports it), and supports `session/load` and `session/list`.
|
|
33
60
|
|
|
34
61
|
## Driving an agent
|
|
35
62
|
|
|
36
|
-
`ACP::ClientConnection` is the other side of the same transport
|
|
63
|
+
`ACP::ClientConnection` is the other side of the same transport. Each method takes the request's generated `ACP::Types` object and returns its response type or the agent's `ACP::Transport::ResponseError`. `connect` sends `initialize`, since Ruby reserves that name for the constructor.
|
|
37
64
|
|
|
38
65
|
```ruby
|
|
39
|
-
|
|
66
|
+
require 'acp/sdk'
|
|
67
|
+
require 'open3'
|
|
68
|
+
|
|
69
|
+
stdin, stdout, = Open3.popen2('my-agent')
|
|
40
70
|
connection = ACP::ClientConnection.new(
|
|
41
71
|
transport: ACP::Transport::Stdio.new(input: stdout, output: stdin),
|
|
42
72
|
permission: ->(request) { ask_the_user(request) },
|
|
@@ -54,28 +84,10 @@ end
|
|
|
54
84
|
- `session_prompt` and `session_load` yield the session's updates on the calling thread as they arrive and return once the agent replies. Updates outside those calls, such as the available commands after `session/new`, go to `updates`, which runs on the reader thread and must return quickly.
|
|
55
85
|
- `permission` answers `session/request_permission` with an `ACP::Types::RequestPermissionResponse` or an `ACP::Transport::ResponseError`. It runs on its own thread, so it may block while the user decides, and `session_cancel` can be sent meanwhile.
|
|
56
86
|
|
|
57
|
-
##
|
|
58
|
-
|
|
59
|
-
Every project chore is a script in `bin/`. The Rakefile behind them is an implementation detail; you never need to call rake directly.
|
|
60
|
-
|
|
61
|
-
| Script | What it does |
|
|
62
|
-
| --------------- | ---------------------------------------------------------------------------------------------- |
|
|
63
|
-
| `bin/setup` | Install dependencies on a fresh checkout (gems + rbs collection) |
|
|
64
|
-
| `bin/test` | Run the test suite. Pass files and/or Minitest flags: `bin/test test/foo_test.rb -n /pattern/` |
|
|
65
|
-
| `bin/lint` | Run RuboCop. Arguments are forwarded, e.g. `bin/lint -a` |
|
|
66
|
-
| `bin/typecheck` | Check `lib/acp/types`, the rbs collection lockfile and `sig/generated` are current, then type-check with Steep |
|
|
67
|
-
| `bin/rbs` | Regenerate `sig/generated` from the inline annotations in `lib/` |
|
|
68
|
-
| `bin/types` | Regenerate `lib/acp/types` from `schema/schema.json`, then `sig/generated` |
|
|
69
|
-
| `bin/rbs-watch` | Regenerate `sig/generated` whenever `lib/` changes |
|
|
70
|
-
| `bin/ci` | Run everything CI runs, serially. Use before pushing |
|
|
71
|
-
| `bin/build` | Build the gem into `pkg/`; the publish workflow runs this before `gem push` |
|
|
72
|
-
|
|
73
|
-
## Releasing
|
|
74
|
-
|
|
75
|
-
PR titles are [conventional commits](https://www.conventionalcommits.org/) and are linted in CI: `feat:` bumps the minor version, `fix:` bumps the patch, and `feat!:` marks a breaking change (also a minor bump while we are on 0.x). `chore:`, `docs:`, `ci:`, `refactor:` and `test:` never release. Squash-merging makes the title the commit on `main`.
|
|
87
|
+
## Contributing
|
|
76
88
|
|
|
77
|
-
[
|
|
89
|
+
Bug reports and pull requests are welcome on [GitHub](https://github.com/bottrall/acp-sdk). See [CONTRIBUTING.md](CONTRIBUTING.md) for setup and workflow. Everyone interacting in the project is expected to follow the [code of conduct](CODE_OF_CONDUCT.md).
|
|
78
90
|
|
|
79
|
-
##
|
|
91
|
+
## License
|
|
80
92
|
|
|
81
|
-
|
|
93
|
+
Released under the [MIT License](LICENSE.txt).
|
|
@@ -33,7 +33,73 @@ class ACP::AgentConnection::Client
|
|
|
33
33
|
# @rbs request: ACP::Types::RequestPermissionRequest
|
|
34
34
|
# @rbs return: ACP::Types::RequestPermissionResponse | ACP::Transport::ResponseError
|
|
35
35
|
def request_permission(request)
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
call('session/request_permission', ACP::Types::RequestPermissionResponse, request)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# @rbs request: ACP::Types::ReadTextFileRequest
|
|
40
|
+
# @rbs return: ACP::Types::ReadTextFileResponse | ACP::Transport::ResponseError
|
|
41
|
+
def read_text_file(request)
|
|
42
|
+
return ACP::Transport::Stdio::METHOD_NOT_FOUND unless capabilities&.fs&.read_text_file
|
|
43
|
+
|
|
44
|
+
call('fs/read_text_file', ACP::Types::ReadTextFileResponse, request)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# @rbs request: ACP::Types::WriteTextFileRequest
|
|
48
|
+
# @rbs return: ACP::Types::WriteTextFileResponse | ACP::Transport::ResponseError
|
|
49
|
+
def write_text_file(request)
|
|
50
|
+
return ACP::Transport::Stdio::METHOD_NOT_FOUND unless capabilities&.fs&.write_text_file
|
|
51
|
+
|
|
52
|
+
call('fs/write_text_file', ACP::Types::WriteTextFileResponse, request)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# @rbs request: ACP::Types::CreateTerminalRequest
|
|
56
|
+
# @rbs return: ACP::Types::CreateTerminalResponse | ACP::Transport::ResponseError
|
|
57
|
+
def create_terminal(request)
|
|
58
|
+
terminal_call('terminal/create', ACP::Types::CreateTerminalResponse, request)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# @rbs request: ACP::Types::TerminalOutputRequest
|
|
62
|
+
# @rbs return: ACP::Types::TerminalOutputResponse | ACP::Transport::ResponseError
|
|
63
|
+
def terminal_output(request)
|
|
64
|
+
terminal_call('terminal/output', ACP::Types::TerminalOutputResponse, request)
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
# @rbs request: ACP::Types::WaitForTerminalExitRequest
|
|
68
|
+
# @rbs return: ACP::Types::WaitForTerminalExitResponse | ACP::Transport::ResponseError
|
|
69
|
+
def wait_for_terminal_exit(request)
|
|
70
|
+
terminal_call('terminal/wait_for_exit', ACP::Types::WaitForTerminalExitResponse, request)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# @rbs request: ACP::Types::KillTerminalRequest
|
|
74
|
+
# @rbs return: ACP::Types::KillTerminalResponse | ACP::Transport::ResponseError
|
|
75
|
+
def kill_terminal(request)
|
|
76
|
+
terminal_call('terminal/kill', ACP::Types::KillTerminalResponse, request)
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
# @rbs request: ACP::Types::ReleaseTerminalRequest
|
|
80
|
+
# @rbs return: ACP::Types::ReleaseTerminalResponse | ACP::Transport::ResponseError
|
|
81
|
+
def release_terminal(request)
|
|
82
|
+
terminal_call('terminal/release', ACP::Types::ReleaseTerminalResponse, request)
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
private
|
|
86
|
+
|
|
87
|
+
# @rbs rpc_method: String
|
|
88
|
+
# @rbs type: ACP::AgentConnection::_Parser
|
|
89
|
+
# @rbs request: ACP::AgentConnection::_Response
|
|
90
|
+
# @rbs return: untyped
|
|
91
|
+
def call(rpc_method, type, request)
|
|
92
|
+
result = @peer.request(rpc_method, request.to_h)
|
|
93
|
+
result.error || type.from_h(result.value)
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
# @rbs rpc_method: String
|
|
97
|
+
# @rbs type: ACP::AgentConnection::_Parser
|
|
98
|
+
# @rbs request: ACP::AgentConnection::_Response
|
|
99
|
+
# @rbs return: untyped
|
|
100
|
+
def terminal_call(rpc_method, type, request)
|
|
101
|
+
return ACP::Transport::Stdio::METHOD_NOT_FOUND unless capabilities&.terminal
|
|
102
|
+
|
|
103
|
+
call(rpc_method, type, request)
|
|
38
104
|
end
|
|
39
105
|
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module ACP::AgentConnection::OptionalMethod::Authenticate
|
|
4
|
+
extend self
|
|
5
|
+
|
|
6
|
+
# @rbs return: String
|
|
7
|
+
def rpc_method
|
|
8
|
+
'authenticate'
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
# @rbs return: Symbol
|
|
12
|
+
def agent_method
|
|
13
|
+
:authenticate
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# @rbs initialize_response: ACP::Types::InitializeResponse
|
|
17
|
+
# @rbs return: bool
|
|
18
|
+
def advertised?(initialize_response)
|
|
19
|
+
initialize_response.auth_methods&.any? || false
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module ACP::AgentConnection::OptionalMethod::CloseSession
|
|
4
|
+
extend self
|
|
5
|
+
|
|
6
|
+
# @rbs return: String
|
|
7
|
+
def rpc_method
|
|
8
|
+
'session/close'
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
# @rbs return: Symbol
|
|
12
|
+
def agent_method
|
|
13
|
+
:close_session
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# @rbs initialize_response: ACP::Types::InitializeResponse
|
|
17
|
+
# @rbs return: bool
|
|
18
|
+
def advertised?(initialize_response)
|
|
19
|
+
initialize_response.agent_capabilities&.session_capabilities&.close ? true : false
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module ACP::AgentConnection::OptionalMethod::DeleteSession
|
|
4
|
+
extend self
|
|
5
|
+
|
|
6
|
+
# @rbs return: String
|
|
7
|
+
def rpc_method
|
|
8
|
+
'session/delete'
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
# @rbs return: Symbol
|
|
12
|
+
def agent_method
|
|
13
|
+
:delete_session
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# @rbs initialize_response: ACP::Types::InitializeResponse
|
|
17
|
+
# @rbs return: bool
|
|
18
|
+
def advertised?(initialize_response)
|
|
19
|
+
initialize_response.agent_capabilities&.session_capabilities&.delete ? true : false
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module ACP::AgentConnection::OptionalMethod::ListSessions
|
|
4
|
+
extend self
|
|
5
|
+
|
|
6
|
+
# @rbs return: String
|
|
7
|
+
def rpc_method
|
|
8
|
+
'session/list'
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
# @rbs return: Symbol
|
|
12
|
+
def agent_method
|
|
13
|
+
:list_sessions
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# @rbs initialize_response: ACP::Types::InitializeResponse
|
|
17
|
+
# @rbs return: bool
|
|
18
|
+
def advertised?(initialize_response)
|
|
19
|
+
initialize_response.agent_capabilities&.session_capabilities&.list ? true : false
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module ACP::AgentConnection::OptionalMethod::LoadSession
|
|
4
|
+
extend self
|
|
5
|
+
|
|
6
|
+
# @rbs return: String
|
|
7
|
+
def rpc_method
|
|
8
|
+
'session/load'
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
# @rbs return: Symbol
|
|
12
|
+
def agent_method
|
|
13
|
+
:load_session
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# @rbs initialize_response: ACP::Types::InitializeResponse
|
|
17
|
+
# @rbs return: bool
|
|
18
|
+
def advertised?(initialize_response)
|
|
19
|
+
initialize_response.agent_capabilities&.load_session ? true : false
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module ACP::AgentConnection::OptionalMethod::ResumeSession
|
|
4
|
+
extend self
|
|
5
|
+
|
|
6
|
+
# @rbs return: String
|
|
7
|
+
def rpc_method
|
|
8
|
+
'session/resume'
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
# @rbs return: Symbol
|
|
12
|
+
def agent_method
|
|
13
|
+
:resume_session
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# @rbs initialize_response: ACP::Types::InitializeResponse
|
|
17
|
+
# @rbs return: bool
|
|
18
|
+
def advertised?(initialize_response)
|
|
19
|
+
initialize_response.agent_capabilities&.session_capabilities&.resume ? true : false
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -1,28 +1,4 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
# @rbs @capability: ^(ACP::Types::AgentCapabilities) -> boolish
|
|
5
|
-
|
|
6
|
-
# @dynamic rpc_method
|
|
7
|
-
attr_reader :rpc_method #: String
|
|
8
|
-
|
|
9
|
-
# @dynamic agent_method
|
|
10
|
-
attr_reader :agent_method #: Symbol
|
|
11
|
-
|
|
12
|
-
# @rbs rpc_method: String
|
|
13
|
-
# @rbs agent_method: Symbol
|
|
14
|
-
# @rbs &capability: (ACP::Types::AgentCapabilities) -> boolish
|
|
15
|
-
# @rbs return: void
|
|
16
|
-
def initialize(rpc_method:, agent_method:, &capability)
|
|
17
|
-
@rpc_method = rpc_method
|
|
18
|
-
@agent_method = agent_method
|
|
19
|
-
@capability = capability
|
|
20
|
-
freeze
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
# @rbs capabilities: ACP::Types::AgentCapabilities
|
|
24
|
-
# @rbs return: bool
|
|
25
|
-
def advertised?(capabilities)
|
|
26
|
-
@capability.call(capabilities) ? true : false
|
|
27
|
-
end
|
|
3
|
+
module ACP::AgentConnection::OptionalMethod
|
|
28
4
|
end
|
data/lib/acp/agent_connection.rb
CHANGED
|
@@ -2,19 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
class ACP::AgentConnection
|
|
4
4
|
# @rbs @transport: ACP::AgentConnection::_Transport
|
|
5
|
-
# @rbs @
|
|
6
|
-
# @rbs @agent_info: ACP::Types::Implementation?
|
|
7
|
-
# @rbs @auth_methods: Array[ACP::Types::AuthMethod::t]
|
|
5
|
+
# @rbs @initialize_response: ACP::Types::InitializeResponse
|
|
8
6
|
# @rbs @factory: ^(ACP::AgentConnection::Client) -> ACP::AgentConnection::_Agent
|
|
9
7
|
|
|
10
8
|
PROTOCOL_VERSION = 1 #: Integer
|
|
11
9
|
INVALID_PARAMS = ACP::Transport::ResponseError.new(code: -32_602, message: 'Invalid params') #: ACP::Transport::ResponseError
|
|
12
10
|
OPTIONAL = [
|
|
13
|
-
ACP::AgentConnection::OptionalMethod
|
|
14
|
-
ACP::AgentConnection::OptionalMethod
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
ACP::AgentConnection::OptionalMethod::LoadSession,
|
|
12
|
+
ACP::AgentConnection::OptionalMethod::ListSessions,
|
|
13
|
+
ACP::AgentConnection::OptionalMethod::Authenticate,
|
|
14
|
+
ACP::AgentConnection::OptionalMethod::ResumeSession,
|
|
15
|
+
ACP::AgentConnection::OptionalMethod::CloseSession,
|
|
16
|
+
ACP::AgentConnection::OptionalMethod::DeleteSession
|
|
17
|
+
].freeze #: Array[ACP::AgentConnection::_OptionalMethod]
|
|
18
|
+
# The schema has no initialize capability for modes or config options: an
|
|
19
|
+
# agent offers them per session, in its session responses, so they are
|
|
20
|
+
# routed whenever the agent defines them.
|
|
21
|
+
PER_SESSION = {
|
|
22
|
+
'session/set_mode' => :change_session_mode,
|
|
23
|
+
'session/set_config_option' => :change_session_config_option
|
|
24
|
+
}.freeze #: Hash[String, Symbol]
|
|
18
25
|
|
|
19
26
|
# @rbs transport: ACP::AgentConnection::_Transport
|
|
20
27
|
# @rbs capabilities: ACP::Types::AgentCapabilities
|
|
@@ -24,9 +31,12 @@ class ACP::AgentConnection
|
|
|
24
31
|
# @rbs return: void
|
|
25
32
|
def initialize(transport:, capabilities:, agent_info: nil, auth_methods: [], &factory)
|
|
26
33
|
@transport = transport
|
|
27
|
-
@
|
|
28
|
-
|
|
29
|
-
|
|
34
|
+
@initialize_response = ACP::Types::InitializeResponse.new(
|
|
35
|
+
protocol_version: PROTOCOL_VERSION,
|
|
36
|
+
agent_capabilities: capabilities,
|
|
37
|
+
auth_methods:,
|
|
38
|
+
agent_info:
|
|
39
|
+
)
|
|
30
40
|
@factory = factory
|
|
31
41
|
end
|
|
32
42
|
|
|
@@ -34,11 +44,11 @@ class ACP::AgentConnection
|
|
|
34
44
|
def start
|
|
35
45
|
client = ACP::AgentConnection::Client.new(peer: @transport)
|
|
36
46
|
agent = @factory.call(client)
|
|
37
|
-
advertised, unadvertised = OPTIONAL.partition { |method| method.advertised?(@
|
|
47
|
+
advertised, unadvertised = OPTIONAL.partition { |method| method.advertised?(@initialize_response) }
|
|
38
48
|
missing = advertised.map(&:agent_method).reject { |name| agent.respond_to?(name) }
|
|
39
|
-
raise ArgumentError, "
|
|
49
|
+
raise ArgumentError, "initialize advertises methods the agent lacks: #{missing.join(', ')}" unless missing.empty?
|
|
40
50
|
|
|
41
|
-
unrouted = unadvertised.map(&:rpc_method)
|
|
51
|
+
unrouted = unadvertised.map(&:rpc_method) + PER_SESSION.reject { |_, name| agent.respond_to?(name) }.keys
|
|
42
52
|
@transport.start(requests: requests(agent, client).except(*unrouted), notifications: notifications(agent))
|
|
43
53
|
end
|
|
44
54
|
|
|
@@ -48,15 +58,25 @@ class ACP::AgentConnection
|
|
|
48
58
|
# @rbs client: ACP::AgentConnection::Client
|
|
49
59
|
# @rbs return: Hash[String, ^(untyped) -> (ACP::Transport::Result | ACP::Transport::Reply)]
|
|
50
60
|
def requests(agent, client)
|
|
51
|
-
# Safe: start drops the
|
|
52
|
-
#
|
|
53
|
-
full = agent #: ACP::AgentConnection::
|
|
61
|
+
# Safe: start drops the optional handlers initialize does not advertise
|
|
62
|
+
# or the agent does not define, and checks the agent defines the rest.
|
|
63
|
+
full = agent #: ACP::AgentConnection::_FullAgent
|
|
54
64
|
{
|
|
55
65
|
'initialize' => route(ACP::Types::InitializeRequest) { |request| connect(client, request) },
|
|
66
|
+
'authenticate' => route(ACP::Types::AuthenticateRequest) { |request| respond(full.authenticate(request)) },
|
|
56
67
|
'session/new' => route(ACP::Types::NewSessionRequest) { |request| new_session(agent, request) },
|
|
57
68
|
'session/prompt' => route(ACP::Types::PromptRequest) { |request| respond(agent.prompt(request)) },
|
|
58
69
|
'session/load' => route(ACP::Types::LoadSessionRequest) { |request| respond(full.load_session(request)) },
|
|
59
|
-
'session/list' => route(ACP::Types::ListSessionsRequest) { |request| respond(full.list_sessions(request)) }
|
|
70
|
+
'session/list' => route(ACP::Types::ListSessionsRequest) { |request| respond(full.list_sessions(request)) },
|
|
71
|
+
'session/resume' => route(ACP::Types::ResumeSessionRequest) { |request| respond(full.resume_session(request)) },
|
|
72
|
+
'session/close' => route(ACP::Types::CloseSessionRequest) { |request| respond(full.close_session(request)) },
|
|
73
|
+
'session/delete' => route(ACP::Types::DeleteSessionRequest) { |request| respond(full.delete_session(request)) },
|
|
74
|
+
'session/set_mode' => route(ACP::Types::SetSessionModeRequest) do |request|
|
|
75
|
+
respond(full.change_session_mode(request))
|
|
76
|
+
end,
|
|
77
|
+
'session/set_config_option' => route(ACP::Types::SetSessionConfigOptionRequest) do |request|
|
|
78
|
+
respond(full.change_session_config_option(request))
|
|
79
|
+
end
|
|
60
80
|
}
|
|
61
81
|
end
|
|
62
82
|
|
|
@@ -95,14 +115,7 @@ class ACP::AgentConnection
|
|
|
95
115
|
# @rbs return: ACP::Transport::Result
|
|
96
116
|
def connect(client, request)
|
|
97
117
|
client.capabilities = request.client_capabilities || ACP::Types::ClientCapabilities.new
|
|
98
|
-
respond(
|
|
99
|
-
ACP::Types::InitializeResponse.new(
|
|
100
|
-
protocol_version: PROTOCOL_VERSION,
|
|
101
|
-
agent_capabilities: @capabilities,
|
|
102
|
-
auth_methods: @auth_methods,
|
|
103
|
-
agent_info: @agent_info
|
|
104
|
-
)
|
|
105
|
-
)
|
|
118
|
+
respond(@initialize_response)
|
|
106
119
|
end
|
|
107
120
|
|
|
108
121
|
# session_created runs after the reply because the client must know the
|
data/lib/acp/types.rb
ADDED
data/lib/acp/version.rb
CHANGED
|
@@ -26,4 +26,46 @@ class ACP::AgentConnection::Client
|
|
|
26
26
|
# @rbs request: ACP::Types::RequestPermissionRequest
|
|
27
27
|
# @rbs return: ACP::Types::RequestPermissionResponse | ACP::Transport::ResponseError
|
|
28
28
|
def request_permission: (ACP::Types::RequestPermissionRequest request) -> (ACP::Types::RequestPermissionResponse | ACP::Transport::ResponseError)
|
|
29
|
+
|
|
30
|
+
# @rbs request: ACP::Types::ReadTextFileRequest
|
|
31
|
+
# @rbs return: ACP::Types::ReadTextFileResponse | ACP::Transport::ResponseError
|
|
32
|
+
def read_text_file: (ACP::Types::ReadTextFileRequest request) -> (ACP::Types::ReadTextFileResponse | ACP::Transport::ResponseError)
|
|
33
|
+
|
|
34
|
+
# @rbs request: ACP::Types::WriteTextFileRequest
|
|
35
|
+
# @rbs return: ACP::Types::WriteTextFileResponse | ACP::Transport::ResponseError
|
|
36
|
+
def write_text_file: (ACP::Types::WriteTextFileRequest request) -> (ACP::Types::WriteTextFileResponse | ACP::Transport::ResponseError)
|
|
37
|
+
|
|
38
|
+
# @rbs request: ACP::Types::CreateTerminalRequest
|
|
39
|
+
# @rbs return: ACP::Types::CreateTerminalResponse | ACP::Transport::ResponseError
|
|
40
|
+
def create_terminal: (ACP::Types::CreateTerminalRequest request) -> (ACP::Types::CreateTerminalResponse | ACP::Transport::ResponseError)
|
|
41
|
+
|
|
42
|
+
# @rbs request: ACP::Types::TerminalOutputRequest
|
|
43
|
+
# @rbs return: ACP::Types::TerminalOutputResponse | ACP::Transport::ResponseError
|
|
44
|
+
def terminal_output: (ACP::Types::TerminalOutputRequest request) -> (ACP::Types::TerminalOutputResponse | ACP::Transport::ResponseError)
|
|
45
|
+
|
|
46
|
+
# @rbs request: ACP::Types::WaitForTerminalExitRequest
|
|
47
|
+
# @rbs return: ACP::Types::WaitForTerminalExitResponse | ACP::Transport::ResponseError
|
|
48
|
+
def wait_for_terminal_exit: (ACP::Types::WaitForTerminalExitRequest request) -> (ACP::Types::WaitForTerminalExitResponse | ACP::Transport::ResponseError)
|
|
49
|
+
|
|
50
|
+
# @rbs request: ACP::Types::KillTerminalRequest
|
|
51
|
+
# @rbs return: ACP::Types::KillTerminalResponse | ACP::Transport::ResponseError
|
|
52
|
+
def kill_terminal: (ACP::Types::KillTerminalRequest request) -> (ACP::Types::KillTerminalResponse | ACP::Transport::ResponseError)
|
|
53
|
+
|
|
54
|
+
# @rbs request: ACP::Types::ReleaseTerminalRequest
|
|
55
|
+
# @rbs return: ACP::Types::ReleaseTerminalResponse | ACP::Transport::ResponseError
|
|
56
|
+
def release_terminal: (ACP::Types::ReleaseTerminalRequest request) -> (ACP::Types::ReleaseTerminalResponse | ACP::Transport::ResponseError)
|
|
57
|
+
|
|
58
|
+
private
|
|
59
|
+
|
|
60
|
+
# @rbs rpc_method: String
|
|
61
|
+
# @rbs type: ACP::AgentConnection::_Parser
|
|
62
|
+
# @rbs request: ACP::AgentConnection::_Response
|
|
63
|
+
# @rbs return: untyped
|
|
64
|
+
def call: (String rpc_method, ACP::AgentConnection::_Parser type, ACP::AgentConnection::_Response request) -> untyped
|
|
65
|
+
|
|
66
|
+
# @rbs rpc_method: String
|
|
67
|
+
# @rbs type: ACP::AgentConnection::_Parser
|
|
68
|
+
# @rbs request: ACP::AgentConnection::_Response
|
|
69
|
+
# @rbs return: untyped
|
|
70
|
+
def terminal_call: (String rpc_method, ACP::AgentConnection::_Parser type, ACP::AgentConnection::_Response request) -> untyped
|
|
29
71
|
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Generated from lib/acp/agent_connection/optional_method/authenticate.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module ACP::AgentConnection::OptionalMethod::Authenticate
|
|
4
|
+
# @rbs return: String
|
|
5
|
+
def rpc_method: () -> String
|
|
6
|
+
|
|
7
|
+
# @rbs return: Symbol
|
|
8
|
+
def agent_method: () -> Symbol
|
|
9
|
+
|
|
10
|
+
# @rbs initialize_response: ACP::Types::InitializeResponse
|
|
11
|
+
# @rbs return: bool
|
|
12
|
+
def advertised?: (ACP::Types::InitializeResponse initialize_response) -> bool
|
|
13
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Generated from lib/acp/agent_connection/optional_method/close_session.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module ACP::AgentConnection::OptionalMethod::CloseSession
|
|
4
|
+
# @rbs return: String
|
|
5
|
+
def rpc_method: () -> String
|
|
6
|
+
|
|
7
|
+
# @rbs return: Symbol
|
|
8
|
+
def agent_method: () -> Symbol
|
|
9
|
+
|
|
10
|
+
# @rbs initialize_response: ACP::Types::InitializeResponse
|
|
11
|
+
# @rbs return: bool
|
|
12
|
+
def advertised?: (ACP::Types::InitializeResponse initialize_response) -> bool
|
|
13
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Generated from lib/acp/agent_connection/optional_method/delete_session.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module ACP::AgentConnection::OptionalMethod::DeleteSession
|
|
4
|
+
# @rbs return: String
|
|
5
|
+
def rpc_method: () -> String
|
|
6
|
+
|
|
7
|
+
# @rbs return: Symbol
|
|
8
|
+
def agent_method: () -> Symbol
|
|
9
|
+
|
|
10
|
+
# @rbs initialize_response: ACP::Types::InitializeResponse
|
|
11
|
+
# @rbs return: bool
|
|
12
|
+
def advertised?: (ACP::Types::InitializeResponse initialize_response) -> bool
|
|
13
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Generated from lib/acp/agent_connection/optional_method/list_sessions.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module ACP::AgentConnection::OptionalMethod::ListSessions
|
|
4
|
+
# @rbs return: String
|
|
5
|
+
def rpc_method: () -> String
|
|
6
|
+
|
|
7
|
+
# @rbs return: Symbol
|
|
8
|
+
def agent_method: () -> Symbol
|
|
9
|
+
|
|
10
|
+
# @rbs initialize_response: ACP::Types::InitializeResponse
|
|
11
|
+
# @rbs return: bool
|
|
12
|
+
def advertised?: (ACP::Types::InitializeResponse initialize_response) -> bool
|
|
13
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Generated from lib/acp/agent_connection/optional_method/load_session.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module ACP::AgentConnection::OptionalMethod::LoadSession
|
|
4
|
+
# @rbs return: String
|
|
5
|
+
def rpc_method: () -> String
|
|
6
|
+
|
|
7
|
+
# @rbs return: Symbol
|
|
8
|
+
def agent_method: () -> Symbol
|
|
9
|
+
|
|
10
|
+
# @rbs initialize_response: ACP::Types::InitializeResponse
|
|
11
|
+
# @rbs return: bool
|
|
12
|
+
def advertised?: (ACP::Types::InitializeResponse initialize_response) -> bool
|
|
13
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Generated from lib/acp/agent_connection/optional_method/resume_session.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module ACP::AgentConnection::OptionalMethod::ResumeSession
|
|
4
|
+
# @rbs return: String
|
|
5
|
+
def rpc_method: () -> String
|
|
6
|
+
|
|
7
|
+
# @rbs return: Symbol
|
|
8
|
+
def agent_method: () -> Symbol
|
|
9
|
+
|
|
10
|
+
# @rbs initialize_response: ACP::Types::InitializeResponse
|
|
11
|
+
# @rbs return: bool
|
|
12
|
+
def advertised?: (ACP::Types::InitializeResponse initialize_response) -> bool
|
|
13
|
+
end
|
|
@@ -1,21 +1,4 @@
|
|
|
1
1
|
# Generated from lib/acp/agent_connection/optional_method.rb with RBS::Inline
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
@capability: ^(ACP::Types::AgentCapabilities) -> boolish
|
|
5
|
-
|
|
6
|
-
# @dynamic rpc_method
|
|
7
|
-
attr_reader rpc_method: String
|
|
8
|
-
|
|
9
|
-
# @dynamic agent_method
|
|
10
|
-
attr_reader agent_method: Symbol
|
|
11
|
-
|
|
12
|
-
# @rbs rpc_method: String
|
|
13
|
-
# @rbs agent_method: Symbol
|
|
14
|
-
# @rbs &capability: (ACP::Types::AgentCapabilities) -> boolish
|
|
15
|
-
# @rbs return: void
|
|
16
|
-
def initialize: (rpc_method: String, agent_method: Symbol) { (ACP::Types::AgentCapabilities) -> boolish } -> void
|
|
17
|
-
|
|
18
|
-
# @rbs capabilities: ACP::Types::AgentCapabilities
|
|
19
|
-
# @rbs return: bool
|
|
20
|
-
def advertised?: (ACP::Types::AgentCapabilities capabilities) -> bool
|
|
3
|
+
module ACP::AgentConnection::OptionalMethod
|
|
21
4
|
end
|
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
# Generated from lib/acp/agent_connection.rb with RBS::Inline
|
|
2
2
|
|
|
3
3
|
class ACP::AgentConnection
|
|
4
|
-
@
|
|
5
|
-
|
|
6
|
-
@auth_methods: Array[ACP::Types::AuthMethod::t]
|
|
7
|
-
|
|
8
|
-
@agent_info: ACP::Types::Implementation?
|
|
4
|
+
@transport: ACP::AgentConnection::_Transport
|
|
9
5
|
|
|
10
|
-
@
|
|
6
|
+
@initialize_response: ACP::Types::InitializeResponse
|
|
11
7
|
|
|
12
|
-
@
|
|
8
|
+
@factory: ^(ACP::AgentConnection::Client) -> ACP::AgentConnection::_Agent
|
|
13
9
|
|
|
14
10
|
PROTOCOL_VERSION: Integer
|
|
15
11
|
|
|
16
12
|
INVALID_PARAMS: ACP::Transport::ResponseError
|
|
17
13
|
|
|
18
|
-
OPTIONAL: Array[ACP::AgentConnection::
|
|
14
|
+
OPTIONAL: Array[ACP::AgentConnection::_OptionalMethod]
|
|
15
|
+
|
|
16
|
+
# The schema has no initialize capability for modes or config options: an
|
|
17
|
+
# agent offers them per session, in its session responses, so they are
|
|
18
|
+
# routed whenever the agent defines them.
|
|
19
|
+
PER_SESSION: Hash[String, Symbol]
|
|
19
20
|
|
|
20
21
|
# @rbs transport: ACP::AgentConnection::_Transport
|
|
21
22
|
# @rbs capabilities: ACP::Types::AgentCapabilities
|
|
@@ -16,6 +16,48 @@ class ACP::AgentConnection
|
|
|
16
16
|
def list_sessions: (ACP::Types::ListSessionsRequest) -> (ACP::Types::ListSessionsResponse | ACP::Transport::ResponseError)
|
|
17
17
|
end
|
|
18
18
|
|
|
19
|
+
interface _Authenticate
|
|
20
|
+
def authenticate: (ACP::Types::AuthenticateRequest) -> (ACP::Types::AuthenticateResponse | ACP::Transport::ResponseError)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
interface _ResumeSession
|
|
24
|
+
def resume_session: (ACP::Types::ResumeSessionRequest) -> (ACP::Types::ResumeSessionResponse | ACP::Transport::ResponseError)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
interface _CloseSession
|
|
28
|
+
def close_session: (ACP::Types::CloseSessionRequest) -> (ACP::Types::CloseSessionResponse | ACP::Transport::ResponseError)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
interface _DeleteSession
|
|
32
|
+
def delete_session: (ACP::Types::DeleteSessionRequest) -> (ACP::Types::DeleteSessionResponse | ACP::Transport::ResponseError)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
interface _ChangeSessionMode
|
|
36
|
+
def change_session_mode: (ACP::Types::SetSessionModeRequest) -> (ACP::Types::SetSessionModeResponse | ACP::Transport::ResponseError)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
interface _ChangeSessionConfigOption
|
|
40
|
+
def change_session_config_option: (ACP::Types::SetSessionConfigOptionRequest) -> (ACP::Types::SetSessionConfigOptionResponse | ACP::Transport::ResponseError)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
interface _FullAgent
|
|
44
|
+
include _Agent
|
|
45
|
+
include _LoadSession
|
|
46
|
+
include _ListSessions
|
|
47
|
+
include _Authenticate
|
|
48
|
+
include _ResumeSession
|
|
49
|
+
include _CloseSession
|
|
50
|
+
include _DeleteSession
|
|
51
|
+
include _ChangeSessionMode
|
|
52
|
+
include _ChangeSessionConfigOption
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
interface _OptionalMethod
|
|
56
|
+
def rpc_method: () -> String
|
|
57
|
+
def agent_method: () -> Symbol
|
|
58
|
+
def advertised?: (ACP::Types::InitializeResponse) -> bool
|
|
59
|
+
end
|
|
60
|
+
|
|
19
61
|
interface _SessionCreated
|
|
20
62
|
def session_created: (ACP::Types::NewSessionResponse) -> void
|
|
21
63
|
end
|
|
@@ -25,6 +67,13 @@ class ACP::AgentConnection
|
|
|
25
67
|
def update: (String session_id, ACP::Types::SessionUpdate::t update) -> void
|
|
26
68
|
def available_commands: (String session_id, Array[ACP::Types::AvailableCommand] commands) -> void
|
|
27
69
|
def request_permission: (ACP::Types::RequestPermissionRequest) -> (ACP::Types::RequestPermissionResponse | ACP::Transport::ResponseError)
|
|
70
|
+
def read_text_file: (ACP::Types::ReadTextFileRequest) -> (ACP::Types::ReadTextFileResponse | ACP::Transport::ResponseError)
|
|
71
|
+
def write_text_file: (ACP::Types::WriteTextFileRequest) -> (ACP::Types::WriteTextFileResponse | ACP::Transport::ResponseError)
|
|
72
|
+
def create_terminal: (ACP::Types::CreateTerminalRequest) -> (ACP::Types::CreateTerminalResponse | ACP::Transport::ResponseError)
|
|
73
|
+
def terminal_output: (ACP::Types::TerminalOutputRequest) -> (ACP::Types::TerminalOutputResponse | ACP::Transport::ResponseError)
|
|
74
|
+
def wait_for_terminal_exit: (ACP::Types::WaitForTerminalExitRequest) -> (ACP::Types::WaitForTerminalExitResponse | ACP::Transport::ResponseError)
|
|
75
|
+
def kill_terminal: (ACP::Types::KillTerminalRequest) -> (ACP::Types::KillTerminalResponse | ACP::Transport::ResponseError)
|
|
76
|
+
def release_terminal: (ACP::Types::ReleaseTerminalRequest) -> (ACP::Types::ReleaseTerminalResponse | ACP::Transport::ResponseError)
|
|
28
77
|
def capabilities: () -> ACP::Types::ClientCapabilities?
|
|
29
78
|
end
|
|
30
79
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: acp-sdk
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jake Bottrall
|
|
@@ -23,8 +23,6 @@ dependencies:
|
|
|
23
23
|
- - "~>"
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
25
|
version: '2.8'
|
|
26
|
-
description: An Agent Client Protocol (ACP) server for exposing agents and a client
|
|
27
|
-
for driving them.
|
|
28
26
|
email:
|
|
29
27
|
- jakebottrall@gmail.com
|
|
30
28
|
executables: []
|
|
@@ -37,6 +35,12 @@ files:
|
|
|
37
35
|
- lib/acp/agent_connection.rb
|
|
38
36
|
- lib/acp/agent_connection/client.rb
|
|
39
37
|
- lib/acp/agent_connection/optional_method.rb
|
|
38
|
+
- lib/acp/agent_connection/optional_method/authenticate.rb
|
|
39
|
+
- lib/acp/agent_connection/optional_method/close_session.rb
|
|
40
|
+
- lib/acp/agent_connection/optional_method/delete_session.rb
|
|
41
|
+
- lib/acp/agent_connection/optional_method/list_sessions.rb
|
|
42
|
+
- lib/acp/agent_connection/optional_method/load_session.rb
|
|
43
|
+
- lib/acp/agent_connection/optional_method/resume_session.rb
|
|
40
44
|
- lib/acp/client_connection.rb
|
|
41
45
|
- lib/acp/sdk.rb
|
|
42
46
|
- lib/acp/transport.rb
|
|
@@ -44,6 +48,7 @@ files:
|
|
|
44
48
|
- lib/acp/transport/response_error.rb
|
|
45
49
|
- lib/acp/transport/result.rb
|
|
46
50
|
- lib/acp/transport/stdio.rb
|
|
51
|
+
- lib/acp/types.rb
|
|
47
52
|
- lib/acp/types/agent_auth_capabilities.rb
|
|
48
53
|
- lib/acp/types/agent_capabilities.rb
|
|
49
54
|
- lib/acp/types/annotations.rb
|
|
@@ -243,6 +248,12 @@ files:
|
|
|
243
248
|
- sig/generated/acp/agent_connection.rbs
|
|
244
249
|
- sig/generated/acp/agent_connection/client.rbs
|
|
245
250
|
- sig/generated/acp/agent_connection/optional_method.rbs
|
|
251
|
+
- sig/generated/acp/agent_connection/optional_method/authenticate.rbs
|
|
252
|
+
- sig/generated/acp/agent_connection/optional_method/close_session.rbs
|
|
253
|
+
- sig/generated/acp/agent_connection/optional_method/delete_session.rbs
|
|
254
|
+
- sig/generated/acp/agent_connection/optional_method/list_sessions.rbs
|
|
255
|
+
- sig/generated/acp/agent_connection/optional_method/load_session.rbs
|
|
256
|
+
- sig/generated/acp/agent_connection/optional_method/resume_session.rbs
|
|
246
257
|
- sig/generated/acp/client_connection.rbs
|
|
247
258
|
- sig/generated/acp/sdk.rbs
|
|
248
259
|
- sig/generated/acp/transport.rbs
|
|
@@ -250,6 +261,7 @@ files:
|
|
|
250
261
|
- sig/generated/acp/transport/response_error.rbs
|
|
251
262
|
- sig/generated/acp/transport/result.rbs
|
|
252
263
|
- sig/generated/acp/transport/stdio.rbs
|
|
264
|
+
- sig/generated/acp/types.rbs
|
|
253
265
|
- sig/generated/acp/types/agent_auth_capabilities.rbs
|
|
254
266
|
- sig/generated/acp/types/agent_capabilities.rbs
|
|
255
267
|
- sig/generated/acp/types/annotations.rbs
|
|
@@ -447,9 +459,14 @@ files:
|
|
|
447
459
|
- sig/generated/acp/types/write_text_file_response.rbs
|
|
448
460
|
- sig/generated/acp/version.rbs
|
|
449
461
|
- sig/manual/acp/agent_connection.rbs
|
|
462
|
+
- sig/manual/acp/agent_connection/optional_method/authenticate.rbs
|
|
463
|
+
- sig/manual/acp/agent_connection/optional_method/close_session.rbs
|
|
464
|
+
- sig/manual/acp/agent_connection/optional_method/delete_session.rbs
|
|
465
|
+
- sig/manual/acp/agent_connection/optional_method/list_sessions.rbs
|
|
466
|
+
- sig/manual/acp/agent_connection/optional_method/load_session.rbs
|
|
467
|
+
- sig/manual/acp/agent_connection/optional_method/resume_session.rbs
|
|
450
468
|
- sig/manual/acp/client_connection.rbs
|
|
451
469
|
- sig/manual/acp/transport/stdio.rbs
|
|
452
|
-
- sig/manual/acp/types.rbs
|
|
453
470
|
homepage: https://github.com/bottrall/acp-sdk
|
|
454
471
|
licenses:
|
|
455
472
|
- MIT
|
data/sig/manual/acp/types.rbs
DELETED