feat: add mobile Hermes CDP support and hermes_targets tool#37
Open
cryptotavares wants to merge 2 commits into
Open
feat: add mobile Hermes CDP support and hermes_targets tool#37cryptotavares wants to merge 2 commits into
cryptotavares wants to merge 2 commits into
Conversation
Dispatch the cdp tool through the platform driver so it targets the Chrome CDP session on browser and the React Native Hermes runtime via Metro on mobile, with each driver owning its own destructive-method blocklist. Add a mobile-only hermes_targets tool to list and diagnose debuggable Hermes targets. Extract platform gating into a shared checkPlatformGate helper used by both the HTTP route handler and the run_steps batch executor, and add isMobileOnlyTool alongside the existing browser-only gating so the two paths cannot drift on error code or message.
Wire up the device-mcp encode option so mobile screenshots can return base64 data when includeBase64 is requested, instead of always empty.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is the current state of things and why does it need to change?
The
cdptool was browser-only: it opened a Playwright CDP session against the active page and enforced a hard-coded blocklist of destructive Chrome methods. There was no way to reach the React Native Hermes JS runtime on a mobile session, so agents driving iOS/Android had no raw-CDP escape hatch and no way to inspect which Hermes debug targets Metro exposes. Platform gating (browser-only tool checks) was also duplicated between the HTTP route handler and therun_stepsbatch executor, so the two paths could drift on error code/message and there was no concept of a mobile-only tool.What is the solution your changes offer and how does it work?
cdptool —cdpnow dispatches through the active platform driver instead of talking to Playwright directly. On browser it targets the page's Chrome CDP session (fullRuntime/DOM/Network/Pagesurface); on mobile it targets the app's Hermes JS runtime via Metro's inspector proxy (@metamask/device-mcp), exposing only the JS-engine subset (Runtime,Debugger,Log,HeapProfiler). Each driver owns its own destructive-method blocklist, socdpis no longer classified as browser-only. OptionalmetroPort/appIdinputs are mobile-only (ignored on browser).hermes_targetstool (mobile only) — lists and diagnoses the debuggable Hermes targets Metro exposes, reporting which target would be chosen or why selection is ambiguous, with anallflag to bypass the appId filter and discover the real appId.checkPlatformGatehelper used by both the HTTP route handler and therun_stepsexecutor, plusisMobileOnlyTool, so browser-only / mobile-only gating cannot drift on error code or message. An absent platform driver is treated as "not mobile", so mobile-only tools are gated off.CdpOutcome,HermesTargetsResult, and related types; Zod schemas for the new inputs; andMM_HERMES_FAILED/MM_HERMES_NOT_AVAILABLE/MM_TOOL_NOT_SUPPORTED_ON_PLATFORMerror codes (underlyingHERMES_*codes are preserved in the message).Full unit coverage added for the driver dispatch, the
hermes_targetstool, platform gating, and the batch/route integration paths.Links