import { AndroidAppLaunchSimulation } from '@igpapi/android';
import { Effect } from 'effect';
// One call builds the app on the virtual device and launches it: a fresh
// install returns the login homepage, a stored session opens on the feed.
const screen = await Effect.runPromise(Effect.scoped(AndroidAppLaunchSimulation({ seed: username })));
The Instagram Android app on a virtual device, as a
Layer: everything the package's public effects and screens run on — the login, the screens and their actions, the shared mobile effects,ExportSnapshotandProtocolDiagnostics. The process entryAndroidAppLaunchSimulationbuilds this same layer from the same options and launches it in one call.Start from
seed(a deterministic new device) or fromsnapshot(a session exported earlier withExportSnapshot). The other options are those of the native transport and the device's network.One build is one app process. Building the layer creates the device and session state, the native transport client and the process state (screen stack, navigation, telemetry); everything the program changes lives in that build. Provide the layer once around the whole program, or keep it in a
ManagedRuntimeyou own: providing it to two programs separately starts two processes from the same input. Export the snapshot inside the program (or the runtime) whose state it should carry.A snapshot that cannot be restored (a damaged cookie jar or state) fails the build with
SnapshotDecodeError, an expected failure to handle — usually by logging in again. Asnapshotkey present butundefinedis not a snapshot: it is the caller's "no saved session", so the layer starts a fresh install instead of failing. Invalid options (a request timeout out of range, a protocol mode the Android profile does not have) are a programming error and fail the build as a defect.