CodeIDE / src /agent /runner.js
FrederickSundeep's picture
commit initial 09-12-2025 007
7323886
raw
history blame contribute delete
608 Bytes
// src/agent/runner.js
import { api } from "../apiClient";
// Map language id -> file extension
const EXT_MAP = {
python: ".py",
javascript: ".js",
typescript: ".ts",
c: ".c",
cpp: ".cpp",
java: ".java",
html: ".html",
css: ".css",
json: ".json",
};
export async function runCode(code, language, stdin = "") {
const ext = EXT_MAP[language] || ".txt";
// Use a consistent name – backend only cares about extension
const filename = "main" + ext;
const res = await api.post("/execute", {
code,
filename,
input: stdin,
});
return res.data; // { output, error }
}