MCPcopy Create free account
hub / github.com/ShipSecAI/studio / readFiles

Method readFiles

worker/src/utils/isolated-volume.ts:298–323  ·  view source on GitHub ↗

* Reads files from the volume after container execution. * * @param filenames - Array of filenames to read * @returns Map of filename to content * * @example * ```typescript * const outputs = await volume.readFiles(['results.json', 'summary.txt']); * console.log(outputs['resu

(filenames: string[])

Source from the content-addressed store, hash-verified

296 * ```
297 */
298 async readFiles(filenames: string[]): Promise<Record<string, string>> {
299 if (!this.volumeName) {
300 throw new ConfigurationError('Volume not initialized', {
301 details: { tenantId: this.tenantId, runId: this.runId },
302 });
303 }
304
305 const results: Record<string, string> = {};
306
307 for (const filename of filenames) {
308 // Strict validation to prevent path traversal and injection
309 this.validateFilename(filename);
310
311 try {
312 const content = await this.readFileFromVolume(filename);
313 results[filename] = content;
314 } catch (error) {
315 // File might not exist, which is okay
316 console.warn(
317 `Could not read file ${filename}: ${error instanceof Error ? error.message : String(error)}`,
318 );
319 }
320 }
321
322 return results;
323 }
324
325 /**
326 * Reads a single file from the volume using docker run.

Callers 2

executeFunction · 0.95
executeFunction · 0.95

Calls 3

validateFilenameMethod · 0.95
readFileFromVolumeMethod · 0.95
warnMethod · 0.80

Tested by

no test coverage detected