mobile-agent-mcp 0.1.1
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/CHANGELOG.md +32 -0
- package/LICENSE +21 -0
- package/NOTICE +4 -0
- package/README.md +115 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +142 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +115 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +137 -0
- package/dist/config.js.map +1 -0
- package/dist/driver/adb.d.ts +2 -0
- package/dist/driver/adb.d.ts.map +1 -0
- package/dist/driver/adb.js +12 -0
- package/dist/driver/adb.js.map +1 -0
- package/dist/driver/dev-server.d.ts +9 -0
- package/dist/driver/dev-server.d.ts.map +1 -0
- package/dist/driver/dev-server.js +24 -0
- package/dist/driver/dev-server.js.map +1 -0
- package/dist/driver/devices.d.ts +2 -0
- package/dist/driver/devices.d.ts.map +1 -0
- package/dist/driver/devices.js +46 -0
- package/dist/driver/devices.js.map +1 -0
- package/dist/driver/doctor.d.ts +11 -0
- package/dist/driver/doctor.d.ts.map +1 -0
- package/dist/driver/doctor.js +64 -0
- package/dist/driver/doctor.js.map +1 -0
- package/dist/driver/exec.d.ts +17 -0
- package/dist/driver/exec.d.ts.map +1 -0
- package/dist/driver/exec.js +60 -0
- package/dist/driver/exec.js.map +1 -0
- package/dist/driver/maestro.d.ts +11 -0
- package/dist/driver/maestro.d.ts.map +1 -0
- package/dist/driver/maestro.js +73 -0
- package/dist/driver/maestro.js.map +1 -0
- package/dist/driver/open-url.d.ts +3 -0
- package/dist/driver/open-url.d.ts.map +1 -0
- package/dist/driver/open-url.js +26 -0
- package/dist/driver/open-url.js.map +1 -0
- package/dist/driver/screenshot.d.ts +3 -0
- package/dist/driver/screenshot.d.ts.map +1 -0
- package/dist/driver/screenshot.js +27 -0
- package/dist/driver/screenshot.js.map +1 -0
- package/dist/errors.d.ts +19 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +45 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/tools.d.ts +12 -0
- package/dist/mcp/tools.d.ts.map +1 -0
- package/dist/mcp/tools.js +152 -0
- package/dist/mcp/tools.js.map +1 -0
- package/dist/mcp-server.d.ts +3 -0
- package/dist/mcp-server.d.ts.map +1 -0
- package/dist/mcp-server.js +34 -0
- package/dist/mcp-server.js.map +1 -0
- package/dist/runtime.d.ts +20 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +71 -0
- package/dist/runtime.js.map +1 -0
- package/dist/version.d.ts +3 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +4 -0
- package/dist/version.js.map +1 -0
- package/mobile-agent.config.example.json +20 -0
- package/package.json +73 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { runCommand } from './exec.js';
|
|
2
|
+
export function detectLanIp() {
|
|
3
|
+
if (process.platform === 'darwin') {
|
|
4
|
+
for (const iface of ['en0', 'en1']) {
|
|
5
|
+
const result = runCommand('ipconfig', ['getifaddr', iface], { allowFailure: true });
|
|
6
|
+
if (result.status === 0 && result.stdout) {
|
|
7
|
+
return result.stdout;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
return '127.0.0.1';
|
|
12
|
+
}
|
|
13
|
+
export function resolveDevServerEnv(config, env = process.env) {
|
|
14
|
+
if (!config) {
|
|
15
|
+
return {};
|
|
16
|
+
}
|
|
17
|
+
const hostEnv = config.hostEnv ?? 'EXPO_DEV_HOST';
|
|
18
|
+
const host = env[hostEnv] ?? detectLanIp();
|
|
19
|
+
const port = env.EXPO_DEV_PORT ?? String(config.port ?? 8081);
|
|
20
|
+
const scheme = config.scheme ?? 'exp';
|
|
21
|
+
const outputEnvKey = config.outputEnvKey ?? 'EXPO_URL';
|
|
22
|
+
return { [outputEnvKey]: `${scheme}://${host}:${port}` };
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=dev-server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev-server.js","sourceRoot":"","sources":["../../src/driver/dev-server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC,MAAM,UAAU,WAAW;IACzB,IAAI,OAAO,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;QAClC,KAAK,MAAM,KAAK,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE,CAAC;YACnC,MAAM,MAAM,GAAG,UAAU,CAAC,UAAU,EAAE,CAAC,WAAW,EAAE,KAAK,CAAC,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC;YACpF,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;gBACzC,OAAO,MAAM,CAAC,MAAM,CAAC;YACvB,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,WAAW,CAAC;AACrB,CAAC;AASD,MAAM,UAAU,mBAAmB,CACjC,MAAsC,EACtC,MAAyB,OAAO,CAAC,GAAG;IAEpC,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,IAAI,eAAe,CAAC;IAClD,MAAM,IAAI,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,WAAW,EAAE,CAAC;IAC3C,MAAM,IAAI,GAAG,GAAG,CAAC,aAAa,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,IAAI,IAAI,CAAC,CAAC;IAC9D,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,IAAI,KAAK,CAAC;IACtC,MAAM,YAAY,GAAG,MAAM,CAAC,YAAY,IAAI,UAAU,CAAC;IAEvD,OAAO,EAAE,CAAC,YAAY,CAAC,EAAE,GAAG,MAAM,MAAM,IAAI,IAAI,IAAI,EAAE,EAAE,CAAC;AAC3D,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"devices.d.ts","sourceRoot":"","sources":["../../src/driver/devices.ts"],"names":[],"mappings":"AAEA,wBAAgB,WAAW,IAAI,MAAM,CA6CpC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { commandExists, runCommand } from './exec.js';
|
|
2
|
+
export function listDevices() {
|
|
3
|
+
const sections = [];
|
|
4
|
+
if (process.platform === 'darwin') {
|
|
5
|
+
sections.push('=== iOS Simulators (booted) ===');
|
|
6
|
+
const booted = runCommand('xcrun', ['simctl', 'list', 'devices', 'booted'], {
|
|
7
|
+
allowFailure: true,
|
|
8
|
+
});
|
|
9
|
+
sections.push(booted.stdout || booted.stderr || '(none)');
|
|
10
|
+
sections.push('');
|
|
11
|
+
sections.push('=== iOS Simulators (available) ===');
|
|
12
|
+
const available = runCommand('xcrun', ['simctl', 'list', 'devices', 'available'], {
|
|
13
|
+
allowFailure: true,
|
|
14
|
+
});
|
|
15
|
+
const filtered = available.stdout
|
|
16
|
+
.split('\n')
|
|
17
|
+
.filter((line) => /iPhone|iPad/.test(line))
|
|
18
|
+
.slice(0, 10)
|
|
19
|
+
.join('\n');
|
|
20
|
+
sections.push(filtered || available.stderr || '(none)');
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
sections.push('=== iOS Simulators ===');
|
|
24
|
+
sections.push('simctl requires macOS');
|
|
25
|
+
}
|
|
26
|
+
sections.push('');
|
|
27
|
+
sections.push('=== Android (adb) ===');
|
|
28
|
+
if (commandExists('adb')) {
|
|
29
|
+
const adb = runCommand('adb', ['devices', '-l'], { allowFailure: true });
|
|
30
|
+
sections.push(adb.stdout || adb.stderr || '(none)');
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
sections.push('adb not installed');
|
|
34
|
+
}
|
|
35
|
+
sections.push('');
|
|
36
|
+
sections.push('=== Maestro ===');
|
|
37
|
+
if (commandExists('maestro')) {
|
|
38
|
+
const version = runCommand('maestro', ['--version'], { allowFailure: true });
|
|
39
|
+
sections.push(`Maestro: OK (${version.stdout || version.stderr || 'unknown'})`);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
sections.push('Maestro not found. Install: curl -Ls "https://get.maestro.mobile.dev" | bash');
|
|
43
|
+
}
|
|
44
|
+
return sections.join('\n');
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=devices.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"devices.js","sourceRoot":"","sources":["../../src/driver/devices.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEtD,MAAM,UAAU,WAAW;IACzB,MAAM,QAAQ,GAAa,EAAE,CAAC;IAE9B,IAAI,OAAO,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;QAClC,QAAQ,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAC;QACjD,MAAM,MAAM,GAAG,UAAU,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,CAAC,EAAE;YAC1E,YAAY,EAAE,IAAI;SACnB,CAAC,CAAC;QACH,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,IAAI,QAAQ,CAAC,CAAC;QAE1D,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAClB,QAAQ,CAAC,IAAI,CAAC,oCAAoC,CAAC,CAAC;QACpD,MAAM,SAAS,GAAG,UAAU,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,CAAC,EAAE;YAChF,YAAY,EAAE,IAAI;SACnB,CAAC,CAAC;QACH,MAAM,QAAQ,GAAG,SAAS,CAAC,MAAM;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IAAI,SAAS,GAAG,CAAC,CAAC;IAClF,CAAC;SAAM,CAAC;QACN,QAAQ,CAAC,IAAI,CAAC,8EAA8E,CAAC,CAAC;IAChG,CAAC;IAED,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC7B,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ResolvedConfig } from '../config.js';
|
|
2
|
+
export type DoctorStatus = 'ok' | 'warn' | 'fail';
|
|
3
|
+
export interface DoctorCheck {
|
|
4
|
+
name: string;
|
|
5
|
+
status: DoctorStatus;
|
|
6
|
+
message: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function runDoctor(config: ResolvedConfig): DoctorCheck[];
|
|
9
|
+
export declare function formatDoctorReport(checks: DoctorCheck[]): string;
|
|
10
|
+
export declare function doctorHasFailures(checks: DoctorCheck[]): boolean;
|
|
11
|
+
//# sourceMappingURL=doctor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../../src/driver/doctor.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAGnD,MAAM,MAAM,YAAY,GAAG,IAAI,GAAG,MAAM,GAAG,MAAM,CAAC;AAElD,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,YAAY,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;CACjB;AAMD,wBAAgB,SAAS,CAAC,MAAM,EAAE,cAAc,GAAG,WAAW,EAAE,CAqE/D;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,CAMhE;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAEhE"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import { commandExists, runCommand } from './exec.js';
|
|
3
|
+
function push(checks, name, status, message) {
|
|
4
|
+
checks.push({ name, status, message });
|
|
5
|
+
}
|
|
6
|
+
export function runDoctor(config) {
|
|
7
|
+
const checks = [];
|
|
8
|
+
if (config.configPath) {
|
|
9
|
+
push(checks, 'config', 'ok', `Found ${config.configPath}`);
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
push(checks, 'config', 'warn', 'No mobile-agent.config.json found; env vars and defaults only');
|
|
13
|
+
}
|
|
14
|
+
if (fs.existsSync(config.flowsDir)) {
|
|
15
|
+
push(checks, 'flowsDir', 'ok', config.flowsDir);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
push(checks, 'flowsDir', 'fail', `Missing flowsDir: ${config.flowsDir}`);
|
|
19
|
+
}
|
|
20
|
+
fs.mkdirSync(config.screenshotDir, { recursive: true });
|
|
21
|
+
push(checks, 'screenshotDir', 'ok', config.screenshotDir);
|
|
22
|
+
if (process.platform === 'darwin') {
|
|
23
|
+
const simctl = runCommand('xcrun', ['simctl', 'list', 'devices', 'booted'], {
|
|
24
|
+
allowFailure: true,
|
|
25
|
+
});
|
|
26
|
+
push(checks, 'simctl', simctl.status === 0 ? 'ok' : 'fail', simctl.status === 0 ? 'xcrun simctl available' : simctl.stderr || 'simctl unavailable');
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
push(checks, 'simctl', 'warn', 'iOS simctl requires macOS');
|
|
30
|
+
}
|
|
31
|
+
if (commandExists('adb')) {
|
|
32
|
+
const adb = runCommand('adb', ['devices'], { allowFailure: true });
|
|
33
|
+
const hasDevice = adb.stdout.split('\n').some((line) => line.trim().endsWith('device'));
|
|
34
|
+
push(checks, 'adb', hasDevice ? 'ok' : 'warn', hasDevice ? 'adb device connected' : 'adb installed but no device/emulator detected');
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
push(checks, 'adb', 'warn', 'adb not installed (Android workflows unavailable)');
|
|
38
|
+
}
|
|
39
|
+
if (commandExists(config.maestroBin)) {
|
|
40
|
+
const version = runCommand(config.maestroBin, ['--version'], { allowFailure: true });
|
|
41
|
+
push(checks, 'maestro', 'ok', `Maestro available (${version.stdout || version.stderr || 'unknown version'})`);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
push(checks, 'maestro', 'fail', `Maestro not found (${config.maestroBin}). Install: curl -Ls "https://get.maestro.mobile.dev" | bash`);
|
|
45
|
+
}
|
|
46
|
+
if (config.smokeFlows.length > 0) {
|
|
47
|
+
push(checks, 'smokeFlows', 'ok', config.smokeFlows.join(', '));
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
push(checks, 'smokeFlows', 'warn', 'Nothing in smokeFlows; run-all will fail');
|
|
51
|
+
}
|
|
52
|
+
return checks;
|
|
53
|
+
}
|
|
54
|
+
export function formatDoctorReport(checks) {
|
|
55
|
+
const lines = checks.map((check) => {
|
|
56
|
+
const icon = check.status === 'ok' ? 'OK' : check.status === 'warn' ? 'WARN' : 'FAIL';
|
|
57
|
+
return `[${icon}] ${check.name}: ${check.message}`;
|
|
58
|
+
});
|
|
59
|
+
return lines.join('\n');
|
|
60
|
+
}
|
|
61
|
+
export function doctorHasFailures(checks) {
|
|
62
|
+
return checks.some((check) => check.status === 'fail');
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=doctor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doctor.js","sourceRoot":"","sources":["../../src/driver/doctor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AAEzB,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAUtD,SAAS,IAAI,CAAC,MAAqB,EAAE,IAAY,EAAE,MAAoB,EAAE,OAAe;IACtF,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC;AACzC,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,MAAsB;IAC9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CAAC;QACjC,IAAI,CAAC,MAAM,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACjE,CAAC;SAAM,CAAC;QACN,IAAI,CAAC,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,0CAA0C,CAAC,CAAC;IACjF,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,MAAqB;IACtD,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;QACjC,MAAM,IAAI,GAAG,KAAK,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC;QACtF,OAAO,IAAI,IAAI,KAAK,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC;IACrD,CAAC,CAAC,CAAC;IACH,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,MAAqB;IACrD,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC;AACzD,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface CommandResult {
|
|
2
|
+
stdout: string;
|
|
3
|
+
stderr: string;
|
|
4
|
+
status: number | null;
|
|
5
|
+
stdoutBuffer?: Buffer;
|
|
6
|
+
}
|
|
7
|
+
export interface RunCommandOptions {
|
|
8
|
+
cwd?: string;
|
|
9
|
+
env?: NodeJS.ProcessEnv;
|
|
10
|
+
allowFailure?: boolean;
|
|
11
|
+
encoding?: BufferEncoding | 'buffer';
|
|
12
|
+
timeoutMs?: number;
|
|
13
|
+
}
|
|
14
|
+
export declare function withMaestroPath(env?: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
|
|
15
|
+
export declare function runCommand(command: string, args: string[], options?: RunCommandOptions): CommandResult;
|
|
16
|
+
export declare function commandExists(command: string, env?: NodeJS.ProcessEnv): boolean;
|
|
17
|
+
//# sourceMappingURL=exec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exec.d.ts","sourceRoot":"","sources":["../../src/driver/exec.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,iBAAiB;IAChC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACxB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,EAAE,cAAc,GAAG,QAAQ,CAAC;IACrC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,eAAe,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,MAAM,CAAC,UAAU,CAKvF;AAQD,wBAAgB,UAAU,CACxB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,GAAE,iBAAsB,GAC9B,aAAa,CAkDf;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,GAAG,OAAO,CAQ/E"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { spawnSync } from 'node:child_process';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { AgentError, ErrorCode } from '../errors.js';
|
|
4
|
+
export function withMaestroPath(env = process.env) {
|
|
5
|
+
const home = env.HOME ?? env.USERPROFILE ?? '';
|
|
6
|
+
const maestroBinDir = home ? path.join(home, '.maestro', 'bin') : '';
|
|
7
|
+
const pathValue = maestroBinDir ? `${env.PATH ?? ''}${path.delimiter}${maestroBinDir}` : env.PATH;
|
|
8
|
+
return { ...env, PATH: pathValue };
|
|
9
|
+
}
|
|
10
|
+
function formatCommandFailure(command, args, result) {
|
|
11
|
+
const joined = [command, ...args].join(' ');
|
|
12
|
+
const details = [result.stdout, result.stderr].filter(Boolean).join('\n');
|
|
13
|
+
return details ? `${joined}\n${details}` : `${joined} (exit ${result.status ?? 'unknown'})`;
|
|
14
|
+
}
|
|
15
|
+
export function runCommand(command, args, options = {}) {
|
|
16
|
+
const encoding = options.encoding ?? 'utf-8';
|
|
17
|
+
const spawnOptions = encoding === 'buffer'
|
|
18
|
+
? {
|
|
19
|
+
cwd: options.cwd,
|
|
20
|
+
env: withMaestroPath(options.env),
|
|
21
|
+
timeout: options.timeoutMs,
|
|
22
|
+
}
|
|
23
|
+
: {
|
|
24
|
+
encoding,
|
|
25
|
+
cwd: options.cwd,
|
|
26
|
+
env: withMaestroPath(options.env),
|
|
27
|
+
timeout: options.timeoutMs,
|
|
28
|
+
};
|
|
29
|
+
const result = spawnSync(command, args, spawnOptions);
|
|
30
|
+
if (result.error) {
|
|
31
|
+
const code = result.error.name === 'ENOENT' ? ErrorCode.TOOL_UNAVAILABLE : ErrorCode.COMMAND_FAILED;
|
|
32
|
+
throw new AgentError(`Failed to run ${command}: ${result.error.message}`, code, result.error);
|
|
33
|
+
}
|
|
34
|
+
const stdoutBuffer = Buffer.isBuffer(result.stdout) ? result.stdout : undefined;
|
|
35
|
+
const stdout = typeof result.stdout === 'string'
|
|
36
|
+
? result.stdout.trim()
|
|
37
|
+
: stdoutBuffer?.length
|
|
38
|
+
? '[binary]'
|
|
39
|
+
: '';
|
|
40
|
+
const stderr = typeof result.stderr === 'string' ? result.stderr.trim() : '';
|
|
41
|
+
const status = result.status;
|
|
42
|
+
const commandResult = { stdout, stderr, status, stdoutBuffer };
|
|
43
|
+
if (result.signal === 'SIGTERM' || result.signal === 'SIGKILL') {
|
|
44
|
+
throw new AgentError(`Command timed out after ${options.timeoutMs}ms: ${command} ${args.join(' ')}`, ErrorCode.COMMAND_FAILED);
|
|
45
|
+
}
|
|
46
|
+
if (status !== 0 && !options.allowFailure) {
|
|
47
|
+
throw new AgentError(formatCommandFailure(command, args, commandResult), ErrorCode.COMMAND_FAILED);
|
|
48
|
+
}
|
|
49
|
+
return commandResult;
|
|
50
|
+
}
|
|
51
|
+
export function commandExists(command, env) {
|
|
52
|
+
const check = process.platform === 'win32' ? 'where' : 'command';
|
|
53
|
+
const checkArgs = process.platform === 'win32' ? [command] : ['-v', command];
|
|
54
|
+
const result = spawnSync(check, checkArgs, {
|
|
55
|
+
encoding: 'utf-8',
|
|
56
|
+
env: withMaestroPath(env),
|
|
57
|
+
});
|
|
58
|
+
return result.status === 0;
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=exec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exec.js","sourceRoot":"","sources":["../../src/driver/exec.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2C,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACxF,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAiBrD,MAAM,UAAU,eAAe,CAAC,MAAyB,OAAO,CAAC,GAAG;IAClE,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,IAAI,GAAG,CAAC,WAAW,IAAI,EAAE,CAAC;IAC/C,MAAM,aAAa,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IACrE,MAAM,SAAS,GAAG,aAAa,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,IAAI,IAAI,EAAE,GAAG,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E,CAAC;QAC1C,MAAM,IAAI,UAAU,CAClB,oBAAoB,CAAC,OAAO,EAAE,IAAI,EAAE,aAAa,CAAC,EAClD,SAAS,CAAC,cAAc,CACzB,CAAC;IACJ,CAAC;IAED,OAAO,aAAa,CAAC;AACvB,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,OAAe,EAAE,GAAuB;IACpE,MAAM,KAAK,GAAG,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC;IACjE,MAAM,SAAS,GAAG,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC7E,MAAM,MAAM,GAAG,SAAS,CAAC,KAAK,EAAE,SAAS,EAAE;QACzC,QAAQ,EAAE,OAAO;QACjB,GAAG,EAAE,eAAe,CAAC,GAAG,CAAC;KAC1B,CAAC,CAAC;IACH,OAAO,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC;AAC7B,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Platform, ResolvedConfig } from '../config.js';
|
|
2
|
+
export interface RunFlowOptions {
|
|
3
|
+
flow: string;
|
|
4
|
+
platform?: Platform;
|
|
5
|
+
env?: Record<string, string>;
|
|
6
|
+
captureAfter?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare function requireMaestro(bin: string): void;
|
|
9
|
+
export declare function runMaestroFlow(config: ResolvedConfig, options: RunFlowOptions): string;
|
|
10
|
+
export declare function runMaestroFlows(config: ResolvedConfig, flows: string[], options: Omit<RunFlowOptions, 'flow'>): string;
|
|
11
|
+
//# sourceMappingURL=maestro.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"maestro.d.ts","sourceRoot":"","sources":["../../src/driver/maestro.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAM7D,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAsBD,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAOhD;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,cAAc,GAAG,MAAM,CAoDtF;AAED,wBAAgB,eAAe,CAC7B,MAAM,EAAE,cAAc,EACtB,KAAK,EAAE,MAAM,EAAE,EACf,OAAO,EAAE,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,GACpC,MAAM,CAMR"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { AgentError, ErrorCode } from '../errors.js';
|
|
4
|
+
import { resolveDevServerEnv } from './dev-server.js';
|
|
5
|
+
import { commandExists, runCommand } from './exec.js';
|
|
6
|
+
import { captureScreenshot } from './screenshot.js';
|
|
7
|
+
const DEFAULT_MAESTRO_TIMEOUT_MS = 10 * 60 * 1000;
|
|
8
|
+
function resolveFlowPath(config, flow) {
|
|
9
|
+
const withYaml = flow.endsWith('.yaml') || flow.endsWith('.yml') ? flow : `${flow}.yaml`;
|
|
10
|
+
const direct = path.join(config.flowsDir, withYaml);
|
|
11
|
+
if (fs.existsSync(direct)) {
|
|
12
|
+
return direct;
|
|
13
|
+
}
|
|
14
|
+
const bare = path.join(config.flowsDir, flow);
|
|
15
|
+
if (fs.existsSync(bare)) {
|
|
16
|
+
return bare;
|
|
17
|
+
}
|
|
18
|
+
throw new AgentError(`Flow not found: ${flow} (looked in ${config.flowsDir})`, ErrorCode.FLOW_NOT_FOUND);
|
|
19
|
+
}
|
|
20
|
+
export function requireMaestro(bin) {
|
|
21
|
+
if (!commandExists(bin)) {
|
|
22
|
+
throw new AgentError(`Maestro not found (${bin}). Install: curl -Ls "https://get.maestro.mobile.dev" | bash`, ErrorCode.MAESTRO_NOT_FOUND);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export function runMaestroFlow(config, options) {
|
|
26
|
+
requireMaestro(config.maestroBin);
|
|
27
|
+
const platform = options.platform ?? 'ios';
|
|
28
|
+
const flowPath = resolveFlowPath(config, options.flow);
|
|
29
|
+
const appId = config.maestroAppIds[platform];
|
|
30
|
+
const mergedEnv = {
|
|
31
|
+
...resolveDevServerEnv(config.devServerUrl),
|
|
32
|
+
...config.maestroDefaultEnv,
|
|
33
|
+
...(appId ? { MAESTRO_APP_ID: appId } : {}),
|
|
34
|
+
...options.env,
|
|
35
|
+
};
|
|
36
|
+
const args = ['test'];
|
|
37
|
+
for (const [key, value] of Object.entries(mergedEnv)) {
|
|
38
|
+
args.push('-e', `${key}=${value}`);
|
|
39
|
+
}
|
|
40
|
+
const device = process.env.MAESTRO_DEVICE;
|
|
41
|
+
if (device) {
|
|
42
|
+
args.push('--device', device);
|
|
43
|
+
}
|
|
44
|
+
args.push(flowPath);
|
|
45
|
+
const header = `${flowPath} (${platform})`;
|
|
46
|
+
const timeoutMs = Number(process.env.MAESTRO_TIMEOUT_MS ?? DEFAULT_MAESTRO_TIMEOUT_MS);
|
|
47
|
+
const result = runCommand(config.maestroBin, args, {
|
|
48
|
+
cwd: config.projectRoot,
|
|
49
|
+
allowFailure: true,
|
|
50
|
+
timeoutMs: Number.isFinite(timeoutMs) ? timeoutMs : DEFAULT_MAESTRO_TIMEOUT_MS,
|
|
51
|
+
});
|
|
52
|
+
if (options.captureAfter !== false) {
|
|
53
|
+
try {
|
|
54
|
+
captureScreenshot(config, platform);
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
/* ignore */
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
const output = [header, result.stdout, result.stderr].filter(Boolean).join('\n');
|
|
61
|
+
if (result.status !== 0) {
|
|
62
|
+
throw new AgentError(output || `Maestro exited with code ${result.status}`, ErrorCode.COMMAND_FAILED);
|
|
63
|
+
}
|
|
64
|
+
return output;
|
|
65
|
+
}
|
|
66
|
+
export function runMaestroFlows(config, flows, options) {
|
|
67
|
+
const outputs = [];
|
|
68
|
+
for (const flow of flows) {
|
|
69
|
+
outputs.push(runMaestroFlow(config, { ...options, flow }));
|
|
70
|
+
}
|
|
71
|
+
return outputs.join('\n\n');
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=maestro.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"maestro.js","sourceRoot":"","sources":["../../src/driver/maestro.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AASpD,MAAM,0BAA0B,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAElD,SAAS,eAAe,CAAC,MAAsB,EAAE,IAAY;IAC3D,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,OAAO,CAAC;IACzF,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IACpD,IAAI,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC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rD,SAAS,CAAC,cAAc,CACzB,CAAC;IACJ,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,eAAe,CAC7B,MAAsB,EACtB,KAAe,EACf,OAAqC;IAErC,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,EAAE,GAAG,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IAC7D,CAAC;IACD,OAAO,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAC9B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"open-url.d.ts","sourceRoot":"","sources":["../../src/driver/open-url.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAI7C,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,MAAM,CAoC/D"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { AgentError, ErrorCode } from '../errors.js';
|
|
2
|
+
import { commandExists, runCommand } from './exec.js';
|
|
3
|
+
export function openUrl(url, platform) {
|
|
4
|
+
if (!url.trim()) {
|
|
5
|
+
throw new AgentError('url is required', ErrorCode.VALIDATION);
|
|
6
|
+
}
|
|
7
|
+
if (platform === 'ios') {
|
|
8
|
+
if (process.platform !== 'darwin') {
|
|
9
|
+
throw new AgentError('iOS open-url requires macOS with xcrun simctl', ErrorCode.TOOL_UNAVAILABLE);
|
|
10
|
+
}
|
|
11
|
+
runCommand('xcrun', ['simctl', 'bootstatus', 'booted', '-b'], { allowFailure: true });
|
|
12
|
+
runCommand('open', ['-a', 'Simulator'], { allowFailure: true });
|
|
13
|
+
runCommand('xcrun', ['simctl', 'openurl', 'booted', url]);
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
if (!commandExists('adb')) {
|
|
17
|
+
throw new AgentError('adb required for Android open-url', ErrorCode.TOOL_UNAVAILABLE);
|
|
18
|
+
}
|
|
19
|
+
const result = runCommand('adb', ['shell', 'am', 'start', '-a', 'android.intent.action.VIEW', '-d', url], { allowFailure: true });
|
|
20
|
+
if (result.status !== 0) {
|
|
21
|
+
throw new AgentError(result.stderr || result.stdout || 'adb open-url failed', ErrorCode.COMMAND_FAILED);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return `opened ${url} (${platform})`;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=open-url.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"open-url.js","sourceRoot":"","sources":["../../src/driver/open-url.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEtD,MAAM,UAAU,OAAO,CAAC,GAAW,EAAE,QAAkB;IACrD,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC;QAChB,MAAM,IAAI,UAAU,CAAC,iBAAiB,EAAE,SAAS,CAAC,UAAU,CAAC,CAAC;IAChE,CAAC;IAED,IAAI,QAAQ,KAAK,KAAK,EAAE,CAAC;QACvB,IAAI,OAAO,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;YAClC,MAAM,IAAI,UAAU,CAClB,+CAA+C,EAC/C,SAAS,CAAC,gBAAgB,CAC3B,CAAC;QACJ,CAAC;QAED,UAAU,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,YAAY,EAAE,QAAQ,EAAE,IAAI,CAAC,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC;QACtF,UAAU,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,WAAW,CAAC,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC;QAChE,UAAU,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,CAAC,CAAC,CAAC;IAC5D,CAAC;SAAM,CAAC;QACN,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;YAC1B,MAAM,IAAI,UAAU,CAAC,mCAAmC,EAAE,SAAS,CAAC,gBAAgB,CAAC,CAAC;QACxF,CAAC;QAED,MAAM,MAAM,GAAG,UAAU,CACvB,KAAK,EACL,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,4BAA4B,EAAE,IAAI,EAAE,GAAG,CAAC,EACvE,EAAE,YAAY,EAAE,IAAI,EAAE,CACvB,CAAC;QAEF,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACxB,MAAM,IAAI,UAAU,CAClB,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,IAAI,qBAAqB,EACvD,SAAS,CAAC,cAAc,CACzB,CAAC;QACJ,CAAC;IACH,CAAC;IAED,OAAO,UAAU,GAAG,KAAK,QAAQ,GAAG,CAAC;AACvC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"screenshot.d.ts","sourceRoot":"","sources":["../../src/driver/screenshot.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAI7D,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,cAAc,EAAE,QAAQ,EAAE,QAAQ,GAAG,MAAM,CA4BpF"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { AgentError, ErrorCode } from '../errors.js';
|
|
4
|
+
import { runCommand } from './exec.js';
|
|
5
|
+
export function captureScreenshot(config, platform) {
|
|
6
|
+
fs.mkdirSync(config.screenshotDir, { recursive: true });
|
|
7
|
+
const timestamp = new Date().toISOString().replace(/[:.]/g, '-').slice(0, 19);
|
|
8
|
+
const outputPath = path.join(config.screenshotDir, `${platform}-${timestamp}.png`);
|
|
9
|
+
if (platform === 'ios') {
|
|
10
|
+
if (process.platform !== 'darwin') {
|
|
11
|
+
throw new AgentError('iOS screenshots require macOS with xcrun simctl', ErrorCode.TOOL_UNAVAILABLE);
|
|
12
|
+
}
|
|
13
|
+
runCommand('xcrun', ['simctl', 'io', 'booted', 'screenshot', outputPath]);
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
const result = runCommand('adb', ['exec-out', 'screencap', '-p'], {
|
|
17
|
+
allowFailure: true,
|
|
18
|
+
encoding: 'buffer',
|
|
19
|
+
});
|
|
20
|
+
if (result.status !== 0 || !result.stdoutBuffer?.length) {
|
|
21
|
+
throw new AgentError(result.stderr || result.stdout || 'adb screencap failed', ErrorCode.COMMAND_FAILED);
|
|
22
|
+
}
|
|
23
|
+
fs.writeFileSync(outputPath, result.stdoutBuffer);
|
|
24
|
+
}
|
|
25
|
+
return outputPath;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=screenshot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"screenshot.js","sourceRoot":"","sources":["../../src/driver/screenshot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC,MAAM,UAAU,iBAAiB,CAAC,MAAsB,EAAE,QAAkB;IAC1E,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,aAAa,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACxD,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,G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
|
|
5
|
+
PLATFORM_INVALID = "PLATFORM_INVALID",
|
|
6
|
+
COMMAND_FAILED = "COMMAND_FAILED",
|
|
7
|
+
TOOL_UNAVAILABLE = "TOOL_UNAVAILABLE",
|
|
8
|
+
VALIDATION = "VALIDATION",
|
|
9
|
+
NOT_CONFIGURED = "NOT_CONFIGURED"
|
|
10
|
+
}
|
|
11
|
+
export declare class AgentError extends Error {
|
|
12
|
+
code: ErrorCode;
|
|
13
|
+
constructor(message: string, code: ErrorCode, cause?: unknown);
|
|
14
|
+
exitCode(): number;
|
|
15
|
+
}
|
|
16
|
+
export declare const MobileAgentError: typeof AgentError;
|
|
17
|
+
export declare function formatError(error: unknown): string;
|
|
18
|
+
export declare function getExitCode(error: unknown): number;
|
|
19
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,oBAAY,SAAS;IACnB,cAAc,mBAAmB;IACjC,cAAc,mBAAmB;IACjC,iBAAiB,sBAAsB;IACvC,gBAAgB,qBAAqB;IACrC,cAAc,mBAAmB;IACjC,gBAAgB,qBAAqB;IACrC,UAAU,eAAe;IACzB,cAAc,mBAAmB;CAClC;AAYD,qBAAa,UAAW,SAAQ,KAAK;IACnC,IAAI,EAAE,SAAS,CAAC;gBAEJ,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,CAAC,EAAE,OAAO;IAM7D,QAAQ,IAAI,MAAM;CAGnB;AAED,eAAO,MAAM,gBAAgB,mBAAa,CAAC;AAE3C,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAQlD;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAElD"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export var ErrorCode;
|
|
2
|
+
(function (ErrorCode) {
|
|
3
|
+
ErrorCode["CONFIG_INVALID"] = "CONFIG_INVALID";
|
|
4
|
+
ErrorCode["FLOW_NOT_FOUND"] = "FLOW_NOT_FOUND";
|
|
5
|
+
ErrorCode["MAESTRO_NOT_FOUND"] = "MAESTRO_NOT_FOUND";
|
|
6
|
+
ErrorCode["PLATFORM_INVALID"] = "PLATFORM_INVALID";
|
|
7
|
+
ErrorCode["COMMAND_FAILED"] = "COMMAND_FAILED";
|
|
8
|
+
ErrorCode["TOOL_UNAVAILABLE"] = "TOOL_UNAVAILABLE";
|
|
9
|
+
ErrorCode["VALIDATION"] = "VALIDATION";
|
|
10
|
+
ErrorCode["NOT_CONFIGURED"] = "NOT_CONFIGURED";
|
|
11
|
+
})(ErrorCode || (ErrorCode = {}));
|
|
12
|
+
const exitCodes = {
|
|
13
|
+
[ErrorCode.CONFIG_INVALID]: 2,
|
|
14
|
+
[ErrorCode.FLOW_NOT_FOUND]: 3,
|
|
15
|
+
[ErrorCode.MAESTRO_NOT_FOUND]: 4,
|
|
16
|
+
[ErrorCode.PLATFORM_INVALID]: 5,
|
|
17
|
+
[ErrorCode.COMMAND_FAILED]: 6,
|
|
18
|
+
[ErrorCode.TOOL_UNAVAILABLE]: 4,
|
|
19
|
+
[ErrorCode.NOT_CONFIGURED]: 2,
|
|
20
|
+
};
|
|
21
|
+
export class AgentError extends Error {
|
|
22
|
+
code;
|
|
23
|
+
constructor(message, code, cause) {
|
|
24
|
+
super(message, cause ? { cause } : undefined);
|
|
25
|
+
this.name = 'AgentError';
|
|
26
|
+
this.code = code;
|
|
27
|
+
}
|
|
28
|
+
exitCode() {
|
|
29
|
+
return exitCodes[this.code] ?? 1;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export const MobileAgentError = AgentError;
|
|
33
|
+
export function formatError(error) {
|
|
34
|
+
if (error instanceof AgentError) {
|
|
35
|
+
return `[${error.code}] ${error.message}`;
|
|
36
|
+
}
|
|
37
|
+
if (error instanceof Error) {
|
|
38
|
+
return error.message;
|
|
39
|
+
}
|
|
40
|
+
return String(error);
|
|
41
|
+
}
|
|
42
|
+
export function getExitCode(error) {
|
|
43
|
+
return error instanceof AgentError ? error.exitCode() : 1;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,SASX;AATD,WAAY,SAAS;IACnB,8CAAiC,CAAA;IACjC,8CAAiC,CAAA;IACjC,oDAAuC,CAAA;IACvC,kDAAqC,CAAA;IACrC,8CAAiC,CAAA;IACjC,kDAAqC,CAAA;IACrC,sCAAyB,CAAA;IACzB,8CAAiC,CAAA;AACnC,CAAC,EATW,SAAS,KAAT,SAAS,QASpB;AAED,MAAM,SAAS,GAAuC;IACpD,CAAC,SAAS,CAAC,cAAc,CAAC,EAAE,CAAC;IAC7B,CAAC,SAAS,CAAC,cAAc,CAAC,EAAE,CAAC;IAC7B,CAAC,SAAS,CAAC,iBAAiB,CAAC,EAAE,CAAC;IAChC,CAAC,SAAS,CAAC,gBAAgB,CAAC,EAAE,CAAC;IAC/B,CAAC,SAAS,CAAC,cAAc,CAAC,EAAE,CAAC;IAC7B,CAAC,SAAS,CAAC,gBAAgB,CAAC,EAAE,CAAC;IAC/B,CAAC,SAAS,CAAC,cAAc,CAAC,EAAE,CAAC;CAC9B,CAAC;AAEF,MAAM,OAAO,UAAW,SAAQ,KAAK;IACnC,IAAI,CAAY;IAEhB,YAAY,OAAe,EAAE,IAAe,EAAE,KAAe;QAC3D,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;QAC9C,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC;QACzB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED,QAAQ;QACN,OAAO,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACnC,CAAC;CACF;AAED,MAAM,CAAC,MAAM,gBAAgB,GAAG,UAAU,CAAC;AAE3C,MAAM,UAAU,WAAW,CAAC,KAAc;IACxC,IAAI,KAAK,YAAY,UAAU,EAAE,CAAC;QAChC,OAAO,IAAI,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC;IAC5C,CAAC;IACD,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC3B,OAAO,KAAK,CAAC,OAAO,CAAC;IACvB,CAAC;IACD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,KAAc;IACxC,OAAO,KAAK,YAAY,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AAC5D,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type { LoadConfigOptions, MobileAgentConfigFile, Platform, ResolvedConfig, } from './config.js';
|
|
2
|
+
export { assertPlatform, CONFIG_FILENAME, findConfigFile, loadConfig, parseEnvPairs, parsePorts, } from './config.js';
|
|
3
|
+
export { adbReverse } from './driver/adb.js';
|
|
4
|
+
export { detectLanIp, resolveDevServerEnv } from './driver/dev-server.js';
|
|
5
|
+
export { listDevices } from './driver/devices.js';
|
|
6
|
+
export type { DoctorCheck, DoctorStatus } from './driver/doctor.js';
|
|
7
|
+
export { doctorHasFailures, formatDoctorReport, runDoctor } from './driver/doctor.js';
|
|
8
|
+
export type { RunFlowOptions } from './driver/maestro.js';
|
|
9
|
+
export { requireMaestro, runMaestroFlow, runMaestroFlows } from './driver/maestro.js';
|
|
10
|
+
export { openUrl } from './driver/open-url.js';
|
|
11
|
+
export { captureScreenshot } from './driver/screenshot.js';
|
|
12
|
+
export { AgentError, ErrorCode, formatError, getExitCode, MobileAgentError } from './errors.js';
|
|
13
|
+
export type { McpToolDefinition } from './mcp/tools.js';
|
|
14
|
+
export { handleMcpToolCall, MCP_TOOLS } from './mcp/tools.js';
|
|
15
|
+
export { createRuntime, MobileAgentRuntime, Runtime } from './runtime.js';
|
|
16
|
+
export { PACKAGE_NAME, PACKAGE_VERSION } from './version.js';
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,iBAAiB,EACjB,qBAAqB,EACrB,QAAQ,EACR,cAAc,GACf,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,cAAc,EACd,eAAe,EACf,cAAc,EACd,UAAU,EACV,aAAa,EACb,UAAU,GACX,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC1E,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACtF,YAAY,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtF,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAChG,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { assertPlatform, CONFIG_FILENAME, findConfigFile, loadConfig, parseEnvPairs, parsePorts, } from './config.js';
|
|
2
|
+
export { adbReverse } from './driver/adb.js';
|
|
3
|
+
export { detectLanIp, resolveDevServerEnv } from './driver/dev-server.js';
|
|
4
|
+
export { listDevices } from './driver/devices.js';
|
|
5
|
+
export { doctorHasFailures, formatDoctorReport, runDoctor } from './driver/doctor.js';
|
|
6
|
+
export { requireMaestro, runMaestroFlow, runMaestroFlows } from './driver/maestro.js';
|
|
7
|
+
export { openUrl } from './driver/open-url.js';
|
|
8
|
+
export { captureScreenshot } from './driver/screenshot.js';
|
|
9
|
+
export { AgentError, ErrorCode, formatError, getExitCode, MobileAgentError } from './errors.js';
|
|
10
|
+
export { handleMcpToolCall, MCP_TOOLS } from './mcp/tools.js';
|
|
11
|
+
export { createRuntime, MobileAgentRuntime, Runtime } from './runtime.js';
|
|
12
|
+
export { PACKAGE_NAME, PACKAGE_VERSION } from './version.js';
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,cAAc,EACd,eAAe,EACf,cAAc,EACd,UAAU,EACV,aAAa,EACb,UAAU,GACX,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC1E,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEtF,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtF,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEhG,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Runtime } from '../runtime.js';
|
|
2
|
+
export interface McpToolDefinition {
|
|
3
|
+
name: string;
|
|
4
|
+
description: string;
|
|
5
|
+
inputSchema: Record<string, unknown>;
|
|
6
|
+
}
|
|
7
|
+
export declare const MCP_TOOLS: McpToolDefinition[];
|
|
8
|
+
export declare function handleMcpToolCall(runtime: Runtime, name: string, args: Record<string, unknown> | undefined): {
|
|
9
|
+
text: string;
|
|
10
|
+
isError?: boolean;
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/mcp/tools.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAE7C,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACtC;AAED,eAAO,MAAM,SAAS,EAAE,iBAAiB,EAsFxC,CAAC;AAeF,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,GACxC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CA2DrC"}
|