import { Box, Text } from "ink"; import { getLocalNetworkIp } from "../../core/network" import type { ProviderMode } from "../types" type EndpointLine = { label: string; value: string } export function WelcomePanel(props: { hostname: string; port: number; compact?: boolean; width?: number; providerMode?: ProviderMode; apiPassword?: string }) { const width = props.width ?? 42 const mode = props.providerMode ?? "codex" const title = `Codex2ClaudeCode - ${mode === "kiro" ? "Kiro" : "Codex"} Mode` const endpoints = welcomeEndpointLines(mode) const displayHostname = props.hostname === "0.0.0.0" || props.hostname === "::" ? "127.0.0.1" : props.hostname const localUrl = `http://${displayHostname}:${props.port}` const networkIp = getLocalNetworkIp() const networkUrl = networkIp ? `http://${networkIp}:${props.port}` : undefined return ( {title} Connect {networkUrl && } Supported endpoints {endpoints.map((endpoint, index) => ( ))} ) } export function welcomeEndpointLines(mode: ProviderMode): EndpointLine[] { const claude = [ { label: "Claude", value: "/v1/messages" }, { label: "", value: "/v1/messages/count_tokens" }, ] if (mode === "kiro") { return [ ...claude, { label: "OpenAI", value: "/v1/responses" }, { label: "", value: "/v1/chat/completions" }, { label: "Runtime", value: "/health" }, ] } return [ ...claude, { label: "OpenAI", value: "/v1/responses" }, { label: "", value: "/v1/chat/completions" }, { label: "Runtime", value: "/usage" }, { label: "", value: "/environments" }, { label: "", value: "/health" }, ] } function InfoLine(props: { label: string; value: string }) { return ( {props.label ? `${props.label}:` : ""} {props.value} ) }