Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥
TypeScript aiai-agentsai-crawlerai-scrapingai-searchcrawlerdata-extractionhtml-to-markdownllmmarkdownscraperscrapingweb-crawlerweb-dataweb-data-extractionweb-scraperweb-scrapingweb-searchwebscraping
feat(api): ab/bs (#2571)
Gergő Móriczb8c1ad84c65f
diff --git a/apps/api/src/controllers/v2/batch-scrape.ts b/apps/api/src/controllers/v2/batch-scrape.tsindex b82240f0b..84d2e9700 100644--- a/apps/api/src/controllers/v2/batch-scrape.ts+++ b/apps/api/src/controllers/v2/batch-scrape.ts@@ -51,6 +51,22 @@ export async function batchScrapeController(const zeroDataRetention =req.acuc?.flags?.forceZDR || (req.body.zeroDataRetention ?? false);+ if (+ req.body.__agentInterop &&+ config.AGENT_INTEROP_SECRET &&+ req.body.__agentInterop.auth !== config.AGENT_INTEROP_SECRET+ ) {+ return res.status(403).json({+ success: false,+ error: "Invalid agent interop.",+ });+ } else if (req.body.__agentInterop && !config.AGENT_INTEROP_SECRET) {+ return res.status(403).json({+ success: false,+ error: "Agent interop is not enabled.",+ });+ }+const id = req.body.appendToId ?? uuidv7();const logger = _logger.child({crawlId: id,@@ -183,6 +199,8 @@ export async function batchScrapeController(origin: "api",integration: req.body.integration,crawl_id: id,+ requestId: req.body.__agentInterop?.requestId ?? undefined,+ bypassBilling: !(req.body.__agentInterop?.shouldBill ?? true),sitemapped: true,v1: true,webhook: req.body.webhook,diff --git a/apps/api/src/controllers/v2/types.ts b/apps/api/src/controllers/v2/types.tsindex 2e13de248..6ccd5901c 100644--- a/apps/api/src/controllers/v2/types.ts+++ b/apps/api/src/controllers/v2/types.ts@@ -779,6 +779,13 @@ const batchScrapeRequestSchemaBase = baseScrapeOptions.extend({ignoreInvalidURLs: z.boolean().prefault(true),maxConcurrency: z.int().positive().optional(),zeroDataRetention: z.boolean().optional(),+ __agentInterop: z+ .object({+ auth: z.string(),+ requestId: z.string(),+ shouldBill: z.boolean(),+ })+ .optional(),});export const batchScrapeRequestSchema = strictWithMessage(@@ -796,6 +803,13 @@ const batchScrapeRequestSchemaNoURLValidationBase = baseScrapeOptions.extend({ignoreInvalidURLs: z.boolean().prefault(true),maxConcurrency: z.int().positive().optional(),zeroDataRetention: z.boolean().optional(),+ __agentInterop: z+ .object({+ auth: z.string(),+ requestId: z.string(),+ shouldBill: z.boolean(),+ })+ .optional(),});export const batchScrapeRequestSchemaNoURLValidation = strictWithMessage(