# josssphzhou/poki architecture

> Architecture diagram of the GitHub repository josssphzhou/poki, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/josssphzhou/poki
- Repository: https://github.com/josssphzhou/poki

## Overview

Poki is an iPhone automation agent: a person gives it a task, it uses a configured model to interpret the task, observes and operates real iPhone apps, and pauses for approval on sensitive actions. The repository also includes a desktop setup product for installing and maintaining Poki, plus native device-control components. The workflow and major capabilities are documented in the README; many implementation paths below are identified by the source index but were not excerpted, so those relationships are omitted unless documented.

Main entry points: [`agent/task-runner.mjs`](https://github.com/josssphzhou/poki/blob/main/agent/task-runner.mjs) (Task orchestration), [`native/ios-app/Poki/Chat/ChatModel.swift`](https://github.com/josssphzhou/poki/blob/main/native/ios-app/Poki/Chat/ChatModel.swift) (Chat and task UI), [`native/ios/PokiCore/Sources/PokiCore/Computer.swift`](https://github.com/josssphzhou/poki/blob/main/native/ios/PokiCore/Sources/PokiCore/Computer.swift) (Screen and actions), [`native/bridge/src/main.rs`](https://github.com/josssphzhou/poki/blob/main/native/bridge/src/main.rs) (Native device bridge)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_phone["iPhone experience"]
  node_chat["Chat and task UI<br/>[ChatModel.swift]"]
  node_model["Model providers<br/>[ModelCatalog.swift]"]
  node_approvals["Action approvals"]
  node_sessions[("Task sessions<br/>[SessionStore.swift]")]
end

subgraph group_agent["Task execution"]
  node_agenttask["Task orchestration<br/>[task-runner.mjs]"]
  node_fasttask["Fast task planning<br/>[task.mjs]"]
  node_readout["Screen readout<br/>[readout.mjs]"]
  node_routes[("Learned routes<br/>[routes.mjs]")]
end

subgraph group_device["Device control"]
  node_core["iOS automation core<br/>[Runner.swift]"]
  node_computer["Screen and actions<br/>[Computer.swift]"]
  node_bridge["Native device bridge<br/>[main.rs]"]
  node_ax["Accessibility tree<br/>[ax.rs]"]
  node_clipboard["Pasteboard access<br/>[pasteboard.rs]"]
end

subgraph group_setup["Desktop setup"]
  node_setupui["Setup application<br/>[App.tsx]"]
  node_setupapi["Setup commands API<br/>[api.ts]"]
  node_setupcore["Install and device setup<br/>[setup.rs]"]
  node_signing["Signing and renewal<br/>[mod.rs]"]
  node_relay["Relay service<br/>[relay.rs]"]
end

node_person(("Phone user"))
node_iphone["iPhone apps"]
node_modelservice["External model service"]

node_person -->|"submits task"| node_chat
node_chat -->|"uses account"| node_model
node_chat -.->|"records task"| node_sessions
node_model -->|"requests reasoning"| node_modelservice
node_chat -.->|"starts automation"| node_agenttask
node_agenttask -.->|"plans steps"| node_fasttask
node_agenttask -.->|"observes screen"| node_readout
node_agenttask -.->|"executes task"| node_core
node_agenttask -->|"stores route"| node_routes
node_routes -->|"checks conditions"| node_fasttask
node_core -.->|"drives device"| node_computer
node_computer -->|"reads and operates"| node_iphone
node_computer -.->|"uses native control"| node_bridge
node_bridge -->|"dispatches tree reads"| node_ax
node_bridge -.->|"dispatches pasteboard"| node_clipboard
node_approvals -->|"requests confirmation"| node_person
node_setupui -->|"invokes commands"| node_setupapi
node_setupapi -.->|"calls setup"| node_setupcore
node_setupcore -.->|"manages signing"| node_signing
node_setupui -.->|"configures relay"| node_relay
node_setupcore -->|"installs app"| node_iphone

click node_chat "https://github.com/josssphzhou/poki/blob/main/native/ios-app/Poki/Chat/ChatModel.swift"
click node_model "https://github.com/josssphzhou/poki/blob/main/native/ios-app/Poki/Chat/ModelCatalog.swift"
click node_sessions "https://github.com/josssphzhou/poki/blob/main/native/ios-app/Poki/Sessions/SessionStore.swift"
click node_agenttask "https://github.com/josssphzhou/poki/blob/main/agent/task-runner.mjs"
click node_fasttask "https://github.com/josssphzhou/poki/blob/main/agent/fast/task.mjs"
click node_readout "https://github.com/josssphzhou/poki/blob/main/agent/readout.mjs"
click node_routes "https://github.com/josssphzhou/poki/blob/main/agent/routes.mjs"
click node_core "https://github.com/josssphzhou/poki/blob/main/native/ios/PokiCore/Sources/PokiCore/Runner.swift"
click node_computer "https://github.com/josssphzhou/poki/blob/main/native/ios/PokiCore/Sources/PokiCore/Computer.swift"
click node_bridge "https://github.com/josssphzhou/poki/blob/main/native/bridge/src/main.rs"
click node_ax "https://github.com/josssphzhou/poki/blob/main/native/bridge/src/ax.rs"
click node_clipboard "https://github.com/josssphzhou/poki/blob/main/native/bridge/src/pasteboard.rs"
click node_setupui "https://github.com/josssphzhou/poki/blob/main/desktop/app/src/App.tsx"
click node_setupapi "https://github.com/josssphzhou/poki/blob/main/desktop/app/src/api.ts"
click node_setupcore "https://github.com/josssphzhou/poki/blob/main/desktop/core/src/setup.rs"
click node_signing "https://github.com/josssphzhou/poki/blob/main/desktop/core/src/sign/mod.rs"
click node_relay "https://github.com/josssphzhou/poki/blob/main/desktop/core/src/relay.rs"

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_chat,node_model,node_approvals,node_sessions,node_person toneBlue
class node_agenttask,node_fasttask,node_readout,node_routes toneAmber
class node_core,node_computer,node_bridge,node_ax,node_clipboard toneMint
class node_setupui,node_setupapi,node_setupcore,node_signing,node_relay toneRose
class node_iphone,node_modelservice toneIndigo
```

## Components

### iPhone experience

- [Chat and task UI](https://github.com/josssphzhou/poki/blob/main/native/ios-app/Poki/Chat/ChatModel.swift): `native/ios-app/Poki/Chat/ChatModel.swift`
- [Model providers](https://github.com/josssphzhou/poki/blob/main/native/ios-app/Poki/Chat/ModelCatalog.swift): `native/ios-app/Poki/Chat/ModelCatalog.swift`
- **Action approvals**
- [Task sessions](https://github.com/josssphzhou/poki/blob/main/native/ios-app/Poki/Sessions/SessionStore.swift): `native/ios-app/Poki/Sessions/SessionStore.swift`

### Task execution

- [Task orchestration](https://github.com/josssphzhou/poki/blob/main/agent/task-runner.mjs): `agent/task-runner.mjs`
- [Fast task planning](https://github.com/josssphzhou/poki/blob/main/agent/fast/task.mjs): `agent/fast/task.mjs`
- [Screen readout](https://github.com/josssphzhou/poki/blob/main/agent/readout.mjs): `agent/readout.mjs`
- [Learned routes](https://github.com/josssphzhou/poki/blob/main/agent/routes.mjs): `agent/routes.mjs`

### Device control

- [iOS automation core](https://github.com/josssphzhou/poki/blob/main/native/ios/PokiCore/Sources/PokiCore/Runner.swift): `native/ios/PokiCore/Sources/PokiCore/Runner.swift`
- [Screen and actions](https://github.com/josssphzhou/poki/blob/main/native/ios/PokiCore/Sources/PokiCore/Computer.swift): `native/ios/PokiCore/Sources/PokiCore/Computer.swift`
- [Native device bridge](https://github.com/josssphzhou/poki/blob/main/native/bridge/src/main.rs): `native/bridge/src/main.rs`
- [Accessibility tree](https://github.com/josssphzhou/poki/blob/main/native/bridge/src/ax.rs): `native/bridge/src/ax.rs`
- [Pasteboard access](https://github.com/josssphzhou/poki/blob/main/native/bridge/src/pasteboard.rs): `native/bridge/src/pasteboard.rs`

### Desktop setup

- [Setup application](https://github.com/josssphzhou/poki/blob/main/desktop/app/src/App.tsx): `desktop/app/src/App.tsx`
- [Setup commands API](https://github.com/josssphzhou/poki/blob/main/desktop/app/src/api.ts): `desktop/app/src/api.ts`
- [Install and device setup](https://github.com/josssphzhou/poki/blob/main/desktop/core/src/setup.rs): `desktop/core/src/setup.rs`
- [Signing and renewal](https://github.com/josssphzhou/poki/blob/main/desktop/core/src/sign/mod.rs): `desktop/core/src/sign/mod.rs`
- [Relay service](https://github.com/josssphzhou/poki/blob/main/desktop/core/src/relay.rs): `desktop/core/src/relay.rs`

### Other components

- **Phone user**
- **iPhone apps**
- **External model service**

## Connections

- Phone user → Chat and task UI: submits task (evidence: `README.md`)
- Chat and task UI → Model providers: uses account (evidence: `README.md`)
- Chat and task UI → Task sessions: records task
- Model providers → External model service: requests reasoning (evidence: `README.md`)
- Chat and task UI → Task orchestration: starts automation
- Task orchestration → Fast task planning: plans steps
- Task orchestration → Screen readout: observes screen
- Task orchestration → iOS automation core: executes task
- Task orchestration → Learned routes: stores route (evidence: `agent/routes.mjs`)
- Learned routes → Fast task planning: checks conditions (evidence: `agent/routes.mjs`)
- iOS automation core → Screen and actions: drives device
- Screen and actions → iPhone apps: reads and operates (evidence: `README.md`)
- Screen and actions → Native device bridge: uses native control
- Native device bridge → Accessibility tree: dispatches tree reads (evidence: `native/bridge/src/main.rs`)
- Native device bridge → Pasteboard access: dispatches pasteboard (evidence: `native/bridge/src/main.rs`)
- Action approvals → Phone user: requests confirmation (evidence: `README.md`)
- Setup application → Setup commands API: invokes commands (evidence: `desktop/app/src/App.tsx`)
- Setup commands API → Install and device setup: calls setup
- Install and device setup → Signing and renewal: manages signing
- Setup application → Relay service: configures relay
- Install and device setup → iPhone apps: installs app (evidence: `README.md`)
