@devries-cameron20 / composio-1 / commits / 25c6e06cd
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.

feat(cli): add trigger status and lifecycle commands

Improve local trigger development by adding trigger status listing with filters and lifecycle mutations (create, enable, disable, delete) so users can manage trigger instances directly from the CLI. Co-authored-by: Cursor <cursoragent@cursor.com>

haxzie committed Feb 23, 2026 at 19:18 UTC 25c6e06cd57098f24ad5b9be313312aa6b6a77d5
14 files changed +1057 -33
ts/packages/cli/src/commands/triggers/commands/triggers.create.cmd.ts new
+88
@@ -0,0 +1,88 @@
1 +import { Args, Command, Options } from '@effect/cli';
2 +import { Effect, Option } from 'effect';
3 +import { requireAuth } from 'src/effects/require-auth';
4 +import { handleHttpServerError } from 'src/effects/handle-http-error';
5 +import { ComposioToolkitsRepository } from 'src/services/composio-clients';
6 +import { TerminalUI } from 'src/services/terminal-ui';
7 +
8 +const triggerName = Args.text({ name: 'trigger-name' }).pipe(
9 + Args.withDescription('Trigger slug (e.g. "GMAIL_NEW_GMAIL_MESSAGE")'),
10 + Args.optional
11 +);
12 +
13 +const connectedAccountId = Options.text('connected-account-id').pipe(
14 + Options.withDescription('Connected account ID (nanoid)'),
15 + Options.optional
16 +);
17 +
18 +const triggerConfig = Options.text('trigger-config').pipe(
19 + Options.withDescription('Trigger config as JSON string'),
20 + Options.optional
21 +);
22 +
23 +/**
24 + * Create a trigger instance.
25 + */
26 +export const triggersCmd$Create = Command.make(
27 + 'create',
28 + { triggerName, connectedAccountId, triggerConfig },
29 + ({ triggerName, connectedAccountId, triggerConfig }) =>
30 + Effect.gen(function* () {
31 + if (!(yield* requireAuth)) return;
32 +
33 + const ui = yield* TerminalUI;
34 + const repo = yield* ComposioToolkitsRepository;
35 +
36 + if (Option.isNone(triggerName)) {
37 + yield* ui.log.warn('Missing required argument: <trigger-name>');
38 + yield* ui.log.step(
39 + 'Try specifying a trigger slug, e.g.:\n> composio triggers create "GMAIL_NEW_GMAIL_MESSAGE" --connected-account-id "con_123"'
40 + );
41 + return;
42 + }
43 +
44 + let parsedTriggerConfig: Record<string, unknown> | undefined;
45 + if (Option.isSome(triggerConfig)) {
46 + try {
47 + parsedTriggerConfig = JSON.parse(triggerConfig.value) as Record<string, unknown>;
48 + } catch {
49 + yield* ui.log.error('Invalid JSON in --trigger-config. Please provide valid JSON.');
50 + yield* ui.log.step(
51 + 'Example:\n> composio triggers create "GMAIL_NEW_GMAIL_MESSAGE" --trigger-config \'{"label":"inbox"}\''
52 + );
53 + return;
54 + }
55 + }
56 +
57 + const createdOpt = yield* ui
58 + .withSpinner(
59 + `Creating trigger "${triggerName.value}"...`,
60 + repo.createTrigger(triggerName.value, {
61 + connected_account_id: Option.getOrUndefined(connectedAccountId),
62 + trigger_config: parsedTriggerConfig,
63 + })
64 + )
65 + .pipe(
66 + Effect.asSome,
67 + Effect.catchTag(
68 + 'services/HttpServerError',
69 + handleHttpServerError(ui, {
70 + fallbackMessage: `Failed to create trigger "${triggerName.value}".`,
71 + hint: 'List available trigger types with:\n> composio triggers status',
72 + fallbackValue: Option.none(),
73 + })
74 + )
75 + );
76 +
77 + if (Option.isNone(createdOpt)) {
78 + return;
79 + }
80 +
81 + const created = createdOpt.value;
82 + yield* ui.log.success(`Trigger created: ${created.trigger_id}`);
83 + yield* ui.log.step(
84 + `To check status:\n> composio triggers status --trigger-ids "${created.trigger_id}"`
85 + );
86 + yield* ui.output(JSON.stringify(created, null, 2));
87 + })
88 +).pipe(Command.withDescription('Create a new trigger instance.'));
ts/packages/cli/src/commands/triggers/commands/triggers.delete.cmd.ts new
+67
@@ -0,0 +1,67 @@
1 +import { Args, Command, Options } from '@effect/cli';
2 +import { Effect, Option } from 'effect';
3 +import { requireAuth } from 'src/effects/require-auth';
4 +import { handleHttpServerError } from 'src/effects/handle-http-error';
5 +import { ComposioToolkitsRepository } from 'src/services/composio-clients';
6 +import { TerminalUI } from 'src/services/terminal-ui';
7 +
8 +const id = Args.text({ name: 'id' }).pipe(
9 + Args.withDescription('Trigger instance ID'),
10 + Args.optional
11 +);
12 +
13 +const yes = Options.boolean('yes').pipe(
14 + Options.withAlias('y'),
15 + Options.withDescription('Skip confirmation prompt'),
16 + Options.withDefault(false)
17 +);
18 +
19 +/**
20 + * Delete a trigger instance.
21 + */
22 +export const triggersCmd$Delete = Command.make('delete', { id, yes }, ({ id, yes }) =>
23 + Effect.gen(function* () {
24 + if (!(yield* requireAuth)) return;
25 +
26 + const ui = yield* TerminalUI;
27 + const repo = yield* ComposioToolkitsRepository;
28 +
29 + if (Option.isNone(id)) {
30 + yield* ui.log.warn('Missing required argument: <id>');
31 + yield* ui.log.step(
32 + 'Try specifying a trigger ID, e.g.:\n> composio triggers delete "trg_123" --yes\n\nTo find trigger IDs:\n> composio triggers status --show-disabled'
33 + );
34 + return;
35 + }
36 +
37 + const idValue = id.value;
38 +
39 + if (!yes) {
40 + const confirmed = yield* ui.confirm(`Delete trigger "${idValue}"? This cannot be undone.`, {
41 + defaultValue: false,
42 + });
43 + if (!confirmed) {
44 + yield* ui.log.warn('Deletion cancelled.');
45 + return;
46 + }
47 + }
48 +
49 + const deleted = yield* ui
50 + .withSpinner(`Deleting trigger "${idValue}"...`, repo.deleteTrigger(idValue))
51 + .pipe(
52 + Effect.as(true),
53 + Effect.catchTag(
54 + 'services/HttpServerError',
55 + handleHttpServerError(ui, {
56 + fallbackMessage: `Failed to delete trigger "${idValue}".`,
57 + hint: 'Browse available triggers:\n> composio triggers status --show-disabled',
58 + fallbackValue: false,
59 + })
60 + )
61 + );
62 +
63 + if (!deleted) return;
64 +
65 + yield* ui.log.success(`Trigger "${idValue}" deleted.`);
66 + })
67 +).pipe(Command.withDescription('Delete a trigger instance.'));
ts/packages/cli/src/commands/triggers/commands/triggers.disable.cmd.ts new
+50
@@ -0,0 +1,50 @@
1 +import { Args, Command } from '@effect/cli';
2 +import { Effect, Option } from 'effect';
3 +import { requireAuth } from 'src/effects/require-auth';
4 +import { handleHttpServerError } from 'src/effects/handle-http-error';
5 +import { ComposioToolkitsRepository } from 'src/services/composio-clients';
6 +import { TerminalUI } from 'src/services/terminal-ui';
7 +
8 +const id = Args.text({ name: 'id' }).pipe(
9 + Args.withDescription('Trigger instance ID'),
10 + Args.optional
11 +);
12 +
13 +/**
14 + * Disable an existing trigger instance.
15 + */
16 +export const triggersCmd$Disable = Command.make('disable', { id }, ({ id }) =>
17 + Effect.gen(function* () {
18 + if (!(yield* requireAuth)) return;
19 +
20 + const ui = yield* TerminalUI;
21 + const repo = yield* ComposioToolkitsRepository;
22 +
23 + if (Option.isNone(id)) {
24 + yield* ui.log.warn('Missing required argument: <id>');
25 + yield* ui.log.step(
26 + 'Try specifying a trigger ID, e.g.:\n> composio triggers disable "trg_123"\n\nTo find trigger IDs:\n> composio triggers status'
27 + );
28 + return;
29 + }
30 +
31 + const idValue = id.value;
32 + const disabled = yield* ui
33 + .withSpinner(`Disabling trigger "${idValue}"...`, repo.disableTrigger(idValue))
34 + .pipe(
35 + Effect.as(true),
36 + Effect.catchTag(
37 + 'services/HttpServerError',
38 + handleHttpServerError(ui, {
39 + fallbackMessage: `Failed to disable trigger "${idValue}".`,
40 + hint: 'Browse available triggers:\n> composio triggers status',
41 + fallbackValue: false,
42 + })
43 + )
44 + );
45 +
46 + if (!disabled) return;
47 +
48 + yield* ui.log.success(`Trigger "${idValue}" disabled.`);
49 + })
50 +).pipe(Command.withDescription('Disable a trigger instance.'));
ts/packages/cli/src/commands/triggers/commands/triggers.enable.cmd.ts new
+50
@@ -0,0 +1,50 @@
1 +import { Args, Command } from '@effect/cli';
2 +import { Effect, Option } from 'effect';
3 +import { requireAuth } from 'src/effects/require-auth';
4 +import { handleHttpServerError } from 'src/effects/handle-http-error';
5 +import { ComposioToolkitsRepository } from 'src/services/composio-clients';
6 +import { TerminalUI } from 'src/services/terminal-ui';
7 +
8 +const id = Args.text({ name: 'id' }).pipe(
9 + Args.withDescription('Trigger instance ID'),
10 + Args.optional
11 +);
12 +
13 +/**
14 + * Enable an existing trigger instance.
15 + */
16 +export const triggersCmd$Enable = Command.make('enable', { id }, ({ id }) =>
17 + Effect.gen(function* () {
18 + if (!(yield* requireAuth)) return;
19 +
20 + const ui = yield* TerminalUI;
21 + const repo = yield* ComposioToolkitsRepository;
22 +
23 + if (Option.isNone(id)) {
24 + yield* ui.log.warn('Missing required argument: <id>');
25 + yield* ui.log.step(
26 + 'Try specifying a trigger ID, e.g.:\n> composio triggers enable "trg_123"\n\nTo find trigger IDs:\n> composio triggers status --show-disabled'
27 + );
28 + return;
29 + }
30 +
31 + const idValue = id.value;
32 + const enabled = yield* ui
33 + .withSpinner(`Enabling trigger "${idValue}"...`, repo.enableTrigger(idValue))
34 + .pipe(
35 + Effect.as(true),
36 + Effect.catchTag(
37 + 'services/HttpServerError',
38 + handleHttpServerError(ui, {
39 + fallbackMessage: `Failed to enable trigger "${idValue}".`,
40 + hint: 'Browse available triggers:\n> composio triggers status --show-disabled',
41 + fallbackValue: false,
42 + })
43 + )
44 + );
45 +
46 + if (!enabled) return;
47 +
48 + yield* ui.log.success(`Trigger "${idValue}" enabled.`);
49 + })
50 +).pipe(Command.withDescription('Enable a trigger instance.'));
ts/packages/cli/src/commands/triggers/commands/triggers.status.cmd.ts new
+152
@@ -0,0 +1,152 @@
1 +import { Command, Options } from '@effect/cli';
2 +import { Effect, Option } from 'effect';
3 +import { requireAuth } from 'src/effects/require-auth';
4 +import { ComposioToolkitsRepository } from 'src/services/composio-clients';
5 +import { TerminalUI } from 'src/services/terminal-ui';
6 +import { clampLimit } from 'src/ui/clamp-limit';
7 +import { formatTriggersStatusJson, formatTriggersStatusTable } from '../format';
8 +
9 +const userIds = Options.text('user-ids').pipe(
10 + Options.withDescription('Filter by user IDs, comma-separated'),
11 + Options.optional
12 +);
13 +
14 +const connectedAccountIds = Options.text('connected-account-ids').pipe(
15 + Options.withDescription('Filter by connected account IDs, comma-separated'),
16 + Options.optional
17 +);
18 +
19 +const toolkits = Options.text('toolkits').pipe(
20 + Options.withDescription(
21 + 'Filter by toolkit slugs, comma-separated (e.g. "gmail" or "gmail,slack")'
22 + ),
23 + Options.optional
24 +);
25 +
26 +const triggerIds = Options.text('trigger-ids').pipe(
27 + Options.withDescription('Filter by trigger instance IDs, comma-separated'),
28 + Options.optional
29 +);
30 +
31 +const triggerNames = Options.text('trigger-names').pipe(
32 + Options.withDescription(
33 + 'Filter by trigger names, comma-separated (case-insensitive; normalized to uppercase)'
34 + ),
35 + Options.optional
36 +);
37 +
38 +const showDisabled = Options.boolean('show-disabled').pipe(
39 + Options.withDefault(false),
40 + Options.withDescription('Include disabled triggers in the response')
41 +);
42 +
43 +const deprecatedConnectedAccountUuids = Options.text('deprecated-connected-account-uuids').pipe(
44 + Options.withDescription(
45 + 'DEPRECATED: Use --connected-account-ids instead. Filter by connected account UUIDs, comma-separated'
46 + ),
47 + Options.optional
48 +);
49 +
50 +const limit = Options.integer('limit').pipe(
51 + Options.withDefault(30),
52 + Options.withDescription('Number of results per page (1-1000)')
53 +);
54 +
55 +const parseCsv = (value: string): string[] =>
56 + value
57 + .split(',')
58 + .map(item => item.trim())
59 + .filter(Boolean);
60 +
61 +const csvOption = (opt: Option.Option<string>): string[] | undefined =>
62 + Option.isSome(opt) ? parseCsv(opt.value) : undefined;
63 +
64 +const mergeCsvOptions = (
65 + preferred: Option.Option<string>,
66 + deprecated: Option.Option<string>
67 +): string[] | undefined => {
68 + const preferredValues = csvOption(preferred) ?? [];
69 + const deprecatedValues = csvOption(deprecated) ?? [];
70 + const merged = [...preferredValues, ...deprecatedValues];
71 + return merged.length > 0 ? merged : undefined;
72 +};
73 +
74 +const deriveToolkitSlug = (triggerName: string): string => {
75 + const prefix = triggerName.split('_')[0];
76 + return prefix ? prefix.toLowerCase() : '';
77 +};
78 +
79 +/**
80 + * Display active trigger instances with optional filters.
81 + */
82 +export const triggersCmd$Status = Command.make(
83 + 'status',
84 + {
85 + userIds,
86 + connectedAccountIds,
87 + toolkits,
88 + triggerIds,
89 + triggerNames,
90 + showDisabled,
91 + deprecatedConnectedAccountUuids,
92 + limit,
93 + },
94 + ({
95 + userIds,
96 + connectedAccountIds,
97 + toolkits,
98 + triggerIds,
99 + triggerNames,
100 + showDisabled,
101 + deprecatedConnectedAccountUuids,
102 + limit,
103 + }) =>
104 + Effect.gen(function* () {
105 + if (!(yield* requireAuth)) return;
106 +
107 + const ui = yield* TerminalUI;
108 + const repo = yield* ComposioToolkitsRepository;
109 +
110 + const connectedAccountIdsList = mergeCsvOptions(
111 + connectedAccountIds,
112 + deprecatedConnectedAccountUuids
113 + );
114 + const triggerNamesList = csvOption(triggerNames)?.map(name => name.toUpperCase());
115 + const toolkitsList = csvOption(toolkits)?.map(slug => slug.toLowerCase());
116 +
117 + const result = yield* ui.withSpinner(
118 + 'Fetching trigger status...',
119 + repo.listActiveTriggers({
120 + user_ids: csvOption(userIds),
121 + connected_account_ids: connectedAccountIdsList,
122 + trigger_ids: csvOption(triggerIds),
123 + trigger_names: triggerNamesList,
124 + show_disabled: showDisabled,
125 + deprecatedConnectedAccountUuids: csvOption(deprecatedConnectedAccountUuids),
126 + limit: clampLimit(limit),
127 + })
128 + );
129 +
130 + const filteredItems =
131 + toolkitsList && toolkitsList.length > 0
132 + ? result.items.filter(item => toolkitsList.includes(deriveToolkitSlug(item.trigger_name)))
133 + : result.items;
134 +
135 + if (filteredItems.length === 0) {
136 + yield* ui.log.warn(
137 + showDisabled
138 + ? 'No triggers found for the provided filters.'
139 + : 'No active triggers found for the provided filters.'
140 + );
141 + return;
142 + }
143 +
144 + const showing = filteredItems.length;
145 + const total = filteredItems.length;
146 +
147 + yield* ui.log.info(
148 + `Listing ${showing} of ${total} triggers\n\n${formatTriggersStatusTable(filteredItems)}`
149 + );
150 + yield* ui.output(formatTriggersStatusJson(filteredItems));
151 + })
152 +).pipe(Command.withDescription('Show active triggers with optional filters.'));
ts/packages/cli/src/commands/triggers/format.ts
+69
@@ -1,4 +1,5 @@
1 import type { TriggerListenEvent } from './types';
2 +import type { TriggerInstanceItem } from 'src/models/triggers';
3 import { bold, gray } from 'src/ui/colors';
4 import { truncate } from 'src/ui/truncate';
5
@@ -56,3 +57,71 @@ export const formatTriggerListenTableRow = ({
57 truncate(connectedAccountId, TRIGGER_TABLE.connectedAccountId),
58 ].join(' ');
59 };
60 +
61 +const TRIGGER_STATUS_TABLE = {
62 + id: 20,
63 + triggerName: 26,
64 + toolkit: 10,
65 + userId: 16,
66 + connectedAccountId: 22,
67 + status: 10,
68 +} as const;
69 +
70 +const toStatus = (item: TriggerInstanceItem): string =>
71 + item.disabled_at === null ? 'ACTIVE' : 'DISABLED';
72 +
73 +const toToolkitSlug = (triggerName: string): string => {
74 + const prefix = triggerName.split('_')[0];
75 + return prefix ? prefix.toLowerCase() : '-';
76 +};
77 +
78 +export const formatTriggersStatusTable = (items: ReadonlyArray<TriggerInstanceItem>): string => {
79 + const header = [
80 + bold('Trigger Id'.padEnd(TRIGGER_STATUS_TABLE.id)),
81 + bold('Trigger Name'.padEnd(TRIGGER_STATUS_TABLE.triggerName)),
82 + bold('Toolkit'.padEnd(TRIGGER_STATUS_TABLE.toolkit)),
83 + bold('User Id'.padEnd(TRIGGER_STATUS_TABLE.userId)),
84 + bold('Connected Account'.padEnd(TRIGGER_STATUS_TABLE.connectedAccountId)),
85 + bold('Status'),
86 + ].join(' ');
87 +
88 + const rows = items.map(item => {
89 + const status = toStatus(item);
90 + return [
91 + truncate(item.id, TRIGGER_STATUS_TABLE.id).padEnd(TRIGGER_STATUS_TABLE.id),
92 + truncate(item.trigger_name, TRIGGER_STATUS_TABLE.triggerName).padEnd(
93 + TRIGGER_STATUS_TABLE.triggerName
94 + ),
95 + truncate(toToolkitSlug(item.trigger_name), TRIGGER_STATUS_TABLE.toolkit).padEnd(
96 + TRIGGER_STATUS_TABLE.toolkit
97 + ),
98 + truncate(item.user_id || '-', TRIGGER_STATUS_TABLE.userId).padEnd(
99 + TRIGGER_STATUS_TABLE.userId
100 + ),
101 + truncate(item.connected_account_id || '-', TRIGGER_STATUS_TABLE.connectedAccountId).padEnd(
102 + TRIGGER_STATUS_TABLE.connectedAccountId
103 + ),
104 + status === 'ACTIVE' ? status : gray(status),
105 + ].join(' ');
106 + });
107 +
108 + return [header, ...rows].join('\n');
109 +};
110 +
111 +export const formatTriggersStatusJson = (items: ReadonlyArray<TriggerInstanceItem>): string =>
112 + JSON.stringify(
113 + items.map(item => ({
114 + id: item.id,
115 + uuid: item.uuid || undefined,
116 + trigger_name: item.trigger_name,
117 + toolkit_slug: toToolkitSlug(item.trigger_name),
118 + user_id: item.user_id || undefined,
119 + connected_account_id: item.connected_account_id || undefined,
120 + status: toStatus(item),
121 + disabled_at: item.disabled_at,
122 + updated_at: item.updated_at || undefined,
123 + trigger_data: item.trigger_data || undefined,
124 + })),
125 + null,
126 + 2
127 + );
ts/packages/cli/src/commands/triggers/triggers.cmd.ts
+14 -2
@@ -1,5 +1,10 @@
1 import { Command } from '@effect/cli';
2 import { triggersCmd$Listen } from './commands/triggers.listen.cmd';
3 +import { triggersCmd$Status } from './commands/triggers.status.cmd';
4 +import { triggersCmd$Create } from './commands/triggers.create.cmd';
5 +import { triggersCmd$Enable } from './commands/triggers.enable.cmd';
6 +import { triggersCmd$Disable } from './commands/triggers.disable.cmd';
7 +import { triggersCmd$Delete } from './commands/triggers.delete.cmd';
8
9 /**
10 * CLI entry point for realtime trigger commands.
@@ -10,6 +15,13 @@ import { triggersCmd$Listen } from './commands/triggers.listen.cmd';
15 * ```
16 */
17 export const triggersCmd = Command.make('triggers').pipe(
13 - Command.withDescription('Subscribe to realtime trigger events.'),
14 - Command.withSubcommands([triggersCmd$Listen])
18 + Command.withDescription('Inspect and subscribe to trigger events.'),
19 + Command.withSubcommands([
20 + triggersCmd$Listen,
21 + triggersCmd$Status,
22 + triggersCmd$Create,
23 + triggersCmd$Enable,
24 + triggersCmd$Disable,
25 + triggersCmd$Delete,
26 + ])
27 );
ts/packages/cli/src/models/triggers.ts new
+33
@@ -0,0 +1,33 @@
1 +import { Schema } from 'effect';
2 +
3 +/**
4 + * A trigger instance item from the list-active endpoint.
5 + * Field names match the raw API response (snake_case).
6 + */
7 +export const TriggerInstanceItem = Schema.Struct({
8 + id: Schema.String,
9 + uuid: Schema.optionalWith(Schema.String, { default: () => '' }),
10 + trigger_name: Schema.optionalWith(Schema.String, { default: () => '' }),
11 + connected_account_id: Schema.optionalWith(Schema.String, { default: () => '' }),
12 + auth_config_id: Schema.optionalWith(Schema.String, { default: () => '' }),
13 + user_id: Schema.optionalWith(Schema.String, { default: () => '' }),
14 + disabled_at: Schema.optionalWith(Schema.NullOr(Schema.String), { default: () => null }),
15 + updated_at: Schema.optionalWith(Schema.String, { default: () => '' }),
16 + trigger_data: Schema.optionalWith(Schema.String, { default: () => '' }),
17 + state: Schema.optionalWith(
18 + Schema.NullOr(Schema.Record({ key: Schema.String, value: Schema.Unknown })),
19 + {
20 + default: () => null,
21 + }
22 + ),
23 + trigger_config: Schema.optionalWith(
24 + Schema.NullOr(Schema.Record({ key: Schema.String, value: Schema.Unknown })),
25 + {
26 + default: () => null,
27 + }
28 + ),
29 +}).annotations({ identifier: 'TriggerInstanceItem' });
30 +export type TriggerInstanceItem = Schema.Schema.Type<typeof TriggerInstanceItem>;
31 +
32 +export const TriggerInstanceItems = Schema.Array(TriggerInstanceItem);
33 +export type TriggerInstanceItems = Schema.Schema.Type<typeof TriggerInstanceItems>;
ts/packages/cli/src/services/composio-clients-cached.ts
+8
@@ -256,6 +256,14 @@ export const ComposioToolkitsRepositoryCached = Layer.effect(
256 getConnectedAccount: nanoid => underlyingRepository.getConnectedAccount(nanoid),
257 deleteConnectedAccount: nanoid => underlyingRepository.deleteConnectedAccount(nanoid),
258 createConnectedAccountLink: params => underlyingRepository.createConnectedAccountLink(params),
259 + // Trigger instance listing should NOT be cached (status can change frequently)
260 + listActiveTriggers: params => underlyingRepository.listActiveTriggers(params),
261 + // Trigger instance mutations should NOT be cached
262 + createTrigger: (triggerSlug, params) =>
263 + underlyingRepository.createTrigger(triggerSlug, params),
264 + enableTrigger: triggerId => underlyingRepository.enableTrigger(triggerId),
265 + disableTrigger: triggerId => underlyingRepository.disableTrigger(triggerId),
266 + deleteTrigger: triggerId => underlyingRepository.deleteTrigger(triggerId),
267 });
268 })
269 ).pipe(
ts/packages/cli/src/services/composio-clients.ts
+134
@@ -17,6 +17,7 @@ import type { AuthConfigCreateParams } from '@composio/client/resources/auth-con
17 import { Toolkit, Toolkits, ToolkitDetailed, type ToolkitSearchResult } from 'src/models/toolkits';
18 import { AuthConfigItem, AuthConfigItems } from 'src/models/auth-configs';
19 import { ConnectedAccountItem, ConnectedAccountItems } from 'src/models/connected-accounts';
20 +import { TriggerInstanceItems } from 'src/models/triggers';
21 import { ToolsAsEnums, Tools, Tool } from 'src/models/tools';
22 import {
23 groupByVersion,
@@ -301,6 +302,137 @@ export const TriggerTypesResponse = Schema.Struct({
302 total_pages: Schema.Int,
303 next_cursor: Schema.NullOr(Schema.String),
304 }).annotations({ identifier: 'TriggerTypesResponse' });
305 +export type TriggerTypesResponse = Schema.Schema.Type<typeof TriggerTypesResponse>;
306 +
307 +export const TriggerInstancesListActiveResponse = Schema.Struct({
308 + items: TriggerInstanceItems,
309 + total_items: Schema.optionalWith(Schema.Int, { default: () => 0 }),
310 + total_pages: Schema.optionalWith(Schema.Int, { default: () => 1 }),
311 + current_page: Schema.optionalWith(Schema.Int, { default: () => 1 }),
312 + next_cursor: Schema.optionalWith(Schema.NullOr(Schema.String), { default: () => null }),
313 +}).annotations({ identifier: 'TriggerInstancesListActiveResponse' });
314 +export type TriggerInstancesListActiveResponse = Schema.Schema.Type<
315 + typeof TriggerInstancesListActiveResponse
316 +>;
317 +
318 +export const TriggerInstanceUpsertResponse = Schema.Struct({
319 + trigger_id: Schema.String,
320 +}).annotations({ identifier: 'TriggerInstanceUpsertResponse' });
321 +export type TriggerInstanceUpsertResponse = Schema.Schema.Type<
322 + typeof TriggerInstanceUpsertResponse
323 +>;
324 +
325 +export const TriggerInstanceManageUpdateResponse = Schema.Struct({
326 + status: Schema.Literal('success'),
327 +}).annotations({ identifier: 'TriggerInstanceManageUpdateResponse' });
328 +export type TriggerInstanceManageUpdateResponse = Schema.Schema.Type<
329 + typeof TriggerInstanceManageUpdateResponse
330 +>;
331 +
332 +export const TriggerInstanceManageDeleteResponse = Schema.Struct({
333 + trigger_id: Schema.String,
334 +}).annotations({ identifier: 'TriggerInstanceManageDeleteResponse' });
335 +export type TriggerInstanceManageDeleteResponse = Schema.Schema.Type<
336 + typeof TriggerInstanceManageDeleteResponse
337 +>;
338 +
339 +export interface TriggerInstancesListActiveParams {
340 + user_ids?: string[];
341 + connected_account_ids?: string[];
342 + auth_config_ids?: string[];
343 + trigger_ids?: string[];
344 + trigger_names?: string[];
345 + connectedAccountIds?: string[];
346 + authConfigIds?: string[];
347 + triggerIds?: string[];
348 + triggerNames?: string[];
349 + show_disabled?: boolean;
350 + showDisabled?: boolean;
351 + deprecatedConnectedAccountUuids?: string[];
352 + deprecatedAuthConfigUuids?: string[];
353 + limit?: number;
354 +}
355 +
356 +export interface TriggerInstanceUpsertParams {
357 + connected_account_id?: string;
358 + trigger_config?: Record<string, unknown>;
359 +}
360 +
361 +function buildTriggerInstancesNamespace(
362 + clientSingleton: ComposioClientSingleton,
363 + withMetrics: <A, E, R>(
364 + effect: Effect.Effect<{ data: A; metrics: Metrics }, E, R>
365 + ) => Effect.Effect<A, E, R>
366 +) {
367 + return {
368 + /**
369 + * Lists active trigger instances with optional filters.
370 + * Returns a single page of results.
371 + */
372 + listActive: (params: TriggerInstancesListActiveParams) =>
373 + withMetrics(
374 + callClient(
375 + clientSingleton,
376 + client =>
377 + client.triggerInstances.listActive({
378 + user_ids: params.user_ids,
379 + connected_account_ids: params.connected_account_ids,
380 + auth_config_ids: params.auth_config_ids,
381 + trigger_ids: params.trigger_ids,
382 + trigger_names: params.trigger_names,
383 + connectedAccountIds: params.connectedAccountIds,
384 + authConfigIds: params.authConfigIds,
385 + triggerIds: params.triggerIds,
386 + show_disabled: params.show_disabled,
387 + triggerNames: params.triggerNames,
388 + showDisabled: params.showDisabled,
389 + deprecatedConnectedAccountUuids: params.deprecatedConnectedAccountUuids,
390 + deprecatedAuthConfigUuids: params.deprecatedAuthConfigUuids,
391 + limit: params.limit,
392 + }),
393 + TriggerInstancesListActiveResponse
394 + )
395 + ),
396 + upsert: (triggerSlug: string, params?: TriggerInstanceUpsertParams) =>
397 + withMetrics(
398 + callClient(
399 + clientSingleton,
400 + client => client.triggerInstances.upsert(triggerSlug, params),
401 + TriggerInstanceUpsertResponse
402 + )
403 + ),
404 + manageUpdate: (triggerId: string, params: { status: 'enable' | 'disable' }) =>
405 + withMetrics(
406 + callClient(
407 + clientSingleton,
408 + client => client.triggerInstances.manage.update(triggerId, params),
409 + TriggerInstanceManageUpdateResponse
410 + )
411 + ),
412 + manageDelete: (triggerId: string) =>
413 + withMetrics(
414 + callClient(
415 + clientSingleton,
416 + client => client.triggerInstances.manage.delete(triggerId),
417 + TriggerInstanceManageDeleteResponse
418 + )
419 + ),
420 + };
421 +}
422 +
423 +function buildTriggerInstanceRepositoryOperations(client: ComposioClientLive) {
424 + return {
425 + listActiveTriggers: (params: TriggerInstancesListActiveParams) =>
426 + client.triggerInstances.listActive(params),
427 + createTrigger: (triggerSlug: string, params?: TriggerInstanceUpsertParams) =>
428 + client.triggerInstances.upsert(triggerSlug, params),
429 + enableTrigger: (triggerId: string) =>
430 + client.triggerInstances.manageUpdate(triggerId, { status: 'enable' }),
431 + disableTrigger: (triggerId: string) =>
432 + client.triggerInstances.manageUpdate(triggerId, { status: 'disable' }),
433 + deleteTrigger: (triggerId: string) => client.triggerInstances.manageDelete(triggerId),
434 + };
435 +}
436
437 // Single-page search response (includes total_items for "Listing X of Y" display)
438 export const ToolkitSearchResponse = Schema.Struct({
@@ -1101,6 +1233,7 @@ export class ComposioClientLive extends Effect.Service<ComposioClientLive>()(
1233 )
1234 ),
1235 },
1236 + triggerInstances: buildTriggerInstancesNamespace(clientSingleton, withMetrics),
1237 cli: {
1238 /**
1239 * Generates a new CLI session with a random 6-character code.
@@ -1391,6 +1524,7 @@ export class ComposioToolkitsRepository extends Effect.Service<ComposioToolkitsR
1524 deleteConnectedAccount: (nanoid: string) => client.connectedAccounts.delete(nanoid),
1525 createConnectedAccountLink: (params: { auth_config_id: string; user_id: string }) =>
1526 client.connectedAccounts.createLink(params),
1527 + ...buildTriggerInstanceRepositoryOperations(client),
1528 };
1529 }),
1530 dependencies: [ComposioClientLive.Default],
ts/packages/cli/test/__utils__/services/test-layer.ts
+92
@@ -35,6 +35,7 @@ import type { Tools } from 'src/models/tools';
35 import type { TriggerTypes, TriggerTypesAsEnums } from 'src/models/trigger-types';
36 import type { AuthConfigItem } from 'src/models/auth-configs';
37 import type { ConnectedAccountItem } from 'src/models/connected-accounts';
38 +import type { TriggerInstanceItem } from 'src/models/triggers';
39 import type { AuthConfigCreateResponse, LinkCreateResponse } from 'src/services/composio-clients';
40 import type { ToolkitVersionSpec } from 'src/effects/toolkit-version-overrides';
41 import { ComposioUserContextLive } from 'src/services/user-context';
@@ -82,6 +83,13 @@ export interface TestLiveInput {
83 linkResponse?: LinkCreateResponse;
84 };
85
86 + /**
87 + * Mock trigger instance data to use in test.
88 + */
89 + triggersData?: {
90 + items?: TriggerInstanceItem[];
91 + };
92 +
93 /**
94 * Mock realtime trigger data to use in test.
95 */
@@ -149,6 +157,14 @@ export const TestLayer = (input?: TestLiveInput) =>
157 ...(input?.realtimeData ?? {}),
158 };
159
160 + const defaultTriggersData = {
161 + items: [] as TriggerInstanceItem[],
162 + } satisfies TestLiveInput['triggersData'];
163 + const triggersData = {
164 + ...defaultTriggersData,
165 + ...(input?.triggersData ?? {}),
166 + };
167 +
168 const tempDir = tempy.temporaryDirectory({ prefix: 'test' });
169 const cwd = (yield* setupFixtureFolder({ fixture, tempDir })) ?? tempDir;
170
@@ -514,6 +530,82 @@ export const TestLayer = (input?: TestLiveInput) =>
530 redirect_url: `https://app.composio.dev/link?token=lt_test_token`,
531 } satisfies LinkCreateResponse);
532 },
533 + listActiveTriggers: (params: {
534 + user_ids?: string[];
535 + connected_account_ids?: string[];
536 + auth_config_ids?: string[];
537 + trigger_ids?: string[];
538 + trigger_names?: string[];
539 + connectedAccountIds?: string[];
540 + authConfigIds?: string[];
541 + triggerIds?: string[];
542 + triggerNames?: string[];
543 + show_disabled?: boolean;
544 + showDisabled?: boolean;
545 + deprecatedConnectedAccountUuids?: string[];
546 + deprecatedAuthConfigUuids?: string[];
547 + limit?: number;
548 + }) => {
549 + let results = [...triggersData.items];
550 +
551 + const userIds = params.user_ids;
552 + if (userIds && userIds.length > 0) {
553 + const set = new Set(userIds);
554 + results = results.filter(item => set.has(item.user_id));
555 + }
556 +
557 + const connectedAccountIds = params.connected_account_ids;
558 + if (connectedAccountIds && connectedAccountIds.length > 0) {
559 + const set = new Set(connectedAccountIds);
560 + results = results.filter(item => set.has(item.connected_account_id));
561 + }
562 +
563 + const authConfigIds = params.auth_config_ids;
564 + if (authConfigIds && authConfigIds.length > 0) {
565 + const set = new Set(authConfigIds);
566 + results = results.filter(item => set.has(item.auth_config_id));
567 + }
568 +
569 + const triggerIds = params.trigger_ids;
570 + if (triggerIds && triggerIds.length > 0) {
571 + const set = new Set(triggerIds);
572 + results = results.filter(item => set.has(item.id));
573 + }
574 +
575 + const triggerNames = params.trigger_names;
576 + if (triggerNames && triggerNames.length > 0) {
577 + const set = new Set(triggerNames.map(name => name.toUpperCase()));
578 + results = results.filter(item => set.has(item.trigger_name.toUpperCase()));
579 + }
580 +
581 + const includeDisabled = params.show_disabled ?? false;
582 + if (!includeDisabled) {
583 + results = results.filter(item => item.disabled_at === null);
584 + }
585 +
586 + const limit = params.limit ?? 30;
587 + const items = results.slice(0, limit);
588 + return Effect.succeed({
589 + items,
590 + total_items: results.length,
591 + total_pages: Math.ceil(results.length / limit),
592 + current_page: 1,
593 + next_cursor: null,
594 + });
595 + },
596 + createTrigger: (
597 + triggerSlug: string,
598 + params?: {
599 + connected_account_id?: string;
600 + trigger_config?: Record<string, unknown>;
601 + }
602 + ) =>
603 + Effect.succeed({
604 + trigger_id: `trg_${triggerSlug.toLowerCase()}_${params?.connected_account_id ?? 'new'}`,
605 + }),
606 + enableTrigger: () => Effect.succeed({ status: 'success' as const }),
607 + disableTrigger: () => Effect.succeed({ status: 'success' as const }),
608 + deleteTrigger: triggerId => Effect.succeed({ trigger_id: triggerId }),
609 })
610 );
611 const ComposioSessionRepositoryTest = yield* setupComposioSessionRepository();
ts/packages/cli/test/src/commands/$default.cmd.test.ts
+41 -31
@@ -56,75 +56,85 @@ describe('CLI: composio', () => {
56
57 COMMANDS
58
59 - - version Display the current Composio CLI version.
59 + - version Display the current Composio CLI version.
60
61 - - upgrade Upgrade your Composio CLI to the latest available version.
61 + - upgrade Upgrade your Composio CLI to the latest available version.
62
63 - - whoami Display your account information.
63 + - whoami Display your account information.
64
65 - - login [--no-browser] Log in to the Composio SDK.
65 + - login [--no-browser] Log in to the Composio SDK.
66
67 - - logout Log out from the Composio SDK.
67 + - logout Log out from the Composio SDK.
68
69 - - generate [(-o, --output-dir directory)] [--type-tools] --toolkits text... Generate type stubs for toolkits, tools, and triggers, auto-detecting project language (TypeScript | Python)
69 + - generate [(-o, --output-dir directory)] [--type-tools] --toolkits text... Generate type stubs for toolkits, tools, and triggers, auto-detecting project language (TypeScript | Python)
70
71 - - py Handle Python projects.
71 + - py Handle Python projects.
72
73 - - py generate [(-o, --output-dir directory)] --toolkits text... Generate Python type stubs for toolkits, tools, and triggers from the Composio API.
73 + - py generate [(-o, --output-dir directory)] --toolkits text... Generate Python type stubs for toolkits, tools, and triggers from the Composio API.
74
75 Environment Variables:
76 COMPOSIO_TOOLKIT_VERSION_<TOOLKIT> Override toolkit version (e.g., COMPOSIO_TOOLKIT_VERSION_GMAIL=20250901_00)
77 Use "latest" or unset to use the latest version.
78
79 - - ts Handle TypeScript projects.
79 + - ts Handle TypeScript projects.
80
81 - - ts generate [(-o, --output-dir directory)] [--compact] [--transpiled] [--type-tools] --toolkits text... Generate TypeScript types for toolkits, tools, and triggers from the Composio API.
81 + - ts generate [(-o, --output-dir directory)] [--compact] [--transpiled] [--type-tools] --toolkits text... Generate TypeScript types for toolkits, tools, and triggers from the Composio API.
82
83 Environment Variables:
84 COMPOSIO_TOOLKIT_VERSION_<TOOLKIT> Override toolkit version (e.g., COMPOSIO_TOOLKIT_VERSION_GMAIL=20250901_00)
85 Use "latest" or unset to use the latest version.
86
87 - - toolkits Discover and inspect Composio toolkits.
87 + - toolkits Discover and inspect Composio toolkits.
88
89 - - toolkits list [--query text] [--limit integer] List available toolkits.
89 + - toolkits list [--query text] [--limit integer] List available toolkits.
90
91 - - toolkits info [<slug>] View details of a specific toolkit.
91 + - toolkits info [<slug>] View details of a specific toolkit.
92
93 - - toolkits search [--limit integer] <query> Search toolkits by use case.
93 + - toolkits search [--limit integer] <query> Search toolkits by use case.
94
95 - - tools Discover and inspect Composio tools.
95 + - tools Discover and inspect Composio tools.
96
97 - - tools list [--query text] [--toolkits text] [--tags text] [--limit integer] List available tools.
97 + - tools list [--query text] [--toolkits text] [--tags text] [--limit integer] List available tools.
98
99 - - tools info [<slug>] View details of a specific tool.
99 + - tools info [<slug>] View details of a specific tool.
100
101 - - tools search [--toolkits text] [--limit integer] <query> Search tools by use case.
101 + - tools search [--toolkits text] [--limit integer] <query> Search tools by use case.
102
103 - - auth-configs View and manage Composio auth configs.
103 + - auth-configs View and manage Composio auth configs.
104
105 - - auth-configs list [--toolkits text] [--query text] [--limit integer] List auth configs.
105 + - auth-configs list [--toolkits text] [--query text] [--limit integer] List auth configs.
106
107 - - auth-configs info [<id>] View details of a specific auth config.
107 + - auth-configs info [<id>] View details of a specific auth config.
108
109 - - auth-configs create --toolkit text [--auth-scheme text] [--scopes text] [--custom-credentials text] [<name>] Create a new auth config.
109 + - auth-configs create --toolkit text [--auth-scheme text] [--scopes text] [--custom-credentials text] [<name>] Create a new auth config.
110
111 - - auth-configs delete [(-y, --yes)] [<id>] Delete an auth config.
111 + - auth-configs delete [(-y, --yes)] [<id>] Delete an auth config.
112
113 - - connected-accounts View and manage Composio connected accounts.
113 + - connected-accounts View and manage Composio connected accounts.
114
115 - - connected-accounts list [--toolkits text] [--user-id text] [--status INITIALIZING | INITIATED | ACTIVE | FAILED | EXPIRED | INACTIVE] [--limit integer] List connected accounts.
115 + - connected-accounts list [--toolkits text] [--user-id text] [--status INITIALIZING | INITIATED | ACTIVE | FAILED | EXPIRED | INACTIVE] [--limit integer] List connected accounts.
116
117 - - connected-accounts info [<id>] View details of a specific connected account.
117 + - connected-accounts info [<id>] View details of a specific connected account.
118
119 - - connected-accounts whoami [<id>] Show the external account profile for a connected account.
119 + - connected-accounts whoami [<id>] Show the external account profile for a connected account.
120
121 - - connected-accounts delete [(-y, --yes)] [<id>] Delete a connected account.
121 + - connected-accounts delete [(-y, --yes)] [<id>] Delete a connected account.
122
123 - - connected-accounts link --auth-config text [--user-id text] [--no-browser] Link an external account via OAuth redirect.
123 + - connected-accounts link --auth-config text [--user-id text] [--no-browser] Link an external account via OAuth redirect.
124
125 - - triggers Subscribe to realtime trigger events.
125 + - triggers Inspect and subscribe to trigger events.
126
127 - - triggers listen [--toolkits text] [--trigger-id text] [--connected-account-id text] [--trigger-slug text] [--user-id text] [--json] [--table] [--max-events integer] [--forward text] [--out text] Listen to realtime trigger events for your project.
127 + - triggers listen [--toolkits text] [--trigger-id text] [--connected-account-id text] [--trigger-slug text] [--user-id text] [--json] [--table] [--max-events integer] [--forward text] [--out text] Listen to realtime trigger events for your project.
128 +
129 + - triggers status [--user-ids text] [--connected-account-ids text] [--toolkits text] [--trigger-ids text] [--trigger-names text] [--show-disabled] [--deprecated-connected-account-uuids text] [--limit integer] Show active triggers with optional filters.
130 +
131 + - triggers create [--connected-account-id text] [--trigger-config text] [<trigger-name>] Create a new trigger instance.
132 +
133 + - triggers enable [<id>] Enable a trigger instance.
134 +
135 + - triggers disable [<id>] Disable a trigger instance.
136 +
137 + - triggers delete [(-y, --yes)] [<id>] Delete a trigger instance.
138 "
139 `);
140 })
ts/packages/cli/test/src/commands/triggers/triggers.mutations.cmd.test.ts new
+103
@@ -0,0 +1,103 @@
1 +import { describe, expect, layer } from '@effect/vitest';
2 +import { ConfigProvider, Effect } from 'effect';
3 +import { extendConfigProvider } from 'src/services/config';
4 +import { cli, MockConsole, TestLive } from 'test/__utils__';
5 +
6 +const testConfigProvider = ConfigProvider.fromMap(
7 + new Map([['COMPOSIO_API_KEY', 'test_api_key']])
8 +).pipe(extendConfigProvider);
9 +
10 +describe('CLI: composio triggers mutations', () => {
11 + layer(TestLive({ baseConfigProvider: testConfigProvider }))(
12 + '[Given] create with valid args [Then] creates trigger',
13 + it => {
14 + it.scoped('creates trigger and prints id', () =>
15 + Effect.gen(function* () {
16 + yield* cli([
17 + 'triggers',
18 + 'create',
19 + 'GMAIL_NEW_GMAIL_MESSAGE',
20 + '--connected-account-id',
21 + 'con_123',
22 + ]);
23 + const lines = yield* MockConsole.getLines({ stripAnsi: true });
24 + const output = lines.join('\n');
25 +
26 + expect(output).toContain('Trigger created');
27 + expect(output).toContain('trg_gmail_new_gmail_message_con_123');
28 + })
29 + );
30 + }
31 + );
32 +
33 + layer(TestLive({ baseConfigProvider: testConfigProvider }))(
34 + '[Given] create with invalid JSON config [Then] shows JSON validation error',
35 + it => {
36 + it.scoped('rejects invalid trigger config JSON', () =>
37 + Effect.gen(function* () {
38 + yield* cli(['triggers', 'create', 'GMAIL_NEW_GMAIL_MESSAGE', '--trigger-config', '{']);
39 + const lines = yield* MockConsole.getLines({ stripAnsi: true });
40 + const output = lines.join('\n');
41 +
42 + expect(output).toContain('Invalid JSON in --trigger-config');
43 + })
44 + );
45 + }
46 + );
47 +
48 + layer(TestLive({ baseConfigProvider: testConfigProvider }))(
49 + '[Given] enable with ID [Then] enables trigger',
50 + it => {
51 + it.scoped('enables trigger successfully', () =>
52 + Effect.gen(function* () {
53 + yield* cli(['triggers', 'enable', 'trg_123']);
54 + const lines = yield* MockConsole.getLines({ stripAnsi: true });
55 + const output = lines.join('\n');
56 + expect(output).toContain('enabled');
57 + })
58 + );
59 + }
60 + );
61 +
62 + layer(TestLive({ baseConfigProvider: testConfigProvider }))(
63 + '[Given] disable with ID [Then] disables trigger',
64 + it => {
65 + it.scoped('disables trigger successfully', () =>
66 + Effect.gen(function* () {
67 + yield* cli(['triggers', 'disable', 'trg_123']);
68 + const lines = yield* MockConsole.getLines({ stripAnsi: true });
69 + const output = lines.join('\n');
70 + expect(output).toContain('disabled');
71 + })
72 + );
73 + }
74 + );
75 +
76 + layer(TestLive({ baseConfigProvider: testConfigProvider }))(
77 + '[Given] delete with --yes [Then] deletes trigger',
78 + it => {
79 + it.scoped('deletes trigger successfully', () =>
80 + Effect.gen(function* () {
81 + yield* cli(['triggers', 'delete', 'trg_123', '--yes']);
82 + const lines = yield* MockConsole.getLines({ stripAnsi: true });
83 + const output = lines.join('\n');
84 + expect(output).toContain('deleted');
85 + })
86 + );
87 + }
88 + );
89 +
90 + layer(TestLive({ baseConfigProvider: testConfigProvider }))(
91 + '[Given] missing ID for enable [Then] warns about missing argument',
92 + it => {
93 + it.scoped('shows missing id warning', () =>
94 + Effect.gen(function* () {
95 + yield* cli(['triggers', 'enable']);
96 + const lines = yield* MockConsole.getLines({ stripAnsi: true });
97 + const output = lines.join('\n');
98 + expect(output).toContain('Missing required argument');
99 + })
100 + );
101 + }
102 + );
103 +});
ts/packages/cli/test/src/commands/triggers/triggers.status.cmd.test.ts new
+156
@@ -0,0 +1,156 @@
1 +import { describe, expect, layer } from '@effect/vitest';
2 +import { ConfigProvider, Effect } from 'effect';
3 +import { extendConfigProvider } from 'src/services/config';
4 +import { cli, MockConsole, TestLive } from 'test/__utils__';
5 +import type { TestLiveInput } from 'test/__utils__/services/test-layer';
6 +import type { TriggerInstanceItem } from 'src/models/triggers';
7 +
8 +const testTriggers: TriggerInstanceItem[] = [
9 + {
10 + id: 'trg_active_1',
11 + uuid: 'uuid-trg-active-1',
12 + trigger_name: 'GMAIL_NEW_GMAIL_MESSAGE',
13 + connected_account_id: 'con_gmail_1',
14 + auth_config_id: 'ac_gmail_1',
15 + user_id: 'user_default',
16 + disabled_at: null,
17 + updated_at: '2026-02-01T00:00:00Z',
18 + trigger_data: '',
19 + state: {},
20 + trigger_config: {},
21 + },
22 + {
23 + id: 'trg_active_2',
24 + uuid: 'uuid-trg-active-2',
25 + trigger_name: 'SLACK_NEW_MESSAGE',
26 + connected_account_id: 'con_slack_1',
27 + auth_config_id: 'ac_slack_1',
28 + user_id: 'user_123',
29 + disabled_at: null,
30 + updated_at: '2026-02-02T00:00:00Z',
31 + trigger_data: '',
32 + state: {},
33 + trigger_config: {},
34 + },
35 + {
36 + id: 'trg_disabled_1',
37 + uuid: 'uuid-trg-disabled-1',
38 + trigger_name: 'GITHUB_COMMIT_EVENT',
39 + connected_account_id: 'con_github_1',
40 + auth_config_id: 'ac_github_1',
41 + user_id: 'user_default',
42 + disabled_at: '2026-02-03T00:00:00Z',
43 + updated_at: '2026-02-03T00:00:00Z',
44 + trigger_data: '',
45 + state: {},
46 + trigger_config: {},
47 + },
48 +];
49 +
50 +const triggersData = {
51 + items: testTriggers,
52 +} satisfies TestLiveInput['triggersData'];
53 +
54 +const testConfigProvider = ConfigProvider.fromMap(
55 + new Map([['COMPOSIO_API_KEY', 'test_api_key']])
56 +).pipe(extendConfigProvider);
57 +
58 +describe('CLI: composio triggers status', () => {
59 + layer(TestLive({ baseConfigProvider: testConfigProvider, triggersData }))(
60 + '[Given] no flags [Then] lists active triggers only',
61 + it => {
62 + it.scoped('lists active trigger instances', () =>
63 + Effect.gen(function* () {
64 + yield* cli(['triggers', 'status']);
65 + const lines = yield* MockConsole.getLines({ stripAnsi: true });
66 + const output = lines.join('\n');
67 +
68 + expect(output).toContain('trg_active_1');
69 + expect(output).toContain('trg_active_2');
70 + expect(output).not.toContain('trg_disabled_1');
71 + expect(output).toContain('Listing 2 of 2 triggers');
72 + })
73 + );
74 + }
75 + );
76 +
77 + layer(TestLive({ baseConfigProvider: testConfigProvider, triggersData }))(
78 + '[Given] --show-disabled [Then] includes disabled triggers',
79 + it => {
80 + it.scoped('includes disabled trigger instances', () =>
81 + Effect.gen(function* () {
82 + yield* cli(['triggers', 'status', '--show-disabled']);
83 + const lines = yield* MockConsole.getLines({ stripAnsi: true });
84 + const output = lines.join('\n');
85 +
86 + expect(output).toContain('trg_active_1');
87 + expect(output).toContain('trg_disabled_1');
88 + expect(output).toContain('Listing 3 of 3 triggers');
89 + })
90 + );
91 + }
92 + );
93 +
94 + layer(TestLive({ baseConfigProvider: testConfigProvider, triggersData }))(
95 + '[Given] --user-ids [Then] filters by user IDs',
96 + it => {
97 + it.scoped('filters by user_ids', () =>
98 + Effect.gen(function* () {
99 + yield* cli(['triggers', 'status', '--user-ids', 'user_123']);
100 + const lines = yield* MockConsole.getLines({ stripAnsi: true });
101 + const output = lines.join('\n');
102 +
103 + expect(output).toContain('trg_active_2');
104 + expect(output).not.toContain('trg_active_1');
105 + expect(output).toContain('Listing 1 of 1 triggers');
106 + })
107 + );
108 + }
109 + );
110 +
111 + layer(TestLive({ baseConfigProvider: testConfigProvider, triggersData }))(
112 + '[Given] --trigger-names lowercase [Then] applies case-insensitive filter',
113 + it => {
114 + it.scoped('normalizes trigger names to uppercase', () =>
115 + Effect.gen(function* () {
116 + yield* cli(['triggers', 'status', '--trigger-names', 'gmail_new_gmail_message']);
117 + const lines = yield* MockConsole.getLines({ stripAnsi: true });
118 + const output = lines.join('\n');
119 +
120 + expect(output).toContain('trg_active_1');
121 + expect(output).not.toContain('trg_active_2');
122 + expect(output).toContain('Listing 1 of 1 triggers');
123 + })
124 + );
125 + }
126 + );
127 +
128 + layer(TestLive({ baseConfigProvider: testConfigProvider, triggersData }))(
129 + '[Given] --toolkits [Then] filters by toolkit slug',
130 + it => {
131 + it.scoped('filters by toolkit prefix in trigger name', () =>
132 + Effect.gen(function* () {
133 + yield* cli(['triggers', 'status', '--toolkits', 'slack']);
134 + const lines = yield* MockConsole.getLines({ stripAnsi: true });
135 + const output = lines.join('\n');
136 +
137 + expect(output).toContain('trg_active_2');
138 + expect(output).not.toContain('trg_active_1');
139 + expect(output).toContain('Listing 1 of 1 triggers');
140 + })
141 + );
142 + }
143 + );
144 +
145 + layer(TestLive())('[Given] no API key [Then] warns user to login', it => {
146 + it.scoped('warns user to login', () =>
147 + Effect.gen(function* () {
148 + yield* cli(['triggers', 'status']);
149 + const lines = yield* MockConsole.getLines({ stripAnsi: true });
150 + const output = lines.join('\n');
151 +
152 + expect(output).toContain('not logged in');
153 + })
154 + );
155 + });
156 +});