@ricsam/r5d-macos-vm 0.0.78 → 0.0.79

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.
@@ -3,8 +3,12 @@ set -euo pipefail
3
3
 
4
4
  export PATH="/opt/homebrew/bin:$HOME/.bun/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
5
5
  STATE_DIR="$HOME/Library/Application Support/r5d"
6
- LOCK_DIR="$STATE_DIR/worker-terminal-__WORKER_LABEL__.lock"
7
- START_SCRIPT="${0:A}"
6
+ LOCK_DIR="$STATE_DIR/worker-credential-authority.lock"
7
+ BOOT_SESSION_ID="$(/usr/sbin/sysctl -n kern.bootsessionuuid 2>/dev/null | /usr/bin/tr '[:upper:]' '[:lower:]' || true)"
8
+ if [[ ! "$BOOT_SESSION_ID" =~ ^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$ ]]; then
9
+ BOOT_SESSION_ID="unknown"
10
+ fi
11
+ RECOVERY_GUARD="$STATE_DIR/worker-lock-recovery-$BOOT_SESSION_ID.lock"
8
12
 
9
13
  mkdir -p "$STATE_DIR"
10
14
  chmod 700 "$STATE_DIR"
@@ -13,8 +17,8 @@ while ! mkdir "$LOCK_DIR" 2>/dev/null; do
13
17
  existing_pid="$(cat "$LOCK_DIR/pid" 2>/dev/null || true)"
14
18
  if [[ "$existing_pid" == <-> ]] && kill -0 "$existing_pid" 2>/dev/null; then
15
19
  existing_command="$(ps -ww -p "$existing_pid" -o command= 2>/dev/null || true)"
16
- if [[ -n "$existing_command" && "$existing_command" == *"$START_SCRIPT"* ]]; then
17
- print "r5d-worker is already running in another Terminal (PID $existing_pid)."
20
+ if [[ -n "$existing_command" && "$existing_command" == *"start-worker.command"* ]]; then
21
+ print "An r5d-worker credential authority is already running in another Terminal (PID $existing_pid)."
18
22
  read -r "?Press Return to close this window: "
19
23
  exit 0
20
24
  fi
@@ -29,12 +33,34 @@ while ! mkdir "$LOCK_DIR" 2>/dev/null; do
29
33
  continue
30
34
  fi
31
35
 
36
+ if ! mkdir "$RECOVERY_GUARD" 2>/dev/null; then
37
+ recovery_modified_at="$(stat -f %m "$RECOVERY_GUARD" 2>/dev/null || print 0)"
38
+ if [[ "$recovery_modified_at" == <-> ]] && (( current_epoch - recovery_modified_at >= 60 )); then
39
+ print "A prior worker-lock recovery was interrupted in this boot session. Reboot the VM before retrying."
40
+ read -r "?Press Return to close this window: "
41
+ exit 1
42
+ fi
43
+ sleep 1
44
+ continue
45
+ fi
46
+
47
+ # Re-read under the boot-scoped recovery guard. Without this second check,
48
+ # two stale-lock contenders can move a newly acquired live lock (ABA).
49
+ guarded_pid="$(cat "$LOCK_DIR/pid" 2>/dev/null || true)"
50
+ if [[ "$guarded_pid" == <-> ]] && kill -0 "$guarded_pid" 2>/dev/null; then
51
+ guarded_command="$(ps -ww -p "$guarded_pid" -o command= 2>/dev/null || true)"
52
+ if [[ -n "$guarded_command" && "$guarded_command" == *"start-worker.command"* ]]; then
53
+ rmdir "$RECOVERY_GUARD" 2>/dev/null || true
54
+ print "An r5d-worker credential authority is already running in another Terminal (PID $guarded_pid)."
55
+ read -r "?Press Return to close this window: "
56
+ exit 0
57
+ fi
58
+ fi
32
59
  stale_lock="$LOCK_DIR.stale.$$.$RANDOM"
33
60
  if mv "$LOCK_DIR" "$stale_lock" 2>/dev/null; then
34
61
  rm -rf "$stale_lock"
35
- else
36
- sleep 1
37
62
  fi
63
+ rmdir "$RECOVERY_GUARD" 2>/dev/null || true
38
64
  done
39
65
 
40
66
  print $$ > "$LOCK_DIR/pid"
@@ -66,6 +92,12 @@ wait "$worker_pid"
66
92
  worker_status=$?
67
93
  set -e
68
94
  print
69
- print "r5d-worker stopped with status $worker_status."
95
+ if [[ "$worker_status" == "77" ]]; then
96
+ print "r5d-worker staged a credential rotation without publishing the new secret."
97
+ print "Shut down and restart the entire r5d macOS VM before opening this launcher again."
98
+ print "Closing this window, logging out, or reopening Terminal is not sufficient."
99
+ else
100
+ print "r5d-worker stopped with status $worker_status."
101
+ fi
70
102
  read -r "?Press Return to close this window: "
71
103
  exit "$worker_status"
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@ricsam/r5d-macos-vm",
3
- "version": "0.0.78",
3
+ "version": "0.0.79",
4
4
  "type": "commonjs"
5
5
  }
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@ricsam/r5d-macos-vm",
3
- "version": "0.0.78",
3
+ "version": "0.0.79",
4
4
  "type": "module"
5
5
  }
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
- "packageVersion": "0.0.78",
4
- "url": "https://downloads.r5d.dev/r5d-macos-vm/0.0.78/R5DMacOSVM.app.zip",
5
- "sha256": "0d97085d8539cb69b7b0b3b11b1cb581bc0938156885f8ad016a378f14cc0658",
6
- "byteLength": 191301,
3
+ "packageVersion": "0.0.79",
4
+ "url": "https://downloads.r5d.dev/r5d-macos-vm/0.0.79/R5DMacOSVM.app.zip",
5
+ "sha256": "6699e9bb75369140663f68000babccd4e5e269dbf23763fb5d55d32670283595",
6
+ "byteLength": 191302,
7
7
  "archiveName": "R5DMacOSVM.app.zip",
8
8
  "appName": "R5DMacOSVM.app",
9
9
  "executableName": "R5DMacOSVM",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ricsam/r5d-macos-vm",
3
- "version": "0.0.78",
3
+ "version": "0.0.79",
4
4
  "type": "module",
5
5
  "main": "./dist/cjs/cli.cjs",
6
6
  "module": "./dist/mjs/cli.mjs",