From 6c57ff12c692ac658e519a5f794b2cd1200c3057 Mon Sep 17 00:00:00 2001 From: fern-api <115122769+fern-api[bot]@users.noreply.github.com> Date: Fri, 18 Apr 2025 17:59:42 +0000 Subject: [PATCH 1/4] SDK regeneration --- poetry.lock | 12 +++++----- pyproject.toml | 2 +- reference.md | 12 ++++++++-- src/scrapybara/core/client_wrapper.py | 2 +- src/scrapybara/instance/client.py | 32 +++++++++++++++++---------- 5 files changed, 38 insertions(+), 22 deletions(-) diff --git a/poetry.lock b/poetry.lock index d1637e3..b284569 100644 --- a/poetry.lock +++ b/poetry.lock @@ -85,13 +85,13 @@ files = [ [[package]] name = "httpcore" -version = "1.0.7" +version = "1.0.8" description = "A minimal low-level HTTP client." optional = false python-versions = ">=3.8" files = [ - {file = "httpcore-1.0.7-py3-none-any.whl", hash = "sha256:a3fff8f43dc260d5bd363d9f9cf1830fa3a458b332856f34282de498ed420edd"}, - {file = "httpcore-1.0.7.tar.gz", hash = "sha256:8551cb62a169ec7162ac7be8d4817d561f60e08eaa485234898414bb5a8a0b4c"}, + {file = "httpcore-1.0.8-py3-none-any.whl", hash = "sha256:5254cf149bcb5f75e9d1b2b9f729ea4a4b883d1ad7379fc632b727cec23674be"}, + {file = "httpcore-1.0.8.tar.gz", hash = "sha256:86e94505ed24ea06514883fd44d2bc02d90e77e7979c8eb71b90f41d364a1bad"}, ] [package.dependencies] @@ -525,13 +525,13 @@ files = [ [[package]] name = "typing-extensions" -version = "4.13.1" +version = "4.13.2" description = "Backported and Experimental Type Hints for Python 3.8+" optional = false python-versions = ">=3.8" files = [ - {file = "typing_extensions-4.13.1-py3-none-any.whl", hash = "sha256:4b6cf02909eb5495cfbc3f6e8fd49217e6cc7944e145cdda8caa3734777f9e69"}, - {file = "typing_extensions-4.13.1.tar.gz", hash = "sha256:98795af00fb9640edec5b8e31fc647597b4691f099ad75f469a2616be1a76dff"}, + {file = "typing_extensions-4.13.2-py3-none-any.whl", hash = "sha256:a439e7c04b49fec3e5d3e2beaa21755cadbbdc391694e28ccdd36ca4a1408f8c"}, + {file = "typing_extensions-4.13.2.tar.gz", hash = "sha256:e6c81219bd689f51865d9e372991c540bda33a0379d5573cddb9a3a23f7caaef"}, ] [metadata] diff --git a/pyproject.toml b/pyproject.toml index da689cf..dfe0372 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ name = "scrapybara" [tool.poetry] name = "scrapybara" -version = "2.5.0" +version = "2.5.1" description = "" readme = "README.md" authors = [] diff --git a/reference.md b/reference.md index ffb2ff0..624134c 100644 --- a/reference.md +++ b/reference.md @@ -458,6 +458,14 @@ client.instance.bash(
+**session:** `typing.Optional[int]` + +
+
+ +
+
+ **restart:** `typing.Optional[bool]`
@@ -466,7 +474,7 @@ client.instance.bash(
-**get_background_processes:** `typing.Optional[bool]` +**list_sessions:** `typing.Optional[bool]`
@@ -474,7 +482,7 @@ client.instance.bash(
-**kill_pid:** `typing.Optional[int]` +**check_session:** `typing.Optional[int]`
diff --git a/src/scrapybara/core/client_wrapper.py b/src/scrapybara/core/client_wrapper.py index 2ea88cd..7f289d0 100644 --- a/src/scrapybara/core/client_wrapper.py +++ b/src/scrapybara/core/client_wrapper.py @@ -16,7 +16,7 @@ def get_headers(self) -> typing.Dict[str, str]: headers: typing.Dict[str, str] = { "X-Fern-Language": "Python", "X-Fern-SDK-Name": "scrapybara", - "X-Fern-SDK-Version": "2.5.0", + "X-Fern-SDK-Version": "2.5.1", } headers["x-api-key"] = self.api_key return headers diff --git a/src/scrapybara/instance/client.py b/src/scrapybara/instance/client.py index 5af25d7..8a964c1 100644 --- a/src/scrapybara/instance/client.py +++ b/src/scrapybara/instance/client.py @@ -213,9 +213,10 @@ def bash( instance_id: str, *, command: typing.Optional[str] = OMIT, + session: typing.Optional[int] = OMIT, restart: typing.Optional[bool] = OMIT, - get_background_processes: typing.Optional[bool] = OMIT, - kill_pid: typing.Optional[int] = OMIT, + list_sessions: typing.Optional[bool] = OMIT, + check_session: typing.Optional[int] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> BashResponse: """ @@ -225,11 +226,13 @@ def bash( command : typing.Optional[str] + session : typing.Optional[int] + restart : typing.Optional[bool] - get_background_processes : typing.Optional[bool] + list_sessions : typing.Optional[bool] - kill_pid : typing.Optional[int] + check_session : typing.Optional[int] request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -255,9 +258,10 @@ def bash( method="POST", json={ "command": command, + "session": session, "restart": restart, - "get_background_processes": get_background_processes, - "kill_pid": kill_pid, + "list_sessions": list_sessions, + "check_session": check_session, }, headers={ "content-type": "application/json", @@ -980,9 +984,10 @@ async def bash( instance_id: str, *, command: typing.Optional[str] = OMIT, + session: typing.Optional[int] = OMIT, restart: typing.Optional[bool] = OMIT, - get_background_processes: typing.Optional[bool] = OMIT, - kill_pid: typing.Optional[int] = OMIT, + list_sessions: typing.Optional[bool] = OMIT, + check_session: typing.Optional[int] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> BashResponse: """ @@ -992,11 +997,13 @@ async def bash( command : typing.Optional[str] + session : typing.Optional[int] + restart : typing.Optional[bool] - get_background_processes : typing.Optional[bool] + list_sessions : typing.Optional[bool] - kill_pid : typing.Optional[int] + check_session : typing.Optional[int] request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -1030,9 +1037,10 @@ async def main() -> None: method="POST", json={ "command": command, + "session": session, "restart": restart, - "get_background_processes": get_background_processes, - "kill_pid": kill_pid, + "list_sessions": list_sessions, + "check_session": check_session, }, headers={ "content-type": "application/json", From 4632da79d03b764ba3ba7eca06ce717a08ba9102 Mon Sep 17 00:00:00 2001 From: Cooper Miller Date: Fri, 18 Apr 2025 11:06:43 -0700 Subject: [PATCH 2/4] update bash --- src/scrapybara/client.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/scrapybara/client.py b/src/scrapybara/client.py index 604f88e..71c1358 100644 --- a/src/scrapybara/client.py +++ b/src/scrapybara/client.py @@ -883,17 +883,19 @@ def bash( self, *, command: Optional[str] = OMIT, + session: Optional[int] = OMIT, restart: Optional[bool] = OMIT, - get_background_processes: Optional[bool] = OMIT, - kill_pid: Optional[int] = OMIT, + list_sessions: Optional[bool] = OMIT, + check_session: Optional[int] = OMIT, request_options: Optional[RequestOptions] = None, ) -> Optional[Any]: return self._client.instance.bash( self.id, command=command, + session=session, restart=restart, - get_background_processes=get_background_processes, - kill_pid=kill_pid, + list_sessions=list_sessions, + check_session=check_session, request_options=request_options ) @@ -1405,17 +1407,19 @@ async def bash( self, *, command: Optional[str] = OMIT, + session: Optional[int] = OMIT, restart: Optional[bool] = OMIT, - get_background_processes: Optional[bool] = OMIT, - kill_pid: Optional[int] = OMIT, + list_sessions: Optional[bool] = OMIT, + check_session: Optional[int] = OMIT, request_options: Optional[RequestOptions] = None, ) -> Optional[Any]: return await self._client.instance.bash( self.id, command=command, + session=session, restart=restart, - get_background_processes=get_background_processes, - kill_pid=kill_pid, + list_sessions=list_sessions, + check_session=check_session, request_options=request_options ) From 7406424874165f6e3a8f7e50192fef7872a3bc6e Mon Sep 17 00:00:00 2001 From: Cooper Miller Date: Fri, 18 Apr 2025 11:15:40 -0700 Subject: [PATCH 3/4] update bash tool --- src/scrapybara/tools/__init__.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/scrapybara/tools/__init__.py b/src/scrapybara/tools/__init__.py index 8e17b0f..63eb214 100644 --- a/src/scrapybara/tools/__init__.py +++ b/src/scrapybara/tools/__init__.py @@ -165,9 +165,10 @@ class BashToolParameters(BaseModel): """Parameters for bash command execution.""" command: Optional[str] = Field(description="The bash command to execute") + session: Optional[int] = Field(None, description="Session ID to run the command in") restart: Optional[bool] = Field(False, description="Whether to restart the shell") - get_background_processes: Optional[bool] = Field(None, description="Retrieve information (pid, status, command) about background processes") - kill_pid: Optional[int] = Field(None, description="Process ID to kill") + list_sessions: Optional[bool] = Field(None, description="Whether to list all bash sessions") + check_session: Optional[int] = Field(None, description="Session ID to check status") class BashTool(Tool): @@ -189,8 +190,9 @@ def __call__(self, **kwargs: Any) -> Any: params = BashToolParameters.model_validate(kwargs) return self._instance.bash( command=params.command, + session=params.session, restart=params.restart, - get_background_processes=params.get_background_processes, - kill_pid=params.kill_pid + list_sessions=params.list_sessions, + check_session=params.check_session ) From edea6219154c7546556623c0aa8fdeeb6eab37aa Mon Sep 17 00:00:00 2001 From: Cooper Miller Date: Fri, 18 Apr 2025 11:30:29 -0700 Subject: [PATCH 4/4] simplify tests --- tests/custom/test_client.py | 62 ++++++++++++++++++------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/tests/custom/test_client.py b/tests/custom/test_client.py index fd5e253..06c9a22 100644 --- a/tests/custom/test_client.py +++ b/tests/custom/test_client.py @@ -20,9 +20,9 @@ from scrapybara.tools import BashTool, ComputerTool, EditTool -class YCStats(BaseModel): - number_of_startups: int - combined_valuation: int +class ExampleSite(BaseModel): + title: str + has_links: bool def _check_api_key() -> None: @@ -47,19 +47,19 @@ def test_ubuntu() -> None: response = client.act( model=Anthropic(), system=UBUNTU_SYSTEM_PROMPT_ANTHROPIC, - prompt="Go to the YC website and get the number of funded startups and combined valuation", + prompt="Go to example.com and get the page title and whether it has any links", tools=[ ComputerTool(ubuntu_instance), BashTool(ubuntu_instance), EditTool(ubuntu_instance), ], - schema=YCStats, + schema=ExampleSite, on_step=lambda step: print(step.text, step.tool_calls), ) print(response.output) assert response.output is not None - assert response.output.number_of_startups is not None - assert response.output.combined_valuation is not None + assert response.output.title is not None + assert isinstance(response.output.has_links, bool) ubuntu_instance.browser.stop() ubuntu_instance.stop() @@ -80,19 +80,19 @@ def test_ubuntu_openai() -> None: response = client.act( model=OpenAI(), system=UBUNTU_SYSTEM_PROMPT_OPENAI, - prompt="Go to the YC website and get the number of funded startups and combined valuation", + prompt="Go to example.com and get the page title and whether it has any links", tools=[ ComputerTool(ubuntu_instance), BashTool(ubuntu_instance), EditTool(ubuntu_instance), ], - schema=YCStats, + schema=ExampleSite, on_step=lambda step: print(step.text, step.tool_calls), ) print(response.output) assert response.output is not None - assert response.output.number_of_startups is not None - assert response.output.combined_valuation is not None + assert response.output.title is not None + assert isinstance(response.output.has_links, bool) ubuntu_instance.browser.stop() ubuntu_instance.stop() @@ -111,17 +111,17 @@ def test_browser() -> None: response = client.act( model=Anthropic(), system=BROWSER_SYSTEM_PROMPT_ANTHROPIC, - prompt="Go to the YC website and get the number of funded startups and combined valuation", + prompt="Go to example.com and get the page title and whether it has any links", tools=[ ComputerTool(browser_instance), ], - schema=YCStats, + schema=ExampleSite, on_step=lambda step: print(step.text, step.tool_calls), ) print(response.output) assert response.output is not None - assert response.output.number_of_startups is not None - assert response.output.combined_valuation is not None + assert response.output.title is not None + assert isinstance(response.output.has_links, bool) browser_instance.stop() def test_browser_openai() -> None: @@ -138,17 +138,17 @@ def test_browser_openai() -> None: response = client.act( model=OpenAI(), system=BROWSER_SYSTEM_PROMPT_OPENAI, - prompt="Go to the YC website and get the number of funded startups and combined valuation", + prompt="Go to example.com and get the page title and whether it has any links", tools=[ ComputerTool(browser_instance), ], - schema=YCStats, + schema=ExampleSite, on_step=lambda step: print(step.text, step.tool_calls), ) print(response.output) assert response.output is not None - assert response.output.number_of_startups is not None - assert response.output.combined_valuation is not None + assert response.output.title is not None + assert isinstance(response.output.has_links, bool) browser_instance.stop() @@ -165,17 +165,17 @@ def test_windows() -> None: response = client.act( model=Anthropic(), system=WINDOWS_SYSTEM_PROMPT_ANTHROPIC, - prompt="Go to the YC website and get the number of funded startups and combined valuation", + prompt="Go to example.com and get the page title and whether it has any links", tools=[ ComputerTool(windows_instance), ], - schema=YCStats, + schema=ExampleSite, on_step=lambda step: print(step.text, step.tool_calls), ) print(response.output) assert response.output is not None - assert response.output.number_of_startups is not None - assert response.output.combined_valuation is not None + assert response.output.title is not None + assert isinstance(response.output.has_links, bool) windows_instance.stop() @@ -197,19 +197,19 @@ def test_ubuntu_thinking() -> None: response = client.act( model=Anthropic(name="claude-3-7-sonnet-20250219-thinking"), system=UBUNTU_SYSTEM_PROMPT_ANTHROPIC, - prompt="Go to the YC website and get the number of funded startups and combined valuation", + prompt="Go to example.com and get the page title and whether it has any links", tools=[ ComputerTool(ubuntu_instance), BashTool(ubuntu_instance), EditTool(ubuntu_instance), ], - schema=YCStats, + schema=ExampleSite, on_step=lambda step: print(step.text, step.tool_calls, step.reasoning_parts), ) print(response.output) assert response.output is not None - assert response.output.number_of_startups is not None - assert response.output.combined_valuation is not None + assert response.output.title is not None + assert isinstance(response.output.has_links, bool) ubuntu_instance.browser.stop() ubuntu_instance.stop() @@ -229,17 +229,17 @@ def test_browser_thinking() -> None: response = client.act( model=Anthropic(name="claude-3-7-sonnet-20250219-thinking"), system=BROWSER_SYSTEM_PROMPT_ANTHROPIC, - prompt="Go to the YC website and get the number of funded startups and combined valuation", + prompt="Go to example.com and get the page title and whether it has any links", tools=[ ComputerTool(browser_instance), ], - schema=YCStats, + schema=ExampleSite, on_step=lambda step: print(step.text, step.tool_calls, step.reasoning_parts), ) print(response.output) assert response.output is not None - assert response.output.number_of_startups is not None - assert response.output.combined_valuation is not None + assert response.output.title is not None + assert isinstance(response.output.has_links, bool) browser_instance.stop()