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.

956 B
Raw Blame
import type * as Path from '@effect/platform/Path';
import type { ToolkitIndex } from 'src/generation/create-toolkit-index';
import type { SourceFile } from 'src/generation/types';
import { Effect } from 'effect';
import { safeOutputPath, type SafeOutputPathError } from 'src/generation/safe-output-path';
import { generatePythonToolkitSources } from './generate-toolkit-sources';

type GeneratePythonSourcesParams = {
  banner: string;
  outputDir: string;
};

export function generatePythonSources(params: GeneratePythonSourcesParams) {
  return (
    index: ToolkitIndex
  ): Effect.Effect<Array<SourceFile>, SafeOutputPathError, Path.Path> => {
    const toolkiteSources = generatePythonToolkitSources(params.banner)(index);

    return Effect.all(
      toolkiteSources.map(([filename, content]) =>
        safeOutputPath(params.outputDir, filename).pipe(
          Effect.map(filePath => [filePath, content] as const)
        )
      )
    );
  };
}