Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
2e9828f
Merge pull request 'App 1.0.9: iOS 16 support, M5Stack StopWatch, fas…
Nov 21, 2026
24d570a
Merge StopWatch voice fix into main
onehumanbeing Nov 21, 2026
612f494
Firmware 0.2.8: StopWatch voice coded in sample order
onehumanbeing Nov 22, 2026
801db19
README: iOS 16.4+ with the TestFlight app (iPhone 8 / X), M5Stack Sto…
onehumanbeing Nov 22, 2026
f985d63
Merge GitHub main (PR #180 --no-audio)
onehumanbeing Nov 22, 2026
1d7551c
Merge GitHub main (PR #182, App 1.0.10)
onehumanbeing Nov 22, 2026
35ab0bd
Merge GitHub main (PR #183, Hermes Agent plugin)
onehumanbeing Nov 23, 2026
aeef46e
Merge GitHub main (PR #184 App 1.0.10.1, #185 changelog)
onehumanbeing Nov 23, 2026
3f229ee
Merge remote-tracking branch 'origin/main' into sync/gh-189
onehumanbeing Nov 24, 2026
218813f
Merge GitHub main (PR #190, App 1.0.11)
onehumanbeing Nov 25, 2026
8e90e30
Harness: runs no longer hang on iOS's open-app prompt; run.sh ends on…
onehumanbeing Nov 26, 2026
4b2d249
Harness: tapcv.py taps without mirroring and restarts Screen Mirrorin…
onehumanbeing Nov 26, 2026
88d61ed
Typing: pinyin for a text is worked out once, and the tokenizer warms…
onehumanbeing Nov 26, 2026
f8cb7c6
Open: an English iPhone searches a known app by its name there (Maps,…
onehumanbeing Nov 26, 2026
62baf83
Pointer search: both frames decoded and grayed once for the near and …
onehumanbeing Nov 26, 2026
ac415eb
harness/run.sh: no picture before a task restarts Screen Mirroring it…
onehumanbeing Nov 26, 2026
18b792b
Long press: tap X Y hold
onehumanbeing Nov 26, 2026
48d5830
Press and drag (swipe … hold) and switch to the previous app
onehumanbeing Nov 26, 2026
296096b
Harness: app files over pymobiledevice3 AFC, devicectl as fallback
onehumanbeing Nov 26, 2026
5a4fab3
Harness: collect.py walks an app's screens; tapcv aims with the app's…
onehumanbeing Nov 26, 2026
08511d6
Harness: one push per command, a woken pointer before each click, che…
onehumanbeing Nov 26, 2026
430449b
Harness: AFC pulls retry instead of waiting on devicectl; backs wait …
onehumanbeing Nov 26, 2026
5570096
App 1.0.11.1: long press, faster opening and typing, the harness
onehumanbeing Nov 26, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ Full changelog with board firmware and every channel: [manina.ai/docs/changelog]

## Unreleased (main)

## App 1.0.11.1 (TestFlight, a new build of 1.0.11)

**Built and tested with an automated harness: the changes below were found, fixed and checked on a real iPhone by the harness itself.**

- Long press: the agent can press and hold (`tap X Y hold`), for a chat message's menu (Forward, Copy), an icon's quick actions or selecting a word.
- Opening apps no longer hangs on iOS's "Open in …?" prompt, and an English iPhone searches a known app by its English name (Maps, rednote) instead of pinyin.
- Faster Chinese typing: the pinyin for a text is worked out once, with no stall on the first character.
- Faster pointer search: each screen is decoded once.
- Harness (`harness/`): files to and from the app over pymobiledevice3 (about 1.5 s instead of 40 s), `tapcv.py` taps and restarts Screen Mirroring with no one at the phone, `collect.py` walks an app's screens and records screen, text and action, `timing.py` shows where a run's time went.

## App 1.0.11 (TestFlight)

- App: Settings › Model › Sign in with ChatGPT: runs use your own ChatGPT Plus or Pro plan (the same usage limits Codex uses), with no API key.
Expand Down
22 changes: 22 additions & 0 deletions harness/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ harness/logs.sh the app's debug.log (+ --runs traces)
harness/hid.sh "…" raw board commands through the app (key, type, move…), plus shot / gop / video-reconnect / point
harness/watch.sh follow a run live: each step's action, thought, screen changed or not, pointer (run it in a Monitor)
harness/ctl.sh pause hold the run to look into a step (continue | stop)
harness/tapcv.py tap without mirroring: screenshot, find the pointer, correct, click, check (uv run)
NO_LAUNCH=1 harness/hid.sh shot during a run: without NO_LAUNCH the launch brings this app to the front mid-run
harness/board.py one-time only: put the board on the Mac's Wi-Fi (net sta | net ap)
```
Expand Down Expand Up @@ -63,6 +64,27 @@ to `Documents/developer/harness-fw-<time>/` (a new folder each run: `devicectl`
never pass `--remove-existing-content`, it wipes the whole app container), then hands the app
`-harness-ota <folder>` and follows its log until the result line (3 minutes at most).

## Tapping without mirroring (tapcv.py)

When mirroring is off or stuck (a new app process gets no keyframe until mirroring starts again), the agent can't see,
but the board still moves the pointer. `tapcv.py` closes the loop from the Mac: it puts the pointer in the top-left
corner, moves by calibrated units, finds the grey pointer disc on a screenshot (the change against the shot before
the move), corrects until it is within 14 px, clicks, and checks the screen changed (`--expect TEXT`: that the text
appeared). The scale is learned per screen size in `~/.cache/harness-tapcv.json`.

```bash
export HARNESS_SHOT=<command that writes a screenshot to the given path> # e.g. pymobiledevice3 developer dvt screenshot --userspace
export HARNESS_OCR=<command that prints [{"text","x","y","w","h"}] for an image>
uv run harness/tapcv.py tap-text Settings --expect General
uv run harness/tapcv.py mirror <board name> --restart # Control Center > Screen Mirroring > the board, until connected
```

`run.sh` does this by itself before a task when `HARNESS_BOARD` names the board and there is no picture.

Files go in and out of the app (the log, commands, screenshots) over `pymobiledevice3 apps afc` when it is installed (`HARNESS_PMD3`, else on PATH; the phone on USB): about 1.5 s a file, where devicectl can take 40 s or fail while a run and mirroring are going. Without it the scripts use devicectl.

`hid.sh "...; stay"` leaves the pointer where the moves put it (otherwise it goes back to the corner at the end).

## Security

- **`-harness-ota`** and the app commands relayed by the board exist only in **Debug builds**; store builds ignore
Expand Down
18 changes: 18 additions & 0 deletions harness/README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ harness/run.sh "<task>" 在 App 里开始一个任务,打印它怎么结束的
harness/logs.sh App 的 debug.log(加 --runs 带运行轨迹)
harness/hid.sh "…" 通过 App 发原始板子命令(key、type、move……),以及 shot / gop / video-reconnect
harness/board.py 只用一次:让板子连上 Mac 的 Wi-Fi(net sta | net ap)
harness/tapcv.py 没有镜像也能点:截图、找指针、修正、点击、检查(uv run)
```

所有操作都通过 `devicectl` 经 Wi-Fi 发到 iPhone。设置完成后 Mac 不再直接和板子通信:App 连着时,板子的 App 连接只属于 App,所以固件走 Mac → App → 板子,和「更新板子」的路径一样。板子以 station 方式(`net sta`)加入 Mac 的 Wi-Fi,而不是打开自己的热点,这样 iPhone 一直留在 Mac 的网络里,也能在这个网络里连到板子。
Expand Down Expand Up @@ -43,6 +44,23 @@ harness/hid.sh "gop; video-reconnect; shot" # 填满 GOP,再断开 Wi-Fi

`fw.sh` 把镜像和一个 `firmware.json`(大小、SHA-256、MD5,版本取自 `hardware/hid_bridge/version.h`)复制到 `Documents/developer/harness-fw-<time>/`(每次一个新目录:`devicectl` 不会替换它之前复制过的文件;千万不要传 `--remove-existing-content`,它会清空整个 App 容器),然后把 `-harness-ota <folder>` 交给 App,并跟踪它的日志直到出现结果行(最多 3 分钟)。

## 没有镜像时点击(tapcv.py)

镜像关了或卡住(新的 App 进程要等镜像重新开始才拿得到关键帧)时,Agent 看不到屏幕,但板子还能移动指针。`tapcv.py` 在 Mac 上做闭环:把指针推到左上角,按标定的单位移动,在截图里找到灰色的指针圆点(和移动前那张截图的差异),修正到 14 px 以内再点击,然后检查屏幕变了(`--expect TEXT`:这段文字出现了)。比例按屏幕尺寸学习,存在 `~/.cache/harness-tapcv.json`。

```bash
export HARNESS_SHOT=<把截图写到指定路径的命令> # 例如 pymobiledevice3 developer dvt screenshot --userspace
export HARNESS_OCR=<对一张图输出 [{"text","x","y","w","h"}] 的命令>
uv run harness/tapcv.py tap-text Settings --expect General
uv run harness/tapcv.py mirror <板子名> --restart # 控制中心 › 屏幕镜像 › 这块板子,直到连上
```

设置了 `HARNESS_BOARD`(板子名)时,`run.sh` 在任务开始前发现没有画面会自己做这一步。

装了 pymobiledevice3 时(`HARNESS_PMD3`,否则从 PATH 找;手机连 USB),进出 App 的文件(日志、命令、截图)走 `pymobiledevice3 apps afc`,每个文件约 1.5 秒;devicectl 在任务和镜像同时进行时可能要 40 秒甚至失败。没装就用 devicectl。

`hid.sh "...; stay"` 让指针留在移动到的位置(否则结束时回到角落)。

## 安全

- **`-harness-ota`** 和经板子转发的 App 命令只存在于 **Debug 构建**;商店版会忽略它们。只有 Debug 构建里,固件清单可以不签名,或者是板子已经在运行的版本;大小、SHA-256 和 MD5 仍然必须匹配。商店版和以前一样只安装签名的正式版本。
Expand Down
103 changes: 103 additions & 0 deletions harness/collect.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# /// script
# requires-python = ">=3.10"
# dependencies = ["numpy", "pillow"]
# ///
"""Walk an app's screens with the board and record each one: the screenshot, the text on it (OCR boxes) and the
step that led there (the screen before, the action, where it went). Screen -> action -> next screen, for training
and for the app guides. Taps are tapcv's closed loop (find the pointer, correct, click, check).

uv run harness/collect.py PLAN.json OUT_DIR

PLAN is a JSON list of steps, each with a "name" for the screen it leads to:
{"name": "contacts", "tap": [437, 2394]} tap at x y (screenshot pixels)
{"name": "new_friends", "tap": "新的朋友"} tap the words, found by OCR
{"name": "menu", "hold": [600, 1500]} long press
{"name": "moments", "back": true} the back arrow at the top left
{"name": "moments_loaded", "wait": 3} wait, then record the screen again
Words in NEVER are never tapped, whatever the plan says: collecting only looks.
Writes OUT_DIR/NNN-name.png, OUT_DIR/NNN-name.json (OCR) and OUT_DIR/steps.jsonl.
"""
import json, sys, time
from pathlib import Path

import numpy as np
from PIL import Image

sys.path.insert(0, str(Path(__file__).resolve().parent))
import tapcv # noqa: E402

NEVER = ("发送", "添加到通讯录", "发表", "转账", "红包", "删除", "视频通话", "语音通话", "支付", "付款", "确定",
"Send", "Delete", "Post", "Pay", "Add to Contacts")
BACK = (0.056, 0.081) # the back arrow, as shares of the screen
TOL = 40 # px: UI targets here are 120 px or more at 1170 wide


def blocked(text: str) -> bool:
return any(w in text for w in NEVER)


def main(plan_path: str, out: str) -> None:
plan = json.loads(Path(plan_path).read_text())
out_dir = Path(out)
out_dir.mkdir(parents=True, exist_ok=True)
log = (out_dir / "steps.jsonl").open("a")
img = tapcv.shot()
prev = "start"
for i, step in enumerate(plan, 1):
name, h, w = step["name"], img.shape[0], img.shape[1]
action: dict = {}
try:
if isinstance(step.get("tap"), str):
words = step["tap"]
hits = [b for b in tapcv.ocr(img) if words in b["text"]]
hit = min(hits, key=lambda b: len(b["text"])) if hits else None
if hit is None or blocked(hit["text"]): # the next steps assume this screen: stop
print(f"{i} {name}: '{words}' {'blocked' if hit else 'not on screen'}; stopped", flush=True)
log.write(json.dumps({"n": i, "to": name, "failed": f"'{words}' not tapped"}, ensure_ascii=False) + "\n")
return
x, y = hit["x"] + hit["w"] / 2, hit["y"] + hit["h"] / 2
action = {"action": "tap", "text": hit["text"], "box": [hit["x"], hit["y"], hit["w"], hit["h"]]}
tapcv.tap(x, y, tol=step.get("tol", TOL))
elif "tap" in step:
x, y = step["tap"]
action = {"action": "tap"}
tapcv.tap(x, y, tol=step.get("tol", TOL))
elif "hold" in step:
x, y = step["hold"]
action = {"action": "hold"}
tapcv.point(x, y, step.get("tol", TOL))
tapcv.hid("press")
time.sleep(1.0)
tapcv.hid("release")
elif step.get("back"): # a small arrow near the edge: a tight landing, and the screen must change
x, y = w * BACK[0], h * BACK[1]
action = {"action": "back"}
if not tapcv.tap(x, y, tol=step.get("tol", 10), wait=3): # a web page (搜一搜) closes slowly
raise SystemExit("back left the screen as it was")
elif "wait" in step:
x = y = None
action = {"action": "wait", "seconds": step["wait"]}
time.sleep(step["wait"])
except SystemExit as e: # tapcv gave up: later steps assume this screen, so stop here
print(f"{i} {name}: {e}; stopped (the next steps start from this screen)", flush=True)
log.write(json.dumps({"n": i, "to": name, "failed": str(e)}, ensure_ascii=False) + "\n")
return
if x is not None:
action["at"] = [round(x), round(y)]
action["at_1000"] = [round(x / w * 1000), round(y / h * 1000)]
time.sleep(step.get("settle", 1.2))
png = out_dir / f"{i:03d}-{name}.png"
img = tapcv.shot(str(png))
boxes = tapcv.ocr(img)
(out_dir / f"{i:03d}-{name}.json").write_text(json.dumps(boxes, ensure_ascii=False))
log.write(json.dumps({"n": i, "from": prev, "to": name, **action, "screen": png.name,
"size": [w, h], "t": time.time()}, ensure_ascii=False) + "\n")
log.flush()
print(f"{i} {prev} -> {name}: {action.get('action')} {action.get('text', '')} ({len(boxes)} text boxes)", flush=True)
prev = name


if __name__ == "__main__":
if len(sys.argv) != 3:
sys.exit(__doc__)
main(sys.argv[1], sys.argv[2])
2 changes: 1 addition & 1 deletion harness/hid.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ echo "$OUT"
mkdir -p /tmp/harness-shots
for shot in $(grep -oE 'saved harness-shots/[0-9]+\.jpg' <<<"$OUT" | cut -d' ' -f2); do
for _ in 1 2 3 4 5; do [[ -s /tmp/$shot ]] || ! live || sleep 0.5; done # live: the app sends it over the link
[[ -s /tmp/$shot ]] || dc device copy from "${ON[@]}" --source "Documents/developer/$shot" --destination "/tmp/$shot" >/dev/null
[[ -s /tmp/$shot ]] || app_copy from "Documents/developer/$shot" "/tmp/$shot"
[[ -s /tmp/$shot ]] && echo "/tmp/$shot"
done
32 changes: 29 additions & 3 deletions harness/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,36 @@ dc() {
LIVE=${HARNESS_LIVE:-/tmp/harness-live}
live() { [[ -e $LIVE/connected && -z ${NO_LIVE:-} ]]; }

# app_copy from|to <src> <dest>: a file out of or into the app's container (its paths relative to the container,
# Documents/…). Over pymobiledevice3's AFC shell when it is there ($HARNESS_PMD3, else on PATH; USB): ~1.5 s, where
# devicectl took 40 s or failed outright beside a run and mirroring (2026-11-26: run.sh saw a 95 s run end 7 min late).
# devicectl when it is not, or when AFC fails.
PMD3=${HARNESS_PMD3:-$(command -v pymobiledevice3 || true)}
app_copy() {
local dir=$1 src=$2 dst=$3
if [[ -n $PMD3 ]]; then
if [[ $dir == from ]]; then # a pull can fail while the app writes the file: try again rather than wait on devicectl
rm -f "$dst"; mkdir -p "$(dirname "$dst")"
local try
for try in 1 2 3; do
printf 'pull /%s %s\nexit\n' "$src" "$dst" | COLUMNS=4000 perl -e 'alarm shift; exec @ARGV' 30 "$PMD3" apps afc "$BUNDLE" >/dev/null 2>&1
[[ -e $dst ]] && return 0
sleep 0.3
done
else # the AFC shell exits 1 even after a good push: its "src --> dst" line is the answer (a second copy over
# devicectl ran every harness command twice, interleaved, 2026-11-26)
# (it also wraps its output at the terminal width: a long path split that line, 2026-11-26)
local said
said=$(printf 'push %s /%s\nexit\n' "$src" "$dst" | COLUMNS=4000 perl -e 'alarm shift; exec @ARGV' 30 "$PMD3" apps afc "$BUNDLE" 2>&1)
[[ $said == *"--> /$dst"* ]] && return 0
fi
fi
dc device copy "$dir" "${ON[@]}" --source "$src" --destination "$dst" >/dev/null 2>&1
}

# copy_log <name> <dest>: Documents/logs/<name> (Documents/<name> for an app from before 2026-11-16).
copy_log() {
dc device copy from "${ON[@]}" --source "Documents/logs/$1" --destination "$2" >/dev/null 2>&1 \
|| dc device copy from "${ON[@]}" --source "Documents/$1" --destination "$2" >/dev/null 2>&1
app_copy from "Documents/logs/$1" "$2" || app_copy from "Documents/$1" "$2"
}

# pull_log <dest>: the app's recent log lines (live, else debug.recent.log, else debug.log for an older app).
Expand Down Expand Up @@ -76,7 +102,7 @@ launch() {
python3 -c 'import json, sys; print(json.dumps(sys.argv[1:]))' "$@" ${extra[@]+"${extra[@]}"} >"$f"
from=$(date -u -v-2S +%Y-%m-%dT%H:%M:%S) # follow from here; the phone's clock may run a little behind
if live; then mv "$f" "$LIVE/outbox/$name"; else
dc device copy to "${ON[@]}" --source "$f" --destination "Documents/developer/harness-inbox/$name" >/dev/null
app_copy to "$f" "Documents/developer/harness-inbox/$name"
rm -f "$f"
fi
[[ -n ${NO_LAUNCH:-} ]] || dc device process launch --device "$DEVICE" "$BUNDLE" >/dev/null
Expand Down
5 changes: 2 additions & 3 deletions harness/logs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ else
fi
if [[ ${1:-} == --runs ]]; then # the latest run's steps only: a run's screenshots and video took minutes over Wi-Fi
RUN=${2:-$(grep -oE 'run [0-9]{8}-[0-9]{6}' "$OUT/debug.log" | tail -1 | cut -d' ' -f2)}
[[ -n $RUN ]] && dc device copy from --device "$DEVICE" --domain-type appDataContainer \
--domain-identifier "$BUNDLE" --source "Documents/traces/$RUN/${RUN_FILE:-steps.jsonl}" \
--destination "$OUT/traces/$RUN/${RUN_FILE:-steps.jsonl}" >/dev/null # RUN_FILE=. for screenshots and video too
[[ -n $RUN ]] && app_copy from "Documents/traces/$RUN/${RUN_FILE:-steps.jsonl}" \
"$OUT/traces/$RUN/${RUN_FILE:-steps.jsonl}" # RUN_FILE=. for screenshots and video too (devicectl only)
fi
echo "$OUT"; tail -n "${LINES:-20}" "$OUT/debug.log"
16 changes: 11 additions & 5 deletions harness/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,15 @@ source harness/lib.sh
[[ -n ${1:-} ]] || { echo 'usage: harness/run.sh "<task>" [seconds]'; exit 1; }
# a run left waiting (asking for help, paused) would refuse the new one ("a run is already going"): stop it first
STOP=$(NO_LAUNCH=1 launch -stop)
follow "$STOP" '^[^ ]+ (debug: stop|finished: )' '^[^ ]+ debug: stop' 15 >/dev/null || true
sleep 2 # the stop is asynchronous: let a running task wind down before the new one asks
follow "$STOP" '^[^ ]+ (debug: stop|finished: )' '^[^ ]+ debug: stopped' 20 >/dev/null || true # the old run has wound down
# No picture (a new app process after app.sh, a stuck session): the run would wait 5 minutes and give up. With
# the board's AirPlay name in HARNESS_BOARD, Screen Mirroring is restarted from the Mac first (tapcv.py).
if [[ -n ${HARNESS_BOARD:-} ]] && NO_LAUNCH=1 harness/hid.sh shot 2>&1 | grep -q 'err no frame'; then
echo "no picture: restarting Screen Mirroring to $HARNESS_BOARD"
uv run -q harness/tapcv.py mirror "$HARNESS_BOARD" --restart | tail -1 || true
fi
FROM=$(launch -run "$1")
follow "$FROM" '^[^ ]+ (debug: |started: |finished: |cannot start: |LLM: )' \
'^[^ ]+ (finished: |cannot start: |debug: run not started|debug: a run is already going)' "${2:-600}" \
'(cannot start: |debug: run not started|debug: a run is already going)'
# a run that asks for help waits for a reply nobody unattended will give: that ends it here too
follow "$FROM" '^[^ ]+ (debug: |started: |finished: |cannot start: |LLM: |step [0-9]+: help )' \
'^[^ ]+ (finished: |cannot start: |(debug: )?run not started|debug: a run is already going|step [0-9]+: help )' "${2:-600}" \
'(cannot start: |(debug: )?run not started|debug: a run is already going)'
Loading
Loading