@@ -20,15 +20,15 @@ class MultiCodeExecutor(SandboxTool):
2020
2121 _name = 'multi_code_executor'
2222 _sandbox_type = SandboxType .DOCKER
23- _description = 'Execute code in various languages (python, cpp, go, java, nodejs, ts, rust, php, bash, pytest, jest, go_test, lua, r, perl, d_ut, ruby, scala, julia, kotlin_script, verilog, lean, swift, racket) with runtime tuning' # noqa: E501
23+ _description = 'Execute code in various languages (python, cpp, csharp, go, java, nodejs, ts, rust, php, bash, pytest, jest, go_test, lua, r, perl, d_ut, ruby, scala, julia, kotlin_script, verilog, lean, swift, racket) with runtime tuning' # noqa: E501
2424 _parameters = ToolParams (
2525 type = 'object' ,
2626 properties = {
2727 'language' : {
2828 'type' :
2929 'string' ,
3030 'description' :
31- 'Language to execute (python, cpp, go, java, nodejs, ts, rust, php, bash, pytest, jest, go_test, lua, r, perl, d_ut, ruby, scala, julia, kotlin_script, verilog, lean, swift, racket)' # noqa: E501
31+ 'Language to execute (python, cpp, csharp, go, java, nodejs, ts, rust, php, bash, pytest, jest, go_test, lua, r, perl, d_ut, ruby, scala, julia, kotlin_script, verilog, lean, swift, racket)' # noqa: E501
3232 },
3333 'code' : {
3434 'type' : 'string' ,
@@ -91,6 +91,8 @@ class MultiCodeExecutor(SandboxTool):
9191
9292 # Languages that benefit from a tuned Python PATH prefix
9393 LANGS_REQUIRE_PY_ENV = {'python' , 'pytest' }
94+ # Include all jars under /root/sandbox/runtime/java and the current dir in the classpath
95+ JAVA_RUNTIME_CP : str = '/root/sandbox/runtime/java/*:.'
9496
9597 async def execute (
9698 self ,
@@ -287,9 +289,7 @@ async def _prebuild_setup(
287289 """Run language-specific pre-build setup. Return ToolResult on error, else None."""
288290 if lang != 'csharp' :
289291 return None
290- init_res = await self ._exec_in_dir (
291- sandbox_context , workdir , 'dotnet new console -n app -o .' , timeout = compile_timeout
292- )
292+ init_res = await self ._exec_in_dir (sandbox_context , workdir , 'dotnet new console -o .' , timeout = compile_timeout )
293293 if init_res .exit_code != 0 :
294294 return ToolResult (
295295 tool_name = self .name ,
@@ -324,15 +324,16 @@ def _build_commands(self, lang: str, main_filename: str, code: Optional[str],
324324 'cpp' :
325325 lambda : self ._cpp_commands (main_filename ),
326326 'csharp' :
327- lambda : (None , 'dotnet run' ),
327+ lambda : (None , 'dotnet run --project . ' ),
328328 'go' :
329329 lambda : (f'go build -o app { main_filename } ' , './app' ),
330330 'go_test' :
331- lambda : (None , f'go test { main_filename } ' ),
331+ lambda : (None , f'go mod init { main_filename } && go test { main_filename } ' ),
332332 'java' :
333- lambda : (f'javac { main_filename } ' , 'java -ea Main' ),
333+ lambda :
334+ (f'javac -cp "{ self .JAVA_RUNTIME_CP } " { main_filename } ' , f'java -ea -cp "{ self .JAVA_RUNTIME_CP } " Main' ),
334335 'junit' :
335- lambda : ('javac *.java' , 'java -ea Main' ),
336+ lambda : (f 'javac -cp " { self . JAVA_RUNTIME_CP } " *.java' , f 'java -ea -cp " { self . JAVA_RUNTIME_CP } " Main' ),
336337 'nodejs' :
337338 lambda : (None , f'node { main_filename } ' ),
338339 'js' :
0 commit comments