Skip to content

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

747 B
Raw Blame
import { Effect } from 'effect';
import * as FileSystem from '@effect/platform/FileSystem';
import * as Path from '@effect/platform/Path';
import * as constants from 'src/constants';
import { APP_CONFIG } from 'src/effects/app-config';
import { NodeOs } from 'src/services/node-os';

// Helper to create cache directory
export const setupCacheDir = Effect.gen(function* () {
  const fs = yield* FileSystem.FileSystem;
  const path = yield* Path.Path;
  const os = yield* NodeOs;

  const cacheDir =
    (yield* APP_CONFIG.CACHE_DIR) ?? path.join(os.homedir, constants.USER_COMPOSIO_DIR);

  // Ensure cache directory exists
  yield* fs.makeDirectory(cacheDir, { recursive: true }).pipe(Effect.catchAll(() => Effect.void));

  return cacheDir;
});