Skip to content

Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.

886 B
Raw Blame
import { spawnSync } from "node:child_process";

export interface Runtime {
  readonly name: "bun" | "node";
  readonly argv: (entry: string) => Array<string>;
  readonly available: boolean;
}

const hasBin = (bin: string): boolean => {
  try {
    // `which` doesn't exist on Windows; `where` is the equivalent.
    const probe = process.platform === "win32" ? "where" : "which";
    const r = spawnSync(probe, [bin], { encoding: "utf-8" });
    return r.status === 0 && Boolean(r.stdout?.trim());
  } catch {
    return false;
  }
};

export const runtimes = (): Array<Runtime> => [
  {
    name: "bun",
    argv: (entry) => ["bun", "run", entry],
    available: hasBin("bun"),
  },
  {
    name: "node",
    argv: (entry) => [
      "node",
      "--experimental-transform-types",
      "--no-warnings=ExperimentalWarning",
      entry,
    ],
    available: hasBin("node"),
  },
];