@mastra/browser-firecrawl 0.2.0 → 0.2.1-alpha.0
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/CHANGELOG.md +10 -0
- package/dist/index.cjs +231 -247
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +62 -58
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.ts +62 -58
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +228 -243
- package/dist/index.js.map +1 -1
- package/package.json +16 -15
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { BrowserManager } from
|
|
3
|
-
import { Firecrawl } from
|
|
4
|
-
|
|
1
|
+
import { AgentBrowser, AgentBrowserConfig, AgentBrowserSession, AgentBrowserThreadManager, AgentBrowserThreadManagerConfig } from "@mastra/agent-browser";
|
|
2
|
+
import { BrowserManager } from "agent-browser";
|
|
3
|
+
import { Firecrawl } from "firecrawl";
|
|
4
|
+
//#region src/types.d.ts
|
|
5
5
|
/**
|
|
6
6
|
* Options passed to Firecrawl `POST /v2/browser` (see Firecrawl JS SDK `browser()`).
|
|
7
7
|
*
|
|
@@ -10,85 +10,89 @@ import { Firecrawl } from 'firecrawl';
|
|
|
10
10
|
* hosted browser API only—different meaning, same nested key name as required by the SDK.
|
|
11
11
|
*/
|
|
12
12
|
interface FirecrawlBrowserSessionOptions {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
13
|
+
/** Max session wall-clock lifetime (seconds, Firecrawl API). */
|
|
14
|
+
ttl?: number;
|
|
15
|
+
/** Idle timeout before the sandbox recycles the session (seconds, Firecrawl API). */
|
|
16
|
+
activityTtl?: number;
|
|
17
|
+
/** When true, Firecrawl may stream WebView frames for the remote session. */
|
|
18
|
+
streamWebView?: boolean;
|
|
19
|
+
/** Firecrawl named profile (not the same as top-level `AgentBrowserConfig.profile`). */
|
|
20
|
+
profile?: {
|
|
21
|
+
/** Saved profile name in Firecrawl. */
|
|
22
|
+
name: string;
|
|
23
|
+
/** Persist profile changes when the session ends. */
|
|
24
|
+
saveChanges?: boolean;
|
|
25
|
+
};
|
|
26
|
+
/** Optional integration label for Firecrawl analytics / routing. */
|
|
27
|
+
integration?: string;
|
|
28
|
+
/** Optional origin hint for the Firecrawl browser session. */
|
|
29
|
+
origin?: string;
|
|
30
30
|
}
|
|
31
31
|
/** Configuration for {@link FirecrawlBrowser}. */
|
|
32
32
|
type FirecrawlBrowserConfig = AgentBrowserConfig & {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
33
|
+
/** Firecrawl API key (or set `FIRECRAWL_API_KEY` in the environment and omit). */
|
|
34
|
+
apiKey?: string;
|
|
35
|
+
/** Base URL for a self-hosted Firecrawl API. */
|
|
36
|
+
apiUrl?: string;
|
|
37
|
+
/**
|
|
38
|
+
* Firecrawl-only session options (`browser()`). Distinct from {@link AgentBrowserConfig.profile}
|
|
39
|
+
* (local Playwright profile path): see {@link FirecrawlBrowserSessionOptions.profile}.
|
|
40
|
+
*/
|
|
41
|
+
firecrawl?: FirecrawlBrowserSessionOptions;
|
|
42
42
|
};
|
|
43
|
-
|
|
43
|
+
//#endregion
|
|
44
|
+
//#region src/firecrawl-browser.d.ts
|
|
44
45
|
/**
|
|
45
46
|
* Mastra browser provider backed by [Firecrawl Browser Sandbox](https://docs.firecrawl.dev/features/browser):
|
|
46
47
|
* provisions remote sessions via API and drives them with the same deterministic tools as {@link AgentBrowser}.
|
|
47
48
|
*/
|
|
48
49
|
declare class FirecrawlBrowser extends AgentBrowser {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
50
|
+
readonly name = "FirecrawlBrowser";
|
|
51
|
+
readonly provider = "firecrawl/browser-sandbox";
|
|
52
|
+
/** Narrowed from base `MastraBrowser` (`unknown`) — same pattern as {@link AgentBrowser}. */
|
|
53
|
+
protected sharedManager: BrowserManager | null;
|
|
54
|
+
private readonly firecrawl;
|
|
55
|
+
private readonly sessionOpts;
|
|
56
|
+
private sharedFirecrawlSessionId?;
|
|
57
|
+
constructor(config: FirecrawlBrowserConfig);
|
|
58
|
+
protected doLaunch(): Promise<void>;
|
|
59
|
+
protected doClose(): Promise<void>;
|
|
59
60
|
}
|
|
60
|
-
|
|
61
|
+
//#endregion
|
|
62
|
+
//#region src/firecrawl-thread-manager.d.ts
|
|
61
63
|
/**
|
|
62
64
|
* Thread session with Firecrawl sandbox id for cleanup.
|
|
63
65
|
*/
|
|
64
66
|
interface FirecrawlAgentBrowserSession extends AgentBrowserSession {
|
|
65
|
-
|
|
67
|
+
firecrawlSessionId?: string;
|
|
66
68
|
}
|
|
67
69
|
interface FirecrawlAgentBrowserThreadManagerConfig extends AgentBrowserThreadManagerConfig {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
70
|
+
firecrawl: Firecrawl;
|
|
71
|
+
/** Resolve HTTP CDP URL to WebSocket URL. */
|
|
72
|
+
resolveWebSocketUrl: (url: string) => Promise<string>;
|
|
73
|
+
/** Options for each `firecrawl.browser()` call (thread scope = one call per thread). */
|
|
74
|
+
sessionOptions?: FirecrawlBrowserSessionOptions;
|
|
73
75
|
}
|
|
74
76
|
/**
|
|
75
77
|
* Provisions a dedicated Firecrawl Browser Sandbox session per Mastra thread and connects Playwright over CDP.
|
|
76
78
|
*/
|
|
77
79
|
declare class FirecrawlAgentBrowserThreadManager extends AgentBrowserThreadManager {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
80
|
+
private readonly firecrawl;
|
|
81
|
+
private readonly resolveWebSocketUrl;
|
|
82
|
+
private readonly sessionOptions;
|
|
83
|
+
constructor(config: FirecrawlAgentBrowserThreadManagerConfig);
|
|
84
|
+
protected createSession(threadId: string): Promise<FirecrawlAgentBrowserSession>;
|
|
85
|
+
protected doDestroySession(session: FirecrawlAgentBrowserSession): Promise<void>;
|
|
84
86
|
}
|
|
85
|
-
|
|
87
|
+
//#endregion
|
|
88
|
+
//#region src/resolve-cdp.d.ts
|
|
86
89
|
/**
|
|
87
90
|
* Resolve an HTTP CDP endpoint to a WebSocket URL (same behavior as MastraBrowser.resolveWebSocketUrl).
|
|
88
91
|
*/
|
|
89
92
|
declare function resolveCdpWebSocketUrl(url: string, logger?: {
|
|
90
|
-
|
|
91
|
-
|
|
93
|
+
debug?: (message: string) => void;
|
|
94
|
+
warn?: (message: string) => void;
|
|
92
95
|
}): Promise<string>;
|
|
93
|
-
|
|
96
|
+
//#endregion
|
|
94
97
|
export { type FirecrawlAgentBrowserSession, FirecrawlAgentBrowserThreadManager, type FirecrawlAgentBrowserThreadManagerConfig, FirecrawlBrowser, type FirecrawlBrowserConfig, type FirecrawlBrowserSessionOptions, resolveCdpWebSocketUrl };
|
|
98
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/types.ts","../src/firecrawl-browser.ts","../src/firecrawl-thread-manager.ts","../src/resolve-cdp.ts"],"mappings":";;;;;;;;;;;UASiB;;EAEf;;EAEA;;EAEA;;EAEA;;IAEE;;IAEA;;;EAGF;;EAEA;;;KAIU,yBAAyB;;EAEnC;;EAEA;;;;;EAKA,YAAY;;;;;;;;cChBD,yBAAyB;WAClB;WACA;;YAGA,eAAe;mBAEhB;mBACA;UACT;EAEI,YAAA,QAAQ;YAsBK,YAAY;YAoEZ,WAAW;;;;;;;UCjHrB,qCAAqC;EACpD;;UAGe,iDAAiD;EAChE,WAAW;;EAEX,sBAAsB,gBAAgB;;EAEtC,iBAAiB;;;;;cAMN,2CAA2C;mBACrC;mBACA;mBACA;EAEL,YAAA,QAAQ;YAOK,cAAc,mBAAmB,QAAQ;YA8FzC,iBAAiB,SAAS,+BAA+B;;;;;;;iBCjI9D,uBACpB,aACA;EAAW,SAAS;EAA0B,QAAQ;IACrD"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { BrowserManager } from
|
|
3
|
-
import { Firecrawl } from
|
|
4
|
-
|
|
1
|
+
import { AgentBrowser, AgentBrowserConfig, AgentBrowserSession, AgentBrowserThreadManager, AgentBrowserThreadManagerConfig } from "@mastra/agent-browser";
|
|
2
|
+
import { BrowserManager } from "agent-browser";
|
|
3
|
+
import { Firecrawl } from "firecrawl";
|
|
4
|
+
//#region src/types.d.ts
|
|
5
5
|
/**
|
|
6
6
|
* Options passed to Firecrawl `POST /v2/browser` (see Firecrawl JS SDK `browser()`).
|
|
7
7
|
*
|
|
@@ -10,85 +10,89 @@ import { Firecrawl } from 'firecrawl';
|
|
|
10
10
|
* hosted browser API only—different meaning, same nested key name as required by the SDK.
|
|
11
11
|
*/
|
|
12
12
|
interface FirecrawlBrowserSessionOptions {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
13
|
+
/** Max session wall-clock lifetime (seconds, Firecrawl API). */
|
|
14
|
+
ttl?: number;
|
|
15
|
+
/** Idle timeout before the sandbox recycles the session (seconds, Firecrawl API). */
|
|
16
|
+
activityTtl?: number;
|
|
17
|
+
/** When true, Firecrawl may stream WebView frames for the remote session. */
|
|
18
|
+
streamWebView?: boolean;
|
|
19
|
+
/** Firecrawl named profile (not the same as top-level `AgentBrowserConfig.profile`). */
|
|
20
|
+
profile?: {
|
|
21
|
+
/** Saved profile name in Firecrawl. */
|
|
22
|
+
name: string;
|
|
23
|
+
/** Persist profile changes when the session ends. */
|
|
24
|
+
saveChanges?: boolean;
|
|
25
|
+
};
|
|
26
|
+
/** Optional integration label for Firecrawl analytics / routing. */
|
|
27
|
+
integration?: string;
|
|
28
|
+
/** Optional origin hint for the Firecrawl browser session. */
|
|
29
|
+
origin?: string;
|
|
30
30
|
}
|
|
31
31
|
/** Configuration for {@link FirecrawlBrowser}. */
|
|
32
32
|
type FirecrawlBrowserConfig = AgentBrowserConfig & {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
33
|
+
/** Firecrawl API key (or set `FIRECRAWL_API_KEY` in the environment and omit). */
|
|
34
|
+
apiKey?: string;
|
|
35
|
+
/** Base URL for a self-hosted Firecrawl API. */
|
|
36
|
+
apiUrl?: string;
|
|
37
|
+
/**
|
|
38
|
+
* Firecrawl-only session options (`browser()`). Distinct from {@link AgentBrowserConfig.profile}
|
|
39
|
+
* (local Playwright profile path): see {@link FirecrawlBrowserSessionOptions.profile}.
|
|
40
|
+
*/
|
|
41
|
+
firecrawl?: FirecrawlBrowserSessionOptions;
|
|
42
42
|
};
|
|
43
|
-
|
|
43
|
+
//#endregion
|
|
44
|
+
//#region src/firecrawl-browser.d.ts
|
|
44
45
|
/**
|
|
45
46
|
* Mastra browser provider backed by [Firecrawl Browser Sandbox](https://docs.firecrawl.dev/features/browser):
|
|
46
47
|
* provisions remote sessions via API and drives them with the same deterministic tools as {@link AgentBrowser}.
|
|
47
48
|
*/
|
|
48
49
|
declare class FirecrawlBrowser extends AgentBrowser {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
50
|
+
readonly name = "FirecrawlBrowser";
|
|
51
|
+
readonly provider = "firecrawl/browser-sandbox";
|
|
52
|
+
/** Narrowed from base `MastraBrowser` (`unknown`) — same pattern as {@link AgentBrowser}. */
|
|
53
|
+
protected sharedManager: BrowserManager | null;
|
|
54
|
+
private readonly firecrawl;
|
|
55
|
+
private readonly sessionOpts;
|
|
56
|
+
private sharedFirecrawlSessionId?;
|
|
57
|
+
constructor(config: FirecrawlBrowserConfig);
|
|
58
|
+
protected doLaunch(): Promise<void>;
|
|
59
|
+
protected doClose(): Promise<void>;
|
|
59
60
|
}
|
|
60
|
-
|
|
61
|
+
//#endregion
|
|
62
|
+
//#region src/firecrawl-thread-manager.d.ts
|
|
61
63
|
/**
|
|
62
64
|
* Thread session with Firecrawl sandbox id for cleanup.
|
|
63
65
|
*/
|
|
64
66
|
interface FirecrawlAgentBrowserSession extends AgentBrowserSession {
|
|
65
|
-
|
|
67
|
+
firecrawlSessionId?: string;
|
|
66
68
|
}
|
|
67
69
|
interface FirecrawlAgentBrowserThreadManagerConfig extends AgentBrowserThreadManagerConfig {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
70
|
+
firecrawl: Firecrawl;
|
|
71
|
+
/** Resolve HTTP CDP URL to WebSocket URL. */
|
|
72
|
+
resolveWebSocketUrl: (url: string) => Promise<string>;
|
|
73
|
+
/** Options for each `firecrawl.browser()` call (thread scope = one call per thread). */
|
|
74
|
+
sessionOptions?: FirecrawlBrowserSessionOptions;
|
|
73
75
|
}
|
|
74
76
|
/**
|
|
75
77
|
* Provisions a dedicated Firecrawl Browser Sandbox session per Mastra thread and connects Playwright over CDP.
|
|
76
78
|
*/
|
|
77
79
|
declare class FirecrawlAgentBrowserThreadManager extends AgentBrowserThreadManager {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
80
|
+
private readonly firecrawl;
|
|
81
|
+
private readonly resolveWebSocketUrl;
|
|
82
|
+
private readonly sessionOptions;
|
|
83
|
+
constructor(config: FirecrawlAgentBrowserThreadManagerConfig);
|
|
84
|
+
protected createSession(threadId: string): Promise<FirecrawlAgentBrowserSession>;
|
|
85
|
+
protected doDestroySession(session: FirecrawlAgentBrowserSession): Promise<void>;
|
|
84
86
|
}
|
|
85
|
-
|
|
87
|
+
//#endregion
|
|
88
|
+
//#region src/resolve-cdp.d.ts
|
|
86
89
|
/**
|
|
87
90
|
* Resolve an HTTP CDP endpoint to a WebSocket URL (same behavior as MastraBrowser.resolveWebSocketUrl).
|
|
88
91
|
*/
|
|
89
92
|
declare function resolveCdpWebSocketUrl(url: string, logger?: {
|
|
90
|
-
|
|
91
|
-
|
|
93
|
+
debug?: (message: string) => void;
|
|
94
|
+
warn?: (message: string) => void;
|
|
92
95
|
}): Promise<string>;
|
|
93
|
-
|
|
96
|
+
//#endregion
|
|
94
97
|
export { type FirecrawlAgentBrowserSession, FirecrawlAgentBrowserThreadManager, type FirecrawlAgentBrowserThreadManagerConfig, FirecrawlBrowser, type FirecrawlBrowserConfig, type FirecrawlBrowserSessionOptions, resolveCdpWebSocketUrl };
|
|
98
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/types.ts","../src/firecrawl-browser.ts","../src/firecrawl-thread-manager.ts","../src/resolve-cdp.ts"],"mappings":";;;;;;;;;;;UASiB;;EAEf;;EAEA;;EAEA;;EAEA;;IAEE;;IAEA;;;EAGF;;EAEA;;;KAIU,yBAAyB;;EAEnC;;EAEA;;;;;EAKA,YAAY;;;;;;;;cChBD,yBAAyB;WAClB;WACA;;YAGA,eAAe;mBAEhB;mBACA;UACT;EAEI,YAAA,QAAQ;YAsBK,YAAY;YAoEZ,WAAW;;;;;;;UCjHrB,qCAAqC;EACpD;;UAGe,iDAAiD;EAChE,WAAW;;EAEX,sBAAsB,gBAAgB;;EAEtC,iBAAiB;;;;;cAMN,2CAA2C;mBACrC;mBACA;mBACA;EAEL,YAAA,QAAQ;YAOK,cAAc,mBAAmB,QAAQ;YA8FzC,iBAAiB,SAAS,+BAA+B;;;;;;;iBCjI9D,uBACpB,aACA;EAAW,SAAS;EAA0B,QAAQ;IACrD"}
|