Debugger Continuity (BE) (#3314)
This commit is contained in:
@@ -20,6 +20,7 @@ from skyvern.forge.sdk.db.models import (
|
||||
BitwardenCreditCardDataParameterModel,
|
||||
BitwardenLoginCredentialParameterModel,
|
||||
BitwardenSensitiveInformationParameterModel,
|
||||
BlockRunModel,
|
||||
CredentialModel,
|
||||
CredentialParameterModel,
|
||||
DebugSessionModel,
|
||||
@@ -75,7 +76,7 @@ from skyvern.forge.sdk.log_artifacts import save_workflow_run_logs
|
||||
from skyvern.forge.sdk.models import Step, StepStatus
|
||||
from skyvern.forge.sdk.schemas.ai_suggestions import AISuggestion
|
||||
from skyvern.forge.sdk.schemas.credentials import Credential, CredentialType
|
||||
from skyvern.forge.sdk.schemas.debug_sessions import DebugSession
|
||||
from skyvern.forge.sdk.schemas.debug_sessions import BlockRun, DebugSession
|
||||
from skyvern.forge.sdk.schemas.organization_bitwarden_collections import OrganizationBitwardenCollection
|
||||
from skyvern.forge.sdk.schemas.organizations import Organization, OrganizationAuthToken
|
||||
from skyvern.forge.sdk.schemas.persistent_browser_sessions import PersistentBrowserSession
|
||||
@@ -2124,6 +2125,29 @@ class AgentDB:
|
||||
LOG.error("SQLAlchemyError", exc_info=True)
|
||||
raise
|
||||
|
||||
async def get_workflow_run_output_parameter_by_id(
|
||||
self, workflow_run_id: str, output_parameter_id: str
|
||||
) -> WorkflowRunOutputParameter | None:
|
||||
try:
|
||||
async with self.Session() as session:
|
||||
parameter = (
|
||||
await session.scalars(
|
||||
select(WorkflowRunOutputParameterModel)
|
||||
.filter_by(workflow_run_id=workflow_run_id)
|
||||
.filter_by(output_parameter_id=output_parameter_id)
|
||||
.order_by(WorkflowRunOutputParameterModel.created_at)
|
||||
)
|
||||
).first()
|
||||
|
||||
if parameter:
|
||||
return convert_to_workflow_run_output_parameter(parameter, self.debug_enabled)
|
||||
|
||||
return None
|
||||
|
||||
except SQLAlchemyError:
|
||||
LOG.error("SQLAlchemyError", exc_info=True)
|
||||
raise
|
||||
|
||||
async def create_or_update_workflow_run_output_parameter(
|
||||
self,
|
||||
workflow_run_id: str,
|
||||
@@ -3520,6 +3544,72 @@ class AgentDB:
|
||||
|
||||
return DebugSession.model_validate(debug_session)
|
||||
|
||||
async def get_latest_block_run(
|
||||
self,
|
||||
*,
|
||||
organization_id: str,
|
||||
user_id: str,
|
||||
block_label: str,
|
||||
) -> BlockRun | None:
|
||||
async with self.Session() as session:
|
||||
query = (
|
||||
select(BlockRunModel)
|
||||
.filter_by(organization_id=organization_id)
|
||||
.filter_by(user_id=user_id)
|
||||
.filter_by(block_label=block_label)
|
||||
.order_by(BlockRunModel.created_at.desc())
|
||||
)
|
||||
|
||||
model = (await session.scalars(query)).first()
|
||||
|
||||
return BlockRun.model_validate(model) if model else None
|
||||
|
||||
async def get_latest_completed_block_run(
|
||||
self,
|
||||
*,
|
||||
organization_id: str,
|
||||
user_id: str,
|
||||
block_label: str,
|
||||
workflow_permanent_id: str,
|
||||
) -> BlockRun | None:
|
||||
async with self.Session() as session:
|
||||
query = (
|
||||
select(BlockRunModel)
|
||||
.join(WorkflowRunModel, BlockRunModel.workflow_run_id == WorkflowRunModel.workflow_run_id)
|
||||
.filter(BlockRunModel.organization_id == organization_id)
|
||||
.filter(BlockRunModel.user_id == user_id)
|
||||
.filter(BlockRunModel.block_label == block_label)
|
||||
.filter(WorkflowRunModel.status == WorkflowRunStatus.completed)
|
||||
.filter(WorkflowRunModel.workflow_permanent_id == workflow_permanent_id)
|
||||
.order_by(BlockRunModel.created_at.desc())
|
||||
)
|
||||
|
||||
model = (await session.scalars(query)).first()
|
||||
|
||||
return BlockRun.model_validate(model) if model else None
|
||||
|
||||
async def create_block_run(
|
||||
self,
|
||||
*,
|
||||
organization_id: str,
|
||||
user_id: str,
|
||||
block_label: str,
|
||||
output_parameter_id: str,
|
||||
workflow_run_id: str,
|
||||
) -> None:
|
||||
async with self.Session() as session:
|
||||
block_run = BlockRunModel(
|
||||
organization_id=organization_id,
|
||||
user_id=user_id,
|
||||
block_label=block_label,
|
||||
output_parameter_id=output_parameter_id,
|
||||
workflow_run_id=workflow_run_id,
|
||||
)
|
||||
|
||||
session.add(block_run)
|
||||
|
||||
await session.commit()
|
||||
|
||||
async def get_latest_debug_session_for_user(
|
||||
self,
|
||||
*,
|
||||
|
||||
Reference in New Issue
Block a user