@swmansion/argent 0.30.2-next.2 → 0.30.2-next.21

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swmansion/argent",
3
- "version": "0.30.2-next.2",
3
+ "version": "0.30.2-next.21",
4
4
  "mcpName": "io.github.software-mansion/argent",
5
5
  "description": "MCP server for iOS Simulator and Android Emulator control",
6
6
  "license": "Apache-2.0",
package/rules/argent.md CHANGED
@@ -37,9 +37,9 @@ If argent is ABSENT, treat it as an expected state, not an error to retry. Do no
37
37
 
38
38
  <tapping_rule>
39
39
  <important>**Never** derive tap coordinates from screenshot pixels</important>
40
- Interaction tools (`gesture-tap`, `gesture-swipe`, `keyboard`, `button`, `launch-app`, `open-url`, `run-sequence`, …) return the screen **after** the action: a screenshot AND the accessibility element tree (`--- Elements after action (describe) ---`, the same format `describe` prints, with normalized 0–1 frames). Take tap coordinates from that tree: the centre of the element's frame (`x + width/2`, `y + height/2`). You do not need a separate discovery call before a tap when the last result already lists the target.
40
+ Interaction tools (`gesture-tap`, `gesture-swipe`, `keyboard`, `button`, `launch-app`, `open-url`, `run-sequence`, `await-ui-element`, …) return the screen **after** the action: a screenshot AND the accessibility element tree (`--- Elements after action (describe) ---`, the same format `describe` prints, with normalized 0–1 frames). Take tap coordinates from that tree: the centre of the element's frame (`x + width/2`, `y + height/2`). You do not need a separate discovery call before a tap when the last result already lists the target.
41
41
 
42
- Call a discovery tool yourself only when you have no fresh tree for the current screen: before the first action on a screen you have not touched yet, after waiting for something to load, or when the last tree did not list your target. Preferred tools are, in order:
42
+ Call a discovery tool yourself only when you have no fresh tree for the current screen: before the first action on a screen you have not touched yet, after waiting for something to load without `await-ui-element`, or when the last tree did not list your target. Preferred tools are, in order:
43
43
 
44
44
  - `describe` - native app-level components and safely targetable foreground apps (iOS and Android).
45
45
  - `native-describe-screen` - accessibility screen description via injected native devtools (iOS only)
@@ -78,11 +78,13 @@ Decision order:
78
78
  - Always open apps with `launch-app` or `open-url`; never tap home screen icons.
79
79
  - If a task can require a saved e2e test, choose `argent-create-e2e` or `argent-qa-e2e` before the first launch or in-app action. Start the recorder before walking the path; recording is not retroactive.
80
80
  - Always use `run-sequence` when performing multiple sequential device actions where you don't need to observe the screen between steps. More in `argent-device-interact` skill.
81
- - When the session ends or the user says they are done: call `stop-all-simulator-servers` with `devices: [...]`
82
- naming the devices this session actually used. One tool-server is shared by every other agent using this
83
- argent install, so an unscoped call tears down their devices too; reserve that form for a deliberate
84
- machine-wide cleanup.
85
- If the user started Metro separately, ask whether to call `stop-metro` (specify the port if not 8081).
81
+ - Do not stop simulator servers when a task finishes: the next task reuses them, and stopping them makes its
82
+ first device action start cold again. Call `stop-all-simulator-servers` when the user asks to clean up or
83
+ ends the session, or when a skill tells you to recycle a device's services (e.g. before a QA proof pass).
84
+ Always pass `devices: [...]` naming the devices this session used. One tool-server is shared by every other
85
+ agent using this argent install, so an unscoped call tears down their devices too; reserve that form for a
86
+ deliberate machine-wide cleanup.
87
+ Never stop a Metro the user started unless they ask (`stop-metro`, specify the port if not 8081).
86
88
  - If tools provided by mcp-server are not sufficient and action can be done using `xcrun`, `adb`, or other commands, use the command. Examples: changing device options, performing a device action such as lock, shake, etc. Not on a physical iPhone.
87
89
  - When waiting for an action, do not call `screenshot` repeatedly without a proper wait mechanism. Use the `await-ui-element` tool to block until the UI settles (e.g. wait for an element to become `visible`/`hidden`, or to contain expected `text`) instead of polling.
88
90
  </general_rules>
@@ -36,7 +36,7 @@ Use `list-devices` to get a target id. Results are tagged with `platform` (`ios`
36
36
  { "udid": "<UDID>", "bundleId": "com.apple.MobileSMS" }
37
37
  ```
38
38
 
39
- Common IDs: `com.apple.MobileSMS` (Messages), `com.apple.mobilesafari` (Safari), `com.apple.Preferences` (Settings), `com.apple.Maps`, `com.apple.Photos`, `com.apple.mobilemail`, `com.apple.mobilenotes`, `com.apple.MobileAddressBook` (Contacts)
39
+ Common IDs: `com.apple.MobileSMS` (Messages), `com.apple.mobilesafari` (Safari), `com.apple.Preferences` (Settings), `com.apple.Maps`, `com.apple.mobileslideshow` (Photos), `com.apple.MobileAddressBook` (Contacts)
40
40
 
41
41
  ### open-url: by URL scheme
42
42
 
@@ -169,6 +169,8 @@ Values: `home`, `back`, `power`, `volumeUp`, `volumeDown`, `appSwitch`, `actionB
169
169
 
170
170
  One call does one action. `text` and `key` are mutually exclusive, and a call that carries both is rejected with nothing typed. To type and then submit, send two `keyboard` steps in one `run-sequence` (§ 8): `{ "text": "search query" }`, then `{ "key": "enter" }`. Two separate calls do the same work, but cost an extra round-trip.
171
171
 
172
+ **React Native: the first tap after typing may only close the keyboard.** Inside a scroll view with the default `keyboardShouldPersistTaps="never"`, React Native uses a tap outside the focused field to dismiss the keyboard and does not pass it on (with `"handled"` or `"always"` the tap reaches the button), so a button tapped right after typing may need a second tap; check the returned tree. When the field submits on return, `{ "key": "enter" }` avoids the extra tap.
173
+
172
174
  Special keys: `enter`, `escape`, `backspace`, `tab`, `space`, `arrow-up`, `arrow-down`, `arrow-left`, `arrow-right`, `f1`–`f12`. Optional: `"delayMs": 100` between keystrokes (default 50ms); applies to the iOS simulator and Chromium; it is ignored on Android phones/tablets (typed via `adb input text`, no per-key cadence), on Vega, and on TV targets.
173
175
 
174
176
  **Typing secrets.** To enter a credential without its plaintext ever entering your context, transcript, or logs, use a secret placeholder in `text` (works in `keyboard`, `paste`, `run-sequence` keyboard steps, and e2e `type` steps):
@@ -66,6 +66,49 @@ Only `enter` (alias `return`), `backspace` (alias `delete`), `space`, `arrow-lef
66
66
  - `reinstall-app` takes one `.hap` file as `appPath` and the bundle name from its `module.json` as `bundleId`; a mismatch is refused before anything is uninstalled. A multi-module `.app` bundle is not accepted.
67
67
  - `open-url` resolves any scheme through `aa start -U`, and every result carries a `note`: `aa` reports success whenever the system accepts the URI. A web URL can leave the screen unchanged, and `tel:` / `mailto:` can leave a "No options to open with" dialog over it. Confirm with `describe` or `screenshot` before treating the link as followed. It fails whenever `aa` refuses the URI, as it does a scheme nothing claims.
68
68
 
69
+ ## Building and signing a HAP
70
+
71
+ Both blocks below use the default macOS install, the only layout verified; elsewhere point `C` and the Java path at the matching DevEco Studio directories. The build assumes the module `entry` and the product `default`, which the output path depends on. Build from the project root without the IDE:
72
+
73
+ ```bash
74
+ C=/Applications/DevEco-Studio.app/Contents
75
+ export DEVECO_SDK_HOME=$C/sdk PATH=$C/tools/node/bin:$C/tools/ohpm/bin:$C/jbr/Contents/Home/bin:$PATH
76
+ ohpm install --all
77
+ rm -rf entry/build/default/outputs
78
+ node $C/tools/hvigor/bin/hvigorw.js --mode module -p module=entry@default -p product=default -p buildMode=debug assembleHap --no-daemon
79
+ ```
80
+
81
+ With no `signingConfigs` in `build-profile.json5` this writes `entry/build/default/outputs/default/entry-default-unsigned.hap`. A `signingConfigs` naming key files this machine lacks (DevEco writes absolute paths under its author's `~/.ohos/config`) fails the build at `SignHap`, e.g. `Invalid storeFile value`, after that HAP is written; sign it below. Any other failed build leaves no HAP.
82
+
83
+ The emulator installs any HAP, including an unsigned one or one whose signature fails verification, so an emulator install proves nothing about signing. A phone refuses an unsigned HAP (`9568320 error: no signature file`). Sign it with a debug profile for the app's bundle name that lists the phone's UDID (`hdc -t <connectKey> shell bm get --udid`, last line; `hdc` is in `$C/sdk/default/openharmony/toolchains`). `L` below is `$C/sdk/default/openharmony/toolchains/lib`, set in the signing block.
84
+
85
+ **Test keys, no account.** `$L/OpenHarmony.p12` (password `123456`) is OpenHarmony's public test PKI; use it for development only. A HAP signed this way installs and launches on a HarmonyOS 6.0 phone.
86
+
87
+ 1. Certificate chain `app-chain.cer`, leaf first: the `bundle-info.development-certificate` from `$L/UnsgnedDebugProfileTemplate.json`, then the `OpenHarmony Application CA` and `OpenHarmony Application Root CA` certificates from `$L/OpenHarmonyProfileDebug.pem`.
88
+ 2. Profile `profile.json`: a copy of the template with your `bundle-info.bundle-name`, the phone's UDID in `debug-info.device-ids`, and a current `validity` window in epoch seconds (the template's expired in January 2024).
89
+ 3. Sign the profile, then the HAP, from the project root with DevEco's Java:
90
+
91
+ ```bash
92
+ C=/Applications/DevEco-Studio.app/Contents L=$C/sdk/default/openharmony/toolchains/lib
93
+ export PATH=$C/jbr/Contents/Home/bin:$PATH
94
+ rm -f app-signed.hap
95
+ java -jar $L/hap-sign-tool.jar sign-profile -mode localSign -signAlg SHA256withECDSA \
96
+ -keystoreFile $L/OpenHarmony.p12 -keystorePwd 123456 -keyPwd 123456 \
97
+ -keyAlias "openharmony application profile debug" -profileCertFile $L/OpenHarmonyProfileDebug.pem \
98
+ -inFile profile.json -outFile profile.p7b &&
99
+ java -jar $L/hap-sign-tool.jar sign-app -mode localSign -signAlg SHA256withECDSA -signCode 1 \
100
+ -keystoreFile $L/OpenHarmony.p12 -keystorePwd 123456 -keyPwd 123456 \
101
+ -keyAlias "openharmony application release" -appCertFile app-chain.cer -profileFile profile.p7b \
102
+ -inFile entry/build/default/outputs/default/entry-default-unsigned.hap -outFile app-signed.hap
103
+ ```
104
+
105
+ **Real keys, Huawei ID.** These need the user's Huawei account; ask before using it.
106
+
107
+ - DevEco Studio: sign in, connect the phone, and tick _Automatically generate signature_ under File > Project Structure > Project > Signing Configs. Tick _Support HarmonyOS_ too if it is offered; without it the signature is an OpenHarmony one. It writes `signingConfigs` into `build-profile.json5`, and the build above then emits `entry-default-signed.hap`.
108
+ - AppGallery Connect: create a `.p12` and CSR (DevEco: Build > Generate Key and CSR), then request a debug certificate (`.cer`) from the CSR, register the phone's UDID and the app, and request a debug profile (`.p7b`) for that app, that certificate and the device. Run the signing block without `sign-profile`, giving `sign-app` your `.p12`, key alias, passwords, `.cer` and `.p7b`; AppGallery Connect has already signed the profile.
109
+
110
+ In the signing block's shell, `java -jar $L/hap-sign-tool.jar verify-app -inFile <hap> -outCertChain c.cer -outProfile p.p7b` checks the signature on the host, but not that the profile's bundle name matches the HAP's. A phone refuses that mismatch with `9568329 verify signature failed`, so only an install proves the phone accepts a HAP. Install it with `reinstall-app` (`appPath` the HAP's absolute path, `bundleId` its bundle name), then `launch-app` it. `reinstall-app` uninstalls first, so a HAP the phone refuses also costs the installed copy and its data; to keep them, install with `hdc -t <connectKey> install <hap>` instead, which leaves the installed copy on a refusal.
111
+
69
112
  ## E2E tests
70
113
 
71
114
  The e2e runner (`e2e-execute`, skill `argent-create-e2e`) runs on HarmonyOS only when you name the device: `device: "harmony-<connectKey>"` (`--device` on the CLI). A HarmonyOS device is never auto-resolved, and `platform` / `--platform` does not accept `harmony`. HarmonyOS is not an authorable platform either: `when: { platform: harmony }` and a `harmony:` launch-map key are rejected when the YAML is parsed, so launch with a bare app id or `native:`.
@@ -11,7 +11,7 @@ Read this only for a physical iPhone. Simulators use `argent-ios-simulator-setup
11
11
 
12
12
  1. Cable the phone, unlock it, keep the screen awake, and turn on Developer Mode (Settings > Privacy & Security > Developer Mode). `list-devices` must show it `connected`.
13
13
  2. `launch-app` only registers the app. The first `describe`, gesture or `screenshot` builds, signs and starts the on-device runner: minutes cold, tens of seconds from cache or after a tool-server restart. Build cap 15 min, runner ready 120 s.
14
- 3. On the first install the phone asks to trust the developer (Settings > General > VPN & Device Management), and an **ArgentRunner** app appears on the home screen. Tell the user it is argent's automation runner and must stay installed.
14
+ 3. On the first install the phone asks to trust the developer (Settings > General > VPN & Device Management), and an **Argent Runner** app appears on the home screen. Tell the user it is argent's automation runner and must stay installed.
15
15
 
16
16
  ## Signing and failures
17
17
 
@@ -57,6 +57,7 @@ You do not need to derive `app_process` manually; just make sure the app is laun
57
57
 
58
58
  Call `native-profiler-start` with `device_id` (iOS UDID or Android serial). The tool auto-detects the running app and saves the trace to `/tmp/argent-profiler-cwd/` with a timestamped filename.
59
59
  Let the user interact with the app or drive interaction via simulator tools (see `argent-device-interact` skill).
60
+ While a profiler records, interaction tools return no automatic screenshot or element tree, so the capture does not load the app. Call `screenshot` or `describe` when you need to see the screen; interaction tools still wait for the screen to settle before they return, so add no wait of your own; on an Android emulator each screenshot during a profile takes one frame in about 100 ms and does not wake the screen capture; on a physical Android device it takes about 150–200 ms and briefly wakes the device screen capture, so take them sparingly there.
60
61
 
61
62
  ### Step 2: Stop and export
62
63
 
@@ -88,6 +88,8 @@ Mind the react-native and ios-native profiler selection mentioned above when sta
88
88
  - if session is marked as "stale", you may overtake it without prompting the user for allowance
89
89
  - if session is NOT "stale" - before taking action and terminating the other session, **stop and ask user what you should do**, explaining the situation.
90
90
 
91
+ While a profiler records, interaction tools return no automatic screenshot or element tree, so the capture does not load the app. Call `screenshot` or `describe` when you need to see the screen; interaction tools still wait for the screen to settle before they return, so add no wait of your own; on an Android emulator each screenshot during a profile takes one frame in about 100 ms and does not wake the screen capture; on a physical Android device it takes about 150–200 ms and briefly wakes the device screen capture, so take them sparingly there.
92
+
91
93
  #### Annotate every interaction
92
94
 
93
95
  After each `gesture-tap` or `gesture-swipe` call, record an annotation using the returned `timestampMs`. Compute `offsetMs = timestampMs - startedAtEpochMs`. Do this for _every_ interaction, including back-navigation swipes, not just the primary action. Pass all collected annotations to `react-profiler-analyze` in Step 3.
@@ -98,8 +98,7 @@ Steps:
98
98
  ```
99
99
  1. gesture-tap { x: 0.5, y: 0.7 } → trigger an action that fetches data
100
100
  2. screenshot → loading spinner is showing
101
- 3. await-ui-element { condition: hidden, selector: { text: "Loading" } } → block until the fetch finishes and the spinner disappears
102
- 4. describe / screenshot → verify the fetched content rendered
101
+ 3. await-ui-element { condition: hidden, selector: { text: "Loading" } } → block until the fetch finishes and the spinner disappears; its result carries the screenshot and element tree, so verify the fetched content rendered from it
103
102
  ```
104
103
 
105
104
  ---