SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.
Assistant: opt-in HTTP authentication for private endpoints (#5341) (#10674)
Colin Faulkingham4d2691e63645
diff --git a/assets/locales/pending/agent-http-consent.json b/assets/locales/pending/agent-http-consent.jsonnew file mode 100644index 0000000000..5aa929d347--- /dev/null+++ b/assets/locales/pending/agent-http-consent.json@@ -0,0 +1,42 @@+{+ "en": {+ "ai.http.allow": "Allow insecure HTTP",+ "ai.http.confirm": "Allow for this endpoint",+ "ai.http.warning": "The API key and conversation will be sent unencrypted. Anyone with access to the network may read or change them. Use this only on a network you trust."+ },+ "ar": {+ "ai.http.allow": "السماح باتصال HTTP غير آمن",+ "ai.http.confirm": "السماح لهذه النقطة الطرفية",+ "ai.http.warning": "سيُرسَل مفتاح API والمحادثة دون تشفير. يمكن لأي شخص لديه وصول إلى الشبكة قراءتهما أو تغييرهما. استخدم هذا الخيار فقط على شبكة تثق بها."+ },+ "de": {+ "ai.http.allow": "Unsicheres HTTP erlauben",+ "ai.http.confirm": "Für diesen Endpunkt erlauben",+ "ai.http.warning": "Der API-Schlüssel und die Unterhaltung werden unverschlüsselt gesendet. Jeder mit Zugriff auf das Netzwerk kann sie lesen oder verändern. Verwenden Sie dies nur in einem vertrauenswürdigen Netzwerk."+ },+ "he": {+ "ai.http.allow": "אפשר HTTP לא מאובטח",+ "ai.http.confirm": "אפשר עבור נקודת קצה זו",+ "ai.http.warning": "מפתח ה־API והשיחה יישלחו ללא הצפנה. כל מי שיש לו גישה לרשת יכול לקרוא או לשנות אותם. יש להשתמש באפשרות זו רק ברשת מהימנה."+ },+ "ja": {+ "ai.http.allow": "安全でない HTTP を許可",+ "ai.http.confirm": "このエンドポイントで許可",+ "ai.http.warning": "API キーと会話は暗号化されずに送信されます。ネットワークにアクセスできる人は、内容を読み取ったり改ざんしたりする可能性があります。信頼できるネットワークでのみ使用してください。"+ },+ "ko": {+ "ai.http.allow": "보안되지 않은 HTTP 허용",+ "ai.http.confirm": "이 엔드포인트에 허용",+ "ai.http.warning": "API 키와 대화가 암호화되지 않은 상태로 전송됩니다. 네트워크에 접근할 수 있는 누구나 이를 읽거나 변경할 수 있습니다. 신뢰하는 네트워크에서만 사용하세요."+ },+ "vi": {+ "ai.http.allow": "Cho phép HTTP không bảo mật",+ "ai.http.confirm": "Cho phép với điểm cuối này",+ "ai.http.warning": "Khóa API và cuộc trò chuyện sẽ được gửi mà không mã hóa. Bất kỳ ai có quyền truy cập mạng đều có thể đọc hoặc thay đổi chúng. Chỉ sử dụng trên mạng mà bạn tin cậy."+ },+ "zh": {+ "ai.http.allow": "允许不安全的 HTTP",+ "ai.http.confirm": "允许此端点",+ "ai.http.warning": "API 密钥和对话将以未加密的方式发送。任何能够访问该网络的人都可能读取或篡改它们。请仅在可信网络上使用。"+ }+}diff --git a/attribution/pending/agent-http-consent.md b/attribution/pending/agent-http-consent.mdnew file mode 100644index 0000000000..8db7f8fdca--- /dev/null+++ b/attribution/pending/agent-http-consent.md@@ -0,0 +1 @@+| assets/locales/pending/agent-http-consent.json | SolidCraft contributors | Original endpoint-specific HTTP consent messages and translations | MIT OR Apache-2.0 |diff --git a/crates/ui-egui/src/agent_chat/agents.rs b/crates/ui-egui/src/agent_chat/agents.rsindex 9f09898206..5448bebc9f 100644--- a/crates/ui-egui/src/agent_chat/agents.rs+++ b/crates/ui-egui/src/agent_chat/agents.rs@@ -110,6 +110,8 @@ pub struct AgentConfig {pub ollama: bool,/// API: a key is stored for it in the system keychain.pub key: bool,+ /// OpenAI-compatible API: explicit consent to send the key over HTTP to this endpoint.+ pub allow_insecure_http: bool,/// API: how long one model request may take, in seconds (clamped to/// [`MIN_REQUEST_TIMEOUT_S`]..=[`MAX_REQUEST_TIMEOUT_S`] where it is used).pub request_timeout_s: u64,@@ -129,6 +131,7 @@ impl Default for AgentConfig {model: String::new(),ollama: false,key: false,+ allow_insecure_http: false,request_timeout_s: DEFAULT_REQUEST_TIMEOUT_S,reasoning_effort: String::new(),}@@ -178,6 +181,7 @@ pub struct Entry {pub base_url: String,pub model: String,pub key: bool,+ pub allow_insecure_http: bool,/// API: seconds one model request may take (in range).pub request_timeout_s: u64,/// API: the reasoning effort to send, empty for none (trimmed, in length).@@ -201,6 +205,7 @@ impl Entry {base_url: c.base_url.clone(),model: c.model.clone(),key: c.key,+ allow_insecure_http: c.kind == Kind::Api && c.allow_insecure_http,request_timeout_s: c.request_timeout_s.clamp(MIN_REQUEST_TIMEOUT_S, MAX_REQUEST_TIMEOUT_S),reasoning_effort: reasoning_effort(&c.reasoning_effort),problem: None,@@ -246,6 +251,7 @@ pub fn entries(app: &crate::SolveApp) -> Vec<Entry> {base_url: String::new(),model: String::new(),key: false,+ allow_insecure_http: false,request_timeout_s: DEFAULT_REQUEST_TIMEOUT_S,reasoning_effort: String::new(),problem: f.problem.clone(),@@ -364,6 +370,11 @@ fn local_authority(authority: &str) -> bool {port_ok && matches!(host, "localhost" | "127.0.0.1" | "[::1]")}+/// The default key policy, with explicit consent for this endpoint's plain HTTP connection.+pub fn key_allowed_for(url: &str, allow_insecure_http: bool) -> bool {+ key_safe_for(url) || (allow_insecure_http && url.trim().to_ascii_lowercase().starts_with("http://"))+}+/// A base URL the API backend accepts: `http(s)://host…`, without a trailing slash.pub fn normalize_url(url: &str) -> Result<String, String> {let u = url.trim().trim_end_matches('/').to_string();@@ -441,6 +452,23 @@ mod tests {}}+ #[test]+ fn http_key_consent_defaults_off_and_only_relaxes_http_for_that_entry() {+ let old: AgentConfig = serde_json::from_value(serde_json::json!({+ "id":"private", "kind":"api", "base_url":"http://192.168.1.100:8000/v1", "key":true+ }))+ .unwrap();+ assert!(!old.allow_insecure_http);+ assert!(!key_allowed_for(&old.base_url, Entry::from_config(&old).allow_insecure_http));+ let opted_in = AgentConfig { allow_insecure_http: true, ..old.clone() };+ let loaded: AgentConfig = serde_json::from_str(&serde_json::to_string(&opted_in).unwrap()).unwrap();+ assert!(key_allowed_for(&loaded.base_url, Entry::from_config(&loaded).allow_insecure_http));+ assert!(!key_allowed_for(&old.base_url, Entry::from_config(&old).allow_insecure_http));+ assert!(!key_allowed_for("ftp://192.168.1.100", true));+ let anthropic = AgentConfig { kind: Kind::Anthropic, ..opted_in };+ assert!(!key_allowed_for(&anthropic.base_url, Entry::from_config(&anthropic).allow_insecure_http));+ }+#[test]fn modes_and_ids_round_trip() {for m in Mode::ALL {diff --git a/crates/ui-egui/src/agent_chat/api_client.rs b/crates/ui-egui/src/agent_chat/api_client.rsindex 72be573306..51a00be8ba 100644--- a/crates/ui-egui/src/agent_chat/api_client.rs+++ b/crates/ui-egui/src/agent_chat/api_client.rs@@ -643,6 +643,7 @@ pub struct ApiConfig {pub base_url: String,pub model: String,pub key: Option<String>,+ pub allow_insecure_http: bool,pub http: HttpFn,/// How long one model request may take, in seconds (the endpoint's setting).pub request_timeout_s: u64,@@ -670,7 +671,7 @@ pub struct ApiBackend {impl ApiBackend {pub fn start(cfg: ApiConfig, ctx: StartContext) -> Result<ApiBackend, String> {- if cfg.key.is_some() && !super::agents::key_safe_for(&cfg.base_url) {+ if cfg.key.is_some() && !super::agents::key_allowed_for(&cfg.base_url, cfg.protocol == Protocol::OpenAi && cfg.allow_insecure_http) {return Err(crate::i18n::tr("ui.ai_key_needs_https").to_string());}// One stable session ID per chat for OpenCode Go's routing and prompt cache.@@ -856,7 +857,7 @@ impl Worker {/// The endpoint's models, in the shape its protocol lists them.fn model_list(&self) -> Result<Vec<ModelInfo>, String> {match self.cfg.protocol {- Protocol::OpenAi => model_list(&self.cfg.http, &self.cfg.base_url, self.cfg.key.as_deref()),+ Protocol::OpenAi => model_list(&self.cfg.http, &self.cfg.base_url, self.cfg.key.as_deref(), self.cfg.allow_insecure_http),Protocol::Anthropic => anthropic_model_list(&self.cfg.http, &self.cfg.base_url, self.cfg.key.as_deref()),}}@@ -1766,10 +1767,10 @@ fn model_entries(http: &HttpFn, base_url: &str, headers: Vec<(String, String)>)}/// The endpoint's models for the picker.-pub fn model_list(http: &HttpFn, base_url: &str, key: Option<&str>) -> Result<Vec<ModelInfo>, String> {+pub fn model_list(http: &HttpFn, base_url: &str, key: Option<&str>, allow_insecure_http: bool) -> Result<Vec<ModelInfo>, String> {let mut headers = Vec::new();if let Some(k) = key {- if !super::agents::key_safe_for(base_url) {+ if !super::agents::key_allowed_for(base_url, allow_insecure_http) {return Err(crate::i18n::tr("ui.ai_key_needs_https").to_string());}headers.push(("Authorization".to_string(), format!("Bearer {k}")));@@ -1778,10 +1779,10 @@ pub fn model_list(http: &HttpFn, base_url: &str, key: Option<&str>) -> Result<Ve}/// Ask an endpoint for its models (Test connection): how many, and whether `model` is one.-pub fn test_endpoint(http: &HttpFn, base_url: &str, key: Option<&str>, model: &str) -> Result<String, String> {+pub fn test_endpoint(http: &HttpFn, base_url: &str, key: Option<&str>, model: &str, allow_insecure_http: bool) -> Result<String, String> {let mut headers = Vec::new();if let Some(k) = key {- if !super::agents::key_safe_for(base_url) {+ if !super::agents::key_allowed_for(base_url, allow_insecure_http) {return Err(crate::i18n::tr("ui.ai_key_needs_https").to_string());}headers.push(("Authorization".to_string(), format!("Bearer {k}")));@@ -1920,6 +1921,7 @@ mod tests {protocol: Protocol::OpenAi,base_url: "http://localhost:1/v1".into(),model: "m".into(),+ allow_insecure_http: false,key: None,http,request_timeout_s: 300,@@ -1971,6 +1973,7 @@ mod tests {protocol: Protocol::OpenAi,base_url: "http://localhost:1/v1".into(),model: "m".into(),+ allow_insecure_http: false,key: None,http,request_timeout_s: 300,@@ -2026,6 +2029,7 @@ mod tests {protocol: Protocol::OpenAi,base_url: "http://localhost:1/v1".into(),model: "m".into(),+ allow_insecure_http: false,key: None,http,request_timeout_s: 300,@@ -2077,6 +2081,7 @@ mod tests {protocol: Protocol::OpenAi,base_url: "http://localhost:1/v1".into(),model: "local".into(),+ allow_insecure_http: false,key: None,http,request_timeout_s: 300,@@ -2162,6 +2167,7 @@ mod tests {protocol: Protocol::OpenAi,base_url: "https://opencode.ai/inference/go/v1".into(),model: model.into(),+ allow_insecure_http: false,key: None,http,request_timeout_s: 300,@@ -2236,6 +2242,7 @@ mod tests {protocol: Protocol::OpenAi,base_url: "https://api.openai.com/v1".into(),model: "muse-spark-1.3-contributor".into(),+ allow_insecure_http: false,key: None,http,request_timeout_s: 300,@@ -2402,7 +2409,7 @@ mod tests {log.lock().unwrap().push(r.clone());Ok((200, b"{\"data\":[{\"id\":\"kimi-k3\"}]}".to_vec()))});- let listed = model_list(&http, "https://opencode.ai/inference/go/v1", None).unwrap();+ let listed = model_list(&http, "https://opencode.ai/inference/go/v1", None, false).unwrap();assert_eq!(listed.iter().map(|m| m.id.as_str()).collect::<Vec<_>>(), ["kimi-k3"]);let reqs = seen.lock().unwrap();assert_eq!(reqs.len(), 1);@@ -2555,6 +2562,7 @@ mod tests {protocol: Protocol::OpenAi,base_url: "http://localhost:1/v1".into(),model: "m".into(),+ allow_insecure_http: false,key: None,http,request_timeout_s: 300,@@ -2608,6 +2616,7 @@ mod tests {protocol: Protocol::OpenAi,base_url: "http://localhost:1/v1".into(),model: "local".into(),+ allow_insecure_http: false,key: None,http,request_timeout_s: 300,@@ -2646,7 +2655,7 @@ mod tests {data.extend((0..MODEL_LIST_CAP + 500).map(|i| json!({"id": format!("m{i}")})));let body = json!({"data": data}).to_string().into_bytes();let http: HttpFn = Arc::new(move |_: &HttpRequest| Ok((200, body.clone())));- let list = model_list(&http, "https://openrouter.ai/api/v1", None).unwrap();+ let list = model_list(&http, "https://openrouter.ai/api/v1", None, false).unwrap();assert_eq!(list.len(), MODEL_LIST_CAP);let [first, same, long, next] = &list[..4] else { panic!("{}", list.len()) };assert_eq!((first.id.as_str(), first.name.as_str(), first.description.as_str()), ("openai/gpt-x", "openai/gpt-x", "OpenAI: GPT X"));@@ -2659,7 +2668,7 @@ mod tests {assert_eq!(first.name, "openai/gpt-x");assert_eq!(same.name, "Same One");assert_eq!(long.name.chars().count(), MODEL_NAME_CAP);- assert!(test_endpoint(&http, "https://openrouter.ai/api/v1", None, "openai/gpt-x").unwrap().contains(&MODEL_LIST_CAP.to_string()));+ assert!(test_endpoint(&http, "https://openrouter.ai/api/v1", None, "openai/gpt-x", false).unwrap().contains(&MODEL_LIST_CAP.to_string()));}/// A 200 that is no model list (a web page where the endpoint should be) is an error, so the@@ -2668,13 +2677,13 @@ mod tests {fn an_answer_that_is_no_model_list_is_an_error() {let expected = crate::i18n::tr("ui.agent_chat_models_not_a_list").to_string();let page: HttpFn = Arc::new(|_: &HttpRequest| Ok((200, b"<!doctype html><html><body>Control UI</body></html>".to_vec())));- assert_eq!(model_list(&page, "http://localhost:18789/v1", None).unwrap_err(), expected);+ assert_eq!(model_list(&page, "http://localhost:18789/v1", None, false).unwrap_err(), expected);assert_eq!(anthropic_model_list(&page, "http://localhost:18789/v1", None).unwrap_err(), expected);- assert_eq!(test_endpoint(&page, "http://localhost:18789/v1", None, "").unwrap_err(), expected);+ assert_eq!(test_endpoint(&page, "http://localhost:18789/v1", None, "", false).unwrap_err(), expected);let object: HttpFn = Arc::new(|_: &HttpRequest| Ok((200, json!({"object": "list"}).to_string().into_bytes())));- assert_eq!(model_list(&object, "http://localhost:18789/v1", None).unwrap_err(), expected);+ assert_eq!(model_list(&object, "http://localhost:18789/v1", None, false).unwrap_err(), expected);let empty: HttpFn = Arc::new(|_: &HttpRequest| Ok((200, json!({"data": []}).to_string().into_bytes())));- assert!(model_list(&empty, "http://localhost:18789/v1", None).unwrap().is_empty());+ assert!(model_list(&empty, "http://localhost:18789/v1", None, false).unwrap().is_empty());}#[test]@@ -2709,6 +2718,7 @@ mod tests {protocol: Protocol::OpenAi,base_url: "http://localhost:1/v1".into(),model: "m".into(),+ allow_insecure_http: false,key: None,http,request_timeout_s: 300,@@ -2731,21 +2741,46 @@ mod tests {}#[test]- fn keys_never_go_over_plain_http_to_another_computer() {- let http: HttpFn = Arc::new(|_: &HttpRequest| Ok((200, b"{}".to_vec())));- assert!(test_endpoint(&http, "http://10.0.0.2:11434/v1", Some("k"), "m").is_err());- let cfg = ApiConfig {+ fn http_authentication_needs_opt_in_for_tests_models_and_chat() {+ let seen = Arc::new(std::sync::Mutex::new(Vec::<HttpRequest>::new()));+ let requests = seen.clone();+ let http: HttpFn = Arc::new(move |r: &HttpRequest| {+ requests.lock().unwrap().push(r.clone());+ let body = if r.method == "GET" {+ json!({"data":[{"id":"m"}]})+ } else {+ json!({"choices":[{"message":{"role":"assistant","content":"Done."}}]})+ };+ Ok((200, body.to_string().into_bytes()))+ });+ assert!(test_endpoint(&http, "http://10.0.0.2:11434/v1", Some("k"), "m", false).is_err());+ assert!(model_list(&http, "http://10.0.0.2:11434/v1", Some("k"), false).is_err());+ let config = |allow_insecure_http, protocol| ApiConfig {name: "x".into(),- protocol: Protocol::OpenAi,+ protocol,base_url: "http://10.0.0.2/v1".into(),model: "m".into(),+ allow_insecure_http,key: Some("k".into()),- http,+ http: http.clone(),request_timeout_s: 300,reasoning_effort: String::new(),};- let ctx = StartContext { cwd: std::env::temp_dir(), bridge: None, tools: None, wake: Box::new(|| {}) };- assert!(ApiBackend::start(cfg, ctx).is_err());+ let context = || StartContext { cwd: std::env::temp_dir(), bridge: None, tools: None, wake: Box::new(|| {}) };+ assert!(ApiBackend::start(config(false, Protocol::OpenAi), context()).is_err());+ assert!(ApiBackend::start(config(true, Protocol::Anthropic), context()).is_err());+ assert!(seen.lock().unwrap().is_empty(), "refusal must happen before any HTTP request");+ assert!(test_endpoint(&http, "http://10.0.0.2/v1", Some("k"), "m", true).is_ok());+ assert_eq!(model_list(&http, "http://10.0.0.2/v1", Some("k"), true).unwrap()[0].id, "m");+ let mut backend = ApiBackend::start(config(true, Protocol::OpenAi), context()).unwrap();+ backend.prompt(&[PromptPart::Text("hello".into())]);+ let events = wait_for_turn(&mut backend);+ assert!(events.iter().any(|e| matches!(e, Event::Text { text, .. } if text == "Done.")), "{events:?}");+ backend.shutdown(true);+ let sent = seen.lock().unwrap();+ assert!(sent.iter().any(|r| r.url == "http://10.0.0.2/v1/chat/completions" && r.method == "POST"));+ assert!(sent.iter().filter(|r| r.url.ends_with("/models")).count() >= 3);+ assert!(sent.iter().all(|r| r.headers.iter().any(|(name, value)| name == "Authorization" && value == "Bearer k")));}/// A worker with one function tool whose endpoint answers each POST with the next scripted@@ -2769,6 +2804,7 @@ mod tests {protocol: Protocol::OpenAi,base_url: "http://localhost:1/v1".into(),model: "m".into(),+ allow_insecure_http: false,key: Some("sk-secret".into()),http,request_timeout_s: 300,@@ -2935,6 +2971,7 @@ mod tests {protocol: Protocol::Anthropic,base_url: "http://localhost:1".into(),model: "m".into(),+ allow_insecure_http: false,key: Some("sk-secret".into()),http,request_timeout_s: 300,@@ -2985,6 +3022,7 @@ mod tests {protocol: Protocol::Anthropic,base_url: "http://localhost:1".into(),model: "m".into(),+ allow_insecure_http: false,key: Some("sk-secret".into()),http,request_timeout_s: 300,@@ -3036,6 +3074,7 @@ mod tests {protocol: Protocol::Anthropic,base_url: "http://localhost:1".into(),model: "m".into(),+ allow_insecure_http: false,key: Some("sk-secret".into()),http,request_timeout_s: 300,diff --git a/crates/ui-egui/src/agent_chat/mod.rs b/crates/ui-egui/src/agent_chat/mod.rsindex 2dbf03d49a..e447efe087 100644--- a/crates/ui-egui/src/agent_chat/mod.rs+++ b/crates/ui-egui/src/agent_chat/mod.rs@@ -496,6 +496,14 @@ impl AgentChat {}}+ pub(crate) fn disconnect_endpoint(&mut self, session: &mut solidcraft_engine::Session, id: &str) {+ #[cfg(not(target_arch = "wasm32"))]+ settings::forget_card_listing(&mut self.settings, id);+ if self.running_id == id {+ self.disconnect_document(session, false);+ }+ }+fn clear_config(&mut self) {if self.config_options.take().is_some() {self.models.clear();@@ -1029,6 +1037,7 @@ pub fn connect(app: &mut SolveApp, ctx: &egui::Context) {base_url: entry.base_url.clone(),model: entry.model.clone(),key,+ allow_insecure_http: entry.allow_insecure_http,http,request_timeout_s: entry.request_timeout_s,reasoning_effort: entry.reasoning_effort.clone(),@@ -1118,6 +1127,16 @@ pub fn disconnect(app: &mut SolveApp) {app.agent_chat.disconnect_document(&mut app.session, false);}+/// Revoking an endpoint's HTTP consent also stops its conversations in other document tabs.+pub(super) fn disconnect_endpoint(app: &mut SolveApp, id: &str) {+ #[cfg(not(target_arch = "wasm32"))]+ settings::forget_card_listing(&mut app.agent_chat.settings, id);+ if app.agent_chat.running_id == id {+ disconnect(app);+ }+ crate::documents::disconnect_background_endpoint(app, id);+}+/// The app is quitting: end the agent and its helpers before the window goes.pub fn shutdown(app: &mut SolveApp) {app.agent_chat.disconnect_document(&mut app.session, true);@@ -2405,6 +2424,10 @@ pub fn control(app: &mut SolveApp, ctx: &egui::Context, p: &Value) -> Result<Valc.id = agents::new_id(&app.preferences, if c.kind.is_api() { c.kind.id() } else { "custom" });}c.key = false;+ c.allow_insecure_http &= c.kind == agents::Kind::Api;+ if !c.allow_insecure_http && app.preferences.agents.iter().any(|old| old.id == c.id && old.allow_insecure_http) {+ disconnect_endpoint(app, &c.id);+ }app.preferences.agents.retain(|x| x.id != c.id);app.preferences.agents.push(c);}diff --git a/crates/ui-egui/src/agent_chat/settings.rs b/crates/ui-egui/src/agent_chat/settings.rsindex 5cfbfd63de..13b43e6024 100644--- a/crates/ui-egui/src/agent_chat/settings.rs+++ b/crates/ui-egui/src/agent_chat/settings.rs@@ -38,6 +38,9 @@ pub struct AddState {pub editing: Option<String>,/// Editing an endpoint whose key is in the keychain: an empty key field keeps it.pub saved_key: bool,+ /// Consent belongs to the normalized URL, never to a different endpoint typed later.+ insecure_http_url: Option<String>,+ confirm_insecure_http: Option<String>,test: Option<Test>,/// The endpoint the model picker lists: what the fields said when they were last left.listing: Option<ListingKey>,@@ -45,6 +48,17 @@ pub struct AddState {list_again: bool,}+impl AddState {+ fn insecure_http_endpoint(&self) -> Option<String> {+ let url = agents::normalize_url(&self.base_url).ok()?;+ (self.kind == AddKind::Api && self.protocol == Protocol::OpenAi && !agents::key_safe_for(&url)).then_some(url)+ }++ fn allow_insecure_http(&self) -> bool {+ self.insecure_http_url.as_ref().is_some_and(|url| self.insecure_http_endpoint().as_ref() == Some(url))+ }+}+/// A connection test running or done.pub enum Test {Running(std::sync::mpsc::Receiver<Result<String, TestError>>),@@ -94,17 +108,26 @@ pub struct State {card_listing: Option<(ListingKey, String)>,}-/// What an endpoint's models are listed by: its protocol, its base URL, and whether a key goes along.-type ListingKey = (Protocol, String, bool);+/// Forget requests queued with an endpoint's revoked permission, without touching a started listing.+#[cfg(not(target_arch = "wasm32"))]+pub(super) fn forget_card_listing(state: &mut State, id: &str) {+ if state.card_listing.as_ref().is_some_and(|(_, agent)| agent == id) {+ state.card_listing = None;+ }+}++/// What an endpoint's models are listed by: protocol, base URL, whether a key goes along, and HTTP consent.+type ListingKey = (Protocol, String, bool, bool);/// Most endpoints' listings kept.const ENDPOINT_LISTINGS_CAP: usize = 128;/// The listing of `base_url`, if that is an address. A key goes along only where it may be sent.-fn listing_key(protocol: Protocol, base_url: &str, with_key: bool) -> Option<ListingKey> {+fn listing_key(protocol: Protocol, base_url: &str, with_key: bool, allow_insecure_http: bool) -> Option<ListingKey> {let url = agents::normalize_url(base_url).ok().filter(|url| url.len() <= 4096)?;- let with_key = with_key && agents::key_safe_for(&url);- Some((protocol, url, with_key))+ let allow_insecure_http = protocol == Protocol::OpenAi && allow_insecure_http;+ let with_key = with_key && agents::key_allowed_for(&url, allow_insecure_http);+ Some((protocol, url, with_key, allow_insecure_http))}/// The models listed for `key`, and the note for under them: still listing, or why it could not.@@ -157,13 +180,13 @@ fn start_listing(app: &mut SolveApp, ctx: &egui::Context, key: ListingKey, secrereturn;};let (tx, rx) = std::sync::mpsc::channel();- let (protocol, url) = (key.0, key.1.clone());+ let (protocol, url, allow_insecure_http) = (key.0, key.1.clone(), key.3);let language = crate::i18n::language();let wake = ctx.clone();let spawned = std::thread::Builder::new().name("endpoint-models".into()).spawn(move || {let _language = crate::i18n::scope(language);let list = secret().and_then(|secret| match protocol {- Protocol::OpenAi => super::api_client::model_list(&http, &url, secret.as_deref()),+ Protocol::OpenAi => super::api_client::model_list(&http, &url, secret.as_deref(), allow_insecure_http),Protocol::Anthropic => super::api_client::anthropic_model_list(&http, &url, secret.as_deref()),});let _ = tx.send(list);@@ -208,7 +231,7 @@ fn list_for_dialog(app: &mut SolveApp, ctx: &egui::Context) {// Editing an agent whose key is kept: the listing goes with that key, read on its thread.let stored = s.editing.clone().filter(|_| s.saved_key && typed.is_none());if std::mem::take(&mut s.list_again) {- s.listing = listing_key(s.protocol, &s.base_url, typed.is_some() || stored.is_some());+ s.listing = listing_key(s.protocol, &s.base_url, typed.is_some() || stored.is_some(), s.allow_insecure_http());// Asked again: what failed may work now, with another key or the server back up.if let Some(key) = &s.listing&& listing_wants_retry(state.endpoint_models.get(key))@@ -350,6 +373,7 @@ pub fn open_edit(app: &mut SolveApp, id: &str) -> bool {s.base_url = c.base_url.clone();s.model = c.model.clone();s.saved_key = c.key;+ s.insecure_http_url = c.allow_insecure_http.then(|| c.base_url.clone());} else {s.kind = AddKind::Custom;s.command = c.command.clone();@@ -371,6 +395,8 @@ pub(super) fn choose_preset(s: &mut AddState, protocol: Protocol, index: usize)s.error = None;s.test = None;s.list_again = true;+ s.insecure_http_url = None;+ s.confirm_insecure_http = None;}/// Run a connection test in the background (it starts the agent briefly, or asks the endpoint@@ -388,8 +414,9 @@ fn start_test(app: &SolveApp, e: &agents::Entry, key: Option<String>) -> Test {Kind::Api => {let Some(http) = app.services.agent_http.clone() else { return Test::Done(Err(TestError::Other(tr("ui.ai_no_http").to_string()))) };let (url, model) = (e.base_url.clone(), e.model.clone());+ let allow_insecure_http = e.allow_insecure_http;std::thread::spawn(move || {- let _ = tx.send(super::api_client::test_endpoint(&http, &url, key.as_deref(), &model).map_err(TestError::Other));+ let _ = tx.send(super::api_client::test_endpoint(&http, &url, key.as_deref(), &model, allow_insecure_http).map_err(TestError::Other));});}Kind::Anthropic => {@@ -845,7 +872,7 @@ fn agents_section(app: &mut SolveApp, ui: &mut egui::Ui) {ui_kit::row(ui, tr("ui.ai_model"), |ui| {let chat = &mut app.agent_chat;let running = chat.running_id == entry.id && chat.backend.is_some();- let key = listing_key(protocol, &entry.base_url, entry.key);+ let key = listing_key(protocol, &entry.base_url, entry.key, entry.allow_insecure_http);let (models, note) = if running {(chat.models.as_slice(), chat.models_note.clone())} else if let Some(models) = chat.models_cache.get(&entry.base_url).filter(|models| !models.is_empty()) {@@ -992,6 +1019,32 @@ pub fn dialog(app: &mut SolveApp, ctx: &egui::Context) {if app.agent_chat.settings.add.is_none() {return;}+ if let Some(url) = app.agent_chat.settings.add.as_ref().and_then(|s| s.confirm_insecure_http.clone()) {+ let (closed, action) = ui_kit::Confirm::new(egui::Id::new("sc_ai_http_consent"), "status_warning", tr("ai.http.allow"))+ .tone(ui_kit::Tone::Warning)+ .actions(tr("ai.http.confirm"), tr("ui.cancel"), None)+ .selected(ui_kit::Action::Cancel)+ .detail(&url)+ .show(ctx, true, |ui| {+ ui_kit::text(ui, tr("ai.http.warning"), ui_kit::Text::Report("http_warning", false));+ });+ for (handle, target) in [("ai_add:http_accept", "dialog:ok"), ("ai_add:http_cancel", "dialog:cancel")] {+ if let Some(rect) = crate::scenario::rect_of(target) {+ crate::scenario::publish_handle(handle, rect.center());+ }+ }+ if let Some(s) = app.agent_chat.settings.add.as_mut() {+ if !closed && action == ui_kit::Action::Ok && s.insecure_http_endpoint().as_ref() == Some(&url) {+ s.insecure_http_url = Some(url);+ s.list_again = true;+ s.error = None;+ }+ if closed || action != ui_kit::Action::None {+ s.confirm_insecure_http = None;+ }+ }+ return;+ }#[cfg(not(target_arch = "wasm32"))]let found: Vec<agents::Entry> = agents::entries(app).into_iter().filter(|e| e.found).collect();#[cfg(target_arch = "wasm32")]@@ -1105,8 +1158,14 @@ pub fn dialog(app: &mut SolveApp, ctx: &egui::Context) {ui_kit::text_field(ui, &mut s.name, "");});ui_kit::row(ui, tr("ui.ai_base_url"), |ui| {- s.list_again |=- ui_kit::cell_editor(ui, egui::Id::new("sc_ai_add_url"), &mut s.base_url, tr("ui.ai_url_hint"), false).lost_focus();+ let r = ui_kit::cell_editor(ui, egui::Id::new("sc_ai_add_url"), &mut s.base_url, tr("ui.ai_url_hint"), false);+ s.list_again |= r.lost_focus();+ if r.changed() {+ s.insecure_http_url = None;+ s.confirm_insecure_http = None;+ s.listing = None;+ s.test = None;+ }});ui_kit::row(ui, tr("ui.ai_model"), |ui| {let (models, note) = listed_for(&app.agent_chat.settings.endpoint_models, s.listing.as_ref());@@ -1149,6 +1208,20 @@ pub fn dialog(app: &mut SolveApp, ctx: &egui::Context) {});});ui_kit::text(ui, tr(if has_keychain { "ui.ai_key_note" } else { "ui.ai_no_keychain" }), ui_kit::Text::Note("keychain"));+ if let Some(url) = s.insecure_http_endpoint() {+ let mut allow = s.allow_insecure_http();+ let r = ui_kit::checkbox(ui, tr("ai.http.allow"), &mut allow).on_hover_text(tr("ai.http.warning"));+ crate::scenario::publish_target("ai_add:allow_insecure_http", r.rect);+ if r.changed() {+ if allow {+ s.confirm_insecure_http = Some(url);+ } else {+ s.insecure_http_url = None;+ s.list_again = true;+ }+ s.test = None;+ }+ }if ui_kit::button(ui, tr("ui.ai_test"), ui_kit::Button::Normal).clicked() {test = true;}@@ -1159,6 +1232,9 @@ pub fn dialog(app: &mut SolveApp, ctx: &egui::Context) {ui_kit::text(ui, e, ui_kit::Text::Report("add_error", true));}});+ if app.agent_chat.settings.add.as_ref().is_some_and(|s| s.confirm_insecure_http.is_some()) {+ return;+ }if let Some(rect) = crate::scenario::rect_of("dialog:ok") {crate::scenario::publish_handle("ai_add:add", rect.center());}@@ -1181,18 +1257,22 @@ pub fn dialog(app: &mut SolveApp, ctx: &egui::Context) {base_url: url.clone().unwrap_or_default(),model: s.model.trim().to_string(),key: false,+ allow_insecure_http: s.allow_insecure_http(),request_timeout_s: s.request_timeout_s,reasoning_effort: agents::reasoning_effort(&s.reasoning_effort),problem: None,install: "",};// Editing with the key field left empty tests with the stored key, which is only ever- // sent where a saved key may go (HTTPS or this computer).+ // read after the endpoint's key policy has been checked.let key = Some(s.key.trim().to_string()).filter(|k| !k.is_empty()).or_else(|| {- let id = s.editing.as_deref().filter(|_| s.saved_key && url.as_deref().is_ok_and(agents::key_safe_for))?;+ let id = s.editing.as_deref().filter(|_| s.saved_key && agents::key_allowed_for(&e.base_url, e.allow_insecure_http))?;app.services.secrets.as_ref().and_then(|store| store.get(id).ok().flatten())});let result = match url {+ Ok(_) if (s.saved_key || key.is_some()) && !agents::key_allowed_for(&e.base_url, e.allow_insecure_http) => {+ Test::Done(Err(TestError::Other(tr("ui.ai_key_needs_https").to_string())))+ }Ok(_) => start_test(app, &e, key),Err(err) => Test::Done(Err(TestError::Other(err))),};@@ -1244,6 +1324,7 @@ fn add_agent(app: &mut SolveApp) -> Result<(), String> {c.kind = s.protocol.kind();c.ollama = s.protocol == Protocol::OpenAi && s.preset == 0;c.base_url = agents::normalize_url(&s.base_url)?;+ c.allow_insecure_http = s.allow_insecure_http();c.model = s.model.trim().to_string();c.request_timeout_s = s.request_timeout_s.clamp(agents::MIN_REQUEST_TIMEOUT_S, agents::MAX_REQUEST_TIMEOUT_S);c.reasoning_effort = agents::reasoning_effort(&s.reasoning_effort);@@ -1253,7 +1334,10 @@ fn add_agent(app: &mut SolveApp) -> Result<(), String> {key = Some(s.key.trim().to_string()).filter(|k| !k.is_empty());// Editing with the key field left empty keeps the stored key.let kept = key.is_none() && editing.is_some() && s.saved_key;- if (key.is_some() || kept) && !agents::key_safe_for(&c.base_url) {+ // Revoking consent keeps the key in the keychain, but disconnects the endpoint.+ // Subsequent edits to that disabled endpoint must still be possible.+ let same_endpoint = kept && editing.and_then(|at| app.preferences.agents.get(at)).is_some_and(|old| old.base_url == c.base_url);+ if (key.is_some() || (kept && !same_endpoint)) && !agents::key_allowed_for(&c.base_url, c.allow_insecure_http) {return Err(tr("ui.ai_key_needs_https").to_string());}c.key = kept;@@ -1278,6 +1362,7 @@ fn add_agent(app: &mut SolveApp) -> Result<(), String> {match app.preferences.agents.get_mut(at) {None => return Err(tr("ui.ai_edit_gone").to_string()),Some(old) => {+ let revoked = old.allow_insecure_http && !c.allow_insecure_http;// An endpoint edited into a program (or one whose key was dropped) leaves no key behind.if old.key&& !c.key@@ -1294,7 +1379,9 @@ fn add_agent(app: &mut SolveApp) -> Result<(), String> {app.agent_chat.login_results.remove(&id);// The running conversation takes a new timeout from its next request on; the rest// applies the next time the agent connects.- if app.agent_chat.running_id == id+ if revoked {+ super::disconnect_endpoint(app, &id);+ } else if app.agent_chat.running_id == id&& let Some(b) = app.agent_chat.backend.as_mut(){b.set_request_timeout(secs);@@ -1757,6 +1844,180 @@ mod card_tests {}}+ #[test]+ fn http_authentication_requires_consent_for_the_current_endpoint() {+ let mut h = Harness::new();+ h.call("ui.resize", json!({"width": 1600.0, "height": 1000.0}));+ h.app.home.open = false;+ h.app.preferences.ai_features = true;+ h.app.agent_chat.detection = Some(Default::default());+ let keys = std::sync::Arc::new(MemoryKeys::default());+ h.app.services.secrets = Some(keys.clone());+ open_add(&mut h.app);+ let s = h.app.agent_chat.settings.add.as_mut().unwrap();+ s.kind = AddKind::Api;+ s.name = "Private endpoint".into();+ s.base_url = "http://192.168.1.100:8000/v1".into();+ s.model = "example-model".into();+ s.key = "test-only-key".into();+ let seen = listing_http(&mut h);+ let requests = || seen.lock().unwrap().clone();+ assert!(add_agent(&mut h.app).is_err(), "HTTP authentication is off by default");+ list_settled(&mut h);+ assert_eq!(requests(), [("http://192.168.1.100:8000/v1/models".into(), false)]);+ h.step(&json!({"click":{"handle":"ai_add:allow_insecure_http"}})).unwrap();+ h.frames(3);+ h.step(&json!({"click":{"handle":"ai_add:http_cancel"}})).unwrap();+ assert!(add_agent(&mut h.app).is_err(), "cancel is not consent");+ assert!(keys.0.lock().unwrap().is_empty());+ list_settled(&mut h);+ assert!(requests().iter().all(|(_, with_key)| !with_key), "cancel must not authenticate a listing");+ h.frames(3);+ h.step(&json!({"click":{"handle":"ai_add:allow_insecure_http"}})).unwrap();+ h.frames(3);+ h.step(&json!({"click":{"handle":"ai_add:http_accept"}})).unwrap();+ list_settled(&mut h);+ assert_eq!(requests().last().cloned(), Some(("http://192.168.1.100:8000/v1/models".into(), true)), "consent applies to the model picker");+ h.step(&json!({"click":{"handle":"ai_add:add"}})).unwrap();+ assert!(h.app.agent_chat.settings.add.is_none());+ let saved = h.app.preferences.agents.last().unwrap();+ let json = serde_json::to_value(saved).unwrap();+ assert_eq!(json["allow_insecure_http"], true);+ assert!(!json.to_string().contains("test-only-key"));+ assert_eq!(keys.get(&saved.id).unwrap().as_deref(), Some("test-only-key"));+ let id = saved.id.clone();++ // The saved agent's picker uses its consent and keychain key too.+ h.app.agent_chat.settings.endpoint_models.clear();+ h.call("ui.prefs", json!({"open": "AI"}));+ h.frames(3);+ reveal_card_action(&mut h, &format!("prefs:ai_model:{id}")).unwrap();+ let before = requests().len();+ h.step(&json!({"click":{"handle":format!("prefs:ai_model:{id}")}})).unwrap();+ list_settled(&mut h);+ assert_eq!(requests().len(), before + 1);+ assert_eq!(requests().last().cloned(), Some(("http://192.168.1.100:8000/v1/models".into(), true)));+ h.step(&json!({"key":"Escape"})).unwrap();++ assert!(open_edit(&mut h.app, &id));+ assert!(h.app.agent_chat.settings.add.as_ref().unwrap().key.is_empty());+ list_settled(&mut h);+ h.app.agent_chat.settings.endpoint_models.clear();+ h.step(&json!({"click":{"handle":"ai_add:allow_insecure_http"}})).unwrap();+ list_settled(&mut h);+ assert_eq!(+ requests().last().cloned(),+ Some(("http://192.168.1.100:8000/v1/models".into(), false)),+ "revocation also refreshes the model picker without the key"+ );+ assert!(open_edit(&mut h.app, &id));+ h.frames(3);+ h.step(&json!({"click":{"handle":"dialog:Base URL"}})).unwrap();+ h.step(&json!({"key":"A", "ctrl":true})).unwrap();+ h.step(&json!({"text":"http://192.168.1.101:8000/v1"})).unwrap();+ assert!(!h.app.agent_chat.settings.add.as_ref().unwrap().allow_insecure_http());+ assert!(add_agent(&mut h.app).is_err(), "a changed URL needs its own consent");+ // Even changing back does not silently restore consent.+ h.app.agent_chat.settings.add.as_mut().unwrap().base_url = "http://192.168.1.100:8000/v1".into();+ assert!(!h.app.agent_chat.settings.add.as_ref().unwrap().allow_insecure_http());+ assert!(open_edit(&mut h.app, &id));+ choose_preset(h.app.agent_chat.settings.add.as_mut().unwrap(), Protocol::OpenAi, 0);+ assert!(!h.app.agent_chat.settings.add.as_ref().unwrap().allow_insecure_http());++ // Revoking consent retains the key, stops this endpoint in every tab, and leaves an+ // unrelated endpoint connected. All requests use a mock transport.+ h.app.services.agent_http = Some(std::sync::Arc::new(|_| Ok((200, br#"{"data":[]}"#.to_vec()))));+ h.app.agent_chat.agent_id = Some(id.clone());+ super::super::connect(&mut h.app, &h.ctx);+ assert!(h.app.agent_chat.backend.is_some());+ crate::documents::open_tab(&mut h.app, solidcraft_engine::Session::default()).unwrap();+ h.app.preferences.agents.push(AgentConfig {+ id: "unrelated".into(),+ kind: Kind::Api,+ base_url: "http://localhost:8000/v1".into(),+ model: "m".into(),+ ..Default::default()+ });+ h.app.agent_chat.agent_id = Some("unrelated".into());+ super::super::connect(&mut h.app, &h.ctx);+ assert!(h.app.agent_chat.backend.is_some());+ crate::documents::open_tab(&mut h.app, solidcraft_engine::Session::default()).unwrap();+ h.app.agent_chat.agent_id = Some(id.clone());+ super::super::connect(&mut h.app, &h.ctx);+ assert!(h.app.agent_chat.backend.is_some());+ assert!(open_edit(&mut h.app, &id));+ h.frames(3);+ h.step(&json!({"click":{"handle":"ai_add:allow_insecure_http"}})).unwrap();+ h.frames(3);+ h.step(&json!({"click":{"handle":"ai_add:add"}})).unwrap();+ assert!(!h.app.preferences.agents[0].allow_insecure_http);+ assert!(h.app.agent_chat.backend.is_none());+ assert_eq!(keys.get(&id).unwrap().as_deref(), Some("test-only-key"));+ super::super::connect(&mut h.app, &h.ctx);+ assert!(h.app.agent_chat.backend.is_none(), "reconnecting without consent refuses the stored key");+ crate::documents::switch(&mut h.app, 0);+ assert!(h.app.agent_chat.backend.is_none(), "the hidden conversation was stopped too");+ crate::documents::switch(&mut h.app, 1);+ assert!(h.app.agent_chat.backend.is_some(), "other endpoints keep their permission");+ super::super::disconnect(&mut h.app);+ }++ #[test]+ fn revoking_http_consent_discards_queued_listings_in_every_tab() {+ let mut h = Harness::new();+ let keys = std::sync::Arc::new(MemoryKeys::default());+ h.app.services.secrets = Some(keys.clone());+ let seen = listing_http(&mut h);+ keys.set("revoked", "test-only-key").unwrap();+ h.app.preferences.agents.push(AgentConfig {+ id: "revoked".into(),+ kind: Kind::Api,+ base_url: "http://revoked.example/v1".into(),+ model: "example-model".into(),+ key: true,+ allow_insecure_http: true,+ ..Default::default()+ });+ let queue = |state: &mut State, id: &str| {+ let key = listing_key(Protocol::OpenAi, &format!("http://{id}.example/v1"), true, true).unwrap();+ let (tx, rx) = std::sync::mpsc::channel();+ state.listing =+ Some(ModelListing { key: listing_key(Protocol::OpenAi, "https://already-started.example/v1", false, false).unwrap(), rx });+ state.card_listing = Some((key, id.into()));+ tx+ };+ let completion = queue(&mut h.app.agent_chat.settings, "revoked");+ // Main keeps picker state in the window when a different document becomes active.+ crate::documents::open_tab(&mut h.app, solidcraft_engine::Session::default()).unwrap();+ assert!(h.app.agent_chat.running_id.is_empty(), "listing does not require a conversation");+ assert!(open_edit(&mut h.app, "revoked"));+ h.app.agent_chat.settings.add.as_mut().unwrap().insecure_http_url = None;+ add_agent(&mut h.app).unwrap();+ h.app.agent_chat.settings.add = None;+ assert!(!h.app.preferences.agents[0].allow_insecure_http);+ assert_eq!(keys.get("revoked").unwrap().as_deref(), Some("test-only-key"));+ crate::documents::switch(&mut h.app, 0);+ assert!(h.app.agent_chat.settings.card_listing.is_none(), "the revoked queue cannot return with an earlier tab");+ assert!(h.app.agent_chat.settings.listing.is_some(), "an already-started listing stays intact");+ completion.send(Ok(Vec::new())).unwrap();+ poll_listing(&mut h.app, &h.ctx);+ assert!(h.app.agent_chat.settings.listing.is_none(), "no revoked request may dispatch after completion");+ assert!(seen.lock().unwrap().is_empty(), "revoked queues must not reach the transport");++ // The background endpoint cleanup also forgets a matching queue before checking running_id.+ for id in ["revoked", "unrelated"] {+ let mut chat = AgentChat::default();+ let _completion = queue(&mut chat.settings, id);+ chat.disconnect_endpoint(&mut solidcraft_engine::Session::default(), "revoked");+ assert_eq!(chat.settings.card_listing.is_some(), id == "unrelated");+ assert!(chat.settings.listing.is_some(), "started listings are preserved for {id}");+ }+ let _completion = queue(&mut h.app.agent_chat.settings, "unrelated");+ super::super::disconnect_endpoint(&mut h.app, "revoked");+ assert_eq!(h.app.agent_chat.settings.card_listing.as_ref().unwrap().1, "unrelated");+ assert!(h.app.agent_chat.settings.listing.is_some());+ }+/// Edit on an added agent reopens the dialog filled in; Save changes it in place, keeping its/// id, its permission override and its always-allowed tools (#9619).#[test]diff --git a/crates/ui-egui/src/documents.rs b/crates/ui-egui/src/documents.rsindex c59f39aafe..e6b4df799f 100644--- a/crates/ui-egui/src/documents.rs+++ b/crates/ui-egui/src/documents.rs@@ -662,6 +662,13 @@ pub(crate) fn disconnect_background_chats(app: &mut SolveApp, wait: bool) {}}+/// Stop only the hidden conversations whose endpoint permission was revoked.+pub(crate) fn disconnect_background_endpoint(app: &mut SolveApp, id: &str) {+ for slot in app.docs.background_mut() {+ slot.agent_chat.disconnect_endpoint(&mut slot.session, id);+ }+}+/// Close several tabs (Close Other Tabs, Close All Tabs; #3055): each with unsaved changes asks/// "save changes?" in turn, the others close; Cancel keeps the tabs not closed yet.pub fn close_many(app: &mut SolveApp, mut tabs: Vec<usize>) {diff --git a/docs/agent-chat.md b/docs/agent-chat.mdindex a39c0487bc..9e269104e0 100644--- a/docs/agent-chat.md+++ b/docs/agent-chat.md@@ -314,7 +314,7 @@ Grok Build also supports `XAI_API_KEY` for users who choose API authentication.and a pick becomes the model for its next connection. While it runs, a pick changes the chat'smodel at once.- The key goes into the system keychain (Keychain on macOS, Credential Manager on Windows, the- Secret Service on Linux) and is only ever sent over HTTPS or to this computer. **Test** asks an+ Secret Service on Linux). By default it is only sent over HTTPS or to this computer. **Test** asks anOpenAI-compatible endpoint for its models; an Anthropic-compatible one gets a short message,because not every such endpoint lists models (Qwen's has no model list). For these agentsSolidCraft runs the conversation itself, with the same tools, limits and questions as for a@@ -332,11 +332,20 @@ Grok Build also supports `XAI_API_KEY` for users who choose API authentication.**Edit** on an agent you added opens the same dialog filled with its name and command, or itsprotocol, endpoint, model and request timeout, and **Save** changes it in place: it keeps its id,its permission setting and the tools you always allow for it. A stored key is never shown: leave-the key field empty to keep it, or type a new one to replace it. A saved key still only goes to-HTTPS or this computer, so moving an endpoint with a key to a plain `http://` address elsewhere is-refused. The running conversation takes a new request timeout at once; a new command, endpoint+the key field empty to keep it, or type a new one to replace it. Moving an endpoint with a key to+a plain `http://` address elsewhere requires the confirmation described below. The running+conversation takes a new request timeout at once; a new command, endpointor model applies the next time the agent connects.+For a private or on-premises OpenAI-compatible endpoint that requires a key over HTTP, enable+**Allow insecure HTTP** in its Add/Edit dialog and confirm the displayed endpoint. This option is+off by default and applies only to that endpoint. The API key and conversation travel unencrypted:+anyone with access to the network may read or change them. Use it only on a network you trust.+The key remains in the system keychain. **Test**, model discovery and chat all use the same+permission; redirects are not followed. Changing the URL or preset clears consent and requires+confirmation again. Turning the option off keeps the stored key and disconnects that endpoint's+conversations, including those in other document tabs.+For Ollama, choosing a model checks its reported capabilities in the background. If itscapabilities list lacks `tools`, a warning below the model picker explains that the model canonly chat and suggests choosing one with tool support. Results are cached in memory per base URL anddiff --git a/docs/control-protocol.md b/docs/control-protocol.mdindex efdfdc223f..80f47756fe 100644--- a/docs/control-protocol.md+++ b/docs/control-protocol.md@@ -653,7 +653,7 @@ no box selection.| `engine.execute` → `browser.expand_all` | `path?`: occurrence ids; `component?`: id; omit both for the whole tree | Open every Browser row under that scope, including folders that start closed (Origin, Named Views, Features). Display only: not saved in the design, not an undo step. || `engine.execute` → `browser.collapse_all` | same | Close those rows. The design row stays open when the whole tree is collapsed. || `engine.execute` → `view.history_layout` | `width?`, `dock?`: `bottom`, `left`, `under_browser`, `collapsed?` | Resize/dock the history without opening a dialog or changing the design. Contents respond to measured width; browser-stacked history shares its width and splits the height at the remembered share (`browser_share`, half until the seam between the two cards is dragged). One folded header gives the expanded card the rest; two folded headers stay at the top. |-| `ui.agent_chat` | `features?`, `toolbar_button?`, `connect_at_start?` and `open_at_start?` (connect the agent started last, and open the panel, when SolidCraft starts; both off by default, never with `--control`), `instructions?` (the custom instructions every new chat's system note carries, Preferences → AI; at most 4000 characters are kept), `permissions?` (`ask`, `edits`, `all`), `add_agent?` ({`name`, `kind`: `acp`, `api` or `anthropic` (`api` is OpenAI-compatible, `anthropic` Anthropic-compatible), `command` or `base_url` + `model` + `request_timeout_s?` (seconds one model request may take, 300 by default, rounded and clamped to 30 to 3600)}; no keys), `add_dialog?` (`installed`, `custom`, `api`, `anthropic`, or `false` to close), `edit_dialog?` (the id of an agent you added: the same dialog filled with what it holds, as its **Edit** button opens it; the key is never shown), `default_agent?`, `agent?` (the conversation's agent, by id), `mode?` (the agent's own mode), `provider?` (which provider's group the model picker opens first, when the models come from several), `model?` (one of its models, or see below), `open?`, `side?` (`left`, `right`), `minimized?`, `popped?` (in its own window), `width?`, `picker?`, `refresh?`, `connect?`, `stop?`, `attach?`: a file's path (a picture, a text file or a CAD file, for the next message; CAD files are imported at once), `remove_file?` (index of a file on the next message), `send?`: text (files alone make a message too), `attach_view?`, `attach_selection?`, `pick?` (true: open the context picker), `permission?`: an option id or `"cancel"` (the newest question of the agent's own), `approve?`: true, false or `"always"` (the oldest request held for Allow/Deny), `cancel?` (Stop: the queue stays), `send_now?` (stop the running step, then send the queued messages), `remove_pending?` (index), `new_chat?` (clear the chat, new session), `undo?` (the last message's changes) | the chat's state: `features`, `agents` (found and added), `currentAgent`, `state` (off, starting, ready, busy, auth, exited, failed: the agent never got ready, and Connect reads Retry), `connectAtStart`, `openAtStart`, `instructions`, `lastAgent` (the agent started last), `popped`, `window` (its place and size), `agent`, `modes`, `mode`, `models`, `model`, `modelWarning` (the model capability warning text, or `null` when unknown or tool support is reported; checked asynchronously and never blocks sending), `turnWarning` (the latest completed turn's no-tool notice, otherwise `null`; cleared on the next turn or new chat), `providers` (`name` and `count` of each, empty with one provider), `provider` (the one listed), `authMethods`, `toolsPort`, `pid`, `waiting`, `turn`, `pending` (queued messages, with their `files`), `attachments` (the files on the next message, by name), `loading` (pictures still being read for it, by name), `stopped`, `detection` and the conversation (`items`). With `features` off only the settings apply. Desktop only; see [Agent chat](agent-chat.md) |+| `ui.agent_chat` | `features?`, `toolbar_button?`, `connect_at_start?` and `open_at_start?` (connect the agent started last, and open the panel, when SolidCraft starts; both off by default, never with `--control`), `instructions?` (the custom instructions every new chat's system note carries, Preferences → AI; at most 4000 characters are kept), `permissions?` (`ask`, `edits`, `all`), `add_agent?` ({`name`, `kind`: `acp`, `api` or `anthropic` (`api` is OpenAI-compatible, `anthropic` Anthropic-compatible), `command` or `base_url` + `model` + `request_timeout_s?` (seconds one model request may take, 300 by default, rounded and clamped to 30 to 3600), `allow_insecure_http?` (OpenAI-compatible endpoints only; false by default; explicitly permits sending the key over unencrypted HTTP to this endpoint, without opening a confirmation dialog)}; no keys), `add_dialog?` (`installed`, `custom`, `api`, `anthropic`, or `false` to close), `edit_dialog?` (the id of an agent you added: the same dialog filled with what it holds, as its **Edit** button opens it; the key is never shown), `default_agent?`, `agent?` (the conversation's agent, by id), `mode?` (the agent's own mode), `provider?` (which provider's group the model picker opens first, when the models come from several), `model?` (one of its models, or see below), `open?`, `side?` (`left`, `right`), `minimized?`, `popped?` (in its own window), `width?`, `picker?`, `refresh?`, `connect?`, `stop?`, `attach?`: a file's path (a picture, a text file or a CAD file, for the next message; CAD files are imported at once), `remove_file?` (index of a file on the next message), `send?`: text (files alone make a message too), `attach_view?`, `attach_selection?`, `pick?` (true: open the context picker), `permission?`: an option id or `"cancel"` (the newest question of the agent's own), `approve?`: true, false or `"always"` (the oldest request held for Allow/Deny), `cancel?` (Stop: the queue stays), `send_now?` (stop the running step, then send the queued messages), `remove_pending?` (index), `new_chat?` (clear the chat, new session), `undo?` (the last message's changes) | the chat's state: `features`, `agents` (found and added), `currentAgent`, `state` (off, starting, ready, busy, auth, exited, failed: the agent never got ready, and Connect reads Retry), `connectAtStart`, `openAtStart`, `instructions`, `lastAgent` (the agent started last), `popped`, `window` (its place and size), `agent`, `modes`, `mode`, `models`, `model`, `modelWarning` (the model capability warning text, or `null` when unknown or tool support is reported; checked asynchronously and never blocks sending), `turnWarning` (the latest completed turn's no-tool notice, otherwise `null`; cleared on the next turn or new chat), `providers` (`name` and `count` of each, empty with one provider), `provider` (the one listed), `authMethods`, `toolsPort`, `pid`, `waiting`, `turn`, `pending` (queued messages, with their `files`), `attachments` (the files on the next message, by name), `loading` (pictures still being read for it, by name), `stopped`, `detection` and the conversation (`items`). With `features` off only the settings apply. Desktop only; see [Agent chat](agent-chat.md) || `ui.resize` | `width`, `height` | || `app.quit` | `force?` (quit without asking about unsaved designs) | `quitting` (the window closes), `asking` (a "save changes?" prompt is open) |