From 2712c066bcec5818010d5f62d3ecb0e1160aefb7 Mon Sep 17 00:00:00 2001 From: Lifei Zhou Date: Mon, 22 Jun 2026 10:41:08 +1000 Subject: [PATCH] feat (acp): used typed request and response for add, get session extensions (#9890) --- crates/goose-sdk-types/src/custom_requests.rs | 10 +- crates/goose/acp-meta.json | 4 +- crates/goose/acp-schema.json | 694 +++++++++--------- crates/goose/src/acp/server.rs | 37 - .../goose/src/acp/server/custom_dispatch.rs | 16 +- crates/goose/src/acp/server/extensions.rs | 39 +- .../goose/tests/acp_custom_requests_test.rs | 84 +++ ui/sdk/src/generated/client.gen.ts | 8 +- ui/sdk/src/generated/index.ts | 6 +- ui/sdk/src/generated/types.gen.ts | 351 +++++---- ui/sdk/src/generated/zod.gen.ts | 292 ++++---- 11 files changed, 798 insertions(+), 743 deletions(-) diff --git a/crates/goose-sdk-types/src/custom_requests.rs b/crates/goose-sdk-types/src/custom_requests.rs index d5dc8729b..f8e511f49 100644 --- a/crates/goose-sdk-types/src/custom_requests.rs +++ b/crates/goose-sdk-types/src/custom_requests.rs @@ -26,18 +26,16 @@ pub struct CustomMethodSchema { #[derive(Debug, Default, Clone, Serialize, Deserialize, JsonSchema, JsonRpcRequest)] #[request(method = "_goose/unstable/session/extensions/add", response = EmptyResponse)] #[serde(rename_all = "camelCase")] -pub struct AddExtensionRequest { +pub struct AddSessionExtensionRequest { pub session_id: String, - /// Extension configuration (see ExtensionConfig variants: Stdio, StreamableHttp, Builtin, Platform). - #[serde(default)] - pub config: serde_json::Value, + pub extension: GooseExtension, } /// Remove an extension from an active session. #[derive(Debug, Default, Clone, Serialize, Deserialize, JsonSchema, JsonRpcRequest)] #[request(method = "_goose/unstable/session/extensions/remove", response = EmptyResponse)] #[serde(rename_all = "camelCase")] -pub struct RemoveExtensionRequest { +pub struct RemoveSessionExtensionRequest { pub session_id: String, pub name: String, } @@ -303,7 +301,7 @@ pub struct GetSessionExtensionsRequest { #[derive(Debug, Default, Clone, Serialize, Deserialize, JsonSchema, JsonRpcResponse)] pub struct GetSessionExtensionsResponse { - pub extensions: Vec, + pub extensions: Vec, } /// Read allowlisted user preferences. Empty `keys` means all supported preferences. diff --git a/crates/goose/acp-meta.json b/crates/goose/acp-meta.json index 2c4ed6ecd..7df1167c6 100644 --- a/crates/goose/acp-meta.json +++ b/crates/goose/acp-meta.json @@ -2,12 +2,12 @@ "methods": [ { "method": "_goose/unstable/session/extensions/add", - "requestType": "AddExtensionRequest_unstable", + "requestType": "AddSessionExtensionRequest_unstable", "responseType": "EmptyResponse" }, { "method": "_goose/unstable/session/extensions/remove", - "requestType": "RemoveExtensionRequest_unstable", + "requestType": "RemoveSessionExtensionRequest_unstable", "responseType": "EmptyResponse" }, { diff --git a/crates/goose/acp-schema.json b/crates/goose/acp-schema.json index 4fa7028d9..766331fdc 100644 --- a/crates/goose/acp-schema.json +++ b/crates/goose/acp-schema.json @@ -2,30 +2,365 @@ "$schema": "https://json-schema.org/draft/2020-12/schema", "title": "GooseExtensions", "$defs": { - "AddExtensionRequest_unstable": { + "AddSessionExtensionRequest_unstable": { "type": "object", "properties": { "sessionId": { "type": "string" }, - "config": { - "description": "Extension configuration (see ExtensionConfig variants: Stdio, StreamableHttp, Builtin, Platform).", - "default": null + "extension": { + "$ref": "#/$defs/GooseExtension" } }, "required": [ - "sessionId" + "sessionId", + "extension" ], "description": "Add an extension to an active session.", "x-side": "agent", "x-method": "_goose/unstable/session/extensions/add" }, + "GooseExtension": { + "oneOf": [ + { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "description": { + "type": [ + "string", + "null" + ] + }, + "display_name": { + "type": [ + "string", + "null" + ] + }, + "timeout": { + "type": [ + "integer", + "null" + ], + "minimum": 0 + }, + "bundled": { + "type": [ + "boolean", + "null" + ] + }, + "type": { + "type": "string", + "const": "builtin" + } + }, + "required": [ + "type", + "name" + ] + }, + { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "description": { + "type": [ + "string", + "null" + ] + }, + "display_name": { + "type": [ + "string", + "null" + ] + }, + "bundled": { + "type": [ + "boolean", + "null" + ] + }, + "type": { + "type": "string", + "const": "platform" + } + }, + "required": [ + "type", + "name" + ] + }, + { + "type": "object", + "properties": { + "server": { + "$ref": "#/$defs/McpServer" + }, + "envKeys": { + "type": "array", + "items": { + "type": "string" + } + }, + "description": { + "type": [ + "string", + "null" + ] + }, + "timeout": { + "type": [ + "integer", + "null" + ], + "minimum": 0 + }, + "socket": { + "type": [ + "string", + "null" + ] + }, + "bundled": { + "type": [ + "boolean", + "null" + ] + }, + "type": { + "type": "string", + "const": "mcp" + } + }, + "required": [ + "type", + "server" + ] + } + ] + }, + "McpServer": { + "anyOf": [ + { + "$ref": "#/$defs/McpServerHttp", + "type": "object", + "properties": { + "type": { + "type": "string", + "const": "http" + } + }, + "required": [ + "type" + ], + "description": "HTTP transport configuration\n\nOnly available when the Agent capabilities indicate `mcp_capabilities.http` is `true`." + }, + { + "$ref": "#/$defs/McpServerSse", + "type": "object", + "properties": { + "type": { + "type": "string", + "const": "sse" + } + }, + "required": [ + "type" + ], + "description": "SSE transport configuration\n\nOnly available when the Agent capabilities indicate `mcp_capabilities.sse` is `true`." + }, + { + "$ref": "#/$defs/McpServerStdio", + "description": "Stdio transport configuration\n\nAll Agents MUST support this transport." + } + ], + "description": "Configuration for connecting to an MCP (Model Context Protocol) server.\n\nMCP servers provide tools and context that the agent can use when\nprocessing prompts.\n\nSee protocol docs: [MCP Servers](https://agentclientprotocol.com/protocol/session-setup#mcp-servers)" + }, + "HttpHeader": { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "The name of the HTTP header." + }, + "value": { + "type": "string", + "description": "The value to set for the HTTP header." + }, + "_meta": { + "type": [ + "object", + "null" + ], + "additionalProperties": {}, + "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)" + } + }, + "required": [ + "name", + "value" + ], + "description": "An HTTP header to set when making requests to the MCP server." + }, + "McpServerHttp": { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "Human-readable name identifying this MCP server." + }, + "url": { + "type": "string", + "description": "URL to the MCP server." + }, + "headers": { + "type": "array", + "items": { + "$ref": "#/$defs/HttpHeader" + }, + "description": "HTTP headers to set when making requests to the MCP server." + }, + "_meta": { + "type": [ + "object", + "null" + ], + "additionalProperties": {}, + "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": { + "type": "string", + "const": "http" + } + }, + "required": [ + "type", + "name", + "url", + "headers" + ], + "description": "HTTP transport configuration for MCP." + }, + "McpServerSse": { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "Human-readable name identifying this MCP server." + }, + "url": { + "type": "string", + "description": "URL to the MCP server." + }, + "headers": { + "type": "array", + "items": { + "$ref": "#/$defs/HttpHeader" + }, + "description": "HTTP headers to set when making requests to the MCP server." + }, + "_meta": { + "type": [ + "object", + "null" + ], + "additionalProperties": {}, + "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": { + "type": "string", + "const": "sse" + } + }, + "required": [ + "type", + "name", + "url", + "headers" + ], + "description": "SSE transport configuration for MCP." + }, + "McpServerStdio": { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "Human-readable name identifying this MCP server." + }, + "command": { + "type": "string", + "description": "Path to the MCP server executable." + }, + "args": { + "type": "array", + "items": { + "type": "string" + }, + "description": "Command-line arguments to pass to the MCP server." + }, + "env": { + "type": "array", + "items": { + "$ref": "#/$defs/EnvVariable" + }, + "description": "Environment variables to set when launching the MCP server." + }, + "_meta": { + "type": [ + "object", + "null" + ], + "additionalProperties": {}, + "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)" + } + }, + "required": [ + "name", + "command", + "args", + "env" + ], + "description": "Stdio transport configuration for MCP." + }, + "EnvVariable": { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "The name of the environment variable." + }, + "value": { + "type": "string", + "description": "The value to set for the environment variable." + }, + "_meta": { + "type": [ + "object", + "null" + ], + "additionalProperties": {}, + "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)" + } + }, + "required": [ + "name", + "value" + ], + "description": "An environment variable to set when launching an MCP server." + }, "EmptyResponse": { "type": "object", "description": "Empty success response for operations that return no data.", "x-side": "agent" }, - "RemoveExtensionRequest_unstable": { + "RemoveSessionExtensionRequest_unstable": { "type": "object", "properties": { "sessionId": { @@ -703,341 +1038,6 @@ "enabled" ] }, - "GooseExtension": { - "oneOf": [ - { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "description": { - "type": [ - "string", - "null" - ] - }, - "display_name": { - "type": [ - "string", - "null" - ] - }, - "timeout": { - "type": [ - "integer", - "null" - ], - "minimum": 0 - }, - "bundled": { - "type": [ - "boolean", - "null" - ] - }, - "type": { - "type": "string", - "const": "builtin" - } - }, - "required": [ - "type", - "name" - ] - }, - { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "description": { - "type": [ - "string", - "null" - ] - }, - "display_name": { - "type": [ - "string", - "null" - ] - }, - "bundled": { - "type": [ - "boolean", - "null" - ] - }, - "type": { - "type": "string", - "const": "platform" - } - }, - "required": [ - "type", - "name" - ] - }, - { - "type": "object", - "properties": { - "server": { - "$ref": "#/$defs/McpServer" - }, - "envKeys": { - "type": "array", - "items": { - "type": "string" - } - }, - "description": { - "type": [ - "string", - "null" - ] - }, - "timeout": { - "type": [ - "integer", - "null" - ], - "minimum": 0 - }, - "socket": { - "type": [ - "string", - "null" - ] - }, - "bundled": { - "type": [ - "boolean", - "null" - ] - }, - "type": { - "type": "string", - "const": "mcp" - } - }, - "required": [ - "type", - "server" - ] - } - ] - }, - "McpServer": { - "anyOf": [ - { - "$ref": "#/$defs/McpServerHttp", - "type": "object", - "properties": { - "type": { - "type": "string", - "const": "http" - } - }, - "required": [ - "type" - ], - "description": "HTTP transport configuration\n\nOnly available when the Agent capabilities indicate `mcp_capabilities.http` is `true`." - }, - { - "$ref": "#/$defs/McpServerSse", - "type": "object", - "properties": { - "type": { - "type": "string", - "const": "sse" - } - }, - "required": [ - "type" - ], - "description": "SSE transport configuration\n\nOnly available when the Agent capabilities indicate `mcp_capabilities.sse` is `true`." - }, - { - "$ref": "#/$defs/McpServerStdio", - "description": "Stdio transport configuration\n\nAll Agents MUST support this transport." - } - ], - "description": "Configuration for connecting to an MCP (Model Context Protocol) server.\n\nMCP servers provide tools and context that the agent can use when\nprocessing prompts.\n\nSee protocol docs: [MCP Servers](https://agentclientprotocol.com/protocol/session-setup#mcp-servers)" - }, - "HttpHeader": { - "type": "object", - "properties": { - "name": { - "type": "string", - "description": "The name of the HTTP header." - }, - "value": { - "type": "string", - "description": "The value to set for the HTTP header." - }, - "_meta": { - "type": [ - "object", - "null" - ], - "additionalProperties": {}, - "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)" - } - }, - "required": [ - "name", - "value" - ], - "description": "An HTTP header to set when making requests to the MCP server." - }, - "McpServerHttp": { - "type": "object", - "properties": { - "name": { - "type": "string", - "description": "Human-readable name identifying this MCP server." - }, - "url": { - "type": "string", - "description": "URL to the MCP server." - }, - "headers": { - "type": "array", - "items": { - "$ref": "#/$defs/HttpHeader" - }, - "description": "HTTP headers to set when making requests to the MCP server." - }, - "_meta": { - "type": [ - "object", - "null" - ], - "additionalProperties": {}, - "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": { - "type": "string", - "const": "http" - } - }, - "required": [ - "type", - "name", - "url", - "headers" - ], - "description": "HTTP transport configuration for MCP." - }, - "McpServerSse": { - "type": "object", - "properties": { - "name": { - "type": "string", - "description": "Human-readable name identifying this MCP server." - }, - "url": { - "type": "string", - "description": "URL to the MCP server." - }, - "headers": { - "type": "array", - "items": { - "$ref": "#/$defs/HttpHeader" - }, - "description": "HTTP headers to set when making requests to the MCP server." - }, - "_meta": { - "type": [ - "object", - "null" - ], - "additionalProperties": {}, - "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": { - "type": "string", - "const": "sse" - } - }, - "required": [ - "type", - "name", - "url", - "headers" - ], - "description": "SSE transport configuration for MCP." - }, - "McpServerStdio": { - "type": "object", - "properties": { - "name": { - "type": "string", - "description": "Human-readable name identifying this MCP server." - }, - "command": { - "type": "string", - "description": "Path to the MCP server executable." - }, - "args": { - "type": "array", - "items": { - "type": "string" - }, - "description": "Command-line arguments to pass to the MCP server." - }, - "env": { - "type": "array", - "items": { - "$ref": "#/$defs/EnvVariable" - }, - "description": "Environment variables to set when launching the MCP server." - }, - "_meta": { - "type": [ - "object", - "null" - ], - "additionalProperties": {}, - "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)" - } - }, - "required": [ - "name", - "command", - "args", - "env" - ], - "description": "Stdio transport configuration for MCP." - }, - "EnvVariable": { - "type": "object", - "properties": { - "name": { - "type": "string", - "description": "The name of the environment variable." - }, - "value": { - "type": "string", - "description": "The value to set for the environment variable." - }, - "_meta": { - "type": [ - "object", - "null" - ], - "additionalProperties": {}, - "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)" - } - }, - "required": [ - "name", - "value" - ], - "description": "An environment variable to set when launching an MCP server." - }, "GetAvailableExtensionsRequest_unstable": { "type": "object", "description": "List Goose-owned extension definitions available to configure or enable.", @@ -1128,7 +1128,9 @@ "properties": { "extensions": { "type": "array", - "items": {} + "items": { + "$ref": "#/$defs/GooseExtension" + } } }, "required": [ @@ -3704,20 +3706,20 @@ { "allOf": [ { - "$ref": "#/$defs/AddExtensionRequest_unstable" + "$ref": "#/$defs/AddSessionExtensionRequest_unstable" } ], "description": "Params for _goose/unstable/session/extensions/add", - "title": "AddExtensionRequest_unstable" + "title": "AddSessionExtensionRequest_unstable" }, { "allOf": [ { - "$ref": "#/$defs/RemoveExtensionRequest_unstable" + "$ref": "#/$defs/RemoveSessionExtensionRequest_unstable" } ], "description": "Params for _goose/unstable/session/extensions/remove", - "title": "RemoveExtensionRequest_unstable" + "title": "RemoveSessionExtensionRequest_unstable" }, { "allOf": [ diff --git a/crates/goose/src/acp/server.rs b/crates/goose/src/acp/server.rs index eb0d185a3..12bd5d4e4 100644 --- a/crates/goose/src/acp/server.rs +++ b/crates/goose/src/acp/server.rs @@ -2310,43 +2310,6 @@ impl GooseAcpAgent { )) } - #[allow(dead_code)] - async fn add_mcp_extensions( - agent: &Arc, - mcp_servers: Vec, - session_id: &str, - ) -> Result<(), agent_client_protocol::Error> { - let mut configs = Vec::with_capacity(mcp_servers.len()); - for mcp_server in mcp_servers { - let config = match mcp_server_to_extension_config(mcp_server) { - Ok(c) => c, - Err(msg) => { - return Err(agent_client_protocol::Error::invalid_params().data(msg)); - } - }; - configs.push(config); - } - - if configs.is_empty() { - return Ok(()); - } - - let results = agent - .add_extensions_bulk(configs, session_id) - .await - .internal_err()?; - for result in &results { - if !result.success { - let error_msg = result.error.as_deref().unwrap_or("unknown error"); - return Err(agent_client_protocol::Error::internal_error().data(format!( - "Failed to add MCP server '{}': {}", - result.name, error_msg - ))); - } - } - Ok(()) - } - async fn on_load_session( &self, cx: &ConnectionTo, diff --git a/crates/goose/src/acp/server/custom_dispatch.rs b/crates/goose/src/acp/server/custom_dispatch.rs index ed45793b9..a6a747b6e 100644 --- a/crates/goose/src/acp/server/custom_dispatch.rs +++ b/crates/goose/src/acp/server/custom_dispatch.rs @@ -11,20 +11,20 @@ impl GooseAcpAgent { self.handle_custom_request(method, params).await } - #[custom_method(AddExtensionRequest)] - async fn dispatch_add_extension( + #[custom_method(AddSessionExtensionRequest)] + async fn dispatch_add_session_extension( &self, - req: AddExtensionRequest, + req: AddSessionExtensionRequest, ) -> Result { - self.on_add_extension(req).await + self.on_add_session_extension(req).await } - #[custom_method(RemoveExtensionRequest)] - async fn dispatch_remove_extension( + #[custom_method(RemoveSessionExtensionRequest)] + async fn dispatch_remove_session_extension( &self, - req: RemoveExtensionRequest, + req: RemoveSessionExtensionRequest, ) -> Result { - self.on_remove_extension(req).await + self.on_remove_session_extension(req).await } #[custom_method(GetToolsRequest)] diff --git a/crates/goose/src/acp/server/extensions.rs b/crates/goose/src/acp/server/extensions.rs index fae9bdadb..eb43ef9b5 100644 --- a/crates/goose/src/acp/server/extensions.rs +++ b/crates/goose/src/acp/server/extensions.rs @@ -4,14 +4,12 @@ use crate::config::extensions::ExtensionEntry; use agent_client_protocol::schema::{HttpHeader, McpServer, McpServerHttp, McpServerStdio}; impl GooseAcpAgent { - pub(super) async fn on_add_extension( + pub(super) async fn on_add_session_extension( &self, - req: AddExtensionRequest, + req: AddSessionExtensionRequest, ) -> Result { let session_id = &req.session_id; - let config: ExtensionConfig = serde_json::from_value(req.config).map_err(|e| { - agent_client_protocol::Error::invalid_params().data(format!("bad config: {e}")) - })?; + let config = goose_extension_to_session_config(req.extension)?; let agent = self.get_session_agent(&req.session_id).await?; agent .add_extension(config, session_id) @@ -20,9 +18,9 @@ impl GooseAcpAgent { Ok(EmptyResponse {}) } - pub(super) async fn on_remove_extension( + pub(super) async fn on_remove_session_extension( &self, - req: RemoveExtensionRequest, + req: RemoveSessionExtensionRequest, ) -> Result { let session_id = &req.session_id; let agent = self.get_session_agent(&req.session_id).await?; @@ -125,15 +123,15 @@ impl GooseAcpAgent { crate::config::Config::global(), ); - let extensions_json = extensions + let extensions = extensions .into_iter() - .map(|e| serde_json::to_value(&e)) - .collect::, _>>() - .internal_err()?; + .map(|config| config_to_goose_extension(&config)) + .collect::, _>>()? + .into_iter() + .flatten() + .collect::>(); - Ok(GetSessionExtensionsResponse { - extensions: extensions_json, - }) + Ok(GetSessionExtensionsResponse { extensions }) } } @@ -317,6 +315,19 @@ fn goose_extension_to_config( }) } +fn goose_extension_to_session_config( + extension: GooseExtension, +) -> Result { + let conversion = goose_extension_to_config(extension)?; + if !conversion.secret_updates.is_empty() { + return Err(agent_client_protocol::Error::invalid_params().data( + "literal environment values are not supported for session extensions; use envKeys", + )); + } + + Ok(conversion.config) +} + fn config_entry_to_goose_entry( entry: ExtensionEntry, ) -> Result, agent_client_protocol::Error> { diff --git a/crates/goose/tests/acp_custom_requests_test.rs b/crates/goose/tests/acp_custom_requests_test.rs index 0453a3c16..3c9c87c85 100644 --- a/crates/goose/tests/acp_custom_requests_test.rs +++ b/crates/goose/tests/acp_custom_requests_test.rs @@ -315,6 +315,90 @@ fn test_custom_get_extensions() { }); } +#[test] +#[serial] +fn test_custom_session_extensions_add_list_remove() { + let extension_name = "summarize"; + let _guard = env_lock::lock_env([("EXTENSIONS", None::<&str>)]); + write_acp_global_config(DEFAULT_ACP_TEST_CONFIG); + + run_test(async move { + let openai = OpenAiFixture::new(vec![], Arc::new(EnforceSessionId::default())).await; + let mut conn = AcpServerConnection::new(TestConnectionConfig::default(), openai).await; + + let SessionData { session, .. } = conn.new_session().await.unwrap(); + let session_id = session.session_id().0.clone(); + + let list_extension = || async { + let result = send_custom( + conn.cx(), + "_goose/unstable/session/extensions/list", + serde_json::json!({ "sessionId": session_id.clone() }), + ) + .await; + assert!(result.is_ok(), "expected ok, got: {:?}", result); + + let response = result.unwrap(); + let extensions = response + .get("extensions") + .and_then(|extensions| extensions.as_array()) + .expect("extensions should be an array"); + extensions + .iter() + .find(|extension| extension["name"] == extension_name) + .cloned() + }; + + assert!( + list_extension().await.is_none(), + "{extension_name} should not be enabled before add" + ); + + let add_result = send_custom( + conn.cx(), + "_goose/unstable/session/extensions/add", + serde_json::json!({ + "sessionId": session_id.clone(), + "extension": { + "type": "platform", + "name": extension_name, + "description": "Load files/directories and get an LLM summary in a single call", + "displayName": "Summarize", + "bundled": true + } + }), + ) + .await; + assert!(add_result.is_ok(), "expected ok, got: {:?}", add_result); + + let extension = list_extension() + .await + .unwrap_or_else(|| panic!("missing added session extension")); + assert_eq!(extension["type"], "platform"); + assert_eq!(extension["name"], extension_name); + + let remove_result = send_custom( + conn.cx(), + "_goose/unstable/session/extensions/remove", + serde_json::json!({ + "sessionId": session_id.clone(), + "name": extension_name, + }), + ) + .await; + assert!( + remove_result.is_ok(), + "expected ok, got: {:?}", + remove_result + ); + + assert!( + list_extension().await.is_none(), + "removed session extension should not be listed" + ); + }); +} + #[test] #[serial] fn test_custom_get_available_extensions() { diff --git a/ui/sdk/src/generated/client.gen.ts b/ui/sdk/src/generated/client.gen.ts index c9a117b20..f4303b6ae 100644 --- a/ui/sdk/src/generated/client.gen.ts +++ b/ui/sdk/src/generated/client.gen.ts @@ -10,7 +10,7 @@ export interface ExtMethodProvider { import type { Client } from "@agentclientprotocol/sdk"; import type { AddConfigExtensionRequest_unstable, - AddExtensionRequest_unstable, + AddSessionExtensionRequest_unstable, ArchiveSessionRequest_unstable, CreateSourceRequest_unstable, CreateSourceResponse_unstable, @@ -95,7 +95,7 @@ import type { RefreshProviderInventoryRequest_unstable, RefreshProviderInventoryResponse_unstable, RemoveConfigExtensionRequest_unstable, - RemoveExtensionRequest_unstable, + RemoveSessionExtensionRequest_unstable, RenameSessionRequest_unstable, SetConfigExtensionEnabledRequest_unstable, SetSessionSystemPromptRequest_unstable, @@ -152,13 +152,13 @@ export class GooseExtClient { constructor(private conn: ExtMethodProvider) {} async sessionExtensionsAdd_unstable( - params: AddExtensionRequest_unstable, + params: AddSessionExtensionRequest_unstable, ): Promise { await this.conn.extMethod("_goose/unstable/session/extensions/add", params); } async sessionExtensionsRemove_unstable( - params: RemoveExtensionRequest_unstable, + params: RemoveSessionExtensionRequest_unstable, ): Promise { await this.conn.extMethod( "_goose/unstable/session/extensions/remove", diff --git a/ui/sdk/src/generated/index.ts b/ui/sdk/src/generated/index.ts index 555182187..bc1346f4c 100644 --- a/ui/sdk/src/generated/index.ts +++ b/ui/sdk/src/generated/index.ts @@ -1,16 +1,16 @@ // This file is auto-generated by @hey-api/openapi-ts -export type { AddConfigExtensionRequest_unstable, AddExtensionRequest_unstable, Annotations, ArchiveSessionRequest_unstable, AudioContent, BlobResourceContents, ContentBlock, CreateSourceRequest_unstable, CreateSourceResponse_unstable, CustomProviderConfigDto, CustomProviderCreateRequest_unstable, CustomProviderCreateResponse_unstable, CustomProviderDeleteRequest_unstable, CustomProviderDeleteResponse_unstable, CustomProviderReadRequest_unstable, CustomProviderReadResponse_unstable, CustomProviderUpdateRequest_unstable, CustomProviderUpdateResponse_unstable, DefaultsReadRequest_unstable, DefaultsReadResponse_unstable, DefaultsSaveRequest_unstable, DeleteSessionRequest, DeleteSourceRequest_unstable, DictationConfigRequest_unstable, DictationConfigResponse_unstable, DictationDownloadProgress, DictationLocalModelStatus, DictationModelCancelRequest_unstable, DictationModelDeleteRequest_unstable, DictationModelDownloadProgressRequest_unstable, DictationModelDownloadProgressResponse_unstable, DictationModelDownloadRequest_unstable, DictationModelOption, DictationModelSelectRequest_unstable, DictationModelsListRequest_unstable, DictationModelsListResponse_unstable, DictationProviderStatusEntry, DictationSecretDeleteRequest_unstable, DictationSecretSaveRequest_unstable, DictationTranscribeRequest_unstable, DictationTranscribeResponse_unstable, EmbeddedResource, EmbeddedResourceResource, EmptyResponse, EnvVariable, ExportSessionRequest_unstable, ExportSessionResponse_unstable, ExportSourceRequest_unstable, ExportSourceResponse_unstable, ExtNotification, ExtRequest, ExtResponse, GetAvailableExtensionsRequest_unstable, GetAvailableExtensionsResponse_unstable, GetConfigExtensionsRequest_unstable, GetConfigExtensionsResponse_unstable, GetSessionExtensionsRequest_unstable, GetSessionExtensionsResponse_unstable, GetSessionInfoRequest_unstable, GetSessionInfoResponse_unstable, GetToolsRequest_unstable, GetToolsResponse_unstable, GooseExtension, GooseExtensionEntry, GooseSessionNotification_unstable, GooseSessionUpdate, GooseToolCallRequest_unstable, GooseToolCallResponse_unstable, HttpHeader, ImageContent, ImportSessionRequest_unstable, ImportSessionResponse_unstable, ImportSourcesRequest_unstable, ImportSourcesResponse_unstable, ListProvidersRequest_unstable, ListProvidersResponse_unstable, ListSourcesRequest_unstable, ListSourcesResponse_unstable, McpServer, McpServerHttp, McpServerSse, McpServerStdio, OnboardingImportApplyRequest_unstable, OnboardingImportApplyResponse_unstable, OnboardingImportCandidate, OnboardingImportCounts, OnboardingImportScanRequest_unstable, OnboardingImportScanResponse_unstable, OnboardingImportSourceKind, PreferenceKey, PreferencesReadRequest_unstable, PreferencesReadResponse_unstable, PreferencesRemoveRequest_unstable, PreferencesSaveRequest_unstable, PreferenceValue, ProviderCatalogListRequest_unstable, ProviderCatalogListResponse_unstable, ProviderCatalogTemplateRequest_unstable, ProviderCatalogTemplateResponse_unstable, ProviderConfigAuthenticateRequest_unstable, ProviderConfigChangeResponse_unstable, ProviderConfigDeleteRequest_unstable, ProviderConfigFieldUpdate, ProviderConfigFieldValueDto, ProviderConfigKey, ProviderConfigReadRequest_unstable, ProviderConfigReadResponse_unstable, ProviderConfigSaveRequest_unstable, ProviderConfigStatusDto, ProviderConfigStatusRequest_unstable, ProviderConfigStatusResponse_unstable, ProviderInventoryEntryDto, ProviderInventoryModelDto, ProviderSetupCatalogEntryDto, ProviderSetupCatalogListRequest_unstable, ProviderSetupCatalogListResponse_unstable, ProviderSetupCategoryDto, ProviderSetupFieldDto, ProviderSetupGroupDto, ProviderSetupMethodDto, ProviderSupportedModelsListRequest_unstable, ProviderSupportedModelsListResponse_unstable, ProviderTemplateCapabilitiesDto, ProviderTemplateCatalogEntryDto, ProviderTemplateDto, ProviderTemplateModelDto, ReadResourceRequest_unstable, ReadResourceResponse_unstable, RefreshProviderInventoryRequest_unstable, RefreshProviderInventoryResponse_unstable, RefreshProviderInventorySkipDto, RefreshProviderInventorySkipReasonDto, RemoveConfigExtensionRequest_unstable, RemoveExtensionRequest_unstable, RenameSessionRequest_unstable, ResourceLink, Role, SessionId, SessionInfo, SessionSystemPromptMode, SessionUsageUpdate, SetConfigExtensionEnabledRequest_unstable, SetSessionSystemPromptRequest_unstable, SourceEntry, SourceScope, SourceType, StatusMessage, StatusMessageUpdate, SteerSessionRequest_unstable, SteerSessionResponse_unstable, TextContent, TextResourceContents, TruncateSessionConversationRequest_unstable, UnarchiveSessionRequest_unstable, UpdateSessionProjectRequest_unstable, UpdateSourceRequest_unstable, UpdateSourceResponse_unstable, UpdateWorkingDirRequest_unstable } from './types.gen.js'; +export type { AddConfigExtensionRequest_unstable, AddSessionExtensionRequest_unstable, Annotations, ArchiveSessionRequest_unstable, AudioContent, BlobResourceContents, ContentBlock, CreateSourceRequest_unstable, CreateSourceResponse_unstable, CustomProviderConfigDto, CustomProviderCreateRequest_unstable, CustomProviderCreateResponse_unstable, CustomProviderDeleteRequest_unstable, CustomProviderDeleteResponse_unstable, CustomProviderReadRequest_unstable, CustomProviderReadResponse_unstable, CustomProviderUpdateRequest_unstable, CustomProviderUpdateResponse_unstable, DefaultsReadRequest_unstable, DefaultsReadResponse_unstable, DefaultsSaveRequest_unstable, DeleteSessionRequest, DeleteSourceRequest_unstable, DictationConfigRequest_unstable, DictationConfigResponse_unstable, DictationDownloadProgress, DictationLocalModelStatus, DictationModelCancelRequest_unstable, DictationModelDeleteRequest_unstable, DictationModelDownloadProgressRequest_unstable, DictationModelDownloadProgressResponse_unstable, DictationModelDownloadRequest_unstable, DictationModelOption, DictationModelSelectRequest_unstable, DictationModelsListRequest_unstable, DictationModelsListResponse_unstable, DictationProviderStatusEntry, DictationSecretDeleteRequest_unstable, DictationSecretSaveRequest_unstable, DictationTranscribeRequest_unstable, DictationTranscribeResponse_unstable, EmbeddedResource, EmbeddedResourceResource, EmptyResponse, EnvVariable, ExportSessionRequest_unstable, ExportSessionResponse_unstable, ExportSourceRequest_unstable, ExportSourceResponse_unstable, ExtNotification, ExtRequest, ExtResponse, GetAvailableExtensionsRequest_unstable, GetAvailableExtensionsResponse_unstable, GetConfigExtensionsRequest_unstable, GetConfigExtensionsResponse_unstable, GetSessionExtensionsRequest_unstable, GetSessionExtensionsResponse_unstable, GetSessionInfoRequest_unstable, GetSessionInfoResponse_unstable, GetToolsRequest_unstable, GetToolsResponse_unstable, GooseExtension, GooseExtensionEntry, GooseSessionNotification_unstable, GooseSessionUpdate, GooseToolCallRequest_unstable, GooseToolCallResponse_unstable, HttpHeader, ImageContent, ImportSessionRequest_unstable, ImportSessionResponse_unstable, ImportSourcesRequest_unstable, ImportSourcesResponse_unstable, ListProvidersRequest_unstable, ListProvidersResponse_unstable, ListSourcesRequest_unstable, ListSourcesResponse_unstable, McpServer, McpServerHttp, McpServerSse, McpServerStdio, OnboardingImportApplyRequest_unstable, OnboardingImportApplyResponse_unstable, OnboardingImportCandidate, OnboardingImportCounts, OnboardingImportScanRequest_unstable, OnboardingImportScanResponse_unstable, OnboardingImportSourceKind, PreferenceKey, PreferencesReadRequest_unstable, PreferencesReadResponse_unstable, PreferencesRemoveRequest_unstable, PreferencesSaveRequest_unstable, PreferenceValue, ProviderCatalogListRequest_unstable, ProviderCatalogListResponse_unstable, ProviderCatalogTemplateRequest_unstable, ProviderCatalogTemplateResponse_unstable, ProviderConfigAuthenticateRequest_unstable, ProviderConfigChangeResponse_unstable, ProviderConfigDeleteRequest_unstable, ProviderConfigFieldUpdate, ProviderConfigFieldValueDto, ProviderConfigKey, ProviderConfigReadRequest_unstable, ProviderConfigReadResponse_unstable, ProviderConfigSaveRequest_unstable, ProviderConfigStatusDto, ProviderConfigStatusRequest_unstable, ProviderConfigStatusResponse_unstable, ProviderInventoryEntryDto, ProviderInventoryModelDto, ProviderSetupCatalogEntryDto, ProviderSetupCatalogListRequest_unstable, ProviderSetupCatalogListResponse_unstable, ProviderSetupCategoryDto, ProviderSetupFieldDto, ProviderSetupGroupDto, ProviderSetupMethodDto, ProviderSupportedModelsListRequest_unstable, ProviderSupportedModelsListResponse_unstable, ProviderTemplateCapabilitiesDto, ProviderTemplateCatalogEntryDto, ProviderTemplateDto, ProviderTemplateModelDto, ReadResourceRequest_unstable, ReadResourceResponse_unstable, RefreshProviderInventoryRequest_unstable, RefreshProviderInventoryResponse_unstable, RefreshProviderInventorySkipDto, RefreshProviderInventorySkipReasonDto, RemoveConfigExtensionRequest_unstable, RemoveSessionExtensionRequest_unstable, RenameSessionRequest_unstable, ResourceLink, Role, SessionId, SessionInfo, SessionSystemPromptMode, SessionUsageUpdate, SetConfigExtensionEnabledRequest_unstable, SetSessionSystemPromptRequest_unstable, SourceEntry, SourceScope, SourceType, StatusMessage, StatusMessageUpdate, SteerSessionRequest_unstable, SteerSessionResponse_unstable, TextContent, TextResourceContents, TruncateSessionConversationRequest_unstable, UnarchiveSessionRequest_unstable, UpdateSessionProjectRequest_unstable, UpdateSourceRequest_unstable, UpdateSourceResponse_unstable, UpdateWorkingDirRequest_unstable } from './types.gen.js'; export const GOOSE_EXT_METHODS = [ { method: "_goose/unstable/session/extensions/add", - requestType: "AddExtensionRequest_unstable", + requestType: "AddSessionExtensionRequest_unstable", responseType: "EmptyResponse", }, { method: "_goose/unstable/session/extensions/remove", - requestType: "RemoveExtensionRequest_unstable", + requestType: "RemoveSessionExtensionRequest_unstable", responseType: "EmptyResponse", }, { diff --git a/ui/sdk/src/generated/types.gen.ts b/ui/sdk/src/generated/types.gen.ts index 7a97352d3..1eb028c6a 100644 --- a/ui/sdk/src/generated/types.gen.ts +++ b/ui/sdk/src/generated/types.gen.ts @@ -4,12 +4,180 @@ /** * Add an extension to an active session. */ -export type AddExtensionRequest_unstable = { +export type AddSessionExtensionRequest_unstable = { sessionId: string; + extension: GooseExtension; +}; + +export type GooseExtension = { + name: string; + description?: string | null; + display_name?: string | null; + timeout?: number | null; + bundled?: boolean | null; + type: 'builtin'; +} | { + name: string; + description?: string | null; + display_name?: string | null; + bundled?: boolean | null; + type: 'platform'; +} | { + server: McpServer; + envKeys?: Array; + description?: string | null; + timeout?: number | null; + socket?: string | null; + bundled?: boolean | null; + type: 'mcp'; +}; + +/** + * Configuration for connecting to an MCP (Model Context Protocol) server. + * + * MCP servers provide tools and context that the agent can use when + * processing prompts. + * + * See protocol docs: [MCP Servers](https://agentclientprotocol.com/protocol/session-setup#mcp-servers) + */ +export type McpServer = McpServerHttp | McpServerSse | McpServerStdio; + +/** + * An HTTP header to set when making requests to the MCP server. + */ +export type HttpHeader = { /** - * Extension configuration (see ExtensionConfig variants: Stdio, StreamableHttp, Builtin, Platform). + * The name of the HTTP header. */ - config?: unknown; + name: string; + /** + * The value to set for the HTTP header. + */ + value: string; + /** + * 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; +}; + +/** + * HTTP transport configuration for MCP. + */ +export type McpServerHttp = { + /** + * Human-readable name identifying this MCP server. + */ + name: string; + /** + * URL to the MCP server. + */ + url: string; + /** + * HTTP headers to set when making requests to the MCP server. + */ + headers: Array; + /** + * 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; + type: 'http'; +}; + +/** + * SSE transport configuration for MCP. + */ +export type McpServerSse = { + /** + * Human-readable name identifying this MCP server. + */ + name: string; + /** + * URL to the MCP server. + */ + url: string; + /** + * HTTP headers to set when making requests to the MCP server. + */ + headers: Array; + /** + * 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; + type: 'sse'; +}; + +/** + * Stdio transport configuration for MCP. + */ +export type McpServerStdio = { + /** + * Human-readable name identifying this MCP server. + */ + name: string; + /** + * Path to the MCP server executable. + */ + command: string; + /** + * Command-line arguments to pass to the MCP server. + */ + args: Array; + /** + * Environment variables to set when launching the MCP server. + */ + env: Array; + /** + * 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; +}; + +/** + * An environment variable to set when launching an MCP server. + */ +export type EnvVariable = { + /** + * The name of the environment variable. + */ + name: string; + /** + * The value to set for the environment variable. + */ + value: string; + /** + * 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; }; /** @@ -22,7 +190,7 @@ export type EmptyResponse = { /** * Remove an extension from an active session. */ -export type RemoveExtensionRequest_unstable = { +export type RemoveSessionExtensionRequest_unstable = { sessionId: string; name: string; }; @@ -349,177 +517,6 @@ export type GooseExtensionEntry = { configKey?: string | null; }; -export type GooseExtension = { - name: string; - description?: string | null; - display_name?: string | null; - timeout?: number | null; - bundled?: boolean | null; - type: 'builtin'; -} | { - name: string; - description?: string | null; - display_name?: string | null; - bundled?: boolean | null; - type: 'platform'; -} | { - server: McpServer; - envKeys?: Array; - description?: string | null; - timeout?: number | null; - socket?: string | null; - bundled?: boolean | null; - type: 'mcp'; -}; - -/** - * Configuration for connecting to an MCP (Model Context Protocol) server. - * - * MCP servers provide tools and context that the agent can use when - * processing prompts. - * - * See protocol docs: [MCP Servers](https://agentclientprotocol.com/protocol/session-setup#mcp-servers) - */ -export type McpServer = McpServerHttp | McpServerSse | McpServerStdio; - -/** - * An HTTP header to set when making requests to the MCP server. - */ -export type HttpHeader = { - /** - * The name of the HTTP header. - */ - name: string; - /** - * The value to set for the HTTP header. - */ - value: string; - /** - * 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; -}; - -/** - * HTTP transport configuration for MCP. - */ -export type McpServerHttp = { - /** - * Human-readable name identifying this MCP server. - */ - name: string; - /** - * URL to the MCP server. - */ - url: string; - /** - * HTTP headers to set when making requests to the MCP server. - */ - headers: Array; - /** - * 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; - type: 'http'; -}; - -/** - * SSE transport configuration for MCP. - */ -export type McpServerSse = { - /** - * Human-readable name identifying this MCP server. - */ - name: string; - /** - * URL to the MCP server. - */ - url: string; - /** - * HTTP headers to set when making requests to the MCP server. - */ - headers: Array; - /** - * 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; - type: 'sse'; -}; - -/** - * Stdio transport configuration for MCP. - */ -export type McpServerStdio = { - /** - * Human-readable name identifying this MCP server. - */ - name: string; - /** - * Path to the MCP server executable. - */ - command: string; - /** - * Command-line arguments to pass to the MCP server. - */ - args: Array; - /** - * Environment variables to set when launching the MCP server. - */ - env: Array; - /** - * 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; -}; - -/** - * An environment variable to set when launching an MCP server. - */ -export type EnvVariable = { - /** - * The name of the environment variable. - */ - name: string; - /** - * The value to set for the environment variable. - */ - value: string; - /** - * 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; -}; - /** * List Goose-owned extension definitions available to configure or enable. */ @@ -559,7 +556,7 @@ export type GetSessionExtensionsRequest_unstable = { }; export type GetSessionExtensionsResponse_unstable = { - extensions: Array; + extensions: Array; }; /** @@ -1602,7 +1599,7 @@ export type StatusMessageUpdate = { export type ExtRequest = { id: string; method: string; - params?: AddExtensionRequest_unstable | RemoveExtensionRequest_unstable | GetToolsRequest_unstable | GooseToolCallRequest_unstable | ReadResourceRequest_unstable | UpdateWorkingDirRequest_unstable | SetSessionSystemPromptRequest_unstable | SteerSessionRequest_unstable | DeleteSessionRequest | GetConfigExtensionsRequest_unstable | GetAvailableExtensionsRequest_unstable | AddConfigExtensionRequest_unstable | RemoveConfigExtensionRequest_unstable | SetConfigExtensionEnabledRequest_unstable | GetSessionExtensionsRequest_unstable | ListProvidersRequest_unstable | ProviderSupportedModelsListRequest_unstable | ProviderCatalogListRequest_unstable | ProviderSetupCatalogListRequest_unstable | ProviderCatalogTemplateRequest_unstable | CustomProviderCreateRequest_unstable | CustomProviderReadRequest_unstable | CustomProviderUpdateRequest_unstable | CustomProviderDeleteRequest_unstable | RefreshProviderInventoryRequest_unstable | ProviderConfigReadRequest_unstable | ProviderConfigStatusRequest_unstable | ProviderConfigSaveRequest_unstable | ProviderConfigDeleteRequest_unstable | ProviderConfigAuthenticateRequest_unstable | PreferencesReadRequest_unstable | PreferencesSaveRequest_unstable | PreferencesRemoveRequest_unstable | DefaultsReadRequest_unstable | DefaultsSaveRequest_unstable | OnboardingImportScanRequest_unstable | OnboardingImportApplyRequest_unstable | ExportSessionRequest_unstable | ImportSessionRequest_unstable | GetSessionInfoRequest_unstable | TruncateSessionConversationRequest_unstable | UpdateSessionProjectRequest_unstable | RenameSessionRequest_unstable | ArchiveSessionRequest_unstable | UnarchiveSessionRequest_unstable | CreateSourceRequest_unstable | ListSourcesRequest_unstable | UpdateSourceRequest_unstable | DeleteSourceRequest_unstable | ExportSourceRequest_unstable | ImportSourcesRequest_unstable | DictationTranscribeRequest_unstable | DictationConfigRequest_unstable | DictationSecretSaveRequest_unstable | DictationSecretDeleteRequest_unstable | DictationModelsListRequest_unstable | DictationModelDownloadRequest_unstable | DictationModelDownloadProgressRequest_unstable | DictationModelCancelRequest_unstable | DictationModelDeleteRequest_unstable | DictationModelSelectRequest_unstable | { + params?: AddSessionExtensionRequest_unstable | RemoveSessionExtensionRequest_unstable | GetToolsRequest_unstable | GooseToolCallRequest_unstable | ReadResourceRequest_unstable | UpdateWorkingDirRequest_unstable | SetSessionSystemPromptRequest_unstable | SteerSessionRequest_unstable | DeleteSessionRequest | GetConfigExtensionsRequest_unstable | GetAvailableExtensionsRequest_unstable | AddConfigExtensionRequest_unstable | RemoveConfigExtensionRequest_unstable | SetConfigExtensionEnabledRequest_unstable | GetSessionExtensionsRequest_unstable | ListProvidersRequest_unstable | ProviderSupportedModelsListRequest_unstable | ProviderCatalogListRequest_unstable | ProviderSetupCatalogListRequest_unstable | ProviderCatalogTemplateRequest_unstable | CustomProviderCreateRequest_unstable | CustomProviderReadRequest_unstable | CustomProviderUpdateRequest_unstable | CustomProviderDeleteRequest_unstable | RefreshProviderInventoryRequest_unstable | ProviderConfigReadRequest_unstable | ProviderConfigStatusRequest_unstable | ProviderConfigSaveRequest_unstable | ProviderConfigDeleteRequest_unstable | ProviderConfigAuthenticateRequest_unstable | PreferencesReadRequest_unstable | PreferencesSaveRequest_unstable | PreferencesRemoveRequest_unstable | DefaultsReadRequest_unstable | DefaultsSaveRequest_unstable | OnboardingImportScanRequest_unstable | OnboardingImportApplyRequest_unstable | ExportSessionRequest_unstable | ImportSessionRequest_unstable | GetSessionInfoRequest_unstable | TruncateSessionConversationRequest_unstable | UpdateSessionProjectRequest_unstable | RenameSessionRequest_unstable | ArchiveSessionRequest_unstable | UnarchiveSessionRequest_unstable | CreateSourceRequest_unstable | ListSourcesRequest_unstable | UpdateSourceRequest_unstable | DeleteSourceRequest_unstable | ExportSourceRequest_unstable | ImportSourcesRequest_unstable | DictationTranscribeRequest_unstable | DictationConfigRequest_unstable | DictationSecretSaveRequest_unstable | DictationSecretDeleteRequest_unstable | DictationModelsListRequest_unstable | DictationModelDownloadRequest_unstable | DictationModelDownloadProgressRequest_unstable | DictationModelCancelRequest_unstable | DictationModelDeleteRequest_unstable | DictationModelSelectRequest_unstable | { [key: string]: unknown; } | null; }; diff --git a/ui/sdk/src/generated/zod.gen.ts b/ui/sdk/src/generated/zod.gen.ts index 54b87f001..3345667f0 100644 --- a/ui/sdk/src/generated/zod.gen.ts +++ b/ui/sdk/src/generated/zod.gen.ts @@ -2,12 +2,152 @@ import { z } from 'zod'; +/** + * An HTTP header to set when making requests to the MCP server. + */ +export const zHttpHeader = z.object({ + name: z.string(), + value: z.string(), + _meta: z.union([ + z.record(z.unknown()), + z.null() + ]).optional() +}); + +/** + * HTTP transport configuration for MCP. + */ +export const zMcpServerHttp = z.object({ + name: z.string(), + url: z.string(), + headers: z.array(zHttpHeader), + _meta: z.union([ + z.record(z.unknown()), + z.null() + ]).optional(), + type: z.literal('http') +}); + +/** + * SSE transport configuration for MCP. + */ +export const zMcpServerSse = z.object({ + name: z.string(), + url: z.string(), + headers: z.array(zHttpHeader), + _meta: z.union([ + z.record(z.unknown()), + z.null() + ]).optional(), + type: z.literal('sse') +}); + +/** + * An environment variable to set when launching an MCP server. + */ +export const zEnvVariable = z.object({ + name: z.string(), + value: z.string(), + _meta: z.union([ + z.record(z.unknown()), + z.null() + ]).optional() +}); + +/** + * Stdio transport configuration for MCP. + */ +export const zMcpServerStdio = z.object({ + name: z.string(), + command: z.string(), + args: z.array(z.string()), + env: z.array(zEnvVariable), + _meta: z.union([ + z.record(z.unknown()), + z.null() + ]).optional() +}); + +/** + * Configuration for connecting to an MCP (Model Context Protocol) server. + * + * MCP servers provide tools and context that the agent can use when + * processing prompts. + * + * See protocol docs: [MCP Servers](https://agentclientprotocol.com/protocol/session-setup#mcp-servers) + */ +export const zMcpServer = z.union([ + zMcpServerHttp, + zMcpServerSse, + zMcpServerStdio +]); + +export const zGooseExtension = z.union([ + z.object({ + name: z.string(), + description: z.union([ + z.string(), + z.null() + ]).optional(), + display_name: z.union([ + z.string(), + z.null() + ]).optional(), + timeout: z.union([ + z.number().int().gte(0), + z.null() + ]).optional(), + bundled: z.union([ + z.boolean(), + z.null() + ]).optional(), + type: z.literal('builtin') + }), + z.object({ + name: z.string(), + description: z.union([ + z.string(), + z.null() + ]).optional(), + display_name: z.union([ + z.string(), + z.null() + ]).optional(), + bundled: z.union([ + z.boolean(), + z.null() + ]).optional(), + type: z.literal('platform') + }), + z.object({ + server: zMcpServer, + envKeys: z.array(z.string()).optional(), + description: z.union([ + z.string(), + z.null() + ]).optional(), + timeout: z.union([ + z.number().int().gte(0), + z.null() + ]).optional(), + socket: z.union([ + z.string(), + z.null() + ]).optional(), + bundled: z.union([ + z.boolean(), + z.null() + ]).optional(), + type: z.literal('mcp') + }) +]); + /** * Add an extension to an active session. */ -export const zAddExtensionRequest_unstable = z.object({ +export const zAddSessionExtensionRequest_unstable = z.object({ sessionId: z.string(), - config: z.unknown().optional().default(null) + extension: zGooseExtension }); /** @@ -18,7 +158,7 @@ export const zEmptyResponse = z.record(z.unknown()); /** * Remove an extension from an active session. */ -export const zRemoveExtensionRequest_unstable = z.object({ +export const zRemoveSessionExtensionRequest_unstable = z.object({ sessionId: z.string(), name: z.string() }); @@ -330,146 +470,6 @@ export const zDeleteSessionRequest = z.object({ */ export const zGetConfigExtensionsRequest_unstable = z.record(z.unknown()); -/** - * An HTTP header to set when making requests to the MCP server. - */ -export const zHttpHeader = z.object({ - name: z.string(), - value: z.string(), - _meta: z.union([ - z.record(z.unknown()), - z.null() - ]).optional() -}); - -/** - * HTTP transport configuration for MCP. - */ -export const zMcpServerHttp = z.object({ - name: z.string(), - url: z.string(), - headers: z.array(zHttpHeader), - _meta: z.union([ - z.record(z.unknown()), - z.null() - ]).optional(), - type: z.literal('http') -}); - -/** - * SSE transport configuration for MCP. - */ -export const zMcpServerSse = z.object({ - name: z.string(), - url: z.string(), - headers: z.array(zHttpHeader), - _meta: z.union([ - z.record(z.unknown()), - z.null() - ]).optional(), - type: z.literal('sse') -}); - -/** - * An environment variable to set when launching an MCP server. - */ -export const zEnvVariable = z.object({ - name: z.string(), - value: z.string(), - _meta: z.union([ - z.record(z.unknown()), - z.null() - ]).optional() -}); - -/** - * Stdio transport configuration for MCP. - */ -export const zMcpServerStdio = z.object({ - name: z.string(), - command: z.string(), - args: z.array(z.string()), - env: z.array(zEnvVariable), - _meta: z.union([ - z.record(z.unknown()), - z.null() - ]).optional() -}); - -/** - * Configuration for connecting to an MCP (Model Context Protocol) server. - * - * MCP servers provide tools and context that the agent can use when - * processing prompts. - * - * See protocol docs: [MCP Servers](https://agentclientprotocol.com/protocol/session-setup#mcp-servers) - */ -export const zMcpServer = z.union([ - zMcpServerHttp, - zMcpServerSse, - zMcpServerStdio -]); - -export const zGooseExtension = z.union([ - z.object({ - name: z.string(), - description: z.union([ - z.string(), - z.null() - ]).optional(), - display_name: z.union([ - z.string(), - z.null() - ]).optional(), - timeout: z.union([ - z.number().int().gte(0), - z.null() - ]).optional(), - bundled: z.union([ - z.boolean(), - z.null() - ]).optional(), - type: z.literal('builtin') - }), - z.object({ - name: z.string(), - description: z.union([ - z.string(), - z.null() - ]).optional(), - display_name: z.union([ - z.string(), - z.null() - ]).optional(), - bundled: z.union([ - z.boolean(), - z.null() - ]).optional(), - type: z.literal('platform') - }), - z.object({ - server: zMcpServer, - envKeys: z.array(z.string()).optional(), - description: z.union([ - z.string(), - z.null() - ]).optional(), - timeout: z.union([ - z.number().int().gte(0), - z.null() - ]).optional(), - socket: z.union([ - z.string(), - z.null() - ]).optional(), - bundled: z.union([ - z.boolean(), - z.null() - ]).optional(), - type: z.literal('mcp') - }) -]); - export const zGooseExtensionEntry = z.object({ extension: zGooseExtension, enabled: z.boolean(), @@ -524,7 +524,7 @@ export const zGetSessionExtensionsRequest_unstable = z.object({ }); export const zGetSessionExtensionsResponse_unstable = z.object({ - extensions: z.array(z.unknown()) + extensions: z.array(zGooseExtension) }); /** @@ -1573,8 +1573,8 @@ export const zExtRequest = z.object({ method: z.string(), params: z.union([ z.union([ - zAddExtensionRequest_unstable, - zRemoveExtensionRequest_unstable, + zAddSessionExtensionRequest_unstable, + zRemoveSessionExtensionRequest_unstable, zGetToolsRequest_unstable, zGooseToolCallRequest_unstable, zReadResourceRequest_unstable,