@deeeed/metamask-harness 0.92.11 → 0.92.12

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/CHANGELOG.md CHANGED
@@ -2,6 +2,16 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ### Changed
6
+
7
+ - Refresh Terminal contract goldens for the shipped console-error window, capture-provider metadata and engine evidence inventories.
8
+
9
+ ## 0.92.12 - 2026-10-16
10
+
11
+ ### Fixed
12
+
13
+ - Stop checkout-owned idb companions with the selected simulator identity, even when Metro and the simulator are already stopped; preserve other devices, checkouts and reused process IDs.
14
+
5
15
  ## 0.92.11 - 2026-10-16
6
16
 
7
17
  ### Changed
@@ -0,0 +1,68 @@
1
+ #!/usr/bin/env bash
2
+ # Stop only companions bound to this checkout and its selected simulator.
3
+
4
+ _idb_companion_identity() {
5
+ ps -p "$1" -o pid=,pgid=,lstart=,comm= 2>/dev/null
6
+ }
7
+
8
+ # 1 is foreign; 2 is unknown and must not authorize a signal.
9
+ _idb_companion_owned() {
10
+ local repo="$1" udid="$2" pid="$3" identity="$4" current cwd args
11
+ current="$(_idb_companion_identity "$pid")"
12
+ [ -n "$current" ] && [ "$current" = "$identity" ] || return 2
13
+ case "$current" in *'/idb_companion'|*' idb_companion') ;; *) return 1 ;; esac
14
+ cwd="$(lsof -a -p "$pid" -d cwd -Fn 2>/dev/null | sed -n 's/^n//p')"
15
+ [ -n "$cwd" ] || return 2
16
+ case "$cwd" in "$repo"|"$repo/"*) ;; *) return 1 ;; esac
17
+ [ -n "$udid" ] || return 2
18
+ args="$(ps -p "$pid" -o args= 2>/dev/null)" || return 2
19
+ case " $args " in *" --udid $udid "*|*" --udid=$udid "*) ;; *) return 1 ;; esac
20
+ [ "$(_idb_companion_identity "$pid")" = "$identity" ] || return 2
21
+ }
22
+
23
+ stop_checkout_idb_companions() {
24
+ local repo="$1" udid="${2:-}" pids pid identity status signal current attempt stopped
25
+ if pids="$(pgrep -u "$(id -u)" -x idb_companion 2>/dev/null)"; then :
26
+ else
27
+ status=$?
28
+ [ "$status" -eq 1 ] && return 0
29
+ printf 'Could not inspect idb companions. Next: mm-harness status --target "%s"\n' "$repo" >&2
30
+ return 1
31
+ fi
32
+ for pid in $pids; do
33
+ case "$pid" in ''|*[!0-9]*) return 1 ;; esac
34
+ [ "$pid" -gt 0 ] || return 1
35
+ identity="$(_idb_companion_identity "$pid")"
36
+ if [ -z "$identity" ] && ! kill -0 "$pid" 2>/dev/null; then continue; fi
37
+ if _idb_companion_owned "$repo" "$udid" "$pid" "$identity"; then :
38
+ else
39
+ status=$?
40
+ [ "$status" -eq 1 ] && continue
41
+ printf 'Companion ownership is unknown. Next: mm-harness status --target "%s"\n' "$repo" >&2
42
+ return 1
43
+ fi
44
+ stopped=false
45
+ for signal in TERM KILL; do
46
+ if ! _idb_companion_owned "$repo" "$udid" "$pid" "$identity"; then
47
+ printf 'Companion ownership changed. Next: mm-harness status --target "%s"\n' "$repo" >&2
48
+ return 1
49
+ fi
50
+ kill -"$signal" "$pid" 2>/dev/null || true
51
+ for attempt in $(seq 1 20); do
52
+ current="$(_idb_companion_identity "$pid")"
53
+ if [ -z "$current" ] && ! kill -0 "$pid" 2>/dev/null; then stopped=true; break; fi
54
+ if [ "$current" != "$identity" ]; then
55
+ printf 'Companion identity changed during stop. Next: mm-harness status --target "%s"\n' "$repo" >&2
56
+ return 1
57
+ fi
58
+ sleep 0.1
59
+ done
60
+ [ "$stopped" = true ] && break
61
+ done
62
+ if [ "$stopped" != true ]; then
63
+ printf 'Companion %s did not stop. Next: mm-harness status --target "%s"\n' "$pid" "$repo" >&2
64
+ return 1
65
+ fi
66
+ printf 'Stopped checkout idb companion %s\n' "$pid" >&2
67
+ done
68
+ }
@@ -32,11 +32,12 @@ if ! command -v recipe_runtime_dir >/dev/null 2>&1; then
32
32
  exit 1
33
33
  fi
34
34
 
35
+ . "$MOBILE_STOP_DIR/../shared/resolve-slot-ports.sh"
36
+
35
37
  # No explicit port: resolve the checkout's own (slot context first, then the
36
38
  # pool/formula fallbacks) so we stop THIS slot's Metro, not the 8081 default.
37
39
  if [ -z "$PORT" ]; then
38
40
  # shellcheck disable=SC1091
39
- . "$MOBILE_STOP_DIR/../shared/resolve-slot-ports.sh"
40
41
  resolved_port="$(resolve_mobile_runtime_ports "$TARGET" 2>/dev/null | sed -n 's/^WATCHER_PORT=//p' | head -1 || true)"
41
42
  PORT="${resolved_port:-8081}"
42
43
  fi
@@ -56,6 +57,15 @@ else
56
57
  printf 'Metro not running on port %s — nothing to stop\n' "$PORT" >&2
57
58
  fi
58
59
 
60
+ # Companion cleanup retains the selected device and checkout boundary.
61
+ . "$MOBILE_STOP_DIR/lib/idb-companion.sh"
62
+ companion_udid="${SIM_UDID:-}"
63
+ if [ -z "$companion_udid" ]; then
64
+ mobile_identity="$(resolve_mobile_runtime_ports "$TARGET" 2>/dev/null || true)"
65
+ companion_udid="$(printf '%s\n' "$mobile_identity" | sed -n 's/^SIM_UDID=//p' | head -1)"
66
+ fi
67
+ stop_checkout_idb_companions "$TARGET" "$companion_udid" || exit 1
68
+
59
69
  # The stop decision is made; everything below is best-effort cleanup (pid file,
60
70
  # leaked-bundler sweep, tmux window). None of it may fail the command — the
61
71
  # idempotent-stop contract is already satisfied. Drop set -e for the tail so an
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deeeed/metamask-harness",
3
- "version": "0.92.11",
3
+ "version": "0.92.12",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "mm-harness": "bin/mm-harness"