The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
feat(browser): add support for running a saved flow instead of planning from goal
Steven Enamakel8efa1eb8bb2e
diff --git a/crates/openhuman-core/src/modules/browser_task.rs b/crates/openhuman-core/src/modules/browser_task.rsindex 206d9ea171..0a89a6854d 100644--- a/crates/openhuman-core/src/modules/browser_task.rs+++ b/crates/openhuman-core/src/modules/browser_task.rs@@ -41,6 +41,9 @@ pub struct BrowserTask {pub origins: Vec<String>,/// Upper bound on the actions the task may take.pub max_actions: u32,+ /// A flow to run instead of having the module plan one from `goal`, such+ /// as a plan saved from an earlier run. `goal` then explains it.+ pub flow: Option<tinycomputer_bus::Flow>,}/// Build the `StartTask` request for a browser-only task under host policy.@@ -48,6 +51,7 @@ pub struct BrowserTask {pub fn start_request(config: &Config, task: &BrowserTask) -> StartTaskRequest {StartTaskRequest {task: Some(task.goal.clone()),+ flow: task.flow.clone(),facts: task.facts.clone(),constraints: TaskConstraints {payment: PaymentMode::StopAtPayment,@@ -81,6 +85,7 @@ pub async fn start(config: &Config, task: &BrowserTask) -> Result<TaskView, Stritracing::debug!(origins = task.origins.len(),max_actions = task.max_actions,+ saved_flow = task.flow.is_some(),"[browser-task] starting");let view: TaskView = call(config, methods::START_TASK, request, true).await?;diff --git a/crates/openhuman-core/src/modules/browser_task_tests.rs b/crates/openhuman-core/src/modules/browser_task_tests.rsindex f78085b80c..ccf1bceb0f 100644--- a/crates/openhuman-core/src/modules/browser_task_tests.rs+++ b/crates/openhuman-core/src/modules/browser_task_tests.rs@@ -7,6 +7,7 @@ fn task() -> BrowserTask {facts: BTreeMap::from([("name".into(), "Asha".into())]),origins: vec!["https://.example.com".into()],max_actions: 12,+ flow: None,}}@@ -66,3 +67,17 @@ fn unwrap_response_returns_data_or_the_structured_error() {.unwrap_err().contains("no result"));}++#[test]+fn a_saved_flow_is_run_instead_of_planned() {+ let flow: tinycomputer_bus::Flow = serde_json::from_value(serde_json::json!({+ "app": "browser",+ "steps": [{"browse": "https://www.example.com/"}, {"stop_before": "paying"}]+ }))+ .unwrap();+ let mut saved = task();+ saved.flow = Some(flow.clone());+ let request = start_request(&Config::default(), &saved);+ assert_eq!(request.flow, Some(flow));+ assert_eq!(request.task.as_deref(), Some("Find the opening hours"));+}diff --git a/crates/openhuman-core/src/tools/impl/browser/browser.rs b/crates/openhuman-core/src/tools/impl/browser/browser.rsindex 572299e371..287d12cece 100644--- a/crates/openhuman-core/src/tools/impl/browser/browser.rs+++ b/crates/openhuman-core/src/tools/impl/browser/browser.rs@@ -321,11 +321,19 @@ impl BrowserTool {None => self.client.task_origins(),};let facts = task_inputs(args)?;+ let flow = match args.get("flow").filter(|flow| !flow.is_null()) {+ Some(flow) => Some(+ serde_json::from_value::<tinycomputer_bus::Flow>(flow.clone())+ .map_err(|error| anyhow::anyhow!("Invalid flow: {error}"))?,+ ),+ None => None,+ };let task = crate::modules::browser_task::BrowserTask {goal,facts,origins,max_actions: u32::try_from(self.max_steps).unwrap_or(u32::MAX),+ flow,};let view = crate::modules::browser_task::start(self.client.config(), &task).await@@ -677,7 +685,7 @@ impl Tool for BrowserTool {fn parameters_schema(&self) -> Value {json!({"type":"object","properties":{"action":{"type":"string","enum":["open","snapshot","read_page","click","fill","type","get_text","get_title","get_url","wait","press","hover","scroll","is_visible","find","task","task_continue","task_cancel","confirm_pending","list_downloads","wait_download","close"]},- "url":{"type":"string","description":"Starting HTTPS URL for open or an optional starting URL for task"},"selector":{"type":"string"},"value":{"type":"string"},"text":{"type":"string"},"key":{"type":"string"},"direction":{"type":"string"},"pixels":{"type":"integer"},"ms":{"type":"integer"},"timeout_ms":{"type":"integer"},"interactive_only":{"type":"boolean"},"compact":{"type":"boolean"},"depth":{"type":"integer"},"by":{"type":"string"},"find_action":{"type":"string"},"fill_value":{"type":"string"},"goal":{"type":"string"},"inputs":{"type":"object","additionalProperties":{"type":"string"}},"task_id":{"type":"string","description":"Task id returned by task, for task_continue and task_cancel"},"answer":{"type":"string","description":"Free-text answer for a paused task; done after a needs_human pause"},"token":{"type":"string","description":"Token returned with the exact pending action"}+ "url":{"type":"string","description":"Starting HTTPS URL for open or an optional starting URL for task"},"selector":{"type":"string"},"value":{"type":"string"},"text":{"type":"string"},"key":{"type":"string"},"direction":{"type":"string"},"pixels":{"type":"integer"},"ms":{"type":"integer"},"timeout_ms":{"type":"integer"},"interactive_only":{"type":"boolean"},"compact":{"type":"boolean"},"depth":{"type":"integer"},"by":{"type":"string"},"find_action":{"type":"string"},"fill_value":{"type":"string"},"goal":{"type":"string"},"inputs":{"type":"object","additionalProperties":{"type":"string"}},"task_id":{"type":"string","description":"Task id returned by task, for task_continue and task_cancel"},"flow":{"type":"object","description":"Optional TinyComputer flow ({app, vars, steps}) to run instead of planning one from goal, e.g. a plan saved from an earlier successful run"},"answer":{"type":"string","description":"Free-text answer for a paused task; done after a needs_human pause"},"token":{"type":"string","description":"Token returned with the exact pending action"}},"required":["action"]})}fn external_effect_with_args(&self, args: &Value) -> bool {