Skip to content

agent.actions.network

Actions

Network and connectivity operations.

Access these methods through agent.actions. Manage network connectivity and IP address changes.

airplane

Signature
airplane(): Promise<void>

Toggles airplane mode on and off to refresh the mobile network connection. This method turns airplane mode ON, waits briefly, then turns it OFF. Primarily used for changing IP address when connected to a mobile/cellular network.

Returns Promise<void>Resolves after airplane mode cycle completes.

Change IP address on mobile network
// Refresh mobile network to get a new IP
await agent.actions.airplane();
console.log("Mobile network refreshed with new IP");
Retry with new IP on failure
async function fetchWithIPRefresh(url: string) {
  try {
    // First attempt
    return await fetch(url);
  } catch (error) {
    // Refresh IP and retry
    await agent.actions.airplane();
    await agent.control.wait(2000); // Wait for network to stabilize
    return await fetch(url);
  }
}

adb.airplane

Signature
adb.airplane(): Promise<boolean>

Toggles airplane mode on and off via ADB shell commands. Same effect as agent.actions.airplane() but does not require the app to be set as the device assistant — only a working ADB connection. Useful when the assistant role can't be granted but ADB is available.

Returns Promise<boolean>Resolves with true if the toggle was kicked off, false if ADB is not connected.

Rotate IP via ADB
const ok = await agent.actions.adb.airplane();
if (!ok) {
  console.warn("ADB not connected — could not rotate IP");
}
Important Notes
  • Only works when the device is connected to a mobile/cellular network.
  • Wi-Fi connections are not affected by this method.
  • The new IP address is assigned by your mobile carrier.
  • There may be a brief period of no connectivity during the toggle.
Use Case: Rate Limit Bypass
// When rate limited, get new IP and continue
async function handleRateLimit() {
  console.log("Rate limited, refreshing IP...");
  await agent.actions.airplane();

  // Wait for network to fully reconnect
  const status = await agent.utils.isServerReachable();
  if (!status.reachable) {
    await agent.control.wait(3000);
  }

  console.log("IP refreshed, continuing automation");
}