From d373da1390848c8457bbb515d08f7a8d5bdb608f Mon Sep 17 00:00:00 2001 From: Steven Enamakel Date: Sat, 14 Nov 2026 12:24:34 +0000 Subject: [PATCH 01/13] feat(browser): add profile config for persistent chrome profiles Adds an optional profile field to BrowserConfig so the host can pin an absolute Chrome profile folder that survives restarts, keeping cookies and sign-ins. The value is host-controlled like executable and is redacted in Debug output. Auto-committed-on: cuttlefish Co-authored-by: Medulla --- crates/tinycomputer-bus/src/config/browser.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/crates/tinycomputer-bus/src/config/browser.rs b/crates/tinycomputer-bus/src/config/browser.rs index 6c217fd13..7267bfa3c 100644 --- a/crates/tinycomputer-bus/src/config/browser.rs +++ b/crates/tinycomputer-bus/src/config/browser.rs @@ -34,6 +34,12 @@ pub struct BrowserConfig { /// The Chrome or Chromium executable to launch, if the host selected one. #[serde(skip_serializing_if = "Option::is_none")] pub executable: Option, + /// The Chrome profile folder (an absolute path) the host keeps between + /// sessions, so cookies and sign-ins survive a restart. Host control, + /// like `executable`: under an egress policy a launch may name this + /// folder and no other. + #[serde(skip_serializing_if = "Option::is_none")] + pub profile: Option, /// The User-Agent sent by every launched browser, when set. #[serde(skip_serializing_if = "Option::is_none")] pub user_agent: Option, @@ -55,6 +61,7 @@ impl Default for BrowserConfig { fn default() -> Self { Self { executable: None, + profile: None, user_agent: None, args: Vec::new(), perception: BrowserPerception::default(), @@ -72,6 +79,7 @@ impl std::fmt::Debug for BrowserConfig { "executable", &self.executable.as_ref().map(|_| "[REDACTED]"), ) + .field("profile", &self.profile.as_ref().map(|_| "[REDACTED]")) .field( "user_agent", &self.user_agent.as_ref().map(|_| "[REDACTED]"), From e00d6a7e8b2451eb7f3179b5af14288e596cf041 Mon Sep 17 00:00:00 2001 From: Steven Enamakel Date: Sat, 14 Nov 2026 12:24:43 +0000 Subject: [PATCH 02/13] test(dispatch): add missing profile field to service test config The shared config fixture in the module service test now sets the browser profile to None, keeping the struct literal complete after the field was added to BrowserConfig. Auto-committed-on: cuttlefish Co-authored-by: Medulla --- crates/tinycomputer/src/tinybus_module/dispatch/service_tests.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/tinycomputer/src/tinybus_module/dispatch/service_tests.rs b/crates/tinycomputer/src/tinybus_module/dispatch/service_tests.rs index 7f9b1016e..114eb057e 100644 --- a/crates/tinycomputer/src/tinybus_module/dispatch/service_tests.rs +++ b/crates/tinycomputer/src/tinybus_module/dispatch/service_tests.rs @@ -13,6 +13,7 @@ fn module_service_consumes_shared_config_and_preserves_its_extensions() { let shared = ComputerConfig { browser: Some(BrowserConfig { executable: Some("/opt/chromium".into()), + profile: None, user_agent: None, args: vec!["--disable-gpu".into()], perception: BrowserPerception::Tree, From 6d1fc870995c9bc04795637c870fd1e8a2bd978a Mon Sep 17 00:00:00 2001 From: Steven Enamakel Date: Sat, 14 Nov 2026 12:24:59 +0000 Subject: [PATCH 03/13] test(browser): cover host profile launch and refusal cases Extend the launch tests to pass a HostBrowser config instead of a bare executable option, and add cases verifying that a host-configured profile launches under the enforced proxy with extensions disabled while requests naming an unconfigured profile are refused. Auto-committed-on: cuttlefish Co-authored-by: Medulla --- .../src/linked/linked_tests/launch_tests.rs | 98 +++++++++++++++++-- 1 file changed, 88 insertions(+), 10 deletions(-) diff --git a/crates/tinycomputer-browser/src/linked/linked_tests/launch_tests.rs b/crates/tinycomputer-browser/src/linked/linked_tests/launch_tests.rs index e8cebe517..e8583d684 100644 --- a/crates/tinycomputer-browser/src/linked/linked_tests/launch_tests.rs +++ b/crates/tinycomputer-browser/src/linked/linked_tests/launch_tests.rs @@ -1,7 +1,7 @@ //! Tests for browser launch command rewriting and policy refusal. #![allow(clippy::unwrap_used, clippy::expect_used, clippy::panic)] -use super::super::{AMBIENT_BROWSER_ENV, enforce_launch_with_config}; +use super::super::{AMBIENT_BROWSER_ENV, HostBrowser, enforce_launch_with_config}; use serde_json::json; #[test] @@ -11,7 +11,7 @@ fn enforced_launch_uses_only_the_host_proxy_and_network_containment_flags() { "http://127.0.0.1:39123", "session-secret", false, - None, + &HostBrowser::default(), ) .expect("enforced launch"); assert_eq!(launch["proxy"]["server"], "http://127.0.0.1:39123"); @@ -36,7 +36,7 @@ fn enforced_launch_refuses_external_cdp_and_caller_flags() { "http://127.0.0.1:39123", "session-secret", false, - None, + &HostBrowser::default(), ); assert!(cdp.is_err()); let args = enforce_launch_with_config( @@ -44,7 +44,7 @@ fn enforced_launch_refuses_external_cdp_and_caller_flags() { "http://127.0.0.1:39123", "session-secret", false, - None, + &HostBrowser::default(), ); assert!(args.is_err()); let executable = enforce_launch_with_config( @@ -52,7 +52,7 @@ fn enforced_launch_refuses_external_cdp_and_caller_flags() { "http://127.0.0.1:39123", "session-secret", false, - None, + &HostBrowser::default(), ); assert!(executable.is_err()); let ambient = enforce_launch_with_config( @@ -60,7 +60,7 @@ fn enforced_launch_refuses_external_cdp_and_caller_flags() { "http://127.0.0.1:39123", "session-secret", true, - None, + &HostBrowser::default(), ); assert!(ambient.is_err()); } @@ -92,7 +92,7 @@ fn enforced_launch_refuses_caller_plugins_extensions_and_init_scripts() { "http://127.0.0.1:39123", "session-secret", false, - None, + &HostBrowser::default(), ) .is_err(), "{field} was accepted" @@ -111,7 +111,7 @@ fn a_host_executable_launches_under_the_enforced_proxy() { "http://127.0.0.1:39123", "session-secret", false, - Some("/opt/host/chrome"), + &HostBrowser::executable("/opt/host/chrome"), ) .expect("host executable launches"); assert_eq!(launch["executablePath"], "/opt/host/chrome"); @@ -138,7 +138,10 @@ fn a_request_cannot_name_an_executable_the_host_did_not_configure() { "http://127.0.0.1:39123", "session-secret", false, - host, + &HostBrowser { + executable: host.map(str::to_owned), + profile: None, + }, ) .is_err(), "{requested} with host {host:?}" @@ -151,8 +154,83 @@ fn a_request_cannot_name_an_executable_the_host_did_not_configure() { "http://127.0.0.1:39123", "session-secret", true, - Some("/opt/host/chrome"), + &HostBrowser::executable("/opt/host/chrome"), ) .is_err() ); } + +fn host_profile() -> HostBrowser { + HostBrowser { + executable: Some("/opt/host/chrome".into()), + profile: Some("/srv/state/browser/profile".into()), + } +} + +/// The host's own profile folder keeps cookies and sign-ins between +/// sessions; it launches under the proxy with extensions off, so nothing +/// stored in the profile can install a proxy of its own. +#[test] +fn a_host_profile_launches_under_the_enforced_proxy_without_extensions() { + for command in [ + json!({"action":"launch"}), + json!({"action":"launch","profile":"/srv/state/browser/profile"}), + ] { + let launch = enforce_launch_with_config( + command.clone(), + "http://127.0.0.1:39123", + "session-secret", + false, + &host_profile(), + ) + .expect("host profile launches"); + let args = launch["args"].as_array().expect("args"); + assert!(args.contains(&json!("--disable-extensions")), "{command}"); + assert_eq!(launch["proxy"]["server"], "http://127.0.0.1:39123"); + // The profile is used only when the session asked for it: a session + // that named none still starts fresh. + assert_eq!(launch.get("profile"), command.get("profile")); + } +} + +#[test] +fn a_request_cannot_name_a_profile_the_host_did_not_configure() { + for (requested, host) in [ + (json!("/tmp/attacker-profile"), host_profile()), + (json!(7), host_profile()), + (json!("/srv/state/browser/profile"), HostBrowser::default()), + ( + json!("/srv/state/browser/profile"), + HostBrowser::executable("/opt/host/chrome"), + ), + ] { + assert!( + enforce_launch_with_config( + json!({"action":"launch","profile":requested}), + "http://127.0.0.1:39123", + "session-secret", + false, + &host, + ) + .is_err(), + "{requested} with host {:?}", + host.profile + ); + } + // The host profile does not lift the other refusals. + for field in ["storageState", "restore", "cdpUrl"] { + let mut command = json!({"action":"launch","profile":"/srv/state/browser/profile"}); + command[field] = json!("x"); + assert!( + enforce_launch_with_config( + command, + "http://127.0.0.1:39123", + "session-secret", + false, + &host_profile(), + ) + .is_err(), + "{field}" + ); + } +} From 768f975d38640e8cfe4234ae25cebcfa92786ea3 Mon Sep 17 00:00:00 2001 From: Steven Enamakel Date: Sat, 14 Nov 2026 12:25:44 +0000 Subject: [PATCH 04/13] feat(browser): add host-configured profile folder for enforced launches Enforced launches can now use a host-chosen profile folder so cookies and sign-ins persist between sessions, while still refusing any profile named by the browser call itself. Extensions stay disabled because one stored in the profile could set a proxy that outranks the enforced one. Auto-committed-on: cuttlefish Co-authored-by: Medulla --- .../src/linked/linked_tests.rs | 8 +-- crates/tinycomputer-browser/src/linked/mod.rs | 72 +++++++++++++++---- .../src/tinybus_module/dispatch/service.rs | 7 +- 3 files changed, 65 insertions(+), 22 deletions(-) diff --git a/crates/tinycomputer-browser/src/linked/linked_tests.rs b/crates/tinycomputer-browser/src/linked/linked_tests.rs index 3bf99e96e..169458c53 100644 --- a/crates/tinycomputer-browser/src/linked/linked_tests.rs +++ b/crates/tinycomputer-browser/src/linked/linked_tests.rs @@ -101,7 +101,7 @@ async fn a_closed_or_lost_browser_cannot_implicitly_launch_without_the_proxy() { proxy: None, proxy_session_id: "private-session-id".into(), proxy_password: "private-proxy-password".into(), - host_executable: None, + host: super::HostBrowser::default(), enforced_launch: true, }; let reply = engine @@ -124,7 +124,7 @@ async fn an_exited_enforced_browser_can_still_be_closed() { proxy: None, proxy_session_id: "private-session-id".into(), proxy_password: "private-proxy-password".into(), - host_executable: None, + host: super::HostBrowser::default(), enforced_launch: true, }; @@ -143,7 +143,7 @@ async fn enforced_browser_refuses_process_side_reads_with_a_url() { proxy: None, proxy_session_id: "private-session-id".into(), proxy_password: "private-proxy-password".into(), - host_executable: None, + host: super::HostBrowser::default(), enforced_launch: true, }; let reply = engine @@ -170,7 +170,7 @@ async fn enforced_browser_rechecks_liveness_after_waiting_for_engine_lock() { proxy: None, proxy_session_id: "private-session-id".into(), proxy_password: "private-proxy-password".into(), - host_executable: None, + host: super::HostBrowser::default(), enforced_launch: true, }; let serialized = ENGINE.lock().await; diff --git a/crates/tinycomputer-browser/src/linked/mod.rs b/crates/tinycomputer-browser/src/linked/mod.rs index 12e029d88..85becf837 100644 --- a/crates/tinycomputer-browser/src/linked/mod.rs +++ b/crates/tinycomputer-browser/src/linked/mod.rs @@ -30,7 +30,25 @@ pub struct AgentBrowser; #[derive(Clone)] pub struct EnforcedAgentBrowser { authorizer: Arc, - executable: Option, + host: HostBrowser, +} + +/// What the host, never a browser call, chooses for an enforced launch: the +/// Chrome binary and the profile folder kept between sessions. +#[derive(Debug, Clone, Default, PartialEq, Eq)] +pub(crate) struct HostBrowser { + pub(crate) executable: Option, + pub(crate) profile: Option, +} + +impl HostBrowser { + #[cfg(test)] + pub(crate) fn executable(executable: &str) -> Self { + Self { + executable: Some(executable.to_owned()), + profile: None, + } + } } impl std::fmt::Debug for EnforcedAgentBrowser { @@ -45,7 +63,7 @@ impl EnforcedAgentBrowser { pub fn new(authorizer: Arc) -> Self { Self { authorizer, - executable: None, + host: HostBrowser::default(), } } @@ -53,7 +71,18 @@ impl EnforcedAgentBrowser { /// control, like the proxy: a launch may repeat it but never name another. #[must_use] pub fn with_executable(mut self, executable: Option) -> Self { - self.executable = executable; + self.host.executable = executable; + self + } + + /// Let a launch use the host-configured profile folder, so cookies and + /// sign-ins survive between sessions. It is host control, like the + /// executable: a launch may name this folder but never another, and it + /// runs with extensions off, since an extension stored in the profile + /// could set a proxy that outranks the enforced one. + #[must_use] + pub fn with_profile(mut self, profile: Option) -> Self { + self.host.profile = profile; self } } @@ -66,7 +95,7 @@ impl Launcher for AgentBrowser { proxy: None, proxy_session_id: String::new(), proxy_password: String::new(), - host_executable: None, + host: HostBrowser::default(), enforced_launch: false, }) } @@ -75,7 +104,7 @@ impl Launcher for AgentBrowser { impl Launcher for EnforcedAgentBrowser { fn open(&self, session: &str) -> Box { let mut engine = enforced(self.authorizer.clone(), session); - engine.host_executable.clone_from(&self.executable); + engine.host.clone_from(&self.host); Box::new(engine) } } @@ -90,7 +119,7 @@ fn enforced(authorizer: Arc, session: &str) -> Linked { proxy: None, proxy_session_id: private_session_id(), proxy_password: private_session_id(), - host_executable: None, + host: HostBrowser::default(), enforced_launch: false, } } @@ -101,7 +130,7 @@ struct Linked { proxy: Option, proxy_session_id: String, proxy_password: String, - host_executable: Option, + host: HostBrowser, enforced_launch: bool, } @@ -144,7 +173,7 @@ impl Engine for Linked { command.clone(), &proxy.url(), &self.proxy_password, - self.host_executable.as_deref(), + &self.host, ) { Ok(command) => command, Err(reason) => return failure_reply(&command, reason), @@ -232,7 +261,7 @@ fn enforce_launch( command: Value, proxy: &str, proxy_password: &str, - host_executable: Option<&str>, + host: &HostBrowser, ) -> Result { let has_ambient_browser_config = command.get("action").and_then(Value::as_str) == Some("launch") @@ -242,7 +271,7 @@ fn enforce_launch( proxy, proxy_password, has_ambient_browser_config, - host_executable, + host, ) } @@ -251,8 +280,9 @@ fn enforce_launch_with_config( proxy: &str, proxy_password: &str, has_ambient_browser_config: bool, - host_executable: Option<&str>, + host: &HostBrowser, ) -> Result { + let host_executable = host.executable.as_deref(); if command.get("action").and_then(Value::as_str) != Some("launch") { return Ok(command); } @@ -261,7 +291,6 @@ fn enforce_launch_with_config( "cdpPort", "autoConnect", "provider", - "profile", "storageState", "restore", ] @@ -270,6 +299,13 @@ fn enforce_launch_with_config( { return Err("network policy refuses attached or externally managed browsers"); } + // Only the host chooses the profile folder, as it does the binary: a + // launch may name the host's own folder, or none for a fresh profile. + if let Some(requested) = command.get("profile") + && (host.profile.is_none() || requested.as_str() != host.profile.as_deref()) + { + return Err("network policy refuses a browser profile the host did not configure"); + } // Only the host chooses the binary. A launch may repeat the host's own // executable (hosts send it with each session) but not name another. if let Some(requested) = command.get("executablePath") @@ -309,12 +345,18 @@ fn enforce_launch_with_config( if let Some(executable) = host_executable { command["executablePath"] = json!(executable); } - command["args"] = json!([ + let mut args = vec![ "--disable-quic", "--disable-http2", "--host-resolver-rules=MAP * ~NOTFOUND, EXCLUDE 127.0.0.1", - "--force-webrtc-ip-handling-policy=disable_non_proxied_udp" - ]); + "--force-webrtc-ip-handling-policy=disable_non_proxied_udp", + ]; + // Chrome ranks an extension's proxy above the command line's, and a kept + // profile can carry installed extensions. + if command.get("profile").is_some() { + args.push("--disable-extensions"); + } + command["args"] = json!(args); Ok(command) } diff --git a/crates/tinycomputer/src/tinybus_module/dispatch/service.rs b/crates/tinycomputer/src/tinybus_module/dispatch/service.rs index 829437c31..d5322b46c 100644 --- a/crates/tinycomputer/src/tinybus_module/dispatch/service.rs +++ b/crates/tinycomputer/src/tinybus_module/dispatch/service.rs @@ -117,17 +117,18 @@ impl DesktopService { let egress = BrowserDefaults::egress_from_raw(config) .map_err(|error| TinyBusError::failed(error.to_string()))?; let browser = if let Some(egress) = &egress { - let executable = computer_config(config) + let host = computer_config(config) .map_err(|error| TinyBusError::failed(error.to_string()))? .browser - .and_then(|browser| browser.executable); + .unwrap_or_default(); Arc::new(Browser::new(Arc::new( EnforcedAgentBrowser::new(Arc::new(BusAuthorizer::new( connection.clone(), egress.policy_id.clone(), egress.generation, ))) - .with_executable(executable), + .with_executable(host.executable) + .with_profile(host.profile), ))) } else { Arc::new(Browser::new(Arc::new(AgentBrowser))) From 03be38e5bdf9abe5ee04513cd9e4b66f6b97beeb Mon Sep 17 00:00:00 2001 From: Steven Enamakel Date: Sat, 14 Nov 2026 12:26:04 +0000 Subject: [PATCH 05/13] test(browser): assert extension flag only for profiled launches The launch test now checks that --disable-extensions is present exactly when the command carries a profile, instead of requiring it unconditionally, so the assertion matches the intended behaviour for sessions that start without a named profile. Auto-committed-on: cuttlefish Co-authored-by: Medulla --- .../src/linked/linked_tests/launch_tests.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/tinycomputer-browser/src/linked/linked_tests/launch_tests.rs b/crates/tinycomputer-browser/src/linked/linked_tests/launch_tests.rs index e8583d684..07cae4a32 100644 --- a/crates/tinycomputer-browser/src/linked/linked_tests/launch_tests.rs +++ b/crates/tinycomputer-browser/src/linked/linked_tests/launch_tests.rs @@ -185,7 +185,11 @@ fn a_host_profile_launches_under_the_enforced_proxy_without_extensions() { ) .expect("host profile launches"); let args = launch["args"].as_array().expect("args"); - assert!(args.contains(&json!("--disable-extensions")), "{command}"); + assert_eq!( + args.contains(&json!("--disable-extensions")), + command.get("profile").is_some(), + "{command}" + ); assert_eq!(launch["proxy"]["server"], "http://127.0.0.1:39123"); // The profile is used only when the session asked for it: a session // that named none still starts fresh. From 152ae906a9689f3282868c63cc11c12c4cab9581 Mon Sep 17 00:00:00 2001 From: Steven Enamakel Date: Sat, 14 Nov 2026 12:26:16 +0000 Subject: [PATCH 06/13] test(config): cover browser profile redaction and parsing Extend the browser config tests to assert that the profile path is redacted in debug output and that a configured profile is accepted by egress validation and parsed into the config. Auto-committed-on: cuttlefish Co-authored-by: Medulla --- .../src/config/config_tests.rs | 2 ++ .../tinybus_module_tests/config_tests.rs | 20 +++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/crates/tinycomputer-bus/src/config/config_tests.rs b/crates/tinycomputer-bus/src/config/config_tests.rs index a11463371..0bb2f1b2f 100644 --- a/crates/tinycomputer-bus/src/config/config_tests.rs +++ b/crates/tinycomputer-bus/src/config/config_tests.rs @@ -86,6 +86,7 @@ fn browser_config_defaults_and_serializes_non_default_fields() { fn browser_config_debug_redacts_sensitive_values() { let config = BrowserConfig { executable: Some("/secret/chromium".into()), + profile: Some("/secret/profile".into()), user_agent: Some("private agent string".into()), args: vec!["--private-argument".into()], ..BrowserConfig::default() @@ -93,6 +94,7 @@ fn browser_config_debug_redacts_sensitive_values() { let debug = format!("{config:?}"); assert!(!debug.contains("/secret/chromium")); + assert!(!debug.contains("/secret/profile")); assert!(!debug.contains("private agent string")); assert!(!debug.contains("--private-argument")); assert!(debug.contains("args_count: 1")); diff --git a/crates/tinycomputer/src/tinybus_module/tinybus_module_tests/config_tests.rs b/crates/tinycomputer/src/tinybus_module/tinybus_module_tests/config_tests.rs index 31d933de8..e8601f20f 100644 --- a/crates/tinycomputer/src/tinybus_module/tinybus_module_tests/config_tests.rs +++ b/crates/tinycomputer/src/tinybus_module/tinybus_module_tests/config_tests.rs @@ -230,6 +230,26 @@ fn the_browser_configuration_is_read_or_refused() { }})) .is_ok() ); + // So does the host's kept profile folder: the enforced launcher lets a + // session use that folder and no other. + let with_profile = json!({"browser": { + "executable": "/usr/bin/chromium", + "profile": "/srv/state/browser/profile", + "egress": {"policy_id": "host-policy", "generation": 7} + }}); + assert!( + BrowserDefaults::egress_from_raw(&with_profile) + .unwrap() + .is_some() + ); + let parsed = serde_json::from_value::(json!({"browser": { + "profile": "/srv/state/browser/profile" + }})) + .unwrap(); + assert_eq!( + parsed.browser.unwrap().profile.as_deref(), + Some("/srv/state/browser/profile") + ); // Settling promptly and opening the browser early are on unless turned // off. let unset = BrowserDefaults::default(); From ce134ad5405a77f5faac5194a2ccdc775c427254 Mon Sep 17 00:00:00 2001 From: Steven Enamakel Date: Sat, 14 Nov 2026 12:26:33 +0000 Subject: [PATCH 07/13] docs(browser): document the kept profile and egress profile restriction Add the `profile` browser setting to the module and configuration docs, describing how a kept Chrome profile folder preserves cookies and sign-ins across restarts. Under `egress`, a launch may only name the host's configured profile and runs with extensions disabled, since an extension's proxy can outrank the command line's. Auto-committed-on: cuttlefish Co-authored-by: Medulla --- MODULE.md | 3 ++- crates/tinycomputer/src/tinybus_module/README.md | 2 +- docs/crates/tinycomputer/configuration.md | 7 ++++++- docs/technical/architecture.md | 1 + 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/MODULE.md b/MODULE.md index 918cba155..aafcdd1ba 100644 --- a/MODULE.md +++ b/MODULE.md @@ -75,7 +75,8 @@ is optional: base URL; and `rescue_route` (`api_key`, `provider`, `endpoint_url`, `sdk_name`) gives the rescuer a route and key of its own; - `browser`: how every browser launches — `executable` (the Chrome or - Chromium binary), `user_agent`, `args` (an array of launch arguments), + Chromium binary), `profile` (the profile folder kept between sessions, the + only one a launch may name under egress), `user_agent`, `args` (an array of launch arguments), `perception` (`sight`, the default, or `tree`: how a task reads a page), `settle` (`prompt`, the default, or `steady`: how long a page is let settle after an action), and `prelaunch` (a boolean, `true` by default: diff --git a/crates/tinycomputer/src/tinybus_module/README.md b/crates/tinycomputer/src/tinybus_module/README.md index 680722040..40264e496 100644 --- a/crates/tinycomputer/src/tinybus_module/README.md +++ b/crates/tinycomputer/src/tinybus_module/README.md @@ -57,7 +57,7 @@ The host-visible loader fields are decoded as `browser`, and `trace_path`. The planner's route types are the same public types used by the engine. The module adapter converts `trace_path` into `Desktop` settings and applies the typed browser defaults: `browser` sets how -every browser launches — `executable`, `user_agent`, `args`, a task's page +every browser launches — `executable`, the kept `profile`, `user_agent`, `args`, a task's page `perception`, how a page `settle`s after an action, and whether to `prelaunch` a planned browser task's browser. diff --git a/docs/crates/tinycomputer/configuration.md b/docs/crates/tinycomputer/configuration.md index 305cd89e1..f8ed30047 100644 --- a/docs/crates/tinycomputer/configuration.md +++ b/docs/crates/tinycomputer/configuration.md @@ -278,18 +278,23 @@ optional: | Key | What it does | |---|---| | `executable` | the Chrome or Chromium binary to launch, for when the platform's own discovery would not find one, for example a container with Chrome installed somewhere nonstandard | +| `profile` | the Chrome profile folder (an absolute path) the host keeps between sessions, so cookies and sign-ins survive a restart. It is not applied by itself: a session or task names it as its profile (`user_data_dir`, `browser_profile`), and one that names none starts fresh. With `egress` set it is the only profile a launch may name | | `user_agent` | the `User-Agent` every launched browser sends; booking sites turn away a browser that announces itself as headless | | `args` | extra launch arguments, as an array of strings | | `perception` | how a task reads a page: `sight` (the default) reads the rendered page as a person sees it, `tree` the accessibility tree alone ([`browser-sight.md`](../../technical/specs/browser-sight.md)) | | `settle` | how a task lets a page settle after an action before reading it again: `prompt` (the default) counts the network's 500 ms of quiet from the start, counting only requests that can change the page and for at most 1 s, and then waits only while the page is still changing (at most 400 ms), so an idle page is read again after about 0.6 s; `steady` waits for the network to go idle, at least about 1.1 s, then 400 ms more | | `prelaunch` | `true` (the default) opens a browser-only task's browser while `StartTask` plans it (a `task` with no `flow`), so the first step does not wait for the launch, and loads in it the one web address the task's text names, if it names one, so a first step that browses there does not wait for the page either; `false` opens it at the first step | -| `egress` | Host-private TinySecurity scope. When present, `policy_id` and `generation` are required; browser `args`, attached DevTools endpoints, caller-supplied launch flags, and any executable other than this section's `executable` are refused. The scope is never a browser or task argument. | +| `egress` | Host-private TinySecurity scope. When present, `policy_id` and `generation` are required; browser `args`, attached DevTools endpoints, caller-supplied launch flags, and any executable or profile other than this section's `executable` and `profile` are refused. The scope is never a browser or task argument. | The launch and attach options above apply only when `egress` is absent, except `executable`. With `egress` set, TinyComputer owns the launch arguments and launches the host's `executable` (or the discovered Chrome) with its proxy and resolver flags. A task `browser_executable` or session `executable` may repeat the host's path; any other is refused, as are attached DevTools endpoints. +Likewise a session's profile may only be this section's `profile` (or none, +for a fresh one), and a launch that uses it runs with `--disable-extensions`: +Chrome ranks an extension's proxy above the command line's, and a kept profile +can carry installed extensions. `storageState` and `restore` stay refused. With `egress`, every launched browser session uses a private, authenticated loopback proxy. TinyComputer parses each HTTP request, asks the authenticated diff --git a/docs/technical/architecture.md b/docs/technical/architecture.md index 5036b776a..f18dae823 100644 --- a/docs/technical/architecture.md +++ b/docs/technical/architecture.md @@ -227,6 +227,7 @@ configuration validates. | `jev` | object | decision provider (`type_safe`, `open_router`, `tiny_humans_open_router`, `open_jev`, `sage`), API key, optional model, approved endpoint, timeout, retries, `sdk_name` for the TinyHumans proxy, and `fast` for Sage | | `planner` | object | `api_key`, `provider` (`open_router` or `tiny_humans`), approved `endpoint_url`, `sdk_name`, and optional `model` for the planner, optional `rescue_route` giving the rescuer its own route and key, optional `rescue_model` for rescuing failed steps (`docs/technical/specs/task-rescue.md`), and optional `output_model` for shaping a finished task's answer (`docs/technical/specs/task-output.md`); absent means no planner, no rescues, and no output shapes | | `browser.executable` | string | the Chrome or Chromium binary to launch, when discovery would not find one | +| `browser.profile` | string | the profile folder kept between sessions; under egress the only profile a launch may name, and it launches with extensions off | | `cursor` | string or object | the agent's on-screen cursor for desktop and browser: a pace (`off`, `brisk`, `natural` (default), `calm`) or `{pace, overlay}` with the overlay helper's path ([spec](specs/virtual-cursor.md)) | Without `jev`, `ResolveIntent`, `RunGoal`, `RunFlow`, and task runs answer From b5623099c961840548ad8b1f8f072992607d0c08 Mon Sep 17 00:00:00 2001 From: Steven Enamakel Date: Sat, 14 Nov 2026 14:33:37 +0000 Subject: [PATCH 08/13] test(tinybus): cover profile gate for linked module sessions Adds static-link tests that open a session against the linked module with a host-configured profile and egress scope, checking that a session naming any other profile folder is refused while the host's own profile passes the gate. The contract version is bumped to 3.1 to reflect the new wire behaviour. Auto-committed-on: cuttlefish Co-authored-by: Medulla --- crates/tinycomputer-bus/src/version/mod.rs | 2 +- .../src/version/version_tests.rs | 2 +- .../src/tinybus_module/static_link_tests.rs | 59 +++++++++++++++++++ crates/tinycomputer/tests/public_api_tests.rs | 2 +- 4 files changed, 62 insertions(+), 3 deletions(-) diff --git a/crates/tinycomputer-bus/src/version/mod.rs b/crates/tinycomputer-bus/src/version/mod.rs index 7cb6ede70..25afa667b 100644 --- a/crates/tinycomputer-bus/src/version/mod.rs +++ b/crates/tinycomputer-bus/src/version/mod.rs @@ -8,7 +8,7 @@ //! release workflow bumps, which tracks the shipped artifact. /// The wire contract version this crate defines. -pub const CONTRACT_VERSION: (u32, u32) = (3, 0); +pub const CONTRACT_VERSION: (u32, u32) = (3, 1); /// Returns whether a host holding [`CONTRACT_VERSION`] can bind to a module /// reporting `module`. diff --git a/crates/tinycomputer-bus/src/version/version_tests.rs b/crates/tinycomputer-bus/src/version/version_tests.rs index d101323cf..89b74d7ab 100644 --- a/crates/tinycomputer-bus/src/version/version_tests.rs +++ b/crates/tinycomputer-bus/src/version/version_tests.rs @@ -6,7 +6,7 @@ use super::{CONTRACT_VERSION, binds, is_compatible}; #[test] fn the_shipped_contract_version_is_pinned() { - assert_eq!(CONTRACT_VERSION, (3, 0)); + assert_eq!(CONTRACT_VERSION, (3, 1)); } #[test] diff --git a/crates/tinycomputer/src/tinybus_module/static_link_tests.rs b/crates/tinycomputer/src/tinybus_module/static_link_tests.rs index eab01b44b..b7b28f3a3 100644 --- a/crates/tinycomputer/src/tinybus_module/static_link_tests.rs +++ b/crates/tinycomputer/src/tinybus_module/static_link_tests.rs @@ -21,3 +21,62 @@ async fn linked_module_is_admitted_by_the_module_host() { assert_eq!(host.list().len(), 1); broker_task.abort(); } + +/// Loads the linked module with an egress scope and the host's profile folder, +/// then opens a session asking for `user_data_dir`, returning the reply. +async fn open_with_profile(user_data_dir: &str) -> tinycomputer_bus::DesktopResponse { + use tinybus::Connection; + use tinycomputer_bus::{DesktopResponse, browser::names::methods, names}; + + let bus = MemoryBus::new(); + let broker = Broker::new(); + let broker_task = broker.spawn(bus.clone()); + let host = ModuleHost::new(broker); + host.attach_linked_with_config( + super::linked_module().expect("manifest is valid"), + serde_json::json!({"browser": { + "profile": "/srv/state/browser/profile", + "egress": {"policy_id": "host-policy", "generation": 7} + }}), + ) + .expect("linked tinycomputer is admitted"); + let client = Connection::connect(bus.connect().await.expect("transport")) + .await + .expect("client connection"); + let proxy = client + .proxy(names::INTERFACE, names::OBJECT_PATH, names::INTERFACE) + .expect("proxy"); + let reply: DesktopResponse = proxy + .call( + methods::OPEN_SESSION, + (serde_json::json!({"user_data_dir": user_data_dir}),), + ) + .await + .expect("the call reaches the module"); + broker_task.abort(); + reply +} + +#[tokio::test] +async fn a_session_may_not_name_a_profile_the_host_did_not_configure() { + let reply = open_with_profile("/tmp/some-other-profile").await; + assert!(!reply.ok, "another folder must be refused"); + let error = format!("{:?}", reply.error); + assert!( + error.contains("a browser profile the host did not configure"), + "unexpected error: {error}" + ); +} + +#[tokio::test] +async fn a_session_may_name_the_host_profile_through_the_enforced_launcher() { + // Without the host's `with_profile` wiring this launch is refused by the + // profile gate; with it the gate passes, and whatever happens next (no + // Chrome here, or a launch) is not the profile refusal. + let reply = open_with_profile("/srv/state/browser/profile").await; + let error = format!("{:?}", reply.error); + assert!( + !error.contains("a browser profile the host did not configure"), + "the host's own profile was refused: {error}" + ); +} diff --git a/crates/tinycomputer/tests/public_api_tests.rs b/crates/tinycomputer/tests/public_api_tests.rs index bb2cbf446..6dac0ac25 100644 --- a/crates/tinycomputer/tests/public_api_tests.rs +++ b/crates/tinycomputer/tests/public_api_tests.rs @@ -34,7 +34,7 @@ fn the_crate_re_exports_the_contract_rather_than_redefining_it() { #[test] fn the_shipped_contract_binds_to_itself() { assert!(is_compatible(CONTRACT_VERSION)); - assert_eq!(CONTRACT_VERSION, (3, 0)); + assert_eq!(CONTRACT_VERSION, (3, 1)); assert!(!is_compatible((2, 29))); assert!(!is_compatible((2, 25))); } From 997fa2ed73d0b13786500c28d02981f2337663b3 Mon Sep 17 00:00:00 2001 From: Steven Enamakel Date: Sat, 14 Nov 2026 14:33:42 +0000 Subject: [PATCH 09/13] docs(version): correct compatibility example in doc comment The doctest for is_compatible asserted that version 3.0 is compatible, which contradicts the current contract version of 3.1. The example now checks 3.1 as compatible and 3.0 as incompatible so the documentation matches the actual behaviour. Auto-committed-on: cuttlefish Co-authored-by: Medulla --- crates/tinycomputer-bus/src/version/mod.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/tinycomputer-bus/src/version/mod.rs b/crates/tinycomputer-bus/src/version/mod.rs index 25afa667b..44aad09cb 100644 --- a/crates/tinycomputer-bus/src/version/mod.rs +++ b/crates/tinycomputer-bus/src/version/mod.rs @@ -22,7 +22,8 @@ pub const CONTRACT_VERSION: (u32, u32) = (3, 1); /// ``` /// # use tinycomputer_bus::{is_compatible, CONTRACT_VERSION}; /// assert!(is_compatible(CONTRACT_VERSION)); -/// assert!(is_compatible((3, 0))); +/// assert!(is_compatible((3, 1))); +/// assert!(!is_compatible((3, 0))); /// assert!(!is_compatible((2, 29))); /// assert!(!is_compatible((1, 8))); /// ``` From acb4dddbe4c6dfb6e8ccd4aedc83e22c647882ee Mon Sep 17 00:00:00 2001 From: Steven Enamakel Date: Sat, 14 Nov 2026 14:33:50 +0000 Subject: [PATCH 10/13] test(version): update compatibility test for 3.1 minor bump The test now asserts that a 3.1 host binds to 3.1 and newer modules but not to 3.0, since the new optional browser.profile field is rejected as unknown by older modules. The contract spec documents the field and the launcher's profile folder restrictions. Auto-committed-on: cuttlefish Co-authored-by: Medulla --- crates/tinycomputer-bus/src/version/version_tests.rs | 5 ++++- docs/technical/specs/desktop-module-contract.md | 12 ++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/crates/tinycomputer-bus/src/version/version_tests.rs b/crates/tinycomputer-bus/src/version/version_tests.rs index 89b74d7ab..b134a5eab 100644 --- a/crates/tinycomputer-bus/src/version/version_tests.rs +++ b/crates/tinycomputer-bus/src/version/version_tests.rs @@ -16,8 +16,11 @@ fn the_contract_binds_to_itself() { #[test] fn a_newer_minor_on_the_module_side_binds() { - assert!(is_compatible((3, 0))); + assert!(is_compatible((3, 1))); assert!(is_compatible((3, 97))); + // 3.1 adds the optional `browser.profile` module configuration field. A + // 3.0 module rejects it as unknown, so a 3.1 host cannot bind to one. + assert!(!is_compatible((3, 0))); // The history below is the 2.x line, which 3.0 no longer binds at all. // 2.24 adds same-task flow-to-planner handoff to StartTask. // 2.22 adds optional host-held secret handles to StartTask and RunFlow. diff --git a/docs/technical/specs/desktop-module-contract.md b/docs/technical/specs/desktop-module-contract.md index 5b258dab6..36b907a1c 100644 --- a/docs/technical/specs/desktop-module-contract.md +++ b/docs/technical/specs/desktop-module-contract.md @@ -348,3 +348,15 @@ endpoints directly. `BrowserReleaseOutput` stay ordinary: they never carry the bytes. A screenshot reply's `OutputRef` does expose the output's id, size, SHA-256 digest, media type, and pixel dimensions in ordinary traffic. + +## Host browser profile (3.1) + +- `browser.profile` is a new optional field of the module's `browser` + configuration: the profile folder the host keeps between sessions. A 3.0 + module rejects it as an unknown field, so this is a minor bump and a 3.1 + host binds only to a 3.1 or newer module. +- The enforced launcher lets a session name that folder through + `user_data_dir`, or none, and refuses any other folder. A profiled launch + runs with `--disable-extensions`, because Chrome ranks an extension's proxy + above the command-line proxy. `storageState`, `restore`, and CDP attach + stay refused. From 518bfcc7115dc4daf08084ac6e6e3156eaa205fd Mon Sep 17 00:00:00 2001 From: Steven Enamakel Date: Sat, 14 Nov 2026 14:34:08 +0000 Subject: [PATCH 11/13] refactor(agentic): simplify trusted endpoint check Consolidate the early return and cfg-gated test branch into a single expression so the function has one exit point. Behaviour is unchanged. Auto-committed-on: cuttlefish Co-authored-by: Medulla --- crates/tinycomputer-engine/src/agentic/runtime.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/crates/tinycomputer-engine/src/agentic/runtime.rs b/crates/tinycomputer-engine/src/agentic/runtime.rs index e034459a5..f177ad85b 100644 --- a/crates/tinycomputer-engine/src/agentic/runtime.rs +++ b/crates/tinycomputer-engine/src/agentic/runtime.rs @@ -414,15 +414,11 @@ pub(super) const fn approved_endpoint(provider: JevProvider) -> &'static str { pub(super) fn trusted_endpoint(provider: JevProvider, endpoint: &str) -> bool { let approved = approved_endpoint(provider); // Sage's endpoint is its API root, so its trailing slash is optional. - if endpoint == approved - || (provider == JevProvider::Sage && endpoint == approved.trim_end_matches('/')) - { - return true; - } + let trusted = endpoint == approved + || (provider == JevProvider::Sage && endpoint == approved.trim_end_matches('/')); #[cfg(test)] - return endpoint.starts_with("http://127.0.0.1:"); - #[cfg(not(test))] - false + let trusted = trusted || endpoint.starts_with("http://127.0.0.1:"); + trusted } /// The HTTP client configuration for a Jev `request`: its provider's From c6ff1d741db0418723be46c6e703d26511a1b441 Mon Sep 17 00:00:00 2001 From: Steven Enamakel Date: Sat, 14 Nov 2026 14:36:00 +0000 Subject: [PATCH 12/13] test(tinybus): pin a nonexistent browser executable in static link tests The test helper now configures a browser executable path that cannot exist, so a permitted launch fails fast instead of searching for or starting a real Chrome on the host. Auto-committed-on: cuttlefish Co-authored-by: Medulla --- crates/tinycomputer/src/tinybus_module/static_link_tests.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crates/tinycomputer/src/tinybus_module/static_link_tests.rs b/crates/tinycomputer/src/tinybus_module/static_link_tests.rs index b7b28f3a3..968b9ada5 100644 --- a/crates/tinycomputer/src/tinybus_module/static_link_tests.rs +++ b/crates/tinycomputer/src/tinybus_module/static_link_tests.rs @@ -35,6 +35,9 @@ async fn open_with_profile(user_data_dir: &str) -> tinycomputer_bus::DesktopResp host.attach_linked_with_config( super::linked_module().expect("manifest is valid"), serde_json::json!({"browser": { + // A binary that cannot start, so a permitted launch fails fast + // instead of looking for or starting a real Chrome. + "executable": "/nonexistent/host-chrome", "profile": "/srv/state/browser/profile", "egress": {"policy_id": "host-policy", "generation": 7} }}), From 51c4653e4ea21defa79ff19a6cc5176aab2b6207 Mon Sep 17 00:00:00 2001 From: Steven Enamakel Date: Sat, 14 Nov 2026 14:56:10 +0000 Subject: [PATCH 13/13] docs(tinycomputer): clarify when the browser profile applies The browser configuration docs now state that the kept profile is used only when a session or task names it via user_data_dir or browser_profile, and that a launch naming none starts fresh. The egress section also notes that profile, like executable, remains permitted under egress. Auto-committed-on: cuttlefish Co-authored-by: Medulla --- MODULE.md | 8 +++++--- crates/tinycomputer/src/tinybus_module/README.md | 6 ++++-- docs/crates/tinycomputer/configuration.md | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/MODULE.md b/MODULE.md index aafcdd1ba..51206bb8a 100644 --- a/MODULE.md +++ b/MODULE.md @@ -75,13 +75,15 @@ is optional: base URL; and `rescue_route` (`api_key`, `provider`, `endpoint_url`, `sdk_name`) gives the rescuer a route and key of its own; - `browser`: how every browser launches — `executable` (the Chrome or - Chromium binary), `profile` (the profile folder kept between sessions, the - only one a launch may name under egress), `user_agent`, `args` (an array of launch arguments), + Chromium binary), `user_agent`, `args` (an array of launch arguments), `perception` (`sight`, the default, or `tree`: how a task reads a page), `settle` (`prompt`, the default, or `steady`: how long a page is let settle after an action), and `prelaunch` (a boolean, `true` by default: open a browser-only task's browser while it is planned, at the one web - address the task's text names, if it names one). + address the task's text names, if it names one). Its `profile` (the folder + kept between sessions, the only one a launch may name under egress) applies + only when a session or task names it as its profile (`user_data_dir` or + `browser_profile`); one that names none starts fresh. Configuration is delivered as sensitive host-control traffic and is never shown to monitors. diff --git a/crates/tinycomputer/src/tinybus_module/README.md b/crates/tinycomputer/src/tinybus_module/README.md index 40264e496..a2557ef2f 100644 --- a/crates/tinycomputer/src/tinybus_module/README.md +++ b/crates/tinycomputer/src/tinybus_module/README.md @@ -57,9 +57,11 @@ The host-visible loader fields are decoded as `browser`, and `trace_path`. The planner's route types are the same public types used by the engine. The module adapter converts `trace_path` into `Desktop` settings and applies the typed browser defaults: `browser` sets how -every browser launches — `executable`, the kept `profile`, `user_agent`, `args`, a task's page +every browser launches — `executable`, `user_agent`, `args`, a task's page `perception`, how a page `settle`s after an action, and whether to `prelaunch` -a planned browser task's browser. +a planned browser task's browser. The kept `profile` applies only when a +session or task names it as its profile (`user_data_dir` or +`browser_profile`); one that names none starts fresh. Setting `trace_sink` to an object with the unique `destination` supplied by `ModuleHost::prepare_host_callbacks` opts into the host's confidential diff --git a/docs/crates/tinycomputer/configuration.md b/docs/crates/tinycomputer/configuration.md index f8ed30047..0de535a96 100644 --- a/docs/crates/tinycomputer/configuration.md +++ b/docs/crates/tinycomputer/configuration.md @@ -287,7 +287,7 @@ optional: | `egress` | Host-private TinySecurity scope. When present, `policy_id` and `generation` are required; browser `args`, attached DevTools endpoints, caller-supplied launch flags, and any executable or profile other than this section's `executable` and `profile` are refused. The scope is never a browser or task argument. | The launch and attach options above apply only when `egress` is absent, except -`executable`. With `egress` set, TinyComputer owns the launch arguments and +`executable` and `profile`. With `egress` set, TinyComputer owns the launch arguments and launches the host's `executable` (or the discovered Chrome) with its proxy and resolver flags. A task `browser_executable` or session `executable` may repeat the host's path; any other is refused, as are attached DevTools endpoints.