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
fix(js-sdk): send origin=js-sdk@<version> on research endpoints
mogery84d736273d31
diff --git a/apps/js-sdk/firecrawl/package.json b/apps/js-sdk/firecrawl/package.jsonindex 777815b4b..e19e01268 100644--- a/apps/js-sdk/firecrawl/package.json+++ b/apps/js-sdk/firecrawl/package.json@@ -1,6 +1,6 @@{"name": "@mendable/firecrawl-js",- "version": "4.29.1",+ "version": "4.29.2","description": "JavaScript SDK for Firecrawl API","main": "dist/index.js","types": "dist/index.d.ts",diff --git a/apps/js-sdk/firecrawl/src/__tests__/unit/v2/research.test.ts b/apps/js-sdk/firecrawl/src/__tests__/unit/v2/research.test.tsindex 9e1995d38..44284cee7 100644--- a/apps/js-sdk/firecrawl/src/__tests__/unit/v2/research.test.ts+++ b/apps/js-sdk/firecrawl/src/__tests__/unit/v2/research.test.ts@@ -53,7 +53,8 @@ describe("research.searchPapers", () => {const { client, calls } = makeClient(() => ({ status: 200, data: { results: [] } }));await client.searchPapers("q");const qs = new URLSearchParams(calls[0].split("?")[1]);- expect([...qs.keys()]).toEqual(["query"]);+ expect([...qs.keys()]).toEqual(["query", "origin"]);+ expect(qs.get("origin")).toMatch(/^js-sdk@/);});test("rejects empty query", async () => {@@ -74,10 +75,14 @@ describe("research.searchPapers", () => {});describe("research.getPaper", () => {- test("detail mode encodes the id and sends no query params", async () => {+ test("detail mode encodes the id and sends only the origin param", async () => {const { client, calls } = makeClient(() => ({ status: 200, data: { paper: {} } }));await client.getPaper("arxiv:2105.05233");- expect(calls[0]).toBe("/v2/search/research/papers/arxiv%3A2105.05233");+ const [path, query] = calls[0].split("?");+ expect(path).toBe("/v2/search/research/papers/arxiv%3A2105.05233");+ const qs = new URLSearchParams(query);+ expect([...qs.keys()]).toEqual(["origin"]);+ expect(qs.get("origin")).toMatch(/^js-sdk@/);});test("read mode adds query and k", async () => {diff --git a/apps/js-sdk/firecrawl/src/v2/methods/research.ts b/apps/js-sdk/firecrawl/src/v2/methods/research.tsindex c764c4400..ffb9494ee 100644--- a/apps/js-sdk/firecrawl/src/v2/methods/research.ts+++ b/apps/js-sdk/firecrawl/src/v2/methods/research.ts@@ -12,6 +12,7 @@ import type {import { SdkError } from "../types";import { HttpClient } from "../utils/httpClient";import { throwForBadResponse } from "../utils/errorHandler";+import { getVersion } from "../utils/getVersion";const BASE = "/v2/search/research";@@ -32,6 +33,9 @@ function appendParam(}function withQuery(path: string, params: URLSearchParams): string {+ // Research endpoints are GETs, so the POST-body origin injection in+ // HttpClient never applies — attach it as a query param instead.+ params.append("origin", `js-sdk@${getVersion()}`);const qs = params.toString();return qs ? `${path}?${qs}` : path;}