Skip to content

Commit 29b4590

Browse files
feat: Align Task Filtering by Status with status Field
1 parent 2ede0a9 commit 29b4590

File tree

7 files changed

+65
-58
lines changed

7 files changed

+65
-58
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: 26
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browser-use%2Fbrowser-use-890b9140b139df6307d175ff31cba0bf14d703887bee2f0a8db9f5bffc78e11d.yml
3-
openapi_spec_hash: 7131a3daffe4f5b67bc1c7ccec06d961
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browser-use%2Fbrowser-use-3a9488448292a0736b08b2d6427e702eaf7106d86345ca2e65b64bed4398b036.yml
3+
openapi_spec_hash: 5ff2781dcc11a0c9aa353f5cb14bcc16
44
config_hash: 9d52be5177b2ede4cb0633c04f4cc4ef

src/browser_use_sdk/resources/tasks.py

Lines changed: 34 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22

33
from __future__ import annotations
44

5-
from typing import Dict, List, Optional
5+
from typing import Dict, List, Union, Optional
6+
from datetime import datetime
67
from typing_extensions import Literal
78

89
import httpx
910

10-
from ..types import task_list_params, task_create_params, task_update_params
11+
from ..types import TaskStatus, task_list_params, task_create_params, task_update_params
1112
from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven
1213
from .._utils import maybe_transform, async_maybe_transform
1314
from .._compat import cached_property
@@ -20,6 +21,7 @@
2021
)
2122
from .._base_client import make_request_options
2223
from ..types.task_view import TaskView
24+
from ..types.task_status import TaskStatus
2325
from ..types.task_list_response import TaskListResponse
2426
from ..types.task_create_response import TaskCreateResponse
2527
from ..types.task_get_logs_response import TaskGetLogsResponse
@@ -280,8 +282,9 @@ def update(
280282
def list(
281283
self,
282284
*,
283-
filter_by: Optional[Literal["started", "paused", "stopped", "finished", "successful", "unsuccessful"]]
284-
| NotGiven = NOT_GIVEN,
285+
after: Union[str, datetime, None] | NotGiven = NOT_GIVEN,
286+
before: Union[str, datetime, None] | NotGiven = NOT_GIVEN,
287+
filter_by: Optional[TaskStatus] | NotGiven = NOT_GIVEN,
285288
page_number: int | NotGiven = NOT_GIVEN,
286289
page_size: int | NotGiven = NOT_GIVEN,
287290
session_id: Optional[str] | NotGiven = NOT_GIVEN,
@@ -293,32 +296,26 @@ def list(
293296
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
294297
) -> TaskListResponse:
295298
"""
296-
Get a paginated list of all AI agent tasks for the authenticated user.
299+
Get a paginated list of all Browser Use Agent tasks for the authenticated user.
297300
298-
AI agent tasks are the individual jobs that your agents perform within a
299-
session. Each task represents a specific instruction or goal that the agent
301+
Browser Use Agent tasks are the individual jobs that your agents perform within
302+
a session. Each task represents a specific instruction or goal that the agent
300303
works on, such as filling out a form, extracting data, or navigating to specific
301304
pages.
302305
303-
You can control what data is included for each task:
304-
305-
- Task steps: Detailed actions the agent took
306-
- User uploaded files: Files you provided for the task
307-
- Output files: Files generated by the agent during the task
308-
309306
Returns:
310307
311-
- A paginated list of agent tasks
312-
- Total count of tasks
308+
- A paginated list of Browser Use Agent tasks
309+
- Total count of Browser Use Agent tasks
313310
- Page information for navigation
314-
- Optional detailed data based on your parameters
315311
316312
Args:
317-
filter_by: Enumeration of possible task filters
313+
filter_by: Enumeration of possible task execution states
318314
319-
Attributes: STARTED: All started tasks PAUSED: All paused tasks STOPPED: All
320-
stopped tasks FINISHED: All finished tasks SUCCESSFUL: All successful tasks
321-
UNSUCCESSFUL: All unsuccessful tasks
315+
Attributes: STARTED: Task has been started and is currently running. PAUSED:
316+
Task execution has been temporarily paused (can be resumed) FINISHED: Task has
317+
finished and the agent has completed the task. STOPPED: Task execution has been
318+
manually stopped (cannot be resumed).
322319
323320
extra_headers: Send extra headers
324321
@@ -337,6 +334,8 @@ def list(
337334
timeout=timeout,
338335
query=maybe_transform(
339336
{
337+
"after": after,
338+
"before": before,
340339
"filter_by": filter_by,
341340
"page_number": page_number,
342341
"page_size": page_size,
@@ -778,8 +777,9 @@ async def update(
778777
async def list(
779778
self,
780779
*,
781-
filter_by: Optional[Literal["started", "paused", "stopped", "finished", "successful", "unsuccessful"]]
782-
| NotGiven = NOT_GIVEN,
780+
after: Union[str, datetime, None] | NotGiven = NOT_GIVEN,
781+
before: Union[str, datetime, None] | NotGiven = NOT_GIVEN,
782+
filter_by: Optional[TaskStatus] | NotGiven = NOT_GIVEN,
783783
page_number: int | NotGiven = NOT_GIVEN,
784784
page_size: int | NotGiven = NOT_GIVEN,
785785
session_id: Optional[str] | NotGiven = NOT_GIVEN,
@@ -791,32 +791,26 @@ async def list(
791791
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
792792
) -> TaskListResponse:
793793
"""
794-
Get a paginated list of all AI agent tasks for the authenticated user.
794+
Get a paginated list of all Browser Use Agent tasks for the authenticated user.
795795
796-
AI agent tasks are the individual jobs that your agents perform within a
797-
session. Each task represents a specific instruction or goal that the agent
796+
Browser Use Agent tasks are the individual jobs that your agents perform within
797+
a session. Each task represents a specific instruction or goal that the agent
798798
works on, such as filling out a form, extracting data, or navigating to specific
799799
pages.
800800
801-
You can control what data is included for each task:
802-
803-
- Task steps: Detailed actions the agent took
804-
- User uploaded files: Files you provided for the task
805-
- Output files: Files generated by the agent during the task
806-
807801
Returns:
808802
809-
- A paginated list of agent tasks
810-
- Total count of tasks
803+
- A paginated list of Browser Use Agent tasks
804+
- Total count of Browser Use Agent tasks
811805
- Page information for navigation
812-
- Optional detailed data based on your parameters
813806
814807
Args:
815-
filter_by: Enumeration of possible task filters
808+
filter_by: Enumeration of possible task execution states
816809
817-
Attributes: STARTED: All started tasks PAUSED: All paused tasks STOPPED: All
818-
stopped tasks FINISHED: All finished tasks SUCCESSFUL: All successful tasks
819-
UNSUCCESSFUL: All unsuccessful tasks
810+
Attributes: STARTED: Task has been started and is currently running. PAUSED:
811+
Task execution has been temporarily paused (can be resumed) FINISHED: Task has
812+
finished and the agent has completed the task. STOPPED: Task execution has been
813+
manually stopped (cannot be resumed).
820814
821815
extra_headers: Send extra headers
822816
@@ -835,6 +829,8 @@ async def list(
835829
timeout=timeout,
836830
query=await async_maybe_transform(
837831
{
832+
"after": after,
833+
"before": before,
838834
"filter_by": filter_by,
839835
"page_number": page_number,
840836
"page_size": page_size,

src/browser_use_sdk/types/task_item_view.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@ class TaskItemView(BaseModel):
2626
status: TaskStatus
2727
"""Enumeration of possible task execution states
2828
29-
Attributes: STARTED: Task has been started and is currently running PAUSED: Task
30-
execution has been temporarily paused (can be resumed) STOPPED: Task execution
31-
has been stopped (cannot be resumed) FINISHED: Task has completed successfully
29+
Attributes: STARTED: Task has been started and is currently running. PAUSED:
30+
Task execution has been temporarily paused (can be resumed) FINISHED: Task has
31+
finished and the agent has completed the task. STOPPED: Task execution has been
32+
manually stopped (cannot be resumed).
3233
"""
3334

3435
task: str

src/browser_use_sdk/types/task_list_params.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,28 @@
22

33
from __future__ import annotations
44

5-
from typing import Optional
6-
from typing_extensions import Literal, Annotated, TypedDict
5+
from typing import Union, Optional
6+
from datetime import datetime
7+
from typing_extensions import Annotated, TypedDict
78

89
from .._utils import PropertyInfo
10+
from .task_status import TaskStatus
911

1012
__all__ = ["TaskListParams"]
1113

1214

1315
class TaskListParams(TypedDict, total=False):
14-
filter_by: Annotated[
15-
Optional[Literal["started", "paused", "stopped", "finished", "successful", "unsuccessful"]],
16-
PropertyInfo(alias="filterBy"),
17-
]
18-
"""Enumeration of possible task filters
19-
20-
Attributes: STARTED: All started tasks PAUSED: All paused tasks STOPPED: All
21-
stopped tasks FINISHED: All finished tasks SUCCESSFUL: All successful tasks
22-
UNSUCCESSFUL: All unsuccessful tasks
16+
after: Annotated[Union[str, datetime, None], PropertyInfo(format="iso8601")]
17+
18+
before: Annotated[Union[str, datetime, None], PropertyInfo(format="iso8601")]
19+
20+
filter_by: Annotated[Optional[TaskStatus], PropertyInfo(alias="filterBy")]
21+
"""Enumeration of possible task execution states
22+
23+
Attributes: STARTED: Task has been started and is currently running. PAUSED:
24+
Task execution has been temporarily paused (can be resumed) FINISHED: Task has
25+
finished and the agent has completed the task. STOPPED: Task execution has been
26+
manually stopped (cannot be resumed).
2327
"""
2428

2529
page_number: Annotated[int, PropertyInfo(alias="pageNumber")]

src/browser_use_sdk/types/task_status.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44

55
__all__ = ["TaskStatus"]
66

7-
TaskStatus: TypeAlias = Literal["started", "paused", "stopped", "finished"]
7+
TaskStatus: TypeAlias = Literal["started", "paused", "finished", "stopped"]

src/browser_use_sdk/types/task_view.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,10 @@ class TaskView(BaseModel):
5757
status: TaskStatus
5858
"""Enumeration of possible task execution states
5959
60-
Attributes: STARTED: Task has been started and is currently running PAUSED: Task
61-
execution has been temporarily paused (can be resumed) STOPPED: Task execution
62-
has been stopped (cannot be resumed) FINISHED: Task has completed successfully
60+
Attributes: STARTED: Task has been started and is currently running. PAUSED:
61+
Task execution has been temporarily paused (can be resumed) FINISHED: Task has
62+
finished and the agent has completed the task. STOPPED: Task execution has been
63+
manually stopped (cannot be resumed).
6364
"""
6465

6566
steps: List[TaskStepView]

tests/api_resources/test_tasks.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
TaskGetOutputFileResponse,
1818
TaskGetUserUploadedFileResponse,
1919
)
20+
from browser_use_sdk._utils import parse_datetime
2021

2122
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
2223

@@ -177,6 +178,8 @@ def test_method_list(self, client: BrowserUse) -> None:
177178
@parametrize
178179
def test_method_list_with_all_params(self, client: BrowserUse) -> None:
179180
task = client.tasks.list(
181+
after=parse_datetime("2019-12-27T18:11:19.117Z"),
182+
before=parse_datetime("2019-12-27T18:11:19.117Z"),
180183
filter_by="started",
181184
page_number=1,
182185
page_size=1,
@@ -511,6 +514,8 @@ async def test_method_list(self, async_client: AsyncBrowserUse) -> None:
511514
@parametrize
512515
async def test_method_list_with_all_params(self, async_client: AsyncBrowserUse) -> None:
513516
task = await async_client.tasks.list(
517+
after=parse_datetime("2019-12-27T18:11:19.117Z"),
518+
before=parse_datetime("2019-12-27T18:11:19.117Z"),
514519
filter_by="started",
515520
page_number=1,
516521
page_size=1,

0 commit comments

Comments
 (0)