From 2c6c4be87e065ca515d3bd78ebee98fd233d2169 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 3 Apr 2026 19:38:44 +0000 Subject: [PATCH 01/18] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index ac9e78a..ade26eb 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 8 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browserbase%2Fstagehand-b969ce378479c79ee64c05127c0ed6c6ce2edbee017ecd037242fb618a5ebc9f.yml openapi_spec_hash: a24aabaa5214effb679808b7f2be0ad4 -config_hash: a962ae71493deb11a1c903256fb25386 +config_hash: 0cc516caf1432087f40654336e0fa8cd From 40cb10eb39c7f53b9c3fd668018c1b3569650e5c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 8 Apr 2026 18:22:47 +0000 Subject: [PATCH 02/18] feat: Bedrock auth passthrough --- .stats.yml | 4 +- src/ServiceContracts/SessionsContract.php | 6 + src/Services/SessionsRawService.php | 2 + src/Services/SessionsService.php | 7 + src/Sessions/ModelConfig.php | 56 ++++- src/Sessions/ModelConfig/ProviderOptions.php | 39 ++++ .../BedrockAPIKeyProviderOptions.php | 68 +++++++ .../BedrockAwsCredentialsProviderOptions.php | 138 +++++++++++++ .../GoogleVertexProviderOptions.php | 130 ++++++++++++ .../GoogleAuthOptions.php | 60 ++++++ .../GoogleAuthOptions/Credentials.php | 192 ++++++++++++++++++ .../SessionExecuteParams/ExecuteOptions.php | 46 +---- src/Sessions/SessionStartParams.php | 31 +++ .../SessionStartParams/ModelClientOptions.php | 39 ++++ .../BedrockAPIKeyModelClientOptions.php | 161 +++++++++++++++ .../ProviderOptions.php | 68 +++++++ ...edrockAwsCredentialsModelClientOptions.php | 141 +++++++++++++ .../ProviderOptions.php | 136 +++++++++++++ .../GenericModelClientOptions.php | 155 ++++++++++++++ .../ProviderOptions.php | 39 ++++ .../BedrockAPIKeyProviderOptions.php | 68 +++++++ .../BedrockAwsCredentialsProviderOptions.php | 138 +++++++++++++ .../GoogleVertexProviderOptions.php | 130 ++++++++++++ .../GoogleAuthOptions.php | 60 ++++++ .../GoogleAuthOptions/Credentials.php | 192 ++++++++++++++++++ src/Sessions/StreamEvent.php | 2 +- tests/Services/SessionsTest.php | 27 ++- 27 files changed, 2078 insertions(+), 57 deletions(-) create mode 100644 src/Sessions/ModelConfig/ProviderOptions.php create mode 100644 src/Sessions/ModelConfig/ProviderOptions/BedrockAPIKeyProviderOptions.php create mode 100644 src/Sessions/ModelConfig/ProviderOptions/BedrockAwsCredentialsProviderOptions.php create mode 100644 src/Sessions/ModelConfig/ProviderOptions/GoogleVertexProviderOptions.php create mode 100644 src/Sessions/ModelConfig/ProviderOptions/GoogleVertexProviderOptions/GoogleAuthOptions.php create mode 100644 src/Sessions/ModelConfig/ProviderOptions/GoogleVertexProviderOptions/GoogleAuthOptions/Credentials.php create mode 100644 src/Sessions/SessionStartParams/ModelClientOptions.php create mode 100644 src/Sessions/SessionStartParams/ModelClientOptions/BedrockAPIKeyModelClientOptions.php create mode 100644 src/Sessions/SessionStartParams/ModelClientOptions/BedrockAPIKeyModelClientOptions/ProviderOptions.php create mode 100644 src/Sessions/SessionStartParams/ModelClientOptions/BedrockAwsCredentialsModelClientOptions.php create mode 100644 src/Sessions/SessionStartParams/ModelClientOptions/BedrockAwsCredentialsModelClientOptions/ProviderOptions.php create mode 100644 src/Sessions/SessionStartParams/ModelClientOptions/GenericModelClientOptions.php create mode 100644 src/Sessions/SessionStartParams/ModelClientOptions/GenericModelClientOptions/ProviderOptions.php create mode 100644 src/Sessions/SessionStartParams/ModelClientOptions/GenericModelClientOptions/ProviderOptions/BedrockAPIKeyProviderOptions.php create mode 100644 src/Sessions/SessionStartParams/ModelClientOptions/GenericModelClientOptions/ProviderOptions/BedrockAwsCredentialsProviderOptions.php create mode 100644 src/Sessions/SessionStartParams/ModelClientOptions/GenericModelClientOptions/ProviderOptions/GoogleVertexProviderOptions.php create mode 100644 src/Sessions/SessionStartParams/ModelClientOptions/GenericModelClientOptions/ProviderOptions/GoogleVertexProviderOptions/GoogleAuthOptions.php create mode 100644 src/Sessions/SessionStartParams/ModelClientOptions/GenericModelClientOptions/ProviderOptions/GoogleVertexProviderOptions/GoogleAuthOptions/Credentials.php diff --git a/.stats.yml b/.stats.yml index ade26eb..f1d6429 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 8 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browserbase%2Fstagehand-b969ce378479c79ee64c05127c0ed6c6ce2edbee017ecd037242fb618a5ebc9f.yml -openapi_spec_hash: a24aabaa5214effb679808b7f2be0ad4 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browserbase%2Fstagehand-7773ef4ca29c983daafb787ee918cfa6b5b12c5bbdc088308653f2737c26e51f.yml +openapi_spec_hash: 47fc8f2540be0b6374e4230c021072d9 config_hash: 0cc516caf1432087f40654336e0fa8cd diff --git a/src/ServiceContracts/SessionsContract.php b/src/ServiceContracts/SessionsContract.php index 0cd0ad2..20797b8 100644 --- a/src/ServiceContracts/SessionsContract.php +++ b/src/ServiceContracts/SessionsContract.php @@ -21,6 +21,9 @@ use Stagehand\Sessions\SessionReplayResponse; use Stagehand\Sessions\SessionStartParams\Browser; use Stagehand\Sessions\SessionStartParams\BrowserbaseSessionCreateParams; +use Stagehand\Sessions\SessionStartParams\ModelClientOptions\BedrockAPIKeyModelClientOptions; +use Stagehand\Sessions\SessionStartParams\ModelClientOptions\BedrockAwsCredentialsModelClientOptions; +use Stagehand\Sessions\SessionStartParams\ModelClientOptions\GenericModelClientOptions; use Stagehand\Sessions\SessionStartResponse; use Stagehand\Sessions\StreamEvent; @@ -28,6 +31,7 @@ * @phpstan-import-type OptionsShape from \Stagehand\Sessions\SessionNavigateParams\Options * @phpstan-import-type BrowserShape from \Stagehand\Sessions\SessionStartParams\Browser * @phpstan-import-type BrowserbaseSessionCreateParamsShape from \Stagehand\Sessions\SessionStartParams\BrowserbaseSessionCreateParams + * @phpstan-import-type ModelClientOptionsShape from \Stagehand\Sessions\SessionStartParams\ModelClientOptions * @phpstan-import-type InputShape from \Stagehand\Sessions\SessionActParams\Input * @phpstan-import-type OptionsShape from \Stagehand\Sessions\SessionActParams\Options as OptionsShape1 * @phpstan-import-type RequestOpts from \Stagehand\RequestOptions @@ -285,6 +289,7 @@ public function replay( * @param string $browserbaseSessionID Body param: Existing Browserbase session ID to resume * @param float $domSettleTimeoutMs Body param: Timeout in ms to wait for DOM to settle * @param bool $experimental Body param + * @param ModelClientOptionsShape $modelClientOptions Body param: Optional provider-specific configuration for the session model (for example Bedrock region and credentials) * @param bool $selfHeal Body param: Enable self-healing for failed actions * @param string $systemPrompt Body param: Custom system prompt for AI operations * @param float $verbose Body param: Logging verbosity level (0=quiet, 1=normal, 2=debug) @@ -302,6 +307,7 @@ public function start( ?string $browserbaseSessionID = null, ?float $domSettleTimeoutMs = null, ?bool $experimental = null, + BedrockAPIKeyModelClientOptions|array|BedrockAwsCredentialsModelClientOptions|GenericModelClientOptions|null $modelClientOptions = null, ?bool $selfHeal = null, ?string $systemPrompt = null, ?float $verbose = null, diff --git a/src/Services/SessionsRawService.php b/src/Services/SessionsRawService.php index 4482975..1d059c7 100644 --- a/src/Services/SessionsRawService.php +++ b/src/Services/SessionsRawService.php @@ -40,6 +40,7 @@ * @phpstan-import-type OptionsShape from \Stagehand\Sessions\SessionNavigateParams\Options * @phpstan-import-type BrowserShape from \Stagehand\Sessions\SessionStartParams\Browser * @phpstan-import-type BrowserbaseSessionCreateParamsShape from \Stagehand\Sessions\SessionStartParams\BrowserbaseSessionCreateParams + * @phpstan-import-type ModelClientOptionsShape from \Stagehand\Sessions\SessionStartParams\ModelClientOptions * @phpstan-import-type InputShape from \Stagehand\Sessions\SessionActParams\Input * @phpstan-import-type OptionsShape from \Stagehand\Sessions\SessionActParams\Options as OptionsShape1 * @phpstan-import-type RequestOpts from \Stagehand\RequestOptions @@ -588,6 +589,7 @@ public function replay( * browserbaseSessionID?: string, * domSettleTimeoutMs?: float, * experimental?: bool, + * modelClientOptions?: ModelClientOptionsShape, * selfHeal?: bool, * systemPrompt?: string, * verbose?: float, diff --git a/src/Services/SessionsService.php b/src/Services/SessionsService.php index f993409..a10109a 100644 --- a/src/Services/SessionsService.php +++ b/src/Services/SessionsService.php @@ -24,6 +24,9 @@ use Stagehand\Sessions\SessionReplayResponse; use Stagehand\Sessions\SessionStartParams\Browser; use Stagehand\Sessions\SessionStartParams\BrowserbaseSessionCreateParams; +use Stagehand\Sessions\SessionStartParams\ModelClientOptions\BedrockAPIKeyModelClientOptions; +use Stagehand\Sessions\SessionStartParams\ModelClientOptions\BedrockAwsCredentialsModelClientOptions; +use Stagehand\Sessions\SessionStartParams\ModelClientOptions\GenericModelClientOptions; use Stagehand\Sessions\SessionStartResponse; use Stagehand\Sessions\StreamEvent; @@ -31,6 +34,7 @@ * @phpstan-import-type OptionsShape from \Stagehand\Sessions\SessionNavigateParams\Options * @phpstan-import-type BrowserShape from \Stagehand\Sessions\SessionStartParams\Browser * @phpstan-import-type BrowserbaseSessionCreateParamsShape from \Stagehand\Sessions\SessionStartParams\BrowserbaseSessionCreateParams + * @phpstan-import-type ModelClientOptionsShape from \Stagehand\Sessions\SessionStartParams\ModelClientOptions * @phpstan-import-type InputShape from \Stagehand\Sessions\SessionActParams\Input * @phpstan-import-type OptionsShape from \Stagehand\Sessions\SessionActParams\Options as OptionsShape1 * @phpstan-import-type RequestOpts from \Stagehand\RequestOptions @@ -462,6 +466,7 @@ public function replay( * @param string $browserbaseSessionID Body param: Existing Browserbase session ID to resume * @param float $domSettleTimeoutMs Body param: Timeout in ms to wait for DOM to settle * @param bool $experimental Body param + * @param ModelClientOptionsShape $modelClientOptions Body param: Optional provider-specific configuration for the session model (for example Bedrock region and credentials) * @param bool $selfHeal Body param: Enable self-healing for failed actions * @param string $systemPrompt Body param: Custom system prompt for AI operations * @param float $verbose Body param: Logging verbosity level (0=quiet, 1=normal, 2=debug) @@ -479,6 +484,7 @@ public function start( ?string $browserbaseSessionID = null, ?float $domSettleTimeoutMs = null, ?bool $experimental = null, + BedrockAPIKeyModelClientOptions|array|BedrockAwsCredentialsModelClientOptions|GenericModelClientOptions|null $modelClientOptions = null, ?bool $selfHeal = null, ?string $systemPrompt = null, ?float $verbose = null, @@ -495,6 +501,7 @@ public function start( 'browserbaseSessionID' => $browserbaseSessionID, 'domSettleTimeoutMs' => $domSettleTimeoutMs, 'experimental' => $experimental, + 'modelClientOptions' => $modelClientOptions, 'selfHeal' => $selfHeal, 'systemPrompt' => $systemPrompt, 'verbose' => $verbose, diff --git a/src/Sessions/ModelConfig.php b/src/Sessions/ModelConfig.php index c03b239..404b5b6 100644 --- a/src/Sessions/ModelConfig.php +++ b/src/Sessions/ModelConfig.php @@ -9,14 +9,22 @@ use Stagehand\Core\Concerns\SdkModel; use Stagehand\Core\Contracts\BaseModel; use Stagehand\Sessions\ModelConfig\Provider; +use Stagehand\Sessions\ModelConfig\ProviderOptions\BedrockAPIKeyProviderOptions; +use Stagehand\Sessions\ModelConfig\ProviderOptions\BedrockAwsCredentialsProviderOptions; +use Stagehand\Sessions\ModelConfig\ProviderOptions\GoogleVertexProviderOptions; /** + * @phpstan-import-type ProviderOptionsVariants from \Stagehand\Sessions\ModelConfig\ProviderOptions + * @phpstan-import-type ProviderOptionsShape from \Stagehand\Sessions\ModelConfig\ProviderOptions + * * @phpstan-type ModelConfigShape = array{ * modelName: string, * apiKey?: string|null, * baseURL?: string|null, * headers?: array|null, * provider?: null|Provider|value-of, + * providerOptions?: ProviderOptionsShape|null, + * skipAPIKeyFallback?: bool|null, * } */ final class ModelConfig implements BaseModel @@ -43,7 +51,7 @@ final class ModelConfig implements BaseModel public ?string $baseURL; /** - * Custom headers sent with every request to the model provider. + * Custom headers for the model provider. * * @var array|null $headers */ @@ -58,6 +66,20 @@ final class ModelConfig implements BaseModel #[Optional(enum: Provider::class)] public ?string $provider; + /** + * Provider-specific options passed through to the AI SDK provider constructor. For Bedrock: { region, accessKeyId, secretAccessKey, sessionToken }. For Vertex: { project, location, googleAuthOptions }. + * + * @var ProviderOptionsVariants|null $providerOptions + */ + #[Optional] + public BedrockAPIKeyProviderOptions|BedrockAwsCredentialsProviderOptions|GoogleVertexProviderOptions|null $providerOptions; + + /** + * When true, hosted sessions will not copy x-model-api-key into model.apiKey. Use this when auth is carried through providerOptions instead of an API key. + */ + #[Optional('skipApiKeyFallback')] + public ?bool $skipAPIKeyFallback; + /** * `new ModelConfig()` is missing required properties by the API. * @@ -84,6 +106,7 @@ public function __construct() * * @param array|null $headers * @param Provider|value-of|null $provider + * @param ProviderOptionsShape|null $providerOptions */ public static function with( string $modelName, @@ -91,6 +114,8 @@ public static function with( ?string $baseURL = null, ?array $headers = null, Provider|string|null $provider = null, + BedrockAPIKeyProviderOptions|array|BedrockAwsCredentialsProviderOptions|GoogleVertexProviderOptions|null $providerOptions = null, + ?bool $skipAPIKeyFallback = null, ): self { $self = new self; @@ -100,6 +125,8 @@ public static function with( null !== $baseURL && $self['baseURL'] = $baseURL; null !== $headers && $self['headers'] = $headers; null !== $provider && $self['provider'] = $provider; + null !== $providerOptions && $self['providerOptions'] = $providerOptions; + null !== $skipAPIKeyFallback && $self['skipAPIKeyFallback'] = $skipAPIKeyFallback; return $self; } @@ -138,7 +165,7 @@ public function withBaseURL(string $baseURL): self } /** - * Custom headers sent with every request to the model provider. + * Custom headers for the model provider. * * @param array $headers */ @@ -162,4 +189,29 @@ public function withProvider(Provider|string $provider): self return $self; } + + /** + * Provider-specific options passed through to the AI SDK provider constructor. For Bedrock: { region, accessKeyId, secretAccessKey, sessionToken }. For Vertex: { project, location, googleAuthOptions }. + * + * @param ProviderOptionsShape $providerOptions + */ + public function withProviderOptions( + BedrockAPIKeyProviderOptions|array|BedrockAwsCredentialsProviderOptions|GoogleVertexProviderOptions $providerOptions, + ): self { + $self = clone $this; + $self['providerOptions'] = $providerOptions; + + return $self; + } + + /** + * When true, hosted sessions will not copy x-model-api-key into model.apiKey. Use this when auth is carried through providerOptions instead of an API key. + */ + public function withSkipAPIKeyFallback(bool $skipAPIKeyFallback): self + { + $self = clone $this; + $self['skipAPIKeyFallback'] = $skipAPIKeyFallback; + + return $self; + } } diff --git a/src/Sessions/ModelConfig/ProviderOptions.php b/src/Sessions/ModelConfig/ProviderOptions.php new file mode 100644 index 0000000..191fc94 --- /dev/null +++ b/src/Sessions/ModelConfig/ProviderOptions.php @@ -0,0 +1,39 @@ +|array + */ + public static function variants(): array + { + return [ + BedrockAPIKeyProviderOptions::class, + BedrockAwsCredentialsProviderOptions::class, + GoogleVertexProviderOptions::class, + ]; + } +} diff --git a/src/Sessions/ModelConfig/ProviderOptions/BedrockAPIKeyProviderOptions.php b/src/Sessions/ModelConfig/ProviderOptions/BedrockAPIKeyProviderOptions.php new file mode 100644 index 0000000..eb11f93 --- /dev/null +++ b/src/Sessions/ModelConfig/ProviderOptions/BedrockAPIKeyProviderOptions.php @@ -0,0 +1,68 @@ + */ + use SdkModel; + + /** + * AWS region for Amazon Bedrock. + */ + #[Required] + public string $region; + + /** + * `new BedrockAPIKeyProviderOptions()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * BedrockAPIKeyProviderOptions::with(region: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new BedrockAPIKeyProviderOptions)->withRegion(...) + * ``` + */ + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + */ + public static function with(string $region): self + { + $self = new self; + + $self['region'] = $region; + + return $self; + } + + /** + * AWS region for Amazon Bedrock. + */ + public function withRegion(string $region): self + { + $self = clone $this; + $self['region'] = $region; + + return $self; + } +} diff --git a/src/Sessions/ModelConfig/ProviderOptions/BedrockAwsCredentialsProviderOptions.php b/src/Sessions/ModelConfig/ProviderOptions/BedrockAwsCredentialsProviderOptions.php new file mode 100644 index 0000000..e26e0b5 --- /dev/null +++ b/src/Sessions/ModelConfig/ProviderOptions/BedrockAwsCredentialsProviderOptions.php @@ -0,0 +1,138 @@ + */ + use SdkModel; + + /** + * AWS access key ID for Bedrock. + */ + #[Required('accessKeyId')] + public string $accessKeyID; + + /** + * AWS region for Amazon Bedrock. + */ + #[Required] + public string $region; + + /** + * AWS secret access key for Bedrock. + */ + #[Required] + public string $secretAccessKey; + + /** + * Optional AWS session token for temporary credentials. + */ + #[Optional] + public ?string $sessionToken; + + /** + * `new BedrockAwsCredentialsProviderOptions()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * BedrockAwsCredentialsProviderOptions::with( + * accessKeyID: ..., region: ..., secretAccessKey: ... + * ) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new BedrockAwsCredentialsProviderOptions) + * ->withAccessKeyID(...) + * ->withRegion(...) + * ->withSecretAccessKey(...) + * ``` + */ + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + */ + public static function with( + string $accessKeyID, + string $region, + string $secretAccessKey, + ?string $sessionToken = null, + ): self { + $self = new self; + + $self['accessKeyID'] = $accessKeyID; + $self['region'] = $region; + $self['secretAccessKey'] = $secretAccessKey; + + null !== $sessionToken && $self['sessionToken'] = $sessionToken; + + return $self; + } + + /** + * AWS access key ID for Bedrock. + */ + public function withAccessKeyID(string $accessKeyID): self + { + $self = clone $this; + $self['accessKeyID'] = $accessKeyID; + + return $self; + } + + /** + * AWS region for Amazon Bedrock. + */ + public function withRegion(string $region): self + { + $self = clone $this; + $self['region'] = $region; + + return $self; + } + + /** + * AWS secret access key for Bedrock. + */ + public function withSecretAccessKey(string $secretAccessKey): self + { + $self = clone $this; + $self['secretAccessKey'] = $secretAccessKey; + + return $self; + } + + /** + * Optional AWS session token for temporary credentials. + */ + public function withSessionToken(string $sessionToken): self + { + $self = clone $this; + $self['sessionToken'] = $sessionToken; + + return $self; + } +} diff --git a/src/Sessions/ModelConfig/ProviderOptions/GoogleVertexProviderOptions.php b/src/Sessions/ModelConfig/ProviderOptions/GoogleVertexProviderOptions.php new file mode 100644 index 0000000..9de95e5 --- /dev/null +++ b/src/Sessions/ModelConfig/ProviderOptions/GoogleVertexProviderOptions.php @@ -0,0 +1,130 @@ +|null, + * location?: string|null, + * project?: string|null, + * } + */ +final class GoogleVertexProviderOptions implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Optional Google auth options for Vertex AI. + */ + #[Optional] + public ?GoogleAuthOptions $googleAuthOptions; + + /** + * Custom headers for Vertex AI requests. + * + * @var array|null $headers + */ + #[Optional(map: 'string')] + public ?array $headers; + + /** + * Google Cloud location for Vertex AI. + */ + #[Optional] + public ?string $location; + + /** + * Google Cloud project ID for Vertex AI. + */ + #[Optional] + public ?string $project; + + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + * + * @param GoogleAuthOptions|GoogleAuthOptionsShape|null $googleAuthOptions + * @param array|null $headers + */ + public static function with( + GoogleAuthOptions|array|null $googleAuthOptions = null, + ?array $headers = null, + ?string $location = null, + ?string $project = null, + ): self { + $self = new self; + + null !== $googleAuthOptions && $self['googleAuthOptions'] = $googleAuthOptions; + null !== $headers && $self['headers'] = $headers; + null !== $location && $self['location'] = $location; + null !== $project && $self['project'] = $project; + + return $self; + } + + /** + * Optional Google auth options for Vertex AI. + * + * @param GoogleAuthOptions|GoogleAuthOptionsShape $googleAuthOptions + */ + public function withGoogleAuthOptions( + GoogleAuthOptions|array $googleAuthOptions + ): self { + $self = clone $this; + $self['googleAuthOptions'] = $googleAuthOptions; + + return $self; + } + + /** + * Custom headers for Vertex AI requests. + * + * @param array $headers + */ + public function withHeaders(array $headers): self + { + $self = clone $this; + $self['headers'] = $headers; + + return $self; + } + + /** + * Google Cloud location for Vertex AI. + */ + public function withLocation(string $location): self + { + $self = clone $this; + $self['location'] = $location; + + return $self; + } + + /** + * Google Cloud project ID for Vertex AI. + */ + public function withProject(string $project): self + { + $self = clone $this; + $self['project'] = $project; + + return $self; + } +} diff --git a/src/Sessions/ModelConfig/ProviderOptions/GoogleVertexProviderOptions/GoogleAuthOptions.php b/src/Sessions/ModelConfig/ProviderOptions/GoogleVertexProviderOptions/GoogleAuthOptions.php new file mode 100644 index 0000000..6272412 --- /dev/null +++ b/src/Sessions/ModelConfig/ProviderOptions/GoogleVertexProviderOptions/GoogleAuthOptions.php @@ -0,0 +1,60 @@ + */ + use SdkModel; + + #[Optional] + public ?Credentials $credentials; + + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + * + * @param Credentials|CredentialsShape|null $credentials + */ + public static function with(Credentials|array|null $credentials = null): self + { + $self = new self; + + null !== $credentials && $self['credentials'] = $credentials; + + return $self; + } + + /** + * @param Credentials|CredentialsShape $credentials + */ + public function withCredentials(Credentials|array $credentials): self + { + $self = clone $this; + $self['credentials'] = $credentials; + + return $self; + } +} diff --git a/src/Sessions/ModelConfig/ProviderOptions/GoogleVertexProviderOptions/GoogleAuthOptions/Credentials.php b/src/Sessions/ModelConfig/ProviderOptions/GoogleVertexProviderOptions/GoogleAuthOptions/Credentials.php new file mode 100644 index 0000000..8842002 --- /dev/null +++ b/src/Sessions/ModelConfig/ProviderOptions/GoogleVertexProviderOptions/GoogleAuthOptions/Credentials.php @@ -0,0 +1,192 @@ + */ + use SdkModel; + + #[Optional('auth_provider_x509_cert_url')] + public ?string $authProviderX509CertURL; + + #[Optional('auth_uri')] + public ?string $authUri; + + #[Optional('client_email')] + public ?string $clientEmail; + + #[Optional('client_id')] + public ?string $clientID; + + #[Optional('client_x509_cert_url')] + public ?string $clientX509CertURL; + + #[Optional('private_key')] + public ?string $privateKey; + + #[Optional('private_key_id')] + public ?string $privateKeyID; + + #[Optional('project_id')] + public ?string $projectID; + + #[Optional('token_uri')] + public ?string $tokenUri; + + #[Optional] + public ?string $type; + + #[Optional('universe_domain')] + public ?string $universeDomain; + + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + */ + public static function with( + ?string $authProviderX509CertURL = null, + ?string $authUri = null, + ?string $clientEmail = null, + ?string $clientID = null, + ?string $clientX509CertURL = null, + ?string $privateKey = null, + ?string $privateKeyID = null, + ?string $projectID = null, + ?string $tokenUri = null, + ?string $type = null, + ?string $universeDomain = null, + ): self { + $self = new self; + + null !== $authProviderX509CertURL && $self['authProviderX509CertURL'] = $authProviderX509CertURL; + null !== $authUri && $self['authUri'] = $authUri; + null !== $clientEmail && $self['clientEmail'] = $clientEmail; + null !== $clientID && $self['clientID'] = $clientID; + null !== $clientX509CertURL && $self['clientX509CertURL'] = $clientX509CertURL; + null !== $privateKey && $self['privateKey'] = $privateKey; + null !== $privateKeyID && $self['privateKeyID'] = $privateKeyID; + null !== $projectID && $self['projectID'] = $projectID; + null !== $tokenUri && $self['tokenUri'] = $tokenUri; + null !== $type && $self['type'] = $type; + null !== $universeDomain && $self['universeDomain'] = $universeDomain; + + return $self; + } + + public function withAuthProviderX509CertURL( + string $authProviderX509CertURL + ): self { + $self = clone $this; + $self['authProviderX509CertURL'] = $authProviderX509CertURL; + + return $self; + } + + public function withAuthUri(string $authUri): self + { + $self = clone $this; + $self['authUri'] = $authUri; + + return $self; + } + + public function withClientEmail(string $clientEmail): self + { + $self = clone $this; + $self['clientEmail'] = $clientEmail; + + return $self; + } + + public function withClientID(string $clientID): self + { + $self = clone $this; + $self['clientID'] = $clientID; + + return $self; + } + + public function withClientX509CertURL(string $clientX509CertURL): self + { + $self = clone $this; + $self['clientX509CertURL'] = $clientX509CertURL; + + return $self; + } + + public function withPrivateKey(string $privateKey): self + { + $self = clone $this; + $self['privateKey'] = $privateKey; + + return $self; + } + + public function withPrivateKeyID(string $privateKeyID): self + { + $self = clone $this; + $self['privateKeyID'] = $privateKeyID; + + return $self; + } + + public function withProjectID(string $projectID): self + { + $self = clone $this; + $self['projectID'] = $projectID; + + return $self; + } + + public function withTokenUri(string $tokenUri): self + { + $self = clone $this; + $self['tokenUri'] = $tokenUri; + + return $self; + } + + public function withType(string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } + + public function withUniverseDomain(string $universeDomain): self + { + $self = clone $this; + $self['universeDomain'] = $universeDomain; + + return $self; + } +} diff --git a/src/Sessions/SessionExecuteParams/ExecuteOptions.php b/src/Sessions/SessionExecuteParams/ExecuteOptions.php index be26904..c5e676f 100644 --- a/src/Sessions/SessionExecuteParams/ExecuteOptions.php +++ b/src/Sessions/SessionExecuteParams/ExecuteOptions.php @@ -11,11 +11,7 @@ /** * @phpstan-type ExecuteOptionsShape = array{ - * instruction: string, - * highlightCursor?: bool|null, - * maxSteps?: float|null, - * toolTimeout?: float|null, - * useSearch?: bool|null, + * instruction: string, highlightCursor?: bool|null, maxSteps?: float|null * } */ final class ExecuteOptions implements BaseModel @@ -41,18 +37,6 @@ final class ExecuteOptions implements BaseModel #[Optional] public ?float $maxSteps; - /** - * Timeout in milliseconds for each agent tool call. - */ - #[Optional] - public ?float $toolTimeout; - - /** - * Whether to enable the web search tool powered by Browserbase Search API. - */ - #[Optional] - public ?bool $useSearch; - /** * `new ExecuteOptions()` is missing required properties by the API. * @@ -80,9 +64,7 @@ public function __construct() public static function with( string $instruction, ?bool $highlightCursor = null, - ?float $maxSteps = null, - ?float $toolTimeout = null, - ?bool $useSearch = null, + ?float $maxSteps = null ): self { $self = new self; @@ -90,8 +72,6 @@ public static function with( null !== $highlightCursor && $self['highlightCursor'] = $highlightCursor; null !== $maxSteps && $self['maxSteps'] = $maxSteps; - null !== $toolTimeout && $self['toolTimeout'] = $toolTimeout; - null !== $useSearch && $self['useSearch'] = $useSearch; return $self; } @@ -128,26 +108,4 @@ public function withMaxSteps(float $maxSteps): self return $self; } - - /** - * Timeout in milliseconds for each agent tool call. - */ - public function withToolTimeout(float $toolTimeout): self - { - $self = clone $this; - $self['toolTimeout'] = $toolTimeout; - - return $self; - } - - /** - * Whether to enable the web search tool powered by Browserbase Search API. - */ - public function withUseSearch(bool $useSearch): self - { - $self = clone $this; - $self['useSearch'] = $useSearch; - - return $self; - } } diff --git a/src/Sessions/SessionStartParams.php b/src/Sessions/SessionStartParams.php index c01446d..ce1c8c4 100644 --- a/src/Sessions/SessionStartParams.php +++ b/src/Sessions/SessionStartParams.php @@ -11,6 +11,9 @@ use Stagehand\Core\Contracts\BaseModel; use Stagehand\Sessions\SessionStartParams\Browser; use Stagehand\Sessions\SessionStartParams\BrowserbaseSessionCreateParams; +use Stagehand\Sessions\SessionStartParams\ModelClientOptions\BedrockAPIKeyModelClientOptions; +use Stagehand\Sessions\SessionStartParams\ModelClientOptions\BedrockAwsCredentialsModelClientOptions; +use Stagehand\Sessions\SessionStartParams\ModelClientOptions\GenericModelClientOptions; use Stagehand\Sessions\SessionStartParams\XStreamResponse; /** @@ -18,8 +21,10 @@ * * @see Stagehand\Services\SessionsService::start() * + * @phpstan-import-type ModelClientOptionsVariants from \Stagehand\Sessions\SessionStartParams\ModelClientOptions * @phpstan-import-type BrowserShape from \Stagehand\Sessions\SessionStartParams\Browser * @phpstan-import-type BrowserbaseSessionCreateParamsShape from \Stagehand\Sessions\SessionStartParams\BrowserbaseSessionCreateParams + * @phpstan-import-type ModelClientOptionsShape from \Stagehand\Sessions\SessionStartParams\ModelClientOptions * * @phpstan-type SessionStartParamsShape = array{ * modelName: string, @@ -29,6 +34,7 @@ * browserbaseSessionID?: string|null, * domSettleTimeoutMs?: float|null, * experimental?: bool|null, + * modelClientOptions?: ModelClientOptionsShape|null, * selfHeal?: bool|null, * systemPrompt?: string|null, * verbose?: float|null, @@ -75,6 +81,14 @@ final class SessionStartParams implements BaseModel #[Optional] public ?bool $experimental; + /** + * Optional provider-specific configuration for the session model (for example Bedrock region and credentials). + * + * @var ModelClientOptionsVariants|null $modelClientOptions + */ + #[Optional] + public BedrockAPIKeyModelClientOptions|BedrockAwsCredentialsModelClientOptions|GenericModelClientOptions|null $modelClientOptions; + /** * Enable self-healing for failed actions. */ @@ -133,6 +147,7 @@ public function __construct() * * @param Browser|BrowserShape|null $browser * @param BrowserbaseSessionCreateParams|BrowserbaseSessionCreateParamsShape|null $browserbaseSessionCreateParams + * @param ModelClientOptionsShape|null $modelClientOptions * @param XStreamResponse|value-of|null $xStreamResponse */ public static function with( @@ -143,6 +158,7 @@ public static function with( ?string $browserbaseSessionID = null, ?float $domSettleTimeoutMs = null, ?bool $experimental = null, + BedrockAPIKeyModelClientOptions|array|BedrockAwsCredentialsModelClientOptions|GenericModelClientOptions|null $modelClientOptions = null, ?bool $selfHeal = null, ?string $systemPrompt = null, ?float $verbose = null, @@ -159,6 +175,7 @@ public static function with( null !== $browserbaseSessionID && $self['browserbaseSessionID'] = $browserbaseSessionID; null !== $domSettleTimeoutMs && $self['domSettleTimeoutMs'] = $domSettleTimeoutMs; null !== $experimental && $self['experimental'] = $experimental; + null !== $modelClientOptions && $self['modelClientOptions'] = $modelClientOptions; null !== $selfHeal && $self['selfHeal'] = $selfHeal; null !== $systemPrompt && $self['systemPrompt'] = $systemPrompt; null !== $verbose && $self['verbose'] = $verbose; @@ -243,6 +260,20 @@ public function withExperimental(bool $experimental): self return $self; } + /** + * Optional provider-specific configuration for the session model (for example Bedrock region and credentials). + * + * @param ModelClientOptionsShape $modelClientOptions + */ + public function withModelClientOptions( + BedrockAPIKeyModelClientOptions|array|BedrockAwsCredentialsModelClientOptions|GenericModelClientOptions $modelClientOptions, + ): self { + $self = clone $this; + $self['modelClientOptions'] = $modelClientOptions; + + return $self; + } + /** * Enable self-healing for failed actions. */ diff --git a/src/Sessions/SessionStartParams/ModelClientOptions.php b/src/Sessions/SessionStartParams/ModelClientOptions.php new file mode 100644 index 0000000..66c9cfc --- /dev/null +++ b/src/Sessions/SessionStartParams/ModelClientOptions.php @@ -0,0 +1,39 @@ +|array + */ + public static function variants(): array + { + return [ + BedrockAPIKeyModelClientOptions::class, + BedrockAwsCredentialsModelClientOptions::class, + GenericModelClientOptions::class, + ]; + } +} diff --git a/src/Sessions/SessionStartParams/ModelClientOptions/BedrockAPIKeyModelClientOptions.php b/src/Sessions/SessionStartParams/ModelClientOptions/BedrockAPIKeyModelClientOptions.php new file mode 100644 index 0000000..34738f5 --- /dev/null +++ b/src/Sessions/SessionStartParams/ModelClientOptions/BedrockAPIKeyModelClientOptions.php @@ -0,0 +1,161 @@ +|null, + * skipAPIKeyFallback?: bool|null, + * } + */ +final class BedrockAPIKeyModelClientOptions implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Short-term Bedrock API key for bearer-token auth. + */ + #[Required] + public string $apiKey; + + #[Required] + public ProviderOptions $providerOptions; + + /** + * Base URL for the model provider. + */ + #[Optional] + public ?string $baseURL; + + /** + * Custom headers for the model provider. + * + * @var array|null $headers + */ + #[Optional(map: 'string')] + public ?array $headers; + + /** + * When true, hosted sessions will not copy x-model-api-key into model.apiKey. Use this when auth is carried through providerOptions instead of an API key. + */ + #[Optional('skipApiKeyFallback')] + public ?bool $skipAPIKeyFallback; + + /** + * `new BedrockAPIKeyModelClientOptions()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * BedrockAPIKeyModelClientOptions::with(apiKey: ..., providerOptions: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new BedrockAPIKeyModelClientOptions)->withAPIKey(...)->withProviderOptions(...) + * ``` + */ + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + * + * @param ProviderOptions|ProviderOptionsShape $providerOptions + * @param array|null $headers + */ + public static function with( + string $apiKey, + ProviderOptions|array $providerOptions, + ?string $baseURL = null, + ?array $headers = null, + ?bool $skipAPIKeyFallback = null, + ): self { + $self = new self; + + $self['apiKey'] = $apiKey; + $self['providerOptions'] = $providerOptions; + + null !== $baseURL && $self['baseURL'] = $baseURL; + null !== $headers && $self['headers'] = $headers; + null !== $skipAPIKeyFallback && $self['skipAPIKeyFallback'] = $skipAPIKeyFallback; + + return $self; + } + + /** + * Short-term Bedrock API key for bearer-token auth. + */ + public function withAPIKey(string $apiKey): self + { + $self = clone $this; + $self['apiKey'] = $apiKey; + + return $self; + } + + /** + * @param ProviderOptions|ProviderOptionsShape $providerOptions + */ + public function withProviderOptions( + ProviderOptions|array $providerOptions + ): self { + $self = clone $this; + $self['providerOptions'] = $providerOptions; + + return $self; + } + + /** + * Base URL for the model provider. + */ + public function withBaseURL(string $baseURL): self + { + $self = clone $this; + $self['baseURL'] = $baseURL; + + return $self; + } + + /** + * Custom headers for the model provider. + * + * @param array $headers + */ + public function withHeaders(array $headers): self + { + $self = clone $this; + $self['headers'] = $headers; + + return $self; + } + + /** + * When true, hosted sessions will not copy x-model-api-key into model.apiKey. Use this when auth is carried through providerOptions instead of an API key. + */ + public function withSkipAPIKeyFallback(bool $skipAPIKeyFallback): self + { + $self = clone $this; + $self['skipAPIKeyFallback'] = $skipAPIKeyFallback; + + return $self; + } +} diff --git a/src/Sessions/SessionStartParams/ModelClientOptions/BedrockAPIKeyModelClientOptions/ProviderOptions.php b/src/Sessions/SessionStartParams/ModelClientOptions/BedrockAPIKeyModelClientOptions/ProviderOptions.php new file mode 100644 index 0000000..ca4707f --- /dev/null +++ b/src/Sessions/SessionStartParams/ModelClientOptions/BedrockAPIKeyModelClientOptions/ProviderOptions.php @@ -0,0 +1,68 @@ + */ + use SdkModel; + + /** + * AWS region for Amazon Bedrock. + */ + #[Required] + public string $region; + + /** + * `new ProviderOptions()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * ProviderOptions::with(region: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new ProviderOptions)->withRegion(...) + * ``` + */ + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + */ + public static function with(string $region): self + { + $self = new self; + + $self['region'] = $region; + + return $self; + } + + /** + * AWS region for Amazon Bedrock. + */ + public function withRegion(string $region): self + { + $self = clone $this; + $self['region'] = $region; + + return $self; + } +} diff --git a/src/Sessions/SessionStartParams/ModelClientOptions/BedrockAwsCredentialsModelClientOptions.php b/src/Sessions/SessionStartParams/ModelClientOptions/BedrockAwsCredentialsModelClientOptions.php new file mode 100644 index 0000000..a5420a4 --- /dev/null +++ b/src/Sessions/SessionStartParams/ModelClientOptions/BedrockAwsCredentialsModelClientOptions.php @@ -0,0 +1,141 @@ +|null, + * skipAPIKeyFallback?: bool|null, + * } + */ +final class BedrockAwsCredentialsModelClientOptions implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + #[Required] + public ProviderOptions $providerOptions; + + /** + * Base URL for the model provider. + */ + #[Optional] + public ?string $baseURL; + + /** + * Custom headers for the model provider. + * + * @var array|null $headers + */ + #[Optional(map: 'string')] + public ?array $headers; + + /** + * When true, hosted sessions will not copy x-model-api-key into model.apiKey. Use this when auth is carried through providerOptions instead of an API key. + */ + #[Optional('skipApiKeyFallback')] + public ?bool $skipAPIKeyFallback; + + /** + * `new BedrockAwsCredentialsModelClientOptions()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * BedrockAwsCredentialsModelClientOptions::with(providerOptions: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new BedrockAwsCredentialsModelClientOptions)->withProviderOptions(...) + * ``` + */ + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + * + * @param ProviderOptions|ProviderOptionsShape $providerOptions + * @param array|null $headers + */ + public static function with( + ProviderOptions|array $providerOptions, + ?string $baseURL = null, + ?array $headers = null, + ?bool $skipAPIKeyFallback = null, + ): self { + $self = new self; + + $self['providerOptions'] = $providerOptions; + + null !== $baseURL && $self['baseURL'] = $baseURL; + null !== $headers && $self['headers'] = $headers; + null !== $skipAPIKeyFallback && $self['skipAPIKeyFallback'] = $skipAPIKeyFallback; + + return $self; + } + + /** + * @param ProviderOptions|ProviderOptionsShape $providerOptions + */ + public function withProviderOptions( + ProviderOptions|array $providerOptions + ): self { + $self = clone $this; + $self['providerOptions'] = $providerOptions; + + return $self; + } + + /** + * Base URL for the model provider. + */ + public function withBaseURL(string $baseURL): self + { + $self = clone $this; + $self['baseURL'] = $baseURL; + + return $self; + } + + /** + * Custom headers for the model provider. + * + * @param array $headers + */ + public function withHeaders(array $headers): self + { + $self = clone $this; + $self['headers'] = $headers; + + return $self; + } + + /** + * When true, hosted sessions will not copy x-model-api-key into model.apiKey. Use this when auth is carried through providerOptions instead of an API key. + */ + public function withSkipAPIKeyFallback(bool $skipAPIKeyFallback): self + { + $self = clone $this; + $self['skipAPIKeyFallback'] = $skipAPIKeyFallback; + + return $self; + } +} diff --git a/src/Sessions/SessionStartParams/ModelClientOptions/BedrockAwsCredentialsModelClientOptions/ProviderOptions.php b/src/Sessions/SessionStartParams/ModelClientOptions/BedrockAwsCredentialsModelClientOptions/ProviderOptions.php new file mode 100644 index 0000000..b14970e --- /dev/null +++ b/src/Sessions/SessionStartParams/ModelClientOptions/BedrockAwsCredentialsModelClientOptions/ProviderOptions.php @@ -0,0 +1,136 @@ + */ + use SdkModel; + + /** + * AWS access key ID for Bedrock. + */ + #[Required('accessKeyId')] + public string $accessKeyID; + + /** + * AWS region for Amazon Bedrock. + */ + #[Required] + public string $region; + + /** + * AWS secret access key for Bedrock. + */ + #[Required] + public string $secretAccessKey; + + /** + * Optional AWS session token for temporary credentials. + */ + #[Optional] + public ?string $sessionToken; + + /** + * `new ProviderOptions()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * ProviderOptions::with(accessKeyID: ..., region: ..., secretAccessKey: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new ProviderOptions) + * ->withAccessKeyID(...) + * ->withRegion(...) + * ->withSecretAccessKey(...) + * ``` + */ + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + */ + public static function with( + string $accessKeyID, + string $region, + string $secretAccessKey, + ?string $sessionToken = null, + ): self { + $self = new self; + + $self['accessKeyID'] = $accessKeyID; + $self['region'] = $region; + $self['secretAccessKey'] = $secretAccessKey; + + null !== $sessionToken && $self['sessionToken'] = $sessionToken; + + return $self; + } + + /** + * AWS access key ID for Bedrock. + */ + public function withAccessKeyID(string $accessKeyID): self + { + $self = clone $this; + $self['accessKeyID'] = $accessKeyID; + + return $self; + } + + /** + * AWS region for Amazon Bedrock. + */ + public function withRegion(string $region): self + { + $self = clone $this; + $self['region'] = $region; + + return $self; + } + + /** + * AWS secret access key for Bedrock. + */ + public function withSecretAccessKey(string $secretAccessKey): self + { + $self = clone $this; + $self['secretAccessKey'] = $secretAccessKey; + + return $self; + } + + /** + * Optional AWS session token for temporary credentials. + */ + public function withSessionToken(string $sessionToken): self + { + $self = clone $this; + $self['sessionToken'] = $sessionToken; + + return $self; + } +} diff --git a/src/Sessions/SessionStartParams/ModelClientOptions/GenericModelClientOptions.php b/src/Sessions/SessionStartParams/ModelClientOptions/GenericModelClientOptions.php new file mode 100644 index 0000000..f109c00 --- /dev/null +++ b/src/Sessions/SessionStartParams/ModelClientOptions/GenericModelClientOptions.php @@ -0,0 +1,155 @@ +|null, + * providerOptions?: ProviderOptionsShape|null, + * skipAPIKeyFallback?: bool|null, + * } + */ +final class GenericModelClientOptions implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * API key for the model provider. + */ + #[Optional] + public ?string $apiKey; + + /** + * Base URL for the model provider. + */ + #[Optional] + public ?string $baseURL; + + /** + * Custom headers for the model provider. + * + * @var array|null $headers + */ + #[Optional(map: 'string')] + public ?array $headers; + + /** + * Provider-specific options passed through to the AI SDK provider constructor. For Bedrock: { region, accessKeyId, secretAccessKey, sessionToken }. For Vertex: { project, location, googleAuthOptions }. + * + * @var ProviderOptionsVariants|null $providerOptions + */ + #[Optional] + public BedrockAPIKeyProviderOptions|BedrockAwsCredentialsProviderOptions|GoogleVertexProviderOptions|null $providerOptions; + + /** + * When true, hosted sessions will not copy x-model-api-key into model.apiKey. Use this when auth is carried through providerOptions instead of an API key. + */ + #[Optional('skipApiKeyFallback')] + public ?bool $skipAPIKeyFallback; + + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + * + * @param array|null $headers + * @param ProviderOptionsShape|null $providerOptions + */ + public static function with( + ?string $apiKey = null, + ?string $baseURL = null, + ?array $headers = null, + BedrockAPIKeyProviderOptions|array|BedrockAwsCredentialsProviderOptions|GoogleVertexProviderOptions|null $providerOptions = null, + ?bool $skipAPIKeyFallback = null, + ): self { + $self = new self; + + null !== $apiKey && $self['apiKey'] = $apiKey; + null !== $baseURL && $self['baseURL'] = $baseURL; + null !== $headers && $self['headers'] = $headers; + null !== $providerOptions && $self['providerOptions'] = $providerOptions; + null !== $skipAPIKeyFallback && $self['skipAPIKeyFallback'] = $skipAPIKeyFallback; + + return $self; + } + + /** + * API key for the model provider. + */ + public function withAPIKey(string $apiKey): self + { + $self = clone $this; + $self['apiKey'] = $apiKey; + + return $self; + } + + /** + * Base URL for the model provider. + */ + public function withBaseURL(string $baseURL): self + { + $self = clone $this; + $self['baseURL'] = $baseURL; + + return $self; + } + + /** + * Custom headers for the model provider. + * + * @param array $headers + */ + public function withHeaders(array $headers): self + { + $self = clone $this; + $self['headers'] = $headers; + + return $self; + } + + /** + * Provider-specific options passed through to the AI SDK provider constructor. For Bedrock: { region, accessKeyId, secretAccessKey, sessionToken }. For Vertex: { project, location, googleAuthOptions }. + * + * @param ProviderOptionsShape $providerOptions + */ + public function withProviderOptions( + BedrockAPIKeyProviderOptions|array|BedrockAwsCredentialsProviderOptions|GoogleVertexProviderOptions $providerOptions, + ): self { + $self = clone $this; + $self['providerOptions'] = $providerOptions; + + return $self; + } + + /** + * When true, hosted sessions will not copy x-model-api-key into model.apiKey. Use this when auth is carried through providerOptions instead of an API key. + */ + public function withSkipAPIKeyFallback(bool $skipAPIKeyFallback): self + { + $self = clone $this; + $self['skipAPIKeyFallback'] = $skipAPIKeyFallback; + + return $self; + } +} diff --git a/src/Sessions/SessionStartParams/ModelClientOptions/GenericModelClientOptions/ProviderOptions.php b/src/Sessions/SessionStartParams/ModelClientOptions/GenericModelClientOptions/ProviderOptions.php new file mode 100644 index 0000000..904b654 --- /dev/null +++ b/src/Sessions/SessionStartParams/ModelClientOptions/GenericModelClientOptions/ProviderOptions.php @@ -0,0 +1,39 @@ +|array + */ + public static function variants(): array + { + return [ + BedrockAPIKeyProviderOptions::class, + BedrockAwsCredentialsProviderOptions::class, + GoogleVertexProviderOptions::class, + ]; + } +} diff --git a/src/Sessions/SessionStartParams/ModelClientOptions/GenericModelClientOptions/ProviderOptions/BedrockAPIKeyProviderOptions.php b/src/Sessions/SessionStartParams/ModelClientOptions/GenericModelClientOptions/ProviderOptions/BedrockAPIKeyProviderOptions.php new file mode 100644 index 0000000..518a59a --- /dev/null +++ b/src/Sessions/SessionStartParams/ModelClientOptions/GenericModelClientOptions/ProviderOptions/BedrockAPIKeyProviderOptions.php @@ -0,0 +1,68 @@ + */ + use SdkModel; + + /** + * AWS region for Amazon Bedrock. + */ + #[Required] + public string $region; + + /** + * `new BedrockAPIKeyProviderOptions()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * BedrockAPIKeyProviderOptions::with(region: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new BedrockAPIKeyProviderOptions)->withRegion(...) + * ``` + */ + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + */ + public static function with(string $region): self + { + $self = new self; + + $self['region'] = $region; + + return $self; + } + + /** + * AWS region for Amazon Bedrock. + */ + public function withRegion(string $region): self + { + $self = clone $this; + $self['region'] = $region; + + return $self; + } +} diff --git a/src/Sessions/SessionStartParams/ModelClientOptions/GenericModelClientOptions/ProviderOptions/BedrockAwsCredentialsProviderOptions.php b/src/Sessions/SessionStartParams/ModelClientOptions/GenericModelClientOptions/ProviderOptions/BedrockAwsCredentialsProviderOptions.php new file mode 100644 index 0000000..69d78b8 --- /dev/null +++ b/src/Sessions/SessionStartParams/ModelClientOptions/GenericModelClientOptions/ProviderOptions/BedrockAwsCredentialsProviderOptions.php @@ -0,0 +1,138 @@ + */ + use SdkModel; + + /** + * AWS access key ID for Bedrock. + */ + #[Required('accessKeyId')] + public string $accessKeyID; + + /** + * AWS region for Amazon Bedrock. + */ + #[Required] + public string $region; + + /** + * AWS secret access key for Bedrock. + */ + #[Required] + public string $secretAccessKey; + + /** + * Optional AWS session token for temporary credentials. + */ + #[Optional] + public ?string $sessionToken; + + /** + * `new BedrockAwsCredentialsProviderOptions()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * BedrockAwsCredentialsProviderOptions::with( + * accessKeyID: ..., region: ..., secretAccessKey: ... + * ) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new BedrockAwsCredentialsProviderOptions) + * ->withAccessKeyID(...) + * ->withRegion(...) + * ->withSecretAccessKey(...) + * ``` + */ + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + */ + public static function with( + string $accessKeyID, + string $region, + string $secretAccessKey, + ?string $sessionToken = null, + ): self { + $self = new self; + + $self['accessKeyID'] = $accessKeyID; + $self['region'] = $region; + $self['secretAccessKey'] = $secretAccessKey; + + null !== $sessionToken && $self['sessionToken'] = $sessionToken; + + return $self; + } + + /** + * AWS access key ID for Bedrock. + */ + public function withAccessKeyID(string $accessKeyID): self + { + $self = clone $this; + $self['accessKeyID'] = $accessKeyID; + + return $self; + } + + /** + * AWS region for Amazon Bedrock. + */ + public function withRegion(string $region): self + { + $self = clone $this; + $self['region'] = $region; + + return $self; + } + + /** + * AWS secret access key for Bedrock. + */ + public function withSecretAccessKey(string $secretAccessKey): self + { + $self = clone $this; + $self['secretAccessKey'] = $secretAccessKey; + + return $self; + } + + /** + * Optional AWS session token for temporary credentials. + */ + public function withSessionToken(string $sessionToken): self + { + $self = clone $this; + $self['sessionToken'] = $sessionToken; + + return $self; + } +} diff --git a/src/Sessions/SessionStartParams/ModelClientOptions/GenericModelClientOptions/ProviderOptions/GoogleVertexProviderOptions.php b/src/Sessions/SessionStartParams/ModelClientOptions/GenericModelClientOptions/ProviderOptions/GoogleVertexProviderOptions.php new file mode 100644 index 0000000..1abd50f --- /dev/null +++ b/src/Sessions/SessionStartParams/ModelClientOptions/GenericModelClientOptions/ProviderOptions/GoogleVertexProviderOptions.php @@ -0,0 +1,130 @@ +|null, + * location?: string|null, + * project?: string|null, + * } + */ +final class GoogleVertexProviderOptions implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Optional Google auth options for Vertex AI. + */ + #[Optional] + public ?GoogleAuthOptions $googleAuthOptions; + + /** + * Custom headers for Vertex AI requests. + * + * @var array|null $headers + */ + #[Optional(map: 'string')] + public ?array $headers; + + /** + * Google Cloud location for Vertex AI. + */ + #[Optional] + public ?string $location; + + /** + * Google Cloud project ID for Vertex AI. + */ + #[Optional] + public ?string $project; + + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + * + * @param GoogleAuthOptions|GoogleAuthOptionsShape|null $googleAuthOptions + * @param array|null $headers + */ + public static function with( + GoogleAuthOptions|array|null $googleAuthOptions = null, + ?array $headers = null, + ?string $location = null, + ?string $project = null, + ): self { + $self = new self; + + null !== $googleAuthOptions && $self['googleAuthOptions'] = $googleAuthOptions; + null !== $headers && $self['headers'] = $headers; + null !== $location && $self['location'] = $location; + null !== $project && $self['project'] = $project; + + return $self; + } + + /** + * Optional Google auth options for Vertex AI. + * + * @param GoogleAuthOptions|GoogleAuthOptionsShape $googleAuthOptions + */ + public function withGoogleAuthOptions( + GoogleAuthOptions|array $googleAuthOptions + ): self { + $self = clone $this; + $self['googleAuthOptions'] = $googleAuthOptions; + + return $self; + } + + /** + * Custom headers for Vertex AI requests. + * + * @param array $headers + */ + public function withHeaders(array $headers): self + { + $self = clone $this; + $self['headers'] = $headers; + + return $self; + } + + /** + * Google Cloud location for Vertex AI. + */ + public function withLocation(string $location): self + { + $self = clone $this; + $self['location'] = $location; + + return $self; + } + + /** + * Google Cloud project ID for Vertex AI. + */ + public function withProject(string $project): self + { + $self = clone $this; + $self['project'] = $project; + + return $self; + } +} diff --git a/src/Sessions/SessionStartParams/ModelClientOptions/GenericModelClientOptions/ProviderOptions/GoogleVertexProviderOptions/GoogleAuthOptions.php b/src/Sessions/SessionStartParams/ModelClientOptions/GenericModelClientOptions/ProviderOptions/GoogleVertexProviderOptions/GoogleAuthOptions.php new file mode 100644 index 0000000..db81c7d --- /dev/null +++ b/src/Sessions/SessionStartParams/ModelClientOptions/GenericModelClientOptions/ProviderOptions/GoogleVertexProviderOptions/GoogleAuthOptions.php @@ -0,0 +1,60 @@ + */ + use SdkModel; + + #[Optional] + public ?Credentials $credentials; + + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + * + * @param Credentials|CredentialsShape|null $credentials + */ + public static function with(Credentials|array|null $credentials = null): self + { + $self = new self; + + null !== $credentials && $self['credentials'] = $credentials; + + return $self; + } + + /** + * @param Credentials|CredentialsShape $credentials + */ + public function withCredentials(Credentials|array $credentials): self + { + $self = clone $this; + $self['credentials'] = $credentials; + + return $self; + } +} diff --git a/src/Sessions/SessionStartParams/ModelClientOptions/GenericModelClientOptions/ProviderOptions/GoogleVertexProviderOptions/GoogleAuthOptions/Credentials.php b/src/Sessions/SessionStartParams/ModelClientOptions/GenericModelClientOptions/ProviderOptions/GoogleVertexProviderOptions/GoogleAuthOptions/Credentials.php new file mode 100644 index 0000000..76e18c5 --- /dev/null +++ b/src/Sessions/SessionStartParams/ModelClientOptions/GenericModelClientOptions/ProviderOptions/GoogleVertexProviderOptions/GoogleAuthOptions/Credentials.php @@ -0,0 +1,192 @@ + */ + use SdkModel; + + #[Optional('auth_provider_x509_cert_url')] + public ?string $authProviderX509CertURL; + + #[Optional('auth_uri')] + public ?string $authUri; + + #[Optional('client_email')] + public ?string $clientEmail; + + #[Optional('client_id')] + public ?string $clientID; + + #[Optional('client_x509_cert_url')] + public ?string $clientX509CertURL; + + #[Optional('private_key')] + public ?string $privateKey; + + #[Optional('private_key_id')] + public ?string $privateKeyID; + + #[Optional('project_id')] + public ?string $projectID; + + #[Optional('token_uri')] + public ?string $tokenUri; + + #[Optional] + public ?string $type; + + #[Optional('universe_domain')] + public ?string $universeDomain; + + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + */ + public static function with( + ?string $authProviderX509CertURL = null, + ?string $authUri = null, + ?string $clientEmail = null, + ?string $clientID = null, + ?string $clientX509CertURL = null, + ?string $privateKey = null, + ?string $privateKeyID = null, + ?string $projectID = null, + ?string $tokenUri = null, + ?string $type = null, + ?string $universeDomain = null, + ): self { + $self = new self; + + null !== $authProviderX509CertURL && $self['authProviderX509CertURL'] = $authProviderX509CertURL; + null !== $authUri && $self['authUri'] = $authUri; + null !== $clientEmail && $self['clientEmail'] = $clientEmail; + null !== $clientID && $self['clientID'] = $clientID; + null !== $clientX509CertURL && $self['clientX509CertURL'] = $clientX509CertURL; + null !== $privateKey && $self['privateKey'] = $privateKey; + null !== $privateKeyID && $self['privateKeyID'] = $privateKeyID; + null !== $projectID && $self['projectID'] = $projectID; + null !== $tokenUri && $self['tokenUri'] = $tokenUri; + null !== $type && $self['type'] = $type; + null !== $universeDomain && $self['universeDomain'] = $universeDomain; + + return $self; + } + + public function withAuthProviderX509CertURL( + string $authProviderX509CertURL + ): self { + $self = clone $this; + $self['authProviderX509CertURL'] = $authProviderX509CertURL; + + return $self; + } + + public function withAuthUri(string $authUri): self + { + $self = clone $this; + $self['authUri'] = $authUri; + + return $self; + } + + public function withClientEmail(string $clientEmail): self + { + $self = clone $this; + $self['clientEmail'] = $clientEmail; + + return $self; + } + + public function withClientID(string $clientID): self + { + $self = clone $this; + $self['clientID'] = $clientID; + + return $self; + } + + public function withClientX509CertURL(string $clientX509CertURL): self + { + $self = clone $this; + $self['clientX509CertURL'] = $clientX509CertURL; + + return $self; + } + + public function withPrivateKey(string $privateKey): self + { + $self = clone $this; + $self['privateKey'] = $privateKey; + + return $self; + } + + public function withPrivateKeyID(string $privateKeyID): self + { + $self = clone $this; + $self['privateKeyID'] = $privateKeyID; + + return $self; + } + + public function withProjectID(string $projectID): self + { + $self = clone $this; + $self['projectID'] = $projectID; + + return $self; + } + + public function withTokenUri(string $tokenUri): self + { + $self = clone $this; + $self['tokenUri'] = $tokenUri; + + return $self; + } + + public function withType(string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } + + public function withUniverseDomain(string $universeDomain): self + { + $self = clone $this; + $self['universeDomain'] = $universeDomain; + + return $self; + } +} diff --git a/src/Sessions/StreamEvent.php b/src/Sessions/StreamEvent.php index ec577de..2c9a1c3 100644 --- a/src/Sessions/StreamEvent.php +++ b/src/Sessions/StreamEvent.php @@ -12,7 +12,7 @@ use Stagehand\Sessions\StreamEvent\Type; /** - * Server-Sent Event emitted during streaming responses. Events are sent as `event: \ndata: \n\n`, where the JSON payload has the shape `{ data, type, id }`. + * Server-Sent Event emitted during streaming responses. Events are sent as `data: \n\n`. Key order: data (with status first), type, id. * * @phpstan-import-type DataVariants from \Stagehand\Sessions\StreamEvent\Data * @phpstan-import-type DataShape from \Stagehand\Sessions\StreamEvent\Data diff --git a/tests/Services/SessionsTest.php b/tests/Services/SessionsTest.php index c0c7b57..29f352c 100644 --- a/tests/Services/SessionsTest.php +++ b/tests/Services/SessionsTest.php @@ -69,11 +69,13 @@ public function testActWithOptionalParams(): void frameID: 'frameId', options: [ 'model' => [ - 'modelName' => 'openai/gpt-5.4-mini', + 'modelName' => 'openai/gpt-5-nano', 'apiKey' => 'sk-some-openai-api-key', 'baseURL' => 'https://api.openai.com/v1', - 'headers' => ['foo' => 'string'], + 'headers' => ['X-Custom-Header' => 'value'], 'provider' => 'openai', + 'providerOptions' => ['region' => 'us-east-1'], + 'skipAPIKeyFallback' => true, ], 'timeout' => 30000, 'variables' => [ @@ -136,19 +138,23 @@ public function testExecuteWithOptionalParams(): void agentConfig: [ 'cua' => true, 'executionModel' => [ - 'modelName' => 'openai/gpt-5.4-mini', + 'modelName' => 'openai/gpt-5-nano', 'apiKey' => 'sk-some-openai-api-key', 'baseURL' => 'https://api.openai.com/v1', - 'headers' => ['foo' => 'string'], + 'headers' => ['X-Custom-Header' => 'value'], 'provider' => 'openai', + 'providerOptions' => ['region' => 'us-east-1'], + 'skipAPIKeyFallback' => true, ], 'mode' => 'cua', 'model' => [ - 'modelName' => 'openai/gpt-5.4-mini', + 'modelName' => 'openai/gpt-5-nano', 'apiKey' => 'sk-some-openai-api-key', 'baseURL' => 'https://api.openai.com/v1', - 'headers' => ['foo' => 'string'], + 'headers' => ['X-Custom-Header' => 'value'], 'provider' => 'openai', + 'providerOptions' => ['region' => 'us-east-1'], + 'skipAPIKeyFallback' => true, ], 'provider' => 'openai', 'systemPrompt' => 'systemPrompt', @@ -157,8 +163,6 @@ public function testExecuteWithOptionalParams(): void 'instruction' => 'Log in with username \'demo\' and password \'test123\', then navigate to settings', 'highlightCursor' => true, 'maxSteps' => 20, - 'toolTimeout' => 30000, - 'useSearch' => true, ], frameID: 'frameId', shouldCache: true, @@ -341,6 +345,13 @@ public function testStartWithOptionalParams(): void browserbaseSessionID: 'browserbaseSessionID', domSettleTimeoutMs: 5000, experimental: true, + modelClientOptions: [ + 'apiKey' => 'bedrock-short-term-api-key', + 'providerOptions' => ['region' => 'us-east-1'], + 'baseURL' => 'https://api.openai.com/v1', + 'headers' => ['X-Custom-Header' => 'value'], + 'skipAPIKeyFallback' => true, + ], selfHeal: true, systemPrompt: 'systemPrompt', verbose: 1, From 52c4636560e5dd556db9c061a3bb9c48ffa20e76 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 8 Apr 2026 23:32:50 +0000 Subject: [PATCH 03/18] feat: [STG-1798] feat: support Browserbase verified sessions --- .stats.yml | 6 +- .../BrowserSettings.php | 62 +++++++++++++++++++ .../BrowserSettings/Os.php | 18 ++++++ tests/Services/SessionsTest.php | 4 ++ 4 files changed, 87 insertions(+), 3 deletions(-) create mode 100644 src/Sessions/SessionStartParams/BrowserbaseSessionCreateParams/BrowserSettings/Os.php diff --git a/.stats.yml b/.stats.yml index f1d6429..6bde59e 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 8 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browserbase%2Fstagehand-7773ef4ca29c983daafb787ee918cfa6b5b12c5bbdc088308653f2737c26e51f.yml -openapi_spec_hash: 47fc8f2540be0b6374e4230c021072d9 -config_hash: 0cc516caf1432087f40654336e0fa8cd +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browserbase%2Fstagehand-a8db51c6460b3daff67b35262517848a0d4e783c6805c2edd531b155a5db71dd.yml +openapi_spec_hash: c6e7127f211f946673d6389e1d8db1ba +config_hash: a962ae71493deb11a1c903256fb25386 diff --git a/src/Sessions/SessionStartParams/BrowserbaseSessionCreateParams/BrowserSettings.php b/src/Sessions/SessionStartParams/BrowserbaseSessionCreateParams/BrowserSettings.php index 6014c60..9272ee9 100644 --- a/src/Sessions/SessionStartParams/BrowserbaseSessionCreateParams/BrowserSettings.php +++ b/src/Sessions/SessionStartParams/BrowserbaseSessionCreateParams/BrowserSettings.php @@ -9,6 +9,7 @@ use Stagehand\Core\Contracts\BaseModel; use Stagehand\Sessions\SessionStartParams\BrowserbaseSessionCreateParams\BrowserSettings\Context; use Stagehand\Sessions\SessionStartParams\BrowserbaseSessionCreateParams\BrowserSettings\Fingerprint; +use Stagehand\Sessions\SessionStartParams\BrowserbaseSessionCreateParams\BrowserSettings\Os; use Stagehand\Sessions\SessionStartParams\BrowserbaseSessionCreateParams\BrowserSettings\Viewport; /** @@ -19,12 +20,16 @@ * @phpstan-type BrowserSettingsShape = array{ * advancedStealth?: bool|null, * blockAds?: bool|null, + * captchaImageSelector?: string|null, + * captchaInputSelector?: string|null, * context?: null|Context|ContextShape, * extensionID?: string|null, * fingerprint?: null|Fingerprint|FingerprintShape, * logSession?: bool|null, + * os?: null|Os|value-of, * recordSession?: bool|null, * solveCaptchas?: bool|null, + * verified?: bool|null, * viewport?: null|Viewport|ViewportShape, * } */ @@ -39,6 +44,12 @@ final class BrowserSettings implements BaseModel #[Optional] public ?bool $blockAds; + #[Optional] + public ?string $captchaImageSelector; + + #[Optional] + public ?string $captchaInputSelector; + #[Optional] public ?Context $context; @@ -51,12 +62,19 @@ final class BrowserSettings implements BaseModel #[Optional] public ?bool $logSession; + /** @var value-of|null $os */ + #[Optional(enum: Os::class)] + public ?string $os; + #[Optional] public ?bool $recordSession; #[Optional] public ?bool $solveCaptchas; + #[Optional] + public ?bool $verified; + #[Optional] public ?Viewport $viewport; @@ -72,29 +90,38 @@ public function __construct() * * @param Context|ContextShape|null $context * @param Fingerprint|FingerprintShape|null $fingerprint + * @param Os|value-of|null $os * @param Viewport|ViewportShape|null $viewport */ public static function with( ?bool $advancedStealth = null, ?bool $blockAds = null, + ?string $captchaImageSelector = null, + ?string $captchaInputSelector = null, Context|array|null $context = null, ?string $extensionID = null, Fingerprint|array|null $fingerprint = null, ?bool $logSession = null, + Os|string|null $os = null, ?bool $recordSession = null, ?bool $solveCaptchas = null, + ?bool $verified = null, Viewport|array|null $viewport = null, ): self { $self = new self; null !== $advancedStealth && $self['advancedStealth'] = $advancedStealth; null !== $blockAds && $self['blockAds'] = $blockAds; + null !== $captchaImageSelector && $self['captchaImageSelector'] = $captchaImageSelector; + null !== $captchaInputSelector && $self['captchaInputSelector'] = $captchaInputSelector; null !== $context && $self['context'] = $context; null !== $extensionID && $self['extensionID'] = $extensionID; null !== $fingerprint && $self['fingerprint'] = $fingerprint; null !== $logSession && $self['logSession'] = $logSession; + null !== $os && $self['os'] = $os; null !== $recordSession && $self['recordSession'] = $recordSession; null !== $solveCaptchas && $self['solveCaptchas'] = $solveCaptchas; + null !== $verified && $self['verified'] = $verified; null !== $viewport && $self['viewport'] = $viewport; return $self; @@ -116,6 +143,22 @@ public function withBlockAds(bool $blockAds): self return $self; } + public function withCaptchaImageSelector(string $captchaImageSelector): self + { + $self = clone $this; + $self['captchaImageSelector'] = $captchaImageSelector; + + return $self; + } + + public function withCaptchaInputSelector(string $captchaInputSelector): self + { + $self = clone $this; + $self['captchaInputSelector'] = $captchaInputSelector; + + return $self; + } + /** * @param Context|ContextShape $context */ @@ -154,6 +197,17 @@ public function withLogSession(bool $logSession): self return $self; } + /** + * @param Os|value-of $os + */ + public function withOs(Os|string $os): self + { + $self = clone $this; + $self['os'] = $os; + + return $self; + } + public function withRecordSession(bool $recordSession): self { $self = clone $this; @@ -170,6 +224,14 @@ public function withSolveCaptchas(bool $solveCaptchas): self return $self; } + public function withVerified(bool $verified): self + { + $self = clone $this; + $self['verified'] = $verified; + + return $self; + } + /** * @param Viewport|ViewportShape $viewport */ diff --git a/src/Sessions/SessionStartParams/BrowserbaseSessionCreateParams/BrowserSettings/Os.php b/src/Sessions/SessionStartParams/BrowserbaseSessionCreateParams/BrowserSettings/Os.php new file mode 100644 index 0000000..745cef8 --- /dev/null +++ b/src/Sessions/SessionStartParams/BrowserbaseSessionCreateParams/BrowserSettings/Os.php @@ -0,0 +1,18 @@ + [ 'advancedStealth' => true, 'blockAds' => true, + 'captchaImageSelector' => 'captchaImageSelector', + 'captchaInputSelector' => 'captchaInputSelector', 'context' => ['id' => 'id', 'persist' => true], 'extensionID' => 'extensionId', 'fingerprint' => [ @@ -330,8 +332,10 @@ public function testStartWithOptionalParams(): void ], ], 'logSession' => true, + 'os' => 'windows', 'recordSession' => true, 'solveCaptchas' => true, + 'verified' => true, 'viewport' => ['height' => 0, 'width' => 0], ], 'extensionID' => 'extensionId', From 1f99ac3957867970c6eaa968e8daaa83ae855b7b Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 9 Apr 2026 20:32:14 +0000 Subject: [PATCH 04/18] feat: Revert "[STG-1573] Add providerOptions for extensible model auth (#1822)" --- .stats.yml | 4 +- src/ServiceContracts/SessionsContract.php | 6 - src/Services/SessionsRawService.php | 2 - src/Services/SessionsService.php | 7 - src/Sessions/ModelConfig.php | 56 +---- src/Sessions/ModelConfig/ProviderOptions.php | 39 ---- .../BedrockAPIKeyProviderOptions.php | 68 ------- .../BedrockAwsCredentialsProviderOptions.php | 138 ------------- .../GoogleVertexProviderOptions.php | 130 ------------ .../GoogleAuthOptions.php | 60 ------ .../GoogleAuthOptions/Credentials.php | 192 ------------------ .../SessionExecuteParams/ExecuteOptions.php | 46 ++++- src/Sessions/SessionStartParams.php | 31 --- .../SessionStartParams/ModelClientOptions.php | 39 ---- .../BedrockAPIKeyModelClientOptions.php | 161 --------------- .../ProviderOptions.php | 68 ------- ...edrockAwsCredentialsModelClientOptions.php | 141 ------------- .../ProviderOptions.php | 136 ------------- .../GenericModelClientOptions.php | 155 -------------- .../ProviderOptions.php | 39 ---- .../BedrockAPIKeyProviderOptions.php | 68 ------- .../BedrockAwsCredentialsProviderOptions.php | 138 ------------- .../GoogleVertexProviderOptions.php | 130 ------------ .../GoogleAuthOptions.php | 60 ------ .../GoogleAuthOptions/Credentials.php | 192 ------------------ src/Sessions/StreamEvent.php | 2 +- tests/Services/SessionsTest.php | 27 +-- 27 files changed, 57 insertions(+), 2078 deletions(-) delete mode 100644 src/Sessions/ModelConfig/ProviderOptions.php delete mode 100644 src/Sessions/ModelConfig/ProviderOptions/BedrockAPIKeyProviderOptions.php delete mode 100644 src/Sessions/ModelConfig/ProviderOptions/BedrockAwsCredentialsProviderOptions.php delete mode 100644 src/Sessions/ModelConfig/ProviderOptions/GoogleVertexProviderOptions.php delete mode 100644 src/Sessions/ModelConfig/ProviderOptions/GoogleVertexProviderOptions/GoogleAuthOptions.php delete mode 100644 src/Sessions/ModelConfig/ProviderOptions/GoogleVertexProviderOptions/GoogleAuthOptions/Credentials.php delete mode 100644 src/Sessions/SessionStartParams/ModelClientOptions.php delete mode 100644 src/Sessions/SessionStartParams/ModelClientOptions/BedrockAPIKeyModelClientOptions.php delete mode 100644 src/Sessions/SessionStartParams/ModelClientOptions/BedrockAPIKeyModelClientOptions/ProviderOptions.php delete mode 100644 src/Sessions/SessionStartParams/ModelClientOptions/BedrockAwsCredentialsModelClientOptions.php delete mode 100644 src/Sessions/SessionStartParams/ModelClientOptions/BedrockAwsCredentialsModelClientOptions/ProviderOptions.php delete mode 100644 src/Sessions/SessionStartParams/ModelClientOptions/GenericModelClientOptions.php delete mode 100644 src/Sessions/SessionStartParams/ModelClientOptions/GenericModelClientOptions/ProviderOptions.php delete mode 100644 src/Sessions/SessionStartParams/ModelClientOptions/GenericModelClientOptions/ProviderOptions/BedrockAPIKeyProviderOptions.php delete mode 100644 src/Sessions/SessionStartParams/ModelClientOptions/GenericModelClientOptions/ProviderOptions/BedrockAwsCredentialsProviderOptions.php delete mode 100644 src/Sessions/SessionStartParams/ModelClientOptions/GenericModelClientOptions/ProviderOptions/GoogleVertexProviderOptions.php delete mode 100644 src/Sessions/SessionStartParams/ModelClientOptions/GenericModelClientOptions/ProviderOptions/GoogleVertexProviderOptions/GoogleAuthOptions.php delete mode 100644 src/Sessions/SessionStartParams/ModelClientOptions/GenericModelClientOptions/ProviderOptions/GoogleVertexProviderOptions/GoogleAuthOptions/Credentials.php diff --git a/.stats.yml b/.stats.yml index 6bde59e..d8428d4 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 8 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browserbase%2Fstagehand-a8db51c6460b3daff67b35262517848a0d4e783c6805c2edd531b155a5db71dd.yml -openapi_spec_hash: c6e7127f211f946673d6389e1d8db1ba +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browserbase%2Fstagehand-1c6caa2891a7f3bdfc0caab143f285badc9145220c9b29cd5e4cf1a9b3ac11cf.yml +openapi_spec_hash: 28c4b734a5309067c39bb4c4b709b9ab config_hash: a962ae71493deb11a1c903256fb25386 diff --git a/src/ServiceContracts/SessionsContract.php b/src/ServiceContracts/SessionsContract.php index 20797b8..0cd0ad2 100644 --- a/src/ServiceContracts/SessionsContract.php +++ b/src/ServiceContracts/SessionsContract.php @@ -21,9 +21,6 @@ use Stagehand\Sessions\SessionReplayResponse; use Stagehand\Sessions\SessionStartParams\Browser; use Stagehand\Sessions\SessionStartParams\BrowserbaseSessionCreateParams; -use Stagehand\Sessions\SessionStartParams\ModelClientOptions\BedrockAPIKeyModelClientOptions; -use Stagehand\Sessions\SessionStartParams\ModelClientOptions\BedrockAwsCredentialsModelClientOptions; -use Stagehand\Sessions\SessionStartParams\ModelClientOptions\GenericModelClientOptions; use Stagehand\Sessions\SessionStartResponse; use Stagehand\Sessions\StreamEvent; @@ -31,7 +28,6 @@ * @phpstan-import-type OptionsShape from \Stagehand\Sessions\SessionNavigateParams\Options * @phpstan-import-type BrowserShape from \Stagehand\Sessions\SessionStartParams\Browser * @phpstan-import-type BrowserbaseSessionCreateParamsShape from \Stagehand\Sessions\SessionStartParams\BrowserbaseSessionCreateParams - * @phpstan-import-type ModelClientOptionsShape from \Stagehand\Sessions\SessionStartParams\ModelClientOptions * @phpstan-import-type InputShape from \Stagehand\Sessions\SessionActParams\Input * @phpstan-import-type OptionsShape from \Stagehand\Sessions\SessionActParams\Options as OptionsShape1 * @phpstan-import-type RequestOpts from \Stagehand\RequestOptions @@ -289,7 +285,6 @@ public function replay( * @param string $browserbaseSessionID Body param: Existing Browserbase session ID to resume * @param float $domSettleTimeoutMs Body param: Timeout in ms to wait for DOM to settle * @param bool $experimental Body param - * @param ModelClientOptionsShape $modelClientOptions Body param: Optional provider-specific configuration for the session model (for example Bedrock region and credentials) * @param bool $selfHeal Body param: Enable self-healing for failed actions * @param string $systemPrompt Body param: Custom system prompt for AI operations * @param float $verbose Body param: Logging verbosity level (0=quiet, 1=normal, 2=debug) @@ -307,7 +302,6 @@ public function start( ?string $browserbaseSessionID = null, ?float $domSettleTimeoutMs = null, ?bool $experimental = null, - BedrockAPIKeyModelClientOptions|array|BedrockAwsCredentialsModelClientOptions|GenericModelClientOptions|null $modelClientOptions = null, ?bool $selfHeal = null, ?string $systemPrompt = null, ?float $verbose = null, diff --git a/src/Services/SessionsRawService.php b/src/Services/SessionsRawService.php index 1d059c7..4482975 100644 --- a/src/Services/SessionsRawService.php +++ b/src/Services/SessionsRawService.php @@ -40,7 +40,6 @@ * @phpstan-import-type OptionsShape from \Stagehand\Sessions\SessionNavigateParams\Options * @phpstan-import-type BrowserShape from \Stagehand\Sessions\SessionStartParams\Browser * @phpstan-import-type BrowserbaseSessionCreateParamsShape from \Stagehand\Sessions\SessionStartParams\BrowserbaseSessionCreateParams - * @phpstan-import-type ModelClientOptionsShape from \Stagehand\Sessions\SessionStartParams\ModelClientOptions * @phpstan-import-type InputShape from \Stagehand\Sessions\SessionActParams\Input * @phpstan-import-type OptionsShape from \Stagehand\Sessions\SessionActParams\Options as OptionsShape1 * @phpstan-import-type RequestOpts from \Stagehand\RequestOptions @@ -589,7 +588,6 @@ public function replay( * browserbaseSessionID?: string, * domSettleTimeoutMs?: float, * experimental?: bool, - * modelClientOptions?: ModelClientOptionsShape, * selfHeal?: bool, * systemPrompt?: string, * verbose?: float, diff --git a/src/Services/SessionsService.php b/src/Services/SessionsService.php index a10109a..f993409 100644 --- a/src/Services/SessionsService.php +++ b/src/Services/SessionsService.php @@ -24,9 +24,6 @@ use Stagehand\Sessions\SessionReplayResponse; use Stagehand\Sessions\SessionStartParams\Browser; use Stagehand\Sessions\SessionStartParams\BrowserbaseSessionCreateParams; -use Stagehand\Sessions\SessionStartParams\ModelClientOptions\BedrockAPIKeyModelClientOptions; -use Stagehand\Sessions\SessionStartParams\ModelClientOptions\BedrockAwsCredentialsModelClientOptions; -use Stagehand\Sessions\SessionStartParams\ModelClientOptions\GenericModelClientOptions; use Stagehand\Sessions\SessionStartResponse; use Stagehand\Sessions\StreamEvent; @@ -34,7 +31,6 @@ * @phpstan-import-type OptionsShape from \Stagehand\Sessions\SessionNavigateParams\Options * @phpstan-import-type BrowserShape from \Stagehand\Sessions\SessionStartParams\Browser * @phpstan-import-type BrowserbaseSessionCreateParamsShape from \Stagehand\Sessions\SessionStartParams\BrowserbaseSessionCreateParams - * @phpstan-import-type ModelClientOptionsShape from \Stagehand\Sessions\SessionStartParams\ModelClientOptions * @phpstan-import-type InputShape from \Stagehand\Sessions\SessionActParams\Input * @phpstan-import-type OptionsShape from \Stagehand\Sessions\SessionActParams\Options as OptionsShape1 * @phpstan-import-type RequestOpts from \Stagehand\RequestOptions @@ -466,7 +462,6 @@ public function replay( * @param string $browserbaseSessionID Body param: Existing Browserbase session ID to resume * @param float $domSettleTimeoutMs Body param: Timeout in ms to wait for DOM to settle * @param bool $experimental Body param - * @param ModelClientOptionsShape $modelClientOptions Body param: Optional provider-specific configuration for the session model (for example Bedrock region and credentials) * @param bool $selfHeal Body param: Enable self-healing for failed actions * @param string $systemPrompt Body param: Custom system prompt for AI operations * @param float $verbose Body param: Logging verbosity level (0=quiet, 1=normal, 2=debug) @@ -484,7 +479,6 @@ public function start( ?string $browserbaseSessionID = null, ?float $domSettleTimeoutMs = null, ?bool $experimental = null, - BedrockAPIKeyModelClientOptions|array|BedrockAwsCredentialsModelClientOptions|GenericModelClientOptions|null $modelClientOptions = null, ?bool $selfHeal = null, ?string $systemPrompt = null, ?float $verbose = null, @@ -501,7 +495,6 @@ public function start( 'browserbaseSessionID' => $browserbaseSessionID, 'domSettleTimeoutMs' => $domSettleTimeoutMs, 'experimental' => $experimental, - 'modelClientOptions' => $modelClientOptions, 'selfHeal' => $selfHeal, 'systemPrompt' => $systemPrompt, 'verbose' => $verbose, diff --git a/src/Sessions/ModelConfig.php b/src/Sessions/ModelConfig.php index 404b5b6..c03b239 100644 --- a/src/Sessions/ModelConfig.php +++ b/src/Sessions/ModelConfig.php @@ -9,22 +9,14 @@ use Stagehand\Core\Concerns\SdkModel; use Stagehand\Core\Contracts\BaseModel; use Stagehand\Sessions\ModelConfig\Provider; -use Stagehand\Sessions\ModelConfig\ProviderOptions\BedrockAPIKeyProviderOptions; -use Stagehand\Sessions\ModelConfig\ProviderOptions\BedrockAwsCredentialsProviderOptions; -use Stagehand\Sessions\ModelConfig\ProviderOptions\GoogleVertexProviderOptions; /** - * @phpstan-import-type ProviderOptionsVariants from \Stagehand\Sessions\ModelConfig\ProviderOptions - * @phpstan-import-type ProviderOptionsShape from \Stagehand\Sessions\ModelConfig\ProviderOptions - * * @phpstan-type ModelConfigShape = array{ * modelName: string, * apiKey?: string|null, * baseURL?: string|null, * headers?: array|null, * provider?: null|Provider|value-of, - * providerOptions?: ProviderOptionsShape|null, - * skipAPIKeyFallback?: bool|null, * } */ final class ModelConfig implements BaseModel @@ -51,7 +43,7 @@ final class ModelConfig implements BaseModel public ?string $baseURL; /** - * Custom headers for the model provider. + * Custom headers sent with every request to the model provider. * * @var array|null $headers */ @@ -66,20 +58,6 @@ final class ModelConfig implements BaseModel #[Optional(enum: Provider::class)] public ?string $provider; - /** - * Provider-specific options passed through to the AI SDK provider constructor. For Bedrock: { region, accessKeyId, secretAccessKey, sessionToken }. For Vertex: { project, location, googleAuthOptions }. - * - * @var ProviderOptionsVariants|null $providerOptions - */ - #[Optional] - public BedrockAPIKeyProviderOptions|BedrockAwsCredentialsProviderOptions|GoogleVertexProviderOptions|null $providerOptions; - - /** - * When true, hosted sessions will not copy x-model-api-key into model.apiKey. Use this when auth is carried through providerOptions instead of an API key. - */ - #[Optional('skipApiKeyFallback')] - public ?bool $skipAPIKeyFallback; - /** * `new ModelConfig()` is missing required properties by the API. * @@ -106,7 +84,6 @@ public function __construct() * * @param array|null $headers * @param Provider|value-of|null $provider - * @param ProviderOptionsShape|null $providerOptions */ public static function with( string $modelName, @@ -114,8 +91,6 @@ public static function with( ?string $baseURL = null, ?array $headers = null, Provider|string|null $provider = null, - BedrockAPIKeyProviderOptions|array|BedrockAwsCredentialsProviderOptions|GoogleVertexProviderOptions|null $providerOptions = null, - ?bool $skipAPIKeyFallback = null, ): self { $self = new self; @@ -125,8 +100,6 @@ public static function with( null !== $baseURL && $self['baseURL'] = $baseURL; null !== $headers && $self['headers'] = $headers; null !== $provider && $self['provider'] = $provider; - null !== $providerOptions && $self['providerOptions'] = $providerOptions; - null !== $skipAPIKeyFallback && $self['skipAPIKeyFallback'] = $skipAPIKeyFallback; return $self; } @@ -165,7 +138,7 @@ public function withBaseURL(string $baseURL): self } /** - * Custom headers for the model provider. + * Custom headers sent with every request to the model provider. * * @param array $headers */ @@ -189,29 +162,4 @@ public function withProvider(Provider|string $provider): self return $self; } - - /** - * Provider-specific options passed through to the AI SDK provider constructor. For Bedrock: { region, accessKeyId, secretAccessKey, sessionToken }. For Vertex: { project, location, googleAuthOptions }. - * - * @param ProviderOptionsShape $providerOptions - */ - public function withProviderOptions( - BedrockAPIKeyProviderOptions|array|BedrockAwsCredentialsProviderOptions|GoogleVertexProviderOptions $providerOptions, - ): self { - $self = clone $this; - $self['providerOptions'] = $providerOptions; - - return $self; - } - - /** - * When true, hosted sessions will not copy x-model-api-key into model.apiKey. Use this when auth is carried through providerOptions instead of an API key. - */ - public function withSkipAPIKeyFallback(bool $skipAPIKeyFallback): self - { - $self = clone $this; - $self['skipAPIKeyFallback'] = $skipAPIKeyFallback; - - return $self; - } } diff --git a/src/Sessions/ModelConfig/ProviderOptions.php b/src/Sessions/ModelConfig/ProviderOptions.php deleted file mode 100644 index 191fc94..0000000 --- a/src/Sessions/ModelConfig/ProviderOptions.php +++ /dev/null @@ -1,39 +0,0 @@ -|array - */ - public static function variants(): array - { - return [ - BedrockAPIKeyProviderOptions::class, - BedrockAwsCredentialsProviderOptions::class, - GoogleVertexProviderOptions::class, - ]; - } -} diff --git a/src/Sessions/ModelConfig/ProviderOptions/BedrockAPIKeyProviderOptions.php b/src/Sessions/ModelConfig/ProviderOptions/BedrockAPIKeyProviderOptions.php deleted file mode 100644 index eb11f93..0000000 --- a/src/Sessions/ModelConfig/ProviderOptions/BedrockAPIKeyProviderOptions.php +++ /dev/null @@ -1,68 +0,0 @@ - */ - use SdkModel; - - /** - * AWS region for Amazon Bedrock. - */ - #[Required] - public string $region; - - /** - * `new BedrockAPIKeyProviderOptions()` is missing required properties by the API. - * - * To enforce required parameters use - * ``` - * BedrockAPIKeyProviderOptions::with(region: ...) - * ``` - * - * Otherwise ensure the following setters are called - * - * ``` - * (new BedrockAPIKeyProviderOptions)->withRegion(...) - * ``` - */ - public function __construct() - { - $this->initialize(); - } - - /** - * Construct an instance from the required parameters. - * - * You must use named parameters to construct any parameters with a default value. - */ - public static function with(string $region): self - { - $self = new self; - - $self['region'] = $region; - - return $self; - } - - /** - * AWS region for Amazon Bedrock. - */ - public function withRegion(string $region): self - { - $self = clone $this; - $self['region'] = $region; - - return $self; - } -} diff --git a/src/Sessions/ModelConfig/ProviderOptions/BedrockAwsCredentialsProviderOptions.php b/src/Sessions/ModelConfig/ProviderOptions/BedrockAwsCredentialsProviderOptions.php deleted file mode 100644 index e26e0b5..0000000 --- a/src/Sessions/ModelConfig/ProviderOptions/BedrockAwsCredentialsProviderOptions.php +++ /dev/null @@ -1,138 +0,0 @@ - */ - use SdkModel; - - /** - * AWS access key ID for Bedrock. - */ - #[Required('accessKeyId')] - public string $accessKeyID; - - /** - * AWS region for Amazon Bedrock. - */ - #[Required] - public string $region; - - /** - * AWS secret access key for Bedrock. - */ - #[Required] - public string $secretAccessKey; - - /** - * Optional AWS session token for temporary credentials. - */ - #[Optional] - public ?string $sessionToken; - - /** - * `new BedrockAwsCredentialsProviderOptions()` is missing required properties by the API. - * - * To enforce required parameters use - * ``` - * BedrockAwsCredentialsProviderOptions::with( - * accessKeyID: ..., region: ..., secretAccessKey: ... - * ) - * ``` - * - * Otherwise ensure the following setters are called - * - * ``` - * (new BedrockAwsCredentialsProviderOptions) - * ->withAccessKeyID(...) - * ->withRegion(...) - * ->withSecretAccessKey(...) - * ``` - */ - public function __construct() - { - $this->initialize(); - } - - /** - * Construct an instance from the required parameters. - * - * You must use named parameters to construct any parameters with a default value. - */ - public static function with( - string $accessKeyID, - string $region, - string $secretAccessKey, - ?string $sessionToken = null, - ): self { - $self = new self; - - $self['accessKeyID'] = $accessKeyID; - $self['region'] = $region; - $self['secretAccessKey'] = $secretAccessKey; - - null !== $sessionToken && $self['sessionToken'] = $sessionToken; - - return $self; - } - - /** - * AWS access key ID for Bedrock. - */ - public function withAccessKeyID(string $accessKeyID): self - { - $self = clone $this; - $self['accessKeyID'] = $accessKeyID; - - return $self; - } - - /** - * AWS region for Amazon Bedrock. - */ - public function withRegion(string $region): self - { - $self = clone $this; - $self['region'] = $region; - - return $self; - } - - /** - * AWS secret access key for Bedrock. - */ - public function withSecretAccessKey(string $secretAccessKey): self - { - $self = clone $this; - $self['secretAccessKey'] = $secretAccessKey; - - return $self; - } - - /** - * Optional AWS session token for temporary credentials. - */ - public function withSessionToken(string $sessionToken): self - { - $self = clone $this; - $self['sessionToken'] = $sessionToken; - - return $self; - } -} diff --git a/src/Sessions/ModelConfig/ProviderOptions/GoogleVertexProviderOptions.php b/src/Sessions/ModelConfig/ProviderOptions/GoogleVertexProviderOptions.php deleted file mode 100644 index 9de95e5..0000000 --- a/src/Sessions/ModelConfig/ProviderOptions/GoogleVertexProviderOptions.php +++ /dev/null @@ -1,130 +0,0 @@ -|null, - * location?: string|null, - * project?: string|null, - * } - */ -final class GoogleVertexProviderOptions implements BaseModel -{ - /** @use SdkModel */ - use SdkModel; - - /** - * Optional Google auth options for Vertex AI. - */ - #[Optional] - public ?GoogleAuthOptions $googleAuthOptions; - - /** - * Custom headers for Vertex AI requests. - * - * @var array|null $headers - */ - #[Optional(map: 'string')] - public ?array $headers; - - /** - * Google Cloud location for Vertex AI. - */ - #[Optional] - public ?string $location; - - /** - * Google Cloud project ID for Vertex AI. - */ - #[Optional] - public ?string $project; - - public function __construct() - { - $this->initialize(); - } - - /** - * Construct an instance from the required parameters. - * - * You must use named parameters to construct any parameters with a default value. - * - * @param GoogleAuthOptions|GoogleAuthOptionsShape|null $googleAuthOptions - * @param array|null $headers - */ - public static function with( - GoogleAuthOptions|array|null $googleAuthOptions = null, - ?array $headers = null, - ?string $location = null, - ?string $project = null, - ): self { - $self = new self; - - null !== $googleAuthOptions && $self['googleAuthOptions'] = $googleAuthOptions; - null !== $headers && $self['headers'] = $headers; - null !== $location && $self['location'] = $location; - null !== $project && $self['project'] = $project; - - return $self; - } - - /** - * Optional Google auth options for Vertex AI. - * - * @param GoogleAuthOptions|GoogleAuthOptionsShape $googleAuthOptions - */ - public function withGoogleAuthOptions( - GoogleAuthOptions|array $googleAuthOptions - ): self { - $self = clone $this; - $self['googleAuthOptions'] = $googleAuthOptions; - - return $self; - } - - /** - * Custom headers for Vertex AI requests. - * - * @param array $headers - */ - public function withHeaders(array $headers): self - { - $self = clone $this; - $self['headers'] = $headers; - - return $self; - } - - /** - * Google Cloud location for Vertex AI. - */ - public function withLocation(string $location): self - { - $self = clone $this; - $self['location'] = $location; - - return $self; - } - - /** - * Google Cloud project ID for Vertex AI. - */ - public function withProject(string $project): self - { - $self = clone $this; - $self['project'] = $project; - - return $self; - } -} diff --git a/src/Sessions/ModelConfig/ProviderOptions/GoogleVertexProviderOptions/GoogleAuthOptions.php b/src/Sessions/ModelConfig/ProviderOptions/GoogleVertexProviderOptions/GoogleAuthOptions.php deleted file mode 100644 index 6272412..0000000 --- a/src/Sessions/ModelConfig/ProviderOptions/GoogleVertexProviderOptions/GoogleAuthOptions.php +++ /dev/null @@ -1,60 +0,0 @@ - */ - use SdkModel; - - #[Optional] - public ?Credentials $credentials; - - public function __construct() - { - $this->initialize(); - } - - /** - * Construct an instance from the required parameters. - * - * You must use named parameters to construct any parameters with a default value. - * - * @param Credentials|CredentialsShape|null $credentials - */ - public static function with(Credentials|array|null $credentials = null): self - { - $self = new self; - - null !== $credentials && $self['credentials'] = $credentials; - - return $self; - } - - /** - * @param Credentials|CredentialsShape $credentials - */ - public function withCredentials(Credentials|array $credentials): self - { - $self = clone $this; - $self['credentials'] = $credentials; - - return $self; - } -} diff --git a/src/Sessions/ModelConfig/ProviderOptions/GoogleVertexProviderOptions/GoogleAuthOptions/Credentials.php b/src/Sessions/ModelConfig/ProviderOptions/GoogleVertexProviderOptions/GoogleAuthOptions/Credentials.php deleted file mode 100644 index 8842002..0000000 --- a/src/Sessions/ModelConfig/ProviderOptions/GoogleVertexProviderOptions/GoogleAuthOptions/Credentials.php +++ /dev/null @@ -1,192 +0,0 @@ - */ - use SdkModel; - - #[Optional('auth_provider_x509_cert_url')] - public ?string $authProviderX509CertURL; - - #[Optional('auth_uri')] - public ?string $authUri; - - #[Optional('client_email')] - public ?string $clientEmail; - - #[Optional('client_id')] - public ?string $clientID; - - #[Optional('client_x509_cert_url')] - public ?string $clientX509CertURL; - - #[Optional('private_key')] - public ?string $privateKey; - - #[Optional('private_key_id')] - public ?string $privateKeyID; - - #[Optional('project_id')] - public ?string $projectID; - - #[Optional('token_uri')] - public ?string $tokenUri; - - #[Optional] - public ?string $type; - - #[Optional('universe_domain')] - public ?string $universeDomain; - - public function __construct() - { - $this->initialize(); - } - - /** - * Construct an instance from the required parameters. - * - * You must use named parameters to construct any parameters with a default value. - */ - public static function with( - ?string $authProviderX509CertURL = null, - ?string $authUri = null, - ?string $clientEmail = null, - ?string $clientID = null, - ?string $clientX509CertURL = null, - ?string $privateKey = null, - ?string $privateKeyID = null, - ?string $projectID = null, - ?string $tokenUri = null, - ?string $type = null, - ?string $universeDomain = null, - ): self { - $self = new self; - - null !== $authProviderX509CertURL && $self['authProviderX509CertURL'] = $authProviderX509CertURL; - null !== $authUri && $self['authUri'] = $authUri; - null !== $clientEmail && $self['clientEmail'] = $clientEmail; - null !== $clientID && $self['clientID'] = $clientID; - null !== $clientX509CertURL && $self['clientX509CertURL'] = $clientX509CertURL; - null !== $privateKey && $self['privateKey'] = $privateKey; - null !== $privateKeyID && $self['privateKeyID'] = $privateKeyID; - null !== $projectID && $self['projectID'] = $projectID; - null !== $tokenUri && $self['tokenUri'] = $tokenUri; - null !== $type && $self['type'] = $type; - null !== $universeDomain && $self['universeDomain'] = $universeDomain; - - return $self; - } - - public function withAuthProviderX509CertURL( - string $authProviderX509CertURL - ): self { - $self = clone $this; - $self['authProviderX509CertURL'] = $authProviderX509CertURL; - - return $self; - } - - public function withAuthUri(string $authUri): self - { - $self = clone $this; - $self['authUri'] = $authUri; - - return $self; - } - - public function withClientEmail(string $clientEmail): self - { - $self = clone $this; - $self['clientEmail'] = $clientEmail; - - return $self; - } - - public function withClientID(string $clientID): self - { - $self = clone $this; - $self['clientID'] = $clientID; - - return $self; - } - - public function withClientX509CertURL(string $clientX509CertURL): self - { - $self = clone $this; - $self['clientX509CertURL'] = $clientX509CertURL; - - return $self; - } - - public function withPrivateKey(string $privateKey): self - { - $self = clone $this; - $self['privateKey'] = $privateKey; - - return $self; - } - - public function withPrivateKeyID(string $privateKeyID): self - { - $self = clone $this; - $self['privateKeyID'] = $privateKeyID; - - return $self; - } - - public function withProjectID(string $projectID): self - { - $self = clone $this; - $self['projectID'] = $projectID; - - return $self; - } - - public function withTokenUri(string $tokenUri): self - { - $self = clone $this; - $self['tokenUri'] = $tokenUri; - - return $self; - } - - public function withType(string $type): self - { - $self = clone $this; - $self['type'] = $type; - - return $self; - } - - public function withUniverseDomain(string $universeDomain): self - { - $self = clone $this; - $self['universeDomain'] = $universeDomain; - - return $self; - } -} diff --git a/src/Sessions/SessionExecuteParams/ExecuteOptions.php b/src/Sessions/SessionExecuteParams/ExecuteOptions.php index c5e676f..be26904 100644 --- a/src/Sessions/SessionExecuteParams/ExecuteOptions.php +++ b/src/Sessions/SessionExecuteParams/ExecuteOptions.php @@ -11,7 +11,11 @@ /** * @phpstan-type ExecuteOptionsShape = array{ - * instruction: string, highlightCursor?: bool|null, maxSteps?: float|null + * instruction: string, + * highlightCursor?: bool|null, + * maxSteps?: float|null, + * toolTimeout?: float|null, + * useSearch?: bool|null, * } */ final class ExecuteOptions implements BaseModel @@ -37,6 +41,18 @@ final class ExecuteOptions implements BaseModel #[Optional] public ?float $maxSteps; + /** + * Timeout in milliseconds for each agent tool call. + */ + #[Optional] + public ?float $toolTimeout; + + /** + * Whether to enable the web search tool powered by Browserbase Search API. + */ + #[Optional] + public ?bool $useSearch; + /** * `new ExecuteOptions()` is missing required properties by the API. * @@ -64,7 +80,9 @@ public function __construct() public static function with( string $instruction, ?bool $highlightCursor = null, - ?float $maxSteps = null + ?float $maxSteps = null, + ?float $toolTimeout = null, + ?bool $useSearch = null, ): self { $self = new self; @@ -72,6 +90,8 @@ public static function with( null !== $highlightCursor && $self['highlightCursor'] = $highlightCursor; null !== $maxSteps && $self['maxSteps'] = $maxSteps; + null !== $toolTimeout && $self['toolTimeout'] = $toolTimeout; + null !== $useSearch && $self['useSearch'] = $useSearch; return $self; } @@ -108,4 +128,26 @@ public function withMaxSteps(float $maxSteps): self return $self; } + + /** + * Timeout in milliseconds for each agent tool call. + */ + public function withToolTimeout(float $toolTimeout): self + { + $self = clone $this; + $self['toolTimeout'] = $toolTimeout; + + return $self; + } + + /** + * Whether to enable the web search tool powered by Browserbase Search API. + */ + public function withUseSearch(bool $useSearch): self + { + $self = clone $this; + $self['useSearch'] = $useSearch; + + return $self; + } } diff --git a/src/Sessions/SessionStartParams.php b/src/Sessions/SessionStartParams.php index ce1c8c4..c01446d 100644 --- a/src/Sessions/SessionStartParams.php +++ b/src/Sessions/SessionStartParams.php @@ -11,9 +11,6 @@ use Stagehand\Core\Contracts\BaseModel; use Stagehand\Sessions\SessionStartParams\Browser; use Stagehand\Sessions\SessionStartParams\BrowserbaseSessionCreateParams; -use Stagehand\Sessions\SessionStartParams\ModelClientOptions\BedrockAPIKeyModelClientOptions; -use Stagehand\Sessions\SessionStartParams\ModelClientOptions\BedrockAwsCredentialsModelClientOptions; -use Stagehand\Sessions\SessionStartParams\ModelClientOptions\GenericModelClientOptions; use Stagehand\Sessions\SessionStartParams\XStreamResponse; /** @@ -21,10 +18,8 @@ * * @see Stagehand\Services\SessionsService::start() * - * @phpstan-import-type ModelClientOptionsVariants from \Stagehand\Sessions\SessionStartParams\ModelClientOptions * @phpstan-import-type BrowserShape from \Stagehand\Sessions\SessionStartParams\Browser * @phpstan-import-type BrowserbaseSessionCreateParamsShape from \Stagehand\Sessions\SessionStartParams\BrowserbaseSessionCreateParams - * @phpstan-import-type ModelClientOptionsShape from \Stagehand\Sessions\SessionStartParams\ModelClientOptions * * @phpstan-type SessionStartParamsShape = array{ * modelName: string, @@ -34,7 +29,6 @@ * browserbaseSessionID?: string|null, * domSettleTimeoutMs?: float|null, * experimental?: bool|null, - * modelClientOptions?: ModelClientOptionsShape|null, * selfHeal?: bool|null, * systemPrompt?: string|null, * verbose?: float|null, @@ -81,14 +75,6 @@ final class SessionStartParams implements BaseModel #[Optional] public ?bool $experimental; - /** - * Optional provider-specific configuration for the session model (for example Bedrock region and credentials). - * - * @var ModelClientOptionsVariants|null $modelClientOptions - */ - #[Optional] - public BedrockAPIKeyModelClientOptions|BedrockAwsCredentialsModelClientOptions|GenericModelClientOptions|null $modelClientOptions; - /** * Enable self-healing for failed actions. */ @@ -147,7 +133,6 @@ public function __construct() * * @param Browser|BrowserShape|null $browser * @param BrowserbaseSessionCreateParams|BrowserbaseSessionCreateParamsShape|null $browserbaseSessionCreateParams - * @param ModelClientOptionsShape|null $modelClientOptions * @param XStreamResponse|value-of|null $xStreamResponse */ public static function with( @@ -158,7 +143,6 @@ public static function with( ?string $browserbaseSessionID = null, ?float $domSettleTimeoutMs = null, ?bool $experimental = null, - BedrockAPIKeyModelClientOptions|array|BedrockAwsCredentialsModelClientOptions|GenericModelClientOptions|null $modelClientOptions = null, ?bool $selfHeal = null, ?string $systemPrompt = null, ?float $verbose = null, @@ -175,7 +159,6 @@ public static function with( null !== $browserbaseSessionID && $self['browserbaseSessionID'] = $browserbaseSessionID; null !== $domSettleTimeoutMs && $self['domSettleTimeoutMs'] = $domSettleTimeoutMs; null !== $experimental && $self['experimental'] = $experimental; - null !== $modelClientOptions && $self['modelClientOptions'] = $modelClientOptions; null !== $selfHeal && $self['selfHeal'] = $selfHeal; null !== $systemPrompt && $self['systemPrompt'] = $systemPrompt; null !== $verbose && $self['verbose'] = $verbose; @@ -260,20 +243,6 @@ public function withExperimental(bool $experimental): self return $self; } - /** - * Optional provider-specific configuration for the session model (for example Bedrock region and credentials). - * - * @param ModelClientOptionsShape $modelClientOptions - */ - public function withModelClientOptions( - BedrockAPIKeyModelClientOptions|array|BedrockAwsCredentialsModelClientOptions|GenericModelClientOptions $modelClientOptions, - ): self { - $self = clone $this; - $self['modelClientOptions'] = $modelClientOptions; - - return $self; - } - /** * Enable self-healing for failed actions. */ diff --git a/src/Sessions/SessionStartParams/ModelClientOptions.php b/src/Sessions/SessionStartParams/ModelClientOptions.php deleted file mode 100644 index 66c9cfc..0000000 --- a/src/Sessions/SessionStartParams/ModelClientOptions.php +++ /dev/null @@ -1,39 +0,0 @@ -|array - */ - public static function variants(): array - { - return [ - BedrockAPIKeyModelClientOptions::class, - BedrockAwsCredentialsModelClientOptions::class, - GenericModelClientOptions::class, - ]; - } -} diff --git a/src/Sessions/SessionStartParams/ModelClientOptions/BedrockAPIKeyModelClientOptions.php b/src/Sessions/SessionStartParams/ModelClientOptions/BedrockAPIKeyModelClientOptions.php deleted file mode 100644 index 34738f5..0000000 --- a/src/Sessions/SessionStartParams/ModelClientOptions/BedrockAPIKeyModelClientOptions.php +++ /dev/null @@ -1,161 +0,0 @@ -|null, - * skipAPIKeyFallback?: bool|null, - * } - */ -final class BedrockAPIKeyModelClientOptions implements BaseModel -{ - /** @use SdkModel */ - use SdkModel; - - /** - * Short-term Bedrock API key for bearer-token auth. - */ - #[Required] - public string $apiKey; - - #[Required] - public ProviderOptions $providerOptions; - - /** - * Base URL for the model provider. - */ - #[Optional] - public ?string $baseURL; - - /** - * Custom headers for the model provider. - * - * @var array|null $headers - */ - #[Optional(map: 'string')] - public ?array $headers; - - /** - * When true, hosted sessions will not copy x-model-api-key into model.apiKey. Use this when auth is carried through providerOptions instead of an API key. - */ - #[Optional('skipApiKeyFallback')] - public ?bool $skipAPIKeyFallback; - - /** - * `new BedrockAPIKeyModelClientOptions()` is missing required properties by the API. - * - * To enforce required parameters use - * ``` - * BedrockAPIKeyModelClientOptions::with(apiKey: ..., providerOptions: ...) - * ``` - * - * Otherwise ensure the following setters are called - * - * ``` - * (new BedrockAPIKeyModelClientOptions)->withAPIKey(...)->withProviderOptions(...) - * ``` - */ - public function __construct() - { - $this->initialize(); - } - - /** - * Construct an instance from the required parameters. - * - * You must use named parameters to construct any parameters with a default value. - * - * @param ProviderOptions|ProviderOptionsShape $providerOptions - * @param array|null $headers - */ - public static function with( - string $apiKey, - ProviderOptions|array $providerOptions, - ?string $baseURL = null, - ?array $headers = null, - ?bool $skipAPIKeyFallback = null, - ): self { - $self = new self; - - $self['apiKey'] = $apiKey; - $self['providerOptions'] = $providerOptions; - - null !== $baseURL && $self['baseURL'] = $baseURL; - null !== $headers && $self['headers'] = $headers; - null !== $skipAPIKeyFallback && $self['skipAPIKeyFallback'] = $skipAPIKeyFallback; - - return $self; - } - - /** - * Short-term Bedrock API key for bearer-token auth. - */ - public function withAPIKey(string $apiKey): self - { - $self = clone $this; - $self['apiKey'] = $apiKey; - - return $self; - } - - /** - * @param ProviderOptions|ProviderOptionsShape $providerOptions - */ - public function withProviderOptions( - ProviderOptions|array $providerOptions - ): self { - $self = clone $this; - $self['providerOptions'] = $providerOptions; - - return $self; - } - - /** - * Base URL for the model provider. - */ - public function withBaseURL(string $baseURL): self - { - $self = clone $this; - $self['baseURL'] = $baseURL; - - return $self; - } - - /** - * Custom headers for the model provider. - * - * @param array $headers - */ - public function withHeaders(array $headers): self - { - $self = clone $this; - $self['headers'] = $headers; - - return $self; - } - - /** - * When true, hosted sessions will not copy x-model-api-key into model.apiKey. Use this when auth is carried through providerOptions instead of an API key. - */ - public function withSkipAPIKeyFallback(bool $skipAPIKeyFallback): self - { - $self = clone $this; - $self['skipAPIKeyFallback'] = $skipAPIKeyFallback; - - return $self; - } -} diff --git a/src/Sessions/SessionStartParams/ModelClientOptions/BedrockAPIKeyModelClientOptions/ProviderOptions.php b/src/Sessions/SessionStartParams/ModelClientOptions/BedrockAPIKeyModelClientOptions/ProviderOptions.php deleted file mode 100644 index ca4707f..0000000 --- a/src/Sessions/SessionStartParams/ModelClientOptions/BedrockAPIKeyModelClientOptions/ProviderOptions.php +++ /dev/null @@ -1,68 +0,0 @@ - */ - use SdkModel; - - /** - * AWS region for Amazon Bedrock. - */ - #[Required] - public string $region; - - /** - * `new ProviderOptions()` is missing required properties by the API. - * - * To enforce required parameters use - * ``` - * ProviderOptions::with(region: ...) - * ``` - * - * Otherwise ensure the following setters are called - * - * ``` - * (new ProviderOptions)->withRegion(...) - * ``` - */ - public function __construct() - { - $this->initialize(); - } - - /** - * Construct an instance from the required parameters. - * - * You must use named parameters to construct any parameters with a default value. - */ - public static function with(string $region): self - { - $self = new self; - - $self['region'] = $region; - - return $self; - } - - /** - * AWS region for Amazon Bedrock. - */ - public function withRegion(string $region): self - { - $self = clone $this; - $self['region'] = $region; - - return $self; - } -} diff --git a/src/Sessions/SessionStartParams/ModelClientOptions/BedrockAwsCredentialsModelClientOptions.php b/src/Sessions/SessionStartParams/ModelClientOptions/BedrockAwsCredentialsModelClientOptions.php deleted file mode 100644 index a5420a4..0000000 --- a/src/Sessions/SessionStartParams/ModelClientOptions/BedrockAwsCredentialsModelClientOptions.php +++ /dev/null @@ -1,141 +0,0 @@ -|null, - * skipAPIKeyFallback?: bool|null, - * } - */ -final class BedrockAwsCredentialsModelClientOptions implements BaseModel -{ - /** @use SdkModel */ - use SdkModel; - - #[Required] - public ProviderOptions $providerOptions; - - /** - * Base URL for the model provider. - */ - #[Optional] - public ?string $baseURL; - - /** - * Custom headers for the model provider. - * - * @var array|null $headers - */ - #[Optional(map: 'string')] - public ?array $headers; - - /** - * When true, hosted sessions will not copy x-model-api-key into model.apiKey. Use this when auth is carried through providerOptions instead of an API key. - */ - #[Optional('skipApiKeyFallback')] - public ?bool $skipAPIKeyFallback; - - /** - * `new BedrockAwsCredentialsModelClientOptions()` is missing required properties by the API. - * - * To enforce required parameters use - * ``` - * BedrockAwsCredentialsModelClientOptions::with(providerOptions: ...) - * ``` - * - * Otherwise ensure the following setters are called - * - * ``` - * (new BedrockAwsCredentialsModelClientOptions)->withProviderOptions(...) - * ``` - */ - public function __construct() - { - $this->initialize(); - } - - /** - * Construct an instance from the required parameters. - * - * You must use named parameters to construct any parameters with a default value. - * - * @param ProviderOptions|ProviderOptionsShape $providerOptions - * @param array|null $headers - */ - public static function with( - ProviderOptions|array $providerOptions, - ?string $baseURL = null, - ?array $headers = null, - ?bool $skipAPIKeyFallback = null, - ): self { - $self = new self; - - $self['providerOptions'] = $providerOptions; - - null !== $baseURL && $self['baseURL'] = $baseURL; - null !== $headers && $self['headers'] = $headers; - null !== $skipAPIKeyFallback && $self['skipAPIKeyFallback'] = $skipAPIKeyFallback; - - return $self; - } - - /** - * @param ProviderOptions|ProviderOptionsShape $providerOptions - */ - public function withProviderOptions( - ProviderOptions|array $providerOptions - ): self { - $self = clone $this; - $self['providerOptions'] = $providerOptions; - - return $self; - } - - /** - * Base URL for the model provider. - */ - public function withBaseURL(string $baseURL): self - { - $self = clone $this; - $self['baseURL'] = $baseURL; - - return $self; - } - - /** - * Custom headers for the model provider. - * - * @param array $headers - */ - public function withHeaders(array $headers): self - { - $self = clone $this; - $self['headers'] = $headers; - - return $self; - } - - /** - * When true, hosted sessions will not copy x-model-api-key into model.apiKey. Use this when auth is carried through providerOptions instead of an API key. - */ - public function withSkipAPIKeyFallback(bool $skipAPIKeyFallback): self - { - $self = clone $this; - $self['skipAPIKeyFallback'] = $skipAPIKeyFallback; - - return $self; - } -} diff --git a/src/Sessions/SessionStartParams/ModelClientOptions/BedrockAwsCredentialsModelClientOptions/ProviderOptions.php b/src/Sessions/SessionStartParams/ModelClientOptions/BedrockAwsCredentialsModelClientOptions/ProviderOptions.php deleted file mode 100644 index b14970e..0000000 --- a/src/Sessions/SessionStartParams/ModelClientOptions/BedrockAwsCredentialsModelClientOptions/ProviderOptions.php +++ /dev/null @@ -1,136 +0,0 @@ - */ - use SdkModel; - - /** - * AWS access key ID for Bedrock. - */ - #[Required('accessKeyId')] - public string $accessKeyID; - - /** - * AWS region for Amazon Bedrock. - */ - #[Required] - public string $region; - - /** - * AWS secret access key for Bedrock. - */ - #[Required] - public string $secretAccessKey; - - /** - * Optional AWS session token for temporary credentials. - */ - #[Optional] - public ?string $sessionToken; - - /** - * `new ProviderOptions()` is missing required properties by the API. - * - * To enforce required parameters use - * ``` - * ProviderOptions::with(accessKeyID: ..., region: ..., secretAccessKey: ...) - * ``` - * - * Otherwise ensure the following setters are called - * - * ``` - * (new ProviderOptions) - * ->withAccessKeyID(...) - * ->withRegion(...) - * ->withSecretAccessKey(...) - * ``` - */ - public function __construct() - { - $this->initialize(); - } - - /** - * Construct an instance from the required parameters. - * - * You must use named parameters to construct any parameters with a default value. - */ - public static function with( - string $accessKeyID, - string $region, - string $secretAccessKey, - ?string $sessionToken = null, - ): self { - $self = new self; - - $self['accessKeyID'] = $accessKeyID; - $self['region'] = $region; - $self['secretAccessKey'] = $secretAccessKey; - - null !== $sessionToken && $self['sessionToken'] = $sessionToken; - - return $self; - } - - /** - * AWS access key ID for Bedrock. - */ - public function withAccessKeyID(string $accessKeyID): self - { - $self = clone $this; - $self['accessKeyID'] = $accessKeyID; - - return $self; - } - - /** - * AWS region for Amazon Bedrock. - */ - public function withRegion(string $region): self - { - $self = clone $this; - $self['region'] = $region; - - return $self; - } - - /** - * AWS secret access key for Bedrock. - */ - public function withSecretAccessKey(string $secretAccessKey): self - { - $self = clone $this; - $self['secretAccessKey'] = $secretAccessKey; - - return $self; - } - - /** - * Optional AWS session token for temporary credentials. - */ - public function withSessionToken(string $sessionToken): self - { - $self = clone $this; - $self['sessionToken'] = $sessionToken; - - return $self; - } -} diff --git a/src/Sessions/SessionStartParams/ModelClientOptions/GenericModelClientOptions.php b/src/Sessions/SessionStartParams/ModelClientOptions/GenericModelClientOptions.php deleted file mode 100644 index f109c00..0000000 --- a/src/Sessions/SessionStartParams/ModelClientOptions/GenericModelClientOptions.php +++ /dev/null @@ -1,155 +0,0 @@ -|null, - * providerOptions?: ProviderOptionsShape|null, - * skipAPIKeyFallback?: bool|null, - * } - */ -final class GenericModelClientOptions implements BaseModel -{ - /** @use SdkModel */ - use SdkModel; - - /** - * API key for the model provider. - */ - #[Optional] - public ?string $apiKey; - - /** - * Base URL for the model provider. - */ - #[Optional] - public ?string $baseURL; - - /** - * Custom headers for the model provider. - * - * @var array|null $headers - */ - #[Optional(map: 'string')] - public ?array $headers; - - /** - * Provider-specific options passed through to the AI SDK provider constructor. For Bedrock: { region, accessKeyId, secretAccessKey, sessionToken }. For Vertex: { project, location, googleAuthOptions }. - * - * @var ProviderOptionsVariants|null $providerOptions - */ - #[Optional] - public BedrockAPIKeyProviderOptions|BedrockAwsCredentialsProviderOptions|GoogleVertexProviderOptions|null $providerOptions; - - /** - * When true, hosted sessions will not copy x-model-api-key into model.apiKey. Use this when auth is carried through providerOptions instead of an API key. - */ - #[Optional('skipApiKeyFallback')] - public ?bool $skipAPIKeyFallback; - - public function __construct() - { - $this->initialize(); - } - - /** - * Construct an instance from the required parameters. - * - * You must use named parameters to construct any parameters with a default value. - * - * @param array|null $headers - * @param ProviderOptionsShape|null $providerOptions - */ - public static function with( - ?string $apiKey = null, - ?string $baseURL = null, - ?array $headers = null, - BedrockAPIKeyProviderOptions|array|BedrockAwsCredentialsProviderOptions|GoogleVertexProviderOptions|null $providerOptions = null, - ?bool $skipAPIKeyFallback = null, - ): self { - $self = new self; - - null !== $apiKey && $self['apiKey'] = $apiKey; - null !== $baseURL && $self['baseURL'] = $baseURL; - null !== $headers && $self['headers'] = $headers; - null !== $providerOptions && $self['providerOptions'] = $providerOptions; - null !== $skipAPIKeyFallback && $self['skipAPIKeyFallback'] = $skipAPIKeyFallback; - - return $self; - } - - /** - * API key for the model provider. - */ - public function withAPIKey(string $apiKey): self - { - $self = clone $this; - $self['apiKey'] = $apiKey; - - return $self; - } - - /** - * Base URL for the model provider. - */ - public function withBaseURL(string $baseURL): self - { - $self = clone $this; - $self['baseURL'] = $baseURL; - - return $self; - } - - /** - * Custom headers for the model provider. - * - * @param array $headers - */ - public function withHeaders(array $headers): self - { - $self = clone $this; - $self['headers'] = $headers; - - return $self; - } - - /** - * Provider-specific options passed through to the AI SDK provider constructor. For Bedrock: { region, accessKeyId, secretAccessKey, sessionToken }. For Vertex: { project, location, googleAuthOptions }. - * - * @param ProviderOptionsShape $providerOptions - */ - public function withProviderOptions( - BedrockAPIKeyProviderOptions|array|BedrockAwsCredentialsProviderOptions|GoogleVertexProviderOptions $providerOptions, - ): self { - $self = clone $this; - $self['providerOptions'] = $providerOptions; - - return $self; - } - - /** - * When true, hosted sessions will not copy x-model-api-key into model.apiKey. Use this when auth is carried through providerOptions instead of an API key. - */ - public function withSkipAPIKeyFallback(bool $skipAPIKeyFallback): self - { - $self = clone $this; - $self['skipAPIKeyFallback'] = $skipAPIKeyFallback; - - return $self; - } -} diff --git a/src/Sessions/SessionStartParams/ModelClientOptions/GenericModelClientOptions/ProviderOptions.php b/src/Sessions/SessionStartParams/ModelClientOptions/GenericModelClientOptions/ProviderOptions.php deleted file mode 100644 index 904b654..0000000 --- a/src/Sessions/SessionStartParams/ModelClientOptions/GenericModelClientOptions/ProviderOptions.php +++ /dev/null @@ -1,39 +0,0 @@ -|array - */ - public static function variants(): array - { - return [ - BedrockAPIKeyProviderOptions::class, - BedrockAwsCredentialsProviderOptions::class, - GoogleVertexProviderOptions::class, - ]; - } -} diff --git a/src/Sessions/SessionStartParams/ModelClientOptions/GenericModelClientOptions/ProviderOptions/BedrockAPIKeyProviderOptions.php b/src/Sessions/SessionStartParams/ModelClientOptions/GenericModelClientOptions/ProviderOptions/BedrockAPIKeyProviderOptions.php deleted file mode 100644 index 518a59a..0000000 --- a/src/Sessions/SessionStartParams/ModelClientOptions/GenericModelClientOptions/ProviderOptions/BedrockAPIKeyProviderOptions.php +++ /dev/null @@ -1,68 +0,0 @@ - */ - use SdkModel; - - /** - * AWS region for Amazon Bedrock. - */ - #[Required] - public string $region; - - /** - * `new BedrockAPIKeyProviderOptions()` is missing required properties by the API. - * - * To enforce required parameters use - * ``` - * BedrockAPIKeyProviderOptions::with(region: ...) - * ``` - * - * Otherwise ensure the following setters are called - * - * ``` - * (new BedrockAPIKeyProviderOptions)->withRegion(...) - * ``` - */ - public function __construct() - { - $this->initialize(); - } - - /** - * Construct an instance from the required parameters. - * - * You must use named parameters to construct any parameters with a default value. - */ - public static function with(string $region): self - { - $self = new self; - - $self['region'] = $region; - - return $self; - } - - /** - * AWS region for Amazon Bedrock. - */ - public function withRegion(string $region): self - { - $self = clone $this; - $self['region'] = $region; - - return $self; - } -} diff --git a/src/Sessions/SessionStartParams/ModelClientOptions/GenericModelClientOptions/ProviderOptions/BedrockAwsCredentialsProviderOptions.php b/src/Sessions/SessionStartParams/ModelClientOptions/GenericModelClientOptions/ProviderOptions/BedrockAwsCredentialsProviderOptions.php deleted file mode 100644 index 69d78b8..0000000 --- a/src/Sessions/SessionStartParams/ModelClientOptions/GenericModelClientOptions/ProviderOptions/BedrockAwsCredentialsProviderOptions.php +++ /dev/null @@ -1,138 +0,0 @@ - */ - use SdkModel; - - /** - * AWS access key ID for Bedrock. - */ - #[Required('accessKeyId')] - public string $accessKeyID; - - /** - * AWS region for Amazon Bedrock. - */ - #[Required] - public string $region; - - /** - * AWS secret access key for Bedrock. - */ - #[Required] - public string $secretAccessKey; - - /** - * Optional AWS session token for temporary credentials. - */ - #[Optional] - public ?string $sessionToken; - - /** - * `new BedrockAwsCredentialsProviderOptions()` is missing required properties by the API. - * - * To enforce required parameters use - * ``` - * BedrockAwsCredentialsProviderOptions::with( - * accessKeyID: ..., region: ..., secretAccessKey: ... - * ) - * ``` - * - * Otherwise ensure the following setters are called - * - * ``` - * (new BedrockAwsCredentialsProviderOptions) - * ->withAccessKeyID(...) - * ->withRegion(...) - * ->withSecretAccessKey(...) - * ``` - */ - public function __construct() - { - $this->initialize(); - } - - /** - * Construct an instance from the required parameters. - * - * You must use named parameters to construct any parameters with a default value. - */ - public static function with( - string $accessKeyID, - string $region, - string $secretAccessKey, - ?string $sessionToken = null, - ): self { - $self = new self; - - $self['accessKeyID'] = $accessKeyID; - $self['region'] = $region; - $self['secretAccessKey'] = $secretAccessKey; - - null !== $sessionToken && $self['sessionToken'] = $sessionToken; - - return $self; - } - - /** - * AWS access key ID for Bedrock. - */ - public function withAccessKeyID(string $accessKeyID): self - { - $self = clone $this; - $self['accessKeyID'] = $accessKeyID; - - return $self; - } - - /** - * AWS region for Amazon Bedrock. - */ - public function withRegion(string $region): self - { - $self = clone $this; - $self['region'] = $region; - - return $self; - } - - /** - * AWS secret access key for Bedrock. - */ - public function withSecretAccessKey(string $secretAccessKey): self - { - $self = clone $this; - $self['secretAccessKey'] = $secretAccessKey; - - return $self; - } - - /** - * Optional AWS session token for temporary credentials. - */ - public function withSessionToken(string $sessionToken): self - { - $self = clone $this; - $self['sessionToken'] = $sessionToken; - - return $self; - } -} diff --git a/src/Sessions/SessionStartParams/ModelClientOptions/GenericModelClientOptions/ProviderOptions/GoogleVertexProviderOptions.php b/src/Sessions/SessionStartParams/ModelClientOptions/GenericModelClientOptions/ProviderOptions/GoogleVertexProviderOptions.php deleted file mode 100644 index 1abd50f..0000000 --- a/src/Sessions/SessionStartParams/ModelClientOptions/GenericModelClientOptions/ProviderOptions/GoogleVertexProviderOptions.php +++ /dev/null @@ -1,130 +0,0 @@ -|null, - * location?: string|null, - * project?: string|null, - * } - */ -final class GoogleVertexProviderOptions implements BaseModel -{ - /** @use SdkModel */ - use SdkModel; - - /** - * Optional Google auth options for Vertex AI. - */ - #[Optional] - public ?GoogleAuthOptions $googleAuthOptions; - - /** - * Custom headers for Vertex AI requests. - * - * @var array|null $headers - */ - #[Optional(map: 'string')] - public ?array $headers; - - /** - * Google Cloud location for Vertex AI. - */ - #[Optional] - public ?string $location; - - /** - * Google Cloud project ID for Vertex AI. - */ - #[Optional] - public ?string $project; - - public function __construct() - { - $this->initialize(); - } - - /** - * Construct an instance from the required parameters. - * - * You must use named parameters to construct any parameters with a default value. - * - * @param GoogleAuthOptions|GoogleAuthOptionsShape|null $googleAuthOptions - * @param array|null $headers - */ - public static function with( - GoogleAuthOptions|array|null $googleAuthOptions = null, - ?array $headers = null, - ?string $location = null, - ?string $project = null, - ): self { - $self = new self; - - null !== $googleAuthOptions && $self['googleAuthOptions'] = $googleAuthOptions; - null !== $headers && $self['headers'] = $headers; - null !== $location && $self['location'] = $location; - null !== $project && $self['project'] = $project; - - return $self; - } - - /** - * Optional Google auth options for Vertex AI. - * - * @param GoogleAuthOptions|GoogleAuthOptionsShape $googleAuthOptions - */ - public function withGoogleAuthOptions( - GoogleAuthOptions|array $googleAuthOptions - ): self { - $self = clone $this; - $self['googleAuthOptions'] = $googleAuthOptions; - - return $self; - } - - /** - * Custom headers for Vertex AI requests. - * - * @param array $headers - */ - public function withHeaders(array $headers): self - { - $self = clone $this; - $self['headers'] = $headers; - - return $self; - } - - /** - * Google Cloud location for Vertex AI. - */ - public function withLocation(string $location): self - { - $self = clone $this; - $self['location'] = $location; - - return $self; - } - - /** - * Google Cloud project ID for Vertex AI. - */ - public function withProject(string $project): self - { - $self = clone $this; - $self['project'] = $project; - - return $self; - } -} diff --git a/src/Sessions/SessionStartParams/ModelClientOptions/GenericModelClientOptions/ProviderOptions/GoogleVertexProviderOptions/GoogleAuthOptions.php b/src/Sessions/SessionStartParams/ModelClientOptions/GenericModelClientOptions/ProviderOptions/GoogleVertexProviderOptions/GoogleAuthOptions.php deleted file mode 100644 index db81c7d..0000000 --- a/src/Sessions/SessionStartParams/ModelClientOptions/GenericModelClientOptions/ProviderOptions/GoogleVertexProviderOptions/GoogleAuthOptions.php +++ /dev/null @@ -1,60 +0,0 @@ - */ - use SdkModel; - - #[Optional] - public ?Credentials $credentials; - - public function __construct() - { - $this->initialize(); - } - - /** - * Construct an instance from the required parameters. - * - * You must use named parameters to construct any parameters with a default value. - * - * @param Credentials|CredentialsShape|null $credentials - */ - public static function with(Credentials|array|null $credentials = null): self - { - $self = new self; - - null !== $credentials && $self['credentials'] = $credentials; - - return $self; - } - - /** - * @param Credentials|CredentialsShape $credentials - */ - public function withCredentials(Credentials|array $credentials): self - { - $self = clone $this; - $self['credentials'] = $credentials; - - return $self; - } -} diff --git a/src/Sessions/SessionStartParams/ModelClientOptions/GenericModelClientOptions/ProviderOptions/GoogleVertexProviderOptions/GoogleAuthOptions/Credentials.php b/src/Sessions/SessionStartParams/ModelClientOptions/GenericModelClientOptions/ProviderOptions/GoogleVertexProviderOptions/GoogleAuthOptions/Credentials.php deleted file mode 100644 index 76e18c5..0000000 --- a/src/Sessions/SessionStartParams/ModelClientOptions/GenericModelClientOptions/ProviderOptions/GoogleVertexProviderOptions/GoogleAuthOptions/Credentials.php +++ /dev/null @@ -1,192 +0,0 @@ - */ - use SdkModel; - - #[Optional('auth_provider_x509_cert_url')] - public ?string $authProviderX509CertURL; - - #[Optional('auth_uri')] - public ?string $authUri; - - #[Optional('client_email')] - public ?string $clientEmail; - - #[Optional('client_id')] - public ?string $clientID; - - #[Optional('client_x509_cert_url')] - public ?string $clientX509CertURL; - - #[Optional('private_key')] - public ?string $privateKey; - - #[Optional('private_key_id')] - public ?string $privateKeyID; - - #[Optional('project_id')] - public ?string $projectID; - - #[Optional('token_uri')] - public ?string $tokenUri; - - #[Optional] - public ?string $type; - - #[Optional('universe_domain')] - public ?string $universeDomain; - - public function __construct() - { - $this->initialize(); - } - - /** - * Construct an instance from the required parameters. - * - * You must use named parameters to construct any parameters with a default value. - */ - public static function with( - ?string $authProviderX509CertURL = null, - ?string $authUri = null, - ?string $clientEmail = null, - ?string $clientID = null, - ?string $clientX509CertURL = null, - ?string $privateKey = null, - ?string $privateKeyID = null, - ?string $projectID = null, - ?string $tokenUri = null, - ?string $type = null, - ?string $universeDomain = null, - ): self { - $self = new self; - - null !== $authProviderX509CertURL && $self['authProviderX509CertURL'] = $authProviderX509CertURL; - null !== $authUri && $self['authUri'] = $authUri; - null !== $clientEmail && $self['clientEmail'] = $clientEmail; - null !== $clientID && $self['clientID'] = $clientID; - null !== $clientX509CertURL && $self['clientX509CertURL'] = $clientX509CertURL; - null !== $privateKey && $self['privateKey'] = $privateKey; - null !== $privateKeyID && $self['privateKeyID'] = $privateKeyID; - null !== $projectID && $self['projectID'] = $projectID; - null !== $tokenUri && $self['tokenUri'] = $tokenUri; - null !== $type && $self['type'] = $type; - null !== $universeDomain && $self['universeDomain'] = $universeDomain; - - return $self; - } - - public function withAuthProviderX509CertURL( - string $authProviderX509CertURL - ): self { - $self = clone $this; - $self['authProviderX509CertURL'] = $authProviderX509CertURL; - - return $self; - } - - public function withAuthUri(string $authUri): self - { - $self = clone $this; - $self['authUri'] = $authUri; - - return $self; - } - - public function withClientEmail(string $clientEmail): self - { - $self = clone $this; - $self['clientEmail'] = $clientEmail; - - return $self; - } - - public function withClientID(string $clientID): self - { - $self = clone $this; - $self['clientID'] = $clientID; - - return $self; - } - - public function withClientX509CertURL(string $clientX509CertURL): self - { - $self = clone $this; - $self['clientX509CertURL'] = $clientX509CertURL; - - return $self; - } - - public function withPrivateKey(string $privateKey): self - { - $self = clone $this; - $self['privateKey'] = $privateKey; - - return $self; - } - - public function withPrivateKeyID(string $privateKeyID): self - { - $self = clone $this; - $self['privateKeyID'] = $privateKeyID; - - return $self; - } - - public function withProjectID(string $projectID): self - { - $self = clone $this; - $self['projectID'] = $projectID; - - return $self; - } - - public function withTokenUri(string $tokenUri): self - { - $self = clone $this; - $self['tokenUri'] = $tokenUri; - - return $self; - } - - public function withType(string $type): self - { - $self = clone $this; - $self['type'] = $type; - - return $self; - } - - public function withUniverseDomain(string $universeDomain): self - { - $self = clone $this; - $self['universeDomain'] = $universeDomain; - - return $self; - } -} diff --git a/src/Sessions/StreamEvent.php b/src/Sessions/StreamEvent.php index 2c9a1c3..ec577de 100644 --- a/src/Sessions/StreamEvent.php +++ b/src/Sessions/StreamEvent.php @@ -12,7 +12,7 @@ use Stagehand\Sessions\StreamEvent\Type; /** - * Server-Sent Event emitted during streaming responses. Events are sent as `data: \n\n`. Key order: data (with status first), type, id. + * Server-Sent Event emitted during streaming responses. Events are sent as `event: \ndata: \n\n`, where the JSON payload has the shape `{ data, type, id }`. * * @phpstan-import-type DataVariants from \Stagehand\Sessions\StreamEvent\Data * @phpstan-import-type DataShape from \Stagehand\Sessions\StreamEvent\Data diff --git a/tests/Services/SessionsTest.php b/tests/Services/SessionsTest.php index 9be245a..142260d 100644 --- a/tests/Services/SessionsTest.php +++ b/tests/Services/SessionsTest.php @@ -69,13 +69,11 @@ public function testActWithOptionalParams(): void frameID: 'frameId', options: [ 'model' => [ - 'modelName' => 'openai/gpt-5-nano', + 'modelName' => 'openai/gpt-5.4-mini', 'apiKey' => 'sk-some-openai-api-key', 'baseURL' => 'https://api.openai.com/v1', - 'headers' => ['X-Custom-Header' => 'value'], + 'headers' => ['foo' => 'string'], 'provider' => 'openai', - 'providerOptions' => ['region' => 'us-east-1'], - 'skipAPIKeyFallback' => true, ], 'timeout' => 30000, 'variables' => [ @@ -138,23 +136,19 @@ public function testExecuteWithOptionalParams(): void agentConfig: [ 'cua' => true, 'executionModel' => [ - 'modelName' => 'openai/gpt-5-nano', + 'modelName' => 'openai/gpt-5.4-mini', 'apiKey' => 'sk-some-openai-api-key', 'baseURL' => 'https://api.openai.com/v1', - 'headers' => ['X-Custom-Header' => 'value'], + 'headers' => ['foo' => 'string'], 'provider' => 'openai', - 'providerOptions' => ['region' => 'us-east-1'], - 'skipAPIKeyFallback' => true, ], 'mode' => 'cua', 'model' => [ - 'modelName' => 'openai/gpt-5-nano', + 'modelName' => 'openai/gpt-5.4-mini', 'apiKey' => 'sk-some-openai-api-key', 'baseURL' => 'https://api.openai.com/v1', - 'headers' => ['X-Custom-Header' => 'value'], + 'headers' => ['foo' => 'string'], 'provider' => 'openai', - 'providerOptions' => ['region' => 'us-east-1'], - 'skipAPIKeyFallback' => true, ], 'provider' => 'openai', 'systemPrompt' => 'systemPrompt', @@ -163,6 +157,8 @@ public function testExecuteWithOptionalParams(): void 'instruction' => 'Log in with username \'demo\' and password \'test123\', then navigate to settings', 'highlightCursor' => true, 'maxSteps' => 20, + 'toolTimeout' => 30000, + 'useSearch' => true, ], frameID: 'frameId', shouldCache: true, @@ -349,13 +345,6 @@ public function testStartWithOptionalParams(): void browserbaseSessionID: 'browserbaseSessionID', domSettleTimeoutMs: 5000, experimental: true, - modelClientOptions: [ - 'apiKey' => 'bedrock-short-term-api-key', - 'providerOptions' => ['region' => 'us-east-1'], - 'baseURL' => 'https://api.openai.com/v1', - 'headers' => ['X-Custom-Header' => 'value'], - 'skipAPIKeyFallback' => true, - ], selfHeal: true, systemPrompt: 'systemPrompt', verbose: 1, From 4a6d85692b4bec4a518cf201999e99b2a7129263 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 11 Apr 2026 07:57:05 +0000 Subject: [PATCH 05/18] fix(client): properly generate file params --- src/Core/Conversion.php | 4 +++ src/Core/FileParam.php | 63 +++++++++++++++++++++++++++++++++++++++++ src/Core/Util.php | 60 ++++++++++++++++++++++++++++++--------- 3 files changed, 114 insertions(+), 13 deletions(-) create mode 100644 src/Core/FileParam.php diff --git a/src/Core/Conversion.php b/src/Core/Conversion.php index 1942914..e9a8688 100644 --- a/src/Core/Conversion.php +++ b/src/Core/Conversion.php @@ -21,6 +21,10 @@ public static function dump_unknown(mixed $value, DumpState $state): mixed } if (is_object($value)) { + if ($value instanceof FileParam) { + return $value; + } + if (is_a($value, class: ConverterSource::class)) { return $value::converter()->dump($value, state: $state); } diff --git a/src/Core/FileParam.php b/src/Core/FileParam.php new file mode 100644 index 0000000..bc52309 --- /dev/null +++ b/src/Core/FileParam.php @@ -0,0 +1,63 @@ +files->upload(file: FileParam::fromResource(fopen('data.csv', 'r'))); + * + * // From a string: + * $client->files->upload(file: FileParam::fromString('csv data...', 'data.csv')); + * ``` + */ +final class FileParam +{ + public const DEFAULT_CONTENT_TYPE = 'application/octet-stream'; + + /** + * @param resource|string $data the file content as a resource or string + */ + private function __construct( + public readonly mixed $data, + public readonly string $filename, + public readonly string $contentType = self::DEFAULT_CONTENT_TYPE, + ) {} + + /** + * Create a FileParam from an open resource (e.g. from fopen()). + * + * @param resource $resource an open file resource + * @param string|null $filename Override the filename. Defaults to the resource URI basename. + * @param string $contentType override the content type + */ + public static function fromResource(mixed $resource, ?string $filename = null, string $contentType = self::DEFAULT_CONTENT_TYPE): self + { + if (!is_resource($resource)) { + throw new \InvalidArgumentException('Expected a resource, got '.get_debug_type($resource)); + } + + if (null === $filename) { + $meta = stream_get_meta_data($resource); + $filename = basename($meta['uri'] ?? 'upload'); + } + + return new self($resource, filename: $filename, contentType: $contentType); + } + + /** + * Create a FileParam from a string. + * + * @param string $content the file content + * @param string $filename the filename for the Content-Disposition header + * @param string $contentType override the content type + */ + public static function fromString(string $content, string $filename, string $contentType = self::DEFAULT_CONTENT_TYPE): self + { + return new self($content, filename: $filename, contentType: $contentType); + } +} diff --git a/src/Core/Util.php b/src/Core/Util.php index 58e82aa..19a90c3 100644 --- a/src/Core/Util.php +++ b/src/Core/Util.php @@ -283,7 +283,7 @@ public static function withSetBody( if (preg_match('/^multipart\/form-data/', $contentType)) { [$boundary, $gen] = self::encodeMultipartStreaming($body); - $encoded = implode('', iterator_to_array($gen)); + $encoded = implode('', iterator_to_array($gen, preserve_keys: false)); $stream = $factory->createStream($encoded); /** @var RequestInterface */ @@ -447,11 +447,18 @@ private static function writeMultipartContent( ): \Generator { $contentLine = "Content-Type: %s\r\n\r\n"; - if (is_resource($val)) { - yield sprintf($contentLine, $contentType ?? 'application/octet-stream'); - while (!feof($val)) { - if ($read = fread($val, length: self::BUF_SIZE)) { - yield $read; + if ($val instanceof FileParam) { + $ct = $val->contentType ?? $contentType; + + yield sprintf($contentLine, $ct); + $data = $val->data; + if (is_string($data)) { + yield $data; + } else { // resource + while (!feof($data)) { + if ($read = fread($data, length: self::BUF_SIZE)) { + yield $read; + } } } } elseif (is_string($val) || is_numeric($val) || is_bool($val)) { @@ -483,17 +490,48 @@ private static function writeMultipartChunk( yield 'Content-Disposition: form-data'; if (!is_null($key)) { - $name = rawurlencode(self::strVal($key)); + $name = str_replace(['"', "\r", "\n"], replace: '', subject: $key); yield "; name=\"{$name}\""; } + // File uploads require a filename in the Content-Disposition header, + // e.g. `Content-Disposition: form-data; name="file"; filename="data.csv"` + // Without this, many servers will reject the upload with a 400. + if ($val instanceof FileParam) { + $filename = str_replace(['"', "\r", "\n"], replace: '', subject: $val->filename); + + yield "; filename=\"{$filename}\""; + } + yield "\r\n"; foreach (self::writeMultipartContent($val, closing: $closing) as $chunk) { yield $chunk; } } + /** + * Expands list arrays into separate multipart parts, applying the configured array key format. + * + * @param list $closing + * + * @return \Generator + */ + private static function writeMultipartField( + string $boundary, + ?string $key, + mixed $val, + array &$closing + ): \Generator { + if (is_array($val) && array_is_list($val)) { + foreach ($val as $item) { + yield from self::writeMultipartField(boundary: $boundary, key: $key, val: $item, closing: $closing); + } + } else { + yield from self::writeMultipartChunk(boundary: $boundary, key: $key, val: $val, closing: $closing); + } + } + /** * @param bool|int|float|string|resource|\Traversable|array|null $body * @@ -508,14 +546,10 @@ private static function encodeMultipartStreaming(mixed $body): array try { if (is_array($body) || is_object($body)) { foreach ((array) $body as $key => $val) { - foreach (static::writeMultipartChunk(boundary: $boundary, key: $key, val: $val, closing: $closing) as $chunk) { - yield $chunk; - } + yield from static::writeMultipartField(boundary: $boundary, key: $key, val: $val, closing: $closing); } } else { - foreach (static::writeMultipartChunk(boundary: $boundary, key: null, val: $body, closing: $closing) as $chunk) { - yield $chunk; - } + yield from static::writeMultipartField(boundary: $boundary, key: null, val: $body, closing: $closing); } yield "--{$boundary}--\r\n"; From 17f1ece3f13369ac5555a6df9af1bb4fdce3d307 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 18 Apr 2026 07:16:32 +0000 Subject: [PATCH 06/18] fix(client): resolve serialization issue with unions and enums --- src/Core/Attributes/Required.php | 17 +---------------- src/Core/Conversion.php | 15 +++++++++++++++ src/Core/Conversion/EnumOf.php | 15 +++++++++++++-- 3 files changed, 29 insertions(+), 18 deletions(-) diff --git a/src/Core/Attributes/Required.php b/src/Core/Attributes/Required.php index c8b5851..82791f6 100644 --- a/src/Core/Attributes/Required.php +++ b/src/Core/Attributes/Required.php @@ -25,9 +25,6 @@ class Required public readonly bool $nullable; - /** @var array */ - private static array $enumConverters = []; - /** * @param class-string|Converter|string|null $type * @param class-string<\BackedEnum>|Converter|null $enum @@ -52,7 +49,7 @@ public function __construct( $type ??= new MapOf($map); } if (null !== $enum) { - $type ??= $enum instanceof Converter ? $enum : self::enumConverter($enum); + $type ??= $enum instanceof Converter ? $enum : EnumOf::fromBackedEnum($enum); } $this->apiName = $apiName; @@ -60,16 +57,4 @@ public function __construct( $this->optional = false; $this->nullable = $nullable; } - - /** @property class-string<\BackedEnum> $enum */ - private static function enumConverter(string $enum): Converter - { - if (!isset(self::$enumConverters[$enum])) { - // @phpstan-ignore-next-line argument.type - $converter = new EnumOf(array_column($enum::cases(), column_key: 'value')); - self::$enumConverters[$enum] = $converter; - } - - return self::$enumConverters[$enum]; - } } diff --git a/src/Core/Conversion.php b/src/Core/Conversion.php index e9a8688..363e47c 100644 --- a/src/Core/Conversion.php +++ b/src/Core/Conversion.php @@ -8,6 +8,7 @@ use Stagehand\Core\Conversion\Contracts\Converter; use Stagehand\Core\Conversion\Contracts\ConverterSource; use Stagehand\Core\Conversion\DumpState; +use Stagehand\Core\Conversion\EnumOf; /** * @internal @@ -65,6 +66,13 @@ public static function coerce(Converter|ConverterSource|string $target, mixed $v return $target->coerce($value, state: $state); } + // BackedEnum class-name targets: wrap in EnumOf so enum values are scored + // against the enum's cases. Without this, tryConvert's default case scores + // any class-name target as `no`, even when the value is a valid enum member. + if (is_a($target, class: \BackedEnum::class, allow_string: true)) { + return EnumOf::fromBackedEnum($target)->coerce($value, state: $state); + } + return self::tryConvert($target, value: $value, state: $state); } @@ -78,6 +86,13 @@ public static function dump(Converter|ConverterSource|string $target, mixed $val return $target::converter()->dump($value, state: $state); } + // BackedEnum class-name targets: wrap in EnumOf so enum values are scored + // against the enum's cases. Without this, tryConvert's default case scores + // any class-name target as `no`, even when the value is a valid enum member. + if (is_a($target, class: \BackedEnum::class, allow_string: true)) { + return EnumOf::fromBackedEnum($target)->dump($value, state: $state); + } + self::tryConvert($target, value: $value, state: $state); return self::dump_unknown($value, state: $state); diff --git a/src/Core/Conversion/EnumOf.php b/src/Core/Conversion/EnumOf.php index 729a2e6..fbb7161 100644 --- a/src/Core/Conversion/EnumOf.php +++ b/src/Core/Conversion/EnumOf.php @@ -14,6 +14,9 @@ final class EnumOf implements Converter { private readonly string $type; + /** @var array, self> */ + private static array $cache = []; + /** * @param list $members */ @@ -26,6 +29,13 @@ public function __construct(private readonly array $members) $this->type = $type; } + /** @param class-string<\BackedEnum> $enum */ + public static function fromBackedEnum(string $enum): self + { + // @phpstan-ignore-next-line argument.type + return self::$cache[$enum] ??= new self(array_column($enum::cases(), column_key: 'value')); + } + public function coerce(mixed $value, CoerceState $state): mixed { $this->tally($value, state: $state); @@ -42,9 +52,10 @@ public function dump(mixed $value, DumpState $state): mixed private function tally(mixed $value, CoerceState|DumpState $state): void { - if (in_array($value, haystack: $this->members, strict: true)) { + $needle = $value instanceof \BackedEnum ? $value->value : $value; + if (in_array($needle, haystack: $this->members, strict: true)) { ++$state->yes; - } elseif ($this->type === gettype($value)) { + } elseif ($this->type === gettype($needle)) { ++$state->maybe; } else { ++$state->no; From 0ba1b6fda9bd4709e3665a3bd7659373b87b64d3 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 18 Apr 2026 07:18:12 +0000 Subject: [PATCH 07/18] fix: populate enum-typed properties with enum instances --- src/Core/Conversion/EnumOf.php | 20 +++++++++-- tests/Core/ModelTest.php | 62 ++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+), 3 deletions(-) diff --git a/src/Core/Conversion/EnumOf.php b/src/Core/Conversion/EnumOf.php index fbb7161..bacdc2e 100644 --- a/src/Core/Conversion/EnumOf.php +++ b/src/Core/Conversion/EnumOf.php @@ -19,9 +19,12 @@ final class EnumOf implements Converter /** * @param list $members + * @param class-string<\BackedEnum>|null $class */ - public function __construct(private readonly array $members) - { + public function __construct( + private readonly array $members, + private readonly ?string $class = null, + ) { $type = 'NULL'; foreach ($this->members as $member) { $type = gettype($member); @@ -33,13 +36,24 @@ public function __construct(private readonly array $members) public static function fromBackedEnum(string $enum): self { // @phpstan-ignore-next-line argument.type - return self::$cache[$enum] ??= new self(array_column($enum::cases(), column_key: 'value')); + return self::$cache[$enum] ??= new self( + array_column($enum::cases(), column_key: 'value'), + class: $enum, + ); } public function coerce(mixed $value, CoerceState $state): mixed { $this->tally($value, state: $state); + if ($value instanceof \BackedEnum) { + return $value; + } + + if (null !== $this->class && (is_int($value) || is_string($value))) { + return ($this->class)::tryFrom($value) ?? $value; + } + return $value; } diff --git a/tests/Core/ModelTest.php b/tests/Core/ModelTest.php index 8d3d680..e919625 100644 --- a/tests/Core/ModelTest.php +++ b/tests/Core/ModelTest.php @@ -47,6 +47,30 @@ public function __construct( } } +enum TicketPriority: string +{ + case Low = 'low'; + case High = 'high'; +} + +class Ticket implements BaseModel +{ + /** @use SdkModel> */ + use SdkModel; + + #[Required(enum: TicketPriority::class)] + public TicketPriority $priority; + + /** @var list */ + #[Required(list: TicketPriority::class)] + public array $labels; + + public function __construct() + { + $this->initialize(); + } +} + /** * @internal * @@ -141,4 +165,42 @@ public function testSerializeModelWithExplicitNull(): void json_encode($model) ); } + + #[Test] + public function testScalarEnumCoercesToInstance(): void + { + $model = Ticket::fromArray(['priority' => 'low', 'labels' => []]); + $this->assertSame(TicketPriority::Low, $model->priority); + } + + #[Test] + public function testListOfEnumCoercesElementsToInstances(): void + { + $model = Ticket::fromArray(['priority' => 'low', 'labels' => ['low', 'high']]); + $this->assertCount(2, $model->labels); + $this->assertSame(TicketPriority::Low, $model->labels[0]); + $this->assertSame(TicketPriority::High, $model->labels[1]); + } + + #[Test] + public function testEnumInstancePassesThrough(): void + { + $model = Ticket::fromArray(['priority' => TicketPriority::High, 'labels' => []]); + $this->assertSame(TicketPriority::High, $model->priority); + } + + #[Test] + public function testInvalidEnumScalarFallsBackToData(): void + { + $model = Ticket::fromArray(['priority' => 'urgent', 'labels' => []]); + $this->assertSame('urgent', $model['priority']); + } + + #[Test] + public function testEnumWireFormatStableAcrossConstruction(): void + { + $fromScalar = Ticket::fromArray(['priority' => 'low', 'labels' => ['high']]); + $fromInstance = Ticket::fromArray(['priority' => TicketPriority::Low, 'labels' => [TicketPriority::High]]); + $this->assertSame(json_encode($fromScalar), json_encode($fromInstance)); + } } From ca1dd7a1dd2d8cf0b0b2d50f9cf317c98652cc89 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 28 Apr 2026 03:48:20 +0000 Subject: [PATCH 08/18] fix: revert enum parsing change that lead to unconditional failure --- src/Core/Conversion/EnumOf.php | 20 ++--------- tests/Core/ModelTest.php | 62 ---------------------------------- 2 files changed, 3 insertions(+), 79 deletions(-) diff --git a/src/Core/Conversion/EnumOf.php b/src/Core/Conversion/EnumOf.php index bacdc2e..fbb7161 100644 --- a/src/Core/Conversion/EnumOf.php +++ b/src/Core/Conversion/EnumOf.php @@ -19,12 +19,9 @@ final class EnumOf implements Converter /** * @param list $members - * @param class-string<\BackedEnum>|null $class */ - public function __construct( - private readonly array $members, - private readonly ?string $class = null, - ) { + public function __construct(private readonly array $members) + { $type = 'NULL'; foreach ($this->members as $member) { $type = gettype($member); @@ -36,24 +33,13 @@ public function __construct( public static function fromBackedEnum(string $enum): self { // @phpstan-ignore-next-line argument.type - return self::$cache[$enum] ??= new self( - array_column($enum::cases(), column_key: 'value'), - class: $enum, - ); + return self::$cache[$enum] ??= new self(array_column($enum::cases(), column_key: 'value')); } public function coerce(mixed $value, CoerceState $state): mixed { $this->tally($value, state: $state); - if ($value instanceof \BackedEnum) { - return $value; - } - - if (null !== $this->class && (is_int($value) || is_string($value))) { - return ($this->class)::tryFrom($value) ?? $value; - } - return $value; } diff --git a/tests/Core/ModelTest.php b/tests/Core/ModelTest.php index e919625..8d3d680 100644 --- a/tests/Core/ModelTest.php +++ b/tests/Core/ModelTest.php @@ -47,30 +47,6 @@ public function __construct( } } -enum TicketPriority: string -{ - case Low = 'low'; - case High = 'high'; -} - -class Ticket implements BaseModel -{ - /** @use SdkModel> */ - use SdkModel; - - #[Required(enum: TicketPriority::class)] - public TicketPriority $priority; - - /** @var list */ - #[Required(list: TicketPriority::class)] - public array $labels; - - public function __construct() - { - $this->initialize(); - } -} - /** * @internal * @@ -165,42 +141,4 @@ public function testSerializeModelWithExplicitNull(): void json_encode($model) ); } - - #[Test] - public function testScalarEnumCoercesToInstance(): void - { - $model = Ticket::fromArray(['priority' => 'low', 'labels' => []]); - $this->assertSame(TicketPriority::Low, $model->priority); - } - - #[Test] - public function testListOfEnumCoercesElementsToInstances(): void - { - $model = Ticket::fromArray(['priority' => 'low', 'labels' => ['low', 'high']]); - $this->assertCount(2, $model->labels); - $this->assertSame(TicketPriority::Low, $model->labels[0]); - $this->assertSame(TicketPriority::High, $model->labels[1]); - } - - #[Test] - public function testEnumInstancePassesThrough(): void - { - $model = Ticket::fromArray(['priority' => TicketPriority::High, 'labels' => []]); - $this->assertSame(TicketPriority::High, $model->priority); - } - - #[Test] - public function testInvalidEnumScalarFallsBackToData(): void - { - $model = Ticket::fromArray(['priority' => 'urgent', 'labels' => []]); - $this->assertSame('urgent', $model['priority']); - } - - #[Test] - public function testEnumWireFormatStableAcrossConstruction(): void - { - $fromScalar = Ticket::fromArray(['priority' => 'low', 'labels' => ['high']]); - $fromInstance = Ticket::fromArray(['priority' => TicketPriority::Low, 'labels' => [TicketPriority::High]]); - $this->assertSame(json_encode($fromScalar), json_encode($fromInstance)); - } } From 81f19911e0d5d090713059122afc4bd0336125c4 Mon Sep 17 00:00:00 2001 From: monadoid Date: Thu, 30 Apr 2026 18:42:12 +0200 Subject: [PATCH 09/18] [STG-1808] Prefer STAGEHAND_API_URL env fallback --- src/Client.php | 6 +-- tests/ClientTest.php | 105 +++++++++++++++++++++++++++++++++++++++---- 2 files changed, 99 insertions(+), 12 deletions(-) diff --git a/src/Client.php b/src/Client.php index 267d660..582b7d3 100644 --- a/src/Client.php +++ b/src/Client.php @@ -47,9 +47,9 @@ public function __construct( 'MODEL_API_KEY' )); - $baseUrl ??= Util::getenv( - 'STAGEHAND_BASE_URL' - ) ?: 'https://api.stagehand.browserbase.com'; + $baseUrl ??= Util::getenv('STAGEHAND_API_URL') + ?: Util::getenv('STAGEHAND_BASE_URL') + ?: 'https://api.stagehand.browserbase.com'; $options = RequestOptions::parse( RequestOptions::with( diff --git a/tests/ClientTest.php b/tests/ClientTest.php index 9f211de..81ba6ea 100644 --- a/tests/ClientTest.php +++ b/tests/ClientTest.php @@ -14,17 +14,65 @@ */ class ClientTest extends TestCase { - public function testDefaultHeaders(): void + public function testBaseUrlUsesStagehandAPIUrlEnv(): void { - $transporter = new Client; - $mockRsp = Psr17FactoryDiscovery::findResponseFactory() - ->createResponse() - ->withStatus(200) - ->withHeader('Content-Type', 'application/json') - ->withBody(Psr17FactoryDiscovery::findStreamFactory()->createStream(json_encode([], flags: Util::JSON_ENCODE_FLAGS) ?: '')) - ; + $this->withEnv( + [ + 'STAGEHAND_API_URL' => 'http://localhost:5000/from-api-env', + 'STAGEHAND_BASE_URL' => 'http://localhost:5000/from-base-env', + ], + function (): void { + $transporter = $this->mockTransport(); - $transporter->setDefaultResponse($mockRsp); + $client = new \Stagehand\Client( + browserbaseAPIKey: 'My Browserbase API Key', + browserbaseProjectID: 'My Browserbase Project ID', + modelAPIKey: 'My Model API Key', + requestOptions: ['transporter' => $transporter], + ); + + $client->sessions->start(modelName: 'openai/gpt-5.4-mini'); + + $this->assertNotFalse($requested = $transporter->getRequests()[0] ?? false); + $this->assertSame( + 'http://localhost:5000/from-api-env/v1/sessions/start', + (string) $requested->getUri() + ); + }, + ); + } + + public function testBaseUrlUsesLegacyStagehandBaseUrlEnv(): void + { + $this->withEnv( + [ + 'STAGEHAND_API_URL' => null, + 'STAGEHAND_BASE_URL' => 'http://localhost:5000/from-base-env', + ], + function (): void { + $transporter = $this->mockTransport(); + + $client = new \Stagehand\Client( + browserbaseAPIKey: 'My Browserbase API Key', + browserbaseProjectID: 'My Browserbase Project ID', + modelAPIKey: 'My Model API Key', + requestOptions: ['transporter' => $transporter], + ); + + $client->sessions->start(modelName: 'openai/gpt-5.4-mini'); + + $this->assertNotFalse($requested = $transporter->getRequests()[0] ?? false); + $this->assertSame( + 'http://localhost:5000/from-base-env/v1/sessions/start', + (string) $requested->getUri() + ); + }, + ); + } + + public function testDefaultHeaders(): void + { + $transporter = $this->mockTransport(); $client = new \Stagehand\Client( baseUrl: 'http://localhost', @@ -43,4 +91,43 @@ public function testDefaultHeaders(): void $this->assertNotEmpty($sent); } } + + private function mockTransport(): Client + { + $transporter = new Client; + $mockRsp = Psr17FactoryDiscovery::findResponseFactory() + ->createResponse() + ->withStatus(200) + ->withHeader('Content-Type', 'application/json') + ->withBody(Psr17FactoryDiscovery::findStreamFactory()->createStream(json_encode([], flags: Util::JSON_ENCODE_FLAGS) ?: '')) + ; + + $transporter->setDefaultResponse($mockRsp); + + return $transporter; + } + + /** + * @param array $vars + */ + private function withEnv(array $vars, callable $callback): void + { + $oldValues = []; + foreach ($vars as $key => $_) { + $value = getenv($key); + $oldValues[$key] = false === $value ? null : $value; + } + + try { + foreach ($vars as $key => $value) { + null === $value ? putenv($key) : putenv("{$key}={$value}"); + } + + $callback(); + } finally { + foreach ($oldValues as $key => $value) { + null === $value ? putenv($key) : putenv("{$key}={$value}"); + } + } + } } From 4e816f6a0d1fe912d11dd0207e9fbc4404d44ab8 Mon Sep 17 00:00:00 2001 From: Sam F <43347795+monadoid@users.noreply.github.com> Date: Wed, 6 May 2026 21:55:04 +0200 Subject: [PATCH 10/18] Deprecate browserbase project ID (#58) Co-authored-by: samfinton --- AGENTS.md | 2 -- README.md | 8 +------- examples/basic.php | 2 -- src/Client.php | 13 ++++++------- tests/ClientTest.php | 18 ++++++++++++++++++ 5 files changed, 25 insertions(+), 18 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index a49b682..c1e86c3 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -32,7 +32,6 @@ composer require browserbase/stagehand # Set environment variables export BROWSERBASE_API_KEY="your-bb-api-key" -export BROWSERBASE_PROJECT_ID="your-bb-project-uuid" export MODEL_API_KEY="sk-proj-your-llm-api-key" # Run the example @@ -45,7 +44,6 @@ use Stagehand\Client; $client = new Client( browserbaseAPIKey: getenv('BROWSERBASE_API_KEY'), - browserbaseProjectID: getenv('BROWSERBASE_PROJECT_ID'), modelAPIKey: getenv('MODEL_API_KEY'), ); $startResponse = $client->sessions->start(model: 'openai/gpt-5-nano'); diff --git a/README.md b/README.md index 1749137..3ea96f8 100644 --- a/README.md +++ b/README.md @@ -113,14 +113,12 @@ if (file_exists(__DIR__ . '/../.env')) { // Initialize the Stagehand client with API keys from environment variables $client = new Client( browserbaseAPIKey: getenv('BROWSERBASE_API_KEY') ?: throw new Exception('BROWSERBASE_API_KEY environment variable is required'), - browserbaseProjectID: getenv('BROWSERBASE_PROJECT_ID') ?: throw new Exception('BROWSERBASE_PROJECT_ID environment variable is required'), modelAPIKey: getenv('MODEL_API_KEY') ?: throw new Exception('MODEL_API_KEY environment variable is required'), ); // Start a new session $startResponse = $client->sessions->start( browserbaseAPIKey: getenv('BROWSERBASE_API_KEY'), - browserbaseProjectID: getenv('BROWSERBASE_PROJECT_ID'), model: 'openai/gpt-4o', ); echo "Session started: {$startResponse->data->sessionID}\n"; @@ -217,12 +215,11 @@ echo "Session ended\n"; ### Running the Example -Set the required environment variables and run the example script: +Set the environment variables and run the example script: ```bash # Set your credentials export BROWSERBASE_API_KEY="your-browserbase-api-key" -export BROWSERBASE_PROJECT_ID="your-browserbase-project-id" export MODEL_API_KEY="your-openai-api-key" # Install dependencies and run @@ -248,9 +245,6 @@ use Stagehand\Client; $client = new Client( browserbaseAPIKey: getenv('BROWSERBASE_API_KEY') ?: 'My Browserbase API Key', - browserbaseProjectID: getenv( - 'BROWSERBASE_PROJECT_ID' - ) ?: 'My Browserbase Project ID', modelAPIKey: getenv('MODEL_API_KEY') ?: 'My Model API Key', ); diff --git a/examples/basic.php b/examples/basic.php index 51ee2b6..3f22180 100644 --- a/examples/basic.php +++ b/examples/basic.php @@ -18,14 +18,12 @@ // Initialize the Stagehand client with API keys from environment variables $client = new Client( browserbaseAPIKey: getenv('BROWSERBASE_API_KEY') ?: throw new Exception('BROWSERBASE_API_KEY environment variable is required'), - browserbaseProjectID: getenv('BROWSERBASE_PROJECT_ID') ?: throw new Exception('BROWSERBASE_PROJECT_ID environment variable is required'), modelAPIKey: getenv('MODEL_API_KEY') ?: throw new Exception('MODEL_API_KEY environment variable is required'), ); // Start a new session $startResponse = $client->sessions->start( browserbaseAPIKey: getenv('BROWSERBASE_API_KEY'), - browserbaseProjectID: getenv('BROWSERBASE_PROJECT_ID'), model: 'openai/gpt-4o', ); echo "Session started: {$startResponse->data->sessionID}\n"; diff --git a/src/Client.php b/src/Client.php index 582b7d3..a08d222 100644 --- a/src/Client.php +++ b/src/Client.php @@ -18,6 +18,10 @@ class Client extends BaseClient { public string $browserbaseAPIKey; + /** + * Deprecated. Browserbase API keys are now project-scoped, so this value is no longer required. + * Accepted for backwards compatibility; it is ignored. + */ public string $browserbaseProjectID; public string $modelAPIKey; @@ -40,9 +44,7 @@ public function __construct( $this->browserbaseAPIKey = (string) ($browserbaseAPIKey ?? Util::getenv( 'BROWSERBASE_API_KEY' )); - $this->browserbaseProjectID = (string) ($browserbaseProjectID ?? Util::getenv( - 'BROWSERBASE_PROJECT_ID' - )); + $this->browserbaseProjectID = (string) $browserbaseProjectID; $this->modelAPIKey = (string) ($modelAPIKey ?? Util::getenv( 'MODEL_API_KEY' )); @@ -85,7 +87,6 @@ protected function authHeaders(): array { return [ ...$this->bbAPIKeyAuth(), - ...$this->bbProjectIDAuth(), ...$this->llmModelAPIKeyAuth(), ]; } @@ -101,9 +102,7 @@ protected function bbAPIKeyAuth(): array /** @return array */ protected function bbProjectIDAuth(): array { - return $this->browserbaseProjectID ? [ - 'x-bb-project-id' => $this->browserbaseProjectID, - ] : []; + return []; } /** @return array */ diff --git a/tests/ClientTest.php b/tests/ClientTest.php index 81ba6ea..0bd037d 100644 --- a/tests/ClientTest.php +++ b/tests/ClientTest.php @@ -92,6 +92,24 @@ public function testDefaultHeaders(): void } } + public function testProjectIDHeaderIsOmitted(): void + { + $transporter = $this->mockTransport(); + + $client = new \Stagehand\Client( + baseUrl: 'http://localhost', + browserbaseAPIKey: 'My Browserbase API Key', + browserbaseProjectID: 'My Browserbase Project ID', + modelAPIKey: 'My Model API Key', + requestOptions: ['transporter' => $transporter], + ); + + $client->sessions->start(modelName: 'openai/gpt-5.4-mini'); + + $this->assertNotFalse($requested = $transporter->getRequests()[0] ?? false); + $this->assertSame('', $requested->getHeaderLine('x-bb-project-id')); + } + private function mockTransport(): Client { $transporter = new Client; From d6235c1aa657237410c3bab8483b6a5f8ebf3eba Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 6 May 2026 20:07:44 +0000 Subject: [PATCH 11/18] feat: support setting headers via env --- src/Client.php | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/src/Client.php b/src/Client.php index a08d222..c571bb6 100644 --- a/src/Client.php +++ b/src/Client.php @@ -63,18 +63,31 @@ public function __construct( $requestOptions, ); + /** @var array $headers */ + $headers = [ + 'Content-Type' => 'application/json', + 'Accept' => 'application/json', + 'User-Agent' => sprintf('stagehand/PHP %s', VERSION), + 'X-Stainless-Lang' => 'php', + 'X-Stainless-Package-Version' => '3.19.3', + 'X-Stainless-Arch' => Util::machtype(), + 'X-Stainless-OS' => Util::ostype(), + 'X-Stainless-Runtime' => php_sapi_name(), + 'X-Stainless-Runtime-Version' => phpversion(), + ]; + + $customHeadersEnv = Util::getenv('STAGEHAND_CUSTOM_HEADERS'); + if (null !== $customHeadersEnv) { + foreach (explode("\n", $customHeadersEnv) as $line) { + $colon = strpos($line, ':'); + if (false !== $colon) { + $headers[trim(substr($line, 0, $colon))] = trim(substr($line, $colon + 1)); + } + } + } + parent::__construct( - headers: [ - 'Content-Type' => 'application/json', - 'Accept' => 'application/json', - 'User-Agent' => sprintf('stagehand/PHP %s', VERSION), - 'X-Stainless-Lang' => 'php', - 'X-Stainless-Package-Version' => '3.1.0', - 'X-Stainless-Arch' => Util::machtype(), - 'X-Stainless-OS' => Util::ostype(), - 'X-Stainless-Runtime' => php_sapi_name(), - 'X-Stainless-Runtime-Version' => phpversion(), - ], + headers: $headers, baseUrl: $baseUrl, options: $options ); From 7265084d281f740b4f74aad0ce6986be1ebeccde Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 30 Apr 2026 06:01:14 +0000 Subject: [PATCH 12/18] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index d8428d4..0bd171d 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 8 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browserbase%2Fstagehand-1c6caa2891a7f3bdfc0caab143f285badc9145220c9b29cd5e4cf1a9b3ac11cf.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browserbase/stagehand-1c6caa2891a7f3bdfc0caab143f285badc9145220c9b29cd5e4cf1a9b3ac11cf.yml openapi_spec_hash: 28c4b734a5309067c39bb4c4b709b9ab config_hash: a962ae71493deb11a1c903256fb25386 From d1e774436fcd82e149f92103edce8bebdcf29902 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 1 May 2026 02:00:23 +0000 Subject: [PATCH 13/18] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 0bd171d..b17eb0a 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 8 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browserbase/stagehand-1c6caa2891a7f3bdfc0caab143f285badc9145220c9b29cd5e4cf1a9b3ac11cf.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browserbase/stagehand-dbbff1a35360850898f7d60588e257faeac145a73cfcae634cfeb1b70109b6af.yml openapi_spec_hash: 28c4b734a5309067c39bb4c4b709b9ab config_hash: a962ae71493deb11a1c903256fb25386 From eb093f76a7e0999169970d79341fafa2871a6eee Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 6 May 2026 02:06:13 +0000 Subject: [PATCH 14/18] fix(release): use canonical GitHub URL in Packagist publish script --- .github/workflows/publish-packagist.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish-packagist.yml b/.github/workflows/publish-packagist.yml index c632370..6c6f68e 100644 --- a/.github/workflows/publish-packagist.yml +++ b/.github/workflows/publish-packagist.yml @@ -15,7 +15,7 @@ jobs: - name: Publish to Packagist run: |- - curl --fail-with-body -X POST -H 'Content-Type: application/json' "https://packagist.org/api/update-package?username=${PACKAGIST_USERNAME}&apiToken=${PACKAGIST_SAFE_KEY}" -d '{"repository":"https://www.github.com/browserbase/stagehand-php"}' + curl --fail-with-body -X POST -H 'Content-Type: application/json' "https://packagist.org/api/update-package?username=${PACKAGIST_USERNAME}&apiToken=${PACKAGIST_SAFE_KEY}" -d '{"repository":"https://github.com/browserbase/stagehand-php"}' env: PACKAGIST_USERNAME: ${{ secrets.STAGEHAND_PACKAGIST_USERNAME || secrets.PACKAGIST_USERNAME }} PACKAGIST_SAFE_KEY: ${{ secrets.STAGEHAND_PACKAGIST_SAFE_KEY || secrets.PACKAGIST_SAFE_KEY }} \ No newline at end of file From 4d548b6b71174972b12884840185357a30e30d8d Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 6 May 2026 17:06:19 +0000 Subject: [PATCH 15/18] feat: [feat]: add `ignoreSelectors` to `extract()` --- .stats.yml | 4 +-- src/Sessions/SessionExtractParams/Options.php | 29 ++++++++++++++++++- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/.stats.yml b/.stats.yml index b17eb0a..128128c 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 8 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browserbase/stagehand-dbbff1a35360850898f7d60588e257faeac145a73cfcae634cfeb1b70109b6af.yml -openapi_spec_hash: 28c4b734a5309067c39bb4c4b709b9ab +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browserbase/stagehand-7182c741edd5e22cda9bd855d31ca7e60a97a409222bb887edf87b9ce15dd493.yml +openapi_spec_hash: 174581867a9191c491b22855b64c4f19 config_hash: a962ae71493deb11a1c903256fb25386 diff --git a/src/Sessions/SessionExtractParams/Options.php b/src/Sessions/SessionExtractParams/Options.php index 835c3b1..0e8a6c3 100644 --- a/src/Sessions/SessionExtractParams/Options.php +++ b/src/Sessions/SessionExtractParams/Options.php @@ -14,7 +14,10 @@ * @phpstan-import-type ModelShape from \Stagehand\Sessions\SessionExtractParams\Options\Model * * @phpstan-type OptionsShape = array{ - * model?: ModelShape|null, selector?: string|null, timeout?: float|null + * ignoreSelectors?: list|null, + * model?: ModelShape|null, + * selector?: string|null, + * timeout?: float|null, * } */ final class Options implements BaseModel @@ -22,6 +25,14 @@ final class Options implements BaseModel /** @use SdkModel */ use SdkModel; + /** + * Selectors for elements and subtrees that should be excluded from extraction. + * + * @var list|null $ignoreSelectors + */ + #[Optional(list: 'string')] + public ?array $ignoreSelectors; + /** * Model configuration object or model name string (e.g., 'openai/gpt-5-nano'). * @@ -52,15 +63,18 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * + * @param list|null $ignoreSelectors * @param ModelShape|null $model */ public static function with( + ?array $ignoreSelectors = null, string|ModelConfig|array|null $model = null, ?string $selector = null, ?float $timeout = null, ): self { $self = new self; + null !== $ignoreSelectors && $self['ignoreSelectors'] = $ignoreSelectors; null !== $model && $self['model'] = $model; null !== $selector && $self['selector'] = $selector; null !== $timeout && $self['timeout'] = $timeout; @@ -68,6 +82,19 @@ public static function with( return $self; } + /** + * Selectors for elements and subtrees that should be excluded from extraction. + * + * @param list $ignoreSelectors + */ + public function withIgnoreSelectors(array $ignoreSelectors): self + { + $self = clone $this; + $self['ignoreSelectors'] = $ignoreSelectors; + + return $self; + } + /** * Model configuration object or model name string (e.g., 'openai/gpt-5-nano'). * From 5ce5e2347bb5700816910f4973b1d74487e2b92e Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 6 May 2026 20:14:51 +0000 Subject: [PATCH 16/18] feat: [STG-1808] Deprecate Browserbase project ID --- .stats.yml | 6 +++--- .../SessionStartParams/BrowserbaseSessionCreateParams.php | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.stats.yml b/.stats.yml index 128128c..d79c632 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 8 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browserbase/stagehand-7182c741edd5e22cda9bd855d31ca7e60a97a409222bb887edf87b9ce15dd493.yml -openapi_spec_hash: 174581867a9191c491b22855b64c4f19 -config_hash: a962ae71493deb11a1c903256fb25386 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browserbase/stagehand-f10429ab9f004c9a7f9f362d7fa82915e0dc04b1ba08a7bc9fd442ed5854cc77.yml +openapi_spec_hash: 818f2e6e7eb5eb6f21f346b0b9828dce +config_hash: 1fb12ae9b478488bc1e56bfbdc210b01 diff --git a/src/Sessions/SessionStartParams/BrowserbaseSessionCreateParams.php b/src/Sessions/SessionStartParams/BrowserbaseSessionCreateParams.php index 07b8956..948d65f 100644 --- a/src/Sessions/SessionStartParams/BrowserbaseSessionCreateParams.php +++ b/src/Sessions/SessionStartParams/BrowserbaseSessionCreateParams.php @@ -41,6 +41,11 @@ final class BrowserbaseSessionCreateParams implements BaseModel #[Optional] public ?bool $keepAlive; + /** + * @deprecated + * + * Deprecated. Browserbase API keys are now project-scoped, so this field is no longer required. + */ #[Optional('projectId')] public ?string $projectID; @@ -126,6 +131,9 @@ public function withKeepAlive(bool $keepAlive): self return $self; } + /** + * Deprecated. Browserbase API keys are now project-scoped, so this field is no longer required. + */ public function withProjectID(string $projectID): self { $self = clone $this; From 7271c1e3ee6a8c3e8fe425a77196c051c7dfa086 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 6 May 2026 18:52:34 +0000 Subject: [PATCH 17/18] feat: remove experimental requirement on agent variables (#2079) --- .stats.yml | 4 +- .../SessionExecuteParams/ExecuteOptions.php | 30 +++++++ .../ExecuteOptions/Variable.php | 29 ++++++ .../ExecuteOptions/Variable/UnionMember3.php | 89 +++++++++++++++++++ .../Variable/UnionMember3/Value.php | 26 ++++++ tests/Services/SessionsTest.php | 1 + 6 files changed, 177 insertions(+), 2 deletions(-) create mode 100644 src/Sessions/SessionExecuteParams/ExecuteOptions/Variable.php create mode 100644 src/Sessions/SessionExecuteParams/ExecuteOptions/Variable/UnionMember3.php create mode 100644 src/Sessions/SessionExecuteParams/ExecuteOptions/Variable/UnionMember3/Value.php diff --git a/.stats.yml b/.stats.yml index d79c632..391cde3 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 8 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browserbase/stagehand-f10429ab9f004c9a7f9f362d7fa82915e0dc04b1ba08a7bc9fd442ed5854cc77.yml -openapi_spec_hash: 818f2e6e7eb5eb6f21f346b0b9828dce +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browserbase/stagehand-6f6bfb81d092f30a5e2005328c97d61b9ea36132bb19e9e79e55294b9534ce20.yml +openapi_spec_hash: f3fc1e3688a38dc2c28f7178f7d534e5 config_hash: 1fb12ae9b478488bc1e56bfbdc210b01 diff --git a/src/Sessions/SessionExecuteParams/ExecuteOptions.php b/src/Sessions/SessionExecuteParams/ExecuteOptions.php index be26904..c66813d 100644 --- a/src/Sessions/SessionExecuteParams/ExecuteOptions.php +++ b/src/Sessions/SessionExecuteParams/ExecuteOptions.php @@ -8,14 +8,19 @@ use Stagehand\Core\Attributes\Required; use Stagehand\Core\Concerns\SdkModel; use Stagehand\Core\Contracts\BaseModel; +use Stagehand\Sessions\SessionExecuteParams\ExecuteOptions\Variable; /** + * @phpstan-import-type VariableVariants from \Stagehand\Sessions\SessionExecuteParams\ExecuteOptions\Variable + * @phpstan-import-type VariableShape from \Stagehand\Sessions\SessionExecuteParams\ExecuteOptions\Variable + * * @phpstan-type ExecuteOptionsShape = array{ * instruction: string, * highlightCursor?: bool|null, * maxSteps?: float|null, * toolTimeout?: float|null, * useSearch?: bool|null, + * variables?: array|null, * } */ final class ExecuteOptions implements BaseModel @@ -53,6 +58,14 @@ final class ExecuteOptions implements BaseModel #[Optional] public ?bool $useSearch; + /** + * Variables available to the agent via %variableName% syntax in supported tools. + * + * @var array|null $variables + */ + #[Optional(map: Variable::class)] + public ?array $variables; + /** * `new ExecuteOptions()` is missing required properties by the API. * @@ -76,6 +89,8 @@ public function __construct() * Construct an instance from the required parameters. * * You must use named parameters to construct any parameters with a default value. + * + * @param array|null $variables */ public static function with( string $instruction, @@ -83,6 +98,7 @@ public static function with( ?float $maxSteps = null, ?float $toolTimeout = null, ?bool $useSearch = null, + ?array $variables = null, ): self { $self = new self; @@ -92,6 +108,7 @@ public static function with( null !== $maxSteps && $self['maxSteps'] = $maxSteps; null !== $toolTimeout && $self['toolTimeout'] = $toolTimeout; null !== $useSearch && $self['useSearch'] = $useSearch; + null !== $variables && $self['variables'] = $variables; return $self; } @@ -150,4 +167,17 @@ public function withUseSearch(bool $useSearch): self return $self; } + + /** + * Variables available to the agent via %variableName% syntax in supported tools. + * + * @param array $variables + */ + public function withVariables(array $variables): self + { + $self = clone $this; + $self['variables'] = $variables; + + return $self; + } } diff --git a/src/Sessions/SessionExecuteParams/ExecuteOptions/Variable.php b/src/Sessions/SessionExecuteParams/ExecuteOptions/Variable.php new file mode 100644 index 0000000..8b2bd3d --- /dev/null +++ b/src/Sessions/SessionExecuteParams/ExecuteOptions/Variable.php @@ -0,0 +1,29 @@ +|array + */ + public static function variants(): array + { + return ['string', 'float', 'bool', UnionMember3::class]; + } +} diff --git a/src/Sessions/SessionExecuteParams/ExecuteOptions/Variable/UnionMember3.php b/src/Sessions/SessionExecuteParams/ExecuteOptions/Variable/UnionMember3.php new file mode 100644 index 0000000..15f3246 --- /dev/null +++ b/src/Sessions/SessionExecuteParams/ExecuteOptions/Variable/UnionMember3.php @@ -0,0 +1,89 @@ + */ + use SdkModel; + + /** @var ValueVariants $value */ + #[Required] + public string|float|bool $value; + + #[Optional] + public ?string $description; + + /** + * `new UnionMember3()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * UnionMember3::with(value: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new UnionMember3)->withValue(...) + * ``` + */ + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + * + * @param ValueShape $value + */ + public static function with( + string|float|bool $value, + ?string $description = null + ): self { + $self = new self; + + $self['value'] = $value; + + null !== $description && $self['description'] = $description; + + return $self; + } + + /** + * @param ValueShape $value + */ + public function withValue(string|float|bool $value): self + { + $self = clone $this; + $self['value'] = $value; + + return $self; + } + + public function withDescription(string $description): self + { + $self = clone $this; + $self['description'] = $description; + + return $self; + } +} diff --git a/src/Sessions/SessionExecuteParams/ExecuteOptions/Variable/UnionMember3/Value.php b/src/Sessions/SessionExecuteParams/ExecuteOptions/Variable/UnionMember3/Value.php new file mode 100644 index 0000000..a8b9cc0 --- /dev/null +++ b/src/Sessions/SessionExecuteParams/ExecuteOptions/Variable/UnionMember3/Value.php @@ -0,0 +1,26 @@ +|array + */ + public static function variants(): array + { + return ['string', 'float', 'bool']; + } +} diff --git a/tests/Services/SessionsTest.php b/tests/Services/SessionsTest.php index 142260d..5d00fc6 100644 --- a/tests/Services/SessionsTest.php +++ b/tests/Services/SessionsTest.php @@ -159,6 +159,7 @@ public function testExecuteWithOptionalParams(): void 'maxSteps' => 20, 'toolTimeout' => 30000, 'useSearch' => true, + 'variables' => ['foo' => 'string'], ], frameID: 'frameId', shouldCache: true, From a93f6d48903002cd851af0096a11efc9f2e3c8a4 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 6 May 2026 20:15:18 +0000 Subject: [PATCH 18/18] release: 3.20.0 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 23 +++++++++++++++++++++++ README.md | 2 +- src/Version.php | 2 +- 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 911c623..d11c8fc 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "3.19.3" + ".": "3.20.0" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index bdc1f55..4ba66f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,28 @@ # Changelog +## 3.20.0 (2026-05-06) + +Full Changelog: [v3.19.3...v3.20.0](https://github.com/browserbase/stagehand-php/compare/v3.19.3...v3.20.0) + +### Features + +* [feat]: add `ignoreSelectors` to `extract()` ([4d548b6](https://github.com/browserbase/stagehand-php/commit/4d548b6b71174972b12884840185357a30e30d8d)) +* [STG-1798] feat: support Browserbase verified sessions ([52c4636](https://github.com/browserbase/stagehand-php/commit/52c4636560e5dd556db9c061a3bb9c48ffa20e76)) +* [STG-1808] Deprecate Browserbase project ID ([5ce5e23](https://github.com/browserbase/stagehand-php/commit/5ce5e2347bb5700816910f4973b1d74487e2b92e)) +* Bedrock auth passthrough ([40cb10e](https://github.com/browserbase/stagehand-php/commit/40cb10eb39c7f53b9c3fd668018c1b3569650e5c)) +* remove experimental requirement on agent variables ([#2079](https://github.com/browserbase/stagehand-php/issues/2079)) ([7271c1e](https://github.com/browserbase/stagehand-php/commit/7271c1e3ee6a8c3e8fe425a77196c051c7dfa086)) +* Revert "[STG-1573] Add providerOptions for extensible model auth ([#1822](https://github.com/browserbase/stagehand-php/issues/1822))" ([1f99ac3](https://github.com/browserbase/stagehand-php/commit/1f99ac3957867970c6eaa968e8daaa83ae855b7b)) +* support setting headers via env ([d6235c1](https://github.com/browserbase/stagehand-php/commit/d6235c1aa657237410c3bab8483b6a5f8ebf3eba)) + + +### Bug Fixes + +* **client:** properly generate file params ([4a6d856](https://github.com/browserbase/stagehand-php/commit/4a6d85692b4bec4a518cf201999e99b2a7129263)) +* **client:** resolve serialization issue with unions and enums ([17f1ece](https://github.com/browserbase/stagehand-php/commit/17f1ece3f13369ac5555a6df9af1bb4fdce3d307)) +* populate enum-typed properties with enum instances ([0ba1b6f](https://github.com/browserbase/stagehand-php/commit/0ba1b6fda9bd4709e3665a3bd7659373b87b64d3)) +* **release:** use canonical GitHub URL in Packagist publish script ([eb093f7](https://github.com/browserbase/stagehand-php/commit/eb093f76a7e0999169970d79341fafa2871a6eee)) +* revert enum parsing change that lead to unconditional failure ([ca1dd7a](https://github.com/browserbase/stagehand-php/commit/ca1dd7a1dd2d8cf0b0b2d50f9cf317c98652cc89)) + ## 3.19.3 (2026-04-03) Full Changelog: [v3.18.0...v3.19.3](https://github.com/browserbase/stagehand-php/compare/v3.18.0...v3.19.3) diff --git a/README.md b/README.md index 3ea96f8..574163f 100644 --- a/README.md +++ b/README.md @@ -80,7 +80,7 @@ The REST API documentation can be found on [docs.stagehand.dev](https://docs.sta ``` -composer require "browserbase/stagehand 3.19.3" +composer require "browserbase/stagehand 3.20.0" ``` diff --git a/src/Version.php b/src/Version.php index 6b0b465..7c36484 100644 --- a/src/Version.php +++ b/src/Version.php @@ -5,5 +5,5 @@ namespace Stagehand; // x-release-please-start-version -const VERSION = '3.19.3'; +const VERSION = '3.20.0'; // x-release-please-end