import { processFileArguments } from "./cli/file-processor.js";
import { buildInitialMessage } from "./cli/initial-message.js";
import { isLocalPath, resolvePath } from "./utils/paths.js";
const NO_UI_EXCLUDED_TOOLS = ["ask_user_question"];
export function resolveExcludedToolsForAppMode(appMode, excludedTools) {
    switch (appMode) {
        case "interactive":
        case "rpc":
            return excludedTools;
        case "print":
        case "json":
            return [...new Set([...(excludedTools ?? []), ...NO_UI_EXCLUDED_TOOLS])];
    }
}
export function resolveAppMode(parsed, stdinIsTTY, stdoutIsTTY) {
    if (parsed.mode === "rpc") {
        return "rpc";
    }
    if (parsed.mode === "json") {
        return "json";
    }
    if (parsed.print || !stdinIsTTY || !stdoutIsTTY) {
        return "print";
    }
    return "interactive";
}
export function isReadOnlyRuntimeMetadataCommand(parsed) {
    return parsed.help === true || parsed.listModels !== undefined;
}
export function isPlainRuntimeMetadataCommand(parsed) {
    return !parsed.print && parsed.mode === undefined && isReadOnlyRuntimeMetadataCommand(parsed);
}
export function toPrintOutputMode(appMode) {
    return appMode === "json" ? "json" : "text";
}
export async function prepareInitialMessage(parsed, autoResizeImages, stdinContent) {
    if (parsed.fileArgs.length === 0) {
        return buildInitialMessage({ parsed, stdinContent });
    }
    const { text, images } = await processFileArguments(parsed.fileArgs, { autoResizeImages });
    return buildInitialMessage({
        parsed,
        fileText: text,
        fileImages: images,
        stdinContent,
    });
}
export function resolveCliPaths(cwd, paths) {
    return paths?.map((value) => (isLocalPath(value) ? resolvePath(value, cwd) : value));
}
//# sourceMappingURL=main-app-mode.js.map