Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
Mirrored from https://github.com/Camo67/composio.git
Synced Nov 21, 04:45 UTC
| 1 | import { Effect, FileSystem, Layer, PlatformError } from 'effect'; |
| 2 | |
| 3 | /** |
| 4 | * Wraps the provided `FileSystem` so `writeFileString` fails with `PermissionDenied` for every |
| 5 | * path `failsFor` matches; other paths and operations reach the real file system. |
| 6 | */ |
| 7 | export const failingFileWrites = (failsFor: (path: string) => boolean) => |
| 8 | Layer.effect( |
| 9 | FileSystem.FileSystem, |
| 10 | Effect.map(FileSystem.FileSystem, fs => |
| 11 | FileSystem.FileSystem.of({ |
| 12 | ...fs, |
| 13 | writeFileString: (path, data, options) => |
| 14 | failsFor(path) |
| 15 | ? Effect.fail( |
| 16 | PlatformError.systemError({ |
| 17 | _tag: 'PermissionDenied', |
| 18 | module: 'FileSystem', |
| 19 | method: 'writeFileString', |
| 20 | pathOrDescriptor: path, |
| 21 | }) |
| 22 | ) |
| 23 | : fs.writeFileString(path, data, options), |
| 24 | }) |
| 25 | ) |
| 26 | ); |