refactor(provider-webdriver): give BrowserStack and AWS Device Farm the plugin factory shape
Summary
Prepares the 0.22 plan to unbundle hosted device providers (#3309 BrowserStack, #3310 AWS Device Farm, #3311 Limrun) by giving BrowserStack and AWS Device Farm the exact shape an installed WebDriver plugin has, so the extraction becomes a packaging change.
- Each bundled provider is a
BundledCloudWebDriverProvider: a manifest-shapeddeclaration(provider id,connectioncapabilities,credentialVariables) pluscreate(host) -> { webDriver, connection }, the shape TestMu returns from its factory. Connect policy and the credential fingerprint read the declaration the way they read a plugin manifest; no provider-name branch is left insrc/. - Core composes bundled and installed providers through one connect route (
resolveProviderConnectionProfile) and one runtime factory. The bundled definition table, theProviderWebDriverfacade with its test-onlylistArtifactsFromEnv,cloud-webdriver-profile.ts, and the per-provider verify adapters are gone. The CLI now fillsleaseBackendfrom the platform for every provider connection, so TestMu and the Doublespeed plugin no longer each spell the mapping. - Connect-time flag readers (
requireConnectPlatform,requireConnectFlag,resolveLocalAppArtifact) and resolved-profile checks (requireResolvedProfileValue,requireResolvedProfilePlatformin contracts) are shared with TestMu, whose connection module drops its private copies. - Connect callbacks load behind a function-scoped
await import, so a daemon never evaluates connect code; the eager-closure gate stays at the merge-base count with no approval row.@agent-device/provider-webdriver/connection-verificationis the subpath core tests substitute, mirroring the TestMu package.
Behaviour notes: generated BrowserStack/AWS profiles now carry stateDir like every other provider profile; a whitespace-only BrowserStack credential is treated as unset by the fingerprint (it was already refused as missing); the lease-time AWS message now also names <arn>, matching connect; TestMu's hand-authored-profile verify errors use the shared COMMAND_FAILED reconnect hint.
46 files. Gross diff is above the 1,000-line budget because every test that built the bundled runtimes or mocked the facade had to be retargeted; production is net +19 lines with the superseded paths deleted, and test coverage moved with the code (new *-connection.test.ts, *-provider.test.ts).
Validation
Tested commit: 586aa86bb1 (rebased onto d994d1f7e1; the only conflict was the aws-device-farm.ts import block after #3303 removed LeaseValue). The pre-rebase head 172607744c passed pnpm check:affected --run in full.
- On the rebased head every locally runnable gate passes individually (
pnpm gate …: format, lint, typecheck, layering, di-seams, fallow, build, package, integration-node, macos-coverage, unit, wire-compat, production-exports, eager-closure budgets, depgraph, gate-manifest, replay-compat, maestro-conformance, …). provider-integrationis 230/231: the one failure isandroid-lifecycle.test.ts› "Android Settings flow uses scripted ADB provider", whosewaitForFileContenthas a 1 s budget. It fails 2/3 runs at the merge-base commitd994d1f7e1under the same host load and 1/3 runs on this head, so it is a pre-existing contention flake, not a regression; it is unrelated to this change (scripted ADB app-log path).- Cloud WebDriver provider scenarios (6 files, 30 tests) build the bundled runtimes through the new factory;
fallow audit --base origin/mainreports no dead code (one 6-line warn-level clone: the lazy connect wrapper in both providers). - No live provider run: the WebDriver engine, hub requests, and capabilities are untouched; the change is composition and connect routing, covered by the connect tests and provider scenarios above. CI provider-integration and coverage remain GitHub-authoritative.