← Files RivetARCHIVED FILE

node_modules/rivet-design/dist/cli/runnerSelection.js

2.88 KB · Nov 7, 2026 · 13:16 UTC

↓ Download file

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.resolveRunner = exports.RUNNER_UNAVAILABLE_REMEDIATION = exports.explicitRunnerSelectionError = exports.EXPLICIT_RUNNER_SELECTIONS = exports.EXECUTABLE_RUNNER_VENDORS = exports.RUNNER_VENDOR_BINARIES = void 0;
exports.RUNNER_VENDOR_BINARIES = {
    claude: 'claude',
    codex: 'codex',
    cursor: 'cursor-agent',
};
exports.EXECUTABLE_RUNNER_VENDORS = [
    'claude',
    'codex',
    'cursor',
];
exports.EXPLICIT_RUNNER_SELECTIONS = [
    ...exports.EXECUTABLE_RUNNER_VENDORS,
];
const explicitRunnerSelectionError = (value) => {
    if (value === undefined) {
        return null;
    }
    if (exports.EXPLICIT_RUNNER_SELECTIONS.includes(value.trim().toLowerCase())) {
        return null;
    }
    return `Flag --agent must be one of ${exports.EXPLICIT_RUNNER_SELECTIONS.join('|')} (got "${value}")`;
};
exports.explicitRunnerSelectionError = explicitRunnerSelectionError;
const asExecutableVendor = (value) => {
    if (!value)
        return null;
    const candidate = value.trim().toLowerCase();
    return exports.EXECUTABLE_RUNNER_VENDORS.includes(candidate)
        ? candidate
        : null;
};
const asExplicitSelection = (value) => {
    return asExecutableVendor(value);
};
exports.RUNNER_UNAVAILABLE_REMEDIATION = 'If the CLI is installed as a shell alias (e.g. Claude Code\'s local ' +
    'install), expose a real binary (`ln -s ~/.claude/local/claude ' +
    '~/.local/bin/claude`) or set `runnerPaths.<vendor>` to its absolute ' +
    'path in ~/.rivet/config.json, then restart the session.';
const resolveRunner = (options) => {
    const paths = options.runnerPaths ?? {};
    const runner = (vendor, source) => ({
        mode: 'runner',
        vendor,
        source,
        ...(paths[vendor] ? { binaryPath: paths[vendor] } : {}),
    });
    const explicit = asExplicitSelection(options.explicitAgent);
    if (explicit) {
        return runner(explicit, 'flag');
    }
    const configured = asExplicitSelection(options.configuredRunner);
    if (configured) {
        return runner(configured, 'user_config');
    }
    const handoffVendor = asExecutableVendor(options.handoff?.agent);
    if (handoffVendor && paths[handoffVendor]) {
        return runner(handoffVendor, 'handoff');
    }
    for (const vendor of exports.EXECUTABLE_RUNNER_VENDORS) {
        if (paths[vendor]) {
            return runner(vendor, 'declared');
        }
    }
    const missing = handoffVendor
        ? `no \`${exports.RUNNER_VENDOR_BINARIES[handoffVendor]}\` binary (or any other vendor CLI)`
        : 'no vendor CLI (claude, codex, or cursor-agent)';
    return {
        mode: 'unavailable',
        reason: `${missing} was found in the invoking environment, and none is ` +
            `configured. ${exports.RUNNER_UNAVAILABLE_REMEDIATION}`,
    };
};
exports.resolveRunner = resolveRunner;
//# sourceMappingURL=runnerSelection.js.map

SHA-256: 52b2fde63854d3f6fede3077d600522642bdfcbe9e7db654d6433b98fd98cecd