2024-03-01 10:09:30 -08:00
|
|
|
from __future__ import annotations
|
|
|
|
|
|
2025-12-02 11:08:38 -07:00
|
|
|
from typing import Protocol
|
2024-08-22 22:36:30 +03:00
|
|
|
|
2024-03-01 10:09:30 -08:00
|
|
|
import structlog
|
|
|
|
|
|
2025-03-24 15:15:21 -07:00
|
|
|
from skyvern.forge.sdk.schemas.tasks import Task
|
2024-09-07 01:57:47 -07:00
|
|
|
from skyvern.forge.sdk.workflow.models.workflow import WorkflowRun
|
2025-12-02 11:08:38 -07:00
|
|
|
from skyvern.webeye.browser_artifacts import VideoArtifact
|
|
|
|
|
from skyvern.webeye.browser_state import BrowserState
|
2024-03-01 10:09:30 -08:00
|
|
|
|
|
|
|
|
LOG = structlog.get_logger()
|
|
|
|
|
|
|
|
|
|
|
2025-12-02 11:08:38 -07:00
|
|
|
class BrowserManager(Protocol):
|
|
|
|
|
pages: dict[str, BrowserState]
|
2024-03-01 10:09:30 -08:00
|
|
|
|
2025-12-02 11:08:38 -07:00
|
|
|
async def get_or_create_for_task(self, task: Task, browser_session_id: str | None = None) -> BrowserState: ...
|
2024-03-01 10:09:30 -08:00
|
|
|
|
2025-01-09 22:04:53 +01:00
|
|
|
async def get_or_create_for_workflow_run(
|
|
|
|
|
self,
|
|
|
|
|
workflow_run: WorkflowRun,
|
|
|
|
|
url: str | None = None,
|
|
|
|
|
browser_session_id: str | None = None,
|
2025-11-06 01:24:39 -08:00
|
|
|
browser_profile_id: str | None = None,
|
2025-12-02 11:08:38 -07:00
|
|
|
) -> BrowserState: ...
|
2024-11-01 15:13:41 -07:00
|
|
|
|
2025-12-02 11:08:38 -07:00
|
|
|
async def cleanup_for_task(
|
|
|
|
|
self,
|
|
|
|
|
task_id: str,
|
|
|
|
|
close_browser_on_completion: bool = True,
|
|
|
|
|
browser_session_id: str | None = None,
|
|
|
|
|
organization_id: str | None = None,
|
|
|
|
|
) -> BrowserState | None: ...
|
2025-01-09 22:04:53 +01:00
|
|
|
|
2025-12-02 11:08:38 -07:00
|
|
|
async def cleanup_for_workflow_run(
|
|
|
|
|
self,
|
|
|
|
|
workflow_run_id: str,
|
|
|
|
|
task_ids: list[str],
|
|
|
|
|
close_browser_on_completion: bool = True,
|
|
|
|
|
browser_session_id: str | None = None,
|
|
|
|
|
organization_id: str | None = None,
|
|
|
|
|
) -> BrowserState | None: ...
|
2025-08-12 00:30:38 +08:00
|
|
|
|
2025-12-02 11:08:38 -07:00
|
|
|
async def get_or_create_for_script(
|
|
|
|
|
self,
|
|
|
|
|
script_id: str | None = None,
|
|
|
|
|
browser_session_id: str | None = None,
|
|
|
|
|
) -> BrowserState: ...
|
2024-03-01 10:09:30 -08:00
|
|
|
|
2025-12-02 11:08:38 -07:00
|
|
|
def get_for_task(self, task_id: str, workflow_run_id: str | None = None) -> BrowserState | None: ...
|
2024-03-01 10:09:30 -08:00
|
|
|
|
2025-03-06 18:27:19 -08:00
|
|
|
def get_for_workflow_run(
|
2025-12-02 11:08:38 -07:00
|
|
|
self,
|
|
|
|
|
workflow_run_id: str,
|
|
|
|
|
parent_workflow_run_id: str | None = None,
|
|
|
|
|
) -> BrowserState | None: ...
|
2024-07-11 09:35:07 -07:00
|
|
|
|
2025-12-02 11:08:38 -07:00
|
|
|
def get_for_script(self, script_id: str | None = None) -> BrowserState | None: ...
|
2024-03-01 10:09:30 -08:00
|
|
|
|
2025-12-02 11:08:38 -07:00
|
|
|
def set_video_artifact_for_task(self, task: Task, artifacts: list[VideoArtifact]) -> None: ...
|
2024-03-01 10:09:30 -08:00
|
|
|
|
2024-08-09 10:46:52 +08:00
|
|
|
async def get_video_artifacts(
|
2024-05-16 18:20:11 -07:00
|
|
|
self,
|
|
|
|
|
browser_state: BrowserState,
|
|
|
|
|
task_id: str = "",
|
|
|
|
|
workflow_id: str = "",
|
|
|
|
|
workflow_run_id: str = "",
|
2025-12-02 11:08:38 -07:00
|
|
|
) -> list[VideoArtifact]: ...
|
2024-03-01 10:09:30 -08:00
|
|
|
|
|
|
|
|
async def get_har_data(
|
2024-05-16 18:20:11 -07:00
|
|
|
self,
|
|
|
|
|
browser_state: BrowserState,
|
|
|
|
|
task_id: str = "",
|
|
|
|
|
workflow_id: str = "",
|
|
|
|
|
workflow_run_id: str = "",
|
2025-12-02 11:08:38 -07:00
|
|
|
) -> bytes: ...
|
2024-03-01 10:09:30 -08:00
|
|
|
|
2024-10-31 23:10:11 +08:00
|
|
|
async def get_browser_console_log(
|
|
|
|
|
self,
|
|
|
|
|
browser_state: BrowserState,
|
|
|
|
|
task_id: str = "",
|
|
|
|
|
workflow_id: str = "",
|
|
|
|
|
workflow_run_id: str = "",
|
2025-12-02 11:08:38 -07:00
|
|
|
) -> bytes: ...
|