Skip to content

Commit 119146f

Browse files
agu-zcole-miller
andauthored
Send available commands over notifications (#62)
Co-authored-by: Cole Miller <cole@zed.dev>
1 parent 88e2477 commit 119146f

File tree

5 files changed

+178
-149
lines changed

5 files changed

+178
-149
lines changed

docs/protocol/schema.mdx

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -250,12 +250,6 @@ See protocol docs: [Creating a Session](https://agentclientprotocol.com/protocol
250250

251251
**Properties:**
252252

253-
<ResponseField name="availableCommands" type={<><span><a href="#availablecommand">AvailableCommand</a></span><span>[]</span></>} >
254-
**UNSTABLE**
255-
256-
Commands that may be executed via `session/prompt` requests
257-
258-
</ResponseField>
259253
<ResponseField name="sessionId" type={<a href="#sessionid">SessionId</a>} required>
260254
Unique identifier for the created session.
261255

@@ -1518,6 +1512,28 @@ with their current status. The client replaces the entire plan with each update.
15181512
</Expandable>
15191513
</ResponseField>
15201514

1515+
<ResponseField name="available_commands_update">
1516+
Available commands are ready or have changed
1517+
1518+
<Expandable title="Properties">
1519+
1520+
<ResponseField
1521+
name="availableCommands"
1522+
type={
1523+
<>
1524+
<span>
1525+
<a href="#availablecommand">AvailableCommand</a>
1526+
</span>
1527+
<span>[]</span>
1528+
</>
1529+
}
1530+
required
1531+
></ResponseField>
1532+
<ResponseField name="sessionUpdate" type={"string"} required></ResponseField>
1533+
1534+
</Expandable>
1535+
</ResponseField>
1536+
15211537
## <span class="font-mono">StopReason</span>
15221538

15231539
Reasons why an agent stops processing a prompt turn.

rust/agent.rs

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -204,37 +204,6 @@ pub struct NewSessionResponse {
204204
///
205205
/// Used in all subsequent requests for this conversation.
206206
pub session_id: SessionId,
207-
/// **UNSTABLE**
208-
///
209-
/// Commands that may be executed via `session/prompt` requests
210-
#[cfg(feature = "unstable")]
211-
#[serde(default, skip_serializing_if = "Vec::is_empty")]
212-
pub available_commands: Vec<AvailableCommand>,
213-
}
214-
215-
/// Information about a command.
216-
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
217-
#[serde(rename_all = "camelCase")]
218-
#[cfg(feature = "unstable")]
219-
pub struct AvailableCommand {
220-
/// Command name (e.g., "create_plan", "research_codebase").
221-
pub name: String,
222-
/// Human-readable description of what the command does.
223-
pub description: String,
224-
/// Input for the command if required
225-
pub input: Option<AvailableCommandInput>,
226-
}
227-
228-
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
229-
#[serde(untagged, rename_all = "camelCase")]
230-
#[cfg(feature = "unstable")]
231-
pub enum AvailableCommandInput {
232-
/// All text that was typed after the command name is provided as input.
233-
#[schemars(rename = "UnstructuredCommandInput")]
234-
Unstructured {
235-
/// A brief description of the expected input
236-
hint: String,
237-
},
238207
}
239208

240209
// Load session

rust/client.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,38 @@ pub enum SessionUpdate {
158158
/// The agent's execution plan for complex tasks.
159159
/// See protocol docs: [Agent Plan](https://agentclientprotocol.com/protocol/agent-plan)
160160
Plan(Plan),
161+
/// Available commands are ready or have changed
162+
#[cfg(feature = "unstable")]
163+
#[serde(rename_all = "camelCase")]
164+
#[schemars(extend("x-docs-ignore" = true))]
165+
AvailableCommandsUpdate {
166+
available_commands: Vec<AvailableCommand>,
167+
},
168+
}
169+
170+
/// Information about a command.
171+
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
172+
#[serde(rename_all = "camelCase")]
173+
#[cfg(feature = "unstable")]
174+
pub struct AvailableCommand {
175+
/// Command name (e.g., "create_plan", "research_codebase").
176+
pub name: String,
177+
/// Human-readable description of what the command does.
178+
pub description: String,
179+
/// Input for the command if required
180+
pub input: Option<AvailableCommandInput>,
181+
}
182+
183+
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
184+
#[serde(untagged, rename_all = "camelCase")]
185+
#[cfg(feature = "unstable")]
186+
pub enum AvailableCommandInput {
187+
/// All text that was typed after the command name is provided as input.
188+
#[schemars(rename = "UnstructuredCommandInput")]
189+
Unstructured {
190+
/// A brief description of the expected input
191+
hint: String,
192+
},
161193
}
162194

163195
// Permission

schema/schema.json

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -765,13 +765,6 @@
765765
"NewSessionResponse": {
766766
"description": "Response from creating a new session.\n\nSee protocol docs: [Creating a Session](https://agentclientprotocol.com/protocol/session-setup#creating-a-session)",
767767
"properties": {
768-
"availableCommands": {
769-
"description": "**UNSTABLE**\n\nCommands that may be executed via `session/prompt` requests",
770-
"items": {
771-
"$ref": "#/$defs/AvailableCommand"
772-
},
773-
"type": "array"
774-
},
775768
"sessionId": {
776769
"$ref": "#/$defs/SessionId",
777770
"description": "Unique identifier for the created session.\n\nUsed in all subsequent requests for this conversation."
@@ -1316,6 +1309,24 @@
13161309
},
13171310
"required": ["sessionUpdate", "entries"],
13181311
"type": "object"
1312+
},
1313+
{
1314+
"description": "Available commands are ready or have changed",
1315+
"properties": {
1316+
"availableCommands": {
1317+
"items": {
1318+
"$ref": "#/$defs/AvailableCommand"
1319+
},
1320+
"type": "array"
1321+
},
1322+
"sessionUpdate": {
1323+
"const": "available_commands_update",
1324+
"type": "string"
1325+
}
1326+
},
1327+
"required": ["sessionUpdate", "availableCommands"],
1328+
"type": "object",
1329+
"x-docs-ignore": true
13191330
}
13201331
]
13211332
},

0 commit comments

Comments
 (0)