MCPcopy Create free account
hub / github.com/agenticsorg/edge-agents / createSandbox

Function createSandbox

scripts/sparc2/scripts/e2b-code-interpreter.ts:45–61  ·  view source on GitHub ↗
(options: CodeInterpreterOptions = {})

Source from the content-addressed store, hash-verified

43 * @returns A CodeInterpreter instance
44 */
45export async function createSandbox(options: CodeInterpreterOptions = {}): Promise<CodeInterpreter> {
46 const apiKey = options.apiKey || Deno.env.get("E2B_API_KEY");
47 if (!apiKey) {
48 throw new Error("E2B_API_KEY is required either in options or as an environment variable");
49 }
50
51 try {
52 // Create a real E2B Code Interpreter instance
53 const interpreter = new CodeInterpreter({ apiKey });
54 await logMessage("info", "Created code interpreter sandbox");
55 return interpreter;
56 } catch (error: unknown) {
57 const errorMessage = error instanceof Error ? error.message : String(error);
58 await logMessage("error", "Failed to create code interpreter sandbox", { error: errorMessage });
59 throw error;
60 }
61}
62
63/**
64 * Execute code in the sandbox

Callers 7

mainFunction · 0.90
mainFunction · 0.90
executeCodeFunction · 0.70
writeFileFunction · 0.70
readFileFunction · 0.70
listFilesFunction · 0.70
installPackagesFunction · 0.70

Calls 2

logMessageFunction · 0.90
getMethod · 0.65

Tested by

no test coverage detected