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

next
ts 87 lines 2.78 KB
Raw
1 import { telemetry, withCommandTelemetry } from 'src/analytics/command-input';
2 import { Argument, Command, Flag } from 'effect/cli';
3 import { withCommandMeta } from 'src/invocation/command-identity';
4 import { runToolsSearch } from './tools.search.handler';
5
6 const query = Argument.String('query').pipe(
7 Argument.variadic(),
8 Argument.withDescription(
9 'One or more semantic use-case queries (e.g. "onboard a new GitHub repo", "notify Slack").'
10 )
11 );
12
13 const toolkits = Flag.String('toolkits').pipe(
14 Flag.withDescription('Filter by toolkit slugs, comma-separated (e.g. "gmail,outlook")'),
15 Flag.optional
16 );
17
18 const limit = Flag.Int('limit').pipe(
19 Flag.withDefault(10),
20 Flag.withDescription('Number of results per page (1-1000)')
21 );
22
23 const json = Flag.Boolean('json').pipe(
24 Flag.withDefault(false),
25 Flag.withDescription('Print the full search response as JSON (default behavior)')
26 );
27
28 const human = Flag.Boolean('human').pipe(
29 Flag.withDefault(false),
30 Flag.withDescription('Show formatted human-readable search output')
31 );
32
33 const toolsCmd$SearchBase = Command.make(
34 'search',
35 { query, toolkits, limit, json, human },
36 runToolsSearch
37 ).pipe(
38 Command.withDescription(
39 'Find tools by use case. Defaults to full JSON output; use `--human` for formatted output.'
40 ),
41 Command.withShortDescription(
42 'Find tools by use case. Defaults to full JSON output; use `--human` for formatted output.'
43 ),
44 Command.withExamples([
45 {
46 command: 'composio search "send an email"',
47 description: 'Find tools for a use case',
48 },
49 {
50 command: 'composio search "send an email" "create github issue"',
51 },
52 {
53 command: 'composio search "my emails" "my github issues" --toolkits gmail,github',
54 },
55 {
56 command: 'composio search "create issue" --toolkits github',
57 },
58 {
59 command: 'composio search "send an email" --human',
60 },
61 {
62 command: 'composio search "post a message to a slack channel"',
63 description: 'Cross-app workflow discovery',
64 },
65 {
66 command: 'composio search "add a row to google sheet"',
67 },
68 {
69 command: 'composio search "list calendar events" --toolkits google_calendar --limit 5',
70 description: 'Narrow results to a specific toolkit',
71 },
72 ]),
73 withCommandMeta({ requiresLogin: true })
74 );
75
76 export const toolsCmd$Search = withCommandTelemetry(toolsCmd$SearchBase, input => {
77 const query = input.query[0] ?? '';
78 return telemetry.fields({
79 toolkits: {
80 value: telemetry.optional(input.toolkits),
81 flags: telemetry.present(input.toolkits) ? ['--toolkits'] : [],
82 },
83 limit: telemetry.value(input.limit === undefined ? undefined : String(input.limit)),
84 query_length: telemetry.value(query.length),
85 query_term_count: telemetry.value(query.split(/\s+/u).filter(Boolean).length),
86 });
87 });