Spaces:
Running
Running
| // src/agent/runner.js | |
| import { api } from "../apiClient"; | |
| // this is not using now | |
| // 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 } | |
| } | |