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

Function writeFile

scripts/e2b/e2b-code-interpreter.ts:231–253  ·  view source on GitHub ↗
(
  path: string, 
  content: string,
  options: CodeInterpreterOptions = {},
  existingSandbox?: Sandbox
)

Source from the content-addressed store, hash-verified

229 * @param options Options for the sandbox
230 */
231export async function writeFile(
232 path: string,
233 content: string,
234 options: CodeInterpreterOptions = {},
235 existingSandbox?: Sandbox
236): Promise<void> {
237 const sandbox = existingSandbox || await createSandbox(options);
238
239 try {
240 // @ts-ignore - Ignore TypeScript errors for API compatibility
241 await sandbox.files.write(path, content);
242 console.log(`File written to sandbox: ${path}`, { contentLength: content.length });
243 } catch (error: unknown) {
244 const errorMessage = error instanceof Error ? error.message : String(error);
245 console.error(`Failed to write file to sandbox: ${path}`, { error: errorMessage });
246 throw error;
247 } finally {
248 if (!existingSandbox) {
249 // @ts-ignore - Ignore TypeScript errors for API compatibility
250 await sandbox.kill();
251 }
252 }
253}
254
255/**
256 * Read a file from the sandbox

Callers 1

mainFunction · 0.70

Calls 1

createSandboxFunction · 0.70

Tested by

no test coverage detected