Skip to content

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

docs(tools): add README files and restructure browser and system modules

Steven Enamakelda7c150d4d80
diff --git a/crates/openhuman-core/src/tools/README.md b/crates/openhuman-core/src/tools/README.md
index 2a9e96040f..b5dce01e12 100644
--- a/crates/openhuman-core/src/tools/README.md
+++ b/crates/openhuman-core/src/tools/README.md
@@ -37,7 +37,7 @@ The agent tool layer. Defines the core [`Tool`] trait every agent-callable capab
| [`crates/openhuman-core/src/tools/impl/mod.rs`](impl/README.md) | Aggregates the built-in tool families; glob re-exports `browser`, `filesystem`, `network`, `system` and the two `documents`-gated tools. `meta` is declared `pub` but not glob re-exported: reach it as `implementations::meta`. |
| `crates/openhuman-core/src/tools/impl/filesystem/` | Tools `file_read`, `file_write`, `edit`, `apply_patch`, `grep`, `glob`, `list`, `read_diff`, `csv_export`, `git_operations`, `run_linter`, `run_tests`, `update_memory_md`. The tools live in `tinytools_std::filesystem` (vendor `tinytools`); this directory holds only the `FsGate` adapter for `SecurityPolicy` (`gate.rs`). |
| `crates/openhuman-core/src/tools/impl/browser/` | Deferred `browser` (TinyComputer browser members and tasks), deferred `browser_open` (simple TinyComputer entry point), and direct `image_info`. |
-| `crates/openhuman-core/src/tools/impl/system/` | Tools `shell`, `node_exec`, `npm_exec`, `python_exec`, `install_tool`, `detect_tools`, `current_time`, `resolve_time`, `schedule`, `proxy_config`, `pushover`, `lsp`, `tool_stats`, `update_check`, `update_apply`, `insert_sql_record`, `read_workspace_state`, `retrieve_tool_output`. Helper module (not a tool): `command_output`, the shared exit-code/stdout/stderr formatter for the shell family. |
+| `crates/openhuman-core/src/tools/impl/system/` | Tools `shell`, `node_exec`, `npm_exec`, `python_exec`, `install_tool`, `detect_tools`, `current_time`, `resolve_time`, `schedule`, `proxy_config`, `pushover`, `lsp`, `tool_stats`, `update_check`, `update_apply`, `read_workspace_state`, `retrieve_tool_output`. Helper module (not a tool): `command_output`, the shared exit-code/stdout/stderr formatter for the shell family. |
| `crates/openhuman-core/src/tools/impl/network/` | Tools `http_request`, `web_fetch`, `curl`, `gitbooks_search`/`gitbooks_get_page`, `mcp_list_servers`/`mcp_list_tools`/`mcp_call_tool` (`mcp`-feature gated), `gmail_unsubscribe`. Helper module: `url_guard` (host allowlist matching, private-address rejection, `validate_url`). |
| `crates/openhuman-core/src/tools/impl/meta/` | Tools *about* the tool surface itself: `deferred` (the host's half of `ToolExposure::Deferred`; the harness's intrinsic `tool_search` bridge is the lookup half) and `collapse` (multi-action schema/permission merging helpers). |
| `crates/openhuman-core/src/tools/impl/document/` (`documents` feature) | `DocumentTool` (`generate_document`): structured document generation/editing engine. |
@@ -74,7 +74,7 @@ Handlers load config via `config::rpc::load_config_with_timeout`, build the back
This module owns the cross-cutting built-in tools (the only ones that belong here per the repo's tool-ownership rule):
- Filesystem: `file_read`, `file_write`, `edit`, `apply_patch`, `grep`, `glob`, `list`, `read_diff`, `csv_export`, `git_operations`, `run_linter`, `run_tests`, `update_memory_md`.
-- System/process: `shell`, `node_exec`, `npm_exec`, `python_exec`, `install_tool`, `detect_tools`, `current_time`, `resolve_time`, `schedule`, `proxy_config`, `pushover`, `lsp`, `tool_stats`, `update_check`, `update_apply`, `insert_sql_record`, `read_workspace_state`, `retrieve_tool_output`.
+- System/process: `shell`, `node_exec`, `npm_exec`, `python_exec`, `install_tool`, `detect_tools`, `current_time`, `resolve_time`, `schedule`, `proxy_config`, `pushover`, `lsp`, `tool_stats`, `update_check`, `update_apply`, `read_workspace_state`, `retrieve_tool_output`.
- Browser: `browser`, `browser_open`, `image_info`.
- Generic network: `http_request`, `web_fetch`, `curl`, `gitbooks_search`/`gitbooks_get_page`, MCP bridge (`mcp_list_servers`/`mcp_list_tools`/`mcp_call_tool`), `gmail_unsubscribe`.
- Meta: `deferred` (which tools leave the wire for the harness's `tool_search` bridge) and the `collapse` multi-action helpers used by other tools' schema merging.
diff --git a/crates/openhuman-core/src/tools/impl/README.md b/crates/openhuman-core/src/tools/impl/README.md
index c89537bb54..133721395b 100644
--- a/crates/openhuman-core/src/tools/impl/README.md
+++ b/crates/openhuman-core/src/tools/impl/README.md
@@ -29,7 +29,7 @@ tested but no production assembly site constructs it today.
| Family | Tools | Registration gate |
| --- | --- | --- |
-| `system/` | `ShellTool`, `NodeExecTool`, `NpmExecTool`, `PythonExecTool`, `InstallToolTool`, `DetectToolsTool` (from `tinytools_std`), `CurrentTimeTool` and `ResolveTimeTool` (imported directly from `tinyagents_harness::tools` at their call sites; no local copy), `ScheduleTool`, `ProxyConfigTool`, `PushoverTool`, `LspTool`, `ToolStatsTool`, `UpdateCheckTool`, `UpdateApplyTool`, `InsertSqlRecordTool`, `WorkspaceStateTool`, `RetrieveToolOutputTool`; shell failure rendering lives in `tinytools_std::command_output` | `node_exec`/`npm_exec` and `shell`'s PATH injection need the `runtime-node` Cargo feature plus `node.enabled`; `python_exec` needs `runtime_python.enabled`; `LspTool` needs `OPENHUMAN_LSP_ENABLED` (`lsp_capability_enabled`); `ToolStatsTool` needs `learning.enabled` and `learning.tool_tracking_enabled`; `InsertSqlRecordTool` is exported, not registered; the rest are always registered |
+| `system/` | `ShellTool`, `NodeExecTool`, `NpmExecTool`, `PythonExecTool`, `InstallToolTool`, `DetectToolsTool` (from `tinytools_std`), `CurrentTimeTool` and `ResolveTimeTool` (imported directly from `tinyagents_harness::tools` at their call sites; no local copy), `ScheduleTool`, `ProxyConfigTool`, `PushoverTool`, `LspTool`, `ToolStatsTool`, `UpdateCheckTool`, `UpdateApplyTool`, `WorkspaceStateTool`, `RetrieveToolOutputTool`; shell failure rendering lives in `tinytools_std::command_output` | `node_exec`/`npm_exec` and `shell`'s PATH injection need the `runtime-node` Cargo feature plus `node.enabled`; `python_exec` needs `runtime_python.enabled`; `LspTool` needs `OPENHUMAN_LSP_ENABLED` (`lsp_capability_enabled`); `ToolStatsTool` needs `learning.enabled` and `learning.tool_tracking_enabled`; the rest are always registered |
| `filesystem/` | Host adapter only: `SecurityPolicy` implements `tinytools_std::filesystem::FsGate`. The tools (`FileReadTool`, `FileWriteTool`, `EditFileTool`, `ApplyPatchTool`, `GrepTool`, `GlobTool`, `ListFilesTool`, `ReadDiffTool`, `CsvExportTool`, `GitOperationsTool`, `RunLinterTool`, `RunTestsTool`, `UpdateMemoryMdTool`) live in `tinytools_std::filesystem` and are imported directly by `tools/ops.rs` | always registered, except `ReadDiffTool`, `RunLinterTool`, and `RunTestsTool`, which are exported, not registered |
| `browser/` | `BrowserTool` (TinyComputer browser members and tasks), `BrowserOpenTool` (simple TinyComputer navigation), `ImageInfoTool` | Both browser tools need `browser.enabled` and the `modules` feature, and are deferred until `tool_search`; `ImageInfoTool` remains direct. Browser navigation uses the shared `http_request.allowed_domains` policy, and the checksum-pinned TinyComputer release module. |
| `network/` | `HttpRequestTool`, `WebFetchTool`, `CurlTool`, `GitbooksSearchTool`, `GitbooksGetPageTool`, `GmailUnsubscribeTool`, and under the `mcp` Cargo feature `McpListServersTool`, `McpListToolsTool`, `McpCallTool`; `url_guard.rs` is the shared SSRF/allowlist validator, not a tool | `http_request`, `web_fetch`, `curl`, `gmail_unsubscribe` always registered; `gitbooks_*` need `gitbooks.enabled` and, when the active profile sets an `mcp_allowlist`, an entry named `gitbooks`; `mcp_list_servers`/`mcp_list_tools`/`mcp_call_tool` register only when the static `[[mcp_client.servers]]` registry (after the profile allowlist) is non-empty |
diff --git a/crates/openhuman-core/src/tools/impl/browser/mod.rs b/crates/openhuman-core/src/tools/impl/browser/mod.rs
index c3c3f4c162..34fc79905d 100644
--- a/crates/openhuman-core/src/tools/impl/browser/mod.rs
+++ b/crates/openhuman-core/src/tools/impl/browser/mod.rs
@@ -6,7 +6,6 @@ mod browser;
#[cfg(feature = "modules")]
mod browser_open;
mod image_info;
-mod security;
#[cfg(feature = "modules")]
pub use browser::BrowserTool;
diff --git a/crates/openhuman-core/src/tools/impl/browser/security.rs b/crates/openhuman-core/src/tools/impl/browser/security.rs
deleted file mode 100644
index f483dfee51..0000000000
--- a/crates/openhuman-core/src/tools/impl/browser/security.rs
+++ /dev/null
@@ -1,150 +0,0 @@
-use std::net::ToSocketAddrs;
-use std::time::Duration;
-
-pub(crate) fn normalize_domains(domains: Vec<String>) -> Vec<String> {
- domains
- .into_iter()
- .map(|d| d.trim().to_lowercase())
- .filter(|d| !d.is_empty())
- .collect()
-}
-
-pub(crate) fn endpoint_reachable(endpoint: &reqwest::Url, timeout: Duration) -> bool {
- let host = match endpoint.host_str() {
- Some(host) if !host.is_empty() => host,
- _ => return false,
- };
-
- let port = match endpoint.port_or_known_default() {
- Some(port) => port,
- None => return false,
- };
-
- let mut addrs = match (host, port).to_socket_addrs() {
- Ok(addrs) => addrs,
- Err(_) => return false,
- };
-
- let addr = match addrs.next() {
- Some(addr) => addr,
- None => return false,
- };
-
- std::net::TcpStream::connect_timeout(&addr, timeout).is_ok()
-}
-
-pub(crate) fn extract_host(url_str: &str) -> anyhow::Result<String> {
- // Simple host extraction without url crate
- let url = url_str.trim();
- let without_scheme = url
- .strip_prefix("https://")
- .or_else(|| url.strip_prefix("http://"))
- .or_else(|| url.strip_prefix("file://"))
- .unwrap_or(url);
-
- // Extract host — handle bracketed IPv6 addresses like [::1]:8080
- let authority = without_scheme.split('/').next().unwrap_or(without_scheme);
-
- let host = if authority.starts_with('[') {
- // IPv6: take everything up to and including the closing ']'
- authority.find(']').map_or(authority, |i| &authority[..=i])
- } else {
- // IPv4 or hostname: take everything before the port separator
- authority.split(':').next().unwrap_or(authority)
- };
-
- if host.is_empty() {
- anyhow::bail!("Invalid URL: no host");
- }
-
- Ok(host.to_lowercase())
-}
-
-pub(crate) fn is_private_host(host: &str) -> bool {
- // Strip brackets from IPv6 addresses like [::1]
- let bare = host
- .strip_prefix('[')
- .and_then(|h| h.strip_suffix(']'))
- .unwrap_or(host);
-
- if bare == "localhost" || bare.ends_with(".localhost") {
- return true;
- }
-
- // .local TLD (mDNS)
- if bare
- .rsplit('.')
- .next()
- .is_some_and(|label| label == "local")
- {
- return true;
- }
-
- // Parse as IP address to catch all representations (decimal, hex, octal, mapped)
- if let Ok(ip) = bare.parse::<std::net::IpAddr>() {
- return match ip {
- std::net::IpAddr::V4(v4) => is_non_global_v4(v4),
- std::net::IpAddr::V6(v6) => is_non_global_v6(v6),
- };
- }
-
- false
-}
-
-/// Returns `true` for any IPv4 address that is not globally routable.
-pub(crate) fn is_non_global_v4(v4: std::net::Ipv4Addr) -> bool {
- let [a, b, _, _] = v4.octets();
- v4.is_loopback()
- || v4.is_private()
- || v4.is_link_local()
- || v4.is_unspecified()
- || v4.is_broadcast()
- || v4.is_multicast()
- // Shared address space (100.64/10)
- || (a == 100 && (64..=127).contains(&b))
- // Reserved (240.0.0.0/4)
- || a >= 240
- // Documentation (192.0.2.0/24, 198.51.100.0/24, 203.0.113.0/24)
- || (a == 192 && b == 0)
- || (a == 198 && b == 51)
- || (a == 203 && b == 0)
- // Benchmarking (198.18.0.0/15)
- || (a == 198 && (18..=19).contains(&b))
-}
-
-/// Returns `true` for any IPv6 address that is not globally routable.
-pub(crate) fn is_non_global_v6(v6: std::net::Ipv6Addr) -> bool {
- let segs = v6.segments();
- v6.is_loopback()
- || v6.is_unspecified()
- || v6.is_multicast()
- // Unique-local (fc00::/7) — IPv6 equivalent of RFC 1918
- || (segs[0] & 0xfe00) == 0xfc00
- // Link-local (fe80::/10)
- || (segs[0] & 0xffc0) == 0xfe80
- // IPv4-mapped addresses
- || v6.to_ipv4_mapped().is_some_and(is_non_global_v4)
-}
-
-pub(crate) fn allow_all_browser_domains() -> bool {
- matches!(
- std::env::var("OPENHUMAN_BROWSER_ALLOW_ALL").ok().as_deref(),
- Some("1") | Some("true") | Some("TRUE") | Some("yes") | Some("YES")
- )
-}
-
-pub(crate) fn host_matches_allowlist(host: &str, allowed: &[String]) -> bool {
- allowed.iter().any(|pattern| {
- if pattern == "*" {
- return true;
- }
- if pattern.starts_with("*.") {
- // Wildcard subdomain match
- let suffix = &pattern[1..]; // ".example.com"
- host.ends_with(suffix) || host == &pattern[2..]
- } else {
- // Exact match or subdomain
- host == pattern || host.ends_with(&format!(".{pattern}"))
- }
- })
-}
diff --git a/crates/openhuman-core/src/tools/impl/system/insert_sql_record.rs b/crates/openhuman-core/src/tools/impl/system/insert_sql_record.rs
deleted file mode 100644
index 79ba20443e..0000000000
--- a/crates/openhuman-core/src/tools/impl/system/insert_sql_record.rs
+++ /dev/null
@@ -1,144 +0,0 @@
-//! Tool: insert_sql_record — insert an episodic record into the FTS5 memory database.
-
-use async_trait::async_trait;
-use serde_json::json;
-use tinytools::{PermissionLevel, Tool, ToolResult};
-
-/// Valid values for the `role` parameter.
-const VALID_ROLES: &[&str] = &["user", "assistant", "tool"];
-
-/// Inserts an episodic memory record into the FTS5 episodic-memory SQLite table.
-///
-/// # Current status
-/// The FTS5 schema and connection pool will be wired in Phase 5 of the harness
-/// implementation. This stub validates parameters, emits structured trace logs,
-/// and returns a success result so calling agents can proceed without blocking.
-pub struct InsertSqlRecordTool;
-
-impl InsertSqlRecordTool {
- pub fn new() -> Self {
- Self
- }
-}
-
-impl Default for InsertSqlRecordTool {
- fn default() -> Self {
- Self::new()
- }
-}
-
-#[async_trait]
-impl Tool for InsertSqlRecordTool {
- fn name(&self) -> &str {
- "insert_sql_record"
- }
-
- fn description(&self) -> &str {
- "Insert an episodic memory record into the FTS5 memory database. \
- Records are tagged with a session ID, role (user/assistant/tool), \
- content, and an optional extracted lesson. The database enables \
- full-text search over conversation history for future retrieval."
- }
-
- fn parameters_schema(&self) -> serde_json::Value {
- json!({
- "type": "object",
- "required": ["session_id", "role", "content"],
- "properties": {
- "session_id": {
- "type": "string",
- "description": "Unique identifier for the conversation session."
- },
- "role": {
- "type": "string",
- "enum": ["user", "assistant", "tool"],
- "description": "Who produced this record."
- },
- "content": {
- "type": "string",
- "description": "The text content of the message or tool output."
- },
- "lesson": {
- "type": "string",
- "description": "Optional distilled lesson extracted from this exchange."
- }
- }
- })
- }
-
- fn permission_level(&self) -> PermissionLevel {
- PermissionLevel::Write
- }
-
- async fn execute(&self, args: serde_json::Value) -> anyhow::Result<ToolResult> {
- // ── Parameter extraction ────────────────────────────────────────────
- let session_id = args
- .get("session_id")
- .and_then(|v| v.as_str())
- .ok_or_else(|| anyhow::anyhow!("Missing required parameter 'session_id'"))?;
-
- let role = args
- .get("role")
- .and_then(|v| v.as_str())
- .ok_or_else(|| anyhow::anyhow!("Missing required parameter 'role'"))?;
-
- let content = args
- .get("content")
- .and_then(|v| v.as_str())
- .ok_or_else(|| anyhow::anyhow!("Missing required parameter 'content'"))?;
-
- let lesson = args.get("lesson").and_then(|v| v.as_str());
-
- // ── Validation ──────────────────────────────────────────────────────
- if !VALID_ROLES.contains(&role) {
- return Ok(ToolResult::error(format!(
- "Invalid role '{role}'. Must be one of: user, assistant, tool."
- )));
- }
-
- if session_id.trim().is_empty() {
- return Ok(ToolResult::error("'session_id' must not be empty."));
- }
-
- if content.trim().is_empty() {
- return Ok(ToolResult::error("'content' must not be empty."));
- }
-
- // ── Structured trace log ────────────────────────────────────────────
- tracing::info!(
- session_id = session_id,
- role = role,
- content_len = content.len(),
- has_lesson = lesson.is_some(),
- "[insert_sql_record] episodic record queued for FTS5 insert"
- );
-
- if let Some(lesson_text) = lesson {
- tracing::debug!(
- session_id = session_id,
- "[insert_sql_record] lesson: {lesson_text}"
- );
- }
-
- // ── Placeholder result (FTS5 wire-up deferred to Phase 5) ───────────
- // TODO(phase-5): obtain `Arc<SqlitePool>` from app state, run:
- // sqlx::query!(
- // "INSERT INTO episodic_memory(session_id, role, content, lesson, ts)
- // VALUES (?, ?, ?, ?, unixepoch())",
- // session_id, role, content, lesson
- // ).execute(&*pool).await?;
- let summary = format!(
- "Record staged: session={session_id} role={role} content_len={} lesson={}",
- content.len(),
- lesson.map_or("none".to_string(), |l| format!("{} chars", l.len())),
- );
-
- Ok(ToolResult::error(format!(
- "episodic memory write not yet wired (FTS5/SQLite insert pending). {summary}"
- )))
- }
-}
-
-#[cfg(test)]
-#[path = "insert_sql_record_tests.rs"]
-mod tests;
diff --git a/crates/openhuman-core/src/tools/impl/system/insert_sql_record_tests.rs b/crates/openhuman-core/src/tools/impl/system/insert_sql_record_tests.rs
deleted file mode 100644
index 8f80a8b9ea..0000000000
--- a/crates/openhuman-core/src/tools/impl/system/insert_sql_record_tests.rs
+++ /dev/null
@@ -1,102 +0,0 @@
-use super::*;
-
-fn tool() -> InsertSqlRecordTool {
- InsertSqlRecordTool::new()
-}
-
-#[tokio::test]
-async fn inserts_minimal_record() {
- let result = tool()
- .execute(json!({
- "session_id": "sess-001",
- "role": "user",
- "content": "Hello, world!"
- }))
- .await
- .unwrap();
- // The tool is a stub: success is false until FTS5 write is wired.
- assert!(result.is_error);
- assert!(result.output().contains("not yet wired"));
- assert!(result.output().contains("sess-001"));
- assert!(result.output().contains("user"));
-}
-
-#[tokio::test]
-async fn inserts_with_lesson() {
- let result = tool()
- .execute(json!({
- "session_id": "sess-002",
- "role": "assistant",
- "content": "Use cargo fmt before committing.",
- "lesson": "Always format Rust code before review."
- }))
- .await
- .unwrap();
- // The tool is a stub: success is false until FTS5 write is wired.
- assert!(result.is_error);
- assert!(result.output().contains("lesson="));
-}
-
-#[tokio::test]
-async fn rejects_invalid_role() {
- let result = tool()
- .execute(json!({
- "session_id": "sess-003",
- "role": "system",
- "content": "Invalid role test."
- }))
- .await
- .unwrap();
- assert!(result.is_error);
- assert!(result.output().contains("Invalid role"));
-}
-
-#[tokio::test]
-async fn rejects_empty_session_id() {
- let result = tool()
- .execute(json!({
- "session_id": " ",
- "role": "user",
- "content": "Some content."
- }))
- .await
- .unwrap();
- assert!(result.is_error);
- assert!(result.output().contains("session_id"));
-}
-
-#[tokio::test]
-async fn rejects_empty_content() {
- let result = tool()
- .execute(json!({
- "session_id": "sess-004",
- "role": "tool",
- "content": ""
- }))
- .await
- .unwrap();
- assert!(result.is_error);
- assert!(result.output().contains("content"));
-}
-
-#[tokio::test]
-async fn missing_required_param_returns_error() {
- let result = tool()
- .execute(json!({ "session_id": "s", "role": "user" }))
- .await;
- assert!(result.is_err(), "should return Err for missing 'content'");
-}
-
-#[test]
-fn schema_has_required_fields() {
- let schema = tool().parameters_schema();
- let required = schema["required"].as_array().unwrap();
- assert!(required.contains(&json!("session_id")));
- assert!(required.contains(&json!("role")));
- assert!(required.contains(&json!("content")));
-}
-
-#[test]
-fn permission_is_write() {
- assert_eq!(tool().permission_level(), PermissionLevel::Write);
-}
diff --git a/crates/openhuman-core/src/tools/impl/system/mod.rs b/crates/openhuman-core/src/tools/impl/system/mod.rs
index e0b110ec0d..c3ec11c637 100644
--- a/crates/openhuman-core/src/tools/impl/system/mod.rs
+++ b/crates/openhuman-core/src/tools/impl/system/mod.rs
@@ -4,7 +4,6 @@
//! `tools/impl/README.md`; `security_for_tool_context` below is the shared
//! `SecurityPolicy` resolver that must stay in step with the `filesystem` copy.
-mod insert_sql_record;
mod install_tool;
mod lsp;
mod node_exec;
@@ -24,7 +23,6 @@ use crate::security::policy::{TrustedAccess, TrustedRoot};
use crate::security::SecurityPolicy;
use tinytools::ToolRunContext;
-pub use insert_sql_record::InsertSqlRecordTool;
pub use install_tool::InstallToolTool;
pub use lsp::{lsp_capability_enabled, LspTool, LSP_ENABLED_ENV};
pub use node_exec::NodeExecTool;