import { motion } from "framer-motion"; import { CheckCircle, XCircle, ArrowRight, ArrowCounterClockwise, Terminal, } from "@phosphor-icons/react"; import { ActionButton } from "../ui"; import type { TerminalCommandKey } from "@shared/contracts"; interface NodeCheckStepProps { nodeStatus: { installed: boolean; version: string | null } | null; checking: boolean; onCheck: () => void; onInstall: (commandKey: TerminalCommandKey) => void; onContinue: () => void; onBack: () => void; t: (key: string) => string; } const INSTALL_COMMANDS: Record = { darwin: { label: "macOS", code: "brew install node@22", commandKey: "install_node_darwin", }, win32: { label: "Windows", code: "winget install -e --id OpenJS.NodeJS.LTS", commandKey: "install_node_win32", }, linux: { label: "Linux", code: `# Download and install nvm: curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.4/install.sh | bash # in lieu of restarting the shell \\. "$HOME/.nvm/nvm.sh" # Download and install Node.js: nvm install 22 # Verify the Node.js version: node -v`, commandKey: "install_node_linux", }, }; export function NodeCheckStep({ nodeStatus, checking, onCheck, onInstall, onContinue, onBack, t, }: NodeCheckStepProps) { const platform = window.agentCompany.platform; const platformInfo = INSTALL_COMMANDS[platform] ?? INSTALL_COMMANDS.linux; return (
{t("onboarding.stepLabel1")} 1 / 5 — {t("onboarding.nodeCheckStep")}
{t("onboarding.nodeCheckTitle")}
{/* Status */}
{checking ? ( ) : nodeStatus?.installed ? ( ) : nodeStatus ? ( ) : null} {checking ? ( {t("onboarding.providerChecking")}... ) : nodeStatus?.installed ? ( {t("onboarding.nodeInstalled").replace("{version}", nodeStatus.version ?? "")} ) : nodeStatus ? ( {t("onboarding.nodeNotInstalled")} ) : null}
{/* Platform-specific install instructions (shown when not installed) */} {nodeStatus && !nodeStatus.installed && (
{platformInfo.label}
            {platformInfo.code}
          
onInstall(platformInfo.commandKey)} icon={Terminal} />
)} {/* Check Again */}
{/* Bottom bar */}
); }