Skip to main content

merry_tools/
lib.rs

1//! Built-in tools for Merry runtimes.
2//!
3//! This crate owns Merry-provided tool implementations and adapts filesystem
4//! bounded text/image reads and opt-in constrained workspace edits into
5//! runtime-registered tools without making the runtime own real workspace
6//! access policy. The public `merry::tool` declaration macro is re-exported by
7//! the facade crate; this crate only contains the implementation dependency.
8//!
9//! A workspace has one root. A relative path is normalized to root-relative
10//! components and dot segments are resolved lexically; an absolute path is used
11//! as the caller named it, and an absolute path below the workspace root is
12//! rewritten to its relative spelling so one file never has two identities. A
13//! path outside the workspace root is not limited to a configured root, because
14//! the process sandbox, accepted process profile, and trusted path rules already
15//! decide which paths exist and which of them are writable. Every spelling is
16//! accepted, including dot-prefixed components. A relative path is walked
17//! without following symlink components, and on Unix file opens also use
18//! `O_NOFOLLOW` to avoid following a symlink swapped into the leaf path between
19//! validation and open. This is not an OS sandbox and does not claim complete
20//! hardening against malicious concurrent filesystem mutation, including
21//! replacement of intermediate directories during an operation.
22
23use merry_core::ToolSpec;
24use merry_runtime::{Tool, ToolBuildError};
25
26pub mod browser;
27mod config;
28mod errors;
29mod external_tree;
30mod file;
31mod patch;
32mod path;
33mod read;
34mod registry;
35mod schema;
36pub mod ssrf;
37mod state;
38mod trace;
39pub mod web_fetch;
40
41pub use browser::{
42    BROWSER_NETWORK_TOOL, BROWSER_TAB_TOOL, BrowserConfig, BrowserLaunchSpec,
43    BrowserLauncherFuture, BrowserNetworkTool, BrowserProcessHandle, BrowserProcessLauncher,
44    BrowserSessionManager, BrowserTabTool, ProcessRunnerBrowserLauncher,
45    child_browser_process_handle,
46};
47pub use config::{WorkspaceToolConfigError, WorkspaceToolLimits, WorkspaceToolsConfig};
48pub use external_tree::{ExternalTreePolicy, ExternalWriteKind};
49pub use patch::envelope::{
50    WorkspacePatchOperationKind, WorkspacePatchSuccess, WorkspacePatchSuccessChange,
51    WorkspacePatchSuccessLine, WorkspacePatchSuccessLineKind,
52};
53pub use read::{WorkspaceReadImageSuccess, WorkspaceReadPdfPagesSuccess};
54pub use registry::WorkspaceTools;
55pub use web_fetch::{WEB_FETCH_TOOL, WebFetchConfig, WebFetchTool};
56
57/// Registered tool name for bounded read-only file reads (UTF-8 text, images, PDFs, Office docs, and notebooks).
58pub const READ_FILE_TOOL: &str = "read_file";
59/// Registered tool name for opt-in constrained file patches.
60pub const APPLY_PATCH_TOOL: &str = "apply_patch";
61
62#[cfg(test)]
63mod tests;