Automate browser based workflows with AI
Python aiapiautomationbrowserbrowser-automationcomputergptllmplaywrightpowerautomatepuppeteerpythonrpaseleniumvisionworkflow
SDK: small fixes and improvements (#4174)
Stanislav Novosadd310c5e39c2b
diff --git a/skyvern/library/skyvern.py b/skyvern/library/skyvern.pyindex 8e7dedacb..5f910e77d 100644--- a/skyvern/library/skyvern.py+++ b/skyvern/library/skyvern.py@@ -234,7 +234,7 @@ class Skyvern(AsyncSkyvern):browser_session_id: str | None = None,user_agent: str | None = None,extra_http_headers: dict[str, str] | None = None,- publish_workflow: bool | None = None,+ publish_workflow: bool = False,include_action_history_in_verification: bool | None = None,max_screenshot_scrolls: int | None = None,browser_address: str | None = None,@@ -383,7 +383,13 @@ class Skyvern(AsyncSkyvern):await asyncio.sleep(DEFAULT_AGENT_HEARTBEAT_INTERVAL)return WorkflowRunResponse.model_validate(workflow_run.model_dump())- async def launch_local_browser(self, *, headless: bool = False, port: int = DEFAULT_CDP_PORT) -> SkyvernBrowser:+ async def launch_local_browser(+ self,+ *,+ headless: bool = False,+ port: int = DEFAULT_CDP_PORT,+ args: list[str] | None = None,+ ) -> SkyvernBrowser:"""Launch a new local Chromium browser with Chrome DevTools Protocol (CDP) enabled.This method launches a browser on your local machine with remote debugging enabled,@@ -392,15 +398,17 @@ class Skyvern(AsyncSkyvern):Args:headless: Whether to run the browser in headless mode. Defaults to False.port: The port number for the CDP endpoint. Defaults to DEFAULT_CDP_PORT.+ args: Additional command-line arguments to pass to Chromium. Defaults to None.+ Example: ["--disable-blink-features=AutomationControlled", "--window-size=1920,1080"]Returns:SkyvernBrowser: A browser instance with Skyvern capabilities."""playwright = await self._get_playwright()- browser = await playwright.chromium.launch(- headless=headless,- args=[f"--remote-debugging-port={port}"],- )+ launch_args = [f"--remote-debugging-port={port}"]+ if args:+ launch_args.extend(args)+ browser = await playwright.chromium.launch(headless=headless, args=launch_args)browser_address = f"http://localhost:{port}"browser_context = browser.contexts[0] if browser.contexts else await browser.new_context()return SkyvernBrowser(self, browser_context, browser_address=browser_address)diff --git a/skyvern/library/skyvern_browser_page.py b/skyvern/library/skyvern_browser_page.pyindex f17b9cddd..27c50776c 100644--- a/skyvern/library/skyvern_browser_page.py+++ b/skyvern/library/skyvern_browser_page.py@@ -91,6 +91,7 @@ class SkyvernPageRun:LOG.info("AI task is running, this may take a while", run_id=task_run.run_id)task_run = await self._wait_for_run_completion(task_run.run_id, timeout)+ LOG.info("AI task finished", run_id=task_run.run_id, status=task_run.status)return TaskRunResponse.model_validate(task_run.model_dump())async def login(@@ -153,6 +154,7 @@ class SkyvernPageRun:LOG.info("AI login workflow is running, this may take a while", run_id=workflow_run.run_id)workflow_run = await self._wait_for_run_completion(workflow_run.run_id, timeout)+ LOG.info("AI login workflow finished", run_id=workflow_run.run_id, status=workflow_run.status)return WorkflowRunResponse.model_validate(workflow_run.model_dump())async def workflow(@@ -199,6 +201,7 @@ class SkyvernPageRun:LOG.info("AI workflow is running, this may take a while", run_id=workflow_run.run_id)workflow_run = await self._wait_for_run_completion(workflow_run.run_id, timeout)+ LOG.info("AI workflow finished", run_id=workflow_run.run_id, status=workflow_run.status)return WorkflowRunResponse.model_validate(workflow_run.model_dump())async def _wait_for_run_completion(self, run_id: str, timeout: float) -> GetRunResponse: