Skip to content

Commit 0cf2b8c

Browse files
committed
Merge branch 'main' into add-custom-commands
2 parents 5f0ce45 + d43b72f commit 0cf2b8c

13 files changed

Lines changed: 130 additions & 12 deletions

File tree

AGENTS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ All paths in the protocol should be absolute
2121
- Add constants for the method names
2222
- Add variants to {Agent|Client}{Request|Response} enums
2323
- Add the methods to the Client/Agent impl of {Agent|Client}SideConnection in rust/acp.rs
24-
- Handle the method in the decoders
24+
- Handle the new method in the `Side::decode_request`/`Side::decode_notification` implementation
2525
- Handle the new request in the blanket impl of MessageHandler<{Agent|Client}Side>
2626
- Add the method to markdown_generator.rs SideDocs functions
2727
- Run `npm run generate` and fix any issues that appear

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "agent-client-protocol"
33
authors = ["Zed <hi@zed.dev>"]
4-
version = "0.2.0-alpha.0"
4+
version = "0.2.0-alpha.3"
55
edition = "2024"
66
license = "Apache-2.0"
77
description = "A protocol for standardizing communication between code editors and AI coding agents"

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@zed-industries/agent-client-protocol",
3-
"version": "0.2.0-alpha.0",
3+
"version": "0.2.0-alpha.3",
44
"publishConfig": {
55
"access": "public"
66
},

rust/acp.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,10 @@ impl Side for ClientSide {
266266
.map(AgentRequest::TerminalOutputRequest)
267267
.map_err(Into::into),
268268
#[cfg(feature = "unstable")]
269+
TERMINAL_KILL_METHOD_NAME => serde_json::from_str(params.get())
270+
.map(AgentRequest::KillTerminalRequest)
271+
.map_err(Into::into),
272+
#[cfg(feature = "unstable")]
269273
TERMINAL_RELEASE_METHOD_NAME => serde_json::from_str(params.get())
270274
.map(AgentRequest::ReleaseTerminalRequest)
271275
.map_err(Into::into),
@@ -327,6 +331,11 @@ impl<T: Client> MessageHandler<ClientSide> for T {
327331
let response = self.wait_for_terminal_exit(args).await?;
328332
Ok(ClientResponse::WaitForTerminalExitResponse(response))
329333
}
334+
#[cfg(feature = "unstable")]
335+
AgentRequest::KillTerminalRequest(args) => {
336+
self.kill_terminal(args).await?;
337+
Ok(ClientResponse::KillTerminalResponse)
338+
}
330339
}
331340
}
332341

@@ -480,6 +489,16 @@ impl Client for AgentSideConnection {
480489
.await
481490
}
482491

492+
#[cfg(feature = "unstable")]
493+
async fn kill_terminal(&self, arguments: KillTerminalRequest) -> Result<(), Error> {
494+
self.conn
495+
.request(
496+
TERMINAL_KILL_METHOD_NAME,
497+
Some(AgentRequest::KillTerminalRequest(arguments)),
498+
)
499+
.await
500+
}
501+
483502
async fn session_notification(&self, notification: SessionNotification) -> Result<(), Error> {
484503
self.conn.notify(
485504
SESSION_UPDATE_NOTIFICATION,

rust/client.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,13 @@ pub trait Client {
111111
&self,
112112
args: WaitForTerminalExitRequest,
113113
) -> impl Future<Output = Result<WaitForTerminalExitResponse, Error>>;
114+
115+
/// **UNSTABLE**
116+
///
117+
/// This method is not part of the spec, and may be removed or changed at any point.
118+
#[doc(hidden)]
119+
#[cfg(feature = "unstable")]
120+
fn kill_terminal(&self, args: KillTerminalRequest) -> impl Future<Output = Result<(), Error>>;
114121
}
115122

116123
// Session updates
@@ -353,6 +360,15 @@ pub struct ReleaseTerminalRequest {
353360
pub terminal_id: TerminalId,
354361
}
355362

363+
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
364+
#[schemars(extend("x-docs-ignore" = true))]
365+
#[serde(rename_all = "camelCase")]
366+
#[cfg(feature = "unstable")]
367+
pub struct KillTerminalRequest {
368+
pub session_id: SessionId,
369+
pub terminal_id: TerminalId,
370+
}
371+
356372
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
357373
#[schemars(extend("x-docs-ignore" = true))]
358374
#[serde(rename_all = "camelCase")]
@@ -445,6 +461,9 @@ pub struct ClientMethodNames {
445461
/// Method for waiting for a terminal to finish.
446462
#[cfg(feature = "unstable")]
447463
pub terminal_wait_for_exit: &'static str,
464+
/// Method for killing a terminal.
465+
#[cfg(feature = "unstable")]
466+
pub terminal_kill: &'static str,
448467
}
449468

450469
/// Constant containing all client method names.
@@ -461,6 +480,8 @@ pub const CLIENT_METHOD_NAMES: ClientMethodNames = ClientMethodNames {
461480
terminal_release: TERMINAL_RELEASE_METHOD_NAME,
462481
#[cfg(feature = "unstable")]
463482
terminal_wait_for_exit: TERMINAL_WAIT_FOR_EXIT_METHOD_NAME,
483+
#[cfg(feature = "unstable")]
484+
terminal_kill: TERMINAL_KILL_METHOD_NAME,
464485
};
465486

466487
/// Notification name for session updates.
@@ -483,6 +504,9 @@ pub(crate) const TERMINAL_RELEASE_METHOD_NAME: &str = "terminal/release";
483504
/// Method for waiting for a terminal to finish.
484505
#[cfg(feature = "unstable")]
485506
pub(crate) const TERMINAL_WAIT_FOR_EXIT_METHOD_NAME: &str = "terminal/wait_for_exit";
507+
/// Method for killing a terminal.
508+
#[cfg(feature = "unstable")]
509+
pub(crate) const TERMINAL_KILL_METHOD_NAME: &str = "terminal/kill";
486510

487511
/// All possible requests that an agent can send to a client.
488512
///
@@ -505,6 +529,8 @@ pub enum AgentRequest {
505529
ReleaseTerminalRequest(ReleaseTerminalRequest),
506530
#[cfg(feature = "unstable")]
507531
WaitForTerminalExitRequest(WaitForTerminalExitRequest),
532+
#[cfg(feature = "unstable")]
533+
KillTerminalRequest(KillTerminalRequest),
508534
}
509535

510536
/// All possible responses that a client can send to an agent.
@@ -528,6 +554,8 @@ pub enum ClientResponse {
528554
ReleaseTerminalResponse,
529555
#[cfg(feature = "unstable")]
530556
WaitForTerminalExitResponse(WaitForTerminalExitResponse),
557+
#[cfg(feature = "unstable")]
558+
KillTerminalResponse,
531559
}
532560

533561
/// All possible notifications that an agent can send to a client.

rust/example_client.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,14 @@ impl acp::Client for ExampleClient {
7272
Err(acp::Error::method_not_found())
7373
}
7474

75+
#[cfg(feature = "unstable")]
76+
async fn kill_terminal(
77+
&self,
78+
_args: acp::KillTerminalRequest,
79+
) -> anyhow::Result<(), acp::Error> {
80+
Err(acp::Error::method_not_found())
81+
}
82+
7583
async fn session_notification(
7684
&self,
7785
args: acp::SessionNotification,

rust/markdown_generator.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,7 @@ impl SideDocs {
649649
"terminal/output" => self.client_methods.get("terminal_output").unwrap(),
650650
"terminal/release" => self.client_methods.get("release_terminal").unwrap(),
651651
"terminal/wait_for_exit" => self.client_methods.get("wait_for_terminal_exit").unwrap(),
652+
"terminal/kill" => self.client_methods.get("kill_terminal").unwrap(),
652653
_ => panic!("Introduced a method? Add it here :)"),
653654
}
654655
}

schema/meta.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"session_request_permission": "session/request_permission",
1515
"session_update": "session/update",
1616
"terminal_create": "terminal/create",
17+
"terminal_kill": "terminal/kill",
1718
"terminal_output": "terminal/output",
1819
"terminal_release": "terminal/release",
1920
"terminal_wait_for_exit": "terminal/wait_for_exit"

0 commit comments

Comments
 (0)