Lines 1-16javascript
3const fs = require("node:fs");
4const http = require("node:http");
5const https = require("node:https");
6const os = require("node:os");
7const path = require("node:path");
8const { spawnSync } = require("node:child_process");
9const { binaryPath, downloadUrl, installRoot, releaseVersion, targetFor } = require("../lib/platform");
10function log(message) { process.stderr.write(`cortex-rmcp: ${message}\n`); }
11function download(url, destination) { return new Promise((resolve,reject)=>{ const client = url.startsWith("http:") ? http : https; const request=client.get(url,(response)=>{ if([301,302,
12function run(command,args) { const result=spawnSync(command,args,{encoding:"utf8"}); if(result.status!==0) throw new Error((result.stderr || result.stdout || `${command} failed`).trim()); }
13function extract(archive,destination,target) { fs.rmSync(destination,{recursive:true,force:true}); fs.mkdirSync(destination,{recursive:true}); if(target.archiveType==="zip") { if(process.platform==="win32") run("powershell.exe",["-NoProfile","-Command",`Expand-Archive -LiteralPath '${archive.replace(/'/g,"''")
14async function main() { if(process.env.CORTEX_RMCP_SKIP_DOWNLOAD==="1") { log("skipping binary download because CORTEX_RMCP_SKIP_DOWNLOAD=1"); return; } const target=targetFor(); const destination=binaryPath(); if(fs.existsSync(destination)) { log(`${path.basename(destination)} already installed for ${releaseVersion()}`);
15main().catch((error)=>{ log(error.message); process.exitCode=1; });
HighSame File Env Network Execution
A single source file combines environment access, network access, and code or shell execution; review context before blocking.
scripts/install.jsView on unpkg · L3 Long lines were clipped for display.