Skip to main content

A library for controlling mobile applications via native debugging bridges

Project description

App Use - AI Control for Mobile Apps

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,
        max_steps=10  # Limit the number of steps the agent will take
    )
    
    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. Run your Flutter app with the VM service enabled:

```bash
flutter run --observe
  1. Look for the VM service URI in the console output, which looks like: Observatory listening on http://127.0.0.1:50505/xyzabcdef=/

  2. Use the WebSocket version of this URI in your code: ws://127.0.0.1:50505/ws

Customize

Widget Interaction Methods

App Use provides several methods to interact with UI elements:

  • click_widget_by_unique_id: Click a widget, with intelligent fallback to parent/child widgets if needed
  • enter_text_with_unique_id: Enter text into a widget
  • scroll_into_view: Ensure a widget is visible
  • scroll_up_or_down: Scroll in a specific direction

Each method tries multiple approaches to ensure successful interaction, including:

  • By Flutter key
  • By text content
  • By widget type
  • By ancestor-descendant relationship
  • By element key/id
  • By text content
  • By element type
  • By ancestor-descendant relationship

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.dev1.tar.gz (34.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.dev1-py3-none-any.whl (34.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: app_use-0.0.1.dev1.tar.gz
  • Upload date:
  • Size: 34.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.dev1.tar.gz
Algorithm Hash digest
SHA256 eda42777bc7ceecfd8f92c77c11111d7816ab4c7f93316b3001760e556aeb58e
MD5 671ddf020dfc8fb523b5b255793b1b07
BLAKE2b-256 1ead9f0611ef7e49da97086e21cff44d4ce92f611fbb60cf85d0ec71b84240f3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: app_use-0.0.1.dev1-py3-none-any.whl
  • Upload date:
  • Size: 34.4 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.dev1-py3-none-any.whl
Algorithm Hash digest
SHA256 41216698ac521f27f9353d1a9217f418c96070f742c324df6b4daa3bb2c3a0f0
MD5 c84fab1dca0cf9284f51fc7610f71b33
BLAKE2b-256 dadcfbd8eb6029dc7f653d9747059027ce053c19cfcb07fd39c826e60c043601

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