Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "3.3.0"
".": "3.4.0"
}
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 7
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browserbase%2Fstagehand-d91dfd9ce727aefac56505ac86feb5cc665d3d5cef80ff17605f45e09b258251.yml
openapi_spec_hash: 0d1cae70e9d1debc5ac1a69fc665af37
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browserbase%2Fstagehand-22af3433e4e2d94d5ba19598d795e91939118eb58af20179f2b07c916907c0b6.yml
openapi_spec_hash: a1ca99a2148ba2eddd0f0d8aab133a35
config_hash: 64c9cc393de93af70e11dbf0b1ba9388
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## 3.4.0 (2026-01-20)

Full Changelog: [v3.3.0...v3.4.0](https://github.com/browserbase/stagehand-php/compare/v3.3.0...v3.4.0)

### Features

* End endpoint cleanup ([3146db4](https://github.com/browserbase/stagehand-php/commit/3146db4768aab42af9ce6c2add2aa583bed8b86f))

## 3.3.0 (2026-01-20)

Full Changelog: [v3.2.2...v3.3.0](https://github.com/browserbase/stagehand-php/compare/v3.2.2...v3.3.0)
Expand Down
6 changes: 2 additions & 4 deletions src/ServiceContracts/SessionsContract.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,14 @@ public function actStream(
/**
* @api
*
* @param string $id Path param: Unique session identifier
* @param mixed $_forceBody Body param
* @param \Stagehand\Sessions\SessionEndParams\XStreamResponse|value-of<\Stagehand\Sessions\SessionEndParams\XStreamResponse> $xStreamResponse Header param: Whether to stream the response via SSE
* @param string $id Unique session identifier
* @param \Stagehand\Sessions\SessionEndParams\XStreamResponse|value-of<\Stagehand\Sessions\SessionEndParams\XStreamResponse> $xStreamResponse Whether to stream the response via SSE
* @param RequestOpts|null $requestOptions
*
* @throws APIException
*/
public function end(
string $id,
mixed $_forceBody = null,
\Stagehand\Sessions\SessionEndParams\XStreamResponse|string|null $xStreamResponse = null,
RequestOptions|array|null $requestOptions = null,
): SessionEndResponse;
Expand Down
2 changes: 1 addition & 1 deletion src/ServiceContracts/SessionsRawContract.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function actStream(
/**
* @api
*
* @param string $id Path param: Unique session identifier
* @param string $id Unique session identifier
* @param array<string,mixed>|SessionEndParams $params
* @param RequestOpts|null $requestOptions
*
Expand Down
10 changes: 2 additions & 8 deletions src/Services/SessionsRawService.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,8 @@ public function actStream(
*
* Terminates the browser session and releases all associated resources.
*
* @param string $id Path param: Unique session identifier
* @param string $id Unique session identifier
* @param array{
* _forceBody?: mixed,
* xStreamResponse?: SessionEndParams\XStreamResponse|value-of<SessionEndParams\XStreamResponse>,
* }|SessionEndParams $params
* @param RequestOpts|null $requestOptions
Expand All @@ -177,19 +176,14 @@ public function end(
$params,
$requestOptions,
);
$header_params = ['xStreamResponse' => 'x-stream-response'];

// @phpstan-ignore-next-line return.type
return $this->client->request(
method: 'post',
path: ['v1/sessions/%1$s/end', $id],
headers: Util::array_transform_keys(
array_intersect_key($parsed, array_flip(array_keys($header_params))),
$header_params,
),
body: (object) array_diff_key(
$parsed,
array_flip(array_keys($header_params))
['xStreamResponse' => 'x-stream-response']
),
options: $options,
convert: SessionEndResponse::class,
Expand Down
10 changes: 3 additions & 7 deletions src/Services/SessionsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,22 +132,18 @@ public function actStream(
*
* Terminates the browser session and releases all associated resources.
*
* @param string $id Path param: Unique session identifier
* @param mixed $_forceBody Body param
* @param \Stagehand\Sessions\SessionEndParams\XStreamResponse|value-of<\Stagehand\Sessions\SessionEndParams\XStreamResponse> $xStreamResponse Header param: Whether to stream the response via SSE
* @param string $id Unique session identifier
* @param \Stagehand\Sessions\SessionEndParams\XStreamResponse|value-of<\Stagehand\Sessions\SessionEndParams\XStreamResponse> $xStreamResponse Whether to stream the response via SSE
* @param RequestOpts|null $requestOptions
*
* @throws APIException
*/
public function end(
string $id,
mixed $_forceBody = null,
\Stagehand\Sessions\SessionEndParams\XStreamResponse|string|null $xStreamResponse = null,
RequestOptions|array|null $requestOptions = null,
): SessionEndResponse {
$params = Util::removeNulls(
['_forceBody' => $_forceBody, 'xStreamResponse' => $xStreamResponse]
);
$params = Util::removeNulls(['xStreamResponse' => $xStreamResponse]);

// @phpstan-ignore-next-line argument.type
$response = $this->raw->end($id, params: $params, requestOptions: $requestOptions);
Expand Down
16 changes: 1 addition & 15 deletions src/Sessions/SessionEndParams.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
* @see Stagehand\Services\SessionsService::end()
*
* @phpstan-type SessionEndParamsShape = array{
* _forceBody?: mixed,
* xStreamResponse?: null|XStreamResponse|value-of<XStreamResponse>,
* xStreamResponse?: null|XStreamResponse|value-of<XStreamResponse>
* }
*/
final class SessionEndParams implements BaseModel
Expand All @@ -26,9 +25,6 @@ final class SessionEndParams implements BaseModel
use SdkModel;
use SdkParams;

#[Optional]
public mixed $_forceBody;

/**
* Whether to stream the response via SSE.
*
Expand All @@ -50,25 +46,15 @@ public function __construct()
* @param XStreamResponse|value-of<XStreamResponse>|null $xStreamResponse
*/
public static function with(
mixed $_forceBody = null,
XStreamResponse|string|null $xStreamResponse = null
): self {
$self = new self;

null !== $_forceBody && $self['_forceBody'] = $_forceBody;
null !== $xStreamResponse && $self['xStreamResponse'] = $xStreamResponse;

return $self;
}

public function withForceBody(mixed $_forceBody): self
{
$self = clone $this;
$self['_forceBody'] = $_forceBody;

return $self;
}

/**
* Whether to stream the response via SSE.
*
Expand Down
14 changes: 14 additions & 0 deletions src/Sessions/SessionStartParams/Browser/LaunchOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
* ignoreDefaultArgs?: IgnoreDefaultArgsShape|null,
* ignoreHTTPSErrors?: bool|null,
* locale?: string|null,
* port?: float|null,
* preserveUserDataDir?: bool|null,
* proxy?: null|Proxy|ProxyShape,
* userDataDir?: string|null,
Expand Down Expand Up @@ -87,6 +88,9 @@ final class LaunchOptions implements BaseModel
#[Optional]
public ?string $locale;

#[Optional]
public ?float $port;

#[Optional]
public ?bool $preserveUserDataDir;

Expand Down Expand Up @@ -129,6 +133,7 @@ public static function with(
bool|array|null $ignoreDefaultArgs = null,
?bool $ignoreHTTPSErrors = null,
?string $locale = null,
?float $port = null,
?bool $preserveUserDataDir = null,
Proxy|array|null $proxy = null,
?string $userDataDir = null,
Expand All @@ -150,6 +155,7 @@ public static function with(
null !== $ignoreDefaultArgs && $self['ignoreDefaultArgs'] = $ignoreDefaultArgs;
null !== $ignoreHTTPSErrors && $self['ignoreHTTPSErrors'] = $ignoreHTTPSErrors;
null !== $locale && $self['locale'] = $locale;
null !== $port && $self['port'] = $port;
null !== $preserveUserDataDir && $self['preserveUserDataDir'] = $preserveUserDataDir;
null !== $proxy && $self['proxy'] = $proxy;
null !== $userDataDir && $self['userDataDir'] = $userDataDir;
Expand Down Expand Up @@ -276,6 +282,14 @@ public function withLocale(string $locale): self
return $self;
}

public function withPort(float $port): self
{
$self = clone $this;
$self['port'] = $port;

return $self;
}

public function withPreserveUserDataDir(bool $preserveUserDataDir): self
{
$self = clone $this;
Expand Down
2 changes: 1 addition & 1 deletion src/Version.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
namespace Stagehand;

// x-release-please-start-version
const VERSION = '3.3.0';
const VERSION = '3.4.0';
// x-release-please-end
1 change: 1 addition & 0 deletions tests/Services/SessionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ public function testStartWithOptionalParams(): void
'ignoreDefaultArgs' => true,
'ignoreHTTPSErrors' => true,
'locale' => 'locale',
'port' => 0,
'preserveUserDataDir' => true,
'proxy' => [
'server' => 'server',
Expand Down