export type CreateApiTavilyCrawlArgs = {body: {url: string, instructions?: string | undefined, chunks_per_source?: number | undefined, max_depth?: number | undefined, max_breadth?: number | undefined, limit?: number | undefined, select_paths?: Array | undefined, select_domains?: Array | undefined, exclude_paths?: Array | undefined, exclude_domains?: Array | undefined, allow_external?: boolean | undefined, include_images?: boolean | undefined, extract_depth?: string | undefined, format?: string | undefined, include_favicon?: boolean | undefined, timeout?: string | undefined}}; export type CreateApiTavilyCrawlOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Tavily Crawl is a graph-based website traversal tool that can explore hundreds of paths in parallel with built-in extraction and intelligent discovery. * * POST /tavily/crawl */ export const createApiTavilyCrawl = async (args: CreateApiTavilyCrawlArgs, options?: CreateApiTavilyCrawlOptions) => { const {baseUrl = "https://api.orthogonal.com/mpp", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/tavily/crawl${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };