Skip to main content

A library for controlling mobile applications via native debugging bridges

Project description

App Use - AI Control for Mobile Apps

ChatGPT Image May 16, 2025 at 03_14_14 PM

Warning: This project is currently under active development. APIs will change! Currently in experimental stages.

App Use is the easiest way to connect AI agents with mobile applications. It enables AI to control your mobile apps through native debugging bridges, providing a powerful yet simple interface for app automation.

Currently, App Use focuses on Flutter apps via the Dart VM Service, with plans to expand to other frameworks like React Native in the future.

Overview

App Use allows you to automate interactions with mobile apps, such as:

  • Clicking buttons and interactive widgets
  • Entering text into fields
  • Scrolling and navigating screens
  • Building AI-powered agents that can interact with mobile app UIs

Perfect for testing, automation, and AI agent applications.

Getting Started

Installation

Install the package using pip:

pip install -r requirements.txt

Quick Start with LLM Agents

Use AI agents to intelligently interact with your mobile app:

import asyncio
import os
from dotenv import load_dotenv
from langchain_openai import ChatOpenAI

from app_use.agent.service import Agent
from app_use.app.app import App

# Load environment variables (like OPENAI_API_KEY)
load_dotenv()

async def main():
    # WebSocket URI for a running Flutter app
    VM_SERVICE_URI = "ws://127.0.0.1:50505/ws"
    
    # Set up your LLM
    llm = ChatOpenAI(
        api_key=os.environ.get("OPENAI_API_KEY"),
        model="gpt-4o",  # or any other model
        temperature=0
    )
    
    # Create an App instance to connect to the Flutter application
    app = App(vm_service_uri=VM_SERVICE_URI)
    
    # Create an agent to control the app
    agent = Agent(
        task="Explore the app and find all buttons, then click on the Login button if it exists.",
        llm=llm,
        app=app,
    )
    
    try:
        # Run the agent
        history = await agent.run()
        
        # Print results
        if history.is_successful():
            print("✅ Agent successfully completed the task!")
        else:
            print("⚠️ Agent couldn't complete the task.")
        
        # Show the final result/message
        print(f"Final result: {history.final_result()}")
        
    except Exception as e:
        print(f"❌ Error: {e}")
    finally:
        # Make sure to close resources
        await agent.close()
        app.close()

if __name__ == "__main__":
    asyncio.run(main())

### Setting Up a Flutter App for Control

> Currently, App Use supports Flutter apps, with more frameworks coming soon.

1. Makesure to enable the flutter driver extension in your mobile app

```dart
import 'package:flutter_driver/driver_extension.dart';

void main() {
  enableFlutterDriverExtension();
  runApp(const HomeScreen());
}
  1. Run your Flutter app with the VM service enabled:
flutter run
  1. Look for the VM service URI in the console output, which looks like: ws://127.0.0.1:50505/ws

Features

  • Smart Widget Interaction: Automatically attempts to interact with parent or child widgets if direct interaction fails
  • Automatic Resource Management: Proper cleanup of connections and services
  • Context Manager Support: Use the with statement for proper resource handling
  • Intelligent Port Management: Automatically handles port conflicts
  • Extensive UI Tree Access: Full access to the application's UI tree
  • Flexible Element Finding: Find UI elements by key, text, type, or hierarchical position

Extending App Use

You can extend App Use by:

  • Creating custom Agent implementations
  • Adding new widget interaction patterns
  • Adding support for additional app frameworks
  • Building domain-specific UI automation tools

Community & Support

Contributions are welcome! Please feel free to submit a Pull Request.

App Use is actively maintained and designed to make mobile app control as simple and reliable as possible.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

app_use-0.0.1.dev6.tar.gz (44.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

app_use-0.0.1.dev6-py3-none-any.whl (46.7 kB view details)

Uploaded Python 3

File details

Details for the file app_use-0.0.1.dev6.tar.gz.

File metadata

  • Download URL: app_use-0.0.1.dev6.tar.gz
  • Upload date:
  • Size: 44.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for app_use-0.0.1.dev6.tar.gz
Algorithm Hash digest
SHA256 ca375372486468095be4481e1f276e8dc6caacfce3dffc4e8217e77e8fe2c9cb
MD5 aa2420cfbc2922cca879d4c4e1151d04
BLAKE2b-256 90f613d11f71ff641d3b5fd0a430c7a326599119187dae655429dd0e859d03c7

See more details on using hashes here.

File details

Details for the file app_use-0.0.1.dev6-py3-none-any.whl.

File metadata

  • Download URL: app_use-0.0.1.dev6-py3-none-any.whl
  • Upload date:
  • Size: 46.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for app_use-0.0.1.dev6-py3-none-any.whl
Algorithm Hash digest
SHA256 1092522cb6f9834fa612f1aa10ff35547ea1b11e94bf6a297d5a6b999ea88985
MD5 6ad9e196558ad92c4d8f878a7c6edc0a
BLAKE2b-256 57ee11c5e9ff34d31ec38d086f297a6be3879c729681063a25aae8b94f9d7beb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page