@devries-cameron20 / composio-1 / commits / 0f67eaf2b
Fork 0

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

refactor(cli): move `triggers create`, `enable` and `disable` to the directory shape (#4970)

This PR: - moves `dev triggers create`, `enable` and `disable` to `triggers/<name>/triggers.<name>.{cmd,handler}.ts` - splits `triggers.mutations.cmd.test.ts` into one mirrored test per command - adds cases for API failures (exit 1), `--trigger-config` reaching the API, and both `disable` gates (`--dangerously-allow`, `developer.destructive_actions`) - removes three entries from `COMMAND_TEST_EXEMPTIONS` (15 → 12) - part of U9 of the CLI command-layout series; `triggers listen` waits for U8; no user-visible change, so no CHANGELOG entry ## Context Verified: `pnpm --filter @composio/cli test` (1905 passed), CLI typecheck, `lint:effect`, oxlint, prettier, `validate:command-tests`. `--help` for each moved command is byte-identical to the `origin/next` binary.

Alberto Schiabel committed Oct 20, 2026 at 15:29 UTC 0f67eaf2b5875b347e8bb55fc5891aeec0da87e3
13 files changed +479 -223
ts/packages/cli/scripts/command-tests.ts
-12
@@ -27,18 +27,6 @@ export const COMMAND_TEST_EXEMPTIONS: readonly CommandTestExemption[] = [
27 },
28 { command: 'orgs/commands/orgs.list.cmd.ts', reason: 'no test yet' },
29 { command: 'signup.cmd.ts', reason: 'no test yet' },
30 - {
31 - command: 'triggers/commands/triggers.create.cmd.ts',
32 - reason: 'covered by triggers.mutations.cmd.test.ts; split pending',
33 - },
34 - {
35 - command: 'triggers/commands/triggers.disable.cmd.ts',
36 - reason: 'covered by triggers.mutations.cmd.test.ts; split pending',
37 - },
38 - {
39 - command: 'triggers/commands/triggers.enable.cmd.ts',
40 - reason: 'covered by triggers.mutations.cmd.test.ts; split pending',
41 - },
30 { command: 'triggers/commands/triggers.listen.cmd.ts', reason: 'no test yet' },
31 { command: 'upgrade.cmd.ts', reason: 'no test yet' },
32 ];
ts/packages/cli/src/commands/triggers/commands/triggers.create.cmd.ts deleted
-93
@@ -1,93 +0,0 @@
1 -import { Argument, Command, Flag } from 'effect/cli';
2 -import { Effect, Option, Result } from 'effect';
3 -import { parseJsonRecord } from 'src/utils/parse-json';
4 -import { handleClientApiError } from 'src/effects/handle-http-error';
5 -import { CLIENT_API_ERROR_TAGS } from 'src/services/composio-errors';
6 -import { ComposioToolkitsRepository } from 'src/services/composio-clients';
7 -import { TerminalUI } from 'src/services/terminal-ui';
8 -
9 -const triggerName = Argument.String('trigger-name').pipe(
10 - Argument.withDescription('Trigger slug (e.g. "GMAIL_NEW_GMAIL_MESSAGE")'),
11 - Argument.optional
12 -);
13 -
14 -const connectedAccountId = Flag.String('connected-account-id').pipe(
15 - Flag.withDescription('Connected account ID (nanoid)'),
16 - Flag.optional
17 -);
18 -
19 -const triggerConfig = Flag.String('trigger-config').pipe(
20 - Flag.withDescription('Trigger config as JSON string'),
21 - Flag.optional
22 -);
23 -
24 -/**
25 - * Create a trigger instance.
26 - */
27 -export const triggersCmd$Create = Command.make(
28 - 'create',
29 - { triggerName, connectedAccountId, triggerConfig },
30 - ({ triggerName, connectedAccountId, triggerConfig }) =>
31 - Effect.gen(function* () {
32 - const ui = yield* TerminalUI;
33 - const repo = yield* ComposioToolkitsRepository;
34 -
35 - if (Option.isNone(triggerName)) {
36 - yield* ui.log.warn('Missing required argument: <trigger-name>');
37 - yield* ui.log.step(
38 - 'Try specifying a trigger slug, e.g.:\n> composio dev triggers create "GMAIL_NEW_GMAIL_MESSAGE" --connected-account-id "con_123"'
39 - );
40 - return;
41 - }
42 -
43 - let parsedTriggerConfig: Record<string, unknown> | undefined;
44 - if (Option.isSome(triggerConfig)) {
45 - const parsed = parseJsonRecord(triggerConfig.value);
46 - if (Result.isFailure(parsed)) {
47 - if (parsed.failure.reason === 'not-a-record') {
48 - yield* ui.log.error(
49 - '--trigger-config must be a JSON object (e.g. \'{"key":"value"}\').'
50 - );
51 - } else {
52 - yield* ui.log.error('Invalid JSON in --trigger-config. Please provide valid JSON.');
53 - yield* ui.log.step(
54 - 'Example:\n> composio dev triggers create "GMAIL_NEW_GMAIL_MESSAGE" --trigger-config \'{"label":"inbox"}\''
55 - );
56 - }
57 - return;
58 - }
59 - parsedTriggerConfig = parsed.success;
60 - }
61 -
62 - const createdOpt = yield* ui
63 - .withSpinner(
64 - `Creating trigger "${triggerName.value}"...`,
65 - repo.createTrigger(triggerName.value, {
66 - connected_account_id: Option.getOrUndefined(connectedAccountId),
67 - trigger_config: parsedTriggerConfig,
68 - })
69 - )
70 - .pipe(
71 - Effect.asSome,
72 - Effect.catchTag(
73 - CLIENT_API_ERROR_TAGS,
74 - handleClientApiError(ui, {
75 - fallbackMessage: `Failed to create trigger "${triggerName.value}".`,
76 - hint: 'List available trigger types with:\n> composio dev triggers list',
77 - fallbackValue: Option.none(),
78 - })
79 - )
80 - );
81 -
82 - if (Option.isNone(createdOpt)) {
83 - return;
84 - }
85 -
86 - const created = createdOpt.value;
87 - yield* ui.log.success(`Trigger created: ${created.trigger_id}`);
88 - yield* ui.log.step(
89 - `To check status:\n> composio dev triggers status --trigger-ids "${created.trigger_id}"`
90 - );
91 - yield* ui.output(JSON.stringify(created, null, 2));
92 - })
93 -).pipe(Command.withDescription('Create a new trigger instance.'));
ts/packages/cli/src/commands/triggers/commands/triggers.disable.cmd.ts deleted
-72
@@ -1,72 +0,0 @@
1 -import { commandInputError } from 'src/commands/errors';
2 -import { Argument, Command, Flag } from 'effect/cli';
3 -import { Effect, Option } from 'effect';
4 -import { handleClientApiError } from 'src/effects/handle-http-error';
5 -import { CLIENT_API_ERROR_TAGS } from 'src/services/composio-errors';
6 -import { ComposioToolkitsRepository } from 'src/services/composio-clients';
7 -import { ComposioCliUserConfig } from 'src/services/cli-user-config';
8 -import { TerminalUI } from 'src/services/terminal-ui';
9 -
10 -const id = Argument.String('id').pipe(
11 - Argument.withDescription('Trigger instance ID'),
12 - Argument.optional
13 -);
14 -
15 -const notAllowed = commandInputError('dev triggers disable');
16 -
17 -const dangerouslyAllow = Flag.Boolean('dangerously-allow').pipe(
18 - Flag.withDescription('Acknowledge disabling this trigger instance'),
19 - Flag.withDefault(false)
20 -);
21 -
22 -/**
23 - * Disable an existing trigger instance.
24 - */
25 -export const triggersCmd$Disable = Command.make(
26 - 'disable',
27 - { id, dangerouslyAllow },
28 - ({ id, dangerouslyAllow }) =>
29 - Effect.gen(function* () {
30 - const config = yield* ComposioCliUserConfig;
31 - if (!config.areDeveloperDangerousCommandsEnabled()) {
32 - return yield* notAllowed(
33 - 'This developer command is disabled by config. Set developer.destructive_actions to true in ~/.composio/config.json to allow it.'
34 - );
35 - }
36 - if (!dangerouslyAllow) {
37 - return yield* notAllowed(
38 - 'This developer command requires explicit acknowledgement. Re-run with --dangerously-allow.',
39 - '--dangerously-allow'
40 - );
41 - }
42 - const ui = yield* TerminalUI;
43 - const repo = yield* ComposioToolkitsRepository;
44 -
45 - if (Option.isNone(id)) {
46 - yield* ui.log.warn('Missing required argument: <id>');
47 - yield* ui.log.step(
48 - 'Try specifying a trigger ID, e.g.:\n> composio dev triggers disable "trg_123"\n\nTo find trigger IDs:\n> composio dev triggers status'
49 - );
50 - return;
51 - }
52 -
53 - const idValue = id.value;
54 - const disabled = yield* ui
55 - .withSpinner(`Disabling trigger "${idValue}"...`, repo.disableTrigger(idValue))
56 - .pipe(
57 - Effect.as(true),
58 - Effect.catchTag(
59 - CLIENT_API_ERROR_TAGS,
60 - handleClientApiError(ui, {
61 - fallbackMessage: `Failed to disable trigger "${idValue}".`,
62 - hint: 'Browse available triggers:\n> composio dev triggers status',
63 - fallbackValue: false,
64 - })
65 - )
66 - );
67 -
68 - if (!disabled) return;
69 -
70 - yield* ui.log.success(`Trigger "${idValue}" disabled.`);
71 - })
72 -).pipe(Command.withDescription('Disable a trigger instance.'));
ts/packages/cli/src/commands/triggers/create/triggers.create.cmd.ts new
+23
@@ -0,0 +1,23 @@
1 +import { Argument, Command, Flag } from 'effect/cli';
2 +import { runTriggersCreate } from './triggers.create.handler';
3 +
4 +const triggerName = Argument.String('trigger-name').pipe(
5 + Argument.withDescription('Trigger slug (e.g. "GMAIL_NEW_GMAIL_MESSAGE")'),
6 + Argument.optional
7 +);
8 +
9 +const connectedAccountId = Flag.String('connected-account-id').pipe(
10 + Flag.withDescription('Connected account ID (nanoid)'),
11 + Flag.optional
12 +);
13 +
14 +const triggerConfig = Flag.String('trigger-config').pipe(
15 + Flag.withDescription('Trigger config as JSON string'),
16 + Flag.optional
17 +);
18 +
19 +export const triggersCmd$Create = Command.make(
20 + 'create',
21 + { triggerName, connectedAccountId, triggerConfig },
22 + runTriggersCreate
23 +).pipe(Command.withDescription('Create a new trigger instance.'));
ts/packages/cli/src/commands/triggers/create/triggers.create.handler.ts new
+98
@@ -0,0 +1,98 @@
1 +import { Effect, Match, Option, Result } from 'effect';
2 +import { handleClientApiError } from 'src/effects/handle-http-error';
3 +import { ComposioToolkitsRepository } from 'src/services/composio-clients';
4 +import { CLIENT_API_ERROR_TAGS } from 'src/services/composio-errors';
5 +import { TerminalUI } from 'src/services/terminal-ui';
6 +import { parseJsonRecord, type JsonParsingError } from 'src/utils/parse-json';
7 +
8 +export type TriggersCreateParams = {
9 + readonly triggerName: Option.Option<string>;
10 + readonly connectedAccountId: Option.Option<string>;
11 + readonly triggerConfig: Option.Option<string>;
12 +};
13 +
14 +/** `--trigger-config` as a record, `undefined` when the flag is absent. */
15 +const parseTriggerConfig = (triggerConfig: Option.Option<string>) =>
16 + Option.match(triggerConfig, {
17 + onNone: () => Result.succeed(undefined),
18 + onSome: parseJsonRecord,
19 + });
20 +
21 +const reportInvalidTriggerConfig = (ui: TerminalUI, error: JsonParsingError) =>
22 + Match.value(error.reason).pipe(
23 + Match.when('not-a-record', () =>
24 + ui.log.error('--trigger-config must be a JSON object (e.g. \'{"key":"value"}\').')
25 + ),
26 + Match.when('syntax', () =>
27 + Effect.andThen(
28 + ui.log.error('Invalid JSON in --trigger-config. Please provide valid JSON.'),
29 + ui.log.step(
30 + 'Example:\n> composio dev triggers create "GMAIL_NEW_GMAIL_MESSAGE" --trigger-config \'{"label":"inbox"}\''
31 + )
32 + )
33 + ),
34 + Match.exhaustive
35 + );
36 +
37 +/**
38 + * Create a trigger instance.
39 + *
40 + * @example
41 + * ```bash
42 + * composio dev triggers create "GMAIL_NEW_GMAIL_MESSAGE" --connected-account-id "con_123"
43 + * ```
44 + */
45 +export const runTriggersCreate = ({
46 + triggerName,
47 + connectedAccountId,
48 + triggerConfig,
49 +}: TriggersCreateParams) =>
50 + Effect.gen(function* () {
51 + const ui = yield* TerminalUI;
52 + const repo = yield* ComposioToolkitsRepository;
53 +
54 + if (Option.isNone(triggerName)) {
55 + yield* ui.log.warn('Missing required argument: <trigger-name>');
56 + yield* ui.log.step(
57 + 'Try specifying a trigger slug, e.g.:\n> composio dev triggers create "GMAIL_NEW_GMAIL_MESSAGE" --connected-account-id "con_123"'
58 + );
59 + return;
60 + }
61 +
62 + const parsedTriggerConfig = parseTriggerConfig(triggerConfig);
63 + if (Result.isFailure(parsedTriggerConfig)) {
64 + yield* reportInvalidTriggerConfig(ui, parsedTriggerConfig.failure);
65 + return;
66 + }
67 +
68 + const createdOpt = yield* ui
69 + .withSpinner(
70 + `Creating trigger "${triggerName.value}"...`,
71 + repo.createTrigger(triggerName.value, {
72 + connected_account_id: Option.getOrUndefined(connectedAccountId),
73 + trigger_config: parsedTriggerConfig.success,
74 + })
75 + )
76 + .pipe(
77 + Effect.asSome,
78 + Effect.catchTag(
79 + CLIENT_API_ERROR_TAGS,
80 + handleClientApiError(ui, {
81 + fallbackMessage: `Failed to create trigger "${triggerName.value}".`,
82 + hint: 'List available trigger types with:\n> composio dev triggers list',
83 + fallbackValue: Option.none(),
84 + })
85 + )
86 + );
87 +
88 + if (Option.isNone(createdOpt)) {
89 + return;
90 + }
91 +
92 + const created = createdOpt.value;
93 + yield* ui.log.success(`Trigger created: ${created.trigger_id}`);
94 + yield* ui.log.step(
95 + `To check status:\n> composio dev triggers status --trigger-ids "${created.trigger_id}"`
96 + );
97 + yield* ui.output(JSON.stringify(created, null, 2));
98 + });
ts/packages/cli/src/commands/triggers/disable/triggers.disable.cmd.ts new
+18
@@ -0,0 +1,18 @@
1 +import { Argument, Command, Flag } from 'effect/cli';
2 +import { runTriggersDisable } from './triggers.disable.handler';
3 +
4 +const id = Argument.String('id').pipe(
5 + Argument.withDescription('Trigger instance ID'),
6 + Argument.optional
7 +);
8 +
9 +const dangerouslyAllow = Flag.Boolean('dangerously-allow').pipe(
10 + Flag.withDescription('Acknowledge disabling this trigger instance'),
11 + Flag.withDefault(false)
12 +);
13 +
14 +export const triggersCmd$Disable = Command.make(
15 + 'disable',
16 + { id, dangerouslyAllow },
17 + runTriggersDisable
18 +).pipe(Command.withDescription('Disable a trigger instance.'));
ts/packages/cli/src/commands/triggers/disable/triggers.disable.handler.ts new
+68
@@ -0,0 +1,68 @@
1 +import { Effect, Option } from 'effect';
2 +import { commandInputError } from 'src/commands/errors';
3 +import { handleClientApiError } from 'src/effects/handle-http-error';
4 +import { ComposioCliUserConfig } from 'src/services/cli-user-config';
5 +import { ComposioToolkitsRepository } from 'src/services/composio-clients';
6 +import { CLIENT_API_ERROR_TAGS } from 'src/services/composio-errors';
7 +import { TerminalUI } from 'src/services/terminal-ui';
8 +
9 +export type TriggersDisableParams = {
10 + readonly id: Option.Option<string>;
11 + readonly dangerouslyAllow: boolean;
12 +};
13 +
14 +const notAllowed = commandInputError('dev triggers disable');
15 +
16 +/**
17 + * Disable an existing trigger instance. A developer-destructive command: it runs only when
18 + * `developer.destructive_actions` is enabled and `--dangerously-allow` is passed.
19 + *
20 + * @example
21 + * ```bash
22 + * composio dev triggers disable "trg_123" --dangerously-allow
23 + * ```
24 + */
25 +export const runTriggersDisable = ({ id, dangerouslyAllow }: TriggersDisableParams) =>
26 + Effect.gen(function* () {
27 + const config = yield* ComposioCliUserConfig;
28 + if (!config.areDeveloperDangerousCommandsEnabled()) {
29 + return yield* notAllowed(
30 + 'This developer command is disabled by config. Set developer.destructive_actions to true in ~/.composio/config.json to allow it.'
31 + );
32 + }
33 + if (!dangerouslyAllow) {
34 + return yield* notAllowed(
35 + 'This developer command requires explicit acknowledgement. Re-run with --dangerously-allow.',
36 + '--dangerously-allow'
37 + );
38 + }
39 + const ui = yield* TerminalUI;
40 + const repo = yield* ComposioToolkitsRepository;
41 +
42 + if (Option.isNone(id)) {
43 + yield* ui.log.warn('Missing required argument: <id>');
44 + yield* ui.log.step(
45 + 'Try specifying a trigger ID, e.g.:\n> composio dev triggers disable "trg_123"\n\nTo find trigger IDs:\n> composio dev triggers status'
46 + );
47 + return;
48 + }
49 +
50 + const idValue = id.value;
51 + const disabled = yield* ui
52 + .withSpinner(`Disabling trigger "${idValue}"...`, repo.disableTrigger(idValue))
53 + .pipe(
54 + Effect.as(true),
55 + Effect.catchTag(
56 + CLIENT_API_ERROR_TAGS,
57 + handleClientApiError(ui, {
58 + fallbackMessage: `Failed to disable trigger "${idValue}".`,
59 + hint: 'Browse available triggers:\n> composio dev triggers status',
60 + fallbackValue: false,
61 + })
62 + )
63 + );
64 +
65 + if (!disabled) return;
66 +
67 + yield* ui.log.success(`Trigger "${idValue}" disabled.`);
68 + });
ts/packages/cli/src/commands/triggers/enable/triggers.enable.cmd.ts new
+11
@@ -0,0 +1,11 @@
1 +import { Argument, Command } from 'effect/cli';
2 +import { runTriggersEnable } from './triggers.enable.handler';
3 +
4 +const id = Argument.String('id').pipe(
5 + Argument.withDescription('Trigger instance ID'),
6 + Argument.optional
7 +);
8 +
9 +export const triggersCmd$Enable = Command.make('enable', { id }, runTriggersEnable).pipe(
10 + Command.withDescription('Enable a trigger instance.')
11 +);
ts/packages/cli/src/commands/triggers/enable/triggers.enable.handler.ts renamed
+11 -9
@@ -1,19 +1,22 @@
1 -import { Argument, Command } from 'effect/cli';
1 import { Effect, Option } from 'effect';
2 import { handleClientApiError } from 'src/effects/handle-http-error';
4 -import { CLIENT_API_ERROR_TAGS } from 'src/services/composio-errors';
3 import { ComposioToolkitsRepository } from 'src/services/composio-clients';
4 +import { CLIENT_API_ERROR_TAGS } from 'src/services/composio-errors';
5 import { TerminalUI } from 'src/services/terminal-ui';
6
8 -const id = Argument.String('id').pipe(
9 - Argument.withDescription('Trigger instance ID'),
10 - Argument.optional
11 -);
7 +export type TriggersEnableParams = {
8 + readonly id: Option.Option<string>;
9 +};
10
11 /**
12 * Enable an existing trigger instance.
13 + *
14 + * @example
15 + * ```bash
16 + * composio dev triggers enable "trg_123"
17 + * ```
18 */
16 -export const triggersCmd$Enable = Command.make('enable', { id }, ({ id }) =>
19 +export const runTriggersEnable = ({ id }: TriggersEnableParams) =>
20 Effect.gen(function* () {
21 const ui = yield* TerminalUI;
22 const repo = yield* ComposioToolkitsRepository;
@@ -44,5 +47,4 @@ export const triggersCmd$Enable = Command.make('enable', { id }, ({ id }) =>
47 if (!enabled) return;
48
49 yield* ui.log.success(`Trigger "${idValue}" enabled.`);
47 - })
48 -).pipe(Command.withDescription('Enable a trigger instance.'));
50 + });
ts/packages/cli/src/commands/triggers/triggers.cmd.ts
+3 -3
@@ -4,9 +4,9 @@ import { rejectsSharedFlags } from 'src/commands/surface';
4 import { triggersCmd$Info } from './info/triggers.info.cmd';
5 import { triggersCmd$List } from './list/triggers.list.cmd';
6 import { triggersCmd$Status } from './commands/triggers.status.cmd';
7 -import { triggersCmd$Create } from './commands/triggers.create.cmd';
8 -import { triggersCmd$Enable } from './commands/triggers.enable.cmd';
9 -import { triggersCmd$Disable } from './commands/triggers.disable.cmd';
7 +import { triggersCmd$Create } from './create/triggers.create.cmd';
8 +import { triggersCmd$Enable } from './enable/triggers.enable.cmd';
9 +import { triggersCmd$Disable } from './disable/triggers.disable.cmd';
10 import { triggersCmd$Listen } from './commands/triggers.listen.cmd';
11
12 /**
ts/packages/cli/test/src/commands/triggers/create/triggers.create.cmd.test.ts renamed
+70 -34
@@ -1,6 +1,11 @@
1 import { describe, expect, layer } from '@effect/vitest';
2 -import { ConfigProvider, Effect } from 'effect';
2 +import { ConfigProvider, Effect, Layer } from 'effect';
3 +import type { TriggerInstanceUpsertParams } from '@composio/client/resources/trigger-instances';
4 +import { ComposioToolkitsRepository } from 'src/services/composio-clients';
5 import { cli, MockConsole, TestLive } from 'test/__utils__';
6 +import { notFoundError } from 'test/__utils__/layers/not-found';
7 +import { recordingNodeProcess } from 'test/__utils__/services/node-process-test';
8 +import { makeToolkitsRepositoryStub } from 'test/__utils__/services/toolkits-repository-stub';
9
10 const testConfigProvider = ConfigProvider.fromEnv({
11 env: { COMPOSIO_USER_API_KEY: 'test_api_key' },
@@ -11,7 +16,7 @@ const dangerousDevConfig = {
16 cliUserConfig: { developerDangerousCommandsEnabled: true },
17 } as const;
18
14 -describe('CLI: composio dev triggers mutations', () => {
19 +describe('CLI: composio dev triggers create', () => {
20 layer(TestLive(dangerousDevConfig))(
21 '[Given] create with valid args [Then] creates trigger',
22 it => {
@@ -30,6 +35,47 @@ describe('CLI: composio dev triggers mutations', () => {
35
36 expect(output).toContain('Trigger created');
37 expect(output).toContain('trg_gmail_new_gmail_message_con_123');
38 + expect(lines.at(-1)).toBe(
39 + JSON.stringify({ trigger_id: 'trg_gmail_new_gmail_message_con_123' }, null, 2)
40 + );
41 + })
42 + );
43 + }
44 + );
45 +
46 + layer(TestLive(dangerousDevConfig))(
47 + '[Given] create with a JSON object config [Then] sends it as the trigger config',
48 + it => {
49 + it.effect('passes the parsed config and connected account to the API', () =>
50 + Effect.gen(function* () {
51 + const calls: Array<{ slug: string; params?: TriggerInstanceUpsertParams }> = [];
52 + const repository = Layer.succeed(
53 + ComposioToolkitsRepository,
54 + makeToolkitsRepositoryStub({
55 + createTrigger: (slug, params) =>
56 + Effect.sync(() => {
57 + calls.push({ slug, params });
58 + return { trigger_id: 'trg_new' };
59 + }),
60 + })
61 + );
62 + yield* cli([
63 + 'dev',
64 + 'triggers',
65 + 'create',
66 + 'GMAIL_NEW_GMAIL_MESSAGE',
67 + '--connected-account-id',
68 + 'con_123',
69 + '--trigger-config',
70 + '{"labelIds":"INBOX"}',
71 + ]).pipe(Effect.provide(repository));
72 +
73 + expect(calls).toEqual([
74 + {
75 + slug: 'GMAIL_NEW_GMAIL_MESSAGE',
76 + params: { connected_account_id: 'con_123', trigger_config: { labelIds: 'INBOX' } },
77 + },
78 + ]);
79 })
80 );
81 }
@@ -57,28 +103,6 @@ describe('CLI: composio dev triggers mutations', () => {
103 }
104 );
105
60 - layer(TestLive(dangerousDevConfig))('[Given] enable with ID [Then] enables trigger', it => {
61 - it.effect('enables trigger successfully', () =>
62 - Effect.gen(function* () {
63 - yield* cli(['dev', 'triggers', 'enable', 'trg_123']);
64 - const lines = yield* MockConsole.getLines({ stripAnsi: true });
65 - const output = lines.join('\n');
66 - expect(output).toContain('enabled');
67 - })
68 - );
69 - });
70 -
71 - layer(TestLive(dangerousDevConfig))('[Given] disable with ID [Then] disables trigger', it => {
72 - it.effect('disables trigger successfully', () =>
73 - Effect.gen(function* () {
74 - yield* cli(['dev', 'triggers', 'disable', 'trg_123', '--dangerously-allow']);
75 - const lines = yield* MockConsole.getLines({ stripAnsi: true });
76 - const output = lines.join('\n');
77 - expect(output).toContain('disabled');
78 - })
79 - );
80 - });
81 -
106 layer(TestLive(dangerousDevConfig))(
107 '[Given] create with non-object JSON config [Then] shows type validation error',
108 it => {
@@ -119,28 +143,40 @@ describe('CLI: composio dev triggers mutations', () => {
143 );
144
145 layer(TestLive(dangerousDevConfig))(
122 - '[Given] missing ID for enable [Then] warns about missing argument',
146 + '[Given] create without a trigger name [Then] warns about missing argument',
147 it => {
124 - it.effect('shows missing id warning', () =>
148 + it.effect('shows missing trigger-name warning', () =>
149 Effect.gen(function* () {
126 - yield* cli(['dev', 'triggers', 'enable']);
150 + yield* cli(['dev', 'triggers', 'create']);
151 const lines = yield* MockConsole.getLines({ stripAnsi: true });
152 const output = lines.join('\n');
129 - expect(output).toContain('Missing required argument');
153 + expect(output).toContain('Missing required argument: <trigger-name>');
154 })
155 );
156 }
157 );
158
159 layer(TestLive(dangerousDevConfig))(
136 - '[Given] missing ID for disable [Then] warns about missing argument',
160 + '[Given] the API rejects the create [Then] reports the failure and exits 1',
161 it => {
138 - it.effect('shows missing id warning', () =>
162 + it.effect('prints the fallback message and the list hint', () =>
163 Effect.gen(function* () {
140 - yield* cli(['dev', 'triggers', 'disable', '--dangerously-allow']);
141 - const lines = yield* MockConsole.getLines({ stripAnsi: true });
142 - const output = lines.join('\n');
143 - expect(output).toContain('Missing required argument');
164 + const proc = recordingNodeProcess();
165 + const repository = Layer.succeed(
166 + ComposioToolkitsRepository,
167 + makeToolkitsRepositoryStub({
168 + createTrigger: () => Effect.fail(notFoundError('Trigger type not found')),
169 + })
170 + );
171 + yield* cli(['dev', 'triggers', 'create', 'UNKNOWN_TRIGGER']).pipe(
172 + Effect.provide(Layer.merge(repository, proc.layer))
173 + );
174 + const output = (yield* MockConsole.getLines({ stripAnsi: true })).join('\n');
175 +
176 + expect(output).toContain('Failed to create trigger "UNKNOWN_TRIGGER".');
177 + expect(output).toContain('composio dev triggers list');
178 + expect(output).not.toContain('Trigger created');
179 + expect(proc.exitCode()).toBe(1);
180 })
181 );
182 }
ts/packages/cli/test/src/commands/triggers/disable/triggers.disable.cmd.test.ts new
+108
@@ -0,0 +1,108 @@
1 +import { describe, expect, layer } from '@effect/vitest';
2 +import { ConfigProvider, Effect, Layer } from 'effect';
3 +import { ComposioToolkitsRepository } from 'src/services/composio-clients';
4 +import { cli, MockConsole, TestLive } from 'test/__utils__';
5 +import { notFoundError } from 'test/__utils__/layers/not-found';
6 +import { recordingNodeProcess } from 'test/__utils__/services/node-process-test';
7 +import { makeToolkitsRepositoryStub } from 'test/__utils__/services/toolkits-repository-stub';
8 +
9 +const testConfigProvider = ConfigProvider.fromEnv({
10 + env: { COMPOSIO_USER_API_KEY: 'test_api_key' },
11 +});
12 +
13 +const dangerousDevConfig = {
14 + baseConfigProvider: testConfigProvider,
15 + cliUserConfig: { developerDangerousCommandsEnabled: true },
16 +} as const;
17 +
18 +describe('CLI: composio dev triggers disable', () => {
19 + layer(TestLive(dangerousDevConfig))('[Given] disable with ID [Then] disables trigger', it => {
20 + it.effect('disables trigger successfully', () =>
21 + Effect.gen(function* () {
22 + yield* cli(['dev', 'triggers', 'disable', 'trg_123', '--dangerously-allow']);
23 + const lines = yield* MockConsole.getLines({ stripAnsi: true });
24 + const output = lines.join('\n');
25 + expect(output).toContain('disabled');
26 + })
27 + );
28 + });
29 +
30 + layer(TestLive(dangerousDevConfig))(
31 + '[Given] missing ID for disable [Then] warns about missing argument',
32 + it => {
33 + it.effect('shows missing id warning', () =>
34 + Effect.gen(function* () {
35 + yield* cli(['dev', 'triggers', 'disable', '--dangerously-allow']);
36 + const lines = yield* MockConsole.getLines({ stripAnsi: true });
37 + const output = lines.join('\n');
38 + expect(output).toContain('Missing required argument');
39 + })
40 + );
41 + }
42 + );
43 +
44 + layer(TestLive(dangerousDevConfig))(
45 + '[Given] disable without --dangerously-allow [Then] fails on that flag',
46 + it => {
47 + it.effect('raises a CommandInputError naming --dangerously-allow', () =>
48 + Effect.gen(function* () {
49 + const failure = yield* cli(['dev', 'triggers', 'disable', 'trg_123']).pipe(Effect.flip);
50 +
51 + expect(failure).toMatchObject({
52 + _tag: 'commands/CommandInputError',
53 + option: '--dangerously-allow',
54 + message: expect.stringContaining('requires explicit acknowledgement'),
55 + });
56 + })
57 + );
58 + }
59 + );
60 +
61 + layer(TestLive({ baseConfigProvider: testConfigProvider }))(
62 + '[Given] destructive dev commands disabled by config [Then] fails before the flag check',
63 + it => {
64 + it.effect('raises a CommandInputError naming the config setting', () =>
65 + Effect.gen(function* () {
66 + const failure = yield* cli([
67 + 'dev',
68 + 'triggers',
69 + 'disable',
70 + 'trg_123',
71 + '--dangerously-allow',
72 + ]).pipe(Effect.flip);
73 +
74 + expect(failure).toMatchObject({
75 + _tag: 'commands/CommandInputError',
76 + message: expect.stringContaining('developer.destructive_actions'),
77 + });
78 + })
79 + );
80 + }
81 + );
82 +
83 + layer(TestLive(dangerousDevConfig))(
84 + '[Given] the API rejects the disable [Then] reports the failure and exits 1',
85 + it => {
86 + it.effect('prints the fallback message and the status hint', () =>
87 + Effect.gen(function* () {
88 + const proc = recordingNodeProcess();
89 + const repository = Layer.succeed(
90 + ComposioToolkitsRepository,
91 + makeToolkitsRepositoryStub({
92 + disableTrigger: () => Effect.fail(notFoundError('Trigger not found')),
93 + })
94 + );
95 + yield* cli(['dev', 'triggers', 'disable', 'trg_missing', '--dangerously-allow']).pipe(
96 + Effect.provide(Layer.merge(repository, proc.layer))
97 + );
98 + const output = (yield* MockConsole.getLines({ stripAnsi: true })).join('\n');
99 +
100 + expect(output).toContain('Failed to disable trigger "trg_missing".');
101 + expect(output).toContain('composio dev triggers status');
102 + expect(output).not.toContain('Trigger "trg_missing" disabled.');
103 + expect(proc.exitCode()).toBe(1);
104 + })
105 + );
106 + }
107 + );
108 +});
ts/packages/cli/test/src/commands/triggers/enable/triggers.enable.cmd.test.ts new
+69
@@ -0,0 +1,69 @@
1 +import { describe, expect, layer } from '@effect/vitest';
2 +import { ConfigProvider, Effect, Layer } from 'effect';
3 +import { ComposioToolkitsRepository } from 'src/services/composio-clients';
4 +import { cli, MockConsole, TestLive } from 'test/__utils__';
5 +import { notFoundError } from 'test/__utils__/layers/not-found';
6 +import { recordingNodeProcess } from 'test/__utils__/services/node-process-test';
7 +import { makeToolkitsRepositoryStub } from 'test/__utils__/services/toolkits-repository-stub';
8 +
9 +const testConfigProvider = ConfigProvider.fromEnv({
10 + env: { COMPOSIO_USER_API_KEY: 'test_api_key' },
11 +});
12 +
13 +const dangerousDevConfig = {
14 + baseConfigProvider: testConfigProvider,
15 + cliUserConfig: { developerDangerousCommandsEnabled: true },
16 +} as const;
17 +
18 +describe('CLI: composio dev triggers enable', () => {
19 + layer(TestLive(dangerousDevConfig))('[Given] enable with ID [Then] enables trigger', it => {
20 + it.effect('enables trigger successfully', () =>
21 + Effect.gen(function* () {
22 + yield* cli(['dev', 'triggers', 'enable', 'trg_123']);
23 + const lines = yield* MockConsole.getLines({ stripAnsi: true });
24 + const output = lines.join('\n');
25 + expect(output).toContain('enabled');
26 + })
27 + );
28 + });
29 +
30 + layer(TestLive(dangerousDevConfig))(
31 + '[Given] missing ID for enable [Then] warns about missing argument',
32 + it => {
33 + it.effect('shows missing id warning', () =>
34 + Effect.gen(function* () {
35 + yield* cli(['dev', 'triggers', 'enable']);
36 + const lines = yield* MockConsole.getLines({ stripAnsi: true });
37 + const output = lines.join('\n');
38 + expect(output).toContain('Missing required argument');
39 + })
40 + );
41 + }
42 + );
43 +
44 + layer(TestLive(dangerousDevConfig))(
45 + '[Given] the API rejects the enable [Then] reports the failure and exits 1',
46 + it => {
47 + it.effect('prints the fallback message and the status hint', () =>
48 + Effect.gen(function* () {
49 + const proc = recordingNodeProcess();
50 + const repository = Layer.succeed(
51 + ComposioToolkitsRepository,
52 + makeToolkitsRepositoryStub({
53 + enableTrigger: () => Effect.fail(notFoundError('Trigger not found')),
54 + })
55 + );
56 + yield* cli(['dev', 'triggers', 'enable', 'trg_missing']).pipe(
57 + Effect.provide(Layer.merge(repository, proc.layer))
58 + );
59 + const output = (yield* MockConsole.getLines({ stripAnsi: true })).join('\n');
60 +
61 + expect(output).toContain('Failed to enable trigger "trg_missing".');
62 + expect(output).toContain('composio dev triggers status --show-disabled');
63 + expect(output).not.toContain('Trigger "trg_missing" enabled.');
64 + expect(proc.exitCode()).toBe(1);
65 + })
66 + );
67 + }
68 + );
69 +});