Skip to content

Commit 9463fa4

Browse files
feat: Bedrock auth passthrough
1 parent feac39d commit 9463fa4

7 files changed

Lines changed: 397 additions & 61 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-b969ce378479c79ee64c05127c0ed6c6ce2edbee017ecd037242fb618a5ebc9f.yml
3-
openapi_spec_hash: a24aabaa5214effb679808b7f2be0ad4
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browserbase%2Fstagehand-7773ef4ca29c983daafb787ee918cfa6b5b12c5bbdc088308653f2737c26e51f.yml
3+
openapi_spec_hash: 47fc8f2540be0b6374e4230c021072d9
44
config_hash: 0cc516caf1432087f40654336e0fa8cd

src/stagehand/resources/sessions.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -927,6 +927,7 @@ def start(
927927
browserbase_session_id: str | Omit = omit,
928928
dom_settle_timeout_ms: float | Omit = omit,
929929
experimental: bool | Omit = omit,
930+
model_client_options: session_start_params.ModelClientOptions | Omit = omit,
930931
self_heal: bool | Omit = omit,
931932
system_prompt: str | Omit = omit,
932933
verbose: Literal[0, 1, 2] | Omit = omit,
@@ -957,6 +958,9 @@ def start(
957958
958959
dom_settle_timeout_ms: Timeout in ms to wait for DOM to settle
959960
961+
model_client_options: Optional provider-specific configuration for the session model (for example
962+
Bedrock region and credentials)
963+
960964
self_heal: Enable self-healing for failed actions
961965
962966
system_prompt: Custom system prompt for AI operations
@@ -997,6 +1001,7 @@ def start(
9971001
"browserbase_session_id": browserbase_session_id,
9981002
"dom_settle_timeout_ms": dom_settle_timeout_ms,
9991003
"experimental": experimental,
1004+
"model_client_options": model_client_options,
10001005
"self_heal": self_heal,
10011006
"system_prompt": system_prompt,
10021007
"verbose": verbose,
@@ -1890,6 +1895,7 @@ async def start(
18901895
browserbase_session_id: str | Omit = omit,
18911896
dom_settle_timeout_ms: float | Omit = omit,
18921897
experimental: bool | Omit = omit,
1898+
model_client_options: session_start_params.ModelClientOptions | Omit = omit,
18931899
self_heal: bool | Omit = omit,
18941900
system_prompt: str | Omit = omit,
18951901
verbose: Literal[0, 1, 2] | Omit = omit,
@@ -1920,6 +1926,9 @@ async def start(
19201926
19211927
dom_settle_timeout_ms: Timeout in ms to wait for DOM to settle
19221928
1929+
model_client_options: Optional provider-specific configuration for the session model (for example
1930+
Bedrock region and credentials)
1931+
19231932
self_heal: Enable self-healing for failed actions
19241933
19251934
system_prompt: Custom system prompt for AI operations
@@ -1960,6 +1969,7 @@ async def start(
19601969
"browserbase_session_id": browserbase_session_id,
19611970
"dom_settle_timeout_ms": dom_settle_timeout_ms,
19621971
"experimental": experimental,
1972+
"model_client_options": model_client_options,
19631973
"self_heal": self_heal,
19641974
"system_prompt": system_prompt,
19651975
"verbose": verbose,

src/stagehand/types/model_config_param.py

Lines changed: 97 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,92 @@
22

33
from __future__ import annotations
44

5-
from typing import Dict
6-
from typing_extensions import Literal, Required, Annotated, TypedDict
5+
from typing import Dict, Union
6+
from typing_extensions import Literal, Required, Annotated, TypeAlias, TypedDict
77

88
from .._utils import PropertyInfo
99

10-
__all__ = ["ModelConfigParam"]
10+
__all__ = [
11+
"ModelConfigParam",
12+
"ProviderOptions",
13+
"ProviderOptionsBedrockAPIKeyProviderOptions",
14+
"ProviderOptionsBedrockAwsCredentialsProviderOptions",
15+
"ProviderOptionsGoogleVertexProviderOptions",
16+
"ProviderOptionsGoogleVertexProviderOptionsGoogleAuthOptions",
17+
"ProviderOptionsGoogleVertexProviderOptionsGoogleAuthOptionsCredentials",
18+
]
19+
20+
21+
class ProviderOptionsBedrockAPIKeyProviderOptions(TypedDict, total=False):
22+
region: Required[str]
23+
"""AWS region for Amazon Bedrock"""
24+
25+
26+
class ProviderOptionsBedrockAwsCredentialsProviderOptions(TypedDict, total=False):
27+
access_key_id: Required[Annotated[str, PropertyInfo(alias="accessKeyId")]]
28+
"""AWS access key ID for Bedrock"""
29+
30+
region: Required[str]
31+
"""AWS region for Amazon Bedrock"""
32+
33+
secret_access_key: Required[Annotated[str, PropertyInfo(alias="secretAccessKey")]]
34+
"""AWS secret access key for Bedrock"""
35+
36+
session_token: Annotated[str, PropertyInfo(alias="sessionToken")]
37+
"""Optional AWS session token for temporary credentials"""
38+
39+
40+
class ProviderOptionsGoogleVertexProviderOptionsGoogleAuthOptionsCredentials(TypedDict, total=False):
41+
auth_provider_x509_cert_url: str
42+
43+
auth_uri: str
44+
45+
client_email: str
46+
47+
client_id: str
48+
49+
client_x509_cert_url: str
50+
51+
private_key: str
52+
53+
private_key_id: str
54+
55+
project_id: str
56+
57+
token_uri: str
58+
59+
type: str
60+
61+
universe_domain: str
62+
63+
64+
class ProviderOptionsGoogleVertexProviderOptionsGoogleAuthOptions(TypedDict, total=False):
65+
"""Optional Google auth options for Vertex AI"""
66+
67+
credentials: ProviderOptionsGoogleVertexProviderOptionsGoogleAuthOptionsCredentials
68+
69+
70+
class ProviderOptionsGoogleVertexProviderOptions(TypedDict, total=False):
71+
google_auth_options: Annotated[
72+
ProviderOptionsGoogleVertexProviderOptionsGoogleAuthOptions, PropertyInfo(alias="googleAuthOptions")
73+
]
74+
"""Optional Google auth options for Vertex AI"""
75+
76+
headers: Dict[str, str]
77+
"""Custom headers for Vertex AI requests"""
78+
79+
location: str
80+
"""Google Cloud location for Vertex AI"""
81+
82+
project: str
83+
"""Google Cloud project ID for Vertex AI"""
84+
85+
86+
ProviderOptions: TypeAlias = Union[
87+
ProviderOptionsBedrockAPIKeyProviderOptions,
88+
ProviderOptionsBedrockAwsCredentialsProviderOptions,
89+
ProviderOptionsGoogleVertexProviderOptions,
90+
]
1191

1292

1393
class ModelConfigParam(TypedDict, total=False):
@@ -21,7 +101,20 @@ class ModelConfigParam(TypedDict, total=False):
21101
"""Base URL for the model provider"""
22102

23103
headers: Dict[str, str]
24-
"""Custom headers sent with every request to the model provider"""
104+
"""Custom headers for the model provider"""
25105

26106
provider: Literal["openai", "anthropic", "google", "microsoft", "bedrock"]
27107
"""AI provider for the model (or provide a baseURL endpoint instead)"""
108+
109+
provider_options: Annotated[ProviderOptions, PropertyInfo(alias="providerOptions")]
110+
"""Provider-specific options passed through to the AI SDK provider constructor.
111+
112+
For Bedrock: { region, accessKeyId, secretAccessKey, sessionToken }. For Vertex:
113+
{ project, location, googleAuthOptions }.
114+
"""
115+
116+
skip_api_key_fallback: Annotated[bool, PropertyInfo(alias="skipApiKeyFallback")]
117+
"""When true, hosted sessions will not copy x-model-api-key into model.apiKey.
118+
119+
Use this when auth is carried through providerOptions instead of an API key.
120+
"""

src/stagehand/types/session_execute_params.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,6 @@ class ExecuteOptions(TypedDict, total=False):
7676
max_steps: Annotated[float, PropertyInfo(alias="maxSteps")]
7777
"""Maximum number of steps the agent can take"""
7878

79-
tool_timeout: Annotated[float, PropertyInfo(alias="toolTimeout")]
80-
"""Timeout in milliseconds for each agent tool call"""
81-
82-
use_search: Annotated[bool, PropertyInfo(alias="useSearch")]
83-
"""Whether to enable the web search tool powered by Browserbase Search API"""
84-
8579

8680
class SessionExecuteParamsNonStreaming(SessionExecuteParamsBase, total=False):
8781
stream_response: Annotated[Literal[False], PropertyInfo(alias="streamResponse")]

0 commit comments

Comments
 (0)