export function initialAgentMode(permissions) {
    if (permissions.allowWrite && permissions.allowShell) {
        return "bypass";
    }
    return permissions.allowWrite || permissions.allowShell ? "build" : "plan";
}
export function nextAgentMode(currentMode) {
    if (currentMode === "plan") {
        return "build";
    }
    if (currentMode === "build") {
        return "bypass";
    }
    return "plan";
}
export function permissionsForMode(mode) {
    return {
        allowWrite: mode === "bypass",
        allowShell: mode === "bypass"
    };
}
export function modePermissionLabel(mode, permission, permissions) {
    if (permissions?.[permission === "write" ? "allowWrite" : "allowShell"]) {
        return "on";
    }
    if (mode === "plan") {
        return "off";
    }
    if (mode === "build") {
        return "approval";
    }
    return permission === "write" ? "on" : "on";
}
export function shouldBypassApproval(options) {
    if (options.mode !== "bypass") {
        return false;
    }
    if (options.permission === "write") {
        return options.permissions.allowWrite;
    }
    if (options.permission === "shell") {
        return options.permissions.allowShell;
    }
    return options.permission === "external_file" && options.allowExternalFileAnalysis;
}
export function modeDescription(mode) {
    if (mode === "plan") {
        return "plan mode is read-only";
    }
    if (mode === "build") {
        return "build mode can edit after approval";
    }
    return "build + bypass runs writes and shell without per-tool approval";
}
//# sourceMappingURL=modes.js.map