Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 84 additions & 32 deletions docs/protocol/schema.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,18 @@ Specifies which authentication method to use.
advertised in the initialize response.
</ResponseField>

#### <span class="font-mono">AuthenticateResponse</span>

Response to authenticate method

**Type:** Object

**Properties:**

<ResponseField name="_meta" type={"object"}>
Extension point for implementations
</ResponseField>

### <span class="font-mono">initialize</span>

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

#### <span class="font-mono">LoadSessionResponse</span>

Response from loading an existing session.

**Type:** Object

**Properties:**

<ResponseField name="_meta" type={"object"} >
Extension point for implementations
</ResponseField>
<ResponseField name="modes" type={<><span><a href="#sessionmodestate">SessionModeState</a></span><span> | null</span></>} >
**UNSTABLE**

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

</ResponseField>

<a id="session-new"></a>
### <span class="font-mono">session/new</span>

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

#### <span class="font-mono">ReadTextFileResponse</span>

Response containing the contents of a text file.

**Type:** Object

**Properties:**

<ResponseField name="_meta" type={"object"}>
Extension point for implementations
</ResponseField>
<ResponseField name="content" type={"string"} required></ResponseField>

<a id="fs-write_text_file"></a>
### <span class="font-mono">fs/write_text_file</span>

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

#### <span class="font-mono">WriteTextFileResponse</span>

Response to fs/write_text_file

**Type:** Object

**Properties:**

<ResponseField name="_meta" type={"object"}>
Extension point for implementations
</ResponseField>

<a id="session-request_permission"></a>
### <span class="font-mono">session/request_permission</span>

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

#### <span class="font-mono">KillTerminalCommandResponse</span>

Response to terminal/kill command method

**Type:** Object

**Properties:**

<ResponseField name="_meta" type={"object"}>
Extension point for implementations
</ResponseField>

<a id="terminal-output"></a>
### <span class="font-mono">terminal/output</span>

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

#### <span class="font-mono">ReleaseTerminalResponse</span>

Response to terminal/release method

**Type:** Object

**Properties:**

<ResponseField name="_meta" type={"object"}>
Extension point for implementations
</ResponseField>

<a id="terminal-wait_for_exit"></a>
### <span class="font-mono">terminal/wait_for_exit</span>

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

## <span class="font-mono">LoadSessionResponse</span>

Response from loading an existing session.

**Type:** Object

**Properties:**

<ResponseField name="_meta" type={"object"} >
Extension point for implementations
</ResponseField>
<ResponseField name="modes" type={<><span><a href="#sessionmodestate">SessionModeState</a></span><span> | null</span></>} >
**UNSTABLE**

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

</ResponseField>

## <span class="font-mono">McpCapabilities</span>

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

## <span class="font-mono">ReadTextFileResponse</span>

Response containing the contents of a text file.

**Type:** Object

**Properties:**

<ResponseField name="_meta" type={"object"}>
Extension point for implementations
</ResponseField>
<ResponseField name="content" type={"string"} required></ResponseField>

## <span class="font-mono">RequestPermissionOutcome</span>

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

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

**Type:** `object`
**Type:** Object

**Properties:**

<ResponseField name="meta" type={"object"}></ResponseField>

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

Expand Down
48 changes: 31 additions & 17 deletions rust/acp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,17 @@ impl Agent for ClientSideConnection {
.await
}

async fn authenticate(&self, arguments: AuthenticateRequest) -> Result<(), Error> {
async fn authenticate(
&self,
arguments: AuthenticateRequest,
) -> Result<AuthenticateResponse, Error> {
self.conn
.request(
.request::<Option<_>>(
AUTHENTICATE_METHOD_NAME,
Some(ClientRequest::AuthenticateRequest(arguments)),
)
.await
.map(|value| value.unwrap_or_default())
}

async fn new_session(&self, arguments: NewSessionRequest) -> Result<NewSessionResponse, Error> {
Expand All @@ -199,11 +203,12 @@ impl Agent for ClientSideConnection {
arguments: LoadSessionRequest,
) -> Result<LoadSessionResponse, Error> {
self.conn
.request(
.request::<Option<_>>(
SESSION_LOAD_METHOD_NAME,
Some(ClientRequest::LoadSessionRequest(arguments)),
)
.await
.map(|value| value.unwrap_or_default())
}

#[cfg(feature = "unstable")]
Expand Down Expand Up @@ -349,8 +354,8 @@ impl<T: Client> MessageHandler<ClientSide> for T {
Ok(ClientResponse::RequestPermissionResponse(response))
}
AgentRequest::WriteTextFileRequest(args) => {
self.write_text_file(args).await?;
Ok(ClientResponse::WriteTextFileResponse)
let response = self.write_text_file(args).await?;
Ok(ClientResponse::WriteTextFileResponse(response))
}
AgentRequest::ReadTextFileRequest(args) => {
let response = self.read_text_file(args).await?;
Expand All @@ -365,16 +370,16 @@ impl<T: Client> MessageHandler<ClientSide> for T {
Ok(ClientResponse::TerminalOutputResponse(response))
}
AgentRequest::ReleaseTerminalRequest(args) => {
self.release_terminal(args).await?;
Ok(ClientResponse::ReleaseTerminalResponse)
let response = self.release_terminal(args).await?;
Ok(ClientResponse::ReleaseTerminalResponse(response))
}
AgentRequest::WaitForTerminalExitRequest(args) => {
let response = self.wait_for_terminal_exit(args).await?;
Ok(ClientResponse::WaitForTerminalExitResponse(response))
}
AgentRequest::KillTerminalCommandRequest(args) => {
self.kill_terminal_command(args).await?;
Ok(ClientResponse::KillTerminalResponse)
let response = self.kill_terminal_command(args).await?;
Ok(ClientResponse::KillTerminalResponse(response))
}
AgentRequest::ExtMethodRequest(args) => {
let response = self.ext_method(args.method, args.params).await?;
Expand Down Expand Up @@ -466,13 +471,17 @@ impl Client for AgentSideConnection {
.await
}

async fn write_text_file(&self, arguments: WriteTextFileRequest) -> Result<(), Error> {
async fn write_text_file(
&self,
arguments: WriteTextFileRequest,
) -> Result<WriteTextFileResponse, Error> {
self.conn
.request(
.request::<Option<_>>(
FS_WRITE_TEXT_FILE_METHOD_NAME,
Some(AgentRequest::WriteTextFileRequest(arguments)),
)
.await
.map(|value| value.unwrap_or_default())
}

async fn read_text_file(
Expand Down Expand Up @@ -511,13 +520,17 @@ impl Client for AgentSideConnection {
.await
}

async fn release_terminal(&self, arguments: ReleaseTerminalRequest) -> Result<(), Error> {
async fn release_terminal(
&self,
arguments: ReleaseTerminalRequest,
) -> Result<ReleaseTerminalResponse, Error> {
self.conn
.request(
.request::<Option<_>>(
TERMINAL_RELEASE_METHOD_NAME,
Some(AgentRequest::ReleaseTerminalRequest(arguments)),
)
.await
.map(|value| value.unwrap_or_default())
}

async fn wait_for_terminal_exit(
Expand All @@ -535,13 +548,14 @@ impl Client for AgentSideConnection {
async fn kill_terminal_command(
&self,
arguments: KillTerminalCommandRequest,
) -> Result<(), Error> {
) -> Result<KillTerminalCommandResponse, Error> {
self.conn
.request(
.request::<Option<_>>(
TERMINAL_KILL_METHOD_NAME,
Some(AgentRequest::KillTerminalCommandRequest(arguments)),
)
.await
.map(|value| value.unwrap_or_default())
}

async fn session_notification(&self, notification: SessionNotification) -> Result<(), Error> {
Expand Down Expand Up @@ -657,8 +671,8 @@ impl<T: Agent> MessageHandler<AgentSide> for T {
Ok(AgentResponse::InitializeResponse(response))
}
ClientRequest::AuthenticateRequest(args) => {
self.authenticate(args).await?;
Ok(AgentResponse::AuthenticateResponse)
let response = self.authenticate(args).await?;
Ok(AgentResponse::AuthenticateResponse(response))
}
ClientRequest::NewSessionRequest(args) => {
let response = self.new_session(args).await?;
Expand Down
Loading