diff --git a/Cargo.toml b/Cargo.toml index b64ca683..91c02281 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,6 +22,7 @@ unstable = [ "unstable_session_model", "unstable_session_resume", "unstable_session_usage", + "unstable_boolean_config", ] unstable_cancel_request = [] unstable_session_fork = [] @@ -30,6 +31,7 @@ unstable_session_list = [] unstable_session_model = [] unstable_session_resume = [] unstable_session_usage = [] +unstable_boolean_config = [] [[bin]] name = "generate" diff --git a/docs/protocol/draft/schema.mdx b/docs/protocol/draft/schema.mdx index d1d6fc58..0ed5d7d1 100644 --- a/docs/protocol/draft/schema.mdx +++ b/docs/protocol/draft/schema.mdx @@ -720,8 +720,9 @@ See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/exte SessionId} required> The ID of the session to set the configuration option for. -SessionConfigValueId} required> - The ID of the configuration option value to set. +SessionConfigOptionValue} required> + The value to set. For `select` options, this is a `SessionConfigValueId` string. +For `boolean` options, this is a boolean. #### SetSessionConfigOptionResponse @@ -2969,6 +2970,22 @@ Whether the agent supports `session/resume`. +## SessionConfigBoolean + +**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. + +**Type:** Object + +**Properties:** + + + The current value of the boolean option. + + ## SessionConfigGroupId Unique identifier for a session configuration option value group. @@ -3011,6 +3028,23 @@ Single-value selector (dropdown). + +**UNSTABLE** + +This capability is not part of the spec yet, and may be removed or changed at any point. + +Boolean on/off toggle. + + + + + The current value of the boolean option. + + + + + + ## SessionConfigOptionCategory Semantic category for a session configuration option. @@ -3041,6 +3075,23 @@ Category names that do not begin with `_` are reserved for the ACP spec. Unknown / uncategorized selector. +## SessionConfigOptionValue + +The value to set for a session configuration option. + +For `select` options, the value is a `SessionConfigValueId` string. +For `boolean` options, the value is a boolean. + +**Type:** Union + + + A string value (used by `select` options). + + + + A boolean value (used by `boolean` options). + + ## SessionConfigSelect A single-value selector (dropdown) session configuration option payload. diff --git a/docs/protocol/schema.mdx b/docs/protocol/schema.mdx index 2f7230ce..63ed8136 100644 --- a/docs/protocol/schema.mdx +++ b/docs/protocol/schema.mdx @@ -448,8 +448,9 @@ See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/exte SessionId} required> The ID of the session to set the configuration option for. -SessionConfigValueId} required> - The ID of the configuration option value to set. +SessionConfigOptionValue} required> + The value to set. For `select` options, this is a `SessionConfigValueId` string. +For `boolean` options, this is a boolean. #### SetSessionConfigOptionResponse @@ -2559,6 +2560,23 @@ Category names that do not begin with `_` are reserved for the ACP spec. Unknown / uncategorized selector. +## SessionConfigOptionValue + +The value to set for a session configuration option. + +For `select` options, the value is a `SessionConfigValueId` string. +For `boolean` options, the value is a boolean. + +**Type:** Union + + + A string value (used by `select` options). + + + + A boolean value (used by `boolean` options). + + ## SessionConfigSelect A single-value selector (dropdown) session configuration option payload. diff --git a/docs/protocol/session-config-options.mdx b/docs/protocol/session-config-options.mdx index 2569b4d5..5dfed672 100644 --- a/docs/protocol/session-config-options.mdx +++ b/docs/protocol/session-config-options.mdx @@ -61,6 +61,13 @@ During [Session Setup](./session-setup) the Agent **MAY** return a list of confi "description": "The most powerful model" } ] + }, + { + "id": "brave_mode", + "name": "Brave Mode", + "description": "Skip confirmation prompts and act autonomously", + "type": "boolean", + "currentValue": false } ] } @@ -93,9 +100,13 @@ During [Session Setup](./session-setup) the Agent **MAY** return a list of confi - The type of input control. Currently only `select` is supported. + The type of input control. Supported types are `select` and `boolean`. +### Select Options + +When `type` is `select`, the following fields are used: + The currently selected value for this option @@ -104,6 +115,16 @@ During [Session Setup](./session-setup) the Agent **MAY** return a list of confi The available values for this option +### Boolean Options + +When `type` is `boolean`, the following fields are used: + + + The current boolean state of the option (`true` for on, `false` for off) + + +Boolean options are intended for simple on/off toggles such as "Brave Mode", "Produce Report", or "Read Only". Clients **SHOULD** render them as toggle switches or checkboxes. + ### ConfigOptionValue @@ -186,9 +207,10 @@ Clients can change a config option value by calling the `session/set_config_opti The `id` of the configuration option to change - - The new value to set. Must be one of the values listed in the option's - `options` array. + + The new value to set. For `select` options, this must be one of the values + listed in the option's `options` array. For `boolean` options, this must be a + boolean (`true` or `false`). The Agent **MUST** respond with the complete list of all configuration options and their current values: diff --git a/schema/schema.json b/schema/schema.json index ae008f8c..e9cc9679 100644 --- a/schema/schema.json +++ b/schema/schema.json @@ -2333,6 +2333,25 @@ ], "description": "Semantic category for a session configuration option.\n\nThis is intended to help Clients distinguish broadly common selectors (e.g. model selector vs\nsession mode selector vs thought/reasoning level) for UX purposes (keyboard shortcuts, icons,\nplacement). It MUST NOT be required for correctness. Clients MUST handle missing or unknown\ncategories gracefully.\n\nCategory names beginning with `_` are free for custom use, like other ACP extension methods.\nCategory names that do not begin with `_` are reserved for the ACP spec." }, + "SessionConfigOptionValue": { + "anyOf": [ + { + "allOf": [ + { + "$ref": "#/$defs/SessionConfigValueId" + } + ], + "description": "A string value (used by `select` options).", + "title": "String" + }, + { + "description": "A boolean value (used by `boolean` options).", + "title": "Bool", + "type": "boolean" + } + ], + "description": "The value to set for a session configuration option.\n\nFor `select` options, the value is a `SessionConfigValueId` string.\nFor `boolean` options, the value is a boolean." + }, "SessionConfigSelect": { "description": "A single-value selector (dropdown) session configuration option payload.", "properties": { @@ -2705,10 +2724,10 @@ "value": { "allOf": [ { - "$ref": "#/$defs/SessionConfigValueId" + "$ref": "#/$defs/SessionConfigOptionValue" } ], - "description": "The ID of the configuration option value to set." + "description": "The value to set. For `select` options, this is a `SessionConfigValueId` string.\nFor `boolean` options, this is a boolean." } }, "required": ["sessionId", "configId", "value"], diff --git a/schema/schema.unstable.json b/schema/schema.unstable.json index f6bed4ae..ff324648 100644 --- a/schema/schema.unstable.json +++ b/schema/schema.unstable.json @@ -2656,6 +2656,17 @@ }, "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": { "description": "Unique identifier for a session configuration option value group.", "type": "string" @@ -2685,6 +2696,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": { @@ -2749,6 +2776,25 @@ ], "description": "Semantic category for a session configuration option.\n\nThis is intended to help Clients distinguish broadly common selectors (e.g. model selector vs\nsession mode selector vs thought/reasoning level) for UX purposes (keyboard shortcuts, icons,\nplacement). It MUST NOT be required for correctness. Clients MUST handle missing or unknown\ncategories gracefully.\n\nCategory names beginning with `_` are free for custom use, like other ACP extension methods.\nCategory names that do not begin with `_` are reserved for the ACP spec." }, + "SessionConfigOptionValue": { + "anyOf": [ + { + "allOf": [ + { + "$ref": "#/$defs/SessionConfigValueId" + } + ], + "description": "A string value (used by `select` options).", + "title": "String" + }, + { + "description": "A boolean value (used by `boolean` options).", + "title": "Bool", + "type": "boolean" + } + ], + "description": "The value to set for a session configuration option.\n\nFor `select` options, the value is a `SessionConfigValueId` string.\nFor `boolean` options, the value is a boolean." + }, "SessionConfigSelect": { "description": "A single-value selector (dropdown) session configuration option payload.", "properties": { @@ -3264,10 +3310,10 @@ "value": { "allOf": [ { - "$ref": "#/$defs/SessionConfigValueId" + "$ref": "#/$defs/SessionConfigOptionValue" } ], - "description": "The ID of the configuration option value to set." + "description": "The value to set. For `select` options, this is a `SessionConfigValueId` string.\nFor `boolean` options, this is a boolean." } }, "required": ["sessionId", "configId", "value"], diff --git a/src/agent.rs b/src/agent.rs index 1c5d671b..5d454d50 100644 --- a/src/agent.rs +++ b/src/agent.rs @@ -1472,6 +1472,28 @@ impl SessionConfigSelect { } } +/// **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. +#[cfg(feature = "unstable_boolean_config")] +#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, PartialEq, Eq)] +#[serde(rename_all = "camelCase")] +#[non_exhaustive] +pub struct SessionConfigBoolean { + /// The current value of the boolean option. + pub current_value: bool, +} + +#[cfg(feature = "unstable_boolean_config")] +impl SessionConfigBoolean { + #[must_use] + pub fn new(current_value: bool) -> Self { + Self { current_value } + } +} + /// Semantic category for a session configuration option. /// /// This is intended to help Clients distinguish broadly common selectors (e.g. model selector vs @@ -1504,6 +1526,13 @@ pub enum SessionConfigOptionCategory { pub enum SessionConfigKind { /// Single-value selector (dropdown). Select(SessionConfigSelect), + /// **UNSTABLE** + /// + /// This capability is not part of the spec yet, and may be removed or changed at any point. + /// + /// Boolean on/off toggle. + #[cfg(feature = "unstable_boolean_config")] + Boolean(SessionConfigBoolean), } /// A session configuration option selector and its current state. @@ -1564,6 +1593,23 @@ impl SessionConfigOption { ) } + /// **UNSTABLE** + /// + /// This capability is not part of the spec yet, and may be removed or changed at any point. + #[cfg(feature = "unstable_boolean_config")] + #[must_use] + pub fn boolean( + id: impl Into, + name: impl Into, + current_value: bool, + ) -> Self { + Self::new( + id, + name, + SessionConfigKind::Boolean(SessionConfigBoolean::new(current_value)), + ) + } + #[must_use] pub fn description(mut self, description: impl IntoOption) -> Self { self.description = description.into_option(); @@ -1588,6 +1634,38 @@ impl SessionConfigOption { } } +/// The value to set for a session configuration option. +/// +/// For `select` options, the value is a `SessionConfigValueId` string. +/// For `boolean` options, the value is a boolean. +#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, PartialEq, Eq)] +#[serde(untagged)] +#[non_exhaustive] +pub enum SessionConfigOptionValue { + /// A string value (used by `select` options). + String(SessionConfigValueId), + /// A boolean value (used by `boolean` options). + Bool(bool), +} + +impl From for SessionConfigOptionValue { + fn from(value: SessionConfigValueId) -> Self { + SessionConfigOptionValue::String(value) + } +} + +impl From for SessionConfigOptionValue { + fn from(value: bool) -> Self { + SessionConfigOptionValue::Bool(value) + } +} + +impl From<&str> for SessionConfigOptionValue { + fn from(value: &str) -> Self { + SessionConfigOptionValue::String(SessionConfigValueId::new(value)) + } +} + /// Request parameters for setting a session configuration option. #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, PartialEq, Eq)] #[schemars(extend("x-side" = "agent", "x-method" = SESSION_SET_CONFIG_OPTION_METHOD_NAME))] @@ -1598,8 +1676,9 @@ pub struct SetSessionConfigOptionRequest { pub session_id: SessionId, /// The ID of the configuration option to set. pub config_id: SessionConfigId, - /// The ID of the configuration option value to set. - pub value: SessionConfigValueId, + /// The value to set. For `select` options, this is a `SessionConfigValueId` string. + /// For `boolean` options, this is a boolean. + pub value: SessionConfigOptionValue, /// 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. @@ -1614,7 +1693,7 @@ impl SetSessionConfigOptionRequest { pub fn new( session_id: impl Into, config_id: impl Into, - value: impl Into, + value: impl Into, ) -> Self { Self { session_id: session_id.into(),