@dst-justin/relay 2.2.3 → 2.2.5

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 (3) hide show
  1. package/README.md +8 -1
  2. package/package.json +1 -1
  3. package/relay +37 -2
package/README.md CHANGED
@@ -223,7 +223,14 @@ Sessions live in `~/.claude/projects/` and are shared across all accounts — af
223
223
 
224
224
  ## Changelog
225
225
 
226
- ### v2.2.2 — 2026-06-28
226
+ ### v2.2.5 — 2026-07-04
227
+ - `relay list -f` / `relay list --follow`: live-refresh mode — clears the screen and redraws the account table every 30 seconds, Ctrl+C to exit
228
+
229
+ ### v2.2.4 — 2026-07-04
230
+ - Fix: `relay switch` from another terminal no longer gets clobbered by a concurrent `relay list` / `!relay` menu run. Root cause: `try_refresh()` in the parallel usage-fetch used a stale snapshot of the current account, causing it to write the old account's refreshed token back to keychain and undo the switch. Now reads `CURRENT_FILE` freshly at write time.
231
+ - Active sessions pick up an account switch on the next message without restarting
232
+
233
+ ### v2.2.3 — 2026-06-28
227
234
  - Fix OAuth token refresh: use correct endpoint (`/v1/oauth/token`), required `client_id`, and `anthropic-version: oauth-2025-04-20` header — `relay refresh-all` now works
228
235
 
229
236
  ### v2.2.0 — 2026-06-28
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dst-justin/relay",
3
- "version": "2.2.3",
3
+ "version": "2.2.5",
4
4
  "description": "Multi-account switcher for Claude Code — instant credential swap across macOS, Linux, and Windows",
5
5
  "bin": {
6
6
  "relay": "./relay.js"
package/relay CHANGED
@@ -203,7 +203,12 @@ def try_refresh(name, cred_path):
203
203
  content = json.dumps(d)
204
204
  with open(cred_path, 'w') as f: f.write(content)
205
205
  os.chmod(cred_path, 0o600)
206
- if name == current:
206
+ # Re-read CURRENT_FILE freshly — do_switch() may have fired during the
207
+ # parallel fetch, making the captured `current` arg stale. Writing
208
+ # keychain with a stale current would clobber a concurrent account switch.
209
+ current_file = os.path.join(relay_dir, 'current')
210
+ live_current = open(current_file).read().strip() if os.path.exists(current_file) else ''
211
+ if name == live_current:
207
212
  update_live_creds(content)
208
213
  return oauth['accessToken']
209
214
  except Exception:
@@ -362,7 +367,7 @@ do_switch() {
362
367
 
363
368
  local email; email=$(get_meta_email "${name}")
364
369
  printf "\n ${GR}${B}✓ switched → %s${R} ${D}%s${R}\n" "${name}" "${email}"
365
- printf " ${D}Restart claude to apply. Resume last session: ${CY}claude -c${R}\n\n"
370
+ printf " ${D}Active sessions pick up the switch on next message. New session: ${CY}claude -c${R}\n\n"
366
371
 
367
372
  # ponytail: sentinel lets autoswitch daemon skip this account until threshold hit
368
373
  printf '{"account":"%s","ts":%s}' "${name}" "$(date +%s)" > "${RELAY_DIR}/manual_switch"
@@ -389,6 +394,35 @@ cmd_quick() {
389
394
  }
390
395
 
391
396
  cmd_list() {
397
+ # -f / --follow: live-refresh mode
398
+ local follow=0
399
+ local passthrough=()
400
+ for arg in "$@"; do
401
+ if [[ "${arg}" == "-f" || "${arg}" == "--follow" ]]; then
402
+ follow=1
403
+ else
404
+ passthrough+=("${arg}")
405
+ fi
406
+ done
407
+
408
+ if [[ "${follow}" -eq 1 ]]; then
409
+ local interval=30
410
+ trap 'tput cnorm 2>/dev/null; printf "\n \033[2mExited relay list -f\033[0m\n\n"; exit 0' INT TERM
411
+ tput civis 2>/dev/null || true
412
+ while true; do
413
+ printf '\033[2J\033[H'
414
+ hdr "Account List"
415
+ printf " ${D}live · refreshes every ${interval}s · Ctrl+C to exit${R}\n\n"
416
+ _sync_current_creds
417
+ render_table full "${CREDS_STORE}" "${META_STORE}" "$(current_name)" "${passthrough[@]+"${passthrough[@]}"}"
418
+ echo ""
419
+ ok "Inside Claude Code: ${CY}!relay <index>${R} to switch"
420
+ printf "\n ${D}updated $(date '+%H:%M:%S')${R}\n"
421
+ sleep "${interval}"
422
+ done
423
+ return
424
+ fi
425
+
392
426
  _check_update_bg
393
427
  hdr "Account List"
394
428
  _sync_current_creds
@@ -1569,6 +1603,7 @@ cmd_help() {
1569
1603
  printf " %-32s %s\n" " relay save <name>" "save current login state"
1570
1604
  printf " %-32s %s\n" " relay rename <old> <new>" "rename an account"
1571
1605
  printf " %-32s %s\n" " relay list" "full list with weekly usage"
1606
+ printf " %-32s %s\n" " relay list -f" "live-refresh list (Ctrl+C to exit)"
1572
1607
  printf " %-32s %s\n" " relay list --no-usage" "list without querying API"
1573
1608
  printf " %-32s %s\n" " relay remove <name>" "delete an account"
1574
1609
  printf " %-32s %s\n" " relay sessions" "show all sessions"