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

fix(cli): address bugbot issues in triggers commands

Use trigger toolkit metadata for info hints, align trigger type table columns, and extract shared CSV/schema parsing helpers to remove duplicated logic across triggers and tools formatting. Co-authored-by: Cursor <cursoragent@cursor.com>

haxzie committed Feb 23, 2026 at 19:36 UTC 87c016ab81cf44387bc749affc1a3ddfff5a21b1
9 files changed +61 -41
ts/packages/cli/src/commands/tools/format.ts
+3 -12
@@ -2,6 +2,7 @@ import type { Tool } from 'src/models/tools';
2 import type { ToolDetailedResponse } from 'src/services/composio-clients';
3 import { bold, gray } from 'src/ui/colors';
4 import { truncate } from 'src/ui/truncate';
5 +import { extractSchemaProperties } from 'src/ui/extract-schema-properties';
6
7 /**
8 * Format a list of tools as a human-readable table.
@@ -40,21 +41,11 @@ export function formatToolsJson(tools: ReadonlyArray<Tool>): string {
41 * Extracts `properties` entries, cross-references `required` array.
42 */
43 function formatSchemaProperties(schema: Record<string, unknown>): string {
43 - const properties = schema['properties'] as Record<string, Record<string, unknown>> | undefined;
44 - if (!properties || Object.keys(properties).length === 0) {
44 + const entries = extractSchemaProperties(schema);
45 + if (entries.length === 0) {
46 return ' (none)';
47 }
48
48 - const requiredArr = (schema['required'] as string[] | undefined) ?? [];
49 - const requiredSet = new Set(requiredArr);
50 -
51 - const entries = Object.entries(properties).map(([name, prop]) => {
52 - const type = (prop['type'] as string) ?? 'unknown';
53 - const label = requiredSet.has(name) ? 'required' : 'optional';
54 - const description = prop['description'] as string | undefined;
55 - return { name, type, label, description };
56 - });
57 -
49 const nameWidth = Math.max(...entries.map(e => e.name.length));
50 const typeWidth = Math.max(...entries.map(e => e.type.length));
51 const labelWidth = Math.max(...entries.map(e => e.label.length));
ts/packages/cli/src/commands/triggers/commands/triggers.info.cmd.ts
+1 -1
@@ -57,7 +57,7 @@ export const triggersCmd$Info = Command.make('info', { slug }, ({ slug }) =>
57
58 yield* ui.log.info(formatTriggerTypeInfo(triggerType));
59
60 - const toolkitSlug = triggerType.slug.split('_')[0]?.toLowerCase();
60 + const toolkitSlug = triggerType.toolkit?.slug?.toLowerCase();
61 if (toolkitSlug) {
62 yield* ui.log.step(
63 `To list more trigger types in this toolkit:\n> composio triggers list --toolkits "${toolkitSlug}"`
ts/packages/cli/src/commands/triggers/commands/triggers.list.cmd.ts
+1 -6
@@ -5,6 +5,7 @@ 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 { formatTriggerTypesJson, formatTriggerTypesTable } from '../format';
8 +import { parseCsv } from '../parse-csv';
9
10 const toolkits = Options.text('toolkits').pipe(
11 Options.withDescription(
@@ -18,12 +19,6 @@ const limit = Options.integer('limit').pipe(
19 Options.withDescription('Maximum number of trigger types to show (1-1000)')
20 );
21
21 -const parseCsv = (value: string): ReadonlyArray<string> =>
22 - value
23 - .split(',')
24 - .map(item => item.trim())
25 - .filter(Boolean);
26 -
22 /**
23 * List available trigger types with optional toolkit filters.
24 *
ts/packages/cli/src/commands/triggers/commands/triggers.listen.cmd.ts
+1 -6
@@ -12,6 +12,7 @@ import {
12 formatTriggerListenTableHeader,
13 formatTriggerListenTableRow,
14 } from '../format';
15 +import { parseCsv } from '../parse-csv';
16 import { parseTriggerListenEvent } from '../parse';
17 import type { TriggerListenFilters } from '../types';
18
@@ -73,12 +74,6 @@ const out = Options.text('out').pipe(
74 Options.optional
75 );
76
76 -const parseCsv = (value: string): ReadonlyArray<string> =>
77 - value
78 - .split(',')
79 - .map(item => item.trim())
80 - .filter(Boolean);
81 -
77 const randomUUID = () => crypto.randomUUID();
78
79 const signWebhookPayload = async ({
ts/packages/cli/src/commands/triggers/format.ts
+6 -15
@@ -2,6 +2,7 @@ import type { TriggerType } from 'src/models/trigger-types';
2 import type { TriggerListenEvent } from './types';
3 import { bold, gray } from 'src/ui/colors';
4 import { truncate } from 'src/ui/truncate';
5 +import { extractSchemaProperties } from 'src/ui/extract-schema-properties';
6
7 export const formatTriggerListenSummary = (event: TriggerListenEvent): string => {
8 const userId = event.userId || '-';
@@ -79,7 +80,9 @@ export const formatTriggerTypesTable = (triggerTypes: ReadonlyArray<TriggerType>
80 const name = truncate(triggerType.name, TRIGGER_TYPES_TABLE.name).padEnd(
81 TRIGGER_TYPES_TABLE.name
82 );
82 - const type = triggerType.type.padEnd(TRIGGER_TYPES_TABLE.type);
83 + const type = truncate(triggerType.type, TRIGGER_TYPES_TABLE.type).padEnd(
84 + TRIGGER_TYPES_TABLE.type
85 + );
86 const description = gray(truncate(triggerType.description, 50));
87 return `${slug} ${name} ${type} ${description}`;
88 });
@@ -100,23 +103,11 @@ export const formatTriggerTypesJson = (triggerTypes: ReadonlyArray<TriggerType>)
103 );
104
105 function formatSchemaProperties(schema: Record<string, unknown>): string {
103 - const properties = schema['properties'] as Record<string, Record<string, unknown>> | undefined;
104 - if (!properties || Object.keys(properties).length === 0) {
106 + const entries = extractSchemaProperties(schema);
107 + if (entries.length === 0) {
108 return ' (none)';
109 }
110
108 - const requiredArr = (schema['required'] as string[] | undefined) ?? [];
109 - const requiredSet = new Set(requiredArr);
110 -
111 - const entries = Object.entries(properties).map(([name, prop]) => {
112 - const type = (prop['type'] as string) ?? 'unknown';
113 - const label = requiredSet.has(name) ? 'required' : 'optional';
114 - const description = prop['description'] as string | undefined;
115 - const hasDefault = Object.prototype.hasOwnProperty.call(prop, 'default');
116 - const defaultValue = hasDefault ? prop['default'] : undefined;
117 - return { name, type, label, description, hasDefault, defaultValue };
118 - });
119 -
111 const typeWidth = Math.max(...entries.map(e => e.type.length));
112 const labelWidth = Math.max(...entries.map(e => e.label.length));
113 const metadataLabels = ['description:', 'type:', 'required:', 'default:'] as const;
ts/packages/cli/src/commands/triggers/parse-csv.ts new
+5
@@ -0,0 +1,5 @@
1 +export const parseCsv = (value: string): ReadonlyArray<string> =>
2 + value
3 + .split(',')
4 + .map(item => item.trim())
5 + .filter(Boolean);
ts/packages/cli/src/models/trigger-types.ts
+6 -1
@@ -61,7 +61,12 @@ export const TriggerType = Schema.Struct({
61 /**
62 * Information about the toolkit that provides this trigger
63 */
64 - // toolkit: Toolkit,
64 + toolkit: Schema.optional(
65 + Schema.Struct({
66 + name: Schema.String,
67 + slug: Schema.String,
68 + })
69 + ),
70
71 /**
72 * The trigger mechanism - either webhook (event-based) or poll (scheduled check)
ts/packages/cli/src/ui/extract-schema-properties.ts new
+36
@@ -0,0 +1,36 @@
1 +export interface SchemaPropertyEntry {
2 + readonly name: string;
3 + readonly type: string;
4 + readonly label: 'required' | 'optional';
5 + readonly description?: string;
6 + readonly hasDefault: boolean;
7 + readonly defaultValue: unknown;
8 +}
9 +
10 +export function extractSchemaProperties(
11 + schema: Record<string, unknown>
12 +): ReadonlyArray<SchemaPropertyEntry> {
13 + const properties = schema['properties'] as Record<string, Record<string, unknown>> | undefined;
14 + if (!properties || Object.keys(properties).length === 0) {
15 + return [];
16 + }
17 +
18 + const requiredArr = (schema['required'] as string[] | undefined) ?? [];
19 + const requiredSet = new Set(requiredArr);
20 +
21 + return Object.entries(properties).map(([name, prop]) => {
22 + const type = (prop['type'] as string) ?? 'unknown';
23 + const label = requiredSet.has(name) ? 'required' : 'optional';
24 + const description = prop['description'] as string | undefined;
25 + const hasDefault = Object.prototype.hasOwnProperty.call(prop, 'default');
26 + const defaultValue = hasDefault ? prop['default'] : undefined;
27 + return {
28 + name,
29 + type,
30 + label,
31 + description,
32 + hasDefault,
33 + defaultValue,
34 + };
35 + });
36 +}
ts/packages/cli/test/src/commands/triggers/triggers.info.cmd.test.ts
+2
@@ -11,6 +11,7 @@ const testTriggerTypes: TriggerTypes = [
11 name: 'NEW_GMAIL_MESSAGE',
12 description: 'Fires when a new message arrives in Gmail',
13 instructions: 'Connect Gmail and subscribe to this trigger',
14 + toolkit: { name: 'Gmail', slug: 'gmail' },
15 type: 'webhook',
16 config: {
17 type: 'object',
@@ -38,6 +39,7 @@ const testTriggerTypes: TriggerTypes = [
39 name: 'NEW_MESSAGE',
40 description: 'Fires when a new message is posted in Slack',
41 instructions: 'Connect Slack and subscribe to this trigger',
42 + toolkit: { name: 'Slack', slug: 'slack' },
43 type: 'webhook',
44 config: { type: 'object', properties: {} },
45 payload: { type: 'object', properties: {} },