Skip to content

Commit c6f6862

Browse files
feat: expose smooth drag mouse movement via public API
1 parent 968f23e commit c6f6862

File tree

5 files changed

+50
-2
lines changed

5 files changed

+50
-2
lines changed

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 103
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-bda5e58fa0bbd08761f27a1e0edbc602c44141ac9483bf6c96d52b7f4d10d9a7.yml
3-
openapi_spec_hash: 10833b36358e8cda023e5bb0abeab0ba
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-e6936890166ce5b11abaccd511a43a8807e2abf96c1f542d4f8d94655ef27d1f.yml
3+
openapi_spec_hash: 0146ecaea96d8136ef4a35cd04aacf22
44
config_hash: cff4d43372b6fa66b64e2d4150f6aa76

src/kernel/resources/browsers/computer.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,9 @@ def drag_mouse(
213213
path: Iterable[Iterable[int]],
214214
button: Literal["left", "middle", "right"] | Omit = omit,
215215
delay: int | Omit = omit,
216+
duration_ms: int | Omit = omit,
216217
hold_keys: SequenceNotStr[str] | Omit = omit,
218+
smooth: bool | Omit = omit,
217219
step_delay_ms: int | Omit = omit,
218220
steps_per_segment: int | Omit = omit,
219221
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -234,8 +236,14 @@ def drag_mouse(
234236
235237
delay: Delay in milliseconds between button down and starting to move along the path.
236238
239+
duration_ms: Target total duration in milliseconds for the entire drag movement when
240+
smooth=true. Omit for automatic timing based on total path length.
241+
237242
hold_keys: Modifier keys to hold during the drag
238243
244+
smooth: Use human-like Bezier curves between path waypoints instead of linear
245+
interpolation. When true, steps_per_segment and step_delay_ms are ignored.
246+
239247
step_delay_ms: Delay in milliseconds between relative steps while dragging (not the initial
240248
delay).
241249
@@ -259,7 +267,9 @@ def drag_mouse(
259267
"path": path,
260268
"button": button,
261269
"delay": delay,
270+
"duration_ms": duration_ms,
262271
"hold_keys": hold_keys,
272+
"smooth": smooth,
263273
"step_delay_ms": step_delay_ms,
264274
"steps_per_segment": steps_per_segment,
265275
},
@@ -804,7 +814,9 @@ async def drag_mouse(
804814
path: Iterable[Iterable[int]],
805815
button: Literal["left", "middle", "right"] | Omit = omit,
806816
delay: int | Omit = omit,
817+
duration_ms: int | Omit = omit,
807818
hold_keys: SequenceNotStr[str] | Omit = omit,
819+
smooth: bool | Omit = omit,
808820
step_delay_ms: int | Omit = omit,
809821
steps_per_segment: int | Omit = omit,
810822
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -825,8 +837,14 @@ async def drag_mouse(
825837
826838
delay: Delay in milliseconds between button down and starting to move along the path.
827839
840+
duration_ms: Target total duration in milliseconds for the entire drag movement when
841+
smooth=true. Omit for automatic timing based on total path length.
842+
828843
hold_keys: Modifier keys to hold during the drag
829844
845+
smooth: Use human-like Bezier curves between path waypoints instead of linear
846+
interpolation. When true, steps_per_segment and step_delay_ms are ignored.
847+
830848
step_delay_ms: Delay in milliseconds between relative steps while dragging (not the initial
831849
delay).
832850
@@ -850,7 +868,9 @@ async def drag_mouse(
850868
"path": path,
851869
"button": button,
852870
"delay": delay,
871+
"duration_ms": duration_ms,
853872
"hold_keys": hold_keys,
873+
"smooth": smooth,
854874
"step_delay_ms": step_delay_ms,
855875
"steps_per_segment": steps_per_segment,
856876
},

src/kernel/types/browsers/computer_batch_params.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,21 @@ class ActionDragMouse(TypedDict, total=False):
5959
delay: int
6060
"""Delay in milliseconds between button down and starting to move along the path."""
6161

62+
duration_ms: int
63+
"""
64+
Target total duration in milliseconds for the entire drag movement when
65+
smooth=true. Omit for automatic timing based on total path length.
66+
"""
67+
6268
hold_keys: SequenceNotStr[str]
6369
"""Modifier keys to hold during the drag"""
6470

71+
smooth: bool
72+
"""
73+
Use human-like Bezier curves between path waypoints instead of linear
74+
interpolation. When true, steps_per_segment and step_delay_ms are ignored.
75+
"""
76+
6577
step_delay_ms: int
6678
"""
6779
Delay in milliseconds between relative steps while dragging (not the initial

src/kernel/types/browsers/computer_drag_mouse_params.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,21 @@ class ComputerDragMouseParams(TypedDict, total=False):
2323
delay: int
2424
"""Delay in milliseconds between button down and starting to move along the path."""
2525

26+
duration_ms: int
27+
"""
28+
Target total duration in milliseconds for the entire drag movement when
29+
smooth=true. Omit for automatic timing based on total path length.
30+
"""
31+
2632
hold_keys: SequenceNotStr[str]
2733
"""Modifier keys to hold during the drag"""
2834

35+
smooth: bool
36+
"""
37+
Use human-like Bezier curves between path waypoints instead of linear
38+
interpolation. When true, steps_per_segment and step_delay_ms are ignored.
39+
"""
40+
2941
step_delay_ms: int
3042
"""
3143
Delay in milliseconds between relative steps while dragging (not the initial

tests/api_resources/browsers/test_computer.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,9 @@ def test_method_drag_mouse_with_all_params(self, client: Kernel) -> None:
224224
path=[[0, 0], [0, 0]],
225225
button="left",
226226
delay=0,
227+
duration_ms=50,
227228
hold_keys=["string"],
229+
smooth=True,
228230
step_delay_ms=0,
229231
steps_per_segment=1,
230232
)
@@ -887,7 +889,9 @@ async def test_method_drag_mouse_with_all_params(self, async_client: AsyncKernel
887889
path=[[0, 0], [0, 0]],
888890
button="left",
889891
delay=0,
892+
duration_ms=50,
890893
hold_keys=["string"],
894+
smooth=True,
891895
step_delay_ms=0,
892896
steps_per_segment=1,
893897
)

0 commit comments

Comments
 (0)