feat: add global device queue and readiness tracking
This commit is contained in:
1 parent
a62ac4aef1
commit
42b8988661
57 files changed
+3606
-716
No files matched your search
@@ -26,6 +26,7 @@ from mcp_server.base import mcp as agent_mcp
|
||||
import mcp_server.tools # noqa: F401
|
||||
from mcp_server.utils import env_utils
|
||||
from artemis.mcp.adb_server import mcp as adb_mcp
|
||||
from artemis.runtime import shutdown_awake_service, start_awake_service
|
||||
from artemis.utils.logger import get_logger
|
||||
from rich.console import Console
|
||||
from rich.syntax import Syntax
|
||||
@@ -723,27 +724,33 @@ def mcp_command(
|
||||
console.print(syntax)
|
||||
raise typer.Exit(0)
|
||||
|
||||
st = server_type.lower()
|
||||
if st in ("agent", "mobile", "artemis", "default"):
|
||||
logger.info(f"Starting Artemis Mobile Agent MCP Server over {transport}...")
|
||||
if transport.lower() == "sse":
|
||||
agent_mcp.run(transport="sse", host=host, port=port)
|
||||
else:
|
||||
agent_mcp.run(transport="stdio")
|
||||
elif st == "adb":
|
||||
logger.info(f"Starting Artemis ADB MCP Server over {transport}...")
|
||||
if transport.lower() == "sse":
|
||||
adb_mcp.run(transport="sse", host=host, port=port)
|
||||
else:
|
||||
adb_mcp.run(transport="stdio")
|
||||
elif st == "xml":
|
||||
from artemis.mcp.xml_search_server import mcp as xml_mcp
|
||||
start_awake_service()
|
||||
try:
|
||||
st = server_type.lower()
|
||||
if st in ("agent", "mobile", "artemis", "default"):
|
||||
logger.info(f"Starting Artemis Mobile Agent MCP Server over {transport}...")
|
||||
if transport.lower() == "sse":
|
||||
agent_mcp.run(transport="sse", host=host, port=port)
|
||||
else:
|
||||
agent_mcp.run(transport="stdio")
|
||||
elif st == "adb":
|
||||
logger.info(f"Starting Artemis ADB MCP Server over {transport}...")
|
||||
if transport.lower() == "sse":
|
||||
adb_mcp.run(transport="sse", host=host, port=port)
|
||||
else:
|
||||
adb_mcp.run(transport="stdio")
|
||||
elif st == "xml":
|
||||
from artemis.mcp.xml_search_server import mcp as xml_mcp
|
||||
|
||||
logger.info(f"Starting Artemis XML Fuzzy Search MCP Server over {transport}...")
|
||||
if transport.lower() == "sse":
|
||||
xml_mcp.run(transport="sse", host=host, port=port)
|
||||
logger.info(f"Starting Artemis XML Fuzzy Search MCP Server over {transport}...")
|
||||
if transport.lower() == "sse":
|
||||
xml_mcp.run(transport="sse", host=host, port=port)
|
||||
else:
|
||||
xml_mcp.run(transport="stdio")
|
||||
else:
|
||||
xml_mcp.run(transport="stdio")
|
||||
else:
|
||||
logger.error(f"Unsupported MCP server type: {server_type}. Use 'agent', 'adb', or 'xml'.")
|
||||
raise typer.Exit(1)
|
||||
logger.error(
|
||||
f"Unsupported MCP server type: {server_type}. Use 'agent', 'adb', or 'xml'."
|
||||
)
|
||||
raise typer.Exit(1)
|
||||
finally:
|
||||
shutdown_awake_service()
|
||||
@@ -23,6 +23,7 @@ from typing import Annotated
|
||||
from adbutils import AdbClient
|
||||
from langchain_core.callbacks.base import Callbacks
|
||||
from artemis.config import initialize_llm_config, settings
|
||||
from artemis.utils.startup_progress import publish_startup_progress
|
||||
from artemis import Agent, Builders
|
||||
from artemis.sdk.types.task import AgentProfile
|
||||
from artemis.utils.cli_helpers import display_device_status
|
||||
@@ -73,6 +74,7 @@ async def execute_task(
|
||||
explorer_flash_mode: Override Explorer version mode for Flash execution profile.
|
||||
explorer_pro_mode: Override Explorer version mode for Pro execution profile.
|
||||
"""
|
||||
publish_startup_progress("configuration", "Loading the run configuration")
|
||||
llm_config = initialize_llm_config()
|
||||
agent_profile = AgentProfile(name="default", llm_config=llm_config)
|
||||
config = Builders.AgentConfig.with_default_profile(profile=agent_profile)
|
||||
@@ -117,11 +119,13 @@ async def execute_task(
|
||||
|
||||
agent: Agent | None = None
|
||||
try:
|
||||
publish_startup_progress("device_check", "Checking the Android device")
|
||||
agent = Agent(config=config.build())
|
||||
await agent.init(
|
||||
retry_count=int(os.getenv("ARTEMIS_HEALTH_RETRIES", 5)),
|
||||
retry_wait_seconds=int(os.getenv("ARTEMIS_HEALTH_DELAY", 2)),
|
||||
)
|
||||
publish_startup_progress("device_ready", "Android device connected")
|
||||
|
||||
task = agent.new_task(goal)
|
||||
if locked_app_package:
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
"""UI Launch and Web Console CLI Command (artemis ui)."""
|
||||
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import threading
|
||||
import time
|
||||
@@ -27,6 +29,13 @@ from rich.panel import Panel
|
||||
import typer
|
||||
|
||||
|
||||
def _resolve_npm_executable(platform_name: str | None = None) -> str | None:
|
||||
"""Return a directly executable npm path for the current platform."""
|
||||
platform_name = platform_name or sys.platform
|
||||
candidates = ("npm.cmd", "npm.exe", "npm") if platform_name == "win32" else ("npm",)
|
||||
return next((path for candidate in candidates if (path := shutil.which(candidate))), None)
|
||||
|
||||
|
||||
def _showcase_build_required(showcase_dir: Path) -> bool:
|
||||
"""Return whether the compiled Angular app is missing or older than its inputs."""
|
||||
base_dist = showcase_dir / "dist"
|
||||
@@ -123,16 +132,16 @@ def ui_command(
|
||||
|
||||
showcase_dir = ROOT_DIR / "apps" / "showcase_ui"
|
||||
if _showcase_build_required(showcase_dir):
|
||||
import shutil
|
||||
import subprocess
|
||||
|
||||
if shutil.which("npm"):
|
||||
npm_executable = _resolve_npm_executable()
|
||||
if npm_executable:
|
||||
console.print(
|
||||
" [yellow]🎨 Showcase UI sources changed. Compiling Angular Showcase UI...[/yellow]"
|
||||
)
|
||||
try:
|
||||
subprocess.run(["npm", "install", "--silent"], cwd=showcase_dir, check=True)
|
||||
subprocess.run(["npm", "run", "build"], cwd=showcase_dir, check=True)
|
||||
subprocess.run(
|
||||
[npm_executable, "install", "--silent"], cwd=showcase_dir, check=True
|
||||
)
|
||||
subprocess.run([npm_executable, "run", "build"], cwd=showcase_dir, check=True)
|
||||
console.print(" [green]✓ Showcase UI built successfully.[/green]\n")
|
||||
except Exception as e:
|
||||
console.print(f" [red]⚠ Failed to auto-build Showcase UI: {e}[/red]\n")
|
||||
|
||||
Reference in new issue
Block a user