Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -740,8 +740,8 @@
"@metamask/auto-changelog": "^6.2.0",
"@metamask/browser-passworder": "^6.0.0",
"@metamask/browser-playground": "0.8.1",
"@metamask/client-mcp-core": "^0.15.0",
"@metamask/device-mcp": "^0.9.0",
"@metamask/client-mcp-core": "^0.16.1",
"@metamask/device-mcp": "^0.10.0",
"@metamask/eslint-config": "15.0.1",
"@metamask/eslint-config-typescript": "15.0.1",
"@metamask/eslint-plugin-design-tokens": "^2.1.0",
Expand Down
4 changes: 2 additions & 2 deletions tests/llm-workflow/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,6 @@ Launch errors use the core `ErrorCode` set, because the `mm` CLI maps each known
| `MM_INVALID_CONFIG` | The launch options are not usable: no app installed and no `--app-bundle`, a destructive flag without `--app-bundle`, a `fox_code` mismatch, an unreachable Metro port, or an E2E-only option in this prod-only workflow. Read the remediation text in the error. |
| `MM_LAUNCH_FAILED` | The app or platform driver failed to start. Run `yarn mm cleanup` and retry. |
| `MM_NO_ACTIVE_SESSION` | Run `yarn mm launch`. |
| `MM_TARGET_NOT_FOUND` | Run `yarn mm describe-screen` and use fresh refs. |
| `MM_TARGET_NOT_FOUND` | Run `yarn mm describe-screen` and use fresh refs. A ref without a test ID, label or text, or marked `ambiguous`, works only with `click`; the error `hint` names what to use instead. |

The workflow uses `@metamask/client-mcp-core` 0.15.0 (mobile platform support since 0.8.0); `@metamask/device-mcp` 0.9.0 supplies the device backends. Core and this workflow must resolve the same device-mcp copy: the workflow creates the backend, so device-mcp fixes (such as the Android tap occlusion check) only apply through it. The device-mcp snapshot helper and its `helper-first` default ship since `@metamask/device-mcp` 0.6.0. When a device-mcp build does not ship the helper APK, the backend default is `dump`. The Android adapter identifies the ADB backend via `@metamask/device-mcp`'s public `DeviceBackend.kind` discriminator (added in 0.3.3).
The workflow uses `@metamask/client-mcp-core` 0.16.1 (mobile platform support since 0.8.0); `@metamask/device-mcp` 0.10.0 supplies the device backends. Core and this workflow must resolve the same device-mcp copy: the workflow creates the backend, so device-mcp fixes (such as the Android tap occlusion check, or iOS `type ""` exiting 0) only apply through it. The device-mcp snapshot helper and its `helper-first` default ship since `@metamask/device-mcp` 0.6.0. When a device-mcp build does not ship the helper APK, the backend default is `dump`. The Android adapter identifies the ADB backend via `@metamask/device-mcp`'s public `DeviceBackend.kind` discriminator (added in 0.3.3).
25 changes: 10 additions & 15 deletions tests/llm-workflow/__tests__/metamask-provider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ describe('MetaMaskMobileSessionManager', () => {
);
});

it('keeps the resolved Metro port and device as the driver Hermes defaults', async () => {
it('returns the resolved Metro port and device from launch', async () => {
const setHermesDefaults = jest.fn();
iosResolve.mockResolvedValue({
platform: 'ios',
Expand All @@ -204,24 +204,19 @@ describe('MetaMaskMobileSessionManager', () => {
state,
});

await manager.launch(createLaunchInput());
const result = await manager.launch(createLaunchInput());

expect(setHermesDefaults).toHaveBeenCalledWith({
deviceId: 'SIM-UDID',
metroPort: 8085,
});
expect(result).toEqual(
expect.objectContaining({ metroPort: 8085, deviceId: 'SIM-UDID' }),
);
expect(setHermesDefaults).not.toHaveBeenCalled();
});

it('sets only the device as a Hermes default when no Metro port is resolved', async () => {
const setHermesDefaults = jest.fn();
iosLaunch.mockResolvedValue({
driver: { ...mobileDriver, setHermesDefaults },
state,
});

await manager.launch(createLaunchInput());
it('returns no Metro port from launch when none is resolved', async () => {
const result = await manager.launch(createLaunchInput());

expect(setHermesDefaults).toHaveBeenCalledWith({ deviceId: 'SIM-UDID' });
expect(result.metroPort).toBeUndefined();
expect(result.deviceId).toBe('SIM-UDID');
});

it('generates an mm-prefixed session ID and persists session metadata to the default artifacts dir', async () => {
Expand Down
16 changes: 7 additions & 9 deletions tests/llm-workflow/metamask-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,6 @@ export class MetaMaskMobileSessionManager implements ISessionManager {

const { driver: mobileDriver, state } = await adapter.launch(resolved);
this.platformDriver = mobileDriver;
// Core only keeps the `--metro-port` flag for `cdp`/`hermes-targets`;
// pass the resolved port so `MM_METRO_PORT` is kept as well.
mobileDriver.setHermesDefaults?.({
deviceId: resolved.deviceId,
...(resolved.metroPort === undefined
? {}
: { metroPort: resolved.metroPort }),
});

const sessionId = generateSessionId();
const startedAt = new Date().toISOString();
Expand Down Expand Up @@ -164,7 +156,13 @@ export class MetaMaskMobileSessionManager implements ISessionManager {
// Non-blocking: launch succeeds even when metadata persistence fails.
}

return { sessionId, extensionId: resolved.appId, state };
return {
sessionId,
extensionId: resolved.appId,
state,
metroPort: resolved.metroPort,
deviceId: resolved.deviceId,
};
} catch (error) {
const launchError = this.toLaunchError(error, requestedPlatform);
try {
Expand Down
22 changes: 11 additions & 11 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9947,11 +9947,11 @@ __metadata:
languageName: node
linkType: hard

"@metamask/client-mcp-core@npm:^0.15.0":
version: 0.15.0
resolution: "@metamask/client-mcp-core@npm:0.15.0"
"@metamask/client-mcp-core@npm:^0.16.1":
version: 0.16.1
resolution: "@metamask/client-mcp-core@npm:0.16.1"
dependencies:
"@metamask/device-mcp": "npm:^0.9.0"
"@metamask/device-mcp": "npm:^0.10.0"
cosmiconfig: "npm:^9.0.0"
express: "npm:^5.2.1"
zod: "npm:^4.4.3"
Expand All @@ -9960,7 +9960,7 @@ __metadata:
playwright: ^1.49.0
bin:
mm: ./dist/cli/mm.cjs
checksum: 10/d1200be23e574c98d75c5389336fbf0028f272a7aa18aad67eeaccc220375959587a827d5583c2b952dbb0a6044c2d17e81a41cd32c0563638a44410fe5210cd
checksum: 10/ad45b9a696350fc0ec384ac42e6605403291d626474d0d51232e7b7e60b9ff898f8376ec2fc884e566de45fbffbe03596c2b71d77052b6adaf58c83fa227f37e
languageName: node
linkType: hard

Expand Down Expand Up @@ -10205,15 +10205,15 @@ __metadata:
languageName: node
linkType: hard

"@metamask/device-mcp@npm:^0.9.0":
version: 0.9.0
resolution: "@metamask/device-mcp@npm:0.9.0"
"@metamask/device-mcp@npm:^0.10.0":
version: 0.10.0
resolution: "@metamask/device-mcp@npm:0.10.0"
dependencies:
"@modelcontextprotocol/sdk": "npm:^1.32.0"
zod: "npm:^4.6.6"
bin:
device-mcp: ./dist/cli/device-mcp.mjs
checksum: 10/edffb339e331a1b2f7ad175ca24d277dfc08e75d4f7e7dcf14a1c72ab0abb659783e4025b72934386af135d0b9cbaabaa2ba2962336f0b646b29a29d51b5bdf5
checksum: 10/6e028567cb1d63d0777be410cf6f31838d5a645bf1c53d738ef895b105bd47abf361350625d7a93dba374c8a27b62546838e571d2a890ad1eb27a749d0bc015e
languageName: node
linkType: hard

Expand Down Expand Up @@ -38906,7 +38906,7 @@ __metadata:
"@metamask/chomp-api-service": "npm:^7.1.0"
"@metamask/claims-controller": "npm:^1.1.0"
"@metamask/client-controller": "npm:^2.0.0"
"@metamask/client-mcp-core": "npm:^0.15.0"
"@metamask/client-mcp-core": "npm:^0.16.1"
"@metamask/client-utils": "npm:^3.4.1"
"@metamask/compliance-controller": "npm:3.0.0"
"@metamask/config-registry-controller": "npm:^6.0.0"
Expand All @@ -38919,7 +38919,7 @@ __metadata:
"@metamask/design-system-react-native": "npm:^0.60.1"
"@metamask/design-system-twrnc-preset": "npm:^0.14.0"
"@metamask/design-tokens": "npm:^13.0.0"
"@metamask/device-mcp": "npm:^0.9.0"
"@metamask/device-mcp": "npm:^0.10.0"
"@metamask/earn-controller": "npm:^13.1.0"
"@metamask/eip-5792-middleware": "npm:^4.1.1"
"@metamask/eip1193-permission-middleware": "npm:^3.1.0"
Expand Down
Loading