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): forward provider-skills through the Exchange proxy (#5487)
Developers Digestfbf047c9e819
diff --git a/apps/api/src/__tests__/routes/exchange-connectors.routes.test.ts b/apps/api/src/__tests__/routes/exchange-connectors.routes.test.tsindex ca66dda56..7ef958375 100644--- a/apps/api/src/__tests__/routes/exchange-connectors.routes.test.ts+++ b/apps/api/src/__tests__/routes/exchange-connectors.routes.test.ts@@ -155,6 +155,27 @@ describe("Alexandria connector routes on the Exchange proxy", () => {"/exchange/team-skills/references?q=fred","/v1/team-skills/references?q=fred",],+ ["get", "/exchange/provider-skills", "/v1/provider-skills"],+ [+ "get",+ "/exchange/provider-skills/acme/research/brief",+ "/v1/provider-skills/acme/research/brief",+ ],+ [+ "get",+ "/exchange/provider-skills/acme/research/brief/file",+ "/v1/provider-skills/acme/research/brief/file",+ ],+ [+ "patch",+ "/exchange/provider-skills/acme/research",+ "/v1/provider-skills/acme/research",+ ],+ [+ "patch",+ "/exchange/provider-skills/acme/research/brief",+ "/v1/provider-skills/acme/research/brief",+ ],] as const)("forwards %s %s for a team with exchangeRetrieve, granting connectors",async (method, path, upstreamPath) => {@@ -220,6 +241,68 @@ describe("Alexandria connector routes on the Exchange proxy", () => {},);+ it.each([+ ["get", "/exchange/provider-skills", "/v1/provider-skills"],+ [+ "get",+ "/exchange/provider-skills/acme/research/brief",+ "/v1/provider-skills/acme/research/brief",+ ],+ [+ "get",+ "/exchange/provider-skills/acme/research/brief/file",+ "/v1/provider-skills/acme/research/brief/file",+ ],+ [+ "patch",+ "/exchange/provider-skills/acme/research",+ "/v1/provider-skills/acme/research",+ ],+ [+ "patch",+ "/exchange/provider-skills/acme/research/brief",+ "/v1/provider-skills/acme/research/brief",+ ],+ ] as const)(+ "forwards %s %s for any team, stamping the team and preserving method and body",+ async (method, path, upstreamPath) => {+ keyResolvesAs({});+ const body = { enabled: false };+ let req = request(app)+ [method](path)+ .set("authorization", `Bearer ${KEY}`);+ if (method === "patch") req = req.send(body);+ const response = await req;+ expect(response.status).toBe(200);+ expect(mocks.upstreamFetch).toHaveBeenCalledTimes(1);+ const { url, init } = upstream();+ expect(url).toBe(`https://exchange.test${upstreamPath}`);+ expect(init.method).toBe(method.toUpperCase());+ expect(init.headers).toMatchObject({+ "x-exchange-team-id": "team-connectors",+ });+ expect(init.headers).not.toHaveProperty("x-exchange-connectors");+ if (method === "patch") {+ expect(JSON.parse(String(init.body))).toEqual(body);+ } else {+ expect(init.body).toBeUndefined();+ }+ },+ );++ it.each(["post", "put", "delete"] as const)(+ "does not forward %s /exchange/provider-skills",+ async method => {+ keyResolvesAs({ exchangeRetrieve: true });+ const response = await request(app)+ [method]("/exchange/provider-skills/acme/research")+ .set("authorization", `Bearer ${KEY}`)+ .send({ enabled: true });+ expect(response.status).toBe(404);+ expect(mocks.upstreamFetch).not.toHaveBeenCalled();+ },+ );+it("forwards the team's billing country only when known, never the caller's own", async () => {keyResolvesAs({});mocks.billingCountry.mockResolvedValueOnce("DE");diff --git a/apps/api/src/routes/exchange.ts b/apps/api/src/routes/exchange.tsindex 208c75a1f..2c89a1832 100644--- a/apps/api/src/routes/exchange.ts+++ b/apps/api/src/routes/exchange.ts@@ -36,6 +36,7 @@ const FORWARDED_PATH_ROOTS = new Set(["enrichment","ingest","platform",+ "provider-skills","provider-terms","publisher","rates",@@ -393,6 +394,19 @@ exchangeRouter.delete(wrap(exchangeProxy(ANALYTICS_TIMEOUT_MS, { requiresRetrieveFlag: false })),);+// Provider-authored skills. Every team may list and read them, and turn a plugin+// or one skill on or off. Exchange scopes that toggle by the stamped team.+exchangeRouter.get(+ "/provider-skills{/*path}",+ authMiddleware(RateLimiterMode.Labs),+ wrap(exchangeProxy(ANALYTICS_TIMEOUT_MS, { requiresRetrieveFlag: false })),+);+exchangeRouter.patch(+ "/provider-skills{/*path}",+ authMiddleware(RateLimiterMode.Labs),+ wrap(exchangeProxy(ANALYTICS_TIMEOUT_MS, { requiresRetrieveFlag: false })),+);+exchangeRouter.post("/retrieve",authMiddleware(RateLimiterMode.Exchange, { allowAgentManagedKey: true }),