跳到正文
发现
agent-device:AI 代理设备控制层
命令行工具开发者工具

agent-device:AI 代理设备控制层

面向 AI 编程代理的开源设备层,用 CLI、MCP 和 Node.js API 控制多端应用。

admin
发布于 2026-11-16 · 更新于 2026-11-27
浏览
23
访问
0
下载
0
Stars
5,524
版本
v0.21.44
平台
Windows、macOS、Linux
该作品还没有经过官方审核。访问演示、下载或复制命令前,请自行确认来源可信。

详细介绍

项目简介

agent-device 是面向 AI 编程代理的开源设备层。它让编码代理在真机、模拟器和仿真器上检查、控制、调试和验证应用,覆盖 iOS、Android、HarmonyOS、tvOS、Android TV、Fire TV、Vega OS TV、web、macOS 和 Linux。代理通过 token 高效的无障碍快照理解界面,用 refs 和选择器执行操作,并保存证据供审查。项目提供 CLI、内置 MCP server 和带类型的 Node.js API 三种入口,支持本地或云端运行。

主要功能

  • 检查应用状态:通过无障碍快照、refs 和选择器读取界面,分析 React Native 渲染以定位交互变慢的原因。
  • 操作可见 UI:点击或按下元素、填写字段、滚动、手势、等待、断言状态、处理弹窗。
  • 诊断失败:截图、视频、日志、trace、网络数据、性能采样、崩溃详情和 React profile。
  • 复用工作流:把可用步骤保存为 .ad 脚本,在本地或 CI 重放,也可导出严格的 Maestro YAML。
  • 多入口一致:CLI、agent-device mcp 启动的 stdio MCP server,以及 createAgentDeviceClient() 的 Node.js API 使用同一运行时。
  • 并行与云端:会话按调用方的 git worktree 隔离,主机本地设备声明防止并行代理互相抢占模拟器;可连接 BrowserStack、AWS Device Farm、TestMu AI、Limrun 等设备云。

安装与使用

需要 Node.js 22.12 或更高版本;web 自动化需要 Node.js 24 或更高版本。

npm install -g agent-device@latest
agent-device doctor
agent-device help workflow

在把 CLI 交给代理之前,先自己运行 doctor。

从 CLI 驱动应用:

agent-device open Contacts --platform ios
agent-device snapshot -i
agent-device press @e2 --settle
agent-device fill @e7 "Ada" --settle
agent-device screenshot ./contact-form.png
agent-device close

为代理添加 MCP 工具,agent-device mcp 启动官方 stdio MCP server:

{
  "mcpServers": {
    "agent-device": {
      "command": "agent-device",
      "args": ["mcp"]
    }
  }
}

从 Node.js 调用:

import { createAgentDeviceClient } from 'agent-device';

const client = createAgentDeviceClient({ session: 'qa-run' });
await client.apps.open({ app: 'com.apple.Preferences', platform: 'ios' });
const snapshot = await client.capture.snapshot({ interactiveOnly: true });

注意事项

  • 不同目标的命令支持深度不同,HarmonyOS、Vega OS 等后端只覆盖部分命令;用 agent-device capabilities --platform <platform> 查看目标支持情况。
  • refs 只在最新输出中有效:执行带 --settle 的命令后使用其 diff 中的 refs,只有 diff 缺少所需内容时才重新快照。
  • 快照来自应用的无障碍树,清晰的标签、角色和 test ID 能让代理运行更可靠;无障碍数据不足时再用截图和视频作为证据。
  • 支持原生 iOS/Android 应用,以及 React Native、Expo、Flutter 应用。

本作品整理自 GitHub 开源项目 callstack/agent-device,原作者 @callstack,许可证 MIT。中文介绍由 AI 根据项目 README 整理,以原仓库为准。

更新记录

  1. v0.21.44当前版本

    ## What's Changed * fix(cli): route reload, restart and pull-to-refresh intents to existing commands by @thymikee in https://github.com/callstack/agent-device/pull/5094 * docs(agents): hand worker validation to CI by @thymikee in https://github.com/callstack/agent-device/pull/5103 * feat(ios): leave Split View on an iPhone Duo simulator by @thymikee in https://github.com/callstack/agent-device/pull/5102 * fix(output): make ref pins shell-literal for agent allow-rules by @thymikee in https://github.com/callstack/agent-device/pull/5097 * fix(apple): keep the Expo dev menu closed when open launches a dev client by @imranbarbhuiya in https://github.com/callstack/agent-device/pull/5053 * fix(metro): reload the app's own dev server instead of assuming port 8081 by @thymikee in https://github.com/callstack/agent-device/pull/5098 * feat(gestures): add settle to swipe and gesture by @thymikee in https://github.com/callstack/agent-device/pull/5109 * fix(daemon-client): name a sandbox-denied conn

  2. v0.21.43

    ## What's Changed * fix(remote): drop a remote artifact whose name cannot be a file name by @zerone0x in https://github.com/callstack/agent-device/pull/4718 * ci(linux): install cached desktop packages without an apt index refresh by @thymikee in https://github.com/callstack/agent-device/pull/5021 * fix(settings): keep the --app hint on the daemon route and type mode for photos only by @imranbarbhuiya in https://github.com/callstack/agent-device/pull/5026 * fix(cli): correct three refusals from #5008 by @imranbarbhuiya in https://github.com/callstack/agent-device/pull/5027 * fix(help): give every selector key a rule and list every selector command by @imranbarbhuiya in https://github.com/callstack/agent-device/pull/5028 * fix(daemon-client): flag proxy links explicitly and sanitize /health labels in the mismatch message by @imranbarbhuiya in https://github.com/callstack/agent-device/pull/5032 * fix(refs): name the settled diff in the plain-ref refusal and issue its replacement refs by

  3. v0.21.42

    ## What's Changed * refactor(daemon): report startup progress over the launch channel instead of marker files by @thymikee in https://github.com/callstack/agent-device/pull/4777 * fix(contracts): pair open runtime hints with their apply operation by @thymikee in https://github.com/callstack/agent-device/pull/4754 * feat(audit): report controls that share one accessible name by @thymikee in https://github.com/callstack/agent-device/pull/4771 * fix(mutation): keep umask-setting tests out of Stryker's thread pool by @thymikee in https://github.com/callstack/agent-device/pull/4785 * feat(audit): evaluate role-less clickable views on Android by @thymikee in https://github.com/callstack/agent-device/pull/4780 * chore(gates): ratchet untyped reason literals per file (R89) by @thymikee in https://github.com/callstack/agent-device/pull/4779 * fix(daemon): bound upload ingress and finalization by @thymikee in https://github.com/callstack/agent-device/pull/4721 * fix(android): authenticate and bo

评论