diff --git a/.codex-plugin/plugin.json b/.codex-plugin/plugin.json
index 07d6337..e433c43 100644
--- a/.codex-plugin/plugin.json
+++ b/.codex-plugin/plugin.json
@@ -1,6 +1,6 @@
{
"name": "android-use",
- "version": "0.6.2",
+ "version": "0.7.0",
"description": "通过 ADB 和 UiAutomator2 操作 Android,支持实时屏幕侧边栏、控件树、截图、中文输入和批处理。",
"skills": "./skills/",
"mcpServers": "./.mcp.json",
diff --git a/README.md b/README.md
index d531431..1fdd5fe 100644
--- a/README.md
+++ b/README.md
@@ -8,7 +8,7 @@
English · 简体中文
- Use in Dim Agent → · Download v0.6.2 · Set up Jev · User guide · Report an issue
+ Use in Dim Agent → · Download v0.7.0 · Set up Jev · User guide · Report an issue
## Android tasks, inside Dim Agent
@@ -34,13 +34,13 @@ For workflows that need repeated UI decisions, enable **Jev**. Your Agent keeps
| Dependencies missing, matching verified native assets available | Use the optional standalone runtime to avoid installing dependencies individually. |
| Offline, unsupported native target, or no native release assets yet | Use a suitable local archive or source setup; report any missing prerequisites. |
-### Optional standalone runtime (new source feature)
+### Optional standalone runtime · v0.7.0
**Python, ADB, ffmpeg, the screen UI and the control service in one native package.** The lightweight Dim plugin installs it automatically on first use. Later MCP connections start the installed version immediately and check for updates in the background; verified updates take effect on the next connection. Failed updates retain the previous version; rollback rechecks it before switching.
**macOS OCR is an optional add-on**, omitted from the default package. Tree interaction, Agent screenshot inspection and Jev can be used without it. Users choosing this package do not need Python, uv, Git, Node.js, a JDK or Xcode tools; public-release bootstrap uses standard OS utilities. Private-release bootstrap additionally supports GitHub CLI with a private token; offline native installation avoids that requirement.
-This is newer than the published v0.6.2 source-plugin ZIP. Use native workflow artifacts for offline trials until a release containing the runtime assets is published. [Install, automatic updates, optional OCR and rollback →](docs/standalone.md)
+Available in v0.7.0 as separate source-plugin, lightweight Dim-plugin and native-runtime downloads. Choose the route for your environment; older v0.6.2 source ZIPs do not include the native runtime. [Install, automatic updates, optional OCR and rollback →](docs/standalone.md)
## Quick start
@@ -114,15 +114,9 @@ Dim Agent calls the Android tools and opens the screen through `aua_screen`. In
## A phone screen you can follow
-
- | Light | Dark |
-
-  |
-  |
-
-
+
-The actual UI, rendered with synthetic phone content for documentation. The frame adapts to theme, window size and orientation. Tap or swipe inside the screen, use Back/Home, or copy a PNG frame. [Live-screen guide →](docs/guide.md#live-screen)
+Android Use in Dim Agent: describe a task in the chat and follow the live phone view beside it. Tap or swipe inside the screen, use Back/Home, or copy a PNG frame. [Live-screen guide →](docs/guide.md#live-screen)
## Agent plans. Jev decides. Android Use acts.
@@ -263,11 +257,11 @@ The preview URL is a private local video endpoint, **not a remote MCP endpoint**
In v0.5.1, supported devices record continuously; legacy segments reuse one connection and decoder. Brief known-health recovery keeps the picture visible. [Recovery behavior and troubleshooting →](docs/guide.md#live-screen).
-## Optional interaction variation (source update)
+## Optional interaction variation · v0.7.0
Add `variation` to a gesture or local goal to sample bounded delays, selector touch points and swipe timing/endpoints. Fixed seeds reproduce samples; explicit coordinates and text stay exact. Added waits revalidate the page and share existing budgets. Default behavior is unchanged. This is interaction testing, with no anti-detection guarantee. [Parameters, audit and boundaries →](docs/interaction-variation.md)
-Source development is synchronized to [arcships/android-use](https://github.com/arcships/android-use); published archives through v0.6.2 remain linked to their original release location.
+Source and v0.7.0 releases are hosted at [arcships/android-use](https://github.com/arcships/android-use).
## A smaller loop, with explicit outcomes
@@ -313,7 +307,7 @@ Development comparisons include **18 source-level trials** and **12 live Agent /
## Project status
-**v0.6.2 · MIT · 392 Python tests · 24 browser tests.** Emulator acceptance covers 15 real stdio MCP scenarios. Earlier physical-device acceptance covers Android 16 / Xiaomi 15 Ultra. New Jev setup and frame changes have local/emulator validation; other manufacturers, host versions and operating systems have different coverage. [Validation evidence →](docs/validation.md)
+**v0.7.0 · MIT · 481 Python tests · 24 browser tests.** Native install/upgrade/rollback acceptance passed on macOS ARM64/Intel (15 scenarios each), Linux x86_64 and Windows x86_64 (13 each). These package checks use no phone or model; earlier Android 16 physical-device and emulator acceptance remain separate. [Validation evidence →](docs/validation.md)
Multi-touch, arbitrary gesture paths, fine-grained text selection and custom-editor input fallbacks are not implemented. A matched UI condition proves that condition; the Agent must verify business outcomes. Control and preview run locally, and tool results are handled by your chosen client/model.
diff --git a/README.zh-CN.md b/README.zh-CN.md
index 396fa0f..a314344 100644
--- a/README.zh-CN.md
+++ b/README.zh-CN.md
@@ -8,7 +8,7 @@
English · 简体中文
- 在 Dim Agent 中使用 → · 下载 v0.6.2 · 配置 Jev · 使用指南 · 反馈问题
+ 在 Dim Agent 中使用 → · 下载 v0.7.0 · 配置 Jev · 使用指南 · 反馈问题
## 在 Dim Agent 中,直接完成 Android 任务
@@ -34,13 +34,13 @@ Android Use 把你自己的 Android 手机或模拟器接入 **Dim Agent**,也
| 缺少依赖,且有匹配、可校验的原生发行包 | 可选独立 runtime,减少逐项安装依赖。 |
| 离线、不支持的原生平台或尚无原生发行资产 | 选择可用的本地包或源码安装,明确缺失条件。 |
-### 可选独立运行包(新源码功能)
+### 可选独立运行包 · v0.7.0
**Python、ADB、ffmpeg、实时界面和控制服务,打成一个原生运行包。** 轻量 Dim 插件首次自动安装;后续 MCP 连接立即使用已安装版本,并在后台检查更新。新包校验、握手通过后,下一次连接使用新版;失败保留旧版,回滚前也会重新验证。
**macOS OCR 是可选组件,默认包不带。** 控件树操作、Agent 看图和 Jev 均可独立使用。选择独立包的用户无需准备 Python、uv、Git、Node.js、JDK 或 Xcode 工具,公开发行包首次下载只使用系统基础工具。私有发行包自动安装支持 GitHub CLI 与私有令牌,也可用原生离线包省去此依赖。
-此功能晚于已发布的 v0.6.2 源码插件 ZIP。正式 Release 尚未包含这些资产时,可用原生构建工作流产物离线体验。[安装、自动更新、可选 OCR 与回滚 →](docs/standalone.md#中文)
+v0.7.0 分别提供源码插件、轻量 Dim 插件和原生运行包,按用户环境选择;旧 v0.6.2 源码 ZIP 不含原生运行包。[安装、自动更新、可选 OCR 与回滚 →](docs/standalone.md#中文)
## 快速开始
@@ -111,15 +111,9 @@ Dim Agent 会调用 Android 工具,通过 `aua_screen` 在桌面端右侧打
## 像拿着手机一样,看见每一步
-
- | 浅色 | 深色 |
-
-  |
-  |
-
-
+
-上图为真实前端渲染,手机内容使用文档示例。机身随主题、窗口和横竖屏适配;屏幕内支持点击和滑动,工具栏支持返回、Home 与 PNG 画面复制。[实时屏幕指南 →](docs/guide.zh-CN.md#实时屏幕与图片复制)
+在 Dim Agent 中描述任务,旁边的实时手机画面展示执行过程。屏幕内支持点击和滑动,工具栏支持返回、Home 与 PNG 画面复制。[实时屏幕指南 →](docs/guide.zh-CN.md#实时屏幕与图片复制)
## Agent 规划,Jev 决策,Android Use 执行
@@ -278,7 +272,7 @@ uv run android-use scroll_until '{"selector":{"text":"显示与亮度"},"directi
手势或局部目标可显式传 `variation`:限定范围内变化等待、选择器落点和滑动参数,支持固定种子复现。明确坐标和文本保持精确;新增等待后检查页面,继续遵守预算与不重放规则。默认行为不变,不承诺防检测。[参数、审计与边界 →](docs/interaction-variation.md#中文)
-源码同步到 [arcships/android-use](https://github.com/arcships/android-use);v0.6.2 及此前安装包仍链接到原发布位置。
+源码及 v0.7.0 发行包统一托管于 [arcships/android-use](https://github.com/arcships/android-use)。
## v0.6.0:无 Key 决策与视觉定位
@@ -311,7 +305,7 @@ v0.5.0 通过 **277 项 Python 测试、17 项界面测试**。内置 OCR 目前
## 项目状态
-**v0.6.2 · MIT · 392 项 Python 测试 · 24 项浏览器测试。** 模拟器验收覆盖 15 项真实 stdio MCP 场景;已有 Android 16 / Xiaomi 15 Ultra 真机验收。新增 Jev 设置和机身界面在本机/模拟器验证,其他厂商、宿主版本及系统的覆盖范围另见[验证记录](docs/validation.md)。
+**v0.7.0 · MIT · 481 项 Python 测试 · 24 项浏览器测试。** 原生安装、升级和回滚在 macOS ARM64/Intel 各通过 15 项,Linux x86_64/Windows x86_64 各通过 13 项。这些包验收不操作手机、不调用模型;历史 Android 16 真机与模拟器验收分开记录。[验证记录](docs/validation.md)。
多指手势、任意轨迹、精细文本选区及自绘编辑器输入兜底尚未实现。UI 条件满足仅证明该条件,Agent 仍需验收业务结果。控制和预览运行于本机,工具结果由你选择的客户端与模型处理。
diff --git a/docs/guide.md b/docs/guide.md
index 61d1990..5522b51 100644
--- a/docs/guide.md
+++ b/docs/guide.md
@@ -144,12 +144,12 @@ Choose a release ZIP or a source checkout. If you already use `android-use-local
### Install the release ZIP
-Download `android-use-0.6.2-plugin.zip` and `SHA256SUMS` from [GitHub Release v0.6.2](https://github.com/JackCaow/android-use/releases/tag/v0.6.2). The ZIP includes the compiled UI, Python source/lockfile, stable installer, skills, bilingual docs and a local marketplace. Prepare uv, ADB, ffmpeg and the Codex CLI; dependencies are downloaded on first installation.
+Download `android-use-0.7.0-plugin.zip` and `SHA256SUMS` from [GitHub Release v0.7.0](https://github.com/arcships/android-use/releases/tag/v0.7.0). The ZIP includes the compiled UI, Python source/lockfile, stable installer, skills, bilingual docs and a local marketplace. Prepare uv, ADB, ffmpeg and the Codex CLI; dependencies are downloaded on first installation.
```bash
shasum -a 256 -c SHA256SUMS # Linux: sha256sum -c SHA256SUMS
-unzip android-use-0.6.2-plugin.zip -d android-use-v0.6.2
-cd android-use-v0.6.2
+unzip android-use-0.7.0-plugin.zip -d android-use-v0.7.0
+cd android-use-v0.7.0
uv run --no-project --python 3.13 python scripts/install.py doctor
uv run --no-project --python 3.13 python scripts/install.py install --source . --codex
```
diff --git a/docs/guide.zh-CN.md b/docs/guide.zh-CN.md
index fb1e156..d06fa25 100644
--- a/docs/guide.zh-CN.md
+++ b/docs/guide.zh-CN.md
@@ -188,12 +188,12 @@ uv run android-use --serial SERIAL ready
### 安装发行包 ZIP
-从 [GitHub Release v0.6.2](https://github.com/JackCaow/android-use/releases/tag/v0.6.2) 下载 `android-use-0.6.2-plugin.zip` 和 `SHA256SUMS`。包内包含编译好的界面、源码与锁文件、固定入口安装器、技能和双语说明;先准备 uv、ADB、ffmpeg 和 Codex CLI,首次安装需下载 Python 依赖。
+从 [GitHub Release v0.7.0](https://github.com/arcships/android-use/releases/tag/v0.7.0) 下载 `android-use-0.7.0-plugin.zip` 和 `SHA256SUMS`。包内包含编译好的界面、源码与锁文件、固定入口安装器、技能和双语说明;先准备 uv、ADB、ffmpeg 和 Codex CLI,首次安装需下载 Python 依赖。
```bash
shasum -a 256 -c SHA256SUMS # Linux: sha256sum -c SHA256SUMS
-unzip android-use-0.6.2-plugin.zip -d android-use-v0.6.2
-cd android-use-v0.6.2
+unzip android-use-0.7.0-plugin.zip -d android-use-v0.7.0
+cd android-use-v0.7.0
uv run --no-project --python 3.13 python scripts/install.py doctor
uv run --no-project --python 3.13 python scripts/install.py install --source . --codex
```
diff --git a/docs/images/dim-agent-live-screen.png b/docs/images/dim-agent-live-screen.png
new file mode 100644
index 0000000..c7de7ba
Binary files /dev/null and b/docs/images/dim-agent-live-screen.png differ
diff --git a/docs/interaction-variation.md b/docs/interaction-variation.md
index 60e69fb..5a5e52a 100644
--- a/docs/interaction-variation.md
+++ b/docs/interaction-variation.md
@@ -1,6 +1,6 @@
# Optional interaction variation
-Experimental source update after v0.6.2. The published v0.6.2 ZIP does not contain these fields. Use the current source and reload MCP tools to advertise the updated schemas. Existing tool names and defaults remain compatible.
+Experimental and optional in v0.7.0. Older v0.6.2 ZIPs do not contain these fields. Update the installation and reconnect MCP to advertise the schemas; existing tool names and defaults remain compatible.
This is bounded variation for interaction testing. It does not hide the UiAutomator execution channel or promise that third-party apps cannot recognize automation. Native swipe/drag paths remain straight; this feature does not add multi-touch, arbitrary curves or synthetic per-character typing.
diff --git a/docs/license-audit.md b/docs/license-audit.md
index a4c2a49..0b53bbb 100644
--- a/docs/license-audit.md
+++ b/docs/license-audit.md
@@ -40,7 +40,7 @@ The FFmpeg source is inside the same downloadable native archive as its binary.
Metadata and filename checks alone cannot prove every statically linked component's provenance. The pinned notices and Python build gate reduce known risks; they are not a blanket legal certification for every OS, wheel and future dependency update. In particular, Windows distributions may contain Microsoft runtime DLLs with separate redistribution terms; the native inventory records their actual filenames. Those binaries are not reclassified as MIT or open source by this project.
-This PR does not publish a release. Keep the per-platform acceptance artifacts and inventory with the release review, and repeat the scan when the interpreter, wheels, compiler or FFmpeg configuration changes. The first pre-audit local artifacts are diagnostic evidence, not the release-approved packages.
+The audit was prepared with the standalone-runtime change. Keep the per-platform acceptance artifacts and inventory with every release, and repeat the scan when the interpreter, wheels, compiler or FFmpeg configuration changes. The first pre-audit local artifacts are diagnostic evidence, not the release-approved packages.
## 中文
@@ -48,4 +48,4 @@ This PR does not publish a release. Keep the per-platform acceptance artifacts a
本轮发现首个构建 Python 内置 GNU gdbm;仅排除模块导入不能移除已静态链接的代码。因此增加构建门禁,改用可排除模块的 CPython,并检查原生文件。ADB 只带实际需要的文件,避免附带无关工具;certifi 源码、Python/原生库声明、FFmpeg 对应源码与精确编译选项一并随包提供。中英文 README 已感谢 iPhone Use 的启发;实际代码复用仍需要保留原许可证和版权,不能只用致谢替代。
-审计按当前声明、构建和产物执行,不把元数据扫描等同于完整二进制溯源或法律认证。Windows 可能包含微软可再分发运行库,其条款单独适用。本次保持 PR 审阅,不发布新版本;后续更新基础环境或依赖时,应连同原生清单一起复查。
+审计按当前声明、构建和产物执行,不把元数据扫描等同于完整二进制溯源或法律认证。Windows 可能包含微软可再分发运行库,其条款单独适用。每次发布都应保留原生验收记录与随包声明;后续更新基础环境或依赖时,应连同原生清单一起复查。
diff --git a/docs/releases/v0.7.0.md b/docs/releases/v0.7.0.md
new file mode 100644
index 0000000..2452ef7
--- /dev/null
+++ b/docs/releases/v0.7.0.md
@@ -0,0 +1,122 @@
+# Android Use v0.7.0
+
+**Your environment. Your installation choice.**
+
+Android Use now offers optional native packages for macOS, Linux and Windows alongside the existing source plugin. Your Agent inspects the host, reuses a healthy installation and chooses the appropriate route. **A standalone runtime is not required.** All 26 MCP tools, keyless host decisions, optional Jev and live-screen integration remain available.
+
+[English README](https://github.com/arcships/android-use/blob/v0.7.0/README.md) · [中文 README](https://github.com/arcships/android-use/blob/v0.7.0/README.zh-CN.md) · [Native installation and rollback](https://github.com/arcships/android-use/blob/v0.7.0/docs/standalone.md) · [Source upgrades](https://github.com/arcships/android-use/blob/v0.7.0/docs/upgrading.md)
+
+## What's new
+
+- **Optional standalone runtime:** includes CPython, locked Python libraries, ADB, minimal FFmpeg, the compiled UI and UiAutomator control JAR. No separate Python/uv, Node.js or JDK setup is needed on this route. Reuse an existing source environment when it already works.
+- **Opt-in lightweight Dim plugins:** select the matching platform ZIP for first-use installation. Use Android Use in Dim Agent, describe a phone task, and follow the live phone view beside the chat. The README now shows an actual Dim Agent screenshot.
+- **Verified updates and rollback:** check downloads and archive paths, probe bundled tools and a real MCP session, then promote one atomic pointer. Existing sessions keep running; the next MCP connection uses the new version. Failed updates retain the active version. Rollback rechecks the previous version and pauses automatic updates.
+- **Optional macOS OCR:** omitted from the default native package. Install the separate precompiled component only when local text recognition is needed; no Swift compiler is needed by its users. Tree interaction, Agent screenshot inspection and Jev do not depend on this helper.
+- **Optional interaction variation:** bounded timing and selector-point variation with reproducible seeds and existing execution guards. Disabled by default; it does not hide automation or guarantee avoidance of app detection.
+- **Cross-platform fixes:** Windows preview resources use UTF-8, original license bytes survive CRLF-configured Git checkouts, and the Windows bootstrap hashes/extracts through .NET without depending on optional PowerShell functions.
+- **Distribution notices:** the project's MIT copyright is attributed to **Archship**. Dependency licenses remain separate. Archives include CPython/package notices, certifi source form, corresponding FFmpeg source/build options and native inventories; known optional DBM/readline risks are blocked at build time. Thanks to [iPhone Use](https://github.com/zhongerxin/iPhone-use) for the inspiration.
+
+## Pick a download
+
+| Asset | Use it for |
+| --- | --- |
+| `android-use-0.7.0-plugin.zip` | Existing source/Codex installation, or any local stdio MCP client using Python/uv. Requires host ADB and ffmpeg for live video. |
+| `android-use-0.7.0-PLATFORM-dim-plugin.zip` | Opt-in native bootstrap plugin for Dim Agent. Choose your platform below. |
+| `android-use-runtime-PLATFORM.zip` | Manual/offline native installation, or a stable local MCP command for other clients. |
+| `android-use-ocr-macos-arm64.zip`, `android-use-ocr-macos-x86_64.zip` | Optional macOS local OCR components. |
+| `SHA256SUMS` | Checksums for every installation ZIP. |
+
+`PLATFORM` is **`macos-arm64`** (Apple Silicon), **`macos-x86_64`** (Intel Mac), **`linux-x86_64`**, or **`windows-x86_64`**. Native Linux packages are built on Ubuntu 22.04. These are desktop packages, **not Android APKs**.
+
+Download the selected ZIP and `SHA256SUMS` from this release. Compare its SHA256 with the matching line before extracting or running it. The repository may require GitHub authentication; use the browser while signed in or, for example:
+
+```bash
+gh release download v0.7.0 --repo arcships/android-use \
+ --pattern android-use-runtime-macos-arm64.zip --pattern SHA256SUMS
+# macOS, verifying only the ZIP downloaded above:
+awk '$2=="android-use-runtime-macos-arm64.zip"' SHA256SUMS | shasum -a 256 -c -
+# Linux: replace shasum -a 256 with sha256sum.
+```
+
+On Windows, `certutil -hashfile FILE.zip SHA256` can display the value to compare with `SHA256SUMS`.
+
+## Install in Dim Agent
+
+Ask your Agent:
+
+> Install Android Use from https://github.com/arcships/android-use. Inspect my existing environment and choose source setup or the optional native package. Reuse healthy installations, preserve my settings and other MCP servers, verify the release checksum, register the returned local stdio command, then check READY and open the live phone view. I will handle USB authorization and unlocking. Leave Jev disabled until I configure it.
+
+If choosing the lightweight native plugin, extract the matching `android-use-0.7.0-PLATFORM-dim-plugin.zip`, then install that directory through Dim's plugin management or:
+
+```bash
+dim plugin install /absolute/path/to/extracted-dim-plugin
+```
+
+First-use bootstrap needs network access and OS download/unzip utilities. A private release additionally needs GitHub CLI plus `ANDROID_USE_GITHUB_TOKEN` with asset read access; alternatively install the native archive offline first. Never put tokens in a chat or committed configuration. After native installation, updates use the bundled HTTP client rather than GitHub CLI.
+
+### Manual native installation / other MCP clients
+
+macOS example (replace the platform for Intel Mac or Linux):
+
+```bash
+unzip android-use-runtime-macos-arm64.zip -d android-use-runtime
+./android-use-runtime/app/android-use-runtime install \
+ --archive android-use-runtime-macos-arm64.zip \
+ --sha256 REPLACE_WITH_THE_MATCHING_64_HEX_VALUE_FROM_SHA256SUMS
+```
+
+Windows PowerShell:
+
+```powershell
+Expand-Archive .\android-use-runtime-windows-x86_64.zip .\android-use-runtime
+& .\android-use-runtime\app\android-use-runtime.exe install `
+ --archive .\android-use-runtime-windows-x86_64.zip `
+ --sha256 REPLACE_WITH_THE_MATCHING_64_HEX_VALUE_FROM_SHA256SUMS
+```
+
+Copy the returned **`mcp_config.command` and all `mcp_config.args`** into the client's local stdio MCP settings. Dim can use its MCP management; Claude Desktop/Cursor use `mcpServers`, while VS Code uses `servers`. Keep existing `env` settings and the intended state directory. Disable duplicate Android Use registrations. The native directory defaults to `~/.local/share/android-use/runtime`; keep it after deleting the downloaded ZIP/extraction.
+
+Reconnect MCP, discover the 26 tools, then call `aua_setup(action="status")`, start only if needed, verify `aua_ready` and open `aua_screen`. The phone still needs debugging authorization, unlocking and a supported recording capability. Jev remains optional and can be configured in the screen's **Jev** settings.
+
+### Source / Codex installation
+
+Extract `android-use-0.7.0-plugin.zip`. Prepare uv and ADB; ffmpeg is needed for live video. From the extraction root:
+
+```bash
+uv run --no-project --python 3.13 python scripts/install.py doctor
+uv run --no-project --python 3.13 python scripts/install.py install --source . --codex
+```
+
+For Dim or another MCP client, omit `--codex` and register the returned `mcp_config`. For a recognized older manual/Codex registration, review diagnostics and explicitly use `--migrate-codex`; already-managed installations can use the ordinary install command. Source installation remains supported and does not provision a native runtime automatically.
+
+## Update, OCR and rollback
+
+For native macOS/Linux installations:
+
+```bash
+/bin/sh "$HOME/.local/share/android-use/runtime/launcher.sh" update
+/bin/sh "$HOME/.local/share/android-use/runtime/launcher.sh" install-ocr # optional, macOS only
+/bin/sh "$HOME/.local/share/android-use/runtime/launcher.sh" rollback
+```
+
+On Windows, use the returned native command and its `--root ROOT` arguments; replace the final `auto-serve` argument with the management command. Automatic checks occur at most once per 24 hours; `ANDROID_USE_AUTO_UPDATE=0` disables them. Rollback pauses checks until an explicit successful `update`. Original runtime versions and settings are retained. Moving from source to native is an explicit installation choice; the source launcher's private environment file is not silently imported.
+
+A full desktop restart is not intrinsic to a runtime upgrade, but an existing MCP process is **not hot-replaced**. Reconnect/reload tools to start the selected version. Publishing this release does not update an already-running local installation.
+
+## Validation and scope
+
+The standalone implementation passed **481 Python regressions, 24 browser tests and Ruff**. Native acceptance passed **15 scenarios on each macOS architecture** and **13 each on Linux and Windows**: real stdio MCP/UI resources, install/upgrade/rollback, active sessions during promotion, bad-update preservation, private settings, bundled H.264 decoding, optional Mac OCR and packaged public/private bootstrap. The release pipeline repeats acceptance with the v0.7.0 binaries before publication.
+
+These package checks perform **no phone actions or model calls**. Earlier device/Jev acceptance is separate. Bootstrap transport was stubbed in CI; live release-download smoke checks are reported separately. Packages are unsigned: new-user OS security prompts and OEM USB drivers are outside CI acceptance. Forced termination can leave a lock; verify the process has exited before cleaning it. SHA256 protects transfer integrity, not a compromised publisher. See the [validation record](https://github.com/arcships/android-use/blob/v0.7.0/docs/validation.md) and [license audit](https://github.com/arcships/android-use/blob/v0.7.0/docs/license-audit.md) for the exact boundaries.
+
+## 中文
+
+v0.7.0 新增四平台可选独立运行包、轻量 Dim 插件、后台校验更新与回滚。**runtime 不是必需项**:Agent 根据已有安装、依赖、平台和网络选择源码方式或独立包,复用健康环境,不重复注册。README 已换成 Dim Agent 实际操作截图;项目 MIT 版权归属为 **Archship**,第三方声明与对应分发材料保留。
+
+**下载选择:** 已有 Python/uv 环境可继续用 `android-use-0.7.0-plugin.zip`;希望减少依赖安装时,选匹配平台的 `android-use-runtime-PLATFORM.zip`,或在 Dim 中使用 `android-use-0.7.0-PLATFORM-dim-plugin.zip`。macOS OCR 单独按需安装,不默认携带;Jev 与本地 OCR 均可选。先下载对应 ZIP 和 `SHA256SUMS` 校验,再按上面的命令安装。私有仓库需要下载权限,可在已登录的浏览器下载;首次私有自动安装需要 GitHub CLI 与私有令牌,也可先离线安装运行包。
+
+**配置使用:** 将安装返回的 `mcp_config.command` 和全部参数填入客户端本地 stdio 配置,保留原 `env`、设备与 Jev 设置,移除重复入口。源码方式用 `scripts/install.py`;Codex 加 `--codex`,其他客户端省略。完成后重连 MCP,确认工具、READY 与实时画面。USB 调试授权、手机解锁及系统权限由用户完成;Jev Key 可在画面的 Jev 设置里自行配置。
+
+**升级回滚:** 原生固定入口支持 `update`、可选 `install-ocr` 和 `rollback`。后台最多每天检查一次,校验与真实 MCP 握手通过才切换;当前任务继续执行,下次连接使用新版。失败保留旧版;回滚先验证旧版并暂停自动更新,显式成功执行 `update` 后恢复。不会自动替换当前 MCP 进程,也不会因发布新版本自动更新本机插件。
+
+481 项 Python、24 项浏览器测试及四平台安装、升级、回滚验收通过;发布流水线对 v0.7.0 产物再验收后上传。包验收不操作手机、不调用 Jev;CI 中的下载传输桩不等于真实 Release 下载验收。原生包未签名、驱动与新用户系统提示等范围见上文。所有包不是 Android APK。
diff --git a/docs/standalone.md b/docs/standalone.md
index c009e9f..ef88106 100644
--- a/docs/standalone.md
+++ b/docs/standalone.md
@@ -1,6 +1,6 @@
# Standalone runtime / 独立运行包
-**Source feature after v0.6.2.** Historical v0.6.2 source-plugin ZIPs do not contain this runtime. The **Standalone runtimes** workflow builds native archives and lightweight Dim plugins; tagged releases publish those artifacts only after their acceptance checks pass. Before a release containing these assets exists, use the workflow artifacts for offline installation. The lightweight plugin's production download URL cannot provision a runtime from an older release that lacks it.
+**Available in v0.7.0.** Download native runtime archives or the optional lightweight Dim plugin from [the release](https://github.com/arcships/android-use/releases/tag/v0.7.0). The four-platform workflow verifies each archive before publication. Older v0.6.2 source-plugin ZIPs do not contain these native assets.
**Optional installation route.** Android Use does not require this runtime. The Agent first reuses a healthy installation, then checks existing Python/uv, ADB, ffmpeg, platform, network and available assets. Use source setup when it fits the host; choose a verified native package when it saves dependency setup. Do not migrate a working source installation solely to use the runtime. Only selecting the lightweight native plugin opts into its runtime bootstrap.
@@ -119,7 +119,7 @@ Builds reject statically embedded optional DBM/readline modules and exclude thei
**runtime 是可选安装方式,不是使用 Android Use 的前提。** Agent 先复用健康安装,再检查 Python/uv、ADB、ffmpeg、平台、网络和发行包可用性,自主选择源码或独立包;不因提供了 runtime 就迁移已有正常环境。仅选择轻量原生插件时,才使用它的运行包自动安装流程。
-这是 v0.6.2 之后的新源码功能,旧 v0.6.2 插件包不包含独立运行时。跨平台工作流生成原生运行包、轻量 Dim 插件与 SHA256;正式发布需要对应 Release 中实际有这些资产,不能把旧 ZIP 当成新包。发布前可使用工作流产物离线安装。
+此功能已纳入 v0.7.0,发行包包含四个平台的原生运行包、轻量 Dim 插件与 SHA256,发布前逐平台验收。旧 v0.6.2 源码插件包不包含这些原生资产。
默认包内置 Python、Python 依赖、ADB、ffmpeg、界面和控制 JAR,普通用户无需 Git、uv、Node.js 或 JDK。**macOS OCR 不默认携带**,需要本地识字时用固定入口的 `install-ocr` 安装可选组件,安装后也不需要 Xcode/Swift。未安装时明确返回不可用,不悄悄编译。Jev 决策和视觉定位不等同于 OCR;树缺失页面的自动离线文字提取仍需此组件。
diff --git a/pyproject.toml b/pyproject.toml
index 5715305..53a85f0 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,6 +1,6 @@
[project]
name = "android-use"
-version = "0.6.2"
+version = "0.7.0"
requires-python = ">=3.11"
description = "Local Android device control for coding agents over MCP and ADB"
license = "MIT"
diff --git a/src/android_use/__init__.py b/src/android_use/__init__.py
index e6cd9d8..cbe7eae 100644
--- a/src/android_use/__init__.py
+++ b/src/android_use/__init__.py
@@ -1,3 +1,3 @@
"""Android Use: an ADB/UiAutomator bridge for agents."""
-__version__ = "0.6.2"
+__version__ = "0.7.0"
diff --git a/src/android_use/assets/phone-screen.html b/src/android_use/assets/phone-screen.html
index 51c0d61..d2608ec 100644
--- a/src/android_use/assets/phone-screen.html
+++ b/src/android_use/assets/phone-screen.html
@@ -240,5 +240,5 @@
- omitted: host decides border`)}),Q4=d.object({method:d.literal("ui/request-display-mode"),params:d.object({mode:Fi.describe("The display mode being requested.")})}),VS=d.object({mode:Fi.describe("The display mode that was actually set. May differ from requested if not supported.")}).passthrough(),FS=d.union([d.literal("model"),d.literal("app")]).describe("Tool visibility scope - who can access the tool."),X4=d.object({resourceUri:d.string().optional(),visibility:d.array(FS).optional().describe(`Who can access this tool. Default: ["model", "app"]
- "model": Tool visible to and callable by the agent
- "app": Tool callable by the app from this server only`),csp:d.never().optional(),permissions:d.never().optional()}),Y4=d.object({mimeTypes:d.array(d.string()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')}),eN=d.object({method:d.literal("ui/download-file"),params:d.object({contents:d.array(d.union([df,mf])).describe("Resource contents to download \u2014 embedded (inline data) or linked (host fetches). Uses standard MCP resource types.")})}),tN=d.object({method:d.literal("ui/message"),params:d.object({role:d.literal("user").describe('Message role, currently only "user" is supported.'),content:d.array(an).describe("Message content blocks (text, image, etc.).")})}),rN=d.object({method:d.literal("ui/notifications/sandbox-resource-ready"),params:d.object({html:d.string().describe("HTML content to load into the inner iframe."),sandbox:d.string().optional().describe("Optional override for the inner iframe's sandbox attribute."),csp:_f.optional().describe("CSP configuration from resource metadata."),permissions:xf.optional().describe("Sandbox permissions from resource metadata.")})}),qS=d.object({method:d.literal("ui/notifications/tool-result"),params:sn.describe("Standard MCP tool execution result.")}),ey=d.object({toolInfo:d.object({id:rn.optional().describe("JSON-RPC id of the tools/call request."),tool:ic.describe("Tool definition including name, inputSchema, etc.")}).optional().describe("Metadata of the tool call that instantiated this App."),theme:PS.optional().describe("Current color theme preference."),styles:RS.optional().describe("Style configuration for theming the app."),displayMode:Fi.optional().describe("How the UI is currently displayed."),availableDisplayModes:d.array(Fi).optional().describe("Display modes the host supports."),containerDimensions:d.union([d.object({height:d.number().describe("Fixed container height in pixels.")}),d.object({maxHeight:d.union([d.number(),d.undefined()]).optional().describe("Maximum container height in pixels.")})]).and(d.union([d.object({width:d.number().describe("Fixed container width in pixels.")}),d.object({maxWidth:d.union([d.number(),d.undefined()]).optional().describe("Maximum container width in pixels.")})])).optional().describe(`Container dimensions. Represents the dimensions of the iframe or other
-container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:d.string().optional().describe("User's language and region preference in BCP 47 format."),timeZone:d.string().optional().describe("User's timezone in IANA format."),userAgent:d.string().optional().describe("Host application identifier."),platform:d.union([d.literal("web"),d.literal("desktop"),d.literal("mobile")]).optional().describe("Platform type for responsive design decisions."),deviceCapabilities:d.object({touch:d.boolean().optional().describe("Whether the device supports touch input."),hover:d.boolean().optional().describe("Whether the device supports hover interactions.")}).optional().describe("Device input capabilities."),safeAreaInsets:d.object({top:d.number().describe("Top safe area inset in pixels."),right:d.number().describe("Right safe area inset in pixels."),bottom:d.number().describe("Bottom safe area inset in pixels."),left:d.number().describe("Left safe area inset in pixels.")}).optional().describe("Mobile safe area boundaries in pixels.")}).passthrough(),JS=d.object({method:d.literal("ui/notifications/host-context-changed"),params:ey.describe("Partial context update containing only changed fields.")}),nN=d.object({method:d.literal("ui/update-model-context"),params:d.object({content:d.array(an).optional().describe("Context content blocks (text, image, etc.)."),structuredContent:d.record(d.string(),d.unknown().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.")})}),iN=d.object({method:d.literal("ui/initialize"),params:d.object({appInfo:Ei.describe("App identification (name and version)."),appCapabilities:MS.describe("Features and capabilities this app provides."),protocolVersion:d.string().describe("Protocol version this app supports.")})}),BS=d.object({protocolVersion:d.string().describe('Negotiated protocol version string (e.g., "2025-11-21").'),hostInfo:Ei.describe("Host application identification and version."),hostCapabilities:LS.describe("Features and capabilities provided by the host."),hostContext:ey.describe("Rich context about the host environment.")}).passthrough(),HS={target:"draft-2020-12"};async function X$(e,r){let i=e["~standard"];if(i.jsonSchema)return i.jsonSchema[r](HS);if(i.vendor==="zod"){let{z:o}=await Promise.resolve().then(()=>(Oi(),Qp));return o.toJSONSchema(e,{io:r})}throw Error(`Schema (vendor: ${i.vendor}) does not implement Standard JSON Schema (~standard.jsonSchema). Use a library that does (zod v4, ArkType, Valibot) or wrap your schema accordingly.`)}async function Y$(e,r,i=""){let o=await e["~standard"].validate(r);if(o.issues){let t=o.issues.map(n=>{let a=n.path?.map(s=>typeof s=="object"?s.key:s).join(".");return a?`${a}: ${n.message}`:n.message}).join("; ");throw Error(i+t)}return o.value}var ac=class e extends yf{_appInfo;_capabilities;options;_hostCapabilities;_hostInfo;_hostContext;_registeredTools={};_initializedSent=!1;_assertInitialized(r){if(this._initializedSent)return;let i=`[ext-apps] App.${r}() called before connect() completed the ui/initialize handshake. Await app.connect() before calling this method, or move data loading to an ontoolresult handler.`;if(this.options?.strict)throw Error(i);console.warn(`${i}. This will throw in a future release.`)}eventSchemas={toolinput:AS,toolinputpartial:US,toolresult:qS,toolcancelled:ES,hostcontextchanged:JS};static ONE_SHOT_EVENTS=new Set(["toolinput","toolinputpartial","toolresult","toolcancelled"]);_everHadListener=new Set;_assertHandlerTiming(r){if(!e.ONE_SHOT_EVENTS.has(r)||this._everHadListener.has(r)||(this._everHadListener.add(r),!this._initializedSent))return;let i=`[ext-apps] "${String(r)}" handler registered after connect() completed the ui/initialize handshake. The host may have already sent this notification. Register handlers before calling app.connect().`;if(this.options?.strict)throw Error(i);console.warn(i)}setEventHandler(r,i){i&&this._assertHandlerTiming(r),super.setEventHandler(r,i)}addEventListener(r,i){this._assertHandlerTiming(r),super.addEventListener(r,i)}onEventDispatch(r,i){r==="hostcontextchanged"&&(this._hostContext={...this._hostContext,...i})}constructor(r,i={},o={autoResize:!0}){super(o),this._appInfo=r,this._capabilities=i,this.options=o,o.allowUnsafeEval||d.config({jitless:!0}),this.setRequestHandler(nn,t=>(console.log("Received ping:",t.params),{})),this.setEventHandler("hostcontextchanged",void 0)}registerCapabilities(r){if(this.transport)throw Error("Cannot register capabilities after transport is established");this._capabilities=G$(this._capabilities,r)}registerTool(r,i,o){if(this._registeredTools[r])throw Error(`Tool ${r} is already registered`);let t=this,n=()=>{t._initializedSent&&t._capabilities.tools?.listChanged&&t.sendToolListChanged()},a=i.inputSchema!==void 0,s={title:i.title,description:i.description,inputSchema:i.inputSchema,outputSchema:i.outputSchema,annotations:i.annotations,_meta:i._meta,enabled:!0,enable(){this.enabled=!0,n()},disable(){this.enabled=!1,n()},update(c){Object.assign(this,c),n()},remove(){t._registeredTools[r]===s&&(delete t._registeredTools[r],n())},handler:async(c,u)=>{if(!s.enabled)throw Error(`Tool ${r} is disabled`);let l;if(a){let m=s.inputSchema,p=m?await Y$(m,c??{},`Invalid input for tool ${r}: `):c??{};l=await o(p,u)}else l=await o(u);return s.outputSchema&&!l.isError&&(l.structuredContent=await Y$(s.outputSchema,l.structuredContent,`Invalid output for tool ${r}: `)),l}};return this._registeredTools[r]=s,!this._capabilities.tools&&!this.transport&&this.registerCapabilities({tools:{listChanged:!0}}),this.ensureToolHandlersInitialized(),n(),s}_toolHandlersInitialized=!1;ensureToolHandlersInitialized(){this._toolHandlersInitialized||(this._toolHandlersInitialized=!0,this.oncalltool=async(r,i)=>{let o=this._registeredTools[r.name];if(!o)throw Error(`Tool ${r.name} not found`);return o.handler(r.arguments,i)},this.onlisttools=async(r,i)=>({tools:await Promise.all(Object.entries(this._registeredTools).filter(([o,t])=>t.enabled).map(async([o,t])=>{let n={name:o,title:t.title,description:t.description,inputSchema:t.inputSchema?await X$(t.inputSchema,"input"):{type:"object",properties:{}}};return t.outputSchema&&(n.outputSchema=await X$(t.outputSchema,"output")),t.annotations&&(n.annotations=t.annotations),t._meta&&(n._meta=t._meta),n}))}))}async sendToolListChanged(r={}){this._assertInitialized("sendToolListChanged"),await this.notification({method:"notifications/tools/list_changed",params:r})}getHostCapabilities(){return this._hostCapabilities}getHostVersion(){return this._hostInfo}getHostContext(){return this._hostContext}get ontoolinput(){return this.getEventHandler("toolinput")}set ontoolinput(r){this.setEventHandler("toolinput",r)}get ontoolinputpartial(){return this.getEventHandler("toolinputpartial")}set ontoolinputpartial(r){this.setEventHandler("toolinputpartial",r)}get ontoolresult(){return this.getEventHandler("toolresult")}set ontoolresult(r){this.setEventHandler("toolresult",r)}get ontoolcancelled(){return this.getEventHandler("toolcancelled")}set ontoolcancelled(r){this.setEventHandler("toolcancelled",r)}get onhostcontextchanged(){return this.getEventHandler("hostcontextchanged")}set onhostcontextchanged(r){this.setEventHandler("hostcontextchanged",r)}_onteardown;get onteardown(){return this._onteardown}set onteardown(r){this.warnIfRequestHandlerReplaced("onteardown",this._onteardown,r),this._onteardown=r,this.replaceRequestHandler(ZS,(i,o)=>{if(!this._onteardown)throw Error("No onteardown handler set");return this._onteardown(i.params,o)})}_oncalltool;get oncalltool(){return this._oncalltool}set oncalltool(r){this.warnIfRequestHandlerReplaced("oncalltool",this._oncalltool,r),this._oncalltool=r,this.replaceRequestHandler(ff,(i,o)=>{if(!this._oncalltool)throw Error("No oncalltool handler set");return this._oncalltool(i.params,o)})}_onlisttools;get onlisttools(){return this._onlisttools}set onlisttools(r){this.warnIfRequestHandlerReplaced("onlisttools",this._onlisttools,r),this._onlisttools=r,this.replaceRequestHandler(pf,(i,o)=>{if(!this._onlisttools)throw Error("No onlisttools handler set");return this._onlisttools(i.params,o)})}assertCapabilityForMethod(r){switch(r){case"sampling/createMessage":if(!this._hostCapabilities?.sampling)throw Error(`Host does not support sampling (required for ${r})`);break}}assertRequestHandlerCapability(r){switch(r){case"tools/call":case"tools/list":if(!this._capabilities.tools)throw Error(`Client does not support tool capability (required for ${r})`);return;case"ping":case"ui/resource-teardown":return;default:throw Error(`No handler for method ${r} registered`)}}assertNotificationCapability(r){}assertTaskCapability(r){throw Error("Tasks are not supported in MCP Apps")}assertTaskHandlerCapability(r){throw Error("Task handlers are not supported in MCP Apps")}async callServerTool(r,i){if(this._assertInitialized("callServerTool"),typeof r=="string")throw Error(`callServerTool() expects an object as its first argument, but received a string ("${r}"). Did you mean: callServerTool({ name: "${r}", arguments: { ... } })?`);return await this.request({method:"tools/call",params:r},sn,{onprogress:()=>{},resetTimeoutOnProgress:!0,...i})}async readServerResource(r,i){return this._assertInitialized("readServerResource"),await this.request({method:"resources/read",params:r},sf,i)}async listServerResources(r,i){return this._assertInitialized("listServerResources"),await this.request({method:"resources/list",params:r},of,i)}async createSamplingMessage(r,i){this._assertInitialized("createSamplingMessage");let o=r.tools?hf:gf;return await this.request({method:"sampling/createMessage",params:r},o,i)}sendMessage(r,i){return this._assertInitialized("sendMessage"),this.request({method:"ui/message",params:r},NS,i)}sendLog(r){return this.notification({method:"notifications/message",params:r})}updateModelContext(r,i){return this._assertInitialized("updateModelContext"),this.request({method:"ui/update-model-context",params:r},Ks,i)}openLink(r,i){return this._assertInitialized("openLink"),this.request({method:"ui/open-link",params:r},DS,i)}sendOpenLink=this.openLink;downloadFile(r,i){return this._assertInitialized("downloadFile"),this.request({method:"ui/download-file",params:r},OS,i)}requestTeardown(r={}){return this.notification({method:"ui/notifications/request-teardown",params:r})}requestDisplayMode(r,i){return this._assertInitialized("requestDisplayMode"),this.request({method:"ui/request-display-mode",params:r},VS,i)}sendSizeChanged(r){return this.notification({method:"ui/notifications/size-changed",params:r})}setupSizeChangedNotifications(){let r=!1,i=0,o=0,t=()=>{r||(r=!0,requestAnimationFrame(()=>{r=!1;let a=document.documentElement,s=a.style.height;a.style.height="max-content";let c=Math.ceil(a.getBoundingClientRect().height);a.style.height=s;let u=Math.ceil(window.innerWidth);(u!==i||c!==o)&&(i=u,o=c,this.sendSizeChanged({width:u,height:c}))}))};t();let n=new ResizeObserver(t);return n.observe(document.documentElement),n.observe(document.body),()=>n.disconnect()}async connect(r=new bf(window.parent,window.parent),i){if(this.transport)throw Error("App is already connected. Call close() before connecting again.");this._initializedSent=!1,await super.connect(r);try{let o=await this.request({method:"ui/initialize",params:{appCapabilities:this._capabilities,appInfo:this._appInfo,protocolVersion:wS}},BS,i);if(o===void 0)throw Error(`Server sent invalid initialize result: ${o}`);this._hostCapabilities=o.hostCapabilities,this._hostInfo=o.hostInfo,this._hostContext=o.hostContext,await this.notification({method:"ui/notifications/initialized"}),this._initializedSent=!0,this.options?.autoResize&&this.setupSizeChangedNotifications()}catch(o){throw this.close(),o}}};var Xe=document.querySelector("#app"),pr=document.querySelector("#frame"),Wi=document.querySelector("#device"),ty=document.querySelector("#overlay"),KS=document.querySelector("#overlay-text"),WS=document.querySelector("#overlay-detail"),GS=document.querySelector("#status-text"),qi=document.querySelector("#notice"),Bi=document.querySelector("#pointer"),hr=Object.fromEntries(["refresh","back","home","copy"].map(e=>[e,document.getElementById(e)])),ny=window.__ANDROID_USE_STANDALONE__===!0,fr=ny?void 0:new ac({name:"Android Use Screen",version:"0.6.2"},{availableDisplayModes:["fullscreen"]},{autoResize:!1}),Le,un=0,cc="",zf=!1,kf=!1,lt=!1,Sf=!1,dt,Hi="",Ze=0,iy=!1,uc=!1,QS=5e3,cn,Ge,Ki,lc=document.querySelector("#settings"),dc=document.querySelector("#jev-settings"),Ye=document.querySelector("#jev-key"),jt=document.querySelector("#jev-message"),wf=document.querySelector("#jev-enable"),mc=document.querySelector("#jev-test"),Gi=document.querySelector("#jev-disable"),Qi=document.querySelector("#jev-clear"),Tt=document.querySelector("#jev-images"),Qe,Be=!1,XS={connecting:"\u8FDE\u63A5\u4E2D",live:"Live",buffering:"\u7F13\u51B2\u4E2D",paused:"\u5DF2\u6682\u505C",offline:"\u672A\u8FDE\u63A5",unsupported:"\u4E0D\u652F\u6301\u9884\u89C8"};function gr(e,r=""){Ki&&clearTimeout(Ki),qi.textContent=e,qi.title=r,Ki=setTimeout(()=>{qi.textContent="",qi.title=""},3e3)}function Te(e,r,i){Xe.dataset.state=e,GS.textContent=XS[e],ty.hidden=e==="live"||e==="buffering",ty.hidden||(KS.textContent=r??"\u6B63\u5728\u8FDE\u63A5\u624B\u673A\u2026",WS.textContent=i??"\u5B9E\u65F6\u89C6\u9891\u5C06\u5728\u8FD9\u91CC\u663E\u793A");for(let o of["home","back","copy"])hr[o].disabled=lt||e!=="live";hr.refresh.disabled=lt}async function eo(e,r={}){if(ny){let o=await fetch(`api/${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r),signal:AbortSignal.timeout(e==="action"?2e4:8e3)});if(!o.ok){if(e==="action"&&String(r.action).startsWith("jev_"))try{let t=await o.json();if(t?.error?.code)return t}catch{}throw new Error("preview_unreachable")}return o.json()}return(await fr.callServerTool({name:e==="frame"?"aua_screen_frame":"aua_screen_action",arguments:e==="frame"?r:e==="refresh"?{action:"refresh"}:r},{timeout:e==="action"?2e4:8e3})).structuredContent}function Xi(e){Qe=e,lc.dataset.enabled=String(e.enabled),document.querySelector("#jev-state").textContent=e.demo?"\u6587\u6863\u793A\u4F8B\uFF0C\u8BF7\u5728\u5B9E\u9645\u624B\u673A\u5C4F\u5E55\u4E2D\u914D\u7F6E":e.enabled?"Jev \u5DF2\u542F\u7528":e.configured?"\u5DF2\u914D\u7F6E Key\uFF0CJev \u672A\u542F\u7528":"\u5C1A\u672A\u914D\u7F6E\uFF0C\u586B\u5165 Key \u5373\u53EF\u5F00\u59CB",document.querySelector("#jev-provider").textContent=`${e.model} \xB7 ${e.base_url}`,Ye.placeholder=e.configured?"\u5DF2\u6709 Key\uFF0C\u7559\u7A7A\u7EE7\u7EED\u4F7F\u7528":"\u7C98\u8D34\u4F60\u7684 API Key",Ye.disabled=!!e.demo||Be,wf.disabled=!!e.demo||Be||!e.configured&&!Ye.value.trim(),mc.disabled=!e.configured||!!e.demo||Be,Gi.hidden=!e.enabled,Qi.hidden=!e.has_saved_key,Gi.disabled=Be,Qi.disabled=Be,Tt.checked=!!e.images_enabled,Tt.disabled=!!e.demo||Be}function YS(e){return e?.error?.code==="jev_http_error"?e.error.status===401?"Key \u65E0\u6548\u6216\u5DF2\u5931\u6548":e.error.status===429?"\u8BF7\u6C42\u8FC7\u4E8E\u9891\u7E41\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5":"\u670D\u52A1\u62D2\u7EDD\u8BF7\u6C42\uFF0C\u8BF7\u68C0\u67E5 Key \u6743\u9650\u548C\u8D26\u6237\u72B6\u6001":{jev_configuration:"\u8BF7\u586B\u5199\u6709\u6548\u7684 TypeSafe API Key",jev_transport_error:"\u65E0\u6CD5\u8FDE\u63A5 TypeSafe\uFF0C\u8BF7\u68C0\u67E5\u7F51\u7EDC\u540E\u91CD\u8BD5",jev_settings_unavailable:"\u65E0\u6CD5\u8BFB\u53D6\u6216\u4FDD\u5B58\u672C\u673A\u8BBE\u7F6E\uFF0C\u8BF7\u68C0\u67E5\u6587\u4EF6\u6743\u9650",jev_validation_failed:"\u8FDE\u63A5\u6D4B\u8BD5\u672A\u901A\u8FC7\uFF0C\u8BBE\u7F6E\u5C1A\u672A\u66F4\u6539",device_busy:"\u53E6\u4E00\u9879\u8BBE\u7F6E\u64CD\u4F5C\u6B63\u5728\u8FDB\u884C\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5"}[e?.error?.code||""]||"\u8BBE\u7F6E\u64CD\u4F5C\u672A\u5B8C\u6210\uFF0C\u8BF7\u91CD\u65B0\u6253\u5F00\u8BBE\u7F6E\u540E\u91CD\u8BD5"}async function to(e){if(!(Be||!Qe||Qe.demo)){Be=!0,jt.textContent=e==="jev_save"?"\u6B63\u5728\u9A8C\u8BC1 Key\u2026":e==="jev_test"?"\u6B63\u5728\u6D4B\u8BD5\u8FDE\u63A5\u2026":"\u6B63\u5728\u66F4\u65B0\u8BBE\u7F6E\u2026",jt.dataset.error="false",Ye.disabled=!0,lc.disabled=!0,document.querySelector("#settings-close").disabled=!0;for(let r of[wf,mc,Gi,Qi,Tt])r.disabled=!0;try{let r=await eo("action",{action:e,...e==="jev_save"?{api_key:Ye.value}:{}});if(!r?.ok){jt.textContent=YS(r),jt.dataset.error="true";return}e.startsWith("jev_images")||(Ye.value=""),Xi(r),jt.textContent=r.tested?`${e==="jev_save"?"\u5DF2\u4FDD\u5B58\u5E76\u542F\u7528":"\u8FDE\u63A5\u6B63\u5E38"} \xB7 ${r.latency_ms} ms`:e==="jev_images_on"?"\u5DF2\u5141\u8BB8\u53D1\u9001\u622A\u56FE":e==="jev_images_off"?"\u5DF2\u5173\u95ED\u622A\u56FE\u53D1\u9001":e==="jev_clear"?"\u672C\u673A Key \u5DF2\u79FB\u9664\uFF0CJev \u5DF2\u505C\u7528":"Jev \u5DF2\u505C\u7528"}catch{jt.textContent="\u65E0\u6CD5\u8FDE\u63A5\u672C\u673A\u8BBE\u7F6E\u670D\u52A1\uFF0C\u8BF7\u91CD\u65B0\u6253\u5F00\u624B\u673A\u5C4F\u5E55",jt.dataset.error="true"}finally{Be=!1,lc.disabled=!1,document.querySelector("#settings-close").disabled=!1,Qe&&Xi(Qe)}}}lc.onclick=()=>{Be||(Qe=void 0,Ye.value="",Ye.disabled=!0,jt.textContent="",dc.showModal(),wf.disabled=!0,mc.disabled=!0,Gi.hidden=!0,Qi.hidden=!0,Tt.disabled=!0,Tt.checked=!1,eo("action",{action:"jev_status"}).then(e=>{if(!e?.ok)throw new Error("settings_unavailable");Xi(e)}).catch(()=>{document.querySelector("#jev-state").textContent="\u65E0\u6CD5\u8BFB\u53D6\u8BBE\u7F6E\uFF0C\u8BF7\u91CD\u65B0\u6253\u5F00\u624B\u673A\u5C4F\u5E55"}))};document.querySelector("#jev-form").onsubmit=e=>{e.preventDefault(),to("jev_save")};Tt.onchange=()=>{let e=Tt.checked;Qe&&(Tt.checked=!!Qe.images_enabled),to(e?"jev_images_on":"jev_images_off")};mc.onclick=()=>void to("jev_test");Gi.onclick=()=>void to("jev_disable");Qi.onclick=()=>void to("jev_clear");document.querySelector("#settings-close").onclick=()=>dc.close();dc.addEventListener("close",()=>{Ye.value=""});dc.addEventListener("cancel",e=>{Be&&e.preventDefault()});Ye.oninput=()=>{Qe&&Xi(Qe)};function mr(){Ze++,pr.removeAttribute("src"),Hi="",un=0}function Ji(e,r=!1,i=!1){cn??=performance.now();let o=performance.now()-cn>=QS;if(!o&&r&&Hi){Te("buffering");return}o&&mr(),Te(o?"offline":"connecting",o?i?"\u672C\u5730\u9884\u89C8\u670D\u52A1\u672A\u54CD\u5E94":"\u89C6\u9891\u6682\u4E0D\u53EF\u7528":e,o?i?"\u6B63\u5728\u81EA\u52A8\u91CD\u8BD5\uFF1B\u82E5\u6301\u7EED\u5931\u8D25\uFF0C\u8BF7\u8BA9 Agent \u91CD\u65B0\u6253\u5F00\u624B\u673A\u5C4F\u5E55":"\u6B63\u5728\u81EA\u52A8\u91CD\u8BD5\uFF0C\u4E5F\u53EF\u70B9\u51FB\u300C\u91CD\u8FDE\u300D":"\u6B63\u5728\u81EA\u52A8\u6062\u590D\uFF0C\u65E0\u9700\u624B\u52A8\u91CD\u8FDE")}function ry(){let e=Le?.interaction_ready===!1?"buffering":"live";Te(e),e==="live"&&uc&&(uc=!1,gr("\u5DF2\u91CD\u65B0\u8FDE\u63A5"))}function oy(e){if(!e?.ok)throw new Error("preview_unreachable");if(Le=e,document.querySelector("#model").textContent=e.device?.model||"Android",cc!==e.stream_id&&(cc=e.stream_id,mr(),Ge=void 0),e.paused){mr(),Ge=void 0,cn=void 0,Te("paused","\u8BF7\u5728\u624B\u673A\u4E0A\u63A5\u7BA1\u64CD\u4F5C",e.pause_reason==="device_locked"?"\u624B\u673A\u5DF2\u9501\u5B9A\uFF0C\u89E3\u9501\u540E\u81EA\u52A8\u6062\u590D":"\u8BA4\u8BC1\u5B8C\u6210\u540E\u7531 agent \u6062\u590D\u9884\u89C8");return}if(!e.connected){mr(),Te("offline","\u624B\u673A\u672A\u8FDE\u63A5","\u8BF7\u68C0\u67E5 USB \u6216\u65E0\u7EBF ADB \u8FDE\u63A5");return}if(e.error==="video_stream_ended"){Ge===void 0&&(Ge=e.seq,Ze++),Ji("\u6B63\u5728\u6062\u590D\u89C6\u9891\u2026",!0);return}if(e.error==="preview_unsupported_device"){mr(),Te("unsupported","\u6B64\u624B\u673A\u4E0D\u652F\u6301\u5B9E\u65F6\u9884\u89C8","\u7CFB\u7EDF\u672A\u63D0\u4F9B screenrecord\uFF1B\u622A\u56FE\u3001\u8BFB\u5C4F\u548C\u64CD\u4F5C\u4ECD\u53EF\u6B63\u5E38\u4F7F\u7528");return}if(e.error){mr(),Te("offline","\u89C6\u9891\u8FDE\u63A5\u6682\u4E0D\u53EF\u7528",e.error==="preview_dependency_missing"?"\u8BF7\u5B89\u88C5 ffmpeg \u540E\u91CD\u8FDE":"\u6B63\u5728\u81EA\u52A8\u91CD\u8BD5\uFF0C\u4E5F\u53EF\u70B9\u51FB\u300C\u91CD\u8FDE\u300D");return}if(Ge!==void 0&&e.seq<=Ge){Ji("\u6B63\u5728\u7B49\u5F85\u65B0\u753B\u9762\u2026",!0);return}let r=e.frame;if(r&&r.seq>un&&r.data&&r.width>0&&r.height>0){un=r.seq;let i=++Ze,o=`data:${r.mimeType};base64,${r.data}`,t=new Image;t.onload=()=>{zf||Sf||i!==Ze||Le?.paused||(Hi=o,pr.src=o,Wi.style.aspectRatio=`${r.width}/${r.height}`,Xe.style.setProperty("--screen-ratio",String(r.width/r.height)),Xe.dataset.orientation=r.width>r.height?"landscape":"portrait",Xe.dataset.frameSeq=String(un),cn=void 0,Ge=void 0,ry())},t.onerror=()=>Te("offline","\u753B\u9762\u89E3\u7801\u5931\u8D25","\u70B9\u51FB\u300C\u91CD\u8FDE\u300D\u91CD\u8BD5"),t.src=o}else e.frame_available&&Hi?(cn=void 0,ry()):Hi?(Ge===void 0&&(Ge=e.seq,Ze++),Ji("\u6B63\u5728\u7B49\u5F85\u65B0\u753B\u9762\u2026",!0)):cn!==void 0?Ji("\u6B63\u5728\u7B49\u5F85\u65B0\u753B\u9762\u2026"):Te("connecting","\u6B63\u5728\u8FDE\u63A5\u89C6\u9891\u2026","\u901A\u8FC7 ADB \u89C6\u9891\u901A\u9053\u4F20\u8F93")}var sc=()=>!zf&&!Sf&&document.visibilityState!=="hidden";function dn(e=150){dt&&clearTimeout(dt),sc()&&(dt=setTimeout(ew,e))}async function ew(){if(!sc()||kf)return;kf=!0;let e=Ze;try{let r=await eo("frame",{after_seq:un});sc()&&e===Ze&&oy(r)}catch{sc()&&e===Ze&&(mr(),Ji("\u89C6\u9891\u8FDE\u63A5\u6062\u590D\u4E2D\u2026",!1,!0))}finally{kf=!1,dn(Le?.paused?500:Xe.dataset.state==="offline"?1e3:150)}}async function Yi(e,r={}){if(!(lt||Le?.paused)){lt=!0,qi.textContent="";for(let i of Object.values(hr))i.disabled=!0;e==="refresh"&&(uc=!0,Ge=un,Ze++,gr("\u6B63\u5728\u91CD\u8FDE\u2026"));try{let i=await eo(e==="refresh"?"refresh":"action",{action:e,...r});if(!i?.ok)throw new Error(i?.error?.code||"action_failed");e==="refresh"&&oy(i)}catch(i){e==="refresh"&&(uc=!1,gr(String(i).includes("device_busy")?"\u624B\u673A\u6B63\u5728\u64CD\u4F5C\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5":"\u91CD\u8FDE\u5C1A\u672A\u5B8C\u6210\uFF0C\u8BF7\u8BA9 Agent \u91CD\u65B0\u6253\u5F00\u624B\u673A\u5C4F\u5E55"))}finally{lt=!1,Te(Xe.dataset.state||"connecting"),dn(50)}}}hr.refresh.onclick=()=>{if(Le?.paused){gr("\u63A5\u7BA1\u671F\u95F4\u4FDD\u6301\u6682\u505C");return}Yi("refresh")};hr.home.onclick=()=>void Yi("home");hr.back.onclick=()=>void Yi("back");hr.copy.onclick=()=>{if(lt||Le?.paused||Xe.dataset.state!=="live"||!pr.naturalWidth)return;if(!navigator.clipboard?.write||typeof ClipboardItem>"u"){gr("\u5F53\u524D\u73AF\u5883\u4E0D\u652F\u6301\u590D\u5236\u56FE\u7247");return}let e=document.createElement("canvas");e.width=pr.naturalWidth,e.height=pr.naturalHeight;let r=e.getContext("2d");if(!r)return;r.drawImage(pr,0,0);let i=new Promise((o,t)=>e.toBlob(n=>n?o(n):t(new Error("encode_failed")),"image/png"));lt=!0,Te(Xe.dataset.state||"live"),navigator.clipboard.write([new ClipboardItem({"image/png":i})]).then(()=>gr("\u753B\u9762\u5DF2\u590D\u5236")).catch(()=>gr("\u590D\u5236\u5931\u8D25\uFF0C\u8BF7\u5141\u8BB8\u5199\u5165\u526A\u8D34\u677F")).finally(()=>{lt=!1,Te(Xe.dataset.state||"live")})};var ln;function ay(e){if(Xe.dataset.state!=="live"||lt||!Le?.viewport)return;let r=pr.getBoundingClientRect(),[i,o]=Le.viewport;if(!(Math.abs(r.width/r.height-i/o)>.08))return[Math.max(0,Math.min(i-1,Math.round((e.clientX-r.left)/r.width*i))),Math.max(0,Math.min(o-1,Math.round((e.clientY-r.top)/r.height*o)))]}Wi.onpointerdown=e=>{let r=ay(e);!r||!Le?.viewport||(ln={x:r[0],y:r[1],at:performance.now(),stream:cc,size:[...Le.viewport]},Wi.setPointerCapture(e.pointerId),Bi.style.display="block",Bi.style.left=`${r[0]/ln.size[0]*100}%`,Bi.style.top=`${r[1]/ln.size[1]*100}%`)};Wi.onpointerup=e=>{Bi.style.display="none";let r=ln;ln=void 0;let i=ay(e);if(!r||!i||r.stream!==cc||r.size.join()!==Le?.viewport?.join())return;let o=i[0]-r.x,t=i[1]-r.y;Math.hypot(o,t)<20?Yi("tap",{x:i[0],y:i[1]}):Yi("swipe",{direction:Math.abs(o)>Math.abs(t)?o>0?"right":"left":t>0?"down":"up"})};Wi.onpointercancel=()=>{ln=void 0,Bi.style.display="none"};document.addEventListener("visibilitychange",()=>{document.hidden?(Ze++,dt&&clearTimeout(dt)):dn(0)});window.addEventListener("pagehide",()=>{zf=!0,Ze++,dt&&clearTimeout(dt),Ki&&clearTimeout(Ki)});fr&&(fr.ontoolresult=()=>{iy&&dn(0)},fr.onhostcontextchanged=e=>{let r=e.displayMode==="inline";Sf=r,r?(Ze++,dt&&clearTimeout(dt)):dn(0)});async function tw(){Te("connecting");try{if(fr){await fr.connect(void 0,{timeout:8e3});try{await fr.requestDisplayMode({mode:"fullscreen"},{timeout:3e3})}catch{}}iy=!0,dn(0),eo("action",{action:"jev_status"}).then(e=>{e?.ok&&Xi(e)}).catch(()=>{})}catch{Te("offline","\u65E0\u6CD5\u8FDE\u63A5\u5BBF\u4E3B","\u8BF7\u91CD\u65B0\u6253\u5F00 Android \u624B\u673A\u5C4F\u5E55")}}tw();
+container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:d.string().optional().describe("User's language and region preference in BCP 47 format."),timeZone:d.string().optional().describe("User's timezone in IANA format."),userAgent:d.string().optional().describe("Host application identifier."),platform:d.union([d.literal("web"),d.literal("desktop"),d.literal("mobile")]).optional().describe("Platform type for responsive design decisions."),deviceCapabilities:d.object({touch:d.boolean().optional().describe("Whether the device supports touch input."),hover:d.boolean().optional().describe("Whether the device supports hover interactions.")}).optional().describe("Device input capabilities."),safeAreaInsets:d.object({top:d.number().describe("Top safe area inset in pixels."),right:d.number().describe("Right safe area inset in pixels."),bottom:d.number().describe("Bottom safe area inset in pixels."),left:d.number().describe("Left safe area inset in pixels.")}).optional().describe("Mobile safe area boundaries in pixels.")}).passthrough(),JS=d.object({method:d.literal("ui/notifications/host-context-changed"),params:ey.describe("Partial context update containing only changed fields.")}),nN=d.object({method:d.literal("ui/update-model-context"),params:d.object({content:d.array(an).optional().describe("Context content blocks (text, image, etc.)."),structuredContent:d.record(d.string(),d.unknown().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.")})}),iN=d.object({method:d.literal("ui/initialize"),params:d.object({appInfo:Ei.describe("App identification (name and version)."),appCapabilities:MS.describe("Features and capabilities this app provides."),protocolVersion:d.string().describe("Protocol version this app supports.")})}),BS=d.object({protocolVersion:d.string().describe('Negotiated protocol version string (e.g., "2025-11-21").'),hostInfo:Ei.describe("Host application identification and version."),hostCapabilities:LS.describe("Features and capabilities provided by the host."),hostContext:ey.describe("Rich context about the host environment.")}).passthrough(),HS={target:"draft-2020-12"};async function X$(e,r){let i=e["~standard"];if(i.jsonSchema)return i.jsonSchema[r](HS);if(i.vendor==="zod"){let{z:o}=await Promise.resolve().then(()=>(Oi(),Qp));return o.toJSONSchema(e,{io:r})}throw Error(`Schema (vendor: ${i.vendor}) does not implement Standard JSON Schema (~standard.jsonSchema). Use a library that does (zod v4, ArkType, Valibot) or wrap your schema accordingly.`)}async function Y$(e,r,i=""){let o=await e["~standard"].validate(r);if(o.issues){let t=o.issues.map(n=>{let a=n.path?.map(s=>typeof s=="object"?s.key:s).join(".");return a?`${a}: ${n.message}`:n.message}).join("; ");throw Error(i+t)}return o.value}var ac=class e extends yf{_appInfo;_capabilities;options;_hostCapabilities;_hostInfo;_hostContext;_registeredTools={};_initializedSent=!1;_assertInitialized(r){if(this._initializedSent)return;let i=`[ext-apps] App.${r}() called before connect() completed the ui/initialize handshake. Await app.connect() before calling this method, or move data loading to an ontoolresult handler.`;if(this.options?.strict)throw Error(i);console.warn(`${i}. This will throw in a future release.`)}eventSchemas={toolinput:AS,toolinputpartial:US,toolresult:qS,toolcancelled:ES,hostcontextchanged:JS};static ONE_SHOT_EVENTS=new Set(["toolinput","toolinputpartial","toolresult","toolcancelled"]);_everHadListener=new Set;_assertHandlerTiming(r){if(!e.ONE_SHOT_EVENTS.has(r)||this._everHadListener.has(r)||(this._everHadListener.add(r),!this._initializedSent))return;let i=`[ext-apps] "${String(r)}" handler registered after connect() completed the ui/initialize handshake. The host may have already sent this notification. Register handlers before calling app.connect().`;if(this.options?.strict)throw Error(i);console.warn(i)}setEventHandler(r,i){i&&this._assertHandlerTiming(r),super.setEventHandler(r,i)}addEventListener(r,i){this._assertHandlerTiming(r),super.addEventListener(r,i)}onEventDispatch(r,i){r==="hostcontextchanged"&&(this._hostContext={...this._hostContext,...i})}constructor(r,i={},o={autoResize:!0}){super(o),this._appInfo=r,this._capabilities=i,this.options=o,o.allowUnsafeEval||d.config({jitless:!0}),this.setRequestHandler(nn,t=>(console.log("Received ping:",t.params),{})),this.setEventHandler("hostcontextchanged",void 0)}registerCapabilities(r){if(this.transport)throw Error("Cannot register capabilities after transport is established");this._capabilities=G$(this._capabilities,r)}registerTool(r,i,o){if(this._registeredTools[r])throw Error(`Tool ${r} is already registered`);let t=this,n=()=>{t._initializedSent&&t._capabilities.tools?.listChanged&&t.sendToolListChanged()},a=i.inputSchema!==void 0,s={title:i.title,description:i.description,inputSchema:i.inputSchema,outputSchema:i.outputSchema,annotations:i.annotations,_meta:i._meta,enabled:!0,enable(){this.enabled=!0,n()},disable(){this.enabled=!1,n()},update(c){Object.assign(this,c),n()},remove(){t._registeredTools[r]===s&&(delete t._registeredTools[r],n())},handler:async(c,u)=>{if(!s.enabled)throw Error(`Tool ${r} is disabled`);let l;if(a){let m=s.inputSchema,p=m?await Y$(m,c??{},`Invalid input for tool ${r}: `):c??{};l=await o(p,u)}else l=await o(u);return s.outputSchema&&!l.isError&&(l.structuredContent=await Y$(s.outputSchema,l.structuredContent,`Invalid output for tool ${r}: `)),l}};return this._registeredTools[r]=s,!this._capabilities.tools&&!this.transport&&this.registerCapabilities({tools:{listChanged:!0}}),this.ensureToolHandlersInitialized(),n(),s}_toolHandlersInitialized=!1;ensureToolHandlersInitialized(){this._toolHandlersInitialized||(this._toolHandlersInitialized=!0,this.oncalltool=async(r,i)=>{let o=this._registeredTools[r.name];if(!o)throw Error(`Tool ${r.name} not found`);return o.handler(r.arguments,i)},this.onlisttools=async(r,i)=>({tools:await Promise.all(Object.entries(this._registeredTools).filter(([o,t])=>t.enabled).map(async([o,t])=>{let n={name:o,title:t.title,description:t.description,inputSchema:t.inputSchema?await X$(t.inputSchema,"input"):{type:"object",properties:{}}};return t.outputSchema&&(n.outputSchema=await X$(t.outputSchema,"output")),t.annotations&&(n.annotations=t.annotations),t._meta&&(n._meta=t._meta),n}))}))}async sendToolListChanged(r={}){this._assertInitialized("sendToolListChanged"),await this.notification({method:"notifications/tools/list_changed",params:r})}getHostCapabilities(){return this._hostCapabilities}getHostVersion(){return this._hostInfo}getHostContext(){return this._hostContext}get ontoolinput(){return this.getEventHandler("toolinput")}set ontoolinput(r){this.setEventHandler("toolinput",r)}get ontoolinputpartial(){return this.getEventHandler("toolinputpartial")}set ontoolinputpartial(r){this.setEventHandler("toolinputpartial",r)}get ontoolresult(){return this.getEventHandler("toolresult")}set ontoolresult(r){this.setEventHandler("toolresult",r)}get ontoolcancelled(){return this.getEventHandler("toolcancelled")}set ontoolcancelled(r){this.setEventHandler("toolcancelled",r)}get onhostcontextchanged(){return this.getEventHandler("hostcontextchanged")}set onhostcontextchanged(r){this.setEventHandler("hostcontextchanged",r)}_onteardown;get onteardown(){return this._onteardown}set onteardown(r){this.warnIfRequestHandlerReplaced("onteardown",this._onteardown,r),this._onteardown=r,this.replaceRequestHandler(ZS,(i,o)=>{if(!this._onteardown)throw Error("No onteardown handler set");return this._onteardown(i.params,o)})}_oncalltool;get oncalltool(){return this._oncalltool}set oncalltool(r){this.warnIfRequestHandlerReplaced("oncalltool",this._oncalltool,r),this._oncalltool=r,this.replaceRequestHandler(ff,(i,o)=>{if(!this._oncalltool)throw Error("No oncalltool handler set");return this._oncalltool(i.params,o)})}_onlisttools;get onlisttools(){return this._onlisttools}set onlisttools(r){this.warnIfRequestHandlerReplaced("onlisttools",this._onlisttools,r),this._onlisttools=r,this.replaceRequestHandler(pf,(i,o)=>{if(!this._onlisttools)throw Error("No onlisttools handler set");return this._onlisttools(i.params,o)})}assertCapabilityForMethod(r){switch(r){case"sampling/createMessage":if(!this._hostCapabilities?.sampling)throw Error(`Host does not support sampling (required for ${r})`);break}}assertRequestHandlerCapability(r){switch(r){case"tools/call":case"tools/list":if(!this._capabilities.tools)throw Error(`Client does not support tool capability (required for ${r})`);return;case"ping":case"ui/resource-teardown":return;default:throw Error(`No handler for method ${r} registered`)}}assertNotificationCapability(r){}assertTaskCapability(r){throw Error("Tasks are not supported in MCP Apps")}assertTaskHandlerCapability(r){throw Error("Task handlers are not supported in MCP Apps")}async callServerTool(r,i){if(this._assertInitialized("callServerTool"),typeof r=="string")throw Error(`callServerTool() expects an object as its first argument, but received a string ("${r}"). Did you mean: callServerTool({ name: "${r}", arguments: { ... } })?`);return await this.request({method:"tools/call",params:r},sn,{onprogress:()=>{},resetTimeoutOnProgress:!0,...i})}async readServerResource(r,i){return this._assertInitialized("readServerResource"),await this.request({method:"resources/read",params:r},sf,i)}async listServerResources(r,i){return this._assertInitialized("listServerResources"),await this.request({method:"resources/list",params:r},of,i)}async createSamplingMessage(r,i){this._assertInitialized("createSamplingMessage");let o=r.tools?hf:gf;return await this.request({method:"sampling/createMessage",params:r},o,i)}sendMessage(r,i){return this._assertInitialized("sendMessage"),this.request({method:"ui/message",params:r},NS,i)}sendLog(r){return this.notification({method:"notifications/message",params:r})}updateModelContext(r,i){return this._assertInitialized("updateModelContext"),this.request({method:"ui/update-model-context",params:r},Ks,i)}openLink(r,i){return this._assertInitialized("openLink"),this.request({method:"ui/open-link",params:r},DS,i)}sendOpenLink=this.openLink;downloadFile(r,i){return this._assertInitialized("downloadFile"),this.request({method:"ui/download-file",params:r},OS,i)}requestTeardown(r={}){return this.notification({method:"ui/notifications/request-teardown",params:r})}requestDisplayMode(r,i){return this._assertInitialized("requestDisplayMode"),this.request({method:"ui/request-display-mode",params:r},VS,i)}sendSizeChanged(r){return this.notification({method:"ui/notifications/size-changed",params:r})}setupSizeChangedNotifications(){let r=!1,i=0,o=0,t=()=>{r||(r=!0,requestAnimationFrame(()=>{r=!1;let a=document.documentElement,s=a.style.height;a.style.height="max-content";let c=Math.ceil(a.getBoundingClientRect().height);a.style.height=s;let u=Math.ceil(window.innerWidth);(u!==i||c!==o)&&(i=u,o=c,this.sendSizeChanged({width:u,height:c}))}))};t();let n=new ResizeObserver(t);return n.observe(document.documentElement),n.observe(document.body),()=>n.disconnect()}async connect(r=new bf(window.parent,window.parent),i){if(this.transport)throw Error("App is already connected. Call close() before connecting again.");this._initializedSent=!1,await super.connect(r);try{let o=await this.request({method:"ui/initialize",params:{appCapabilities:this._capabilities,appInfo:this._appInfo,protocolVersion:wS}},BS,i);if(o===void 0)throw Error(`Server sent invalid initialize result: ${o}`);this._hostCapabilities=o.hostCapabilities,this._hostInfo=o.hostInfo,this._hostContext=o.hostContext,await this.notification({method:"ui/notifications/initialized"}),this._initializedSent=!0,this.options?.autoResize&&this.setupSizeChangedNotifications()}catch(o){throw this.close(),o}}};var Xe=document.querySelector("#app"),pr=document.querySelector("#frame"),Wi=document.querySelector("#device"),ty=document.querySelector("#overlay"),KS=document.querySelector("#overlay-text"),WS=document.querySelector("#overlay-detail"),GS=document.querySelector("#status-text"),qi=document.querySelector("#notice"),Bi=document.querySelector("#pointer"),hr=Object.fromEntries(["refresh","back","home","copy"].map(e=>[e,document.getElementById(e)])),ny=window.__ANDROID_USE_STANDALONE__===!0,fr=ny?void 0:new ac({name:"Android Use Screen",version:"0.7.0"},{availableDisplayModes:["fullscreen"]},{autoResize:!1}),Le,un=0,cc="",zf=!1,kf=!1,lt=!1,Sf=!1,dt,Hi="",Ze=0,iy=!1,uc=!1,QS=5e3,cn,Ge,Ki,lc=document.querySelector("#settings"),dc=document.querySelector("#jev-settings"),Ye=document.querySelector("#jev-key"),jt=document.querySelector("#jev-message"),wf=document.querySelector("#jev-enable"),mc=document.querySelector("#jev-test"),Gi=document.querySelector("#jev-disable"),Qi=document.querySelector("#jev-clear"),Tt=document.querySelector("#jev-images"),Qe,Be=!1,XS={connecting:"\u8FDE\u63A5\u4E2D",live:"Live",buffering:"\u7F13\u51B2\u4E2D",paused:"\u5DF2\u6682\u505C",offline:"\u672A\u8FDE\u63A5",unsupported:"\u4E0D\u652F\u6301\u9884\u89C8"};function gr(e,r=""){Ki&&clearTimeout(Ki),qi.textContent=e,qi.title=r,Ki=setTimeout(()=>{qi.textContent="",qi.title=""},3e3)}function Te(e,r,i){Xe.dataset.state=e,GS.textContent=XS[e],ty.hidden=e==="live"||e==="buffering",ty.hidden||(KS.textContent=r??"\u6B63\u5728\u8FDE\u63A5\u624B\u673A\u2026",WS.textContent=i??"\u5B9E\u65F6\u89C6\u9891\u5C06\u5728\u8FD9\u91CC\u663E\u793A");for(let o of["home","back","copy"])hr[o].disabled=lt||e!=="live";hr.refresh.disabled=lt}async function eo(e,r={}){if(ny){let o=await fetch(`api/${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r),signal:AbortSignal.timeout(e==="action"?2e4:8e3)});if(!o.ok){if(e==="action"&&String(r.action).startsWith("jev_"))try{let t=await o.json();if(t?.error?.code)return t}catch{}throw new Error("preview_unreachable")}return o.json()}return(await fr.callServerTool({name:e==="frame"?"aua_screen_frame":"aua_screen_action",arguments:e==="frame"?r:e==="refresh"?{action:"refresh"}:r},{timeout:e==="action"?2e4:8e3})).structuredContent}function Xi(e){Qe=e,lc.dataset.enabled=String(e.enabled),document.querySelector("#jev-state").textContent=e.demo?"\u6587\u6863\u793A\u4F8B\uFF0C\u8BF7\u5728\u5B9E\u9645\u624B\u673A\u5C4F\u5E55\u4E2D\u914D\u7F6E":e.enabled?"Jev \u5DF2\u542F\u7528":e.configured?"\u5DF2\u914D\u7F6E Key\uFF0CJev \u672A\u542F\u7528":"\u5C1A\u672A\u914D\u7F6E\uFF0C\u586B\u5165 Key \u5373\u53EF\u5F00\u59CB",document.querySelector("#jev-provider").textContent=`${e.model} \xB7 ${e.base_url}`,Ye.placeholder=e.configured?"\u5DF2\u6709 Key\uFF0C\u7559\u7A7A\u7EE7\u7EED\u4F7F\u7528":"\u7C98\u8D34\u4F60\u7684 API Key",Ye.disabled=!!e.demo||Be,wf.disabled=!!e.demo||Be||!e.configured&&!Ye.value.trim(),mc.disabled=!e.configured||!!e.demo||Be,Gi.hidden=!e.enabled,Qi.hidden=!e.has_saved_key,Gi.disabled=Be,Qi.disabled=Be,Tt.checked=!!e.images_enabled,Tt.disabled=!!e.demo||Be}function YS(e){return e?.error?.code==="jev_http_error"?e.error.status===401?"Key \u65E0\u6548\u6216\u5DF2\u5931\u6548":e.error.status===429?"\u8BF7\u6C42\u8FC7\u4E8E\u9891\u7E41\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5":"\u670D\u52A1\u62D2\u7EDD\u8BF7\u6C42\uFF0C\u8BF7\u68C0\u67E5 Key \u6743\u9650\u548C\u8D26\u6237\u72B6\u6001":{jev_configuration:"\u8BF7\u586B\u5199\u6709\u6548\u7684 TypeSafe API Key",jev_transport_error:"\u65E0\u6CD5\u8FDE\u63A5 TypeSafe\uFF0C\u8BF7\u68C0\u67E5\u7F51\u7EDC\u540E\u91CD\u8BD5",jev_settings_unavailable:"\u65E0\u6CD5\u8BFB\u53D6\u6216\u4FDD\u5B58\u672C\u673A\u8BBE\u7F6E\uFF0C\u8BF7\u68C0\u67E5\u6587\u4EF6\u6743\u9650",jev_validation_failed:"\u8FDE\u63A5\u6D4B\u8BD5\u672A\u901A\u8FC7\uFF0C\u8BBE\u7F6E\u5C1A\u672A\u66F4\u6539",device_busy:"\u53E6\u4E00\u9879\u8BBE\u7F6E\u64CD\u4F5C\u6B63\u5728\u8FDB\u884C\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5"}[e?.error?.code||""]||"\u8BBE\u7F6E\u64CD\u4F5C\u672A\u5B8C\u6210\uFF0C\u8BF7\u91CD\u65B0\u6253\u5F00\u8BBE\u7F6E\u540E\u91CD\u8BD5"}async function to(e){if(!(Be||!Qe||Qe.demo)){Be=!0,jt.textContent=e==="jev_save"?"\u6B63\u5728\u9A8C\u8BC1 Key\u2026":e==="jev_test"?"\u6B63\u5728\u6D4B\u8BD5\u8FDE\u63A5\u2026":"\u6B63\u5728\u66F4\u65B0\u8BBE\u7F6E\u2026",jt.dataset.error="false",Ye.disabled=!0,lc.disabled=!0,document.querySelector("#settings-close").disabled=!0;for(let r of[wf,mc,Gi,Qi,Tt])r.disabled=!0;try{let r=await eo("action",{action:e,...e==="jev_save"?{api_key:Ye.value}:{}});if(!r?.ok){jt.textContent=YS(r),jt.dataset.error="true";return}e.startsWith("jev_images")||(Ye.value=""),Xi(r),jt.textContent=r.tested?`${e==="jev_save"?"\u5DF2\u4FDD\u5B58\u5E76\u542F\u7528":"\u8FDE\u63A5\u6B63\u5E38"} \xB7 ${r.latency_ms} ms`:e==="jev_images_on"?"\u5DF2\u5141\u8BB8\u53D1\u9001\u622A\u56FE":e==="jev_images_off"?"\u5DF2\u5173\u95ED\u622A\u56FE\u53D1\u9001":e==="jev_clear"?"\u672C\u673A Key \u5DF2\u79FB\u9664\uFF0CJev \u5DF2\u505C\u7528":"Jev \u5DF2\u505C\u7528"}catch{jt.textContent="\u65E0\u6CD5\u8FDE\u63A5\u672C\u673A\u8BBE\u7F6E\u670D\u52A1\uFF0C\u8BF7\u91CD\u65B0\u6253\u5F00\u624B\u673A\u5C4F\u5E55",jt.dataset.error="true"}finally{Be=!1,lc.disabled=!1,document.querySelector("#settings-close").disabled=!1,Qe&&Xi(Qe)}}}lc.onclick=()=>{Be||(Qe=void 0,Ye.value="",Ye.disabled=!0,jt.textContent="",dc.showModal(),wf.disabled=!0,mc.disabled=!0,Gi.hidden=!0,Qi.hidden=!0,Tt.disabled=!0,Tt.checked=!1,eo("action",{action:"jev_status"}).then(e=>{if(!e?.ok)throw new Error("settings_unavailable");Xi(e)}).catch(()=>{document.querySelector("#jev-state").textContent="\u65E0\u6CD5\u8BFB\u53D6\u8BBE\u7F6E\uFF0C\u8BF7\u91CD\u65B0\u6253\u5F00\u624B\u673A\u5C4F\u5E55"}))};document.querySelector("#jev-form").onsubmit=e=>{e.preventDefault(),to("jev_save")};Tt.onchange=()=>{let e=Tt.checked;Qe&&(Tt.checked=!!Qe.images_enabled),to(e?"jev_images_on":"jev_images_off")};mc.onclick=()=>void to("jev_test");Gi.onclick=()=>void to("jev_disable");Qi.onclick=()=>void to("jev_clear");document.querySelector("#settings-close").onclick=()=>dc.close();dc.addEventListener("close",()=>{Ye.value=""});dc.addEventListener("cancel",e=>{Be&&e.preventDefault()});Ye.oninput=()=>{Qe&&Xi(Qe)};function mr(){Ze++,pr.removeAttribute("src"),Hi="",un=0}function Ji(e,r=!1,i=!1){cn??=performance.now();let o=performance.now()-cn>=QS;if(!o&&r&&Hi){Te("buffering");return}o&&mr(),Te(o?"offline":"connecting",o?i?"\u672C\u5730\u9884\u89C8\u670D\u52A1\u672A\u54CD\u5E94":"\u89C6\u9891\u6682\u4E0D\u53EF\u7528":e,o?i?"\u6B63\u5728\u81EA\u52A8\u91CD\u8BD5\uFF1B\u82E5\u6301\u7EED\u5931\u8D25\uFF0C\u8BF7\u8BA9 Agent \u91CD\u65B0\u6253\u5F00\u624B\u673A\u5C4F\u5E55":"\u6B63\u5728\u81EA\u52A8\u91CD\u8BD5\uFF0C\u4E5F\u53EF\u70B9\u51FB\u300C\u91CD\u8FDE\u300D":"\u6B63\u5728\u81EA\u52A8\u6062\u590D\uFF0C\u65E0\u9700\u624B\u52A8\u91CD\u8FDE")}function ry(){let e=Le?.interaction_ready===!1?"buffering":"live";Te(e),e==="live"&&uc&&(uc=!1,gr("\u5DF2\u91CD\u65B0\u8FDE\u63A5"))}function oy(e){if(!e?.ok)throw new Error("preview_unreachable");if(Le=e,document.querySelector("#model").textContent=e.device?.model||"Android",cc!==e.stream_id&&(cc=e.stream_id,mr(),Ge=void 0),e.paused){mr(),Ge=void 0,cn=void 0,Te("paused","\u8BF7\u5728\u624B\u673A\u4E0A\u63A5\u7BA1\u64CD\u4F5C",e.pause_reason==="device_locked"?"\u624B\u673A\u5DF2\u9501\u5B9A\uFF0C\u89E3\u9501\u540E\u81EA\u52A8\u6062\u590D":"\u8BA4\u8BC1\u5B8C\u6210\u540E\u7531 agent \u6062\u590D\u9884\u89C8");return}if(!e.connected){mr(),Te("offline","\u624B\u673A\u672A\u8FDE\u63A5","\u8BF7\u68C0\u67E5 USB \u6216\u65E0\u7EBF ADB \u8FDE\u63A5");return}if(e.error==="video_stream_ended"){Ge===void 0&&(Ge=e.seq,Ze++),Ji("\u6B63\u5728\u6062\u590D\u89C6\u9891\u2026",!0);return}if(e.error==="preview_unsupported_device"){mr(),Te("unsupported","\u6B64\u624B\u673A\u4E0D\u652F\u6301\u5B9E\u65F6\u9884\u89C8","\u7CFB\u7EDF\u672A\u63D0\u4F9B screenrecord\uFF1B\u622A\u56FE\u3001\u8BFB\u5C4F\u548C\u64CD\u4F5C\u4ECD\u53EF\u6B63\u5E38\u4F7F\u7528");return}if(e.error){mr(),Te("offline","\u89C6\u9891\u8FDE\u63A5\u6682\u4E0D\u53EF\u7528",e.error==="preview_dependency_missing"?"\u8BF7\u5B89\u88C5 ffmpeg \u540E\u91CD\u8FDE":"\u6B63\u5728\u81EA\u52A8\u91CD\u8BD5\uFF0C\u4E5F\u53EF\u70B9\u51FB\u300C\u91CD\u8FDE\u300D");return}if(Ge!==void 0&&e.seq<=Ge){Ji("\u6B63\u5728\u7B49\u5F85\u65B0\u753B\u9762\u2026",!0);return}let r=e.frame;if(r&&r.seq>un&&r.data&&r.width>0&&r.height>0){un=r.seq;let i=++Ze,o=`data:${r.mimeType};base64,${r.data}`,t=new Image;t.onload=()=>{zf||Sf||i!==Ze||Le?.paused||(Hi=o,pr.src=o,Wi.style.aspectRatio=`${r.width}/${r.height}`,Xe.style.setProperty("--screen-ratio",String(r.width/r.height)),Xe.dataset.orientation=r.width>r.height?"landscape":"portrait",Xe.dataset.frameSeq=String(un),cn=void 0,Ge=void 0,ry())},t.onerror=()=>Te("offline","\u753B\u9762\u89E3\u7801\u5931\u8D25","\u70B9\u51FB\u300C\u91CD\u8FDE\u300D\u91CD\u8BD5"),t.src=o}else e.frame_available&&Hi?(cn=void 0,ry()):Hi?(Ge===void 0&&(Ge=e.seq,Ze++),Ji("\u6B63\u5728\u7B49\u5F85\u65B0\u753B\u9762\u2026",!0)):cn!==void 0?Ji("\u6B63\u5728\u7B49\u5F85\u65B0\u753B\u9762\u2026"):Te("connecting","\u6B63\u5728\u8FDE\u63A5\u89C6\u9891\u2026","\u901A\u8FC7 ADB \u89C6\u9891\u901A\u9053\u4F20\u8F93")}var sc=()=>!zf&&!Sf&&document.visibilityState!=="hidden";function dn(e=150){dt&&clearTimeout(dt),sc()&&(dt=setTimeout(ew,e))}async function ew(){if(!sc()||kf)return;kf=!0;let e=Ze;try{let r=await eo("frame",{after_seq:un});sc()&&e===Ze&&oy(r)}catch{sc()&&e===Ze&&(mr(),Ji("\u89C6\u9891\u8FDE\u63A5\u6062\u590D\u4E2D\u2026",!1,!0))}finally{kf=!1,dn(Le?.paused?500:Xe.dataset.state==="offline"?1e3:150)}}async function Yi(e,r={}){if(!(lt||Le?.paused)){lt=!0,qi.textContent="";for(let i of Object.values(hr))i.disabled=!0;e==="refresh"&&(uc=!0,Ge=un,Ze++,gr("\u6B63\u5728\u91CD\u8FDE\u2026"));try{let i=await eo(e==="refresh"?"refresh":"action",{action:e,...r});if(!i?.ok)throw new Error(i?.error?.code||"action_failed");e==="refresh"&&oy(i)}catch(i){e==="refresh"&&(uc=!1,gr(String(i).includes("device_busy")?"\u624B\u673A\u6B63\u5728\u64CD\u4F5C\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5":"\u91CD\u8FDE\u5C1A\u672A\u5B8C\u6210\uFF0C\u8BF7\u8BA9 Agent \u91CD\u65B0\u6253\u5F00\u624B\u673A\u5C4F\u5E55"))}finally{lt=!1,Te(Xe.dataset.state||"connecting"),dn(50)}}}hr.refresh.onclick=()=>{if(Le?.paused){gr("\u63A5\u7BA1\u671F\u95F4\u4FDD\u6301\u6682\u505C");return}Yi("refresh")};hr.home.onclick=()=>void Yi("home");hr.back.onclick=()=>void Yi("back");hr.copy.onclick=()=>{if(lt||Le?.paused||Xe.dataset.state!=="live"||!pr.naturalWidth)return;if(!navigator.clipboard?.write||typeof ClipboardItem>"u"){gr("\u5F53\u524D\u73AF\u5883\u4E0D\u652F\u6301\u590D\u5236\u56FE\u7247");return}let e=document.createElement("canvas");e.width=pr.naturalWidth,e.height=pr.naturalHeight;let r=e.getContext("2d");if(!r)return;r.drawImage(pr,0,0);let i=new Promise((o,t)=>e.toBlob(n=>n?o(n):t(new Error("encode_failed")),"image/png"));lt=!0,Te(Xe.dataset.state||"live"),navigator.clipboard.write([new ClipboardItem({"image/png":i})]).then(()=>gr("\u753B\u9762\u5DF2\u590D\u5236")).catch(()=>gr("\u590D\u5236\u5931\u8D25\uFF0C\u8BF7\u5141\u8BB8\u5199\u5165\u526A\u8D34\u677F")).finally(()=>{lt=!1,Te(Xe.dataset.state||"live")})};var ln;function ay(e){if(Xe.dataset.state!=="live"||lt||!Le?.viewport)return;let r=pr.getBoundingClientRect(),[i,o]=Le.viewport;if(!(Math.abs(r.width/r.height-i/o)>.08))return[Math.max(0,Math.min(i-1,Math.round((e.clientX-r.left)/r.width*i))),Math.max(0,Math.min(o-1,Math.round((e.clientY-r.top)/r.height*o)))]}Wi.onpointerdown=e=>{let r=ay(e);!r||!Le?.viewport||(ln={x:r[0],y:r[1],at:performance.now(),stream:cc,size:[...Le.viewport]},Wi.setPointerCapture(e.pointerId),Bi.style.display="block",Bi.style.left=`${r[0]/ln.size[0]*100}%`,Bi.style.top=`${r[1]/ln.size[1]*100}%`)};Wi.onpointerup=e=>{Bi.style.display="none";let r=ln;ln=void 0;let i=ay(e);if(!r||!i||r.stream!==cc||r.size.join()!==Le?.viewport?.join())return;let o=i[0]-r.x,t=i[1]-r.y;Math.hypot(o,t)<20?Yi("tap",{x:i[0],y:i[1]}):Yi("swipe",{direction:Math.abs(o)>Math.abs(t)?o>0?"right":"left":t>0?"down":"up"})};Wi.onpointercancel=()=>{ln=void 0,Bi.style.display="none"};document.addEventListener("visibilitychange",()=>{document.hidden?(Ze++,dt&&clearTimeout(dt)):dn(0)});window.addEventListener("pagehide",()=>{zf=!0,Ze++,dt&&clearTimeout(dt),Ki&&clearTimeout(Ki)});fr&&(fr.ontoolresult=()=>{iy&&dn(0)},fr.onhostcontextchanged=e=>{let r=e.displayMode==="inline";Sf=r,r?(Ze++,dt&&clearTimeout(dt)):dn(0)});async function tw(){Te("connecting");try{if(fr){await fr.connect(void 0,{timeout:8e3});try{await fr.requestDisplayMode({mode:"fullscreen"},{timeout:3e3})}catch{}}iy=!0,dn(0),eo("action",{action:"jev_status"}).then(e=>{e?.ok&&Xi(e)}).catch(()=>{})}catch{Te("offline","\u65E0\u6CD5\u8FDE\u63A5\u5BBF\u4E3B","\u8BF7\u91CD\u65B0\u6253\u5F00 Android \u624B\u673A\u5C4F\u5E55")}}tw();