diff --git a/schema/VERSION b/schema/VERSION index 4803c54..719c2e3 100644 --- a/schema/VERSION +++ b/schema/VERSION @@ -1 +1 @@ -refs/tags/v0.7.0 +refs/tags/v0.8.0 diff --git a/schema/schema.json b/schema/schema.json index 88f286e..a8570b4 100644 --- a/schema/schema.json +++ b/schema/schema.json @@ -48,247 +48,207 @@ "type": "object" }, "AgentNotification": { - "anyOf": [ - { - "allOf": [ + "properties": { + "method": { + "type": "string" + }, + "params": { + "anyOf": [ { - "$ref": "#/$defs/SessionNotification" + "anyOf": [ + { + "allOf": [ + { + "$ref": "#/$defs/SessionNotification" + } + ], + "description": "Handles session update notifications from the agent.\n\nThis is a notification endpoint (no response expected) that receives\nreal-time updates about session progress, including message chunks,\ntool calls, and execution plans.\n\nNote: Clients SHOULD continue accepting tool call updates even after\nsending a `session/cancel` notification, as the agent may send final\nupdates before responding with the cancelled stop reason.\n\nSee protocol docs: [Agent Reports Output](https://agentclientprotocol.com/protocol/prompt-turn#3-agent-reports-output)" + }, + { + "allOf": [ + { + "$ref": "#/$defs/ExtNotification" + } + ], + "description": "Handles extension notifications from the agent.\n\nAllows the Agent to send an arbitrary notification that is not part of the ACP spec.\nExtension notifications provide a way to send one-way messages for custom functionality\nwhile maintaining protocol compatibility.\n\nSee protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)" + } + ], + "description": "All possible notifications that an agent can send to a client.\n\nThis enum is used internally for routing RPC notifications. You typically won't need\nto use this directly - use the notification methods on the [`Client`] trait instead.\n\nNotifications do not expect a response." + }, + { + "type": "null" } - ], - "description": "Handles session update notifications from the agent.\n\nThis is a notification endpoint (no response expected) that receives\nreal-time updates about session progress, including message chunks,\ntool calls, and execution plans.\n\nNote: Clients SHOULD continue accepting tool call updates even after\nsending a `session/cancel` notification, as the agent may send final\nupdates before responding with the cancelled stop reason.\n\nSee protocol docs: [Agent Reports Output](https://agentclientprotocol.com/protocol/prompt-turn#3-agent-reports-output)" - }, - { - "description": "Handles extension notifications from the agent.\n\nAllows the Agent to send an arbitrary notification that is not part of the ACP spec.\nExtension notifications provide a way to send one-way messages for custom functionality\nwhile maintaining protocol compatibility.\n\nSee protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)" + ] } + }, + "required": [ + "method" ], - "description": "All possible notifications that an agent can send to a client.\n\nThis enum is used internally for routing RPC notifications. You typically won't need\nto use this directly - use the notification methods on the [`Client`] trait instead.\n\nNotifications do not expect a response.", + "type": "object", "x-docs-ignore": true }, - "AgentOutgoingMessage": { - "anyOf": [ - { - "properties": { - "id": { + "AgentRequest": { + "properties": { + "id": { + "$ref": "#/$defs/RequestId" + }, + "method": { + "type": "string" + }, + "params": { + "anyOf": [ + { "anyOf": [ { - "type": "null" + "allOf": [ + { + "$ref": "#/$defs/WriteTextFileRequest" + } + ], + "description": "Writes content to a text file in the client's file system.\n\nOnly available if the client advertises the `fs.writeTextFile` capability.\nAllows the agent to create or modify files within the client's environment.\n\nSee protocol docs: [Client](https://agentclientprotocol.com/protocol/overview#client)" }, { - "format": "int64", - "type": "integer" + "allOf": [ + { + "$ref": "#/$defs/ReadTextFileRequest" + } + ], + "description": "Reads content from a text file in the client's file system.\n\nOnly available if the client advertises the `fs.readTextFile` capability.\nAllows the agent to access file contents within the client's environment.\n\nSee protocol docs: [Client](https://agentclientprotocol.com/protocol/overview#client)" }, { - "type": "string" - } - ], - "description": "JSON RPC Request Id\n\nAn identifier established by the Client that MUST contain a String, Number, or NULL value if included. If it is not included it is assumed to be a notification. The value SHOULD normally not be Null [1] and Numbers SHOULD NOT contain fractional parts [2]\n\nThe Server MUST reply with the same value in the Response object if included. This member is used to correlate the context between the two objects.\n\n[1] The use of Null as a value for the id member in a Request object is discouraged, because this specification uses a value of Null for Responses with an unknown id. Also, because JSON-RPC 1.0 uses an id value of Null for Notifications this could cause confusion in handling.\n\n[2] Fractional parts may be problematic, since many decimal fractions cannot be represented exactly as binary fractions." - }, - "method": { - "type": "string" - }, - "params": { - "anyOf": [ + "allOf": [ + { + "$ref": "#/$defs/RequestPermissionRequest" + } + ], + "description": "Requests permission from the user for a tool call operation.\n\nCalled by the agent when it needs user authorization before executing\na potentially sensitive operation. The client should present the options\nto the user and return their decision.\n\nIf the client cancels the prompt turn via `session/cancel`, it MUST\nrespond to this request with `RequestPermissionOutcome::Cancelled`.\n\nSee protocol docs: [Requesting Permission](https://agentclientprotocol.com/protocol/tool-calls#requesting-permission)" + }, { - "$ref": "#/$defs/AgentRequest" + "allOf": [ + { + "$ref": "#/$defs/CreateTerminalRequest" + } + ], + "description": "Executes a command in a new terminal\n\nOnly available if the `terminal` Client capability is set to `true`.\n\nReturns a `TerminalId` that can be used with other terminal methods\nto get the current output, wait for exit, and kill the command.\n\nThe `TerminalId` can also be used to embed the terminal in a tool call\nby using the `ToolCallContent::Terminal` variant.\n\nThe Agent is responsible for releasing the terminal by using the `terminal/release`\nmethod.\n\nSee protocol docs: [Terminals](https://agentclientprotocol.com/protocol/terminals)" }, { - "type": "null" - } - ] - } - }, - "required": [ - "id", - "method" - ], - "type": "object" - }, - { - "oneOf": [ - { - "properties": { - "result": { - "$ref": "#/$defs/AgentResponse" + "allOf": [ + { + "$ref": "#/$defs/TerminalOutputRequest" + } + ], + "description": "Gets the terminal output and exit status\n\nReturns the current content in the terminal without waiting for the command to exit.\nIf the command has already exited, the exit status is included.\n\nSee protocol docs: [Terminals](https://agentclientprotocol.com/protocol/terminals)" + }, + { + "allOf": [ + { + "$ref": "#/$defs/ReleaseTerminalRequest" + } + ], + "description": "Releases a terminal\n\nThe command is killed if it hasn't exited yet. Use `terminal/wait_for_exit`\nto wait for the command to exit before releasing the terminal.\n\nAfter release, the `TerminalId` can no longer be used with other `terminal/*` methods,\nbut tool calls that already contain it, continue to display its output.\n\nThe `terminal/kill` method can be used to terminate the command without releasing\nthe terminal, allowing the Agent to call `terminal/output` and other methods.\n\nSee protocol docs: [Terminals](https://agentclientprotocol.com/protocol/terminals)" + }, + { + "allOf": [ + { + "$ref": "#/$defs/WaitForTerminalExitRequest" + } + ], + "description": "Waits for the terminal command to exit and return its exit status\n\nSee protocol docs: [Terminals](https://agentclientprotocol.com/protocol/terminals)" + }, + { + "allOf": [ + { + "$ref": "#/$defs/KillTerminalCommandRequest" + } + ], + "description": "Kills the terminal command without releasing the terminal\n\nWhile `terminal/release` will also kill the command, this method will keep\nthe `TerminalId` valid so it can be used with other methods.\n\nThis method can be helpful when implementing command timeouts which terminate\nthe command as soon as elapsed, and then get the final output so it can be sent\nto the model.\n\nNote: `terminal/release` when `TerminalId` is no longer needed.\n\nSee protocol docs: [Terminals](https://agentclientprotocol.com/protocol/terminals)" + }, + { + "allOf": [ + { + "$ref": "#/$defs/ExtRequest" + } + ], + "description": "Handles extension method requests from the agent.\n\nAllows the Agent to send an arbitrary request that is not part of the ACP spec.\nExtension methods provide a way to add custom functionality while maintaining\nprotocol compatibility.\n\nSee protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)" } - }, - "required": [ - "result" ], - "type": "object" + "description": "All possible requests that an agent can send to a client.\n\nThis enum is used internally for routing RPC requests. You typically won't need\nto use this directly - instead, use the methods on the [`Client`] trait.\n\nThis enum encompasses all method calls from agent to client." }, { - "properties": { - "error": { - "$ref": "#/$defs/Error" - } - }, - "required": [ - "error" - ], - "type": "object" + "type": "null" } - ], + ] + } + }, + "required": [ + "id", + "method" + ], + "type": "object", + "x-docs-ignore": true + }, + "AgentResponse": { + "anyOf": [ + { "properties": { "id": { + "$ref": "#/$defs/RequestId" + }, + "result": { "anyOf": [ { - "type": "null" + "$ref": "#/$defs/InitializeResponse" + }, + { + "$ref": "#/$defs/AuthenticateResponse" + }, + { + "$ref": "#/$defs/NewSessionResponse" }, { - "format": "int64", - "type": "integer" + "$ref": "#/$defs/LoadSessionResponse" }, { - "type": "string" + "$ref": "#/$defs/ListSessionsResponse" + }, + { + "$ref": "#/$defs/SetSessionModeResponse" + }, + { + "$ref": "#/$defs/PromptResponse" + }, + { + "$ref": "#/$defs/SetSessionModelResponse" + }, + { + "$ref": "#/$defs/ExtResponse" } ], - "description": "JSON RPC Request Id\n\nAn identifier established by the Client that MUST contain a String, Number, or NULL value if included. If it is not included it is assumed to be a notification. The value SHOULD normally not be Null [1] and Numbers SHOULD NOT contain fractional parts [2]\n\nThe Server MUST reply with the same value in the Response object if included. This member is used to correlate the context between the two objects.\n\n[1] The use of Null as a value for the id member in a Request object is discouraged, because this specification uses a value of Null for Responses with an unknown id. Also, because JSON-RPC 1.0 uses an id value of Null for Notifications this could cause confusion in handling.\n\n[2] Fractional parts may be problematic, since many decimal fractions cannot be represented exactly as binary fractions." + "description": "All possible responses that an agent can send to a client.\n\nThis enum is used internally for routing RPC responses. You typically won't need\nto use this directly - the responses are handled automatically by the connection.\n\nThese are responses to the corresponding `ClientRequest` variants." } }, "required": [ - "id" + "id", + "result" ], "type": "object" }, { "properties": { - "method": { - "type": "string" + "error": { + "$ref": "#/$defs/Error" }, - "params": { - "anyOf": [ - { - "$ref": "#/$defs/AgentNotification" - }, - { - "type": "null" - } - ] + "id": { + "$ref": "#/$defs/RequestId" } }, "required": [ - "method" + "id", + "error" ], "type": "object" } ], - "description": "A message (request, response, or notification) with `\"jsonrpc\": \"2.0\"` specified as\n[required by JSON-RPC 2.0 Specification][1].\n\n[1]: https://www.jsonrpc.org/specification#compatibility", - "properties": { - "jsonrpc": { - "enum": [ - "2.0" - ], - "type": "string" - } - }, - "required": [ - "jsonrpc" - ], - "type": "object", - "x-docs-ignore": true - }, - "AgentRequest": { - "anyOf": [ - { - "allOf": [ - { - "$ref": "#/$defs/WriteTextFileRequest" - } - ], - "description": "Writes content to a text file in the client's file system.\n\nOnly available if the client advertises the `fs.writeTextFile` capability.\nAllows the agent to create or modify files within the client's environment.\n\nSee protocol docs: [Client](https://agentclientprotocol.com/protocol/overview#client)" - }, - { - "allOf": [ - { - "$ref": "#/$defs/ReadTextFileRequest" - } - ], - "description": "Reads content from a text file in the client's file system.\n\nOnly available if the client advertises the `fs.readTextFile` capability.\nAllows the agent to access file contents within the client's environment.\n\nSee protocol docs: [Client](https://agentclientprotocol.com/protocol/overview#client)" - }, - { - "allOf": [ - { - "$ref": "#/$defs/RequestPermissionRequest" - } - ], - "description": "Requests permission from the user for a tool call operation.\n\nCalled by the agent when it needs user authorization before executing\na potentially sensitive operation. The client should present the options\nto the user and return their decision.\n\nIf the client cancels the prompt turn via `session/cancel`, it MUST\nrespond to this request with `RequestPermissionOutcome::Cancelled`.\n\nSee protocol docs: [Requesting Permission](https://agentclientprotocol.com/protocol/tool-calls#requesting-permission)" - }, - { - "allOf": [ - { - "$ref": "#/$defs/CreateTerminalRequest" - } - ], - "description": "Executes a command in a new terminal\n\nOnly available if the `terminal` Client capability is set to `true`.\n\nReturns a `TerminalId` that can be used with other terminal methods\nto get the current output, wait for exit, and kill the command.\n\nThe `TerminalId` can also be used to embed the terminal in a tool call\nby using the `ToolCallContent::Terminal` variant.\n\nThe Agent is responsible for releasing the terminal by using the `terminal/release`\nmethod.\n\nSee protocol docs: [Terminals](https://agentclientprotocol.com/protocol/terminals)" - }, - { - "allOf": [ - { - "$ref": "#/$defs/TerminalOutputRequest" - } - ], - "description": "Gets the terminal output and exit status\n\nReturns the current content in the terminal without waiting for the command to exit.\nIf the command has already exited, the exit status is included.\n\nSee protocol docs: [Terminals](https://agentclientprotocol.com/protocol/terminals)" - }, - { - "allOf": [ - { - "$ref": "#/$defs/ReleaseTerminalRequest" - } - ], - "description": "Releases a terminal\n\nThe command is killed if it hasn't exited yet. Use `terminal/wait_for_exit`\nto wait for the command to exit before releasing the terminal.\n\nAfter release, the `TerminalId` can no longer be used with other `terminal/*` methods,\nbut tool calls that already contain it, continue to display its output.\n\nThe `terminal/kill` method can be used to terminate the command without releasing\nthe terminal, allowing the Agent to call `terminal/output` and other methods.\n\nSee protocol docs: [Terminals](https://agentclientprotocol.com/protocol/terminals)" - }, - { - "allOf": [ - { - "$ref": "#/$defs/WaitForTerminalExitRequest" - } - ], - "description": "Waits for the terminal command to exit and return its exit status\n\nSee protocol docs: [Terminals](https://agentclientprotocol.com/protocol/terminals)" - }, - { - "allOf": [ - { - "$ref": "#/$defs/KillTerminalCommandRequest" - } - ], - "description": "Kills the terminal command without releasing the terminal\n\nWhile `terminal/release` will also kill the command, this method will keep\nthe `TerminalId` valid so it can be used with other methods.\n\nThis method can be helpful when implementing command timeouts which terminate\nthe command as soon as elapsed, and then get the final output so it can be sent\nto the model.\n\nNote: `terminal/release` when `TerminalId` is no longer needed.\n\nSee protocol docs: [Terminals](https://agentclientprotocol.com/protocol/terminals)" - }, - { - "description": "Handles extension method requests from the agent.\n\nAllows the Agent to send an arbitrary request that is not part of the ACP spec.\nExtension methods provide a way to add custom functionality while maintaining\nprotocol compatibility.\n\nSee protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)" - } - ], - "description": "All possible requests that an agent can send to a client.\n\nThis enum is used internally for routing RPC requests. You typically won't need\nto use this directly - instead, use the methods on the [`Client`] trait.\n\nThis enum encompasses all method calls from agent to client.", - "x-docs-ignore": true - }, - "AgentResponse": { - "anyOf": [ - { - "$ref": "#/$defs/InitializeResponse" - }, - { - "$ref": "#/$defs/AuthenticateResponse" - }, - { - "$ref": "#/$defs/NewSessionResponse" - }, - { - "$ref": "#/$defs/LoadSessionResponse" - }, - { - "$ref": "#/$defs/ListSessionsResponse" - }, - { - "$ref": "#/$defs/SetSessionModeResponse" - }, - { - "$ref": "#/$defs/PromptResponse" - }, - { - "$ref": "#/$defs/SetSessionModelResponse" - }, - {} - ], - "description": "All possible responses that an agent can send to a client.\n\nThis enum is used internally for routing RPC responses. You typically won't need\nto use this directly - the responses are handled automatically by the connection.\n\nThese are responses to the corresponding `ClientRequest` variants.", "x-docs-ignore": true }, "Annotations": { @@ -546,247 +506,207 @@ "type": "object" }, "ClientNotification": { - "anyOf": [ - { - "allOf": [ + "properties": { + "method": { + "type": "string" + }, + "params": { + "anyOf": [ + { + "anyOf": [ + { + "allOf": [ + { + "$ref": "#/$defs/CancelNotification" + } + ], + "description": "Cancels ongoing operations for a session.\n\nThis is a notification sent by the client to cancel an ongoing prompt turn.\n\nUpon receiving this notification, the Agent SHOULD:\n- Stop all language model requests as soon as possible\n- Abort all tool call invocations in progress\n- Send any pending `session/update` notifications\n- Respond to the original `session/prompt` request with `StopReason::Cancelled`\n\nSee protocol docs: [Cancellation](https://agentclientprotocol.com/protocol/prompt-turn#cancellation)" + }, + { + "allOf": [ + { + "$ref": "#/$defs/ExtNotification" + } + ], + "description": "Handles extension notifications from the client.\n\nExtension notifications provide a way to send one-way messages for custom functionality\nwhile maintaining protocol compatibility.\n\nSee protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)" + } + ], + "description": "All possible notifications that a client can send to an agent.\n\nThis enum is used internally for routing RPC notifications. You typically won't need\nto use this directly - use the notification methods on the [`Agent`] trait instead.\n\nNotifications do not expect a response." + }, { - "$ref": "#/$defs/CancelNotification" + "type": "null" } - ], - "description": "Cancels ongoing operations for a session.\n\nThis is a notification sent by the client to cancel an ongoing prompt turn.\n\nUpon receiving this notification, the Agent SHOULD:\n- Stop all language model requests as soon as possible\n- Abort all tool call invocations in progress\n- Send any pending `session/update` notifications\n- Respond to the original `session/prompt` request with `StopReason::Cancelled`\n\nSee protocol docs: [Cancellation](https://agentclientprotocol.com/protocol/prompt-turn#cancellation)" - }, - { - "description": "Handles extension notifications from the client.\n\nExtension notifications provide a way to send one-way messages for custom functionality\nwhile maintaining protocol compatibility.\n\nSee protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)" + ] } + }, + "required": [ + "method" ], - "description": "All possible notifications that a client can send to an agent.\n\nThis enum is used internally for routing RPC notifications. You typically won't need\nto use this directly - use the notification methods on the [`Agent`] trait instead.\n\nNotifications do not expect a response.", + "type": "object", "x-docs-ignore": true }, - "ClientOutgoingMessage": { - "anyOf": [ - { - "properties": { - "id": { + "ClientRequest": { + "properties": { + "id": { + "$ref": "#/$defs/RequestId" + }, + "method": { + "type": "string" + }, + "params": { + "anyOf": [ + { "anyOf": [ { - "type": "null" + "allOf": [ + { + "$ref": "#/$defs/InitializeRequest" + } + ], + "description": "Establishes the connection with a client and negotiates protocol capabilities.\n\nThis method is called once at the beginning of the connection to:\n- Negotiate the protocol version to use\n- Exchange capability information between client and agent\n- Determine available authentication methods\n\nThe agent should respond with its supported protocol version and capabilities.\n\nSee protocol docs: [Initialization](https://agentclientprotocol.com/protocol/initialization)" }, { - "format": "int64", - "type": "integer" + "allOf": [ + { + "$ref": "#/$defs/AuthenticateRequest" + } + ], + "description": "Authenticates the client using the specified authentication method.\n\nCalled when the agent requires authentication before allowing session creation.\nThe client provides the authentication method ID that was advertised during initialization.\n\nAfter successful authentication, the client can proceed to create sessions with\n`new_session` without receiving an `auth_required` error.\n\nSee protocol docs: [Initialization](https://agentclientprotocol.com/protocol/initialization)" }, { - "type": "string" - } - ], - "description": "JSON RPC Request Id\n\nAn identifier established by the Client that MUST contain a String, Number, or NULL value if included. If it is not included it is assumed to be a notification. The value SHOULD normally not be Null [1] and Numbers SHOULD NOT contain fractional parts [2]\n\nThe Server MUST reply with the same value in the Response object if included. This member is used to correlate the context between the two objects.\n\n[1] The use of Null as a value for the id member in a Request object is discouraged, because this specification uses a value of Null for Responses with an unknown id. Also, because JSON-RPC 1.0 uses an id value of Null for Notifications this could cause confusion in handling.\n\n[2] Fractional parts may be problematic, since many decimal fractions cannot be represented exactly as binary fractions." - }, - "method": { - "type": "string" - }, - "params": { - "anyOf": [ + "allOf": [ + { + "$ref": "#/$defs/NewSessionRequest" + } + ], + "description": "Creates a new conversation session with the agent.\n\nSessions represent independent conversation contexts with their own history and state.\n\nThe agent should:\n- Create a new session context\n- Connect to any specified MCP servers\n- Return a unique session ID for future requests\n\nMay return an `auth_required` error if the agent requires authentication.\n\nSee protocol docs: [Session Setup](https://agentclientprotocol.com/protocol/session-setup)" + }, { - "$ref": "#/$defs/ClientRequest" + "allOf": [ + { + "$ref": "#/$defs/LoadSessionRequest" + } + ], + "description": "Loads an existing session to resume a previous conversation.\n\nThis method is only available if the agent advertises the `loadSession` capability.\n\nThe agent should:\n- Restore the session context and conversation history\n- Connect to the specified MCP servers\n- Stream the entire conversation history back to the client via notifications\n\nSee protocol docs: [Loading Sessions](https://agentclientprotocol.com/protocol/session-setup#loading-sessions)" }, { - "type": "null" - } - ] - } - }, - "required": [ - "id", - "method" - ], - "type": "object" - }, - { - "oneOf": [ - { - "properties": { - "result": { - "$ref": "#/$defs/ClientResponse" + "allOf": [ + { + "$ref": "#/$defs/ListSessionsRequest" + } + ], + "description": "**UNSTABLE**\n\nThis capability is not part of the spec yet, and may be removed or changed at any point.\n\nLists existing sessions known to the agent.\n\nThis method is only available if the agent advertises the `listSessions` capability.\n\nThe agent should return metadata about sessions with optional filtering and pagination support." + }, + { + "allOf": [ + { + "$ref": "#/$defs/SetSessionModeRequest" + } + ], + "description": "Sets the current mode for a session.\n\nAllows switching between different agent modes (e.g., \"ask\", \"architect\", \"code\")\nthat affect system prompts, tool availability, and permission behaviors.\n\nThe mode must be one of the modes advertised in `availableModes` during session\ncreation or loading. Agents may also change modes autonomously and notify the\nclient via `current_mode_update` notifications.\n\nThis method can be called at any time during a session, whether the Agent is\nidle or actively generating a response.\n\nSee protocol docs: [Session Modes](https://agentclientprotocol.com/protocol/session-modes)" + }, + { + "allOf": [ + { + "$ref": "#/$defs/PromptRequest" + } + ], + "description": "Processes a user prompt within a session.\n\nThis method handles the whole lifecycle of a prompt:\n- Receives user messages with optional context (files, images, etc.)\n- Processes the prompt using language models\n- Reports language model content and tool calls to the Clients\n- Requests permission to run tools\n- Executes any requested tool calls\n- Returns when the turn is complete with a stop reason\n\nSee protocol docs: [Prompt Turn](https://agentclientprotocol.com/protocol/prompt-turn)" + }, + { + "allOf": [ + { + "$ref": "#/$defs/SetSessionModelRequest" + } + ], + "description": "**UNSTABLE**\n\nThis capability is not part of the spec yet, and may be removed or changed at any point.\n\nSelect a model for a given session." + }, + { + "allOf": [ + { + "$ref": "#/$defs/ExtRequest" + } + ], + "description": "Handles extension method requests from the client.\n\nExtension methods provide a way to add custom functionality while maintaining\nprotocol compatibility.\n\nSee protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)" } - }, - "required": [ - "result" ], - "type": "object" + "description": "All possible requests that a client can send to an agent.\n\nThis enum is used internally for routing RPC requests. You typically won't need\nto use this directly - instead, use the methods on the [`Agent`] trait.\n\nThis enum encompasses all method calls from client to agent." }, { - "properties": { - "error": { - "$ref": "#/$defs/Error" - } - }, - "required": [ - "error" - ], - "type": "object" + "type": "null" } - ], + ] + } + }, + "required": [ + "id", + "method" + ], + "type": "object", + "x-docs-ignore": true + }, + "ClientResponse": { + "anyOf": [ + { "properties": { "id": { + "$ref": "#/$defs/RequestId" + }, + "result": { "anyOf": [ { - "type": "null" + "$ref": "#/$defs/WriteTextFileResponse" + }, + { + "$ref": "#/$defs/ReadTextFileResponse" + }, + { + "$ref": "#/$defs/RequestPermissionResponse" + }, + { + "$ref": "#/$defs/CreateTerminalResponse" }, { - "format": "int64", - "type": "integer" + "$ref": "#/$defs/TerminalOutputResponse" }, { - "type": "string" + "$ref": "#/$defs/ReleaseTerminalResponse" + }, + { + "$ref": "#/$defs/WaitForTerminalExitResponse" + }, + { + "$ref": "#/$defs/KillTerminalCommandResponse" + }, + { + "$ref": "#/$defs/ExtResponse" } ], - "description": "JSON RPC Request Id\n\nAn identifier established by the Client that MUST contain a String, Number, or NULL value if included. If it is not included it is assumed to be a notification. The value SHOULD normally not be Null [1] and Numbers SHOULD NOT contain fractional parts [2]\n\nThe Server MUST reply with the same value in the Response object if included. This member is used to correlate the context between the two objects.\n\n[1] The use of Null as a value for the id member in a Request object is discouraged, because this specification uses a value of Null for Responses with an unknown id. Also, because JSON-RPC 1.0 uses an id value of Null for Notifications this could cause confusion in handling.\n\n[2] Fractional parts may be problematic, since many decimal fractions cannot be represented exactly as binary fractions." + "description": "All possible responses that a client can send to an agent.\n\nThis enum is used internally for routing RPC responses. You typically won't need\nto use this directly - the responses are handled automatically by the connection.\n\nThese are responses to the corresponding `AgentRequest` variants." } }, "required": [ - "id" + "id", + "result" ], "type": "object" }, { "properties": { - "method": { - "type": "string" + "error": { + "$ref": "#/$defs/Error" }, - "params": { - "anyOf": [ - { - "$ref": "#/$defs/ClientNotification" - }, - { - "type": "null" - } - ] + "id": { + "$ref": "#/$defs/RequestId" } }, "required": [ - "method" + "id", + "error" ], "type": "object" } ], - "description": "A message (request, response, or notification) with `\"jsonrpc\": \"2.0\"` specified as\n[required by JSON-RPC 2.0 Specification][1].\n\n[1]: https://www.jsonrpc.org/specification#compatibility", - "properties": { - "jsonrpc": { - "enum": [ - "2.0" - ], - "type": "string" - } - }, - "required": [ - "jsonrpc" - ], - "type": "object", - "x-docs-ignore": true - }, - "ClientRequest": { - "anyOf": [ - { - "allOf": [ - { - "$ref": "#/$defs/InitializeRequest" - } - ], - "description": "Establishes the connection with a client and negotiates protocol capabilities.\n\nThis method is called once at the beginning of the connection to:\n- Negotiate the protocol version to use\n- Exchange capability information between client and agent\n- Determine available authentication methods\n\nThe agent should respond with its supported protocol version and capabilities.\n\nSee protocol docs: [Initialization](https://agentclientprotocol.com/protocol/initialization)" - }, - { - "allOf": [ - { - "$ref": "#/$defs/AuthenticateRequest" - } - ], - "description": "Authenticates the client using the specified authentication method.\n\nCalled when the agent requires authentication before allowing session creation.\nThe client provides the authentication method ID that was advertised during initialization.\n\nAfter successful authentication, the client can proceed to create sessions with\n`new_session` without receiving an `auth_required` error.\n\nSee protocol docs: [Initialization](https://agentclientprotocol.com/protocol/initialization)" - }, - { - "allOf": [ - { - "$ref": "#/$defs/NewSessionRequest" - } - ], - "description": "Creates a new conversation session with the agent.\n\nSessions represent independent conversation contexts with their own history and state.\n\nThe agent should:\n- Create a new session context\n- Connect to any specified MCP servers\n- Return a unique session ID for future requests\n\nMay return an `auth_required` error if the agent requires authentication.\n\nSee protocol docs: [Session Setup](https://agentclientprotocol.com/protocol/session-setup)" - }, - { - "allOf": [ - { - "$ref": "#/$defs/LoadSessionRequest" - } - ], - "description": "Loads an existing session to resume a previous conversation.\n\nThis method is only available if the agent advertises the `loadSession` capability.\n\nThe agent should:\n- Restore the session context and conversation history\n- Connect to the specified MCP servers\n- Stream the entire conversation history back to the client via notifications\n\nSee protocol docs: [Loading Sessions](https://agentclientprotocol.com/protocol/session-setup#loading-sessions)" - }, - { - "allOf": [ - { - "$ref": "#/$defs/ListSessionsRequest" - } - ], - "description": "**UNSTABLE**\n\nThis capability is not part of the spec yet, and may be removed or changed at any point.\n\nLists existing sessions known to the agent.\n\nThis method is only available if the agent advertises the `listSessions` capability.\n\nThe agent should return metadata about sessions with optional filtering and pagination support." - }, - { - "allOf": [ - { - "$ref": "#/$defs/SetSessionModeRequest" - } - ], - "description": "Sets the current mode for a session.\n\nAllows switching between different agent modes (e.g., \"ask\", \"architect\", \"code\")\nthat affect system prompts, tool availability, and permission behaviors.\n\nThe mode must be one of the modes advertised in `availableModes` during session\ncreation or loading. Agents may also change modes autonomously and notify the\nclient via `current_mode_update` notifications.\n\nThis method can be called at any time during a session, whether the Agent is\nidle or actively generating a response.\n\nSee protocol docs: [Session Modes](https://agentclientprotocol.com/protocol/session-modes)" - }, - { - "allOf": [ - { - "$ref": "#/$defs/PromptRequest" - } - ], - "description": "Processes a user prompt within a session.\n\nThis method handles the whole lifecycle of a prompt:\n- Receives user messages with optional context (files, images, etc.)\n- Processes the prompt using language models\n- Reports language model content and tool calls to the Clients\n- Requests permission to run tools\n- Executes any requested tool calls\n- Returns when the turn is complete with a stop reason\n\nSee protocol docs: [Prompt Turn](https://agentclientprotocol.com/protocol/prompt-turn)" - }, - { - "allOf": [ - { - "$ref": "#/$defs/SetSessionModelRequest" - } - ], - "description": "**UNSTABLE**\n\nThis capability is not part of the spec yet, and may be removed or changed at any point.\n\nSelect a model for a given session." - }, - { - "description": "Handles extension method requests from the client.\n\nExtension methods provide a way to add custom functionality while maintaining\nprotocol compatibility.\n\nSee protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)" - } - ], - "description": "All possible requests that a client can send to an agent.\n\nThis enum is used internally for routing RPC requests. You typically won't need\nto use this directly - instead, use the methods on the [`Agent`] trait.\n\nThis enum encompasses all method calls from client to agent.", - "x-docs-ignore": true - }, - "ClientResponse": { - "anyOf": [ - { - "$ref": "#/$defs/WriteTextFileResponse" - }, - { - "$ref": "#/$defs/ReadTextFileResponse" - }, - { - "$ref": "#/$defs/RequestPermissionResponse" - }, - { - "$ref": "#/$defs/CreateTerminalResponse" - }, - { - "$ref": "#/$defs/TerminalOutputResponse" - }, - { - "$ref": "#/$defs/ReleaseTerminalResponse" - }, - { - "$ref": "#/$defs/WaitForTerminalExitResponse" - }, - { - "$ref": "#/$defs/KillTerminalCommandResponse" - }, - {} - ], - "description": "All possible responses that a client can send to an agent.\n\nThis enum is used internally for routing RPC responses. You typically won't need\nto use this directly - the responses are handled automatically by the connection.\n\nThese are responses to the corresponding `AgentRequest` variants.", "x-docs-ignore": true }, "Content": { @@ -1129,6 +1049,15 @@ ], "type": "object" }, + "ExtNotification": { + "description": "Allows the Agent to send an arbitrary notification that is not part of the ACP spec.\nExtension notifications provide a way to send one-way messages for custom functionality\nwhile maintaining protocol compatibility.\n\nSee protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)" + }, + "ExtRequest": { + "description": "Allows for sending an arbitrary request that is not part of the ACP spec.\nExtension methods provide a way to add custom functionality while maintaining\nprotocol compatibility.\n\nSee protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)" + }, + "ExtResponse": { + "description": "Allows for sending an arbitrary response to an [`ExtRequest`] that is not part of the ACP spec.\nExtension methods provide a way to add custom functionality while maintaining\nprotocol compatibility.\n\nSee protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)" + }, "FileSystemCapability": { "description": "Filesystem capabilities supported by the client.\nFile system capabilities that a client may support.\n\nSee protocol docs: [FileSystem](https://agentclientprotocol.com/protocol/initialization#filesystem)", "properties": { @@ -2112,6 +2041,21 @@ "x-method": "terminal/release", "x-side": "client" }, + "RequestId": { + "anyOf": [ + { + "type": "null" + }, + { + "format": "int64", + "type": "integer" + }, + { + "type": "string" + } + ], + "description": "JSON RPC Request Id\n\nAn identifier established by the Client that MUST contain a String, Number, or NULL value if included. If it is not included it is assumed to be a notification. The value SHOULD normally not be Null [1] and Numbers SHOULD NOT contain fractional parts [2]\n\nThe Server MUST reply with the same value in the Response object if included. This member is used to correlate the context between the two objects.\n\n[1] The use of Null as a value for the id member in a Request object is discouraged, because this specification uses a value of Null for Responses with an unknown id. Also, because JSON-RPC 1.0 uses an id value of Null for Notifications this could cause confusion in handling.\n\n[2] Fractional parts may be problematic, since many decimal fractions cannot be represented exactly as binary fractions." + }, "RequestPermissionOutcome": { "description": "The outcome of a permission request.", "discriminator": { @@ -2315,7 +2259,7 @@ "type": "object" }, "SessionId": { - "description": "A unique identifier for a conversation session between a client and agent.\n\nSessions maintain their own context, conversation history, and state,\nallowing multiple independent interactions with the same agent.\n\n# Example\n\n```\nuse agent_client_protocol::SessionId;\nuse std::sync::Arc;\n\nlet session_id = SessionId(Arc::from(\"sess_abc123def456\"));\n```\n\nSee protocol docs: [Session ID](https://agentclientprotocol.com/protocol/session-setup#session-id)", + "description": "A unique identifier for a conversation session between a client and agent.\n\nSessions maintain their own context, conversation history, and state,\nallowing multiple independent interactions with the same agent.\n\nSee protocol docs: [Session ID](https://agentclientprotocol.com/protocol/session-setup#session-id)", "type": "string" }, "SessionInfo": { @@ -3321,10 +3265,56 @@ "$schema": "https://json-schema.org/draft/2020-12/schema", "anyOf": [ { - "$ref": "#/$defs/AgentOutgoingMessage" + "anyOf": [ + { + "$ref": "#/$defs/AgentRequest" + }, + { + "$ref": "#/$defs/AgentResponse" + }, + { + "$ref": "#/$defs/AgentNotification" + } + ], + "description": "A message (request, response, or notification) with `\"jsonrpc\": \"2.0\"` specified as\n[required by JSON-RPC 2.0 Specification][1].\n\n[1]: https://www.jsonrpc.org/specification#compatibility", + "properties": { + "jsonrpc": { + "enum": [ + "2.0" + ], + "type": "string" + } + }, + "required": [ + "jsonrpc" + ], + "type": "object" }, { - "$ref": "#/$defs/ClientOutgoingMessage" + "anyOf": [ + { + "$ref": "#/$defs/ClientRequest" + }, + { + "$ref": "#/$defs/ClientResponse" + }, + { + "$ref": "#/$defs/ClientNotification" + } + ], + "description": "A message (request, response, or notification) with `\"jsonrpc\": \"2.0\"` specified as\n[required by JSON-RPC 2.0 Specification][1].\n\n[1]: https://www.jsonrpc.org/specification#compatibility", + "properties": { + "jsonrpc": { + "enum": [ + "2.0" + ], + "type": "string" + } + }, + "required": [ + "jsonrpc" + ], + "type": "object" } ] } diff --git a/scripts/gen_schema.py b/scripts/gen_schema.py index b8f9e9a..a782179 100644 --- a/scripts/gen_schema.py +++ b/scripts/gen_schema.py @@ -32,18 +32,15 @@ r"(?:\s*=\s*['\"][^'\"]+['\"])?\s*$", re.MULTILINE, ) +MODELS_TO_REMOVE = ["Model1", "Model2", "Model3", "Model4", "Model5", "Model6", "Model"] # Map of numbered classes produced by datamodel-code-generator to descriptive names. # Keep this in sync with the Rust/TypeScript SDK nomenclature. RENAME_MAP: dict[str, str] = { - "AgentOutgoingMessage1": "AgentRequestMessage", - "AgentOutgoingMessage2": "AgentResponseMessage", - "AgentOutgoingMessage3": "AgentErrorMessage", - "AgentOutgoingMessage4": "AgentNotificationMessage", - "ClientOutgoingMessage1": "ClientRequestMessage", - "ClientOutgoingMessage2": "ClientResponseMessage", - "ClientOutgoingMessage3": "ClientErrorMessage", - "ClientOutgoingMessage4": "ClientNotificationMessage", + "AgentResponse1": "AgentResponseMessage", + "AgentResponse2": "AgentErrorMessage", + "ClientResponse1": "ClientResponseMessage", + "ClientResponse2": "ClientErrorMessage", "ContentBlock1": "TextContentBlock", "ContentBlock2": "ImageContentBlock", "ContentBlock3": "AudioContentBlock", @@ -172,6 +169,7 @@ def postprocess_generated_schema(output_path: Path) -> list[str]: content = _strip_existing_header(raw_content) content = _remove_backcompat_block(content) + content = _remove_unused_models(content) content, leftover_classes = _rename_numbered_models(content) processing_steps: tuple[_ProcessingStep, ...] = ( @@ -518,5 +516,17 @@ def _inject_enum_aliases(content: str) -> str: return content[:insertion_point] + block + content[insertion_point:] +def _remove_unused_models(content: str) -> str: + for model_name in MODELS_TO_REMOVE: + pattern = re.compile( + rf"^(class {model_name}\([\s\S]*?\):)([\s\S]*?)(?=^\S|\Z)", + re.MULTILINE, + ) + content, count = pattern.subn("", content) + if count > 0: + print(f"Removed unused model: {model_name}", file=sys.stderr) + return content + + if __name__ == "__main__": main() diff --git a/src/acp/meta.py b/src/acp/meta.py index 900e195..2600fd9 100644 --- a/src/acp/meta.py +++ b/src/acp/meta.py @@ -1,5 +1,5 @@ # Generated from schema/meta.json. Do not edit by hand. -# Schema ref: refs/tags/v0.7.0 +# Schema ref: refs/tags/v0.8.0 AGENT_METHODS = { "authenticate": "authenticate", "initialize": "initialize", diff --git a/src/acp/schema.py b/src/acp/schema.py index 2576f48..e9e27a1 100644 --- a/src/acp/schema.py +++ b/src/acp/schema.py @@ -1,5 +1,5 @@ # Generated from schema/schema.json. Do not edit by hand. -# Schema ref: refs/tags/v0.7.0 +# Schema ref: refs/tags/v0.8.0 from __future__ import annotations @@ -658,7 +658,7 @@ class WriteTextFileResponse(BaseModel): class AgentErrorMessage(BaseModel): - jsonrpc: Jsonrpc + error: Error # JSON RPC Request Id # # An identifier established by the Client that MUST contain a String, Number, or NULL value if included. If it is not included it is assumed to be a notification. The value SHOULD normally not be Null [1] and Numbers SHOULD NOT contain fractional parts [2] @@ -674,7 +674,6 @@ class AgentErrorMessage(BaseModel): description="JSON RPC Request Id\n\nAn identifier established by the Client that MUST contain a String, Number, or NULL value if included. If it is not included it is assumed to be a notification. The value SHOULD normally not be Null [1] and Numbers SHOULD NOT contain fractional parts [2]\n\nThe Server MUST reply with the same value in the Response object if included. This member is used to correlate the context between the two objects.\n\n[1] The use of Null as a value for the id member in a Request object is discouraged, because this specification uses a value of Null for Responses with an unknown id. Also, because JSON-RPC 1.0 uses an id value of Null for Notifications this could cause confusion in handling.\n\n[2] Fractional parts may be problematic, since many decimal fractions cannot be represented exactly as binary fractions." ), ] = None - error: Error class Annotations(BaseModel): @@ -744,8 +743,13 @@ class ClientCapabilities(BaseModel): ] = False +class ClientNotification(BaseModel): + method: str + params: Optional[Union[CancelNotification, Any]] = None + + class ClientErrorMessage(BaseModel): - jsonrpc: Jsonrpc + error: Error # JSON RPC Request Id # # An identifier established by the Client that MUST contain a String, Number, or NULL value if included. If it is not included it is assumed to be a notification. The value SHOULD normally not be Null [1] and Numbers SHOULD NOT contain fractional parts [2] @@ -761,13 +765,6 @@ class ClientErrorMessage(BaseModel): description="JSON RPC Request Id\n\nAn identifier established by the Client that MUST contain a String, Number, or NULL value if included. If it is not included it is assumed to be a notification. The value SHOULD normally not be Null [1] and Numbers SHOULD NOT contain fractional parts [2]\n\nThe Server MUST reply with the same value in the Response object if included. This member is used to correlate the context between the two objects.\n\n[1] The use of Null as a value for the id member in a Request object is discouraged, because this specification uses a value of Null for Responses with an unknown id. Also, because JSON-RPC 1.0 uses an id value of Null for Notifications this could cause confusion in handling.\n\n[2] Fractional parts may be problematic, since many decimal fractions cannot be represented exactly as binary fractions." ), ] = None - error: Error - - -class ClientNotificationMessage(BaseModel): - jsonrpc: Jsonrpc - method: str - params: Optional[Union[CancelNotification, Any]] = None class AudioContentBlock(AudioContent): @@ -1191,6 +1188,50 @@ class AvailableCommandsUpdate(BaseModel): ] +class ClientResponseMessage(BaseModel): + # JSON RPC Request Id + # + # An identifier established by the Client that MUST contain a String, Number, or NULL value if included. If it is not included it is assumed to be a notification. The value SHOULD normally not be Null [1] and Numbers SHOULD NOT contain fractional parts [2] + # + # The Server MUST reply with the same value in the Response object if included. This member is used to correlate the context between the two objects. + # + # [1] The use of Null as a value for the id member in a Request object is discouraged, because this specification uses a value of Null for Responses with an unknown id. Also, because JSON-RPC 1.0 uses an id value of Null for Notifications this could cause confusion in handling. + # + # [2] Fractional parts may be problematic, since many decimal fractions cannot be represented exactly as binary fractions. + id: Annotated[ + Optional[Union[int, str]], + Field( + description="JSON RPC Request Id\n\nAn identifier established by the Client that MUST contain a String, Number, or NULL value if included. If it is not included it is assumed to be a notification. The value SHOULD normally not be Null [1] and Numbers SHOULD NOT contain fractional parts [2]\n\nThe Server MUST reply with the same value in the Response object if included. This member is used to correlate the context between the two objects.\n\n[1] The use of Null as a value for the id member in a Request object is discouraged, because this specification uses a value of Null for Responses with an unknown id. Also, because JSON-RPC 1.0 uses an id value of Null for Notifications this could cause confusion in handling.\n\n[2] Fractional parts may be problematic, since many decimal fractions cannot be represented exactly as binary fractions." + ), + ] = None + # All possible responses that a client can send to an agent. + # + # This enum is used internally for routing RPC responses. You typically won't need + # to use this directly - the responses are handled automatically by the connection. + # + # These are responses to the corresponding `AgentRequest` variants. + result: Annotated[ + Union[ + WriteTextFileResponse, + ReadTextFileResponse, + RequestPermissionResponse, + CreateTerminalResponse, + TerminalOutputResponse, + ReleaseTerminalResponse, + WaitForTerminalExitResponse, + KillTerminalCommandResponse, + Any, + ], + Field( + description="All possible responses that a client can send to an agent.\n\nThis enum is used internally for routing RPC responses. You typically won't need\nto use this directly - the responses are handled automatically by the connection.\n\nThese are responses to the corresponding `AgentRequest` variants." + ), + ] + + +class ClientResponse(RootModel[Union[ClientResponseMessage, ClientErrorMessage]]): + root: Union[ClientResponseMessage, ClientErrorMessage] + + class TextContentBlock(TextContent): type: Literal["text"] @@ -1376,8 +1417,7 @@ class AvailableCommandsUpdate(AvailableCommandsUpdate): session_update: Annotated[Literal["available_commands_update"], Field(alias="sessionUpdate")] -class ClientResponseMessage(BaseModel): - jsonrpc: Jsonrpc +class AgentResponseMessage(BaseModel): # JSON RPC Request Id # # An identifier established by the Client that MUST contain a String, Number, or NULL value if included. If it is not included it is assumed to be a notification. The value SHOULD normally not be Null [1] and Numbers SHOULD NOT contain fractional parts [2] @@ -1393,30 +1433,34 @@ class ClientResponseMessage(BaseModel): description="JSON RPC Request Id\n\nAn identifier established by the Client that MUST contain a String, Number, or NULL value if included. If it is not included it is assumed to be a notification. The value SHOULD normally not be Null [1] and Numbers SHOULD NOT contain fractional parts [2]\n\nThe Server MUST reply with the same value in the Response object if included. This member is used to correlate the context between the two objects.\n\n[1] The use of Null as a value for the id member in a Request object is discouraged, because this specification uses a value of Null for Responses with an unknown id. Also, because JSON-RPC 1.0 uses an id value of Null for Notifications this could cause confusion in handling.\n\n[2] Fractional parts may be problematic, since many decimal fractions cannot be represented exactly as binary fractions." ), ] = None - # All possible responses that a client can send to an agent. + # All possible responses that an agent can send to a client. # # This enum is used internally for routing RPC responses. You typically won't need # to use this directly - the responses are handled automatically by the connection. # - # These are responses to the corresponding `AgentRequest` variants. + # These are responses to the corresponding `ClientRequest` variants. result: Annotated[ Union[ - WriteTextFileResponse, - ReadTextFileResponse, - RequestPermissionResponse, - CreateTerminalResponse, - TerminalOutputResponse, - ReleaseTerminalResponse, - WaitForTerminalExitResponse, - KillTerminalCommandResponse, + InitializeResponse, + AuthenticateResponse, + NewSessionResponse, + LoadSessionResponse, + ListSessionsResponse, + SetSessionModeResponse, + PromptResponse, + SetSessionModelResponse, Any, ], Field( - description="All possible responses that a client can send to an agent.\n\nThis enum is used internally for routing RPC responses. You typically won't need\nto use this directly - the responses are handled automatically by the connection.\n\nThese are responses to the corresponding `AgentRequest` variants." + description="All possible responses that an agent can send to a client.\n\nThis enum is used internally for routing RPC responses. You typically won't need\nto use this directly - the responses are handled automatically by the connection.\n\nThese are responses to the corresponding `ClientRequest` variants." ), ] +class AgentResponse(RootModel[Union[AgentResponseMessage, AgentErrorMessage]]): + root: Union[AgentResponseMessage, AgentErrorMessage] + + class EmbeddedResourceContentBlock(EmbeddedResource): type: Literal["resource"] @@ -1491,8 +1535,7 @@ class AgentThoughtChunk(ContentChunk): session_update: Annotated[Literal["agent_thought_chunk"], Field(alias="sessionUpdate")] -class AgentResponseMessage(BaseModel): - jsonrpc: Jsonrpc +class ClientRequest(BaseModel): # JSON RPC Request Id # # An identifier established by the Client that MUST contain a String, Number, or NULL value if included. If it is not included it is assumed to be a notification. The value SHOULD normally not be Null [1] and Numbers SHOULD NOT contain fractional parts [2] @@ -1508,28 +1551,20 @@ class AgentResponseMessage(BaseModel): description="JSON RPC Request Id\n\nAn identifier established by the Client that MUST contain a String, Number, or NULL value if included. If it is not included it is assumed to be a notification. The value SHOULD normally not be Null [1] and Numbers SHOULD NOT contain fractional parts [2]\n\nThe Server MUST reply with the same value in the Response object if included. This member is used to correlate the context between the two objects.\n\n[1] The use of Null as a value for the id member in a Request object is discouraged, because this specification uses a value of Null for Responses with an unknown id. Also, because JSON-RPC 1.0 uses an id value of Null for Notifications this could cause confusion in handling.\n\n[2] Fractional parts may be problematic, since many decimal fractions cannot be represented exactly as binary fractions." ), ] = None - # All possible responses that an agent can send to a client. - # - # This enum is used internally for routing RPC responses. You typically won't need - # to use this directly - the responses are handled automatically by the connection. - # - # These are responses to the corresponding `ClientRequest` variants. - result: Annotated[ + method: str + params: Optional[ Union[ - InitializeResponse, - AuthenticateResponse, - NewSessionResponse, - LoadSessionResponse, - ListSessionsResponse, - SetSessionModeResponse, - PromptResponse, - SetSessionModelResponse, + InitializeRequest, + AuthenticateRequest, + NewSessionRequest, + LoadSessionRequest, + ListSessionsRequest, + SetSessionModeRequest, + PromptRequest, + SetSessionModelRequest, Any, - ], - Field( - description="All possible responses that an agent can send to a client.\n\nThis enum is used internally for routing RPC responses. You typically won't need\nto use this directly - the responses are handled automatically by the connection.\n\nThese are responses to the corresponding `ClientRequest` variants." - ), - ] + ] + ] = None class Content(BaseModel): @@ -1584,39 +1619,6 @@ class ToolCallUpdate(BaseModel): ] -class ClientRequestMessage(BaseModel): - jsonrpc: Jsonrpc - # JSON RPC Request Id - # - # An identifier established by the Client that MUST contain a String, Number, or NULL value if included. If it is not included it is assumed to be a notification. The value SHOULD normally not be Null [1] and Numbers SHOULD NOT contain fractional parts [2] - # - # The Server MUST reply with the same value in the Response object if included. This member is used to correlate the context between the two objects. - # - # [1] The use of Null as a value for the id member in a Request object is discouraged, because this specification uses a value of Null for Responses with an unknown id. Also, because JSON-RPC 1.0 uses an id value of Null for Notifications this could cause confusion in handling. - # - # [2] Fractional parts may be problematic, since many decimal fractions cannot be represented exactly as binary fractions. - id: Annotated[ - Optional[Union[int, str]], - Field( - description="JSON RPC Request Id\n\nAn identifier established by the Client that MUST contain a String, Number, or NULL value if included. If it is not included it is assumed to be a notification. The value SHOULD normally not be Null [1] and Numbers SHOULD NOT contain fractional parts [2]\n\nThe Server MUST reply with the same value in the Response object if included. This member is used to correlate the context between the two objects.\n\n[1] The use of Null as a value for the id member in a Request object is discouraged, because this specification uses a value of Null for Responses with an unknown id. Also, because JSON-RPC 1.0 uses an id value of Null for Notifications this could cause confusion in handling.\n\n[2] Fractional parts may be problematic, since many decimal fractions cannot be represented exactly as binary fractions." - ), - ] = None - method: str - params: Optional[ - Union[ - InitializeRequest, - AuthenticateRequest, - NewSessionRequest, - LoadSessionRequest, - ListSessionsRequest, - SetSessionModeRequest, - PromptRequest, - SetSessionModelRequest, - Any, - ] - ] = None - - class RequestPermissionRequest(BaseModel): # Extension point for implementations field_meta: Annotated[ @@ -1696,12 +1698,7 @@ class ToolCall(BaseModel): ] -class ToolCallStart(ToolCall): - session_update: Annotated[Literal["tool_call"], Field(alias="sessionUpdate")] - - -class AgentRequestMessage(BaseModel): - jsonrpc: Jsonrpc +class AgentRequest(BaseModel): # JSON RPC Request Id # # An identifier established by the Client that MUST contain a String, Number, or NULL value if included. If it is not included it is assumed to be a notification. The value SHOULD normally not be Null [1] and Numbers SHOULD NOT contain fractional parts [2] @@ -1733,6 +1730,10 @@ class AgentRequestMessage(BaseModel): ] = None +class ToolCallStart(ToolCall): + session_update: Annotated[Literal["tool_call"], Field(alias="sessionUpdate")] + + class SessionNotification(BaseModel): # Extension point for implementations field_meta: Annotated[ @@ -1763,51 +1764,16 @@ class SessionNotification(BaseModel): ] -class AgentNotificationMessage(BaseModel): - jsonrpc: Jsonrpc +class AgentNotification(BaseModel): method: str params: Optional[Union[SessionNotification, Any]] = None -class Model( - RootModel[ - Union[ - Union[ - AgentRequestMessage, - Union[AgentResponseMessage, AgentErrorMessage], - AgentNotificationMessage, - ], - Union[ - ClientRequestMessage, - Union[ClientResponseMessage, ClientErrorMessage], - ClientNotificationMessage, - ], - ] - ] -): - root: Union[ - Union[ - AgentRequestMessage, - Union[AgentResponseMessage, AgentErrorMessage], - AgentNotificationMessage, - ], - Union[ - ClientRequestMessage, - Union[ClientResponseMessage, ClientErrorMessage], - ClientNotificationMessage, - ], - ] - - # Backwards compatibility aliases -AgentOutgoingMessage1 = AgentRequestMessage -AgentOutgoingMessage2 = AgentResponseMessage -AgentOutgoingMessage3 = AgentErrorMessage -AgentOutgoingMessage4 = AgentNotificationMessage -ClientOutgoingMessage1 = ClientRequestMessage -ClientOutgoingMessage2 = ClientResponseMessage -ClientOutgoingMessage3 = ClientErrorMessage -ClientOutgoingMessage4 = ClientNotificationMessage +AgentResponse1 = AgentResponseMessage +AgentResponse2 = AgentErrorMessage +ClientResponse1 = ClientResponseMessage +ClientResponse2 = ClientErrorMessage ContentBlock1 = TextContentBlock ContentBlock2 = ImageContentBlock ContentBlock3 = AudioContentBlock