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

Function listFiles

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

Source from the content-addressed store, hash-verified

289 * @returns Array of file names
290 */
291export async function listFiles(
292 path: string,
293 options: CodeInterpreterOptions = {},
294 existingSandbox?: Sandbox
295): Promise<string[]> {
296 const sandbox = existingSandbox || await createSandbox(options);
297
298 try {
299 // @ts-ignore - Ignore TypeScript errors for API compatibility
300 const entries = await sandbox.files.list(path);
301 const files = entries.map((entry: any) => entry.name || entry.path || String(entry));
302 console.log(`Listed files in sandbox: ${path}`, { fileCount: entries.length });
303 return files;
304 } catch (error) {
305 const errorMessage = error instanceof Error ? error.message : String(error);
306 console.error(`Failed to list files in sandbox: ${path}`, { error: errorMessage });
307 throw error;
308 } finally {
309 if (!existingSandbox) {
310 // @ts-ignore - Ignore TypeScript errors for API compatibility
311 await sandbox.kill();
312 }
313 }
314}
315
316/**
317 * Install packages in the sandbox

Callers 1

mainFunction · 0.70

Calls 1

createSandboxFunction · 0.70

Tested by

no test coverage detected