Skip to content

Open source Grok Bot alternative, Bring your own agent and subscription: message Claude Code, Codex, Gemini CLI, Cursor, Copilot and 40+ AI agents as bots on your own computer, from iPhone, Mac, Windows, Linux or terminal. Agent-agnostic and free. Also a Muse and Dots alternative. Built in Rust.

448 B
Raw Blame
import { randomUUID } from "node:crypto";
import { promises as fs } from "node:fs";

/** A concurrent upload/GET must never see a partially written asset. */
export async function writeAsset(filename: string, bytes: Buffer) {
  const temporary = `${filename}.${randomUUID()}.tmp`;
  try {
    await fs.writeFile(temporary, bytes);
    await fs.rename(temporary, filename);
  } finally {
    await fs.unlink(temporary).catch(() => undefined);
  }
}