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 54 lines 2.32 KB
Raw
1 import { Schema } from 'effect';
2
3 /**
4 * The CLI's contract for a Tool Router search response (`toolRouter.session.search`): the fields
5 * `composio search` reads, and nothing it does not. The client's schema for the endpoint also
6 * fixes enums and requires fields the command never reads, which may change without this
7 * version of the CLI noticing.
8 */
9
10 const JsonObject = Schema.Record(Schema.String, Schema.Unknown);
11
12 /** A tool's schema in a search response, as `composio search` lists and caches it. */
13 export const SearchToolSchema = Schema.Struct({
14 toolkit: Schema.String,
15 tool_slug: Schema.String,
16 description: Schema.optional(Schema.NullOr(Schema.String)),
17 input_schema: Schema.optional(Schema.NullOr(JsonObject)),
18 output_schema: Schema.optional(Schema.NullOr(JsonObject)),
19 }).annotate({ identifier: 'SearchToolSchema' });
20 export type SearchToolSchema = Schema.Schema.Type<typeof SearchToolSchema>;
21
22 export const SearchToolSchemas = Schema.Record(Schema.String, SearchToolSchema);
23 export type SearchToolSchemas = Schema.Schema.Type<typeof SearchToolSchemas>;
24
25 const SearchResultFields = Schema.StructWithRest(
26 Schema.Struct({
27 use_case: Schema.String,
28 primary_tool_slugs: Schema.Array(Schema.String),
29 related_tool_slugs: Schema.Array(Schema.String),
30 recommended_plan_steps: Schema.optional(Schema.NullOr(Schema.Array(Schema.String))),
31 }),
32 [JsonObject]
33 );
34 export type SearchResult = Schema.Schema.Type<typeof SearchResultFields>;
35
36 /**
37 * One query's result. `composio search` prints the result on stdout, so it is checked and then
38 * kept as the API sent it, its other fields and its key order included: decoding a struct
39 * rebuilds the object with the declared fields first.
40 */
41 export const SearchResult = Schema.declare(Schema.is(SearchResultFields)).annotate({
42 identifier: 'SearchResult',
43 });
44
45 export const ToolSearchResponse = Schema.Struct({
46 results: Schema.Array(SearchResult),
47 tool_schemas: SearchToolSchemas,
48 toolkit_connection_statuses: Schema.Array(
49 Schema.Struct({ toolkit: Schema.String, has_active_connection: Schema.Boolean })
50 ),
51 error: Schema.optional(Schema.NullOr(Schema.String)),
52 next_steps_guidance: Schema.optional(Schema.NullOr(Schema.Array(Schema.String))),
53 }).annotate({ identifier: 'ToolSearchResponse' });
54 export type ToolSearchResponse = Schema.Schema.Type<typeof ToolSearchResponse>;