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

Function readFile

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

Source from the content-addressed store, hash-verified

259 * @returns The file content
260 */
261export async function readFile(
262 path: string,
263 options: CodeInterpreterOptions = {},
264 existingSandbox?: Sandbox
265): Promise<string> {
266 const sandbox = existingSandbox || await createSandbox(options);
267
268 try {
269 // @ts-ignore - Ignore TypeScript errors for API compatibility
270 const content = await sandbox.files.read(path);
271 console.log(`File read from sandbox: ${path}`, { contentLength: content.length });
272 return content;
273 } catch (error: unknown) {
274 const errorMessage = error instanceof Error ? error.message : String(error);
275 console.error(`Failed to read file from sandbox: ${path}`, { error: errorMessage });
276 throw error;
277 } finally {
278 if (!existingSandbox) {
279 // @ts-ignore - Ignore TypeScript errors for API compatibility
280 await sandbox.kill();
281 }
282 }
283}
284
285/**
286 * List files in the sandbox

Callers 1

mainFunction · 0.70

Calls 1

createSandboxFunction · 0.70

Tested by

no test coverage detected