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

917 B
Raw Blame
import { execSync } from "node:child_process";

export function copyToClipboard(text) {
  try {
    const execOpts = { input: text, stdio: ["pipe", "ignore", "ignore"], timeout: 2000 };
    if (process.platform === "darwin") {
      execSync("pbcopy", execOpts);
    } else if (process.platform === "win32") {
      execSync("clip", execOpts);
    } else {
      try {
        execSync("xclip -selection clipboard", execOpts);
      } catch {
        try {
          execSync("xsel --clipboard --input", execOpts);
        } catch {
          execSync("wl-copy", execOpts);
        }
      }
    }
    return true;
  } catch {
    return false;
  }
}

export function isClipboardSupported() {
  if (process.platform === "darwin" || process.platform === "win32") return true;
  try {
    execSync("which xclip || which xsel || which wl-copy", { stdio: "ignore" });
    return true;
  } catch {
    return false;
  }
}