feat: extract in-process MCP action layer, concurrent task dispatch, and spawn/reconcile hardening

- Extract device action execution into artemis/mcp action layer:
  typed ActionResult, capability manifest with startup validation,
  AdbActuator as the single physical implementation, in-memory
  ActionSession (replaces stdio subprocess MCP in validator), and
  McpActionExecutor preserving the legacy executor contract.
  adb_server keeps its external stdio/SSE surface unchanged and now
  reuses the actuator implementation; import-time side effects moved
  into configure_stdio_mode().
- Capability-gated prompt assembly (prompt_assembly.py): tool enums and
  teaching segments render per available backend tools; full-set output
  is byte-identical to the previous static text (locked by tests).
- Admin console task queue: serial worker replaced by a per-device
  concurrent dispatcher (ARTEMIS_CONCURRENCY_MODE=global restores
  serial semantics), per-session cancellation, strict device binding on
  enqueue, unified stdio piping with tee to trace stdout.log, and
  shutdown cleanup of all active runs. Fix _pid_exists exception order
  so PermissionError is treated as alive.
- mcp_server reliability: spawn watchdog kills runners stuck before
  interpreter startup and releases device reservations; task state
  reconcile uses psutil liveness, prefers runner-reported pids, and
  adds a 45s startup grace to stop false failure reports on Windows;
  conversation_id is now optional end-to-end; explicit device_serial is
  validated at submission.
- CLI install now writes ~/.claude/rules/artemis.md for Claude Code and
  migrates/removes the legacy CLAUDE.md injection block; ~/.claude.json
  is never rewritten when it fails to parse.
- Tests: Windows-portable stdio lifecycle and path assertions; new
  suites for action layer, prompt assembly, spawn watchdog, and task
  reconcile (895 passed, 3 skipped).
This commit is contained in:
weilinliu55 committed 2026-08-27 18:25:27 -07:00
1 parent 60312abbb0
commit cbdca1497c
52 files changed
+5735 -1649

No files matched your search

+12 -23
View File
@@ -34,31 +34,20 @@ from artemis.utils.visualization import format_minimal_list_with_elements
async def mobile_get_device_state(view_type: str, device_serial: str | None = None) -> str:
"""Real-time mobile device state observer (for debugging and validation).
Use this tool to inspect the latest mobile status or to assist in tracking
the subagent's task progress.
Retrieves a real-time screenshot (returns local file URI) or a simplified
element tree text list of the target mobile device.
### Device Selection Modes:
1. **Direct Device Specification**: Provide `device_serial` to observe a specific
phone or emulator (e.g. `device_serial="63191FDKX00062"`).
2. **Automatic Device Selection**: Omit `device_serial` or leave it `None` to
automatically inspect the default/connected device.
**Diagnostics & User Preference**:
- When multiple devices are attached, prioritize letting the user specify or confirm the device.
- Run `adb devices` to check connected devices and identify their serial numbers.
Retrieves a real-time screenshot or a simplified UI element tree from the
target device — useful for inspecting device status or tracking a
subagent's progress.
Args:
view_type: The observation type. Supported values:
- "screenshot": Captures the real-time mobile screen and saves it to the workspace,
returning the local URI path of the image file (e.g., "file:///path/to/screenshot.jpg").
- "hierarchy": Directly returns the simplified text-labeled element list, which is
identical to what the mobile UI automation subagent sees when making decisions.
device_serial: Optional Android device serial number (e.g., "63191FDKX00062" or
"emulator-5554"). If specified, inspects state from that specific device. If omitted,
inspects the default connected device.
view_type: Observation type:
- "screenshot": captures the screen, saves it to the workspace, and
returns the image's local file URI.
- "hierarchy": returns the simplified text-labeled element list —
exactly what the automation subagent sees when making decisions.
device_serial: Optional device serial (e.g. "emulator-5554") to inspect
a specific device; omitted → the default connected device. With
several devices attached, confirm the target with the user
(`adb devices -l` lists serials).
"""
try:
controller = _get_controller(device_serial=device_serial)