Expose one typed facade bridge for native computer-use adapters

Merged
MI
2mo ago
+434-6

Provides one typed bridge from native computer-use adapters to the canonical facade on the runner-owned browser. The bridge centralizes MCP results, screenshots, evidence capture, and failure decoding; provider protocols remain in their own adapters.

An internal callback envelope preserves strings such as "42" and "null" as strings while also preserving JSON values and undefined. Malformed action results and incomplete action batches fail explicitly. Visible facade pages also expose their read-only Stagehand pageId, so native tab tools can use the shared visible context without reaching into the hidden keeper tab. Tool and transport failures use fixed typed diagnostics. Runner RPC deadlines now raise a typed StagehandFacadeTimeoutError carrying timeoutMs; the CUA adapter preserves that duration while keeping arbitrary transport-error text generic. Confirmed session loss still takes precedence. Only the runner-owned browser-loss getter can produce terminal session loss, so page content and model-written error strings cannot stop a run by impersonating that signal.

Validation: 23 bridge and transport tests pass, including the compiled facade/MCP fixture, an actual expired RPC, preserved timeout duration, generic handling of spoofed timeout text, and confirmed session loss. Eval typecheck, build prerequisites, and formatting pass.

Stack base: external-contributor-pr-2771. Review this PR relative to its immediate predecessor.

Reviewer entry points:

Current open stack: #2893 → #2894 → #2902 → #2903 → #2889 → #2904 → #2905 → #2906 → #2907.