lucy-screen-agent

agent
Security Audit
Pass
Health Pass
  • License รขโ‚ฌโ€ License: MIT
  • Description รขโ‚ฌโ€ Repository has a description
  • Active repo รขโ‚ฌโ€ Last push 0 days ago
  • Community trust รขโ‚ฌโ€ 13 GitHub stars
Code Pass
  • Code scan รขโ‚ฌโ€ Scanned 9 files during light audit, no dangerous patterns found
Permissions Pass
  • Permissions รขโ‚ฌโ€ No dangerous permissions requested

No AI report is available for this listing yet.

SUMMARY

๐Ÿ”ฎ Lucy โ€” a screen-aware AI voice agent for Android. She sees your screen, understands it with Gemini, and taps and types for you.

README.md

๐Ÿ”ฎ Lucy

Your screen-aware AI companion for Android

Lucy sees your screen, understands what's on it, and taps, types and swipes for you โ€” all from a voice command.

Latest release
Downloads
CI
License: MIT
Flutter
Platform
Gemini
PRs Welcome
Ko-fi

Download the latest APK

Download ยท Quick Start ยท How It Works ยท Contributing ยท Troubleshooting


๐ŸŽฌ Lucy in action

https://github.com/user-attachments/assets/2fd60821-7cae-42f9-aa20-763938b61d23

"There's an e-mail called 'my manager' in my e-mail list. I want you to send an
e-mail with the subject 'Today's agenda' mentioning the team meeting at 10 AM."

Lucy finds the contact, opens the compose screen, fills in the recipient, subject
and body, and sends it. Every tap and keystroke is hers.


[!IMPORTANT]
Lucy is an experimental research project. To work, she needs two of the most powerful permissions Android offers: screen capture and an accessibility service that can tap and type on your behalf. Read Privacy & Security before you install, and prefer a spare or test device.


๐Ÿ“– Table of Contents


๐Ÿ”ฎ What is Lucy?

Most voice assistants are limited to the apps their vendor integrated with. Lucy takes a different approach: instead of using APIs, she uses the phone the way you do.

Say "Open WhatsApp and send Sarah a message saying I'm running late." Lucy will:

  1. ๐Ÿ‘‚ Transcribe your voice
  2. ๐Ÿ“ธ Take a screenshot of whatever is currently on screen
  3. ๐ŸŒฒ Read the Android accessibility tree โ€” every button, label and text field with exact pixel bounds
  4. ๐Ÿค– Send the screenshot and the UI tree to Google Gemini, which replies with a single next action
  5. โšก Execute that action through the accessibility service โ€” a real tap, a real keystroke
  6. ๐Ÿ” Take a fresh screenshot and repeat until the task is done
  7. ๐Ÿ”Š Speak the result back to you, in your language

Because Lucy works at the screen level, she works with any app on your phone โ€” no integration required.

Who Lucy is for

Lucy started with a simple problem: driving. On a long drive you constantly want small things from your phone โ€” reply to a message, skip to another playlist, re-route to a petrol station โ€” and every one of them normally means picking the phone up. Lucy lets you ask out loud and keep both hands on the wheel.

That turned out to be one case out of several. The common thread is your hands are busy, or using them is hard:

๐Ÿš— Driving Reply, navigate and change music by voice, without reaching for the phone.
โ™ฟ Limited dexterity Tremor, arthritis, RSI, paralysis, or a temporary cast โ€” Lucy does the tapping. Screen readers describe a screen; Lucy actually operates it.
๐Ÿ‘ฉโ€๐Ÿณ Hands full or dirty Cooking, workshop, gardening, gloves in winter, carrying a child or the shopping.
๐Ÿ‘ด Unfamiliar with the phone Say what you want instead of hunting through five levels of settings menus.
๐Ÿ” Tedious multi-step chores Anything buried eight taps deep across three apps becomes one sentence.
๐Ÿงฉ Apps with no automation No API, no Shortcuts support, no integration? Doesn't matter โ€” Lucy drives the UI itself.

[!WARNING]
Lucy is a hands-free convenience, not a safety device. She is experimental and can act on the wrong element. If you use her while driving, set the command running before you move off and keep your eyes on the road โ€” never read or correct her mid-drive. Obey your local road traffic laws; in many countries, including Japan, operating or looking at a phone screen while the vehicle is moving is an offence regardless of how the phone is controlled.


โœจ Features

๐Ÿ—ฃ๏ธ Voice-driven Speech-to-text in, text-to-speech out. No typing required.
๐Ÿ‘๏ธ Screen-aware Combines a JPEG screenshot with a structured accessibility tree, so the model sees and reads the screen.
๐ŸŽฏ No hallucinated taps The model taps elements by ID, never by guessed coordinates. Real pixel bounds are resolved on the Dart side from the accessibility tree.
๐ŸŒ Trilingual English ๐Ÿ‡ฌ๐Ÿ‡ง, Japanese ๐Ÿ‡ฏ๐Ÿ‡ต and Arabic ๐Ÿ‡ธ๐Ÿ‡ฆ โ€” with language detection and matching TTS/STT locales.
๐Ÿ”„ Agentic loop Observe โ†’ decide โ†’ act โ†’ re-observe, up to 50 steps per command.
๐Ÿ›‘ Always interruptible A persistent "Stop Lucy" notification cancels the agent instantly, even while she's inside another app.
๐ŸŽจ Live transcript Every screenshot, action and reply is shown in a scrollable conversation view.
๐Ÿ”‘ Bring your own key Your Gemini API key stays on your device. No backend, no telemetry, no account.

๐Ÿ“ฅ Download & Install

Every release ships a ready-to-install APK. You don't need Flutter, Android Studio,
or a computer at all โ€” just your phone.

Download the latest APK

That link never changes and always serves the newest stable build. If you want a
smaller download or a specific version, pick one from the
Releases page:

File Who it's for
lucy-latest.apk The newest stable build, always at the same URL. Installs on any device.
lucy-vX.Y.Z-arm64-v8a.apk Most people โ€” any Android phone from roughly 2017 onwards. Smallest download.
lucy-vX.Y.Z-universal.apk Every CPU variant in one file. Larger, but installs anywhere.
lucy-vX.Y.Z-armeabi-v7a.apk Older 32-bit phones.
lucy-vX.Y.Z-x86_64.apk Emulators and x86 tablets.

Each release also attaches SHA256SUMS.txt if you'd like to verify what you downloaded.

Installing the APK

  1. Tap the downloaded .apk โ€” from your notification shade, or in Files โ†’ Downloads.
  2. Android asks whether to allow installs from your browser or file manager. Allow it (Settings โ†’ Install unknown apps), then tap Install.
  3. Play Protect may warn that the developer is unknown. That's expected for any app not distributed through the Play Store โ€” tap Install anyway if you're happy to proceed.

Then three more steps

Installing is only the beginning; Lucy is inert until she has her permissions and a key. The app walks you through each one:

Where
โ™ฟ Enable Lucy's accessibility service โ€” this is how she taps and types Step 8
๐Ÿ“ธ Grant screen capture when the mic button asks Step 9
๐Ÿ”‘ Paste a free Gemini API key from AI Studio Steps 6โ€“7

[!WARNING]
Release APKs are currently signed with a debug key, so the signature isn't stable between builds. If you already have Lucy installed, uninstall her before installing a newer version โ€” otherwise Android refuses the update with INSTALL_FAILED_UPDATE_INCOMPATIBLE. See docs/RELEASING.md.

Would rather build it yourself and read the code first? That's the Quick Start below โ€” very reasonable, given what Lucy is allowed to do.


๐Ÿง  How It Works

flowchart TD
    A([๐ŸŽค User speaks]) --> B[speech_to_text<br/>transcription]
    B --> C{{AgentController<br/>agent loop}}

    C -->|1 ยท observe| D[MediaProjection<br/>screenshot โ†’ JPEG]
    C -->|1 ยท observe| E[AccessibilityService<br/>UI tree โ†’ JSON]

    D --> F[[Google Gemini<br/>vision + reasoning]]
    E --> F

    F -->|strict JSON:<br/>one action + speak + done| G{done?}

    G -->|no ยท 2 ยท act| H[AccessibilityService<br/>tap / type / swipe / back / home]
    H -->|3 ยท re-observe| C

    G -->|yes| I[flutter_tts<br/>speaks the answer]
    I --> J([๐Ÿ”Š User hears the result])

    style F fill:#8E75B2,color:#fff
    style C fill:#6C63FF,color:#fff

The two sources of truth

Vision alone is unreliable for UI automation โ€” models guess coordinates and miss by 40 pixels. Lucy solves this by giving Gemini both a picture and a map:

// What Gemini receives alongside the screenshot
{
  "package": "com.whatsapp",
  "elements": [
    { "id": 5, "type": "Button", "text": "Send", "clickable": true,
      "bounds": { "cx": 1012, "cy": 2180, "w": 120, "h": 120 } },
    { "id": 6, "type": "EditText", "desc": "Type a message", "editable": true,
      "bounds": { "cx": 520, "cy": 2180, "w": 860, "h": 120 } }
  ]
}

Gemini replies with {"type": "tap", "element": 5} โ€” an ID, not a coordinate. Lucy looks up the real bounds and dispatches a gesture there. This single design choice is what makes the agent reliable.

Available actions

Action Parameters Effect
open_app package Launch an app by package name
tap element Tap the accessibility element with that ID
type text Type into the focused input field
swipe startX, startY, endX, endY Scroll or swipe
back โ€” Press the system back button
home โ€” Press the system home button
wait ms Pause before the next observation

After each action Lucy waits for the screen to actually settle โ€” a package change, a UI-tree change, or a newly focused text field โ€” instead of sleeping a fixed amount of time.


๐Ÿ“‹ Requirements

Minimum Notes
Flutter Dart SDK ^3.11.1 Verified on Flutter 3.47.1 / Dart 3.13.1
Android device Android 7.0 (API 24) Targets API 36. A physical device is strongly recommended โ€” emulators often lack a usable STT/TTS engine
JDK 17 Bundled with recent Android Studio
Gemini API key free tier works Get one at aistudio.google.com

[!NOTE]
Android only. Screen capture and the action layer are implemented in Kotlin against Android APIs. There is no iOS target โ€” iOS does not permit this kind of system-wide control.


๐Ÿš€ Quick Start

Step 1 โ€” Install Flutter

If you don't have Flutter yet, follow the official install guide, then verify your setup:

flutter doctor

Make sure the Android toolchain row has a green check. Everything else (iOS, web, desktop) is irrelevant for Lucy.

Step 2 โ€” Clone the repository

git clone https://github.com/alzin/lucy-screen-agent.git
cd lucy-screen-agent

Step 3 โ€” Install dependencies

flutter pub get

Step 4 โ€” Connect your Android device

  1. On your phone, open Settings โ†’ About phone and tap Build number seven times to unlock Developer options.
  2. Go to Settings โ†’ Developer options and enable USB debugging.
  3. Plug the phone into your computer and accept the debugging prompt.
  4. Confirm your computer can see it:
flutter devices

Step 5 โ€” Run the app

flutter run

The first build downloads Gradle dependencies and can take several minutes. Later runs are much faster.

Step 6 โ€” Get a Gemini API key

  1. Open Google AI Studio.
  2. Sign in and click Create API key.
  3. Copy the key โ€” it starts with AIza....

Step 7 โ€” Add your key to Lucy

In the app, tap the ๐Ÿ”‘ key icon in the top bar, paste your key and hit Save. It is stored locally with shared_preferences and never leaves your device except in requests to Google's Gemini API.

Step 8 โ€” Enable the accessibility service

Lucy cannot start without this โ€” it's how she taps and types.

  1. The app shows an "Accessibility Required" screen on first launch. Tap Open Settings.
  2. Navigate to Installed apps (wording varies by manufacturer) โ†’ Lucy.
  3. Toggle it on and accept the system warning.
  4. Return to Lucy with the back button โ€” she detects the change automatically.

Step 9 โ€” Grant screen capture

Tap the ๐ŸŽค microphone button. Android shows a "Start recording or casting?" dialog โ€” tap Start now. This grants the MediaProjection permission Lucy uses to screenshot.

Step 10 โ€” Talk to her

Say something like:

"Open the calculator and work out 47 times 12."

Watch the conversation view fill up with screenshots and actions. ๐ŸŽ‰


๐ŸŽฎ Using Lucy

Example commands

Command
๐Ÿ“ฑ "Open YouTube and search for lofi hip hop."
โš™๏ธ "Go to settings and turn on Bluetooth."
๐Ÿ‘€ "What's on my screen right now?"
๐Ÿ’ฌ "Open WhatsApp and message Mom that I'll call tonight."
โฐ "Set an alarm for 7 in the morning."

Lucy asks "Do you need any further help?" after each completed task. Answer "no" (or "stop", "nothing") and she shuts down cleanly.

Switching language ๐ŸŒ

Tap the ๐ŸŒ language selector in the top bar to pick English, ๆ—ฅๆœฌ่ชž or ุงู„ุนุฑุจูŠุฉ. This sets the speech-recognition locale.

Lucy also detects the language you actually spoke and replies in it โ€” the AI tags each response with a language code, and the app switches its TTS voice and follow-up prompts to match. Your choice persists across restarts.

Stopping the agent ๐Ÿ›‘

Three ways, in order of urgency:

  1. The red stop button in the app โ€” tap the mic button while she's running.
  2. The "Stop Lucy" notification โ€” swipe down from anywhere, even inside another app, and tap Stop Lucy. This is the one you want when she's off doing something in a different app.
  3. Force-stop the app from Android settings โ€” the nuclear option.

Lucy also stops herself automatically after 50 steps on a single command, so she can never loop forever.


๐Ÿ“ฆ Building & Releasing

Published releases are automatic

Nobody builds or uploads an APK by hand. .github/workflows/release.yml watches main and reads the version: in pubspec.yaml. When the semantic part โ€” everything before the + โ€” has no matching vX.Y.Z tag yet, it analyzes, tests, builds and publishes a GitHub Release with every APK attached.

So the version bump is the trigger, not the merge: merges that leave it alone produce no release, and bumping only the build number after the + doesn't either. Full details, including how to cut one, live in docs/RELEASING.md.

Building a release APK locally

flutter build apk --release

The APK lands in build/app/outputs/flutter-apk/app-release.apk. Without a keystore this is signed with the debug key โ€” fine for testing on your own device, not for distribution.

Signing it with your own key

1. Create a keystore

keytool -genkey -v -keystore lucy-release.jks -keyalg RSA -keysize 2048 -validity 10000 -alias lucy

2. Create android/key.properties

storePassword=<your store password>
keyPassword=<your key password>
keyAlias=lucy
storeFile=<absolute path to lucy-release.jks>

Build again and Gradle picks it up automatically.

[!WARNING]
key.properties, *.jks and *.keystore are in .gitignore. Never commit them. Anyone with your keystore can publish updates impersonating your app.

To sign the published releases too, the same keystore goes into four repository secrets โ€” see docs/RELEASING.md.

Building an App Bundle for the Play Store
flutter build appbundle --release

๐Ÿ“ Project Structure

lucy-screen-agent/
โ”œโ”€โ”€ lib/
โ”‚   โ”œโ”€โ”€ main.dart                          # App entry point, theme, LucyApp widget
โ”‚   โ”œโ”€โ”€ screens/
โ”‚   โ”‚   โ””โ”€โ”€ home_screen.dart               # Conversation UI, mic button, API-key dialog,
โ”‚   โ”‚                                      # accessibility gate, language selector
โ”‚   โ””โ”€โ”€ services/
โ”‚       โ”œโ”€โ”€ agent_controller.dart          # โญ The brain: agent loop, state machine,
โ”‚       โ”‚                                  #    action execution, language handling
โ”‚       โ”œโ”€โ”€ ai_service.dart                # Gemini client, system prompt, JSON parsing
โ”‚       โ”œโ”€โ”€ voice_service.dart             # speech_to_text + flutter_tts wrapper
โ”‚       โ””โ”€โ”€ screen_capture_service.dart    # Dart side of the platform channel
โ”‚
โ”œโ”€โ”€ android/app/src/main/kotlin/com/poc/screen_aware_ai/
โ”‚   โ”œโ”€โ”€ MainActivity.kt                    # Method-channel host, MediaProjection consent
โ”‚   โ”œโ”€โ”€ ScreenCaptureService.kt            # Foreground service: VirtualDisplay โ†’ JPEG
โ”‚   โ”œโ”€โ”€ ScreenActionService.kt             # AccessibilityService: UI tree + gestures
โ”‚   โ””โ”€โ”€ OverlayService.kt                  # Persistent "Stop Lucy" notification
โ”‚
โ”œโ”€โ”€ test/                                  # Widget tests
โ”œโ”€โ”€ docs/
โ”‚   โ”œโ”€โ”€ ARCHITECTURE.md                    # Deep dive for contributors
โ”‚   โ””โ”€โ”€ RELEASING.md                       # How versions become downloadable APKs
โ””โ”€โ”€ .github/workflows/
    โ”œโ”€โ”€ ci.yml                             # Format, analyze, test, debug APK
    โ””โ”€โ”€ release.yml                        # Publishes a Release when the version bumps

Data flow in one line: home_screen.dart โ†’ agent_controller.dart โ†’ (ai_service.dart โ‡„ Gemini) โ†’ screen_capture_service.dart โ†’ MethodChannel โ†’ Kotlin services โ†’ Android.

๐Ÿ“š New contributors should read docs/ARCHITECTURE.md โ€” it explains the agent loop, the platform-channel contract, and how to add a new action.


๐Ÿ”ง Troubleshooting

"Accessibility Required" screen won't go away

Some manufacturers (Xiaomi, Oppo, Vivo, Samsung) bury accessibility toggles or silently revoke them.

  • Look under Settings โ†’ Accessibility โ†’ Installed apps / Downloaded apps โ†’ Lucy.
  • On MIUI/ColorOS you may also need to disable battery optimisation for Lucy and enable Autostart.
  • Fully close and reopen the app after enabling โ€” Lucy re-checks on resume, but a cold start is a reliable reset.
"Screen capture permission denied" or blank screenshots
  • Tap the mic button again and accept the "Start now" dialog.
  • On Android 14+, the MediaProjection token is single-use. If you switch away for a long time, Lucy re-requests permission automatically โ€” accept it again.
  • Some apps set FLAG_SECURE (banking apps, Netflix) and their screens come back black. This is enforced by Android and cannot be worked around.
Lucy doesn't hear me / listening times out
  • Grant the microphone permission (Android asks on first use).
  • Make sure a speech-recognition engine is installed โ€” usually the Google app โ†’ Settings โ†’ Voice.
  • Check that the language selected in the top bar matches the language you're speaking; the STT locale is set from it.
  • Lucy retries listening 3 times, then stops and asks you to tap the mic again.
"โš ๏ธ Please set your Gemini API key first"

Tap the ๐Ÿ”‘ icon and paste a valid key from AI Studio. If it still fails, your key may be rate-limited or restricted โ€” check the quota page in AI Studio.

Lucy taps the wrong thing

This usually means the accessibility tree is incomplete โ€” some apps (games, or apps with poor semantics) expose very little. Check the conversation view: if the action summary shows a tap on an element that doesn't match, the UI tree given to the model was misleading. Please open an issue with the app name and what you asked for.

Gradle build fails on first run
  • Confirm JDK 17: java -version.
  • Wipe and retry: flutter clean, then flutter pub get, then flutter run.
  • android/local.properties is generated by Flutter and gitignored โ€” if it's missing, running flutter run once recreates it.

๐Ÿ” Privacy & Security

Please read this before installing. Lucy is powerful precisely because she has deep access.

What leaves your device

  • ๐Ÿ“ธ Screenshots (downscaled to max 1280px, JPEG quality 72) are sent to the Google Gemini API on every step of an active task.
  • ๐ŸŒฒ The accessibility tree โ€” including any text visible on screen โ€” is sent with them.
  • ๐ŸŽค Voice is transcribed by Android's speech recognizer, subject to your device's own settings.

What does not

  • Lucy has no backend. There is no analytics, no crash reporting, no account, no server operated by this project.
  • Your API key is stored locally in shared_preferences and only ever sent to Google.

What this means in practice

[!CAUTION]
While a task is running, anything visible on your screen may be sent to Google โ€” including messages, emails, banking screens and notifications. The accessibility service can also read text fields and dispatch taps. Don't run Lucy while sensitive information is on screen, and review Google's Gemini API terms to understand how prompt data is handled on your tier.

Recommendations

  • โœ… Use a spare device, a test profile, or Android's Work Profile.
  • โœ… Stop Lucy (via the notification) before opening anything sensitive.
  • โœ… Revoke the accessibility service when you're not actively using the app.
  • โŒ Never commit your API key, keystore, or key.properties.

Found a security issue? Please read SECURITY.md โ€” don't open a public issue.


๐Ÿ—บ๏ธ Roadmap

Ideas that would make great contributions. Comment on an issue or open one to claim it:

  • ๐Ÿ”’ Confirmation gate for destructive actions (sending messages, purchases, deletions)
  • ๐Ÿงฉ Pluggable AI backends โ€” OpenAI, Anthropic, or a local model behind the AiService interface
  • ๐Ÿšซ App allowlist/blocklist so Lucy can never touch chosen apps
  • ๐Ÿ’พ Persistent conversation history across restarts
  • ๐ŸŒ More languages (see CONTRIBUTING.md โ€” it's a ~20-line change)
  • ๐Ÿงช Test coverage for the AgentController state machine
  • ๐Ÿ“Š Token/cost counter in the UI
  • โ™ฟ Better UI-tree extraction for apps with weak accessibility semantics

๐Ÿค Contributing

Contributions are very welcome โ€” this project is early and there's a lot of low-hanging fruit.

๐Ÿ‘‰ Start with CONTRIBUTING.md. It covers the dev setup, code style, the PR process, and walkthroughs for adding a new agent action or language.

Good first issues are labelled good first issue.

By participating you agree to the Code of Conduct.


โ˜• Support the Project

Lucy is free, open source, and developed in spare time. If she saves you some of yours, you can chip in:

Support on Ko-fi
Donate with PayPal
Tip by card with Stripe

Support is entirely optional and buys no priority on issues or pull requests โ€” it just keeps the API bills paid and the roadmap moving. Starring the repo and filing good bug reports helps just as much.


๐Ÿ“„ License

Released under the MIT License.


Built with Flutter and Google Gemini.

If Lucy is useful to you, consider leaving a โญ โ€” it genuinely helps others find the project.

Report a bug ยท Request a feature

Reviews (0)

No results found