mobile-automator 0.32.0 → 0.35.0
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/LICENSE +198 -13
- package/README.md +3 -1
- package/package.json +1 -1
- package/src/cli.js +46 -13
- package/src/device/action-catalog.js +48 -4
- package/src/device/app-not-running.js +46 -0
- package/src/device/bridge.js +26 -0
- package/src/device/mobile-mcp-client.js +13 -0
- package/src/device/mobile-mcp-tools.js +1 -0
- package/src/guide/content/execute.agnostic.md +4 -3
- package/src/guide/content/execute.aware.md +5 -3
- package/src/guide/content/generate.agnostic.md +3 -2
- package/src/guide/content/generate.aware.md +4 -3
- package/src/guide/emitter.js +2 -1
- package/src/observe/telemetry.js +27 -0
- package/src/observe/vocab.js +1 -0
- package/src/scenario/replayability.js +85 -23
- package/src/schemas/scenario_schema.json +5 -0
package/LICENSE
CHANGED
|
@@ -1,17 +1,202 @@
|
|
|
1
|
-
Apache License
|
|
2
|
-
Version 2.0, January 2004
|
|
3
|
-
http://www.apache.org/licenses/
|
|
4
1
|
|
|
5
|
-
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
you may not use this file except in compliance with the License.
|
|
9
|
-
You may obtain a copy of the License at
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
10
7
|
|
|
11
|
-
|
|
8
|
+
1. Definitions.
|
|
12
9
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright 2025 mobile-automator contributors
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -124,7 +124,9 @@ In agnostic mode, OS-shaped gestures become four semantic actions — `press_bac
|
|
|
124
124
|
`mauto` collects nothing by default. Anonymous usage telemetry is opt-in via
|
|
125
125
|
`mauto telemetry enable`, sends no free text of any kind, and carries no
|
|
126
126
|
per-machine identifier.
|
|
127
|
-
`MAUTO_TELEMETRY=0` and `DO_NOT_TRACK=1` force it off.
|
|
127
|
+
`MAUTO_TELEMETRY=0` and `DO_NOT_TRACK=1` force it off. The device engine's own
|
|
128
|
+
telemetry (mobile-mcp's) is off by default too: `mauto` starts it with
|
|
129
|
+
`MOBILEMCP_DISABLE_TELEMETRY=1`. Run `mauto telemetry
|
|
128
130
|
status` for the exact field list, or read
|
|
129
131
|
[Telemetry & Privacy](https://sh3lan93.github.io/mobile-automator/reference/telemetry/).
|
|
130
132
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mobile-automator",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.35.0",
|
|
4
4
|
"description": "Host-agnostic mauto CLI for AI-driven mobile QA automation — analyzes a mobile project and drives devices through mobile-mcp.",
|
|
5
5
|
"homepage": "https://github.com/sh3lan93/mobile-automator#readme",
|
|
6
6
|
"repository": {
|
package/src/cli.js
CHANGED
|
@@ -10,7 +10,7 @@ const { ok, fail, render, exitCodeFor } = require('./output/envelope');
|
|
|
10
10
|
const selectionStore = require('./device/selection');
|
|
11
11
|
const { engineHint } = require('./device/engine-hints');
|
|
12
12
|
const { ScenarioValidator } = require('./scenario/validator');
|
|
13
|
-
const {
|
|
13
|
+
const { findReplayWarnings, summarize } = require('./scenario/replayability');
|
|
14
14
|
const { evaluate, MECHANICAL_TYPES } = require('./assertion/evaluator');
|
|
15
15
|
const { ResultStore } = require('./result/store');
|
|
16
16
|
const { OBSERVATION_TYPES, parseObservation, parseCapture, parseBool } = require('./result/flags');
|
|
@@ -245,15 +245,15 @@ function handleValidate({ validator }, file, opts = {}) {
|
|
|
245
245
|
|
|
246
246
|
const result = validator.validate(scenario);
|
|
247
247
|
if (result.valid) {
|
|
248
|
-
// Schema-valid is not the same as replayable: surface
|
|
249
|
-
//
|
|
250
|
-
//
|
|
251
|
-
const warnings =
|
|
248
|
+
// Schema-valid is not the same as replayable: surface findings by default
|
|
249
|
+
// so existing scenarios keep validating; `--strict` fails only on the
|
|
250
|
+
// blocking ones. Codes, severity and wording live in the replayability module.
|
|
251
|
+
const warnings = findReplayWarnings(scenario);
|
|
252
252
|
if (warnings.length === 0) {
|
|
253
253
|
return { envelope: ok({ valid: true }), exitKind: 'ok' };
|
|
254
254
|
}
|
|
255
|
-
const
|
|
256
|
-
if (opts.strict) {
|
|
255
|
+
const { blocking, hint } = summarize(warnings);
|
|
256
|
+
if (opts.strict && blocking.length > 0) {
|
|
257
257
|
const env = fail('invalid_input', 'scenario uses actions with no execution path', hint);
|
|
258
258
|
env.data = { valid: false, errors: [], warnings };
|
|
259
259
|
return { envelope: env, exitKind: 'invalid_input' };
|
|
@@ -398,7 +398,9 @@ async function handleDoubleTap({ deviceBridge }, raw) {
|
|
|
398
398
|
}
|
|
399
399
|
}
|
|
400
400
|
|
|
401
|
-
|
|
401
|
+
// Cold start by default (#255; the why lives in DeviceBridge#restartApp).
|
|
402
|
+
// `resume` opts out and keeps the old bring-to-front behaviour.
|
|
403
|
+
async function handleLaunch({ deviceBridge }, appId, { resume } = {}) {
|
|
402
404
|
const id = String(appId == null ? '' : appId);
|
|
403
405
|
if (!id) {
|
|
404
406
|
return {
|
|
@@ -407,8 +409,25 @@ async function handleLaunch({ deviceBridge }, appId) {
|
|
|
407
409
|
};
|
|
408
410
|
}
|
|
409
411
|
try {
|
|
410
|
-
|
|
411
|
-
|
|
412
|
+
const cold = !resume;
|
|
413
|
+
await (cold ? deviceBridge.restartApp(id) : deviceBridge.launchApp(id));
|
|
414
|
+
return { envelope: ok({ launched: id, cold }), exitKind: 'ok' };
|
|
415
|
+
} catch (err) {
|
|
416
|
+
return deviceFail(err);
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
async function handleTerminate({ deviceBridge }, appId) {
|
|
421
|
+
const id = String(appId == null ? '' : appId);
|
|
422
|
+
if (!id) {
|
|
423
|
+
return {
|
|
424
|
+
envelope: fail('invalid_input', 'an app id is required', 'e.g. mauto terminate com.example.app'),
|
|
425
|
+
exitKind: 'invalid_input',
|
|
426
|
+
};
|
|
427
|
+
}
|
|
428
|
+
try {
|
|
429
|
+
await deviceBridge.terminateApp(id);
|
|
430
|
+
return { envelope: ok({ terminated: id }), exitKind: 'ok' };
|
|
412
431
|
} catch (err) {
|
|
413
432
|
return deviceFail(err);
|
|
414
433
|
}
|
|
@@ -961,12 +980,18 @@ function setEngine({ projectRoot, env, store }, value) {
|
|
|
961
980
|
// field lists come from EVENT_FIELDS at runtime, so the disclosure a user reads
|
|
962
981
|
// before opting in cannot drift from what the uploader actually sends. Prose
|
|
963
982
|
// that restates a catalog is prose that will eventually be wrong.
|
|
964
|
-
|
|
983
|
+
//
|
|
984
|
+
// `engine` is the device engine's (mobile-mcp's) own telemetry (#213), a
|
|
985
|
+
// separate sender with a separate switch. It comes from the same resolver
|
|
986
|
+
// buildEngineEnv uses, so the report states what the engine is actually handed
|
|
987
|
+
// rather than a second opinion about it.
|
|
965
988
|
function telemetryReport({ projectRoot, env }, extra = {}) {
|
|
966
989
|
const decision = observeTelemetry.decideForProject(projectRoot, env);
|
|
990
|
+
const engine = observeTelemetry.resolveEngineTelemetry(env);
|
|
967
991
|
return {
|
|
968
992
|
enabled: decision.enabled,
|
|
969
993
|
reason: decision.reason,
|
|
994
|
+
engine: { enabled: engine.enabled, reason: engine.reason },
|
|
970
995
|
endpoint: observeTransport.endpointUrl(env),
|
|
971
996
|
fields_sent: observeTelemetry.sentFields(),
|
|
972
997
|
fields_never_sent: observeTelemetry.neverSentFields(),
|
|
@@ -1969,9 +1994,16 @@ function buildProgram(deps = {}) {
|
|
|
1969
1994
|
|
|
1970
1995
|
program
|
|
1971
1996
|
.command('launch <appId>')
|
|
1972
|
-
.description('Launch an installed app by its package/bundle id')
|
|
1997
|
+
.description('Launch an installed app by its package/bundle id, restarting it if it is already running')
|
|
1998
|
+
.option('--resume', 'bring a running app to the front instead of restarting it')
|
|
1999
|
+
.option('--device <id>', 'target device id')
|
|
2000
|
+
.action(withEnvelope((appId, opts) => withBridge(opts.device, (bridge) => handleLaunch({ deviceBridge: bridge }, appId, { resume: Boolean(opts.resume) }))));
|
|
2001
|
+
|
|
2002
|
+
program
|
|
2003
|
+
.command('terminate <appId>')
|
|
2004
|
+
.description('Stop a running app by its package/bundle id')
|
|
1973
2005
|
.option('--device <id>', 'target device id')
|
|
1974
|
-
.action(withEnvelope((appId, opts) => withBridge(opts.device, (bridge) =>
|
|
2006
|
+
.action(withEnvelope((appId, opts) => withBridge(opts.device, (bridge) => handleTerminate({ deviceBridge: bridge }, appId))));
|
|
1975
2007
|
|
|
1976
2008
|
program
|
|
1977
2009
|
.command('install <path>')
|
|
@@ -2602,6 +2634,7 @@ module.exports = {
|
|
|
2602
2634
|
handleSwipe,
|
|
2603
2635
|
handlePress,
|
|
2604
2636
|
handleLaunch,
|
|
2637
|
+
handleTerminate,
|
|
2605
2638
|
handleInstall,
|
|
2606
2639
|
handleUninstall,
|
|
2607
2640
|
handleOpenUrl,
|
|
@@ -10,7 +10,9 @@
|
|
|
10
10
|
//
|
|
11
11
|
// `resolution` declares the execution contract for each action:
|
|
12
12
|
// 'verb' — a dedicated one-shot `mauto` verb backed by a DeviceBridge
|
|
13
|
-
// method that calls
|
|
13
|
+
// method that calls one or more mobile-mcp primitives
|
|
14
|
+
// (`primitive` for one, `primitives` for an ordered sequence;
|
|
15
|
+
// read either through primitivesOf).
|
|
14
16
|
// 'semantic' — invoked via `mauto press <action>`; resolved to per-platform
|
|
15
17
|
// mechanics by src/device/semantic-press (see ACTION_METHOD).
|
|
16
18
|
// 'composed' — no dedicated verb; the agent composes it from existing verbs
|
|
@@ -23,6 +25,18 @@
|
|
|
23
25
|
// For 'verb' entries, `args` documents the mobile-mcp argument keys the bridge
|
|
24
26
|
// method must pass — deliberately explicit because the keys are inconsistent
|
|
25
27
|
// across the engine (launch=packageName, uninstall=bundle_id, install=path).
|
|
28
|
+
//
|
|
29
|
+
// `stepFlags` records a scenario step field that changes how the verb runs:
|
|
30
|
+
// `{ field, value, flag }` means "when step[field] === value, pass flag". This
|
|
31
|
+
// is the one place the mapping lives; the E2E harness derives the flags via
|
|
32
|
+
// stepFlagsFor and tests/lint/action-coverage.test.js checks the field, the
|
|
33
|
+
// verb's option and both execute guides against it.
|
|
34
|
+
//
|
|
35
|
+
// `warnWhenUnset` on a stepFlags entry names the advisory finding code for a
|
|
36
|
+
// step that leaves `field` unset: the field's schema default selects the
|
|
37
|
+
// no-flag behaviour, so an unset field is ambiguous about the author's intent.
|
|
38
|
+
// implicitStepFlags derives those entries; src/scenario/replayability.js turns
|
|
39
|
+
// them into findings and owns the wording and severity for each code.
|
|
26
40
|
|
|
27
41
|
const ACTION_CATALOG = {
|
|
28
42
|
// --- direct verbs (engine-backed) --------------------------------------
|
|
@@ -51,8 +65,11 @@ const ACTION_CATALOG = {
|
|
|
51
65
|
primitive: 'mobile_press_button', args: ['button'],
|
|
52
66
|
},
|
|
53
67
|
launch_app: {
|
|
54
|
-
|
|
55
|
-
|
|
68
|
+
// Cold start (#255): restartApp terminates, then launches.
|
|
69
|
+
resolution: 'verb', verb: 'launch', bridge: 'restartApp',
|
|
70
|
+
primitives: ['mobile_terminate_app', 'mobile_launch_app'], args: ['packageName'],
|
|
71
|
+
// `cold: false` opts out of the restart (#255).
|
|
72
|
+
stepFlags: [{ field: 'cold', value: false, flag: '--resume', warnWhenUnset: 'launch_cold_implicit' }],
|
|
56
73
|
},
|
|
57
74
|
install_app: {
|
|
58
75
|
resolution: 'verb', verb: 'install', bridge: 'installApp',
|
|
@@ -96,4 +113,31 @@ function actionsByResolution(resolution) {
|
|
|
96
113
|
return Object.keys(ACTION_CATALOG).filter((a) => ACTION_CATALOG[a].resolution === resolution);
|
|
97
114
|
}
|
|
98
115
|
|
|
99
|
-
|
|
116
|
+
// The mobile-mcp primitives a 'verb' entry's bridge method calls, in order.
|
|
117
|
+
function primitivesOf(def) {
|
|
118
|
+
if (!def) return [];
|
|
119
|
+
if (Array.isArray(def.primitives)) return def.primitives.slice();
|
|
120
|
+
return def.primitive ? [def.primitive] : [];
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// The verb flags a scenario step's fields select for `action`, derived from
|
|
124
|
+
// the entry's `stepFlags`. [] when the action has none or is unknown.
|
|
125
|
+
function stepFlagsFor(action, step) {
|
|
126
|
+
const def = Object.prototype.hasOwnProperty.call(ACTION_CATALOG, action) ? ACTION_CATALOG[action] : null;
|
|
127
|
+
if (!def || !Array.isArray(def.stepFlags) || !step || typeof step !== 'object') return [];
|
|
128
|
+
return def.stepFlags.filter((sf) => step[sf.field] === sf.value).map((sf) => sf.flag);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// The stepFlags entries carrying a `warnWhenUnset` marker whose field the step
|
|
132
|
+
// leaves unset (not an own property). [] for an unknown action or a non-object
|
|
133
|
+
// step.
|
|
134
|
+
function implicitStepFlags(action, step) {
|
|
135
|
+
const def = ACTION_CATALOG[action];
|
|
136
|
+
if (!def || !Array.isArray(def.stepFlags) || !step || typeof step !== 'object') return [];
|
|
137
|
+
return def.stepFlags.filter((sf) => sf.warnWhenUnset
|
|
138
|
+
&& !Object.prototype.hasOwnProperty.call(step, sf.field));
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
module.exports = {
|
|
142
|
+
ACTION_CATALOG, RESOLUTIONS, actionsByResolution, primitivesOf, stepFlagsFor, implicitStepFlags,
|
|
143
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// Classifies the one terminate failure that still leaves the app stopped: the
|
|
4
|
+
// app was not running in the first place. DeviceBridge#restartApp (#255) uses
|
|
5
|
+
// it to tolerate exactly that case and treat every other terminate failure as
|
|
6
|
+
// a real fault. Pure: error in, boolean out. It never throws — a classifier
|
|
7
|
+
// that crashed would turn a device failure into an internal one.
|
|
8
|
+
//
|
|
9
|
+
// Only engines/targets with known evidence get a pattern. An unrecognised
|
|
10
|
+
// message is deliberately NOT tolerated: restartApp fails loudly and hints at
|
|
11
|
+
// `--resume`, which is honest, rather than claiming a cold start it cannot
|
|
12
|
+
// vouch for.
|
|
13
|
+
//
|
|
14
|
+
// No pattern is needed for Android: `am force-stop` (both engines) succeeds
|
|
15
|
+
// for an app that is not running, and even for one that is not installed
|
|
16
|
+
// (device-probed on an emulator, mobilecli and legacy engines).
|
|
17
|
+
//
|
|
18
|
+
// Legacy engine, real iOS (go-ios `ios kill`): message unknown, no pattern, so
|
|
19
|
+
// it is fatal until someone captures it.
|
|
20
|
+
|
|
21
|
+
const NOT_RUNNING_PATTERNS = [
|
|
22
|
+
// iOS simulator, BOTH engines (the legacy engine still drives simulators
|
|
23
|
+
// through mobilecli). simctl terminate exits 3 (ESRCH, "found nothing to
|
|
24
|
+
// terminate"); mobilecli drops simctl's output so only the exit status
|
|
25
|
+
// survives. Device-probed (mobilecli 1.0.13 via mobile-mcp 1.0.5).
|
|
26
|
+
// A NOT-INSTALLED app yields the identical message; tolerating it is safe
|
|
27
|
+
// because the launch that follows fails loudly for an app that is missing.
|
|
28
|
+
/xcrun simctl command: exit status 3\b/,
|
|
29
|
+
// Real iOS, mobilecli engine. Source-verified (mobilecli 1.0.13
|
|
30
|
+
// devices/ios.go TerminateApp returns `process of <bundle> not found`,
|
|
31
|
+
// wrapped by commands/apps.go), not device-probed.
|
|
32
|
+
/: process of \S+ not found\b/,
|
|
33
|
+
];
|
|
34
|
+
|
|
35
|
+
function isAppNotRunning(err) {
|
|
36
|
+
try {
|
|
37
|
+
if (!(err instanceof Error)) return false;
|
|
38
|
+
const message = err.message;
|
|
39
|
+
if (typeof message !== 'string' || !message) return false;
|
|
40
|
+
return NOT_RUNNING_PATTERNS.some((re) => re.test(message));
|
|
41
|
+
} catch {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
module.exports = { isAppNotRunning };
|
package/src/device/bridge.js
CHANGED
|
@@ -5,6 +5,7 @@ const { normalizeDevices } = require('./device-model');
|
|
|
5
5
|
const { normalizeCrashes } = require('./crash-model');
|
|
6
6
|
const { resolveSingleDevice } = require('./device-resolver');
|
|
7
7
|
const { centredSwipe } = require('./swipe-geometry');
|
|
8
|
+
const { isAppNotRunning } = require('./app-not-running');
|
|
8
9
|
|
|
9
10
|
// Thin wrapper over an injected mobile-mcp `call(toolName, args)` function.
|
|
10
11
|
// Returns the agnostic element model and exposes only the primitives the CLI needs.
|
|
@@ -143,6 +144,31 @@ class DeviceBridge {
|
|
|
143
144
|
return await this._call('mobile_launch_app', { packageName });
|
|
144
145
|
}
|
|
145
146
|
|
|
147
|
+
// Stop a running app by its package/bundle identifier.
|
|
148
|
+
async terminateApp(packageName) {
|
|
149
|
+
return await this._call('mobile_terminate_app', { packageName });
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// Cold start (#255): mobile_launch_app alone brings a running app to the
|
|
153
|
+
// front with its state kept, so stop it first. "Not running" is the one
|
|
154
|
+
// terminate failure that still yields a cold start (iOS reports it as an
|
|
155
|
+
// error; Android does not); anything else is a real fault and propagates,
|
|
156
|
+
// carrying a hint that names the opt-out.
|
|
157
|
+
async restartApp(packageName) {
|
|
158
|
+
try {
|
|
159
|
+
await this.terminateApp(packageName);
|
|
160
|
+
} catch (err) {
|
|
161
|
+
if (!isAppNotRunning(err)) {
|
|
162
|
+
if (err && typeof err === 'object' && !err.hint) {
|
|
163
|
+
err.hint =
|
|
164
|
+
'Could not stop the app before restarting it. Pass --resume to bring it to the front without restarting.';
|
|
165
|
+
}
|
|
166
|
+
throw err;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return await this.launchApp(packageName);
|
|
170
|
+
}
|
|
171
|
+
|
|
146
172
|
// Install an app from a local artifact (apk/ipa) path.
|
|
147
173
|
async installApp(appPath) {
|
|
148
174
|
return await this._call('mobile_install_app', { path: appPath });
|
|
@@ -6,6 +6,7 @@ const { StdioClientTransport } = require('@modelcontextprotocol/sdk/client/stdio
|
|
|
6
6
|
const { injectDeviceArg } = require('./tool-args');
|
|
7
7
|
const { resolveSingleDevice } = require('./device-resolver');
|
|
8
8
|
const { normalizeDevices } = require('./device-model');
|
|
9
|
+
const { resolveEngineTelemetry } = require('../observe/telemetry');
|
|
9
10
|
const { ErrorCode } = require('@modelcontextprotocol/sdk/types.js');
|
|
10
11
|
|
|
11
12
|
// Bound on mobile-mcp's MCP initialize handshake (#156). Measured at ~200ms on
|
|
@@ -68,10 +69,22 @@ function resolveServerEntry() {
|
|
|
68
69
|
// resolveEngine reports the env as the source so the recorded engine matches
|
|
69
70
|
// the one that runs. Unlike the URL guard, a running daemon on the other
|
|
70
71
|
// engine needs no manual `session end`: resolve-connection.js restarts it.
|
|
72
|
+
//
|
|
73
|
+
// MOBILEMCP_DISABLE_TELEMETRY defaults to "1" (#213). Left unset, mobile-mcp
|
|
74
|
+
// sends a PostHog event on every tool call and a scarf.sh pixel once per
|
|
75
|
+
// process. mauto's own telemetry is opt-in, and an engine it spawns on the
|
|
76
|
+
// user's behalf should not be quietly opt-out. The engine's gate is truthiness,
|
|
77
|
+
// so any non-empty value keeps it off and only an explicit empty string
|
|
78
|
+
// (MOBILEMCP_DISABLE_TELEMETRY=) opts back in; a user-set value is passed
|
|
79
|
+
// through verbatim. MAUTO_TELEMETRY=0 and DO_NOT_TRACK=1 force it off whatever
|
|
80
|
+
// the user set. The decision lives in resolveEngineTelemetry so that
|
|
81
|
+
// `mauto telemetry status` reports exactly what this hands the engine, and the
|
|
82
|
+
// same `mauto session end` rule applies to a change.
|
|
71
83
|
function buildEngineEnv({ device = null, baseEnv = process.env, engine = null } = {}) {
|
|
72
84
|
const env = {
|
|
73
85
|
...baseEnv,
|
|
74
86
|
MOBILEMCP_ALLOW_UNSAFE_URLS: baseEnv.MOBILEMCP_ALLOW_UNSAFE_URLS ?? '1',
|
|
87
|
+
MOBILEMCP_DISABLE_TELEMETRY: resolveEngineTelemetry(baseEnv).disableValue,
|
|
75
88
|
};
|
|
76
89
|
if (engine === 'legacy' && baseEnv.MOBILEMCP_LEGACY_ROBOT === undefined) {
|
|
77
90
|
env.MOBILEMCP_LEGACY_ROBOT = '1';
|
|
@@ -62,7 +62,7 @@ Record each observation with `mauto result add-step --observation <type>:<messag
|
|
|
62
62
|
- If the install fails because a different build is already on the device, uninstall it with `mauto uninstall <appId>` (the app identifier from `mobile-automator/config.json` — `android_package` / `ios_bundle_id`), install again, and report that app data was wiped — a scenario whose preconditions assume existing app state may now fail for that reason.
|
|
63
63
|
- State which path you took before continuing.
|
|
64
64
|
5. **Validate schema version:** read the `$schema_version` field; it must be `"2.1"`. If absent or unrecognized, report an error and halt.
|
|
65
|
-
6. Validate the scenario with `mauto validate <path>` against `mauto schema scenario`. If the result lists `data.warnings`, each entry (its `path` names the step or precondition) uses an action that is unsupported on this run: report it as unsupported in the result (see "Not mechanically executable" under step execution) and do not substitute a gesture for it.
|
|
65
|
+
6. Validate the scenario with `mauto validate <path>` against `mauto schema scenario`. If the result lists `data.warnings`, branch on each entry's `code` (its `path` names the step or precondition): `unsupported_action` means it uses an action that is unsupported on this run: report it as unsupported in the result (see "Not mechanically executable" under step execution) and do not substitute a gesture for it. `launch_cold_implicit` is advisory: replay that step exactly as written (a step that does not set `"cold": false` is a cold start, per the step table below) and do not substitute your own reading of what the author meant; record the warning's `message` as a `state_context` observation on that step (`mauto result add-step ... --observation state_context:<message>`).
|
|
66
66
|
|
|
67
67
|
**Precondition `device_actions`** (from the scenario's `preconditions`, run before step replay):
|
|
68
68
|
|
|
@@ -100,7 +100,8 @@ For each step in the scenario:
|
|
|
100
100
|
1. **Wait for prior stability:** poll `mauto elements` until loading indicators ({{loading_indicators}}) are absent before continuing.
|
|
101
101
|
2. **Resolve the target:** for actions with a target, run `mauto elements` to locate by semantic description; never use stored coordinates. If `target_pattern` is set, use it as a regex to filter elements by text.
|
|
102
102
|
3. **Execute the action:**
|
|
103
|
-
- Standard actions → run the corresponding `mauto` verb: `tap` → `mauto tap --at <x,y>`, `long_press` → `mauto long-press --at <x,y>` (optional `--duration <ms>`), `double_tap` → `mauto double-tap --at <x,y>`, `swipe` / `scroll_to_element` → `mauto swipe --direction <dir>`, `type` → `mauto type <text>`, `press_button` → `mauto press <button>`, `launch_app` → `mauto launch <appId
|
|
103
|
+
- Standard actions → run the corresponding `mauto` verb: `tap` → `mauto tap --at <x,y>`, `long_press` → `mauto long-press --at <x,y>` (optional `--duration <ms>`), `double_tap` → `mauto double-tap --at <x,y>`, `swipe` / `scroll_to_element` → `mauto swipe --direction <dir>`, `type` → `mauto type <text>`, `press_button` → `mauto press <button>`, `launch_app` → `mauto launch <appId>` (add `--resume` when the step sets `"cold": false`), `open_url` → `mauto open-url <url>`, `wait_for_*` → poll `mauto elements`, `capture_value` → `mauto elements` (extract text). Resolve coordinates from the latest `mauto elements` output.
|
|
104
|
+
- `launch_app` restarts the app so the step starts on its initial screen; `--resume` instead brings a running app to the front in its current state. A plain launch resets the screen, not app data: `app_state: "fresh_install"` is still the data reset. It returns `{launched, cold}`; an app that is not running is simply started. If the app cannot be stopped, the launch fails with a device error and a hint to use `--resume` — record the step as failed rather than retrying blindly.
|
|
104
105
|
- Semantic actions → run `mauto press <action>` and let the CLI resolve them for the connected device.
|
|
105
106
|
- Not mechanically executable → `clear_app_data` (and the precondition device actions `enable_wifi` / `disable_wifi`) have no verb and no underlying primitive. Do NOT substitute a gesture: report them honestly as unsupported on this run, or perform them manually out of band if the run depends on them.
|
|
106
107
|
4. **Capture screenshot:** Run `mauto screenshot mobile-automator/screenshots/<scenario_id>/<run_id>/step_<step_id>.png`.
|
|
@@ -229,7 +230,7 @@ When neither attempt succeeds, fail the step and add a detailed observation desc
|
|
|
229
230
|
|
|
230
231
|
## Multi-Scenario Execution
|
|
231
232
|
|
|
232
|
-
- Execute scenarios sequentially
|
|
233
|
+
- Execute scenarios sequentially. Each scenario's leading `launch_app` restarts the app (`mauto launch <appId>`), so a scenario never inherits the previous one's screen and needs no separate reset; use `app_state: "fresh_install"` only when app data must be wiped too.
|
|
233
234
|
- "run all smoke tests" → filter by the `smoke` tag. "run all" → every scenario in `mobile-automator/scenarios/`.
|
|
234
235
|
- Present a combined summary with a per-scenario breakdown.
|
|
235
236
|
|
|
@@ -63,7 +63,7 @@ Record each observation with `mauto result add-step --observation <type>:<messag
|
|
|
63
63
|
|
|
64
64
|
- Read the JSON scenario file from `mobile-automator/scenarios/`.
|
|
65
65
|
- **Validate schema version:** Read the `$schema_version` field. It must be `"2.1"`. If absent or unrecognized, report an error and halt.
|
|
66
|
-
- Validate the scenario with `mauto validate <path>` against `mauto schema scenario`. If the result lists `data.warnings`, each entry (its `path` names the step or precondition) uses an action that is unsupported on this run: report it as unsupported in the result, as described under "Not mechanically executable" below, and do not substitute a gesture for it.
|
|
66
|
+
- Validate the scenario with `mauto validate <path>` against `mauto schema scenario`. If the result lists `data.warnings`, branch on each entry's `code` (its `path` names the step or precondition): `unsupported_action` means it uses an action that is unsupported on this run: report it as unsupported in the result, as described under "Not mechanically executable" below, and do not substitute a gesture for it. `launch_cold_implicit` is advisory: replay that step exactly as written (a step that does not set `"cold": false` is a cold start, per the step table below) and do not substitute your own reading of what the author meant; record the warning's `message` as a `state_context` observation on that step (`mauto result add-step ... --observation state_context:<message>`).
|
|
67
67
|
- Read the `metadata` to compare the recording environment against the current execution environment. Note any differences (different device, API level, environment).
|
|
68
68
|
|
|
69
69
|
### 3. Verify Preconditions
|
|
@@ -104,7 +104,7 @@ For each step in the scenario:
|
|
|
104
104
|
|
|
105
105
|
| Action | `mauto` verb | Notes |
|
|
106
106
|
|---|---|---|
|
|
107
|
-
| `launch_app` | `mauto launch <appId>` | `appId` from config / scenario metadata |
|
|
107
|
+
| `launch_app` | `mauto launch <appId>` (add `--resume` when the step sets `"cold": false`) | `appId` from config / scenario metadata. Restarts the app so the step starts on its initial screen; `--resume` brings a running app to the front in its current state instead |
|
|
108
108
|
| `tap` | `mauto tap --at <x,y>` | Find element first via `mauto elements` |
|
|
109
109
|
| `long_press` | `mauto long-press --at <x,y>` | Optional `--duration <ms>` |
|
|
110
110
|
| `double_tap` | `mauto double-tap --at <x,y>` | |
|
|
@@ -118,6 +118,8 @@ For each step in the scenario:
|
|
|
118
118
|
| `wait_for_loading_complete` | Poll `mauto screenshot <path>` + visual check | Wait for loading indicators ({{loading_indicators}}) to be absent |
|
|
119
119
|
| `capture_value` | `mauto elements` | Extract text from the target element, store in the `capture_to` variable |
|
|
120
120
|
|
|
121
|
+
A plain `mauto launch` resets the screen, not app data: `app_state: "fresh_install"` is still the data reset. It returns `{launched, cold}`; an app that is not running is simply started. If the app cannot be stopped, the launch fails with a device error and a hint to use `--resume` — record the step as failed rather than retrying blindly.
|
|
122
|
+
|
|
121
123
|
**Precondition `device_actions`** (run before the step replay, from the scenario's `preconditions`):
|
|
122
124
|
|
|
123
125
|
| Device action | `mauto` verb | Notes |
|
|
@@ -301,7 +303,7 @@ State context:
|
|
|
301
303
|
When asked to run multiple scenarios:
|
|
302
304
|
|
|
303
305
|
- Execute them sequentially.
|
|
304
|
-
-
|
|
306
|
+
- Each scenario's leading `launch_app` restarts the app (`mauto launch <appId>`), so a scenario never inherits the previous one's screen and needs no separate reset. Use `app_state: "fresh_install"` only when app data must be wiped too.
|
|
305
307
|
- If the user says "run all smoke tests", filter scenarios by the `smoke` tag.
|
|
306
308
|
- If the user says "run all", execute every scenario in `mobile-automator/scenarios/`.
|
|
307
309
|
- Present a combined summary at the end with a per-scenario breakdown.
|
|
@@ -98,7 +98,8 @@ Translate user language to action types and `mauto` verbs:
|
|
|
98
98
|
|
|
99
99
|
| User says | Action type | `mauto` verb | Notes |
|
|
100
100
|
|---|---|---|---|
|
|
101
|
-
| "open the app", "launch" | `launch_app` | `mauto
|
|
101
|
+
| "open the app", "launch" | `launch_app` | `mauto launch <appId>` | Restarts the app by default, so the step starts on its initial screen |
|
|
102
|
+
| "return to the app", "resume the app" | `launch_app` with `"cold": false` | `mauto launch <appId> --resume` | Brings a running app to the front in its current state; without `"cold": false`, `launch_app` restarts the app |
|
|
102
103
|
| "uninstall", "remove the app" | (precondition `device_action`) | uninstall before scenario | |
|
|
103
104
|
| "clear app data", "fresh install" | `uninstall_app` + `install_app` | reset app to a clean state before scenario | Set `app_state: "fresh_install"` in preconditions and add `device_actions`: `[{ "action": "uninstall_app" }, { "action": "install_app" }]`. Leave out `target_package` and `value`: a cross-platform scenario must not bake in one platform's app identifier or build path, and the executor fills both per platform from config and the pre-flight build |
|
|
104
105
|
| "tap", "click", "press" | `tap` | `mauto tap --at <x,y>` | Resolve coords from `mauto elements` |
|
|
@@ -202,7 +203,7 @@ After all steps are executed and recorded:
|
|
|
202
203
|
2. Obtain the scenario schema by running `mauto schema scenario`, and assemble the JSON scenario to match it. Include the `tags` array.
|
|
203
204
|
3. **Always include `"$schema_version": "2.1"` as the first field** in agnostic-mode scenarios.
|
|
204
205
|
4. **Use named string IDs** for all steps and assertions (snake_case, e.g., `"id": "tap_login"`).
|
|
205
|
-
5. Validate the assembled scenario with `mauto validate <path>` against `mauto schema scenario`. If it returns `data.warnings`, revise the scenario to drop
|
|
206
|
+
5. Validate the assembled scenario with `mauto validate <path>` against `mauto schema scenario`. If it returns `data.warnings`, revise the scenario to drop each `unsupported_action` step, or tell the user the step needs manual handling; for a `launch_cold_implicit` entry, set the step's `cold` explicitly (`false` when it means returning to the already-open app, `true` when it means a restart).
|
|
206
207
|
6. Save to `mobile-automator/scenarios/<scenario_id>.json`.
|
|
207
208
|
7. Present summary:
|
|
208
209
|
> "Scenario saved: `mobile-automator/scenarios/<scenario_id>.json`
|
|
@@ -217,7 +217,7 @@ After all steps are executed and recorded:
|
|
|
217
217
|
- `app_version` — from the installed app
|
|
218
218
|
- `environment` — ask the user or use `default_environment` from `mobile-automator/config.json`
|
|
219
219
|
- Do NOT include `device_model`, `api_level`, or `timestamp` in metadata — these belong in the result schema, not the scenario.
|
|
220
|
-
7. Validate the assembled scenario with `mauto validate <path>` against `mauto schema scenario`. If it returns `data.warnings`, revise the scenario to drop
|
|
220
|
+
7. Validate the assembled scenario with `mauto validate <path>` against `mauto schema scenario`. If it returns `data.warnings`, revise the scenario to drop each `unsupported_action` step, or tell the user the step needs manual handling; for a `launch_cold_implicit` entry, set the step's `cold` explicitly (`false` when it means returning to the already-open app, `true` when it means a restart).
|
|
221
221
|
8. Save to `mobile-automator/scenarios/<scenario_id>.json`.
|
|
222
222
|
9. Present summary:
|
|
223
223
|
> "Scenario saved: `mobile-automator/scenarios/<scenario_id>.json`
|
|
@@ -230,7 +230,8 @@ Translate user language to `mauto` verbs and schema actions:
|
|
|
230
230
|
|
|
231
231
|
| User says | Action | `mauto` verb | Notes |
|
|
232
232
|
|---|---|---|---|
|
|
233
|
-
| "open the app", "launch" | `launch_app` | `mauto
|
|
233
|
+
| "open the app", "launch" | `launch_app` | `mauto launch <appId>` | Restarts the app by default, so the step starts on its initial screen |
|
|
234
|
+
| "return to the app", "resume the app" | `launch_app` with `"cold": false` | `mauto launch <appId> --resume` | Brings a running app to the front in its current state; without `"cold": false`, `launch_app` restarts the app |
|
|
234
235
|
| "uninstall", "remove the app" | (precondition device_action) | uninstall before scenario | Use `device_actions` in `preconditions` block |
|
|
235
236
|
| "clear app data", "fresh install" | `uninstall_app` + `install_app` | reset app to a clean state before scenario | Set `app_state: "fresh_install"` in preconditions and add `device_actions`: `uninstall_app` then `install_app`. Both fields are optional: `target_package` defaults to the config app package ({{app_package}}) and `install_app` `value` defaults to the build installed in pre-flight; set them only to override those |
|
|
236
237
|
| "tap", "click", "press" | `tap` | `mauto tap --at <x,y>` | Resolve `<x,y>` from `mauto elements` |
|
|
@@ -268,7 +269,7 @@ Translate user language to `mauto` verbs and schema actions:
|
|
|
268
269
|
- Create assertion step using mapped type from Pass 2b
|
|
269
270
|
- Evaluate via `mauto assert <type> ...` and record with appropriate fields
|
|
270
271
|
6. Combine steps and assertions into ordered scenario
|
|
271
|
-
7. Generate scenario JSON, then `mauto validate <path>` (if it returns `data.warnings`, revise the scenario to drop
|
|
272
|
+
7. Generate scenario JSON, then `mauto validate <path>` (if it returns `data.warnings`, revise the scenario to drop each `unsupported_action` step, or tell the user the step needs manual handling; for a `launch_cold_implicit` entry, set the step's `cold` explicitly)
|
|
272
273
|
```
|
|
273
274
|
|
|
274
275
|
### Detecting and Encoding Patterns
|
package/src/guide/emitter.js
CHANGED
|
@@ -102,7 +102,8 @@ function emitBootstrap() {
|
|
|
102
102
|
['type', 'type text into the focused element'],
|
|
103
103
|
['swipe', 'swipe in a cardinal direction'],
|
|
104
104
|
['press', 'press a system/hardware button or semantic action'],
|
|
105
|
-
['launch', 'launch an installed app by its package/bundle id'],
|
|
105
|
+
['launch', 'launch an installed app by its package/bundle id, restarting it if running (--resume keeps its state)'],
|
|
106
|
+
['terminate', 'stop a running app by its package/bundle id'],
|
|
106
107
|
['install', 'install an app from a local artifact path'],
|
|
107
108
|
['uninstall', 'uninstall an app by its package/bundle id'],
|
|
108
109
|
['open-url', 'open a URL (deep link or web) on the device'],
|
package/src/observe/telemetry.js
CHANGED
|
@@ -49,6 +49,9 @@ const CONSENT_NOTICE = [
|
|
|
49
49
|
'Run `mauto telemetry status` to see the exact field list, read from the same',
|
|
50
50
|
'catalog the uploader uses. Run `mauto telemetry enable` to turn it on, or set',
|
|
51
51
|
'MAUTO_TELEMETRY=0 (or DO_NOT_TRACK=1) to force it off everywhere.',
|
|
52
|
+
'',
|
|
53
|
+
'The device engine mauto drives (mobile-mcp) has telemetry of its own, and it',
|
|
54
|
+
'is off too: mauto starts it with MOBILEMCP_DISABLE_TELEMETRY=1.',
|
|
52
55
|
].join('\n');
|
|
53
56
|
|
|
54
57
|
function envKillSwitch(env = process.env) {
|
|
@@ -70,6 +73,29 @@ function resolveTelemetry({ env = process.env, config = null } = {}) {
|
|
|
70
73
|
return { enabled: true, reason: 'enabled' };
|
|
71
74
|
}
|
|
72
75
|
|
|
76
|
+
// The device engine's own telemetry (#213). mobile-mcp sends a PostHog event
|
|
77
|
+
// per tool call and a scarf.sh pixel per process unless
|
|
78
|
+
// MOBILEMCP_DISABLE_TELEMETRY is set, and its gate is a plain truthiness check:
|
|
79
|
+
// any non-empty string turns it off, and only an empty string leaves it on.
|
|
80
|
+
//
|
|
81
|
+
// mauto's own telemetry is opt-in, so an engine mauto spawns must not be
|
|
82
|
+
// opt-out — the default here is off. The user's opt-in is the engine's own
|
|
83
|
+
// variable, passed through verbatim the way #212 passes through
|
|
84
|
+
// MOBILEMCP_ALLOW_UNSAFE_URLS: if they set it at all, even to '', they meant
|
|
85
|
+
// it. The env kill switches still win, because they promise "nothing leaves
|
|
86
|
+
// this machine", and a promise with an exception is not one.
|
|
87
|
+
//
|
|
88
|
+
// One function decides, and both buildEngineEnv (what the engine receives) and
|
|
89
|
+
// `mauto telemetry status` (what the user is told) call it, so the env and the
|
|
90
|
+
// report cannot disagree.
|
|
91
|
+
function resolveEngineTelemetry(env = process.env) {
|
|
92
|
+
const killed = envKillSwitch(env);
|
|
93
|
+
if (killed) return { disableValue: '1', enabled: false, reason: killed };
|
|
94
|
+
const value = env && env.MOBILEMCP_DISABLE_TELEMETRY;
|
|
95
|
+
if (value === undefined) return { disableValue: '1', enabled: false, reason: 'default_off' };
|
|
96
|
+
return { disableValue: value, enabled: value === '', reason: 'user_env' };
|
|
97
|
+
}
|
|
98
|
+
|
|
73
99
|
// Memoised per project root. resolveLevels() is re-derived per record() call
|
|
74
100
|
// because it reads only env; this one reads config.json, and a file read per
|
|
75
101
|
// event is not acceptable on a path that runs on every verb.
|
|
@@ -135,6 +161,7 @@ module.exports = {
|
|
|
135
161
|
REASONS,
|
|
136
162
|
envKillSwitch,
|
|
137
163
|
resolveTelemetry,
|
|
164
|
+
resolveEngineTelemetry,
|
|
138
165
|
decideForProject,
|
|
139
166
|
setEnabled,
|
|
140
167
|
_resetMemo,
|
package/src/observe/vocab.js
CHANGED
|
@@ -1,59 +1,121 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
// Replayability check for scenarios
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
3
|
+
// Replayability check for scenarios. Schema validity alone overstates what a
|
|
4
|
+
// scenario will do on replay; this module reports two kinds of gap:
|
|
5
|
+
//
|
|
6
|
+
// - `unsupported_action` (#166): the schema accepts every action in its enum,
|
|
7
|
+
// but the action catalog marks some `unsupported`. mobile-mcp exposes no
|
|
8
|
+
// primitive for them, so no `mauto` verb can run them and the step can never
|
|
9
|
+
// replay unattended. Blocking: `mauto validate --strict` fails on it.
|
|
10
|
+
// - `launch_cold_implicit` (#255): a catalog `stepFlags` entry marked
|
|
11
|
+
// `warnWhenUnset`. A step after the first that leaves the marked field to its
|
|
12
|
+
// schema default is ambiguous about the author's intent. Advisory: it never
|
|
13
|
+
// fails `--strict`.
|
|
8
14
|
//
|
|
9
15
|
// The unsupported set is derived from the catalog, never restated here, so it
|
|
10
16
|
// moves when an action gains (or loses) a device primitive.
|
|
11
17
|
|
|
12
|
-
const { actionsByResolution } = require('../device/action-catalog');
|
|
18
|
+
const { actionsByResolution, implicitStepFlags } = require('../device/action-catalog');
|
|
13
19
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
// Severity and wording for every finding code live here and nowhere else.
|
|
21
|
+
// `blocking` is the `--strict` policy: only a step that cannot run at all fails
|
|
22
|
+
// validation. `clause(n)` is the hint fragment for n findings of the code;
|
|
23
|
+
// `message(f)` is the per-finding text. Advisory codes other than
|
|
24
|
+
// `unsupported_action` are the catalog's `warnWhenUnset` markers.
|
|
25
|
+
const CODES = {
|
|
26
|
+
unsupported_action: {
|
|
27
|
+
blocking: true,
|
|
28
|
+
clause: (n) => `${n} action(s) cannot replay unattended`,
|
|
29
|
+
message: (f) => `${f.action} has no execution path in mauto; this step cannot replay unattended`,
|
|
30
|
+
},
|
|
31
|
+
launch_cold_implicit: {
|
|
32
|
+
blocking: false,
|
|
33
|
+
clause: (n) => `${n} step(s) leave an optional field unset; set it explicitly`,
|
|
34
|
+
message: (f) => `${f.action} leaves "${f.field}" unset, so it restarts the app; `
|
|
35
|
+
+ `set "${f.field}" explicitly (${JSON.stringify(f.value)} to return to the running app, `
|
|
36
|
+
+ `${JSON.stringify(!f.value)} to confirm the restart)`,
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
function makeFinding(code, fields, path, stepId) {
|
|
41
|
+
const f = { code, action: fields.action, path, message: CODES[code].message(fields) };
|
|
21
42
|
if (stepId !== undefined) f.step_id = stepId;
|
|
22
43
|
return f;
|
|
23
44
|
}
|
|
24
45
|
|
|
46
|
+
function unsupportedFinding(action, path, stepId) {
|
|
47
|
+
return makeFinding('unsupported_action', { action }, path, stepId);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// One advisory per catalog marker: the step leaves `sf.field` unset, so the
|
|
51
|
+
// field's default decides. The catalog owns action/field/value.
|
|
52
|
+
function implicitFinding(action, sf, path, stepId) {
|
|
53
|
+
return makeFinding(sf.warnWhenUnset, { action, field: sf.field, value: sf.value }, path, stepId);
|
|
54
|
+
}
|
|
55
|
+
|
|
25
56
|
// Walks a step list depth-first in document order, descending into each
|
|
26
57
|
// step's `sub_steps` (the schema types them as steps, so they nest freely).
|
|
27
|
-
function scanSteps(steps, basePath, unsupported, findings) {
|
|
58
|
+
function scanSteps(steps, basePath, unsupported, findings, topLevel) {
|
|
28
59
|
if (!Array.isArray(steps)) return;
|
|
29
60
|
steps.forEach((step, i) => {
|
|
30
61
|
if (!step) return;
|
|
31
62
|
const path = `${basePath}[${i}]`;
|
|
32
63
|
if (unsupported.has(step.action)) {
|
|
33
|
-
findings.push(
|
|
64
|
+
findings.push(unsupportedFinding(step.action, path, step.id));
|
|
34
65
|
}
|
|
35
|
-
|
|
66
|
+
// Only the scenario's first top-level step is unambiguously a fresh
|
|
67
|
+
// start; any other step that leaves a marked field unset is worth a look.
|
|
68
|
+
if (!(topLevel && i === 0)) {
|
|
69
|
+
for (const sf of implicitStepFlags(step.action, step)) {
|
|
70
|
+
findings.push(implicitFinding(step.action, sf, path, step.id));
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
scanSteps(step.sub_steps, `${path}.sub_steps`, unsupported, findings, false);
|
|
36
74
|
});
|
|
37
75
|
}
|
|
38
76
|
|
|
39
|
-
// Returns
|
|
40
|
-
//
|
|
41
|
-
|
|
42
|
-
function findUnsupportedActions(scenario) {
|
|
77
|
+
// Returns every finding in document order: steps first (including nested
|
|
78
|
+
// sub_steps, depth-first), then precondition device actions.
|
|
79
|
+
function findReplayWarnings(scenario) {
|
|
43
80
|
const unsupported = new Set(actionsByResolution('unsupported'));
|
|
44
81
|
const findings = [];
|
|
45
82
|
|
|
46
|
-
scanSteps(scenario && scenario.steps, 'steps', unsupported, findings);
|
|
83
|
+
scanSteps(scenario && scenario.steps, 'steps', unsupported, findings, true);
|
|
47
84
|
|
|
48
85
|
const pre = scenario && scenario.preconditions;
|
|
49
86
|
const deviceActions = pre && Array.isArray(pre.device_actions) ? pre.device_actions : [];
|
|
50
87
|
deviceActions.forEach((da, i) => {
|
|
51
88
|
if (da && unsupported.has(da.action)) {
|
|
52
|
-
findings.push(
|
|
89
|
+
findings.push(unsupportedFinding(da.action, `preconditions.device_actions[${i}]`));
|
|
53
90
|
}
|
|
54
91
|
});
|
|
55
92
|
|
|
56
93
|
return findings;
|
|
57
94
|
}
|
|
58
95
|
|
|
59
|
-
|
|
96
|
+
function isBlocking(finding) {
|
|
97
|
+
const row = CODES[finding.code];
|
|
98
|
+
return Boolean(row && row.blocking);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// Splits findings into the `--strict`-failing ones and builds the one-line
|
|
102
|
+
// hint: blocking clauses first, then advisories, one clause per code (counted),
|
|
103
|
+
// each ending `— see data.warnings`. A code without a CODES row is advisory
|
|
104
|
+
// with a generic clause.
|
|
105
|
+
function summarize(findings) {
|
|
106
|
+
const blocking = findings.filter(isBlocking);
|
|
107
|
+
const counts = new Map();
|
|
108
|
+
for (const f of findings) counts.set(f.code, (counts.get(f.code) || 0) + 1);
|
|
109
|
+
const clauseOf = (code, n) => {
|
|
110
|
+
const row = CODES[code];
|
|
111
|
+
return `${row && row.clause ? row.clause(n) : `${n} ${code} finding(s)`} — see data.warnings`;
|
|
112
|
+
};
|
|
113
|
+
const codes = [...counts.keys()];
|
|
114
|
+
const ordered = [
|
|
115
|
+
...codes.filter((c) => CODES[c] && CODES[c].blocking),
|
|
116
|
+
...codes.filter((c) => !(CODES[c] && CODES[c].blocking)),
|
|
117
|
+
];
|
|
118
|
+
return { blocking, hint: ordered.map((c) => clauseOf(c, counts.get(c))).join('; ') };
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
module.exports = { findReplayWarnings, summarize, isBlocking, CODES };
|
|
@@ -277,6 +277,11 @@
|
|
|
277
277
|
"type": "string",
|
|
278
278
|
"description": "Description of the expected visual state after this step completes — used by the executor for semantic validation"
|
|
279
279
|
},
|
|
280
|
+
"cold": {
|
|
281
|
+
"type": "boolean",
|
|
282
|
+
"default": true,
|
|
283
|
+
"description": "launch_app only: stop the app before launching it so the step starts on the app's initial screen. Set false to bring a running app to the front in its current state."
|
|
284
|
+
},
|
|
280
285
|
"optional": {
|
|
281
286
|
"type": "boolean",
|
|
282
287
|
"default": false,
|