Skip to content

Commit 52c4636

Browse files
feat: [STG-1798] feat: support Browserbase verified sessions
1 parent 40cb10e commit 52c4636

File tree

4 files changed

+87
-3
lines changed

4 files changed

+87
-3
lines changed

.stats.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 8
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browserbase%2Fstagehand-7773ef4ca29c983daafb787ee918cfa6b5b12c5bbdc088308653f2737c26e51f.yml
3-
openapi_spec_hash: 47fc8f2540be0b6374e4230c021072d9
4-
config_hash: 0cc516caf1432087f40654336e0fa8cd
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browserbase%2Fstagehand-a8db51c6460b3daff67b35262517848a0d4e783c6805c2edd531b155a5db71dd.yml
3+
openapi_spec_hash: c6e7127f211f946673d6389e1d8db1ba
4+
config_hash: a962ae71493deb11a1c903256fb25386

src/Sessions/SessionStartParams/BrowserbaseSessionCreateParams/BrowserSettings.php

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Stagehand\Core\Contracts\BaseModel;
1010
use Stagehand\Sessions\SessionStartParams\BrowserbaseSessionCreateParams\BrowserSettings\Context;
1111
use Stagehand\Sessions\SessionStartParams\BrowserbaseSessionCreateParams\BrowserSettings\Fingerprint;
12+
use Stagehand\Sessions\SessionStartParams\BrowserbaseSessionCreateParams\BrowserSettings\Os;
1213
use Stagehand\Sessions\SessionStartParams\BrowserbaseSessionCreateParams\BrowserSettings\Viewport;
1314

1415
/**
@@ -19,12 +20,16 @@
1920
* @phpstan-type BrowserSettingsShape = array{
2021
* advancedStealth?: bool|null,
2122
* blockAds?: bool|null,
23+
* captchaImageSelector?: string|null,
24+
* captchaInputSelector?: string|null,
2225
* context?: null|Context|ContextShape,
2326
* extensionID?: string|null,
2427
* fingerprint?: null|Fingerprint|FingerprintShape,
2528
* logSession?: bool|null,
29+
* os?: null|Os|value-of<Os>,
2630
* recordSession?: bool|null,
2731
* solveCaptchas?: bool|null,
32+
* verified?: bool|null,
2833
* viewport?: null|Viewport|ViewportShape,
2934
* }
3035
*/
@@ -39,6 +44,12 @@ final class BrowserSettings implements BaseModel
3944
#[Optional]
4045
public ?bool $blockAds;
4146

47+
#[Optional]
48+
public ?string $captchaImageSelector;
49+
50+
#[Optional]
51+
public ?string $captchaInputSelector;
52+
4253
#[Optional]
4354
public ?Context $context;
4455

@@ -51,12 +62,19 @@ final class BrowserSettings implements BaseModel
5162
#[Optional]
5263
public ?bool $logSession;
5364

65+
/** @var value-of<Os>|null $os */
66+
#[Optional(enum: Os::class)]
67+
public ?string $os;
68+
5469
#[Optional]
5570
public ?bool $recordSession;
5671

5772
#[Optional]
5873
public ?bool $solveCaptchas;
5974

75+
#[Optional]
76+
public ?bool $verified;
77+
6078
#[Optional]
6179
public ?Viewport $viewport;
6280

@@ -72,29 +90,38 @@ public function __construct()
7290
*
7391
* @param Context|ContextShape|null $context
7492
* @param Fingerprint|FingerprintShape|null $fingerprint
93+
* @param Os|value-of<Os>|null $os
7594
* @param Viewport|ViewportShape|null $viewport
7695
*/
7796
public static function with(
7897
?bool $advancedStealth = null,
7998
?bool $blockAds = null,
99+
?string $captchaImageSelector = null,
100+
?string $captchaInputSelector = null,
80101
Context|array|null $context = null,
81102
?string $extensionID = null,
82103
Fingerprint|array|null $fingerprint = null,
83104
?bool $logSession = null,
105+
Os|string|null $os = null,
84106
?bool $recordSession = null,
85107
?bool $solveCaptchas = null,
108+
?bool $verified = null,
86109
Viewport|array|null $viewport = null,
87110
): self {
88111
$self = new self;
89112

90113
null !== $advancedStealth && $self['advancedStealth'] = $advancedStealth;
91114
null !== $blockAds && $self['blockAds'] = $blockAds;
115+
null !== $captchaImageSelector && $self['captchaImageSelector'] = $captchaImageSelector;
116+
null !== $captchaInputSelector && $self['captchaInputSelector'] = $captchaInputSelector;
92117
null !== $context && $self['context'] = $context;
93118
null !== $extensionID && $self['extensionID'] = $extensionID;
94119
null !== $fingerprint && $self['fingerprint'] = $fingerprint;
95120
null !== $logSession && $self['logSession'] = $logSession;
121+
null !== $os && $self['os'] = $os;
96122
null !== $recordSession && $self['recordSession'] = $recordSession;
97123
null !== $solveCaptchas && $self['solveCaptchas'] = $solveCaptchas;
124+
null !== $verified && $self['verified'] = $verified;
98125
null !== $viewport && $self['viewport'] = $viewport;
99126

100127
return $self;
@@ -116,6 +143,22 @@ public function withBlockAds(bool $blockAds): self
116143
return $self;
117144
}
118145

146+
public function withCaptchaImageSelector(string $captchaImageSelector): self
147+
{
148+
$self = clone $this;
149+
$self['captchaImageSelector'] = $captchaImageSelector;
150+
151+
return $self;
152+
}
153+
154+
public function withCaptchaInputSelector(string $captchaInputSelector): self
155+
{
156+
$self = clone $this;
157+
$self['captchaInputSelector'] = $captchaInputSelector;
158+
159+
return $self;
160+
}
161+
119162
/**
120163
* @param Context|ContextShape $context
121164
*/
@@ -154,6 +197,17 @@ public function withLogSession(bool $logSession): self
154197
return $self;
155198
}
156199

200+
/**
201+
* @param Os|value-of<Os> $os
202+
*/
203+
public function withOs(Os|string $os): self
204+
{
205+
$self = clone $this;
206+
$self['os'] = $os;
207+
208+
return $self;
209+
}
210+
157211
public function withRecordSession(bool $recordSession): self
158212
{
159213
$self = clone $this;
@@ -170,6 +224,14 @@ public function withSolveCaptchas(bool $solveCaptchas): self
170224
return $self;
171225
}
172226

227+
public function withVerified(bool $verified): self
228+
{
229+
$self = clone $this;
230+
$self['verified'] = $verified;
231+
232+
return $self;
233+
}
234+
173235
/**
174236
* @param Viewport|ViewportShape $viewport
175237
*/
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Stagehand\Sessions\SessionStartParams\BrowserbaseSessionCreateParams\BrowserSettings;
6+
7+
enum Os: string
8+
{
9+
case WINDOWS = 'windows';
10+
11+
case MAC = 'mac';
12+
13+
case LINUX = 'linux';
14+
15+
case MOBILE = 'mobile';
16+
17+
case TABLET = 'tablet';
18+
}

tests/Services/SessionsTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,8 @@ public function testStartWithOptionalParams(): void
314314
'browserSettings' => [
315315
'advancedStealth' => true,
316316
'blockAds' => true,
317+
'captchaImageSelector' => 'captchaImageSelector',
318+
'captchaInputSelector' => 'captchaInputSelector',
317319
'context' => ['id' => 'id', 'persist' => true],
318320
'extensionID' => 'extensionId',
319321
'fingerprint' => [
@@ -330,8 +332,10 @@ public function testStartWithOptionalParams(): void
330332
],
331333
],
332334
'logSession' => true,
335+
'os' => 'windows',
333336
'recordSession' => true,
334337
'solveCaptchas' => true,
338+
'verified' => true,
335339
'viewport' => ['height' => 0, 'width' => 0],
336340
],
337341
'extensionID' => 'extensionId',

0 commit comments

Comments
 (0)