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.

feat(cli): add "composio generate --toolkits [toolkits]" support, for both ts and py

jkomyno3f0395eb5fcf
diff --git a/ts/packages/cli/src/commands/generate.cmd.ts b/ts/packages/cli/src/commands/generate.cmd.ts
index 959f4ac68..d801ae910 100644
--- a/ts/packages/cli/src/commands/generate.cmd.ts
+++ b/ts/packages/cli/src/commands/generate.cmd.ts
@@ -18,17 +18,24 @@ export const typeTools = Options.boolean('type-tools').pipe(
)
);
+export const toolkitsOpt = Options.text('toolkits').pipe(
+ Options.repeated,
+ Options.withDescription(
+ 'Filter output to only include the specified toolkits. Can be specified multiple times (e.g., --toolkits gmail --toolkits slack)'
+ )
+);
+
/**
* @example
* ```bash
* composio generate <command>
* ```
*/
-export const generateCmd = Command.make('generate', { outputOpt, typeTools }).pipe(
+export const generateCmd = Command.make('generate', { outputOpt, typeTools, toolkitsOpt }).pipe(
Command.withDescription(
'Updates the local type stubs with the latest app data, automatically detecting the language of the project in the current working directory (TypeScript | Python).'
),
- Command.withHandler(({ outputOpt, typeTools }) =>
+ Command.withHandler(({ outputOpt, typeTools, toolkitsOpt }) =>
Effect.gen(function* () {
const process = yield* NodeProcess;
const cwd = process.cwd;
@@ -41,9 +48,15 @@ export const generateCmd = Command.make('generate', { outputOpt, typeTools }).pi
// Redirect to either `ts generate` or `py generate` commands
yield* Match.value(envLang).pipe(
Match.when('TypeScript', () =>
- generateTypescriptTypeStubs({ outputOpt, compact: false, transpiled: false, typeTools })
+ generateTypescriptTypeStubs({
+ outputOpt,
+ compact: false,
+ transpiled: false,
+ typeTools,
+ toolkitsOpt,
+ })
),
- Match.when('Python', () => generatePythonTypeStubs({ outputOpt })),
+ Match.when('Python', () => generatePythonTypeStubs({ outputOpt, toolkitsOpt })),
Match.exhaustive
);
})
diff --git a/ts/packages/cli/src/commands/py/commands/py.generate.cmd.ts b/ts/packages/cli/src/commands/py/commands/py.generate.cmd.ts
index ac5c42e26..9d4e4472c 100644
--- a/ts/packages/cli/src/commands/py/commands/py.generate.cmd.ts
+++ b/ts/packages/cli/src/commands/py/commands/py.generate.cmd.ts
@@ -1,5 +1,5 @@
import { Command, Options } from '@effect/cli';
-import { pipe, Console, Effect, Option } from 'effect';
+import { pipe, Console, Effect, Option, Array } from 'effect';
import { FileSystem } from '@effect/platform';
import { ComposioToolkitsRepository } from 'src/services/composio-clients';
import type { GetCmdParams } from 'src/type-utils';
@@ -18,13 +18,23 @@ export const outputOpt = Options.optional(
Options.withDescription('Output directory for the generated Python type stubs')
);
-const _pyCmd$Generate = Command.make('generate', { outputOpt }).pipe(
+export const toolkitsOpt = Options.text('toolkits').pipe(
+ Options.repeated,
+ Options.withDescription(
+ 'Filter output to only include the specified toolkits. Can be specified multiple times (e.g., --toolkits gmail --toolkits slack)'
+ )
+);
+
+const _pyCmd$Generate = Command.make('generate', { outputOpt, toolkitsOpt }).pipe(
Command.withDescription('Updates the local type stubs with the latest app data.')
);
export const pyCmd$Generate = _pyCmd$Generate.pipe(Command.withHandler(generatePythonTypeStubs));
-export function generatePythonTypeStubs({ outputOpt }: GetCmdParams<typeof _pyCmd$Generate>) {
+export function generatePythonTypeStubs({
+ outputOpt,
+ toolkitsOpt,
+}: GetCmdParams<typeof _pyCmd$Generate>) {
return Effect.gen(function* () {
const process = yield* NodeProcess;
const cwd = process.cwd;
@@ -48,11 +58,28 @@ export function generatePythonTypeStubs({ outputOpt }: GetCmdParams<typeof _pyCm
// Fetch data from Composio API
yield* Console.log('Fetching latest data from Composio API. This may take a while...');
+ // Validate toolkit slugs if specified
+ const hasToolkitsFilter = Array.isNonEmptyArray(toolkitsOpt);
+ const validatedToolkitSlugs = hasToolkitsFilter
+ ? yield* client
+ .validateToolkits(toolkitsOpt)
+ .pipe(
+ Effect.catchTag('services/InvalidToolkitsError', error =>
+ Effect.fail(
+ new Error(
+ `Invalid toolkit(s): ${error.invalidToolkits.join(', ')}. ` +
+ `Available toolkits: ${error.availableToolkits.slice(0, 10).join(', ')}${error.availableToolkits.length > 10 ? '...' : ''}`
+ )
+ )
+ )
+ )
+ : [];
+
const triggerTypesAsEnums = yield* Effect.logDebug('Fetching trigger types...').pipe(
Effect.flatMap(() => client.getTriggerTypesAsEnums())
);
- const [toolkits, tools, triggerTypes] = yield* Effect.all(
+ const [allToolkits, tools, triggerTypes] = yield* Effect.all(
[
Effect.logDebug('Fetching toolkits...').pipe(Effect.flatMap(() => client.getToolkits())),
Effect.logDebug('Fetching tools...').pipe(Effect.flatMap(() => client.getToolsAsEnums())),
@@ -63,6 +90,17 @@ export function generatePythonTypeStubs({ outputOpt }: GetCmdParams<typeof _pyCm
{ concurrency: 'unbounded' }
);
+ // Filter toolkits if --toolkits was specified
+ const toolkits = hasToolkitsFilter
+ ? client.filterToolkitsBySlugs(allToolkits, validatedToolkitSlugs)
+ : allToolkits;
+
+ if (hasToolkitsFilter) {
+ yield* Console.log(
+ `Filtering to ${toolkits.length} toolkit(s): ${toolkits.map(t => t.slug).join(', ')}`
+ );
+ }
+
const typeableTools = { withTypes: false as const, tools };
const index = createToolkitIndex({ toolkits, typeableTools, triggerTypes });
diff --git a/ts/packages/cli/src/commands/ts/commands/ts.generate.cmd.ts b/ts/packages/cli/src/commands/ts/commands/ts.generate.cmd.ts
index aec372049..f8c83e7b9 100644
--- a/ts/packages/cli/src/commands/ts/commands/ts.generate.cmd.ts
+++ b/ts/packages/cli/src/commands/ts/commands/ts.generate.cmd.ts
@@ -3,6 +3,7 @@
* - `--compact`: Emit a single module file
* - `--transpiled`: Emit not just the TypeScript files, but also the transpiled JavaScript files
* - `--output-dir`: Output directory for the generated TypeScript type stubs.
+ * - `--toolkits`: Filter output to only include the specified toolkits. Can be specified multiple times (e.g., --toolkits gmail --toolkits slack)
*
* Invariants:
* - The `--output-dir` cannot refer to a path inside `node_modules`
@@ -16,10 +17,10 @@
import path from 'node:path';
import { Command, Options } from '@effect/cli';
-import { Console, Effect, Option, pipe } from 'effect';
+import { Console, Effect, Option, pipe, Array } from 'effect';
import { Match } from 'effect';
import { FileSystem } from '@effect/platform';
-import { ComposioToolkitsRepository } from 'src/services/composio-clients';
+import { ComposioToolkitsRepository, InvalidToolkitsError } from 'src/services/composio-clients';
import { NodeProcess } from 'src/services/node-process';
import { createToolkitIndex } from 'src/generation/create-toolkit-index';
import type { GetCmdParams } from 'src/type-utils';
@@ -52,11 +53,19 @@ export const typeTools = Options.boolean('type-tools').pipe(
Options.withDescription('Whether to emit type stubs for tools')
);
+export const toolkitsOpt = Options.text('toolkits').pipe(
+ Options.repeated,
+ Options.withDescription(
+ 'Filter output to only include the specified toolkits. Can be specified multiple times (e.g., --toolkits gmail --toolkits slack)'
+ )
+);
+
const _tsCmd$Generate = Command.make('generate', {
outputOpt,
compact,
transpiled: transpiled,
typeTools,
+ toolkitsOpt,
}).pipe(Command.withDescription('Updates the local type stubs with the latest app data.'));
/**
@@ -98,6 +107,7 @@ export function generateTypescriptTypeStubs({
compact,
typeTools,
transpiled = false,
+ toolkitsOpt,
}: GetCmdParams<typeof _tsCmd$Generate> & { transpiled?: boolean }) {
return Effect.gen(function* () {
const fs = yield* FileSystem.FileSystem;
@@ -122,6 +132,23 @@ export function generateTypescriptTypeStubs({
// Fetch data from Composio API
yield* Console.log('Fetching latest data from Composio API. This may take a while...');
+ // Validate toolkit slugs if specified
+ const hasToolkitsFilter = Array.isNonEmptyArray(toolkitsOpt);
+ const validatedToolkitSlugs = hasToolkitsFilter
+ ? yield* client
+ .validateToolkits(toolkitsOpt)
+ .pipe(
+ Effect.catchTag('services/InvalidToolkitsError', error =>
+ Effect.fail(
+ new Error(
+ `Invalid toolkit(s): ${error.invalidToolkits.join(', ')}. ` +
+ `Available toolkits: ${error.availableToolkits.slice(0, 10).join(', ')}${error.availableToolkits.length > 10 ? '...' : ''}`
+ )
+ )
+ )
+ )
+ : [];
+
const [triggerTypesAsEnums, toolsAsEnums] = yield* Effect.all([
Effect.logDebug('Fetching trigger types...').pipe(
Effect.flatMap(() => client.getTriggerTypesAsEnums())
@@ -129,7 +156,7 @@ export function generateTypescriptTypeStubs({
Effect.logDebug('Fetching tools...').pipe(Effect.flatMap(() => client.getToolsAsEnums())),
]);
- const [toolkits, triggerTypes] = yield* Effect.all(
+ const [allToolkits, triggerTypes] = yield* Effect.all(
[
Effect.logDebug('Fetching toolkits...').pipe(Effect.flatMap(() => client.getToolkits())),
Effect.logDebug('Fetching trigger types payloads...').pipe(
@@ -139,6 +166,17 @@ export function generateTypescriptTypeStubs({
{ concurrency: 'unbounded' }
);
+ // Filter toolkits if --toolkits was specified
+ const toolkits = hasToolkitsFilter
+ ? client.filterToolkitsBySlugs(allToolkits, validatedToolkitSlugs)
+ : allToolkits;
+
+ if (hasToolkitsFilter) {
+ yield* Console.log(
+ `Filtering to ${toolkits.length} toolkit(s): ${toolkits.map(t => t.slug).join(', ')}`
+ );
+ }
+
// Only fetch tools if `--type-tools` was specified
const typeableTools = yield* Match.value(typeTools).pipe(
Match.when(true, typePredicate =>
diff --git a/ts/packages/cli/src/services/composio-clients-cached.ts b/ts/packages/cli/src/services/composio-clients-cached.ts
index e317673ef..9179426c7 100644
--- a/ts/packages/cli/src/services/composio-clients-cached.ts
+++ b/ts/packages/cli/src/services/composio-clients-cached.ts
@@ -161,6 +161,12 @@ export const ComposioToolkitsRepositoryCached = Layer.effect(
underlyingRepository.getTools(limit)
);
},
+
+ // These methods don't need caching as they operate on already fetched data
+ // or perform validation that should always be fresh
+ validateToolkits: toolkitSlugs => underlyingRepository.validateToolkits(toolkitSlugs),
+ filterToolkitsBySlugs: (toolkits, toolkitSlugs) =>
+ underlyingRepository.filterToolkitsBySlugs(toolkits, toolkitSlugs),
});
})
).pipe(
diff --git a/ts/packages/cli/src/services/composio-clients.ts b/ts/packages/cli/src/services/composio-clients.ts
index 2ddf3e877..366ca29e1 100644
--- a/ts/packages/cli/src/services/composio-clients.ts
+++ b/ts/packages/cli/src/services/composio-clients.ts
@@ -1,6 +1,6 @@
-import { pipe, Data, Effect, Option, Schema, Array, Order, ParseResult } from 'effect';
+import { pipe, Data, Effect, Option, Schema, Array, Order, ParseResult, String } from 'effect';
import { Composio as _RawComposioClient } from '@composio/client';
-import { Toolkit, Toolkits } from 'src/models/toolkits';
+import { Toolkit, Toolkits, ToolkitName } from 'src/models/toolkits';
import { ToolsAsEnums, Tools, Tool } from 'src/models/tools';
import { Session, RetrievedSession } from 'src/models/session';
import { TriggerType, TriggerTypes, TriggerTypesAsEnums } from 'src/models/trigger-types';
@@ -19,6 +19,14 @@ export class HttpServerError extends Data.TaggedError('services/HttpServerError'
readonly cause?: unknown;
}> {}
+/**
+ * Error thrown when one or more toolkit slugs are invalid.
+ */
+export class InvalidToolkitsError extends Data.TaggedError('services/InvalidToolkitsError')<{
+ readonly invalidToolkits: ReadonlyArray<string>;
+ readonly availableToolkits: ReadonlyArray<string>;
+}> {}
+
/**
* Error thrown when a HTTP response doesn't match the expected response schema.
*/
@@ -359,19 +367,21 @@ export class ComposioToolkitsRepository extends Effect.Service<ComposioToolkitsR
effect: Effect.gen(function* () {
const client = yield* ComposioClientLive;
+ const getToolkits = (limit?: number) =>
+ client.toolkits.list({ limit }).pipe(
+ Effect.map(response => response.items),
+ Effect.flatMap(
+ Effect.fn(function* (toolkits) {
+ // Sort apps by slug.
+ // TODO: make sure this happens on the server-side.
+ const orderBySlug = Order.mapInput(Order.string, (app: Toolkit) => app.slug);
+ return Array.sort(toolkits, orderBySlug) as ReadonlyArray<Toolkit>;
+ })
+ )
+ );
+
return {
- getToolkits: (limit?: number) =>
- client.toolkits.list({ limit }).pipe(
- Effect.map(response => response.items),
- Effect.flatMap(
- Effect.fn(function* (toolkits) {
- // Sort apps by slug.
- // TODO: make sure this happens on the server-side.
- const orderBySlug = Order.mapInput(Order.string, (app: Toolkit) => app.slug);
- return Array.sort(toolkits, orderBySlug) as ReadonlyArray<Toolkit>;
- })
- )
- ),
+ getToolkits,
getToolsAsEnums: () => client.tools.retrieveEnum(),
getTools: (limit: number) =>
client.tools.list({ limit }).pipe(
@@ -398,6 +408,53 @@ export class ComposioToolkitsRepository extends Effect.Service<ComposioToolkitsR
})
)
),
+ /**
+ * Validates that the given toolkit slugs are valid by comparing them against the list
+ * of available toolkits. Returns the list of valid toolkit slugs (normalized to lowercase).
+ * @param toolkitSlugs - Array of toolkit slugs to validate (case-insensitive)
+ */
+ validateToolkits: (
+ toolkitSlugs: ReadonlyArray<string>
+ ): Effect.Effect<
+ ReadonlyArray<string>,
+ InvalidToolkitsError | HttpError | NoSuchElementException
+ > =>
+ Effect.gen(function* () {
+ // Normalize input slugs to lowercase for comparison
+ const normalizedInputSlugs = toolkitSlugs.map(slug => String.toLowerCase(slug));
+
+ // Fetch all available toolkits
+ const allToolkits = yield* getToolkits();
+ const availableSlugs = allToolkits.map(toolkit => String.toLowerCase(toolkit.slug));
+
+ // Find invalid slugs
+ const invalidSlugs = normalizedInputSlugs.filter(
+ slug => !availableSlugs.includes(slug)
+ );
+
+ if (invalidSlugs.length > 0) {
+ return yield* Effect.fail(
+ new InvalidToolkitsError({
+ invalidToolkits: invalidSlugs,
+ availableToolkits: availableSlugs,
+ })
+ );
+ }
+
+ return normalizedInputSlugs;
+ }),
+ /**
+ * Filters the given list of toolkits to only include those with the specified slugs.
+ * @param toolkits - Array of toolkits to filter
+ * @param toolkitSlugs - Array of toolkit slugs to filter by (case-insensitive)
+ */
+ filterToolkitsBySlugs: (
+ toolkits: ReadonlyArray<Toolkit>,
+ toolkitSlugs: ReadonlyArray<string>
+ ): ReadonlyArray<Toolkit> => {
+ const normalizedSlugs = new Set(toolkitSlugs.map(slug => String.toLowerCase(slug)));
+ return toolkits.filter(toolkit => normalizedSlugs.has(String.toLowerCase(toolkit.slug)));
+ },
};
}),
dependencies: [ComposioClientLive.Default],
diff --git a/ts/packages/cli/test/__utils__/services/test-layer.ts b/ts/packages/cli/test/__utils__/services/test-layer.ts
index 48e3bfe64..4c2323270 100644
--- a/ts/packages/cli/test/__utils__/services/test-layer.ts
+++ b/ts/packages/cli/test/__utils__/services/test-layer.ts
@@ -12,6 +12,7 @@ import {
Logger,
LogLevel,
Schedule,
+ String,
} from 'effect';
import { ComposioCliConfig } from 'src/cli-config';
import * as MockConsole from './mock-console';
@@ -21,6 +22,7 @@ import { NodeProcess } from 'src/services/node-process';
import {
ComposioSessionRepository,
ComposioToolkitsRepository,
+ InvalidToolkitsError,
} from 'src/services/composio-clients';
import { EnvLangDetector } from 'src/services/env-lang-detector';
import { JsPackageManagerDetector } from 'src/services/js-package-manager-detector';
@@ -94,6 +96,28 @@ export const TestLayer = (input?: TestLiveInput) =>
getTriggerTypesAsEnums: () => Effect.succeed(toolkitsData.triggerTypesAsEnums),
getTriggerTypes: limit => Effect.succeed(toolkitsData.triggerTypes.slice(0, limit)),
getTools: limit => Effect.succeed(toolkitsData.tools.slice(0, limit)),
+ validateToolkits: (toolkitSlugs: ReadonlyArray<string>) => {
+ const normalizedInputSlugs = toolkitSlugs.map(slug => String.toLowerCase(slug));
+ const availableSlugs = toolkitsData.toolkits.map(toolkit =>
+ String.toLowerCase(toolkit.slug)
+ );
+ const invalidSlugs = normalizedInputSlugs.filter(slug => !availableSlugs.includes(slug));
+
+ if (invalidSlugs.length > 0) {
+ return Effect.fail(
+ new InvalidToolkitsError({
+ invalidToolkits: invalidSlugs,
+ availableToolkits: availableSlugs,
+ })
+ );
+ }
+
+ return Effect.succeed(normalizedInputSlugs);
+ },
+ filterToolkitsBySlugs: (toolkits, toolkitSlugs) => {
+ const normalizedSlugs = new Set(toolkitSlugs.map(slug => String.toLowerCase(slug)));
+ return toolkits.filter(toolkit => normalizedSlugs.has(String.toLowerCase(toolkit.slug)));
+ },
})
);
diff --git a/ts/packages/cli/test/src/commands/$default.cmd.test.ts b/ts/packages/cli/test/src/commands/$default.cmd.test.ts
index 4059d450d..4cb41d1fe 100644
--- a/ts/packages/cli/test/src/commands/$default.cmd.test.ts
+++ b/ts/packages/cli/test/src/commands/$default.cmd.test.ts
@@ -58,25 +58,25 @@ describe('CLI: composio', () => {
COMMANDS
- - version Display your account information.
+ - version Display your account information.
- - upgrade Upgrade your Composio CLI to the latest available version.
+ - upgrade Upgrade your Composio CLI to the latest available version.
- - whoami Display your account information.
+ - whoami Display your account information.
- - login [--no-browser] Log in to the Composio SDK.
+ - login [--no-browser] Log in to the Composio SDK.
- - logout Log out from the Composio SDK.
+ - logout Log out from the Composio SDK.
- - generate [(-o, --output-dir directory)] [--type-tools] Updates the local type stubs with the latest app data, automatically detecting the language of the project in the current working directory (TypeScript | Python).
+ - generate [(-o, --output-dir directory)] [--type-tools] --toolkits text... Updates the local type stubs with the latest app data, automatically detecting the language of the project in the current working directory (TypeScript | Python).
- - py Handle Python projects.
+ - py Handle Python projects.
- - py generate [(-o, --output-dir directory)] Updates the local type stubs with the latest app data.
+ - py generate [(-o, --output-dir directory)] --toolkits text... Updates the local type stubs with the latest app data.
- - ts Handle TypeScript projects.
+ - ts Handle TypeScript projects.
- - ts generate [(-o, --output-dir directory)] [--compact] [--transpiled] [--type-tools] Updates the local type stubs with the latest app data.
+ - ts generate [(-o, --output-dir directory)] [--compact] [--transpiled] [--type-tools] --toolkits text... Updates the local type stubs with the latest app data.
"
`);
})
diff --git a/ts/packages/cli/test/src/commands/generate.cmd.test.ts b/ts/packages/cli/test/src/commands/generate.cmd.test.ts
index 3235d9373..0b39dee19 100644
--- a/ts/packages/cli/test/src/commands/generate.cmd.test.ts
+++ b/ts/packages/cli/test/src/commands/generate.cmd.test.ts
@@ -1,9 +1,31 @@
+import path from 'node:path';
import { describe, expect, layer } from '@effect/vitest';
import { Effect } from 'effect';
+import { FileSystem } from '@effect/platform';
import { NodeProcess } from 'src/services/node-process';
import { cli, TestLive, MockConsole } from 'test/__utils__';
+import { makeTestToolkits } from 'test/__utils__/models/toolkits';
+import { TRIGGER_TYPES_GMAIL } from 'test/__mocks__/trigger-types-gmail';
+import { TOOLS_TYPES_GMAIL } from 'test/__mocks__/tools-types-gmail';
+import type { TestLiveInput } from 'test/__utils__/services/test-layer';
describe('CLI: composio generate', () => {
+ const appClientData = {
+ toolkits: makeTestToolkits([
+ {
+ name: 'Gmail',
+ slug: 'gmail',
+ },
+ {
+ name: 'Slack',
+ slug: 'slack',
+ },
+ ]),
+ tools: [...TOOLS_TYPES_GMAIL.slice(0, 3)],
+ triggerTypes: [...TRIGGER_TYPES_GMAIL.slice(0, 3)],
+ triggerTypesAsEnums: [...TRIGGER_TYPES_GMAIL.slice(0, 3).map(triggerType => triggerType.slug)],
+ } satisfies TestLiveInput['toolkitsData'];
+
layer(
TestLive({
fixture: 'python-project',
@@ -41,4 +63,70 @@ describe('CLI: composio generate', () => {
})
);
});
+
+ layer(
+ TestLive({
+ fixture: 'typescript-project',
+ toolkitsData: appClientData,
+ })
+ )(it => {
+ it.scoped(
+ '[Given] TypeScript project with --toolkits [Then] it filters output to specified toolkits',
+ () =>
+ Effect.gen(function* () {
+ const process = yield* NodeProcess;
+ const cwd = process.cwd;
+ const fs = yield* FileSystem.FileSystem;
+ const outputDir = path.join(cwd, '.generated', 'composio-filtered');
+
+ const args = ['generate', '--toolkits', 'gmail', '--output-dir', outputDir];
+ yield* cli(args);
+
+ const lines = yield* MockConsole.getLines();
+ const output = lines.join('\n');
+ expect(output).toContain('Project type detected: TypeScript');
+ expect(output).toContain('Filtering to 1 toolkit(s): gmail');
+
+ // Check generated files - only gmail.ts should exist
+ const files = yield* fs.readDirectory(outputDir);
+ const fileNames = files.map(file => path.basename(file));
+
+ expect(fileNames).toContain('gmail.ts');
+ expect(fileNames).not.toContain('slack.ts');
+ })
+ );
+ });
+
+ layer(
+ TestLive({
+ fixture: 'python-project',
+ toolkitsData: appClientData,
+ })
+ )(it => {
+ it.scoped(
+ '[Given] Python project with --toolkits [Then] it filters output to specified toolkits',
+ () =>
+ Effect.gen(function* () {
+ const process = yield* NodeProcess;
+ const cwd = process.cwd;
+ const fs = yield* FileSystem.FileSystem;
+ const outputDir = path.join(cwd, '.generated', 'composio-filtered');
+
+ const args = ['generate', '--toolkits', 'gmail', '--output-dir', outputDir];
+ yield* cli(args);
+
+ const lines = yield* MockConsole.getLines();
+ const output = lines.join('\n');
+ expect(output).toContain('Project type detected: Python');
+ expect(output).toContain('Filtering to 1 toolkit(s): gmail');
+
+ // Check generated files - only gmail.py should exist
+ const files = yield* fs.readDirectory(outputDir);
+ const fileNames = files.map(file => path.basename(file));
+
+ expect(fileNames).toContain('gmail.py');
+ expect(fileNames).not.toContain('slack.py');
+ })
+ );
+ });
});
diff --git a/ts/packages/cli/test/src/commands/py/py.generate.cmd.test.ts b/ts/packages/cli/test/src/commands/py/py.generate.cmd.test.ts
index 9aaba09bc..3e10e7bc7 100644
--- a/ts/packages/cli/test/src/commands/py/py.generate.cmd.test.ts
+++ b/ts/packages/cli/test/src/commands/py/py.generate.cmd.test.ts
@@ -295,6 +295,100 @@ describe('CLI: composio py generate', () => {
});
})
);
+
+ it.scoped(
+ '[Given] --toolkits gmail [Then] it generates type stubs only for the gmail toolkit',
+ Effect.fn(function* () {
+ const process = yield* NodeProcess;
+ const cwd = process.cwd;
+ const fs = yield* FileSystem.FileSystem;
+ const outputDir = path.join(cwd, '.generated', 'composio-py-filtered');
+
+ const args = ['py', 'generate', '--toolkits', 'gmail', '--output-dir', outputDir];
+ yield* cli(args);
+
+ // Check generated files - only gmail.py should exist (no slack.py)
+ const files = yield* fs.readDirectory(outputDir);
+ const fileNames = files.map(file => path.basename(file));
+
+ expect(fileNames).toContain('gmail.py');
+ expect(fileNames).not.toContain('slack.py');
+
+ // Verify gmail.py contains GMAIL class
+ const gmailSourceCode = yield* fs.readFileString(path.join(outputDir, 'gmail.py'));
+ expect(gmailSourceCode).toContain('GMAIL');
+ })
+ );
+
+ it.scoped(
+ '[Given] --toolkits gmail --toolkits slack [Then] it generates type stubs for both toolkits',
+ Effect.fn(function* () {
+ const process = yield* NodeProcess;
+ const cwd = process.cwd;
+ const fs = yield* FileSystem.FileSystem;
+ const outputDir = path.join(cwd, '.generated', 'composio-py-multi');
+
+ const args = [
+ 'py',
+ 'generate',
+ '--toolkits',
+ 'gmail',
+ '--toolkits',
+ 'slack',
+ '--output-dir',
+ outputDir,
+ ];
+ yield* cli(args);
+
+ // Check generated files - both gmail.py and slack.py should exist
+ const files = yield* fs.readDirectory(outputDir);
+ const fileNames = files.map(file => path.basename(file));
+
+ expect(fileNames).toContain('gmail.py');
+ expect(fileNames).toContain('slack.py');
+
+ // Verify both files contain their respective classes
+ const gmailSourceCode = yield* fs.readFileString(path.join(outputDir, 'gmail.py'));
+ const slackSourceCode = yield* fs.readFileString(path.join(outputDir, 'slack.py'));
+ expect(gmailSourceCode).toContain('GMAIL');
+ expect(slackSourceCode).toContain('SLACK');
+ })
+ );
+
+ it.scoped(
+ '[Given] --toolkits with invalid toolkit [Then] it fails with an error',
+ Effect.fn(function* () {
+ const process = yield* NodeProcess;
+ const cwd = process.cwd;
+ const outputDir = path.join(cwd, '.generated', 'composio-py-invalid');
+
+ const args = ['py', 'generate', '--toolkits', 'nonexistent', '--output-dir', outputDir];
+ const result = yield* cli(args).pipe(Effect.catchAll(e => Effect.succeed(e)));
+
+ expect(result).toBeInstanceOf(Error);
+ expect((result as Error).message).toContain('Invalid toolkit(s): nonexistent');
+ })
+ );
+
+ it.scoped(
+ '[Given] --toolkits GMAIL (uppercase) [Then] it handles case-insensitive matching',
+ Effect.fn(function* () {
+ const process = yield* NodeProcess;
+ const cwd = process.cwd;
+ const fs = yield* FileSystem.FileSystem;
+ const outputDir = path.join(cwd, '.generated', 'composio-py-uppercase');
+
+ const args = ['py', 'generate', '--toolkits', 'GMAIL', '--output-dir', outputDir];
+ yield* cli(args);
+
+ // Check generated files - only gmail.py should exist
+ const files = yield* fs.readDirectory(outputDir);
+ const fileNames = files.map(file => path.basename(file));
+
+ expect(fileNames).toContain('gmail.py');
+ expect(fileNames).not.toContain('slack.py');
+ })
+ );
});
});
});
diff --git a/ts/packages/cli/test/src/commands/ts/ts.generate.cmd.test.ts b/ts/packages/cli/test/src/commands/ts/ts.generate.cmd.test.ts
index c7ff04bcf..af35c205b 100644
--- a/ts/packages/cli/test/src/commands/ts/ts.generate.cmd.test.ts
+++ b/ts/packages/cli/test/src/commands/ts/ts.generate.cmd.test.ts
@@ -847,6 +847,108 @@ describe('CLI: composio ts generate', () => {
assertTypeScriptIsValid({ files: { './index.ts': indexSourceCode } });
})
);
+
+ it.scoped(
+ '[Given] --toolkits gmail [Then] it generates type stubs only for the gmail toolkit',
+ () =>
+ Effect.gen(function* () {
+ const process = yield* NodeProcess;
+ const cwd = process.cwd;
+ const fs = yield* FileSystem.FileSystem;
+ const outputDir = path.join(cwd, 'generated-filtered');
+
+ const args = ['ts', 'generate', '--toolkits', 'gmail', '--output-dir', outputDir];
+ yield* cli(args);
+
+ // Check generated files - only gmail.ts and index.ts should exist
+ const files = yield* fs.readDirectory(outputDir);
+ const fileNames = files.map(file => path.basename(file));
+
+ expect(fileNames).toContain('gmail.ts');
+ expect(fileNames).toContain('index.ts');
+ expect(fileNames).not.toContain('slack.ts');
+
+ // Verify index only references gmail
+ const indexSourceCode = yield* fs.readFileString(path.join(outputDir, 'index.ts'));
+ expect(indexSourceCode).toContain('GMAIL');
+ expect(indexSourceCode).not.toContain('SLACK');
+
+ assertTypeScriptIsValid({ files: { './index.ts': indexSourceCode } });
+ })
+ );
+
+ it.scoped(
+ '[Given] --toolkits gmail --toolkits slack [Then] it generates type stubs for both toolkits',
+ () =>
+ Effect.gen(function* () {
+ const process = yield* NodeProcess;
+ const cwd = process.cwd;
+ const fs = yield* FileSystem.FileSystem;
+ const outputDir = path.join(cwd, 'generated-multi-filtered');
+
+ const args = [
+ 'ts',
+ 'generate',
+ '--toolkits',
+ 'gmail',
+ '--toolkits',
+ 'slack',
+ '--output-dir',
+ outputDir,
+ ];
+ yield* cli(args);
+
+ // Check generated files - both gmail.ts and slack.ts should exist
+ const files = yield* fs.readDirectory(outputDir);
+ const fileNames = files.map(file => path.basename(file));
+
+ expect(fileNames).toContain('gmail.ts');
+ expect(fileNames).toContain('slack.ts');
+ expect(fileNames).toContain('index.ts');
+
+ // Verify index references both
+ const indexSourceCode = yield* fs.readFileString(path.join(outputDir, 'index.ts'));
+ expect(indexSourceCode).toContain('GMAIL');
+ expect(indexSourceCode).toContain('SLACK');
+
+ assertTypeScriptIsValid({ files: { './index.ts': indexSourceCode } });
+ })
+ );
+
+ it.scoped('[Given] --toolkits with invalid toolkit [Then] it fails with an error', () =>
+ Effect.gen(function* () {
+ const process = yield* NodeProcess;
+ const cwd = process.cwd;
+ const outputDir = path.join(cwd, 'generated-invalid');
+
+ const args = ['ts', 'generate', '--toolkits', 'nonexistent', '--output-dir', outputDir];
+ const result = yield* cli(args).pipe(Effect.catchAll(e => Effect.succeed(e)));
+
+ expect(result).toBeInstanceOf(Error);
+ expect((result as Error).message).toContain('Invalid toolkit(s): nonexistent');
+ })
+ );
+
+ it.scoped(
+ '[Given] --toolkits GMAIL (uppercase) [Then] it handles case-insensitive matching',
+ () =>
+ Effect.gen(function* () {
+ const process = yield* NodeProcess;
+ const cwd = process.cwd;
+ const fs = yield* FileSystem.FileSystem;
+ const outputDir = path.join(cwd, 'generated-uppercase');
+
+ const args = ['ts', 'generate', '--toolkits', 'GMAIL', '--output-dir', outputDir];
+ yield* cli(args);
+
+ // Check generated files - only gmail.ts should exist
+ const files = yield* fs.readDirectory(outputDir);
+ const fileNames = files.map(file => path.basename(file));
+
+ expect(fileNames).toContain('gmail.ts');
+ expect(fileNames).not.toContain('slack.ts');
+ })
+ );
});
});