Skip to content

Commit 1cf7e2c

Browse files
authored
Allow methods that previously returned void to return _meta (#85)
* Allow methods that previously returned void to use _meta * Hide AgentNotification from docs
1 parent de424c6 commit 1cf7e2c

15 files changed

Lines changed: 579 additions & 172 deletions

File tree

docs/protocol/schema.mdx

Lines changed: 84 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,18 @@ Specifies which authentication method to use.
4444
advertised in the initialize response.
4545
</ResponseField>
4646

47+
#### <span class="font-mono">AuthenticateResponse</span>
48+
49+
Response to authenticate method
50+
51+
**Type:** Object
52+
53+
**Properties:**
54+
55+
<ResponseField name="_meta" type={"object"}>
56+
Extension point for implementations
57+
</ResponseField>
58+
4759
### <span class="font-mono">initialize</span>
4860

4961
Establishes the connection with a client and negotiates protocol capabilities.
@@ -210,6 +222,24 @@ See protocol docs: [Loading Sessions](https://agentclientprotocol.com/protocol/s
210222
The ID of the session to load.
211223
</ResponseField>
212224

225+
#### <span class="font-mono">LoadSessionResponse</span>
226+
227+
Response from loading an existing session.
228+
229+
**Type:** Object
230+
231+
**Properties:**
232+
233+
<ResponseField name="_meta" type={"object"} >
234+
Extension point for implementations
235+
</ResponseField>
236+
<ResponseField name="modes" type={<><span><a href="#sessionmodestate">SessionModeState</a></span><span> | null</span></>} >
237+
**UNSTABLE**
238+
239+
This field is not part of the spec, and may be removed or changed at any point.
240+
241+
</ResponseField>
242+
213243
<a id="session-new"></a>
214244
### <span class="font-mono">session/new</span>
215245

@@ -406,6 +436,19 @@ Only available if the client supports the `fs.readTextFile` capability.
406436
The session ID for this request.
407437
</ResponseField>
408438

439+
#### <span class="font-mono">ReadTextFileResponse</span>
440+
441+
Response containing the contents of a text file.
442+
443+
**Type:** Object
444+
445+
**Properties:**
446+
447+
<ResponseField name="_meta" type={"object"}>
448+
Extension point for implementations
449+
</ResponseField>
450+
<ResponseField name="content" type={"string"} required></ResponseField>
451+
409452
<a id="fs-write_text_file"></a>
410453
### <span class="font-mono">fs/write_text_file</span>
411454

@@ -443,6 +486,18 @@ Only available if the client supports the `fs.writeTextFile` capability.
443486
The session ID for this request.
444487
</ResponseField>
445488

489+
#### <span class="font-mono">WriteTextFileResponse</span>
490+
491+
Response to fs/write_text_file
492+
493+
**Type:** Object
494+
495+
**Properties:**
496+
497+
<ResponseField name="_meta" type={"object"}>
498+
Extension point for implementations
499+
</ResponseField>
500+
446501
<a id="session-request_permission"></a>
447502
### <span class="font-mono">session/request_permission</span>
448503

@@ -676,6 +731,18 @@ Request to kill a terminal command without releasing the terminal.
676731
The ID of the terminal to kill.
677732
</ResponseField>
678733

734+
#### <span class="font-mono">KillTerminalCommandResponse</span>
735+
736+
Response to terminal/kill command method
737+
738+
**Type:** Object
739+
740+
**Properties:**
741+
742+
<ResponseField name="_meta" type={"object"}>
743+
Extension point for implementations
744+
</ResponseField>
745+
679746
<a id="terminal-output"></a>
680747
### <span class="font-mono">terminal/output</span>
681748

@@ -777,6 +844,18 @@ Request to release a terminal and free its resources.
777844
The ID of the terminal to release.
778845
</ResponseField>
779846

847+
#### <span class="font-mono">ReleaseTerminalResponse</span>
848+
849+
Response to terminal/release method
850+
851+
**Type:** Object
852+
853+
**Properties:**
854+
855+
<ResponseField name="_meta" type={"object"}>
856+
Extension point for implementations
857+
</ResponseField>
858+
780859
<a id="terminal-wait_for_exit"></a>
781860
### <span class="font-mono">terminal/wait_for_exit</span>
782861

@@ -1346,24 +1425,6 @@ An image provided to or from an LLM.
13461425
<ResponseField name="mimeType" type={"string"} required></ResponseField>
13471426
<ResponseField name="uri" type={"string | null"}></ResponseField>
13481427

1349-
## <span class="font-mono">LoadSessionResponse</span>
1350-
1351-
Response from loading an existing session.
1352-
1353-
**Type:** Object
1354-
1355-
**Properties:**
1356-
1357-
<ResponseField name="_meta" type={"object"} >
1358-
Extension point for implementations
1359-
</ResponseField>
1360-
<ResponseField name="modes" type={<><span><a href="#sessionmodestate">SessionModeState</a></span><span> | null</span></>} >
1361-
**UNSTABLE**
1362-
1363-
This field is not part of the spec, and may be removed or changed at any point.
1364-
1365-
</ResponseField>
1366-
13671428
## <span class="font-mono">McpCapabilities</span>
13681429

13691430
MCP capabilities supported by the agent
@@ -1723,19 +1784,6 @@ Non-breaking changes should be introduced via capabilities.
17231784
| Minimum | `0` |
17241785
| Maximum | `65535` |
17251786

1726-
## <span class="font-mono">ReadTextFileResponse</span>
1727-
1728-
Response containing the contents of a text file.
1729-
1730-
**Type:** Object
1731-
1732-
**Properties:**
1733-
1734-
<ResponseField name="_meta" type={"object"}>
1735-
Extension point for implementations
1736-
</ResponseField>
1737-
<ResponseField name="content" type={"string"} required></ResponseField>
1738-
17391787
## <span class="font-mono">RequestPermissionOutcome</span>
17401788

17411789
The outcome of a permission request.
@@ -2142,7 +2190,11 @@ The current mode of the session has changed
21422190

21432191
This type is not part of the spec, and may be removed or changed at any point.
21442192

2145-
**Type:** `object`
2193+
**Type:** Object
2194+
2195+
**Properties:**
2196+
2197+
<ResponseField name="meta" type={"object"}></ResponseField>
21462198

21472199
## <span class="font-mono">StopReason</span>
21482200

rust/acp.rs

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -176,13 +176,17 @@ impl Agent for ClientSideConnection {
176176
.await
177177
}
178178

179-
async fn authenticate(&self, arguments: AuthenticateRequest) -> Result<(), Error> {
179+
async fn authenticate(
180+
&self,
181+
arguments: AuthenticateRequest,
182+
) -> Result<AuthenticateResponse, Error> {
180183
self.conn
181-
.request(
184+
.request::<Option<_>>(
182185
AUTHENTICATE_METHOD_NAME,
183186
Some(ClientRequest::AuthenticateRequest(arguments)),
184187
)
185188
.await
189+
.map(|value| value.unwrap_or_default())
186190
}
187191

188192
async fn new_session(&self, arguments: NewSessionRequest) -> Result<NewSessionResponse, Error> {
@@ -199,11 +203,12 @@ impl Agent for ClientSideConnection {
199203
arguments: LoadSessionRequest,
200204
) -> Result<LoadSessionResponse, Error> {
201205
self.conn
202-
.request(
206+
.request::<Option<_>>(
203207
SESSION_LOAD_METHOD_NAME,
204208
Some(ClientRequest::LoadSessionRequest(arguments)),
205209
)
206210
.await
211+
.map(|value| value.unwrap_or_default())
207212
}
208213

209214
#[cfg(feature = "unstable")]
@@ -349,8 +354,8 @@ impl<T: Client> MessageHandler<ClientSide> for T {
349354
Ok(ClientResponse::RequestPermissionResponse(response))
350355
}
351356
AgentRequest::WriteTextFileRequest(args) => {
352-
self.write_text_file(args).await?;
353-
Ok(ClientResponse::WriteTextFileResponse)
357+
let response = self.write_text_file(args).await?;
358+
Ok(ClientResponse::WriteTextFileResponse(response))
354359
}
355360
AgentRequest::ReadTextFileRequest(args) => {
356361
let response = self.read_text_file(args).await?;
@@ -365,16 +370,16 @@ impl<T: Client> MessageHandler<ClientSide> for T {
365370
Ok(ClientResponse::TerminalOutputResponse(response))
366371
}
367372
AgentRequest::ReleaseTerminalRequest(args) => {
368-
self.release_terminal(args).await?;
369-
Ok(ClientResponse::ReleaseTerminalResponse)
373+
let response = self.release_terminal(args).await?;
374+
Ok(ClientResponse::ReleaseTerminalResponse(response))
370375
}
371376
AgentRequest::WaitForTerminalExitRequest(args) => {
372377
let response = self.wait_for_terminal_exit(args).await?;
373378
Ok(ClientResponse::WaitForTerminalExitResponse(response))
374379
}
375380
AgentRequest::KillTerminalCommandRequest(args) => {
376-
self.kill_terminal_command(args).await?;
377-
Ok(ClientResponse::KillTerminalResponse)
381+
let response = self.kill_terminal_command(args).await?;
382+
Ok(ClientResponse::KillTerminalResponse(response))
378383
}
379384
AgentRequest::ExtMethodRequest(args) => {
380385
let response = self.ext_method(args.method, args.params).await?;
@@ -466,13 +471,17 @@ impl Client for AgentSideConnection {
466471
.await
467472
}
468473

469-
async fn write_text_file(&self, arguments: WriteTextFileRequest) -> Result<(), Error> {
474+
async fn write_text_file(
475+
&self,
476+
arguments: WriteTextFileRequest,
477+
) -> Result<WriteTextFileResponse, Error> {
470478
self.conn
471-
.request(
479+
.request::<Option<_>>(
472480
FS_WRITE_TEXT_FILE_METHOD_NAME,
473481
Some(AgentRequest::WriteTextFileRequest(arguments)),
474482
)
475483
.await
484+
.map(|value| value.unwrap_or_default())
476485
}
477486

478487
async fn read_text_file(
@@ -511,13 +520,17 @@ impl Client for AgentSideConnection {
511520
.await
512521
}
513522

514-
async fn release_terminal(&self, arguments: ReleaseTerminalRequest) -> Result<(), Error> {
523+
async fn release_terminal(
524+
&self,
525+
arguments: ReleaseTerminalRequest,
526+
) -> Result<ReleaseTerminalResponse, Error> {
515527
self.conn
516-
.request(
528+
.request::<Option<_>>(
517529
TERMINAL_RELEASE_METHOD_NAME,
518530
Some(AgentRequest::ReleaseTerminalRequest(arguments)),
519531
)
520532
.await
533+
.map(|value| value.unwrap_or_default())
521534
}
522535

523536
async fn wait_for_terminal_exit(
@@ -535,13 +548,14 @@ impl Client for AgentSideConnection {
535548
async fn kill_terminal_command(
536549
&self,
537550
arguments: KillTerminalCommandRequest,
538-
) -> Result<(), Error> {
551+
) -> Result<KillTerminalCommandResponse, Error> {
539552
self.conn
540-
.request(
553+
.request::<Option<_>>(
541554
TERMINAL_KILL_METHOD_NAME,
542555
Some(AgentRequest::KillTerminalCommandRequest(arguments)),
543556
)
544557
.await
558+
.map(|value| value.unwrap_or_default())
545559
}
546560

547561
async fn session_notification(&self, notification: SessionNotification) -> Result<(), Error> {
@@ -657,8 +671,8 @@ impl<T: Agent> MessageHandler<AgentSide> for T {
657671
Ok(AgentResponse::InitializeResponse(response))
658672
}
659673
ClientRequest::AuthenticateRequest(args) => {
660-
self.authenticate(args).await?;
661-
Ok(AgentResponse::AuthenticateResponse)
674+
let response = self.authenticate(args).await?;
675+
Ok(AgentResponse::AuthenticateResponse(response))
662676
}
663677
ClientRequest::NewSessionRequest(args) => {
664678
let response = self.new_session(args).await?;

0 commit comments

Comments
 (0)