(path: string, content: string)
| 169 | * @param content Content to write |
| 170 | */ |
| 171 | export async function writeFile(path: string, content: string): Promise<void> { |
| 172 | const sandbox = await createSandbox(); |
| 173 | |
| 174 | try { |
| 175 | await sandbox.filesystem.write(path, content); |
| 176 | await logMessage("info", `File written to sandbox: ${path}`, { contentLength: content.length }); |
| 177 | } catch (error: unknown) { |
| 178 | const errorMessage = error instanceof Error ? error.message : String(error); |
| 179 | await logMessage("error", `Failed to write file to sandbox: ${path}`, { error: errorMessage }); |
| 180 | throw error; |
| 181 | } finally { |
| 182 | await sandbox.close(); |
| 183 | } |
| 184 | } |
| 185 | |
| 186 | /** |
| 187 | * Read a file from the sandbox |
no test coverage detected