From eb80a55fbcba51f761c8f26d4fdd3be6aba7344f Mon Sep 17 00:00:00 2001 From: Steffen Deusch Date: Fri, 6 Mar 2026 16:08:29 +0100 Subject: [PATCH 1/3] add unstable session/stop See https://github.com/agentclientprotocol/agent-client-protocol/pull/577. --- src/acp.ts | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/src/acp.ts b/src/acp.ts index b93cd7c..43a1b14 100644 --- a/src/acp.ts +++ b/src/acp.ts @@ -85,6 +85,13 @@ export class AgentSideConnection { const validatedParams = validate.zResumeSessionRequest.parse(params); return agent.unstable_resumeSession(validatedParams); } + case schema.AGENT_METHODS.session_stop: { + if (!agent.unstable_stopSession) { + throw RequestError.methodNotFound(method); + } + const validatedParams = validate.zStopSessionRequest.parse(params); + return agent.unstable_stopSession(validatedParams); + } case schema.AGENT_METHODS.session_set_mode: { if (!agent.setSessionMode) { throw RequestError.methodNotFound(method); @@ -679,6 +686,29 @@ export class ClientSideConnection implements Agent { ); } + /** + * **UNSTABLE** + * + * This capability is not part of the spec yet, and may be removed or changed at any point. + * + * Stops an active session and frees up any resources associated with it. + * + * This method is only available if the agent advertises the `session.stop` capability. + * + * The agent must cancel any ongoing work (as if `session/cancel` was called) + * and then free up any resources associated with the session. + * + * @experimental + */ + async unstable_stopSession( + params: schema.StopSessionRequest, + ): Promise { + return await this.#connection.sendRequest( + schema.AGENT_METHODS.session_stop, + params, + ); + } + /** * Sets the operational mode for a session. * @@ -1514,6 +1544,23 @@ export interface Agent { unstable_resumeSession?( params: schema.ResumeSessionRequest, ): Promise; + /** + * **UNSTABLE** + * + * This capability is not part of the spec yet, and may be removed or changed at any point. + * + * Stops an active session and frees up any resources associated with it. + * + * This method is only available if the agent advertises the `session.stop` capability. + * + * The agent must cancel any ongoing work (as if `session/cancel` was called) + * and then free up any resources associated with the session. + * + * @experimental + */ + unstable_stopSession?( + params: schema.StopSessionRequest, + ): Promise; /** * Sets the operational mode for a session. * From 4c2ef2bbb0225301a8de2e8f6f56ceba396cb1e5 Mon Sep 17 00:00:00 2001 From: Steffen Deusch Date: Tue, 10 Mar 2026 16:47:04 +0100 Subject: [PATCH 2/3] update schema and rename stop to close --- schema/meta.json | 4 +- schema/schema.json | 195 ++++++---- scripts/generate.js | 2 +- src/acp.ts | 30 +- src/schema/index.ts | 10 +- src/schema/types.gen.ts | 254 +++++++------ src/schema/zod.gen.ts | 779 +++++++++++++++++++++++----------------- 7 files changed, 720 insertions(+), 554 deletions(-) diff --git a/schema/meta.json b/schema/meta.json index b1cba08..bfa8448 100644 --- a/schema/meta.json +++ b/schema/meta.json @@ -3,6 +3,7 @@ "authenticate": "authenticate", "initialize": "initialize", "session_cancel": "session/cancel", + "session_close": "session/close", "session_fork": "session/fork", "session_list": "session/list", "session_load": "session/load", @@ -11,8 +12,7 @@ "session_resume": "session/resume", "session_set_config_option": "session/set_config_option", "session_set_mode": "session/set_mode", - "session_set_model": "session/set_model", - "session_stop": "session/stop" + "session_set_model": "session/set_model" }, "clientMethods": { "fs_read_text_file": "fs/read_text_file", diff --git a/schema/schema.json b/schema/schema.json index 64cba0d..684ab92 100644 --- a/schema/schema.json +++ b/schema/schema.json @@ -263,10 +263,10 @@ { "allOf": [ { - "$ref": "#/$defs/StopSessionResponse" + "$ref": "#/$defs/CloseSessionResponse" } ], - "title": "StopSessionResponse" + "title": "CloseSessionResponse" }, { "allOf": [ @@ -866,7 +866,7 @@ "$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.", + "description": "Lists existing sessions known to the agent.\n\nThis method is only available if the agent advertises the `sessionCapabilities.list` capability.\n\nThe agent should return metadata about sessions with optional filtering and pagination support.", "title": "ListSessionsRequest" }, { @@ -890,11 +890,11 @@ { "allOf": [ { - "$ref": "#/$defs/StopSessionRequest" + "$ref": "#/$defs/CloseSessionRequest" } ], - "description": "**UNSTABLE**\n\nThis capability is not part of the spec yet, and may be removed or changed at any point.\n\nStops an active session and frees up any resources associated with it.\n\nThis method is only available if the agent advertises the `session.stop` capability.\n\nThe agent must cancel any ongoing work (as if `session/cancel` was called)\nand then free up any resources associated with the session.", - "title": "StopSessionRequest" + "description": "**UNSTABLE**\n\nThis capability is not part of the spec yet, and may be removed or changed at any point.\n\nCloses an active session and frees up any resources associated with it.\n\nThis method is only available if the agent advertises the `session.close` capability.\n\nThe agent must cancel any ongoing work (as if `session/cancel` was called)\nand then free up any resources associated with the session.", + "title": "CloseSessionRequest" }, { "allOf": [ @@ -1059,6 +1059,41 @@ ], "x-docs-ignore": true }, + "CloseSessionRequest": { + "description": "**UNSTABLE**\n\nThis capability is not part of the spec yet, and may be removed or changed at any point.\n\nRequest parameters for closing an active session.\n\nIf supported, the agent **must** cancel any ongoing work related to the session\n(treat it as if `session/cancel` was called) and then free up any resources\nassociated with the session.\n\nOnly available if the Agent supports the `session.close` capability.", + "properties": { + "_meta": { + "additionalProperties": true, + "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)", + "type": ["object", "null"] + }, + "sessionId": { + "allOf": [ + { + "$ref": "#/$defs/SessionId" + } + ], + "description": "The ID of the session to close." + } + }, + "required": ["sessionId"], + "type": "object", + "x-method": "session/close", + "x-side": "agent" + }, + "CloseSessionResponse": { + "description": "**UNSTABLE**\n\nThis capability is not part of the spec yet, and may be removed or changed at any point.\n\nResponse from closing a session.", + "properties": { + "_meta": { + "additionalProperties": true, + "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)", + "type": ["object", "null"] + } + }, + "type": "object", + "x-method": "session/close", + "x-side": "agent" + }, "ConfigOptionUpdate": { "description": "Session configuration options have been updated.", "properties": { @@ -1407,13 +1442,6 @@ "Error": { "description": "JSON-RPC error object.\n\nRepresents an error that occurred during method execution, following the\nJSON-RPC 2.0 error object specification with optional additional data.\n\nSee protocol docs: [JSON-RPC Error Object](https://www.jsonrpc.org/specification#error_object)", "properties": { - "authMethods": { - "description": "**UNSTABLE**\n\nThis capability is not part of the spec yet, and may be removed or changed at any point.\n\nAuthentication methods relevant to this error.\nTypically included with `AUTH_REQUIRED` errors to narrow down which\nauthentication methods are applicable from those shared during initialization.", - "items": { - "$ref": "#/$defs/AuthMethod" - }, - "type": "array" - }, "code": { "allOf": [ { @@ -1842,7 +1870,7 @@ "x-side": "client" }, "ListSessionsRequest": { - "description": "**UNSTABLE**\n\nThis capability is not part of the spec yet, and may be removed or changed at any point.\n\nRequest parameters for listing existing sessions.\n\nOnly available if the Agent supports the `listSessions` capability.", + "description": "Request parameters for listing existing sessions.\n\nOnly available if the Agent supports the `sessionCapabilities.list` capability.", "properties": { "_meta": { "additionalProperties": true, @@ -1863,7 +1891,7 @@ "x-side": "agent" }, "ListSessionsResponse": { - "description": "**UNSTABLE**\n\nThis capability is not part of the spec yet, and may be removed or changed at any point.\n\nResponse from listing sessions.", + "description": "Response from listing sessions.", "properties": { "_meta": { "additionalProperties": true, @@ -2855,7 +2883,7 @@ "type": "null" } ], - "description": "**UNSTABLE**\n\nThis capability is not part of the spec yet, and may be removed or changed at any point.\n\nWhether the agent supports `session/list`." + "description": "Whether the agent supports `session/list`." }, "resume": { "anyOf": [ @@ -2871,15 +2899,37 @@ "stop": { "anyOf": [ { - "$ref": "#/$defs/SessionStopCapabilities" + "$ref": "#/$defs/SessionCloseCapabilities" }, { "type": "null" } ], - "description": "**UNSTABLE**\n\nThis capability is not part of the spec yet, and may be removed or changed at any point.\n\nWhether the agent supports `session/stop`." + "description": "**UNSTABLE**\n\nThis capability is not part of the spec yet, and may be removed or changed at any point.\n\nWhether the agent supports `session/close`." + } + }, + "type": "object" + }, + "SessionCloseCapabilities": { + "description": "**UNSTABLE**\n\nThis capability is not part of the spec yet, and may be removed or changed at any point.\n\nCapabilities for the `session/close` method.\n\nBy supplying `{}` it means that the agent supports closing of sessions.", + "properties": { + "_meta": { + "additionalProperties": true, + "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)", + "type": ["object", "null"] + } + }, + "type": "object" + }, + "SessionConfigBoolean": { + "description": "**UNSTABLE**\n\nThis capability is not part of the spec yet, and may be removed or changed at any point.\n\nA boolean on/off toggle session configuration option payload.", + "properties": { + "currentValue": { + "description": "The current value of the boolean option.", + "type": "boolean" } }, + "required": ["currentValue"], "type": "object" }, "SessionConfigGroupId": { @@ -2911,6 +2961,22 @@ }, "required": ["type"], "type": "object" + }, + { + "allOf": [ + { + "$ref": "#/$defs/SessionConfigBoolean" + } + ], + "description": "**UNSTABLE**\n\nThis capability is not part of the spec yet, and may be removed or changed at any point.\n\nBoolean on/off toggle.", + "properties": { + "type": { + "const": "boolean", + "type": "string" + } + }, + "required": ["type"], + "type": "object" } ], "properties": { @@ -3098,7 +3164,7 @@ "type": "string" }, "SessionInfo": { - "description": "**UNSTABLE**\n\nThis capability is not part of the spec yet, and may be removed or changed at any point.\n\nInformation about a session returned by session/list", + "description": "Information about a session returned by session/list", "properties": { "_meta": { "additionalProperties": true, @@ -3149,7 +3215,7 @@ "type": "object" }, "SessionListCapabilities": { - "description": "Capabilities for the `session/list` method.\n\nBy supplying `{}` it means that the agent supports listing of sessions.\n\nFurther capabilities can be added in the future for other means of filtering or searching the list.", + "description": "Capabilities for the `session/list` method.\n\nBy supplying `{}` it means that the agent supports listing of sessions.", "properties": { "_meta": { "additionalProperties": true, @@ -3279,17 +3345,6 @@ }, "type": "object" }, - "SessionStopCapabilities": { - "description": "**UNSTABLE**\n\nThis capability is not part of the spec yet, and may be removed or changed at any point.\n\nCapabilities for the `session/stop` method.\n\nBy supplying `{}` it means that the agent supports stopping of sessions.", - "properties": { - "_meta": { - "additionalProperties": true, - "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)", - "type": ["object", "null"] - } - }, - "type": "object" - }, "SessionUpdate": { "description": "Different types of updates that can be sent during session processing.\n\nThese updates provide real-time feedback about the agent's progress.\n\nSee protocol docs: [Agent Reports Output](https://agentclientprotocol.com/protocol/prompt-turn#3-agent-reports-output)", "discriminator": { @@ -3475,6 +3530,39 @@ ] }, "SetSessionConfigOptionRequest": { + "anyOf": [ + { + "description": "A boolean value (`type: \"boolean\"`).", + "properties": { + "type": { + "const": "boolean", + "type": "string" + }, + "value": { + "description": "The boolean value.", + "type": "boolean" + } + }, + "required": ["type", "value"], + "type": "object" + }, + { + "description": "A [`SessionConfigValueId`] string value.\n\nThis is the default when `type` is absent on the wire. Unknown `type`\nvalues with string payloads also gracefully deserialize into this\nvariant.", + "properties": { + "value": { + "allOf": [ + { + "$ref": "#/$defs/SessionConfigValueId" + } + ], + "description": "The value ID." + } + }, + "required": ["value"], + "title": "value_id", + "type": "object" + } + ], "description": "Request parameters for setting a session configuration option.", "properties": { "_meta": { @@ -3497,17 +3585,9 @@ } ], "description": "The ID of the session to set the configuration option for." - }, - "value": { - "allOf": [ - { - "$ref": "#/$defs/SessionConfigValueId" - } - ], - "description": "The ID of the configuration option value to set." } }, - "required": ["sessionId", "configId", "value"], + "required": ["sessionId", "configId"], "type": "object", "x-method": "session/set_config_option", "x-side": "agent" @@ -3649,41 +3729,6 @@ } ] }, - "StopSessionRequest": { - "description": "**UNSTABLE**\n\nThis capability is not part of the spec yet, and may be removed or changed at any point.\n\nRequest parameters for stopping an active session.\n\nIf supported, the agent **must** cancel any ongoing work related to the session\n(treat it as if `session/cancel` was called) and then free up any resources\nassociated with the session.\n\nOnly available if the Agent supports the `session.stop` capability.", - "properties": { - "_meta": { - "additionalProperties": true, - "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)", - "type": ["object", "null"] - }, - "sessionId": { - "allOf": [ - { - "$ref": "#/$defs/SessionId" - } - ], - "description": "The ID of the session to stop." - } - }, - "required": ["sessionId"], - "type": "object", - "x-method": "session/stop", - "x-side": "agent" - }, - "StopSessionResponse": { - "description": "**UNSTABLE**\n\nThis capability is not part of the spec yet, and may be removed or changed at any point.\n\nResponse from stopping a session.", - "properties": { - "_meta": { - "additionalProperties": true, - "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)", - "type": ["object", "null"] - } - }, - "type": "object", - "x-method": "session/stop", - "x-side": "agent" - }, "Terminal": { "description": "Embed a terminal created with `terminal/create` by its id.\n\nThe terminal must be added before calling `terminal/release`.\n\nSee protocol docs: [Terminal](https://agentclientprotocol.com/protocol/terminals)", "properties": { diff --git a/scripts/generate.js b/scripts/generate.js index 7207304..32e5c2d 100644 --- a/scripts/generate.js +++ b/scripts/generate.js @@ -5,7 +5,7 @@ import * as fs from "fs/promises"; import { dirname } from "path"; import * as prettier from "prettier"; -const CURRENT_SCHEMA_RELEASE = "v0.11.0"; +const CURRENT_SCHEMA_RELEASE = "v0.11.1"; await main(); diff --git a/src/acp.ts b/src/acp.ts index 43a1b14..44cdccc 100644 --- a/src/acp.ts +++ b/src/acp.ts @@ -85,12 +85,12 @@ export class AgentSideConnection { const validatedParams = validate.zResumeSessionRequest.parse(params); return agent.unstable_resumeSession(validatedParams); } - case schema.AGENT_METHODS.session_stop: { - if (!agent.unstable_stopSession) { + case schema.AGENT_METHODS.session_close: { + if (!agent.unstable_closeSession) { throw RequestError.methodNotFound(method); } - const validatedParams = validate.zStopSessionRequest.parse(params); - return agent.unstable_stopSession(validatedParams); + const validatedParams = validate.zCloseSessionRequest.parse(params); + return agent.unstable_closeSession(validatedParams); } case schema.AGENT_METHODS.session_set_mode: { if (!agent.setSessionMode) { @@ -691,20 +691,20 @@ export class ClientSideConnection implements Agent { * * This capability is not part of the spec yet, and may be removed or changed at any point. * - * Stops an active session and frees up any resources associated with it. + * Closes an active session and frees up any resources associated with it. * - * This method is only available if the agent advertises the `session.stop` capability. + * This method is only available if the agent advertises the `session.close` capability. * * The agent must cancel any ongoing work (as if `session/cancel` was called) * and then free up any resources associated with the session. * * @experimental */ - async unstable_stopSession( - params: schema.StopSessionRequest, - ): Promise { + async unstable_closeSession( + params: schema.CloseSessionRequest, + ): Promise { return await this.#connection.sendRequest( - schema.AGENT_METHODS.session_stop, + schema.AGENT_METHODS.session_close, params, ); } @@ -1549,18 +1549,18 @@ export interface Agent { * * This capability is not part of the spec yet, and may be removed or changed at any point. * - * Stops an active session and frees up any resources associated with it. + * Closes an active session and frees up any resources associated with it. * - * This method is only available if the agent advertises the `session.stop` capability. + * This method is only available if the agent advertises the `session.close` capability. * * The agent must cancel any ongoing work (as if `session/cancel` was called) * and then free up any resources associated with the session. * * @experimental */ - unstable_stopSession?( - params: schema.StopSessionRequest, - ): Promise; + unstable_closeSession?( + params: schema.CloseSessionRequest, + ): Promise; /** * Sets the operational mode for a session. * diff --git a/src/schema/index.ts b/src/schema/index.ts index 4368ca0..0236284 100644 --- a/src/schema/index.ts +++ b/src/schema/index.ts @@ -23,8 +23,11 @@ export type { CancelRequestNotification, ClientCapabilities, ClientNotification, + ClientOptions, ClientRequest, ClientResponse, + CloseSessionRequest, + CloseSessionResponse, ConfigOptionUpdate, Content, ContentBlock, @@ -90,6 +93,8 @@ export type { Role, SelectedPermissionOutcome, SessionCapabilities, + SessionCloseCapabilities, + SessionConfigBoolean, SessionConfigGroupId, SessionConfigId, SessionConfigOption, @@ -110,7 +115,6 @@ export type { SessionModeState, SessionNotification, SessionResumeCapabilities, - SessionStopCapabilities, SessionUpdate, SetSessionConfigOptionRequest, SetSessionConfigOptionResponse, @@ -119,8 +123,6 @@ export type { SetSessionModeRequest, SetSessionModeResponse, StopReason, - StopSessionRequest, - StopSessionResponse, Terminal, TerminalExitStatus, TerminalOutputRequest, @@ -147,6 +149,7 @@ export const AGENT_METHODS = { authenticate: "authenticate", initialize: "initialize", session_cancel: "session/cancel", + session_close: "session/close", session_fork: "session/fork", session_list: "session/list", session_load: "session/load", @@ -156,7 +159,6 @@ export const AGENT_METHODS = { session_set_config_option: "session/set_config_option", session_set_mode: "session/set_mode", session_set_model: "session/set_model", - session_stop: "session/stop", } as const; export const CLIENT_METHODS = { diff --git a/src/schema/types.gen.ts b/src/schema/types.gen.ts index 30cc871..2197421 100644 --- a/src/schema/types.gen.ts +++ b/src/schema/types.gen.ts @@ -79,7 +79,7 @@ export type AgentResponse = | ListSessionsResponse | ForkSessionResponse | ResumeSessionResponse - | StopSessionResponse + | CloseSessionResponse | SetSessionModeResponse | SetSessionConfigOptionResponse | PromptResponse @@ -560,7 +560,7 @@ export type ClientRequest = { | ListSessionsRequest | ForkSessionRequest | ResumeSessionRequest - | StopSessionRequest + | CloseSessionRequest | SetSessionModeRequest | SetSessionConfigOptionRequest | PromptRequest @@ -596,6 +596,60 @@ export type ClientResponse = id: RequestId; }; +/** + * **UNSTABLE** + * + * This capability is not part of the spec yet, and may be removed or changed at any point. + * + * Request parameters for closing an active session. + * + * If supported, the agent **must** cancel any ongoing work related to the session + * (treat it as if `session/cancel` was called) and then free up any resources + * associated with the session. + * + * Only available if the Agent supports the `session.close` capability. + * + * @experimental + */ +export type CloseSessionRequest = { + /** + * The _meta property is reserved by ACP to allow clients and agents to attach additional + * metadata to their interactions. Implementations MUST NOT make assumptions about values at + * these keys. + * + * See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility) + */ + _meta?: { + [key: string]: unknown; + } | null; + /** + * The ID of the session to close. + */ + sessionId: SessionId; +}; + +/** + * **UNSTABLE** + * + * This capability is not part of the spec yet, and may be removed or changed at any point. + * + * Response from closing a session. + * + * @experimental + */ +export type CloseSessionResponse = { + /** + * The _meta property is reserved by ACP to allow clients and agents to attach additional + * metadata to their interactions. Implementations MUST NOT make assumptions about values at + * these keys. + * + * See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility) + */ + _meta?: { + [key: string]: unknown; + } | null; +}; + /** * Session configuration options have been updated. */ @@ -902,18 +956,6 @@ export type EnvVariable = { * See protocol docs: [JSON-RPC Error Object](https://www.jsonrpc.org/specification#error_object) */ export type Error = { - /** - * **UNSTABLE** - * - * This capability is not part of the spec yet, and may be removed or changed at any point. - * - * Authentication methods relevant to this error. - * Typically included with `AUTH_REQUIRED` errors to narrow down which - * authentication methods are applicable from those shared during initialization. - * - * @experimental - */ - authMethods?: Array; /** * A number indicating the error type that occurred. * This must be an integer as defined in the JSON-RPC specification. @@ -1281,15 +1323,9 @@ export type KillTerminalResponse = { }; /** - * **UNSTABLE** - * - * This capability is not part of the spec yet, and may be removed or changed at any point. - * * Request parameters for listing existing sessions. * - * Only available if the Agent supports the `listSessions` capability. - * - * @experimental + * Only available if the Agent supports the `sessionCapabilities.list` capability. */ export type ListSessionsRequest = { /** @@ -1313,13 +1349,7 @@ export type ListSessionsRequest = { }; /** - * **UNSTABLE** - * - * This capability is not part of the spec yet, and may be removed or changed at any point. - * * Response from listing sessions. - * - * @experimental */ export type ListSessionsResponse = { /** @@ -2257,13 +2287,7 @@ export type SessionCapabilities = { */ fork?: SessionForkCapabilities | null; /** - * **UNSTABLE** - * - * This capability is not part of the spec yet, and may be removed or changed at any point. - * * Whether the agent supports `session/list`. - * - * @experimental */ list?: SessionListCapabilities | null; /** @@ -2281,11 +2305,51 @@ export type SessionCapabilities = { * * This capability is not part of the spec yet, and may be removed or changed at any point. * - * Whether the agent supports `session/stop`. + * Whether the agent supports `session/close`. * * @experimental */ - stop?: SessionStopCapabilities | null; + stop?: SessionCloseCapabilities | null; +}; + +/** + * **UNSTABLE** + * + * This capability is not part of the spec yet, and may be removed or changed at any point. + * + * Capabilities for the `session/close` method. + * + * By supplying `{}` it means that the agent supports closing of sessions. + * + * @experimental + */ +export type SessionCloseCapabilities = { + /** + * The _meta property is reserved by ACP to allow clients and agents to attach additional + * metadata to their interactions. Implementations MUST NOT make assumptions about values at + * these keys. + * + * See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility) + */ + _meta?: { + [key: string]: unknown; + } | null; +}; + +/** + * **UNSTABLE** + * + * This capability is not part of the spec yet, and may be removed or changed at any point. + * + * A boolean on/off toggle session configuration option payload. + * + * @experimental + */ +export type SessionConfigBoolean = { + /** + * The current value of the boolean option. + */ + currentValue: boolean; }; /** @@ -2298,9 +2362,14 @@ export type SessionConfigGroupId = string; */ export type SessionConfigId = string; -export type SessionConfigOption = SessionConfigSelect & { - type: "select"; -} & { +export type SessionConfigOption = ( + | (SessionConfigSelect & { + type: "select"; + }) + | (SessionConfigBoolean & { + type: "boolean"; + }) +) & { /** * The _meta property is reserved by ACP to allow clients and agents to attach additional * metadata to their interactions. Implementations MUST NOT make assumptions about values at @@ -2463,13 +2532,7 @@ export type SessionForkCapabilities = { export type SessionId = string; /** - * **UNSTABLE** - * - * This capability is not part of the spec yet, and may be removed or changed at any point. - * * Information about a session returned by session/list - * - * @experimental */ export type SessionInfo = { /** @@ -2531,8 +2594,6 @@ export type SessionInfoUpdate = { * Capabilities for the `session/list` method. * * By supplying `{}` it means that the agent supports listing of sessions. - * - * Further capabilities can be added in the future for other means of filtering or searching the list. */ export type SessionListCapabilities = { /** @@ -2679,30 +2740,6 @@ export type SessionResumeCapabilities = { } | null; }; -/** - * **UNSTABLE** - * - * This capability is not part of the spec yet, and may be removed or changed at any point. - * - * Capabilities for the `session/stop` method. - * - * By supplying `{}` it means that the agent supports stopping of sessions. - * - * @experimental - */ -export type SessionStopCapabilities = { - /** - * The _meta property is reserved by ACP to allow clients and agents to attach additional - * metadata to their interactions. Implementations MUST NOT make assumptions about values at - * these keys. - * - * See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility) - */ - _meta?: { - [key: string]: unknown; - } | null; -}; - /** * Different types of updates that can be sent during session processing. * @@ -2745,10 +2782,21 @@ export type SessionUpdate = sessionUpdate: "usage_update"; }); -/** - * Request parameters for setting a session configuration option. - */ -export type SetSessionConfigOptionRequest = { +export type SetSessionConfigOptionRequest = ( + | { + type: "boolean"; + /** + * The boolean value. + */ + value: boolean; + } + | { + /** + * The value ID. + */ + value: SessionConfigValueId; + } +) & { /** * The _meta property is reserved by ACP to allow clients and agents to attach additional * metadata to their interactions. Implementations MUST NOT make assumptions about values at @@ -2767,10 +2815,6 @@ export type SetSessionConfigOptionRequest = { * The ID of the session to set the configuration option for. */ sessionId: SessionId; - /** - * The ID of the configuration option value to set. - */ - value: SessionConfigValueId; }; /** @@ -2897,60 +2941,6 @@ export type StopReason = | "refusal" | "cancelled"; -/** - * **UNSTABLE** - * - * This capability is not part of the spec yet, and may be removed or changed at any point. - * - * Request parameters for stopping an active session. - * - * If supported, the agent **must** cancel any ongoing work related to the session - * (treat it as if `session/cancel` was called) and then free up any resources - * associated with the session. - * - * Only available if the Agent supports the `session.stop` capability. - * - * @experimental - */ -export type StopSessionRequest = { - /** - * The _meta property is reserved by ACP to allow clients and agents to attach additional - * metadata to their interactions. Implementations MUST NOT make assumptions about values at - * these keys. - * - * See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility) - */ - _meta?: { - [key: string]: unknown; - } | null; - /** - * The ID of the session to stop. - */ - sessionId: SessionId; -}; - -/** - * **UNSTABLE** - * - * This capability is not part of the spec yet, and may be removed or changed at any point. - * - * Response from stopping a session. - * - * @experimental - */ -export type StopSessionResponse = { - /** - * The _meta property is reserved by ACP to allow clients and agents to attach additional - * metadata to their interactions. Implementations MUST NOT make assumptions about values at - * these keys. - * - * See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility) - */ - _meta?: { - [key: string]: unknown; - } | null; -}; - /** * Embed a terminal created with `terminal/create` by its id. * diff --git a/src/schema/zod.gen.ts b/src/schema/zod.gen.ts index 0d853f7..d09d07e 100644 --- a/src/schema/zod.gen.ts +++ b/src/schema/zod.gen.ts @@ -16,7 +16,7 @@ import { z } from "zod/v4"; * @experimental */ export const zAuthCapabilities = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), terminal: z.boolean().optional().default(false), }); @@ -30,8 +30,8 @@ export const zAuthCapabilities = z.object({ * @experimental */ export const zAuthEnvVar = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), - label: z.string().nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + label: z.union([z.string(), z.null()]).optional(), name: z.string(), optional: z.boolean().optional().default(false), secret: z.boolean().optional().default(true), @@ -43,8 +43,8 @@ export const zAuthEnvVar = z.object({ * This is the default authentication method type. */ export const zAuthMethodAgent = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), - description: z.string().nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + description: z.union([z.string(), z.null()]).optional(), id: z.string(), name: z.string(), }); @@ -61,10 +61,10 @@ export const zAuthMethodAgent = z.object({ * @experimental */ export const zAuthMethodEnvVar = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), - description: z.string().nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + description: z.union([z.string(), z.null()]).optional(), id: z.string(), - link: z.string().nullish(), + link: z.union([z.string(), z.null()]).optional(), name: z.string(), vars: z.array(zAuthEnvVar), }); @@ -81,10 +81,10 @@ export const zAuthMethodEnvVar = z.object({ * @experimental */ export const zAuthMethodTerminal = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), args: z.array(z.string()).optional(), - description: z.string().nullish(), - env: z.record(z.string(), z.string()).optional(), + description: z.union([z.string(), z.null()]).optional(), + env: z.record(z.string()).optional(), id: z.string(), name: z.string(), }); @@ -115,7 +115,7 @@ export const zAuthMethod = z.union([ * Specifies which authentication method to use. */ export const zAuthenticateRequest = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), methodId: z.string(), }); @@ -123,19 +123,32 @@ export const zAuthenticateRequest = z.object({ * Response to the `authenticate` method. */ export const zAuthenticateResponse = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), }); /** * Binary resource contents. */ export const zBlobResourceContents = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), blob: z.string(), - mimeType: z.string().nullish(), + mimeType: z.union([z.string(), z.null()]).optional(), uri: z.string(), }); +/** + * **UNSTABLE** + * + * This capability is not part of the spec yet, and may be removed or changed at any point. + * + * Response from closing a session. + * + * @experimental + */ +export const zCloseSessionResponse = z.object({ + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), +}); + /** * **UNSTABLE** * @@ -154,7 +167,7 @@ export const zCost = z.object({ * Response containing the ID of the created terminal. */ export const zCreateTerminalResponse = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), terminalId: z.string(), }); @@ -166,9 +179,9 @@ export const zCreateTerminalResponse = z.object({ * See protocol docs: [Content](https://agentclientprotocol.com/protocol/tool-calls#content) */ export const zDiff = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), newText: z.string(), - oldText: z.string().nullish(), + oldText: z.union([z.string(), z.null()]).optional(), path: z.string(), }); @@ -176,7 +189,7 @@ export const zDiff = z.object({ * An environment variable to set when launching an MCP server. */ export const zEnvVariable = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), name: z.string(), value: z.string(), }); @@ -254,7 +267,7 @@ export const zExtResponse = z.unknown(); * See protocol docs: [FileSystem](https://agentclientprotocol.com/protocol/initialization#filesystem) */ export const zFileSystemCapabilities = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), readTextFile: z.boolean().optional().default(false), writeTextFile: z.boolean().optional().default(false), }); @@ -268,7 +281,7 @@ export const zFileSystemCapabilities = z.object({ * See protocol docs: [Client Capabilities](https://agentclientprotocol.com/protocol/initialization#client-capabilities) */ export const zClientCapabilities = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), auth: zAuthCapabilities.optional().default({ terminal: false }), fs: zFileSystemCapabilities .optional() @@ -280,7 +293,7 @@ export const zClientCapabilities = z.object({ * An HTTP header to set when making requests to the MCP server. */ export const zHttpHeader = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), name: z.string(), value: z.string(), }); @@ -291,9 +304,9 @@ export const zHttpHeader = z.object({ * title for UI representation. */ export const zImplementation = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), name: z.string(), - title: z.string().nullish(), + title: z.union([z.string(), z.null()]).optional(), version: z.string(), }); @@ -301,31 +314,25 @@ export const zImplementation = z.object({ * Response to `terminal/kill` method */ export const zKillTerminalResponse = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), }); /** - * **UNSTABLE** - * - * This capability is not part of the spec yet, and may be removed or changed at any point. - * * Request parameters for listing existing sessions. * - * Only available if the Agent supports the `listSessions` capability. - * - * @experimental + * Only available if the Agent supports the `sessionCapabilities.list` capability. */ export const zListSessionsRequest = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), - cursor: z.string().nullish(), - cwd: z.string().nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + cursor: z.union([z.string(), z.null()]).optional(), + cwd: z.union([z.string(), z.null()]).optional(), }); /** * MCP capabilities supported by the agent */ export const zMcpCapabilities = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), http: z.boolean().optional().default(false), sse: z.boolean().optional().default(false), }); @@ -334,7 +341,7 @@ export const zMcpCapabilities = z.object({ * HTTP transport configuration for MCP. */ export const zMcpServerHttp = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), headers: z.array(zHttpHeader), name: z.string(), url: z.string(), @@ -344,7 +351,7 @@ export const zMcpServerHttp = z.object({ * SSE transport configuration for MCP. */ export const zMcpServerSse = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), headers: z.array(zHttpHeader), name: z.string(), url: z.string(), @@ -354,7 +361,7 @@ export const zMcpServerSse = z.object({ * Stdio transport configuration for MCP. */ export const zMcpServerStdio = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), args: z.array(z.string()), command: z.string(), env: z.array(zEnvVariable), @@ -404,8 +411,8 @@ export const zModelId = z.string(); * @experimental */ export const zModelInfo = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), - description: z.string().nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + description: z.union([z.string(), z.null()]).optional(), modelId: zModelId, name: z.string(), }); @@ -416,7 +423,7 @@ export const zModelInfo = z.object({ * See protocol docs: [Creating a Session](https://agentclientprotocol.com/protocol/session-setup#creating-a-session) */ export const zNewSessionRequest = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), cwd: z.string(), mcpServers: z.array(zMcpServer), }); @@ -442,7 +449,7 @@ export const zPermissionOptionKind = z.union([ * An option presented to the user when requesting permission. */ export const zPermissionOption = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), kind: zPermissionOptionKind, name: z.string(), optionId: zPermissionOptionId, @@ -481,7 +488,7 @@ export const zPlanEntryStatus = z.union([ * See protocol docs: [Plan Entries](https://agentclientprotocol.com/protocol/agent-plan#plan-entries) */ export const zPlanEntry = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), content: z.string(), priority: zPlanEntryPriority, status: zPlanEntryStatus, @@ -497,7 +504,7 @@ export const zPlanEntry = z.object({ * See protocol docs: [Agent Plan](https://agentclientprotocol.com/protocol/agent-plan) */ export const zPlan = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), entries: z.array(zPlanEntry), }); @@ -516,7 +523,7 @@ export const zPlan = z.object({ * See protocol docs: [Prompt Capabilities](https://agentclientprotocol.com/protocol/initialization#prompt-capabilities) */ export const zPromptCapabilities = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), audio: z.boolean().optional().default(false), embeddedContext: z.boolean().optional().default(false), image: z.boolean().optional().default(false), @@ -538,13 +545,13 @@ export const zProtocolVersion = z.number().int().gte(0).lte(65535); * See protocol docs: [Initialization](https://agentclientprotocol.com/protocol/initialization) */ export const zInitializeRequest = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), clientCapabilities: zClientCapabilities.optional().default({ auth: { terminal: false }, fs: { readTextFile: false, writeTextFile: false }, terminal: false, }), - clientInfo: zImplementation.nullish(), + clientInfo: z.union([zImplementation, z.null()]).optional(), protocolVersion: zProtocolVersion, }); @@ -552,7 +559,7 @@ export const zInitializeRequest = z.object({ * Response containing the contents of a text file. */ export const zReadTextFileResponse = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), content: z.string(), }); @@ -560,7 +567,7 @@ export const zReadTextFileResponse = z.object({ * Response to terminal/release method */ export const zReleaseTerminalResponse = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), }); /** @@ -574,7 +581,18 @@ export const zReleaseTerminalResponse = z.object({ * * [2] Fractional parts may be problematic, since many decimal fractions cannot be represented exactly as binary fractions. */ -export const zRequestId = z.union([z.number(), z.string()]).nullable(); +export const zRequestId = z.union([ + z.null(), + z.coerce + .bigint() + .min(BigInt("-9223372036854775808"), { + message: "Invalid value: Expected int64 to be >= -9223372036854775808", + }) + .max(BigInt("9223372036854775807"), { + message: "Invalid value: Expected int64 to be <= 9223372036854775807", + }), + z.string(), +]); /** * **UNSTABLE** @@ -588,7 +606,7 @@ export const zRequestId = z.union([z.number(), z.string()]).nullable(); * @experimental */ export const zCancelRequestNotification = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), requestId: zRequestId, }); @@ -601,18 +619,18 @@ export const zRole = z.enum(["assistant", "user"]); * Optional annotations for the client. The client can use annotations to inform how objects are used or displayed */ export const zAnnotations = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), - audience: z.array(zRole).nullish(), - lastModified: z.string().nullish(), - priority: z.number().nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + audience: z.union([z.array(zRole), z.null()]).optional(), + lastModified: z.union([z.string(), z.null()]).optional(), + priority: z.union([z.number(), z.null()]).optional(), }); /** * Audio provided to or from an LLM. */ export const zAudioContent = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), - annotations: zAnnotations.nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + annotations: z.union([zAnnotations, z.null()]).optional(), data: z.string(), mimeType: z.string(), }); @@ -621,24 +639,37 @@ export const zAudioContent = z.object({ * An image provided to or from an LLM. */ export const zImageContent = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), - annotations: zAnnotations.nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + annotations: z.union([zAnnotations, z.null()]).optional(), data: z.string(), mimeType: z.string(), - uri: z.string().nullish(), + uri: z.union([z.string(), z.null()]).optional(), }); /** * A resource that the server is capable of reading, included in a prompt or tool call result. */ export const zResourceLink = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), - annotations: zAnnotations.nullish(), - description: z.string().nullish(), - mimeType: z.string().nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + annotations: z.union([zAnnotations, z.null()]).optional(), + description: z.union([z.string(), z.null()]).optional(), + mimeType: z.union([z.string(), z.null()]).optional(), name: z.string(), - size: z.number().nullish(), - title: z.string().nullish(), + size: z + .union([ + z.coerce + .bigint() + .min(BigInt("-9223372036854775808"), { + message: + "Invalid value: Expected int64 to be >= -9223372036854775808", + }) + .max(BigInt("9223372036854775807"), { + message: "Invalid value: Expected int64 to be <= 9223372036854775807", + }), + z.null(), + ]) + .optional(), + title: z.union([z.string(), z.null()]).optional(), uri: z.string(), }); @@ -646,7 +677,7 @@ export const zResourceLink = z.object({ * The user selected one of the provided options. */ export const zSelectedPermissionOutcome = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), optionId: zPermissionOptionId, }); @@ -668,10 +699,38 @@ export const zRequestPermissionOutcome = z.union([ * Response to a permission request. */ export const zRequestPermissionResponse = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), outcome: zRequestPermissionOutcome, }); +/** + * **UNSTABLE** + * + * This capability is not part of the spec yet, and may be removed or changed at any point. + * + * Capabilities for the `session/close` method. + * + * By supplying `{}` it means that the agent supports closing of sessions. + * + * @experimental + */ +export const zSessionCloseCapabilities = z.object({ + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), +}); + +/** + * **UNSTABLE** + * + * This capability is not part of the spec yet, and may be removed or changed at any point. + * + * A boolean on/off toggle session configuration option payload. + * + * @experimental + */ +export const zSessionConfigBoolean = z.object({ + currentValue: z.boolean(), +}); + /** * Unique identifier for a session configuration option value group. */ @@ -709,8 +768,8 @@ export const zSessionConfigValueId = z.string(); * A possible value for a session configuration option. */ export const zSessionConfigSelectOption = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), - description: z.string().nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + description: z.union([z.string(), z.null()]).optional(), name: z.string(), value: zSessionConfigValueId, }); @@ -719,7 +778,7 @@ export const zSessionConfigSelectOption = z.object({ * A group of possible values for a session configuration option. */ export const zSessionConfigSelectGroup = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), group: zSessionConfigGroupId, name: z.string(), options: z.array(zSessionConfigSelectOption), @@ -741,27 +800,33 @@ export const zSessionConfigSelect = z.object({ options: zSessionConfigSelectOptions, }); -export const zSessionConfigOption = zSessionConfigSelect - .and( - z.object({ - type: z.literal("select"), - }), - ) - .and( - z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), - category: zSessionConfigOptionCategory.nullish(), - description: z.string().nullish(), - id: zSessionConfigId, - name: z.string(), - }), - ); +export const zSessionConfigOption = z.intersection( + z.union([ + zSessionConfigSelect.and( + z.object({ + type: z.literal("select"), + }), + ), + zSessionConfigBoolean.and( + z.object({ + type: z.literal("boolean"), + }), + ), + ]), + z.object({ + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + category: z.union([zSessionConfigOptionCategory, z.null()]).optional(), + description: z.union([z.string(), z.null()]).optional(), + id: zSessionConfigId, + name: z.string(), + }), +); /** * Session configuration options have been updated. */ export const zConfigOptionUpdate = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), configOptions: z.array(zSessionConfigOption), }); @@ -777,7 +842,7 @@ export const zConfigOptionUpdate = z.object({ * @experimental */ export const zSessionForkCapabilities = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), }); /** @@ -796,25 +861,58 @@ export const zSessionId = z.string(); * See protocol docs: [Cancellation](https://agentclientprotocol.com/protocol/prompt-turn#cancellation) */ export const zCancelNotification = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), sessionId: zSessionId, }); export const zClientNotification = z.object({ method: z.string(), - params: z.union([zCancelNotification, zExtNotification]).nullish(), + params: z + .union([z.union([zCancelNotification, zExtNotification]), z.null()]) + .optional(), +}); + +/** + * **UNSTABLE** + * + * This capability is not part of the spec yet, and may be removed or changed at any point. + * + * Request parameters for closing an active session. + * + * If supported, the agent **must** cancel any ongoing work related to the session + * (treat it as if `session/cancel` was called) and then free up any resources + * associated with the session. + * + * Only available if the Agent supports the `session.close` capability. + * + * @experimental + */ +export const zCloseSessionRequest = z.object({ + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + sessionId: zSessionId, }); /** * Request to create a new terminal and execute a command. */ export const zCreateTerminalRequest = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), args: z.array(z.string()).optional(), command: z.string(), - cwd: z.string().nullish(), + cwd: z.union([z.string(), z.null()]).optional(), env: z.array(zEnvVariable).optional(), - outputByteLimit: z.number().nullish(), + outputByteLimit: z + .union([ + z.coerce + .bigint() + .gte(BigInt(0)) + .max(BigInt("18446744073709551615"), { + message: + "Invalid value: Expected uint64 to be <= 18446744073709551615", + }), + z.null(), + ]) + .optional(), sessionId: zSessionId, }); @@ -833,7 +931,7 @@ export const zCreateTerminalRequest = z.object({ * @experimental */ export const zForkSessionRequest = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), cwd: z.string(), mcpServers: z.array(zMcpServer).optional(), sessionId: zSessionId, @@ -843,7 +941,7 @@ export const zForkSessionRequest = z.object({ * Request to kill a terminal without releasing it. */ export const zKillTerminalRequest = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), sessionId: zSessionId, terminalId: z.string(), }); @@ -856,7 +954,7 @@ export const zKillTerminalRequest = z.object({ * See protocol docs: [Loading Sessions](https://agentclientprotocol.com/protocol/session-setup#loading-sessions) */ export const zLoadSessionRequest = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), cwd: z.string(), mcpServers: z.array(zMcpServer), sessionId: zSessionId, @@ -868,23 +966,31 @@ export const zLoadSessionRequest = z.object({ * Only available if the client supports the `fs.readTextFile` capability. */ export const zReadTextFileRequest = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), limit: z - .number() - .int() - .gte(0) - .max(4294967295, { - message: "Invalid value: Expected uint32 to be <= 4294967295", - }) - .nullish(), + .union([ + z + .number() + .int() + .gte(0) + .max(4294967295, { + message: "Invalid value: Expected uint32 to be <= 4294967295", + }), + z.null(), + ]) + .optional(), line: z - .number() - .int() - .gte(0) - .max(4294967295, { - message: "Invalid value: Expected uint32 to be <= 4294967295", - }) - .nullish(), + .union([ + z + .number() + .int() + .gte(0) + .max(4294967295, { + message: "Invalid value: Expected uint32 to be <= 4294967295", + }), + z.null(), + ]) + .optional(), path: z.string(), sessionId: zSessionId, }); @@ -893,7 +999,7 @@ export const zReadTextFileRequest = z.object({ * Request to release a terminal and free its resources. */ export const zReleaseTerminalRequest = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), sessionId: zSessionId, terminalId: z.string(), }); @@ -913,41 +1019,29 @@ export const zReleaseTerminalRequest = z.object({ * @experimental */ export const zResumeSessionRequest = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), cwd: z.string(), mcpServers: z.array(zMcpServer).optional(), sessionId: zSessionId, }); /** - * **UNSTABLE** - * - * This capability is not part of the spec yet, and may be removed or changed at any point. - * * Information about a session returned by session/list - * - * @experimental */ export const zSessionInfo = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), cwd: z.string(), sessionId: zSessionId, - title: z.string().nullish(), - updatedAt: z.string().nullish(), + title: z.union([z.string(), z.null()]).optional(), + updatedAt: z.union([z.string(), z.null()]).optional(), }); /** - * **UNSTABLE** - * - * This capability is not part of the spec yet, and may be removed or changed at any point. - * * Response from listing sessions. - * - * @experimental */ export const zListSessionsResponse = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), - nextCursor: z.string().nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + nextCursor: z.union([z.string(), z.null()]).optional(), sessions: z.array(zSessionInfo), }); @@ -958,20 +1052,18 @@ export const zListSessionsResponse = z.object({ * This allows clients to display dynamic session names and track session state changes. */ export const zSessionInfoUpdate = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), - title: z.string().nullish(), - updatedAt: z.string().nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + title: z.union([z.string(), z.null()]).optional(), + updatedAt: z.union([z.string(), z.null()]).optional(), }); /** * Capabilities for the `session/list` method. * * By supplying `{}` it means that the agent supports listing of sessions. - * - * Further capabilities can be added in the future for other means of filtering or searching the list. */ export const zSessionListCapabilities = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), }); /** @@ -985,7 +1077,7 @@ export const zSessionModeId = z.string(); * See protocol docs: [Session Modes](https://agentclientprotocol.com/protocol/session-modes) */ export const zCurrentModeUpdate = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), currentModeId: zSessionModeId, }); @@ -995,8 +1087,8 @@ export const zCurrentModeUpdate = z.object({ * See protocol docs: [Session Modes](https://agentclientprotocol.com/protocol/session-modes) */ export const zSessionMode = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), - description: z.string().nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + description: z.union([z.string(), z.null()]).optional(), id: zSessionModeId, name: z.string(), }); @@ -1005,7 +1097,7 @@ export const zSessionMode = z.object({ * The set of modes and the one currently active. */ export const zSessionModeState = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), availableModes: z.array(zSessionMode), currentModeId: zSessionModeId, }); @@ -1020,7 +1112,7 @@ export const zSessionModeState = z.object({ * @experimental */ export const zSessionModelState = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), availableModels: z.array(zModelInfo), currentModelId: zModelId, }); @@ -1035,10 +1127,10 @@ export const zSessionModelState = z.object({ * @experimental */ export const zForkSessionResponse = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), - configOptions: z.array(zSessionConfigOption).nullish(), - models: zSessionModelState.nullish(), - modes: zSessionModeState.nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + configOptions: z.union([z.array(zSessionConfigOption), z.null()]).optional(), + models: z.union([zSessionModelState, z.null()]).optional(), + modes: z.union([zSessionModeState, z.null()]).optional(), sessionId: zSessionId, }); @@ -1046,10 +1138,10 @@ export const zForkSessionResponse = z.object({ * Response from loading an existing session. */ export const zLoadSessionResponse = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), - configOptions: z.array(zSessionConfigOption).nullish(), - models: zSessionModelState.nullish(), - modes: zSessionModeState.nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + configOptions: z.union([z.array(zSessionConfigOption), z.null()]).optional(), + models: z.union([zSessionModelState, z.null()]).optional(), + modes: z.union([zSessionModeState, z.null()]).optional(), }); /** @@ -1058,10 +1150,10 @@ export const zLoadSessionResponse = z.object({ * See protocol docs: [Creating a Session](https://agentclientprotocol.com/protocol/session-setup#creating-a-session) */ export const zNewSessionResponse = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), - configOptions: z.array(zSessionConfigOption).nullish(), - models: zSessionModelState.nullish(), - modes: zSessionModeState.nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + configOptions: z.union([z.array(zSessionConfigOption), z.null()]).optional(), + models: z.union([zSessionModelState, z.null()]).optional(), + modes: z.union([zSessionModeState, z.null()]).optional(), sessionId: zSessionId, }); @@ -1075,10 +1167,10 @@ export const zNewSessionResponse = z.object({ * @experimental */ export const zResumeSessionResponse = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), - configOptions: z.array(zSessionConfigOption).nullish(), - models: zSessionModelState.nullish(), - modes: zSessionModeState.nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + configOptions: z.union([z.array(zSessionConfigOption), z.null()]).optional(), + models: z.union([zSessionModelState, z.null()]).optional(), + modes: z.union([zSessionModeState, z.null()]).optional(), }); /** @@ -1093,22 +1185,7 @@ export const zResumeSessionResponse = z.object({ * @experimental */ export const zSessionResumeCapabilities = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), -}); - -/** - * **UNSTABLE** - * - * This capability is not part of the spec yet, and may be removed or changed at any point. - * - * Capabilities for the `session/stop` method. - * - * By supplying `{}` it means that the agent supports stopping of sessions. - * - * @experimental - */ -export const zSessionStopCapabilities = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), }); /** @@ -1123,11 +1200,11 @@ export const zSessionStopCapabilities = z.object({ * See protocol docs: [Session Capabilities](https://agentclientprotocol.com/protocol/initialization#session-capabilities) */ export const zSessionCapabilities = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), - fork: zSessionForkCapabilities.nullish(), - list: zSessionListCapabilities.nullish(), - resume: zSessionResumeCapabilities.nullish(), - stop: zSessionStopCapabilities.nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + fork: z.union([zSessionForkCapabilities, z.null()]).optional(), + list: z.union([zSessionListCapabilities, z.null()]).optional(), + resume: z.union([zSessionResumeCapabilities, z.null()]).optional(), + stop: z.union([zSessionCloseCapabilities, z.null()]).optional(), }); /** @@ -1139,7 +1216,7 @@ export const zSessionCapabilities = z.object({ * See protocol docs: [Agent Capabilities](https://agentclientprotocol.com/protocol/initialization#agent-capabilities) */ export const zAgentCapabilities = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), loadSession: z.boolean().optional().default(false), mcpCapabilities: zMcpCapabilities .optional() @@ -1160,7 +1237,7 @@ export const zAgentCapabilities = z.object({ * See protocol docs: [Initialization](https://agentclientprotocol.com/protocol/initialization) */ export const zInitializeResponse = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), agentCapabilities: zAgentCapabilities.optional().default({ loadSession: false, mcpCapabilities: { http: false, sse: false }, @@ -1171,26 +1248,33 @@ export const zInitializeResponse = z.object({ }, sessionCapabilities: {}, }), - agentInfo: zImplementation.nullish(), + agentInfo: z.union([zImplementation, z.null()]).optional(), authMethods: z.array(zAuthMethod).optional().default([]), protocolVersion: zProtocolVersion, }); -/** - * Request parameters for setting a session configuration option. - */ -export const zSetSessionConfigOptionRequest = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), - configId: zSessionConfigId, - sessionId: zSessionId, - value: zSessionConfigValueId, -}); +export const zSetSessionConfigOptionRequest = z.intersection( + z.union([ + z.object({ + type: z.literal("boolean"), + value: z.boolean(), + }), + z.object({ + value: zSessionConfigValueId, + }), + ]), + z.object({ + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + configId: zSessionConfigId, + sessionId: zSessionId, + }), +); /** * Response to `session/set_config_option` method. */ export const zSetSessionConfigOptionResponse = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), configOptions: z.array(zSessionConfigOption), }); @@ -1198,7 +1282,7 @@ export const zSetSessionConfigOptionResponse = z.object({ * Request parameters for setting a session mode. */ export const zSetSessionModeRequest = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), modeId: zSessionModeId, sessionId: zSessionId, }); @@ -1207,7 +1291,7 @@ export const zSetSessionModeRequest = z.object({ * Response to `session/set_mode` method. */ export const zSetSessionModeResponse = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), }); /** @@ -1220,7 +1304,7 @@ export const zSetSessionModeResponse = z.object({ * @experimental */ export const zSetSessionModelRequest = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), modelId: zModelId, sessionId: zSessionId, }); @@ -1235,7 +1319,7 @@ export const zSetSessionModelRequest = z.object({ * @experimental */ export const zSetSessionModelResponse = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), }); /** @@ -1251,39 +1335,6 @@ export const zStopReason = z.union([ z.literal("cancelled"), ]); -/** - * **UNSTABLE** - * - * This capability is not part of the spec yet, and may be removed or changed at any point. - * - * Request parameters for stopping an active session. - * - * If supported, the agent **must** cancel any ongoing work related to the session - * (treat it as if `session/cancel` was called) and then free up any resources - * associated with the session. - * - * Only available if the Agent supports the `session.stop` capability. - * - * @experimental - */ -export const zStopSessionRequest = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), - sessionId: zSessionId, -}); - -/** - * **UNSTABLE** - * - * This capability is not part of the spec yet, and may be removed or changed at any point. - * - * Response from stopping a session. - * - * @experimental - */ -export const zStopSessionResponse = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), -}); - /** * Embed a terminal created with `terminal/create` by its id. * @@ -1292,7 +1343,7 @@ export const zStopSessionResponse = z.object({ * See protocol docs: [Terminal](https://agentclientprotocol.com/protocol/terminals) */ export const zTerminal = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), terminalId: z.string(), }); @@ -1300,23 +1351,27 @@ export const zTerminal = z.object({ * Exit status of a terminal command. */ export const zTerminalExitStatus = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), exitCode: z - .number() - .int() - .gte(0) - .max(4294967295, { - message: "Invalid value: Expected uint32 to be <= 4294967295", - }) - .nullish(), - signal: z.string().nullish(), + .union([ + z + .number() + .int() + .gte(0) + .max(4294967295, { + message: "Invalid value: Expected uint32 to be <= 4294967295", + }), + z.null(), + ]) + .optional(), + signal: z.union([z.string(), z.null()]).optional(), }); /** * Request to get the current output and status of a terminal. */ export const zTerminalOutputRequest = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), sessionId: zSessionId, terminalId: z.string(), }); @@ -1325,8 +1380,8 @@ export const zTerminalOutputRequest = z.object({ * Response containing the terminal output and exit status. */ export const zTerminalOutputResponse = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), - exitStatus: zTerminalExitStatus.nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + exitStatus: z.union([zTerminalExitStatus, z.null()]).optional(), output: z.string(), truncated: z.boolean(), }); @@ -1335,8 +1390,8 @@ export const zTerminalOutputResponse = z.object({ * Text provided to or from an LLM. */ export const zTextContent = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), - annotations: zAnnotations.nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + annotations: z.union([zAnnotations, z.null()]).optional(), text: z.string(), }); @@ -1344,8 +1399,8 @@ export const zTextContent = z.object({ * Text-based resource contents. */ export const zTextResourceContents = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), - mimeType: z.string().nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + mimeType: z.union([z.string(), z.null()]).optional(), text: z.string(), uri: z.string(), }); @@ -1362,8 +1417,8 @@ export const zEmbeddedResourceResource = z.union([ * The contents of a resource, embedded into a prompt or tool call result. */ export const zEmbeddedResource = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), - annotations: zAnnotations.nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + annotations: z.union([zAnnotations, z.null()]).optional(), resource: zEmbeddedResourceResource, }); @@ -1415,7 +1470,7 @@ export const zContentBlock = z.union([ * Standard content block (text, images, resources). */ export const zContent = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), content: zContentBlock, }); @@ -1423,9 +1478,9 @@ export const zContent = z.object({ * A streamed item of content */ export const zContentChunk = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), content: zContentBlock, - messageId: z.string().nullish(), + messageId: z.union([z.string(), z.null()]).optional(), }); /** @@ -1436,8 +1491,8 @@ export const zContentChunk = z.object({ * See protocol docs: [User Message](https://agentclientprotocol.com/protocol/prompt-turn#1-user-message) */ export const zPromptRequest = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), - messageId: z.string().nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + messageId: z.union([z.string(), z.null()]).optional(), prompt: z.array(zContentBlock), sessionId: zSessionId, }); @@ -1447,21 +1502,24 @@ export const zClientRequest = z.object({ method: z.string(), params: z .union([ - zInitializeRequest, - zAuthenticateRequest, - zNewSessionRequest, - zLoadSessionRequest, - zListSessionsRequest, - zForkSessionRequest, - zResumeSessionRequest, - zStopSessionRequest, - zSetSessionModeRequest, - zSetSessionConfigOptionRequest, - zPromptRequest, - zSetSessionModelRequest, - zExtRequest, + z.union([ + zInitializeRequest, + zAuthenticateRequest, + zNewSessionRequest, + zLoadSessionRequest, + zListSessionsRequest, + zForkSessionRequest, + zResumeSessionRequest, + zCloseSessionRequest, + zSetSessionModeRequest, + zSetSessionConfigOptionRequest, + zPromptRequest, + zSetSessionModelRequest, + zExtRequest, + ]), + z.null(), ]) - .nullish(), + .optional(), }); /** @@ -1504,15 +1562,19 @@ export const zToolCallId = z.string(); * See protocol docs: [Following the Agent](https://agentclientprotocol.com/protocol/tool-calls#following-the-agent) */ export const zToolCallLocation = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), line: z - .number() - .int() - .gte(0) - .max(4294967295, { - message: "Invalid value: Expected uint32 to be <= 4294967295", - }) - .nullish(), + .union([ + z + .number() + .int() + .gte(0) + .max(4294967295, { + message: "Invalid value: Expected uint32 to be <= 4294967295", + }), + z.null(), + ]) + .optional(), path: z.string(), }); @@ -1560,7 +1622,7 @@ export const zToolKind = z.union([ * See protocol docs: [Tool Calls](https://agentclientprotocol.com/protocol/tool-calls) */ export const zToolCall = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), content: z.array(zToolCallContent).optional(), kind: zToolKind.optional(), locations: z.array(zToolCallLocation).optional(), @@ -1580,14 +1642,14 @@ export const zToolCall = z.object({ * See protocol docs: [Updating](https://agentclientprotocol.com/protocol/tool-calls#updating) */ export const zToolCallUpdate = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), - content: z.array(zToolCallContent).nullish(), - kind: zToolKind.nullish(), - locations: z.array(zToolCallLocation).nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + content: z.union([z.array(zToolCallContent), z.null()]).optional(), + kind: z.union([zToolKind, z.null()]).optional(), + locations: z.union([z.array(zToolCallLocation), z.null()]).optional(), rawInput: z.unknown().optional(), rawOutput: z.unknown().optional(), - status: zToolCallStatus.nullish(), - title: z.string().nullish(), + status: z.union([zToolCallStatus, z.null()]).optional(), + title: z.union([z.string(), z.null()]).optional(), toolCallId: zToolCallId, }); @@ -1599,7 +1661,7 @@ export const zToolCallUpdate = z.object({ * See protocol docs: [Requesting Permission](https://agentclientprotocol.com/protocol/tool-calls#requesting-permission) */ export const zRequestPermissionRequest = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), options: z.array(zPermissionOption), sessionId: zSessionId, toolCall: zToolCallUpdate, @@ -1609,7 +1671,7 @@ export const zRequestPermissionRequest = z.object({ * All text that was typed after the command name is provided as input. */ export const zUnstructuredCommandInput = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), hint: z.string(), }); @@ -1624,9 +1686,9 @@ export const zAvailableCommandInput = zUnstructuredCommandInput; * Information about a command. */ export const zAvailableCommand = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), description: z.string(), - input: zAvailableCommandInput.nullish(), + input: z.union([zAvailableCommandInput, z.null()]).optional(), name: z.string(), }); @@ -1634,7 +1696,7 @@ export const zAvailableCommand = z.object({ * Available commands are ready or have changed */ export const zAvailableCommandsUpdate = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), availableCommands: z.array(zAvailableCommand), }); @@ -1648,12 +1710,60 @@ export const zAvailableCommandsUpdate = z.object({ * @experimental */ export const zUsage = z.object({ - cachedReadTokens: z.number().nullish(), - cachedWriteTokens: z.number().nullish(), - inputTokens: z.number(), - outputTokens: z.number(), - thoughtTokens: z.number().nullish(), - totalTokens: z.number(), + cachedReadTokens: z + .union([ + z.coerce + .bigint() + .gte(BigInt(0)) + .max(BigInt("18446744073709551615"), { + message: + "Invalid value: Expected uint64 to be <= 18446744073709551615", + }), + z.null(), + ]) + .optional(), + cachedWriteTokens: z + .union([ + z.coerce + .bigint() + .gte(BigInt(0)) + .max(BigInt("18446744073709551615"), { + message: + "Invalid value: Expected uint64 to be <= 18446744073709551615", + }), + z.null(), + ]) + .optional(), + inputTokens: z.coerce + .bigint() + .gte(BigInt(0)) + .max(BigInt("18446744073709551615"), { + message: "Invalid value: Expected uint64 to be <= 18446744073709551615", + }), + outputTokens: z.coerce + .bigint() + .gte(BigInt(0)) + .max(BigInt("18446744073709551615"), { + message: "Invalid value: Expected uint64 to be <= 18446744073709551615", + }), + thoughtTokens: z + .union([ + z.coerce + .bigint() + .gte(BigInt(0)) + .max(BigInt("18446744073709551615"), { + message: + "Invalid value: Expected uint64 to be <= 18446744073709551615", + }), + z.null(), + ]) + .optional(), + totalTokens: z.coerce + .bigint() + .gte(BigInt(0)) + .max(BigInt("18446744073709551615"), { + message: "Invalid value: Expected uint64 to be <= 18446744073709551615", + }), }); /** @@ -1662,10 +1772,10 @@ export const zUsage = z.object({ * See protocol docs: [Check for Completion](https://agentclientprotocol.com/protocol/prompt-turn#4-check-for-completion) */ export const zPromptResponse = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), stopReason: zStopReason, - usage: zUsage.nullish(), - userMessageId: z.string().nullish(), + usage: z.union([zUsage, z.null()]).optional(), + userMessageId: z.union([z.string(), z.null()]).optional(), }); export const zAgentResponse = z.union([ @@ -1679,7 +1789,7 @@ export const zAgentResponse = z.union([ zListSessionsResponse, zForkSessionResponse, zResumeSessionResponse, - zStopSessionResponse, + zCloseSessionResponse, zSetSessionModeResponse, zSetSessionConfigOptionResponse, zPromptResponse, @@ -1703,10 +1813,20 @@ export const zAgentResponse = z.union([ * @experimental */ export const zUsageUpdate = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), - cost: zCost.nullish(), - size: z.number(), - used: z.number(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + cost: z.union([zCost, z.null()]).optional(), + size: z.coerce + .bigint() + .gte(BigInt(0)) + .max(BigInt("18446744073709551615"), { + message: "Invalid value: Expected uint64 to be <= 18446744073709551615", + }), + used: z.coerce + .bigint() + .gte(BigInt(0)) + .max(BigInt("18446744073709551615"), { + message: "Invalid value: Expected uint64 to be <= 18446744073709551615", + }), }); /** @@ -1782,21 +1902,23 @@ export const zSessionUpdate = z.union([ * See protocol docs: [Agent Reports Output](https://agentclientprotocol.com/protocol/prompt-turn#3-agent-reports-output) */ export const zSessionNotification = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), sessionId: zSessionId, update: zSessionUpdate, }); export const zAgentNotification = z.object({ method: z.string(), - params: z.union([zSessionNotification, zExtNotification]).nullish(), + params: z + .union([z.union([zSessionNotification, zExtNotification]), z.null()]) + .optional(), }); /** * Request to wait for a terminal command to exit. */ export const zWaitForTerminalExitRequest = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), sessionId: zSessionId, terminalId: z.string(), }); @@ -1805,16 +1927,20 @@ export const zWaitForTerminalExitRequest = z.object({ * Response containing the exit status of a terminal command. */ export const zWaitForTerminalExitResponse = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), exitCode: z - .number() - .int() - .gte(0) - .max(4294967295, { - message: "Invalid value: Expected uint32 to be <= 4294967295", - }) - .nullish(), - signal: z.string().nullish(), + .union([ + z + .number() + .int() + .gte(0) + .max(4294967295, { + message: "Invalid value: Expected uint32 to be <= 4294967295", + }), + z.null(), + ]) + .optional(), + signal: z.union([z.string(), z.null()]).optional(), }); /** @@ -1823,7 +1949,7 @@ export const zWaitForTerminalExitResponse = z.object({ * Only available if the client supports the `fs.writeTextFile` capability. */ export const zWriteTextFileRequest = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), content: z.string(), path: z.string(), sessionId: zSessionId, @@ -1834,24 +1960,27 @@ export const zAgentRequest = z.object({ method: z.string(), params: z .union([ - zWriteTextFileRequest, - zReadTextFileRequest, - zRequestPermissionRequest, - zCreateTerminalRequest, - zTerminalOutputRequest, - zReleaseTerminalRequest, - zWaitForTerminalExitRequest, - zKillTerminalRequest, - zExtRequest, + z.union([ + zWriteTextFileRequest, + zReadTextFileRequest, + zRequestPermissionRequest, + zCreateTerminalRequest, + zTerminalOutputRequest, + zReleaseTerminalRequest, + zWaitForTerminalExitRequest, + zKillTerminalRequest, + zExtRequest, + ]), + z.null(), ]) - .nullish(), + .optional(), }); /** * Response to `fs/write_text_file` */ export const zWriteTextFileResponse = z.object({ - _meta: z.record(z.string(), z.unknown()).nullish(), + _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), }); export const zClientResponse = z.union([ From d9a440d8f6bd15db50f84b46faacf27192b63452 Mon Sep 17 00:00:00 2001 From: Ben Brandt Date: Tue, 10 Mar 2026 18:46:54 +0000 Subject: [PATCH 3/3] Fix generation issues... --- src/schema/index.ts | 1 - src/schema/zod.gen.ts | 599 +++++++++++++++++------------------------- 2 files changed, 238 insertions(+), 362 deletions(-) diff --git a/src/schema/index.ts b/src/schema/index.ts index 0236284..91e3143 100644 --- a/src/schema/index.ts +++ b/src/schema/index.ts @@ -23,7 +23,6 @@ export type { CancelRequestNotification, ClientCapabilities, ClientNotification, - ClientOptions, ClientRequest, ClientResponse, CloseSessionRequest, diff --git a/src/schema/zod.gen.ts b/src/schema/zod.gen.ts index d09d07e..54d4b01 100644 --- a/src/schema/zod.gen.ts +++ b/src/schema/zod.gen.ts @@ -16,7 +16,7 @@ import { z } from "zod/v4"; * @experimental */ export const zAuthCapabilities = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), terminal: z.boolean().optional().default(false), }); @@ -30,8 +30,8 @@ export const zAuthCapabilities = z.object({ * @experimental */ export const zAuthEnvVar = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), - label: z.union([z.string(), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), + label: z.string().nullish(), name: z.string(), optional: z.boolean().optional().default(false), secret: z.boolean().optional().default(true), @@ -43,8 +43,8 @@ export const zAuthEnvVar = z.object({ * This is the default authentication method type. */ export const zAuthMethodAgent = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), - description: z.union([z.string(), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), + description: z.string().nullish(), id: z.string(), name: z.string(), }); @@ -61,10 +61,10 @@ export const zAuthMethodAgent = z.object({ * @experimental */ export const zAuthMethodEnvVar = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), - description: z.union([z.string(), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), + description: z.string().nullish(), id: z.string(), - link: z.union([z.string(), z.null()]).optional(), + link: z.string().nullish(), name: z.string(), vars: z.array(zAuthEnvVar), }); @@ -81,10 +81,10 @@ export const zAuthMethodEnvVar = z.object({ * @experimental */ export const zAuthMethodTerminal = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), args: z.array(z.string()).optional(), - description: z.union([z.string(), z.null()]).optional(), - env: z.record(z.string()).optional(), + description: z.string().nullish(), + env: z.record(z.string(), z.string()).optional(), id: z.string(), name: z.string(), }); @@ -115,7 +115,7 @@ export const zAuthMethod = z.union([ * Specifies which authentication method to use. */ export const zAuthenticateRequest = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), methodId: z.string(), }); @@ -123,16 +123,16 @@ export const zAuthenticateRequest = z.object({ * Response to the `authenticate` method. */ export const zAuthenticateResponse = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), }); /** * Binary resource contents. */ export const zBlobResourceContents = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), blob: z.string(), - mimeType: z.union([z.string(), z.null()]).optional(), + mimeType: z.string().nullish(), uri: z.string(), }); @@ -146,7 +146,7 @@ export const zBlobResourceContents = z.object({ * @experimental */ export const zCloseSessionResponse = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), }); /** @@ -167,7 +167,7 @@ export const zCost = z.object({ * Response containing the ID of the created terminal. */ export const zCreateTerminalResponse = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), terminalId: z.string(), }); @@ -179,9 +179,9 @@ export const zCreateTerminalResponse = z.object({ * See protocol docs: [Content](https://agentclientprotocol.com/protocol/tool-calls#content) */ export const zDiff = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), newText: z.string(), - oldText: z.union([z.string(), z.null()]).optional(), + oldText: z.string().nullish(), path: z.string(), }); @@ -189,7 +189,7 @@ export const zDiff = z.object({ * An environment variable to set when launching an MCP server. */ export const zEnvVariable = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), name: z.string(), value: z.string(), }); @@ -267,7 +267,7 @@ export const zExtResponse = z.unknown(); * See protocol docs: [FileSystem](https://agentclientprotocol.com/protocol/initialization#filesystem) */ export const zFileSystemCapabilities = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), readTextFile: z.boolean().optional().default(false), writeTextFile: z.boolean().optional().default(false), }); @@ -281,7 +281,7 @@ export const zFileSystemCapabilities = z.object({ * See protocol docs: [Client Capabilities](https://agentclientprotocol.com/protocol/initialization#client-capabilities) */ export const zClientCapabilities = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), auth: zAuthCapabilities.optional().default({ terminal: false }), fs: zFileSystemCapabilities .optional() @@ -293,7 +293,7 @@ export const zClientCapabilities = z.object({ * An HTTP header to set when making requests to the MCP server. */ export const zHttpHeader = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), name: z.string(), value: z.string(), }); @@ -304,9 +304,9 @@ export const zHttpHeader = z.object({ * title for UI representation. */ export const zImplementation = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), name: z.string(), - title: z.union([z.string(), z.null()]).optional(), + title: z.string().nullish(), version: z.string(), }); @@ -314,7 +314,7 @@ export const zImplementation = z.object({ * Response to `terminal/kill` method */ export const zKillTerminalResponse = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), }); /** @@ -323,16 +323,16 @@ export const zKillTerminalResponse = z.object({ * Only available if the Agent supports the `sessionCapabilities.list` capability. */ export const zListSessionsRequest = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), - cursor: z.union([z.string(), z.null()]).optional(), - cwd: z.union([z.string(), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), + cursor: z.string().nullish(), + cwd: z.string().nullish(), }); /** * MCP capabilities supported by the agent */ export const zMcpCapabilities = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), http: z.boolean().optional().default(false), sse: z.boolean().optional().default(false), }); @@ -341,7 +341,7 @@ export const zMcpCapabilities = z.object({ * HTTP transport configuration for MCP. */ export const zMcpServerHttp = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), headers: z.array(zHttpHeader), name: z.string(), url: z.string(), @@ -351,7 +351,7 @@ export const zMcpServerHttp = z.object({ * SSE transport configuration for MCP. */ export const zMcpServerSse = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), headers: z.array(zHttpHeader), name: z.string(), url: z.string(), @@ -361,7 +361,7 @@ export const zMcpServerSse = z.object({ * Stdio transport configuration for MCP. */ export const zMcpServerStdio = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), args: z.array(z.string()), command: z.string(), env: z.array(zEnvVariable), @@ -411,8 +411,8 @@ export const zModelId = z.string(); * @experimental */ export const zModelInfo = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), - description: z.union([z.string(), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), + description: z.string().nullish(), modelId: zModelId, name: z.string(), }); @@ -423,7 +423,7 @@ export const zModelInfo = z.object({ * See protocol docs: [Creating a Session](https://agentclientprotocol.com/protocol/session-setup#creating-a-session) */ export const zNewSessionRequest = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), cwd: z.string(), mcpServers: z.array(zMcpServer), }); @@ -449,7 +449,7 @@ export const zPermissionOptionKind = z.union([ * An option presented to the user when requesting permission. */ export const zPermissionOption = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), kind: zPermissionOptionKind, name: z.string(), optionId: zPermissionOptionId, @@ -488,7 +488,7 @@ export const zPlanEntryStatus = z.union([ * See protocol docs: [Plan Entries](https://agentclientprotocol.com/protocol/agent-plan#plan-entries) */ export const zPlanEntry = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), content: z.string(), priority: zPlanEntryPriority, status: zPlanEntryStatus, @@ -504,7 +504,7 @@ export const zPlanEntry = z.object({ * See protocol docs: [Agent Plan](https://agentclientprotocol.com/protocol/agent-plan) */ export const zPlan = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), entries: z.array(zPlanEntry), }); @@ -523,7 +523,7 @@ export const zPlan = z.object({ * See protocol docs: [Prompt Capabilities](https://agentclientprotocol.com/protocol/initialization#prompt-capabilities) */ export const zPromptCapabilities = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), audio: z.boolean().optional().default(false), embeddedContext: z.boolean().optional().default(false), image: z.boolean().optional().default(false), @@ -545,13 +545,13 @@ export const zProtocolVersion = z.number().int().gte(0).lte(65535); * See protocol docs: [Initialization](https://agentclientprotocol.com/protocol/initialization) */ export const zInitializeRequest = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), clientCapabilities: zClientCapabilities.optional().default({ auth: { terminal: false }, fs: { readTextFile: false, writeTextFile: false }, terminal: false, }), - clientInfo: z.union([zImplementation, z.null()]).optional(), + clientInfo: zImplementation.nullish(), protocolVersion: zProtocolVersion, }); @@ -559,7 +559,7 @@ export const zInitializeRequest = z.object({ * Response containing the contents of a text file. */ export const zReadTextFileResponse = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), content: z.string(), }); @@ -567,7 +567,7 @@ export const zReadTextFileResponse = z.object({ * Response to terminal/release method */ export const zReleaseTerminalResponse = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), }); /** @@ -581,18 +581,7 @@ export const zReleaseTerminalResponse = z.object({ * * [2] Fractional parts may be problematic, since many decimal fractions cannot be represented exactly as binary fractions. */ -export const zRequestId = z.union([ - z.null(), - z.coerce - .bigint() - .min(BigInt("-9223372036854775808"), { - message: "Invalid value: Expected int64 to be >= -9223372036854775808", - }) - .max(BigInt("9223372036854775807"), { - message: "Invalid value: Expected int64 to be <= 9223372036854775807", - }), - z.string(), -]); +export const zRequestId = z.union([z.number(), z.string()]).nullable(); /** * **UNSTABLE** @@ -606,7 +595,7 @@ export const zRequestId = z.union([ * @experimental */ export const zCancelRequestNotification = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), requestId: zRequestId, }); @@ -619,18 +608,18 @@ export const zRole = z.enum(["assistant", "user"]); * Optional annotations for the client. The client can use annotations to inform how objects are used or displayed */ export const zAnnotations = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), - audience: z.union([z.array(zRole), z.null()]).optional(), - lastModified: z.union([z.string(), z.null()]).optional(), - priority: z.union([z.number(), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), + audience: z.array(zRole).nullish(), + lastModified: z.string().nullish(), + priority: z.number().nullish(), }); /** * Audio provided to or from an LLM. */ export const zAudioContent = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), - annotations: z.union([zAnnotations, z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), + annotations: zAnnotations.nullish(), data: z.string(), mimeType: z.string(), }); @@ -639,37 +628,24 @@ export const zAudioContent = z.object({ * An image provided to or from an LLM. */ export const zImageContent = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), - annotations: z.union([zAnnotations, z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), + annotations: zAnnotations.nullish(), data: z.string(), mimeType: z.string(), - uri: z.union([z.string(), z.null()]).optional(), + uri: z.string().nullish(), }); /** * A resource that the server is capable of reading, included in a prompt or tool call result. */ export const zResourceLink = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), - annotations: z.union([zAnnotations, z.null()]).optional(), - description: z.union([z.string(), z.null()]).optional(), - mimeType: z.union([z.string(), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), + annotations: zAnnotations.nullish(), + description: z.string().nullish(), + mimeType: z.string().nullish(), name: z.string(), - size: z - .union([ - z.coerce - .bigint() - .min(BigInt("-9223372036854775808"), { - message: - "Invalid value: Expected int64 to be >= -9223372036854775808", - }) - .max(BigInt("9223372036854775807"), { - message: "Invalid value: Expected int64 to be <= 9223372036854775807", - }), - z.null(), - ]) - .optional(), - title: z.union([z.string(), z.null()]).optional(), + size: z.number().nullish(), + title: z.string().nullish(), uri: z.string(), }); @@ -677,7 +653,7 @@ export const zResourceLink = z.object({ * The user selected one of the provided options. */ export const zSelectedPermissionOutcome = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), optionId: zPermissionOptionId, }); @@ -699,7 +675,7 @@ export const zRequestPermissionOutcome = z.union([ * Response to a permission request. */ export const zRequestPermissionResponse = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), outcome: zRequestPermissionOutcome, }); @@ -715,7 +691,7 @@ export const zRequestPermissionResponse = z.object({ * @experimental */ export const zSessionCloseCapabilities = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), }); /** @@ -768,8 +744,8 @@ export const zSessionConfigValueId = z.string(); * A possible value for a session configuration option. */ export const zSessionConfigSelectOption = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), - description: z.union([z.string(), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), + description: z.string().nullish(), name: z.string(), value: zSessionConfigValueId, }); @@ -778,7 +754,7 @@ export const zSessionConfigSelectOption = z.object({ * A group of possible values for a session configuration option. */ export const zSessionConfigSelectGroup = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), group: zSessionConfigGroupId, name: z.string(), options: z.array(zSessionConfigSelectOption), @@ -814,9 +790,9 @@ export const zSessionConfigOption = z.intersection( ), ]), z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), - category: z.union([zSessionConfigOptionCategory, z.null()]).optional(), - description: z.union([z.string(), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), + category: zSessionConfigOptionCategory.nullish(), + description: z.string().nullish(), id: zSessionConfigId, name: z.string(), }), @@ -826,7 +802,7 @@ export const zSessionConfigOption = z.intersection( * Session configuration options have been updated. */ export const zConfigOptionUpdate = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), configOptions: z.array(zSessionConfigOption), }); @@ -842,7 +818,7 @@ export const zConfigOptionUpdate = z.object({ * @experimental */ export const zSessionForkCapabilities = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), }); /** @@ -861,15 +837,13 @@ export const zSessionId = z.string(); * See protocol docs: [Cancellation](https://agentclientprotocol.com/protocol/prompt-turn#cancellation) */ export const zCancelNotification = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), sessionId: zSessionId, }); export const zClientNotification = z.object({ method: z.string(), - params: z - .union([z.union([zCancelNotification, zExtNotification]), z.null()]) - .optional(), + params: z.union([zCancelNotification, zExtNotification]).nullish(), }); /** @@ -888,7 +862,7 @@ export const zClientNotification = z.object({ * @experimental */ export const zCloseSessionRequest = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), sessionId: zSessionId, }); @@ -896,23 +870,12 @@ export const zCloseSessionRequest = z.object({ * Request to create a new terminal and execute a command. */ export const zCreateTerminalRequest = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), args: z.array(z.string()).optional(), command: z.string(), - cwd: z.union([z.string(), z.null()]).optional(), + cwd: z.string().nullish(), env: z.array(zEnvVariable).optional(), - outputByteLimit: z - .union([ - z.coerce - .bigint() - .gte(BigInt(0)) - .max(BigInt("18446744073709551615"), { - message: - "Invalid value: Expected uint64 to be <= 18446744073709551615", - }), - z.null(), - ]) - .optional(), + outputByteLimit: z.number().nullish(), sessionId: zSessionId, }); @@ -931,7 +894,7 @@ export const zCreateTerminalRequest = z.object({ * @experimental */ export const zForkSessionRequest = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), cwd: z.string(), mcpServers: z.array(zMcpServer).optional(), sessionId: zSessionId, @@ -941,7 +904,7 @@ export const zForkSessionRequest = z.object({ * Request to kill a terminal without releasing it. */ export const zKillTerminalRequest = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), sessionId: zSessionId, terminalId: z.string(), }); @@ -954,7 +917,7 @@ export const zKillTerminalRequest = z.object({ * See protocol docs: [Loading Sessions](https://agentclientprotocol.com/protocol/session-setup#loading-sessions) */ export const zLoadSessionRequest = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), cwd: z.string(), mcpServers: z.array(zMcpServer), sessionId: zSessionId, @@ -966,31 +929,23 @@ export const zLoadSessionRequest = z.object({ * Only available if the client supports the `fs.readTextFile` capability. */ export const zReadTextFileRequest = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), limit: z - .union([ - z - .number() - .int() - .gte(0) - .max(4294967295, { - message: "Invalid value: Expected uint32 to be <= 4294967295", - }), - z.null(), - ]) - .optional(), + .number() + .int() + .gte(0) + .max(4294967295, { + message: "Invalid value: Expected uint32 to be <= 4294967295", + }) + .nullish(), line: z - .union([ - z - .number() - .int() - .gte(0) - .max(4294967295, { - message: "Invalid value: Expected uint32 to be <= 4294967295", - }), - z.null(), - ]) - .optional(), + .number() + .int() + .gte(0) + .max(4294967295, { + message: "Invalid value: Expected uint32 to be <= 4294967295", + }) + .nullish(), path: z.string(), sessionId: zSessionId, }); @@ -999,7 +954,7 @@ export const zReadTextFileRequest = z.object({ * Request to release a terminal and free its resources. */ export const zReleaseTerminalRequest = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), sessionId: zSessionId, terminalId: z.string(), }); @@ -1019,7 +974,7 @@ export const zReleaseTerminalRequest = z.object({ * @experimental */ export const zResumeSessionRequest = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), cwd: z.string(), mcpServers: z.array(zMcpServer).optional(), sessionId: zSessionId, @@ -1029,19 +984,19 @@ export const zResumeSessionRequest = z.object({ * Information about a session returned by session/list */ export const zSessionInfo = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), cwd: z.string(), sessionId: zSessionId, - title: z.union([z.string(), z.null()]).optional(), - updatedAt: z.union([z.string(), z.null()]).optional(), + title: z.string().nullish(), + updatedAt: z.string().nullish(), }); /** * Response from listing sessions. */ export const zListSessionsResponse = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), - nextCursor: z.union([z.string(), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), + nextCursor: z.string().nullish(), sessions: z.array(zSessionInfo), }); @@ -1052,9 +1007,9 @@ export const zListSessionsResponse = z.object({ * This allows clients to display dynamic session names and track session state changes. */ export const zSessionInfoUpdate = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), - title: z.union([z.string(), z.null()]).optional(), - updatedAt: z.union([z.string(), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), + title: z.string().nullish(), + updatedAt: z.string().nullish(), }); /** @@ -1063,7 +1018,7 @@ export const zSessionInfoUpdate = z.object({ * By supplying `{}` it means that the agent supports listing of sessions. */ export const zSessionListCapabilities = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), }); /** @@ -1077,7 +1032,7 @@ export const zSessionModeId = z.string(); * See protocol docs: [Session Modes](https://agentclientprotocol.com/protocol/session-modes) */ export const zCurrentModeUpdate = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), currentModeId: zSessionModeId, }); @@ -1087,8 +1042,8 @@ export const zCurrentModeUpdate = z.object({ * See protocol docs: [Session Modes](https://agentclientprotocol.com/protocol/session-modes) */ export const zSessionMode = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), - description: z.union([z.string(), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), + description: z.string().nullish(), id: zSessionModeId, name: z.string(), }); @@ -1097,7 +1052,7 @@ export const zSessionMode = z.object({ * The set of modes and the one currently active. */ export const zSessionModeState = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), availableModes: z.array(zSessionMode), currentModeId: zSessionModeId, }); @@ -1112,7 +1067,7 @@ export const zSessionModeState = z.object({ * @experimental */ export const zSessionModelState = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), availableModels: z.array(zModelInfo), currentModelId: zModelId, }); @@ -1127,10 +1082,10 @@ export const zSessionModelState = z.object({ * @experimental */ export const zForkSessionResponse = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), - configOptions: z.union([z.array(zSessionConfigOption), z.null()]).optional(), - models: z.union([zSessionModelState, z.null()]).optional(), - modes: z.union([zSessionModeState, z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), + configOptions: z.array(zSessionConfigOption).nullish(), + models: zSessionModelState.nullish(), + modes: zSessionModeState.nullish(), sessionId: zSessionId, }); @@ -1138,10 +1093,10 @@ export const zForkSessionResponse = z.object({ * Response from loading an existing session. */ export const zLoadSessionResponse = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), - configOptions: z.union([z.array(zSessionConfigOption), z.null()]).optional(), - models: z.union([zSessionModelState, z.null()]).optional(), - modes: z.union([zSessionModeState, z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), + configOptions: z.array(zSessionConfigOption).nullish(), + models: zSessionModelState.nullish(), + modes: zSessionModeState.nullish(), }); /** @@ -1150,10 +1105,10 @@ export const zLoadSessionResponse = z.object({ * See protocol docs: [Creating a Session](https://agentclientprotocol.com/protocol/session-setup#creating-a-session) */ export const zNewSessionResponse = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), - configOptions: z.union([z.array(zSessionConfigOption), z.null()]).optional(), - models: z.union([zSessionModelState, z.null()]).optional(), - modes: z.union([zSessionModeState, z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), + configOptions: z.array(zSessionConfigOption).nullish(), + models: zSessionModelState.nullish(), + modes: zSessionModeState.nullish(), sessionId: zSessionId, }); @@ -1167,10 +1122,10 @@ export const zNewSessionResponse = z.object({ * @experimental */ export const zResumeSessionResponse = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), - configOptions: z.union([z.array(zSessionConfigOption), z.null()]).optional(), - models: z.union([zSessionModelState, z.null()]).optional(), - modes: z.union([zSessionModeState, z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), + configOptions: z.array(zSessionConfigOption).nullish(), + models: zSessionModelState.nullish(), + modes: zSessionModeState.nullish(), }); /** @@ -1185,7 +1140,7 @@ export const zResumeSessionResponse = z.object({ * @experimental */ export const zSessionResumeCapabilities = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), }); /** @@ -1200,11 +1155,11 @@ export const zSessionResumeCapabilities = z.object({ * See protocol docs: [Session Capabilities](https://agentclientprotocol.com/protocol/initialization#session-capabilities) */ export const zSessionCapabilities = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), - fork: z.union([zSessionForkCapabilities, z.null()]).optional(), - list: z.union([zSessionListCapabilities, z.null()]).optional(), - resume: z.union([zSessionResumeCapabilities, z.null()]).optional(), - stop: z.union([zSessionCloseCapabilities, z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), + fork: zSessionForkCapabilities.nullish(), + list: zSessionListCapabilities.nullish(), + resume: zSessionResumeCapabilities.nullish(), + stop: zSessionCloseCapabilities.nullish(), }); /** @@ -1216,7 +1171,7 @@ export const zSessionCapabilities = z.object({ * See protocol docs: [Agent Capabilities](https://agentclientprotocol.com/protocol/initialization#agent-capabilities) */ export const zAgentCapabilities = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), loadSession: z.boolean().optional().default(false), mcpCapabilities: zMcpCapabilities .optional() @@ -1237,7 +1192,7 @@ export const zAgentCapabilities = z.object({ * See protocol docs: [Initialization](https://agentclientprotocol.com/protocol/initialization) */ export const zInitializeResponse = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), agentCapabilities: zAgentCapabilities.optional().default({ loadSession: false, mcpCapabilities: { http: false, sse: false }, @@ -1248,7 +1203,7 @@ export const zInitializeResponse = z.object({ }, sessionCapabilities: {}, }), - agentInfo: z.union([zImplementation, z.null()]).optional(), + agentInfo: zImplementation.nullish(), authMethods: z.array(zAuthMethod).optional().default([]), protocolVersion: zProtocolVersion, }); @@ -1264,7 +1219,7 @@ export const zSetSessionConfigOptionRequest = z.intersection( }), ]), z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), configId: zSessionConfigId, sessionId: zSessionId, }), @@ -1274,7 +1229,7 @@ export const zSetSessionConfigOptionRequest = z.intersection( * Response to `session/set_config_option` method. */ export const zSetSessionConfigOptionResponse = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), configOptions: z.array(zSessionConfigOption), }); @@ -1282,7 +1237,7 @@ export const zSetSessionConfigOptionResponse = z.object({ * Request parameters for setting a session mode. */ export const zSetSessionModeRequest = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), modeId: zSessionModeId, sessionId: zSessionId, }); @@ -1291,7 +1246,7 @@ export const zSetSessionModeRequest = z.object({ * Response to `session/set_mode` method. */ export const zSetSessionModeResponse = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), }); /** @@ -1304,7 +1259,7 @@ export const zSetSessionModeResponse = z.object({ * @experimental */ export const zSetSessionModelRequest = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), modelId: zModelId, sessionId: zSessionId, }); @@ -1319,7 +1274,7 @@ export const zSetSessionModelRequest = z.object({ * @experimental */ export const zSetSessionModelResponse = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), }); /** @@ -1343,7 +1298,7 @@ export const zStopReason = z.union([ * See protocol docs: [Terminal](https://agentclientprotocol.com/protocol/terminals) */ export const zTerminal = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), terminalId: z.string(), }); @@ -1351,27 +1306,23 @@ export const zTerminal = z.object({ * Exit status of a terminal command. */ export const zTerminalExitStatus = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), exitCode: z - .union([ - z - .number() - .int() - .gte(0) - .max(4294967295, { - message: "Invalid value: Expected uint32 to be <= 4294967295", - }), - z.null(), - ]) - .optional(), - signal: z.union([z.string(), z.null()]).optional(), + .number() + .int() + .gte(0) + .max(4294967295, { + message: "Invalid value: Expected uint32 to be <= 4294967295", + }) + .nullish(), + signal: z.string().nullish(), }); /** * Request to get the current output and status of a terminal. */ export const zTerminalOutputRequest = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), sessionId: zSessionId, terminalId: z.string(), }); @@ -1380,8 +1331,8 @@ export const zTerminalOutputRequest = z.object({ * Response containing the terminal output and exit status. */ export const zTerminalOutputResponse = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), - exitStatus: z.union([zTerminalExitStatus, z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), + exitStatus: zTerminalExitStatus.nullish(), output: z.string(), truncated: z.boolean(), }); @@ -1390,8 +1341,8 @@ export const zTerminalOutputResponse = z.object({ * Text provided to or from an LLM. */ export const zTextContent = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), - annotations: z.union([zAnnotations, z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), + annotations: zAnnotations.nullish(), text: z.string(), }); @@ -1399,8 +1350,8 @@ export const zTextContent = z.object({ * Text-based resource contents. */ export const zTextResourceContents = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), - mimeType: z.union([z.string(), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), + mimeType: z.string().nullish(), text: z.string(), uri: z.string(), }); @@ -1417,8 +1368,8 @@ export const zEmbeddedResourceResource = z.union([ * The contents of a resource, embedded into a prompt or tool call result. */ export const zEmbeddedResource = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), - annotations: z.union([zAnnotations, z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), + annotations: zAnnotations.nullish(), resource: zEmbeddedResourceResource, }); @@ -1470,7 +1421,7 @@ export const zContentBlock = z.union([ * Standard content block (text, images, resources). */ export const zContent = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), content: zContentBlock, }); @@ -1478,9 +1429,9 @@ export const zContent = z.object({ * A streamed item of content */ export const zContentChunk = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), content: zContentBlock, - messageId: z.union([z.string(), z.null()]).optional(), + messageId: z.string().nullish(), }); /** @@ -1491,8 +1442,8 @@ export const zContentChunk = z.object({ * See protocol docs: [User Message](https://agentclientprotocol.com/protocol/prompt-turn#1-user-message) */ export const zPromptRequest = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), - messageId: z.union([z.string(), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), + messageId: z.string().nullish(), prompt: z.array(zContentBlock), sessionId: zSessionId, }); @@ -1502,24 +1453,21 @@ export const zClientRequest = z.object({ method: z.string(), params: z .union([ - z.union([ - zInitializeRequest, - zAuthenticateRequest, - zNewSessionRequest, - zLoadSessionRequest, - zListSessionsRequest, - zForkSessionRequest, - zResumeSessionRequest, - zCloseSessionRequest, - zSetSessionModeRequest, - zSetSessionConfigOptionRequest, - zPromptRequest, - zSetSessionModelRequest, - zExtRequest, - ]), - z.null(), + zInitializeRequest, + zAuthenticateRequest, + zNewSessionRequest, + zLoadSessionRequest, + zListSessionsRequest, + zForkSessionRequest, + zResumeSessionRequest, + zCloseSessionRequest, + zSetSessionModeRequest, + zSetSessionConfigOptionRequest, + zPromptRequest, + zSetSessionModelRequest, + zExtRequest, ]) - .optional(), + .nullish(), }); /** @@ -1562,19 +1510,15 @@ export const zToolCallId = z.string(); * See protocol docs: [Following the Agent](https://agentclientprotocol.com/protocol/tool-calls#following-the-agent) */ export const zToolCallLocation = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), line: z - .union([ - z - .number() - .int() - .gte(0) - .max(4294967295, { - message: "Invalid value: Expected uint32 to be <= 4294967295", - }), - z.null(), - ]) - .optional(), + .number() + .int() + .gte(0) + .max(4294967295, { + message: "Invalid value: Expected uint32 to be <= 4294967295", + }) + .nullish(), path: z.string(), }); @@ -1622,7 +1566,7 @@ export const zToolKind = z.union([ * See protocol docs: [Tool Calls](https://agentclientprotocol.com/protocol/tool-calls) */ export const zToolCall = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), content: z.array(zToolCallContent).optional(), kind: zToolKind.optional(), locations: z.array(zToolCallLocation).optional(), @@ -1642,14 +1586,14 @@ export const zToolCall = z.object({ * See protocol docs: [Updating](https://agentclientprotocol.com/protocol/tool-calls#updating) */ export const zToolCallUpdate = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), - content: z.union([z.array(zToolCallContent), z.null()]).optional(), - kind: z.union([zToolKind, z.null()]).optional(), - locations: z.union([z.array(zToolCallLocation), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), + content: z.array(zToolCallContent).nullish(), + kind: zToolKind.nullish(), + locations: z.array(zToolCallLocation).nullish(), rawInput: z.unknown().optional(), rawOutput: z.unknown().optional(), - status: z.union([zToolCallStatus, z.null()]).optional(), - title: z.union([z.string(), z.null()]).optional(), + status: zToolCallStatus.nullish(), + title: z.string().nullish(), toolCallId: zToolCallId, }); @@ -1661,7 +1605,7 @@ export const zToolCallUpdate = z.object({ * See protocol docs: [Requesting Permission](https://agentclientprotocol.com/protocol/tool-calls#requesting-permission) */ export const zRequestPermissionRequest = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), options: z.array(zPermissionOption), sessionId: zSessionId, toolCall: zToolCallUpdate, @@ -1671,7 +1615,7 @@ export const zRequestPermissionRequest = z.object({ * All text that was typed after the command name is provided as input. */ export const zUnstructuredCommandInput = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), hint: z.string(), }); @@ -1686,9 +1630,9 @@ export const zAvailableCommandInput = zUnstructuredCommandInput; * Information about a command. */ export const zAvailableCommand = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), description: z.string(), - input: z.union([zAvailableCommandInput, z.null()]).optional(), + input: zAvailableCommandInput.nullish(), name: z.string(), }); @@ -1696,7 +1640,7 @@ export const zAvailableCommand = z.object({ * Available commands are ready or have changed */ export const zAvailableCommandsUpdate = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), availableCommands: z.array(zAvailableCommand), }); @@ -1710,60 +1654,12 @@ export const zAvailableCommandsUpdate = z.object({ * @experimental */ export const zUsage = z.object({ - cachedReadTokens: z - .union([ - z.coerce - .bigint() - .gte(BigInt(0)) - .max(BigInt("18446744073709551615"), { - message: - "Invalid value: Expected uint64 to be <= 18446744073709551615", - }), - z.null(), - ]) - .optional(), - cachedWriteTokens: z - .union([ - z.coerce - .bigint() - .gte(BigInt(0)) - .max(BigInt("18446744073709551615"), { - message: - "Invalid value: Expected uint64 to be <= 18446744073709551615", - }), - z.null(), - ]) - .optional(), - inputTokens: z.coerce - .bigint() - .gte(BigInt(0)) - .max(BigInt("18446744073709551615"), { - message: "Invalid value: Expected uint64 to be <= 18446744073709551615", - }), - outputTokens: z.coerce - .bigint() - .gte(BigInt(0)) - .max(BigInt("18446744073709551615"), { - message: "Invalid value: Expected uint64 to be <= 18446744073709551615", - }), - thoughtTokens: z - .union([ - z.coerce - .bigint() - .gte(BigInt(0)) - .max(BigInt("18446744073709551615"), { - message: - "Invalid value: Expected uint64 to be <= 18446744073709551615", - }), - z.null(), - ]) - .optional(), - totalTokens: z.coerce - .bigint() - .gte(BigInt(0)) - .max(BigInt("18446744073709551615"), { - message: "Invalid value: Expected uint64 to be <= 18446744073709551615", - }), + cachedReadTokens: z.number().nullish(), + cachedWriteTokens: z.number().nullish(), + inputTokens: z.number(), + outputTokens: z.number(), + thoughtTokens: z.number().nullish(), + totalTokens: z.number(), }); /** @@ -1772,10 +1668,10 @@ export const zUsage = z.object({ * See protocol docs: [Check for Completion](https://agentclientprotocol.com/protocol/prompt-turn#4-check-for-completion) */ export const zPromptResponse = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), stopReason: zStopReason, - usage: z.union([zUsage, z.null()]).optional(), - userMessageId: z.union([z.string(), z.null()]).optional(), + usage: zUsage.nullish(), + userMessageId: z.string().nullish(), }); export const zAgentResponse = z.union([ @@ -1813,20 +1709,10 @@ export const zAgentResponse = z.union([ * @experimental */ export const zUsageUpdate = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), - cost: z.union([zCost, z.null()]).optional(), - size: z.coerce - .bigint() - .gte(BigInt(0)) - .max(BigInt("18446744073709551615"), { - message: "Invalid value: Expected uint64 to be <= 18446744073709551615", - }), - used: z.coerce - .bigint() - .gte(BigInt(0)) - .max(BigInt("18446744073709551615"), { - message: "Invalid value: Expected uint64 to be <= 18446744073709551615", - }), + _meta: z.record(z.string(), z.unknown()).nullish(), + cost: zCost.nullish(), + size: z.number(), + used: z.number(), }); /** @@ -1902,23 +1788,21 @@ export const zSessionUpdate = z.union([ * See protocol docs: [Agent Reports Output](https://agentclientprotocol.com/protocol/prompt-turn#3-agent-reports-output) */ export const zSessionNotification = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), sessionId: zSessionId, update: zSessionUpdate, }); export const zAgentNotification = z.object({ method: z.string(), - params: z - .union([z.union([zSessionNotification, zExtNotification]), z.null()]) - .optional(), + params: z.union([zSessionNotification, zExtNotification]).nullish(), }); /** * Request to wait for a terminal command to exit. */ export const zWaitForTerminalExitRequest = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), sessionId: zSessionId, terminalId: z.string(), }); @@ -1927,20 +1811,16 @@ export const zWaitForTerminalExitRequest = z.object({ * Response containing the exit status of a terminal command. */ export const zWaitForTerminalExitResponse = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), exitCode: z - .union([ - z - .number() - .int() - .gte(0) - .max(4294967295, { - message: "Invalid value: Expected uint32 to be <= 4294967295", - }), - z.null(), - ]) - .optional(), - signal: z.union([z.string(), z.null()]).optional(), + .number() + .int() + .gte(0) + .max(4294967295, { + message: "Invalid value: Expected uint32 to be <= 4294967295", + }) + .nullish(), + signal: z.string().nullish(), }); /** @@ -1949,7 +1829,7 @@ export const zWaitForTerminalExitResponse = z.object({ * Only available if the client supports the `fs.writeTextFile` capability. */ export const zWriteTextFileRequest = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), content: z.string(), path: z.string(), sessionId: zSessionId, @@ -1960,27 +1840,24 @@ export const zAgentRequest = z.object({ method: z.string(), params: z .union([ - z.union([ - zWriteTextFileRequest, - zReadTextFileRequest, - zRequestPermissionRequest, - zCreateTerminalRequest, - zTerminalOutputRequest, - zReleaseTerminalRequest, - zWaitForTerminalExitRequest, - zKillTerminalRequest, - zExtRequest, - ]), - z.null(), + zWriteTextFileRequest, + zReadTextFileRequest, + zRequestPermissionRequest, + zCreateTerminalRequest, + zTerminalOutputRequest, + zReleaseTerminalRequest, + zWaitForTerminalExitRequest, + zKillTerminalRequest, + zExtRequest, ]) - .optional(), + .nullish(), }); /** * Response to `fs/write_text_file` */ export const zWriteTextFileResponse = z.object({ - _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), + _meta: z.record(z.string(), z.unknown()).nullish(), }); export const zClientResponse = z.union([