Skip to content

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

chore: files changed crates/openhuman-core/src/tools/impl/network/host.rs,crates/openhuman-core/src/

Steven Enamakel9ce3a4f8078d
diff --git a/crates/openhuman-core/src/tools/impl/network/host.rs b/crates/openhuman-core/src/tools/impl/network/host.rs
index 9e35879be9..329229c027 100644
--- a/crates/openhuman-core/src/tools/impl/network/host.rs
+++ b/crates/openhuman-core/src/tools/impl/network/host.rs
@@ -10,6 +10,7 @@ use std::sync::Arc;
use tinytools_std::network::{
AsyncHtmlExtractor, HttpLimits, HttpRequestTool, NetGate, WebFetchTool,
};
+use tinytools::{PermissionLevel, Tool, ToolResult};
use crate::config::HttpRequestConfig;
use crate::inference::tokenjuice::focus::{summary_focus_property, SUMMARY_FOCUS_ARG};
@@ -66,6 +67,58 @@ pub fn http_request_tool(
tool
}
+/// Dedicated x402 agent entry point backed by the same host HTTP policy and
+/// the module payment hook used by `http_request`.
+#[cfg(feature = "web3")]
+pub fn x402_request_tool(
+ gate: Arc<dyn NetGate>,
+ allowed_domains: Vec<String>,
+ max_response_size: usize,
+ timeout_secs: u64,
+) -> impl Tool {
+ X402RequestTool {
+ gate: Arc::clone(&gate),
+ inner: http_request_tool(gate, allowed_domains, max_response_size, timeout_secs),
+ }
+}
+
+#[cfg(feature = "web3")]
+#[derive(Debug)]
+struct X402RequestTool {
+ gate: Arc<dyn NetGate>,
+ inner: HttpRequestTool,
+}
+
+#[cfg(feature = "web3")]
+#[async_trait::async_trait]
+impl Tool for X402RequestTool {
+ fn name(&self) -> &'static str {
+ tinywallet_bus::tools::x402_request_tool_declaration().name
+ }
+
+ fn description(&self) -> &'static str {
+ tinywallet_bus::tools::x402_request_tool_declaration().description
+ }
+
+ fn parameters_schema(&self) -> serde_json::Value {
+ tinywallet_bus::tools::x402_request_tool_declaration()
+ .parameters
+ .clone()
+ }
+
+ fn permission_level(&self) -> PermissionLevel {
+ PermissionLevel::Write
+ }
+
+ fn external_effect_with_args(&self, _args: &serde_json::Value) -> bool {
+ self.gate.network_needs_approval()
+ }
+
+ async fn execute(&self, args: serde_json::Value) -> anyhow::Result<ToolResult> {
+ self.inner.execute(args).await
+ }
+}
+
/// `web_fetch`, converting HTML through TinyJuice and opting into TinyJuice's
/// optional `summary_focus` argument.
pub fn web_fetch_tool(
@@ -91,7 +144,7 @@ mod x402 {
//! x402 machine payment for `http_request`'s `402 Payment Required` retry.
use async_trait::async_trait;
- use tinytools_std::network::{PaymentAttempt, PaymentHook, PaymentOutcome};
+ use tinytools_std::network::{PaymentAttempt, PaymentHook};
use crate::modules::x402_service;
diff --git a/crates/openhuman-core/src/tools/ops.rs b/crates/openhuman-core/src/tools/ops.rs
index 57299fdd9c..5cddffff69 100644
--- a/crates/openhuman-core/src/tools/ops.rs
+++ b/crates/openhuman-core/src/tools/ops.rs
@@ -550,9 +550,11 @@ pub fn all_tools_with_runtime(
// or SPL payment signing, and ledger recording. Gated with the `web3`
// feature (the x402 domain is compiled out when web3 is disabled).
#[cfg(feature = "web3")]
- tools.push(Box::new(crate::web3::x402::request_tool(
+ tools.push(Box::new(crate::tools::impl::network::host::x402_request_tool(
security.clone(),
http_config.allowed_domains.clone(),
+ http_config.max_response_size,
+ http_config.timeout_secs,
)));
// Coding-harness baseline `web_fetch` (issue #1205) — single-purpose