FrederickSundeep commited on
Commit
ea51d47
·
1 Parent(s): 56922cb

commit initial 09-12-2025 006

Browse files
Files changed (1) hide show
  1. src/agent/runner.js +24 -2
src/agent/runner.js CHANGED
@@ -1,7 +1,29 @@
1
  // src/agent/runner.js
2
  import { api } from "../apiClient";
3
 
4
- export async function runCode(code, filename = "main.py") {
5
- const res = await api.post("/execute", { code, filename });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  return res.data; // { output, error }
7
  }
 
1
  // src/agent/runner.js
2
  import { api } from "../apiClient";
3
 
4
+ // Map language id -> file extension
5
+ const EXT_MAP = {
6
+ python: ".py",
7
+ javascript: ".js",
8
+ typescript: ".ts",
9
+ c: ".c",
10
+ cpp: ".cpp",
11
+ java: ".java",
12
+ html: ".html",
13
+ css: ".css",
14
+ json: ".json",
15
+ };
16
+
17
+ export async function runCode(code, language = "python") {
18
+ const ext = EXT_MAP[language] || ".txt";
19
+
20
+ // Use a consistent name – backend only cares about extension
21
+ const filename = "main" + ext;
22
+
23
+ const res = await api.post("/execute", {
24
+ code,
25
+ filename,
26
+ });
27
+
28
  return res.data; // { output, error }
29
  }