All files / src/types base_toolset.ts

100% Statements 4/4
100% Branches 0/0
100% Functions 0/0
100% Lines 4/4

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 836x             6x                                                         6x                                                                       6x                    
import { z } from "zod";
import { ActionExecutionResDto } from "../sdk/client";
 
/*
    This is the schema for the raw action to be stored locally
    Also returned by the API
*/
export const ZRawActionSchema = z.object({
  name: z.string(),
  display_name: z.string(),
  description: z.string(),
  appKey: z.string(),
  appId: z.string(),
  appName: z.string(),
  logo: z.string(),
  enabled: z.boolean(),
  tags: z.array(z.string()),
  parameters: z.object({
    type: z.string(),
    title: z.string(),
    description: z.string(),
    required: z.array(z.string()),
    properties: z.record(z.any()),
  }),
  response: z.record(z.any()),
  metadata: z.object({
    name: z.string(),
    toolName: z.string().optional(),
  }),
});
 
export type RawActionData = z.infer<typeof ZRawActionSchema>;
 
/*
    This is the schema for the params object in the ExecuteAction function
*/
export const ZExecuteActionParams = z.object({
  action: z.string(),
  params: z.record(z.any()).optional(),
  entityId: z.string().optional(),
  nlaText: z.string().optional(),
  connectedAccountId: z.string().optional(),
  config: z
    .object({
      labels: z.array(z.string()).optional(),
    })
    .optional(),
});
 
export type TPreProcessor = ({
  params,
}: {
  params: Record<string, unknown>;
  actionName: string;
}) => Record<string, unknown>;
 
export type TPostProcessor = ({
  actionName,
  toolResponse,
}: {
  actionName: string;
  toolResponse: ActionExecutionResDto;
}) => ActionExecutionResDto;
 
export type TSchemaProcessor = ({
  actionName,
  toolSchema,
}: {
  actionName: string;
  toolSchema: RawActionData;
}) => RawActionData;
 
export const ZToolSchemaFilter = z.object({
  actions: z.array(z.string()).optional(),
  apps: z.array(z.string()).optional(),
  tags: z.array(z.string()).optional(),
  useCase: z.string().optional(),
  useCaseLimit: z.number().optional(),
  filterByAvailableApps: z.boolean().optional(),
});
 
export type TToolSchemaFilter = z.infer<typeof ZToolSchemaFilter>;