# Device Management

AgentKit includes OS-level device management so AI agents can autonomously boot simulators, install apps, grant permissions, and launch — without any manual setup.

> 💡 **Note**: Device commands are **optional**. If the app is already running and connected to the relay, the agent skips device setup and goes straight to UI commands.

## CLI Commands

```bash
npx react-native-agentkit device list [--platform=ios|android]
npx react-native-agentkit device boot [--name="iPhone 16"]
npx react-native-agentkit device shutdown <udid>
npx react-native-agentkit device install <path> [--device=<udid>] [--expo]
npx react-native-agentkit device uninstall <bundle-id> [--device=<udid>]
npx react-native-agentkit device launch <bundle-id> [--device=<udid>] [--expo]
npx react-native-agentkit device terminate <bundle-id> [--device=<udid>]
npx react-native-agentkit device erase <udid>
npx react-native-agentkit device create-emulator <name> [--image=<system-image>]
npx react-native-agentkit device grant-permissions --bundleId=<id> --permissions=camera,photos,...
npx react-native-agentkit device reset-permissions --bundleId=<id>
npx react-native-agentkit device clear-data <package-id> [--device=<serial>]
npx react-native-agentkit device status
```

All commands output JSON for pipe-mode compatibility.

## Permission Pre-Granting

Grant OS-level permissions before app launch to prevent native permission dialogs during automation:

```bash
# iOS (via xcrun simctl privacy)
npx react-native-agentkit device grant-permissions \
  --bundleId=com.myapp \
  --permissions=camera,photos,location,notifications

# Android (via adb shell pm grant)
npx react-native-agentkit device grant-permissions \
  --packageId=com.myapp \
  --permissions=CAMERA,ACCESS_FINE_LOCATION
```

On Android, `device install` grants all manifest-declared permissions by default.

### iOS Permission Services

`calendar`, `contacts`, `location`, `location-always`, `camera`, `microphone`, `photos`, `reminders`, `siri`, `notifications`, `speech-recognition`, `motion`, `media-library`, or `all`

### Android Permissions

Use short names (e.g., `CAMERA`, `ACCESS_FINE_LOCATION`) or full names (e.g., `android.permission.CAMERA`). Short names are auto-expanded.

## Physical iOS Devices

For physical device deployment, AgentKit uses [ios-deploy](https://github.com/ios-control/ios-deploy) (auto-installed via Homebrew if missing):

```bash
npx react-native-agentkit device list --platform=ios  # Shows simulators + physical devices
npx react-native-agentkit device install ./MyApp.app --device=<udid>
npx react-native-agentkit device launch com.myapp --device=<udid>
```

## Expo Integration

For Expo-managed projects, use the `--expo` flag:

```bash
npx react-native-agentkit device install --expo --platform=ios
npx react-native-agentkit device launch --expo --platform=android
```
