How ghost-in-the-droid/android-agent works
Ghost in the Droid is a cross-platform mobile automation framework: an agent or dashboard sends commands, the backend interprets device state and executes actions on Android or iOS, and skills and scheduled jobs package those actions into reusable workflows. The map also includes documented streaming, skill creation and discovery, emulator, and on-device inference capabilities. Source excerpts establish core device, API, and scheduling links; broader feature links are cited to the README, so unsampled internals are not expanded.
Main entry points: device.py Platform Device Factory · phone.py Phone Routes · app.py FastAPI App · job_engine.py Job Engine
Components 28
Agent Interfaces
- Web Dashboard
frontend/src/App.vue - MCP Server
gitd/mcp_server.py - Framework Adapters
integrations/_core.py - Ghost CLI
gitd/ghostcli/run.py
API and Orchestration
- FastAPI App
gitd/app.py - Phone Routes
gitd/routers/phone.py - Agent Chat Routes
gitd/routers/agent_chat.py - Agent Chat
gitd/services/agent_chat.py - Agent Tools
gitd/services/agent_tools.py - Device Context
gitd/services/device_context.py - SQLite Persistence
gitd/models/base.py - Database Helpers
gitd/services/db_helpers.py
Device Runtime
- Platform Device Factory
gitd/bots/common/device.py - Android ADB
gitd/bots/common/adb.py - iOS WDA
gitd/bots/common/ios.py - Screen Streaming
gitd/routers/streaming.py - Emulator Pool
gitd/services/emulator_service.py
Skills and Jobs
- Skill Runtime
gitd/skills/base.py - Skill Platforms
gitd/skills/platforms.py - Skill Hub
gitd/routers/skills.py - Skill Creator
gitd/services/skill_creation.py - App Explorer
gitd/skills/auto_creator.py - Job Engine
gitd/services/job_engine.py - Scheduler
gitd/services/scheduler_service.py
Phone Applications
- Android Portal
portal/app/src/main/java/com/ghostinthedroid/portal/GhostWebRtcManager.kt - iOS On-Device Agent
ios/GhostLLM/Agent/AgentLoop.swift - On-Device Inference
ios/GhostLLM/Engine/InferenceEngine.swift
Other components
- Agent or User
Connections 33
- Agent or User → MCP Server: issues tool requests
README.md - Agent or User → Web Dashboard: starts device chat
README.md - Agent or User → Ghost CLI: runs task
README.md - Agent or User → Framework Adapters: uses agent tools
README.md - Web Dashboard → FastAPI App: calls REST API
README.md - Ghost CLI → Agent Chat: invokes agent
gitd/ghostcli/run.py - Framework Adapters → Agent Tools: exposes tools
integrations/_core.py - FastAPI App → Phone Routes: registers routes
gitd/app.py - FastAPI App → Agent Chat Routes: registers routes
gitd/app.py - MCP Server → Agent Tools: provides tool surface
- Agent Chat Routes → Agent Chat: dispatches chat
gitd/routers/agent_chat.py - Agent Chat → Agent Tools: uses tools
- Phone Routes → Platform Device Factory: resolves devices
gitd/routers/phone.py - Phone Routes → Device Context: requests screen context
gitd/routers/phone.py - Device Context → Platform Device Factory: gets device
gitd/services/device_context.py - Platform Device Factory → Android ADB: dispatches Android
gitd/bots/common/device.py - Platform Device Factory → iOS WDA: dispatches iOS
gitd/bots/common/device.py - Phone Routes → SQLite Persistence: reads device records
gitd/routers/phone.py - Phone Routes → Database Helpers: uses DB helpers
gitd/routers/phone.py - Screen Streaming → Platform Device Factory: gets device stream
gitd/routers/streaming.py - Screen Streaming → Android Portal: connects Android stream
- Agent Tools → Device Context: reads device state
gitd/services/device_context.py - Skill Runtime → Skill Platforms: selects platform
gitd/skills/base.py - Skill Platforms → Platform Device Factory: uses device
gitd/skills/platforms.py - Skill Hub → Skill Runtime: installs and runs skills
README.md - Skill Creator → Device Context: inspects screen
- App Explorer → Platform Device Factory: explores device
- Scheduler → Job Engine: enqueues scheduled jobs
gitd/services/scheduler_service.py - Job Engine → Skill Platforms: runs skill jobs
gitd/services/job_engine.py - Job Engine → Platform Device Factory: targets device
gitd/services/job_engine.py - Job Engine → Database Helpers: uses DB helpers
- FastAPI App → Emulator Pool: registers emulator routes
- iOS On-Device Agent → On-Device Inference: generates responses