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 22 lines 941 Bytes
Raw
1 import type { Tool as ComposioTool } from '@composio/core';
2 import { Type, type TSchema } from 'typebox';
3
4 const EmptyObjectSchema = Type.Object({});
5
6 export const ToolkitsSchema = Type.Optional(
7 Type.Array(Type.String({ description: 'Optional toolkit slug filter, e.g. github, gmail.' }))
8 );
9
10 export const objectInputSchema = (schema: ComposioTool['inputParameters'] | undefined): TSchema => {
11 const candidate =
12 schema && typeof schema === 'object'
13 ? ({ ...schema } as Record<string, unknown>)
14 : ({ ...EmptyObjectSchema } as Record<string, unknown>);
15 if (!candidate.type) candidate.type = 'object';
16 if (!candidate.properties) candidate.properties = {};
17 if (candidate.additionalProperties === undefined) candidate.additionalProperties = true;
18 return Type.Unsafe(candidate);
19 };
20
21 export const optionalRecordSchema = (description: string) =>
22 Type.Optional(Type.Record(Type.String(), Type.Any(), { description }));