dsh-scrcpy-mirror: Cast Android screen to DSH chat

Preface

When doing automation in DSH, you often need to “take a look at the phone screen”. Scrcpy itself can cast the Android screen to a PC, but it is a command-line tool: you have to remember arguments, determine whether it is USB or wireless, check the phone’s IP, and run adb tcpip again after the phone restarts. Every step can be done, but every step requires manual judgment.

The gem-gti/dsh-scrcpy-mirror project encapsulates these manual judgments into a DSH plugin, enabling models to directly launch screen projection, check status, and take screenshots via the phone_mirror tool. The following sections introduce its capabilities, installation, and usage.

What is this

This is a client-side plugin maintained by gem-gti that casts the Android phone screen to a Windows PC based on scrcpy. It does not include the client component itself; it only provides tools and commands:

  • The phone_mirror tool for models, supporting status / start / stop / connect / screenshot
  • The session command /mirror for users, which executes directly in the input box without going through the model

Platform and Host Requirements

  • Only Windows (depends on scrcpy.exe / adb.exe)
  • Host: DeepSeek Harness >=0.2.0-rc.1 <0.3.0-0
  • The local machine must have scrcpy installed, and package.json’s engines.node requires >=20

Core Features

The various actions of the phone_mirror tool:

action Description
status View scrcpy/adb paths, current gateway, whether port 5555 is open, authorized devices, and the running screen projection process
start Start screen projection: prioritize USB; if no USB is present, automatically read the gateway to go wireless
stop Terminate the screen projection process
connect Open port 5555 and connect wirelessly (must be run once after a phone restart)
screenshot Take a screenshot of the phone screen via adb exec-out screencap and return the PNG path

In addition to the tools for models, the plugin also registers a session command that can be typed directly in the input box:

/mirror              Start screen projection (equivalent to start)
/mirror stop         Stop screen projection
/mirror status       Check device and connection status
/mirror connect      Reconnect wirelessly after phone restart
/mirror screenshot   Take a screenshot of the phone screen

The commands go through Host-side ctx.commands.register, and the results are displayed as plain text in the session.

Installation and Enablement

The following commands are from the plugin README and are all in PowerShell. Choose one installation method first, then restart DSH or enable phone-mirror on the plugin page.

Local directory (development/debugging):

dsh plugin --profile desktop add "D:\path\to\dsh-scrcpy-mirror"

Local tarball:

npm pack
dsh plugin --profile desktop add ".\mu-dsh-scrcpy-mirror-0.2.0.tgz"

From npm (after publishing):

dsh plugin --profile desktop add dsh-scrcpy-mirror

Community Market: After publishing to npm and being indexed by a directory source (such as DSH 1024Store), search for Phone Mirror in DSH’s “Community Market → Installable” and click to install.

Typical Usage

After installation, just say things like “Help me check the phone screen status”, “Turn on the phone screen projection”, “The phone restarted and I can’t connect wirelessly anymore”, or “Take a screenshot of the phone screen for me” in the chat, and the model will sequentially call:

{ "action": "status" }
{ "action": "start" }
{ "action": "connect" }
{ "action": "screenshot" }

Example return for status (excerpt from README):

scrcpy: C:\Users\...\scrcpy.exe
adb: C:\Users\...\adb.exe
Gateway (Phone IP when connected to phone hotspot): 10.99.177.119
Gateway 5555 Port: Open
Devices:
  - VCJFK7WSLNS8TOEQ (USB)
  - 10.99.177.119:5555 (Wireless)
Screen Projection Process: 127224

This example itself illustrates that it infers the phone’s IP as the gateway: when connected to the phone’s hotspot, the gateway is the phone’s address.

Configuration

The config in the relevant line of cordis.patch.yml can override default values:

- insert:
    - id: phone-mirror
      name: dsh-scrcpy-mirror
      config:
        maxSize: "1280"        # Max length of the screen, larger is clearer
        bitRate: "6M"          # Video bitrate; 8M for USB, 4M~6M recommended for wireless
        audioSource: output    # output=Capture full system audio and mute phone / playback / mic
        turnScreenOff: true    # Turn off phone screen but continue projection
        alwaysOnTop: true      # Keep projection window on top
        shortcutMod: lctrl     # Shortcut modifier key: lctrl (recommended) / lalt
        adbPort: 5555
        scrcpyPath: ""         # Leave empty to automatically search in winget directory and PATH
        adbPath: ""

Prerequisites

  1. Install scrcpy on the computer:
winget install --id Genymobile.scrcpy
  1. Enable “Developer Options → USB Debugging” on the phone.
  2. Click “Allow USB Debugging” on the phone when plugging it in for the first time.
  3. For wireless projection: Connect the computer to the phone’s hotspot (or the same WiFi) and run connect once.

Implementation Details

When the plugin calls external commands (adb / ipconfig / tasklist / taskkill / scrcpy), it does not use pipes. Instead, it uses spawn + file handles to write directly to temporary files and then read them. This is because the DSH host may run the plugin tools within a restricted sandbox, where pipe-based stdio is rejected (resulting in spawn EPERM), appearing as “silent command failure” or “device never found”.

The inference of the phone’s IP address is not solely based on the IPv4 default gateway. As mentioned in the README, Xiaomi/HyperOS hotspots often only issue an IPv6 gateway. Therefore, the fallback order is: IPv4 gateway → DHCP server (the phone) → Same subnet .1.

Suitable Scenarios and Notes

Suitable for Windows developers using DSH for Android automation: allowing models to actively view the phone screen, take screenshots, or allowing users to start projection without going through the model.

Points to note:

  • Only available on Windows; taskkill / ipconfig / winget paths are implemented for Windows.
  • The plugin runs with the permissions of the current DSH process. You should check the source code and license before installing. (This project is MIT, and the projection capability comes from Apache-2.0 scrcpy. This project does not bundle its binaries; it only calls the locally installed version.)
  • After a phone restart, wireless connection will definitely fail. This is a limitation of adb and requires plugging in the USB cable and running connect once.
  • On Xiaomi/HyperOS models, scrcpy’s built-in “Turn on Screen” shortcut is often blocked by the system. The plugin does not provide wake-up functionality; you need to press the phone’s power button.
  • The projection window is scrcpy’s own window, not inside the DSH interface.
  • The README also explains one point: this plugin does not contain a client component. This is because DSH’s custom Host service requires the ./typert entry generated by the Typert compiler to be accessible via remote.xxx. A hand-written bundle lacks this artifact, causing the client injection to wait indefinitely and dragging down the entire frontend startup. Therefore, this plugin only provides tools and commands.

Conclusion

This plugin converges scrcpy’s command-line operations into one tool and one command, suitable for scenarios on Windows where the model needs to directly view/operate the Android screen. See https://www.skillhub.cn/plugins/gem-gti/dsh-scrcpy-mirror for the directory page and https://github.com/gem-gti/dsh-scrcpy-mirror for the source code.

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye