zig-mobile-runner 0.1.0

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.
Files changed (225) hide show
  1. package/CHANGELOG.md +484 -0
  2. package/CONTRIBUTING.md +42 -0
  3. package/FEATURES.md +112 -0
  4. package/LICENSE +21 -0
  5. package/README.md +255 -0
  6. package/SECURITY.md +34 -0
  7. package/build.zig +38 -0
  8. package/build.zig.zon +7 -0
  9. package/clients/README.md +144 -0
  10. package/clients/go/README.md +24 -0
  11. package/clients/go/examples/fake-session/main.go +93 -0
  12. package/clients/go/go.mod +3 -0
  13. package/clients/go/zmr/client.go +432 -0
  14. package/clients/kotlin/README.md +35 -0
  15. package/clients/kotlin/build.gradle.kts +35 -0
  16. package/clients/kotlin/settings.gradle.kts +15 -0
  17. package/clients/kotlin/src/main/kotlin/dev/zmr/FakeSession.kt +86 -0
  18. package/clients/kotlin/src/main/kotlin/dev/zmr/ZmrClient.kt +67 -0
  19. package/clients/python/README.md +29 -0
  20. package/clients/python/examples/fake_session.py +48 -0
  21. package/clients/python/pyproject.toml +13 -0
  22. package/clients/python/zmr_client.py +202 -0
  23. package/clients/rust/Cargo.lock +107 -0
  24. package/clients/rust/Cargo.toml +10 -0
  25. package/clients/rust/README.md +19 -0
  26. package/clients/rust/examples/fake_session.rs +70 -0
  27. package/clients/rust/src/lib.rs +461 -0
  28. package/clients/swift/Package.swift +16 -0
  29. package/clients/swift/README.md +36 -0
  30. package/clients/swift/Sources/ZMRClient/ZMRClient.swift +114 -0
  31. package/clients/swift/Sources/ZMRFakeSession/main.swift +86 -0
  32. package/clients/typescript/README.md +34 -0
  33. package/clients/typescript/examples/fake-session.mjs +36 -0
  34. package/clients/typescript/index.d.ts +144 -0
  35. package/clients/typescript/index.mjs +192 -0
  36. package/clients/typescript/package.json +8 -0
  37. package/docs/adr/0001-agent-native-runner-boundary.md +31 -0
  38. package/docs/adr/0002-app-local-zmr-contract.md +39 -0
  39. package/docs/adr/0003-ios-simulator-xctest-shim.md +41 -0
  40. package/docs/adr/0004-benchmark-claims-and-baseline-collection.md +37 -0
  41. package/docs/adr/README.md +12 -0
  42. package/docs/ai-agents.md +156 -0
  43. package/docs/app-integration.md +316 -0
  44. package/docs/benchmarking.md +275 -0
  45. package/docs/client-installation.md +141 -0
  46. package/docs/clients.md +98 -0
  47. package/docs/config.md +175 -0
  48. package/docs/demo.md +259 -0
  49. package/docs/dsl.md +57 -0
  50. package/docs/install.md +233 -0
  51. package/docs/market-positioning.md +70 -0
  52. package/docs/npm.md +359 -0
  53. package/docs/protocol-fixtures/README.md +8 -0
  54. package/docs/protocol-fixtures/core-session.requests.jsonl +8 -0
  55. package/docs/protocol-fixtures/core-session.responses.jsonl +8 -0
  56. package/docs/protocol-versioning.md +65 -0
  57. package/docs/protocol.md +560 -0
  58. package/docs/publication.md +77 -0
  59. package/docs/release-audit.md +99 -0
  60. package/docs/release-candidate.md +111 -0
  61. package/docs/release-evidence.md +188 -0
  62. package/docs/release-notes-template.md +58 -0
  63. package/docs/roadmap.md +334 -0
  64. package/docs/scenario-authoring.md +88 -0
  65. package/docs/shipping.md +170 -0
  66. package/docs/trace-privacy.md +88 -0
  67. package/docs/troubleshooting.md +256 -0
  68. package/examples/android-app-auth-probe.json +89 -0
  69. package/examples/android-app-error-state.json +13 -0
  70. package/examples/android-app-login-smoke.json +192 -0
  71. package/examples/android-app-onboarding.json +12 -0
  72. package/examples/android-app-referral-deep-link.json +12 -0
  73. package/examples/android-shim-smoke.json +19 -0
  74. package/examples/demo-failure.json +12 -0
  75. package/examples/demo-fake.json +14 -0
  76. package/examples/ios-dev-client-open-link.json +26 -0
  77. package/examples/ios-dev-client-route-snapshot.json +24 -0
  78. package/examples/ios-shim-smoke.json +23 -0
  79. package/examples/ios-smoke.json +9 -0
  80. package/go.work +3 -0
  81. package/npm/agents.mjs +183 -0
  82. package/npm/app-config.mjs +95 -0
  83. package/npm/build-zmr.mjs +21 -0
  84. package/npm/commands.mjs +104 -0
  85. package/npm/generated-files.mjs +50 -0
  86. package/npm/index.mjs +75 -0
  87. package/npm/init-app.mjs +80 -0
  88. package/npm/package-scripts.mjs +72 -0
  89. package/npm/postinstall.mjs +21 -0
  90. package/npm/scaffold.mjs +179 -0
  91. package/npm/scenarios.mjs +93 -0
  92. package/npm/setup.mjs +69 -0
  93. package/npm/wizard.mjs +117 -0
  94. package/npm/zmr.mjs +23 -0
  95. package/package.json +114 -0
  96. package/prebuilds/darwin-arm64/zmr +0 -0
  97. package/prebuilds/darwin-x64/zmr +0 -0
  98. package/prebuilds/linux-arm64/zmr +0 -0
  99. package/prebuilds/linux-x64/zmr +0 -0
  100. package/schemas/README.md +26 -0
  101. package/schemas/action-result.schema.json +27 -0
  102. package/schemas/capabilities-output.schema.json +98 -0
  103. package/schemas/devices-output.schema.json +25 -0
  104. package/schemas/doctor-output.schema.json +51 -0
  105. package/schemas/explain-output.schema.json +51 -0
  106. package/schemas/import-output.schema.json +23 -0
  107. package/schemas/init-output.schema.json +71 -0
  108. package/schemas/json-rpc.schema.json +55 -0
  109. package/schemas/release-manifest.schema.json +43 -0
  110. package/schemas/release-readiness-output.schema.json +127 -0
  111. package/schemas/run-output.schema.json +43 -0
  112. package/schemas/scenario.schema.json +128 -0
  113. package/schemas/schemas-output.schema.json +26 -0
  114. package/schemas/semantic-snapshot.schema.json +116 -0
  115. package/schemas/snapshot.schema.json +60 -0
  116. package/schemas/trace-event.schema.json +14 -0
  117. package/schemas/trace-manifest.schema.json +59 -0
  118. package/schemas/validate-output.schema.json +42 -0
  119. package/schemas/version-output.schema.json +23 -0
  120. package/schemas/zmr-config.schema.json +75 -0
  121. package/scripts/android-emulator.sh +126 -0
  122. package/scripts/assert-ios-physical-ready.sh +213 -0
  123. package/scripts/benchmark-command.sh +307 -0
  124. package/scripts/benchmark.sh +359 -0
  125. package/scripts/benchmark_gate.py +117 -0
  126. package/scripts/benchmark_result_row.py +88 -0
  127. package/scripts/compare-benchmarks.py +288 -0
  128. package/scripts/create-android-demo-app.sh +342 -0
  129. package/scripts/create-ios-demo-app.sh +261 -0
  130. package/scripts/demo-android-real.sh +232 -0
  131. package/scripts/demo-ios-real.sh +270 -0
  132. package/scripts/demo.sh +464 -0
  133. package/scripts/device-matrix.sh +338 -0
  134. package/scripts/ensure-ios-shim-target.rb +237 -0
  135. package/scripts/install-android-shim.sh +281 -0
  136. package/scripts/install-ios-shim.sh +589 -0
  137. package/scripts/pilot-gate.sh +560 -0
  138. package/scripts/release-readiness.py +838 -0
  139. package/scripts/release-readiness.sh +91 -0
  140. package/scripts/run-android-pilot.sh +561 -0
  141. package/scripts/run-ios-pilot.sh +509 -0
  142. package/shims/android/README.md +21 -0
  143. package/shims/android/ZMRShimInstrumentedTest.java +152 -0
  144. package/shims/android/protocol.md +18 -0
  145. package/shims/ios/README.md +50 -0
  146. package/shims/ios/ZMRShim.swift +110 -0
  147. package/shims/ios/ZMRShimUITestCase.swift +475 -0
  148. package/shims/ios/protocol.md +74 -0
  149. package/skills/zmr-mobile-testing/SKILL.md +127 -0
  150. package/src/android.zig +344 -0
  151. package/src/android_device_info.zig +99 -0
  152. package/src/android_emulator.zig +154 -0
  153. package/src/android_screen_recording.zig +112 -0
  154. package/src/android_shell.zig +112 -0
  155. package/src/bundle.zig +124 -0
  156. package/src/bundle_redaction.zig +272 -0
  157. package/src/bundle_tar.zig +123 -0
  158. package/src/cli_devices.zig +97 -0
  159. package/src/cli_doctor.zig +114 -0
  160. package/src/cli_import.zig +70 -0
  161. package/src/cli_info.zig +39 -0
  162. package/src/cli_init.zig +72 -0
  163. package/src/cli_output.zig +467 -0
  164. package/src/cli_run.zig +259 -0
  165. package/src/cli_serve.zig +287 -0
  166. package/src/cli_trace.zig +111 -0
  167. package/src/cli_validate.zig +41 -0
  168. package/src/command.zig +211 -0
  169. package/src/config.zig +305 -0
  170. package/src/config_diagnostics.zig +212 -0
  171. package/src/config_paths.zig +49 -0
  172. package/src/device_registry.zig +37 -0
  173. package/src/doctor.zig +412 -0
  174. package/src/doctor_hints.zig +52 -0
  175. package/src/errors.zig +55 -0
  176. package/src/fake_device.zig +163 -0
  177. package/src/health.zig +28 -0
  178. package/src/importer.zig +343 -0
  179. package/src/importer_json.zig +100 -0
  180. package/src/importer_model.zig +103 -0
  181. package/src/ios.zig +399 -0
  182. package/src/ios_devices.zig +219 -0
  183. package/src/ios_lifecycle.zig +72 -0
  184. package/src/ios_shim.zig +242 -0
  185. package/src/ios_snapshot.zig +20 -0
  186. package/src/json_fields.zig +80 -0
  187. package/src/json_rpc.zig +150 -0
  188. package/src/json_rpc_methods.zig +318 -0
  189. package/src/json_rpc_observation.zig +31 -0
  190. package/src/json_rpc_params.zig +52 -0
  191. package/src/json_rpc_protocol.zig +110 -0
  192. package/src/json_rpc_trace.zig +73 -0
  193. package/src/main.zig +135 -0
  194. package/src/mcp.zig +234 -0
  195. package/src/mcp_protocol.zig +64 -0
  196. package/src/mcp_trace.zig +83 -0
  197. package/src/report.zig +346 -0
  198. package/src/report_html.zig +63 -0
  199. package/src/report_values.zig +27 -0
  200. package/src/run_options.zig +152 -0
  201. package/src/runner.zig +280 -0
  202. package/src/runner_actions.zig +109 -0
  203. package/src/runner_config.zig +6 -0
  204. package/src/runner_diagnostics.zig +268 -0
  205. package/src/runner_events.zig +170 -0
  206. package/src/runner_native.zig +88 -0
  207. package/src/runner_waits.zig +300 -0
  208. package/src/scaffold.zig +472 -0
  209. package/src/scenario.zig +346 -0
  210. package/src/scenario_fields.zig +50 -0
  211. package/src/schema_registry.zig +53 -0
  212. package/src/selector.zig +84 -0
  213. package/src/semantic.zig +171 -0
  214. package/src/trace.zig +315 -0
  215. package/src/trace_json.zig +340 -0
  216. package/src/trace_summary.zig +218 -0
  217. package/src/trace_summary_diagnostic.zig +202 -0
  218. package/src/types.zig +120 -0
  219. package/src/uiautomator.zig +164 -0
  220. package/src/validation.zig +187 -0
  221. package/src/version.zig +22 -0
  222. package/viewer/app.js +373 -0
  223. package/viewer/index.html +126 -0
  224. package/viewer/parser.js +233 -0
  225. package/viewer/styles.css +585 -0
@@ -0,0 +1,464 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
5
+ cd "$ROOT"
6
+
7
+ ZIG_TARGET="${ZIG_TARGET:-}"
8
+ if [[ -z "$ZIG_TARGET" ]]; then
9
+ if [[ "$(uname -s)" == "Darwin" && "$(uname -m)" == "arm64" ]]; then
10
+ ZIG_TARGET="aarch64-macos.15.0"
11
+ else
12
+ ZIG_TARGET="native"
13
+ fi
14
+ fi
15
+
16
+ target_args=()
17
+ if [[ "$ZIG_TARGET" != "native" ]]; then
18
+ target_args=(-target "$ZIG_TARGET")
19
+ fi
20
+
21
+ mkdir -p zig-out/bin traces
22
+ zig build-exe src/main.zig "${target_args[@]}" -O Debug -femit-bin=zig-out/bin/zmr
23
+
24
+ echo "== ZMR version =="
25
+ ./zig-out/bin/zmr version
26
+ ./zig-out/bin/zmr version --json
27
+
28
+ echo
29
+ echo "== Public schema discovery =="
30
+ ./zig-out/bin/zmr schemas --json
31
+
32
+ echo
33
+ echo "== Validate demo scenarios =="
34
+ ./zig-out/bin/zmr validate examples/demo-fake.json
35
+ ./zig-out/bin/zmr validate examples/demo-failure.json
36
+ ./zig-out/bin/zmr validate examples/android-app-onboarding.json
37
+ ./zig-out/bin/zmr validate examples/android-app-referral-deep-link.json
38
+ ./zig-out/bin/zmr validate examples/android-app-error-state.json
39
+ ./zig-out/bin/zmr validate examples/android-shim-smoke.json
40
+ ./zig-out/bin/zmr validate examples/ios-smoke.json
41
+ ./zig-out/bin/zmr validate examples/ios-dev-client-open-link.json
42
+ ./zig-out/bin/zmr validate examples/ios-shim-smoke.json
43
+
44
+ echo
45
+ echo "== Validate diagnostics: field and line location =="
46
+ INVALID_SCENARIO="traces/demo-invalid-scenario.json"
47
+ printf '{\n "name": "invalid",\n "steps": "nope"\n}\n' > "$INVALID_SCENARIO"
48
+ if ./zig-out/bin/zmr validate "$INVALID_SCENARIO" --json; then
49
+ echo "expected invalid scenario validation to fail" >&2
50
+ exit 1
51
+ fi
52
+
53
+ echo
54
+ echo "== Doctor: fake local toolchain =="
55
+ ./zig-out/bin/zmr doctor --adb ./tests/fake-adb.sh --android-shim ./tests/fake-android-shim.sh --xcrun ./tests/fake-xcrun.sh --ios-shim ./tests/fake-ios-shim.sh
56
+
57
+ echo
58
+ echo "== Doctor: remediation hint JSON =="
59
+ DOCTOR_HINT_JSON="$(./zig-out/bin/zmr doctor --json --adb ./tests/fake-adb.sh --android-shim ./definitely-missing-android-shim --xcrun ./tests/fake-xcrun.sh)"
60
+ printf '%s\n' "$DOCTOR_HINT_JSON"
61
+ case "$DOCTOR_HINT_JSON" in
62
+ *'"name":"android-shim"'*'"errorCode":"setup.android_shim.not_found"'*'"hint":"Run npx zmr-install-android-shim'*)
63
+ ;;
64
+ *)
65
+ echo "expected doctor --json to include android-shim remediation hint" >&2
66
+ exit 1
67
+ ;;
68
+ esac
69
+
70
+ echo
71
+ echo "== Doctor: no ready devices diagnostics =="
72
+ EMPTY_ADB="traces/demo-fake-adb-empty.sh"
73
+ EMPTY_XCRUN="traces/demo-fake-xcrun-empty.sh"
74
+ cat > "$EMPTY_ADB" <<'SH'
75
+ #!/usr/bin/env bash
76
+ set -euo pipefail
77
+ case "${1:-}" in
78
+ version) printf 'Android Debug Bridge version 1.0.41\n' ;;
79
+ devices) printf 'List of devices attached\n' ;;
80
+ *) exit 2 ;;
81
+ esac
82
+ SH
83
+ cat > "$EMPTY_XCRUN" <<'SH'
84
+ #!/usr/bin/env bash
85
+ set -euo pipefail
86
+ if [[ "${1:-}" == "--version" ]]; then
87
+ printf 'xcrun version 70\n'
88
+ exit 0
89
+ fi
90
+ if [[ "${1:-}" == "simctl" && "${2:-}" == "list" && "${3:-}" == "devices" && "${4:-}" == "--json" ]]; then
91
+ printf '{"devices":{"com.apple.CoreSimulator.SimRuntime.iOS-18-5":[]}}\n'
92
+ exit 0
93
+ fi
94
+ if [[ "${1:-}" == "devicectl" && "${2:-}" == "list" && "${3:-}" == "devices" ]]; then
95
+ while [[ $# -gt 0 ]]; do
96
+ if [[ "${1:-}" == "--json-output" ]]; then
97
+ printf '{"result":{"devices":[]}}\n' > "${2:-}"
98
+ exit 0
99
+ fi
100
+ shift
101
+ done
102
+ fi
103
+ exit 2
104
+ SH
105
+ chmod +x "$EMPTY_ADB" "$EMPTY_XCRUN"
106
+ NO_DEVICE_JSON="$(./zig-out/bin/zmr doctor --json --adb "$EMPTY_ADB" --xcrun "$EMPTY_XCRUN")"
107
+ printf '%s\n' "$NO_DEVICE_JSON"
108
+ case "$NO_DEVICE_JSON" in
109
+ *'"name":"android-devices"'*'"errorCode":"setup.android.no_devices"'*'"name":"ios-simulators"'*'"errorCode":"setup.ios.no_booted_simulators"'*'"name":"ios-physical-devices"'*'"errorCode":"setup.ios.no_physical_devices"'*)
110
+ ;;
111
+ *)
112
+ echo "expected doctor --json to warn when no Android, iOS simulator, or physical iOS devices are ready" >&2
113
+ exit 1
114
+ ;;
115
+ esac
116
+ if ./zig-out/bin/zmr doctor --strict --json --adb "$EMPTY_ADB" --xcrun "$EMPTY_XCRUN" > traces/demo-doctor-strict.json; then
117
+ echo "expected doctor --strict to fail when setup checks need attention" >&2
118
+ exit 1
119
+ fi
120
+ grep -q '"ok":false' traces/demo-doctor-strict.json
121
+
122
+ echo
123
+ echo "== Doctor: config field diagnostics =="
124
+ DOCTOR_BAD_CONFIG="traces/demo-bad-config.json"
125
+ cat > "$DOCTOR_BAD_CONFIG" <<'JSON'
126
+ {
127
+ "schemaVersion": 1,
128
+ "scripts": {
129
+ "android": ""
130
+ }
131
+ }
132
+ JSON
133
+ DOCTOR_BAD_CONFIG_JSON="$(./zig-out/bin/zmr doctor --json --config "$DOCTOR_BAD_CONFIG" --adb ./tests/fake-adb.sh --xcrun ./tests/fake-xcrun.sh)"
134
+ printf '%s\n' "$DOCTOR_BAD_CONFIG_JSON"
135
+ case "$DOCTOR_BAD_CONFIG_JSON" in
136
+ *'"name":"config"'*'"errorCode":"config.empty_string"'*'ConfigFieldMustBeNonEmptyString'*'"fieldPath":"$.scripts.android"'*)
137
+ ;;
138
+ *)
139
+ echo "expected doctor --config to include config fieldPath diagnostics" >&2
140
+ exit 1
141
+ ;;
142
+ esac
143
+
144
+ echo
145
+ echo "== Doctor: config smoke scenario checks =="
146
+ DOCTOR_CONFIG="traces/demo-doctor-config.json"
147
+ DOCTOR_INVALID_SMOKE="traces/demo-invalid-smoke-scenario.json"
148
+ printf '{\n "name": "invalid smoke",\n "steps": "nope"\n}\n' > "$DOCTOR_INVALID_SMOKE"
149
+ cat > "$DOCTOR_CONFIG" <<'JSON'
150
+ {
151
+ "schemaVersion": 1,
152
+ "android": {
153
+ "smokeScenario": "traces/demo-invalid-smoke-scenario.json"
154
+ },
155
+ "ios": {
156
+ "smokeScenario": "./definitely-missing-ios-smoke.json"
157
+ },
158
+ "tools": {
159
+ "adbPath": "./tests/fake-adb.sh",
160
+ "xcrunPath": "./tests/fake-xcrun.sh"
161
+ }
162
+ }
163
+ JSON
164
+ DOCTOR_CONFIG_JSON="$(./zig-out/bin/zmr doctor --json --config "$DOCTOR_CONFIG")"
165
+ printf '%s\n' "$DOCTOR_CONFIG_JSON"
166
+ case "$DOCTOR_CONFIG_JSON" in
167
+ *'"name":"ios-smoke-scenario"'*'"hint":"Run npx zmr-wizard'*'ios.smokeScenario'*)
168
+ ;;
169
+ *)
170
+ echo "expected doctor --config to include ios.smokeScenario remediation hint" >&2
171
+ exit 1
172
+ ;;
173
+ esac
174
+ case "$DOCTOR_CONFIG_JSON" in
175
+ *'"name":"android-smoke-scenario"'*'scenario.invalid'*'"hint":"Run zmr validate on the configured Android smoke scenario'*)
176
+ ;;
177
+ *)
178
+ echo "expected doctor --config to include android smoke scenario validation hint" >&2
179
+ exit 1
180
+ ;;
181
+ esac
182
+
183
+ echo
184
+ echo "== Devices: fake Android =="
185
+ ./zig-out/bin/zmr devices --adb ./tests/fake-adb.sh
186
+ ./zig-out/bin/zmr devices --json --adb ./tests/fake-adb.sh
187
+
188
+ echo
189
+ echo "== Devices: fake iOS simulator =="
190
+ ./zig-out/bin/zmr devices --platform ios --xcrun ./tests/fake-xcrun.sh
191
+ ./zig-out/bin/zmr devices --json --platform ios --xcrun ./tests/fake-xcrun.sh
192
+
193
+ echo
194
+ echo "== Init an app-local .zmr workspace =="
195
+ rm -rf traces/demo-init-app
196
+ ./zig-out/bin/zmr init --app --json --dir traces/demo-init-app --app-id com.example.demoapp
197
+ (
198
+ cd traces/demo-init-app
199
+ "$ROOT/zig-out/bin/zmr" validate .zmr/android-smoke.json
200
+ "$ROOT/zig-out/bin/zmr" validate .zmr/ios-smoke.json
201
+ "$ROOT/zig-out/bin/zmr" doctor --strict --json \
202
+ --config .zmr/config.json \
203
+ --adb "$ROOT/tests/fake-adb.sh" \
204
+ --xcrun "$ROOT/tests/fake-xcrun.sh"
205
+ )
206
+
207
+ echo
208
+ echo "== Import a mobile-flow YAML scenario =="
209
+ cat > traces/demo-flow-yaml-flow.yaml <<'YAML'
210
+ appId: com.example.demoapp
211
+ name: Imported demo smoke
212
+ ---
213
+ - launchApp
214
+ - tapOn: "Sign in"
215
+ - inputText: "agent@example.com"
216
+ - hideKeyboard
217
+ - assertVisible:
218
+ id: dashboard-title
219
+ - takeScreenshot: "after-import"
220
+ YAML
221
+ ./zig-out/bin/zmr import flow-yaml traces/demo-flow-yaml-flow.yaml --out traces/demo-imported-flow.json --json
222
+ ./zig-out/bin/zmr validate traces/demo-imported-flow.json
223
+
224
+ rm -rf traces/demo-fake-android traces/demo-config-redaction traces/demo-failure traces/demo-device-matrix traces/demo-android-shim traces/demo-fake-ios traces/demo-ios-shim traces/demo-rpc-session traces/demo-typescript-client traces/demo-python-client traces/demo-swift-client traces/demo-kotlin-client traces/demo-go-client traces/demo-rust-client traces/demo-fake-android.zmrtrace traces/demo-fake-android-redacted.zmrtrace
225
+ rm -rf traces/demo-android-shim.zmrtrace traces/demo-android-shim-redacted.zmrtrace traces/demo-fake-ios.zmrtrace traces/demo-fake-ios-redacted.zmrtrace traces/demo-ios-shim.zmrtrace traces/demo-ios-shim-redacted.zmrtrace traces/demo-rpc-session-redacted.zmrtrace traces/demo-typescript-client-redacted.zmrtrace traces/demo-python-client-redacted.zmrtrace traces/demo-swift-client-redacted.zmrtrace traces/demo-kotlin-client-redacted.zmrtrace traces/demo-go-client-redacted.zmrtrace traces/demo-rust-client-redacted.zmrtrace
226
+ rm -f traces/demo-redaction-config.json traces/demo-doctor-config.json traces/demo-bad-config.json traces/demo-doctor-strict.json traces/demo-invalid-smoke-scenario.json traces/demo-device-matrix.json traces/demo-fake-adb-empty.sh traces/demo-fake-xcrun-empty.sh traces/demo-flow-yaml-flow.yaml traces/demo-imported-flow.json
227
+
228
+ echo
229
+ echo "== Run fake Android auth probe =="
230
+ ./zig-out/bin/zmr run examples/demo-fake.json \
231
+ --device fake-android-1 \
232
+ --adb ./tests/fake-adb.sh \
233
+ --trace-dir traces/demo-fake-android \
234
+ --json
235
+ tail -n 5 traces/demo-fake-android/events.jsonl
236
+
237
+ echo
238
+ echo "== Export fake Android trace bundle =="
239
+ ./zig-out/bin/zmr export traces/demo-fake-android --out traces/demo-fake-android.zmrtrace
240
+ ./zig-out/bin/zmr export traces/demo-fake-android --out traces/demo-fake-android-redacted.zmrtrace --redact
241
+
242
+ echo
243
+ echo "== Run fake Android/iOS device matrix =="
244
+ cat > traces/demo-device-matrix.json <<'JSON'
245
+ {
246
+ "runs": 1,
247
+ "appId": "com.example.mobiletest",
248
+ "devices": [
249
+ {
250
+ "name": "android-fake",
251
+ "platform": "android",
252
+ "serial": "fake-android-1",
253
+ "scenario": "examples/demo-fake.json",
254
+ "adb": "./tests/fake-adb.sh"
255
+ },
256
+ {
257
+ "name": "ios-simulator-fake",
258
+ "platform": "ios",
259
+ "iosDeviceType": "simulator",
260
+ "serial": "fake-ios-1",
261
+ "scenario": "examples/ios-smoke.json",
262
+ "xcrun": "./tests/fake-xcrun.sh",
263
+ "iosShim": "./tests/fake-ios-shim.sh"
264
+ },
265
+ {
266
+ "name": "ios-physical-fake",
267
+ "platform": "ios",
268
+ "iosDeviceType": "physical",
269
+ "serial": "fake-physical-ios-1",
270
+ "scenario": "examples/ios-shim-smoke.json",
271
+ "xcrun": "./tests/fake-xcrun.sh",
272
+ "iosShim": "./tests/fake-ios-shim.sh"
273
+ }
274
+ ]
275
+ }
276
+ JSON
277
+ ./scripts/device-matrix.sh \
278
+ --matrix traces/demo-device-matrix.json \
279
+ --trace-root traces/demo-device-matrix \
280
+ --min-pass-rate 100 \
281
+ --max-failures 0
282
+ cat traces/demo-device-matrix/summary.json
283
+
284
+ echo
285
+ echo "== Run config-driven trace redaction demo =="
286
+ cat > traces/demo-redaction-config.json <<'JSON'
287
+ {
288
+ "schemaVersion": 1,
289
+ "redaction": {
290
+ "denylistResourceIds": ["password-input"],
291
+ "allowlistResourceIds": ["e2e-auth-probe-marker"]
292
+ }
293
+ }
294
+ JSON
295
+ ./zig-out/bin/zmr run examples/demo-fake.json \
296
+ --config traces/demo-redaction-config.json \
297
+ --device fake-android-1 \
298
+ --adb ./tests/fake-adb.sh \
299
+ --trace-dir traces/demo-config-redaction
300
+ grep -R -F -q '"resourceId":"[REDACTED:resourceId]"' traces/demo-config-redaction/artifacts
301
+
302
+ echo
303
+ echo "== Explain a fake failing trace =="
304
+ mkdir -p traces/demo-failure
305
+ if ./zig-out/bin/zmr run examples/demo-failure.json \
306
+ --device fake-android-1 \
307
+ --adb ./tests/fake-adb.sh \
308
+ --trace-dir traces/demo-failure \
309
+ --json \
310
+ 2> traces/demo-failure/expected-error.log; then
311
+ echo "expected demo failure scenario to fail" >&2
312
+ exit 1
313
+ fi
314
+ ./zig-out/bin/zmr explain traces/demo-failure
315
+ ./zig-out/bin/zmr explain traces/demo-failure --json
316
+
317
+ echo
318
+ echo "== Run fake JSON-RPC agent session with live trace export =="
319
+ printf '%s\n' \
320
+ '{"jsonrpc":"2.0","id":1,"method":"session.create","params":{}}' \
321
+ '{"jsonrpc":"2.0","id":2,"method":"runner.capabilities","params":{}}' \
322
+ '{"jsonrpc":"2.0","id":3,"method":"app.openLink","params":{"url":"exampleapp://e2e-auth?probe=1"}}' \
323
+ '{"jsonrpc":"2.0","id":4,"method":"observe.snapshot","params":{}}' \
324
+ '{"jsonrpc":"2.0","id":5,"method":"trace.events","params":{"afterSeq":0,"limit":20}}' \
325
+ '{"jsonrpc":"2.0","id":6,"method":"trace.export","params":{"out":"traces/demo-rpc-session-redacted.zmrtrace","redact":true}}' \
326
+ | ./zig-out/bin/zmr serve \
327
+ --transport stdio \
328
+ --device fake-android-1 \
329
+ --app-id com.example.mobiletest \
330
+ --adb ./tests/fake-adb.sh \
331
+ --trace-dir traces/demo-rpc-session
332
+ tail -n 5 traces/demo-rpc-session/events.jsonl
333
+
334
+ echo
335
+ echo "== Run TypeScript reference client against zmr serve fake-device backend =="
336
+ node clients/typescript/examples/fake-session.mjs
337
+ tail -n 5 traces/demo-typescript-client/events.jsonl
338
+
339
+ echo
340
+ echo "== Run Python reference client against zmr serve fake-device backend =="
341
+ python3 clients/python/examples/fake_session.py
342
+ tail -n 5 traces/demo-python-client/events.jsonl
343
+
344
+ echo
345
+ echo "== Run Swift reference client against zmr serve fake-device backend =="
346
+ (
347
+ cd clients/swift
348
+ swift run ZMRFakeSession \
349
+ --zmr "$ROOT/zig-out/bin/zmr" \
350
+ --adb "$ROOT/tests/fake-adb.sh" \
351
+ --trace-dir "$ROOT/traces/demo-swift-client" \
352
+ --trace-out "$ROOT/traces/demo-swift-client-redacted.zmrtrace"
353
+ )
354
+
355
+ echo
356
+ echo "== Run Kotlin reference client against zmr serve fake-device backend =="
357
+ if command -v gradle >/dev/null 2>&1; then
358
+ gradle -p clients/kotlin runFakeSession \
359
+ -Pzmr="$ROOT/zig-out/bin/zmr" \
360
+ -Padb="$ROOT/tests/fake-adb.sh" \
361
+ -PtraceDir="$ROOT/traces/demo-kotlin-client" \
362
+ -PtraceOut="$ROOT/traces/demo-kotlin-client-redacted.zmrtrace"
363
+ else
364
+ echo "skip kotlin demo: gradle not found"
365
+ fi
366
+
367
+ echo
368
+ echo "== Run Go reference client against zmr serve fake-device backend =="
369
+ (
370
+ cd clients/go
371
+ go run ./examples/fake-session \
372
+ --zmr "$ROOT/zig-out/bin/zmr" \
373
+ --adb "$ROOT/tests/fake-adb.sh" \
374
+ --trace-dir "$ROOT/traces/demo-go-client" \
375
+ --trace-out "$ROOT/traces/demo-go-client-redacted.zmrtrace"
376
+ )
377
+
378
+ echo
379
+ echo "== Run Rust reference client against zmr serve fake-device backend =="
380
+ cargo run --quiet \
381
+ --manifest-path clients/rust/Cargo.toml \
382
+ --example fake_session \
383
+ -- \
384
+ --zmr "$ROOT/zig-out/bin/zmr" \
385
+ --adb "$ROOT/tests/fake-adb.sh" \
386
+ --trace-dir "$ROOT/traces/demo-rust-client" \
387
+ --trace-out "$ROOT/traces/demo-rust-client-redacted.zmrtrace"
388
+
389
+ echo
390
+ echo "== Run fake Android shim selector demo =="
391
+ ./zig-out/bin/zmr run examples/android-shim-smoke.json \
392
+ --device fake-android-1 \
393
+ --adb ./tests/fake-adb.sh \
394
+ --android-shim ./tests/fake-android-shim.sh \
395
+ --trace-dir traces/demo-android-shim
396
+ tail -n 5 traces/demo-android-shim/events.jsonl
397
+
398
+ echo
399
+ echo "== Export fake Android shim trace bundle =="
400
+ ./zig-out/bin/zmr export traces/demo-android-shim --out traces/demo-android-shim.zmrtrace
401
+ ./zig-out/bin/zmr export traces/demo-android-shim --out traces/demo-android-shim-redacted.zmrtrace --redact
402
+
403
+ echo
404
+ echo "== Run fake iOS simulator smoke =="
405
+ ./zig-out/bin/zmr run examples/ios-smoke.json \
406
+ --platform ios \
407
+ --device fake-ios-1 \
408
+ --xcrun ./tests/fake-xcrun.sh \
409
+ --ios-shim ./tests/fake-ios-shim.sh \
410
+ --trace-dir traces/demo-fake-ios
411
+ tail -n 5 traces/demo-fake-ios/events.jsonl
412
+
413
+ echo
414
+ echo "== Export fake iOS simulator trace bundle =="
415
+ ./zig-out/bin/zmr export traces/demo-fake-ios --out traces/demo-fake-ios.zmrtrace
416
+ ./zig-out/bin/zmr export traces/demo-fake-ios --out traces/demo-fake-ios-redacted.zmrtrace --redact
417
+
418
+ echo
419
+ echo "== Run fake iOS shim selector demo =="
420
+ ./zig-out/bin/zmr run examples/ios-shim-smoke.json \
421
+ --platform ios \
422
+ --device fake-ios-1 \
423
+ --xcrun ./tests/fake-xcrun.sh \
424
+ --ios-shim ./tests/fake-ios-shim.sh \
425
+ --trace-dir traces/demo-ios-shim
426
+ tail -n 5 traces/demo-ios-shim/events.jsonl
427
+
428
+ echo
429
+ echo "== Export fake iOS shim trace bundle =="
430
+ ./zig-out/bin/zmr export traces/demo-ios-shim --out traces/demo-ios-shim.zmrtrace
431
+ ./zig-out/bin/zmr export traces/demo-ios-shim --out traces/demo-ios-shim-redacted.zmrtrace --redact
432
+
433
+ echo
434
+ echo "Demo traces:"
435
+ echo " $ROOT/traces/demo-fake-android"
436
+ echo " $ROOT/traces/demo-init-app"
437
+ echo " $ROOT/traces/demo-failure"
438
+ echo " $ROOT/traces/demo-device-matrix"
439
+ echo " $ROOT/traces/demo-android-shim"
440
+ echo " $ROOT/traces/demo-fake-ios"
441
+ echo " $ROOT/traces/demo-ios-shim"
442
+ echo " $ROOT/traces/demo-rpc-session"
443
+ echo " $ROOT/traces/demo-typescript-client"
444
+ echo " $ROOT/traces/demo-python-client"
445
+ echo " $ROOT/traces/demo-swift-client"
446
+ echo " $ROOT/traces/demo-kotlin-client"
447
+ echo " $ROOT/traces/demo-go-client"
448
+ echo " $ROOT/traces/demo-rust-client"
449
+ echo " $ROOT/traces/demo-fake-android.zmrtrace"
450
+ echo " $ROOT/traces/demo-fake-android-redacted.zmrtrace"
451
+ echo " $ROOT/traces/demo-android-shim.zmrtrace"
452
+ echo " $ROOT/traces/demo-android-shim-redacted.zmrtrace"
453
+ echo " $ROOT/traces/demo-fake-ios.zmrtrace"
454
+ echo " $ROOT/traces/demo-fake-ios-redacted.zmrtrace"
455
+ echo " $ROOT/traces/demo-ios-shim.zmrtrace"
456
+ echo " $ROOT/traces/demo-ios-shim-redacted.zmrtrace"
457
+ echo " $ROOT/traces/demo-rpc-session-redacted.zmrtrace"
458
+ echo " $ROOT/traces/demo-typescript-client-redacted.zmrtrace"
459
+ echo " $ROOT/traces/demo-python-client-redacted.zmrtrace"
460
+ echo " $ROOT/traces/demo-swift-client-redacted.zmrtrace"
461
+ echo " $ROOT/traces/demo-kotlin-client-redacted.zmrtrace"
462
+ echo " $ROOT/traces/demo-go-client-redacted.zmrtrace"
463
+ echo " $ROOT/traces/demo-rust-client-redacted.zmrtrace"
464
+ echo " $ROOT/viewer/index.html"