feat: introduce MCP server, cross-platform runtime, and Showcase UI reorganization

- Showcase UI Reorganization:
  * Move web UI dashboard from root directory into apps/showcase_ui/ for cleaner project structure
  * Add 'artemis ui' CLI command (artemis/interfaces/cli/commands/ui.py) and launcher scripts for the interactive showcase console
- Standalone MCP Server & Notifiers (mcp_server/):
  * Implement dedicated MCP server package with mobile automation tools (device_state, inspect_trace, task_manager, task_runner)
  * Add multi-channel notifiers (AgentAPI, Desktop notifications, Webhooks, File output, and Composite routing)
  * Introduce background task runner and trace store for autonomous mobile execution monitoring
- Cross-Platform Runtime & Toolchain Support:
  * Add artemis/platform/ with OS-specific implementations for Linux, macOS (Darwin), and Windows
  * Add artemis/runtime/supervisor.py for resilient process and agent runtime supervision
  * Add artemis/toolchain/ with dependency resolution and SDK descriptors
  * Add cross-platform launcher scripts (start.sh, start.bat) and installer scripts (scripts/install_deps.*)
- Core Enhancements & Diagnostics:
  * Enhance coordinate normalization, OCR API fallback, and perception pipeline
  * Add credential validation (credentials_validator.py) and system diagnostics
  * Update bilingual documentation (README.md, README_CN.md) and architecture diagrams
- Test Suite Expansion:
  * Add integration tests for cloud gateway, remote ADB, and Artemis login
  * Add unit tests covering core diagnostics, platform detection, toolchain, credentials validator, optional OCR, and MCP tools
This commit is contained in:
somew1nd committed 2026-08-18 13:59:27 -07:00
1 parent 78e478f502
commit 9a5aaf99b7
249 files changed
+37226 -9339

No files matched your search

+34
View File
@@ -0,0 +1,34 @@
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Managed Toolchain and Binary Discovery Subsystem."""
from artemis.toolchain.descriptors import TOOLS, ToolDescriptor
from artemis.toolchain.resolver import ToolchainResolver, toolchain
find_adb = toolchain.find_adb
find_ffmpeg = toolchain.find_ffmpeg
find_scrcpy = toolchain.find_scrcpy
is_installed = toolchain.is_installed
__all__ = [
"toolchain",
"ToolchainResolver",
"ToolDescriptor",
"TOOLS",
"find_adb",
"find_ffmpeg",
"find_scrcpy",
"is_installed",
]
+86
View File
@@ -0,0 +1,86 @@
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Toolchain descriptors and metadata for cross-platform binary discovery."""
from collections.abc import Callable
from dataclasses import dataclass
def _get_embedded_adb() -> str | None:
"""Fallback to adb binary bundled with adbutils if available."""
try:
import adbutils
if hasattr(adbutils, "adb_path"):
return adbutils.adb_path()
except Exception:
pass
return None
def _get_embedded_ffmpeg() -> str | None:
"""Fallback to ffmpeg binary bundled with imageio_ffmpeg if available."""
try:
import imageio_ffmpeg
if hasattr(imageio_ffmpeg, "get_ffmpeg_exe"):
return imageio_ffmpeg.get_ffmpeg_exe()
except Exception:
pass
return None
@dataclass(frozen=True)
class ToolDescriptor:
"""Metadata and resolution strategies for an external binary/toolchain."""
name: str
binary_name: str
win_binary_name: str
sdk_relative_path: str | None = None
embedded_fallback: Callable[[], str | None] | None = None
description: str = ""
# Standard supported toolchains
TOOLS: dict[str, ToolDescriptor] = {
"adb": ToolDescriptor(
name="adb",
binary_name="adb",
win_binary_name="adb.exe",
sdk_relative_path="platform-tools/adb",
embedded_fallback=_get_embedded_adb,
description="Android Debug Bridge client",
),
"ffmpeg": ToolDescriptor(
name="ffmpeg",
binary_name="ffmpeg",
win_binary_name="ffmpeg.exe",
embedded_fallback=_get_embedded_ffmpeg,
description="FFmpeg multimedia processing framework",
),
"scrcpy": ToolDescriptor(
name="scrcpy",
binary_name="scrcpy",
win_binary_name="scrcpy.exe",
description="Screen Copy display and control tool",
),
"uv": ToolDescriptor(
name="uv",
binary_name="uv",
win_binary_name="uv.exe",
description="Fast Python package manager",
),
}
+178
View File
@@ -0,0 +1,178 @@
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Multi-tier cross-platform binary resolution and discovery engine."""
import os
from pathlib import Path
import shutil
from artemis.platform import OSType, platform
from artemis.toolchain.descriptors import TOOLS, ToolDescriptor
class ToolchainResolver:
"""Discovers, validates, and resolves platform-specific binaries with graceful fallbacks."""
def __init__(self):
self._cache: dict[str, str | None] = {}
def clear_cache(self, tool_name: str | None = None) -> None:
"""Invalidate cached tool paths to force fresh discovery."""
if tool_name:
self._cache.pop(tool_name.lower(), None)
else:
self._cache.clear()
def resolve(self, tool_name: str, force_refresh: bool = False) -> str | None:
"""Resolve absolute path to a tool across all discovery tiers."""
key = tool_name.lower()
if not force_refresh and key in self._cache:
cached_val = self._cache[key]
if cached_val is not None and Path(cached_val).exists():
return cached_val
# Cache miss or binary removed: proceed to re-discover
desc = TOOLS.get(key)
if desc is None:
# Generic binary lookup
res = shutil.which(tool_name)
if res and Path(res).exists():
self._cache[key] = str(Path(res).resolve())
return self._cache[key]
self._cache.pop(key, None)
return None
binary_name = (
desc.win_binary_name if platform.os_type == OSType.WINDOWS else desc.binary_name
)
# Tier 1: Explicit environment variable override (e.g. ARTEMIS_ADB_PATH)
env_var = f"ARTEMIS_{desc.name.upper()}_PATH"
env_override = os.getenv(env_var)
if env_override and Path(env_override).exists():
resolved = str(Path(env_override).resolve())
self._cache[key] = resolved
return resolved
# Tier 2: SDK Environment Variables (for Android tools)
if desc.sdk_relative_path:
for sdk_env in ("ANDROID_HOME", "ANDROID_SDK_ROOT"):
sdk_dir = os.getenv(sdk_env)
if sdk_dir:
candidate = Path(sdk_dir) / desc.sdk_relative_path
if platform.os_type == OSType.WINDOWS:
candidate = candidate.with_suffix(".exe")
if candidate.exists():
resolved = str(candidate.resolve())
self._cache[key] = resolved
return resolved
# Tier 3: Common OS default installation paths
common_candidates = self._get_os_common_paths(desc)
for cand in common_candidates:
if cand.exists():
resolved = str(cand.resolve())
self._cache[key] = resolved
return resolved
# Tier 4: System PATH
which_path = shutil.which(binary_name) or shutil.which(desc.name)
if which_path:
resolved = str(Path(which_path).resolve())
self._cache[key] = resolved
return resolved
# Tier 5: Python library embedded binary fallback
if desc.embedded_fallback:
try:
embedded = desc.embedded_fallback()
if embedded and Path(embedded).exists():
resolved = str(Path(embedded).resolve())
self._cache[key] = resolved
return resolved
except Exception:
pass
# Do not permanently cache negative lookups so dynamic installs are detected immediately
self._cache.pop(key, None)
return None
def _get_os_common_paths(self, desc: ToolDescriptor) -> list[Path]:
candidates: list[Path] = []
home = Path.home()
if platform.os_type == OSType.WINDOWS:
local_appdata = os.getenv("LOCALAPPDATA", "")
program_files = os.getenv("ProgramFiles", "C:\\Program Files")
program_data = os.getenv("ProgramData", "C:\\ProgramData")
if desc.name == "adb":
if local_appdata:
candidates.append(
Path(local_appdata) / "Android" / "Sdk" / "platform-tools" / "adb.exe"
)
candidates.append(Path(program_files) / "Android" / "platform-tools" / "adb.exe")
elif desc.name == "scrcpy":
candidates.append(Path(program_data) / "chocolatey" / "bin" / "scrcpy.exe")
if local_appdata:
candidates.append(
Path(local_appdata) / "Microsoft" / "WinGet" / "Links" / "scrcpy.exe"
)
elif desc.name == "ffmpeg":
candidates.append(Path(program_data) / "chocolatey" / "bin" / "ffmpeg.exe")
if local_appdata:
candidates.append(
Path(local_appdata) / "Microsoft" / "WinGet" / "Links" / "ffmpeg.exe"
)
elif platform.os_type == OSType.MACOS:
if desc.name == "adb":
candidates.append(home / "Library" / "Android" / "sdk" / "platform-tools" / "adb")
candidates.append(Path("/opt/homebrew/bin/adb"))
candidates.append(Path("/usr/local/bin/adb"))
elif desc.name in ("ffmpeg", "scrcpy"):
candidates.append(Path(f"/opt/homebrew/bin/{desc.name}"))
candidates.append(Path(f"/usr/local/bin/{desc.name}"))
elif platform.os_type == OSType.LINUX:
if desc.name == "adb":
candidates.append(home / "Android" / "Sdk" / "platform-tools" / "adb")
candidates.append(Path("/usr/lib/android-sdk/platform-tools/adb"))
candidates.append(Path("/usr/bin/adb"))
elif desc.name in ("ffmpeg", "scrcpy"):
candidates.append(Path(f"/usr/bin/{desc.name}"))
candidates.append(Path(f"/usr/local/bin/{desc.name}"))
return candidates
def find_adb(self) -> str:
"""Find ADB executable or fallback to default name."""
return self.resolve("adb") or "adb"
def find_ffmpeg(self) -> str:
"""Find FFmpeg executable or fallback to default name."""
return self.resolve("ffmpeg") or "ffmpeg"
def find_scrcpy(self) -> str:
"""Find scrcpy executable or fallback to default name."""
return self.resolve("scrcpy") or "scrcpy"
def is_installed(self, tool_name: str) -> bool:
"""Check whether a tool is found on this system."""
return self.resolve(tool_name) is not None
# Global toolchain resolver singleton
toolchain: ToolchainResolver = ToolchainResolver()