@beeos-ai/device-mcp-server 0.5.2 → 0.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/BeeosUiDump.java +81 -0
- package/android/README.md +31 -0
- package/android/build-helper.sh +13 -0
- package/assets/beeos-ui-dump.jar +0 -0
- package/dist/backends/android-adb.d.ts +7 -0
- package/dist/backends/android-adb.js +101 -9
- package/dist/backends/android-adb.js.map +1 -1
- package/dist/backends/base.d.ts +2 -0
- package/dist/backends/base.js.map +1 -1
- package/dist/backends/index.d.ts +4 -57
- package/dist/backends/index.js +8 -100
- package/dist/backends/index.js.map +1 -1
- package/dist/cli.d.ts +4 -13
- package/dist/cli.js +7 -55
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/server/tool-registry.d.ts +1 -0
- package/dist/server/tool-registry.js +47 -13
- package/dist/server/tool-registry.js.map +1 -1
- package/dist/util/android-apps.js +2 -1
- package/dist/util/android-apps.js.map +1 -1
- package/package.json +6 -4
- package/dist/backends/desktop.d.ts +0 -63
- package/dist/backends/desktop.js +0 -182
- package/dist/backends/desktop.js.map +0 -1
- package/dist/backends/linux.d.ts +0 -69
- package/dist/backends/linux.js +0 -233
- package/dist/backends/linux.js.map +0 -1
- package/dist/backends/mac.d.ts +0 -163
- package/dist/backends/mac.js +0 -919
- package/dist/backends/mac.js.map +0 -1
- package/dist/backends/stubs/ios.d.ts +0 -17
- package/dist/backends/stubs/ios.js +0 -32
- package/dist/backends/stubs/ios.js.map +0 -1
- package/dist/backends/stubs/windows.d.ts +0 -69
- package/dist/backends/stubs/windows.js +0 -194
- package/dist/backends/stubs/windows.js.map +0 -1
package/dist/backends/base.d.ts
CHANGED
|
@@ -162,6 +162,8 @@ export interface SandboxBackend {
|
|
|
162
162
|
doubleClick(x: number, y: number): Promise<void>;
|
|
163
163
|
rightClick(x: number, y: number): Promise<void>;
|
|
164
164
|
tap(x: number, y: number): Promise<void>;
|
|
165
|
+
/** Internal sequence primitive; the caller owns pacing, bounds and the device lease. */
|
|
166
|
+
tapForSequence?(x: number, y: number): Promise<void>;
|
|
165
167
|
longPress(x: number, y: number, durationMs?: number): Promise<void>;
|
|
166
168
|
drag(x1: number, y1: number, x2: number, y2: number, durationMs?: number): Promise<void>;
|
|
167
169
|
swipe(x1: number, y1: number, x2: number, y2: number, durationMs?: number): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../src/backends/base.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAqBH,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAwB7C;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,yBAAyB,CACvC,GAA0C;IAE1C,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,KAAK,IAAI;QAAE,OAAO,EAAE,CAAC;IACjD,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC;IACtD,OAAO,GAAG,CAAC;AACb,CAAC;
|
|
1
|
+
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../src/backends/base.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAqBH,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAwB7C;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,yBAAyB,CACvC,GAA0C;IAE1C,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,KAAK,IAAI;QAAE,OAAO,EAAE,CAAC;IACjD,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,C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WAAW,CAAC,oBAAoB,CAAC,CAAC;IAChD,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,cAAc,CAClB,SAAiB,EACjB,IAAwB;QAExB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QACzC,MAAM,SAAS,CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;QACtC,OAAO;YACL,IAAI,EAAE,SAAS;YACf,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM;YACvB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,MAAM,EAAE,IAAI,CAAC,MAAM;SACpB,CAAC;IACJ,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,eAAe;QACnB,OAAO,CAAC,CAAC;IACX,CAAC;IAED;;;OAGG;IACO,WAAW,CAAY,IAAY;QAC3C,OAAO,OAAO,CAAC,MAAM,CACnB,IAAI,WAAW,CAAC,SAAS,IAAI,kCAAkC,IAAI,CAAC,EAAE,GAAG,EAAE;YACzE,OAAO,EAAE,aAAa;YACtB,SAAS,EAAE,KAAK;SACjB,CAAC,CACH,CAAC;IACJ,CAAC;CACF"}
|
package/dist/backends/index.d.ts
CHANGED
|
@@ -1,63 +1,10 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Backend registry — string → backend factory.
|
|
3
|
-
*
|
|
4
|
-
* Used by the CLI (`device-mcp-server --backend android ...`) and
|
|
5
|
-
* `server/app.ts` to resolve a `SandboxBackend` from configuration.
|
|
6
|
-
*
|
|
7
|
-
* **Naming convention** (after the self-hosted plan §3.4 "去掉 backend
|
|
8
|
-
* 私有词"):
|
|
9
|
-
*
|
|
10
|
-
* Canonical short name (CLI surface) Aliases (back-compat / verbose)
|
|
11
|
-
* --------------------------------- --------------------------------------
|
|
12
|
-
* adb → AndroidAdbBackend "android"
|
|
13
|
-
* macos → MacOsBackend "mac", "desktop-macos"
|
|
14
|
-
* linux → LinuxBackend "desktop-linux" (used to be the mock —
|
|
15
|
-
* now resolves to the real native
|
|
16
|
-
* LinuxBackend; the in-memory mock is
|
|
17
|
-
* still reachable via "mock-desktop"
|
|
18
|
-
* and is used by integration tests)
|
|
19
|
-
* windows → WindowsBackend "win", "desktop-windows"
|
|
20
|
-
* ios → IosBackend (zero caps stub, reserved for WDA / libimobiledevice)
|
|
21
|
-
*
|
|
22
|
-
* desktop "smart-resolve": MacOsBackend on darwin,
|
|
23
|
-
* LinuxBackend on linux, WindowsBackend
|
|
24
|
-
* on win32, mock elsewhere.
|
|
25
|
-
*
|
|
26
|
-
* mock-desktop DesktopBackend (in-memory, for tests
|
|
27
|
-
* — never picks itself in `desktop`).
|
|
28
|
-
*/
|
|
29
|
-
import type { BackendFamily, BackendOs, SandboxBackend } from "./base.js";
|
|
30
1
|
import { AndroidAdbBackend, type AndroidAdbBackendOptions } from "./android-adb.js";
|
|
31
|
-
import {
|
|
32
|
-
|
|
33
|
-
import { MacOsBackend, type MacOsBackendOptions } from "./mac.js";
|
|
34
|
-
import { WindowsBackend, type WindowsBackendOptions } from "./stubs/windows.js";
|
|
35
|
-
import { IosBackend } from "./stubs/ios.js";
|
|
36
|
-
/**
|
|
37
|
-
* Public CLI surface — what `--backend` accepts. Intentionally narrow:
|
|
38
|
-
* the four short names from the plan (`adb`, `macos`, `linux`,
|
|
39
|
-
* `windows`) plus `desktop` for "smart-resolve to my OS" and a small
|
|
40
|
-
* back-compat alias set so existing devices.json entries written by
|
|
41
|
-
* older CLI versions still work.
|
|
42
|
-
*/
|
|
43
|
-
export type BackendName = "adb" | "macos" | "linux" | "windows" | "desktop" | "android" | "mac" | "win" | "desktop-linux" | "desktop-windows" | "desktop-macos" | "mock-desktop" | "ios";
|
|
2
|
+
import type { SandboxBackend, BackendFamily, BackendOs } from "./base.js";
|
|
3
|
+
export type BackendName = "adb" | "android";
|
|
44
4
|
export interface CreateBackendOptions {
|
|
45
5
|
android?: AndroidAdbBackendOptions;
|
|
46
|
-
desktop?: DesktopBackendOptions;
|
|
47
|
-
macos?: MacOsBackendOptions;
|
|
48
|
-
linux?: LinuxBackendOptions;
|
|
49
|
-
windows?: WindowsBackendOptions;
|
|
50
6
|
}
|
|
51
|
-
/**
|
|
52
|
-
* Resolve any of the canonical / alias / smart-resolve names to a real
|
|
53
|
-
* backend instance. Aliases collapse early so the rest of the codebase
|
|
54
|
-
* only ever sees the canonical name when building options.
|
|
55
|
-
*/
|
|
56
7
|
export declare function createBackend(name: BackendName, opts?: CreateBackendOptions): SandboxBackend;
|
|
57
|
-
/**
|
|
58
|
-
* `--backend` autocomplete / `--help` source. Lists canonical names
|
|
59
|
-
* first, then aliases, so help output reads top-down most-useful.
|
|
60
|
-
*/
|
|
61
8
|
export declare const SUPPORTED_BACKENDS: BackendName[];
|
|
62
|
-
export
|
|
63
|
-
export {
|
|
9
|
+
export { AndroidAdbBackend };
|
|
10
|
+
export type { AndroidAdbBackendOptions, SandboxBackend, BackendFamily, BackendOs };
|
package/dist/backends/index.js
CHANGED
|
@@ -1,105 +1,13 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Backend registry — string → backend factory.
|
|
3
|
-
*
|
|
4
|
-
* Used by the CLI (`device-mcp-server --backend android ...`) and
|
|
5
|
-
* `server/app.ts` to resolve a `SandboxBackend` from configuration.
|
|
6
|
-
*
|
|
7
|
-
* **Naming convention** (after the self-hosted plan §3.4 "去掉 backend
|
|
8
|
-
* 私有词"):
|
|
9
|
-
*
|
|
10
|
-
* Canonical short name (CLI surface) Aliases (back-compat / verbose)
|
|
11
|
-
* --------------------------------- --------------------------------------
|
|
12
|
-
* adb → AndroidAdbBackend "android"
|
|
13
|
-
* macos → MacOsBackend "mac", "desktop-macos"
|
|
14
|
-
* linux → LinuxBackend "desktop-linux" (used to be the mock —
|
|
15
|
-
* now resolves to the real native
|
|
16
|
-
* LinuxBackend; the in-memory mock is
|
|
17
|
-
* still reachable via "mock-desktop"
|
|
18
|
-
* and is used by integration tests)
|
|
19
|
-
* windows → WindowsBackend "win", "desktop-windows"
|
|
20
|
-
* ios → IosBackend (zero caps stub, reserved for WDA / libimobiledevice)
|
|
21
|
-
*
|
|
22
|
-
* desktop "smart-resolve": MacOsBackend on darwin,
|
|
23
|
-
* LinuxBackend on linux, WindowsBackend
|
|
24
|
-
* on win32, mock elsewhere.
|
|
25
|
-
*
|
|
26
|
-
* mock-desktop DesktopBackend (in-memory, for tests
|
|
27
|
-
* — never picks itself in `desktop`).
|
|
28
|
-
*/
|
|
1
|
+
/** Android-only runtime. Unsupported hosts fail explicitly rather than selecting a mock. */
|
|
29
2
|
import { DeviceError } from "@beeos-ai/device-common";
|
|
30
3
|
import { AndroidAdbBackend } from "./android-adb.js";
|
|
31
|
-
import { DesktopBackend } from "./desktop.js";
|
|
32
|
-
import { LinuxBackend } from "./linux.js";
|
|
33
|
-
import { MacOsBackend } from "./mac.js";
|
|
34
|
-
import { WindowsBackend } from "./stubs/windows.js";
|
|
35
|
-
import { IosBackend } from "./stubs/ios.js";
|
|
36
|
-
/**
|
|
37
|
-
* Resolve any of the canonical / alias / smart-resolve names to a real
|
|
38
|
-
* backend instance. Aliases collapse early so the rest of the codebase
|
|
39
|
-
* only ever sees the canonical name when building options.
|
|
40
|
-
*/
|
|
41
4
|
export function createBackend(name, opts = {}) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
/* — macOS — */
|
|
48
|
-
case "macos":
|
|
49
|
-
case "mac":
|
|
50
|
-
case "desktop-macos":
|
|
51
|
-
return new MacOsBackend(opts.macos);
|
|
52
|
-
/* — Linux (real native, gnome-screenshot/scrot/import + /bin/sh) — */
|
|
53
|
-
case "linux":
|
|
54
|
-
case "desktop-linux":
|
|
55
|
-
return new LinuxBackend(opts.linux);
|
|
56
|
-
/* — Windows (real native, PowerShell + cmd.exe) — */
|
|
57
|
-
case "windows":
|
|
58
|
-
case "win":
|
|
59
|
-
case "desktop-windows":
|
|
60
|
-
return new WindowsBackend(opts.windows);
|
|
61
|
-
/* — Smart-resolve — */
|
|
62
|
-
case "desktop":
|
|
63
|
-
if (process.platform === "darwin")
|
|
64
|
-
return new MacOsBackend(opts.macos);
|
|
65
|
-
if (process.platform === "linux")
|
|
66
|
-
return new LinuxBackend(opts.linux);
|
|
67
|
-
if (process.platform === "win32")
|
|
68
|
-
return new WindowsBackend(opts.windows);
|
|
69
|
-
// Anything exotic falls back to the mock so the agent main loop
|
|
70
|
-
// still boots in unusual sandboxes / CI runners.
|
|
71
|
-
return new DesktopBackend({ ...opts.desktop, os: "desktop-linux" });
|
|
72
|
-
/* — Explicit in-memory mock for tests — */
|
|
73
|
-
case "mock-desktop":
|
|
74
|
-
return new DesktopBackend({ ...opts.desktop, os: "desktop-linux" });
|
|
75
|
-
/* — Reserved stub — */
|
|
76
|
-
case "ios":
|
|
77
|
-
return new IosBackend();
|
|
78
|
-
default:
|
|
79
|
-
throw new DeviceError(`unknown backend '${name}'`, {
|
|
80
|
-
subtype: "unsupported",
|
|
81
|
-
retriable: false,
|
|
82
|
-
});
|
|
83
|
-
}
|
|
5
|
+
if (name === "adb" || name === "android")
|
|
6
|
+
return new AndroidAdbBackend(opts.android);
|
|
7
|
+
throw new DeviceError(`Unsupported backend '${name}': this package supports Android only`, {
|
|
8
|
+
subtype: "unsupported", retriable: false,
|
|
9
|
+
});
|
|
84
10
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
* first, then aliases, so help output reads top-down most-useful.
|
|
88
|
-
*/
|
|
89
|
-
export const SUPPORTED_BACKENDS = [
|
|
90
|
-
"adb",
|
|
91
|
-
"macos",
|
|
92
|
-
"linux",
|
|
93
|
-
"windows",
|
|
94
|
-
"desktop",
|
|
95
|
-
"android",
|
|
96
|
-
"mac",
|
|
97
|
-
"win",
|
|
98
|
-
"desktop-linux",
|
|
99
|
-
"desktop-windows",
|
|
100
|
-
"desktop-macos",
|
|
101
|
-
"mock-desktop",
|
|
102
|
-
"ios",
|
|
103
|
-
];
|
|
104
|
-
export { AndroidAdbBackend, DesktopBackend, LinuxBackend, MacOsBackend, WindowsBackend, IosBackend, };
|
|
11
|
+
export const SUPPORTED_BACKENDS = ["adb", "android"];
|
|
12
|
+
export { AndroidAdbBackend };
|
|
105
13
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/backends/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/backends/index.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAiC,MAAM,kBAAkB,CAAC;AAIpF,MAAM,UAAU,aAAa,CAAC,IAAiB,EAAE,OAA6B,EAAE;IAC9E,IAAI,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,IAAI,iBAAiB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACrF,MAAM,IAAI,WAAW,CAAC,wBAAwB,IAAI,uCAAuC,EAAE;QACzF,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,KAAK;KACzC,CAAC,CAAC;AACL,CAAC;AACD,MAAM,CAAC,MAAM,kBAAkB,GAAkB,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
|
package/dist/cli.d.ts
CHANGED
|
@@ -16,36 +16,27 @@
|
|
|
16
16
|
*
|
|
17
17
|
* Examples:
|
|
18
18
|
* # HTTP loopback for `device-agent` siblings
|
|
19
|
-
* device-mcp-server --backend
|
|
19
|
+
* device-mcp-server --backend adb --port 7900
|
|
20
20
|
*
|
|
21
21
|
* # IDE / Cursor stdio entry — JSON-RPC on stdin/stdout, logs on stderr
|
|
22
|
-
* device-mcp-server --backend
|
|
22
|
+
* device-mcp-server --backend adb --stdio
|
|
23
23
|
*
|
|
24
24
|
* # Android farm — server discovers every adb device and exposes them
|
|
25
25
|
* # as separate `device` ids. Pass `device: <serial>` per tool call.
|
|
26
26
|
* device-mcp-server --backend adb --port 7900
|
|
27
27
|
*
|
|
28
28
|
* Env overrides:
|
|
29
|
-
* DEVICEAGENT_BACKEND=adb|
|
|
29
|
+
* DEVICEAGENT_BACKEND=adb|android
|
|
30
30
|
* ADB_DEFAULT_TIMEOUT_MS per-call adb command timeout (ms)
|
|
31
31
|
* ADB_SHELL_TIMEOUT_MS adb shell timeout (ms)
|
|
32
32
|
* ADB_SCREENSHOT_TIMEOUT_MS adb exec-out screencap timeout (ms)
|
|
33
33
|
* ADB_INSTALL_TIMEOUT_MS adb install timeout (ms)
|
|
34
|
-
* MAC_CLICLICK_PATH override autodetected cliclick path
|
|
35
34
|
* MCP_HOST HTTP bind address (default 127.0.0.1)
|
|
36
35
|
* MCP_PORT HTTP listen port (default 7900)
|
|
37
36
|
* DEVICE_MCP_POLL_MS adb-discovery poll interval (default 10000)
|
|
38
37
|
* GUI_AGENT_SS_MAX_EDGE screenshot resize cap (default 1280)
|
|
39
38
|
* GUI_AGENT_SS_JPEG_QUALITY screenshot JPEG quality (default 80)
|
|
40
39
|
*
|
|
41
|
-
* macOS
|
|
42
|
-
* - The `macos` backend (and `desktop` on a darwin host) drives the
|
|
43
|
-
* real local Mac via cliclick + osascript + screencapture. The host
|
|
44
|
-
* process MUST hold Accessibility permission (System Settings →
|
|
45
|
-
* Privacy & Security → Accessibility) for synthetic input to take
|
|
46
|
-
* effect.
|
|
47
|
-
* - cliclick is auto-detected on PATH; install via `brew install
|
|
48
|
-
* cliclick` for the smoothest pointer ergonomics. Without it the
|
|
49
|
-
* backend falls back to JXA + Quartz CGEvent.
|
|
40
|
+
* The host may run macOS, Linux or Windows; controlled devices are Android only.
|
|
50
41
|
*/
|
|
51
42
|
export {};
|
package/dist/cli.js
CHANGED
|
@@ -16,41 +16,32 @@
|
|
|
16
16
|
*
|
|
17
17
|
* Examples:
|
|
18
18
|
* # HTTP loopback for `device-agent` siblings
|
|
19
|
-
* device-mcp-server --backend
|
|
19
|
+
* device-mcp-server --backend adb --port 7900
|
|
20
20
|
*
|
|
21
21
|
* # IDE / Cursor stdio entry — JSON-RPC on stdin/stdout, logs on stderr
|
|
22
|
-
* device-mcp-server --backend
|
|
22
|
+
* device-mcp-server --backend adb --stdio
|
|
23
23
|
*
|
|
24
24
|
* # Android farm — server discovers every adb device and exposes them
|
|
25
25
|
* # as separate `device` ids. Pass `device: <serial>` per tool call.
|
|
26
26
|
* device-mcp-server --backend adb --port 7900
|
|
27
27
|
*
|
|
28
28
|
* Env overrides:
|
|
29
|
-
* DEVICEAGENT_BACKEND=adb|
|
|
29
|
+
* DEVICEAGENT_BACKEND=adb|android
|
|
30
30
|
* ADB_DEFAULT_TIMEOUT_MS per-call adb command timeout (ms)
|
|
31
31
|
* ADB_SHELL_TIMEOUT_MS adb shell timeout (ms)
|
|
32
32
|
* ADB_SCREENSHOT_TIMEOUT_MS adb exec-out screencap timeout (ms)
|
|
33
33
|
* ADB_INSTALL_TIMEOUT_MS adb install timeout (ms)
|
|
34
|
-
* MAC_CLICLICK_PATH override autodetected cliclick path
|
|
35
34
|
* MCP_HOST HTTP bind address (default 127.0.0.1)
|
|
36
35
|
* MCP_PORT HTTP listen port (default 7900)
|
|
37
36
|
* DEVICE_MCP_POLL_MS adb-discovery poll interval (default 10000)
|
|
38
37
|
* GUI_AGENT_SS_MAX_EDGE screenshot resize cap (default 1280)
|
|
39
38
|
* GUI_AGENT_SS_JPEG_QUALITY screenshot JPEG quality (default 80)
|
|
40
39
|
*
|
|
41
|
-
* macOS
|
|
42
|
-
* - The `macos` backend (and `desktop` on a darwin host) drives the
|
|
43
|
-
* real local Mac via cliclick + osascript + screencapture. The host
|
|
44
|
-
* process MUST hold Accessibility permission (System Settings →
|
|
45
|
-
* Privacy & Security → Accessibility) for synthetic input to take
|
|
46
|
-
* effect.
|
|
47
|
-
* - cliclick is auto-detected on PATH; install via `brew install
|
|
48
|
-
* cliclick` for the smoothest pointer ergonomics. Without it the
|
|
49
|
-
* backend falls back to JXA + Quartz CGEvent.
|
|
40
|
+
* The host may run macOS, Linux or Windows; controlled devices are Android only.
|
|
50
41
|
*/
|
|
51
42
|
import { parseArgs } from "node:util";
|
|
52
43
|
import { DeviceError } from "@beeos-ai/device-common";
|
|
53
|
-
import {
|
|
44
|
+
import { SUPPORTED_BACKENDS } from "./backends/index.js";
|
|
54
45
|
import { buildApp } from "./server/app.js";
|
|
55
46
|
import { runStdio } from "./server/stdio.js";
|
|
56
47
|
import { BackendRegistry } from "./server/registry.js";
|
|
@@ -98,15 +89,9 @@ Usage:
|
|
|
98
89
|
device-mcp-server [options]
|
|
99
90
|
|
|
100
91
|
Options:
|
|
101
|
-
--backend <name>
|
|
102
|
-
Aliases: android (= adb), mac (= macos), win (= windows),
|
|
103
|
-
desktop-{linux,macos,windows}, mock-desktop, ios
|
|
104
|
-
Default: "adb" — the singleton multi-device path.
|
|
105
|
-
--host <addr> HTTP bind address (default: 127.0.0.1; ignored under --stdio)
|
|
106
|
-
--port <n> HTTP listen port (default: 7900; ignored under --stdio)
|
|
92
|
+
--backend <name> adb | android (Android only)\n --port <n> HTTP listen port (default: 7900; ignored under --stdio)
|
|
107
93
|
--stdio Use stdio transport (single session, JSON-RPC on stdin/stdout,
|
|
108
94
|
logs on stderr). Mutually exclusive with HTTP.
|
|
109
|
-
--width / --height Override mock-desktop canvas size (ignored on macos)
|
|
110
95
|
-h, --help Show this help
|
|
111
96
|
|
|
112
97
|
Env overrides:
|
|
@@ -127,30 +112,8 @@ function parsePositiveIntEnv(name) {
|
|
|
127
112
|
}
|
|
128
113
|
async function main() {
|
|
129
114
|
const cli = parseCliArgs(process.argv.slice(2));
|
|
130
|
-
// Build the static (non-adb) backend up front. The adb path is handled
|
|
131
|
-
// by the registry's discovery poll — there's no per-process adb pinning
|
|
132
|
-
// any more.
|
|
133
|
-
const isAdb = cli.backend === "adb" || cli.backend === "android";
|
|
134
|
-
const initialBackends = isAdb
|
|
135
|
-
? []
|
|
136
|
-
: [
|
|
137
|
-
createBackend(cli.backend, {
|
|
138
|
-
desktop: { width: cli.width, height: cli.height },
|
|
139
|
-
macos: {
|
|
140
|
-
cliclickPath: process.env.MAC_CLICLICK_PATH || undefined,
|
|
141
|
-
},
|
|
142
|
-
linux: {
|
|
143
|
-
shellTimeoutMs: parsePositiveIntEnv("LINUX_SHELL_TIMEOUT_MS"),
|
|
144
|
-
},
|
|
145
|
-
windows: {
|
|
146
|
-
shellTimeoutMs: parsePositiveIntEnv("WINDOWS_SHELL_TIMEOUT_MS"),
|
|
147
|
-
powershellBin: process.env.WINDOWS_POWERSHELL_BIN || undefined,
|
|
148
|
-
},
|
|
149
|
-
}),
|
|
150
|
-
];
|
|
151
115
|
const registry = new BackendRegistry({
|
|
152
|
-
|
|
153
|
-
enableAdbDiscovery: isAdb,
|
|
116
|
+
enableAdbDiscovery: true,
|
|
154
117
|
pollIntervalMs: parsePositiveIntEnv("DEVICE_MCP_POLL_MS") ?? undefined,
|
|
155
118
|
androidDefaults: {
|
|
156
119
|
defaultTimeoutMs: parsePositiveIntEnv("ADB_DEFAULT_TIMEOUT_MS"),
|
|
@@ -160,17 +123,6 @@ async function main() {
|
|
|
160
123
|
},
|
|
161
124
|
});
|
|
162
125
|
await registry.start();
|
|
163
|
-
// Surface a one-shot warning for macOS Accessibility permission since
|
|
164
|
-
// that's the most common "tools silently no-op" failure mode.
|
|
165
|
-
if (!cli.stdio &&
|
|
166
|
-
((cli.backend === "desktop" && process.platform === "darwin") ||
|
|
167
|
-
cli.backend === "macos" ||
|
|
168
|
-
cli.backend === "mac" ||
|
|
169
|
-
cli.backend === "desktop-macos")) {
|
|
170
|
-
process.stderr.write("[device-mcp-server] macOS backend selected — ensure the host process " +
|
|
171
|
-
"holds Accessibility permission (System Settings → Privacy & Security " +
|
|
172
|
-
"→ Accessibility) for synthetic input to take effect.\n");
|
|
173
|
-
}
|
|
174
126
|
if (cli.stdio) {
|
|
175
127
|
await runStdio({ registry, version: process.env.npm_package_version });
|
|
176
128
|
// runStdio resolves once stdin is wired up; the SDK transport keeps
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEtD,OAAO,EAAiB,kBAAkB,EAAoB,MAAM,qBAAqB,CAAC;AAC1F,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAWhD,SAAS,YAAY,CAAC,IAAc;IAClC,MAAM,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;QAC3B,IAAI,EAAE,IAAI;QACV,OAAO,EAAE;YACP,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YAC3B,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YACxB,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YACxB,KAAK,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE;YAC1C,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YACzB,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YAC1B,IAAI,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAA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CAAC,CAAC;QAClB,CAAC;IACH,CAAC,CAAC;IACF,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,KAAK,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC;IACpD,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE,CAAC,KAAK,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC;AACxD,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAY,EAAE,EAAE;IAC5B,MAAM,OAAO,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACjE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,8BAA8B,OAAO,IAAI,CAAC,CAAC;IAChE,IAAI,GAAG,YAAY,WAAW,EAAE,CAAC;QAC/B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,aAAa,GAAG,CAAC,OAAO,cAAc,GAAG,CAAC,SAAS,IAAI,CAAC,CAAC;IAChF,CAAC;IACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -11,6 +11,6 @@ export { runStdio, type RunStdioOptions } from "./server/stdio.js";
|
|
|
11
11
|
export { buildMcpServer, type BuildMcpServerOptions } from "./server/mcp-server.js";
|
|
12
12
|
export { BackendRegistry, type AvailableDevice as RegistryAvailableDevice, type BackendRegistryOptions, } from "./server/registry.js";
|
|
13
13
|
export { TOOL_SPECS, allToolNames, getToolSpec, registerAllTools, type ToolHandler, type ToolHandlerContext, type ToolSpec, } from "./server/tool-registry.js";
|
|
14
|
-
export { AndroidAdbBackend,
|
|
14
|
+
export { AndroidAdbBackend, createBackend, SUPPORTED_BACKENDS, type BackendName, type SandboxBackend, type BackendFamily, type AndroidAdbBackendOptions, type CreateBackendOptions, } from "./backends/index.js";
|
|
15
15
|
export { BaseSandboxBackend, type ScreenSize, type UiDumpOutput, type ExecuteCommandOutput, type ListDirectoryEntry, } from "./backends/base.js";
|
|
16
16
|
export declare const VERSION = "0.5.1";
|
package/dist/index.js
CHANGED
|
@@ -11,7 +11,7 @@ export { runStdio } from "./server/stdio.js";
|
|
|
11
11
|
export { buildMcpServer } from "./server/mcp-server.js";
|
|
12
12
|
export { BackendRegistry, } from "./server/registry.js";
|
|
13
13
|
export { TOOL_SPECS, allToolNames, getToolSpec, registerAllTools, } from "./server/tool-registry.js";
|
|
14
|
-
export { AndroidAdbBackend,
|
|
14
|
+
export { AndroidAdbBackend, createBackend, SUPPORTED_BACKENDS, } from "./backends/index.js";
|
|
15
15
|
export { BaseSandboxBackend, } from "./backends/base.js";
|
|
16
16
|
export const VERSION = "0.5.1";
|
|
17
17
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,QAAQ,EAAwB,MAAM,iBAAiB,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAwB,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,cAAc,EAA8B,MAAM,wBAAwB,CAAC;AACpF,OAAO,EACL,eAAe,GAGhB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,UAAU,EACV,YAAY,EACZ,WAAW,EACX,gBAAgB,GAIjB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACL,iBAAiB,EACjB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,QAAQ,EAAwB,MAAM,iBAAiB,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAwB,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,cAAc,EAA8B,MAAM,wBAAwB,CAAC;AACpF,OAAO,EACL,eAAe,GAGhB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,UAAU,EACV,YAAY,EACZ,WAAW,EACX,gBAAgB,GAIjB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACL,iBAAiB,EACjB,aAAa,EACb,kBAAkB,GAMnB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,kBAAkB,GAKnB,MAAM,oBAAoB,CAAC;AAE5B,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC"}
|
|
@@ -34,6 +34,7 @@ import type { SandboxBackend } from "../backends/base.js";
|
|
|
34
34
|
import type { BackendRegistry } from "./registry.js";
|
|
35
35
|
/** Backend reference passed into handlers for backend-bound tools. */
|
|
36
36
|
export interface ToolHandlerContext {
|
|
37
|
+
signal?: AbortSignal;
|
|
37
38
|
backend: SandboxBackend;
|
|
38
39
|
registry: BackendRegistry;
|
|
39
40
|
sessionId?: string;
|
|
@@ -28,6 +28,8 @@
|
|
|
28
28
|
* typed payload that programmatic callers (`device-agent`) parse.
|
|
29
29
|
*/
|
|
30
30
|
import { z } from "zod";
|
|
31
|
+
import { setTimeout as delay } from "node:timers/promises";
|
|
32
|
+
import { CLICK_SEQUENCE_INTERVAL_MS, CLICK_SEQUENCE_TIMEOUT_MS, MAX_CLICK_SEQUENCE_LENGTH } from "@beeos-ai/device-common";
|
|
31
33
|
import { DeviceError, DEVICE_LEASE_META, DEVICE_LEASE_TOOLS, DEVICE_LEASE_TTL_MS, DEVICE_LEASE_MIN_TTL_MS, DEVICE_LEASE_MAX_TTL_MS, } from "@beeos-ai/device-common";
|
|
32
34
|
import { formatUiXmlToolOutput } from "../util/ui-xml.js";
|
|
33
35
|
import { assertSafeUrl, PRESS_BUTTON_KEYMAP } from "../backends/android-adb.js";
|
|
@@ -371,6 +373,43 @@ export const TOOL_SPECS = [
|
|
|
371
373
|
return ack("tap");
|
|
372
374
|
},
|
|
373
375
|
},
|
|
376
|
+
{
|
|
377
|
+
name: "click_sequence",
|
|
378
|
+
description: "Execute 2-4 rapid taps serially without observing between them. Only for a short, known transient interaction; never use for unseen pages or sensitive submissions. Returns partial progress on failure.",
|
|
379
|
+
inputShape: { points: z.array(z.object({ x: z.number().int().nonnegative(), y: z.number().int().nonnegative() })).min(2).max(MAX_CLICK_SEQUENCE_LENGTH) },
|
|
380
|
+
annotations: { ...MUTATING, title: "Click sequence" },
|
|
381
|
+
requires: "tap",
|
|
382
|
+
handler: async (args, { backend, signal }) => {
|
|
383
|
+
const completed = [];
|
|
384
|
+
const result = { ok: false, completed };
|
|
385
|
+
const deadline = Date.now() + CLICK_SEQUENCE_TIMEOUT_MS;
|
|
386
|
+
try {
|
|
387
|
+
const points = z.array(z.object({ x: z.number().int().nonnegative(), y: z.number().int().nonnegative() })).min(2).max(MAX_CLICK_SEQUENCE_LENGTH).parse(args.points);
|
|
388
|
+
const size = await backend.screenSize();
|
|
389
|
+
if (points.some((p) => p.x >= size.w || p.y >= size.h))
|
|
390
|
+
throw new Error("Sequence target outside screen");
|
|
391
|
+
for (const point of points) {
|
|
392
|
+
signal?.throwIfAborted();
|
|
393
|
+
if (Date.now() >= deadline)
|
|
394
|
+
throw new Error("Click sequence deadline reached");
|
|
395
|
+
// Ordinary Android tap settles for a full second. Only this bounded,
|
|
396
|
+
// leased sequence owns its shorter inter-tap pacing.
|
|
397
|
+
if (backend.tapForSequence)
|
|
398
|
+
await backend.tapForSequence(point.x, point.y);
|
|
399
|
+
else
|
|
400
|
+
await backend.tap(point.x, point.y);
|
|
401
|
+
completed.push(point);
|
|
402
|
+
if (completed.length < points.length)
|
|
403
|
+
await delay(CLICK_SEQUENCE_INTERVAL_MS, undefined, { signal });
|
|
404
|
+
}
|
|
405
|
+
result.ok = true;
|
|
406
|
+
}
|
|
407
|
+
catch (error) {
|
|
408
|
+
result.error = error instanceof Error ? error.message : String(error);
|
|
409
|
+
}
|
|
410
|
+
return { ...ok("click_sequence", result), isError: !result.ok };
|
|
411
|
+
},
|
|
412
|
+
},
|
|
374
413
|
{
|
|
375
414
|
name: "double_tap",
|
|
376
415
|
description: "Double-tap at (x, y) on a touch device. Mobile-side alias for `double_click` — the underlying backend method is the same (`doubleClick`); this wire name exists for prompt parity with `mobile_double_tap_on_screen` (mobile-mcp).",
|
|
@@ -453,23 +492,17 @@ export const TOOL_SPECS = [
|
|
|
453
492
|
submit: z
|
|
454
493
|
.boolean()
|
|
455
494
|
.optional()
|
|
456
|
-
.describe("When true, send
|
|
495
|
+
.describe("When true, send KEYCODE_ENTER after the text — useful for search bars / chat composers."),
|
|
457
496
|
},
|
|
458
497
|
annotations: { ...MUTATING, title: "Type text" },
|
|
459
498
|
requires: "type",
|
|
460
|
-
handler: async (args, { backend }) => {
|
|
499
|
+
handler: async (args, { backend, signal }) => {
|
|
500
|
+
signal?.throwIfAborted();
|
|
461
501
|
await backend.typeText(getStr(args, "text"));
|
|
462
502
|
if (args.submit === true) {
|
|
463
|
-
|
|
464
|
-
//
|
|
465
|
-
|
|
466
|
-
// for desktop backends that don't speak Android keycodes.
|
|
467
|
-
try {
|
|
468
|
-
await backend.pressKey("KEYCODE_ENTER");
|
|
469
|
-
}
|
|
470
|
-
catch {
|
|
471
|
-
await backend.pressKey("Enter");
|
|
472
|
-
}
|
|
503
|
+
signal?.throwIfAborted();
|
|
504
|
+
// A failed submission may already have taken effect; never replay it.
|
|
505
|
+
await backend.pressKey("KEYCODE_ENTER");
|
|
473
506
|
}
|
|
474
507
|
return ack("type");
|
|
475
508
|
},
|
|
@@ -993,7 +1026,8 @@ export function registerAllTools(server, registry) {
|
|
|
993
1026
|
if (!backend.tools.has(spec.requires)) {
|
|
994
1027
|
throw new DeviceError(`tool '${spec.name}' is not supported by backend '${backend.os}'`, { subtype: "unsupported", retriable: false });
|
|
995
1028
|
}
|
|
996
|
-
const run = () => spec.handler(a, { backend, registry, sessionId
|
|
1029
|
+
const run = () => spec.handler(a, { backend, registry, sessionId,
|
|
1030
|
+
signal: extra?.signal });
|
|
997
1031
|
if (spec.annotations?.readOnlyHint === true || spec.concurrentObservation)
|
|
998
1032
|
return await run();
|
|
999
1033
|
const token = extra?._meta?.[DEVICE_LEASE_META];
|