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 1/5] 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 2/5] 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 3/5] 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 4/5] 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 9be00cc4d6fc084d469c552a2b3e45781d596a55 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:32 +0000 Subject: [PATCH 5/5] release: 3.20.0 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 10 ++++++++++ README.md | 2 +- src/Version.php | 2 +- 4 files changed, 13 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..63c04e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Changelog +## 3.20.0 (2026-04-09) + +Full Changelog: [v3.19.3...v3.20.0](https://github.com/browserbase/stagehand-php/compare/v3.19.3...v3.20.0) + +### Features + +* [STG-1798] feat: support Browserbase verified sessions ([52c4636](https://github.com/browserbase/stagehand-php/commit/52c4636560e5dd556db9c061a3bb9c48ffa20e76)) +* Bedrock auth passthrough ([40cb10e](https://github.com/browserbase/stagehand-php/commit/40cb10eb39c7f53b9c3fd668018c1b3569650e5c)) +* 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)) + ## 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 1749137..fcdd864 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