import { findExecutableOnPath } from "../codex/codex-cli.js";
export function resolveHermesCli(env = process.env, explicitPath) {
    const configuredPath = optionalString(explicitPath) ?? optionalString(env.HERMES_CLI_PATH);
    if (configuredPath) {
        return { path: configuredPath, source: "env" };
    }
    const pathMatch = findExecutableOnPath("hermes", env.PATH, { pathext: env.PATHEXT });
    return pathMatch ? { path: pathMatch, source: "path" } : { source: "missing" };
}
export function describeHermesCli(resolution) {
    if (resolution.path) {
        return `${resolution.source} (${resolution.path})`;
    }
    return "missing";
}
function optionalString(value) {
    const trimmed = value?.trim();
    return trimmed ? trimmed : undefined;
}
