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: files changed crates/openhuman-core/src/hooks/README.md,crates/openhuman-core/src/tools/impl/
Steven Enamakel90f7feaf0802
diff --git a/crates/openhuman-core/src/hooks/README.md b/crates/openhuman-core/src/hooks/README.mdindex 5b77617381..353ebed5fe 100644--- a/crates/openhuman-core/src/hooks/README.md+++ b/crates/openhuman-core/src/hooks/README.md@@ -9,9 +9,10 @@ written for either host runs on the other unchanged.This is a different "hook" from two other things in the codebase: thein-process Rust traits an *embedding host* installs by compiling against the-core (`agent/hooks.rs`'s `PostTurnHook`, `agent/stop_hooks.rs`), and inbound-webhook ingestion (`skills/webhooks/`). This module bridges onto the first via-`bridge.rs`; it is unrelated to the second.+core (`ToolHook` and `PostTurnHook` in `agent/hooks.rs`, `agent/stop_hooks.rs`),+and inbound webhook ingestion (`skills/webhooks/`, RPC namespace `webhooks`).+This module bridges onto the first via `bridge.rs`; it is unrelated to the+second.## Submodule map@@ -24,7 +25,7 @@ webhook ingestion (`skills/webhooks/`). This module bridges onto the first via| `engine.rs` | Selection, ordering, aggregation, session state || `context.rs` | Assembling the envelope from ambient host facts || `bridge.rs` | Mounting the engine on the harness's existing tool/turn seams |-| `ops.rs` | Lifecycle moments (init, prompt submission, subagent start) that have no existing seam |+| `ops.rs` | `init` plus the lifecycle moments that have no tool seam (`prompt_submitted`, `subagent_starting`, and the not-yet-called session/compact/thought/subagent-stop entry points) || `prompt_eval.rs` | Model evaluation for `prompt`-kind hooks || `followup.rs` | Queueing what a `stop` hook asks for next || `schemas.rs` | RPC namespace `hooks`: `list`, `reload`, `test` |@@ -43,44 +44,74 @@ between running hooks sequentially in the turn's path and spawning them onto abackground task. Do not weaken this: an audit hook that hangs must not hangthe agent, and a gating hook must not be demoted to fire-and-forget.-`exec.rs` fails open on a hook error (timeout, missing interpreter,-unparseable stdout) unless the hook definition sets `fail_closed`, in which-case a failure denies. Do not change this default without reading-`AGENTS.md`'s autonomy-policy section — a hook allowing an action does not-bypass the approval gate underneath it; both still apply.+`exec.rs` reads a command hook's exit code: `0` parses stdout as a+`HookOutput` (the last complete JSON object on stdout, so progress lines are+fine), `2` denies regardless of stdout with stderr as the reason, and anything+else — including a timeout, a missing interpreter, or unparseable stdout — is a+failure that fails open unless the definition sets `fail_closed`, in which case+it denies. Do not change this default without reading the configuration and+security section of `AGENTS.md`. A hook that answers `allow` only lets the call+continue to the autonomy policy and approval gate underneath it; both still+apply. A hook that answers `ask` reaches the harness as+`ToolHookDecision::Ask`, and `agent/tinyagents/middleware_part_03.rs` has no+approval channel, so today it denies rather than quietly allowing.++Not every event in `types::HookEvent::ALL` fires yet. `HookEvent::is_wired`+lists the ones without a call site (`sessionStart`, `sessionEnd`,+`preCompact`, `afterAgentThought`, `subagentStop`); the loader warns when a+`hooks.json` registers one. Move an event out of that list only when its call+site lands.## Layering (`config.rs`)-Four `hooks.json` layers are read and concatenated, lowest trust last:-system (machine-wide, operator-managed), user (`~/.openhuman/hooks.json`),-workspace (the core's workspace directory), project (`<project>/.openhuman/hooks.json`-inside the action dir). This is the opposite of how `config.toml` merges-(override, not concatenate) — deliberately, since concatenation combined with-`HookOutput::merge`'s strictest-wins rule is the only composition that can't-be used to loosen policy.+Four `hooks.json` layers are read by `layer_paths` and concatenated, lowest+trust last:++| `HookLayer` | Path |+| --- | --- |+| `System` | `/etc/openhuman/hooks.json` (Linux), `/Library/Application Support/OpenHuman/hooks.json` (macOS), `%ProgramData%\OpenHuman\hooks.json` (Windows) |+| `User` | `~/.openhuman/hooks.json` |+| `Workspace` | `<workspace_dir>/hooks.json` |+| `Project` | `<action_dir>/.openhuman/hooks.json` |++This is the opposite of how `config.toml` merges (override, not concatenate)+— deliberately, since concatenation combined with `HookOutput::merge`'s+strictest-wins rule is the only composition that can't be used to loosen+policy. `HookDefinition::layer` and `source_dir` are `skip_deserializing` and+stamped from the file's own location, so a `hooks.json` cannot claim a more+trusted layer. Only `version: 1` is accepted; a missing file is silent, an+unreadable or malformed one becomes a `HookConfig::warnings` entry surfaced by+`hooks.list`.## `prompt`-kind hooksMost hooks are `command`: spawn a program, hand it the event JSON on stdin,read a decision from stdout. A `prompt` hook is a policy written in Englishinstead — `prompt_eval.rs` asks the configured model to judge a condition,-via a one-shot `inference::ops::inference_prompt` call. A hook definition may-override the model; the override is applied by cloning the loaded `Config`-rather than mutating it, so nothing persists and a concurrent turn on the-real config is unaffected. Reserve `prompt` hooks for rare, high-stakes-moments — they cost a model call per event.+via a one-shot `inference::ops::inference_prompt` call capped at 200 output+tokens. A hook definition may override the model; the override is applied to+the `Config` copy returned by `load_config_with_timeout` for that one call+(`default_model`), so nothing persists and a concurrent turn on the real+config is unaffected. Reserve `prompt` hooks for rare, high-stakes moments —+they cost a model call per event.## Bridge (`bridge.rs`)The harness already carries in-process hook seams (`ToolHook`, `PostTurnHook`in `agent/hooks.rs`). Rather than adding a second set of call sites, theengine registers itself through those seams once at bootstrap-(`ConfiguredHookBridge::install`/`uninstall`). Cursor's `beforeShellExecution`,-`beforeReadFile`, and `afterFileEdit` are not separate call sites here — the-bridge derives them from the ordinary tool seam by matching tool names-(`shell`/`run_command`/`bash`/... , `file_read`/`read_diff`, `file_write`/`edit`/...)-and firing both the generic `preToolUse` event and the specialised one with a-Cursor-shaped payload.+(`ConfiguredHookBridge::install`/`uninstall`, registered under+`BRIDGE_HOOK_NAME` so a rebuilt core replaces rather than duplicates it).+Cursor's `beforeShellExecution`, `beforeReadFile`, and `afterFileEdit` are not+separate call sites here — `derived_event` maps tool names onto them+(`SHELL_TOOLS`: `shell`/`run_command`/`bash`/...; `READ_TOOLS`:+`file_read`/`read_diff`; `WRITE_TOOLS`: `file_write`/`edit`/...; MCP tools+get `before`/`afterMcpExecution`). On the pre side the bridge fires+`preToolUse` and then the derived `before*` event with a Cursor-shaped+payload, merging both verdicts; on the post side it fires `postToolUse` (or+`postToolUseFailure`) and then `afterShellExecution`/`afterFileEdit`. A write+therefore has no derived pre-event — denying it belongs to `preToolUse`. The+`PostTurnHook` impl fires `afterAgentResponse` and `stop`.## Wiring@@ -101,8 +132,10 @@ Cursor-shaped payload.## Tests-`bridge_tests.rs`, `exec_tests.rs`, `followup_tests.rs`, `matcher_tests.rs`,-and `hooks_tests.rs` (aggregated via `#[path]` in `mod.rs`).+`bridge_tests.rs`, `exec_tests.rs`, `followup_tests.rs`, and+`matcher_tests.rs` are attached with `#[path]` from their own module files;+`hooks_tests.rs` (config loading, engine, verdict merge) is attached from+`mod.rs`.## Related docsdiff --git a/crates/openhuman-core/src/tools/impl/README.md b/crates/openhuman-core/src/tools/impl/README.mdindex 894317c2e5..0e9b794097 100644--- a/crates/openhuman-core/src/tools/impl/README.md+++ b/crates/openhuman-core/src/tools/impl/README.md@@ -1,40 +1,51 @@# tools/implBuilt-in implementations of the cross-cutting tool families that `tools/ops.rs`-assembles into the agent registry. Per the ownership rule in `AGENTS.md`: only-genuinely cross-cutting capabilities (filesystem, browser, generic-process/system, generic network, document/presentation generation, tool-search-meta tools) live here. Domain-owned tools (memory, cron, wallet, composio,-codegraph, integrations, voice, agent sub-dispatch) live in their own domain's-`tools.rs` and are only re-exported through `tools/mod.rs` — do not add a new-family under `impl/` for a domain capability.--`impl/mod.rs` aggregates the seven families and gates `document`/`presentation`-behind the `documents` Cargo feature; the other five are unconditional. See-[`../README.md`](../README.md) for the registry, policy, and RPC layer this+assembles into the agent registry. Ownership rule from `AGENTS.md`: only+cross-cutting capabilities (filesystem, browser, generic process/system, generic+network, document/presentation generation, tool-surface meta helpers) live+here. Domain-owned tools (memory, cron, wallet, composio, integrations, voice,+agent sub-dispatch, ...) live in their own domain's `tools.rs` and are only+re-exported through `tools/mod.rs`. Do not add a family under `impl/` for a+domain capability.++`tools/mod.rs` mounts this directory as `#[path = "impl/mod.rs"] pub(crate) mod+implementations` (`impl` is a keyword) and glob re-exports it, so tool structs+are imported as `crate::tools::*`. `impl/mod.rs` gates `document/` and+`presentation/` behind the `documents` Cargo feature; the other five families+compile unconditionally. `meta/` is declared but not glob re-exported, so its+items are reached as `crate::tools::implementations::meta::...`.++See [`../README.md`](../README.md) for the registry, policy, and RPC layer thisfeeds, and [`../../security/README.md`](../../security/README.md) for the`SecurityPolicy` threaded through nearly every tool here (path validation,trusted roots, egress gating).## Families+The gates below are what `tools/ops.rs::all_tools_with_runtime` checks before+registering a tool. "Exported, not registered" means the struct is public and+tested but no production assembly site constructs it today.+| Family | Tools | Registration gate || --- | --- | --- |-| `system/` | `ShellTool`, `NodeExecTool`, `NpmExecTool`, `PythonExecTool`, `InstallToolTool`, `DetectToolsTool`, `CurrentTimeTool`, `ResolveTimeTool`, `ScheduleTool`, `ProxyConfigTool`, `PushoverTool`, `LspTool`, `ToolStatsTool`, `UpdateCheckTool`, `UpdateApplyTool`, `InsertSqlRecordTool`, `WorkspaceStateTool`, plus internal `command_output`/`retrieve_tool_output` helpers | `node_exec`/`npm_exec` and `shell`'s PATH injection require `node.enabled`; `LspTool` requires the `OPENHUMAN_LSP_ENABLED` env var (`lsp_capability_enabled`) |-| `filesystem/` | `FileReadTool`, `FileWriteTool`, `EditFileTool`, `ApplyPatchTool`, `GrepTool`, `GlobTool`, `ListFilesTool`, `ReadDiffTool`, `CsvExportTool`, `GitOperationsTool`, `RunLinterTool`, `RunTestsTool`, `UpdateMemoryMdTool` | unconditional |-| `browser/` | `BrowserTool` (DOM-snapshot automation, pluggable backend), `BrowserOpenTool`, `ImageInfoTool` | `browser.enabled`; allow-all reach requires `OPENHUMAN_BROWSER_ALLOW_ALL`, otherwise `browser_allowed_domains` narrows the shared `http_request` allowlist by stripping `"*"`. Ships a Playwright backend (`playwright_backend.rs` + `playwright_runner.mjs`) alongside `native_backend.rs` |-| `network/` | `HttpRequestTool`, `WebFetchTool`, `CurlTool`, `GitbooksSearchTool`/`GitbooksGetPageTool`, `GmailUnsubscribeTool`, and (feature `mcp`) `McpListServersTool`/`McpListToolsTool`/`McpCallTool` + the `mcp_setup` family (`McpSetupSearchTool`, `McpSetupGetTool`, `McpSetupInstallAndConnectTool`, `McpSetupRequestSecretTool`, `McpSetupTestConnectionTool`); `url_guard` is the shared SSRF/allowlist validator, not a tool | `gitbooks_*` requires `gitbooks.enabled` plus the docs-domain MCP allowlist; the `mcp`/`mcp_setup` tools are compiled only under the `mcp` Cargo feature |-| `document/` (feature `documents`) | `DocumentTool` (`generate_document`) | builds a `.docx` via the native `engine` module (no subprocess); writes an artifact through `agent::artifacts` (`create_artifact`/`finalize_artifact`/`fail_artifact`, kind `Document`) and persists `args.json` for the Retry path |-| `presentation/` (feature `documents`) | `PresentationTool` (`generate_presentation`) | builds a `.pptx` via the native `engine` module; same artifact lifecycle as `document/` (kind `Presentation`), so both stay parallel producers |-| `meta/` | `ToolSearchTool` (`tool_search`), `collapse` helpers (`resolve`, `strictest_permission`, `any_external_effect`, `unknown_action_message`, `CollapsedAction`) | unconditional; `tool_search` is the lookup half of `ToolExposure::Deferred` — it lets the model discover tools that are registered but hidden from its default catalog. `collapse` merges a multi-action tool's per-action schemas/permissions into one entry |+| `system/` | `ShellTool`, `NodeExecTool`, `NpmExecTool`, `PythonExecTool`, `InstallToolTool`, `DetectToolsTool`, `CurrentTimeTool`, `ResolveTimeTool`, `ScheduleTool`, `ProxyConfigTool`, `PushoverTool`, `LspTool`, `ToolStatsTool`, `UpdateCheckTool`, `UpdateApplyTool`, `InsertSqlRecordTool`, `WorkspaceStateTool`, `RetrieveToolOutputTool`; `command_output.rs` is a shared helper, not a tool | `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 |+| `filesystem/` | `FileReadTool`, `FileWriteTool`, `EditFileTool`, `ApplyPatchTool`, `GrepTool`, `GlobTool`, `ListFilesTool`, `ReadDiffTool`, `CsvExportTool`, `GitOperationsTool`, `RunLinterTool`, `RunTestsTool`, `UpdateMemoryMdTool` | always registered, except `ReadDiffTool`, `RunLinterTool`, and `RunTestsTool`, which are exported, not registered |+| `browser/` | `BrowserTool` (DOM-snapshot automation with pluggable backend: `agent_browser`, `playwright`, `rust_native`, `computer_use`, `auto`), `BrowserOpenTool`, `ImageInfoTool` | `BrowserTool`/`BrowserOpenTool` need `browser.enabled`; `ImageInfoTool` is always registered. The browser host allowlist is `browser_allowed_domains(http_request.allowed_domains)`, which strips the `"*"` wildcard; allow-all needs `OPENHUMAN_BROWSER_ALLOW_ALL`. Playwright ships as `playwright_backend.rs` + `include_str!("playwright_runner.mjs")`; `native_backend.rs` (fantoccini) compiles only with the `browser-native` Cargo feature |+| `network/` | `HttpRequestTool`, `WebFetchTool`, `CurlTool`, `GitbooksSearchTool`, `GitbooksGetPageTool`, `GmailUnsubscribeTool`, and under the `mcp` Cargo feature `McpListServersTool`, `McpListToolsTool`, `McpCallTool`, `McpSetupSearchTool`, `McpSetupGetTool`, `McpSetupInstallAndConnectTool`, `McpSetupRequestSecretTool`, `McpSetupTestConnectionTool`; `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`; the `mcp_setup_*` tools register whenever the `mcp` feature is on; `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 |+| `document/` (feature `documents`) | `DocumentTool` (`generate_document`) | always registered when compiled. Builds `.docx` bytes via the pure-Rust `engine` module (`docx-rs`, no subprocess) inside `spawn_blocking` + `tokio::time::timeout`; allocates the artifact with `agent::artifacts::create_artifact` (kind `Document`), persists `args.json` next to it for the failed-card Retry path, then `finalize_artifact` or `fail_artifact` |+| `presentation/` (feature `documents`) | `PresentationTool` (`generate_presentation`) | always registered when compiled. Same shape as `document/` with `ppt-rs` producing `.pptx` and kind `Presentation` |+| `meta/` | `ToolSearchTool` (`tool_search`, name constant `TOOL_SEARCH_NAME`), `ToolSearchIndex`, `ToolSearchHandle`, `strip_deferred_from_visible`, `bind_tool_search_index`; `collapse` helpers (`resolve`, `merge_action_schemas`, `args_without_action`, `strictest_permission`, `any_external_effect`, `unknown_action_message`, `CollapsedAction`) | not registered: nothing in `tools/ops.rs` or the session builder constructs `ToolSearchTool` or calls `bind_tool_search_index` today, so `ToolExposure::Deferred` tools have no lookup path. The `collapse` helpers are used by `cron/tools/collapsed.rs` and `memory/tools/collapsed.rs` to merge a multi-action tool's per-action schemas and permissions into one entry |## Notes-- `document/` and `presentation/` are deliberately kept structurally parallel- (validate input → allocate artifact → generate bytes off the async runtime- via `spawn_blocking` + timeout → finalize/fail the artifact) so future- artifact-producing tools can follow the same shape.-- `meta/` is not under `system/` because it isn't a host capability the user- cares about — it's the model introspecting its own tool surface.-- Tool struct names above are re-exported through `impl/mod.rs` and then- `tools/mod.rs`; import via `crate::tools::*`, not `crate::tools::implementations::<family>::*`.+- `document/` and `presentation/` are kept structurally parallel (validate+ input, allocate artifact, generate bytes off the async runtime, finalize or+ fail the artifact) so further artifact-producing tools follow the same shape.+- `meta/` sits outside `system/` because it is the model introspecting its own+ tool surface, not a host capability.+- `system/mod.rs` and `filesystem/mod.rs` each carry a+ `security_for_tool_context` that grants the run's TinyAgents workspace+ descriptor as `action_dir` plus a `ReadWrite` trusted root on a per-call+ clone of `SecurityPolicy`. They must stay in step; `is_always_forbidden` and+ `is_workspace_internal_path` are evaluated before any trusted-root shortcut.