Nick: exec js actions

This commit is contained in:
Nicolas 2024-11-06 11:56:23 -05:00
parent ed5a0d3cf2
commit 7500ebe4c6
3 changed files with 10 additions and 0 deletions

View File

@ -92,6 +92,10 @@ export const actionsSchema = z.array(z.union([
z.object({ z.object({
type: z.literal("scrape"), type: z.literal("scrape"),
}), }),
z.object({
type: z.literal("executeJavascript"),
script: z.string()
}),
])); ]));
export const scrapeOptions = z.object({ export const scrapeOptions = z.object({

View File

@ -31,6 +31,9 @@ export type Action = {
direction: "up" | "down" direction: "up" | "down"
} | { } | {
type: "scrape", type: "scrape",
} | {
type: "executeJavascript",
script: string,
} }
export type PageOptions = { export type PageOptions = {

View File

@ -109,6 +109,9 @@ export type Action = {
direction: "up" | "down", direction: "up" | "down",
} | { } | {
type: "scrape", type: "scrape",
} | {
type: "executeJavascript",
script: string,
}; };
export interface ScrapeParams<LLMSchema extends zt.ZodSchema = any, ActionsSchema extends (Action[] | undefined) = undefined> extends CrawlScrapeOptions { export interface ScrapeParams<LLMSchema extends zt.ZodSchema = any, ActionsSchema extends (Action[] | undefined) = undefined> extends CrawlScrapeOptions {