Skip to content

Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors

961 B
Raw Blame
import { execFileSync } from "node:child_process";
import { arch, release, type as osType } from "node:os";

let cachedDeviceModel: string | null = null;

export function getKimiDeviceModel(): string {
  if (cachedDeviceModel !== null) return cachedDeviceModel;

  const type = osType();
  const version = release();
  const architecture = arch();
  if (type === "Darwin") {
    let productVersion = version;
    try {
      productVersion =
        execFileSync("/usr/bin/sw_vers", ["-productVersion"], {
          encoding: "utf8",
          timeout: 1000,
        }).trim() || version;
    } catch {
      // Fall back to the Darwin release when sw_vers is unavailable.
    }
    cachedDeviceModel = `macOS ${productVersion} ${architecture}`;
  } else if (type === "Windows_NT") {
    cachedDeviceModel = `Windows ${version} ${architecture}`;
  } else {
    cachedDeviceModel = `${type} ${version} ${architecture}`.trim();
  }

  return cachedDeviceModel;
}