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 26 lines 1.01 KB
Raw
1 import { z } from 'zod';
2
3 export const instantSchema = z.object({
4 supported: z.boolean().optional().catch(undefined),
5 price: z.object({
6 description: z.string().optional().catch(undefined),
7 discount: z.string().optional().catch(undefined),
8 }).optional().catch(undefined),
9 }).optional().catch(undefined);
10
11 export type Instant = z.infer<typeof instantSchema>;
12
13 export function toolkitSupportsInstant(instant: Instant, tools: { instant?: Instant }[]): boolean {
14 return instant?.supported === true || tools.some(tool => tool.instant?.supported === true);
15 }
16
17 export function instantPricingDescription(instant: Instant): string | undefined {
18 if (instant?.supported !== true) return undefined;
19 return instant.price?.description?.trim() || 'Pricing is not available.';
20 }
21
22 export function instantDiscount(instant: Instant): string | undefined {
23 if (instant?.supported !== true) return undefined;
24 const discount = instant.price?.discount;
25 return discount?.trim() && discount.trim() !== '0' ? discount : undefined;
26 }