acp-sdk 0.2.0 → 0.4.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.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +21 -0
  3. data/README.md +29 -16
  4. data/lib/acp/agent_connection/client.rb +27 -12
  5. data/lib/acp/agent_connection/optional_method/logout.rb +21 -0
  6. data/lib/acp/agent_connection.rb +21 -32
  7. data/lib/acp/agent_process.rb +119 -0
  8. data/lib/acp/client_connection.rb +15 -15
  9. data/lib/acp/request_error.rb +90 -0
  10. data/lib/acp/transport/reply.rb +4 -4
  11. data/lib/acp/transport/stdio.rb +28 -25
  12. data/lib/acp/types/session_update/tool_call.rb +8 -0
  13. data/lib/acp/types/session_update/tool_call_update.rb +8 -0
  14. data/lib/acp/types/tool_call.rb +8 -0
  15. data/lib/acp/types/tool_call_update.rb +8 -0
  16. data/lib/acp/version.rb +1 -1
  17. data/sig/generated/acp/agent_connection/client.rbs +23 -16
  18. data/sig/generated/acp/agent_connection/optional_method/logout.rbs +13 -0
  19. data/sig/generated/acp/agent_connection.rbs +9 -15
  20. data/sig/generated/acp/agent_process.rbs +72 -0
  21. data/sig/generated/acp/client_connection.rbs +16 -16
  22. data/sig/generated/acp/request_error.rbs +72 -0
  23. data/sig/generated/acp/transport/reply.rbs +5 -5
  24. data/sig/generated/acp/transport/stdio.rbs +14 -19
  25. data/sig/generated/acp/types/session_update/tool_call.rbs +5 -1
  26. data/sig/generated/acp/types/session_update/tool_call_update.rbs +5 -1
  27. data/sig/generated/acp/types/tool_call.rbs +5 -1
  28. data/sig/generated/acp/types/tool_call_update.rbs +5 -1
  29. data/sig/manual/acp/agent_connection/optional_method/logout.rbs +6 -0
  30. data/sig/manual/acp/agent_connection.rbs +24 -19
  31. data/sig/manual/acp/agent_process.rbs +7 -0
  32. data/sig/manual/acp/client_connection.rbs +1 -1
  33. data/sig/manual/acp/transport/stdio.rbs +7 -1
  34. metadata +9 -5
  35. data/lib/acp/transport/response_error.rb +0 -28
  36. data/lib/acp/transport/result.rb +0 -35
  37. data/sig/generated/acp/transport/response_error.rbs +0 -21
  38. data/sig/generated/acp/transport/result.rbs +0 -25
@@ -0,0 +1,72 @@
1
+ # Generated from lib/acp/request_error.rb with RBS::Inline
2
+
3
+ # The schema's JSON-RPC Error object, named after the official SDKs'
4
+ # RequestError: built by handlers and local refusals, and decoded from a
5
+ # peer's error replies by the transport.
6
+ class ACP::RequestError
7
+ PARSE_ERROR: Integer
8
+
9
+ INVALID_REQUEST: Integer
10
+
11
+ METHOD_NOT_FOUND: Integer
12
+
13
+ INVALID_PARAMS: Integer
14
+
15
+ INTERNAL_ERROR: Integer
16
+
17
+ REQUEST_CANCELLED: Integer
18
+
19
+ AUTH_REQUIRED: Integer
20
+
21
+ RESOURCE_NOT_FOUND: Integer
22
+
23
+ # @rbs code: Integer
24
+ # @rbs message: String
25
+ # @rbs data: untyped
26
+ # @rbs return: void
27
+ def initialize: (code: Integer, message: String, ?data: untyped) -> void
28
+
29
+ # @dynamic code
30
+ attr_reader code: Integer
31
+
32
+ # @dynamic message
33
+ attr_reader message: String
34
+
35
+ # @dynamic data
36
+ attr_reader data: untyped
37
+
38
+ # @rbs return: Hash[String, untyped]
39
+ def to_h: () -> Hash[String, untyped]
40
+
41
+ # @rbs return: ACP::RequestError
42
+ def self.parse_error: () -> ACP::RequestError
43
+
44
+ # @rbs return: ACP::RequestError
45
+ def self.invalid_request: () -> ACP::RequestError
46
+
47
+ # @rbs return: ACP::RequestError
48
+ def self.method_not_found: () -> ACP::RequestError
49
+
50
+ # @rbs return: ACP::RequestError
51
+ def self.invalid_params: () -> ACP::RequestError
52
+
53
+ # @rbs return: ACP::RequestError
54
+ def self.internal_error: () -> ACP::RequestError
55
+
56
+ # The message tells a malformed peer reply apart from an internal error a
57
+ # handler raised, though both use the -32603 code.
58
+ #
59
+ # @rbs response: untyped
60
+ # @rbs return: ACP::RequestError
61
+ def self.invalid_response: (untyped response) -> ACP::RequestError
62
+
63
+ # @rbs return: ACP::RequestError
64
+ def self.request_cancelled: () -> ACP::RequestError
65
+
66
+ # @rbs return: ACP::RequestError
67
+ def self.auth_required: () -> ACP::RequestError
68
+
69
+ # @rbs uri: String?
70
+ # @rbs return: ACP::RequestError
71
+ def self.resource_not_found: (?String? uri) -> ACP::RequestError
72
+ end
@@ -1,16 +1,16 @@
1
1
  # Generated from lib/acp/transport/reply.rb with RBS::Inline
2
2
 
3
- # A request handler's result plus a callback the transport runs once that
4
- # result is on the wire, for messages the peer must only see after the reply.
3
+ # A request handler's outcome plus a callback the transport runs once that
4
+ # outcome is on the wire, for messages the peer must only see after the reply.
5
5
  class ACP::Transport::Reply
6
6
  # @dynamic result
7
- attr_reader result: ACP::Transport::Result
7
+ attr_reader result: ACP::Transport::Stdio::_ToH
8
8
 
9
9
  # @dynamic after
10
10
  attr_reader after: ^() -> void
11
11
 
12
- # @rbs result: ACP::Transport::Result
12
+ # @rbs result: ACP::Transport::Stdio::_ToH
13
13
  # @rbs after: ^() -> void
14
14
  # @rbs return: void
15
- def initialize: (ACP::Transport::Result result, after: ^() -> void) -> void
15
+ def initialize: (ACP::Transport::Stdio::_ToH result, after: ^() -> void) -> void
16
16
  end
@@ -20,15 +20,7 @@ class ACP::Transport::Stdio
20
20
 
21
21
  @input: _Reader
22
22
 
23
- INTERNAL_ERROR: Integer
24
-
25
- PARSE_ERROR: ACP::Transport::ResponseError
26
-
27
- INVALID_REQUEST: ACP::Transport::ResponseError
28
-
29
- METHOD_NOT_FOUND: ACP::Transport::ResponseError
30
-
31
- CONNECTION_CLOSED: ACP::Transport::ResponseError
23
+ CONNECTION_CLOSED: ACP::RequestError
32
24
 
33
25
  # @rbs input: _Reader
34
26
  # @rbs output: _Writer
@@ -45,8 +37,8 @@ class ACP::Transport::Stdio
45
37
 
46
38
  # @rbs method: String
47
39
  # @rbs params: untyped
48
- # @rbs return: ACP::Transport::Result
49
- def request: (String method, ?untyped params) -> ACP::Transport::Result
40
+ # @rbs return: (Hash[String, untyped] | ACP::RequestError)
41
+ def request: (String method, ?untyped params) -> (Hash[String, untyped] | ACP::RequestError)
50
42
 
51
43
  # @rbs method: String
52
44
  # @rbs params: untyped
@@ -68,8 +60,8 @@ class ACP::Transport::Stdio
68
60
  def route: (Hash[String, untyped] message, Hash[String, _Handler] requests, Hash[String, _NotificationHandler] notifications) -> void
69
61
 
70
62
  # @rbs line: String
71
- # @rbs return: Hash[String, untyped] | ACP::Transport::ResponseError
72
- def parse: (String line) -> (Hash[String, untyped] | ACP::Transport::ResponseError)
63
+ # @rbs return: Hash[String, untyped] | ACP::RequestError
64
+ def parse: (String line) -> (Hash[String, untyped] | ACP::RequestError)
73
65
 
74
66
  # @rbs handler: _Handler?
75
67
  # @rbs id: untyped
@@ -90,22 +82,25 @@ class ACP::Transport::Stdio
90
82
  #
91
83
  # @rbs handler: _Handler
92
84
  # @rbs params: untyped
93
- # @rbs return: ACP::Transport::Result | ACP::Transport::Reply
94
- def invoke: (_Handler handler, untyped params) -> (ACP::Transport::Result | ACP::Transport::Reply)
85
+ # @rbs return: (_ToH | ACP::RequestError | ACP::Transport::Reply)
86
+ def invoke: (_Handler handler, untyped params) -> (_ToH | ACP::RequestError | ACP::Transport::Reply)
95
87
 
88
+ # The success arm is whatever the handler returned, which the transport only
89
+ # knows serializes with to_h; RequestError picks the error arm of the reply.
90
+ #
96
91
  # @rbs id: untyped
97
- # @rbs result: ACP::Transport::Result
92
+ # @rbs outcome: (_ToH | ACP::RequestError)
98
93
  # @rbs return: void
99
- def reply: (untyped id, ACP::Transport::Result result) -> void
94
+ def reply: (untyped id, _ToH | ACP::RequestError outcome) -> void
100
95
 
101
96
  # @rbs queue: Thread::Queue
102
97
  # @rbs return: Integer?
103
98
  def register: (Thread::Queue queue) -> Integer?
104
99
 
105
100
  # @rbs id: untyped
106
- # @rbs result: ACP::Transport::Result
101
+ # @rbs result: (Hash[String, untyped] | ACP::RequestError)
107
102
  # @rbs return: void
108
- def settle: (untyped id, ACP::Transport::Result result) -> void
103
+ def settle: (untyped id, Hash[String, untyped] | ACP::RequestError result) -> void
109
104
 
110
105
  # @rbs return: void
111
106
  def close: () -> void
@@ -7,6 +7,9 @@ class ACP::Types::SessionUpdate::ToolCall
7
7
  # @dynamic title
8
8
  attr_reader title: String
9
9
 
10
+ # @dynamic name
11
+ attr_reader name: String?
12
+
10
13
  # @dynamic kind
11
14
  attr_reader kind: String?
12
15
 
@@ -30,6 +33,7 @@ class ACP::Types::SessionUpdate::ToolCall
30
33
 
31
34
  # @rbs tool_call_id: String
32
35
  # @rbs title: String
36
+ # @rbs name: String?
33
37
  # @rbs kind: String?
34
38
  # @rbs status: String?
35
39
  # @rbs content: Array[ACP::Types::ToolCallContent::t]?
@@ -38,7 +42,7 @@ class ACP::Types::SessionUpdate::ToolCall
38
42
  # @rbs raw_output: untyped
39
43
  # @rbs meta: Hash[String, untyped]?
40
44
  # @rbs return: void
41
- def initialize: (tool_call_id: String, title: String, ?kind: String?, ?status: String?, ?content: Array[ACP::Types::ToolCallContent::t]?, ?locations: Array[ACP::Types::ToolCallLocation]?, ?raw_input: untyped, ?raw_output: untyped, ?meta: Hash[String, untyped]?) -> void
45
+ def initialize: (tool_call_id: String, title: String, ?name: String?, ?kind: String?, ?status: String?, ?content: Array[ACP::Types::ToolCallContent::t]?, ?locations: Array[ACP::Types::ToolCallLocation]?, ?raw_input: untyped, ?raw_output: untyped, ?meta: Hash[String, untyped]?) -> void
42
46
 
43
47
  # @rbs hash: Hash[String, untyped]
44
48
  # @rbs return: ACP::Types::SessionUpdate::ToolCall
@@ -13,6 +13,9 @@ class ACP::Types::SessionUpdate::ToolCallUpdate
13
13
  # @dynamic title
14
14
  attr_reader title: String?
15
15
 
16
+ # @dynamic name
17
+ attr_reader name: String?
18
+
16
19
  # @dynamic content
17
20
  attr_reader content: Array[ACP::Types::ToolCallContent::t]?
18
21
 
@@ -32,13 +35,14 @@ class ACP::Types::SessionUpdate::ToolCallUpdate
32
35
  # @rbs kind: String?
33
36
  # @rbs status: String?
34
37
  # @rbs title: String?
38
+ # @rbs name: String?
35
39
  # @rbs content: Array[ACP::Types::ToolCallContent::t]?
36
40
  # @rbs locations: Array[ACP::Types::ToolCallLocation]?
37
41
  # @rbs raw_input: untyped
38
42
  # @rbs raw_output: untyped
39
43
  # @rbs meta: Hash[String, untyped]?
40
44
  # @rbs return: void
41
- def initialize: (tool_call_id: String, ?kind: String?, ?status: String?, ?title: String?, ?content: Array[ACP::Types::ToolCallContent::t]?, ?locations: Array[ACP::Types::ToolCallLocation]?, ?raw_input: untyped, ?raw_output: untyped, ?meta: Hash[String, untyped]?) -> void
45
+ def initialize: (tool_call_id: String, ?kind: String?, ?status: String?, ?title: String?, ?name: String?, ?content: Array[ACP::Types::ToolCallContent::t]?, ?locations: Array[ACP::Types::ToolCallLocation]?, ?raw_input: untyped, ?raw_output: untyped, ?meta: Hash[String, untyped]?) -> void
42
46
 
43
47
  # @rbs hash: Hash[String, untyped]
44
48
  # @rbs return: ACP::Types::SessionUpdate::ToolCallUpdate
@@ -7,6 +7,9 @@ class ACP::Types::ToolCall
7
7
  # @dynamic title
8
8
  attr_reader title: String
9
9
 
10
+ # @dynamic name
11
+ attr_reader name: String?
12
+
10
13
  # @dynamic kind
11
14
  attr_reader kind: String?
12
15
 
@@ -30,6 +33,7 @@ class ACP::Types::ToolCall
30
33
 
31
34
  # @rbs tool_call_id: String
32
35
  # @rbs title: String
36
+ # @rbs name: String?
33
37
  # @rbs kind: String?
34
38
  # @rbs status: String?
35
39
  # @rbs content: Array[ACP::Types::ToolCallContent::t]?
@@ -38,7 +42,7 @@ class ACP::Types::ToolCall
38
42
  # @rbs raw_output: untyped
39
43
  # @rbs meta: Hash[String, untyped]?
40
44
  # @rbs return: void
41
- def initialize: (tool_call_id: String, title: String, ?kind: String?, ?status: String?, ?content: Array[ACP::Types::ToolCallContent::t]?, ?locations: Array[ACP::Types::ToolCallLocation]?, ?raw_input: untyped, ?raw_output: untyped, ?meta: Hash[String, untyped]?) -> void
45
+ def initialize: (tool_call_id: String, title: String, ?name: String?, ?kind: String?, ?status: String?, ?content: Array[ACP::Types::ToolCallContent::t]?, ?locations: Array[ACP::Types::ToolCallLocation]?, ?raw_input: untyped, ?raw_output: untyped, ?meta: Hash[String, untyped]?) -> void
42
46
 
43
47
  # @rbs hash: Hash[String, untyped]
44
48
  # @rbs return: ACP::Types::ToolCall
@@ -13,6 +13,9 @@ class ACP::Types::ToolCallUpdate
13
13
  # @dynamic title
14
14
  attr_reader title: String?
15
15
 
16
+ # @dynamic name
17
+ attr_reader name: String?
18
+
16
19
  # @dynamic content
17
20
  attr_reader content: Array[ACP::Types::ToolCallContent::t]?
18
21
 
@@ -32,13 +35,14 @@ class ACP::Types::ToolCallUpdate
32
35
  # @rbs kind: String?
33
36
  # @rbs status: String?
34
37
  # @rbs title: String?
38
+ # @rbs name: String?
35
39
  # @rbs content: Array[ACP::Types::ToolCallContent::t]?
36
40
  # @rbs locations: Array[ACP::Types::ToolCallLocation]?
37
41
  # @rbs raw_input: untyped
38
42
  # @rbs raw_output: untyped
39
43
  # @rbs meta: Hash[String, untyped]?
40
44
  # @rbs return: void
41
- def initialize: (tool_call_id: String, ?kind: String?, ?status: String?, ?title: String?, ?content: Array[ACP::Types::ToolCallContent::t]?, ?locations: Array[ACP::Types::ToolCallLocation]?, ?raw_input: untyped, ?raw_output: untyped, ?meta: Hash[String, untyped]?) -> void
45
+ def initialize: (tool_call_id: String, ?kind: String?, ?status: String?, ?title: String?, ?name: String?, ?content: Array[ACP::Types::ToolCallContent::t]?, ?locations: Array[ACP::Types::ToolCallLocation]?, ?raw_input: untyped, ?raw_output: untyped, ?meta: Hash[String, untyped]?) -> void
42
46
 
43
47
  # @rbs hash: Hash[String, untyped]
44
48
  # @rbs return: ACP::Types::ToolCallUpdate
@@ -0,0 +1,6 @@
1
+ # rbs-inline does not emit `extend self`, so without this reopen the module's
2
+ # methods aren't visible as singleton methods.
3
+
4
+ module ACP::AgentConnection::OptionalMethod::Logout
5
+ extend ::ACP::AgentConnection::OptionalMethod::Logout
6
+ end
@@ -1,7 +1,7 @@
1
1
  class ACP::AgentConnection
2
2
  interface _Agent
3
- def new_session: (ACP::Types::NewSessionRequest) -> (ACP::Types::NewSessionResponse | ACP::Transport::ResponseError)
4
- def prompt: (ACP::Types::PromptRequest) -> (ACP::Types::PromptResponse | ACP::Transport::ResponseError)
3
+ def new_session: (ACP::Types::NewSessionRequest) -> (ACP::Types::NewSessionResponse | ACP::RequestError)
4
+ def prompt: (ACP::Types::PromptRequest) -> (ACP::Types::PromptResponse | ACP::RequestError)
5
5
  # Runs on the transport's reader thread, so it must return quickly.
6
6
  def cancel: (ACP::Types::CancelNotification) -> void
7
7
  # AgentConnection probes for the optional methods below.
@@ -9,35 +9,39 @@ class ACP::AgentConnection
9
9
  end
10
10
 
11
11
  interface _LoadSession
12
- def load_session: (ACP::Types::LoadSessionRequest) -> (ACP::Types::LoadSessionResponse | ACP::Transport::ResponseError)
12
+ def load_session: (ACP::Types::LoadSessionRequest) -> (ACP::Types::LoadSessionResponse | ACP::RequestError)
13
13
  end
14
14
 
15
15
  interface _ListSessions
16
- def list_sessions: (ACP::Types::ListSessionsRequest) -> (ACP::Types::ListSessionsResponse | ACP::Transport::ResponseError)
16
+ def list_sessions: (ACP::Types::ListSessionsRequest) -> (ACP::Types::ListSessionsResponse | ACP::RequestError)
17
17
  end
18
18
 
19
19
  interface _Authenticate
20
- def authenticate: (ACP::Types::AuthenticateRequest) -> (ACP::Types::AuthenticateResponse | ACP::Transport::ResponseError)
20
+ def authenticate: (ACP::Types::AuthenticateRequest) -> (ACP::Types::AuthenticateResponse | ACP::RequestError)
21
21
  end
22
22
 
23
23
  interface _ResumeSession
24
- def resume_session: (ACP::Types::ResumeSessionRequest) -> (ACP::Types::ResumeSessionResponse | ACP::Transport::ResponseError)
24
+ def resume_session: (ACP::Types::ResumeSessionRequest) -> (ACP::Types::ResumeSessionResponse | ACP::RequestError)
25
25
  end
26
26
 
27
27
  interface _CloseSession
28
- def close_session: (ACP::Types::CloseSessionRequest) -> (ACP::Types::CloseSessionResponse | ACP::Transport::ResponseError)
28
+ def close_session: (ACP::Types::CloseSessionRequest) -> (ACP::Types::CloseSessionResponse | ACP::RequestError)
29
29
  end
30
30
 
31
31
  interface _DeleteSession
32
- def delete_session: (ACP::Types::DeleteSessionRequest) -> (ACP::Types::DeleteSessionResponse | ACP::Transport::ResponseError)
32
+ def delete_session: (ACP::Types::DeleteSessionRequest) -> (ACP::Types::DeleteSessionResponse | ACP::RequestError)
33
+ end
34
+
35
+ interface _Logout
36
+ def logout: (ACP::Types::LogoutRequest) -> (ACP::Types::LogoutResponse | ACP::RequestError)
33
37
  end
34
38
 
35
39
  interface _ChangeSessionMode
36
- def change_session_mode: (ACP::Types::SetSessionModeRequest) -> (ACP::Types::SetSessionModeResponse | ACP::Transport::ResponseError)
40
+ def change_session_mode: (ACP::Types::SetSessionModeRequest) -> (ACP::Types::SetSessionModeResponse | ACP::RequestError)
37
41
  end
38
42
 
39
43
  interface _ChangeSessionConfigOption
40
- def change_session_config_option: (ACP::Types::SetSessionConfigOptionRequest) -> (ACP::Types::SetSessionConfigOptionResponse | ACP::Transport::ResponseError)
44
+ def change_session_config_option: (ACP::Types::SetSessionConfigOptionRequest) -> (ACP::Types::SetSessionConfigOptionResponse | ACP::RequestError)
41
45
  end
42
46
 
43
47
  interface _FullAgent
@@ -48,6 +52,7 @@ class ACP::AgentConnection
48
52
  include _ResumeSession
49
53
  include _CloseSession
50
54
  include _DeleteSession
55
+ include _Logout
51
56
  include _ChangeSessionMode
52
57
  include _ChangeSessionConfigOption
53
58
  end
@@ -66,19 +71,19 @@ class ACP::AgentConnection
66
71
  interface _Client
67
72
  def update: (String session_id, ACP::Types::SessionUpdate::t update) -> void
68
73
  def available_commands: (String session_id, Array[ACP::Types::AvailableCommand] commands) -> void
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)
74
+ def request_permission: (ACP::Types::RequestPermissionRequest) -> (ACP::Types::RequestPermissionResponse | ACP::RequestError)
75
+ def read_text_file: (ACP::Types::ReadTextFileRequest) -> (ACP::Types::ReadTextFileResponse | ACP::RequestError)
76
+ def write_text_file: (ACP::Types::WriteTextFileRequest) -> (ACP::Types::WriteTextFileResponse | ACP::RequestError)
77
+ def create_terminal: (ACP::Types::CreateTerminalRequest) -> (ACP::Types::CreateTerminalResponse | ACP::RequestError)
78
+ def terminal_output: (ACP::Types::TerminalOutputRequest) -> (ACP::Types::TerminalOutputResponse | ACP::RequestError)
79
+ def wait_for_terminal_exit: (ACP::Types::WaitForTerminalExitRequest) -> (ACP::Types::WaitForTerminalExitResponse | ACP::RequestError)
80
+ def kill_terminal: (ACP::Types::KillTerminalRequest) -> (ACP::Types::KillTerminalResponse | ACP::RequestError)
81
+ def release_terminal: (ACP::Types::ReleaseTerminalRequest) -> (ACP::Types::ReleaseTerminalResponse | ACP::RequestError)
77
82
  def capabilities: () -> ACP::Types::ClientCapabilities?
78
83
  end
79
84
 
80
85
  interface _Peer
81
- def request: (String method, ?untyped params) -> ACP::Transport::Result
86
+ def request: (String method, ?untyped params) -> (Hash[String, untyped] | ACP::RequestError)
82
87
  def notify: (String method, ?untyped params) -> void
83
88
  end
84
89
 
@@ -0,0 +1,7 @@
1
+ class ACP::AgentProcess
2
+ # The stdlib RBS for Open3#popen2 models neither the leading env hash nor
3
+ # the err: option, so spawn calls it through this narrower type.
4
+ interface _Spawner
5
+ def call: (*untyped, **untyped) -> [IO, IO, Process::Waiter]
6
+ end
7
+ end
@@ -1,7 +1,7 @@
1
1
  class ACP::ClientConnection
2
2
  interface _PermissionHandler
3
3
  # Runs on its own thread, so it may block while the user decides.
4
- def call: (ACP::Types::RequestPermissionRequest) -> (ACP::Types::RequestPermissionResponse | ACP::Transport::ResponseError)
4
+ def call: (ACP::Types::RequestPermissionRequest) -> (ACP::Types::RequestPermissionResponse | ACP::RequestError)
5
5
  end
6
6
 
7
7
  # Receives the session/update notifications that arrive outside a
@@ -1,4 +1,10 @@
1
1
  class ACP::Transport::Stdio
2
+ # The success arm of a request handler's return: the transport serializes it
3
+ # with to_h into the reply's result.
4
+ interface _ToH
5
+ def to_h: () -> Hash[String, untyped]
6
+ end
7
+
2
8
  interface _Reader
3
9
  def each_line: () { (String) -> void } -> untyped
4
10
  end
@@ -9,7 +15,7 @@ class ACP::Transport::Stdio
9
15
  end
10
16
 
11
17
  interface _Handler
12
- def call: (untyped params) -> (ACP::Transport::Result | ACP::Transport::Reply)
18
+ def call: (untyped params) -> (_ToH | ACP::RequestError | ACP::Transport::Reply)
13
19
  end
14
20
 
15
21
  interface _NotificationHandler
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.2.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jake Bottrall
@@ -40,13 +40,14 @@ files:
40
40
  - lib/acp/agent_connection/optional_method/delete_session.rb
41
41
  - lib/acp/agent_connection/optional_method/list_sessions.rb
42
42
  - lib/acp/agent_connection/optional_method/load_session.rb
43
+ - lib/acp/agent_connection/optional_method/logout.rb
43
44
  - lib/acp/agent_connection/optional_method/resume_session.rb
45
+ - lib/acp/agent_process.rb
44
46
  - lib/acp/client_connection.rb
47
+ - lib/acp/request_error.rb
45
48
  - lib/acp/sdk.rb
46
49
  - lib/acp/transport.rb
47
50
  - lib/acp/transport/reply.rb
48
- - lib/acp/transport/response_error.rb
49
- - lib/acp/transport/result.rb
50
51
  - lib/acp/transport/stdio.rb
51
52
  - lib/acp/types.rb
52
53
  - lib/acp/types/agent_auth_capabilities.rb
@@ -253,13 +254,14 @@ files:
253
254
  - sig/generated/acp/agent_connection/optional_method/delete_session.rbs
254
255
  - sig/generated/acp/agent_connection/optional_method/list_sessions.rbs
255
256
  - sig/generated/acp/agent_connection/optional_method/load_session.rbs
257
+ - sig/generated/acp/agent_connection/optional_method/logout.rbs
256
258
  - sig/generated/acp/agent_connection/optional_method/resume_session.rbs
259
+ - sig/generated/acp/agent_process.rbs
257
260
  - sig/generated/acp/client_connection.rbs
261
+ - sig/generated/acp/request_error.rbs
258
262
  - sig/generated/acp/sdk.rbs
259
263
  - sig/generated/acp/transport.rbs
260
264
  - sig/generated/acp/transport/reply.rbs
261
- - sig/generated/acp/transport/response_error.rbs
262
- - sig/generated/acp/transport/result.rbs
263
265
  - sig/generated/acp/transport/stdio.rbs
264
266
  - sig/generated/acp/types.rbs
265
267
  - sig/generated/acp/types/agent_auth_capabilities.rbs
@@ -464,7 +466,9 @@ files:
464
466
  - sig/manual/acp/agent_connection/optional_method/delete_session.rbs
465
467
  - sig/manual/acp/agent_connection/optional_method/list_sessions.rbs
466
468
  - sig/manual/acp/agent_connection/optional_method/load_session.rbs
469
+ - sig/manual/acp/agent_connection/optional_method/logout.rbs
467
470
  - sig/manual/acp/agent_connection/optional_method/resume_session.rbs
471
+ - sig/manual/acp/agent_process.rbs
468
472
  - sig/manual/acp/client_connection.rbs
469
473
  - sig/manual/acp/transport/stdio.rbs
470
474
  homepage: https://github.com/bottrall/acp-sdk
@@ -1,28 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class ACP::Transport::ResponseError
4
- # @dynamic code
5
- attr_reader :code #: Integer
6
-
7
- # @dynamic message
8
- attr_reader :message #: String
9
-
10
- # @dynamic data
11
- attr_reader :data #: untyped
12
-
13
- # @rbs code: Integer
14
- # @rbs message: String
15
- # @rbs data: untyped
16
- # @rbs return: void
17
- def initialize(code:, message:, data: nil)
18
- @code = code
19
- @message = message
20
- @data = data
21
- freeze
22
- end
23
-
24
- # @rbs return: Hash[String, untyped]
25
- def to_h
26
- { 'code' => code, 'message' => message, 'data' => data }.compact
27
- end
28
- end
@@ -1,35 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class ACP::Transport::Result
4
- # @dynamic value
5
- attr_reader :value #: untyped
6
-
7
- # @dynamic error
8
- attr_reader :error #: ACP::Transport::ResponseError?
9
-
10
- # @rbs value: untyped
11
- # @rbs return: ACP::Transport::Result
12
- def self.ok(value)
13
- new(value:, error: nil)
14
- end
15
-
16
- # @rbs error: ACP::Transport::ResponseError
17
- # @rbs return: ACP::Transport::Result
18
- def self.error(error)
19
- new(value: nil, error:)
20
- end
21
-
22
- # @rbs value: untyped
23
- # @rbs error: ACP::Transport::ResponseError?
24
- # @rbs return: void
25
- def initialize(value:, error:)
26
- @value = value
27
- @error = error
28
- freeze
29
- end
30
-
31
- # @rbs return: bool
32
- def ok?
33
- error.nil?
34
- end
35
- end
@@ -1,21 +0,0 @@
1
- # Generated from lib/acp/transport/response_error.rb with RBS::Inline
2
-
3
- class ACP::Transport::ResponseError
4
- # @dynamic code
5
- attr_reader code: Integer
6
-
7
- # @dynamic message
8
- attr_reader message: String
9
-
10
- # @dynamic data
11
- attr_reader data: untyped
12
-
13
- # @rbs code: Integer
14
- # @rbs message: String
15
- # @rbs data: untyped
16
- # @rbs return: void
17
- def initialize: (code: Integer, message: String, ?data: untyped) -> void
18
-
19
- # @rbs return: Hash[String, untyped]
20
- def to_h: () -> Hash[String, untyped]
21
- end
@@ -1,25 +0,0 @@
1
- # Generated from lib/acp/transport/result.rb with RBS::Inline
2
-
3
- class ACP::Transport::Result
4
- # @dynamic value
5
- attr_reader value: untyped
6
-
7
- # @dynamic error
8
- attr_reader error: ACP::Transport::ResponseError?
9
-
10
- # @rbs value: untyped
11
- # @rbs return: ACP::Transport::Result
12
- def self.ok: (untyped value) -> ACP::Transport::Result
13
-
14
- # @rbs error: ACP::Transport::ResponseError
15
- # @rbs return: ACP::Transport::Result
16
- def self.error: (ACP::Transport::ResponseError error) -> ACP::Transport::Result
17
-
18
- # @rbs value: untyped
19
- # @rbs error: ACP::Transport::ResponseError?
20
- # @rbs return: void
21
- def initialize: (value: untyped, error: ACP::Transport::ResponseError?) -> void
22
-
23
- # @rbs return: bool
24
- def ok?: () -> bool
25
- end