* Execute code in a sandbox * @param code Code to execute * @param options Execution options * @returns Execution result
(
code: string,
options?: "python" | "javascript" | "typescript" | {
language?: "python" | "javascript" | "typescript";
stream?: boolean;
},
)
| 355 | * @returns Execution result |
| 356 | */ |
| 357 | async executeCode( |
| 358 | code: string, |
| 359 | options?: "python" | "javascript" | "typescript" | { |
| 360 | language?: "python" | "javascript" | "typescript"; |
| 361 | stream?: boolean; |
| 362 | }, |
| 363 | ) { |
| 364 | let language: "python" | "javascript" | "typescript" = "javascript"; |
| 365 | let stream = true; |
| 366 | |
| 367 | if (typeof options === "string") { |
| 368 | language = options; |
| 369 | } else if (options && typeof options === "object") { |
| 370 | language = options.language || language; |
| 371 | stream = options.stream !== undefined ? options.stream : stream; |
| 372 | } |
| 373 | |
| 374 | await logInfo(`Executing code`, { language, codeLength: code.length }); |
| 375 | |
| 376 | return executeCode(code, { language, stream }); |
| 377 | } |
| 378 | } |
| 379 | |
| 380 | /** |
nothing calls this directly
no test coverage detected