Skip to content

Commit b47581e

Browse files
authored
Merge pull request #1 from browserbase/release-please--branches--main--changes--next
release: 0.1.0
2 parents 582a585 + 4bf6c9b commit b47581e

16 files changed

Lines changed: 158 additions & 211 deletions

.github/workflows/release-doctor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
release_doctor:
1010
name: release doctor
1111
runs-on: ubuntu-latest
12-
if: github.repository == 'stainless-sdks/stagehand-php' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || startsWith(github.head_ref, 'release-please') || github.head_ref == 'next')
12+
if: github.repository == 'browserbase/stagehand-php' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || startsWith(github.head_ref, 'release-please') || github.head_ref == 'next')
1313

1414
steps:
1515
- uses: actions/checkout@v4

.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "0.0.1"
2+
".": "0.1.0"
33
}

.stats.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 7
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browserbase%2Fstagehand-0c12f985340be2a9287e8e01ff8733f7f2d02e019149d1ae95f1a8f8798c6690.yml
3-
openapi_spec_hash: efb79934e1dc63763dd4e8493b825273
4-
config_hash: 5f3345d1d825e49f896f3b0e493e6938
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browserbase%2Fstagehand-2c88c6d890406ff8a5f1bca692264fb9af4bc4fe64df0986e06d3386fc6d6fcb.yml
3+
openapi_spec_hash: dc6ea17f8152708dc0a390c7f86b1a5d
4+
config_hash: a17b6052ac65237b7b8e145f4f692d3c

CHANGELOG.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Changelog
2+
3+
## 0.1.0 (2025-12-16)
4+
5+
Full Changelog: [v0.0.1...v0.1.0](https://github.com/browserbase/stagehand-php/compare/v0.0.1...v0.1.0)
6+
7+
### Features
8+
9+
* **api:** manual updates ([45de578](https://github.com/browserbase/stagehand-php/commit/45de5783970107d40cb031f867e6844a7e03acfb))
10+
* **api:** manual updates ([1a693a0](https://github.com/browserbase/stagehand-php/commit/1a693a00b3455b5368a4f8e480c6a10d69f52d57))
11+
* **api:** manual updates ([9cb66f2](https://github.com/browserbase/stagehand-php/commit/9cb66f25e24c9584566aad1d8cc5e2f048ac27e1))
12+
* **api:** manual updates ([b1d2b2c](https://github.com/browserbase/stagehand-php/commit/b1d2b2ccbb10c56928f6ae81a914770b70411053))
13+
* **api:** manual updates ([9080e0a](https://github.com/browserbase/stagehand-php/commit/9080e0a09f5ccd2d34ee480ddaea25e21058664e))
14+
* **api:** tweak branding and fix some config fields ([90c7197](https://github.com/browserbase/stagehand-php/commit/90c71979a68c674d6c7acc99f44bca480bb0969b))
15+
16+
17+
### Chores
18+
19+
* configure new SDK language ([83f228c](https://github.com/browserbase/stagehand-php/commit/83f228c57bb2a41078c00161a01aa6be4e36074e))
20+
* **internal:** codegen related update ([582a585](https://github.com/browserbase/stagehand-php/commit/582a58509d679383e90422b7f9d836afa9277354))
21+
* **internal:** codegen related update ([f320af0](https://github.com/browserbase/stagehand-php/commit/f320af00744b1ef4ea2007ca9b80d58f147061aa))

README.md

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,38 @@
55
>
66
> This library has not yet been exhaustively tested in production environments and may be missing some features you'd expect in a stable release. As we continue development, there may be breaking changes that require updates to your code.
77
>
8-
> **We'd love your feedback!** Please share any suggestions, bug reports, feature requests, or general thoughts by [filing an issue](https://www.github.com/stainless-sdks/stagehand-php/issues/new).
8+
> **We'd love your feedback!** Please share any suggestions, bug reports, feature requests, or general thoughts by [filing an issue](https://www.github.com/browserbase/stagehand-php/issues/new).
99
1010
The Stagehand PHP library provides convenient access to the Stagehand REST API from any PHP 8.1.0+ application.
1111

1212
It is generated with [Stainless](https://www.stainless.com/).
1313

1414
## Documentation
1515

16-
The REST API documentation can be found on [browserbase.com](https://browserbase.com).
16+
The REST API documentation can be found on [docs.stagehand.dev](https://docs.stagehand.dev).
1717

1818
## Installation
1919

2020
To use this package, install via Composer by adding the following to your application's `composer.json`:
2121

22+
<!-- x-release-please-start-version -->
23+
2224
```json
2325
{
2426
"repositories": [
2527
{
2628
"type": "vcs",
27-
"url": "git@github.com:stainless-sdks/stagehand-php.git"
29+
"url": "git@github.com:browserbase/stagehand-php.git"
2830
}
2931
],
3032
"require": {
31-
"org-placeholder/stagehand": "dev-main"
33+
"browserbase/stagehand": "dev-main"
3234
}
3335
}
3436
```
3537

38+
<!-- x-release-please-end -->
39+
3640
## Usage
3741

3842
This library uses named parameters to specify optional arguments.
@@ -44,13 +48,19 @@ Parameters with a default value must be set by name.
4448
use Stagehand\Client;
4549

4650
$client = new Client(
47-
apiKey: getenv('STAGEHAND_API_KEY') ?: 'My API Key',
48-
environment: 'environment_1',
51+
browserbaseAPIKey: getenv('BROWSERBASE_API_KEY') ?: 'My Browserbase API Key',
52+
browserbaseProjectID: getenv(
53+
'BROWSERBASE_PROJECT_ID'
54+
) ?: 'My Browserbase Project ID',
55+
modelAPIKey: getenv('MODEL_API_KEY') ?: 'My Model API Key',
4956
);
5057

51-
$response = $client->sessions->start(env: 'LOCAL');
58+
$response = $client->sessions->act(
59+
'00000000-your-session-id-000000000000',
60+
input: 'click the first link on the page',
61+
);
5262

53-
var_dump($response->available);
63+
var_dump($response->actions);
5464
```
5565

5666
### Value Objects
@@ -70,7 +80,10 @@ When the library is unable to connect to the API, or if the API returns a non-su
7080
use Stagehand\Core\Exceptions\APIConnectionException;
7181

7282
try {
73-
$response = $client->sessions->start(env: 'LOCAL');
83+
$response = $client->sessions->start(
84+
browserbaseAPIKey: '<your API key here>',
85+
browserbaseProjectID: '<your project ID here>',
86+
);
7487
} catch (APIConnectionException $e) {
7588
echo "The server could not be reached", PHP_EOL;
7689
var_dump($e->getPrevious());
@@ -117,7 +130,9 @@ $client = new Client(maxRetries: 0);
117130

118131
// Or, configure per-request:
119132
$result = $client->sessions->start(
120-
env: 'LOCAL', requestOptions: RequestOptions::with(maxRetries: 5)
133+
browserbaseAPIKey: '<your API key here>',
134+
browserbaseProjectID: '<your project ID here>',
135+
requestOptions: RequestOptions::with(maxRetries: 5),
121136
);
122137
```
123138

@@ -137,7 +152,8 @@ Note: the `extra*` parameters of the same name overrides the documented paramete
137152
use Stagehand\RequestOptions;
138153

139154
$response = $client->sessions->start(
140-
env: 'LOCAL',
155+
browserbaseAPIKey: '<your API key here>',
156+
browserbaseProjectID: '<your project ID here>',
141157
requestOptions: RequestOptions::with(
142158
extraQueryParams: ['my_query_parameter' => 'value'],
143159
extraBodyParams: ['my_body_parameter' => 'value'],
@@ -178,4 +194,4 @@ PHP 8.1.0 or higher.
178194

179195
## Contributing
180196

181-
See [the contributing documentation](https://github.com/stainless-sdks/stagehand-php/tree/main/CONTRIBUTING.md).
197+
See [the contributing documentation](https://github.com/browserbase/stagehand-php/tree/main/CONTRIBUTING.md).

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"sort-packages": true
3030
},
3131
"description": "Stagehand PHP SDK",
32-
"name": "org-placeholder/stagehand",
32+
"name": "browserbase/stagehand",
3333
"require": {
3434
"php": "^8.1",
3535
"php-http/discovery": "^1",

src/Client.php

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,30 @@
1212

1313
class Client extends BaseClient
1414
{
15-
public string $apiKey;
15+
public string $browserbaseAPIKey;
16+
17+
public string $browserbaseProjectID;
18+
19+
public string $modelAPIKey;
1620

1721
/**
1822
* @api
1923
*/
2024
public SessionsService $sessions;
2125

22-
public function __construct(?string $apiKey = null, ?string $baseUrl = null)
23-
{
24-
$this->apiKey = (string) ($apiKey ?? getenv('STAGEHAND_API_KEY'));
26+
public function __construct(
27+
?string $browserbaseAPIKey = null,
28+
?string $browserbaseProjectID = null,
29+
?string $modelAPIKey = null,
30+
?string $baseUrl = null,
31+
) {
32+
$this->browserbaseAPIKey = (string) ($browserbaseAPIKey ?? getenv('BROWSERBASE_API_KEY'));
33+
$this->browserbaseProjectID = (string) ($browserbaseProjectID ?? getenv('BROWSERBASE_PROJECT_ID'));
34+
$this->modelAPIKey = (string) ($modelAPIKey ?? getenv('MODEL_API_KEY'));
2535

26-
$baseUrl ??= getenv('STAGEHAND_BASE_URL') ?: 'http://localhost:3000/v1';
36+
$baseUrl ??= getenv(
37+
'STAGEHAND_BASE_URL'
38+
) ?: 'https://api.stagehand.browserbase.com/v1';
2739

2840
$options = RequestOptions::with(
2941
uriFactory: Psr17FactoryDiscovery::findUriFactory(),
@@ -52,8 +64,24 @@ public function __construct(?string $apiKey = null, ?string $baseUrl = null)
5264
}
5365

5466
/** @return array<string,string> */
55-
protected function authHeaders(): array
67+
protected function bbAPIKeyAuth(): array
68+
{
69+
return $this->browserbaseAPIKey ? [
70+
'x-bb-api-key' => $this->browserbaseAPIKey,
71+
] : [];
72+
}
73+
74+
/** @return array<string,string> */
75+
protected function bbProjectIDAuth(): array
76+
{
77+
return $this->browserbaseProjectID ? [
78+
'x-bb-project-id' => $this->browserbaseProjectID,
79+
] : [];
80+
}
81+
82+
/** @return array<string,string> */
83+
protected function llmModelAPIKeyAuth(): array
5684
{
57-
return $this->apiKey ? ['Authorization' => "Bearer {$this->apiKey}"] : [];
85+
return $this->modelAPIKey ? ['x-model-api-key' => $this->modelAPIKey] : [];
5886
}
5987
}

src/Core/BaseClient.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,23 @@ public function request(
8989
}
9090

9191
/** @return array<string,string> */
92-
abstract protected function authHeaders(): array;
92+
protected function authHeaders(): array
93+
{
94+
return [
95+
...$this->bbAPIKeyAuth(),
96+
...$this->bbProjectIDAuth(),
97+
...$this->llmModelAPIKeyAuth(),
98+
];
99+
}
100+
101+
/** @return array<string,string> */
102+
abstract protected function bbAPIKeyAuth(): array;
103+
104+
/** @return array<string,string> */
105+
abstract protected function bbProjectIDAuth(): array;
106+
107+
/** @return array<string,string> */
108+
abstract protected function llmModelAPIKeyAuth(): array;
93109

94110
/**
95111
* @internal

src/ServiceContracts/SessionsContract.php

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
use Stagehand\Sessions\SessionExtractResponse\Extraction;
1616
use Stagehand\Sessions\SessionNavigateParams\Options\WaitUntil;
1717
use Stagehand\Sessions\SessionNavigateResponse;
18-
use Stagehand\Sessions\SessionStartParams\Env;
1918
use Stagehand\Sessions\SessionStartResponse;
2019

2120
interface SessionsContract
@@ -188,27 +187,21 @@ public function observe(
188187
/**
189188
* @api
190189
*
191-
* @param 'LOCAL'|'BROWSERBASE'|Env $env Environment to run the browser in
192-
* @param string $apiKey API key for Browserbase (required when env=BROWSERBASE)
190+
* @param string $browserbaseAPIKey API key for Browserbase Cloud
191+
* @param string $browserbaseProjectID Project ID for Browserbase
193192
* @param int $domSettleTimeout Timeout in ms to wait for DOM to settle
194-
* @param array{
195-
* headless?: bool
196-
* } $localBrowserLaunchOptions Options for local browser launch
197-
* @param string $model AI model to use for actions
198-
* @param string $projectID Project ID for Browserbase (required when env=BROWSERBASE)
193+
* @param string $model AI model to use for actions (must be prefixed with provider/)
199194
* @param bool $selfHeal Enable self-healing for failed actions
200195
* @param string $systemPrompt Custom system prompt for AI actions
201196
* @param int $verbose Logging verbosity level
202197
*
203198
* @throws APIException
204199
*/
205200
public function start(
206-
string|Env $env,
207-
?string $apiKey = null,
201+
string $browserbaseAPIKey,
202+
string $browserbaseProjectID,
208203
?int $domSettleTimeout = null,
209-
?array $localBrowserLaunchOptions = null,
210204
?string $model = null,
211-
?string $projectID = null,
212205
?bool $selfHeal = null,
213206
?string $systemPrompt = null,
214207
int $verbose = 0,

src/Services/SessionsRawService.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
use Stagehand\Sessions\SessionNavigateResponse;
2828
use Stagehand\Sessions\SessionObserveParams;
2929
use Stagehand\Sessions\SessionStartParams;
30-
use Stagehand\Sessions\SessionStartParams\Env;
3130
use Stagehand\Sessions\SessionStartResponse;
3231

3332
final class SessionsRawService implements SessionsRawContract
@@ -346,12 +345,10 @@ public function observe(
346345
* Returns a session ID that must be used for all subsequent requests.
347346
*
348347
* @param array{
349-
* env: 'LOCAL'|'BROWSERBASE'|Env,
350-
* apiKey?: string,
348+
* browserbaseAPIKey: string,
349+
* browserbaseProjectID: string,
351350
* domSettleTimeout?: int,
352-
* localBrowserLaunchOptions?: array{headless?: bool},
353351
* model?: string,
354-
* projectID?: string,
355352
* selfHeal?: bool,
356353
* systemPrompt?: string,
357354
* verbose?: int,

0 commit comments

Comments
 (0)