# zai-org/open-autoglm architecture

> Architecture diagram of the GitHub repository zai-org/open-autoglm, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/zai-org/open-autoglm
- Repository: https://github.com/zai-org/open-autoglm

## Overview

Open-AutoGLM is a multimodal phone-agent framework: a user gives a natural-language task, the agent pairs a screen image with task context, requests a model response, parses an action, and executes it on a selected phone backend until completion. The documented product supports Android/ADB, HarmonyOS/HDC, and iOS/WebDriverAgent, plus sensitive-action confirmation and human takeover. The graph reflects those documented capabilities; unsampled implementation details are represented only where paths are supported, and unsupported internal call links are omitted.

Main entry points: [`phone_agent/agent_ios.py`](https://github.com/zai-org/open-autoglm/blob/main/phone_agent/agent_ios.py) (iOS agent loop), [`phone_agent/agent.py`](https://github.com/zai-org/open-autoglm/blob/main/phone_agent/agent.py) (Android agent loop), [`phone_agent/adb/device.py`](https://github.com/zai-org/open-autoglm/blob/main/phone_agent/adb/device.py) (ADB device operations), [`phone_agent/hdc/device.py`](https://github.com/zai-org/open-autoglm/blob/main/phone_agent/hdc/device.py) (HDC device operations)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Agent workflow"]
  node_cli["CLI entry<br/>[main.py]"]
  node_agent["Android agent loop<br/>[agent.py]"]
  node_iosagent["iOS agent loop<br/>[agent_ios.py]"]
  node_action["Android action handler<br/>[handler.py]"]
  node_iosaction["iOS action handler<br/>[handler_ios.py]"]
end

subgraph group_device["Device control"]
  node_factory["Android backend selector<br/>[device_factory.py]"]
  node_adb["ADB device operations<br/>[device.py]"]
  node_adbconn["ADB connection<br/>[connection.py]"]
  node_adbinput["ADB input<br/>[input.py]"]
  node_adbscreen["ADB screenshots<br/>[screenshot.py]"]
  node_hdc["HDC device operations<br/>[device.py]"]
  node_hdcconn["HDC connection<br/>[connection.py]"]
  node_hdcinput["HDC input<br/>[input.py]"]
  node_hdcscreen["HDC screenshots<br/>[screenshot.py]"]
end

subgraph group_modelconfig["Model and configuration"]
  node_model["Model API client<br/>[client.py]"]
  node_prompts["Agent prompts<br/>[prompts.py]"]
  node_languages["Prompt localization<br/>[i18n.py]"]
  node_timing["Operation timing<br/>[timing.py]"]
  node_apps["Android app mappings<br/>[apps.py]"]
  node_harmonyapps["HarmonyOS app mappings<br/>[apps_harmonyos.py]"]
end

subgraph group_ios["iOS control"]
  node_iosapps["iOS app mappings<br/>[apps_ios.py]"]
  node_wda["WebDriverAgent connection<br/>[connection.py]"]
  node_iosdevice["iOS device operations<br/>[device.py]"]
  node_iosinput["iOS input<br/>[input.py]"]
  node_iosscreen["iOS screenshots<br/>[screenshot.py]"]
end

node_user(("Task requester"))
node_androidphone(("Android or HarmonyOS phone"))
node_iosphone(("iPhone"))
node_modelservice(("OpenAI-compatible model service"))

node_user -->|"submits task"| node_cli
node_cli -->|"starts agent"| node_agent
node_cli -->|"starts iOS agent"| node_iosagent
node_agent -->|"requests inference"| node_model
node_agent -->|"executes action"| node_action
node_iosagent -->|"requests inference"| node_model
node_iosagent -->|"executes action"| node_iosaction
node_action -->|"dispatches controls"| node_factory
node_factory -->|"selects backend"| node_adb
node_factory -->|"selects backend"| node_hdc
node_adb -->|"controls"| node_androidphone
node_hdc -->|"controls"| node_androidphone
node_iosagent -->|"creates session"| node_wda
node_iosaction -->|"performs actions"| node_iosdevice
node_iosdevice -->|"controls"| node_iosphone
node_iosagent -.->|"captures screen"| node_iosscreen
node_agent -.->|"captures screen"| node_adbscreen
node_model -->|"sends requests"| node_modelservice
node_model -->|"uses translations"| node_languages
node_adbconn -->|"uses delays"| node_timing
node_hdcconn -->|"uses delays"| node_timing
node_adb -->|"resolves app names"| node_apps
node_hdc -->|"resolves app names"| node_harmonyapps
node_iosdevice -->|"resolves bundle IDs"| node_iosapps
node_iosaction -->|"types text"| node_iosinput
node_adb -->|"uses connection"| node_adbconn
node_hdc -->|"uses connection"| node_hdcconn

click node_cli "https://github.com/zai-org/open-autoglm/blob/main/main.py"
click node_agent "https://github.com/zai-org/open-autoglm/blob/main/phone_agent/agent.py"
click node_iosagent "https://github.com/zai-org/open-autoglm/blob/main/phone_agent/agent_ios.py"
click node_action "https://github.com/zai-org/open-autoglm/blob/main/phone_agent/actions/handler.py"
click node_iosaction "https://github.com/zai-org/open-autoglm/blob/main/phone_agent/actions/handler_ios.py"
click node_model "https://github.com/zai-org/open-autoglm/blob/main/phone_agent/model/client.py"
click node_prompts "https://github.com/zai-org/open-autoglm/blob/main/phone_agent/config/prompts.py"
click node_languages "https://github.com/zai-org/open-autoglm/blob/main/phone_agent/config/i18n.py"
click node_timing "https://github.com/zai-org/open-autoglm/blob/main/phone_agent/config/timing.py"
click node_apps "https://github.com/zai-org/open-autoglm/blob/main/phone_agent/config/apps.py"
click node_harmonyapps "https://github.com/zai-org/open-autoglm/blob/main/phone_agent/config/apps_harmonyos.py"
click node_iosapps "https://github.com/zai-org/open-autoglm/blob/main/phone_agent/config/apps_ios.py"
click node_factory "https://github.com/zai-org/open-autoglm/blob/main/phone_agent/device_factory.py"
click node_adb "https://github.com/zai-org/open-autoglm/blob/main/phone_agent/adb/device.py"
click node_adbconn "https://github.com/zai-org/open-autoglm/blob/main/phone_agent/adb/connection.py"
click node_adbinput "https://github.com/zai-org/open-autoglm/blob/main/phone_agent/adb/input.py"
click node_adbscreen "https://github.com/zai-org/open-autoglm/blob/main/phone_agent/adb/screenshot.py"
click node_hdc "https://github.com/zai-org/open-autoglm/blob/main/phone_agent/hdc/device.py"
click node_hdcconn "https://github.com/zai-org/open-autoglm/blob/main/phone_agent/hdc/connection.py"
click node_hdcinput "https://github.com/zai-org/open-autoglm/blob/main/phone_agent/hdc/input.py"
click node_hdcscreen "https://github.com/zai-org/open-autoglm/blob/main/phone_agent/hdc/screenshot.py"
click node_wda "https://github.com/zai-org/open-autoglm/blob/main/phone_agent/xctest/connection.py"
click node_iosdevice "https://github.com/zai-org/open-autoglm/blob/main/phone_agent/xctest/device.py"
click node_iosinput "https://github.com/zai-org/open-autoglm/blob/main/phone_agent/xctest/input.py"
click node_iosscreen "https://github.com/zai-org/open-autoglm/blob/main/phone_agent/xctest/screenshot.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli,node_agent,node_iosagent,node_action,node_iosaction toneBlue
class node_factory,node_adb,node_adbconn,node_adbinput,node_adbscreen,node_hdc,node_hdcconn,node_hdcinput,node_hdcscreen toneAmber
class node_model,node_prompts,node_languages,node_timing,node_apps,node_harmonyapps toneMint
class node_iosapps,node_wda,node_iosdevice,node_iosinput,node_iosscreen,node_user toneRose
class node_androidphone,node_iosphone,node_modelservice toneIndigo
```

## Components

### Agent workflow

- [CLI entry](https://github.com/zai-org/open-autoglm/blob/main/main.py): `main.py`
- [Android agent loop](https://github.com/zai-org/open-autoglm/blob/main/phone_agent/agent.py): `phone_agent/agent.py`
- [iOS agent loop](https://github.com/zai-org/open-autoglm/blob/main/phone_agent/agent_ios.py): `phone_agent/agent_ios.py`
- [Android action handler](https://github.com/zai-org/open-autoglm/blob/main/phone_agent/actions/handler.py): `phone_agent/actions/handler.py`
- [iOS action handler](https://github.com/zai-org/open-autoglm/blob/main/phone_agent/actions/handler_ios.py): `phone_agent/actions/handler_ios.py`

### Device control

- [Android backend selector](https://github.com/zai-org/open-autoglm/blob/main/phone_agent/device_factory.py): `phone_agent/device_factory.py`
- [ADB device operations](https://github.com/zai-org/open-autoglm/blob/main/phone_agent/adb/device.py): `phone_agent/adb/device.py`
- [ADB connection](https://github.com/zai-org/open-autoglm/blob/main/phone_agent/adb/connection.py): `phone_agent/adb/connection.py`
- [ADB input](https://github.com/zai-org/open-autoglm/blob/main/phone_agent/adb/input.py): `phone_agent/adb/input.py`
- [ADB screenshots](https://github.com/zai-org/open-autoglm/blob/main/phone_agent/adb/screenshot.py): `phone_agent/adb/screenshot.py`
- [HDC device operations](https://github.com/zai-org/open-autoglm/blob/main/phone_agent/hdc/device.py): `phone_agent/hdc/device.py`
- [HDC connection](https://github.com/zai-org/open-autoglm/blob/main/phone_agent/hdc/connection.py): `phone_agent/hdc/connection.py`
- [HDC input](https://github.com/zai-org/open-autoglm/blob/main/phone_agent/hdc/input.py): `phone_agent/hdc/input.py`
- [HDC screenshots](https://github.com/zai-org/open-autoglm/blob/main/phone_agent/hdc/screenshot.py): `phone_agent/hdc/screenshot.py`

### Model and configuration

- [Model API client](https://github.com/zai-org/open-autoglm/blob/main/phone_agent/model/client.py): `phone_agent/model/client.py`
- [Agent prompts](https://github.com/zai-org/open-autoglm/blob/main/phone_agent/config/prompts.py): `phone_agent/config/prompts.py`
- [Prompt localization](https://github.com/zai-org/open-autoglm/blob/main/phone_agent/config/i18n.py): `phone_agent/config/i18n.py`
- [Operation timing](https://github.com/zai-org/open-autoglm/blob/main/phone_agent/config/timing.py): `phone_agent/config/timing.py`
- [Android app mappings](https://github.com/zai-org/open-autoglm/blob/main/phone_agent/config/apps.py): `phone_agent/config/apps.py`
- [HarmonyOS app mappings](https://github.com/zai-org/open-autoglm/blob/main/phone_agent/config/apps_harmonyos.py): `phone_agent/config/apps_harmonyos.py`

### iOS control

- [iOS app mappings](https://github.com/zai-org/open-autoglm/blob/main/phone_agent/config/apps_ios.py): `phone_agent/config/apps_ios.py`
- [WebDriverAgent connection](https://github.com/zai-org/open-autoglm/blob/main/phone_agent/xctest/connection.py): `phone_agent/xctest/connection.py`
- [iOS device operations](https://github.com/zai-org/open-autoglm/blob/main/phone_agent/xctest/device.py): `phone_agent/xctest/device.py`
- [iOS input](https://github.com/zai-org/open-autoglm/blob/main/phone_agent/xctest/input.py): `phone_agent/xctest/input.py`
- [iOS screenshots](https://github.com/zai-org/open-autoglm/blob/main/phone_agent/xctest/screenshot.py): `phone_agent/xctest/screenshot.py`

### Other components

- **Task requester**
- **Android or HarmonyOS phone**
- **iPhone**
- **OpenAI-compatible model service**

## Connections

- Task requester → CLI entry: submits task (evidence: `README.md`)
- CLI entry → Android agent loop: starts agent (evidence: `main.py`)
- CLI entry → iOS agent loop: starts iOS agent (evidence: `main.py`)
- Android agent loop → Model API client: requests inference (evidence: `phone_agent/agent.py`)
- Android agent loop → Android action handler: executes action (evidence: `phone_agent/agent.py`)
- iOS agent loop → Model API client: requests inference (evidence: `phone_agent/agent_ios.py`)
- iOS agent loop → iOS action handler: executes action (evidence: `phone_agent/agent_ios.py`)
- Android action handler → Android backend selector: dispatches controls (evidence: `phone_agent/actions/handler.py`)
- Android backend selector → ADB device operations: selects backend (evidence: `phone_agent/device_factory.py`)
- Android backend selector → HDC device operations: selects backend (evidence: `phone_agent/device_factory.py`)
- ADB device operations → Android or HarmonyOS phone: controls (evidence: `README.md`)
- HDC device operations → Android or HarmonyOS phone: controls (evidence: `README.md`)
- iOS agent loop → WebDriverAgent connection: creates session (evidence: `phone_agent/agent_ios.py`)
- iOS action handler → iOS device operations: performs actions (evidence: `phone_agent/actions/handler_ios.py`)
- iOS device operations → iPhone: controls (evidence: `README.md`)
- iOS agent loop → iOS screenshots: captures screen
- Android agent loop → ADB screenshots: captures screen
- Model API client → OpenAI-compatible model service: sends requests (evidence: `phone_agent/model/client.py`)
- Model API client → Prompt localization: uses translations (evidence: `phone_agent/model/client.py`)
- ADB connection → Operation timing: uses delays (evidence: `phone_agent/adb/connection.py`)
- HDC connection → Operation timing: uses delays (evidence: `phone_agent/hdc/connection.py`)
- ADB device operations → Android app mappings: resolves app names (evidence: `phone_agent/adb/device.py`)
- HDC device operations → HarmonyOS app mappings: resolves app names (evidence: `phone_agent/hdc/device.py`)
- iOS device operations → iOS app mappings: resolves bundle IDs (evidence: `phone_agent/xctest/device.py`)
- iOS action handler → iOS input: types text (evidence: `phone_agent/actions/handler_ios.py`)
- ADB device operations → ADB connection: uses connection (evidence: `phone_agent/adb/device.py`)
- HDC device operations → HDC connection: uses connection (evidence: `phone_agent/hdc/device.py`)
