Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 83 additions & 0 deletions .github/workflows/screen-relay.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: Screen Relay desktop

on:
pull_request:
paths:
- 'packages/screen-relay/**'
- 'packages/shared/utils/**'
- '.github/workflows/screen-relay.yml'
- 'pnpm-lock.yaml'
push:
branches: [main]
paths:
- 'packages/screen-relay/**'
- 'packages/shared/utils/**'
- '.github/workflows/screen-relay.yml'
- 'pnpm-lock.yaml'
workflow_dispatch:

permissions:
contents: read

jobs:
desktop:
runs-on: ubuntu-24.04
timeout-minutes: 20
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
persist-credentials: false
- uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7
with:
node-version: '22'
cache: pnpm
- run: pnpm install --frozen-lockfile
- run: pnpm --filter @midscene/screen-relay... -r build
- name: Install the publishable tarball in a clean project
working-directory: packages/screen-relay
run: |
pnpm --dir ../shared/utils pack --pack-destination "$RUNNER_TEMP"
pnpm pack --pack-destination "$RUNNER_TEMP"
consumer="$RUNNER_TEMP/relay-consumer"
mkdir -p "$consumer"
npm install --prefix "$consumer" --no-audit --no-fund "$RUNNER_TEMP"/midscene-{robotics-shared,screen-relay}-*.tgz
cli="$consumer/node_modules/.bin/midscene-screen-relay"
"$cli" --help
echo "SCREEN_RELAY_TEST_CLI=$cli" >> "$GITHUB_ENV"
- name: Start the X11 virtual desktop
working-directory: packages/screen-relay
run: |
relay=./node_modules/.bin/screen-relay
"$relay" install --backend x11 --desktop none --yes
url=http://127.0.0.1:18080
if ! output=$(SCREEN_RELAY_RESOLUTION=1280x720 "$relay" up -d --backend x11 --desktop none --port 18080 --allow-origin "$url" --yes 2>&1); then
printf '%s\n' "$output" | sed -E 's/[[:xdigit:]]{64}/[redacted]/g' >&2
exit 1
fi
pattern='#token=([[:xdigit:]]{64})'
[[ $output =~ $pattern ]] || { echo 'Missing relay session token'; exit 1; }
token=${BASH_REMATCH[1]}
echo "::add-mask::$token"
echo "MIDSCENE_SCREEN_RELAY_URL=$url/#token=$token" >> "$GITHUB_ENV"
- name: Test desktop actions and configured visual model
run: pnpm --filter @midscene/screen-relay test:desktop
env:
# Ark IPv4 connections from GitHub runners can take longer than Node's default 250 ms.
NODE_OPTIONS: ${{ env.NODE_OPTIONS }} --network-family-autoselection-attempt-timeout=2000
MIDSCENE_RUN_DIR: ${{ runner.temp }}/midscene_run
MIDSCENE_MODEL_API_KEY: ${{ (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) && secrets.MIDSCENE_MODEL_API_KEY || '' }}
MIDSCENE_MODEL_BASE_URL: ${{ (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) && secrets.MIDSCENE_MODEL_BASE_URL || '' }}
MIDSCENE_MODEL_NAME: ${{ (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) && secrets.MIDSCENE_MODEL_NAME || '' }}
MIDSCENE_MODEL_FAMILY: ${{ (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) && secrets.MIDSCENE_MODEL_FAMILY || '' }}
- name: Upload AI report
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: screen-relay-ai-report
path: ${{ runner.temp }}/midscene_run/report/*.html
if-no-files-found: ignore
retention-days: 7
- name: Stop desktop
if: always()
run: pnpm --filter @midscene/screen-relay exec screen-relay down
1 change: 1 addition & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# AGENTS.md

- Use the Node.js and pnpm versions specified in the root `package.json`. See [CONTRIBUTING.md](./CONTRIBUTING.md) for development commands and package boundaries.
- Use Rslib to build new workspace packages and Rstest to run their tests.
- Build affected workspace packages and their dependencies before running tests. Tests consume compiled output.
- Keep tests minimal and focused on observable behavior. Avoid redundant coverage, assertions tied to implementation details, and unnecessary complexity.
- Follow [.github/pull_request_template.md](./.github/pull_request_template.md) when drafting PR descriptions, and verify each applicable checklist item before checking it off.
Expand Down
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Automate physical touchscreens (car cockpits, industrial panels) via a robotic a
</tr>
<tr>
<td><video src="https://github.com/user-attachments/assets/a8946f0f-245d-48aa-832e-8d77eb700bca" controls width="100%"></video></td>
<td><video src="https://github.com/user-attachments/assets/e1457d75-d693-40b7-b478-d3f49108a1a6" controls width="100%"></video></td>
<td><video src="https://github.com/user-attachments/assets/d7a7594c-bd23-4354-a762-d6f727ecc6ef" controls width="100%"></video></td>
</tr>
</table>

Expand Down Expand Up @@ -77,6 +77,16 @@ With [esp32-iphone-agent](https://github.com/onehumanbeing/esp32-iphone-agent),

[Set up the board and run your first test →](./packages/ios-esp32/README.md)

### 🖥️ Screen Relay × Remote Desktop

Midscene Connect uses [screen-relay](https://github.com/vercel-labs/screen-relay) to control local, remote, or virtual desktops across Windows, macOS, and Linux. In this demo on a remote Windows desktop, the agent creates `README.txt`, writes a URL in Notepad, then checks the filename and the full URL.

<table align="center">
<tr><td width="480"><video src="https://github.com/user-attachments/assets/e2c4ab5f-9780-46f4-a8e1-8480e5669d1d" controls width="100%"></video></td></tr>
</table>

[Connect a remote desktop and run your first test →](./packages/screen-relay/README.md)

### 🤝 Showcase your solution

We warmly welcome community contributions of successful integrations across different devices and scenarios! If you have built an alternative hardware solution, connectivity protocol, or unique platform practice, feel free to [open an issue](https://github.com/web-infra-dev/midscene-test-everything/issues/new) to let us know. We would love to feature and link your project right here for the community to see.
Expand Down Expand Up @@ -168,6 +178,7 @@ iOS AirLink and the MG400 service host many devices. Each one is at `http://<hos
| --- | --- |
| [`mg400-service`](./packages/robot-arm/mg400-service/README.md) | DOBOT MG400 device service, including setup, calibration, and touchscreen control |
| [`arm-kit`](./packages/robot-arm/arm-kit/README.md) | Adapter API for integrating custom robot arms |
| [`screen-relay`](./packages/screen-relay/README.md) | Connect a local, remote, or virtual desktop to Midscene Connect |
| [`ios-airlink`](./packages/ios-airlink/README.md) | Connect to and control physical iPhones from macOS |
| [`ios-esp32`](./packages/ios-esp32/README.md) | Run Midscene E2E tests on real iPhones via an `esp32-iphone-agent` board |
| [`robotics-vision`](./packages/shared/vision/README.md) | Cross-platform camera capture, ArUco screen calibration, and perspective correction |
Expand All @@ -181,6 +192,7 @@ See the [contributing guide](./CONTRIBUTING.md) for local setup and development
- Special thanks to our community contributor, the [AVATR Robotic team](https://www.avatr.com), who spearheaded the development of the core architecture, camera calibration, and motion control for this physical testing solution, thoroughly validating it in real-world automotive cockpit scenarios.
- [iphone-use](https://github.com/xhoantran/iphone-use) is the source of parts of the Bluetooth HID descriptors used in iOS AirLink.
- The open-source [esp32-iphone-agent](https://github.com/onehumanbeing/esp32-iphone-agent) project provides all the low-level device capabilities in `ios-esp32`, including screen capture and Bluetooth HID control.
- [screen-relay](https://github.com/vercel-labs/screen-relay) provides the desktop screen capture and mouse/keyboard input backend used by `@midscene/screen-relay`.

## 📖 License

Expand Down
16 changes: 14 additions & 2 deletions README.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
</tr>
<tr>
<td><video src="https://github.com/user-attachments/assets/a8946f0f-245d-48aa-832e-8d77eb700bca" controls width="100%"></video></td>
<td><video src="https://github.com/user-attachments/assets/92ce9e69-ada6-46c3-a8f4-dba8d3b7a4ed" controls width="100%"></video></td>
<td><video src="https://github.com/user-attachments/assets/75f45f0e-daa9-464e-bfba-c68b09762d2e" controls width="100%"></video></td>
</tr>
</table>

Expand Down Expand Up @@ -75,6 +75,16 @@

[配置开发板并运行第一个测试 →](./packages/ios-esp32/README.zh.md)

### 🖥️ Screen Relay × 远程桌面

Midscene Connect 通过 [screen-relay](https://github.com/vercel-labs/screen-relay) 操作 Windows、macOS 或 Linux 上的本机、远程与虚拟桌面。在这个远程 Windows 桌面演示中,Agent 新建 `README.txt`,在记事本里写入网址,再核对文件名和完整网址。

<table align="center">
<tr><td width="480"><video src="https://github.com/user-attachments/assets/e2c4ab5f-9780-46f4-a8e1-8480e5669d1d" controls width="100%"></video></td></tr>
</table>

[连接远程桌面并运行第一个测试 →](./packages/screen-relay/README.zh.md)

### 🤝 欢迎贡献你的成功案例

我们非常欢迎社区贡献更多不同设备与场景的成功接入实践!如果你有其他优秀的硬件方案、连接协议或独特平台的实战经验,欢迎[提交 Issue](https://github.com/web-infra-dev/midscene-test-everything/issues/new) 告诉我们。我们会把你的方案链接展示在这个版块,让更多开发者看到你的精彩实践。
Expand Down Expand Up @@ -164,7 +174,8 @@ iOS AirLink 与 MG400 服务会同时托管多台设备,每台设备的地址
| --- | --- |
| [`mg400-service`](./packages/robot-arm/mg400-service/README.zh.md) | DOBOT MG400 设备服务,提供配置、校准和触屏操作 |
| [`arm-kit`](./packages/robot-arm/arm-kit/README.zh.md) | 机械臂适配器接口,可用于接入自定义机械臂 |
| [`ios-airlink`](./packages/ios-airlink/README.md) | 在 macOS 上连接和控制 iPhone 真机 |
| [`screen-relay`](./packages/screen-relay/README.zh.md) | 通过 Midscene Connect 操作本机、远程或虚拟桌面 |
| [`ios-airlink`](./packages/ios-airlink/README.zh.md) | 在 macOS 上连接和控制 iPhone 真机 |
| [`ios-esp32`](./packages/ios-esp32/README.zh.md) | 基于 `esp32-iphone-agent` 硬件板子在 iPhone 真机上运行 Midscene E2E 测试 |
| [`robotics-vision`](./packages/shared/vision/README.zh.md) | 跨平台摄像头采集、ArUco 屏幕标定与透视校正 |

Expand All @@ -177,6 +188,7 @@ iOS AirLink 与 MG400 服务会同时托管多台设备,每台设备的地址
- 特别感谢来自社区的贡献者 [阿维塔科技 Robotic 团队](https://www.avatr.com):主导研发了机械臂物理触屏自动化方案的核心架构、相机标定与运动控制能力,并在真实车载座舱测试场景中完成了全面落地验证。
- iOS AirLink 的部分蓝牙 HID 描述符改编自 [iphone-use](https://github.com/xhoantran/iphone-use)。
- `ios-esp32` 的底层设备能力,包括屏幕采集与蓝牙 HID 控制,均来自开源项目 [esp32-iphone-agent](https://github.com/onehumanbeing/esp32-iphone-agent)。
- `@midscene/screen-relay` 的底层桌面截图与键鼠控制能力来自开源项目 [screen-relay](https://github.com/vercel-labs/screen-relay)。

## 📖 许可证

Expand Down
2 changes: 1 addition & 1 deletion packages/ios-esp32/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
"dependencies": {
"@clack/prompts": "^0.11.0",
"@midscene/connect": "1.19.0",
"@midscene/robotics-shared": "workspace:*",
"chalk": "5.6.2",
"commander": "13.1.0",
"execa": "8.0.1"
},
"devDependencies": {
Expand Down
69 changes: 15 additions & 54 deletions packages/ios-esp32/src/commands.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,28 @@
#!/usr/bin/env node
import { serveDevice } from '@midscene/connect/server';
import chalk, { chalkStderr } from 'chalk';
import { Command } from 'commander';
import {
createConnectCommand,
reportCliError,
serveConnectCli,
} from '@midscene/robotics-shared/connect-cli';
import chalk from 'chalk';
import esp32Device from './device.js';
import { getBoardIdentity, resolveDevice } from './esp32agent.js';

async function main() {
const values = new Command()
.name('ios-esp32')
.description('Connect an iPhone to Midscene through an ESP32 board')
const values = createConnectCommand(
'ios-esp32',
'Connect an iPhone to Midscene through an ESP32 board',
)
.option(
'--device <id>',
'Board ID (also ESP32AGENT_DEVICE); omit to discover boards',
)
.option('--host <host>', 'Listen address', '127.0.0.1')
.option('--port <port>', 'Listen port', Number, 5820)
.option(
'--token <token>',
'Bearer token for API access (generated automatically on non-loopback hosts)',
)
.option(
'--stale-retry-ms <ms>',
'Additional screenshot retry time in milliseconds',
Number,
10_000,
)
.allowExcessArguments(false)
.parse()
.opts<{
device?: string;
Expand All @@ -35,48 +32,16 @@ async function main() {
staleRetryMs: number;
}>();

if (values.token !== undefined && !values.token.trim()) {
throw new Error('Token must not be empty.');
}

const board = await resolveDevice(values.device);

const served = await serveDevice(esp32Device, {
await serveConnectCli(esp32Device, {
host: values.host,
port: values.port,
token: values.token,
options: { device: board.id, staleRetryMs: values.staleRetryMs },
});

const { url, token } = served;

const stop = () => {
served.close().finally(() => process.exit(0));
};
process.once('SIGINT', stop);
process.once('SIGTERM', stop);

const interactive = process.stdout.isTTY;
const row = (label: string, value: string) =>
` ${chalk.dim(label.padEnd(9))}${value}`;

if (interactive) {
console.log(
`\n ${chalk.bold('Midscene Connect')}\n ${chalk.bold.cyan(url)}\n`,
);
console.log(row('Docs', chalk.underline(`${url}/api/docs/`)));
console.log(
row(
'Token',
token ? chalk.yellow(token) : chalk.dim('Not required on localhost'),
),
);
} else {
console.log(`Connect URL: ${url}`);
console.log(`API docs: ${url}/api/docs/`);
console.log(`Connect token: ${token ?? 'not required (loopback)'}`);
}

const info = board.name
? board
: await getBoardIdentity(board.id).catch(() => undefined);
Expand All @@ -85,14 +50,10 @@ async function main() {
.filter(Boolean)
.join(interactive ? chalk.dim(' · ') : ' · ');
console.log(
interactive ? `\n${row('Device', identity)}\n` : `Device: ${identity}`,
interactive
? `\n ${chalk.dim('Device ')}${identity}\n`
: `Device: ${identity}`,
);
}

main().catch((error: unknown) => {
const message = error instanceof Error ? error.message : String(error);
console.error(
message.replace(/`[^`\n]+`/g, (command) => chalkStderr.cyan(command)),
);
process.exitCode = 1;
});
main().catch(reportCliError);
Loading
Loading