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
Use Alexandria name in provider execution errors (#4720)
Developers Digesta6e2130d72b7
diff --git a/apps/api/src/services/alexandria/README.md b/apps/api/src/services/alexandria/README.mdindex da1bccead..5d1db77ee 100644--- a/apps/api/src/services/alexandria/README.md+++ b/apps/api/src/services/alexandria/README.md@@ -1,7 +1,8 @@# Alexandria Search and Scrape-Search discovers tools; Scrape executes them. Both require the-`exchangeRetrieve` flag. Ordinary Search and Scrape keep their paths and billing.+Search discovers tools; Scrape executes them. Provider execution enforces+authentication, organization access, provider terms, and billing. Ordinary Search+and Scrape keep their paths and billing.```json{@@ -28,16 +29,16 @@ URL matching only.An ordinary URL scrape accepts `domainTools: true` (default off) and adds`data.tools` matched to the page's domain in the same shape as Search. It-needs Exchange access and no zero data retention, refused with the same 403+requires authentication and no zero data retention, refused with the same 403Search returns; discovery itself is free and never fails the scrape.Scrape with `alexandria` accepts one call or up to ten and returns`data.alexandria` with `data.creditsCost`. `/exchange/retrieve` shares the path; its single-call-shape relays a provider error with the Exchange's status and `code`.+shape relays a provider error with Alexandria's status and `code`.## Billing-Inline in the request (`retrieve.ts`): authorize through the Exchange+Inline in the request (`retrieve.ts`): authorize through Alexandria(`/v1/provider-terms/requirements`, which refuses unknown providers) againstthe organization's `organizationDataSourceAccess` flags, then refuse afree-plan team (Autumn rate-limit multiplier below the hobby floor) calling adiff --git a/apps/api/src/services/alexandria/client.ts b/apps/api/src/services/alexandria/client.tsindex 494a3f88d..299fd9970 100644--- a/apps/api/src/services/alexandria/client.ts+++ b/apps/api/src/services/alexandria/client.ts@@ -18,7 +18,7 @@ export async function exchangeRequest(input: {resultAuthorization?: string;termsIdentity?: { organizationId: string; apiKeyId: string };}): Promise<ExchangeResponse> {- if (!config.FIRE_EXCHANGE_URL) throw new Error("Exchange is not configured");+ if (!config.FIRE_EXCHANGE_URL) throw new Error("Alexandria is not configured");const base = config.FIRE_EXCHANGE_URL.replace(/\/+$/, "");const response = await fetch(base + input.path, {method: input.body === undefined ? "GET" : "POST",@@ -59,7 +59,7 @@ export async function exchangeRequest(input: {for await (const chunk of response.body ?? []) {size += chunk.length;if (size > 5 * 1024 * 1024)- throw new Error("Exchange response is too large");+ throw new Error("Alexandria response is too large");chunks.push(chunk);}const text = Buffer.concat(chunks).toString();diff --git a/apps/api/src/services/alexandria/retrieve.ts b/apps/api/src/services/alexandria/retrieve.tsindex 28f5a777e..2134b7f8b 100644--- a/apps/api/src/services/alexandria/retrieve.ts+++ b/apps/api/src/services/alexandria/retrieve.ts@@ -353,7 +353,7 @@ export async function retrieveProviders(input: {...(termsIdentity ? { termsIdentity } : {}),maximumCredits,}).catch(error => {- throw new Error(`Exchange did not answer: ${error?.message ?? error}`);+ throw new Error(`Alexandria did not answer: ${error?.message ?? error}`);});const body = (response.body ?? {}) as Record<string, unknown>;@@ -365,10 +365,10 @@ export async function retrieveProviders(input: {return refuse(relay(response), true);}if (response.status < 200 || response.status >= 300)- return fail(`Exchange answered ${response.status}`);+ return fail(`Alexandria answered ${response.status}`);const parsed = answerSchema.safeParse(response.body);- if (!parsed.success) return fail("Exchange answer was malformed");+ if (!parsed.success) return fail("Alexandria answer was malformed");const answer = parsed.data;const receiptMatches =answer.results.length === input.calls.length &&@@ -383,7 +383,7 @@ export async function retrieveProviders(input: {input.calls[i].capability,);if (!receiptMatches)- return fail("Exchange receipt did not match the request");+ return fail("Alexandria receipt did not match the request");const credits = answer.creditsCost;const settled = await finalize(credits);