Skip to content

Commit 12e2b09

Browse files
committed
Use unstable feature flag
1 parent 6fa24c3 commit 12e2b09

File tree

6 files changed

+81
-23
lines changed

6 files changed

+81
-23
lines changed

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ keywords = ["agent", "client", "protocol", "ai", "editor"]
1313
categories = ["development-tools", "api-bindings"]
1414
include = ["/rust/**/*.rs", "/README.md", "/LICENSE-APACHE", "/Cargo.toml"]
1515

16+
[features]
17+
unstable = []
18+
1619
[lib]
1720
path = "rust/acp.rs"
1821
doctest = false

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"test": "cargo check --all-targets && cargo test && vitest run",
3535
"test:ts": "vitest run",
3636
"test:ts:watch": "vitest",
37-
"generate:json-schema": "cd rust && cargo run --bin generate",
37+
"generate:json-schema": "cd rust && cargo run --bin generate --features unstable",
3838
"generate:ts-schema": "node typescript/generate.js",
3939
"generate": "npm run generate:json-schema && npm run generate:ts-schema && npm run format",
4040
"build": "npm run generate && tsc",

rust/acp.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,15 +245,19 @@ impl Side for ClientSide {
245245
FS_READ_TEXT_FILE_METHOD_NAME => serde_json::from_str(params.get())
246246
.map(AgentRequest::ReadTextFileRequest)
247247
.map_err(Into::into),
248+
#[cfg(feature = "unstable")]
248249
TERMINAL_CREATE_METHOD_NAME => serde_json::from_str(params.get())
249250
.map(AgentRequest::CreateTerminalRequest)
250251
.map_err(Into::into),
252+
#[cfg(feature = "unstable")]
251253
TERMINAL_OUTPUT_METHOD_NAME => serde_json::from_str(params.get())
252254
.map(AgentRequest::TerminalOutputRequest)
253255
.map_err(Into::into),
256+
#[cfg(feature = "unstable")]
254257
TERMINAL_RELEASE_METHOD_NAME => serde_json::from_str(params.get())
255258
.map(AgentRequest::ReleaseTerminalRequest)
256259
.map_err(Into::into),
260+
#[cfg(feature = "unstable")]
257261
TERMINAL_WAIT_FOR_EXIT_METHOD_NAME => serde_json::from_str(params.get())
258262
.map(AgentRequest::WaitForTerminalExitRequest)
259263
.map_err(Into::into),
@@ -291,18 +295,22 @@ impl<T: Client> MessageHandler<ClientSide> for T {
291295
let response = self.read_text_file(args).await?;
292296
Ok(ClientResponse::ReadTextFileResponse(response))
293297
}
298+
#[cfg(feature = "unstable")]
294299
AgentRequest::CreateTerminalRequest(args) => {
295300
let response = self.create_terminal(args).await?;
296301
Ok(ClientResponse::CreateTerminalResponse(response))
297302
}
303+
#[cfg(feature = "unstable")]
298304
AgentRequest::TerminalOutputRequest(args) => {
299305
let response = self.terminal_output(args).await?;
300306
Ok(ClientResponse::TerminalOutputResponse(response))
301307
}
308+
#[cfg(feature = "unstable")]
302309
AgentRequest::ReleaseTerminalRequest(args) => {
303310
self.release_terminal(args).await?;
304311
Ok(ClientResponse::ReleaseTerminalResponse)
305312
}
313+
#[cfg(feature = "unstable")]
306314
AgentRequest::WaitForTerminalExitRequest(args) => {
307315
let response = self.wait_for_terminal_exit(args).await?;
308316
Ok(ClientResponse::WaitForTerminalExitResponse(response))
@@ -411,6 +419,7 @@ impl Client for AgentSideConnection {
411419
.await
412420
}
413421

422+
#[cfg(feature = "unstable")]
414423
async fn create_terminal(
415424
&self,
416425
arguments: CreateTerminalRequest,
@@ -423,6 +432,7 @@ impl Client for AgentSideConnection {
423432
.await
424433
}
425434

435+
#[cfg(feature = "unstable")]
426436
async fn terminal_output(
427437
&self,
428438
arguments: TerminalOutputRequest,
@@ -435,6 +445,7 @@ impl Client for AgentSideConnection {
435445
.await
436446
}
437447

448+
#[cfg(feature = "unstable")]
438449
async fn release_terminal(&self, arguments: ReleaseTerminalRequest) -> Result<(), Error> {
439450
self.conn
440451
.request(
@@ -444,6 +455,7 @@ impl Client for AgentSideConnection {
444455
.await
445456
}
446457

458+
#[cfg(feature = "unstable")]
447459
async fn wait_for_terminal_exit(
448460
&self,
449461
arguments: WaitForTerminalExitRequest,

rust/client.rs

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use anyhow::Result;
99
use schemars::JsonSchema;
1010
use serde::{Deserialize, Serialize};
1111

12-
use crate::{ContentBlock, EnvVariable, Error, Plan, SessionId, ToolCall, ToolCallUpdate};
12+
use crate::{ContentBlock, Error, Plan, SessionId, ToolCall, ToolCallUpdate};
1313

1414
/// Defines the interface that ACP-compliant clients must implement.
1515
///
@@ -76,6 +76,7 @@ pub trait Client {
7676
///
7777
/// This method is not part of the spec, and may be removed or changed at any point.
7878
#[doc(hidden)]
79+
#[cfg(feature = "unstable")]
7980
fn create_terminal(
8081
&self,
8182
args: CreateTerminalRequest,
@@ -85,6 +86,7 @@ pub trait Client {
8586
///
8687
/// This method is not part of the spec, and may be removed or changed at any point.
8788
#[doc(hidden)]
89+
#[cfg(feature = "unstable")]
8890
fn terminal_output(
8991
&self,
9092
args: TerminalOutputRequest,
@@ -94,6 +96,7 @@ pub trait Client {
9496
///
9597
/// This method is not part of the spec, and may be removed or changed at any point.
9698
#[doc(hidden)]
99+
#[cfg(feature = "unstable")]
97100
fn release_terminal(
98101
&self,
99102
args: ReleaseTerminalRequest,
@@ -103,6 +106,7 @@ pub trait Client {
103106
///
104107
/// This method is not part of the spec, and may be removed or changed at any point.
105108
#[doc(hidden)]
109+
#[cfg(feature = "unstable")]
106110
fn wait_for_terminal_exit(
107111
&self,
108112
args: WaitForTerminalExitRequest,
@@ -286,8 +290,10 @@ pub struct ReadTextFileResponse {
286290

287291
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, PartialEq, Eq, Hash)]
288292
#[serde(transparent)]
293+
#[cfg(feature = "unstable")]
289294
pub struct TerminalId(pub Arc<str>);
290295

296+
#[cfg(feature = "unstable")]
291297
impl std::fmt::Display for TerminalId {
292298
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
293299
write!(f, "{}", self.0)
@@ -297,13 +303,14 @@ impl std::fmt::Display for TerminalId {
297303
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
298304
#[schemars(extend("x-docs-ignore" = true))]
299305
#[serde(rename_all = "camelCase")]
306+
#[cfg(feature = "unstable")]
300307
pub struct CreateTerminalRequest {
301308
pub session_id: SessionId,
302309
pub command: String,
303310
#[serde(default, skip_serializing_if = "Vec::is_empty")]
304311
pub args: Vec<String>,
305312
#[serde(default, skip_serializing_if = "Vec::is_empty")]
306-
pub env: Vec<EnvVariable>,
313+
pub env: Vec<crate::EnvVariable>,
307314
#[serde(default, skip_serializing_if = "Option::is_none")]
308315
pub cwd: Option<PathBuf>,
309316
#[serde(default, skip_serializing_if = "Option::is_none")]
@@ -313,13 +320,15 @@ pub struct CreateTerminalRequest {
313320
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
314321
#[schemars(extend("x-docs-ignore" = true))]
315322
#[serde(rename_all = "camelCase")]
323+
#[cfg(feature = "unstable")]
316324
pub struct CreateTerminalResponse {
317325
pub terminal_id: TerminalId,
318326
}
319327

320328
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
321329
#[schemars(extend("x-docs-ignore" = true))]
322330
#[serde(rename_all = "camelCase")]
331+
#[cfg(feature = "unstable")]
323332
pub struct TerminalOutputRequest {
324333
pub session_id: SessionId,
325334
pub terminal_id: TerminalId,
@@ -328,6 +337,7 @@ pub struct TerminalOutputRequest {
328337
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
329338
#[schemars(extend("x-docs-ignore" = true))]
330339
#[serde(rename_all = "camelCase")]
340+
#[cfg(feature = "unstable")]
331341
pub struct TerminalOutputResponse {
332342
pub output: String,
333343
pub truncated: bool,
@@ -337,6 +347,7 @@ pub struct TerminalOutputResponse {
337347
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
338348
#[schemars(extend("x-docs-ignore" = true))]
339349
#[serde(rename_all = "camelCase")]
350+
#[cfg(feature = "unstable")]
340351
pub struct ReleaseTerminalRequest {
341352
pub session_id: SessionId,
342353
pub terminal_id: TerminalId,
@@ -345,6 +356,7 @@ pub struct ReleaseTerminalRequest {
345356
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
346357
#[schemars(extend("x-docs-ignore" = true))]
347358
#[serde(rename_all = "camelCase")]
359+
#[cfg(feature = "unstable")]
348360
pub struct WaitForTerminalExitRequest {
349361
pub session_id: SessionId,
350362
pub terminal_id: TerminalId,
@@ -353,6 +365,7 @@ pub struct WaitForTerminalExitRequest {
353365
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
354366
#[schemars(extend("x-docs-ignore" = true))]
355367
#[serde(rename_all = "camelCase")]
368+
#[cfg(feature = "unstable")]
356369
pub struct WaitForTerminalExitResponse {
357370
#[serde(flatten)]
358371
pub exit_status: TerminalExitStatus,
@@ -361,6 +374,7 @@ pub struct WaitForTerminalExitResponse {
361374
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
362375
#[schemars(extend("x-docs-ignore" = true))]
363376
#[serde(rename_all = "camelCase")]
377+
#[cfg(feature = "unstable")]
364378
pub struct TerminalExitStatus {
365379
pub exit_code: Option<u32>,
366380
pub signal: Option<String>,
@@ -420,12 +434,16 @@ pub struct ClientMethodNames {
420434
/// Method for reading text files.
421435
pub fs_read_text_file: &'static str,
422436
/// Method for creating new terminals.
437+
#[cfg(feature = "unstable")]
423438
pub terminal_create: &'static str,
424439
/// Method for getting terminals output.
440+
#[cfg(feature = "unstable")]
425441
pub terminal_output: &'static str,
426442
/// Method for releasing a terminal.
443+
#[cfg(feature = "unstable")]
427444
pub terminal_release: &'static str,
428445
/// Method for waiting for a terminal to finish.
446+
#[cfg(feature = "unstable")]
429447
pub terminal_wait_for_exit: &'static str,
430448
}
431449

@@ -435,9 +453,13 @@ pub const CLIENT_METHOD_NAMES: ClientMethodNames = ClientMethodNames {
435453
session_request_permission: SESSION_REQUEST_PERMISSION_METHOD_NAME,
436454
fs_write_text_file: FS_WRITE_TEXT_FILE_METHOD_NAME,
437455
fs_read_text_file: FS_READ_TEXT_FILE_METHOD_NAME,
456+
#[cfg(feature = "unstable")]
438457
terminal_create: TERMINAL_CREATE_METHOD_NAME,
458+
#[cfg(feature = "unstable")]
439459
terminal_output: TERMINAL_OUTPUT_METHOD_NAME,
460+
#[cfg(feature = "unstable")]
440461
terminal_release: TERMINAL_RELEASE_METHOD_NAME,
462+
#[cfg(feature = "unstable")]
441463
terminal_wait_for_exit: TERMINAL_WAIT_FOR_EXIT_METHOD_NAME,
442464
};
443465

@@ -450,12 +472,16 @@ pub(crate) const FS_WRITE_TEXT_FILE_METHOD_NAME: &str = "fs/write_text_file";
450472
/// Method name for reading text files.
451473
pub(crate) const FS_READ_TEXT_FILE_METHOD_NAME: &str = "fs/read_text_file";
452474
/// Method name for creating a new terminal.
475+
#[cfg(feature = "unstable")]
453476
pub(crate) const TERMINAL_CREATE_METHOD_NAME: &str = "terminal/create";
454477
/// Method for getting terminals output.
478+
#[cfg(feature = "unstable")]
455479
pub(crate) const TERMINAL_OUTPUT_METHOD_NAME: &str = "terminal/output";
456480
/// Method for releasing a terminal.
481+
#[cfg(feature = "unstable")]
457482
pub(crate) const TERMINAL_RELEASE_METHOD_NAME: &str = "terminal/release";
458483
/// Method for waiting for a terminal to finish.
484+
#[cfg(feature = "unstable")]
459485
pub(crate) const TERMINAL_WAIT_FOR_EXIT_METHOD_NAME: &str = "terminal/wait_for_exit";
460486

461487
/// All possible requests that an agent can send to a client.
@@ -471,9 +497,13 @@ pub enum AgentRequest {
471497
WriteTextFileRequest(WriteTextFileRequest),
472498
ReadTextFileRequest(ReadTextFileRequest),
473499
RequestPermissionRequest(RequestPermissionRequest),
500+
#[cfg(feature = "unstable")]
474501
CreateTerminalRequest(CreateTerminalRequest),
502+
#[cfg(feature = "unstable")]
475503
TerminalOutputRequest(TerminalOutputRequest),
504+
#[cfg(feature = "unstable")]
476505
ReleaseTerminalRequest(ReleaseTerminalRequest),
506+
#[cfg(feature = "unstable")]
477507
WaitForTerminalExitRequest(WaitForTerminalExitRequest),
478508
}
479509

@@ -490,9 +520,13 @@ pub enum ClientResponse {
490520
WriteTextFileResponse,
491521
ReadTextFileResponse(ReadTextFileResponse),
492522
RequestPermissionResponse(RequestPermissionResponse),
523+
#[cfg(feature = "unstable")]
493524
CreateTerminalResponse(CreateTerminalResponse),
525+
#[cfg(feature = "unstable")]
494526
TerminalOutputResponse(TerminalOutputResponse),
527+
#[cfg(feature = "unstable")]
495528
ReleaseTerminalResponse,
529+
#[cfg(feature = "unstable")]
496530
WaitForTerminalExitResponse(WaitForTerminalExitResponse),
497531
}
498532

rust/tool_call.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use std::{path::PathBuf, sync::Arc};
99
use schemars::JsonSchema;
1010
use serde::{Deserialize, Serialize};
1111

12-
use crate::{ContentBlock, Error, TerminalId};
12+
use crate::{ContentBlock, Error};
1313

1414
/// Represents a tool call that the language model has requested.
1515
///
@@ -275,7 +275,8 @@ pub enum ToolCallContent {
275275
diff: Diff,
276276
},
277277
#[serde(rename_all = "camelCase")]
278-
Terminal { terminal_id: TerminalId },
278+
#[cfg(feature = "unstable")]
279+
Terminal { terminal_id: crate::TerminalId },
279280
}
280281

281282
impl<T: Into<ContentBlock>> From<T> for ToolCallContent {

typescript/acp.ts

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -293,28 +293,28 @@ export class ClientSideConnection implements Agent {
293293
case schema.CLIENT_METHODS.terminal_create: {
294294
const validatedParams =
295295
schema.createTerminalRequestSchema.parse(params);
296-
return client.createTerminal(
296+
return client.createTerminal?.(
297297
validatedParams as schema.CreateTerminalRequest,
298298
);
299299
}
300300
case schema.CLIENT_METHODS.terminal_output: {
301301
const validatedParams =
302302
schema.terminalOutputRequestSchema.parse(params);
303-
return client.terminalOutput(
303+
return client.terminalOutput?.(
304304
validatedParams as schema.TerminalOutputRequest,
305305
);
306306
}
307307
case schema.CLIENT_METHODS.terminal_release: {
308308
const validatedParams =
309309
schema.releaseTerminalRequestSchema.parse(params);
310-
return client.releaseTerminal(
310+
return client.releaseTerminal?.(
311311
validatedParams as schema.ReleaseTerminalRequest,
312312
);
313313
}
314314
case schema.CLIENT_METHODS.terminal_wait_for_exit: {
315315
const validatedParams =
316316
schema.waitForTerminalExitRequestSchema.parse(params);
317-
return client.waitForTerminalExit(
317+
return client.waitForTerminalExit?.(
318318
validatedParams as schema.WaitForTerminalExitRequest,
319319
);
320320
}
@@ -798,30 +798,38 @@ export interface Client {
798798
readTextFile(
799799
params: schema.ReadTextFileRequest,
800800
): Promise<schema.ReadTextFileResponse>;
801+
801802
/**
802-
* Creates a new terminal instance in the client's environment.
803-
*
804-
* Only available if the client advertises the `terminal` capability.
805-
* Allows the agent to spawn and interact with terminal processes.
803+
* @internal **UNSTABLE**
806804
*
807-
* See protocol docs: [Client](https://agentclientprotocol.com/protocol/overview#client)
805+
* This method is not part of the spec, and may be removed or changed at any point.
808806
*/
809-
createTerminal(
807+
createTerminal?(
810808
params: schema.CreateTerminalRequest,
811809
): Promise<schema.CreateTerminalResponse>;
810+
812811
/**
813-
* Retrieves output from a previously created terminal.
814-
*
815-
* Only available if the client advertises the `terminal` capability.
816-
* Returns the terminal's output buffer and exit status if available.
812+
* @internal **UNSTABLE**
817813
*
818-
* See protocol docs: [Client](https://agentclientprotocol.com/protocol/overview#client)
814+
* This method is not part of the spec, and may be removed or changed at any point.
819815
*/
820-
terminalOutput(
816+
terminalOutput?(
821817
params: schema.TerminalOutputRequest,
822818
): Promise<schema.TerminalOutputResponse>;
823-
releaseTerminal(params: schema.ReleaseTerminalRequest): Promise<void>;
824-
waitForTerminalExit(
819+
820+
/**
821+
* @internal **UNSTABLE**
822+
*
823+
* This method is not part of the spec, and may be removed or changed at any point.
824+
*/
825+
releaseTerminal?(params: schema.ReleaseTerminalRequest): Promise<void>;
826+
827+
/**
828+
* @internal **UNSTABLE**
829+
*
830+
* This method is not part of the spec, and may be removed or changed at any point.
831+
*/
832+
waitForTerminalExit?(
825833
params: schema.WaitForTerminalExitRequest,
826834
): Promise<schema.WaitForTerminalExitResponse>;
827835
}

0 commit comments

Comments
 (0)