@crawlee/stagehand 4.0.0-beta.85 → 4.0.0-beta.87

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.
@@ -197,9 +197,9 @@ export interface StagehandRequestHandler extends RequestHandler<LoadedContext<St
197
197
  /**
198
198
  * Options for StagehandCrawler.
199
199
  */
200
- export interface StagehandCrawlerOptions<ContextExtension = Dictionary<never>, ExtendedContext extends StagehandCrawlingContext = StagehandCrawlingContext & ContextExtension> extends BrowserCrawlerOptions<StagehandPage, Response, StagehandCrawlingContext, ContextExtension, ExtendedContext, {
200
+ export interface StagehandCrawlerOptions<ContextExtension = Dictionary<never>, ExtendedContext extends StagehandCrawlingContext = StagehandCrawlingContext & ContextExtension, Routes extends Record<keyof Routes, Dictionary> = Record<string, GetUserDataFromRequest<StagehandCrawlingContext['request']>>> extends BrowserCrawlerOptions<StagehandPage, Response, StagehandCrawlingContext, ContextExtension, ExtendedContext, {
201
201
  browserPlugins: [StagehandPlugin];
202
- }> {
202
+ }, Routes> {
203
203
  /**
204
204
  * Stagehand-specific configuration options.
205
205
  * These options configure the AI behavior and Browserbase integration.
@@ -253,7 +253,7 @@ export interface StagehandCrawlerOptions<ContextExtension = Dictionary<never>, E
253
253
  * }
254
254
  * ```
255
255
  */
256
- requestHandler?: StagehandRequestHandler;
256
+ requestHandler?: RouterHandler<ExtendedContext, Routes> | RequestHandler<ExtendedContext>;
257
257
  /**
258
258
  * Async functions that are sequentially evaluated before the navigation.
259
259
  */
@@ -312,9 +312,9 @@ export interface StagehandCrawlerOptions<ContextExtension = Dictionary<never>, E
312
312
  * await crawler.run(['https://example.com']);
313
313
  * ```
314
314
  */
315
- export declare class StagehandCrawler<ContextExtension = Dictionary<never>, ExtendedContext extends StagehandCrawlingContext = StagehandCrawlingContext & ContextExtension> extends BrowserCrawler<StagehandPage, Response, {
315
+ export declare class StagehandCrawler<ContextExtension = Dictionary<never>, ExtendedContext extends StagehandCrawlingContext = StagehandCrawlingContext & ContextExtension, Routes extends Record<keyof Routes, Dictionary> = Record<string, GetUserDataFromRequest<StagehandCrawlingContext['request']>>> extends BrowserCrawler<StagehandPage, Response, {
316
316
  browserPlugins: [StagehandPlugin];
317
- }, LaunchOptions, StagehandCrawlingContext, ContextExtension, ExtendedContext> {
317
+ }, LaunchOptions, StagehandCrawlingContext, ContextExtension, ExtendedContext, Routes> {
318
318
  protected static optionsShape: {
319
319
  // @ts-ignore optional peer dependency or compatibility with es2022
320
320
  stagehandOptions: import("ow", { with: { "resolution-mode": "import" } }).ObjectPredicate<object> & import("ow", { with: { "resolution-mode": "import" } }).BasePredicate<object | undefined>;
@@ -410,7 +410,7 @@ export declare class StagehandCrawler<ContextExtension = Dictionary<never>, Exte
410
410
  *
411
411
  * @param options - Crawler configuration options
412
412
  */
413
- constructor(options?: StagehandCrawlerOptions<ContextExtension, ExtendedContext>);
413
+ constructor(options?: StagehandCrawlerOptions<ContextExtension, ExtendedContext, Routes>);
414
414
  protected buildContextPipeline(): ContextPipeline<CrawlingContext, StagehandCrawlingContext>;
415
415
  /**
416
416
  * Resolves the {@link StagehandController} that owns the given page, or
@@ -54,7 +54,7 @@ export interface StagehandLaunchContext extends BrowserLaunchContext<LaunchOptio
54
54
  * @ignore
55
55
  */
56
56
  export declare class StagehandLauncher extends BrowserLauncher<StagehandPlugin> {
57
- readonly config: Configuration;
57
+ readonly configuration: Configuration;
58
58
  protected static optionsShape: {
59
59
  // @ts-ignore optional peer dependency or compatibility with es2022
60
60
  launcher: import("ow", { with: { "resolution-mode": "import" } }).ObjectPredicate<object> & import("ow", { with: { "resolution-mode": "import" } }).BasePredicate<object | undefined>;
@@ -83,7 +83,7 @@ export declare class StagehandLauncher extends BrowserLauncher<StagehandPlugin>
83
83
  /**
84
84
  * All StagehandLauncher parameters are passed via the launchContext object.
85
85
  */
86
- constructor(launchContext?: StagehandLaunchContext, config?: Configuration);
86
+ constructor(launchContext?: StagehandLaunchContext, configuration?: Configuration);
87
87
  /**
88
88
  * Creates a new StagehandPlugin instance with resolved options.
89
89
  */
@@ -12,7 +12,7 @@ const stagehand_plugin_1 = require("./stagehand-plugin");
12
12
  * @ignore
13
13
  */
14
14
  class StagehandLauncher extends browser_1.BrowserLauncher {
15
- config;
15
+ configuration;
16
16
  static optionsShape = {
17
17
  ...browser_1.BrowserLauncher.optionsShape,
18
18
  launcher: ow_1.default.optional.object,
@@ -23,7 +23,7 @@ class StagehandLauncher extends browser_1.BrowserLauncher {
23
23
  /**
24
24
  * All StagehandLauncher parameters are passed via the launchContext object.
25
25
  */
26
- constructor(launchContext = {}, config = browser_1.Configuration.getGlobalConfig()) {
26
+ constructor(launchContext = {}, configuration = browser_1.Configuration.getGlobalConfiguration()) {
27
27
  (0, ow_1.default)(launchContext, 'StagehandLaunchContext', ow_1.default.object.exactShape(StagehandLauncher.optionsShape));
28
28
  const { launcher = browser_1.BrowserLauncher.requireLauncherOrThrow('playwright', 'apify/actor-node-playwright-*').chromium, stagehandOptions = {}, } = launchContext;
29
29
  const { launchOptions = {}, ...rest } = launchContext;
@@ -32,11 +32,11 @@ class StagehandLauncher extends browser_1.BrowserLauncher {
32
32
  ...rest,
33
33
  launchOptions: {
34
34
  ...launchOptions,
35
- executablePath: getDefaultExecutablePath(launchContext, config),
35
+ executablePath: getDefaultExecutablePath(launchContext, configuration),
36
36
  },
37
37
  launcher,
38
- }, config);
39
- this.config = config;
38
+ }, configuration);
39
+ this.configuration = configuration;
40
40
  this.stagehandOptions = {
41
41
  env: 'LOCAL',
42
42
  model: 'openai/gpt-4.1-mini',
@@ -61,8 +61,8 @@ exports.StagehandLauncher = StagehandLauncher;
61
61
  * Gets the default executable path for the browser.
62
62
  * @ignore
63
63
  */
64
- function getDefaultExecutablePath(launchContext, config) {
65
- const pathFromPlaywrightImage = config.defaultBrowserPath;
64
+ function getDefaultExecutablePath(launchContext, configuration) {
65
+ const pathFromPlaywrightImage = configuration.defaultBrowserPath;
66
66
  const { launchOptions = {} } = launchContext;
67
67
  if (launchOptions.executablePath) {
68
68
  return launchOptions.executablePath;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crawlee/stagehand",
3
- "version": "4.0.0-beta.85",
3
+ "version": "4.0.0-beta.87",
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.0.0"
@@ -57,11 +57,11 @@
57
57
  },
58
58
  "dependencies": {
59
59
  "@apify/timeout": "^0.3.2",
60
- "@crawlee/browser": "4.0.0-beta.85",
61
- "@crawlee/browser-pool": "4.0.0-beta.85",
62
- "@crawlee/core": "4.0.0-beta.85",
63
- "@crawlee/types": "4.0.0-beta.85",
64
- "@crawlee/utils": "4.0.0-beta.85",
60
+ "@crawlee/browser": "4.0.0-beta.87",
61
+ "@crawlee/browser-pool": "4.0.0-beta.87",
62
+ "@crawlee/core": "4.0.0-beta.87",
63
+ "@crawlee/types": "4.0.0-beta.87",
64
+ "@crawlee/utils": "4.0.0-beta.87",
65
65
  "ow": "^2.0.0",
66
66
  "tslib": "^2.8.1"
67
67
  },
@@ -93,5 +93,5 @@
93
93
  }
94
94
  }
95
95
  },
96
- "gitHead": "8d6d3cd9da3dc9cb0b7822b28eb317019b6806bc"
96
+ "gitHead": "1b7604cd77b694460aac4448b4555444fa1b2bdb"
97
97
  }