mobile-automator 0.33.0 → 0.35.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/LICENSE CHANGED
@@ -1,17 +1,202 @@
1
- Apache License
2
- Version 2.0, January 2004
3
- http://www.apache.org/licenses/
4
1
 
5
- Copyright 2025 Mobile QA Skills Contributors
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
6
5
 
7
- Licensed under the Apache License, Version 2.0 (the "License");
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
- http://www.apache.org/licenses/LICENSE-2.0
8
+ 1. Definitions.
12
9
 
13
- Unless required by applicable law or agreed to in writing, software
14
- distributed under the License is distributed on an "AS IS" BASIS,
15
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- See the License for the specific language governing permissions and
17
- limitations under the License.
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mobile-automator",
3
- "version": "0.33.0",
3
+ "version": "0.35.1",
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 { findUnsupportedActions } = require('./scenario/replayability');
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 actions the catalog
249
- // marks unsupported. A warning by default so existing scenarios keep
250
- // validating; `--strict` makes it a failure (#166).
251
- const warnings = findUnsupportedActions(scenario);
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 hint = `${warnings.length} action(s) cannot replay unattended — see data.warnings`;
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
- async function handleLaunch({ deviceBridge }, appId) {
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
- await deviceBridge.launchApp(id);
411
- return { envelope: ok({ launched: id }), exitKind: 'ok' };
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
  }
@@ -1975,9 +1994,16 @@ function buildProgram(deps = {}) {
1975
1994
 
1976
1995
  program
1977
1996
  .command('launch <appId>')
1978
- .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')
1979
2005
  .option('--device <id>', 'target device id')
1980
- .action(withEnvelope((appId, opts) => withBridge(opts.device, (bridge) => handleLaunch({ deviceBridge: bridge }, appId))));
2006
+ .action(withEnvelope((appId, opts) => withBridge(opts.device, (bridge) => handleTerminate({ deviceBridge: bridge }, appId))));
1981
2007
 
1982
2008
  program
1983
2009
  .command('install <path>')
@@ -2608,6 +2634,7 @@ module.exports = {
2608
2634
  handleSwipe,
2609
2635
  handlePress,
2610
2636
  handleLaunch,
2637
+ handleTerminate,
2611
2638
  handleInstall,
2612
2639
  handleUninstall,
2613
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 a single mobile-mcp primitive.
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
- resolution: 'verb', verb: 'launch', bridge: 'launchApp',
55
- primitive: 'mobile_launch_app', args: ['packageName'],
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
- module.exports = { ACTION_CATALOG, RESOLUTIONS, actionsByResolution };
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 };
@@ -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 });
@@ -8,6 +8,7 @@ const { resolveSingleDevice } = require('./device-resolver');
8
8
  const { normalizeDevices } = require('./device-model');
9
9
  const { resolveEngineTelemetry } = require('../observe/telemetry');
10
10
  const { ErrorCode } = require('@modelcontextprotocol/sdk/types.js');
11
+ const { argvPath } = require('./session-paths');
11
12
 
12
13
  // Bound on mobile-mcp's MCP initialize handshake (#156). Measured at ~200ms on
13
14
  // mobile-mcp 1.0.5 — initialize touches no device — so 10s is ~50x headroom.
@@ -80,7 +81,42 @@ function resolveServerEntry() {
80
81
  // the user set. The decision lives in resolveEngineTelemetry so that
81
82
  // `mauto telemetry status` reports exactly what this hands the engine, and the
82
83
  // same `mauto session end` rule applies to a change.
83
- function buildEngineEnv({ device = null, baseEnv = process.env, engine = null } = {}) {
84
+ //
85
+ // MOBILECLI_PATH is set root-relative when `projectRoot` is given (#236).
86
+ // mobile-mcp runs mobilecli by the absolute path its own resolver finds, and
87
+ // for an in-project install that path contains the project root, which `ps`
88
+ // shows every user on the host. mobile-mcp 1.0.5 takes MOBILECLI_PATH verbatim
89
+ // and spawns mobilecli without a cwd option, so the binary inherits the
90
+ // engine's cwd, which createCall pins to projectRoot: a root-relative path
91
+ // reaches the same file. The lookup itself stays mobile-mcp's
92
+ // (resolveMobilecli; tests/integration/mobile-mcp-contract.test.js fails if an
93
+ // engine bump moves it). A resolver that throws leaves the key unset, so the
94
+ // engine surfaces its own "mobilecli not found". A user-set value always wins.
95
+ // A bare relative name would be a PATH lookup for execFile, so a binary
96
+ // sitting directly in the root keeps a `./`.
97
+ function defaultResolveMobilecli() {
98
+ return require('@mobilenext/mobile-mcp/lib/mobilecli.js').Mobilecli.getMobilecliPath();
99
+ }
100
+
101
+ function relativeMobilecliPath(projectRoot, resolveMobilecli) {
102
+ let resolved;
103
+ try {
104
+ resolved = resolveMobilecli();
105
+ } catch (_e) {
106
+ return undefined;
107
+ }
108
+ if (!resolved) return undefined;
109
+ const p = argvPath(projectRoot, resolved);
110
+ return path.isAbsolute(p) || p.includes(path.sep) ? p : `.${path.sep}${p}`;
111
+ }
112
+
113
+ function buildEngineEnv({
114
+ device = null,
115
+ baseEnv = process.env,
116
+ engine = null,
117
+ projectRoot = null,
118
+ resolveMobilecli = defaultResolveMobilecli,
119
+ } = {}) {
84
120
  const env = {
85
121
  ...baseEnv,
86
122
  MOBILEMCP_ALLOW_UNSAFE_URLS: baseEnv.MOBILEMCP_ALLOW_UNSAFE_URLS ?? '1',
@@ -92,6 +128,10 @@ function buildEngineEnv({ device = null, baseEnv = process.env, engine = null }
92
128
  // mobile-mcp reads the target device from the environment / its own
93
129
  // selection; we pass it through when provided so callers can pin a device.
94
130
  if (device) env.MOBILE_MCP_DEVICE = device;
131
+ if (projectRoot && baseEnv.MOBILECLI_PATH === undefined) {
132
+ const mobilecli = relativeMobilecliPath(projectRoot, resolveMobilecli);
133
+ if (mobilecli !== undefined) env.MOBILECLI_PATH = mobilecli;
134
+ }
95
135
  return env;
96
136
  }
97
137
 
@@ -115,6 +155,12 @@ function pidTracking(Transport) {
115
155
  // Integration glue: spawns mobile-mcp over stdio and returns a `call`
116
156
  // function shaped exactly like the one DeviceBridge expects.
117
157
  //
158
+ // `projectRoot` (#236): the daemon passes its workspace root. The engine then
159
+ // runs with cwd = root, its in-project entry is passed relative to that root
160
+ // (argvPath), and so is MOBILECLI_PATH (buildEngineEnv): the engine is the
161
+ // daemon's long-lived child and `ps` shows its argv to every user on the host.
162
+ // Null keeps the absolute entry and the inherited cwd.
163
+ //
118
164
  // `sdk`, `server` and `reaper` are test seams: production passes none of them.
119
165
  // tests/unit/device/mobile-mcp-client-lifecycle.test.js drives this against a
120
166
  // fake SDK; tests/integration/engine-lifecycle.test.js against the real SDK and
@@ -122,6 +168,7 @@ function pidTracking(Transport) {
122
168
  async function createCall({
123
169
  device,
124
170
  engine = null,
171
+ projectRoot = null,
125
172
  connectTimeoutMs = CONNECT_TIMEOUT_MS,
126
173
  onEngineExit = null,
127
174
  sdk = { Client, StdioClientTransport },
@@ -129,12 +176,16 @@ async function createCall({
129
176
  reaper = require('./process-reaper'),
130
177
  } = {}) {
131
178
  // Resolved lazily, here, so the module still loads without mobile-mcp installed.
132
- const { command, args } = server || { command: process.execPath, args: [resolveServerEntry()] };
179
+ // The relative entry and MOBILECLI_PATH only resolve because cwd is the same
180
+ // projectRoot, so both come from it here.
181
+ const entry = () => (projectRoot ? argvPath(projectRoot, resolveServerEntry()) : resolveServerEntry());
182
+ const { command, args } = server || { command: process.execPath, args: [entry()] };
133
183
  const Transport = pidTracking(sdk.StdioClientTransport);
134
184
  const transport = new Transport({
135
185
  command,
136
186
  args,
137
- env: buildEngineEnv({ device, engine }),
187
+ env: buildEngineEnv({ device, engine, projectRoot }),
188
+ ...(projectRoot ? { cwd: projectRoot } : {}),
138
189
  });
139
190
 
140
191
  const client = new sdk.Client({ name: 'mauto', version: '0.1.0' }, { capabilities: {} });
@@ -40,6 +40,7 @@ const MOBILE_MCP_TOOL_NAMES = Object.freeze([
40
40
  'mobile_get_screen_size',
41
41
  'mobile_press_button',
42
42
  'mobile_launch_app',
43
+ 'mobile_terminate_app',
43
44
  'mobile_install_app',
44
45
  'mobile_uninstall_app',
45
46
  'mobile_open_url',
@@ -13,6 +13,7 @@ const childProcess = require('child_process');
13
13
  const fs = require('fs');
14
14
 
15
15
  const paths = require('./session-paths');
16
+ const sessionSalt = require('./session-salt');
16
17
 
17
18
  // True when a pid is a live process we own. ESRCH => dead; EPERM => alive.
18
19
  // cleanStale routes through pidIdentity, which also checks the process's
@@ -73,12 +74,18 @@ function isZombie(
73
74
  // 'unknown' - alive but `ps` itself failed (e.g. no `ps` on the host) —
74
75
  // treated as 'ours' by cleanStale: never clean when unsure.
75
76
  // `execFile` is injectable for tests; a failure there must never crash the
76
- // daemon, hence the 'unknown' fallback.
77
+ // daemon, hence the 'unknown' fallback. So is `readSalt` (#236): the marker is
78
+ // HMAC(salt, root), and the salt is read from THIS workspace's .session/, only
79
+ // when a projectRoot is given. A copied workspace has the salt but not the
80
+ // root, so the original's daemon stays 'foreign' to it.
77
81
  //
78
82
  // cleanStale passes no projectRoot and keeps the binary-level answer: there a
79
83
  // wrong 'ours' only means stale files are left alone. `session end` passes one,
80
84
  // because there a wrong 'ours' sends a process-group kill (src/device/connection.js).
81
- function pidIdentity(pid, { execFile = childProcess.execFileSync, projectRoot = null } = {}) {
85
+ function pidIdentity(
86
+ pid,
87
+ { execFile = childProcess.execFileSync, projectRoot = null, readSalt = sessionSalt.readSalt } = {}
88
+ ) {
82
89
  if (!pid || !Number.isInteger(pid)) return 'dead';
83
90
  // Our own pid is the in-process daemon (unit tests run startDaemon in the
84
91
  // test process, so the lock/pidfile carry the test runner's pid). Never clean
@@ -105,7 +112,7 @@ function pidIdentity(pid, { execFile = childProcess.execFileSync, projectRoot =
105
112
  );
106
113
  if (!/mauto-session-daemon/.test(out)) return 'other';
107
114
  if (projectRoot == null) return 'ours';
108
- return paths.commandNamesWorkspace(out, projectRoot) ? 'ours' : 'foreign';
115
+ return paths.commandNamesWorkspace(out, projectRoot, readSalt(projectRoot)) ? 'ours' : 'foreign';
109
116
  } catch (_) {
110
117
  return 'unknown';
111
118
  }
@@ -272,7 +272,9 @@ async function startDaemon({
272
272
  let call;
273
273
  let close;
274
274
  try {
275
- ({ call, close } = await createCall({ device, engine, onEngineExit }));
275
+ // projectRoot lets the engine run from the root with root-relative paths in
276
+ // its argv and MOBILECLI_PATH, so `ps` never shows the project path (#236).
277
+ ({ call, close } = await createCall({ device, engine, projectRoot, onEngineExit }));
276
278
  } catch (err) {
277
279
  // #156's core symptom: mobile-mcp never came up, and until now the only
278
280
  // trace was a 15s readiness timeout in the spawning verb.
@@ -7,10 +7,15 @@
7
7
  // daemon.pid — pidfile written once the daemon is listening
8
8
  // session.json — handle describing the live session (device pin, socket, pid)
9
9
  // daemon.log — bounded stdout/stderr capture from the detached daemon
10
+ // marker.salt — per-workspace secret salting the daemon's argv marker
11
+ // (#236); created once (session-salt.js), never rotated or
12
+ // deleted by any teardown
10
13
  //
11
14
  // These are intentionally side-effect-free so they can be unit-tested without
12
- // touching the filesystem.
15
+ // touching the filesystem. argvPath is the one exception: it reads realpaths,
16
+ // but never writes.
13
17
 
18
+ const fs = require('fs');
14
19
  const path = require('path');
15
20
  const os = require('os');
16
21
  const crypto = require('crypto');
@@ -21,6 +26,7 @@ const PID_NAME = 'daemon.pid';
21
26
  const HANDLE_NAME = 'session.json';
22
27
  const LOCK_NAME = 'daemon.lock';
23
28
  const LOG_NAME = 'daemon.log';
29
+ const SALT_NAME = 'marker.salt';
24
30
 
25
31
  // Unix domain socket paths have a hard length limit (~104 bytes on macOS,
26
32
  // ~108 on Linux). Deep project roots blow past it, so when the in-workspace
@@ -44,12 +50,16 @@ function workspaceSocketPath(projectRoot) {
44
50
  function socketPath(projectRoot) {
45
51
  const inWorkspace = workspaceSocketPath(projectRoot);
46
52
  if (Buffer.byteLength(inWorkspace) <= SOCKET_PATH_LIMIT) return inWorkspace;
47
- const hash = crypto
48
- .createHash('sha1')
49
- .update(path.resolve(projectRoot))
50
- .digest('hex')
51
- .slice(0, 16);
52
- return path.join(os.tmpdir(), `mauto-${hash}.sock`);
53
+ return path.join(os.tmpdir(), `mauto-${workspaceKey(projectRoot)}.sock`);
54
+ }
55
+
56
+ // A short, deterministic name for a workspace: the first 16 hex chars of
57
+ // sha1(resolved project root). It names ONLY the tmpdir socket fallback above.
58
+ // It is unsalted, so anyone who guesses the root can compute it; the daemon's
59
+ // argv marker uses daemonMarkerKey below instead (#236). Changing it moves the
60
+ // socket a running daemon is bound to, so its output is pinned by tests.
61
+ function workspaceKey(projectRoot) {
62
+ return crypto.createHash('sha1').update(path.resolve(projectRoot)).digest('hex').slice(0, 16);
53
63
  }
54
64
 
55
65
  // Deliberately has no os.tmpdir() fallback, unlike socketPath(). That fallback
@@ -68,6 +78,12 @@ function handlePath(projectRoot) {
68
78
  return path.join(sessionDir(projectRoot), HANDLE_NAME);
69
79
  }
70
80
 
81
+ // The per-workspace salt for the daemon's argv marker (#236). Read and created
82
+ // by session-salt.js; this module stays free of IO.
83
+ function saltPath(projectRoot) {
84
+ return path.join(sessionDir(projectRoot), SALT_NAME);
85
+ }
86
+
71
87
  // Exclusive workspace lock acquired BEFORE building the mobile-mcp connection so
72
88
  // a double-spawn loser fails fast and exits before it ever spawns a child.
73
89
  function lockPath(projectRoot) {
@@ -80,18 +96,76 @@ function lockPath(projectRoot) {
80
96
  // marker is what lets `session end` tell THIS workspace's daemon from another
81
97
  // workspace's before it signals a process group: a copied workspace (`cp -R`
82
98
  // carries daemon.pid) or a recycled pid can name a different live daemon.
83
- // The root is the LAST argument so a match can be anchored at the end.
84
- const DAEMON_ROOT_FLAG = '--project-root';
99
+ //
100
+ // The marker is a SALTED key, not the path (#236). `ps` shows every process's
101
+ // argv to every user on the host, and a project path can name a client or an
102
+ // unreleased project. An unsalted digest would not hide it: another user can
103
+ // guess `/Users/alice/clients/acme-app`, hash it, and compare. So the key is
104
+ // HMAC-SHA256(salt, resolved root), where the salt is a per-workspace secret in
105
+ // .session/marker.salt (mode 0600, session-salt.js). Both inputs are needed:
106
+ // - the salt makes the key unconfirmable by anyone who cannot read the
107
+ // workspace;
108
+ // - the root keeps `cp -R` safe: a copied workspace carries the salt AND
109
+ // daemon.pid, but its root differs, so the original daemon's key never
110
+ // names the copy.
111
+ // Losing the salt strands nothing new: it lives beside daemon.pid, so whatever
112
+ // removes one removes the other. The daemon never reads its argv. The key is
113
+ // the LAST argument so a match can be anchored at the end.
114
+ const DAEMON_WORKSPACE_FLAG = '--workspace-key';
115
+
116
+ // Match-only, never emitted. Daemons started by 0.28.0-0.35.0 carry the
117
+ // absolute root behind this flag; still recognising them keeps a stuck one
118
+ // force-stoppable by `session end` after an upgrade.
119
+ const LEGACY_DAEMON_ROOT_FLAG = '--project-root';
85
120
 
86
- function daemonArgv(projectRoot) {
87
- return [DAEMON_ROOT_FLAG, path.resolve(projectRoot)];
121
+ function daemonMarkerKey(projectRoot, salt) {
122
+ return crypto.createHmac('sha256', String(salt)).update(path.resolve(projectRoot)).digest('hex').slice(0, 16);
88
123
  }
89
124
 
90
- // Does a `ps -o command=` line name exactly this workspace? Anchored at the end
91
- // of the line so `/a/proj` never matches a daemon serving `/a/proj2`.
92
- function commandNamesWorkspace(command, projectRoot) {
125
+ function daemonArgv(projectRoot, salt) {
126
+ return [DAEMON_WORKSPACE_FLAG, daemonMarkerKey(projectRoot, salt)];
127
+ }
128
+
129
+ // Does a `ps -o command=` line name exactly this workspace, by salted key or by
130
+ // the legacy root? The key form needs the workspace's salt: with none (missing
131
+ // or unreadable) no keyed daemon can be proven ours. The legacy form needs no
132
+ // salt. Anchored at the end of the line so `/a/proj` never matches a daemon
133
+ // serving `/a/proj2`, and a key never matches a longer or shorter one.
134
+ function commandNamesWorkspace(command, projectRoot, salt = null) {
93
135
  const line = String(command || '').replace(/\s+$/, '');
94
- return line.endsWith(` ${DAEMON_ROOT_FLAG} ${path.resolve(projectRoot)}`);
136
+ if (salt != null && line.endsWith(` ${DAEMON_WORKSPACE_FLAG} ${daemonMarkerKey(projectRoot, salt)}`)) return true;
137
+ return line.endsWith(` ${LEGACY_DAEMON_ROOT_FLAG} ${path.resolve(projectRoot)}`);
138
+ }
139
+
140
+ // A path as it should appear in a child's argv (or an env var the child execs
141
+ // by) (#236). `ps` shows every process's argv to every user on the host, and
142
+ // when mobile-automator is installed inside the project (a devDependency, a
143
+ // source checkout) the absolute paths of the daemon bin, the engine entry and
144
+ // mobilecli all contain the project root, which often names a client. A file
145
+ // under the root is returned relative to it; the caller MUST run the child with
146
+ // cwd = projectRoot, or the relative path resolves somewhere else. A file
147
+ // outside the root (a global install) is returned unchanged: it reveals no
148
+ // project path.
149
+ //
150
+ // Both sides are compared by realpath, so a root reached through a symlink
151
+ // (macOS /tmp vs /private/tmp, a symlinked checkout) still gets the relative
152
+ // form, and the result is relative to the REAL root, which is what the child's
153
+ // cwd resolves to. A path that cannot be realpath'd (it does not exist yet, or
154
+ // in unit tests) falls back to path.resolve. "Under" is strict: the root itself
155
+ // is not under it, and a sibling sharing its prefix (/a/proj2 vs /a/proj) is
156
+ // outside it.
157
+ function realOrResolved(p) {
158
+ try {
159
+ return fs.realpathSync(p);
160
+ } catch (_e) {
161
+ return path.resolve(p);
162
+ }
163
+ }
164
+
165
+ function argvPath(projectRoot, absPath) {
166
+ const rel = path.relative(realOrResolved(projectRoot), realOrResolved(absPath));
167
+ if (!rel || path.isAbsolute(rel) || rel === '..' || rel.startsWith('..' + path.sep)) return absPath;
168
+ return rel;
95
169
  }
96
170
 
97
171
  module.exports = {
@@ -101,6 +175,7 @@ module.exports = {
101
175
  HANDLE_NAME,
102
176
  LOCK_NAME,
103
177
  LOG_NAME,
178
+ SALT_NAME,
104
179
  SOCKET_PATH_LIMIT,
105
180
  sessionDir,
106
181
  workspaceSocketPath,
@@ -109,7 +184,12 @@ module.exports = {
109
184
  pidFilePath,
110
185
  handlePath,
111
186
  lockPath,
112
- DAEMON_ROOT_FLAG,
187
+ saltPath,
188
+ workspaceKey,
189
+ daemonMarkerKey,
190
+ DAEMON_WORKSPACE_FLAG,
191
+ LEGACY_DAEMON_ROOT_FLAG,
113
192
  daemonArgv,
114
193
  commandNamesWorkspace,
194
+ argvPath,
115
195
  };
@@ -0,0 +1,84 @@
1
+ 'use strict';
2
+
3
+ // The per-workspace salt behind the daemon's argv marker (#236).
4
+ //
5
+ // `ps` shows every process's argv to every user on the host, so the daemon's
6
+ // command line carries HMAC(salt, root) (session-paths.daemonMarkerKey) rather
7
+ // than a digest anyone could recompute from a guessed project path. The salt is
8
+ // 32 random bytes as hex in <root>/mobile-automator/.session/marker.salt, mode
9
+ // 0600 so only the workspace's owner can read it. It is created once and never
10
+ // rotated: rotating it would orphan a running daemon's marker, and no teardown
11
+ // deletes it (cleanStale, daemon stop and the bin's exit cleanup all unlink
12
+ // named files only).
13
+ //
14
+ // Kept out of session-paths.js so that module stays free of IO.
15
+
16
+ const realFs = require('fs');
17
+ const path = require('path');
18
+ const crypto = require('crypto');
19
+
20
+ const paths = require('./session-paths');
21
+
22
+ // The salt, or null when it is missing, unreadable or empty. Any other content
23
+ // IS the salt: an HMAC key needs no particular shape, so there is no
24
+ // "malformed" salt to detect or repair. A null salt means no keyed daemon can
25
+ // be proven this workspace's (commandNamesWorkspace).
26
+ function readSalt(projectRoot, { fs = realFs } = {}) {
27
+ try {
28
+ return String(fs.readFileSync(paths.saltPath(projectRoot), 'utf8')).trim() || null;
29
+ } catch (_) {
30
+ return null;
31
+ }
32
+ }
33
+
34
+ // The salt, created if this workspace has none yet. Throws when it can neither
35
+ // read nor create one: an unwritable workspace, or an empty salt file, which
36
+ // only a hand edit makes and which is never replaced behind a running
37
+ // daemon's back.
38
+ //
39
+ // Race-free without a lock: the salt is written and fsynced in full to a
40
+ // private temp file, then link(2)ed to its final name. link never replaces an
41
+ // existing file, so exactly one of several concurrent spawners wins; every
42
+ // loser gets EEXIST and reads the winner's salt, which was complete before it
43
+ // became visible. A reader therefore never sees a half-written salt. (The
44
+ // rename in util/atomic.js would not do: it replaces, so two racers could each
45
+ // hand back a different salt.)
46
+ function ensureSalt(projectRoot, { fs = realFs } = {}) {
47
+ const existing = readSalt(projectRoot, { fs });
48
+ if (existing) return existing;
49
+
50
+ const file = paths.saltPath(projectRoot);
51
+ fs.mkdirSync(path.dirname(file), { recursive: true });
52
+ const tmp = path.join(
53
+ path.dirname(file),
54
+ `.${path.basename(file)}.tmp.${process.pid}.${crypto.randomBytes(6).toString('hex')}`
55
+ );
56
+ const salt = crypto.randomBytes(32).toString('hex');
57
+ try {
58
+ const fd = fs.openSync(tmp, 'wx', 0o600);
59
+ try {
60
+ fs.writeFileSync(fd, `${salt}\n`);
61
+ fs.fsyncSync(fd);
62
+ } finally {
63
+ fs.closeSync(fd);
64
+ }
65
+ try {
66
+ fs.linkSync(tmp, file);
67
+ return salt;
68
+ } catch (err) {
69
+ if (err.code !== 'EEXIST') throw err;
70
+ }
71
+ // Another process won the race; its salt was complete before it was linked.
72
+ const theirs = readSalt(projectRoot, { fs });
73
+ if (theirs) return theirs;
74
+ throw new Error(`the session marker salt at ${file} is empty; delete it and retry`);
75
+ } finally {
76
+ try {
77
+ fs.unlinkSync(tmp);
78
+ } catch (_) {
79
+ /* never created */
80
+ }
81
+ }
82
+ }
83
+
84
+ module.exports = { ensureSalt, readSalt };
@@ -13,6 +13,7 @@ const childProcess = require('child_process');
13
13
  const sessionClient = require('./session-client');
14
14
  const sessionLog = require('./session-log');
15
15
  const paths = require('./session-paths');
16
+ const sessionSalt = require('./session-salt');
16
17
  const reaper = require('./process-reaper');
17
18
 
18
19
  const DAEMON_BIN = path.join(__dirname, '..', '..', 'bin', 'mauto-session-daemon.js');
@@ -38,6 +39,9 @@ async function spawnDaemon({
38
39
  pollMs = DEFAULT_POLL_MS,
39
40
  isAlive = sessionClient.isAlive,
40
41
  openLog = sessionLog.openDaemonLog,
42
+ // Reads or creates the workspace's marker salt (#236). Injectable so the
43
+ // spawn args are testable without a writable workspace.
44
+ ensureSalt = sessionSalt.ensureSalt,
41
45
  // Kills a daemon that never became ready (#156). group:true reaches the
42
46
  // daemon AND its mobile-mcp engine: `detached: true` below makes the daemon
43
47
  // a process-group leader, and the engine is spawned into its group.
@@ -63,14 +67,31 @@ async function spawnDaemon({
63
67
  const log = openLog(projectRoot);
64
68
 
65
69
  try {
66
- // The root in argv is an identity marker only (see paths.daemonArgv): env
67
- // stays the daemon's source of truth, but `ps` can only see argv.
70
+ // The workspace key in argv is an identity marker only (see paths.daemonArgv):
71
+ // env stays the daemon's source of truth, but `ps` can only see argv. It is
72
+ // salted with the workspace's own secret, so `ps` readers cannot confirm a
73
+ // guessed path by hashing it (#236). A salt we can neither read nor create
74
+ // fails the spawn, like a bin that cannot exec: a daemon with no marker is
75
+ // one `session end` can never force-stop, and a workspace that cannot hold
76
+ // the salt cannot hold the daemon's own lock and pidfile either. No
77
+ // argument names the project path, since `ps` shows argv to every user on
78
+ // the host (#236): an in-project bin is passed relative to the root
79
+ // (paths.argvPath), which only resolves because the child's cwd IS that
80
+ // root. One `cwd` feeds both, so the two cannot drift apart.
68
81
  // cwd: the engine inherits the daemon's cwd, and mobile-mcp's
69
82
  // validateOutputPath only allows screenshots under its own process.cwd()
70
83
  // (or the temp dir). Pin it to the project root so the allow-list never
71
84
  // depends on which subdirectory happened to spawn the daemon (#214).
72
- const child = spawn(process.execPath, [DAEMON_BIN, ...paths.daemonArgv(projectRoot)], {
73
- cwd: projectRoot,
85
+ let marker;
86
+ try {
87
+ marker = paths.daemonArgv(projectRoot, ensureSalt(projectRoot));
88
+ } catch (err) {
89
+ log.write(`mauto: daemon not spawned: could not create the session marker salt: ${err && err.message ? err.message : err}\n`);
90
+ return false;
91
+ }
92
+ const cwd = projectRoot;
93
+ const child = spawn(process.execPath, [paths.argvPath(cwd, DAEMON_BIN), ...marker], {
94
+ cwd,
74
95
  detached: true,
75
96
  stdio: log.stdio,
76
97
  env,
@@ -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>`, `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.
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; reset app state (force-close and relaunch) between them.
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
- - Reset app state between scenarios (force-close and relaunch).
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 press` / launch the app under test | |
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 those steps, or tell the user the step needs manual handling.
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 those steps, or tell the user the step needs manual handling.
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 press` / launch the app under test | |
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 those steps, or tell the user the step needs manual handling)
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
@@ -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'],
@@ -67,6 +67,7 @@ const VERB_NAMES = Object.freeze([
67
67
  'long-press',
68
68
  'double-tap',
69
69
  'launch',
70
+ 'terminate',
70
71
  'install',
71
72
  'uninstall',
72
73
  'open-url',
@@ -1,59 +1,121 @@
1
1
  'use strict';
2
2
 
3
- // Replayability check for scenarios (#166). The scenario schema accepts every
4
- // action in its enum, but the action catalog marks some `unsupported`: mobile-mcp
5
- // exposes no primitive for them, so no `mauto` verb can run them and the step
6
- // can never replay unattended. Schema validity alone therefore overstates what
7
- // a scenario can do; this module reports the gap.
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
- function finding(action, path, stepId) {
15
- const f = {
16
- code: 'unsupported_action',
17
- action,
18
- path,
19
- message: `${action} has no execution path in mauto; this step cannot replay unattended`,
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(finding(step.action, path, step.id));
64
+ findings.push(unsupportedFinding(step.action, path, step.id));
34
65
  }
35
- scanSteps(step.sub_steps, `${path}.sub_steps`, unsupported, findings);
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 one finding per use of an unsupported action: steps first (including
40
- // nested sub_steps, depth-first in document order), then precondition device
41
- // actions in document order.
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(finding(da.action, `preconditions.device_actions[${i}]`));
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
- module.exports = { findUnsupportedActions };
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,