Skip to content

Commit 50948e8

Browse files
feat: add auto-bedrock support based on bedrock/provider.model-name
1 parent 47c2db3 commit 50948e8

4 files changed

Lines changed: 48 additions & 4 deletions

File tree

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 8
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browserbase%2Fstagehand-089c8670f1d7c2e9fa8e5c97010db7c24b8f162eb7cfe76ffa41d70fa46efe2f.yml
3-
openapi_spec_hash: 7a226aee8f3f2ab16febbe6bb35e1657
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browserbase%2Fstagehand-43e6dd4ce19381de488d296e9036fea15bfea9a6f946cf8ccf4e02aecc8fb765.yml
3+
openapi_spec_hash: f736e7a8acea0d73e1031c86ea803246
44
config_hash: 75b561cd2ba925e4f2a62ec2f1d13738

src/Sessions/SessionExecuteParams/AgentConfig.php

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Stagehand\Core\Concerns\SdkModel;
99
use Stagehand\Core\Contracts\BaseModel;
1010
use Stagehand\Sessions\ModelConfig;
11+
use Stagehand\Sessions\SessionExecuteParams\AgentConfig\Mode;
1112
use Stagehand\Sessions\SessionExecuteParams\AgentConfig\Provider;
1213

1314
/**
@@ -16,6 +17,7 @@
1617
*
1718
* @phpstan-type AgentConfigShape = array{
1819
* cua?: bool|null,
20+
* mode?: null|Mode|value-of<Mode>,
1921
* model?: ModelShape|null,
2022
* provider?: null|Provider|value-of<Provider>,
2123
* systemPrompt?: string|null,
@@ -27,11 +29,19 @@ final class AgentConfig implements BaseModel
2729
use SdkModel;
2830

2931
/**
30-
* Enable Computer Use Agent mode.
32+
* Deprecated. Use mode: 'cua' instead. If both are provided, mode takes precedence.
3133
*/
3234
#[Optional]
3335
public ?bool $cua;
3436

37+
/**
38+
* Tool mode for the agent (dom, hybrid, cua). If set, overrides cua.
39+
*
40+
* @var value-of<Mode>|null $mode
41+
*/
42+
#[Optional(enum: Mode::class)]
43+
public ?string $mode;
44+
3545
/**
3646
* Model configuration object or model name string (e.g., 'openai/gpt-5-nano').
3747
*
@@ -64,18 +74,21 @@ public function __construct()
6474
*
6575
* You must use named parameters to construct any parameters with a default value.
6676
*
77+
* @param Mode|value-of<Mode>|null $mode
6778
* @param ModelShape|null $model
6879
* @param Provider|value-of<Provider>|null $provider
6980
*/
7081
public static function with(
7182
?bool $cua = null,
83+
Mode|string|null $mode = null,
7284
string|ModelConfig|array|null $model = null,
7385
Provider|string|null $provider = null,
7486
?string $systemPrompt = null,
7587
): self {
7688
$self = new self;
7789

7890
null !== $cua && $self['cua'] = $cua;
91+
null !== $mode && $self['mode'] = $mode;
7992
null !== $model && $self['model'] = $model;
8093
null !== $provider && $self['provider'] = $provider;
8194
null !== $systemPrompt && $self['systemPrompt'] = $systemPrompt;
@@ -84,7 +97,7 @@ public static function with(
8497
}
8598

8699
/**
87-
* Enable Computer Use Agent mode.
100+
* Deprecated. Use mode: 'cua' instead. If both are provided, mode takes precedence.
88101
*/
89102
public function withCua(bool $cua): self
90103
{
@@ -94,6 +107,19 @@ public function withCua(bool $cua): self
94107
return $self;
95108
}
96109

110+
/**
111+
* Tool mode for the agent (dom, hybrid, cua). If set, overrides cua.
112+
*
113+
* @param Mode|value-of<Mode> $mode
114+
*/
115+
public function withMode(Mode|string $mode): self
116+
{
117+
$self = clone $this;
118+
$self['mode'] = $mode;
119+
120+
return $self;
121+
}
122+
97123
/**
98124
* Model configuration object or model name string (e.g., 'openai/gpt-5-nano').
99125
*
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Stagehand\Sessions\SessionExecuteParams\AgentConfig;
6+
7+
/**
8+
* Tool mode for the agent (dom, hybrid, cua). If set, overrides cua.
9+
*/
10+
enum Mode: string
11+
{
12+
case DOM = 'dom';
13+
14+
case HYBRID = 'hybrid';
15+
16+
case CUA = 'cua';
17+
}

tests/Services/SessionsTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ public function testExecuteWithOptionalParams(): void
128128
'c4dbf3a9-9a58-4b22-8a1c-9f20f9f9e123',
129129
agentConfig: [
130130
'cua' => true,
131+
'mode' => 'cua',
131132
'model' => [
132133
'modelName' => 'openai/gpt-5-nano',
133134
'apiKey' => 'sk-some-openai-api-key',

0 commit comments

Comments
 (0)