diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 92d22a8..0273714 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,7 +20,7 @@ jobs: if: github.event_name == 'push' || github.event.pull_request.head.repo.fork steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Set up PHP uses: 'shivammathur/setup-php@v2' @@ -38,7 +38,7 @@ jobs: runs-on: ${{ github.repository == 'stainless-sdks/stagehand-php' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} if: github.event_name == 'push' || github.event.pull_request.head.repo.fork steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Set up PHP uses: 'shivammathur/setup-php@v2' diff --git a/.github/workflows/release-doctor.yml b/.github/workflows/release-doctor.yml index 441f7fc..1358383 100644 --- a/.github/workflows/release-doctor.yml +++ b/.github/workflows/release-doctor.yml @@ -12,7 +12,7 @@ jobs: if: github.repository == 'browserbase/stagehand-php' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || startsWith(github.head_ref, 'release-please') || github.head_ref == 'next') steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Check release environment run: | diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 144739c..ff1c7af 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "3.2.2" + ".": "3.3.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index ee1de31..9c0f6d9 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 7 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browserbase%2Fstagehand-07032b695bc66ecd76328d936b41e01cfad508a870928c09c185f5faa5ea66ab.yml -openapi_spec_hash: fca4b895ce36ad547fb015c3dd38821f -config_hash: d4df55e4b30aac2d8d0982be97f837c4 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browserbase%2Fstagehand-d91dfd9ce727aefac56505ac86feb5cc665d3d5cef80ff17605f45e09b258251.yml +openapi_spec_hash: 0d1cae70e9d1debc5ac1a69fc665af37 +config_hash: 64c9cc393de93af70e11dbf0b1ba9388 diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d54dbe..089a87d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ # Changelog +## 3.3.0 (2026-01-20) + +Full Changelog: [v3.2.2...v3.3.0](https://github.com/browserbase/stagehand-php/compare/v3.2.2...v3.3.0) + +### Features + +* move Stainless compatibility transforms from gen-openapi.ts into stainless.yml ([92aa35d](https://github.com/browserbase/stagehand-php/commit/92aa35dc997b874b76c9ca1b3397f0ede3910a28)) + + +### Chores + +* **internal:** minor test script reformatting ([4aa1009](https://github.com/browserbase/stagehand-php/commit/4aa10092946a58f994dd9fe91675a1b8c1a9f28f)) +* **internal:** update `actions/checkout` version ([43bf977](https://github.com/browserbase/stagehand-php/commit/43bf9775e76419afaa665fccb6f1cec69b20bcc1)) + ## 3.2.2 (2026-01-16) Full Changelog: [v3.2.1...v3.2.2](https://github.com/browserbase/stagehand-php/compare/v3.2.1...v3.2.2) diff --git a/LICENSE b/LICENSE index a7b82c2..d15d021 100644 --- a/LICENSE +++ b/LICENSE @@ -1,7 +1,201 @@ -Copyright 2026 stagehand + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + 1. Definitions. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2026 Stagehand + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/composer.json b/composer.json index 5d324e7..496519d 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "$schema": "https://getcomposer.org/schema.json", - "license": "MIT", + "license": "Apache-2.0", "autoload": { "files": [ "src/Version.php" diff --git a/scripts/test b/scripts/test index a8dc7cd..4b777e0 100755 --- a/scripts/test +++ b/scripts/test @@ -10,7 +10,7 @@ YELLOW='\033[0;33m' NC='\033[0m' # No Color function prism_is_running() { - curl --silent "http://localhost:4010" > /dev/null 2>&1 + curl --silent "http://localhost:4010" >/dev/null 2>&1 } kill_server_on_port() { @@ -25,7 +25,7 @@ function is_overriding_api_base_url() { [ -n "$TEST_API_BASE_URL" ] } -if ! is_overriding_api_base_url && ! prism_is_running; then +if ! is_overriding_api_base_url && ! prism_is_running ; then # When we exit this script, make sure to kill the background mock server process trap 'kill_server_on_port 4010' EXIT @@ -33,10 +33,10 @@ if ! is_overriding_api_base_url && ! prism_is_running; then ./scripts/mock --daemon fi -if is_overriding_api_base_url; then +if is_overriding_api_base_url ; then echo -e "${GREEN}✔ Running tests against ${TEST_API_BASE_URL}${NC}" echo -elif ! prism_is_running; then +elif ! prism_is_running ; then echo -e "${RED}ERROR:${NC} The test suite will not run without a mock Prism server" echo -e "running against your OpenAPI spec." echo diff --git a/src/ServiceContracts/SessionsContract.php b/src/ServiceContracts/SessionsContract.php index 98caa33..ce30b23 100644 --- a/src/ServiceContracts/SessionsContract.php +++ b/src/ServiceContracts/SessionsContract.php @@ -260,7 +260,7 @@ public function observeStream( /** * @api * - * @param string $modelName Body param: Model name to use for AI operations. Always use the format 'provider/model-name' (e.g., 'openai/gpt-4o', 'anthropic/claude-sonnet-4-5-20250929', 'google/gemini-2.0-flash') + * @param string $modelName Body param: Model name to use for AI operations * @param float $actTimeoutMs Body param: Timeout in ms for act operations (deprecated, v2 only) * @param Browser|BrowserShape $browser Body param * @param BrowserbaseSessionCreateParams|BrowserbaseSessionCreateParamsShape $browserbaseSessionCreateParams Body param diff --git a/src/Services/SessionsService.php b/src/Services/SessionsService.php index 539159b..2dc3838 100644 --- a/src/Services/SessionsService.php +++ b/src/Services/SessionsService.php @@ -428,7 +428,7 @@ public function observeStream( * * Creates a new browser session with the specified configuration. Returns a session ID used for all subsequent operations. * - * @param string $modelName Body param: Model name to use for AI operations. Always use the format 'provider/model-name' (e.g., 'openai/gpt-4o', 'anthropic/claude-sonnet-4-5-20250929', 'google/gemini-2.0-flash') + * @param string $modelName Body param: Model name to use for AI operations * @param float $actTimeoutMs Body param: Timeout in ms for act operations (deprecated, v2 only) * @param Browser|BrowserShape $browser Body param * @param BrowserbaseSessionCreateParams|BrowserbaseSessionCreateParamsShape $browserbaseSessionCreateParams Body param diff --git a/src/Sessions/ModelConfig.php b/src/Sessions/ModelConfig.php index cb0a31a..1a7a6a0 100644 --- a/src/Sessions/ModelConfig.php +++ b/src/Sessions/ModelConfig.php @@ -4,28 +4,137 @@ namespace Stagehand\Sessions; -use Stagehand\Core\Concerns\SdkUnion; -use Stagehand\Core\Conversion\Contracts\Converter; -use Stagehand\Core\Conversion\Contracts\ConverterSource; -use Stagehand\Sessions\ModelConfig\ModelConfigObject; +use Stagehand\Core\Attributes\Optional; +use Stagehand\Core\Attributes\Required; +use Stagehand\Core\Concerns\SdkModel; +use Stagehand\Core\Contracts\BaseModel; +use Stagehand\Sessions\ModelConfig\Provider; /** - * Model name string with provider prefix. Always use the format 'provider/model-name' (e.g., 'openai/gpt-4o', 'anthropic/claude-sonnet-4-5-20250929', 'google/gemini-2.0-flash'). - * - * @phpstan-import-type ModelConfigObjectShape from \Stagehand\Sessions\ModelConfig\ModelConfigObject - * - * @phpstan-type ModelConfigVariants = string|ModelConfigObject - * @phpstan-type ModelConfigShape = ModelConfigVariants|ModelConfigObjectShape + * @phpstan-type ModelConfigShape = array{ + * modelName: string, + * apiKey?: string|null, + * baseURL?: string|null, + * provider?: null|Provider|value-of, + * } */ -final class ModelConfig implements ConverterSource +final class ModelConfig implements BaseModel { - use SdkUnion; + /** @use SdkModel */ + use SdkModel; /** - * @return list|array + * Model name string with provider prefix (e.g., 'openai/gpt-5-nano'). */ - public static function variants(): array + #[Required] + public string $modelName; + + /** + * API key for the model provider. + */ + #[Optional] + public ?string $apiKey; + + /** + * Base URL for the model provider. + */ + #[Optional] + public ?string $baseURL; + + /** + * AI provider for the model (or provide a baseURL endpoint instead). + * + * @var value-of|null $provider + */ + #[Optional(enum: Provider::class)] + public ?string $provider; + + /** + * `new ModelConfig()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * ModelConfig::with(modelName: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new ModelConfig)->withModelName(...) + * ``` + */ + public function __construct() { - return ['string', ModelConfigObject::class]; + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + * + * @param Provider|value-of|null $provider + */ + public static function with( + string $modelName, + ?string $apiKey = null, + ?string $baseURL = null, + Provider|string|null $provider = null, + ): self { + $self = new self; + + $self['modelName'] = $modelName; + + null !== $apiKey && $self['apiKey'] = $apiKey; + null !== $baseURL && $self['baseURL'] = $baseURL; + null !== $provider && $self['provider'] = $provider; + + return $self; + } + + /** + * Model name string with provider prefix (e.g., 'openai/gpt-5-nano'). + */ + public function withModelName(string $modelName): self + { + $self = clone $this; + $self['modelName'] = $modelName; + + 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; + } + + /** + * AI provider for the model (or provide a baseURL endpoint instead). + * + * @param Provider|value-of $provider + */ + public function withProvider(Provider|string $provider): self + { + $self = clone $this; + $self['provider'] = $provider; + + return $self; } } diff --git a/src/Sessions/ModelConfig/ModelConfigObject.php b/src/Sessions/ModelConfig/ModelConfigObject.php deleted file mode 100644 index 681c8cb..0000000 --- a/src/Sessions/ModelConfig/ModelConfigObject.php +++ /dev/null @@ -1,140 +0,0 @@ -, - * } - */ -final class ModelConfigObject implements BaseModel -{ - /** @use SdkModel */ - use SdkModel; - - /** - * Model name string with provider prefix. Always use the format 'provider/model-name' (e.g., 'openai/gpt-4o', 'anthropic/claude-sonnet-4-5-20250929', 'google/gemini-2.0-flash'). - */ - #[Required] - public string $modelName; - - /** - * API key for the model provider. - */ - #[Optional] - public ?string $apiKey; - - /** - * Base URL for the model provider. - */ - #[Optional] - public ?string $baseURL; - - /** - * AI provider for the model (or provide a baseURL endpoint instead). - * - * @var value-of|null $provider - */ - #[Optional(enum: Provider::class)] - public ?string $provider; - - /** - * `new ModelConfigObject()` is missing required properties by the API. - * - * To enforce required parameters use - * ``` - * ModelConfigObject::with(modelName: ...) - * ``` - * - * Otherwise ensure the following setters are called - * - * ``` - * (new ModelConfigObject)->withModelName(...) - * ``` - */ - 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 Provider|value-of|null $provider - */ - public static function with( - string $modelName, - ?string $apiKey = null, - ?string $baseURL = null, - Provider|string|null $provider = null, - ): self { - $self = new self; - - $self['modelName'] = $modelName; - - null !== $apiKey && $self['apiKey'] = $apiKey; - null !== $baseURL && $self['baseURL'] = $baseURL; - null !== $provider && $self['provider'] = $provider; - - return $self; - } - - /** - * Model name string with provider prefix. Always use the format 'provider/model-name' (e.g., 'openai/gpt-4o', 'anthropic/claude-sonnet-4-5-20250929', 'google/gemini-2.0-flash'). - */ - public function withModelName(string $modelName): self - { - $self = clone $this; - $self['modelName'] = $modelName; - - 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; - } - - /** - * AI provider for the model (or provide a baseURL endpoint instead). - * - * @param Provider|value-of $provider - */ - public function withProvider(Provider|string $provider): self - { - $self = clone $this; - $self['provider'] = $provider; - - return $self; - } -} diff --git a/src/Sessions/ModelConfig/ModelConfigObject/Provider.php b/src/Sessions/ModelConfig/Provider.php similarity index 81% rename from src/Sessions/ModelConfig/ModelConfigObject/Provider.php rename to src/Sessions/ModelConfig/Provider.php index fb1ced7..8c5bba0 100644 --- a/src/Sessions/ModelConfig/ModelConfigObject/Provider.php +++ b/src/Sessions/ModelConfig/Provider.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Stagehand\Sessions\ModelConfig\ModelConfigObject; +namespace Stagehand\Sessions\ModelConfig; /** * AI provider for the model (or provide a baseURL endpoint instead). diff --git a/src/Sessions/SessionActParams/Options.php b/src/Sessions/SessionActParams/Options.php index 05f4f85..60ae9cd 100644 --- a/src/Sessions/SessionActParams/Options.php +++ b/src/Sessions/SessionActParams/Options.php @@ -7,14 +7,13 @@ use Stagehand\Core\Attributes\Optional; use Stagehand\Core\Concerns\SdkModel; use Stagehand\Core\Contracts\BaseModel; -use Stagehand\Sessions\ModelConfig\ModelConfigObject; +use Stagehand\Sessions\ModelConfig; /** - * @phpstan-import-type ModelConfigVariants from \Stagehand\Sessions\ModelConfig * @phpstan-import-type ModelConfigShape from \Stagehand\Sessions\ModelConfig * * @phpstan-type OptionsShape = array{ - * model?: ModelConfigShape|null, + * model?: null|ModelConfig|ModelConfigShape, * timeout?: float|null, * variables?: array|null, * } @@ -24,13 +23,8 @@ final class Options implements BaseModel /** @use SdkModel */ use SdkModel; - /** - * Model name string with provider prefix. Always use the format 'provider/model-name' (e.g., 'openai/gpt-4o', 'anthropic/claude-sonnet-4-5-20250929', 'google/gemini-2.0-flash'). - * - * @var ModelConfigVariants|null $model - */ #[Optional] - public string|ModelConfigObject|null $model; + public ?ModelConfig $model; /** * Timeout in ms for the action. @@ -56,11 +50,11 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * - * @param ModelConfigShape|null $model + * @param ModelConfig|ModelConfigShape|null $model * @param array|null $variables */ public static function with( - string|ModelConfigObject|array|null $model = null, + ModelConfig|array|null $model = null, ?float $timeout = null, ?array $variables = null, ): self { @@ -74,11 +68,9 @@ public static function with( } /** - * Model name string with provider prefix. Always use the format 'provider/model-name' (e.g., 'openai/gpt-4o', 'anthropic/claude-sonnet-4-5-20250929', 'google/gemini-2.0-flash'). - * - * @param ModelConfigShape $model + * @param ModelConfig|ModelConfigShape $model */ - public function withModel(string|ModelConfigObject|array $model): self + public function withModel(ModelConfig|array $model): self { $self = clone $this; $self['model'] = $model; diff --git a/src/Sessions/SessionExecuteParams/AgentConfig.php b/src/Sessions/SessionExecuteParams/AgentConfig.php index cd46a3a..d30f6f1 100644 --- a/src/Sessions/SessionExecuteParams/AgentConfig.php +++ b/src/Sessions/SessionExecuteParams/AgentConfig.php @@ -7,16 +7,15 @@ use Stagehand\Core\Attributes\Optional; use Stagehand\Core\Concerns\SdkModel; use Stagehand\Core\Contracts\BaseModel; -use Stagehand\Sessions\ModelConfig\ModelConfigObject; +use Stagehand\Sessions\ModelConfig; use Stagehand\Sessions\SessionExecuteParams\AgentConfig\Provider; /** - * @phpstan-import-type ModelConfigVariants from \Stagehand\Sessions\ModelConfig * @phpstan-import-type ModelConfigShape from \Stagehand\Sessions\ModelConfig * * @phpstan-type AgentConfigShape = array{ * cua?: bool|null, - * model?: ModelConfigShape|null, + * model?: null|ModelConfig|ModelConfigShape, * provider?: null|Provider|value-of, * systemPrompt?: string|null, * } @@ -32,13 +31,8 @@ final class AgentConfig implements BaseModel #[Optional] public ?bool $cua; - /** - * Model name string with provider prefix. Always use the format 'provider/model-name' (e.g., 'openai/gpt-4o', 'anthropic/claude-sonnet-4-5-20250929', 'google/gemini-2.0-flash'). - * - * @var ModelConfigVariants|null $model - */ #[Optional] - public string|ModelConfigObject|null $model; + public ?ModelConfig $model; /** * AI provider for the agent (legacy, use model: openai/gpt-5-nano instead). @@ -64,12 +58,12 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * - * @param ModelConfigShape|null $model + * @param ModelConfig|ModelConfigShape|null $model * @param Provider|value-of|null $provider */ public static function with( ?bool $cua = null, - string|ModelConfigObject|array|null $model = null, + ModelConfig|array|null $model = null, Provider|string|null $provider = null, ?string $systemPrompt = null, ): self { @@ -95,11 +89,9 @@ public function withCua(bool $cua): self } /** - * Model name string with provider prefix. Always use the format 'provider/model-name' (e.g., 'openai/gpt-4o', 'anthropic/claude-sonnet-4-5-20250929', 'google/gemini-2.0-flash'). - * - * @param ModelConfigShape $model + * @param ModelConfig|ModelConfigShape $model */ - public function withModel(string|ModelConfigObject|array $model): self + public function withModel(ModelConfig|array $model): self { $self = clone $this; $self['model'] = $model; diff --git a/src/Sessions/SessionExtractParams/Options.php b/src/Sessions/SessionExtractParams/Options.php index 4606c73..3ebbeda 100644 --- a/src/Sessions/SessionExtractParams/Options.php +++ b/src/Sessions/SessionExtractParams/Options.php @@ -7,14 +7,15 @@ use Stagehand\Core\Attributes\Optional; use Stagehand\Core\Concerns\SdkModel; use Stagehand\Core\Contracts\BaseModel; -use Stagehand\Sessions\ModelConfig\ModelConfigObject; +use Stagehand\Sessions\ModelConfig; /** - * @phpstan-import-type ModelConfigVariants from \Stagehand\Sessions\ModelConfig * @phpstan-import-type ModelConfigShape from \Stagehand\Sessions\ModelConfig * * @phpstan-type OptionsShape = array{ - * model?: ModelConfigShape|null, selector?: string|null, timeout?: float|null + * model?: null|ModelConfig|ModelConfigShape, + * selector?: string|null, + * timeout?: float|null, * } */ final class Options implements BaseModel @@ -22,13 +23,8 @@ final class Options implements BaseModel /** @use SdkModel */ use SdkModel; - /** - * Model name string with provider prefix. Always use the format 'provider/model-name' (e.g., 'openai/gpt-4o', 'anthropic/claude-sonnet-4-5-20250929', 'google/gemini-2.0-flash'). - * - * @var ModelConfigVariants|null $model - */ #[Optional] - public string|ModelConfigObject|null $model; + public ?ModelConfig $model; /** * CSS selector to scope extraction to a specific element. @@ -52,10 +48,10 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * - * @param ModelConfigShape|null $model + * @param ModelConfig|ModelConfigShape|null $model */ public static function with( - string|ModelConfigObject|array|null $model = null, + ModelConfig|array|null $model = null, ?string $selector = null, ?float $timeout = null, ): self { @@ -69,11 +65,9 @@ public static function with( } /** - * Model name string with provider prefix. Always use the format 'provider/model-name' (e.g., 'openai/gpt-4o', 'anthropic/claude-sonnet-4-5-20250929', 'google/gemini-2.0-flash'). - * - * @param ModelConfigShape $model + * @param ModelConfig|ModelConfigShape $model */ - public function withModel(string|ModelConfigObject|array $model): self + public function withModel(ModelConfig|array $model): self { $self = clone $this; $self['model'] = $model; diff --git a/src/Sessions/SessionObserveParams/Options.php b/src/Sessions/SessionObserveParams/Options.php index cc0f7fd..58aa0cc 100644 --- a/src/Sessions/SessionObserveParams/Options.php +++ b/src/Sessions/SessionObserveParams/Options.php @@ -7,14 +7,15 @@ use Stagehand\Core\Attributes\Optional; use Stagehand\Core\Concerns\SdkModel; use Stagehand\Core\Contracts\BaseModel; -use Stagehand\Sessions\ModelConfig\ModelConfigObject; +use Stagehand\Sessions\ModelConfig; /** - * @phpstan-import-type ModelConfigVariants from \Stagehand\Sessions\ModelConfig * @phpstan-import-type ModelConfigShape from \Stagehand\Sessions\ModelConfig * * @phpstan-type OptionsShape = array{ - * model?: ModelConfigShape|null, selector?: string|null, timeout?: float|null + * model?: null|ModelConfig|ModelConfigShape, + * selector?: string|null, + * timeout?: float|null, * } */ final class Options implements BaseModel @@ -22,13 +23,8 @@ final class Options implements BaseModel /** @use SdkModel */ use SdkModel; - /** - * Model name string with provider prefix. Always use the format 'provider/model-name' (e.g., 'openai/gpt-4o', 'anthropic/claude-sonnet-4-5-20250929', 'google/gemini-2.0-flash'). - * - * @var ModelConfigVariants|null $model - */ #[Optional] - public string|ModelConfigObject|null $model; + public ?ModelConfig $model; /** * CSS selector to scope observation to a specific element. @@ -52,10 +48,10 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * - * @param ModelConfigShape|null $model + * @param ModelConfig|ModelConfigShape|null $model */ public static function with( - string|ModelConfigObject|array|null $model = null, + ModelConfig|array|null $model = null, ?string $selector = null, ?float $timeout = null, ): self { @@ -69,11 +65,9 @@ public static function with( } /** - * Model name string with provider prefix. Always use the format 'provider/model-name' (e.g., 'openai/gpt-4o', 'anthropic/claude-sonnet-4-5-20250929', 'google/gemini-2.0-flash'). - * - * @param ModelConfigShape $model + * @param ModelConfig|ModelConfigShape $model */ - public function withModel(string|ModelConfigObject|array $model): self + public function withModel(ModelConfig|array $model): self { $self = clone $this; $self['model'] = $model; diff --git a/src/Sessions/SessionStartParams.php b/src/Sessions/SessionStartParams.php index 8babbfb..c01446d 100644 --- a/src/Sessions/SessionStartParams.php +++ b/src/Sessions/SessionStartParams.php @@ -43,7 +43,7 @@ final class SessionStartParams implements BaseModel use SdkParams; /** - * Model name to use for AI operations. Always use the format 'provider/model-name' (e.g., 'openai/gpt-4o', 'anthropic/claude-sonnet-4-5-20250929', 'google/gemini-2.0-flash'). + * Model name to use for AI operations. */ #[Required] public string $modelName; @@ -169,7 +169,7 @@ public static function with( } /** - * Model name to use for AI operations. Always use the format 'provider/model-name' (e.g., 'openai/gpt-4o', 'anthropic/claude-sonnet-4-5-20250929', 'google/gemini-2.0-flash'). + * Model name to use for AI operations. */ public function withModelName(string $modelName): self { diff --git a/src/Version.php b/src/Version.php index 05f082c..8fcd28f 100644 --- a/src/Version.php +++ b/src/Version.php @@ -5,5 +5,5 @@ namespace Stagehand; // x-release-please-start-version -const VERSION = '3.2.2'; +const VERSION = '3.3.0'; // x-release-please-end diff --git a/tests/Services/SessionsTest.php b/tests/Services/SessionsTest.php index 857db56..e8dedbb 100644 --- a/tests/Services/SessionsTest.php +++ b/tests/Services/SessionsTest.php @@ -66,7 +66,12 @@ public function testActWithOptionalParams(): void input: 'Click the login button', frameID: 'frameId', options: [ - 'model' => 'openai/gpt-4o', + 'model' => [ + 'modelName' => 'openai/gpt-5-nano', + 'apiKey' => 'sk-some-openai-api-key', + 'baseURL' => 'https://api.openai.com/v1', + 'provider' => 'openai', + ], 'timeout' => 30000, 'variables' => ['username' => 'john_doe'], ], @@ -122,7 +127,12 @@ public function testExecuteWithOptionalParams(): void 'c4dbf3a9-9a58-4b22-8a1c-9f20f9f9e123', agentConfig: [ 'cua' => true, - 'model' => 'openai/gpt-4o', + 'model' => [ + 'modelName' => 'openai/gpt-5-nano', + 'apiKey' => 'sk-some-openai-api-key', + 'baseURL' => 'https://api.openai.com/v1', + 'provider' => 'openai', + ], 'provider' => 'openai', 'systemPrompt' => 'systemPrompt', ],