Skip to content

Automate browser based workflows with AI

Fix missing app initialization in `skyvern init` (#4038)

Stanislav Novosadd5a7485d45fa
diff --git a/skyvern/cli/init_command.py b/skyvern/cli/init_command.py
index d7bb66846..3fde1c628 100644
--- a/skyvern/cli/init_command.py
+++ b/skyvern/cli/init_command.py
@@ -8,6 +8,7 @@ from rich.panel import Panel
from rich.progress import Progress, SpinnerColumn, TextColumn
from rich.prompt import Confirm, Prompt
+from skyvern.forge.forge_app_initializer import start_forge_app
from skyvern.utils import migrate_db
from skyvern.utils.env_paths import resolve_backend_env_path
@@ -44,6 +45,7 @@ def init(
console.print("βœ… [green]Database migration complete.[/green]")
console.print("πŸ”‘ [bold blue]Generating local organization API key...[/bold blue]")
+ start_forge_app()
api_key = asyncio.run(setup_local_organization())
if api_key:
console.print("βœ… [green]Local organization API key generated.[/green]")
diff --git a/skyvern/cli/tasks.py b/skyvern/cli/tasks.py
index 14050db1e..473bb150f 100644
--- a/skyvern/cli/tasks.py
+++ b/skyvern/cli/tasks.py
@@ -41,7 +41,7 @@ def _get_client(api_key: str | None = None) -> Skyvern:
def _list_workflow_tasks(client: Skyvern, run_id: str) -> list[dict]:
"""Return tasks for the given workflow run."""
- resp = client.agent._client_wrapper.httpx_client.request(
+ resp = client._client_wrapper.httpx_client.request(
"api/v1/tasks",
method="GET",
params={"workflow_run_id": run_id, "page_size": 100, "page": 1},
diff --git a/skyvern/cli/workflow.py b/skyvern/cli/workflow.py
index abb834468..eb8d6a204 100644
--- a/skyvern/cli/workflow.py
+++ b/skyvern/cli/workflow.py
@@ -56,7 +56,7 @@ def run_workflow(
raise typer.Exit(code=1)
client = _get_client(ctx.obj.get("api_key") if ctx.obj else None)
- run_resp = client.agent.run_workflow(
+ run_resp = client.run_workflow(
workflow_id=workflow_id,
parameters=params_dict,
title=title,
@@ -77,7 +77,7 @@ def cancel_workflow(
) -> None:
"""Cancel a running workflow."""
client = _get_client(ctx.obj.get("api_key") if ctx.obj else None)
- client.agent.cancel_run(run_id=run_id)
+ client.cancel_run(run_id=run_id)
console.print(Panel(f"Cancel signal sent for run {run_id}", border_style="red"))
@@ -89,7 +89,7 @@ def workflow_status(
) -> None:
"""Retrieve status information for a workflow run."""
client = _get_client(ctx.obj.get("api_key") if ctx.obj else None)
- run = client.agent.get_run(run_id=run_id)
+ run = client.get_run(run_id=run_id)
console.print(Panel(run.model_dump_json(indent=2), border_style="cyan"))
if tasks:
task_list = _list_workflow_tasks(client, run_id)
@@ -105,7 +105,7 @@ def list_workflows(
) -> None:
"""List workflows for the organization."""
client = _get_client(ctx.obj.get("api_key") if ctx.obj else None)
- resp = client.agent._client_wrapper.httpx_client.request(
+ resp = client._client_wrapper.httpx_client.request(
"api/v1/workflows",
method="GET",
params={"page": page, "page_size": page_size, "template": template},
diff --git a/skyvern/forge/__init__.py b/skyvern/forge/__init__.py
index 1df634d5a..eaec27f99 100644
--- a/skyvern/forge/__init__.py
+++ b/skyvern/forge/__init__.py
@@ -17,14 +17,14 @@ class AppHolder:
def __getattr__(self, name: str) -> Any:
inst = object.__getattribute__(self, "_inst")
if inst is None:
- raise RuntimeError("ForgeApp is not initialized, start_forge_app should be called")
+ raise RuntimeError("ForgeApp is not initialized. Call start_forge_app() before accessing app properties.")
return getattr(inst, name)
def __setattr__(self, name: str, value: Any) -> None:
inst = object.__getattribute__(self, "_inst")
if inst is None:
- raise RuntimeError("ForgeApp is not initialized, start_forge_app should be called")
+ raise RuntimeError("ForgeApp is not initialized. Call start_forge_app() before accessing app properties.")
setattr(inst, name, value)