Skip to content

Commit 63ab9d6

Browse files
authored
fix: propagate remote config through remote flows (#422)
* fix: propagate remote config through commands * fix: complete remote React Native flow * test: cover remote install source lease reuse * fix: honor remote config session scope * refactor: drop remote react native shortcut * docs: simplify remote tenancy skill flow * docs: use trusted artifact placeholders * docs: prune remote tenancy prompt note
1 parent 3c8cbcb commit 63ab9d6

14 files changed

Lines changed: 844 additions & 81 deletions

File tree

skills/agent-device/references/bootstrap-install.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,17 @@ agent-device install com.example.app ./build/MyApp.app --platform ios --device "
6262
```
6363

6464
```bash
65-
agent-device install-from-source https://example.com/builds/app.aab --platform android
66-
agent-device install-from-source https://api.github.com/repos/acme/app/actions/artifacts/123/zip --platform ios --header "authorization: Bearer TOKEN"
65+
ARTIFACT_URL="<trusted-artifact-url>"
66+
agent-device install-from-source "$ARTIFACT_URL" --platform android
67+
GITHUB_ARTIFACT_URL="<trusted-github-actions-artifact-api-url>"
68+
agent-device install-from-source "$GITHUB_ARTIFACT_URL" --platform ios --header "authorization: Bearer TOKEN"
6769
```
6870

6971
## Install guidance
7072

7173
- Use `install <app> <path>` when the app may already be installed and you do not need a fresh-state reset.
7274
- Use `reinstall <app> <path>` when you explicitly need uninstall plus install as one deterministic step.
73-
- Use `install-from-source <url>` when an existing artifact URL is already reachable by the daemon.
75+
- Use `install-from-source <url>` only when an existing artifact URL is trusted, operator-approved, and reachable by the daemon.
7476
- Local `.apk`, `.aab`, `.app`, and `.ipa` paths go through `install` or `reinstall`; existing reachable URLs go through `install-from-source`.
7577
- Do not download, re-zip, publish temporary GitHub releases, or move CI artifacts elsewhere just to make an install command work.
7678
- Keep install and open as separate phases. Do not turn them into one default command flow.

skills/agent-device/references/remote-tenancy.md

Lines changed: 53 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,47 +7,87 @@ Open this file for remote daemon HTTP flows that let an agent running in a Linux
77
## Main commands to reach for first
88

99
- `agent-device connect --remote-config <path>`
10+
- `agent-device install-from-source <url> --remote-config <path> --platform android`
11+
- `agent-device open <package> --remote-config <path> --relaunch`
12+
- `agent-device snapshot --remote-config <path> -i`
13+
- `agent-device disconnect --remote-config <path>`
1014
- `agent-device connection status`
11-
- `agent-device disconnect`
1215
- `AGENT_DEVICE_DAEMON_AUTH_TOKEN=...`
1316

1417
## Most common mistake to avoid
1518

16-
Do not run remote tenant work by repeating `--remote-config` on every command. `--remote-config` is a `connect` input. After connecting, use normal `agent-device` commands; the active connection supplies daemon URL, tenant, run, and session context, then resolves lease and Metro details only when a later command actually needs them.
19+
Do not mix an arbitrary `--session` plus ad-hoc daemon, tenant, run, or lease flags. That can bypass saved Metro runtime hints. Use one of these patterns instead:
1720

18-
## Preferred remote flow
21+
- Interactive flow: run `connect --remote-config <path>` once, then normal commands, then `disconnect`.
22+
- Script flow: pass the same `--remote-config <path>` to every command, including `disconnect`.
1923

20-
Use this when the agent needs the simplest remote control flow: a Linux sandbox agent talks over HTTP to `agent-device` on a remote macOS host and launches the target app through a checked-in `--remote-config` profile.
24+
## Choose one flow
25+
26+
### Interactive flow
27+
28+
Use this when the agent will run several commands in one session.
2129

2230
```bash
2331
export AGENT_DEVICE_DAEMON_AUTH_TOKEN="YOUR_TOKEN"
2432
export AGENT_DEVICE_PROXY_TOKEN="$AGENT_DEVICE_DAEMON_AUTH_TOKEN"
2533

26-
agent-device connect \
27-
--remote-config ./remote-config.json
34+
agent-device connect --remote-config ./remote-config.json
2835

29-
agent-device install com.example.app ./app.apk
30-
agent-device install-from-source https://example.com/builds/app.apk --platform android
36+
ARTIFACT_URL="<trusted-artifact-url>"
37+
agent-device install-from-source "$ARTIFACT_URL" --platform android
3138
agent-device open com.example.app --relaunch
3239
agent-device snapshot -i
3340
agent-device fill @e3 "test@example.com"
3441
agent-device disconnect
3542
```
3643

37-
`connect` resolves the remote profile, generates a local session name when the profile omits one, stores local non-secret connection state, and defers tenant lease allocation plus Metro preparation until a later command needs them. When a command such as `open`, `install`, `apps`, or `snapshot` needs a lease, the client allocates or refreshes it from the connected scope. When a command needs Metro runtime hints, the client prepares Metro locally at that point and starts the local Metro companion when the bridge needs it, including `batch` runs whose steps open an app. `disconnect` closes the session when possible, stops the Metro companion owned by that connection, releases the lease when one was allocated, and removes local connection state.
44+
After `connect`, normal commands use the active remote connection. End with `disconnect` to release the lease and stop the owned Metro companion.
45+
46+
### Self-contained script flow
47+
48+
Use this when each command must be explicit and repeatable. Pass the same `--remote-config` to each step.
49+
50+
```bash
51+
ARTIFACT_URL="<trusted-artifact-url>"
52+
53+
agent-device install-from-source "$ARTIFACT_URL" \
54+
--remote-config ./remote-config.json \
55+
--platform android
56+
57+
agent-device open com.example.app \
58+
--remote-config ./remote-config.json \
59+
--relaunch
60+
61+
agent-device snapshot \
62+
--remote-config ./remote-config.json \
63+
-i
64+
65+
agent-device disconnect \
66+
--remote-config ./remote-config.json
67+
```
68+
69+
The first command that needs a lease or Metro runtime prepares and persists it. Later commands with the same `--remote-config` reuse that state. End with `disconnect --remote-config <path>` to release the lease and stop the owned Metro companion.
70+
71+
## Behavior summary
3872

39-
After `connect`, normal `agent-device` commands use the active remote connection. Do not repeat `--remote-config` on every command.
73+
- `connect` stores local non-secret connection state and defers tenant lease allocation plus Metro preparation until a later command needs them.
74+
- Commands such as `install-from-source`, `open`, `snapshot`, and `apps` allocate or refresh the lease when needed.
75+
- `open` prepares Metro runtime hints when the remote profile has Metro fields and no compatible runtime is already saved.
76+
- `batch` also prepares Metro when any step opens an app and that step does not provide its own runtime.
77+
- `disconnect` closes the session when possible, stops the Metro companion owned by the connection, releases the lease when one was allocated, and removes local connection state.
4078

4179
Remote install examples:
4280

4381
```bash
4482
agent-device install com.example.app ./app.apk
45-
agent-device install-from-source https://example.com/builds/app.aab --platform android
46-
agent-device install-from-source https://api.github.com/repos/acme/app/actions/artifacts/123/zip --platform ios --header "authorization: Bearer TOKEN"
83+
ARTIFACT_URL="<trusted-artifact-url>"
84+
agent-device install-from-source "$ARTIFACT_URL" --platform android
85+
GITHUB_ARTIFACT_URL="<trusted-github-actions-artifact-api-url>"
86+
agent-device install-from-source "$GITHUB_ARTIFACT_URL" --platform ios --header "authorization: Bearer TOKEN"
4787
```
4888

4989
- Use `install` or `reinstall` for local paths; remote daemons upload local artifacts automatically.
50-
- Use `install-from-source` for artifact URLs the remote daemon can reach.
90+
- Use `install-from-source` only for trusted, operator-approved artifact URLs the remote daemon can reach. Do not fetch arbitrary user-supplied URLs.
5191
- For local-path versus URL artifact rules, follow [bootstrap-install.md](bootstrap-install.md).
5292

5393
Use `agent-device connection status --session adc-android` to inspect the active connection without reading JSON state manually. Status output must not include auth tokens.

0 commit comments

Comments
 (0)