Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

feat(browser): add browser tool implementation

Steven Enamakel566a882bc348
diff --git a/crates/openhuman-core/src/tools/impl/browser/browser.rs b/crates/openhuman-core/src/tools/impl/browser/browser.rs
index 60023faa9f..70f0fe8ada 100644
--- a/crates/openhuman-core/src/tools/impl/browser/browser.rs
+++ b/crates/openhuman-core/src/tools/impl/browser/browser.rs
@@ -548,17 +548,8 @@ impl Tool for BrowserTool {
false
}
async fn execute(&self, args: Value) -> anyhow::Result<ToolResult> {
- if !self.security.can_act() {
- return Ok(ToolResult::error(
- "[policy-blocked] Action blocked: autonomy is read-only",
- ));
- }
- // A task counts once here; its own steps are bounded by max_actions.
- if !self.security.record_action() {
- return Ok(ToolResult::error("Action blocked: rate limit exceeded"));
- }
- // The typed origin bound to this turn's immutable CoreContext by its
- // entry point (cron, background job, workflow, chat).
+ // Direct dispatch has no run: the turn's origin is whatever the calling
+ // task's scope carries.
let origin = crate::core::runtime::DispatchCtx::ambient_turn().turn_origin();
self.execute_with_origin(args, origin).await
}
@@ -581,6 +572,30 @@ impl Tool for BrowserTool {
}
}
+impl BrowserTool {
+ /// Runs the tool for a turn running under `origin` (cron, background job,
+ /// workflow, chat), the typed authority its entry point supplied.
+ async fn execute_with_origin(
+ &self,
+ args: Value,
+ origin: Option<crate::agent::turn_origin::AgentTurnOrigin>,
+ ) -> anyhow::Result<ToolResult> {
+ if !self.security.can_act() {
+ return Ok(ToolResult::error(
+ "[policy-blocked] Action blocked: autonomy is read-only",
+ ));
+ }
+ // A task counts once here; its own steps are bounded by max_actions.
+ if !self.security.record_action() {
+ return Ok(ToolResult::error("Action blocked: rate limit exceeded"));
+ }
+ match self.run(&args, origin.as_ref()).await {
+ Ok(v) => Ok(ToolResult::success(serde_json::to_string_pretty(&v)?)),
+ Err(e) => Ok(ToolResult::error(e.to_string())),
+ }
+ }
+}
+
#[cfg(test)]
#[path = "browser_computer_tests.rs"]
mod tests;