Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
2e0e907
chore(vendor): bump tinycomputer submodule
senamakel Nov 15, 2026
06ac856
feat(config): add captcha provider setting for the computer module
senamakel Nov 15, 2026
cda9b84
feat(computer): add configurable captcha solver provider
senamakel Nov 15, 2026
18cd649
chore(core): inline captcha provider into debug log message
senamakel Nov 15, 2026
2ab9b5b
docs(jev): document captcha provider selection
senamakel Nov 15, 2026
0e93923
test(config): cover captcha provider persistence in computer settings
senamakel Nov 15, 2026
3da000d
fix(config): stop persisting captcha provider on computer settings up…
senamakel Nov 15, 2026
8771833
fix(agent): persist captcha_provider from computer settings updates
senamakel Nov 15, 2026
d57dae6
chore(vendor): bump tinycomputer submodule
senamakel Nov 15, 2026
8f963c5
chore(vendor): keep tinycomputer at main's pin until the v0.18.0 re-pin
senamakel Nov 15, 2026
1c638b5
chore(vendor): bump tinycomputer submodule
senamakel Nov 15, 2026
73812ed
chore(vendor): keep tinycomputer at main's pin until the v0.18.0 re-pin
senamakel Nov 15, 2026
0a496a9
chore(vendor): bump tinycomputer submodule
senamakel Nov 15, 2026
2ccc896
chore(vendor): bump tinycomputer submodule
senamakel Nov 15, 2026
a4e869b
chore(deps): bump tinycomputer to 0.18.0
senamakel Nov 15, 2026
3747022
test(registry): update tinycomputer release fixtures to 0.18.0
senamakel Nov 15, 2026
5189655
chore(deps): bump tinycomputer crates to 0.18.0
senamakel Nov 15, 2026
7ff4c32
chore(deps): bump tinycomputer-bus to 0.18.0
senamakel Nov 15, 2026
606ba8a
fix(about_app): disclose captcha image destinations in privacy catalog
senamakel Nov 15, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/openhuman-app/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions crates/openhuman-core/src/config/ops/computer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub struct ComputerSettingsPatch {
pub rescue_model: Option<String>,
pub max_rescues: Option<u32>,
pub captcha_solver: Option<bool>,
pub captcha_provider: Option<String>,
pub captcha_model: Option<String>,
pub max_captcha_attempts: Option<u32>,
}
Expand All @@ -38,6 +39,19 @@ fn parse_decision_model(raw: &str) -> Result<DecisionModel, String> {
}
}

/// The captcha solver's Jev provider in its wire spelling; empty restores
/// the default (`type_safe`).
fn parse_captcha_provider(raw: &str) -> Result<Option<String>, String> {
match raw.trim().to_ascii_lowercase().replace('-', "_").as_str() {
"" => Ok(None),
"type_safe" | "typesafe" => Ok(Some("type_safe".into())),
"surplus" => Ok(Some("surplus".into())),
other => Err(format!(
"Unsupported captcha provider '{other}'. Use type_safe or surplus"
)),
}
}

fn model_id(raw: String) -> Result<Option<String>, String> {
let value = raw.trim();
if value.is_empty() {
Expand Down Expand Up @@ -76,6 +90,9 @@ pub fn patched(
if let Some(enabled) = update.captcha_solver {
computer.captcha_solver = enabled;
}
if let Some(raw) = update.captcha_provider {
computer.captcha_provider = parse_captcha_provider(&raw)?;
}
if let Some(raw) = update.captcha_model {
computer.captcha_model = model_id(raw)?;
}
Expand All @@ -101,6 +118,7 @@ pub async fn apply_computer_settings(
rescue_model = ?config.computer.rescue_model,
max_rescues = ?config.computer.max_rescues,
captcha_solver = config.computer.captcha_solver,
captcha_provider = ?config.computer.captcha_provider,
captcha_model = ?config.computer.captcha_model,
max_captcha_attempts = ?config.computer.max_captcha_attempts,
"[config] computer settings updated"
Expand Down
40 changes: 40 additions & 0 deletions crates/openhuman-core/src/config/ops/computer_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,43 @@ fn patch_turns_the_captcha_solver_on_with_its_model_and_attempts() {
assert_eq!(next.max_captcha_attempts, Some(4));
assert!(!ComputerConfig::default().captcha_solver, "off by default");
}

#[test]
fn patch_selects_the_captcha_provider() {
let base = ComputerConfig::default();
for (raw, stored) in [
("surplus", Some("surplus")),
(" Surplus ", Some("surplus")),
("type_safe", Some("type_safe")),
("Type-Safe", Some("type_safe")),
("typesafe", Some("type_safe")),
(" ", None),
] {
let next = patched(
&base,
ComputerSettingsPatch {
captcha_provider: Some(raw.into()),
..ComputerSettingsPatch::default()
},
)
.unwrap();
assert_eq!(next.captcha_provider.as_deref(), stored, "{raw:?}");
}
}

#[test]
fn an_unknown_captcha_provider_is_refused_with_the_accepted_values() {
let error = patched(
&ComputerConfig::default(),
ComputerSettingsPatch {
captcha_provider: Some("open_router".into()),
..ComputerSettingsPatch::default()
},
)
.unwrap_err();
assert!(error.contains("open_router"), "{error}");
assert!(
error.contains("type_safe") && error.contains("surplus"),
"{error}"
);
}
12 changes: 9 additions & 3 deletions crates/openhuman-core/src/config/schema/computer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,17 @@ pub struct ComputerConfig {
/// `None` keeps the module's default (5, also its maximum).
pub max_rescues: Option<u32>,
/// Let a browser task try a captcha or "verify you are human" check with
/// Jev's image questions before it asks a person. Needs a TypeSafe key
/// (the `typesafe` credential or `TYPESAFE_API_KEY`). Off by default.
/// Jev's image questions before it asks a person. Needs a key for the
/// [`captcha_provider`](Self::captcha_provider): TypeSafe (the `typesafe`
/// credential or `TYPESAFE_API_KEY`) or Surplus (the `surplus` credential
/// or `SURPLUS_API_KEY`). Off by default.
pub captcha_solver: bool,
/// Where the captcha solver's Jev runs: `type_safe` (TypeSafe's own API)
/// or `surplus` (Surplus Intelligence). `None` means `type_safe`.
pub captcha_provider: Option<String>,
/// The image-reading Jev model the captcha solver asks. `None` keeps the
/// module's default (`jev-preview`).
/// module's default for the provider (`jev-preview` on TypeSafe,
/// `jev-1.14` on Surplus).
pub captcha_model: Option<String>,
/// Image challenges one try may submit before the task asks a person;
/// `None` keeps the module's default (3). At most 10.
Expand Down
12 changes: 12 additions & 0 deletions crates/openhuman-core/src/config/schema/computer_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,15 @@ fn parses_every_decision_model_and_rescue_settings() {
}
assert!(toml::from_str::<ComputerConfig>("decision_model = \"jet\"").is_err());
}

#[test]
fn the_captcha_provider_defaults_to_absent_and_round_trips() {
assert_eq!(ComputerConfig::default().captcha_provider, None);
let config: ComputerConfig =
toml::from_str("captcha_solver = true\ncaptcha_provider = \"surplus\"").unwrap();
assert_eq!(config.captcha_provider.as_deref(), Some("surplus"));
let saved = toml::to_string(&config).unwrap();
assert!(saved.contains("captcha_provider = \"surplus\""), "{saved}");
let reloaded: ComputerConfig = toml::from_str(&saved).unwrap();
assert_eq!(reloaded, config);
}
2 changes: 2 additions & 0 deletions crates/openhuman-core/src/config/schemas/controllers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ mod workspace;

pub use registry::{all_controller_schemas, all_registered_controllers};

#[cfg(test)]
use agent::handle_update_computer_settings;
#[cfg(test)]
pub(super) use agent::{handle_get_autonomy_settings, handle_update_autonomy_settings};
#[cfg(test)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ pub(super) fn handle_update_computer_settings(
rescue_model: update.rescue_model,
max_rescues: update.max_rescues,
captcha_solver: update.captcha_solver,
captcha_provider: update.captcha_provider,
captcha_model: update.captcha_model,
max_captcha_attempts: update.max_captcha_attempts,
};
Expand Down
25 changes: 25 additions & 0 deletions crates/openhuman-core/src/config/schemas/controllers_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,28 @@ async fn handle_get_data_paths_scopes_to_explicit_user_id() {
}

// ── platform slug validation (finding #6) ───────────────────

// ── update_computer_settings captcha provider ────────────────

#[tokio::test]
async fn update_computer_settings_saves_the_captcha_provider() {
let dir = tempfile::tempdir().unwrap();
let mut config = crate::config::Config::default();
config.config_path = dir.path().join("config.toml");
config.workspace_dir = dir.path().join("workspace");
let ctx = DispatchCtx::new(crate::core::runtime::CoreContext::for_inspection(config));
let mut params = Map::new();
params.insert("captcha_solver".into(), Value::Bool(true));
params.insert("captcha_provider".into(), Value::String("surplus".into()));
handle_update_computer_settings(ctx, params).await.unwrap();
let saved = std::fs::read_to_string(dir.path().join("config.toml")).unwrap();
assert!(saved.contains("captcha_provider = \"surplus\""), "{saved}");

let schema = super::super::schema_defs::schemas("update_computer_settings");
let field = schema
.inputs
.iter()
.find(|field| field.name == "captcha_provider")
.expect("captcha_provider schema input");
assert!(field.comment.contains("type_safe") && field.comment.contains("surplus"));
}
1 change: 1 addition & 0 deletions crates/openhuman-core/src/config/schemas/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ pub(super) struct ComputerSettingsUpdate {
pub(super) rescue_model: Option<String>,
pub(super) max_rescues: Option<u32>,
pub(super) captcha_solver: Option<bool>,
pub(super) captcha_provider: Option<String>,
pub(super) captcha_model: Option<String>,
pub(super) max_captcha_attempts: Option<u32>,
}
Expand Down
8 changes: 6 additions & 2 deletions crates/openhuman-core/src/config/schemas/schema_defs/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,15 @@ pub(super) fn lookup(function: &str) -> Option<ControllerSchema> {
),
optional_bool(
"captcha_solver",
"Let browser tasks try a captcha with Jev's image questions before asking a person; needs a TypeSafe key.",
"Let browser tasks try a captcha with Jev's image questions before asking a person; needs a key for the captcha provider.",
),
optional_string(
"captcha_provider",
"Captcha solver's Jev provider: type_safe (TYPESAFE_API_KEY) or surplus (SURPLUS_API_KEY); empty restores type_safe.",
),
optional_string(
"captcha_model",
"Image-reading Jev model for the captcha solver; empty restores the module default (jev-preview).",
"Image-reading Jev model for the captcha solver; empty restores the provider's default (jev-preview on type_safe, jev-1.14 on surplus).",
),
optional_number(
"max_captcha_attempts",
Expand Down
37 changes: 30 additions & 7 deletions crates/openhuman-core/src/modules/computer_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
//! TinyHumans proxy when signed in, else the user's OpenRouter key.
//! - `browser` — the Chrome executable the user picked, if any.
//! - `captcha` — the captcha solver's image-reading Jev route, on TypeSafe
//! with the user's TypeSafe key, when `[computer] captcha_solver` is on.
//! or Surplus (`[computer] captcha_provider`) with the user's key for it,
//! when `[computer] captcha_solver` is on.
//! - `trace_path` — where desktop commands are traced, when tracing is on.

#[cfg(unix)]
Expand Down Expand Up @@ -68,19 +69,41 @@ async fn jev(config: &Config, hosted: Option<&str>) -> Option<Value> {
}
}

/// The captcha solver's section: TypeSafe's own Jev route (the one that
/// takes images), the chosen image model and attempt bound. `None` when the
/// solver is off or there is no TypeSafe key.
/// The captcha solver's section: the chosen provider's Jev route (one that
/// takes images) with its key, the chosen image model and attempt bound.
/// `None` when the solver is off, the provider is unknown, or there is no key
/// for it.
async fn captcha(config: &Config) -> Option<Value> {
let computer = &config.computer;
if !computer.captcha_solver {
return None;
}
let Some(api_key) = provider_key(config, "typesafe", "TYPESAFE_API_KEY").await else {
tracing::debug!("[computer] captcha_solver is on but no TypeSafe key is configured");
let provider = computer
.captcha_provider
.as_deref()
.map(str::trim)
.filter(|provider| !provider.is_empty())
.unwrap_or("type_safe");
let (slug, env) = match provider {
"type_safe" => ("typesafe", "TYPESAFE_API_KEY"),
"surplus" => ("surplus", "SURPLUS_API_KEY"),
Comment thread
senamakel marked this conversation as resolved.
Resolved
other => {
tracing::warn!(
captcha_provider = other,
"[computer] captcha_solver is on but captcha_provider is unknown; use type_safe or surplus"
);
return None;
}
};
let Some(api_key) = provider_key(config, slug, env).await else {
tracing::debug!(
captcha_provider = provider,
"[computer] captcha_solver is on but no {provider} key is configured"
);
return None;
};
let mut jev = json!({ "api_key": api_key, "provider": "type_safe" });
tracing::debug!("[computer] captcha solver provider={provider}");
let mut jev = json!({ "api_key": api_key, "provider": provider });
if let Some(model) = computer
.captcha_model
.as_deref()
Expand Down
Loading
Loading