@crawlee/stagehand 4.0.0-beta.225 → 4.0.0-beta.227
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/index.d.ts +5 -5
- package/index.js +5 -5
- package/internals/stagehand-browser-pool.d.ts +3 -3
- package/internals/stagehand-browser-pool.js +2 -2
- package/internals/stagehand-controller.d.ts +1 -1
- package/internals/stagehand-crawler.d.ts +1 -1
- package/internals/stagehand-crawler.js +4 -4
- package/internals/stagehand-launcher.d.ts +2 -2
- package/internals/stagehand-launcher.js +3 -3
- package/internals/stagehand-plugin.d.ts +1 -1
- package/internals/stagehand-plugin.js +2 -2
- package/internals/utils/stagehand-utils.d.ts +1 -1
- package/package.json +7 -7
package/index.d.ts
CHANGED
|
@@ -50,9 +50,9 @@
|
|
|
50
50
|
* @module @crawlee/stagehand
|
|
51
51
|
*/
|
|
52
52
|
export * from '@crawlee/browser';
|
|
53
|
-
export { StagehandCrawler, createStagehandRouter } from './internals/stagehand-crawler';
|
|
54
|
-
export { stagehandBrowserPool } from './internals/stagehand-browser-pool';
|
|
55
|
-
export type { StagehandBrowserPool, StagehandBrowserPoolOptions } from './internals/stagehand-browser-pool';
|
|
56
|
-
export type { StagehandOptions, StagehandPage, StagehandCrawlingContext, StagehandHook, StagehandGotoOptions, StagehandCrawlerOptions, } from './internals/stagehand-crawler';
|
|
57
|
-
export type { StagehandLaunchContext } from './internals/stagehand-launcher';
|
|
53
|
+
export { StagehandCrawler, createStagehandRouter } from './internals/stagehand-crawler.js';
|
|
54
|
+
export { stagehandBrowserPool } from './internals/stagehand-browser-pool.js';
|
|
55
|
+
export type { StagehandBrowserPool, StagehandBrowserPoolOptions } from './internals/stagehand-browser-pool.js';
|
|
56
|
+
export type { StagehandOptions, StagehandPage, StagehandCrawlingContext, StagehandHook, StagehandGotoOptions, StagehandCrawlerOptions, } from './internals/stagehand-crawler.js';
|
|
57
|
+
export type { StagehandLaunchContext } from './internals/stagehand-launcher.js';
|
|
58
58
|
export type { ActOptions, ActResult, Action, AgentConfig, ExtractOptions, ModelConfiguration, ObserveOptions, Stagehand, } from '@browserbasehq/stagehand';
|
package/index.js
CHANGED
|
@@ -56,9 +56,9 @@ const tslib_1 = require("tslib");
|
|
|
56
56
|
// Re-export everything from @crawlee/browser for convenience
|
|
57
57
|
tslib_1.__exportStar(require("@crawlee/browser"), exports);
|
|
58
58
|
// Export main crawler class
|
|
59
|
-
var
|
|
60
|
-
Object.defineProperty(exports, "StagehandCrawler", { enumerable: true, get: function () { return
|
|
61
|
-
Object.defineProperty(exports, "createStagehandRouter", { enumerable: true, get: function () { return
|
|
59
|
+
var stagehand_crawler_js_1 = require("./internals/stagehand-crawler.js");
|
|
60
|
+
Object.defineProperty(exports, "StagehandCrawler", { enumerable: true, get: function () { return stagehand_crawler_js_1.StagehandCrawler; } });
|
|
61
|
+
Object.defineProperty(exports, "createStagehandRouter", { enumerable: true, get: function () { return stagehand_crawler_js_1.createStagehandRouter; } });
|
|
62
62
|
// Export the browser pool factories, which are how a pool with non-default options reaches the crawler
|
|
63
|
-
var
|
|
64
|
-
Object.defineProperty(exports, "stagehandBrowserPool", { enumerable: true, get: function () { return
|
|
63
|
+
var stagehand_browser_pool_js_1 = require("./internals/stagehand-browser-pool.js");
|
|
64
|
+
Object.defineProperty(exports, "stagehandBrowserPool", { enumerable: true, get: function () { return stagehand_browser_pool_js_1.stagehandBrowserPool; } });
|
|
@@ -2,9 +2,9 @@ import type { Configuration } from '@crawlee/browser';
|
|
|
2
2
|
import type { BrowserPool, BrowserPoolHooks, BrowserPoolOptions } from '@crawlee/browser-pool';
|
|
3
3
|
// @ts-ignore optional peer dependency or compatibility with es2022
|
|
4
4
|
import type { Page } from 'playwright';
|
|
5
|
-
import type { StagehandOptions } from './stagehand-crawler';
|
|
6
|
-
import type { StagehandLaunchContext } from './stagehand-launcher';
|
|
7
|
-
import type { StagehandPlugin } from './stagehand-plugin';
|
|
5
|
+
import type { StagehandOptions } from './stagehand-crawler.js';
|
|
6
|
+
import type { StagehandLaunchContext } from './stagehand-launcher.js';
|
|
7
|
+
import type { StagehandPlugin } from './stagehand-plugin.js';
|
|
8
8
|
/** A {@link BrowserPool} of Stagehand browsers, as built by {@link stagehandBrowserPool}. */
|
|
9
9
|
export type StagehandBrowserPool = BrowserPool<{
|
|
10
10
|
browserPlugins: [StagehandPlugin];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.stagehandBrowserPool = stagehandBrowserPool;
|
|
4
|
-
const
|
|
4
|
+
const stagehand_launcher_js_1 = require("./stagehand-launcher.js");
|
|
5
5
|
/**
|
|
6
6
|
* Builds a {@link BrowserPool} of Stagehand browsers to pass to a {@link StagehandCrawler} as its
|
|
7
7
|
* {@link BrowserCrawlerOptions.browserPool|`browserPool`}.
|
|
@@ -32,7 +32,7 @@ function stagehandBrowserPool(options = {}) {
|
|
|
32
32
|
return stagehandLauncher(launchContext, stagehandOptions, headless, configuration).createBrowserPool(poolOptions);
|
|
33
33
|
}
|
|
34
34
|
function stagehandLauncher(launchContext = {}, stagehandOptions = {}, headless, configuration) {
|
|
35
|
-
return new
|
|
35
|
+
return new stagehand_launcher_js_1.StagehandLauncher({
|
|
36
36
|
...launchContext,
|
|
37
37
|
stagehandOptions,
|
|
38
38
|
...(headless == null ? {} : { launchOptions: { ...launchContext.launchOptions, headless } }),
|
|
@@ -3,7 +3,7 @@ import { BrowserController } from '@crawlee/browser-pool';
|
|
|
3
3
|
import type { Cookie } from '@crawlee/types';
|
|
4
4
|
// @ts-ignore optional peer dependency or compatibility with es2022
|
|
5
5
|
import type { Browser as PlaywrightBrowser, BrowserType, LaunchOptions, Page } from 'playwright';
|
|
6
|
-
import type { StagehandPlugin } from './stagehand-plugin';
|
|
6
|
+
import type { StagehandPlugin } from './stagehand-plugin.js';
|
|
7
7
|
/**
|
|
8
8
|
* StagehandController manages the lifecycle of a Stagehand-controlled browser for Crawlee's BrowserPool.
|
|
9
9
|
*
|
|
@@ -5,7 +5,7 @@ import type { Dictionary } from '@crawlee/types';
|
|
|
5
5
|
// @ts-ignore optional peer dependency or compatibility with es2022
|
|
6
6
|
import type { Page, Response } from 'playwright';
|
|
7
7
|
import { z } from 'zod';
|
|
8
|
-
import type { StagehandLaunchContext } from './stagehand-launcher';
|
|
8
|
+
import type { StagehandLaunchContext } from './stagehand-launcher.js';
|
|
9
9
|
/**
|
|
10
10
|
* Stagehand-specific configuration options.
|
|
11
11
|
*/
|
|
@@ -5,8 +5,8 @@ exports.createStagehandRouter = createStagehandRouter;
|
|
|
5
5
|
const browser_1 = require("@crawlee/browser");
|
|
6
6
|
const internal_1 = require("@crawlee/utils/internal");
|
|
7
7
|
const zod_1 = require("zod");
|
|
8
|
-
const
|
|
9
|
-
const
|
|
8
|
+
const stagehand_browser_pool_js_1 = require("./stagehand-browser-pool.js");
|
|
9
|
+
const stagehand_utils_js_1 = require("./utils/stagehand-utils.js");
|
|
10
10
|
/**
|
|
11
11
|
* StagehandCrawler provides AI-powered web crawling using Browserbase's Stagehand library.
|
|
12
12
|
*
|
|
@@ -95,7 +95,7 @@ class StagehandCrawler extends browser_1.BrowserCrawler {
|
|
|
95
95
|
if (remoteBrowser) {
|
|
96
96
|
throw new Error('StagehandCrawler does not support `remoteBrowser`. Use `stagehandOptions.env: "BROWSERBASE"` instead.');
|
|
97
97
|
}
|
|
98
|
-
return (0,
|
|
98
|
+
return (0, stagehand_browser_pool_js_1.stagehandBrowserPool)({
|
|
99
99
|
launchContext,
|
|
100
100
|
stagehandOptions,
|
|
101
101
|
headless,
|
|
@@ -134,7 +134,7 @@ class StagehandCrawler extends browser_1.BrowserCrawler {
|
|
|
134
134
|
const stagehand = controller.getStagehand();
|
|
135
135
|
return {
|
|
136
136
|
stagehand,
|
|
137
|
-
page: (0,
|
|
137
|
+
page: (0, stagehand_utils_js_1.enhancePageWithStagehand)(crawlingContext.page, stagehand),
|
|
138
138
|
};
|
|
139
139
|
}
|
|
140
140
|
/**
|
|
@@ -3,8 +3,8 @@ import { BrowserLauncher, Configuration } from '@crawlee/browser';
|
|
|
3
3
|
// @ts-ignore optional peer dependency or compatibility with es2022
|
|
4
4
|
import type { BrowserType, LaunchOptions } from 'playwright';
|
|
5
5
|
import { z } from 'zod';
|
|
6
|
-
import type { StagehandOptions } from './stagehand-crawler';
|
|
7
|
-
import { StagehandPlugin } from './stagehand-plugin';
|
|
6
|
+
import type { StagehandOptions } from './stagehand-crawler.js';
|
|
7
|
+
import { StagehandPlugin } from './stagehand-plugin.js';
|
|
8
8
|
/**
|
|
9
9
|
* Launch context for Stagehand crawler with AI-specific options.
|
|
10
10
|
*/
|
|
@@ -4,7 +4,7 @@ exports.StagehandLauncher = void 0;
|
|
|
4
4
|
const browser_1 = require("@crawlee/browser");
|
|
5
5
|
const internal_1 = require("@crawlee/utils/internal");
|
|
6
6
|
const zod_1 = require("zod");
|
|
7
|
-
const
|
|
7
|
+
const stagehand_plugin_js_1 = require("./stagehand-plugin.js");
|
|
8
8
|
/**
|
|
9
9
|
* StagehandLauncher is based on BrowserLauncher and creates StagehandPlugin instances.
|
|
10
10
|
* It manages the lifecycle of Stagehand browsers with fingerprinting and anti-blocking features.
|
|
@@ -51,13 +51,13 @@ class StagehandLauncher extends browser_1.BrowserLauncher {
|
|
|
51
51
|
model: 'openai/gpt-4.1-mini',
|
|
52
52
|
...stagehandOptions,
|
|
53
53
|
};
|
|
54
|
-
this.Plugin =
|
|
54
|
+
this.Plugin = stagehand_plugin_js_1.StagehandPlugin;
|
|
55
55
|
}
|
|
56
56
|
/**
|
|
57
57
|
* Creates a new StagehandPlugin instance with resolved options.
|
|
58
58
|
*/
|
|
59
59
|
createBrowserPlugin() {
|
|
60
|
-
return new
|
|
60
|
+
return new stagehand_plugin_js_1.StagehandPlugin(this.launcher, {
|
|
61
61
|
...this.otherLaunchContextProps,
|
|
62
62
|
proxyUrl: this.proxyUrl,
|
|
63
63
|
launchOptions: this.createLaunchOptions(),
|
|
@@ -2,7 +2,7 @@ import type { BrowserController, BrowserPluginOptions, LaunchContext } from '@cr
|
|
|
2
2
|
import { BrowserPlugin } from '@crawlee/browser-pool';
|
|
3
3
|
// @ts-ignore optional peer dependency or compatibility with es2022
|
|
4
4
|
import type { Browser as PlaywrightBrowser, BrowserType, LaunchOptions } from 'playwright';
|
|
5
|
-
import type { StagehandOptions } from './stagehand-crawler';
|
|
5
|
+
import type { StagehandOptions } from './stagehand-crawler.js';
|
|
6
6
|
/**
|
|
7
7
|
* Options for StagehandPlugin initialization.
|
|
8
8
|
*/
|
|
@@ -6,7 +6,7 @@ const core_1 = require("@crawlee/core");
|
|
|
6
6
|
// Stagehand is built on CDP (Chrome DevTools Protocol), which only works with Chromium-based browsers.
|
|
7
7
|
// Firefox and WebKit are not supported by Stagehand.
|
|
8
8
|
const playwright_1 = require("playwright");
|
|
9
|
-
const
|
|
9
|
+
const stagehand_controller_js_1 = require("./stagehand-controller.js");
|
|
10
10
|
/**
|
|
11
11
|
* StagehandPlugin integrates Stagehand with Crawlee's BrowserPool.
|
|
12
12
|
*
|
|
@@ -112,7 +112,7 @@ class StagehandPlugin extends browser_pool_1.BrowserPlugin {
|
|
|
112
112
|
* Creates a controller for the Stagehand browser.
|
|
113
113
|
*/
|
|
114
114
|
createController() {
|
|
115
|
-
return new
|
|
115
|
+
return new stagehand_controller_js_1.StagehandController(this, this.#stagehandInstances);
|
|
116
116
|
}
|
|
117
117
|
/**
|
|
118
118
|
* Adds proxy configuration to launch options.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Stagehand } from '@browserbasehq/stagehand';
|
|
2
2
|
// @ts-ignore optional peer dependency or compatibility with es2022
|
|
3
3
|
import type { Page } from 'playwright';
|
|
4
|
-
import type { StagehandPage } from '../stagehand-crawler';
|
|
4
|
+
import type { StagehandPage } from '../stagehand-crawler.js';
|
|
5
5
|
/**
|
|
6
6
|
* Enhances a Playwright Page with Stagehand AI methods.
|
|
7
7
|
* Adds page.act(), page.extract(), page.observe(), and page.agent() methods.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crawlee/stagehand",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.227",
|
|
4
4
|
"description": "AI-powered web crawling with Stagehand integration for Crawlee - enables natural language browser automation with act(), extract(), and observe() methods.",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=22.13.0"
|
|
@@ -56,11 +56,11 @@
|
|
|
56
56
|
"access": "public"
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"@crawlee/browser": "4.0.0-beta.
|
|
60
|
-
"@crawlee/browser-pool": "4.0.0-beta.
|
|
61
|
-
"@crawlee/core": "4.0.0-beta.
|
|
62
|
-
"@crawlee/types": "4.0.0-beta.
|
|
63
|
-
"@crawlee/utils": "4.0.0-beta.
|
|
59
|
+
"@crawlee/browser": "4.0.0-beta.227",
|
|
60
|
+
"@crawlee/browser-pool": "4.0.0-beta.227",
|
|
61
|
+
"@crawlee/core": "4.0.0-beta.227",
|
|
62
|
+
"@crawlee/types": "4.0.0-beta.227",
|
|
63
|
+
"@crawlee/utils": "4.0.0-beta.227",
|
|
64
64
|
"tslib": "^2.8.1",
|
|
65
65
|
"zod": "^4.5.4"
|
|
66
66
|
},
|
|
@@ -87,5 +87,5 @@
|
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
},
|
|
90
|
-
"gitHead": "
|
|
90
|
+
"gitHead": "489f64b3e886fd63af7dde5c724e998694239130"
|
|
91
91
|
}
|