feat(mobile): a device lease carries agent-device client configuration
Merged
OK
2mo ago+286+286+012345678901234567890123456789-39-39-01234567890123456789
A DeviceLease can now carry client: agent-device client configuration the worker's client is created with, next to the daemon address, which becomes optional.
- agent-device ships its own device-cloud runtimes (Limrun, BrowserStack, AWS Device Farm). Their daemon resolves a hosted device from the lease scope on each command:
tenant,runId,leaseId,leaseBackend,leaseProvider, asleases.allocatereturned it. A command without that scope falls back to the local inventory, and on a Mac with a booted simulator the test silently runs there while the hosted instance sits idle. - The engine's client only knew a session name and a daemon URL, so a provider on one of those runtimes had to put a proxy in front of the daemon that stamped the scope onto every request. Now it returns what
leases.allocategave it. client.stateDirreaches a daemon the provider started for the run, so such a provider needs nodaemonaddress at all. A lease namesdaemon,client, or both.clientis JSON data, since it travels to the worker through the environment under the existing 16 KiB cap.session,daemonBaseUrl, anddaemonAuthTokenstay with the engine anddaemon; a lease setting them is refused atprepare.DeviceClientConfigandDeviceConnectionare exported. The mobile guide gains a second example, a provider on a device cloud through agent-device, typechecked like the first.
const lease = await client.leases.allocate({ tenant, runId, leaseBackend, leaseProvider, platform, target: 'mobile' });
return {
id: lease.leaseId,
client: { stateDir, tenant: lease.tenantId, runId: lease.runId, leaseId: lease.leaseId, leaseBackend, leaseProvider },
};
flowchart LR
P[provider.acquire] -->|lease.client| B[SlotBinding in worker env]
B --> F["createAgentDeviceClient({ ...client, session, daemonBaseUrl?, daemonAuthToken? })"]
F --> D[daemon]
D -->|lease scope on every command| H[hosted device]
Refs: packages/mobile/src/bindings.ts (DeviceClientConfig, isSlotBinding), packages/mobile/src/provider.ts (DeviceLease, isDeviceLease), packages/mobile/src/engine.ts (the client factory), docs/examples/mobile/device-cloud-provider.ts.