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

Function listFiles

scripts/sparc2/src/sandbox/codeInterpreter.ts:322–345  ·  view source on GitHub ↗
(
  path: string,
  options: CodeInterpreterOptions = {},
  existingSandbox?: Sandbox,
)

Source from the content-addressed store, hash-verified

320 * @returns Array of file names
321 */
322export async function listFiles(
323 path: string,
324 options: CodeInterpreterOptions = {},
325 existingSandbox?: Sandbox,
326): Promise<string[]> {
327 const sandbox = existingSandbox || await createSandbox(options);
328
329 try {
330 // @ts-ignore - Ignore TypeScript errors for API compatibility
331 const entries = await sandbox.files.list(path);
332 const files = entries.map((entry: any) => entry.name || entry.path || String(entry));
333 await logMessage("info", `Listed files in sandbox: ${path}`, { fileCount: entries.length });
334 return files;
335 } catch (error: unknown) {
336 const errorMessage = error instanceof Error ? error.message : String(error);
337 await logMessage("error", `Failed to list files in sandbox: ${path}`, { error: errorMessage });
338 throw error;
339 } finally {
340 if (!existingSandbox) {
341 // @ts-ignore - Ignore TypeScript errors for API compatibility
342 await sandbox.kill();
343 }
344 }
345}
346
347/**
348 * Install packages in the sandbox

Callers 1

fnFunction · 0.90

Calls 2

logMessageFunction · 0.90
createSandboxFunction · 0.70

Tested by 1

fnFunction · 0.72