Automate browser based workflows with AI
Python aiapiautomationbrowserbrowser-automationcomputergptllmplaywrightpowerautomatepuppeteerpythonrpaseleniumvisionworkflow
Jon/allow block scripts to be fetched with status (#3469)
Jonathan Dobsonf283958a52b3
diff --git a/skyvern/forge/sdk/db/client.py b/skyvern/forge/sdk/db/client.pyindex 619b675c1..161207e12 100644--- a/skyvern/forge/sdk/db/client.py+++ b/skyvern/forge/sdk/db/client.py@@ -107,7 +107,7 @@ from skyvern.forge.sdk.workflow.models.workflow import (WorkflowRunStatus,)from skyvern.schemas.runs import ProxyLocation, RunEngine, RunType-from skyvern.schemas.scripts import Script, ScriptBlock, ScriptFile+from skyvern.schemas.scripts import Script, ScriptBlock, ScriptFile, ScriptStatusfrom skyvern.schemas.steps import AgentStepOutputfrom skyvern.schemas.workflows import BlockStatus, BlockType, WorkflowStatusfrom skyvern.webeye.actions.actions import Action@@ -4088,6 +4088,7 @@ class AgentDB:workflow_permanent_id: str,cache_key_value: str,cache_key: str | None = None,+ statuses: list[ScriptStatus] | None = None,) -> list[Script]:"""Get latest script versions linked to a workflow by a specific cache_key_value."""try:@@ -4104,6 +4105,9 @@ class AgentDB:if cache_key is not None:ws_script_ids_subquery = ws_script_ids_subquery.where(WorkflowScriptModel.cache_key == cache_key)+ if statuses is not None and len(statuses) > 0:+ ws_script_ids_subquery = ws_script_ids_subquery.where(WorkflowScriptModel.status.in_(statuses))+# Latest version per script_id within the org and not deletedlatest_versions_subquery = (select(diff --git a/skyvern/forge/sdk/routes/scripts.py b/skyvern/forge/sdk/routes/scripts.pyindex 3d5611391..711c6cd76 100644--- a/skyvern/forge/sdk/routes/scripts.py+++ b/skyvern/forge/sdk/routes/scripts.py@@ -295,12 +295,14 @@ async def get_workflow_script_blocks(raise HTTPException(status_code=404, detail="Workflow not found")cache_key = block_script_request.cache_key or workflow.cache_key or ""+ status = block_script_request.statusscripts = await app.DATABASE.get_workflow_scripts_by_cache_key_value(organization_id=current_org.organization_id,workflow_permanent_id=workflow_permanent_id,cache_key_value=cache_key_value,cache_key=cache_key,+ statuses=[status] if status else None,)if not scripts:diff --git a/skyvern/schemas/scripts.py b/skyvern/schemas/scripts.pyindex 08efa2b36..10b4bf070 100644--- a/skyvern/schemas/scripts.py+++ b/skyvern/schemas/scripts.py@@ -154,6 +154,7 @@ class ScriptBlocksResponse(BaseModel):class ScriptBlocksRequest(BaseModel):cache_key_value: strcache_key: str | None = None+ status: ScriptStatus | None = Noneclass ScriptStatus(StrEnum):