Skip to main content

resolve_tool_path

Function resolve_tool_path 

Source
pub fn resolve_tool_path(
    project_root: Option<&str>,
    shell_cwd: Option<&str>,
    raw: &str,
) -> Result<String, String>
Expand description

Resolve a (possibly relative) tool path to a normalized, jail-checked, secret-screened absolute path.

Resolution order for relative inputs:

  1. absolute or already-existing path → used as-is
  2. <project_root>/<path> if it exists
  3. <shell_cwd>/<path> if a shell cwd is known
  4. <jail_root>/<path> as a last resort

jail_root is project_root, else shell_cwd, else ".". The result is confined to the jail root via crate::core::pathjail::jail_path and screened by the secret-path I/O boundary.

Performs blocking filesystem exists() checks; callers on async runtimes must wrap this in tokio::task::block_in_place.