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 b93cd7c..44cdccc 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_close: { + if (!agent.unstable_closeSession) { + throw RequestError.methodNotFound(method); + } + const validatedParams = validate.zCloseSessionRequest.parse(params); + return agent.unstable_closeSession(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. + * + * Closes an active session and frees up any resources associated with it. + * + * 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_closeSession( + params: schema.CloseSessionRequest, + ): Promise { + return await this.#connection.sendRequest( + schema.AGENT_METHODS.session_close, + 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. + * + * Closes an active session and frees up any resources associated with it. + * + * 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_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..91e3143 100644 --- a/src/schema/index.ts +++ b/src/schema/index.ts @@ -25,6 +25,8 @@ export type { ClientNotification, ClientRequest, ClientResponse, + CloseSessionRequest, + CloseSessionResponse, ConfigOptionUpdate, Content, ContentBlock, @@ -90,6 +92,8 @@ export type { Role, SelectedPermissionOutcome, SessionCapabilities, + SessionCloseCapabilities, + SessionConfigBoolean, SessionConfigGroupId, SessionConfigId, SessionConfigOption, @@ -110,7 +114,6 @@ export type { SessionModeState, SessionNotification, SessionResumeCapabilities, - SessionStopCapabilities, SessionUpdate, SetSessionConfigOptionRequest, SetSessionConfigOptionResponse, @@ -119,8 +122,6 @@ export type { SetSessionModeRequest, SetSessionModeResponse, StopReason, - StopSessionRequest, - StopSessionResponse, Terminal, TerminalExitStatus, TerminalOutputRequest, @@ -147,6 +148,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 +158,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..54d4b01 100644 --- a/src/schema/zod.gen.ts +++ b/src/schema/zod.gen.ts @@ -136,6 +136,19 @@ export const zBlobResourceContents = z.object({ 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.record(z.string(), z.unknown()).nullish(), +}); + /** * **UNSTABLE** * @@ -305,15 +318,9 @@ export const zKillTerminalResponse = z.object({ }); /** - * **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(), @@ -672,6 +679,34 @@ export const zRequestPermissionResponse = z.object({ 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.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. + * + * 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. */ @@ -741,21 +776,27 @@ 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.record(z.string(), z.unknown()).nullish(), + category: zSessionConfigOptionCategory.nullish(), + description: z.string().nullish(), + id: zSessionConfigId, + name: z.string(), + }), +); /** * Session configuration options have been updated. @@ -805,6 +846,26 @@ export const zClientNotification = z.object({ params: z.union([zCancelNotification, zExtNotification]).nullish(), }); +/** + * **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.record(z.string(), z.unknown()).nullish(), + sessionId: zSessionId, +}); + /** * Request to create a new terminal and execute a command. */ @@ -920,13 +981,7 @@ export const zResumeSessionRequest = z.object({ }); /** - * **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(), @@ -937,13 +992,7 @@ export const zSessionInfo = z.object({ }); /** - * **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(), @@ -967,8 +1016,6 @@ export const zSessionInfoUpdate = z.object({ * 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(), @@ -1096,21 +1143,6 @@ 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(), -}); - /** * Session capabilities supported by the agent. * @@ -1127,7 +1159,7 @@ export const zSessionCapabilities = z.object({ fork: zSessionForkCapabilities.nullish(), list: zSessionListCapabilities.nullish(), resume: zSessionResumeCapabilities.nullish(), - stop: zSessionStopCapabilities.nullish(), + stop: zSessionCloseCapabilities.nullish(), }); /** @@ -1176,15 +1208,22 @@ export const zInitializeResponse = z.object({ 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.record(z.string(), z.unknown()).nullish(), + configId: zSessionConfigId, + sessionId: zSessionId, + }), +); /** * Response to `session/set_config_option` method. @@ -1251,39 +1290,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. * @@ -1454,7 +1460,7 @@ export const zClientRequest = z.object({ zListSessionsRequest, zForkSessionRequest, zResumeSessionRequest, - zStopSessionRequest, + zCloseSessionRequest, zSetSessionModeRequest, zSetSessionConfigOptionRequest, zPromptRequest, @@ -1679,7 +1685,7 @@ export const zAgentResponse = z.union([ zListSessionsResponse, zForkSessionResponse, zResumeSessionResponse, - zStopSessionResponse, + zCloseSessionResponse, zSetSessionModeResponse, zSetSessionConfigOptionResponse, zPromptResponse,