Skip to content

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

chore(tools): remove unused network gate module

Steven Enamakel8fd1efbd4da7
diff --git a/crates/openhuman-core/src/tools/impl/network/gate.rs b/crates/openhuman-core/src/tools/impl/network/gate.rs
index 5f488833ee..d516e012ec 100644
--- a/crates/openhuman-core/src/tools/impl/network/gate.rs
+++ b/crates/openhuman-core/src/tools/impl/network/gate.rs
@@ -34,6 +34,77 @@ pub(super) fn network_egress_descriptor(
desc
}
+/// `SecurityPolicy` as the network tools' [`NetGate`] for one turn: every answer is
+/// the policy's, and the disclosure additionally reaches the turn's chat.
+///
+/// `NetGate::disclose` takes no run context (the trait lives in `tinytools_std`),
+/// so the chat the disclosure is routed to is held by the gate itself, which the
+/// per-call tool wrapper ([`crate::tools::per_call::PerCallTool`]) builds for each
+/// call.
+#[derive(Debug)]
+pub(crate) struct RoutedGate {
+ policy: std::sync::Arc<SecurityPolicy>,
+ chat: Option<crate::security::approval::ApprovalChatContext>,
+}
+
+impl RoutedGate {
+ pub(crate) fn new(
+ policy: std::sync::Arc<SecurityPolicy>,
+ chat: Option<&crate::security::approval::ApprovalChatContext>,
+ ) -> Self {
+ Self {
+ policy,
+ chat: chat.cloned(),
+ }
+ }
+}
+
+impl NetGate for RoutedGate {
+ fn can_act(&self) -> bool {
+ NetGate::can_act(&*self.policy)
+ }
+
+ fn is_rate_limited(&self) -> bool {
+ NetGate::is_rate_limited(&*self.policy)
+ }
+
+ fn record_action(&self) -> bool {
+ NetGate::record_action(&*self.policy)
+ }
+
+ fn network_needs_approval(&self) -> bool {
+ NetGate::network_needs_approval(&*self.policy)
+ }
+
+ fn local_only_block(&self, host: &str) -> Option<String> {
+ NetGate::local_only_block(&*self.policy, host)
+ }
+
+ fn disclose(&self, host: &str, has_body: bool, has_headers: bool) {
+ emit_external_transfer(
+ self.chat.as_ref(),
+ network_egress_descriptor(host, has_body, has_headers),
+ );
+ }
+
+ fn prepare_client(
+ &self,
+ service: &str,
+ builder: reqwest::ClientBuilder,
+ ) -> reqwest::ClientBuilder {
+ NetGate::prepare_client(&*self.policy, service, builder)
+ }
+
+ fn timeout_client(
+ &self,
+ service: &str,
+ timeout_secs: u64,
+ connect_timeout_secs: u64,
+ ) -> reqwest::Client {
+ NetGate::timeout_client(&*self.policy, service, timeout_secs, connect_timeout_secs)
+ }
+}
+
impl NetGate for SecurityPolicy {
fn can_act(&self) -> bool {
SecurityPolicy::can_act(self)
@@ -56,6 +127,9 @@ impl NetGate for SecurityPolicy {
}
fn disclose(&self, host: &str, has_body: bool, has_headers: bool) {
+ // A caller that holds only the policy (a flow node, a direct dispatch) is
+ // not in a chat turn; the tools a chat turn runs are built around a
+ // `RoutedGate` instead.
emit_external_transfer(None, network_egress_descriptor(host, has_body, has_headers));
}