Lines 1-62javascript
1import { execFileSync } from "node:child_process";
2import { createHash } from "node:crypto";
3import fs from "node:fs";
4import os from "node:os";
5import path from "node:path";
6import { Readable } from "node:stream";
7import { pipeline } from "node:stream/promises";
9export const DEFAULT_RELEASE_MANIFEST_URL = "https://pub-2ad7ea477e7d42d39847b6376c82e059.r2.dev/stable.json";
11function platformKey() {
12 return `${process.platform}-${process.arch}`;
15function executable(root, relative) {
16 return path.join(root, ...relative.split("/"));
19function commandExists(command) {
20 if (!command) return false;
21 if (command.includes(path.sep)) return fs.existsSync(command);
22 return (process.env.PATH || "").split(path.delimiter).some((entry) => fs.existsSync(path.join(entry, command)));
25async function fetchJson(url) {
26 const response = await fetch(url, { signal: AbortSignal.timeout(30_000), headers: { "user-agent": "autopost-cli" } });
27 if (!response.ok) throw new Error(`Unable to fetch AutoPost release manifest: HTTP ${response.status}`);
HighSandbox Evasion Gated Capability
Source gates dangerous network, credential, or execution behavior behind CI, host, platform, time, or geo fingerprint checks.
src/runtime-installer.jsView on unpkg · L1 28 return response.json();
31async function download(url, destination) {
32 const response = await fetch(url, { signal: AbortSignal.timeout(10 * 60_000), headers: { "user-agent": "autopost-cli" } });
33 if (!response.ok || !response.body) throw new Error(`Unable to download AutoPost Runtime: HTTP ${response.status}`);
34 await pipeline(Readable.fromWeb(response.body), fs.createWriteStream(destination, { mode: 0o600 }));
37function sha256(filePath) {
38 return createHash("sha256").update(fs.readFileSync(filePath)).digest("hex");
41function installUv(home, progress) {
43 process.env.AUTOPOST_UV_BIN,
44 path.join(home, "tools", "bin", "uv"),
45 path.join(os.homedir(), ".local", "bin", "uv"),
48 const existing = candidates.find(commandExists);
49 if (existing) return existing;
50 if (process.platform !== "darwin") throw new Error("Automatic uv installation currently supports Apple Silicon macOS only.");
52 progress("Installing uv and managed Python support");
53 const toolsBin = path.join(home, "tools", "bin");
54 fs.mkdirSync(toolsBin, { recursive: true, mode: 0o700 });
55 const installer = path.join(home, "downloads", "uv-install.sh");
56 execFileSync("curl", ["-LsSf", "https://astral.sh/uv/install.sh", "-o", installer], { stdio: "inherit" });
57 execFileSync("/bin/sh", [installer], {
HighSame File Env Network Execution
A single source file combines environment access, network access, and code or shell execution; review context before blocking.
src/runtime-installer.jsView on unpkg · L42 58 env: { ...process.env, UV_INSTALL_DIR: toolsBin, UV_NO_MODIFY_PATH: "1" },
61 const installed = path.join(toolsBin, "uv");
62 if (!fs.existsSync(installed)) throw new Error("uv installer completed without creating the expected executable.");