@mendable/firecrawl 4.11.1 → 4.11.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.
- package/dist/{chunk-SHZTLDEM.js → chunk-GVCNL5KA.js} +3 -3
- package/dist/index.cjs +5 -4
- package/dist/index.d.cts +9 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.js +4 -3
- package/dist/{package-LM7L2L66.js → package-LU5XQZAL.js} +1 -1
- package/package.json +8 -17
- package/src/__tests__/unit/v2/agent.test.ts +80 -0
- package/src/v2/methods/agent.ts +3 -1
- package/src/v2/types.ts +10 -0
|
@@ -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.11.
|
|
11
|
+
version: "4.11.2",
|
|
12
12
|
description: "JavaScript SDK for Firecrawl API",
|
|
13
13
|
main: "dist/index.js",
|
|
14
14
|
types: "dist/index.d.ts",
|
|
@@ -22,8 +22,8 @@ var require_package = __commonJS({
|
|
|
22
22
|
type: "module",
|
|
23
23
|
scripts: {
|
|
24
24
|
build: "tsup",
|
|
25
|
-
"build-and-publish": "
|
|
26
|
-
"publish-beta": "
|
|
25
|
+
"build-and-publish": "pnpm run build && pnpm publish --access public",
|
|
26
|
+
"publish-beta": "pnpm run build && pnpm publish --access public --tag beta",
|
|
27
27
|
test: "NODE_OPTIONS=--experimental-vm-modules jest --verbose src/__tests__/e2e/v2/*.test.ts --detectOpenHandles",
|
|
28
28
|
"test:unit": "NODE_OPTIONS=--experimental-vm-modules jest --verbose src/__tests__/unit/v2/*.test.ts"
|
|
29
29
|
},
|
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.11.
|
|
38
|
+
version: "4.11.2",
|
|
39
39
|
description: "JavaScript SDK for Firecrawl API",
|
|
40
40
|
main: "dist/index.js",
|
|
41
41
|
types: "dist/index.d.ts",
|
|
@@ -49,8 +49,8 @@ var require_package = __commonJS({
|
|
|
49
49
|
type: "module",
|
|
50
50
|
scripts: {
|
|
51
51
|
build: "tsup",
|
|
52
|
-
"build-and-publish": "
|
|
53
|
-
"publish-beta": "
|
|
52
|
+
"build-and-publish": "pnpm run build && pnpm publish --access public",
|
|
53
|
+
"publish-beta": "pnpm run build && pnpm publish --access public --tag beta",
|
|
54
54
|
test: "NODE_OPTIONS=--experimental-vm-modules jest --verbose src/__tests__/e2e/v2/*.test.ts --detectOpenHandles",
|
|
55
55
|
"test:unit": "NODE_OPTIONS=--experimental-vm-modules jest --verbose src/__tests__/unit/v2/*.test.ts"
|
|
56
56
|
},
|
|
@@ -855,6 +855,7 @@ function prepareAgentPayload(args) {
|
|
|
855
855
|
if (args.maxCredits !== null && args.maxCredits !== void 0) body.maxCredits = args.maxCredits;
|
|
856
856
|
if (args.strictConstrainToURLs !== null && args.strictConstrainToURLs !== void 0) body.strictConstrainToURLs = args.strictConstrainToURLs;
|
|
857
857
|
if (args.model !== null && args.model !== void 0) body.model = args.model;
|
|
858
|
+
if (args.webhook != null) body.webhook = args.webhook;
|
|
858
859
|
return body;
|
|
859
860
|
}
|
|
860
861
|
async function startAgent(http, args) {
|
|
@@ -1438,7 +1439,7 @@ var import_axios3 = __toESM(require("axios"), 1);
|
|
|
1438
1439
|
var zt2 = require("zod");
|
|
1439
1440
|
var import_zod_to_json_schema4 = require("zod-to-json-schema");
|
|
1440
1441
|
|
|
1441
|
-
// node_modules/typescript-event-target/dist/index.mjs
|
|
1442
|
+
// node_modules/.pnpm/typescript-event-target@1.1.1/node_modules/typescript-event-target/dist/index.mjs
|
|
1442
1443
|
var e = class extends EventTarget {
|
|
1443
1444
|
dispatchTypedEvent(s, t) {
|
|
1444
1445
|
return super.dispatchEvent(t);
|
package/dist/index.d.cts
CHANGED
|
@@ -122,6 +122,13 @@ interface WebhookConfig {
|
|
|
122
122
|
metadata?: Record<string, string>;
|
|
123
123
|
events?: Array<'completed' | 'failed' | 'page' | 'started'>;
|
|
124
124
|
}
|
|
125
|
+
type AgentWebhookEvent = 'started' | 'action' | 'completed' | 'failed' | 'cancelled';
|
|
126
|
+
interface AgentWebhookConfig {
|
|
127
|
+
url: string;
|
|
128
|
+
headers?: Record<string, string>;
|
|
129
|
+
metadata?: Record<string, string>;
|
|
130
|
+
events?: AgentWebhookEvent[];
|
|
131
|
+
}
|
|
125
132
|
interface BrandingProfile {
|
|
126
133
|
colorScheme?: 'light' | 'dark';
|
|
127
134
|
logo?: string | null;
|
|
@@ -594,6 +601,7 @@ declare function prepareAgentPayload(args: {
|
|
|
594
601
|
maxCredits?: number;
|
|
595
602
|
strictConstrainToURLs?: boolean;
|
|
596
603
|
model?: "spark-1-pro" | "spark-1-mini";
|
|
604
|
+
webhook?: string | AgentWebhookConfig;
|
|
597
605
|
}): Record<string, unknown>;
|
|
598
606
|
declare function startAgent(http: HttpClient, args: Parameters<typeof prepareAgentPayload>[0]): Promise<AgentResponse>;
|
|
599
607
|
|
|
@@ -1727,4 +1735,4 @@ declare class Firecrawl extends FirecrawlClient {
|
|
|
1727
1735
|
get v1(): FirecrawlApp;
|
|
1728
1736
|
}
|
|
1729
1737
|
|
|
1730
|
-
export { type ActionOption, type ActiveCrawl, type ActiveCrawlsResponse, type AgentOptions$1 as AgentOptions, type AgentResponse, type AgentStatusResponse, type AttributesFormat, type BatchScrapeJob, type BatchScrapeOptions, type BatchScrapeResponse$1 as BatchScrapeResponse, type BrandingProfile, type CategoryOption, type ChangeTrackingFormat, type ClickAction, type ConcurrencyCheck, type CrawlErrorsResponse$1 as CrawlErrorsResponse, type CrawlJob, type CrawlOptions, type CrawlResponse$1 as CrawlResponse, type CreditUsage, type CreditUsageHistoricalPeriod, type CreditUsageHistoricalResponse, type Document, type DocumentMetadata, type ErrorDetails, type ExecuteJavascriptAction, type ExtractResponse$1 as ExtractResponse, Firecrawl, FirecrawlApp as FirecrawlAppV1, FirecrawlClient, type FirecrawlClientOptions, type Format, type FormatOption, type FormatString, JobTimeoutError, type JsonFormat, type LocationConfig$1 as LocationConfig, type MapData, type MapOptions, type PDFAction, type PaginationConfig, type PressAction, type QueueStatusResponse$1 as QueueStatusResponse, type ScrapeAction, type ScrapeOptions, type ScreenshotAction, type ScreenshotFormat, type ScrollAction, SdkError, type SearchData, type SearchRequest, type SearchResultImages, type SearchResultNews, type SearchResultWeb, type TokenUsage, type TokenUsageHistoricalPeriod, type TokenUsageHistoricalResponse, type Viewport, type WaitAction, type WebhookConfig, type WriteAction, Firecrawl as default };
|
|
1738
|
+
export { type ActionOption, type ActiveCrawl, type ActiveCrawlsResponse, type AgentOptions$1 as AgentOptions, type AgentResponse, type AgentStatusResponse, type AgentWebhookConfig, type AgentWebhookEvent, type AttributesFormat, type BatchScrapeJob, type BatchScrapeOptions, type BatchScrapeResponse$1 as BatchScrapeResponse, type BrandingProfile, type CategoryOption, type ChangeTrackingFormat, type ClickAction, type ConcurrencyCheck, type CrawlErrorsResponse$1 as CrawlErrorsResponse, type CrawlJob, type CrawlOptions, type CrawlResponse$1 as CrawlResponse, type CreditUsage, type CreditUsageHistoricalPeriod, type CreditUsageHistoricalResponse, type Document, type DocumentMetadata, type ErrorDetails, type ExecuteJavascriptAction, type ExtractResponse$1 as ExtractResponse, Firecrawl, FirecrawlApp as FirecrawlAppV1, FirecrawlClient, type FirecrawlClientOptions, type Format, type FormatOption, type FormatString, JobTimeoutError, type JsonFormat, type LocationConfig$1 as LocationConfig, type MapData, type MapOptions, type PDFAction, type PaginationConfig, type PressAction, type QueueStatusResponse$1 as QueueStatusResponse, type ScrapeAction, type ScrapeOptions, type ScreenshotAction, type ScreenshotFormat, type ScrollAction, SdkError, type SearchData, type SearchRequest, type SearchResultImages, type SearchResultNews, type SearchResultWeb, type TokenUsage, type TokenUsageHistoricalPeriod, type TokenUsageHistoricalResponse, type Viewport, type WaitAction, type WebhookConfig, type WriteAction, Firecrawl as default };
|
package/dist/index.d.ts
CHANGED
|
@@ -122,6 +122,13 @@ interface WebhookConfig {
|
|
|
122
122
|
metadata?: Record<string, string>;
|
|
123
123
|
events?: Array<'completed' | 'failed' | 'page' | 'started'>;
|
|
124
124
|
}
|
|
125
|
+
type AgentWebhookEvent = 'started' | 'action' | 'completed' | 'failed' | 'cancelled';
|
|
126
|
+
interface AgentWebhookConfig {
|
|
127
|
+
url: string;
|
|
128
|
+
headers?: Record<string, string>;
|
|
129
|
+
metadata?: Record<string, string>;
|
|
130
|
+
events?: AgentWebhookEvent[];
|
|
131
|
+
}
|
|
125
132
|
interface BrandingProfile {
|
|
126
133
|
colorScheme?: 'light' | 'dark';
|
|
127
134
|
logo?: string | null;
|
|
@@ -594,6 +601,7 @@ declare function prepareAgentPayload(args: {
|
|
|
594
601
|
maxCredits?: number;
|
|
595
602
|
strictConstrainToURLs?: boolean;
|
|
596
603
|
model?: "spark-1-pro" | "spark-1-mini";
|
|
604
|
+
webhook?: string | AgentWebhookConfig;
|
|
597
605
|
}): Record<string, unknown>;
|
|
598
606
|
declare function startAgent(http: HttpClient, args: Parameters<typeof prepareAgentPayload>[0]): Promise<AgentResponse>;
|
|
599
607
|
|
|
@@ -1727,4 +1735,4 @@ declare class Firecrawl extends FirecrawlClient {
|
|
|
1727
1735
|
get v1(): FirecrawlApp;
|
|
1728
1736
|
}
|
|
1729
1737
|
|
|
1730
|
-
export { type ActionOption, type ActiveCrawl, type ActiveCrawlsResponse, type AgentOptions$1 as AgentOptions, type AgentResponse, type AgentStatusResponse, type AttributesFormat, type BatchScrapeJob, type BatchScrapeOptions, type BatchScrapeResponse$1 as BatchScrapeResponse, type BrandingProfile, type CategoryOption, type ChangeTrackingFormat, type ClickAction, type ConcurrencyCheck, type CrawlErrorsResponse$1 as CrawlErrorsResponse, type CrawlJob, type CrawlOptions, type CrawlResponse$1 as CrawlResponse, type CreditUsage, type CreditUsageHistoricalPeriod, type CreditUsageHistoricalResponse, type Document, type DocumentMetadata, type ErrorDetails, type ExecuteJavascriptAction, type ExtractResponse$1 as ExtractResponse, Firecrawl, FirecrawlApp as FirecrawlAppV1, FirecrawlClient, type FirecrawlClientOptions, type Format, type FormatOption, type FormatString, JobTimeoutError, type JsonFormat, type LocationConfig$1 as LocationConfig, type MapData, type MapOptions, type PDFAction, type PaginationConfig, type PressAction, type QueueStatusResponse$1 as QueueStatusResponse, type ScrapeAction, type ScrapeOptions, type ScreenshotAction, type ScreenshotFormat, type ScrollAction, SdkError, type SearchData, type SearchRequest, type SearchResultImages, type SearchResultNews, type SearchResultWeb, type TokenUsage, type TokenUsageHistoricalPeriod, type TokenUsageHistoricalResponse, type Viewport, type WaitAction, type WebhookConfig, type WriteAction, Firecrawl as default };
|
|
1738
|
+
export { type ActionOption, type ActiveCrawl, type ActiveCrawlsResponse, type AgentOptions$1 as AgentOptions, type AgentResponse, type AgentStatusResponse, type AgentWebhookConfig, type AgentWebhookEvent, type AttributesFormat, type BatchScrapeJob, type BatchScrapeOptions, type BatchScrapeResponse$1 as BatchScrapeResponse, type BrandingProfile, type CategoryOption, type ChangeTrackingFormat, type ClickAction, type ConcurrencyCheck, type CrawlErrorsResponse$1 as CrawlErrorsResponse, type CrawlJob, type CrawlOptions, type CrawlResponse$1 as CrawlResponse, type CreditUsage, type CreditUsageHistoricalPeriod, type CreditUsageHistoricalResponse, type Document, type DocumentMetadata, type ErrorDetails, type ExecuteJavascriptAction, type ExtractResponse$1 as ExtractResponse, Firecrawl, FirecrawlApp as FirecrawlAppV1, FirecrawlClient, type FirecrawlClientOptions, type Format, type FormatOption, type FormatString, JobTimeoutError, type JsonFormat, type LocationConfig$1 as LocationConfig, type MapData, type MapOptions, type PDFAction, type PaginationConfig, type PressAction, type QueueStatusResponse$1 as QueueStatusResponse, type ScrapeAction, type ScrapeOptions, type ScreenshotAction, type ScreenshotFormat, type ScrollAction, SdkError, type SearchData, type SearchRequest, type SearchResultImages, type SearchResultNews, type SearchResultWeb, type TokenUsage, type TokenUsageHistoricalPeriod, type TokenUsageHistoricalResponse, type Viewport, type WaitAction, type WebhookConfig, type WriteAction, Firecrawl as default };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
require_package
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-GVCNL5KA.js";
|
|
4
4
|
|
|
5
5
|
// src/v2/utils/httpClient.ts
|
|
6
6
|
import axios from "axios";
|
|
@@ -736,6 +736,7 @@ function prepareAgentPayload(args) {
|
|
|
736
736
|
if (args.maxCredits !== null && args.maxCredits !== void 0) body.maxCredits = args.maxCredits;
|
|
737
737
|
if (args.strictConstrainToURLs !== null && args.strictConstrainToURLs !== void 0) body.strictConstrainToURLs = args.strictConstrainToURLs;
|
|
738
738
|
if (args.model !== null && args.model !== void 0) body.model = args.model;
|
|
739
|
+
if (args.webhook != null) body.webhook = args.webhook;
|
|
739
740
|
return body;
|
|
740
741
|
}
|
|
741
742
|
async function startAgent(http, args) {
|
|
@@ -1319,7 +1320,7 @@ import axios2, { AxiosError } from "axios";
|
|
|
1319
1320
|
import "zod";
|
|
1320
1321
|
import { zodToJsonSchema as zodToJsonSchema4 } from "zod-to-json-schema";
|
|
1321
1322
|
|
|
1322
|
-
// node_modules/typescript-event-target/dist/index.mjs
|
|
1323
|
+
// node_modules/.pnpm/typescript-event-target@1.1.1/node_modules/typescript-event-target/dist/index.mjs
|
|
1323
1324
|
var e = class extends EventTarget {
|
|
1324
1325
|
dispatchTypedEvent(s, t) {
|
|
1325
1326
|
return super.dispatchEvent(t);
|
|
@@ -1348,7 +1349,7 @@ var FirecrawlApp = class {
|
|
|
1348
1349
|
if (typeof process !== "undefined" && process.env && process.env.npm_package_version) {
|
|
1349
1350
|
return process.env.npm_package_version;
|
|
1350
1351
|
}
|
|
1351
|
-
const packageJson = await import("./package-
|
|
1352
|
+
const packageJson = await import("./package-LU5XQZAL.js");
|
|
1352
1353
|
return packageJson.default.version;
|
|
1353
1354
|
} catch (error) {
|
|
1354
1355
|
const isTest = typeof process !== "undefined" && (process.env.JEST_WORKER_ID != null || false);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mendable/firecrawl",
|
|
3
|
-
"version": "4.11.
|
|
3
|
+
"version": "4.11.2",
|
|
4
4
|
"description": "JavaScript SDK for Firecrawl API",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -12,13 +12,6 @@
|
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
14
|
"type": "module",
|
|
15
|
-
"scripts": {
|
|
16
|
-
"build": "tsup",
|
|
17
|
-
"build-and-publish": "npm run build && npm publish --access public",
|
|
18
|
-
"publish-beta": "npm run build && npm publish --access public --tag beta",
|
|
19
|
-
"test": "NODE_OPTIONS=--experimental-vm-modules jest --verbose src/__tests__/e2e/v2/*.test.ts --detectOpenHandles",
|
|
20
|
-
"test:unit": "NODE_OPTIONS=--experimental-vm-modules jest --verbose src/__tests__/unit/v2/*.test.ts"
|
|
21
|
-
},
|
|
22
15
|
"repository": {
|
|
23
16
|
"type": "git",
|
|
24
17
|
"url": "git+https://github.com/firecrawl/firecrawl.git"
|
|
@@ -61,13 +54,11 @@
|
|
|
61
54
|
"engines": {
|
|
62
55
|
"node": ">=22.0.0"
|
|
63
56
|
},
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
"glob@>=10.2.0 <10.5.0": ">=10.5.0"
|
|
71
|
-
}
|
|
57
|
+
"scripts": {
|
|
58
|
+
"build": "tsup",
|
|
59
|
+
"build-and-publish": "pnpm run build && pnpm publish --access public",
|
|
60
|
+
"publish-beta": "pnpm run build && pnpm publish --access public --tag beta",
|
|
61
|
+
"test": "NODE_OPTIONS=--experimental-vm-modules jest --verbose src/__tests__/e2e/v2/*.test.ts --detectOpenHandles",
|
|
62
|
+
"test:unit": "NODE_OPTIONS=--experimental-vm-modules jest --verbose src/__tests__/unit/v2/*.test.ts"
|
|
72
63
|
}
|
|
73
|
-
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { describe, test, expect } from "@jest/globals";
|
|
2
|
+
|
|
3
|
+
// We need to test the prepareAgentPayload function, but it's not exported.
|
|
4
|
+
// Since the function is internal, we'll test the behavior through type checking
|
|
5
|
+
// and verify the types are properly exported.
|
|
6
|
+
|
|
7
|
+
import type { AgentWebhookConfig, AgentWebhookEvent } from "../../../v2/types";
|
|
8
|
+
|
|
9
|
+
describe("v2 types: Agent webhook types", () => {
|
|
10
|
+
test("AgentWebhookConfig accepts string webhook", () => {
|
|
11
|
+
// Type check - this should compile without errors
|
|
12
|
+
const webhook: string | AgentWebhookConfig = "https://example.com/webhook";
|
|
13
|
+
expect(typeof webhook).toBe("string");
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
test("AgentWebhookConfig accepts config object", () => {
|
|
17
|
+
const config: AgentWebhookConfig = {
|
|
18
|
+
url: "https://example.com/webhook",
|
|
19
|
+
headers: { Authorization: "Bearer token" },
|
|
20
|
+
events: ["completed", "failed"],
|
|
21
|
+
};
|
|
22
|
+
expect(config.url).toBe("https://example.com/webhook");
|
|
23
|
+
expect(config.headers).toEqual({ Authorization: "Bearer token" });
|
|
24
|
+
expect(config.events).toEqual(["completed", "failed"]);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
test("AgentWebhookConfig accepts minimal config", () => {
|
|
28
|
+
const config: AgentWebhookConfig = {
|
|
29
|
+
url: "https://example.com/webhook",
|
|
30
|
+
};
|
|
31
|
+
expect(config.url).toBe("https://example.com/webhook");
|
|
32
|
+
expect(config.headers).toBeUndefined();
|
|
33
|
+
expect(config.metadata).toBeUndefined();
|
|
34
|
+
expect(config.events).toBeUndefined();
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
test("AgentWebhookEvent includes agent-specific events", () => {
|
|
38
|
+
const events: AgentWebhookEvent[] = [
|
|
39
|
+
"started",
|
|
40
|
+
"action",
|
|
41
|
+
"completed",
|
|
42
|
+
"failed",
|
|
43
|
+
"cancelled",
|
|
44
|
+
];
|
|
45
|
+
expect(events).toContain("action");
|
|
46
|
+
expect(events).toContain("cancelled");
|
|
47
|
+
expect(events.length).toBe(5);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
test("AgentWebhookConfig accepts all fields", () => {
|
|
51
|
+
const config: AgentWebhookConfig = {
|
|
52
|
+
url: "https://example.com/webhook",
|
|
53
|
+
headers: {
|
|
54
|
+
Authorization: "Bearer token",
|
|
55
|
+
"X-Custom-Header": "value",
|
|
56
|
+
},
|
|
57
|
+
metadata: {
|
|
58
|
+
project: "test",
|
|
59
|
+
environment: "staging",
|
|
60
|
+
},
|
|
61
|
+
events: ["started", "action", "completed", "failed", "cancelled"],
|
|
62
|
+
};
|
|
63
|
+
expect(config.url).toBe("https://example.com/webhook");
|
|
64
|
+
expect(Object.keys(config.headers!).length).toBe(2);
|
|
65
|
+
expect(config.metadata!.project).toBe("test");
|
|
66
|
+
expect(config.events!.length).toBe(5);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
test("AgentWebhookConfig events are agent-specific (not crawl)", () => {
|
|
70
|
+
// Agent has 'action' and 'cancelled', but not 'page'
|
|
71
|
+
const config: AgentWebhookConfig = {
|
|
72
|
+
url: "https://example.com/webhook",
|
|
73
|
+
events: ["action", "cancelled"],
|
|
74
|
+
};
|
|
75
|
+
expect(config.events).toContain("action");
|
|
76
|
+
expect(config.events).toContain("cancelled");
|
|
77
|
+
// 'page' is a crawl-specific event, not valid for agent
|
|
78
|
+
// This is enforced at the type level
|
|
79
|
+
});
|
|
80
|
+
});
|
package/src/v2/methods/agent.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type AgentResponse, type AgentStatusResponse } from "../types";
|
|
1
|
+
import { type AgentResponse, type AgentStatusResponse, type AgentWebhookConfig } from "../types";
|
|
2
2
|
import { HttpClient } from "../utils/httpClient";
|
|
3
3
|
import { normalizeAxiosError, throwForBadResponse } from "../utils/errorHandler";
|
|
4
4
|
import { zodToJsonSchema } from "zod-to-json-schema";
|
|
@@ -12,6 +12,7 @@ function prepareAgentPayload(args: {
|
|
|
12
12
|
maxCredits?: number;
|
|
13
13
|
strictConstrainToURLs?: boolean;
|
|
14
14
|
model?: "spark-1-pro" | "spark-1-mini";
|
|
15
|
+
webhook?: string | AgentWebhookConfig;
|
|
15
16
|
}): Record<string, unknown> {
|
|
16
17
|
const body: Record<string, unknown> = {};
|
|
17
18
|
if (args.urls) body.urls = args.urls;
|
|
@@ -25,6 +26,7 @@ function prepareAgentPayload(args: {
|
|
|
25
26
|
if (args.maxCredits !== null && args.maxCredits !== undefined) body.maxCredits = args.maxCredits;
|
|
26
27
|
if (args.strictConstrainToURLs !== null && args.strictConstrainToURLs !== undefined) body.strictConstrainToURLs = args.strictConstrainToURLs;
|
|
27
28
|
if (args.model !== null && args.model !== undefined) body.model = args.model;
|
|
29
|
+
if (args.webhook != null) body.webhook = args.webhook;
|
|
28
30
|
return body;
|
|
29
31
|
}
|
|
30
32
|
|
package/src/v2/types.ts
CHANGED
|
@@ -167,6 +167,16 @@ export interface WebhookConfig {
|
|
|
167
167
|
events?: Array<'completed' | 'failed' | 'page' | 'started'>;
|
|
168
168
|
}
|
|
169
169
|
|
|
170
|
+
// Agent webhook events differ from crawl: has 'action' and 'cancelled', no 'page'
|
|
171
|
+
export type AgentWebhookEvent = 'started' | 'action' | 'completed' | 'failed' | 'cancelled';
|
|
172
|
+
|
|
173
|
+
export interface AgentWebhookConfig {
|
|
174
|
+
url: string;
|
|
175
|
+
headers?: Record<string, string>;
|
|
176
|
+
metadata?: Record<string, string>;
|
|
177
|
+
events?: AgentWebhookEvent[];
|
|
178
|
+
}
|
|
179
|
+
|
|
170
180
|
export interface BrandingProfile {
|
|
171
181
|
colorScheme?: 'light' | 'dark';
|
|
172
182
|
logo?: string | null;
|