Automate browser based workflows with AI
Python aiapiautomationbrowserbrowser-automationcomputergptllmplaywrightpowerautomatepuppeteerpythonrpaseleniumvisionworkflow
[CLI] Add non-interactive quickstart setup (#6025)
Suchintan9cb7ea110611
diff --git a/skyvern/cli/browser.py b/skyvern/cli/browser.pyindex 3cd64a424..7c6387803 100644--- a/skyvern/cli/browser.py+++ b/skyvern/cli/browser.py@@ -4,16 +4,10 @@ import timefrom typing import Any, Optionalfrom urllib.parse import urlparse-import requests # type: ignorefrom rich.panel import Panelfrom rich.prompt import Confirm, Promptfrom .console import console-from .core.browser_launcher import (- SKYVERN_DATA_DIR,- clone_local_chrome_profile,- get_local_chrome_profile_dir,-)# Ports to scan when auto-discovering a CDP debugging server_CDP_SCAN_PORTS = [9222, 9223, 9224, 9225, 9226, 9229]@@ -72,6 +66,8 @@ def _discover_cdp_server() -> Optional[tuple[str, dict | None]]:- "ws://127.0.0.1:{port}/devtools/browser" if only WS is availableversion_info is cached to avoid a redundant probe in _print_cdp_info."""+ import requests # type: ignore+for port in _CDP_SCAN_PORTS:http_url = f"http://127.0.0.1:{port}"# Try HTTP first (standard --remote-debugging-port)@@ -108,6 +104,8 @@ def _print_cdp_info(url: str, cached_info: dict | None = None) -> None:return# Standard HTTP CDP server+ import requests # type: ignore+info = cached_infoif not info:try:@@ -171,6 +169,12 @@ def _print_classic_cdp_instructions() -> None:def _setup_local_browser_clone() -> tuple[str, Optional[str], Optional[str]]:"""Set up a new browser with the user's Chrome profile cloned."""+ from .core.browser_launcher import ( # noqa: PLC0415+ SKYVERN_DATA_DIR,+ clone_local_chrome_profile,+ get_local_chrome_profile_dir,+ )+chrome_profile_dir = get_local_chrome_profile_dir()if not chrome_profile_dir.is_dir():console.print(@@ -295,6 +299,8 @@ def _setup_local_browser_actual() -> tuple[str, Optional[str], Optional[str]]:)# Verify the manual URL+ import requests # type: ignore+try:response = requests.get(f"{manual_url}/json/version", timeout=2)if response.status_code == 200:diff --git a/skyvern/cli/init_command.py b/skyvern/cli/init_command.pyindex 4dca63769..5613cba2d 100644--- a/skyvern/cli/init_command.py+++ b/skyvern/cli/init_command.py@@ -4,7 +4,7 @@ import osimport subprocessimport sysimport uuid-from collections.abc import Callable, Coroutine+from collections.abc import Callablefrom dataclasses import dataclass, fieldfrom pathlib import Pathfrom typing import Any, Literal, TypeVar, overload@@ -25,7 +25,6 @@ from skyvern.utils.env_paths import (resolve_backend_env_path,)-from .browser import setup_browser_configfrom .console import consolefrom .database import setup_postgresqlfrom .llm_setup import setup_llm_providers, update_or_add_env_var@@ -130,7 +129,12 @@ def _ensure_playwright_chromium(browser_type: str | None, skip_browser_install:) as progress:progress.add_task("[bold blue]Downloading Chromium, this may take a moment...", total=None)try:- subprocess.run(["playwright", "install", "chromium"], check=True, capture_output=True, text=True)+ subprocess.run(+ [sys.executable, "-m", "playwright", "install", "chromium"],+ check=True,+ capture_output=True,+ text=True,+ )capture_setup_event("playwright-install-complete", success=True)console.print("β [green]Chromium installation complete.[/green]")return BrowserInstallStatus(required=True, ready=True, attempted=True)@@ -293,7 +297,10 @@ def _install_server_extra_for_missing_dependency(exc: ImportError) -> None:_SERVER_EXTRA_INSTALL_ATTEMPTED = Trueconsole.print(f"π¦ [bold blue]Installing {escape(target)}...[/bold blue]")try:- subprocess.run([sys.executable, "-m", "pip", "install", target], check=True)+ subprocess.run(+ [sys.executable, "-m", "pip", "install", "--retries", "5", "--timeout", "60", target],+ check=True,+ )except subprocess.CalledProcessError as install_error:console.print(f"[bold red]Failed to install {target}: {install_error}[/bold red]")_print_local_server_dependency_hint(missing_module, target)@@ -308,11 +315,27 @@ def _run_with_server_dependency_install(action: Callable[[], _T]) -> _T:_install_server_extra_for_missing_dependency(exc)+async def _setup_local_organization_from_database() -> str:+ """Seed the local org/API key without constructing the full server runtime."""+ from skyvern.config import settings # noqa: PLC0415++ from .mcp import setup_local_organization_from_database_string # noqa: PLC0415++ return await setup_local_organization_from_database_string(settings.DATABASE_STRING)++@overloaddef init_env(no_postgres: bool = False,database_string: str = "",skip_browser_install: bool = False,+ mode: Literal["local", "cloud"] | None = None,+ skip_llm_setup: bool = False,+ configure_mcp: bool | None = None,+ browser_type: Literal["chromium-headful", "chromium-headless", "cdp-connect"] | None = None,+ browser_location: str | None = None,+ remote_debugging_url: str | None = None,+ analytics_id: str | None = None,env_scope: str | None = None,env_path: Path | str | None = None,return_result: Literal[False] = False,@@ -324,6 +347,13 @@ def init_env(no_postgres: bool = False,database_string: str = "",skip_browser_install: bool = False,+ mode: Literal["local", "cloud"] | None = None,+ skip_llm_setup: bool = False,+ configure_mcp: bool | None = None,+ browser_type: Literal["chromium-headful", "chromium-headless", "cdp-connect"] | None = None,+ browser_location: str | None = None,+ remote_debugging_url: str | None = None,+ analytics_id: str | None = None,env_scope: str | None = None,env_path: Path | str | None = None,return_result: Literal[True] = True,@@ -334,6 +364,13 @@ def init_env(no_postgres: bool = False,database_string: str = "",skip_browser_install: bool = False,+ mode: Literal["local", "cloud"] | None = None,+ skip_llm_setup: bool = False,+ configure_mcp: bool | None = None,+ browser_type: Literal["chromium-headful", "chromium-headless", "cdp-connect"] | None = None,+ browser_location: str | None = None,+ remote_debugging_url: str | None = None,+ analytics_id: str | None = None,env_scope: str | None = None,env_path: Path | str | None = None,return_result: bool = False,@@ -348,7 +385,7 @@ def init_env()console.print("[italic]This wizard will help you set up Skyvern.[/italic]")- infra_choice = Prompt.ask(+ infra_choice = mode or Prompt.ask("Would you like to run Skyvern [bold blue]local[/bold blue]ly or in the [bold purple]cloud[/bold purple]?",choices=["local", "cloud"],)@@ -385,27 +422,16 @@ def init_env(console.print("β [green]Database migration complete.[/green]")console.print("π [bold blue]Generating local organization API key...[/bold blue]")-- def _load_start_forge_app() -> Callable[[], object]:- from skyvern.forge.forge_app_initializer import start_forge_app # noqa: PLC0415-- return start_forge_app-- def _load_setup_local_organization() -> Callable[[], Coroutine[Any, Any, str]]:- from .mcp import setup_local_organization # noqa: PLC0415-- return setup_local_organization-- start_forge_app = _run_with_server_dependency_install(_load_start_forge_app)- setup_local_organization = _run_with_server_dependency_install(_load_setup_local_organization)- _run_with_server_dependency_install(start_forge_app)- api_key = _run_with_server_dependency_install(lambda: asyncio.run(setup_local_organization()))+ api_key = _run_with_server_dependency_install(lambda: asyncio.run(_setup_local_organization_from_database()))if api_key:console.print("β [green]Local organization API key generated.[/green]")else:console.print("[red]Failed to generate local organization API key. Please check server logs.[/red]")- if backend_env_path.exists():+ if skip_llm_setup:+ console.print("[yellow]Skipping LLM setup as requested.[/yellow]")+ set_env_var("ENV", "local")+ elif backend_env_path.exists():console.print(f"π‘ [{backend_env_path}] file already exists.", style="yellow", markup=False)redo_llm_setup = Confirm.ask("Do you want to go through [bold yellow]LLM provider setup again[/bold yellow]?",@@ -421,13 +447,29 @@ def init_env(setup_llm_providers(env_path=backend_env_path)console.print("\n[bold blue]Configuring browser settings...[/bold blue]")- browser_type, browser_location, remote_debugging_url = setup_browser_config()- result.browser_type = browser_type- set_env_var("BROWSER_TYPE", browser_type)- if browser_location:- set_env_var("CHROME_EXECUTABLE_PATH", browser_location)- if remote_debugging_url:- set_env_var("BROWSER_REMOTE_DEBUGGING_URL", remote_debugging_url)+ selected_browser_type: str+ selected_browser_location: str | None+ selected_remote_debugging_url: str | None+ if browser_type:+ selected_browser_type = browser_type+ selected_browser_location = browser_location+ selected_remote_debugging_url = remote_debugging_url+ capture_setup_event(+ "browser-config-select",+ success=True,+ extra_data={"type": selected_browser_type, "source": "cli-option"},+ )+ else:+ from .browser import setup_browser_config # noqa: PLC0415++ selected_browser_type, selected_browser_location, selected_remote_debugging_url = setup_browser_config()++ result.browser_type = selected_browser_type+ set_env_var("BROWSER_TYPE", selected_browser_type)+ if selected_browser_location:+ set_env_var("CHROME_EXECUTABLE_PATH", selected_browser_location)+ if selected_remote_debugging_url:+ set_env_var("BROWSER_REMOTE_DEBUGGING_URL", selected_remote_debugging_url)set_env_var("BROWSER_STREAMING_MODE", "cdp")console.print("β [green]Browser configuration complete.[/green]")@@ -488,9 +530,11 @@ def init_env(console.print(" This starts Chrome on your machine and creates a tunnel so Skyvern Cloud can control it.")console.print(" Learn more: [link]https://www.skyvern.com/docs/optimization/browser-tunneling[/link]")- analytics_id_input = Prompt.ask("Please enter your email for analytics (press enter to skip)", default="")- analytics_id = analytics_id_input if analytics_id_input else str(uuid.uuid4())- set_env_var("ANALYTICS_ID", analytics_id)+ resolved_analytics_id = analytics_id+ if resolved_analytics_id is None:+ analytics_id_input = Prompt.ask("Please enter your email for analytics (press enter to skip)", default="")+ resolved_analytics_id = analytics_id_input if analytics_id_input else str(uuid.uuid4())+ set_env_var("ANALYTICS_ID", resolved_analytics_id)if api_key:set_env_var("SKYVERN_API_KEY", api_key)console.print(f"β [green]{backend_env_path} file has been initialized.[/green]")@@ -499,7 +543,14 @@ def init_env(_mcp_browser_type = os.environ.get("BROWSER_TYPE") if run_local else None_mcp_browser_url = os.environ.get("BROWSER_REMOTE_DEBUGGING_URL") if run_local else None- if Confirm.ask("\nWould you like to [bold yellow]configure the MCP server[/bold yellow]?", default=True):+ should_configure_mcp = configure_mcp+ if should_configure_mcp is None:+ should_configure_mcp = Confirm.ask(+ "\nWould you like to [bold yellow]configure the MCP server[/bold yellow]?",+ default=True,+ )++ if should_configure_mcp:from .mcp import setup_mcp # noqa: PLC0415setup_mcp(@@ -567,6 +618,8 @@ def init_browser() -> None:"""Initialize only the browser configuration and install Chromium."""console.print("\n[bold blue]Configuring browser settings...[/bold blue]")capture_setup_event("browser-config-start")+ from .browser import setup_browser_config # noqa: PLC0415+browser_type, browser_location, remote_debugging_url = setup_browser_config()update_or_add_env_var("BROWSER_TYPE", browser_type)if browser_location:diff --git a/skyvern/cli/mcp.py b/skyvern/cli/mcp.pyindex 0c0b1fa57..2784173cc 100644--- a/skyvern/cli/mcp.py+++ b/skyvern/cli/mcp.py@@ -1,31 +1,67 @@+from __future__ import annotations++import base64+import hashlib+import hmac+import json+from datetime import datetime, timedelta+from typing import TYPE_CHECKING, Any+from rich.panel import Panelfrom rich.prompt import Confirmfrom skyvern.forge import app-from skyvern.forge.sdk.core import securityfrom skyvern.forge.sdk.db.enums import OrganizationAuthTokenType-from skyvern.forge.sdk.schemas.organizations import Organization-from skyvern.forge.sdk.services.local_org_auth_token_service import SKYVERN_LOCAL_DOMAIN, SKYVERN_LOCAL_ORG-from skyvern.forge.sdk.services.org_auth_token_service import API_KEY_LIFETIMEfrom .console import consolefrom .setup_commands import setup_claude, setup_claude_code, setup_cursor, setup_windsurf+if TYPE_CHECKING:+ from skyvern.forge.sdk.schemas.organizations import Organization++API_KEY_LIFETIME = timedelta(weeks=5200)+SKYVERN_LOCAL_ORG = "Skyvern-local"+SKYVERN_LOCAL_DOMAIN = "skyvern.local"+++def _base64url_encode(data: bytes) -> str:+ return base64.urlsafe_b64encode(data).rstrip(b"=").decode("ascii")-async def get_or_create_local_organization() -> Organization:- organization = await app.DATABASE.organizations.get_organization_by_domain(SKYVERN_LOCAL_DOMAIN)++def _create_local_access_token(subject: str, expires_delta: timedelta) -> str:+ from skyvern.config import settings # noqa: PLC0415++ if settings.SIGNATURE_ALGORITHM != "HS256":+ raise RuntimeError("Local quickstart token bootstrap only supports HS256 SIGNATURE_ALGORITHM")++ expire = datetime.utcnow() + expires_delta+ header = {"alg": "HS256", "typ": "JWT"}+ payload = {"exp": int(expire.timestamp()), "sub": str(subject)}+ signing_input = ".".join(+ [+ _base64url_encode(json.dumps(header, separators=(",", ":")).encode("utf-8")),+ _base64url_encode(json.dumps(payload, separators=(",", ":")).encode("utf-8")),+ ]+ )+ signature = hmac.new(settings.SECRET_KEY.encode("utf-8"), signing_input.encode("ascii"), hashlib.sha256).digest()+ return f"{signing_input}.{_base64url_encode(signature)}"+++async def get_or_create_local_organization(database: Any | None = None) -> Organization:+ database = database or app.DATABASE+ organization = await database.organizations.get_organization_by_domain(SKYVERN_LOCAL_DOMAIN)if not organization:- organization = await app.DATABASE.organizations.create_organization(+ organization = await database.organizations.create_organization(organization_name=SKYVERN_LOCAL_ORG,domain=SKYVERN_LOCAL_DOMAIN,max_steps_per_run=10,max_retries_per_step=3,)- api_key = security.create_access_token(+ api_key = _create_local_access_token(organization.organization_id,expires_delta=API_KEY_LIFETIME,)- await app.DATABASE.organizations.create_org_auth_token(+ await database.organizations.create_org_auth_token(organization_id=organization.organization_id,token=api_key,token_type=OrganizationAuthTokenType.api,@@ -33,15 +69,138 @@ async def get_or_create_local_organization() -> Organization:return organization-async def setup_local_organization() -> str:- organization = await get_or_create_local_organization()- org_auth_token = await app.DATABASE.organizations.get_valid_org_auth_token(+async def setup_local_organization(database: Any | None = None) -> str:+ database = database or app.DATABASE+ organization = await get_or_create_local_organization(database=database)+ org_auth_token = await database.organizations.get_valid_org_auth_token(organization_id=organization.organization_id,token_type=OrganizationAuthTokenType.api.value,)return org_auth_token.token if org_auth_token else ""+async def setup_local_organization_from_database_string(database_string: str) -> str:+ """Seed the local org/API key without importing the full repository graph."""+ from sqlalchemy import text # noqa: PLC0415+ from sqlalchemy.ext.asyncio import create_async_engine # noqa: PLC0415++ from skyvern.forge.sdk.db.id import generate_org_id, generate_organization_auth_token_id # noqa: PLC0415++ connect_args = {"prepare_threshold": None} if "postgresql+psycopg" in database_string else {}+ engine = create_async_engine(database_string, connect_args=connect_args, pool_pre_ping=True)+ try:+ async with engine.begin() as connection:+ organization_id = (+ await connection.execute(+ text("SELECT organization_id FROM organizations WHERE domain = :domain LIMIT 1"),+ {"domain": SKYVERN_LOCAL_DOMAIN},+ )+ ).scalar_one_or_none()++ if not organization_id:+ organization_id = generate_org_id()+ now = datetime.utcnow()+ await connection.execute(+ text(+ """+ INSERT INTO organizations (+ organization_id,+ organization_name,+ domain,+ max_steps_per_run,+ max_retries_per_step,+ created_at,+ modified_at+ )+ VALUES (+ :organization_id,+ :organization_name,+ :domain,+ :max_steps_per_run,+ :max_retries_per_step,+ :created_at,+ :modified_at+ )+ """+ ),+ {+ "organization_id": organization_id,+ "organization_name": SKYVERN_LOCAL_ORG,+ "domain": SKYVERN_LOCAL_DOMAIN,+ "max_steps_per_run": 10,+ "max_retries_per_step": 3,+ "created_at": now,+ "modified_at": now,+ },+ )+ api_key = _create_local_access_token(+ organization_id,+ expires_delta=API_KEY_LIFETIME,+ )+ await connection.execute(+ text(+ """+ INSERT INTO organization_auth_tokens (+ id,+ organization_id,+ token_type,+ token,+ encrypted_token,+ encrypted_method,+ valid,+ created_at,+ modified_at+ )+ VALUES (+ :id,+ :organization_id,+ :token_type,+ :token,+ :encrypted_token,+ :encrypted_method,+ :valid,+ :created_at,+ :modified_at+ )+ """+ ),+ {+ "id": generate_organization_auth_token_id(),+ "organization_id": organization_id,+ "token_type": OrganizationAuthTokenType.api.value,+ "token": api_key,+ "encrypted_token": "",+ "encrypted_method": "",+ "valid": True,+ "created_at": now,+ "modified_at": now,+ },+ )++ token = (+ await connection.execute(+ text(+ """+ SELECT token+ FROM organization_auth_tokens+ WHERE organization_id = :organization_id+ AND token_type = :token_type+ AND valid = true+ ORDER BY created_at DESC+ LIMIT 1+ """+ ),+ {+ "organization_id": organization_id,+ "token_type": OrganizationAuthTokenType.api.value,+ },+ )+ ).scalar_one_or_none()+ return token or ""+ finally:+ await engine.dispose()++def setup_mcp(*,local: bool = False,diff --git a/skyvern/cli/quickstart.py b/skyvern/cli/quickstart.pyindex aeefe2178..66df19d4f 100644--- a/skyvern/cli/quickstart.py+++ b/skyvern/cli/quickstart.py@@ -7,7 +7,7 @@ import subprocessimport sysfrom enum import Enumfrom pathlib import Path-from typing import Any+from typing import Any, Literalimport typerfrom rich.markup import escape@@ -36,7 +36,7 @@ def _server_extra_install_target() -> str:return f"skyvern[server]=={version}"-def _install_server_extra_for_quickstart() -> bool:+def _install_server_extra_for_quickstart(*, assume_yes: bool = False) -> bool:target = _server_extra_install_target()console.print(Panel(@@ -46,13 +46,16 @@ def _install_server_extra_for_quickstart() -> bool:border_style="yellow",))- if not Confirm.ask("Install the missing server dependencies now?", default=True):+ if not assume_yes and not Confirm.ask("Install the missing server dependencies now?", default=True):_print_server_guidance()return Falseconsole.print(f"π¦ [bold blue]Installing {escape(target)}...[/bold blue]")try:- subprocess.run([sys.executable, "-m", "pip", "install", target], check=True)+ subprocess.run(+ [sys.executable, "-m", "pip", "install", "--retries", "5", "--timeout", "60", target],+ check=True,+ )except subprocess.CalledProcessError as install_error:console.print(f"[bold red]Failed to install {target}: {install_error}[/bold red]")_print_server_guidance()@@ -285,6 +288,13 @@ def _run_server_quickstart(database_string: str,skip_browser_install: bool,server_only: bool,+ skip_llm_setup: bool = False,+ configure_mcp: bool | None = None,+ browser_type: Literal["chromium-headful", "chromium-headless", "cdp-connect"] | None = None,+ browser_location: str | None = None,+ remote_debugging_url: str | None = None,+ analytics_id: str | None = None,+ start_services_now: bool | None = None,) -> None:try:from skyvern.cli.init_command import init_env # noqa: PLC0415@@ -296,6 +306,13 @@ def _run_server_quickstart(no_postgres=no_postgres,database_string=database_string,skip_browser_install=skip_browser_install,+ mode="local",+ skip_llm_setup=skip_llm_setup,+ configure_mcp=configure_mcp,+ browser_type=browser_type,+ browser_location=browser_location,+ remote_debugging_url=remote_debugging_url,+ analytics_id=analytics_id,return_result=True,)run_local = bool(init_result)@@ -321,7 +338,11 @@ def _run_server_quickstart()return- start_now = typer.confirm("\nDo you want to start Skyvern services now?", default=True)+ start_now = (+ start_services_now+ if start_services_now is not None+ else typer.confirm("\nDo you want to start Skyvern services now?", default=True)+ )if start_now:console.print("\n[bold blue]Starting Skyvern services...[/bold blue]")asyncio.run(start_services(server_only=server_only))@@ -668,12 +689,78 @@ def quickstart("--env-scope",help="Backend env location for setup writes: legacy/current, project, or global.",),+ yes: bool = typer.Option(+ False,+ "--yes",+ "-y",+ help="Automatically approve installing missing Skyvern server dependencies.",+ ),+ non_interactive: bool = typer.Option(+ False,+ "--non-interactive",+ help=(+ "Run the self-hosted server quickstart path without prompts. Installs missing server dependencies, "+ "skips LLM/MCP prompts, uses headless Chromium, anonymous analytics, and does not start services."+ ),+ ),+ skip_llm_setup: bool = typer.Option(+ False,+ "--skip-llm-setup",+ help="Skip interactive LLM provider setup and keep/default environment values.",+ ),+ skip_mcp: bool = typer.Option(False, "--skip-mcp", help="Skip interactive MCP server configuration."),+ browser_type: Literal["chromium-headful", "chromium-headless", "cdp-connect"] | None = typer.Option(+ None,+ "--browser-type",+ help="Browser type to write without prompting.",+ ),+ browser_location: str | None = typer.Option(+ None,+ "--browser-location",+ help="Chrome executable path to write when using a custom browser location.",+ ),+ remote_debugging_url: str | None = typer.Option(+ None,+ "--remote-debugging-url",+ help="CDP URL to write when using --browser-type cdp-connect.",+ ),+ analytics_id: str | None = typer.Option(+ None,+ "--analytics-id",+ help="Analytics identifier to write without prompting. Use 'anonymous' for agent tests.",+ ),+ start_services_now: bool | None = typer.Option(+ None,+ "--start/--no-start",+ help="Start Skyvern services after setup. Omit to prompt.",+ ),) -> None:"""Quickstart command to set up and run Skyvern with one command."""# Run initializationconsole.print(Panel("[bold green]π Starting Skyvern Quickstart[/bold green]", border_style="green"))install_type_value = install_type if isinstance(install_type, str) else Noneenv_scope_value = env_scope if isinstance(env_scope, str) else None+ if non_interactive:+ install_type_value = install_type_value or QuickstartPath.SERVER.value+ yes = True+ skip_llm_setup = True+ skip_mcp = True+ browser_type = browser_type or "chromium-headless"+ analytics_id = analytics_id or "anonymous"+ if start_services_now is None:+ start_services_now = False+ if not database_string:+ no_postgres = True+ console.print(+ Panel(+ "[bold yellow]Non-interactive quickstart will not prompt to start PostgreSQL.[/bold yellow]\n\n"+ "No [cyan]--database-string[/cyan] was provided, so Skyvern will use any existing "+ "[cyan]DATABASE_STRING[/cyan] from your environment or .env file.\n\n"+ "For unattended agent tests, pass "+ "[cyan]--database-string postgresql+psycopg://user:pass@host:5432/dbname[/cyan].",+ border_style="yellow",+ )+ )has_server_extra = _has_server_quickstart_extra()# The server extra is a superset of the local embedded runtime dependencies.@@ -685,6 +772,16 @@ def quickstart(server_only=server_only,)if docker_compose:+ if non_interactive:+ console.print(+ Panel(+ "[bold red]Non-interactive Docker Compose quickstart is not supported yet.[/bold red]\n"+ "Use [cyan]--install-type server --database-string postgresql+psycopg://...[/cyan] "+ "for unattended agent tests.",+ border_style="red",+ )+ )+ raise typer.Exit(1)selected_path = (QuickstartPath.SERVER if install_type_value is None else _parse_quickstart_path(install_type_value))@@ -761,7 +858,7 @@ def quickstart(return# If Docker Compose file exists, offer the choice- if docker_compose_available and check_docker() and not server_flags_requested:+ if not non_interactive and docker_compose_available and check_docker() and not server_flags_requested:console.print("\n[bold blue]Setup Method[/bold blue]")console.print("Docker Compose file detected. Choose your setup method:\n")console.print(" [cyan]1.[/cyan] [green]Docker Compose (Recommended)[/green] - Full containerized setup")@@ -777,10 +874,10 @@ def quickstart(returnif not _has_server_quickstart_extra():- if not _is_interactive_input():+ if not yes and not _is_interactive_input():_print_server_guidance()raise typer.Exit(0)- if not _install_server_extra_for_quickstart() or not _has_server_quickstart_extra():+ if not _install_server_extra_for_quickstart(assume_yes=yes) or not _has_server_quickstart_extra():raise typer.Exit(1)_run_server_quickstart(@@ -788,4 +885,11 @@ def quickstart(database_string=database_string,skip_browser_install=skip_browser_install,server_only=server_only,+ skip_llm_setup=skip_llm_setup,+ configure_mcp=False if skip_mcp else None,+ browser_type=browser_type,+ browser_location=browser_location,+ remote_debugging_url=remote_debugging_url,+ analytics_id=analytics_id,+ start_services_now=start_services_now,)diff --git a/skyvern/exceptions.py b/skyvern/exceptions.pyindex b3ab55085..131672cfc 100644--- a/skyvern/exceptions.py+++ b/skyvern/exceptions.py@@ -8,10 +8,13 @@ from typing import NoReturn# the heavy modules users commonly have partially installed._LOCAL_EXTRA_SENTINELS = ("fastapi",+ "fuzzysearch","jinja2","libcst","litellm",+ "openai","playwright",+ "psycopg","sqlalchemy","starlette","starlette_context",@@ -22,7 +25,7 @@ _LOCAL_EXTRA_SENTINELS = (# server sentinels local-compatible so those imports continue to work in# skyvern[local]. Full server entrypoints pass server-only module_names such as# "uvicorn" when they need to fail for local-only installs.-_SERVER_EXTRA_SENTINELS = tuple(_LOCAL_EXTRA_SENTINELS)+_SERVER_EXTRA_SENTINELS = tuple(dict.fromkeys((*_LOCAL_EXTRA_SENTINELS, "alembic", "anthropic")))_EXTRA_SUPPORT_LABELS = {"local": "local embedded/browser support",diff --git a/tests/unit/test_init_command.py b/tests/unit/test_init_command.pyindex 4fad7634b..a6aac409e 100644--- a/tests/unit/test_init_command.py+++ b/tests/unit/test_init_command.py@@ -1,7 +1,9 @@from __future__ import annotationsimport subprocess+from collections.abc import Callablefrom pathlib import Path+from typing import Anyimport pytest@@ -46,4 +48,58 @@ def test_run_with_server_dependency_install_installs_and_retries(monkeypatch: pyassert init_command._run_with_server_dependency_install(action) == "ok"assert calls == ["action", "action"]- assert install_calls == [["/usr/bin/python", "-m", "pip", "install", "skyvern[server]==1.2.3"]]+ assert install_calls == [+ [+ "/usr/bin/python",+ "-m",+ "pip",+ "install",+ "--retries",+ "5",+ "--timeout",+ "60",+ "skyvern[server]==1.2.3",+ ]+ ]+++def test_init_env_wraps_local_org_setup_with_server_dependency_install(+ tmp_path: Path, monkeypatch: pytest.MonkeyPatch+) -> None:+ wrapped_results: list[Any] = []++ def fake_run_with_server_dependency_install(action: Callable[[], Any]) -> Any:+ result = action()+ wrapped_results.append(result)+ return result++ async def fake_setup_local_organization() -> str:+ return "skyvern-api-key"++ env_updates: dict[str, str] = {}++ def fake_update_or_add_env_var(key: str, value: str, **_kwargs: Any) -> None:+ env_updates[key] = value++ monkeypatch.setenv(init_command.BACKEND_ENV_FILE_ENV_VAR, "")+ monkeypatch.setattr(init_command, "setup_postgresql", lambda *args, **kwargs: None)+ monkeypatch.setattr("skyvern.utils.migrate_db", lambda: None)+ monkeypatch.setattr(init_command, "_setup_local_organization_from_database", fake_setup_local_organization)+ monkeypatch.setattr(init_command, "_run_with_server_dependency_install", fake_run_with_server_dependency_install)+ monkeypatch.setattr(init_command, "update_or_add_env_var", fake_update_or_add_env_var)++ result = init_command.init_env(+ no_postgres=True,+ skip_browser_install=True,+ mode="local",+ skip_llm_setup=True,+ configure_mcp=False,+ browser_type="cdp-connect",+ analytics_id="anonymous",+ env_path=tmp_path / ".env",+ return_result=True,+ )++ assert result.run_local is True+ assert wrapped_results == [None, "skyvern-api-key"]+ assert env_updates["SKYVERN_API_KEY"] == "skyvern-api-key"diff --git a/tests/unit/test_init_mcp.py b/tests/unit/test_init_mcp.pyindex 056152d11..0054db577 100644--- a/tests/unit/test_init_mcp.py+++ b/tests/unit/test_init_mcp.py@@ -40,7 +40,7 @@ def test_init_callback_passes_plain_database_string(monkeypatch) -> None:monkeypatch.setattr("skyvern.cli.init_command.init_env",- lambda no_postgres=False, database_string="", env_scope=None: calls.append(+ lambda no_postgres=False, database_string="", env_scope=None, **kwargs: calls.append((no_postgres, database_string, env_scope)),)diff --git a/tests/unit/test_quickstart_command.py b/tests/unit/test_quickstart_command.pyindex 3c019787e..a032ae1d5 100644--- a/tests/unit/test_quickstart_command.py+++ b/tests/unit/test_quickstart_command.py@@ -479,7 +479,7 @@ def test_quickstart_server_flags_select_server_path_without_server_extra(monkeypmonkeypatch.setattr(quickstart_module,"_install_server_extra_for_quickstart",- lambda: install_calls.append("install") or True,+ lambda **kwargs: install_calls.append(kwargs) or True,)monkeypatch.setattr(quickstart_module, "_run_server_quickstart", lambda **kwargs: server_calls.append(kwargs))@@ -547,20 +547,27 @@ def test_quickstart_interactive_server_choice_can_install_server_extra(monkeypatmonkeypatch.setattr(quickstart_module,"_install_server_extra_for_quickstart",- lambda: install_calls.append("install") or True,+ lambda **kwargs: install_calls.append(kwargs) or True,)monkeypatch.setattr(quickstart_module, "_run_server_quickstart", lambda **kwargs: server_calls.append(kwargs))result = CliRunner().invoke(quickstart_module.quickstart_app, [], input="3\n")assert result.exit_code == 0- assert install_calls == ["install"]+ assert install_calls == [{"assume_yes": False}]assert server_calls == [{"no_postgres": False,"database_string": "","skip_browser_install": False,"server_only": False,+ "skip_llm_setup": False,+ "configure_mcp": None,+ "browser_type": None,+ "browser_location": None,+ "remote_debugging_url": None,+ "analytics_id": None,+ "start_services_now": None,}]@@ -721,6 +728,13 @@ def test_quickstart_with_server_extra_preserves_existing_flow(monkeypatch) -> No"database_string": "postgresql+psycopg://user/db","skip_browser_install": True,"server_only": True,+ "skip_llm_setup": False,+ "configure_mcp": None,+ "browser_type": None,+ "browser_location": None,+ "remote_debugging_url": None,+ "analytics_id": None,+ "start_services_now": None,}]diff --git a/tests/unit/test_quickstart_server_extra.py b/tests/unit/test_quickstart_server_extra.pynew file mode 100644index 000000000..a23b87dde--- /dev/null+++ b/tests/unit/test_quickstart_server_extra.py@@ -0,0 +1,103 @@+from __future__ import annotations++import subprocess++from typer.testing import CliRunner++from skyvern.cli import quickstart as quickstart_module+from skyvern.cli.quickstart import quickstart_app+++def test_install_server_extra_assume_yes_skips_prompt(monkeypatch) -> None:+ commands: list[list[str]] = []++ monkeypatch.setattr(quickstart_module, "_server_extra_install_target", lambda: "skyvern[server]==1.2.3")+ monkeypatch.setattr(+ quickstart_module.Confirm,+ "ask",+ lambda *args, **kwargs: (_ for _ in ()).throw(AssertionError("should not prompt")),+ )+ monkeypatch.setattr(+ quickstart_module.subprocess,+ "run",+ lambda command, **kwargs: commands.append(command) or subprocess.CompletedProcess(command, returncode=0),+ )++ assert quickstart_module._install_server_extra_for_quickstart(assume_yes=True) is True+ assert commands == [+ [+ quickstart_module.sys.executable,+ "-m",+ "pip",+ "install",+ "--retries",+ "5",+ "--timeout",+ "60",+ "skyvern[server]==1.2.3",+ ]+ ]+++def test_quickstart_non_interactive_server_options_skip_prompts(monkeypatch) -> None:+ calls: list[dict] = []++ def fake_init_env(**kwargs):+ calls.append(kwargs)+ return False++ monkeypatch.setattr("skyvern.cli.quickstart._has_server_quickstart_extra", lambda: True)+ monkeypatch.setattr("skyvern.cli.quickstart.check_docker_compose_file", lambda: False)+ monkeypatch.setattr("skyvern.cli.init_command.init_env", fake_init_env)+ monkeypatch.setattr(+ "skyvern.cli.quickstart.Confirm.ask",+ lambda *args, **kwargs: (_ for _ in ()).throw(AssertionError("should not prompt")),+ )++ result = CliRunner().invoke(+ quickstart_app,+ [+ "--non-interactive",+ "--skip-browser-install",+ "--database-string",+ "postgresql+psycopg://skyvern:skyvern@postgres:5432/skyvern",+ ],+ )++ assert result.exit_code == 0+ assert calls+ call = calls[0]+ assert call["no_postgres"] is False+ assert call["mode"] == "local"+ assert call["skip_llm_setup"] is True+ assert call["configure_mcp"] is False+ assert call["browser_type"] == "chromium-headless"+ assert call["analytics_id"] == "anonymous"+ assert call["return_result"] is True+++def test_quickstart_non_interactive_without_database_string_skips_postgres_prompt(monkeypatch) -> None:+ calls: list[dict] = []++ monkeypatch.setattr("skyvern.cli.quickstart._has_server_quickstart_extra", lambda: True)+ monkeypatch.setattr("skyvern.cli.quickstart.check_docker_compose_file", lambda: False)+ monkeypatch.setattr("skyvern.cli.quickstart._run_server_quickstart", lambda **kwargs: calls.append(kwargs))+ monkeypatch.setattr(+ "skyvern.cli.quickstart.Confirm.ask",+ lambda *args, **kwargs: (_ for _ in ()).throw(AssertionError("should not prompt")),+ )++ result = CliRunner().invoke(quickstart_app, ["--non-interactive"])++ assert result.exit_code == 0+ assert "Non-interactive quickstart will not prompt to start PostgreSQL" in result.output+ assert "--database-string" in result.output+ assert calls+ call = calls[0]+ assert call["no_postgres"] is True+ assert call["database_string"] == ""+ assert call["skip_llm_setup"] is True+ assert call["configure_mcp"] is False+ assert call["browser_type"] == "chromium-headless"+ assert call["analytics_id"] == "anonymous"+ assert call["start_services_now"] is False