22
33from __future__ import annotations
44
5- from typing import TYPE_CHECKING , Union
5+ from typing import TYPE_CHECKING , Any , Union , Mapping , TypeVar , cast
66from datetime import datetime
77from typing_extensions import Unpack , Literal
88
2323from .types .session_observe_response import SessionObserveResponse
2424from .types .session_navigate_response import SessionNavigateResponse
2525
26+ TSessionParams = TypeVar ("TSessionParams" , bound = Mapping [str , Any ])
27+
28+
29+ def _with_default_frame_id (params : TSessionParams ) -> TSessionParams :
30+ prepared = dict (params )
31+ if "frame_id" not in prepared :
32+ prepared ["frame_id" ] = ""
33+ return cast (TSessionParams , prepared )
34+
2635if TYPE_CHECKING :
2736 from ._client import Stagehand , AsyncStagehand
2837
@@ -49,7 +58,7 @@ def navigate(
4958 extra_query = extra_query ,
5059 extra_body = extra_body ,
5160 timeout = timeout ,
52- ** params ,
61+ ** _with_default_frame_id ( params ) ,
5362 )
5463
5564 def act (
@@ -67,7 +76,7 @@ def act(
6776 extra_query = extra_query ,
6877 extra_body = extra_body ,
6978 timeout = timeout ,
70- ** params ,
79+ ** _with_default_frame_id ( params ) ,
7180 )
7281
7382 def observe (
@@ -85,7 +94,7 @@ def observe(
8594 extra_query = extra_query ,
8695 extra_body = extra_body ,
8796 timeout = timeout ,
88- ** params ,
97+ ** _with_default_frame_id ( params ) ,
8998 )
9099
91100 def extract (
@@ -103,7 +112,7 @@ def extract(
103112 extra_query = extra_query ,
104113 extra_body = extra_body ,
105114 timeout = timeout ,
106- ** params ,
115+ ** _with_default_frame_id ( params ) ,
107116 )
108117
109118 def execute (
@@ -121,7 +130,7 @@ def execute(
121130 extra_query = extra_query ,
122131 extra_body = extra_body ,
123132 timeout = timeout ,
124- ** params ,
133+ ** _with_default_frame_id ( params ) ,
125134 )
126135
127136 def end (
@@ -171,7 +180,7 @@ async def navigate(
171180 extra_query = extra_query ,
172181 extra_body = extra_body ,
173182 timeout = timeout ,
174- ** params ,
183+ ** _with_default_frame_id ( params ) ,
175184 )
176185
177186 async def act (
@@ -189,7 +198,7 @@ async def act(
189198 extra_query = extra_query ,
190199 extra_body = extra_body ,
191200 timeout = timeout ,
192- ** params ,
201+ ** _with_default_frame_id ( params ) ,
193202 )
194203
195204 async def observe (
@@ -207,7 +216,7 @@ async def observe(
207216 extra_query = extra_query ,
208217 extra_body = extra_body ,
209218 timeout = timeout ,
210- ** params ,
219+ ** _with_default_frame_id ( params ) ,
211220 )
212221
213222 async def extract (
@@ -225,7 +234,7 @@ async def extract(
225234 extra_query = extra_query ,
226235 extra_body = extra_body ,
227236 timeout = timeout ,
228- ** params ,
237+ ** _with_default_frame_id ( params ) ,
229238 )
230239
231240 async def execute (
@@ -243,7 +252,7 @@ async def execute(
243252 extra_query = extra_query ,
244253 extra_body = extra_body ,
245254 timeout = timeout ,
246- ** params ,
255+ ** _with_default_frame_id ( params ) ,
247256 )
248257
249258 async def end (
0 commit comments