@mendable/firecrawl 4.9.0 → 4.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,7 +8,7 @@ var require_package = __commonJS({
8
8
  "package.json"(exports, module) {
9
9
  module.exports = {
10
10
  name: "@mendable/firecrawl-js",
11
- version: "4.9.0",
11
+ version: "4.9.2",
12
12
  description: "JavaScript SDK for Firecrawl API",
13
13
  main: "dist/index.js",
14
14
  types: "dist/index.d.ts",
package/dist/index.cjs CHANGED
@@ -35,7 +35,7 @@ var require_package = __commonJS({
35
35
  "package.json"(exports2, module2) {
36
36
  module2.exports = {
37
37
  name: "@mendable/firecrawl-js",
38
- version: "4.9.0",
38
+ version: "4.9.2",
39
39
  description: "JavaScript SDK for Firecrawl API",
40
40
  main: "dist/index.js",
41
41
  types: "dist/index.d.ts",
@@ -763,6 +763,7 @@ function prepareAgentPayload(args) {
763
763
  body.schema = isZod ? (0, import_zod_to_json_schema3.zodToJsonSchema)(s) : args.schema;
764
764
  }
765
765
  if (args.integration && args.integration.trim()) body.integration = args.integration.trim();
766
+ if (args.maxCredits !== null && args.maxCredits !== void 0) body.maxCredits = args.maxCredits;
766
767
  return body;
767
768
  }
768
769
  async function startAgent(http, args) {
@@ -801,6 +802,16 @@ async function agent(http, args) {
801
802
  if (!jobId) return started;
802
803
  return waitAgent(http, jobId, args.pollInterval ?? 2, args.timeout);
803
804
  }
805
+ async function cancelAgent(http, jobId) {
806
+ try {
807
+ const res = await http.delete(`/v2/agent/${jobId}`);
808
+ if (res.status !== 200) throwForBadResponse(res, "cancel agent");
809
+ return res.data?.success === true;
810
+ } catch (err) {
811
+ if (err?.isAxiosError) return normalizeAxiosError(err, "cancel agent");
812
+ throw err;
813
+ }
814
+ }
804
815
 
805
816
  // src/v2/methods/usage.ts
806
817
  async function getConcurrency(http) {
@@ -1287,6 +1298,14 @@ var FirecrawlClient = class {
1287
1298
  async agent(args) {
1288
1299
  return agent(this.http, args);
1289
1300
  }
1301
+ /**
1302
+ * Cancel an agent job.
1303
+ * @param jobId Agent job id.
1304
+ * @returns True if cancelled.
1305
+ */
1306
+ async cancelAgent(jobId) {
1307
+ return cancelAgent(this.http, jobId);
1308
+ }
1290
1309
  // Usage
1291
1310
  /** Current concurrency usage. */
1292
1311
  async getConcurrency() {
package/dist/index.d.cts CHANGED
@@ -586,6 +586,7 @@ declare function prepareAgentPayload(args: {
586
586
  prompt: string;
587
587
  schema?: Record<string, unknown> | ZodTypeAny;
588
588
  integration?: string;
589
+ maxCredits?: number;
589
590
  }): Record<string, unknown>;
590
591
  declare function startAgent(http: HttpClient, args: Parameters<typeof prepareAgentPayload>[0]): Promise<AgentResponse>;
591
592
 
@@ -788,6 +789,12 @@ declare class FirecrawlClient {
788
789
  pollInterval?: number;
789
790
  timeout?: number;
790
791
  }): Promise<AgentStatusResponse>;
792
+ /**
793
+ * Cancel an agent job.
794
+ * @param jobId Agent job id.
795
+ * @returns True if cancelled.
796
+ */
797
+ cancelAgent(jobId: string): Promise<boolean>;
791
798
  /** Current concurrency usage. */
792
799
  getConcurrency(): Promise<ConcurrencyCheck>;
793
800
  /** Current credit usage. */
package/dist/index.d.ts CHANGED
@@ -586,6 +586,7 @@ declare function prepareAgentPayload(args: {
586
586
  prompt: string;
587
587
  schema?: Record<string, unknown> | ZodTypeAny;
588
588
  integration?: string;
589
+ maxCredits?: number;
589
590
  }): Record<string, unknown>;
590
591
  declare function startAgent(http: HttpClient, args: Parameters<typeof prepareAgentPayload>[0]): Promise<AgentResponse>;
591
592
 
@@ -788,6 +789,12 @@ declare class FirecrawlClient {
788
789
  pollInterval?: number;
789
790
  timeout?: number;
790
791
  }): Promise<AgentStatusResponse>;
792
+ /**
793
+ * Cancel an agent job.
794
+ * @param jobId Agent job id.
795
+ * @returns True if cancelled.
796
+ */
797
+ cancelAgent(jobId: string): Promise<boolean>;
791
798
  /** Current concurrency usage. */
792
799
  getConcurrency(): Promise<ConcurrencyCheck>;
793
800
  /** Current credit usage. */
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  require_package
3
- } from "./chunk-KS6E546Q.js";
3
+ } from "./chunk-NR7V4IEX.js";
4
4
 
5
5
  // src/v2/utils/httpClient.ts
6
6
  import axios from "axios";
@@ -645,6 +645,7 @@ function prepareAgentPayload(args) {
645
645
  body.schema = isZod ? zodToJsonSchema3(s) : args.schema;
646
646
  }
647
647
  if (args.integration && args.integration.trim()) body.integration = args.integration.trim();
648
+ if (args.maxCredits !== null && args.maxCredits !== void 0) body.maxCredits = args.maxCredits;
648
649
  return body;
649
650
  }
650
651
  async function startAgent(http, args) {
@@ -683,6 +684,16 @@ async function agent(http, args) {
683
684
  if (!jobId) return started;
684
685
  return waitAgent(http, jobId, args.pollInterval ?? 2, args.timeout);
685
686
  }
687
+ async function cancelAgent(http, jobId) {
688
+ try {
689
+ const res = await http.delete(`/v2/agent/${jobId}`);
690
+ if (res.status !== 200) throwForBadResponse(res, "cancel agent");
691
+ return res.data?.success === true;
692
+ } catch (err) {
693
+ if (err?.isAxiosError) return normalizeAxiosError(err, "cancel agent");
694
+ throw err;
695
+ }
696
+ }
686
697
 
687
698
  // src/v2/methods/usage.ts
688
699
  async function getConcurrency(http) {
@@ -1169,6 +1180,14 @@ var FirecrawlClient = class {
1169
1180
  async agent(args) {
1170
1181
  return agent(this.http, args);
1171
1182
  }
1183
+ /**
1184
+ * Cancel an agent job.
1185
+ * @param jobId Agent job id.
1186
+ * @returns True if cancelled.
1187
+ */
1188
+ async cancelAgent(jobId) {
1189
+ return cancelAgent(this.http, jobId);
1190
+ }
1172
1191
  // Usage
1173
1192
  /** Current concurrency usage. */
1174
1193
  async getConcurrency() {
@@ -1239,7 +1258,7 @@ var FirecrawlApp = class {
1239
1258
  if (typeof process !== "undefined" && process.env && process.env.npm_package_version) {
1240
1259
  return process.env.npm_package_version;
1241
1260
  }
1242
- const packageJson = await import("./package-F4K5ZEVR.js");
1261
+ const packageJson = await import("./package-647PIJ6T.js");
1243
1262
  return packageJson.default.version;
1244
1263
  } catch (error) {
1245
1264
  const isTest = typeof process !== "undefined" && (process.env.JEST_WORKER_ID != null || false);
@@ -1,4 +1,4 @@
1
1
  import {
2
2
  require_package
3
- } from "./chunk-KS6E546Q.js";
3
+ } from "./chunk-NR7V4IEX.js";
4
4
  export default require_package();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mendable/firecrawl",
3
- "version": "4.9.0",
3
+ "version": "4.9.2",
4
4
  "description": "JavaScript SDK for Firecrawl API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/v2/client.ts CHANGED
@@ -19,7 +19,7 @@ import {
19
19
  batchScrape as batchWaiter,
20
20
  } from "./methods/batch";
21
21
  import { startExtract, getExtractStatus, extract as extractWaiter } from "./methods/extract";
22
- import { startAgent, getAgentStatus, agent as agentWaiter } from "./methods/agent";
22
+ import { startAgent, getAgentStatus, cancelAgent, agent as agentWaiter } from "./methods/agent";
23
23
  import { getConcurrency, getCreditUsage, getQueueStatus, getTokenUsage, getCreditUsageHistorical, getTokenUsageHistorical } from "./methods/usage";
24
24
  import type {
25
25
  Document,
@@ -289,6 +289,14 @@ export class FirecrawlClient {
289
289
  async agent(args: Parameters<typeof startAgent>[1] & { pollInterval?: number; timeout?: number }): Promise<AgentStatusResponse> {
290
290
  return agentWaiter(this.http, args);
291
291
  }
292
+ /**
293
+ * Cancel an agent job.
294
+ * @param jobId Agent job id.
295
+ * @returns True if cancelled.
296
+ */
297
+ async cancelAgent(jobId: string): Promise<boolean> {
298
+ return cancelAgent(this.http, jobId);
299
+ }
292
300
 
293
301
  // Usage
294
302
  /** Current concurrency usage. */
@@ -9,6 +9,7 @@ function prepareAgentPayload(args: {
9
9
  prompt: string;
10
10
  schema?: Record<string, unknown> | ZodTypeAny;
11
11
  integration?: string;
12
+ maxCredits?: number;
12
13
  }): Record<string, unknown> {
13
14
  const body: Record<string, unknown> = {};
14
15
  if (args.urls) body.urls = args.urls;
@@ -19,6 +20,7 @@ function prepareAgentPayload(args: {
19
20
  body.schema = isZod ? zodToJsonSchema(s) : args.schema;
20
21
  }
21
22
  if (args.integration && args.integration.trim()) body.integration = args.integration.trim();
23
+ if (args.maxCredits !== null && args.maxCredits !== undefined) body.maxCredits = args.maxCredits;
22
24
  return body;
23
25
  }
24
26
 
@@ -69,3 +71,14 @@ export async function agent(
69
71
  if (!jobId) return started as unknown as AgentStatusResponse;
70
72
  return waitAgent(http, jobId, args.pollInterval ?? 2, args.timeout);
71
73
  }
74
+
75
+ export async function cancelAgent(http: HttpClient, jobId: string): Promise<boolean> {
76
+ try {
77
+ const res = await http.delete<{ success: boolean }>(`/v2/agent/${jobId}`);
78
+ if (res.status !== 200) throwForBadResponse(res, "cancel agent");
79
+ return res.data?.success === true;
80
+ } catch (err: any) {
81
+ if (err?.isAxiosError) return normalizeAxiosError(err, "cancel agent");
82
+ throw err;
83
+ }
84
+ }