agent-device 0.7.1 → 0.7.2
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/package.json
CHANGED
|
@@ -25,6 +25,8 @@ Use this skill as a router, not a full manual.
|
|
|
25
25
|
- Normal UI task: `open` -> `snapshot -i` -> `press/fill` -> `diff snapshot -i` -> `close`
|
|
26
26
|
- Debug/crash: `open <app>` -> `logs clear --restart` -> reproduce -> `network dump` -> `logs path` -> targeted `grep`
|
|
27
27
|
- Replay drift: `replay -u <path>` -> verify updated selectors
|
|
28
|
+
- Remote multi-tenant run: allocate lease -> run commands with tenant isolation flags -> heartbeat/release lease
|
|
29
|
+
- Device-scope isolation run: set iOS simulator set / Android allowlist -> run selectors within scope only
|
|
28
30
|
|
|
29
31
|
## Canonical Flows
|
|
30
32
|
|
|
@@ -57,12 +59,42 @@ Logging is off by default. Enable only for debugging windows.
|
|
|
57
59
|
agent-device replay -u ./session.ad
|
|
58
60
|
```
|
|
59
61
|
|
|
62
|
+
### 4) Remote Tenant Lease Flow (HTTP JSON-RPC)
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
# Allocate lease
|
|
66
|
+
curl -sS http://127.0.0.1:${AGENT_DEVICE_DAEMON_HTTP_PORT}/rpc \
|
|
67
|
+
-H "content-type: application/json" \
|
|
68
|
+
-H "Authorization: Bearer <token>" \
|
|
69
|
+
-d '{"jsonrpc":"2.0","id":"alloc-1","method":"agent_device.lease.allocate","params":{"runId":"run-123","tenantId":"acme","ttlMs":60000}}'
|
|
70
|
+
|
|
71
|
+
# Use lease in tenant-isolated command execution
|
|
72
|
+
agent-device --daemon-transport http \
|
|
73
|
+
--tenant acme \
|
|
74
|
+
--session-isolation tenant \
|
|
75
|
+
--run-id run-123 \
|
|
76
|
+
--lease-id <lease-id> \
|
|
77
|
+
session list --json
|
|
78
|
+
|
|
79
|
+
# Heartbeat and release
|
|
80
|
+
curl -sS http://127.0.0.1:${AGENT_DEVICE_DAEMON_HTTP_PORT}/rpc \
|
|
81
|
+
-H "content-type: application/json" \
|
|
82
|
+
-H "Authorization: Bearer <token>" \
|
|
83
|
+
-d '{"jsonrpc":"2.0","id":"hb-1","method":"agent_device.lease.heartbeat","params":{"leaseId":"<lease-id>","ttlMs":60000}}'
|
|
84
|
+
curl -sS http://127.0.0.1:${AGENT_DEVICE_DAEMON_HTTP_PORT}/rpc \
|
|
85
|
+
-H "content-type: application/json" \
|
|
86
|
+
-H "Authorization: Bearer <token>" \
|
|
87
|
+
-d '{"jsonrpc":"2.0","id":"rel-1","method":"agent_device.lease.release","params":{"leaseId":"<lease-id>"}}'
|
|
88
|
+
```
|
|
89
|
+
|
|
60
90
|
## Command Skeleton (Minimal)
|
|
61
91
|
|
|
62
92
|
### Session and navigation
|
|
63
93
|
|
|
64
94
|
```bash
|
|
65
95
|
agent-device devices
|
|
96
|
+
agent-device devices --platform ios --ios-simulator-device-set /tmp/tenant-a/simulators
|
|
97
|
+
agent-device devices --platform android --android-device-allowlist emulator-5554,device-1234
|
|
66
98
|
agent-device open [app|url] [url]
|
|
67
99
|
agent-device open [app] --relaunch
|
|
68
100
|
agent-device close [app]
|
|
@@ -70,8 +102,16 @@ agent-device session list
|
|
|
70
102
|
```
|
|
71
103
|
|
|
72
104
|
Use `boot` only as fallback when `open` cannot find/connect to a ready target.
|
|
105
|
+
For Android emulators by AVD name, use `boot --platform android --device <avd-name>`.
|
|
106
|
+
For Android emulators without GUI, add `--headless`.
|
|
73
107
|
Use `--target mobile|tv` with `--platform` (required) to pick phone/tablet vs TV targets (AndroidTV/tvOS).
|
|
74
108
|
|
|
109
|
+
Isolation scoping quick reference:
|
|
110
|
+
- `--ios-simulator-device-set <path>` scopes iOS simulator discovery + command execution to one simulator set.
|
|
111
|
+
- `--android-device-allowlist <serials>` scopes Android discovery/selection to comma/space separated serials.
|
|
112
|
+
- Scope is applied before selectors (`--device`, `--udid`, `--serial`); out-of-scope selectors fail with `DEVICE_NOT_FOUND`.
|
|
113
|
+
- With iOS simulator-set scope enabled, iOS physical devices are not enumerated.
|
|
114
|
+
|
|
75
115
|
TV quick reference:
|
|
76
116
|
- AndroidTV: `open`/`apps` use TV launcher discovery automatically.
|
|
77
117
|
- TV target selection works on emulators/simulators and connected physical devices (AndroidTV + AppleTV).
|
|
@@ -101,6 +141,7 @@ agent-device clipboard write "token"
|
|
|
101
141
|
agent-device perf --json
|
|
102
142
|
agent-device network dump [limit] [summary|headers|body|all]
|
|
103
143
|
agent-device push <bundle|package> <payload.json|inline-json>
|
|
144
|
+
agent-device trigger-app-event screenshot_taken '{"source":"qa"}'
|
|
104
145
|
agent-device get text @e1
|
|
105
146
|
agent-device screenshot out.png
|
|
106
147
|
agent-device settings permission grant notifications
|
|
@@ -134,11 +175,18 @@ agent-device batch --steps-file /tmp/batch-steps.json --json
|
|
|
134
175
|
- `push` simulates notification delivery:
|
|
135
176
|
- iOS simulator uses APNs-style payload JSON.
|
|
136
177
|
- Android uses broadcast action + typed extras (string/boolean/number).
|
|
178
|
+
- `trigger-app-event` requires app-defined deep-link hooks and URL template configuration (`AGENT_DEVICE_APP_EVENT_URL_TEMPLATE` or platform-specific variants).
|
|
179
|
+
- `trigger-app-event` requires an active session or explicit selectors (`--platform`, `--device`, `--udid`, `--serial`); on iOS physical devices, custom-scheme triggers require active app context.
|
|
180
|
+
- Canonical trigger behavior and caveats are documented in [`website/docs/docs/commands.md`](../../website/docs/docs/commands.md) under **App event triggers**.
|
|
137
181
|
- Permission settings are app-scoped and require an active session app:
|
|
138
182
|
`settings permission <grant|deny|reset> <camera|microphone|photos|contacts|notifications> [full|limited]`
|
|
139
183
|
- `full|limited` mode applies only to iOS `photos`; other targets reject mode.
|
|
140
184
|
- On Android, non-ASCII `fill/type` may require an ADB keyboard IME on some system images; only install IME APKs from trusted sources and verify checksum/signature.
|
|
141
185
|
- If using `--save-script`, prefer explicit path syntax (`--save-script=flow.ad` or `./flow.ad`).
|
|
186
|
+
- For tenant-isolated remote runs, always pass `--tenant`, `--session-isolation tenant`, `--run-id`, and `--lease-id` together.
|
|
187
|
+
- Use short lease TTLs and heartbeat only while work is active; release leases immediately after run completion/failure.
|
|
188
|
+
- Env equivalents for scoped runs: `AGENT_DEVICE_IOS_SIMULATOR_DEVICE_SET` (compat `IOS_SIMULATOR_DEVICE_SET`) and
|
|
189
|
+
`AGENT_DEVICE_ANDROID_DEVICE_ALLOWLIST` (compat `ANDROID_DEVICE_ALLOWLIST`).
|
|
142
190
|
|
|
143
191
|
## Security and Trust Notes
|
|
144
192
|
|
|
@@ -146,6 +194,7 @@ agent-device batch --steps-file /tmp/batch-steps.json --json
|
|
|
146
194
|
- If install is required, pin an exact version (for example: `npx --yes agent-device@<exact-version> --help`).
|
|
147
195
|
- Signing/provisioning environment variables are optional, sensitive, and only for iOS physical-device setup.
|
|
148
196
|
- Logs/artifacts are written under `~/.agent-device`; replay scripts write to explicit paths you provide.
|
|
197
|
+
- For remote daemon mode, prefer `AGENT_DEVICE_DAEMON_SERVER_MODE=http|dual` with `AGENT_DEVICE_HTTP_AUTH_HOOK` and tenant-scoped lease admission.
|
|
149
198
|
- Keep logging off unless debugging and use least-privilege/isolated environments for autonomous runs.
|
|
150
199
|
|
|
151
200
|
## Common Mistakes
|
|
@@ -165,3 +214,4 @@ agent-device batch --steps-file /tmp/batch-steps.json --json
|
|
|
165
214
|
- [references/coordinate-system.md](references/coordinate-system.md)
|
|
166
215
|
- [references/batching.md](references/batching.md)
|
|
167
216
|
- [references/perf-metrics.md](references/perf-metrics.md)
|
|
217
|
+
- [references/remote-tenancy.md](references/remote-tenancy.md)
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# Remote Tenancy and Lease Admission
|
|
2
|
+
|
|
3
|
+
Use this reference for remote daemon HTTP flows that require explicit
|
|
4
|
+
tenant/run admission control.
|
|
5
|
+
|
|
6
|
+
## Transport prerequisites
|
|
7
|
+
|
|
8
|
+
- Start daemon in HTTP mode (`AGENT_DEVICE_DAEMON_SERVER_MODE=http|dual`).
|
|
9
|
+
- Use a token from daemon metadata or `Authorization: Bearer <token>`.
|
|
10
|
+
- Prefer an auth hook (`AGENT_DEVICE_HTTP_AUTH_HOOK`) for caller validation and
|
|
11
|
+
tenant injection.
|
|
12
|
+
|
|
13
|
+
## Lease lifecycle (JSON-RPC)
|
|
14
|
+
|
|
15
|
+
Use `POST /rpc` with JSON-RPC 2.0 methods:
|
|
16
|
+
|
|
17
|
+
- `agent_device.lease.allocate`
|
|
18
|
+
- `agent_device.lease.heartbeat`
|
|
19
|
+
- `agent_device.lease.release`
|
|
20
|
+
|
|
21
|
+
Example allocate:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
curl -sS http://127.0.0.1:${AGENT_DEVICE_DAEMON_HTTP_PORT}/rpc \
|
|
25
|
+
-H "content-type: application/json" \
|
|
26
|
+
-H "Authorization: Bearer <token>" \
|
|
27
|
+
-d '{"jsonrpc":"2.0","id":"alloc-1","method":"agent_device.lease.allocate","params":{"tenantId":"acme","runId":"run-123","ttlMs":60000}}'
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Example heartbeat:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
curl -sS http://127.0.0.1:${AGENT_DEVICE_DAEMON_HTTP_PORT}/rpc \
|
|
34
|
+
-H "content-type: application/json" \
|
|
35
|
+
-H "Authorization: Bearer <token>" \
|
|
36
|
+
-d '{"jsonrpc":"2.0","id":"hb-1","method":"agent_device.lease.heartbeat","params":{"leaseId":"<lease-id>","ttlMs":60000}}'
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Example release:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
curl -sS http://127.0.0.1:${AGENT_DEVICE_DAEMON_HTTP_PORT}/rpc \
|
|
43
|
+
-H "content-type: application/json" \
|
|
44
|
+
-H "Authorization: Bearer <token>" \
|
|
45
|
+
-d '{"jsonrpc":"2.0","id":"rel-1","method":"agent_device.lease.release","params":{"leaseId":"<lease-id>"}}'
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Command admission contract
|
|
49
|
+
|
|
50
|
+
For tenant-isolated command execution, pass all four flags:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
agent-device --daemon-transport http \
|
|
54
|
+
--tenant acme \
|
|
55
|
+
--session-isolation tenant \
|
|
56
|
+
--run-id run-123 \
|
|
57
|
+
--lease-id <lease-id> \
|
|
58
|
+
session list --json
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Admission checks require tenant/run/lease scope alignment.
|
|
62
|
+
|
|
63
|
+
## Failure semantics
|
|
64
|
+
|
|
65
|
+
- Missing tenant/run/lease fields in tenant isolation mode: `INVALID_ARGS`
|
|
66
|
+
- Lease not active or wrong scope: `UNAUTHORIZED`
|
|
67
|
+
- Method mismatch: JSON-RPC `-32601` (HTTP 404)
|
|
68
|
+
|
|
69
|
+
## Operational guidance
|
|
70
|
+
|
|
71
|
+
- Keep TTL short and heartbeat only while a run is active.
|
|
72
|
+
- Release lease immediately on run completion/error paths.
|
|
73
|
+
- For bounded hosts, configure:
|
|
74
|
+
- `AGENT_DEVICE_MAX_SIMULATOR_LEASES`
|
|
75
|
+
- `AGENT_DEVICE_LEASE_TTL_MS`
|
|
76
|
+
- `AGENT_DEVICE_LEASE_MIN_TTL_MS`
|
|
77
|
+
- `AGENT_DEVICE_LEASE_MAX_TTL_MS`
|
|
@@ -14,6 +14,8 @@ Sessions isolate device context. A device can only be held by one session at a t
|
|
|
14
14
|
- Name sessions semantically.
|
|
15
15
|
- Close sessions when done.
|
|
16
16
|
- Use separate sessions for parallel work.
|
|
17
|
+
- For remote tenant-scoped automation, run commands with:
|
|
18
|
+
`--tenant <id> --session-isolation tenant --run-id <id> --lease-id <id>`
|
|
17
19
|
- In iOS sessions, use `open <app>`. `open <url>` opens deep links; on devices `http(s)://` opens Safari when no app is active, and custom schemes require an active app in the session.
|
|
18
20
|
- In iOS sessions, `open <app> <url>` opens a deep link.
|
|
19
21
|
- On iOS, `appstate` is session-scoped and requires a matching active session on the target device.
|
|
@@ -23,6 +25,22 @@ Sessions isolate device context. A device can only be held by one session at a t
|
|
|
23
25
|
- For deterministic replay scripts, prefer selector-based actions and assertions.
|
|
24
26
|
- Use `replay -u` to update selector drift during maintenance.
|
|
25
27
|
|
|
28
|
+
## Scoped device isolation
|
|
29
|
+
|
|
30
|
+
Use scoped discovery when sessions must not see host-global device lists.
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
agent-device devices --platform ios --ios-simulator-device-set /tmp/tenant-a/simulators
|
|
34
|
+
agent-device devices --platform android --android-device-allowlist emulator-5554,device-1234
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
- Scope is applied before selectors (`--device`, `--udid`, `--serial`).
|
|
38
|
+
- If selector target is outside scope, resolution fails with `DEVICE_NOT_FOUND`.
|
|
39
|
+
- With iOS simulator-set scope enabled, iOS physical devices are not enumerated.
|
|
40
|
+
- Environment equivalents:
|
|
41
|
+
- `AGENT_DEVICE_IOS_SIMULATOR_DEVICE_SET` (compat: `IOS_SIMULATOR_DEVICE_SET`)
|
|
42
|
+
- `AGENT_DEVICE_ANDROID_DEVICE_ALLOWLIST` (compat: `ANDROID_DEVICE_ALLOWLIST`)
|
|
43
|
+
|
|
26
44
|
## Listing sessions
|
|
27
45
|
|
|
28
46
|
```bash
|
|
@@ -35,3 +53,9 @@ agent-device session list
|
|
|
35
53
|
agent-device replay ./session.ad --session auth
|
|
36
54
|
agent-device replay -u ./session.ad --session auth
|
|
37
55
|
```
|
|
56
|
+
|
|
57
|
+
## Tenant isolation note
|
|
58
|
+
|
|
59
|
+
When session isolation is set to tenant mode, session namespace is scoped as
|
|
60
|
+
`<tenant>:<session>`. For remote runs, allocate and maintain an active lease
|
|
61
|
+
for the same tenant/run scope before executing tenant-isolated commands.
|