Skip to content

Commit 5c56e54

Browse files
SteffenDEbenbrandt
andauthored
feat(unstable): add cwd and mcp_servers to session/fork (#333)
* feat(unstable): add cwd and mcp_servers to session/fork See #326. I did not run generate yet, as it changes a bunch of unrelated lines for me. * Generate schema --------- Co-authored-by: Ben Brandt <[email protected]>
1 parent a0f431a commit 5c56e54

File tree

4 files changed

+35
-7
lines changed

4 files changed

+35
-7
lines changed

docs/protocol/draft/schema.mdx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,12 @@ these keys.
235235

236236
See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
237237

238+
</ResponseField>
239+
<ResponseField name="cwd" type={"string"} required>
240+
The working directory for this session.
241+
</ResponseField>
242+
<ResponseField name="mcpServers" type={<><span><a href="#mcpserver">McpServer</a></span><span>[]</span></>} >
243+
List of MCP servers to connect to for this session.
238244
</ResponseField>
239245
<ResponseField name="sessionId" type={<a href="#sessionid">SessionId</a>} required>
240246
The ID of the session to fork.

schema/schema.unstable.json

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1134,6 +1134,17 @@
11341134
"description": "The _meta property is reserved by ACP to allow clients and agents to attach additional\nmetadata to their interactions. Implementations MUST NOT make assumptions about values at\nthese keys.\n\nSee protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)",
11351135
"type": ["object", "null"]
11361136
},
1137+
"cwd": {
1138+
"description": "The working directory for this session.",
1139+
"type": "string"
1140+
},
1141+
"mcpServers": {
1142+
"description": "List of MCP servers to connect to for this session.",
1143+
"items": {
1144+
"$ref": "#/$defs/McpServer"
1145+
},
1146+
"type": "array"
1147+
},
11371148
"sessionId": {
11381149
"allOf": [
11391150
{
@@ -1143,7 +1154,7 @@
11431154
"description": "The ID of the session to fork."
11441155
}
11451156
},
1146-
"required": ["sessionId"],
1157+
"required": ["sessionId", "cwd"],
11471158
"type": "object",
11481159
"x-method": "session/fork",
11491160
"x-side": "agent"

src/agent.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,11 @@ impl LoadSessionResponse {
621621
pub struct ForkSessionRequest {
622622
/// The ID of the session to fork.
623623
pub session_id: SessionId,
624+
/// The working directory for this session.
625+
pub cwd: PathBuf,
626+
/// List of MCP servers to connect to for this session.
627+
#[serde(default, skip_serializing_if = "Vec::is_empty")]
628+
pub mcp_servers: Vec<McpServer>,
624629
/// The _meta property is reserved by ACP to allow clients and agents to attach additional
625630
/// metadata to their interactions. Implementations MUST NOT make assumptions about values at
626631
/// these keys.
@@ -632,13 +637,22 @@ pub struct ForkSessionRequest {
632637

633638
#[cfg(feature = "unstable_session_fork")]
634639
impl ForkSessionRequest {
635-
pub fn new(session_id: impl Into<SessionId>) -> Self {
640+
pub fn new(session_id: impl Into<SessionId>, cwd: impl Into<PathBuf>) -> Self {
636641
Self {
637642
session_id: session_id.into(),
643+
cwd: cwd.into(),
644+
mcp_servers: vec![],
638645
meta: None,
639646
}
640647
}
641648

649+
/// List of MCP servers to connect to for this session.
650+
#[must_use]
651+
pub fn mcp_servers(mut self, mcp_servers: Vec<McpServer>) -> Self {
652+
self.mcp_servers = mcp_servers;
653+
self
654+
}
655+
642656
/// The _meta property is reserved by ACP to allow clients and agents to attach additional
643657
/// metadata to their interactions. Implementations MUST NOT make assumptions about values at
644658
/// these keys.

src/bin/generate.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -759,11 +759,8 @@ starting with '$/' it is free to ignore the notification."
759759
other_type = Some(t);
760760
}
761761
}
762-
if has_null && other_type.is_some() {
763-
return format!(
764-
"<><span>{}</span><span> | null</span></>",
765-
other_type.unwrap()
766-
);
762+
if has_null && let Some(other_type) = other_type {
763+
return format!("<><span>{other_type}</span><span> | null</span></>");
767764
}
768765
}
769766
return "union".to_string();

0 commit comments

Comments
 (0)