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.

fix(cli): address bugbot issues in triggers commands

haxzie87c016ab81cf
diff --git a/ts/packages/cli/src/commands/tools/format.ts b/ts/packages/cli/src/commands/tools/format.ts
index af732675a..380f9e631 100644
--- a/ts/packages/cli/src/commands/tools/format.ts
+++ b/ts/packages/cli/src/commands/tools/format.ts
@@ -2,6 +2,7 @@ import type { Tool } from 'src/models/tools';
import type { ToolDetailedResponse } from 'src/services/composio-clients';
import { bold, gray } from 'src/ui/colors';
import { truncate } from 'src/ui/truncate';
+import { extractSchemaProperties } from 'src/ui/extract-schema-properties';
/**
* Format a list of tools as a human-readable table.
@@ -40,21 +41,11 @@ export function formatToolsJson(tools: ReadonlyArray<Tool>): string {
* Extracts `properties` entries, cross-references `required` array.
*/
function formatSchemaProperties(schema: Record<string, unknown>): string {
- const properties = schema['properties'] as Record<string, Record<string, unknown>> | undefined;
- if (!properties || Object.keys(properties).length === 0) {
+ const entries = extractSchemaProperties(schema);
+ if (entries.length === 0) {
return ' (none)';
}
- const requiredArr = (schema['required'] as string[] | undefined) ?? [];
- const requiredSet = new Set(requiredArr);
-
- const entries = Object.entries(properties).map(([name, prop]) => {
- const type = (prop['type'] as string) ?? 'unknown';
- const label = requiredSet.has(name) ? 'required' : 'optional';
- const description = prop['description'] as string | undefined;
- return { name, type, label, description };
- });
-
const nameWidth = Math.max(...entries.map(e => e.name.length));
const typeWidth = Math.max(...entries.map(e => e.type.length));
const labelWidth = Math.max(...entries.map(e => e.label.length));
diff --git a/ts/packages/cli/src/commands/triggers/commands/triggers.info.cmd.ts b/ts/packages/cli/src/commands/triggers/commands/triggers.info.cmd.ts
index 3f7a5347b..b7eae9635 100644
--- a/ts/packages/cli/src/commands/triggers/commands/triggers.info.cmd.ts
+++ b/ts/packages/cli/src/commands/triggers/commands/triggers.info.cmd.ts
@@ -57,7 +57,7 @@ export const triggersCmd$Info = Command.make('info', { slug }, ({ slug }) =>
yield* ui.log.info(formatTriggerTypeInfo(triggerType));
- const toolkitSlug = triggerType.slug.split('_')[0]?.toLowerCase();
+ const toolkitSlug = triggerType.toolkit?.slug?.toLowerCase();
if (toolkitSlug) {
yield* ui.log.step(
`To list more trigger types in this toolkit:\n> composio triggers list --toolkits "${toolkitSlug}"`
diff --git a/ts/packages/cli/src/commands/triggers/commands/triggers.list.cmd.ts b/ts/packages/cli/src/commands/triggers/commands/triggers.list.cmd.ts
index 3ede1a6f4..1098ee581 100644
--- a/ts/packages/cli/src/commands/triggers/commands/triggers.list.cmd.ts
+++ b/ts/packages/cli/src/commands/triggers/commands/triggers.list.cmd.ts
@@ -5,6 +5,7 @@ import { ComposioToolkitsRepository } from 'src/services/composio-clients';
import { TerminalUI } from 'src/services/terminal-ui';
import { clampLimit } from 'src/ui/clamp-limit';
import { formatTriggerTypesJson, formatTriggerTypesTable } from '../format';
+import { parseCsv } from '../parse-csv';
const toolkits = Options.text('toolkits').pipe(
Options.withDescription(
@@ -18,12 +19,6 @@ const limit = Options.integer('limit').pipe(
Options.withDescription('Maximum number of trigger types to show (1-1000)')
);
-const parseCsv = (value: string): ReadonlyArray<string> =>
- value
- .split(',')
- .map(item => item.trim())
- .filter(Boolean);
-
/**
* List available trigger types with optional toolkit filters.
*
diff --git a/ts/packages/cli/src/commands/triggers/commands/triggers.listen.cmd.ts b/ts/packages/cli/src/commands/triggers/commands/triggers.listen.cmd.ts
index 0e384eb85..c582f4da2 100644
--- a/ts/packages/cli/src/commands/triggers/commands/triggers.listen.cmd.ts
+++ b/ts/packages/cli/src/commands/triggers/commands/triggers.listen.cmd.ts
@@ -12,6 +12,7 @@ import {
formatTriggerListenTableHeader,
formatTriggerListenTableRow,
} from '../format';
+import { parseCsv } from '../parse-csv';
import { parseTriggerListenEvent } from '../parse';
import type { TriggerListenFilters } from '../types';
@@ -73,12 +74,6 @@ const out = Options.text('out').pipe(
Options.optional
);
-const parseCsv = (value: string): ReadonlyArray<string> =>
- value
- .split(',')
- .map(item => item.trim())
- .filter(Boolean);
-
const randomUUID = () => crypto.randomUUID();
const signWebhookPayload = async ({
diff --git a/ts/packages/cli/src/commands/triggers/format.ts b/ts/packages/cli/src/commands/triggers/format.ts
index a1a5067cd..dd46cf8fe 100644
--- a/ts/packages/cli/src/commands/triggers/format.ts
+++ b/ts/packages/cli/src/commands/triggers/format.ts
@@ -2,6 +2,7 @@ import type { TriggerType } from 'src/models/trigger-types';
import type { TriggerListenEvent } from './types';
import { bold, gray } from 'src/ui/colors';
import { truncate } from 'src/ui/truncate';
+import { extractSchemaProperties } from 'src/ui/extract-schema-properties';
export const formatTriggerListenSummary = (event: TriggerListenEvent): string => {
const userId = event.userId || '-';
@@ -79,7 +80,9 @@ export const formatTriggerTypesTable = (triggerTypes: ReadonlyArray<TriggerType>
const name = truncate(triggerType.name, TRIGGER_TYPES_TABLE.name).padEnd(
TRIGGER_TYPES_TABLE.name
);
- const type = triggerType.type.padEnd(TRIGGER_TYPES_TABLE.type);
+ const type = truncate(triggerType.type, TRIGGER_TYPES_TABLE.type).padEnd(
+ TRIGGER_TYPES_TABLE.type
+ );
const description = gray(truncate(triggerType.description, 50));
return `${slug} ${name} ${type} ${description}`;
});
@@ -100,23 +103,11 @@ export const formatTriggerTypesJson = (triggerTypes: ReadonlyArray<TriggerType>)
);
function formatSchemaProperties(schema: Record<string, unknown>): string {
- const properties = schema['properties'] as Record<string, Record<string, unknown>> | undefined;
- if (!properties || Object.keys(properties).length === 0) {
+ const entries = extractSchemaProperties(schema);
+ if (entries.length === 0) {
return ' (none)';
}
- const requiredArr = (schema['required'] as string[] | undefined) ?? [];
- const requiredSet = new Set(requiredArr);
-
- const entries = Object.entries(properties).map(([name, prop]) => {
- const type = (prop['type'] as string) ?? 'unknown';
- const label = requiredSet.has(name) ? 'required' : 'optional';
- const description = prop['description'] as string | undefined;
- const hasDefault = Object.prototype.hasOwnProperty.call(prop, 'default');
- const defaultValue = hasDefault ? prop['default'] : undefined;
- return { name, type, label, description, hasDefault, defaultValue };
- });
-
const typeWidth = Math.max(...entries.map(e => e.type.length));
const labelWidth = Math.max(...entries.map(e => e.label.length));
const metadataLabels = ['description:', 'type:', 'required:', 'default:'] as const;
diff --git a/ts/packages/cli/src/commands/triggers/parse-csv.ts b/ts/packages/cli/src/commands/triggers/parse-csv.ts
new file mode 100644
index 000000000..1a4a35340
--- /dev/null
+++ b/ts/packages/cli/src/commands/triggers/parse-csv.ts
@@ -0,0 +1,5 @@
+export const parseCsv = (value: string): ReadonlyArray<string> =>
+ value
+ .split(',')
+ .map(item => item.trim())
+ .filter(Boolean);
diff --git a/ts/packages/cli/src/models/trigger-types.ts b/ts/packages/cli/src/models/trigger-types.ts
index 5b2d07385..034acdef9 100644
--- a/ts/packages/cli/src/models/trigger-types.ts
+++ b/ts/packages/cli/src/models/trigger-types.ts
@@ -61,7 +61,12 @@ export const TriggerType = Schema.Struct({
/**
* Information about the toolkit that provides this trigger
*/
- // toolkit: Toolkit,
+ toolkit: Schema.optional(
+ Schema.Struct({
+ name: Schema.String,
+ slug: Schema.String,
+ })
+ ),
/**
* The trigger mechanism - either webhook (event-based) or poll (scheduled check)
diff --git a/ts/packages/cli/src/ui/extract-schema-properties.ts b/ts/packages/cli/src/ui/extract-schema-properties.ts
new file mode 100644
index 000000000..7cf7eec74
--- /dev/null
+++ b/ts/packages/cli/src/ui/extract-schema-properties.ts
@@ -0,0 +1,36 @@
+export interface SchemaPropertyEntry {
+ readonly name: string;
+ readonly type: string;
+ readonly label: 'required' | 'optional';
+ readonly description?: string;
+ readonly hasDefault: boolean;
+ readonly defaultValue: unknown;
+}
+
+export function extractSchemaProperties(
+ schema: Record<string, unknown>
+): ReadonlyArray<SchemaPropertyEntry> {
+ const properties = schema['properties'] as Record<string, Record<string, unknown>> | undefined;
+ if (!properties || Object.keys(properties).length === 0) {
+ return [];
+ }
+
+ const requiredArr = (schema['required'] as string[] | undefined) ?? [];
+ const requiredSet = new Set(requiredArr);
+
+ return Object.entries(properties).map(([name, prop]) => {
+ const type = (prop['type'] as string) ?? 'unknown';
+ const label = requiredSet.has(name) ? 'required' : 'optional';
+ const description = prop['description'] as string | undefined;
+ const hasDefault = Object.prototype.hasOwnProperty.call(prop, 'default');
+ const defaultValue = hasDefault ? prop['default'] : undefined;
+ return {
+ name,
+ type,
+ label,
+ description,
+ hasDefault,
+ defaultValue,
+ };
+ });
+}
diff --git a/ts/packages/cli/test/src/commands/triggers/triggers.info.cmd.test.ts b/ts/packages/cli/test/src/commands/triggers/triggers.info.cmd.test.ts
index 01f2a8561..8ff3d9b7c 100644
--- a/ts/packages/cli/test/src/commands/triggers/triggers.info.cmd.test.ts
+++ b/ts/packages/cli/test/src/commands/triggers/triggers.info.cmd.test.ts
@@ -11,6 +11,7 @@ const testTriggerTypes: TriggerTypes = [
name: 'NEW_GMAIL_MESSAGE',
description: 'Fires when a new message arrives in Gmail',
instructions: 'Connect Gmail and subscribe to this trigger',
+ toolkit: { name: 'Gmail', slug: 'gmail' },
type: 'webhook',
config: {
type: 'object',
@@ -38,6 +39,7 @@ const testTriggerTypes: TriggerTypes = [
name: 'NEW_MESSAGE',
description: 'Fires when a new message is posted in Slack',
instructions: 'Connect Slack and subscribe to this trigger',
+ toolkit: { name: 'Slack', slug: 'slack' },
type: 'webhook',
config: { type: 'object', properties: {} },
payload: { type: 'object', properties: {} },