diff --git a/docs/protocol/schema.mdx b/docs/protocol/schema.mdx index d5d46aa9..b6da6580 100644 --- a/docs/protocol/schema.mdx +++ b/docs/protocol/schema.mdx @@ -250,12 +250,6 @@ See protocol docs: [Creating a Session](https://agentclientprotocol.com/protocol **Properties:** -AvailableCommand[]} > - **UNSTABLE** - -Commands that may be executed via `session/prompt` requests - - SessionId} required> Unique identifier for the created session. @@ -1518,6 +1512,28 @@ with their current status. The client replaces the entire plan with each update. + +Available commands are ready or have changed + + + + + + AvailableCommand + + [] + + } + required +> + + + + + ## StopReason Reasons why an agent stops processing a prompt turn. diff --git a/rust/agent.rs b/rust/agent.rs index b172eb35..ffeda9a3 100644 --- a/rust/agent.rs +++ b/rust/agent.rs @@ -204,37 +204,6 @@ pub struct NewSessionResponse { /// /// Used in all subsequent requests for this conversation. pub session_id: SessionId, - /// **UNSTABLE** - /// - /// Commands that may be executed via `session/prompt` requests - #[cfg(feature = "unstable")] - #[serde(default, skip_serializing_if = "Vec::is_empty")] - pub available_commands: Vec, -} - -/// Information about a command. -#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)] -#[serde(rename_all = "camelCase")] -#[cfg(feature = "unstable")] -pub struct AvailableCommand { - /// Command name (e.g., "create_plan", "research_codebase"). - pub name: String, - /// Human-readable description of what the command does. - pub description: String, - /// Input for the command if required - pub input: Option, -} - -#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)] -#[serde(untagged, rename_all = "camelCase")] -#[cfg(feature = "unstable")] -pub enum AvailableCommandInput { - /// All text that was typed after the command name is provided as input. - #[schemars(rename = "UnstructuredCommandInput")] - Unstructured { - /// A brief description of the expected input - hint: String, - }, } // Load session diff --git a/rust/client.rs b/rust/client.rs index a24c8006..bc910564 100644 --- a/rust/client.rs +++ b/rust/client.rs @@ -158,6 +158,38 @@ pub enum SessionUpdate { /// The agent's execution plan for complex tasks. /// See protocol docs: [Agent Plan](https://agentclientprotocol.com/protocol/agent-plan) Plan(Plan), + /// Available commands are ready or have changed + #[cfg(feature = "unstable")] + #[serde(rename_all = "camelCase")] + #[schemars(extend("x-docs-ignore" = true))] + AvailableCommandsUpdate { + available_commands: Vec, + }, +} + +/// Information about a command. +#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)] +#[serde(rename_all = "camelCase")] +#[cfg(feature = "unstable")] +pub struct AvailableCommand { + /// Command name (e.g., "create_plan", "research_codebase"). + pub name: String, + /// Human-readable description of what the command does. + pub description: String, + /// Input for the command if required + pub input: Option, +} + +#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)] +#[serde(untagged, rename_all = "camelCase")] +#[cfg(feature = "unstable")] +pub enum AvailableCommandInput { + /// All text that was typed after the command name is provided as input. + #[schemars(rename = "UnstructuredCommandInput")] + Unstructured { + /// A brief description of the expected input + hint: String, + }, } // Permission diff --git a/schema/schema.json b/schema/schema.json index f77bef1e..f583f213 100644 --- a/schema/schema.json +++ b/schema/schema.json @@ -765,13 +765,6 @@ "NewSessionResponse": { "description": "Response from creating a new session.\n\nSee protocol docs: [Creating a Session](https://agentclientprotocol.com/protocol/session-setup#creating-a-session)", "properties": { - "availableCommands": { - "description": "**UNSTABLE**\n\nCommands that may be executed via `session/prompt` requests", - "items": { - "$ref": "#/$defs/AvailableCommand" - }, - "type": "array" - }, "sessionId": { "$ref": "#/$defs/SessionId", "description": "Unique identifier for the created session.\n\nUsed in all subsequent requests for this conversation." @@ -1316,6 +1309,24 @@ }, "required": ["sessionUpdate", "entries"], "type": "object" + }, + { + "description": "Available commands are ready or have changed", + "properties": { + "availableCommands": { + "items": { + "$ref": "#/$defs/AvailableCommand" + }, + "type": "array" + }, + "sessionUpdate": { + "const": "available_commands_update", + "type": "string" + } + }, + "required": ["sessionUpdate", "availableCommands"], + "type": "object", + "x-docs-ignore": true } ] }, diff --git a/typescript/schema.ts b/typescript/schema.ts index 1c6023f1..2098829d 100644 --- a/typescript/schema.ts +++ b/typescript/schema.ts @@ -295,7 +295,6 @@ export type AgentResponse = | LoadSessionResponse | PromptResponse; export type AuthenticateResponse = null; -export type AvailableCommandInput = UnstructuredCommandInput; export type LoadSessionResponse = null; /** * All possible notifications that an agent can send to a client. @@ -307,6 +306,7 @@ export type LoadSessionResponse = null; */ /** @internal */ export type AgentNotification = SessionNotification; +export type AvailableCommandInput = UnstructuredCommandInput; /** * Request to write content to a text file. @@ -816,12 +816,6 @@ export interface AuthMethod { * See protocol docs: [Creating a Session](https://agentclientprotocol.com/protocol/session-setup#creating-a-session) */ export interface NewSessionResponse { - /** - * **UNSTABLE** - * - * Commands that may be executed via `session/prompt` requests - */ - availableCommands?: AvailableCommand[]; /** * A unique identifier for a conversation session between a client and agent. * @@ -841,32 +835,6 @@ export interface NewSessionResponse { */ sessionId: string; } -/** - * Information about a command. - */ -export interface AvailableCommand { - /** - * Human-readable description of what the command does. - */ - description: string; - /** - * Input for the command if required - */ - input?: AvailableCommandInput | null; - /** - * Command name (e.g., "create_plan", "research_codebase"). - */ - name: string; -} -/** - * All text that was typed after the command name is provided as input. - */ -export interface UnstructuredCommandInput { - /** - * A brief description of the expected input - */ - hint: string; -} /** * Response from processing a user prompt. * @@ -1009,6 +977,10 @@ export interface SessionNotification { */ entries: PlanEntry[]; sessionUpdate: "plan"; + } + | { + availableCommands: AvailableCommand[]; + sessionUpdate: "available_commands_update"; }; } /** @@ -1033,6 +1005,32 @@ export interface PlanEntry { */ status: "pending" | "in_progress" | "completed"; } +/** + * Information about a command. + */ +export interface AvailableCommand { + /** + * Human-readable description of what the command does. + */ + description: string; + /** + * Input for the command if required + */ + input?: AvailableCommandInput | null; + /** + * Command name (e.g., "create_plan", "research_codebase"). + */ + name: string; +} +/** + * All text that was typed after the command name is provided as input. + */ +export interface UnstructuredCommandInput { + /** + * A brief description of the expected input + */ + hint: string; +} /** @internal */ export const writeTextFileRequestSchema = z.object({ @@ -1154,6 +1152,11 @@ export const embeddedResourceResourceSchema = z.union([ /** @internal */ export const authenticateResponseSchema = z.null(); +/** @internal */ +export const newSessionResponseSchema = z.object({ + sessionId: z.string(), +}); + /** @internal */ export const loadSessionResponseSchema = z.null(); @@ -1351,9 +1354,6 @@ export const promptCapabilitiesSchema = z.object({ image: z.boolean().optional(), }); -/** @internal */ -export const availableCommandInputSchema = unstructuredCommandInputSchema; - /** @internal */ export const planEntrySchema = z.object({ content: z.string(), @@ -1365,6 +1365,9 @@ export const planEntrySchema = z.object({ ]), }); +/** @internal */ +export const availableCommandInputSchema = unstructuredCommandInputSchema; + /** @internal */ export const clientNotificationSchema = cancelNotificationSchema; @@ -1397,70 +1400,6 @@ export const promptRequestSchema = z.object({ sessionId: z.string(), }); -/** @internal */ -export const sessionNotificationSchema = z.object({ - sessionId: z.string(), - update: z.union([ - z.object({ - content: contentBlockSchema, - sessionUpdate: z.literal("user_message_chunk"), - }), - z.object({ - content: contentBlockSchema, - sessionUpdate: z.literal("agent_message_chunk"), - }), - z.object({ - content: contentBlockSchema, - sessionUpdate: z.literal("agent_thought_chunk"), - }), - z.object({ - content: z.array(toolCallContentSchema).optional(), - kind: z - .union([ - z.literal("read"), - z.literal("edit"), - z.literal("delete"), - z.literal("move"), - z.literal("search"), - z.literal("execute"), - z.literal("think"), - z.literal("fetch"), - z.literal("other"), - ]) - .optional(), - locations: z.array(toolCallLocationSchema).optional(), - rawInput: z.record(z.unknown()).optional(), - rawOutput: z.record(z.unknown()).optional(), - sessionUpdate: z.literal("tool_call"), - status: z - .union([ - z.literal("pending"), - z.literal("in_progress"), - z.literal("completed"), - z.literal("failed"), - ]) - .optional(), - title: z.string(), - toolCallId: z.string(), - }), - z.object({ - content: z.array(toolCallContentSchema).optional().nullable(), - kind: toolKindSchema.optional().nullable(), - locations: z.array(toolCallLocationSchema).optional().nullable(), - rawInput: z.record(z.unknown()).optional(), - rawOutput: z.record(z.unknown()).optional(), - sessionUpdate: z.literal("tool_call_update"), - status: toolCallStatusSchema.optional().nullable(), - title: z.string().optional().nullable(), - toolCallId: z.string(), - }), - z.object({ - entries: z.array(planEntrySchema), - sessionUpdate: z.literal("plan"), - }), - ]), -}); - /** @internal */ export const toolCallUpdateSchema = z.object({ content: z.array(toolCallContentSchema).optional().nullable(), @@ -1504,9 +1443,6 @@ export const clientResponseSchema = z.union([ killTerminalResponseSchema, ]); -/** @internal */ -export const agentNotificationSchema = sessionNotificationSchema; - /** @internal */ export const requestPermissionRequestSchema = z.object({ options: z.array(permissionOptionSchema), @@ -1528,9 +1464,71 @@ export const initializeResponseSchema = z.object({ }); /** @internal */ -export const newSessionResponseSchema = z.object({ - availableCommands: z.array(availableCommandSchema).optional(), +export const sessionNotificationSchema = z.object({ sessionId: z.string(), + update: z.union([ + z.object({ + content: contentBlockSchema, + sessionUpdate: z.literal("user_message_chunk"), + }), + z.object({ + content: contentBlockSchema, + sessionUpdate: z.literal("agent_message_chunk"), + }), + z.object({ + content: contentBlockSchema, + sessionUpdate: z.literal("agent_thought_chunk"), + }), + z.object({ + content: z.array(toolCallContentSchema).optional(), + kind: z + .union([ + z.literal("read"), + z.literal("edit"), + z.literal("delete"), + z.literal("move"), + z.literal("search"), + z.literal("execute"), + z.literal("think"), + z.literal("fetch"), + z.literal("other"), + ]) + .optional(), + locations: z.array(toolCallLocationSchema).optional(), + rawInput: z.record(z.unknown()).optional(), + rawOutput: z.record(z.unknown()).optional(), + sessionUpdate: z.literal("tool_call"), + status: z + .union([ + z.literal("pending"), + z.literal("in_progress"), + z.literal("completed"), + z.literal("failed"), + ]) + .optional(), + title: z.string(), + toolCallId: z.string(), + }), + z.object({ + content: z.array(toolCallContentSchema).optional().nullable(), + kind: toolKindSchema.optional().nullable(), + locations: z.array(toolCallLocationSchema).optional().nullable(), + rawInput: z.record(z.unknown()).optional(), + rawOutput: z.record(z.unknown()).optional(), + sessionUpdate: z.literal("tool_call_update"), + status: toolCallStatusSchema.optional().nullable(), + title: z.string().optional().nullable(), + toolCallId: z.string(), + }), + z.object({ + entries: z.array(planEntrySchema), + sessionUpdate: z.literal("plan"), + }), + z.object({ + availableCommands: z.array(availableCommandSchema), + sessionUpdate: z.literal("available_commands_update"), + }), + ]), }); /** @internal */ @@ -1563,6 +1561,9 @@ export const agentResponseSchema = z.union([ promptResponseSchema, ]); +/** @internal */ +export const agentNotificationSchema = sessionNotificationSchema; + /** @internal */ export const agentClientProtocolSchema = z.union([ clientRequestSchema,