mobile-debug-mcp 0.26.0 → 0.26.2
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/dist/interact/classify.js +48 -11
- package/dist/interact/index.js +26 -33
- package/dist/server/common.js +14 -1
- package/dist/server/tool-definitions.js +38 -15
- package/dist/server/tool-handlers.js +9 -0
- package/dist/server-core.js +1 -1
- package/docs/CHANGELOG.md +6 -0
- package/docs/ROADMAP.md +281 -88
- package/docs/rfcs/004-action-verification-routing.md +342 -0
- package/docs/rfcs/005-unified-action-execution-and-verification-model.md +216 -0
- package/docs/rfcs/006-runtime-action-instrumentation-and-binding-layer.md +230 -0
- package/docs/specs/mcp-tooling-spec-v1.md +7 -3
- package/docs/tools/interact.md +14 -8
- package/package.json +1 -1
- package/src/interact/classify.ts +53 -13
- package/src/interact/index.ts +27 -35
- package/src/server/common.ts +22 -1
- package/src/server/tool-definitions.ts +38 -15
- package/src/server/tool-handlers.ts +9 -0
- package/src/server-core.ts +1 -1
- package/src/types.ts +2 -0
- package/test/unit/interact/classify_action_outcome.test.ts +44 -25
- package/test/unit/server/contract.test.ts +8 -6
- package/test/unit/server/response_shapes.test.ts +8 -0
|
@@ -1,35 +1,72 @@
|
|
|
1
|
+
const ACTION_CATEGORY_BY_TYPE = {
|
|
2
|
+
tap: 'local_state',
|
|
3
|
+
tap_element: 'local_state',
|
|
4
|
+
swipe: 'local_state',
|
|
5
|
+
scroll_to_element: 'local_state',
|
|
6
|
+
type_text: 'local_state',
|
|
7
|
+
press_back: 'local_state',
|
|
8
|
+
start_app: 'side_effect',
|
|
9
|
+
restart_app: 'side_effect',
|
|
10
|
+
terminate_app: 'side_effect',
|
|
11
|
+
reset_app_data: 'side_effect',
|
|
12
|
+
install_app: 'side_effect',
|
|
13
|
+
build_app: 'side_effect',
|
|
14
|
+
build_and_install: 'side_effect'
|
|
15
|
+
};
|
|
16
|
+
function inferActionCategory(actionType) {
|
|
17
|
+
if (typeof actionType !== 'string')
|
|
18
|
+
return null;
|
|
19
|
+
const normalized = actionType.trim().toLowerCase();
|
|
20
|
+
if (!normalized)
|
|
21
|
+
return null;
|
|
22
|
+
return ACTION_CATEGORY_BY_TYPE[normalized] ?? 'side_effect';
|
|
23
|
+
}
|
|
1
24
|
/**
|
|
2
25
|
* Pure deterministic classifier. Applies rules in fixed order.
|
|
3
26
|
* Same inputs always produce the same output.
|
|
4
27
|
*/
|
|
5
28
|
export function classifyActionOutcome(input) {
|
|
6
|
-
const { uiChanged, expectedElementVisible, networkRequests, hasLogErrors } = input;
|
|
29
|
+
const { uiChanged, expectedElementVisible, actionType, networkRequests, hasLogErrors } = input;
|
|
30
|
+
const actionCategory = inferActionCategory(actionType);
|
|
7
31
|
// Step 1 — UI signal is positive
|
|
8
32
|
if (uiChanged || expectedElementVisible === true) {
|
|
9
33
|
return { outcome: 'success', reasoning: expectedElementVisible === true ? 'expected element is visible' : 'UI changed after action' };
|
|
10
34
|
}
|
|
11
|
-
// Step 2 —
|
|
12
|
-
if (
|
|
35
|
+
// Step 2 — no action type means we cannot choose a safe routing path
|
|
36
|
+
if (actionCategory === null) {
|
|
13
37
|
return {
|
|
14
38
|
outcome: 'unknown',
|
|
15
|
-
reasoning: '
|
|
16
|
-
nextAction: 'call_get_network_activity'
|
|
39
|
+
reasoning: 'actionType was not supplied; pass the runtime action_type so the classifier can distinguish local-state and side-effect routing'
|
|
17
40
|
};
|
|
18
41
|
}
|
|
19
|
-
|
|
20
|
-
const failedRequest = networkRequests.find((r) => r.status === 'failure' || r.status === 'retryable');
|
|
42
|
+
const failedRequest = networkRequests?.find((r) => r.status === 'failure' || r.status === 'retryable');
|
|
21
43
|
if (failedRequest) {
|
|
22
44
|
return { outcome: 'backend_failure', reasoning: `network request ${failedRequest.endpoint} returned ${failedRequest.status}` };
|
|
23
45
|
}
|
|
24
|
-
// Step
|
|
46
|
+
// Step 3 — local-state actions should be verified with state-specific signals first
|
|
47
|
+
if (actionCategory === 'local_state') {
|
|
48
|
+
const logNote = hasLogErrors ? ' (log errors present)' : '';
|
|
49
|
+
return {
|
|
50
|
+
outcome: 'no_op',
|
|
51
|
+
reasoning: `local-state action${logNote}; use expect_state, refreshed snapshot comparison, or expect_element_visible instead of defaulting to network inspection`
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
// Step 4 — side-effect actions may legitimately need network or log inspection
|
|
55
|
+
if (networkRequests === null || networkRequests === undefined) {
|
|
56
|
+
return {
|
|
57
|
+
outcome: 'unknown',
|
|
58
|
+
reasoning: 'side-effect action without network data; inspect network or log signals only if the outcome is still ambiguous'
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
// Step 5 — no network requests at all
|
|
25
62
|
if (networkRequests.length === 0) {
|
|
26
63
|
const logNote = hasLogErrors ? ' (log errors present)' : '';
|
|
27
|
-
return { outcome: 'no_op', reasoning: `
|
|
64
|
+
return { outcome: 'no_op', reasoning: `side-effect action and no network activity${logNote}` };
|
|
28
65
|
}
|
|
29
|
-
// Step
|
|
66
|
+
// Step 6 — network requests exist and all succeeded
|
|
30
67
|
if (networkRequests.every((r) => r.status === 'success')) {
|
|
31
68
|
return { outcome: 'ui_failure', reasoning: 'network requests succeeded but UI did not change' };
|
|
32
69
|
}
|
|
33
|
-
// Step
|
|
70
|
+
// Step 7 — fallback
|
|
34
71
|
return { outcome: 'unknown', reasoning: 'signals are inconclusive' };
|
|
35
72
|
}
|
package/dist/interact/index.js
CHANGED
|
@@ -5,7 +5,7 @@ export { AndroidInteract, iOSInteract };
|
|
|
5
5
|
import { resolveTargetDevice } from '../utils/resolve-device.js';
|
|
6
6
|
import { ToolsObserve } from '../observe/index.js';
|
|
7
7
|
import { computeSnapshotSignature } from '../observe/snapshot-metadata.js';
|
|
8
|
-
import {
|
|
8
|
+
import { buildActionExecutionResult } from '../server/common.js';
|
|
9
9
|
export class ToolsInteract {
|
|
10
10
|
static _maxResolvedUiElements = 256;
|
|
11
11
|
static _uiChangeKinds = ['hierarchy_diff', 'text_change', 'state_change'];
|
|
@@ -203,18 +203,17 @@ export class ToolsInteract {
|
|
|
203
203
|
semantic: element.semantic ?? null
|
|
204
204
|
};
|
|
205
205
|
}
|
|
206
|
-
static _actionFailure(
|
|
207
|
-
return {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
target: { selector, resolved },
|
|
206
|
+
static _actionFailure(actionType, selector, resolved, failureCode, retryable, uiFingerprintBefore, uiFingerprintAfter, sourceModule = 'interact') {
|
|
207
|
+
return buildActionExecutionResult({
|
|
208
|
+
actionType,
|
|
209
|
+
selector,
|
|
210
|
+
resolved,
|
|
212
211
|
success: false,
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
};
|
|
212
|
+
uiFingerprintBefore,
|
|
213
|
+
uiFingerprintAfter: uiFingerprintAfter ?? null,
|
|
214
|
+
failure: { failureCode, retryable },
|
|
215
|
+
sourceModule
|
|
216
|
+
});
|
|
218
217
|
}
|
|
219
218
|
static _resetResolvedUiElementsForTests() {
|
|
220
219
|
ToolsInteract._resolvedUiElements.clear();
|
|
@@ -350,14 +349,11 @@ export class ToolsInteract {
|
|
|
350
349
|
return await interact.tap(x, y, resolved.id);
|
|
351
350
|
}
|
|
352
351
|
static async tapElementHandler({ elementId }) {
|
|
353
|
-
const timestampMs = Date.now();
|
|
354
|
-
const timestamp = new Date(timestampMs).toISOString();
|
|
355
352
|
const actionType = 'tap_element';
|
|
356
|
-
const actionId = nextActionId(actionType, timestampMs);
|
|
357
353
|
const selector = { elementId };
|
|
358
354
|
const resolved = ToolsInteract._resolvedUiElements.get(elementId);
|
|
359
355
|
if (!resolved) {
|
|
360
|
-
return ToolsInteract._actionFailure(
|
|
356
|
+
return ToolsInteract._actionFailure(actionType, selector, null, 'STALE_REFERENCE', true, null);
|
|
361
357
|
}
|
|
362
358
|
const fingerprintBefore = await ToolsInteract._captureFingerprint(resolved.platform, resolved.deviceId);
|
|
363
359
|
const tree = await ToolsObserve.getUITreeHandler({ platform: resolved.platform, deviceId: resolved.deviceId });
|
|
@@ -366,40 +362,37 @@ export class ToolsInteract {
|
|
|
366
362
|
const elements = Array.isArray(tree?.elements) ? tree.elements : [];
|
|
367
363
|
const currentMatch = ToolsInteract._findCurrentResolvedElement(elements, treePlatform, treeDeviceId, resolved);
|
|
368
364
|
if (!currentMatch) {
|
|
369
|
-
return ToolsInteract._actionFailure(
|
|
365
|
+
return ToolsInteract._actionFailure(actionType, selector, null, 'STALE_REFERENCE', true, fingerprintBefore);
|
|
370
366
|
}
|
|
371
367
|
const resolvedTarget = ToolsInteract._resolvedTargetFromElement(resolved.elementId, currentMatch.el, currentMatch.index);
|
|
372
368
|
if (!ToolsInteract._isVisibleElement(currentMatch.el)) {
|
|
373
|
-
return ToolsInteract._actionFailure(
|
|
369
|
+
return ToolsInteract._actionFailure(actionType, selector, resolvedTarget, 'ELEMENT_NOT_INTERACTABLE', true, fingerprintBefore);
|
|
374
370
|
}
|
|
375
371
|
if (currentMatch.el.enabled === false) {
|
|
376
|
-
return ToolsInteract._actionFailure(
|
|
372
|
+
return ToolsInteract._actionFailure(actionType, selector, resolvedTarget, 'ELEMENT_NOT_INTERACTABLE', true, fingerprintBefore);
|
|
377
373
|
}
|
|
378
374
|
const bounds = ToolsInteract._normalizeBounds(currentMatch.el.bounds) ?? resolved.bounds;
|
|
379
375
|
if (!bounds || bounds[2] <= bounds[0] || bounds[3] <= bounds[1]) {
|
|
380
|
-
return ToolsInteract._actionFailure(
|
|
376
|
+
return ToolsInteract._actionFailure(actionType, selector, resolvedTarget, 'ELEMENT_NOT_INTERACTABLE', true, fingerprintBefore);
|
|
381
377
|
}
|
|
382
378
|
const x = Math.floor((bounds[0] + bounds[2]) / 2);
|
|
383
379
|
const y = Math.floor((bounds[1] + bounds[3]) / 2);
|
|
384
380
|
const tapResult = await ToolsInteract.tapHandler({ platform: resolved.platform, x, y, deviceId: resolved.deviceId });
|
|
385
381
|
if (!tapResult.success) {
|
|
386
382
|
const fingerprintAfterFailure = await ToolsInteract._captureFingerprint(resolved.platform, resolved.deviceId);
|
|
387
|
-
return ToolsInteract._actionFailure(
|
|
383
|
+
return ToolsInteract._actionFailure(actionType, selector, resolvedTarget, 'UNKNOWN', false, fingerprintBefore, fingerprintAfterFailure);
|
|
388
384
|
}
|
|
389
385
|
const fingerprintAfter = await ToolsInteract._captureFingerprint(resolved.platform, resolved.deviceId);
|
|
390
|
-
return {
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
target: {
|
|
396
|
-
selector,
|
|
397
|
-
resolved: resolvedTarget
|
|
398
|
-
},
|
|
386
|
+
return buildActionExecutionResult({
|
|
387
|
+
actionType,
|
|
388
|
+
device: tree?.device,
|
|
389
|
+
selector,
|
|
390
|
+
resolved: resolvedTarget,
|
|
399
391
|
success: true,
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
392
|
+
uiFingerprintBefore: fingerprintBefore,
|
|
393
|
+
uiFingerprintAfter: fingerprintAfter,
|
|
394
|
+
sourceModule: 'interact'
|
|
395
|
+
});
|
|
403
396
|
}
|
|
404
397
|
static async swipeHandler({ platform = 'android', x1, y1, x2, y2, duration, deviceId }) {
|
|
405
398
|
const { interact, resolved } = await ToolsInteract.getInteractionService(platform, deviceId);
|
package/dist/server/common.js
CHANGED
|
@@ -95,13 +95,26 @@ export function inferScrollFailure(message) {
|
|
|
95
95
|
return { failureCode: 'TIMEOUT', retryable: true };
|
|
96
96
|
return { failureCode: 'UNKNOWN', retryable: false };
|
|
97
97
|
}
|
|
98
|
-
|
|
98
|
+
const ACTION_LIFECYCLE_STATE_BY_OUTCOME = {
|
|
99
|
+
success: 'pending_verification',
|
|
100
|
+
failure: 'failed'
|
|
101
|
+
};
|
|
102
|
+
export function determineActionLifecycleState({ success, failure }) {
|
|
103
|
+
if (failure)
|
|
104
|
+
return ACTION_LIFECYCLE_STATE_BY_OUTCOME.failure;
|
|
105
|
+
if (success)
|
|
106
|
+
return ACTION_LIFECYCLE_STATE_BY_OUTCOME.success;
|
|
107
|
+
return ACTION_LIFECYCLE_STATE_BY_OUTCOME.success;
|
|
108
|
+
}
|
|
109
|
+
export function buildActionExecutionResult({ actionType, device, selector, resolved, success, uiFingerprintBefore, uiFingerprintAfter, failure, details, sourceModule }) {
|
|
99
110
|
const timestampMs = Date.now();
|
|
100
111
|
const timestamp = new Date(timestampMs).toISOString();
|
|
101
112
|
return {
|
|
102
113
|
action_id: nextActionId(actionType, timestampMs),
|
|
103
114
|
timestamp,
|
|
104
115
|
action_type: actionType,
|
|
116
|
+
lifecycle_state: determineActionLifecycleState({ success, failure }),
|
|
117
|
+
source_module: sourceModule,
|
|
105
118
|
...(device ? { device } : {}),
|
|
106
119
|
target: {
|
|
107
120
|
selector,
|
|
@@ -11,7 +11,9 @@ Inputs:
|
|
|
11
11
|
|
|
12
12
|
Output Structure:
|
|
13
13
|
- action_id, timestamp (ISO 8601), action_type
|
|
14
|
-
-
|
|
14
|
+
- lifecycle_state: post-dispatch lifecycle state (pending_verification or failed)
|
|
15
|
+
- source_module: runtime source of the action envelope
|
|
16
|
+
- target.selector = { appId }
|
|
15
17
|
- success = true when launch was dispatched successfully
|
|
16
18
|
- failure_code/retryable when launch dispatch fails
|
|
17
19
|
- ui_fingerprint_before/ui_fingerprint_after when available
|
|
@@ -84,7 +86,9 @@ Inputs:
|
|
|
84
86
|
|
|
85
87
|
Output Structure:
|
|
86
88
|
- action_id, timestamp (ISO 8601), action_type
|
|
87
|
-
-
|
|
89
|
+
- lifecycle_state: post-dispatch lifecycle state (pending_verification or failed)
|
|
90
|
+
- source_module: runtime source of the action envelope
|
|
91
|
+
- target.selector = { appId }
|
|
88
92
|
- success = true when the restart command completed
|
|
89
93
|
- failure_code/retryable when restart dispatch fails
|
|
90
94
|
- ui_fingerprint_before/ui_fingerprint_after when available
|
|
@@ -344,7 +348,7 @@ Capabilities:
|
|
|
344
348
|
Constraints:
|
|
345
349
|
- Does not verify correctness of the resulting state
|
|
346
350
|
- Must not be used alone to confirm action success when an applicable expect_* tool exists
|
|
347
|
-
-
|
|
351
|
+
- For backend/API activity without a visible UI change, pass the runtime action_type into classify_action_outcome and collect network evidence only if the result remains ambiguous
|
|
348
352
|
|
|
349
353
|
Recommended Usage:
|
|
350
354
|
1. Capture or define the expected outcome
|
|
@@ -617,7 +621,9 @@ Inputs:
|
|
|
617
621
|
|
|
618
622
|
Output Structure:
|
|
619
623
|
- action_id, timestamp (ISO 8601), action_type
|
|
620
|
-
-
|
|
624
|
+
- lifecycle_state: post-dispatch lifecycle state (pending_verification or failed)
|
|
625
|
+
- source_module: runtime source of the action envelope
|
|
626
|
+
- target.selector = { x, y }
|
|
621
627
|
- success = true when the tap was dispatched
|
|
622
628
|
- failure_code/retryable when dispatch fails
|
|
623
629
|
- ui_fingerprint_before/ui_fingerprint_after when available
|
|
@@ -673,6 +679,8 @@ Output Structure:
|
|
|
673
679
|
- action_id: unique timestamp-based action identifier
|
|
674
680
|
- timestamp: ISO 8601 timestamp for the action attempt
|
|
675
681
|
- action_type: "tap_element"
|
|
682
|
+
- lifecycle_state: post-dispatch lifecycle state (pending_verification or failed)
|
|
683
|
+
- source_module: runtime source of the action envelope
|
|
676
684
|
- target.selector: original target handle ({ elementId })
|
|
677
685
|
- target.resolved: minimal resolved element info used for the tap
|
|
678
686
|
- success: true when the tap was dispatched
|
|
@@ -725,6 +733,8 @@ Inputs:
|
|
|
725
733
|
|
|
726
734
|
Output Structure:
|
|
727
735
|
- action_id, timestamp (ISO 8601), action_type
|
|
736
|
+
- lifecycle_state: post-dispatch lifecycle state (pending_verification or failed)
|
|
737
|
+
- source_module: runtime source of the action envelope
|
|
728
738
|
- target.selector = { x1, y1, x2, y2, duration }
|
|
729
739
|
- success = true when the swipe was dispatched
|
|
730
740
|
- failure_code/retryable when dispatch fails
|
|
@@ -777,6 +787,8 @@ Inputs:
|
|
|
777
787
|
|
|
778
788
|
Output Structure:
|
|
779
789
|
- action_id, timestamp (ISO 8601), action_type
|
|
790
|
+
- lifecycle_state: post-dispatch lifecycle state (pending_verification or failed)
|
|
791
|
+
- source_module: runtime source of the action envelope
|
|
780
792
|
- target.selector = original selector
|
|
781
793
|
- target.resolved = minimal resolved element info when found
|
|
782
794
|
- success = true when scrolling produced a visible target element
|
|
@@ -831,6 +843,8 @@ Inputs:
|
|
|
831
843
|
|
|
832
844
|
Output Structure:
|
|
833
845
|
- action_id, timestamp (ISO 8601), action_type
|
|
846
|
+
- lifecycle_state: post-dispatch lifecycle state (pending_verification or failed)
|
|
847
|
+
- source_module: runtime source of the action envelope
|
|
834
848
|
- target.selector = { text }
|
|
835
849
|
- success = true when text input was dispatched
|
|
836
850
|
- failure_code/retryable when dispatch fails
|
|
@@ -880,6 +894,8 @@ Inputs:
|
|
|
880
894
|
|
|
881
895
|
Output Structure:
|
|
882
896
|
- action_id, timestamp (ISO 8601), action_type
|
|
897
|
+
- lifecycle_state: post-dispatch lifecycle state (pending_verification or failed)
|
|
898
|
+
- source_module: runtime source of the action envelope
|
|
883
899
|
- target.selector = { key: "back" }
|
|
884
900
|
- success = true when the back action was dispatched
|
|
885
901
|
- failure_code/retryable when dispatch fails
|
|
@@ -918,26 +934,29 @@ Failure Handling:
|
|
|
918
934
|
name: 'classify_action_outcome',
|
|
919
935
|
description: `Classify the outcome of the most recent action into exactly one of: success, no_op, backend_failure, ui_failure, unknown.
|
|
920
936
|
|
|
921
|
-
|
|
922
|
-
Use this
|
|
923
|
-
For backend/API activity, compare get_screen_fingerprint before and after the action and call get_network_activity immediately after the action
|
|
937
|
+
Use the runtime action result's \`action_type\` as \`actionType\` so the classifier can distinguish local-state actions from side-effect actions.
|
|
938
|
+
Use this when the intended outcome is not already fully verified by the UI signal alone.
|
|
939
|
+
For backend/API activity, compare get_screen_fingerprint before and after the action and call get_network_activity immediately after the action if the outcome is still ambiguous.
|
|
924
940
|
|
|
925
941
|
HOW TO GATHER INPUTS before calling:
|
|
926
942
|
1. Call wait_for_screen_change or compare get_screen_fingerprint before/after — set uiChanged accordingly.
|
|
927
943
|
2. If you checked for a specific element with wait_for_ui, set expectedElementVisible.
|
|
928
|
-
3.
|
|
944
|
+
3. Pass actionType from the action response when available.
|
|
945
|
+
4. Only provide networkRequests if you already collected them or want to classify a side-effect action with backend evidence.
|
|
929
946
|
|
|
930
947
|
RULES (applied in order — stop at first match):
|
|
931
948
|
1. If uiChanged=true OR expectedElementVisible=true → outcome=success
|
|
932
|
-
2.
|
|
949
|
+
2. If actionType is missing → outcome=unknown
|
|
933
950
|
3. If any request has status=failure or retryable → outcome=backend_failure
|
|
934
|
-
4. If
|
|
935
|
-
5. If
|
|
936
|
-
6.
|
|
951
|
+
4. If actionType maps to a local-state action → outcome=no_op; prefer state-based verification and avoid default network fallback
|
|
952
|
+
5. If actionType maps to a side-effect action and no networkRequests were supplied → outcome=unknown
|
|
953
|
+
6. If no requests returned → outcome=no_op
|
|
954
|
+
7. If all requests succeeded → outcome=ui_failure
|
|
955
|
+
8. Otherwise → outcome=unknown
|
|
937
956
|
|
|
938
957
|
BEHAVIOUR after outcome:
|
|
939
958
|
- success → continue
|
|
940
|
-
- no_op → retry
|
|
959
|
+
- no_op → retry with richer state verification or re-resolve the element
|
|
941
960
|
- backend_failure → stop and report the failing endpoint
|
|
942
961
|
- ui_failure → stop and report failure
|
|
943
962
|
- unknown → take one recovery step (e.g. capture_debug_snapshot), then stop`,
|
|
@@ -952,9 +971,13 @@ BEHAVIOUR after outcome:
|
|
|
952
971
|
type: 'boolean',
|
|
953
972
|
description: 'true if the element you expected to appear is now visible (from wait_for_ui). Omit if you did not check for a specific element.'
|
|
954
973
|
},
|
|
974
|
+
actionType: {
|
|
975
|
+
type: 'string',
|
|
976
|
+
description: 'The runtime action_type from the action response (for example tap, tap_element, swipe, type_text, press_back, start_app).'
|
|
977
|
+
},
|
|
955
978
|
networkRequests: {
|
|
956
979
|
type: 'array',
|
|
957
|
-
description: '
|
|
980
|
+
description: 'Optional network evidence collected after the action. Use it when the expected outcome is backend/API activity or when the UI signal is ambiguous.',
|
|
958
981
|
items: {
|
|
959
982
|
type: 'object',
|
|
960
983
|
properties: {
|
|
@@ -976,7 +999,7 @@ BEHAVIOUR after outcome:
|
|
|
976
999
|
name: 'get_network_activity',
|
|
977
1000
|
description: `Returns structured network events captured from platform logs since the last action.
|
|
978
1001
|
|
|
979
|
-
Call this
|
|
1002
|
+
Call this immediately after an action when you want backend evidence for a side-effect flow, only if the result is still ambiguous.
|
|
980
1003
|
Do not call more than once per action.
|
|
981
1004
|
|
|
982
1005
|
Events are filtered to significant (non-background) requests only.
|
|
@@ -15,6 +15,7 @@ async function handleStartApp(args) {
|
|
|
15
15
|
const uiFingerprintAfter = await captureActionFingerprint(platform, deviceId);
|
|
16
16
|
return wrapResponse(buildActionExecutionResult({
|
|
17
17
|
actionType: 'start_app',
|
|
18
|
+
sourceModule: 'server',
|
|
18
19
|
device: res.device,
|
|
19
20
|
selector: { appId },
|
|
20
21
|
success: !!res.appStarted,
|
|
@@ -48,6 +49,7 @@ async function handleRestartApp(args) {
|
|
|
48
49
|
const uiFingerprintAfter = await captureActionFingerprint(platform, deviceId);
|
|
49
50
|
return wrapResponse(buildActionExecutionResult({
|
|
50
51
|
actionType: 'restart_app',
|
|
52
|
+
sourceModule: 'server',
|
|
51
53
|
device: res.device,
|
|
52
54
|
selector: { appId },
|
|
53
55
|
success: !!res.appRestarted,
|
|
@@ -265,6 +267,7 @@ async function handleTap(args) {
|
|
|
265
267
|
const uiFingerprintAfter = await captureActionFingerprint(platform, deviceId);
|
|
266
268
|
return wrapResponse(buildActionExecutionResult({
|
|
267
269
|
actionType: 'tap',
|
|
270
|
+
sourceModule: 'server',
|
|
268
271
|
selector: { x, y },
|
|
269
272
|
success: !!res.success,
|
|
270
273
|
uiFingerprintBefore,
|
|
@@ -292,6 +295,7 @@ async function handleSwipe(args) {
|
|
|
292
295
|
const uiFingerprintAfter = await captureActionFingerprint(platform, deviceId);
|
|
293
296
|
return wrapResponse(buildActionExecutionResult({
|
|
294
297
|
actionType: 'swipe',
|
|
298
|
+
sourceModule: 'server',
|
|
295
299
|
selector: { x1, y1, x2, y2, duration },
|
|
296
300
|
success: !!res.success,
|
|
297
301
|
uiFingerprintBefore,
|
|
@@ -312,6 +316,7 @@ async function handleScrollToElement(args) {
|
|
|
312
316
|
const uiFingerprintAfter = await captureActionFingerprint(platform, deviceId);
|
|
313
317
|
return wrapResponse(buildActionExecutionResult({
|
|
314
318
|
actionType: 'scroll_to_element',
|
|
319
|
+
sourceModule: 'server',
|
|
315
320
|
selector: selector ?? null,
|
|
316
321
|
resolved: res?.success && res?.element ? {
|
|
317
322
|
elementId: null,
|
|
@@ -337,6 +342,7 @@ async function handleTypeText(args) {
|
|
|
337
342
|
const uiFingerprintAfter = await captureActionFingerprint('android', deviceId);
|
|
338
343
|
return wrapResponse(buildActionExecutionResult({
|
|
339
344
|
actionType: 'type_text',
|
|
345
|
+
sourceModule: 'server',
|
|
340
346
|
selector: { text },
|
|
341
347
|
success: !!res.success,
|
|
342
348
|
uiFingerprintBefore,
|
|
@@ -352,6 +358,7 @@ async function handlePressBack(args) {
|
|
|
352
358
|
const uiFingerprintAfter = await captureActionFingerprint('android', deviceId);
|
|
353
359
|
return wrapResponse(buildActionExecutionResult({
|
|
354
360
|
actionType: 'press_back',
|
|
361
|
+
sourceModule: 'server',
|
|
355
362
|
selector: { key: 'back' },
|
|
356
363
|
success: !!res.success,
|
|
357
364
|
uiFingerprintBefore,
|
|
@@ -385,11 +392,13 @@ async function handleStopLogStream(args) {
|
|
|
385
392
|
function handleClassifyActionOutcome(args) {
|
|
386
393
|
const uiChanged = requireBooleanArg(args, 'uiChanged');
|
|
387
394
|
const expectedElementVisible = getBooleanArg(args, 'expectedElementVisible');
|
|
395
|
+
const actionType = getStringArg(args, 'actionType');
|
|
388
396
|
const networkRequests = getArrayArg(args, 'networkRequests');
|
|
389
397
|
const hasLogErrors = getBooleanArg(args, 'hasLogErrors');
|
|
390
398
|
const result = classifyActionOutcome({
|
|
391
399
|
uiChanged,
|
|
392
400
|
expectedElementVisible: expectedElementVisible ?? null,
|
|
401
|
+
actionType: actionType ?? null,
|
|
393
402
|
networkRequests: networkRequests ?? null,
|
|
394
403
|
hasLogErrors: hasLogErrors ?? null
|
|
395
404
|
});
|
package/dist/server-core.js
CHANGED
|
@@ -6,7 +6,7 @@ import { handleToolCall } from './server/tool-handlers.js';
|
|
|
6
6
|
export { wrapResponse, toolDefinitions, handleToolCall };
|
|
7
7
|
export const serverInfo = {
|
|
8
8
|
name: 'mobile-debug-mcp',
|
|
9
|
-
version: '0.26.
|
|
9
|
+
version: '0.26.2'
|
|
10
10
|
};
|
|
11
11
|
export function createServer() {
|
|
12
12
|
const server = new Server(serverInfo, {
|
package/docs/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to the **Mobile Debug MCP** project will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## [0.26.2]
|
|
6
|
+
- unified action execution and verification model
|
|
7
|
+
|
|
8
|
+
## [0.26.1]
|
|
9
|
+
- Fixed overuse of `get_network_activity`
|
|
10
|
+
|
|
5
11
|
## [0.26.0]
|
|
6
12
|
- RFC-003 wait/synchronization contract with `snapshot_revision`, `captured_at_ms`, and `loading_state`
|
|
7
13
|
- Added `wait_for_ui_change` for stable in-place UI mutations
|