@mobileaidev/ai-app-bridge 0.2.11 → 0.2.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # AI App Bridge CLI
2
2
 
3
+ AI App Bridge CLI/MCP supports Android native apps, Android WebView/H5/CDP,
4
+ Flutter apps on Android and iOS, iOS native apps via `AiAppBridgeIOS` plus
5
+ WebDriverAgent/XCUITest, WKWebView, and desktop Web Bridge sessions.
6
+
7
+ Command domains:
8
+
9
+ - `core`: `status`, `tree`, `uia-tree`, `screenshot`, `logs`, `network`, `state`, `events`
10
+ - `app`: `install-apk`, `clear-app-data`, `launch-*`, `freeze-app`, `thaw-app`, `permission-*`, `appops-set`
11
+ - `action`: `tap`, `tap-text`, `tap-uia-text`, `input-text`, `swipe`, `keyevent`, `wait-text`, `keyboard-state`, `hide-keyboard`
12
+ - `flutter`: `flutter-tree`, `flutter-nodes`, `flutter-action`, `tap-flutter-text`, `input-flutter-text`, `scroll-flutter`
13
+ - `webview`: `h5-*`, `flutter-h5-*`, `webview-pages`, `webview-network`, `webview-console`
14
+ - `ios`: `ios-devices`, `ios-doctor`, `ios-setup`, `ios-*` runtime evidence, WDA tree/tap/input/swipe, WKWebView, and Flutter iOS
15
+ - `web`: `web-session-start`, `web-sessions`, `web-status`, `web-dom`, `web-logs`, `web-network`, `web-state`, `web-events`, `web-command`, `web-click`, `web-input`, `web-wait`, `web-scroll`
16
+ - `diagnostics` / `advanced`: `logcat`, `smoke`, `batch`, `forward`, `remove-forward`
17
+
18
+ For MCP clients, the default surface is compact: call `capabilities` to discover
19
+ domains, commands, and options, then call `run` with the selected command.
20
+
3
21
  ```bash
4
22
  npm install -g @mobileaidev/ai-app-bridge
5
23
 
@@ -19,9 +37,10 @@ ai-app-bridge ios-setup --device-id <device-or-udid> --bundle-id <ios.bundle.id>
19
37
  ai-app-bridge ios-status --device-id <device-or-udid> --bundle-id <ios.bundle.id>
20
38
  ai-app-bridge ios-tap --bundle-id <ios.bundle.id> --tap-x 120 --tap-y 360 --wda-url <wda-url-from-setup>
21
39
  ai-app-bridge ios-input --bundle-id <ios.bundle.id> --accessibility-id sample_text_field --clear-first --text "hello" --wda-url <wda-url-from-setup>
40
+ ai-app-bridge-mcp # then run web-session-start / web-* commands through MCP
22
41
  ai-app-bridge thaw-app --package-name io.github.mobileaidev.aiappbridge.sample
23
42
  ai-app-bridge freeze-app --package-name io.github.mobileaidev.aiappbridge.sample
24
- ai-app-bridge-mcp
43
+ ai-app-bridge-mcp --help
25
44
  ```
26
45
 
27
46
  AI agents, model clients, automation frameworks, and IDE MCP clients reading
@@ -37,12 +56,13 @@ refresh the session.
37
56
  MCP defaults to a compact tool surface to avoid loading every command schema
38
57
  into the model context:
39
58
 
40
- - `capabilities` lists the bridge domains and command names.
59
+ - `capabilities` lists supported targets, command domains, command names, and optional argument names.
41
60
  - `run` executes a selected command with command-specific arguments.
42
61
 
43
- This keeps install, data reset, launch, UI, Flutter, WebView, logcat, network,
44
- permission, iOS, and web capabilities discoverable without exposing dozens of full schemas
45
- at session start. Set `AI_APP_BRIDGE_MCP_SURFACE=full` before launching
62
+ This keeps install, data reset, launch, UI action, Flutter, WebView/H5/CDP,
63
+ iOS, Web Bridge, logcat, network, permission, smoke, batch, and port-forward
64
+ capabilities discoverable without exposing dozens of full schemas at session start.
65
+ Set `AI_APP_BRIDGE_MCP_SURFACE=full` before launching
46
66
  `ai-app-bridge-mcp` only when a client needs the legacy one-tool-per-command
47
67
  surface.
48
68
 
@@ -22,6 +22,15 @@ const defaults = {
22
22
 
23
23
  const helpText = `Usage: ai-app-bridge <command> [options]
24
24
 
25
+ Supports:
26
+ Android native apps; Android WebView/H5/CDP; Flutter apps on Android and iOS;
27
+ iOS native apps via AiAppBridgeIOS + WebDriverAgent/XCUITest; WKWebView;
28
+ desktop Web Bridge sessions through ai-app-bridge-mcp.
29
+
30
+ MCP discovery:
31
+ ai-app-bridge-mcp exposes a compact capability index by default.
32
+ Call capabilities, then run a command from core/app/action/flutter/webview/ios/web/diagnostics/advanced.
33
+
25
34
  Commands:
26
35
  status Read bridge status and app/device metadata.
27
36
  tree Read the Android View tree from the in-app bridge.
@@ -84,6 +93,23 @@ Flutter commands:
84
93
  flutter-h5-wait Wait for Flutter H5 text or selector.
85
94
  flutter-h5-scroll Scroll Flutter H5 content.
86
95
 
96
+ Web Bridge MCP commands:
97
+ web-provider-status Read desktop Web Bridge provider status.
98
+ web-session-start Start the Web Bridge WebSocket session server.
99
+ web-connect-info Read endpoint/token for browser SDK clients.
100
+ web-sessions List connected Web Bridge SDK sessions.
101
+ web-status Read Web Bridge session status.
102
+ web-dom Read or refresh Web Bridge DOM snapshots.
103
+ web-logs Read Web Bridge log records.
104
+ web-network Read Web Bridge network records.
105
+ web-state Read Web Bridge state records.
106
+ web-events Read Web Bridge event records.
107
+ web-command Run a whitelisted browser SDK command.
108
+ web-click Click a DOM element through the browser SDK.
109
+ web-input Set text in a DOM input through the browser SDK.
110
+ web-wait Wait for text or selector through the browser SDK.
111
+ web-scroll Scroll a Web Bridge DOM target.
112
+
87
113
  Device/action commands:
88
114
  tap Tap device coordinates through ADB.
89
115
  tap-text Tap a visible node by exact text or content description.
@@ -4555,4 +4581,3 @@ module.exports = {
4555
4581
  waitTextConditionsMet,
4556
4582
  withFileLock,
4557
4583
  };
4558
-
package/bin/mcp-server.js CHANGED
@@ -12,12 +12,62 @@ const nodeBinary = process.env.AI_APP_BRIDGE_NODE || process.execPath;
12
12
  const supportedProtocolVersions = ['2025-06-18', '2024-11-05'];
13
13
  const defaultProtocolVersion = supportedProtocolVersions[0];
14
14
  const mcpSurface = (process.env.AI_APP_BRIDGE_MCP_SURFACE || 'compact').toLowerCase();
15
+ const supportedTargets = [
16
+ 'Android native apps',
17
+ 'Android WebView/H5/CDP',
18
+ 'Flutter apps on Android and iOS',
19
+ 'iOS native apps via AiAppBridgeIOS + WebDriverAgent/XCUITest',
20
+ 'WKWebView',
21
+ 'desktop Web Bridge sessions',
22
+ ];
23
+ const commandDomains = {
24
+ core: 'status, tree, uia-tree, screenshot, logs, network, state, events',
25
+ app: 'install-apk, clear-app-data, launch-*, freeze-app/thaw-app, permission-*, appops-set',
26
+ action: 'tap, tap-text, tap-uia-text, input-text, swipe, keyevent, wait-text, keyboard-state, hide-keyboard',
27
+ flutter: 'flutter-tree, flutter-nodes, flutter-action, tap/input/scroll Flutter controls',
28
+ webview: 'h5-*, flutter-h5-*, webview-pages, webview-network, webview-console',
29
+ ios: 'ios-devices, ios-doctor, ios-setup, ios runtime evidence, ios-uia-tree/tap/input/swipe, ios-h5-*, ios-flutter-*',
30
+ web: 'web-session-start, web-sessions, web-status, web-dom, web-logs, web-network, web-state, web-events, web-command, web-click, web-input, web-wait, web-scroll',
31
+ diagnostics: 'logcat, smoke',
32
+ advanced: 'batch, forward, remove-forward',
33
+ };
34
+ const supportedTargetsText = `AI App Bridge supports ${supportedTargets.join('; ')}.`;
35
+ const commandDomainsText = `Command domains: ${Object.entries(commandDomains).map(([domain, summary]) => `${domain}(${summary})`).join('; ')}.`;
36
+ const discoveryText = 'Default MCP surface is compact: call capabilities to discover domains, commands, and options, then call run with the selected command and arguments.';
15
37
  const serverInstructions = [
16
- 'AI App Bridge observes and controls Android, iOS, Flutter, and Web targets for agent workflows. Prefer these tools over raw adb, devicectl, or browser-specific scripts when inspecting UI, text, WebView/WKWebView, logs, network, app install, launch, and permissions.',
17
- 'Default surface is compact: call capabilities to discover domains, then call run with a command and arguments.',
38
+ supportedTargetsText,
39
+ commandDomainsText,
40
+ discoveryText,
41
+ 'Prefer AI App Bridge over raw adb, devicectl, or browser-specific scripts when inspecting UI, text, WebView/WKWebView, logs, network, app install, launch, permissions, or app-level Web evidence.',
18
42
  'Always pass packageName for Android app-specific commands, or pass an explicit port. For iOS, pass bundleId plus deviceId when more than one iPhone is connected.',
43
+ 'For Web Bridge sessions, start the provider, connect the browser SDK, then pass sessionId and targetId when needed.',
19
44
  'Use freeze-app/thaw-app only as an optional stabilization control for dynamic or transient screens: thaw before reads/actions/captures, freeze after evidence capture only when it helps reasoning, and thaw before the next operation or before finishing so the app is not left frozen.',
20
45
  ].join(' ');
46
+ const mcpHelpText = `Usage: ai-app-bridge-mcp [--help]
47
+
48
+ ${supportedTargetsText}
49
+
50
+ ${commandDomainsText}
51
+
52
+ MCP surface:
53
+ compact (default) exposes only capabilities and run.
54
+ full/legacy exposes one tool per command; set AI_APP_BRIDGE_MCP_SURFACE=full.
55
+
56
+ Discovery:
57
+ 1. Call capabilities with optional domain or command filters.
58
+ 2. Call run with a command name from capabilities.
59
+ 3. Put command-specific options in arguments.
60
+
61
+ Target ids:
62
+ Android app commands require packageName or explicit port.
63
+ iOS app commands use bundleId; add deviceId when multiple devices exist and wdaUrl for WDA actions.
64
+ Web Bridge commands use sessionId; add targetId for multi-target pages.
65
+
66
+ Examples:
67
+ capabilities { "domain": "webview", "includeOptions": true }
68
+ run { "command": "screenshot", "packageName": "com.example.app" }
69
+ run { "command": "web-session-start", "arguments": { "webPort": 18180 } }
70
+ `;
21
71
  const iosProvider = new IOSBridgeProvider();
22
72
  const webProvider = new WebBridgeProvider();
23
73
 
@@ -185,18 +235,20 @@ function toolDefinitions() {
185
235
 
186
236
  function compactToolDefinitions() {
187
237
  return [
188
- bridgeTool('capabilities', 'List AI App Bridge capability domains and commands. Call this first when planning app automation; then use run to execute the selected command.', {
189
- domain: { type: 'string', description: 'Optional domain filter such as core, app, action, flutter, webview, ios, web, or diagnostics.' },
190
- command: { type: 'string', description: 'Optional command name for detailed arguments, such as install-apk, launch-app, tree, input-text, webview-network, ios-setup, or ios-tap.' },
238
+ bridgeTool('capabilities', `List AI App Bridge capability domains and commands across Android, iOS, Flutter, WebView/H5/CDP, and Web Bridge targets. ${commandDomainsText}`, {
239
+ domain: { type: 'string', description: 'Optional domain filter: core, app, action, flutter, webview, ios, web, diagnostics, or advanced.' },
240
+ command: { type: 'string', description: 'Optional command name for detailed arguments, such as install-apk, launch-app, tree, input-text, webview-network, ios-setup, ios-tap, web-session-start, or web-command.' },
191
241
  includeOptions: { type: 'boolean', description: 'Include per-command argument names. Defaults to false to keep output compact.' },
192
242
  }),
193
- bridgeTool('run', 'Run an AI App Bridge command. Use capabilities first to choose the command. Pass packageName for Android app commands and bundleId for iOS app commands.', {
194
- command: { type: 'string', description: 'Command name from capabilities, using CLI form such as status, install-apk, launch-app, input-text, webview-network, ios-doctor, ios-setup, ios-status, ios-tap, or web-status.' },
243
+ bridgeTool('run', 'Run an AI App Bridge command from capabilities. Pass packageName/port for Android app commands, bundleId/deviceId for iOS app commands, and sessionId/targetId for Web Bridge commands.', {
244
+ command: { type: 'string', description: 'Command name from capabilities, using CLI form such as status, install-apk, launch-app, input-text, webview-network, ios-doctor, ios-setup, ios-status, ios-tap, web-session-start, web-status, or web-command.' },
195
245
  packageName: { type: 'string', description: 'Target Android package for app-specific commands. Strongly recommended.' },
196
246
  serial: { type: 'string', description: 'ADB serial when multiple devices are connected.' },
197
247
  port: { type: 'number', description: 'Explicit bridge port when packageName discovery is not available.' },
198
248
  bundleId: { type: 'string', description: 'Target iOS app bundle identifier for ios-* commands.' },
199
249
  deviceId: { type: 'string', description: 'iOS devicectl identifier, UDID, serial number, or device name.' },
250
+ sessionId: { type: 'string', description: 'Target Web Bridge SDK session id for web-* commands.' },
251
+ targetId: { type: 'string', description: 'Optional Web Bridge target id for multi-target pages.' },
200
252
  iosHost: { type: 'string', description: 'iOS runtime host or CoreDevice tunnel IP.' },
201
253
  iosPort: { type: 'number', description: 'iOS runtime port when auto-discovery is unavailable.' },
202
254
  runtimeUrl: { type: 'string', description: 'Explicit iOS runtime base URL.' },
@@ -635,7 +687,9 @@ function capabilityPayload(args = {}) {
635
687
  return {
636
688
  ok: true,
637
689
  surface: mcpSurface === 'full' || mcpSurface === 'legacy' ? 'full' : 'compact',
638
- usage: 'Use run with one of these command names. Prefer packageName for app-specific commands; install-apk, clear-app-data, launch-app, freeze/thaw, UI, WebView, logcat, network, and permission workflows are supported.',
690
+ supportedTargets,
691
+ commandDomains,
692
+ usage: `${supportedTargetsText} ${discoveryText} Use run with one of these command names. Prefer packageName for Android app commands, bundleId/deviceId for iOS, and sessionId/targetId for Web Bridge sessions.`,
639
693
  domains,
640
694
  };
641
695
  }
@@ -1225,12 +1279,19 @@ function writeLog(text) {
1225
1279
  }
1226
1280
 
1227
1281
  if (require.main === module) {
1282
+ if (process.argv.includes('--help') || process.argv.includes('-h')) {
1283
+ process.stdout.write(`${mcpHelpText}\n`);
1284
+ process.exit(0);
1285
+ }
1228
1286
  startServer();
1229
1287
  }
1230
1288
 
1231
1289
  module.exports = {
1232
1290
  buildBridgeCliArgs,
1291
+ commandDomains,
1292
+ mcpHelpText,
1233
1293
  readNextMessage,
1234
1294
  runBatch,
1235
1295
  startServer,
1296
+ supportedTargets,
1236
1297
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mobileaidev/ai-app-bridge",
3
- "version": "0.2.11",
4
- "description": "Desktop CLI and MCP server for AI App Bridge.",
3
+ "version": "0.2.13",
4
+ "description": "Desktop CLI and MCP server for AI App Bridge across Android, iOS, Flutter, WebView, and Web targets.",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/mobileAiDev/ai-app-bridge.git",
@@ -1,15 +1,33 @@
1
1
  ---
2
2
  name: ai-app-bridge-use
3
- description: 使用 AI App Bridge MCP 观察、操作、验证和调试 Android、iOS Flutter 应用。Codex 需要检查移动端 UI、截图、Android View/UIAutomator treeiOS UIKit/WDA tree、点击/输入/等待/滑动、安装/启动/清数据、Flutter widget action、WebView/WKWebView/H5 DOM 或 CDP 网络/控制台、日志/网络/状态/事件、权限/appops、smoke 测试,或按需使用 freeze/thaw 稳定动态画面时触发。
3
+ description: 使用 AI App Bridge MCP 观察、操作、验证和调试 Android nativeAndroid WebView/H5/CDP、Flutter、iOS native + WDA/XCUITestWKWebView 和桌面 Web Bridge。能力域包括 core/status/tree/screenshot/logs/network/state/events,app/install/clear-data/launch/freeze/thaw/permissions/appops,action/tap/input/swipe/keyevent/wait/keyboard,flutter/widget/action,webview/H5/CDP,ios/devices/setup/runtime/WDA/H5/flutter,web/session/DOM/logs/network/events/command,diagnostics/logcat/smoke,advanced/batch/port-forward。
4
4
  ---
5
5
 
6
6
  # AI App Bridge Use
7
7
 
8
+ ## 能力总览
9
+
10
+ AI App Bridge 支持 Android native apps、Android WebView/H5/CDP、Flutter apps、iOS native apps via `AiAppBridgeIOS` + WebDriverAgent/XCUITest、WKWebView,以及桌面 Web Bridge sessions。
11
+
12
+ 默认 MCP surface 只有 `capabilities` 和 `run`;先用 `capabilities` 查 domain、command 和 options,再用 `run` 执行。
13
+
14
+ 目标标识:Android 用 `packageName` 或显式 `port`;iOS 用 `bundleId`,多设备加 `deviceId`,full-control 加 `wdaUrl`;Web 用 `sessionId`,多 target 加 `targetId`。
15
+
16
+ 命令域:
17
+ - `core`: `status`/`tree`/`uia-tree`/`screenshot`/`logs`/`network`/`state`/`events`
18
+ - `app`: `install-apk`/`clear-app-data`/`launch-*`/`freeze-app`/`thaw-app`/`permission-*`/`appops-set`
19
+ - `action`: `tap`/`tap-text`/`tap-uia-text`/`input-text`/`swipe`/`keyevent`/`wait-text`/`keyboard-*`
20
+ - `flutter`: `flutter-tree`/`flutter-nodes`/`flutter-action`/`tap-flutter-text`/`input-flutter-text`/`scroll-flutter`
21
+ - `webview`: `h5-*`/`flutter-h5-*`/`webview-pages`/`webview-network`/`webview-console`
22
+ - `ios`: `ios-devices`/`ios-doctor`/`ios-setup`/`ios-status`/`ios-tree`/`ios-uia-tree`/`ios-tap`/`ios-input`/`ios-swipe`/`ios-h5-*`/`ios-flutter-*`
23
+ - `web`: `web-session-start`/`web-sessions`/`web-status`/`web-dom`/`web-logs`/`web-network`/`web-state`/`web-events`/`web-command`/`web-click`/`web-input`/`web-wait`/`web-scroll`
24
+ - `diagnostics`/`advanced`: `logcat`/`smoke`/`batch`/`forward`/`remove-forward`
25
+
8
26
  ## Agent 快速流程
9
27
 
10
- 1. 确认目标 app:Android 使用 `packageName`,iOS 使用 `bundleId`,真机多设备场景传 `deviceId`/UDID;没有目标 id 时先从上下文、构建配置或前台 app 线索推断。面向具体 app 的命令必须传目标 id,只有无法发现 bridge 端口时才传 `port` `runtimeUrl`。
28
+ 1. 确认目标:Android 使用 `packageName`,iOS 使用 `bundleId`,真机多设备场景传 `deviceId`/UDID;Web 使用 `sessionId`,多 target 时加 `targetId`。没有目标 id 时先从上下文、构建配置或前台 app/session 线索推断。面向具体 app/session 的命令必须传目标 id,只有无法发现 bridge 端口时才传 `port`、`runtimeUrl` 或先启动 Web session。
11
29
  2. 发现能力:默认 MCP surface 只有 `capabilities` 和 `run`。不确定命令或参数时先调用 `capabilities`,再用 `run` 执行。
12
- 3. 选择命令路径:按任务类型选 `core`、`app`、`action`、`flutter`、`webview`、`diagnostics` 或 `advanced` 域;不要先退回原始 `adb`。
30
+ 3. 选择命令路径:按任务类型选 `core`、`app`、`action`、`flutter`、`webview`、`ios`、`web`、`diagnostics` 或 `advanced` 域;不要先退回原始 `adb`、浏览器脚本或坐标猜测。
13
31
  4. 用 `batch` 串联相关步骤:观察、操作、等待、截图、tree 验证尽量放进一次 MCP 调用。
14
32
  5. 验证可见结果:界面变化必须用 `screenshot` 加 `tree`/`uia-tree` 交叉确认。
15
33
  6. 只在需要稳定动态画面时使用 `freeze-app`/`thaw-app`;如果本轮冻结过 app,最终回复前必须解冻。
@@ -58,6 +76,9 @@ description: 使用 AI App Bridge MCP 观察、操作、验证和调试 Android
58
76
  | iOS 设备/环境检查 | `ios-devices`、`ios-doctor`、`ios-setup` |
59
77
  | iOS App 内证据 | `ios-status`、`ios-tree`、`ios-logs`、`ios-network`、`ios-state`、`ios-events`、`ios-h5-dom`、`ios-h5-eval` |
60
78
  | iOS 系统级 UI 与动作 | `ios-uia-tree`、`ios-tap`、`ios-input`、`ios-swipe`、`ios-screenshot` |
79
+ | Web Bridge session | `web-provider-status`、`web-session-start`、`web-connect-info`、`web-sessions` |
80
+ | Web DOM 和证据 | `web-status`、`web-dom`、`web-logs`、`web-network`、`web-state`、`web-events` |
81
+ | Web 页面动作 | `web-click`、`web-input`、`web-wait`、`web-scroll`、`web-command` |
61
82
  | 自检 | `smoke` |
62
83
  | 多步骤串行执行 | `batch` |
63
84
  | 动态画面稳定 | `freeze-app`、`thaw-app`,只按需使用 |
@@ -150,6 +171,53 @@ iOS 观察和操作:
150
171
  }
151
172
  ```
152
173
 
174
+ Web session 启动和连接:
175
+
176
+ ```json
177
+ {
178
+ "command": "web-session-start",
179
+ "arguments": {
180
+ "webPort": 18180,
181
+ "token": "session-token"
182
+ }
183
+ }
184
+ ```
185
+
186
+ 页面调试入口使用 Web SDK 连接:
187
+
188
+ ```js
189
+ import { createAiAppBridge } from "@mobileaidev/ai-app-bridge-web";
190
+
191
+ const bridge = createAiAppBridge({
192
+ endpoint: "ws://127.0.0.1:18180/ai-app-bridge-web",
193
+ token: "session-token",
194
+ appName: "demo-web-app",
195
+ capture: { console: true, errors: true, fetch: true, xhr: true, dom: true }
196
+ });
197
+
198
+ bridge.start();
199
+ ```
200
+
201
+ Web 观察、操作和验证:
202
+
203
+ ```json
204
+ {
205
+ "command": "batch",
206
+ "arguments": {
207
+ "defaults": { "sessionId": "web-session-abc123" },
208
+ "steps": [
209
+ { "id": "status", "command": "web-status" },
210
+ { "id": "dom", "command": "web-dom", "arguments": { "refresh": true } },
211
+ { "id": "click", "command": "web-click", "arguments": { "selector": "button[type=submit]" } },
212
+ { "id": "wait", "command": "web-wait", "arguments": { "targetText": "Saved", "timeoutMs": 5000 } },
213
+ { "id": "events", "command": "web-events" }
214
+ ],
215
+ "stopOnError": true,
216
+ "includeRaw": true
217
+ }
218
+ }
219
+ ```
220
+
153
221
  ## 验证规则
154
222
 
155
223
  把 `screenshot` 当作当前可见画面的最高优先级证据,把 `tree`/`uia-tree` 当作可操作节点和结构证据。
@@ -175,6 +243,14 @@ iOS:
175
243
  - 文本输入优先用元素目标,例如 `ios-input` 搭配 `accessibilityId` 或 `elementId` 和 `clearFirst`;坐标输入仅用于没有稳定 accessibility id 的控件。
176
244
  - Flutter iOS 仍按 Flutter 路径读 widget/action 证据;设备级动作、权限弹窗和外部 UI 仍走 iOS WDA 命令。
177
245
 
246
+ Web:
247
+
248
+ - 独立 Web app 不用 Android `packageName`;先 `web-session-start` 启动桌面 WebSocket provider,再用 `web-connect-info` 读取 endpoint/token,让页面里的 `@mobileaidev/ai-app-bridge-web` SDK 连接。
249
+ - SDK 只放在 debug/test/client 代码里;SSR 框架必须只在浏览器端初始化,生产环境默认不要启用。
250
+ - 页面连接后先用 `web-sessions` 找 `sessionId`,再用 `web-status`、`web-dom`、`web-logs`、`web-network`、`web-state`、`web-events` 采集证据。
251
+ - 操作页面优先用 `web-command` 调注册过的白名单 action;需要 DOM 操作时用 `web-click`、`web-input`、`web-wait`、`web-scroll`,并传稳定 `selector` 或 `targetText`。
252
+ - 多页面、iframe 或自定义 surface 时传 `targetId`;如果返回 target ambiguous,先读取候选 target 再重试。
253
+
178
254
  Flutter:
179
255
 
180
256
  - 先尝试泛用 `tap-text`/`input-text`;失败、节点不可见或语义特殊时切到 `flutter-*`。
@@ -200,6 +276,8 @@ WebView/H5:
200
276
 
201
277
  `freeze-app`/`thaw-app` 是稳定动态画面的能力之一,不是默认动作节奏。只有冻结能让证据更可靠时才用。
202
278
 
279
+ `freeze-app`/`thaw-app` 只适用于移动 app runtime;Web Bridge 目标不要使用这两个命令。
280
+
203
281
  适合冻结:
204
282
 
205
283
  - 视频、动画、倒计时、实时刷新列表、游戏、播放页等会在思考期间变化的画面。
@@ -253,6 +331,10 @@ WebView/H5:
253
331
  - `packageName`/`port` 缺失:先补目标,不要让 MCP 回落到默认 sample。
254
332
  - iOS `bundleId`/`deviceId`/`wdaUrl` 缺失:先用 `ios-devices`/`ios-setup` 补齐;需要 full-control 时不要在没有 WDA 的情况下宣称完成。
255
333
  - iOS 设备锁屏、未信任、Developer Mode/DDI 不可用、WDA signing 失败、首次启动弹出授权/密码框:停下告诉用户需要操作,用户处理后再重试。
334
+ - Web `sessionId` 缺失:先跑 `web-session-start`、让页面 SDK 连接,再用 `web-sessions` 获取 session;不要把 Web 命令改成 Android `packageName`。
335
+ - Web provider 未运行或 endpoint/token 不匹配:用 `web-provider-status` 和 `web-connect-info` 重新确认连接信息,让页面刷新后重连。
336
+ - Web target ambiguous:读取 `web-sessions` 或 `web-dom` 返回的 target 候选,明确传 `targetId`。
337
+ - Web command 被拒绝:确认页面 SDK 是否注册了对应 action,或改用允许的 `web-click`/`web-input`/`web-scroll`;不要临时打开任意 `eval`。
256
338
  - `screenshot` 报前台 package 不匹配:先 `launch-app` 或确认当前前台,再继续判断。
257
339
  - `tree` 为空但截图正常:尝试 `uia-tree`、等待一轮或使用 Flutter/WebView 专用命令。
258
340
  - WebView CDP 不可用:确认 app debuggable、WebView debugging、目标 page;不能用 CDP 时退回 `h5-*` 或可见 UI 验证。
@@ -268,6 +350,12 @@ WebView/H5:
268
350
  npm install -g @mobileaidev/ai-app-bridge
269
351
  ```
270
352
 
353
+ Web 页面需要额外在目标项目中安装调试 SDK:
354
+
355
+ ```bash
356
+ npm install --save-dev @mobileaidev/ai-app-bridge-web
357
+ ```
358
+
271
359
  macOS / Linux:
272
360
 
273
361
  ```json
@@ -1,4 +1,4 @@
1
1
  interface:
2
2
  display_name: "AI App Bridge Use"
3
- short_description: "观察、操作并验证 Android/iOS/Flutter app。"
4
- default_prompt: "使用 $ai-app-bridge-use 观察、操作和验证目标 Android/iOS/Flutter app;先发现能力,Android 传 packageName,iOS 传 bundleId/deviceId 并在 full-control 时使用 WDA,只有动态画面需要稳定证据时才使用 freeze/thaw。"
3
+ short_description: "Android/iOS/Flutter/Web 全域观察、操作、验证能力索引。"
4
+ default_prompt: "使用 $ai-app-bridge-use 观察、操作和验证 Android native、Android WebView/H5/CDP、Flutter、iOS native/WKWebView/WDA/XCUITest 或桌面 Web Bridge;先用 capabilities 查 core/app/action/flutter/webview/ios/web/diagnostics/advanced,再用 run 执行。Android 传 packageName,iOS 传 bundleId/deviceId 并在 full-control 时使用 WDA,Web 先建立 sessionId,只有移动端动态画面需要稳定证据时才使用 freeze/thaw。"