Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

next
ts 21 lines 573 Bytes
Raw
1 import { FileSystem } from 'effect/FileSystem';
2 import { Effect, pipe } from 'effect';
3
4 import { parseJsonRecord } from 'src/utils/parse-json';
5
6 export const readJsonEffect = (filePath: string) =>
7 pipe(
8 Effect.gen(function* () {
9 const { readFileString } = yield* FileSystem;
10 const data = yield* readFileString(filePath, 'utf8');
11
12 if (data.length === 0) {
13 return null;
14 }
15
16 const json = yield* Effect.fromResult(parseJsonRecord(data));
17
18 return json;
19 }),
20 Effect.withSpan('read-json', { attributes: { filePath } })
21 );