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

Function createSandbox

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

Source from the content-addressed store, hash-verified

48 * @returns A promise that resolves to the sandbox instance
49 */
50export async function createSandbox(options: CodeInterpreterOptions = {}): Promise<Sandbox> {
51 const apiKey = options.apiKey || Deno.env.get("E2B_API_KEY");
52 if (!apiKey) {
53 throw new Error("E2B_API_KEY is required either in options or as an environment variable");
54 }
55
56 try {
57 // Create a new sandbox instance using the factory method
58 // @ts-ignore - Ignore TypeScript errors for API compatibility
59 const sandbox = await Sandbox.create({ apiKey });
60 console.log("Created code interpreter sandbox");
61 return sandbox;
62 } catch (error: unknown) {
63 const errorMessage = error instanceof Error ? error.message : String(error);
64 console.error("Failed to create code interpreter sandbox:", errorMessage);
65 throw error;
66 }
67}
68
69/**
70 * Execute code in the sandbox

Callers 6

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

Calls 1

getMethod · 0.65

Tested by

no test coverage detected