* 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[])
| 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. |
no test coverage detected