mirror of
https://github.com/prowler-cloud/prowler.git
synced 2025-12-19 05:17:47 +00:00
42 lines
1.2 KiB
TypeScript
42 lines
1.2 KiB
TypeScript
import { tool } from "@langchain/core/tools";
|
|
import { z } from "zod";
|
|
|
|
import { getFindings, getMetadataInfo } from "@/actions/findings";
|
|
import { getFindingsSchema, getMetadataInfoSchema } from "@/types/lighthouse";
|
|
|
|
export const getFindingsTool = tool(
|
|
async (input) => {
|
|
const typedInput = input as z.infer<typeof getFindingsSchema>;
|
|
return await getFindings({
|
|
page: typedInput.page,
|
|
pageSize: typedInput.pageSize,
|
|
query: typedInput.query,
|
|
sort: typedInput.sort,
|
|
filters: typedInput.filters,
|
|
});
|
|
},
|
|
{
|
|
name: "getFindings",
|
|
description:
|
|
"Retrieves a list of all findings with options for filtering by various criteria.",
|
|
schema: getFindingsSchema,
|
|
},
|
|
);
|
|
|
|
export const getMetadataInfoTool = tool(
|
|
async (input) => {
|
|
const typedInput = input as z.infer<typeof getMetadataInfoSchema>;
|
|
return await getMetadataInfo({
|
|
query: typedInput.query,
|
|
sort: typedInput.sort,
|
|
filters: typedInput.filters,
|
|
});
|
|
},
|
|
{
|
|
name: "getMetadataInfo",
|
|
description:
|
|
"Fetches unique metadata values from a set of findings. This is useful for dynamic filtering.",
|
|
schema: getMetadataInfoSchema,
|
|
},
|
|
);
|