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
chore: remove trailing blank lines and reformat re-export list
Steven Enamakel67e913154f1a
diff --git a/crates/openhuman-core/src/search/tools/tavily.rs b/crates/openhuman-core/src/search/tools/tavily.rsindex a44fe06a56..2c704cdf06 100644--- a/crates/openhuman-core/src/search/tools/tavily.rs+++ b/crates/openhuman-core/src/search/tools/tavily.rs@@ -24,8 +24,7 @@ mod tests;pub use extract_tool::TavilyExtractTool;pub use search_tool::TavilySearchTool;pub use types::{- TavilyExtractResponse, TavilyExtractResult, TavilyImage, TavilyResultItem,- TavilySearchResponse,+ TavilyExtractResponse, TavilyExtractResult, TavilyImage, TavilyResultItem, TavilySearchResponse,};// Re-exported only for the test module (`super::*`), which builds realdiff --git a/crates/openhuman-core/src/search/tools/tavily/search_tool.rs b/crates/openhuman-core/src/search/tools/tavily/search_tool.rsindex 102c4233e0..5f9722bb35 100644--- a/crates/openhuman-core/src/search/tools/tavily/search_tool.rs+++ b/crates/openhuman-core/src/search/tools/tavily/search_tool.rs@@ -6,7 +6,6 @@ use crate::tools::traits::{Tool, ToolCallOptions, ToolResult};use async_trait::async_trait;use serde_json::{json, Value};-/// Web / news / finance search via the Tavily API (`POST /search`).pub struct TavilySearchTool {tool_name: &'static str,@@ -216,4 +215,3 @@ impl Tool for TavilySearchTool {Ok(result)}}-diff --git a/crates/openhuman-core/src/security/policy/policy_command/classification.rs b/crates/openhuman-core/src/security/policy/policy_command/classification.rsnew file mode 100644index 0000000000..fbc634f7f1--- /dev/null+++ b/crates/openhuman-core/src/security/policy/policy_command/classification.rs@@ -0,0 +1,370 @@+//! Base-command classification: the read/write/network/install/destructive+//! bucket lists, verb-sensitive VCS / package-manager handling, and the+//! structural "hidden execution" guard for the harness-gated command flow.++use super::quoting::contains_unquoted_background_ampersand;+use super::{command_name::is_command_executor, CommandClass};++/// Provably read-only command bases (cross-platform union). A base **not** in+/// this set — and not a recognized network/destructive/executor command, nor a+/// read-only verb of git/npm/cargo — falls through to [`CommandClass::Write`]+/// (the classifier is fail-closed). Conservative on purpose: anything that can+/// write a file under a common flag is intentionally omitted (`sort -o`, `tee`).+const READ_ONLY_BASES: &[&str] = &[+ // POSIX inspection / read-only coreutils+ "ls",+ "cat",+ "pwd",+ "echo",+ "wc",+ "head",+ "tail",+ "date",+ "grep",+ "egrep",+ "fgrep",+ "rg",+ "which",+ "whoami",+ "id",+ "hostname",+ "uname",+ "printenv",+ "stat",+ "file",+ "du",+ "df",+ "tree",+ "realpath",+ "readlink",+ "dirname",+ "basename",+ "cmp",+ "true",+ "false",+ "sleep",+ "seq",+ "tty",+ "groups",+ "locale",+ "ps",+ "top",+ "free",+ "uptime",+ "lsblk",+ "lscpu",+ "cut",+ // NOTE: OS-native launchers (`open`, `xdg-open`, `start`) are deliberately+ // NOT in the read-only set. `classify_command` only sees the base command,+ // not its args, and these launchers can open arbitrary `https://` URLs and+ // custom URI handlers — i.e. trigger outbound network / system actions — so+ // treating them as `Read` (no approval) is too broad. App launching now+ // goes through the dedicated `launch_app` tool, which is scoped to named+ // applications only and carries no shell-arg ambiguity.+ // Windows cmd / PowerShell read verbs + common aliases+ "dir",+ "type",+ "where",+ "whereis",+ "get-childitem",+ "gci",+ "get-content",+ "gc",+ "get-location",+ "gl",+ "select-string",+ "sls",+ "measure-object",+ "get-item",+ "gi",+ "test-path",+ "resolve-path",+ "get-command",+ "gcm",+ "get-process",+];++/// Commands that reach the network. Always-ask in every acting tier.+const NETWORK_BASES: &[&str] = &[+ "curl",+ "wget",+ "ssh",+ "scp",+ "sftp",+ "rsync",+ "nc",+ "ncat",+ "netcat",+ "telnet",+ "ftp",+ "tftp",+ "socat",+ // Windows / PowerShell+ "invoke-webrequest",+ "iwr",+ "invoke-restmethod",+ "irm",+ "start-bitstransfer",+ "bitsadmin",+];++/// Catastrophic / irreversible / privilege / system-control bases. Always-ask+/// in every acting tier (Full included). Coarse on the broad Windows verbs+/// (`reg`/`net`/`sc`) — over-prompting there is the safe default.+const DESTRUCTIVE_BASES: &[&str] = &[+ // POSIX privilege / disk / system-control+ "sudo",+ "su",+ "doas",+ "dd",+ "mkfs",+ "fdisk",+ "sfdisk",+ "parted",+ "wipefs",+ "shred",+ "shutdown",+ "reboot",+ "halt",+ "poweroff",+ "init",+ "telinit",+ "mount",+ "umount",+ "swapoff",+ "iptables",+ "ip6tables",+ "nft",+ "ufw",+ "firewall-cmd",+ "useradd",+ "userdel",+ "usermod",+ "groupadd",+ "groupdel",+ "passwd",+ "chpasswd",+ "visudo",+ "modprobe",+ "insmod",+ "rmmod",+ // Windows / PowerShell+ "format",+ "diskpart",+ "bcdedit",+ "takeown",+ "cipher",+ "vssadmin",+ "reg",+ "regedit",+ "runas",+ "sc",+ "net",+ "set-executionpolicy",+ "stop-computer",+ "restart-computer",+ "clear-disk",+ "format-volume",+ "remove-partition",+ "disable-computerrestore",+];++/// Git subcommands that only read repository state. Anything else — including+/// `commit`/`push`/`branch`/`config`/unknown/bare `git` — is fail-closed to+/// `Write`.+const GIT_READ_VERBS: &[&str] = &[+ "status",+ "log",+ "diff",+ "show",+ "remote",+ "describe",+ "blame",+ "ls-files",+ "ls-tree",+ "rev-parse",+ "cat-file",+ "shortlog",+ "reflog",+ "rev-list",+ "name-rev",+ "var",+ "check-ignore",+ "check-attr",+ "verify-commit",+ "count-objects",+ "fsck",+ "whatchanged",+ "grep",+ "version",+ "help",+];++/// npm/pnpm/yarn read-only subcommands. `install`/`run`/`test`/`exec` (which+/// run arbitrary scripts) and unknown verbs are fail-closed to `Write`.+const NODE_PKG_READ_VERBS: &[&str] = &[+ "ls", "list", "view", "info", "outdated", "ping", "whoami", "help", "why", "audit", "doctor",+];++/// cargo read-only subcommands. `build`/`run`/`test`/`check` compile and may+/// run build scripts, so they are fail-closed to `Write`.+const CARGO_READ_VERBS: &[&str] = &["tree", "metadata", "search", "info", "version", "help"];++/// Detect a pacman *install/upgrade* from its bundled operation flag.+///+/// pacman packs its operation and modifiers into a single flag (`-Syu`, `-Ss`),+/// and `args` reach us already lowercased — so the `-S` (sync) operation is+/// indistinguishable from a literal `-s` by case alone. We therefore key off+/// the *modifier* letters instead of a blanket `starts_with("-s")`, which would+/// over-match every read-only `-S` query: a `-S`-family flag mutates the host+/// only when it carries none of pacman's read-only query modifiers — search+/// (`s`), info (`i`), list (`l`), groups (`g`) or print (`p`). So `-S pkg`,+/// `-Sy`, `-Syu` are installs while `-Ss`/`-Si`/`-Sl`/`-Sg`/`-Sp` are reads.+fn is_pacman_install(args: &[String]) -> bool {+ args.iter().any(|a| {+ a.strip_prefix("-s")+ .is_some_and(|modifiers| !modifiers.contains(['s', 'i', 'l', 'g', 'p']))+ })+}++/// Detect a package-manager *install* invocation. These mutate the host /+/// global environment, so they are the always-ask `Install` bucket (even in+/// Full) — the same gate the dedicated `install_tool` enforces, applied to the+/// shell escape hatch. Project-local installs (`npm install` without `-g`,+/// `cargo add`) are ordinary `Write`s and are deliberately NOT matched here.+/// `args` are already lowercased by the caller.+fn is_install_command(base: &str, args: &[String]) -> bool {+ let has = |needle: &str| args.iter().any(|a| a == needle);+ let first_is = |verb: &str| args.first().map(String::as_str) == Some(verb);+ match base {+ // System package managers.+ "apt" | "apt-get" | "dnf" | "yum" | "zypper" => has("install"),+ "pacman" => is_pacman_install(args),+ "apk" => has("add"),+ "brew" | "snap" | "flatpak" | "winget" | "choco" | "scoop" => has("install"),+ // Language package managers — host/global-modifying installs only.+ "pip" | "pip3" | "pipx" | "gem" | "go" | "cargo" => first_is("install"),+ "npm" | "pnpm" => {+ (has("install") || has("i") || has("add")) && (has("-g") || has("--global"))+ }+ "yarn" => has("global"),+ _ => false,+ }+}++/// Classify a single already-split shell segment. `base` is the normalized+/// (lowercased, `.exe`-stripped, basename-only) program name; `args` are the+/// lowercased remaining words; `joined` is the lowercased segment used for+/// pattern matching. Fail-closed: an unrecognized base resolves to `Write`.+pub(in crate::security::policy) fn classify_segment(+ base: &str,+ args: &[String],+ joined: &str,+) -> CommandClass {+ // Catastrophic patterns first — they win regardless of the base command.+ if joined.contains("rm -rf /") || joined.contains("rm -fr /") || joined.contains(":(){:|:&};:")+ {+ return CommandClass::Destructive;+ }+ if DESTRUCTIVE_BASES.contains(&base) {+ return CommandClass::Destructive;+ }+ if NETWORK_BASES.contains(&base) {+ return CommandClass::Network;+ }+ // Package installs mutate the host → always-ask Install bucket (closes the+ // shell escape hatch around `install_tool`).+ if is_install_command(base, args) {+ return CommandClass::Install;+ }+ // Interpreters / code executors run arbitrary code. Fail-closed to Write+ // (not Destructive) so Full can still run code while Supervised prompts.+ if is_command_executor(base) {+ return CommandClass::Write;+ }+ // `find` is read-only unless it executes commands, deletes, or writes+ // files. -fprintf / -fprint / -fprint0 / -fls write their output to a+ // named file rather than stdout — an arbitrary-path write that side-steps+ // the gated file-write tools (and their workspace confinement), so they+ // must be classified Write (approval-gated) alongside -delete.+ //+ // `args` is built with `split_whitespace()`, which keeps shell quotes that+ // the shell itself strips before `find` runs — `find . '-fprint' out`+ // arrives as the literal `'-fprint'`. Trim surrounding single/double quotes+ // before matching so a quoted predicate cannot slip the write past the gate.+ if base == "find" {+ if args.iter().any(|a| {+ matches!(+ a.trim_matches(|c| c == '\'' || c == '"'),+ "-exec"+ | "-execdir"+ | "-ok"+ | "-okdir"+ | "-delete"+ | "-fprintf"+ | "-fprint"+ | "-fprint0"+ | "-fls"+ )+ }) {+ return CommandClass::Write;+ }+ return CommandClass::Read;+ }+ // Verb-sensitive VCS / package tools.+ if base == "git" {+ return verb_class(args, GIT_READ_VERBS);+ }+ if matches!(base, "npm" | "pnpm" | "yarn") {+ return verb_class(args, NODE_PKG_READ_VERBS);+ }+ if base == "cargo" {+ return verb_class(args, CARGO_READ_VERBS);+ }+ if READ_ONLY_BASES.contains(&base) {+ return CommandClass::Read;+ }+ // Fail closed: unknown or known-mutating base → Write.+ CommandClass::Write+}++/// `Read` when the first subcommand word is in `read_verbs`, else fail-closed+/// `Write`. Mirrors the `args.first()` verb check used by `command_risk_level`.+fn verb_class(args: &[String], read_verbs: &[&str]) -> CommandClass {+ match args.first().map(String::as_str) {+ Some(verb) if read_verbs.contains(&verb) => CommandClass::Read,+ _ => CommandClass::Write,+ }+}++/// Structural-safety guard for the harness-gated command flow (Option 2). Even+/// after a human approves a command, a hidden subshell / command substitution /+/// output redirect / `tee` / background `&` could smuggle a *different* command+/// past the approval summary, so these are refused outside Full (which is+/// trusted to use redirects and pipes). Mirrors the structural checks in+/// [`SecurityPolicy::is_command_allowed`].+/// Detect shell structure that can **hide execution** from `classify_command`,+/// which only inspects the base command of each `;`/`&&`/`|` segment. Command+/// and process substitution and backticks run an *inner* command classification+/// can't see (`echo $(rm -rf ~)` classifies as `echo` = Read and would run+/// unprompted), and a trailing `&` detaches a process past the gate — so these+/// stay hard-blocked outside Full.+///+/// Deliberately NOT flagged here: plain redirects (`>`, `2>&1`, `2>/dev/null`),+/// `tee`, and `${VAR}` expansion. `classify_command` already lifts a redirect /+/// `tee` to `Write`, so the gate prompts and — once the human approves — the+/// command MUST actually run. Re-blocking an approved `… 2>&1` here was the bug+/// that made Supervised mode unusable: every command the agent wrote carried a+/// `2>&1`, got approved, then silently failed this in-tool guard and never ran.+pub(in crate::security::policy) fn has_hidden_execution(command: &str) -> bool {+ // The backtick check is deliberately NOT quote-aware: any backtick in the+ // command string is blocked, even inside a double-quoted literal. Over-+ // blocking is the safe direction here. (By contrast the `&` case below is+ // quote-aware via `contains_unquoted_background_ampersand`, because that one+ // must still allow benign fd-dup redirects like `2>&1`.)+ command.contains('`')+ || command.contains("$(")+ || command.contains("<(")+ || command.contains(">(")+ || contains_unquoted_background_ampersand(command)+}