@deeeed/metamask-harness 0.41.0 → 0.42.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 (44) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/README.md +7 -0
  3. package/adapters/manifest.json +25 -1
  4. package/adapters/mobile/bridge-runtime/cdp-bridge.cjs +70 -10
  5. package/adapters/mobile/bridge-runtime/console-forwarder.cjs +115 -15
  6. package/adapters/mobile/bridge-runtime/lib/cdp-broker.cjs +752 -0
  7. package/adapters/mobile/bridge-runtime/lib/devtools-proxy.cjs +177 -0
  8. package/adapters/mobile/bridge-runtime/lib/target-discovery.cjs +13 -3
  9. package/adapters/mobile/coalesce-metro-log.cjs +24 -0
  10. package/adapters/mobile/launch-metro.cjs +9 -8
  11. package/adapters/mobile/metro-log-generation.cjs +106 -0
  12. package/adapters/mobile/reload-app.mjs +67 -0
  13. package/adapters/mobile/start-console-forwarder.sh +17 -2
  14. package/adapters/mobile/start-metro.sh +23 -18
  15. package/adapters/mobile/stop-metro.sh +15 -7
  16. package/adapters/shared/open-debug.mjs +172 -2
  17. package/adapters/shared/reap-checkout-metros.sh +17 -0
  18. package/dist/adapters/extension/network-observer.js +300 -0
  19. package/dist/adapters/mobile/metro-env.js +0 -5
  20. package/dist/adapters/mobile/prepare.js +1 -3
  21. package/dist/adapters/mobile/runtime-decision.js +6 -30
  22. package/dist/adapters.js +14 -1
  23. package/dist/cli-commands.js +6 -3
  24. package/dist/cli.js +4 -0
  25. package/dist/command-contract.js +3 -0
  26. package/dist/commands/call.js +45 -20
  27. package/dist/commands/launch/index.js +25 -5
  28. package/dist/commands/reload.js +80 -0
  29. package/dist/commands/run.js +49 -22
  30. package/dist/mm-harness-cli.js +17 -1
  31. package/dist/network-observation.js +271 -0
  32. package/docs/NETWORK-CAPTURE.md +98 -0
  33. package/docs/QA.md +2 -0
  34. package/docs/RECIPES.md +10 -0
  35. package/library/actions/mobile/app/network_assert.mjs +14 -0
  36. package/library/actions/mobile/app/network_capture.mjs +72 -0
  37. package/library/actions/mobile/platform/bridge.mjs +7 -2
  38. package/library/actions/shared/app/network-artifact.mjs +10 -0
  39. package/library/actions/shared/app/network-assert.mjs +154 -0
  40. package/library/manifests/extension.action-manifest.json +88 -0
  41. package/library/manifests/mobile.action-manifest.json +107 -0
  42. package/library/recipes/mobile/perps/performance.recipe.json +11 -11
  43. package/package.json +1 -1
  44. package/scripts/completions.sh +2 -1
@@ -1119,6 +1119,94 @@
1119
1119
  }
1120
1120
  ]
1121
1121
  },
1122
+ "app.network_capture": {
1123
+ "description": "Capture redacted HTTP requests between named Recipe Protocol v1 nodes through the adapter's persistent Network observer.",
1124
+ "examples": [
1125
+ {
1126
+ "action": "app.network_capture",
1127
+ "phase": "start",
1128
+ "id": "perps-home",
1129
+ "url_includes": ["api.hyperliquid.xyz/info"],
1130
+ "methods": ["POST"],
1131
+ "body_json_fields": ["type", "req.coin", "dex"],
1132
+ "intent": "Start the redacted request window",
1133
+ "next": "exercise-flow"
1134
+ },
1135
+ {
1136
+ "action": "app.network_capture",
1137
+ "phase": "end",
1138
+ "id": "perps-home",
1139
+ "artifact_path": "network/perps-home.json",
1140
+ "intent": "End and index the redacted request window",
1141
+ "next": "assert-network"
1142
+ }
1143
+ ],
1144
+ "schema": {
1145
+ "type": "object",
1146
+ "properties": {
1147
+ "phase": { "type": "string", "enum": ["start", "end"] },
1148
+ "id": { "type": "string" },
1149
+ "url_includes": {
1150
+ "type": "array",
1151
+ "items": { "type": "string" }
1152
+ },
1153
+ "methods": {
1154
+ "type": "array",
1155
+ "items": { "type": "string" }
1156
+ },
1157
+ "body_json_fields": {
1158
+ "type": "array",
1159
+ "items": { "type": "string" }
1160
+ },
1161
+ "max_requests": { "type": "integer" },
1162
+ "max_duration_ms": { "type": "integer" },
1163
+ "artifact_path": { "type": "string" }
1164
+ },
1165
+ "required": ["phase", "id"],
1166
+ "additionalProperties": false
1167
+ },
1168
+ "execution_capabilities": []
1169
+ },
1170
+ "app.network_assert": {
1171
+ "description": "Assert a previously indexed app.network_capture summary without hiding its diagnostics on failure.",
1172
+ "examples": [
1173
+ {
1174
+ "action": "app.network_assert",
1175
+ "id": "perps-home",
1176
+ "artifact_path": "network/perps-home.json",
1177
+ "required_status": "complete",
1178
+ "required_min_requests": 1,
1179
+ "required_types": ["allMids"],
1180
+ "forbidden_types": ["candleSnapshot"],
1181
+ "intent": "Assert the indexed request summary",
1182
+ "next": "done"
1183
+ }
1184
+ ],
1185
+ "schema": {
1186
+ "type": "object",
1187
+ "properties": {
1188
+ "id": { "type": "string" },
1189
+ "artifact_path": { "type": "string" },
1190
+ "required_status": {
1191
+ "type": "string",
1192
+ "enum": ["complete", "partial", "unavailable"]
1193
+ },
1194
+ "required_min_requests": { "type": "integer" },
1195
+ "required_max_requests": { "type": "integer" },
1196
+ "required_types": {
1197
+ "type": "array",
1198
+ "items": { "type": "string" }
1199
+ },
1200
+ "forbidden_types": {
1201
+ "type": "array",
1202
+ "items": { "type": "string" }
1203
+ }
1204
+ },
1205
+ "required": ["id"],
1206
+ "additionalProperties": false
1207
+ },
1208
+ "execution_capabilities": []
1209
+ },
1122
1210
  "app.status": {
1123
1211
  "description": "Report the adapter's static status — platform, project root, resolved checkout shape, and headless compatibility mode (no live route or account).",
1124
1212
  "examples": [
@@ -1112,6 +1112,113 @@
1112
1112
  },
1113
1113
  "execution_capabilities": ["app-mutation"]
1114
1114
  },
1115
+ "app.network_capture": {
1116
+ "description": "Capture redacted HTTP requests between named Recipe Protocol v1 nodes through the adapter's persistent Network observer.",
1117
+ "examples": [
1118
+ {
1119
+ "action": "app.network_capture",
1120
+ "phase": "start",
1121
+ "id": "perps-home",
1122
+ "url_includes": ["api.hyperliquid.xyz/info"],
1123
+ "methods": ["POST"],
1124
+ "body_json_fields": ["type", "req.coin", "dex"],
1125
+ "intent": "Start the redacted request window",
1126
+ "next": "exercise-flow"
1127
+ },
1128
+ {
1129
+ "action": "app.network_capture",
1130
+ "phase": "end",
1131
+ "id": "perps-home",
1132
+ "artifact_path": "network/perps-home.json",
1133
+ "intent": "End and index the redacted request window",
1134
+ "next": "assert-network"
1135
+ }
1136
+ ],
1137
+ "schema": {
1138
+ "type": "object",
1139
+ "properties": {
1140
+ "phase": {
1141
+ "type": "string",
1142
+ "enum": ["start", "end"]
1143
+ },
1144
+ "id": {
1145
+ "type": "string"
1146
+ },
1147
+ "url_includes": {
1148
+ "type": "array",
1149
+ "items": { "type": "string" }
1150
+ },
1151
+ "methods": {
1152
+ "type": "array",
1153
+ "items": { "type": "string" }
1154
+ },
1155
+ "body_json_fields": {
1156
+ "type": "array",
1157
+ "items": { "type": "string" }
1158
+ },
1159
+ "max_requests": {
1160
+ "type": "integer"
1161
+ },
1162
+ "max_duration_ms": {
1163
+ "type": "integer"
1164
+ },
1165
+ "artifact_path": {
1166
+ "type": "string"
1167
+ }
1168
+ },
1169
+ "required": ["phase", "id"],
1170
+ "additionalProperties": false
1171
+ },
1172
+ "execution_capabilities": []
1173
+ },
1174
+ "app.network_assert": {
1175
+ "description": "Assert a previously indexed app.network_capture summary without hiding its diagnostics on failure.",
1176
+ "examples": [
1177
+ {
1178
+ "action": "app.network_assert",
1179
+ "id": "perps-home",
1180
+ "artifact_path": "network/perps-home.json",
1181
+ "required_status": "complete",
1182
+ "required_min_requests": 1,
1183
+ "required_types": ["allMids"],
1184
+ "forbidden_types": ["candleSnapshot"],
1185
+ "intent": "Assert the indexed request summary",
1186
+ "next": "done"
1187
+ }
1188
+ ],
1189
+ "schema": {
1190
+ "type": "object",
1191
+ "properties": {
1192
+ "id": {
1193
+ "type": "string"
1194
+ },
1195
+ "artifact_path": {
1196
+ "type": "string"
1197
+ },
1198
+ "required_status": {
1199
+ "type": "string",
1200
+ "enum": ["complete", "partial", "unavailable"]
1201
+ },
1202
+ "required_min_requests": {
1203
+ "type": "integer"
1204
+ },
1205
+ "required_max_requests": {
1206
+ "type": "integer"
1207
+ },
1208
+ "required_types": {
1209
+ "type": "array",
1210
+ "items": { "type": "string" }
1211
+ },
1212
+ "forbidden_types": {
1213
+ "type": "array",
1214
+ "items": { "type": "string" }
1215
+ }
1216
+ },
1217
+ "required": ["id"],
1218
+ "additionalProperties": false
1219
+ },
1220
+ "execution_capabilities": []
1221
+ },
1115
1222
  "app.status": {
1116
1223
  "description": "Report the adapter's static status — platform, project root, resolved checkout shape, and headless compatibility mode (no live route or account).",
1117
1224
  "examples": [
@@ -168,25 +168,25 @@
168
168
  "value": "{{params.content_variant}}",
169
169
  "equals": "trending",
170
170
  "cases": {
171
- "match": "assert-no-positions"
171
+ "match": "ensure-no-positions"
172
172
  },
173
173
  "default": "assert-position",
174
- "intent": "Prove either the existing position or the empty account before timing"
174
+ "intent": "Prepare either the existing position or an empty account before timing"
175
175
  },
176
- "assert-no-positions": {
177
- "action": "metamask.perps.assert_positions",
176
+ "ensure-no-positions": {
177
+ "action": "metamask.perps.ensure_positions",
178
178
  "state": "none",
179
179
  "mode": "all",
180
- "timeout_ms": 30000,
181
- "intent": "Prove the market-only account has no open positions",
182
- "next": "assert-no-orders"
180
+ "timeout_ms": 120000,
181
+ "intent": "Close all positions outside timing so the market-only account is empty",
182
+ "next": "ensure-no-orders"
183
183
  },
184
- "assert-no-orders": {
185
- "action": "metamask.perps.assert_orders",
184
+ "ensure-no-orders": {
185
+ "action": "metamask.perps.ensure_orders",
186
186
  "state": "none",
187
187
  "mode": "all",
188
- "timeout_ms": 30000,
189
- "intent": "Prove the market-only account has no open orders",
188
+ "timeout_ms": 120000,
189
+ "intent": "Cancel all orders outside timing so the market-only account is empty",
190
190
  "next": "select-account-switch-preparation"
191
191
  },
192
192
  "assert-position": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deeeed/metamask-harness",
3
- "version": "0.41.0",
3
+ "version": "0.42.0",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "mm-harness": "bin/mm-harness"
@@ -29,7 +29,7 @@ _mmh_bin() {
29
29
  return 1
30
30
  }
31
31
 
32
- _mmh_commands="launch stop logs debug fixtures actions call run doctor check checklist execution-template recipe-quality install verify cleanup completions"
32
+ _mmh_commands="launch stop logs debug reload fixtures actions call run doctor check checklist execution-template recipe-quality install verify cleanup completions"
33
33
 
34
34
  # Per-command flags (static, from the mm-harness surface).
35
35
  _mmh_flags_for() {
@@ -38,6 +38,7 @@ _mmh_flags_for() {
38
38
  stop) printf '%s' "--port --target --json" ;;
39
39
  logs) printf '%s' "--full --events --source --adapter --target --json" ;;
40
40
  debug) printf '%s' "--worker --dev-menu --adapter --target --json" ;;
41
+ reload) printf '%s' "--adapter --platform --target --json" ;;
41
42
  fixtures) printf '%s' "--from --dev --force --fixture --adapter --target --json" ;;
42
43
  checklist) printf '%s' "" ;;
43
44
  execution-template) printf '%s' "--dir --domain-dir --project-worker --project-name --package-templates --package-id --flow --run-mode --platform --domain --id --provenance --include-shadowed --no-include-shadowed --title --force --json" ;;