[SKY-6974] Browser Profiles [2/3] Marc/backend browser session profiles (#3923)
This commit is contained in:
@@ -645,7 +645,10 @@ class BaseTaskBlock(Block):
|
||||
# the first task block will create the browser state and do the navigation
|
||||
try:
|
||||
browser_state = await app.BROWSER_MANAGER.get_or_create_for_workflow_run(
|
||||
workflow_run=workflow_run, url=self.url, browser_session_id=browser_session_id
|
||||
workflow_run=workflow_run,
|
||||
url=self.url,
|
||||
browser_session_id=browser_session_id,
|
||||
browser_profile_id=workflow_run.browser_profile_id,
|
||||
)
|
||||
working_page = await browser_state.get_working_page()
|
||||
if not working_page:
|
||||
@@ -1586,6 +1589,7 @@ async def wrapper():
|
||||
workflow_run=workflow_run,
|
||||
url=None, # Code block doesn't need to navigate to a URL initially
|
||||
browser_session_id=browser_session_id,
|
||||
browser_profile_id=workflow_run.browser_profile_id,
|
||||
)
|
||||
# Ensure the browser state has a working page
|
||||
await browser_state.check_and_fix_state(
|
||||
@@ -1595,6 +1599,7 @@ async def wrapper():
|
||||
organization_id=workflow_run.organization_id,
|
||||
extra_http_headers=workflow_run.extra_http_headers,
|
||||
browser_address=workflow_run.browser_address,
|
||||
browser_profile_id=workflow_run.browser_profile_id,
|
||||
)
|
||||
except Exception as e:
|
||||
LOG.exception(
|
||||
|
||||
@@ -2,7 +2,7 @@ from datetime import datetime
|
||||
from enum import StrEnum
|
||||
from typing import Any, List
|
||||
|
||||
from pydantic import BaseModel, field_validator
|
||||
from pydantic import BaseModel, field_validator, model_validator
|
||||
from typing_extensions import deprecated
|
||||
|
||||
from skyvern.forge.sdk.schemas.files import FileInfo
|
||||
@@ -23,6 +23,7 @@ class WorkflowRequestBody(BaseModel):
|
||||
totp_verification_url: str | None = None
|
||||
totp_identifier: str | None = None
|
||||
browser_session_id: str | None = None
|
||||
browser_profile_id: str | None = None
|
||||
max_screenshot_scrolls: int | None = None
|
||||
extra_http_headers: dict[str, str] | None = None
|
||||
browser_address: str | None = None
|
||||
@@ -36,6 +37,12 @@ class WorkflowRequestBody(BaseModel):
|
||||
return None
|
||||
return validate_url(url)
|
||||
|
||||
@model_validator(mode="after")
|
||||
def validate_browser_reference(cls, values: "WorkflowRequestBody") -> "WorkflowRequestBody":
|
||||
if values.browser_session_id and values.browser_profile_id:
|
||||
raise ValueError("Cannot specify both browser_session_id and browser_profile_id")
|
||||
return values
|
||||
|
||||
|
||||
@deprecated("Use WorkflowRunResponse instead")
|
||||
class RunWorkflowResponse(BaseModel):
|
||||
@@ -130,6 +137,7 @@ class WorkflowRun(BaseModel):
|
||||
workflow_permanent_id: str
|
||||
organization_id: str
|
||||
browser_session_id: str | None = None
|
||||
browser_profile_id: str | None = None
|
||||
debug_session_id: str | None = None
|
||||
status: WorkflowRunStatus
|
||||
extra_http_headers: dict[str, str] | None = None
|
||||
@@ -199,6 +207,7 @@ class WorkflowRunResponseBase(BaseModel):
|
||||
task_v2: TaskV2 | None = None
|
||||
workflow_title: str | None = None
|
||||
browser_session_id: str | None = None
|
||||
browser_profile_id: str | None = None
|
||||
max_screenshot_scrolls: int | None = None
|
||||
browser_address: str | None = None
|
||||
script_run: ScriptRunResponse | None = None
|
||||
|
||||
Reference in New Issue
Block a user